Skip to content
Permalink
Browse files
usb: typec: tcpm: add interface for passing supported_pd_rev from tcp…
…c_dev

Current TCPM allways assume using PD_MAX_REV for negotiation,
but for some USB controller only support PD 2.0, adding an interface
for passing supported_pd_rev from tcpc_dev.

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
  • Loading branch information
potinlai authored and intel-lab-lkp committed Feb 8, 2022
1 parent e9cdf07 commit 322696594704fa918e63d1c80fa6d346a02e9a28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
@@ -571,6 +571,16 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port)
port->cc2 == TYPEC_CC_OPEN)));
}

static u32 tcpm_pd_supported_rev(struct tcpm_port *port)
{
u32 rev = PD_MAX_REV;

if (port->tcpc->supported_pd_rev)
rev = port->tcpc->supported_pd_rev(port->tcpc);

return min(rev, PD_MAX_REV);
}

/*
* Logging
*/
@@ -3932,7 +3942,7 @@ static void run_state_machine(struct tcpm_port *port)
typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->caps_count = 0;
port->negotiated_rev = PD_MAX_REV;
port->negotiated_rev = tcpm_pd_supported_rev(port);
port->message_id = 0;
port->rx_msgid = -1;
port->explicit_contract = false;
@@ -4167,7 +4177,7 @@ static void run_state_machine(struct tcpm_port *port)
port->cc2 : port->cc1);
typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->negotiated_rev = PD_MAX_REV;
port->negotiated_rev = tcpm_pd_supported_rev(port);
port->message_id = 0;
port->rx_msgid = -1;
port->explicit_contract = false;
@@ -114,6 +114,9 @@ enum tcpm_transmit_type {
* Optional; The USB Communications Capable bit indicates if port
* partner is capable of communication over the USB data lines
* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
* @supported_pd_rev:
* Optional; TCPM call this function to get supported PD revesion
* from lower level driver.
*/
struct tcpc_dev {
struct fwnode_handle *fwnode;
@@ -148,6 +151,7 @@ struct tcpc_dev {
bool pps_active, u32 requested_vbus_voltage);
bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
u32 (*supported_pd_rev)(struct tcpc_dev *dev);
};

struct tcpm_port;

0 comments on commit 3226965

Please sign in to comment.