Skip to content

Commit 4288deb

Browse files
Badhri Jagan Sridharangregkh
authored andcommitted
usb: typec: tcpci: Fix up sink disconnect thresholds for PD
"Table 4-3 VBUS Sink Characteristics" of "Type-C Cable and Connector Specification" defines the disconnect voltage thresholds of various configurations. This change fixes the disconnect threshold voltage calculation based on vSinkPD_min and vSinkDisconnectPD as defined by the table. Fixes: e1a97bf ("usb: typec: tcpci: Implement Auto discharge disconnect callbacks") Cc: stable <[email protected]> Acked-by: Heikki Krogerus <[email protected]> Signed-off-by: Badhri Jagan Sridharan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 73f3d94 commit 4288deb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/usb/typec/tcpm/tcpci.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121
#define PD_RETRY_COUNT_DEFAULT 3
2222
#define PD_RETRY_COUNT_3_0_OR_HIGHER 2
2323
#define AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV 3500
24-
#define AUTO_DISCHARGE_PD_HEADROOM_MV 850
25-
#define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250
24+
#define VSINKPD_MIN_IR_DROP_MV 750
25+
#define VSRC_NEW_MIN_PERCENT 95
26+
#define VSRC_VALID_MIN_MV 500
27+
#define VPPS_NEW_MIN_PERCENT 95
28+
#define VPPS_VALID_MIN_MV 100
29+
#define VSINKDISCONNECT_PD_MIN_PERCENT 90
2630

2731
#define tcpc_presenting_rd(reg, cc) \
2832
(!(TCPC_ROLE_CTRL_DRP & (reg)) && \
@@ -351,11 +355,13 @@ static int tcpci_set_auto_vbus_discharge_threshold(struct tcpc_dev *dev, enum ty
351355
threshold = AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV;
352356
} else if (mode == TYPEC_PWR_MODE_PD) {
353357
if (pps_active)
354-
threshold = (95 * requested_vbus_voltage_mv / 100) -
355-
AUTO_DISCHARGE_PD_HEADROOM_MV;
358+
threshold = ((VPPS_NEW_MIN_PERCENT * requested_vbus_voltage_mv / 100) -
359+
VSINKPD_MIN_IR_DROP_MV - VPPS_VALID_MIN_MV) *
360+
VSINKDISCONNECT_PD_MIN_PERCENT / 100;
356361
else
357-
threshold = (95 * requested_vbus_voltage_mv / 100) -
358-
AUTO_DISCHARGE_PPS_HEADROOM_MV;
362+
threshold = ((VSRC_NEW_MIN_PERCENT * requested_vbus_voltage_mv / 100) -
363+
VSINKPD_MIN_IR_DROP_MV - VSRC_VALID_MIN_MV) *
364+
VSINKDISCONNECT_PD_MIN_PERCENT / 100;
359365
} else {
360366
/* 3.5V for non-pd sink */
361367
threshold = AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV;

0 commit comments

Comments
 (0)