usb: typec: tcpm: Do not disconnect while receiving VBUS off
Subsystems (4)
Badhri Jagan Sridharan
maintainerPATCH 1/2 usb: typec: tcpm: Do not disconnect while receiving VBUS off
With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V before tcpm gets to read port->tcpc->get_vbus. This will will report a VBUS off event causing TCPM to transition to SNK_UNATTACHED where it should be waiting in either SNK_ATTACH_WAIT or SNK_DEBOUNCED state. This patch makes TCPM avoid vbus off events while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state.
Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."
[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start toggling
--- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +2 -1
@@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)case SNK_TRYWAIT_DEBOUNCE :break ;case SNK_ATTACH_WAIT : -tcpm_set_state (port,SNK_UNATTACHED ,0 ); +case SNK_DEBOUNCED : +/* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */ break ;case SNK_NEGOTIATE_CAPABILITIES :
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
Badhri Jagan Sridharan
maintainerPATCH 2/2 usb: typec: tcpm: Do not disconnect when receiving VSAFE0V
With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V causing VSAFE0V to be triggered. This will
will report a VBUS off event causing TCPM to transition to SNK_UNATTACHED state where it should be waiting in either SNK_ATTACH_WAIT or SNK_DEBOUNCED state. This patch makes TCPM avoid VSAFE0V events while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state.
Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."
[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start toggling
--- drivers/usb/typec/tcpm/tcpm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +4 -0
@@ -5264,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port)case PR_SWAP_SNK_SRC_SOURCE_ON :/* Do nothing, vsafe0v is expected during transition */ break ; +case SNK_ATTACH_WAIT : +case SNK_DEBOUNCED : +/*Do nothing, still waiting for VSAFE5V for connect */ +break ;default :if (port->pwr_role ==TYPEC_SINK && port->auto_vbus_discharge_enabled)tcpm_set_state (port,SNK_UNATTACHED ,0 );
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
Re: [PATCH v1 2/2] usb: typec: tcpm: Do not disconnect when receiving VSAFE0V
Quoted 22 lines · Badhri Jagan Sridharan
With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V causing VSAFE0V to be triggered. This will
will report a VBUS off event causing TCPM to transition toSNK_UNATTACHEDstate where it should be waiting in eitherSNK_ATTACH_WAITorSNK_DEBOUNCEDstate. This patch makes TCPM avoid VSAFE0V events while inSNK_ATTACH_WAITorSNK_DEBOUNCEDstate.Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start toggling
Quoted 3 lines
Fixes 28b43d3d746b8 ("usb: typec: tcpm: Introduce vsafe0v for vbus")Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 21 lines
--- drivers/usb/typec/tcpm/tcpm.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/usb/typec/tcpm/tcpm.c +4
-0@@ -5264,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port)case PR_SWAP_SNK_SRC_SOURCE_ON :/* Do nothing, vsafe0v is expected during transition */ break ; +case SNK_ATTACH_WAIT : +case SNK_DEBOUNCED : +/*Do nothing, still waiting for VSAFE5V for connect */ +break ;default :if (port->pwr_role ==TYPEC_SINK && port->auto_vbus_discharge_enabled)tcpm_set_state (port,SNK_UNATTACHED ,0 );Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
Signature · 1 line
heikki
Re: [PATCH v1 2/2] usb: typec: tcpm: Do not disconnect when receiving VSAFE0V
In reply to Badhri Jagan SridharanQuoted 3 lines · Badhri Jagan Sridharan
With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V causing VSAFE0V to be triggered. This will
will report a VBUS off event causing TCPM to transition to
s/will will/will/
Quoted 31 lines
SNK_UNATTACHEDstate where it should be waiting in eitherSNK_ATTACH_WAITorSNK_DEBOUNCEDstate. This patch makes TCPM avoid VSAFE0V events while inSNK_ATTACH_WAITorSNK_DEBOUNCEDstate.Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start togglingFixes 28b43d3d746b8 ("usb: typec: tcpm: Introduce vsafe0v for vbus")Signed-off-by Badhri Jagan Sridharan <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/usb/typec/tcpm/tcpm.c +0
-0
drivers/usb/typec/tcpm/tcpm.c static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) · line 5269
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +3
-0@@ -5264,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port)case PR_SWAP_SNK_SRC_SOURCE_ON :/* Do nothing, vsafe0v is expected during transition */ break ; +case SNK_ATTACH_WAIT : +case SNK_DEBOUNCED : +/*Do nothing, still waiting for VSAFE5V for connect */
Space before Do
s/for connect/to connect/, maybe ?
Other than that,
Quoted 4 lines
drivers/usb/typec/tcpm/tcpm.c +1
-0+break ;default :if (port->pwr_role ==TYPEC_SINK && port->auto_vbus_discharge_enabled)tcpm_set_state (port,SNK_UNATTACHED ,0 );
Quoted 22 lines · Badhri Jagan Sridharan
With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V before tcpm gets to read
port->tcpc->get_vbus. This will will report a VBUS off event causing TCPM to transition toSNK_UNATTACHEDwhere it should be waiting in eitherSNK_ATTACH_WAITorSNK_DEBOUNCEDstate. This patch makes TCPM avoid vbus off events while inSNK_ATTACH_WAITorSNK_DEBOUNCEDstate.Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start toggling
Quoted 3 lines
Fixes f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)")Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 20 lines
--- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/typec/tcpm/tcpm.c +2
-1@@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)case SNK_TRYWAIT_DEBOUNCE :break ;case SNK_ATTACH_WAIT : -tcpm_set_state (port,SNK_UNATTACHED ,0 ); +case SNK_DEBOUNCED : +/* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */ break ;case SNK_NEGOTIATE_CAPABILITIES :Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
Signature · 1 line
heikki
Quoted 3 lines · Badhri Jagan Sridharan
With some chargers, vbus might momentarily raise above VSAFE5V and fall back to 0V before tcpm gets to read
port->tcpc->get_vbus. This will will report a VBUS off event causing TCPM to transition to
s/will will/will/
Quoted 31 lines
SNK_UNATTACHEDwhere it should be waiting in eitherSNK_ATTACH_WAITorSNK_DEBOUNCEDstate. This patch makes TCPM avoid vbus off events while inSNK_ATTACH_WAITorSNK_DEBOUNCEDstate.Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. A DRP shall transition to Unattached.SRC when the state of both the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [23.300579] VBUS off [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] [23.301014] VBUS VSAFE0V [23.301111] Start togglingFixes f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)")Signed-off-by Badhri Jagan Sridharan <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/typec/tcpm/tcpm.c +0
-0
drivers/usb/typec/tcpm/tcpm.c static void _tcpm_pd_vbus_off(struct tcpm_port *port) · line 5160
Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +2
-1@@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)case SNK_TRYWAIT_DEBOUNCE :break ;case SNK_ATTACH_WAIT : -tcpm_set_state (port,SNK_UNATTACHED ,0 ); +case SNK_DEBOUNCED : +/* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */
s/reaach/reach/
Other than that,
Quoted 3 lines
drivers/usb/typec/tcpm/tcpm.c +0
-0break ;case SNK_NEGOTIATE_CAPABILITIES :