Lines Matching +full:t +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()
100 dev_warn(&phy->dev, "Unsupported rate: %d MHz\n", mhz); in keembay_emmc_phy_power()
109 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, PWR_DOWN_MASK, in keembay_emmc_phy_power()
112 dev_err(&phy->dev, "CALIO power down bar failed: %d\n", ret); in keembay_emmc_phy_power()
123 ret = regmap_read_poll_timeout(priv->syscfg, PHY_STAT, in keembay_emmc_phy_power()
127 dev_err(&phy->dev, "caldone failed, ret=%d\n", ret); in keembay_emmc_phy_power()
132 ret = regmap_update_bits(priv->syscfg, PHY_CFG_2, SEL_FREQ_MASK, in keembay_emmc_phy_power()
135 dev_err(&phy->dev, "set the frequency of dll failed:%d\n", ret); in keembay_emmc_phy_power()
140 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, DLL_EN_MASK, in keembay_emmc_phy_power()
143 dev_err(&phy->dev, "turn on the dll failed: %d\n", ret); in keembay_emmc_phy_power()
149 * clock might be turned on later. ...but we can't wait for the DLL in keembay_emmc_phy_power()
154 * is turned on, but for now we won't. in keembay_emmc_phy_power()
162 * with clock speed. If we are powering on the PHY and the card clock in keembay_emmc_phy_power()
165 * hopefully we won't be running at 100 kHz, but we should still make in keembay_emmc_phy_power()
169 * extra long to lock for reasons that aren't understood. In some in keembay_emmc_phy_power()
173 ret = regmap_read_poll_timeout(priv->syscfg, PHY_STAT, in keembay_emmc_phy_power()
177 dev_err(&phy->dev, "dllrdy failed, ret=%d\n", ret); in keembay_emmc_phy_power()
182 static int keembay_emmc_phy_init(struct phy *phy) in keembay_emmc_phy_init() argument
184 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_init()
189 * - PHY driver to probe in keembay_emmc_phy_init()
190 * - SDHCI driver to start probe in keembay_emmc_phy_init()
191 * - SDHCI driver to register it's clock in keembay_emmc_phy_init()
192 * - SDHCI driver to get the PHY in keembay_emmc_phy_init()
193 * - SDHCI driver to init the PHY in keembay_emmc_phy_init()
198 priv->emmcclk = clk_get_optional(&phy->dev, "emmcclk"); in keembay_emmc_phy_init()
200 return PTR_ERR_OR_ZERO(priv->emmcclk); in keembay_emmc_phy_init()
203 static int keembay_emmc_phy_exit(struct phy *phy) in keembay_emmc_phy_exit() argument
205 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_exit()
207 clk_put(priv->emmcclk); in keembay_emmc_phy_exit()
212 static int keembay_emmc_phy_power_on(struct phy *phy) in keembay_emmc_phy_power_on() argument
214 struct keembay_emmc_phy *priv = phy_get_drvdata(phy); in keembay_emmc_phy_power_on()
218 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, SEL_DLY_TXCLK_MASK, in keembay_emmc_phy_power_on()
221 dev_err(&phy->dev, "ERROR: delay chain txclk set: %d\n", ret); in keembay_emmc_phy_power_on()
226 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, OTAP_DLY_ENA_MASK, in keembay_emmc_phy_power_on()
229 dev_err(&phy->dev, "ERROR: output tap delay set: %d\n", ret); in keembay_emmc_phy_power_on()
234 ret = regmap_update_bits(priv->syscfg, PHY_CFG_0, OTAP_DLY_SEL_MASK, in keembay_emmc_phy_power_on()
237 dev_err(&phy->dev, "ERROR: output tap delay select: %d\n", ret); in keembay_emmc_phy_power_on()
241 /* Power up eMMC phy analog blocks */ in keembay_emmc_phy_power_on()
242 return keembay_emmc_phy_power(phy, true); in keembay_emmc_phy_power_on()
245 static int keembay_emmc_phy_power_off(struct phy *phy) in keembay_emmc_phy_power_off() argument
247 /* Power down eMMC phy analog blocks */ in keembay_emmc_phy_power_off()
248 return keembay_emmc_phy_power(phy, false); in keembay_emmc_phy_power_off()
261 struct device *dev = &pdev->dev; in keembay_emmc_phy_probe()
262 struct device_node *np = dev->of_node; in keembay_emmc_phy_probe()
264 struct phy *generic_phy; in keembay_emmc_phy_probe()
270 return -ENOMEM; in keembay_emmc_phy_probe()
276 priv->syscfg = devm_regmap_init_mmio(dev, base, &keembay_regmap_config); in keembay_emmc_phy_probe()
277 if (IS_ERR(priv->syscfg)) in keembay_emmc_phy_probe()
278 return PTR_ERR(priv->syscfg); in keembay_emmc_phy_probe()
283 "failed to create PHY\n"); in keembay_emmc_phy_probe()
292 { .compatible = "intel,keembay-emmc-phy" },
300 .name = "keembay-emmc-phy",
307 MODULE_DESCRIPTION("Intel Keem Bay eMMC PHY driver");