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 <jianwei.zheng@rock-chips.com>
Change-Id: Ia16365d79015b81fa8aff2fd7a1c61256b38aa3d
This commit is contained in:
Jianwei Zheng
2023-09-11 19:59:25 +08:00
committed by Tao Huang
parent 1e49b6a722
commit 22d153d2eb
@@ -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 },
},