Commit cabb6c5f authored by Amit Sunil Dhamne's avatar Amit Sunil Dhamne Committed by Greg Kroah-Hartman
Browse files

usb: typec: maxim_contaminant: disable low power mode when reading comparator values



Low power mode is enabled when reading CC resistance as part of
`max_contaminant_read_resistance_kohm()` and left in that state.
However, it's supposed to work with 1uA current source. To read CC
comparator values current source is changed to 80uA. This causes a storm
of CC interrupts as it (falsely) detects a potential contaminant. To
prevent this, disable low power mode current sourcing before reading
comparator values.

Fixes: 02b332a0 ("usb: typec: maxim_contaminant: Implement check_contaminant callback")
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarAmit Sunil Dhamne <amitsd@google.com>
Reviewed-by: default avatarBadhri Jagan Sridharan <badhri@google.com>
Rule: add
Link: https://lore.kernel.org/stable/20250814-fix-upstream-contaminant-v1-1-801ce8089031%40google.com
Link: https://lore.kernel.org/r/20250815-fix-upstream-contaminant-v2-1-6c8d6c3adafb@google.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 45eae113
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -188,6 +188,11 @@ static int max_contaminant_read_comparators(struct max_tcpci_chip *chip, u8 *ven
	if (ret < 0)
		return ret;

	/* Disable low power mode */
	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL,
				 FIELD_PREP(CCLPMODESEL,
					    LOW_POWER_MODE_DISABLE));

	/* Sleep to allow comparators settle */
	usleep_range(5000, 6000);
	ret = regmap_update_bits(regmap, TCPC_TCPC_CTRL, TCPC_TCPC_CTRL_ORIENTATION, PLUG_ORNT_CC1);
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#define CCOVPDIS                                BIT(6)
#define SBURPCTRL                               BIT(5)
#define CCLPMODESEL                             GENMASK(4, 3)
#define LOW_POWER_MODE_DISABLE                  0
#define ULTRA_LOW_POWER_MODE                    1
#define CCRPCTRL                                GENMASK(2, 0)
#define UA_1_SRC                                1