Lines Matching +full:thunderbay +full:- +full:emmc +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel ThunderBay eMMC PHY driver
15 #include <linux/phy/phy.h>
18 /* eMMC/SD/SDIO core/phy configuration registers */
134 /* Phy power status */
140 * To avoid incorrectly setting the phy for init(400KHZ) "phy_power_sts" is used.
141 * When actual clock is set always phy is powered off once and then powered on.
144 * 0 --> init settings
145 * 1 --> actual settings
159 tmp = readl(tbh_phy->reg_base + offset); in update_reg()
162 writel(tmp, tbh_phy->reg_base + offset); in update_reg()
165 static int thunderbay_emmc_phy_power(struct phy *phy, bool power_on) in thunderbay_emmc_phy_power() argument
167 struct thunderbay_emmc_phy *tbh_phy = phy_get_drvdata(phy); in thunderbay_emmc_phy_power()
175 rate = clk_get_rate(tbh_phy->emmcclk); in thunderbay_emmc_phy_power()
192 rate = clk_get_rate(tbh_phy->emmcclk); in thunderbay_emmc_phy_power()
230 dev_warn(&phy->dev, "Unsupported rate: %lu\n", rate); in thunderbay_emmc_phy_power()
246 ret = readl_poll_timeout(tbh_phy->reg_base + PHY_STAT, in thunderbay_emmc_phy_power()
249 dev_err(&phy->dev, "caldone failed, ret=%d\n", ret); in thunderbay_emmc_phy_power()
253 rate = clk_get_rate(tbh_phy->emmcclk); in thunderbay_emmc_phy_power()
265 * with clock speed. If we are powering on the PHY and the card clock in thunderbay_emmc_phy_power()
276 ret = readl_poll_timeout(tbh_phy->reg_base + PHY_STAT, in thunderbay_emmc_phy_power()
279 dev_err(&phy->dev, "dllrdy failed, ret=%d\n", ret); in thunderbay_emmc_phy_power()
290 static int thunderbay_emmc_phy_init(struct phy *phy) in thunderbay_emmc_phy_init() argument
292 struct thunderbay_emmc_phy *tbh_phy = phy_get_drvdata(phy); in thunderbay_emmc_phy_init()
294 tbh_phy->emmcclk = clk_get(&phy->dev, "emmcclk"); in thunderbay_emmc_phy_init()
296 return PTR_ERR_OR_ZERO(tbh_phy->emmcclk); in thunderbay_emmc_phy_init()
299 static int thunderbay_emmc_phy_exit(struct phy *phy) in thunderbay_emmc_phy_exit() argument
301 struct thunderbay_emmc_phy *tbh_phy = phy_get_drvdata(phy); in thunderbay_emmc_phy_exit()
303 clk_put(tbh_phy->emmcclk); in thunderbay_emmc_phy_exit()
308 static int thunderbay_emmc_phy_power_on(struct phy *phy) in thunderbay_emmc_phy_power_on() argument
310 struct thunderbay_emmc_phy *tbh_phy = phy_get_drvdata(phy); in thunderbay_emmc_phy_power_on()
329 if (tbh_phy->phy_power_sts == PHY_UNINITIALIZED) { in thunderbay_emmc_phy_power_on()
340 } else if (tbh_phy->phy_power_sts == PHY_INITIALIZED) { in thunderbay_emmc_phy_power_on()
342 rate = clk_get_rate(tbh_phy->emmcclk); in thunderbay_emmc_phy_power_on()
424 tbh_phy->phy_power_sts = PHY_UNINITIALIZED; in thunderbay_emmc_phy_power_on()
430 return thunderbay_emmc_phy_power(phy, 1); in thunderbay_emmc_phy_power_on()
433 static int thunderbay_emmc_phy_power_off(struct phy *phy) in thunderbay_emmc_phy_power_off() argument
435 struct thunderbay_emmc_phy *tbh_phy = phy_get_drvdata(phy); in thunderbay_emmc_phy_power_off()
437 tbh_phy->phy_power_sts = PHY_INITIALIZED; in thunderbay_emmc_phy_power_off()
439 return thunderbay_emmc_phy_power(phy, 0); in thunderbay_emmc_phy_power_off()
451 { .compatible = "intel,thunderbay-emmc-phy",
461 struct device *dev = &pdev->dev; in thunderbay_emmc_phy_probe()
463 struct phy *generic_phy; in thunderbay_emmc_phy_probe()
466 if (!dev->of_node) in thunderbay_emmc_phy_probe()
467 return -ENODEV; in thunderbay_emmc_phy_probe()
471 return -ENOMEM; in thunderbay_emmc_phy_probe()
474 tbh_phy->reg_base = devm_ioremap_resource(&pdev->dev, res); in thunderbay_emmc_phy_probe()
475 if (IS_ERR(tbh_phy->reg_base)) in thunderbay_emmc_phy_probe()
476 return PTR_ERR(tbh_phy->reg_base); in thunderbay_emmc_phy_probe()
478 tbh_phy->phy_power_sts = PHY_UNINITIALIZED; in thunderbay_emmc_phy_probe()
479 id = of_match_node(thunderbay_emmc_phy_of_match, pdev->dev.of_node); in thunderbay_emmc_phy_probe()
482 return -EINVAL; in thunderbay_emmc_phy_probe()
485 generic_phy = devm_phy_create(dev, dev->of_node, id->data); in thunderbay_emmc_phy_probe()
487 dev_err(dev, "failed to create PHY\n"); in thunderbay_emmc_phy_probe()
500 .name = "thunderbay-emmc-phy",
508 MODULE_DESCRIPTION("Intel Thunder Bay eMMC PHY driver");