From 22d153d2ebadacc28d47cc37195b539843bc0bf3 Mon Sep 17 00:00:00 2001 From: Jianwei Zheng Date: Mon, 11 Sep 2023 19:59:25 +0800 Subject: [PATCH] phy: rockchip-inno-usb2: fix USB OTG not working in HOST mode for RK3328 On current code, We check the iddig status to make sure that the id status is indeed in low level, and then send HOST notification and power on phy based on this state. But On some Rockchip platforms like RK3328, the ID Detector pin is not cited, the default state of ID pin is floating, so the iddig status is always 1 which means in device mode. To resolve this problem, We need to further check whether usb2phy_reg structure of utmi_iddig has been initialized or not. If not, We can't use the iddig status as a judgment condition. Signed-off-by: Jianwei Zheng Change-Id: Ia16365d79015b81fa8aff2fd7a1c61256b38aa3d --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index fdf1ebaf3ec6..20cbf303969c 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1767,8 +1767,12 @@ static irqreturn_t rockchip_usb2phy_id_irq(int irq, void *data) if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st)) { property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr, true); - /* switch to host if id fall det and iddig status is low */ - if (!property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig)) + /* + * if id fall det, switch to host if ID Detector pin is floating + * or iddig status is low. + */ + if (!rport->port_cfg->utmi_iddig.enable || + !property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig)) cable_vbus_state = true; } else if (property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st)) { property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr, @@ -3428,7 +3432,6 @@ static const struct rockchip_usb2phy_cfg rk3328_phy_cfgs[] = { .ls_det_clr = { 0x0118, 0, 0, 0, 1 }, .utmi_avalid = { 0x0120, 10, 10, 0, 1 }, .utmi_bvalid = { 0x0120, 9, 9, 0, 1 }, - .utmi_iddig = { 0x0120, 6, 6, 0, 1 }, .utmi_ls = { 0x0120, 5, 4, 0, 1 }, .vbus_det_en = { 0x001c, 15, 15, 1, 0 }, },