Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: uniphier-pcie: Fix updating phy parameters

The current driver uses a value from register TEST_O as the original
value for register TEST_I, though, the value is overwritten by "param",
so there is a bug that the original value isn't no longer used.

The value of TEST_O[7:0] should be masked with "mask", replaced with
"param", and placed in the bitfield TESTI_DAT_MASK as new TEST_I value.

Fixes: c6d9b1324159 ("phy: socionext: add PCIe PHY driver support")
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Link: https://lore.kernel.org/r/1623037842-19363-1-git-send-email-hayashi.kunihiko@socionext.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Kunihiko Hayashi and committed by
Vinod Koul
4a90bbb4 bd1f775d

+7 -4
+7 -4
drivers/phy/socionext/phy-uniphier-pcie.c
··· 24 24 #define PORT_SEL_1 FIELD_PREP(PORT_SEL_MASK, 1) 25 25 26 26 #define PCL_PHY_TEST_I 0x2000 27 - #define PCL_PHY_TEST_O 0x2004 28 27 #define TESTI_DAT_MASK GENMASK(13, 6) 29 28 #define TESTI_ADR_MASK GENMASK(5, 1) 30 29 #define TESTI_WR_EN BIT(0) 30 + 31 + #define PCL_PHY_TEST_O 0x2004 32 + #define TESTO_DAT_MASK GENMASK(7, 0) 31 33 32 34 #define PCL_PHY_RESET 0x200c 33 35 #define PCL_PHY_RESET_N_MNMODE BIT(8) /* =1:manual */ ··· 79 77 val = FIELD_PREP(TESTI_DAT_MASK, 1); 80 78 val |= FIELD_PREP(TESTI_ADR_MASK, reg); 81 79 uniphier_pciephy_testio_write(priv, val); 82 - val = readl(priv->base + PCL_PHY_TEST_O); 80 + val = readl(priv->base + PCL_PHY_TEST_O) & TESTO_DAT_MASK; 83 81 84 82 /* update value */ 85 - val &= ~FIELD_PREP(TESTI_DAT_MASK, mask); 86 - val = FIELD_PREP(TESTI_DAT_MASK, mask & param); 83 + val &= ~mask; 84 + val |= mask & param; 85 + val = FIELD_PREP(TESTI_DAT_MASK, val); 87 86 val |= FIELD_PREP(TESTI_ADR_MASK, reg); 88 87 uniphier_pciephy_testio_write(priv, val); 89 88 uniphier_pciephy_testio_write(priv, val | TESTI_WR_EN);