Commit 867b0263 authored by Ye Li's avatar Ye Li

MLK-18289-1 tcpc: Update driver to support two ports logic

On iMX8MM EVK, there are two USB ports. Both can support USB PD, but
with USB2 has HW priority.

So we Change tcpc_pd_sink_check_charging to public function and
use it to know whether the USB tcpc is power charging.

Additional, add disable_pd to init config. So we can disable PD session
for uncharged or lower priority port.
Signed-off-by: 's avatarYe Li <ye.li@nxp.com>
parent a5dd1efd
......@@ -14,8 +14,6 @@
#define tcpc_debug_log(port, fmt, args...)
#endif
static bool tcpc_pd_sink_check_charging(struct tcpc_port *port);
static int tcpc_log(struct tcpc_port *port, const char *fmt, ...)
{
va_list args;
......@@ -758,7 +756,7 @@ static void tcpc_pd_sink_process(struct tcpc_port *port)
}
}
static bool tcpc_pd_sink_check_charging(struct tcpc_port *port)
bool tcpc_pd_sink_check_charging(struct tcpc_port *port)
{
uint8_t valb;
int err;
......@@ -939,10 +937,11 @@ int tcpc_init(struct tcpc_port *port, struct tcpc_port_config config, ss_mux_sel
return -EIO;
}
tcpc_log(port, "TCPC: Vendor ID [0x%x], Product ID [0x%x]\n", vid, pid);
tcpc_log(port, "TCPC: Vendor ID [0x%x], Product ID [0x%x], Addr [I2C%u 0x%x]\n",
vid, pid, port->cfg.i2c_bus, port->cfg.addr);
if (port->cfg.port_type == TYPEC_PORT_UFP
|| port->cfg.port_type == TYPEC_PORT_DRP)
if (!port->cfg.disable_pd && (port->cfg.port_type == TYPEC_PORT_UFP
|| port->cfg.port_type == TYPEC_PORT_DRP))
tcpc_pd_sink_init(port);
tcpc_clear_alert(port, 0xffff);
......
......@@ -417,6 +417,7 @@ struct tcpc_port_config {
uint32_t max_snk_ma;
uint32_t max_snk_mw;
uint32_t op_snk_mv;
bool disable_pd;
};
struct tcpc_port {
......@@ -443,6 +444,7 @@ int tcpc_setup_dfp_mode(struct tcpc_port *port);
int tcpc_setup_ufp_mode(struct tcpc_port *port);
int tcpc_disable_src_vbus(struct tcpc_port *port);
int tcpc_init(struct tcpc_port *port, struct tcpc_port_config config, ss_mux_sel ss_sel_func);
bool tcpc_pd_sink_check_charging(struct tcpc_port *port);
void tcpc_print_log(struct tcpc_port *port);
#endif /* __TCPCI_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment