From 745529254c5f72c5f371dc873d0cb282ad5fefa1 Mon Sep 17 00:00:00 2001 From: Jianing Ren Date: Tue, 28 Apr 2020 09:18:42 +0800 Subject: [PATCH] phy: phy-rockchip-naneng-usb2: fix bug of io read Phy internal registers is read by APB bus. If you get phy registers and APB data at the same time, you will get wrong data which is the previous value of register. Therefore, pready_cnt must be set bigger than rden_cnt. Change-Id: I2e7e5544077170466bdaabc2f7d61f67a06b3283 Signed-off-by: Jianing Ren --- .../phy/rockchip/phy-rockchip-naneng-usb2.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-naneng-usb2.c b/drivers/phy/rockchip/phy-rockchip-naneng-usb2.c index 4ec3a1352589..eecda6bba62f 100644 --- a/drivers/phy/rockchip/phy-rockchip-naneng-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-naneng-usb2.c @@ -1375,10 +1375,24 @@ static int rv1126_usb2phy_tuning(struct rockchip_usb2phy *rphy) { int ret = 0; - /* set iddig interrupt filter time to 10ms */ - ret = regmap_write(rphy->grf, 0x1031c, 0x000f4240); - if (ret) - goto out; + if (rphy->phy_cfg->reg == 0xff4c0000) { + /* set iddig interrupt filter time to 10ms */ + ret = regmap_write(rphy->grf, 0x1031c, 0x000f4240); + if (ret) + goto out; + + /* set pready_cnt to 1 and rden_cnt to 0 */ + ret = regmap_write(rphy->grf, 0x1027c, 0x0f0f0100); + if (ret) + goto out; + } + + if (rphy->phy_cfg->reg == 0xff4c8000) { + /* set pready_cnt to 1 and rden_cnt to 0 */ + ret = regmap_write(rphy->grf, 0x1028c, 0x0f0f0100); + if (ret) + goto out; + } out: return ret;