usb: typec: tcpm: Correct the PPS out_volt calculation
Subsystems (3)
PATCH 1/1 usb: typec: tcpm: Correct the PPS out_volt calculation
When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (out_volt). If the previous out_volt is lower than the new min_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possible min_volt 7V.
Fix this by choosing the maximal value between the previous voltage and the new min_volt first. And ensure that this value will not exceed the new max_volt. The new out_volt will fall within the new voltage range while being the closest value compared to the previous out_volt.
--- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +2 -1
@@ -2297,7 +2297,8 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) pdo_pps_apdo_max_voltage(snk)); port->pps_data.max_curr =min_pps_apdo_current (src, snk); port->pps_data.out_volt =min (port->pps_data.max_volt, - port->pps_data.out_volt); +max (port->pps_data.min_volt, + port->pps_data.out_volt)); port->pps_data.op_curr =min (port->pps_data.max_curr, port->pps_data.op_curr); }
Quoted 7 lines · Kyle Tso
When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (
out_volt). If the previousout_voltis lower than the newmin_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possiblemin_volt7V.
Quoted 6 lines
Fix this by choosing the maximal value between the previous voltage and the new
min_voltfirst. And ensure that this value will not exceed the newmax_volt. The newout_voltwill fall within the new voltage range while being the closest value compared to the previousout_volt.Signed-off-by Kyle Tso <[email protected]>
I'd be interested to see how many Sources go off-piste like that with a more unusual PPS range, especially when the default fixed is 5V, and they're required to support one of the defined PPS ranges which will start at 3.3V. Not sure what this might gain you. However, spec says it's possible so:
Quoted 21 lines
--- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/typec/tcpm/tcpm.c +2
-1@@ -2297,7 +2297,8 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) pdo_pps_apdo_max_voltage(snk)); port->pps_data.max_curr =min_pps_apdo_current (src, snk); port->pps_data.out_volt =min (port->pps_data.max_volt, - port->pps_data.out_volt); +max (port->pps_data.min_volt, + port->pps_data.out_volt)); port->pps_data.op_curr =min (port->pps_data.max_curr, port->pps_data.op_curr);}
--
2.20.1.495.gaa96b0ce6b-goog
Quoted 8 lines · Kyle Tso
When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (
out_volt). If the previousout_voltis lower than the newmin_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possiblemin_volt7V.
Quoted 6 lines
Fix this by choosing the maximal value between the previous voltage and the new
min_voltfirst. And ensure that this value will not exceed the newmax_volt. The newout_voltwill fall within the new voltage range while being the closest value compared to the previousout_volt.Signed-off-by Kyle Tso <[email protected]>
Quoted 21 lines
--- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/typec/tcpm/tcpm.c +2
-1@@ -2297,7 +2297,8 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) pdo_pps_apdo_max_voltage(snk)); port->pps_data.max_curr =min_pps_apdo_current (src, snk); port->pps_data.out_volt =min (port->pps_data.max_volt, - port->pps_data.out_volt); +max (port->pps_data.min_volt, + port->pps_data.out_volt)); port->pps_data.op_curr =min (port->pps_data.max_curr, port->pps_data.op_curr); }Signature · 1 line
2.20.1.495.gaa96b0ce6b-goog
Quoted 8 lines · Kyle Tso
When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (
out_volt). If the previousout_voltis lower than the newmin_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possiblemin_volt7V.
Quoted 6 lines
Fix this by choosing the maximal value between the previous voltage and the new
min_voltfirst. And ensure that this value will not exceed the newmax_volt. The newout_voltwill fall within the new voltage range while being the closest value compared to the previousout_volt.Signed-off-by Kyle Tso <[email protected]>
Right? In any case:
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@@ -2297,7 +2297,8 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) pdo_pps_apdo_max_voltage(snk)); port->pps_data.max_curr =min_pps_apdo_current (src, snk); port->pps_data.out_volt =min (port->pps_data.max_volt, - port->pps_data.out_volt); +max (port->pps_data.min_volt, + port->pps_data.out_volt)); port->pps_data.op_curr =min (port->pps_data.max_curr, port->pps_data.op_curr); }Signature · 1 line
2.20.1.495.gaa96b0ce6b-goog
thanks,
Greg KH
maintainerQuoted 14 lines · Heikki Krogerus
Quoted 13 lines · Kyle Tso
When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (
out_volt). If the previousout_voltis lower than the newmin_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possiblemin_volt7V.Fix this by choosing the maximal value between the previous voltage and the new
min_voltfirst. And ensure that this value will not exceed the newmax_volt. The newout_voltwill fall within the new voltage range while being the closest value compared to the previousout_volt.
Quoted 4 lines
Quoted 1 line
Signed-off-by Kyle Tso <[email protected]>Fixes c710d0bb76ff0 ("usb: typec: tcpm: Extend the matching rules on PPS APDO selection")Cc stable...
No need for stable, as c710d0bb76ff ("usb: typec: tcpm: Extend the matching rules on PPS APDO selection") only showed up in 5.0-rc1.
Note, no need for the extra digit on your sha1 listing, here's the recommended way to show this:
git show -s --abbrev-commit --abbrev=12 --pretty=format:"%h (\"%s\")%n"
thanks,
greg k-h
Heikki Krogerus
maintainerQuoted 20 lines · Greg KH
Quoted 14 lines · Heikki Krogerus
Quoted 13 lines · Kyle Tso
When Sink negotiates PPS, the voltage range of selected PPS APDO might not cover the previous voltage (
out_volt). If the previousout_voltis lower than the newmin_volt, the output voltage in RDO might be set to an invalid value. For instance, supposed that the previous voltage is 5V, and the new voltage range in the APDO is 7V-12V. Then the output voltage in the RDO should not be set to 5V which is lower than the possiblemin_volt7V.Fix this by choosing the maximal value between the previous voltage and the new
min_voltfirst. And ensure that this value will not exceed the newmax_volt. The newout_voltwill fall within the new voltage range while being the closest value compared to the previousout_volt.Quoted 4 lines
Quoted 1 line
Signed-off-by Kyle Tso <[email protected]>Fixes c710d0bb76ff0 ("usb: typec: tcpm: Extend the matching rules on PPS APDO selection")Cc stable...
Quoted 6 lines
No need for stable, as
c710d0bb76ff("usb: typec: tcpm: Extend the matching rules on PPS APDO selection") only showed up in 5.0-rc1.Note, no need for the extra digit on your sha1 listing, here's the recommended way to show this:
git show -s --abbrev-commit --abbrev=12 --pretty=format:"%h (\"%s\")%n"
OK. Thanks for the hint!
Cheers,