
From: Maksim Kiselev bigunclemax@gmail.com
PU\PD resistors on CC lines must be configured before running the TCPM state machine.
Also, when the Type-C port acts as a host (SRC), the VBUS sould be enabled only after the toggling has been completed. And we have to wait for the corresponding IRQ to finish the toggling process. But this doesn't happen because we exit from tcpm_poll_event() if VBUS != OK.
So, Let's check for VBUS state only when the port acts as a host (SRC) to solve this problem.
Signed-off-by: Maksim Kiselev bigunclemax@gmail.com --- drivers/usb/tcpm/tcpm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c index 0aee57cb2f4..c9f8dbdc795 100644 --- a/drivers/usb/tcpm/tcpm.c +++ b/drivers/usb/tcpm/tcpm.c @@ -2122,6 +2122,12 @@ static void tcpm_init(struct udevice *dev) else port->vbus_vsafe0v = true;
+ if (port->self_powered) + tcpm_set_cc(dev, TYPEC_CC_OPEN); + else + tcpm_set_cc(dev, tcpm_default_state(port) == SNK_UNATTACHED ? + TYPEC_CC_RD : tcpm_rp_cc(port)); + tcpm_set_state(dev, tcpm_default_state(port), 0);
if (drvops->get_cc(dev, &cc1, &cc2) == 0) @@ -2234,7 +2240,7 @@ static void tcpm_poll_event(struct udevice *dev) const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); struct tcpm_port *port = dev_get_uclass_plat(dev);
- if (!drvops->get_vbus(dev)) + if (!drvops->get_vbus(dev) && (tcpm_default_state(port) == SNK_UNATTACHED)) return;
while (port->poll_event_cnt < TCPM_POLL_EVENT_TIME_OUT) {