From bc2fd405a72546c21d801d576e59e095d017cc50 Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 1 Feb 2021 20:14:19 +0800 Subject: [PATCH] phy: rockchip: inno-usb2: set bvalid and id filter time for rk356x This patch sets the bvalid and id filter time to 10ms for rk356x USB 2.0 PHY0 which is used for OTG. The filter count is base on the USB 2.0 PHY GRF pclk 100MHz. With this patch, it can avoid trigger the bvalid rising edge irq when unplug the OTG cable. Change-Id: I95794510921e6c065f4ec1102ab6c1f35994bf42 Signed-off-by: William Wu --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 8a6118739a08..c91ab5d35aa2 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -43,6 +43,7 @@ #define SCHEDULE_DELAY (60 * HZ) #define OTG_SCHEDULE_DELAY (1 * HZ) #define BYPASS_SCHEDULE_DELAY (2 * HZ) +#define FILTER_COUNTER 0xF4240 struct rockchip_usb2phy; @@ -2232,12 +2233,27 @@ static int rk3399_usb2phy_tuning(struct rockchip_usb2phy *rphy) static int rk3568_usb2phy_tuning(struct rockchip_usb2phy *rphy) { u32 reg; + int ret = 0; reg = readl(rphy->phy_base + 0x30); /* turn off differential reciver in suspend mode */ writel(reg & ~BIT(2), rphy->phy_base + 0x30); - return 0; + if (rphy->phy_cfg->reg == 0xfe8a0000) { + /* + * Set the bvalid filter time to 10ms + * based on the usb2 phy grf pclk 100MHz. + */ + ret |= regmap_write(rphy->grf, 0x0048, FILTER_COUNTER); + + /* + * Set the id filter time to 10ms based + * on the usb2 phy grf pclk 100MHz. + */ + ret |= regmap_write(rphy->grf, 0x004c, FILTER_COUNTER); + } + + return ret; } static int rk3568_vbus_detect_control(struct rockchip_usb2phy *rphy, bool en)