Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: tcpm: Report back negotiated PPS voltage and current

Currently when requesting a specific voltage or current through
the psy interface, for PPS, when reading back from that interface
the values will always be the same as previously given, if the
request was successful. However PPS only allows for 20mV voltage
steps and 50mA current steps, and the psy class expects microvolt
and micro amp requests, so inbetween values can be provided through
this interface. Really when reading back the true values negotiated
should be given, and not the ones originally asked for.

To report the actual values negotiated with the Source, the values
stored are now rounded down to the relevant step units prior to
building the PPS request, so that those values are later correctly
reported through the psy interface. In addition this improves the
adjustments made to meet the operating power requirements of the
platform, which previously could have been slightly out due to not
using valid PPS units of voltage and current.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Adam Thomson and committed by
Greg Kroah-Hartman
554fab6d c36e96bd

+6
+6
drivers/usb/typec/tcpm/tcpm.c
··· 4113 4113 goto port_unlock; 4114 4114 } 4115 4115 4116 + /* Round down operating current to align with PPS valid steps */ 4117 + op_curr = op_curr - (op_curr % RDO_PROG_CURR_MA_STEP); 4118 + 4116 4119 reinit_completion(&port->pps_complete); 4117 4120 port->pps_data.op_curr = op_curr; 4118 4121 port->pps_status = 0; ··· 4168 4165 ret = -EINVAL; 4169 4166 goto port_unlock; 4170 4167 } 4168 + 4169 + /* Round down output voltage to align with PPS valid steps */ 4170 + out_volt = out_volt - (out_volt % RDO_PROG_VOLT_MV_STEP); 4171 4171 4172 4172 reinit_completion(&port->pps_complete); 4173 4173 port->pps_data.out_volt = out_volt;