Lines Matching +full:d +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel Keem Bay eMMC PHY driver
14 #include <linux/phy/phy.h>
18 /* eMMC/SD/SDIO core/phy configuration registers */
53 static int keembay_emmc_phy_power(struct phy *phy, bool on_off) in keembay_emmc_phy_power() argument
55 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_power()
66 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, PWR_DOWN_MASK, in keembay_emmc_phy_power()
69 dev_err(&phy->dev, "CALIO power down bar failed: %d\n", ret); in keembay_emmc_phy_power()
73 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, DLL_EN_MASK, in keembay_emmc_phy_power()
76 dev_err(&phy->dev, "turn off the dll failed: %d\n", ret); in keembay_emmc_phy_power()
84 mhz = DIV_ROUND_CLOSEST(clk_get_rate(priv->emmcclk), 1000000); in keembay_emmc_phy_power()
99 dev_warn(&phy->dev, "Unsupported rate: %d MHz\n", mhz); in keembay_emmc_phy_power()
108 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, PWR_DOWN_MASK, in keembay_emmc_phy_power()
111 dev_err(&phy->dev, "CALIO power down bar failed: %d\n", ret); in keembay_emmc_phy_power()
122 ret = regmap_read_poll_timeout(priv->syscfg, PHY_STAT, in keembay_emmc_phy_power()
126 dev_err(&phy->dev, "caldone failed, ret=%d\n", ret); in keembay_emmc_phy_power()
131 ret = regmap_update_bits(priv->syscfg, PHY_CFG_2, SEL_FREQ_MASK, in keembay_emmc_phy_power()
134 dev_err(&phy->dev, "set the frequency of dll failed:%d\n", ret); in keembay_emmc_phy_power()
139 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, DLL_EN_MASK, in keembay_emmc_phy_power()
142 dev_err(&phy->dev, "turn on the dll failed: %d\n", ret); in keembay_emmc_phy_power()
161 * with clock speed. If we are powering on the PHY and the card clock in keembay_emmc_phy_power()
172 ret = regmap_read_poll_timeout(priv->syscfg, PHY_STAT, in keembay_emmc_phy_power()
176 dev_err(&phy->dev, "dllrdy failed, ret=%d\n", ret); in keembay_emmc_phy_power()
181 static int keembay_emmc_phy_init(struct phy *phy) in keembay_emmc_phy_init() argument
183 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_init()
188 * - PHY driver to probe in keembay_emmc_phy_init()
189 * - SDHCI driver to start probe in keembay_emmc_phy_init()
190 * - SDHCI driver to register it's clock in keembay_emmc_phy_init()
191 * - SDHCI driver to get the PHY in keembay_emmc_phy_init()
192 * - SDHCI driver to init the PHY in keembay_emmc_phy_init()
197 priv->emmcclk = clk_get_optional(&phy->dev, "emmcclk"); in keembay_emmc_phy_init()
199 return PTR_ERR_OR_ZERO(priv->emmcclk); in keembay_emmc_phy_init()
202 static int keembay_emmc_phy_exit(struct phy *phy) in keembay_emmc_phy_exit() argument
204 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_exit()
206 clk_put(priv->emmcclk); in keembay_emmc_phy_exit()
211 static int keembay_emmc_phy_power_on(struct phy *phy) in keembay_emmc_phy_power_on() argument
213 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_power_on()
217 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, SEL_DLY_TXCLK_MASK, in keembay_emmc_phy_power_on()
220 dev_err(&phy->dev, "ERROR: delay chain txclk set: %d\n", ret); in keembay_emmc_phy_power_on()
225 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, OTAP_DLY_ENA_MASK, in keembay_emmc_phy_power_on()
228 dev_err(&phy->dev, "ERROR: output tap delay set: %d\n", ret); in keembay_emmc_phy_power_on()
233 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, OTAP_DLY_SEL_MASK, in keembay_emmc_phy_power_on()
236 dev_err(&phy->dev, "ERROR: output tap delay select: %d\n", ret); in keembay_emmc_phy_power_on()
240 /* Power up eMMC phy analog blocks */ in keembay_emmc_phy_power_on()
241 return keembay_emmc_phy_power(phy, true); in keembay_emmc_phy_power_on()
244 static int keembay_emmc_phy_power_off(struct phy *phy) in keembay_emmc_phy_power_off() argument
246 /* Power down eMMC phy analog blocks */ in keembay_emmc_phy_power_off()
247 return keembay_emmc_phy_power(phy, false); in keembay_emmc_phy_power_off()
260 struct device *dev = &pdev->dev; in keembay_emmc_phy_probe()
261 struct device_node *np = dev->of_node; in keembay_emmc_phy_probe()
263 struct phy *generic_phy; in keembay_emmc_phy_probe()
269 return -ENOMEM; in keembay_emmc_phy_probe()
275 priv->syscfg = devm_regmap_init_mmio(dev, base, &keembay_regmap_config); in keembay_emmc_phy_probe()
276 if (IS_ERR(priv->syscfg)) in keembay_emmc_phy_probe()
277 return PTR_ERR(priv->syscfg); in keembay_emmc_phy_probe()
282 "failed to create PHY\n"); in keembay_emmc_phy_probe()
291 { .compatible = "intel,keembay-emmc-phy" },
299 .name = "keembay-emmc-phy",
306 MODULE_DESCRIPTION("Intel Keem Bay eMMC PHY driver");