Skip to content

Commit 3624688

Browse files
Ondrej Jirmangregkh
authored andcommitted
usb: typec: fusb302: Fix masking of comparator and bc_lvl interrupts
The code that enables either BC_LVL or COMP_CHNG interrupt in tcpm_set_cc wrongly assumes that the interrupt is unmasked by writing 1 to the apropriate bit in the mask register. In fact, interrupts are enabled when the mask is 0, so the tcpm_set_cc enables interrupt for COMP_CHNG when it expects BC_LVL interrupt to be enabled. This causes inability of the driver to recognize cable unplug events in host mode (unplug is recognized only via a COMP_CHNG interrupt). In device mode this bug was masked by simultaneous triggering of the VBUS change interrupt, because of loss of VBUS when the port peer is providing power. Fixes: 48242e3 ("usb: typec: fusb302: Revert "Resolve fixed power role contract setup"") Cc: stable <[email protected]> Cc: Hans de Goede <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Acked-by: Heikki Krogerus <[email protected]> Signed-off-by: Ondrej Jirman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 47ce459 commit 3624688

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/usb/typec/tcpm/fusb302.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,25 +669,27 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc)
669669
ret = fusb302_i2c_mask_write(chip, FUSB_REG_MASK,
670670
FUSB_REG_MASK_BC_LVL |
671671
FUSB_REG_MASK_COMP_CHNG,
672-
FUSB_REG_MASK_COMP_CHNG);
672+
FUSB_REG_MASK_BC_LVL);
673673
if (ret < 0) {
674674
fusb302_log(chip, "cannot set SRC interrupt, ret=%d",
675675
ret);
676676
goto done;
677677
}
678678
chip->intr_comp_chng = true;
679+
chip->intr_bc_lvl = false;
679680
break;
680681
case TYPEC_CC_RD:
681682
ret = fusb302_i2c_mask_write(chip, FUSB_REG_MASK,
682683
FUSB_REG_MASK_BC_LVL |
683684
FUSB_REG_MASK_COMP_CHNG,
684-
FUSB_REG_MASK_BC_LVL);
685+
FUSB_REG_MASK_COMP_CHNG);
685686
if (ret < 0) {
686687
fusb302_log(chip, "cannot set SRC interrupt, ret=%d",
687688
ret);
688689
goto done;
689690
}
690691
chip->intr_bc_lvl = true;
692+
chip->intr_comp_chng = false;
691693
break;
692694
default:
693695
break;

0 commit comments

Comments
 (0)