phy: samsung: phy-exynos-pcie: sanitize init/power_on callbacks
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): CGME20220713072117eucas1p23fb25c2e8bba73200690d289f1b3e91a@eucas1p2.samsung.com
PATCH v2 1/2 phy: samsung: phy-exynos-pcie: sanitize init/power_on callbacks
The exynos-pcie driver called phy_power_on() and then 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 call the power_on() code directly from the init() callback and drop it from the phy ops. This way the driver will also work with the old (incorrect) PHY initialization call sequence.
---
v2:
- keep exynos5433_pcie_phy_power_on() function and call it directly from exynos5433_pcie_phy_init() as suggested by Vinod Koul
--- drivers/phy/samsung/phy-exynos-pcie.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/phy/samsung/phy-exynos-pcie.c +5 -1
@@ -47,10 +47,15 @@ static void exynos_pcie_phy_writel(void __iomem *base, u32 val, u32 offset) }/* Exynos5433 specific functions */ +static int exynos5433_pcie_phy_power_on (struct phy *phy); +static int exynos5433_pcie_phy_init (struct phy *phy) {struct exynos_pcie_phy *ep =phy_get_drvdata (phy); +/* Power must be enabled in PMU before any other register write */ +exynos5433_pcie_phy_power_on (phy); +regmap_update_bits (ep->fsysreg,PCIE_EXYNOS5433_PHY_COMMON_RESET ,PCIE_PHY_RESET ,1 ); regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_MAC_RESET,
@@ -135,7 +140,6 @@ static int exynos5433_pcie_phy_power_off(struct phy *phy)static const struct phy_ops exynos5433_phy_ops = { .init = exynos5433_pcie_phy_init, - .power_on = exynos5433_pcie_phy_power_on, .power_off = exynos5433_pcie_phy_power_off, .owner =THIS_MODULE , };
Signature · 1 line
2.17.1
PATCH v2 2/2 PCI: dwc: exynos: Correct generic PHY usage
The proper initialization for generic PHYs is to call first phy_init(), then phy_power_on().
While touching this, lets remove the phy_reset() call. It is just a left-over from the obsoleted Exynos5440 support and current exynos-pcie PHY driver doesn't even support this function. It is also rarely used by other drivers.
--- drivers/pci/controller/dwc/pci-exynos.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-exynos.c +1 -2
@@ -258,9 +258,8 @@ static int exynos_pcie_host_init(struct dw_pcie_rp *pp)exynos_pcie_assert_core_reset (ep); -phy_reset (ep->phy); -phy_power_on (ep->phy);phy_init (ep->phy); +phy_power_on (ep->phy);exynos_pcie_deassert_core_reset (ep);exynos_pcie_enable_irq_pulse (ep);
Signature · 1 line
2.17.1