Skip to content

Commit f281222

Browse files
mszyprowbjorn-helgaas
authored andcommitted
phy: samsung: phy-exynos-pcie: sanitize init/power_on callbacks
The exynos-pcie driver called phy_power_on() before phy_init() for some historical reasons. However the generic PHY framework assumes that the proper sequence is to call phy_init() first, then phy_power_on(). The operations done by both functions should be considered as one action and as such they are called by the exynos-pcie driver (without doing anything between them). The initialization is just a sequence of register writes, which cannot be altered without breaking the hardware operation. To match the generic PHY framework requirement, simply move all register writes to the phy_init()/phy_exit() and drop power_on()/power_off() callbacks. This way the driver will also work with the old (incorrect) PHY initialization call sequence. Link: https://lore.kernel.org/r/20220628220409.26545-1-m.szyprowski@samsung.com Reported-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Chanho Park <chanho61.park@samsung.com> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Acked-By: Vinod Koul <vkoul@kernel.org>
1 parent 91a773f commit f281222

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

drivers/phy/samsung/phy-exynos-pcie.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ static int exynos5433_pcie_phy_init(struct phy *phy)
5151
{
5252
struct exynos_pcie_phy *ep = phy_get_drvdata(phy);
5353

54+
regmap_update_bits(ep->pmureg, EXYNOS5433_PMU_PCIE_PHY_OFFSET,
55+
BIT(0), 1);
56+
regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_GLOBAL_RESET,
57+
PCIE_APP_REQ_EXIT_L1_MODE, 0);
58+
regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_L1SUB_CM_CON,
59+
PCIE_REFCLK_GATING_EN, 0);
60+
5461
regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_COMMON_RESET,
5562
PCIE_PHY_RESET, 1);
5663
regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_MAC_RESET,
@@ -109,20 +116,7 @@ static int exynos5433_pcie_phy_init(struct phy *phy)
109116
return 0;
110117
}
111118

112-
static int exynos5433_pcie_phy_power_on(struct phy *phy)
113-
{
114-
struct exynos_pcie_phy *ep = phy_get_drvdata(phy);
115-
116-
regmap_update_bits(ep->pmureg, EXYNOS5433_PMU_PCIE_PHY_OFFSET,
117-
BIT(0), 1);
118-
regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_GLOBAL_RESET,
119-
PCIE_APP_REQ_EXIT_L1_MODE, 0);
120-
regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_L1SUB_CM_CON,
121-
PCIE_REFCLK_GATING_EN, 0);
122-
return 0;
123-
}
124-
125-
static int exynos5433_pcie_phy_power_off(struct phy *phy)
119+
static int exynos5433_pcie_phy_exit(struct phy *phy)
126120
{
127121
struct exynos_pcie_phy *ep = phy_get_drvdata(phy);
128122

@@ -135,8 +129,7 @@ static int exynos5433_pcie_phy_power_off(struct phy *phy)
135129

136130
static const struct phy_ops exynos5433_phy_ops = {
137131
.init = exynos5433_pcie_phy_init,
138-
.power_on = exynos5433_pcie_phy_power_on,
139-
.power_off = exynos5433_pcie_phy_power_off,
132+
.exit = exynos5433_pcie_phy_exit,
140133
.owner = THIS_MODULE,
141134
};
142135

0 commit comments

Comments
 (0)