mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
ANDROID: usb: typec: tcpci: Combine the parameters of set_auto_vbus_discharge_threshold
The change Ifdb1ba19f7147da286ea5e044e84dfb679050a94 ("FROMGIT: usb:
typec: tcpci: Prevent Sink disconnection before vPpsShutdown in SPR
PPS") breaks the KMI. Prevent the breakage by combining the parameters
"requested_vbus_voltage" and "pps_apdo_min_voltage" to a single u32
variable whose value is selected according to the values of parameter
"mode" and parameter "pps_active".
Bug: 388029777
Change-Id: I85872b9490561d248169bc8e008f3d907cc6c3c0
Signed-off-by: Kyle Tso <kyletso@google.com>
This commit is contained in:
committed by
Treehugger Robot
parent
f84d5a5fad
commit
52a41f0bf1
@@ -341,8 +341,7 @@ static int tcpci_enable_auto_vbus_discharge(struct tcpc_dev *dev, bool enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int tcpci_set_auto_vbus_discharge_threshold(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
|
static int tcpci_set_auto_vbus_discharge_threshold(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
|
||||||
bool pps_active, u32 requested_vbus_voltage_mv,
|
bool pps_active, u32 requested_vbus_voltage_mv)
|
||||||
u32 apdo_min_voltage_mv)
|
|
||||||
{
|
{
|
||||||
struct tcpci *tcpci = tcpc_to_tcpci(dev);
|
struct tcpci *tcpci = tcpc_to_tcpci(dev);
|
||||||
unsigned int pwr_ctrl, threshold = 0;
|
unsigned int pwr_ctrl, threshold = 0;
|
||||||
@@ -368,7 +367,7 @@ static int tcpci_set_auto_vbus_discharge_threshold(struct tcpc_dev *dev, enum ty
|
|||||||
* To prevent disconnect when the source is in Current Limit Mode.
|
* To prevent disconnect when the source is in Current Limit Mode.
|
||||||
* Set the threshold to the lowest possible voltage vPpsShutdown (min)
|
* Set the threshold to the lowest possible voltage vPpsShutdown (min)
|
||||||
*/
|
*/
|
||||||
threshold = VPPS_SHUTDOWN_MIN_PERCENT * apdo_min_voltage_mv / 100 -
|
threshold = VPPS_SHUTDOWN_MIN_PERCENT * requested_vbus_voltage_mv / 100 -
|
||||||
VSINKPD_MIN_IR_DROP_MV;
|
VSINKPD_MIN_IR_DROP_MV;
|
||||||
else
|
else
|
||||||
threshold = ((VSRC_NEW_MIN_PERCENT * requested_vbus_voltage_mv / 100) -
|
threshold = ((VSRC_NEW_MIN_PERCENT * requested_vbus_voltage_mv / 100) -
|
||||||
|
|||||||
@@ -2342,14 +2342,18 @@ static int tcpm_set_auto_vbus_discharge_threshold(struct tcpm_port *port,
|
|||||||
enum typec_pwr_opmode mode, bool pps_active,
|
enum typec_pwr_opmode mode, bool pps_active,
|
||||||
u32 requested_vbus_voltage)
|
u32 requested_vbus_voltage)
|
||||||
{
|
{
|
||||||
|
u32 voltage;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!port->tcpc->set_auto_vbus_discharge_threshold)
|
if (!port->tcpc->set_auto_vbus_discharge_threshold)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = port->tcpc->set_auto_vbus_discharge_threshold(port->tcpc, mode, pps_active,
|
if (mode == TYPEC_PWR_MODE_PD && pps_active)
|
||||||
requested_vbus_voltage,
|
voltage = port->pps_data.min_volt;
|
||||||
port->pps_data.min_volt);
|
else
|
||||||
|
voltage = requested_vbus_voltage;
|
||||||
|
|
||||||
|
ret = port->tcpc->set_auto_vbus_discharge_threshold(port->tcpc, mode, pps_active, voltage);
|
||||||
tcpm_log_force(port,
|
tcpm_log_force(port,
|
||||||
"set_auto_vbus_discharge_threshold mode:%d pps_active:%c vbus:%u pps_apdo_min_volt:%u ret:%d",
|
"set_auto_vbus_discharge_threshold mode:%d pps_active:%c vbus:%u pps_apdo_min_volt:%u ret:%d",
|
||||||
mode, pps_active ? 'y' : 'n', requested_vbus_voltage,
|
mode, pps_active ? 'y' : 'n', requested_vbus_voltage,
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ struct tcpc_dev {
|
|||||||
void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
|
void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
|
||||||
int (*enable_auto_vbus_discharge)(struct tcpc_dev *dev, bool enable);
|
int (*enable_auto_vbus_discharge)(struct tcpc_dev *dev, bool enable);
|
||||||
int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
|
int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
|
||||||
bool pps_active, u32 requested_vbus_voltage,
|
bool pps_active, u32 requested_vbus_voltage);
|
||||||
u32 pps_apdo_min_voltage);
|
|
||||||
bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
|
bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
|
||||||
void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
|
void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
|
||||||
void (*check_contaminant)(struct tcpc_dev *dev);
|
void (*check_contaminant)(struct tcpc_dev *dev);
|
||||||
|
|||||||
Reference in New Issue
Block a user