Lines Matching +full:lgm +full:- +full:emmc +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0
3 * Intel eMMC PHY driver
14 #include <linux/phy/phy.h>
18 /* eMMC phy register definitions */
51 static int intel_emmc_phy_power(struct phy *phy, bool on_off) in intel_emmc_phy_power() argument
53 struct intel_emmc_phy *priv = phy_get_drvdata(phy); in intel_emmc_phy_power()
64 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL1_REG, PDB_MASK, in intel_emmc_phy_power()
67 dev_err(&phy->dev, "CALIO power down bar failed: %d\n", ret); in intel_emmc_phy_power()
75 rate = clk_get_rate(priv->emmcclk); in intel_emmc_phy_power()
78 dev_warn(&phy->dev, "Unsupported rate: %lu\n", rate); in intel_emmc_phy_power()
88 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL1_REG, PDB_MASK, in intel_emmc_phy_power()
91 dev_err(&phy->dev, "CALIO power down bar failed: %d\n", ret); in intel_emmc_phy_power()
102 ret = regmap_read_poll_timeout(priv->syscfg, EMMC_PHYSTAT_REG, in intel_emmc_phy_power()
106 dev_err(&phy->dev, "caldone failed, ret=%d\n", ret); in intel_emmc_phy_power()
111 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL2_REG, FRQSEL_MASK, in intel_emmc_phy_power()
114 dev_err(&phy->dev, "set the frequency of dll failed:%d\n", ret); in intel_emmc_phy_power()
119 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL1_REG, ENDLL_MASK, in intel_emmc_phy_power()
122 dev_err(&phy->dev, "turn on the dll failed: %d\n", ret); in intel_emmc_phy_power()
129 * with clock speed. If we are powering on the PHY and the card clock in intel_emmc_phy_power()
140 ret = regmap_read_poll_timeout(priv->syscfg, in intel_emmc_phy_power()
145 dev_err(&phy->dev, "dllrdy failed. ret=%d\n", ret); in intel_emmc_phy_power()
152 static int intel_emmc_phy_init(struct phy *phy) in intel_emmc_phy_init() argument
154 struct intel_emmc_phy *priv = phy_get_drvdata(phy); in intel_emmc_phy_init()
159 * - PHY driver to probe in intel_emmc_phy_init()
160 * - SDHCI driver to start probe in intel_emmc_phy_init()
161 * - SDHCI driver to register it's clock in intel_emmc_phy_init()
162 * - SDHCI driver to get the PHY in intel_emmc_phy_init()
163 * - SDHCI driver to init the PHY in intel_emmc_phy_init()
169 priv->emmcclk = clk_get_optional(&phy->dev, "emmcclk"); in intel_emmc_phy_init()
170 if (IS_ERR(priv->emmcclk)) { in intel_emmc_phy_init()
171 dev_err(&phy->dev, "ERROR: getting emmcclk\n"); in intel_emmc_phy_init()
172 return PTR_ERR(priv->emmcclk); in intel_emmc_phy_init()
178 static int intel_emmc_phy_exit(struct phy *phy) in intel_emmc_phy_exit() argument
180 struct intel_emmc_phy *priv = phy_get_drvdata(phy); in intel_emmc_phy_exit()
182 clk_put(priv->emmcclk); in intel_emmc_phy_exit()
187 static int intel_emmc_phy_power_on(struct phy *phy) in intel_emmc_phy_power_on() argument
189 struct intel_emmc_phy *priv = phy_get_drvdata(phy); in intel_emmc_phy_power_on()
193 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL0_REG, DR_TY_MASK, in intel_emmc_phy_power_on()
196 dev_err(&phy->dev, "ERROR set drive-impednce-50ohm: %d\n", ret); in intel_emmc_phy_power_on()
201 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL0_REG, OTAPDLYENA, in intel_emmc_phy_power_on()
204 dev_err(&phy->dev, "ERROR Set output tap delay : %d\n", ret); in intel_emmc_phy_power_on()
209 ret = regmap_update_bits(priv->syscfg, EMMC_PHYCTRL0_REG, in intel_emmc_phy_power_on()
212 dev_err(&phy->dev, "ERROR: output tap dly select: %d\n", ret); in intel_emmc_phy_power_on()
216 /* Power up eMMC phy analog blocks */ in intel_emmc_phy_power_on()
217 return intel_emmc_phy_power(phy, true); in intel_emmc_phy_power_on()
220 static int intel_emmc_phy_power_off(struct phy *phy) in intel_emmc_phy_power_off() argument
222 /* Power down eMMC phy analog blocks */ in intel_emmc_phy_power_off()
223 return intel_emmc_phy_power(phy, false); in intel_emmc_phy_power_off()
236 struct device *dev = &pdev->dev; in intel_emmc_phy_probe()
237 struct device_node *np = dev->of_node; in intel_emmc_phy_probe()
239 struct phy *generic_phy; in intel_emmc_phy_probe()
244 return -ENOMEM; in intel_emmc_phy_probe()
246 /* Get eMMC phy (accessed via chiptop) regmap */ in intel_emmc_phy_probe()
247 priv->syscfg = syscon_regmap_lookup_by_phandle(np, "intel,syscon"); in intel_emmc_phy_probe()
248 if (IS_ERR(priv->syscfg)) { in intel_emmc_phy_probe()
250 return PTR_ERR(priv->syscfg); in intel_emmc_phy_probe()
255 dev_err(dev, "failed to create PHY\n"); in intel_emmc_phy_probe()
266 { .compatible = "intel,lgm-emmc-phy" },
275 .name = "intel-emmc-phy",
283 MODULE_DESCRIPTION("Intel eMMC PHY driver");