phy: rockchip: inno-usb2: fix miss host disc irq for rk3588

On RK3588 platform, the USB Host port may miss disconnect
falling edge irq which is used to detect usb device plug in.
This always happens in the following two cases:
1. For RK3588 ARM PC, boot system from U Disk which connected
   the USB2 Host port (EHCI & OHCI Controller);
2. For RK3588 EVB, increase the disconnect filer counter to
   0xF4240 in the reg USB2PHY_GRF_DIS_CON. That is, the
   disconnect rising/falling irq filter time is set to 10ms
   depend on the 100MHz pclk.

In this case, we can clear the host_disconnect state depend
on the linestate irq which also means that an usb device is
connecting to the port.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: Iadde3278c3383c0d477a0b9998871a5a1f5fe206
This commit is contained in:
William Wu
2022-05-11 11:24:14 +08:00
parent d4e5a644c5
commit 200edc7b87

View File

@@ -1607,7 +1607,8 @@ static irqreturn_t rockchip_usb2phy_linestate_irq(int irq, void *data)
struct rockchip_usb2phy_port *rport = data;
struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st))
if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st) ||
!property_enabled(rphy->grf, &rport->port_cfg->ls_det_en))
return IRQ_NONE;
dev_dbg(&rport->phy->dev, "linestate interrupt\n");
@@ -1617,6 +1618,14 @@ static irqreturn_t rockchip_usb2phy_linestate_irq(int irq, void *data)
/* disable linestate detect irq and clear its status */
rockchip_usb2phy_enable_line_irq(rphy, rport, false);
/*
* For host port, it may miss disc irq when device is connected,
* in this case, we can clear host_disconnect state depend on
* the linestate irq.
*/
if (rport->port_id == USB2PHY_PORT_HOST && rport->port_cfg->disfall_en.offset)
rport->host_disconnect = false;
mutex_unlock(&rport->mutex);
/*
@@ -1743,12 +1752,16 @@ static irqreturn_t rockchip_usb2phy_irq(int irq, void *data)
if (!rport->phy)
continue;
/*
* Handle disc irq before linestate irq to set the disc
* state for sm work scheduled in the linestate irq handler.
*/
if (rport->port_id == USB2PHY_PORT_HOST &&
rport->port_cfg->disfall_en.offset)
ret = rockchip_usb2phy_host_disc_irq(irq, rport);
ret |= rockchip_usb2phy_host_disc_irq(irq, rport);
/* Handle linestate irq for both otg port and host port */
ret = rockchip_usb2phy_linestate_irq(irq, rport);
ret |= rockchip_usb2phy_linestate_irq(irq, rport);
/*
* Handle bvalid irq and id irq for otg port which