Lines Matching +full:lpc1850 +full:- +full:usb +full:- +full:otg +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
3 * PHY driver for NXP LPC18xx/43xx internal USB OTG PHY
13 #include <linux/phy/phy.h>
17 /* USB OTG PHY register offset and bit in CREG */
22 struct phy *phy; member
27 static int lpc18xx_usb_otg_phy_init(struct phy *phy) in lpc18xx_usb_otg_phy_init() argument
29 struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy); in lpc18xx_usb_otg_phy_init()
32 /* The PHY must be clocked at 480 MHz */ in lpc18xx_usb_otg_phy_init()
33 ret = clk_set_rate(lpc->clk, 480000000); in lpc18xx_usb_otg_phy_init()
37 return clk_prepare(lpc->clk); in lpc18xx_usb_otg_phy_init()
40 static int lpc18xx_usb_otg_phy_exit(struct phy *phy) in lpc18xx_usb_otg_phy_exit() argument
42 struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy); in lpc18xx_usb_otg_phy_exit()
44 clk_unprepare(lpc->clk); in lpc18xx_usb_otg_phy_exit()
49 static int lpc18xx_usb_otg_phy_power_on(struct phy *phy) in lpc18xx_usb_otg_phy_power_on() argument
51 struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy); in lpc18xx_usb_otg_phy_power_on()
54 ret = clk_enable(lpc->clk); in lpc18xx_usb_otg_phy_power_on()
58 /* The bit in CREG is cleared to enable the PHY */ in lpc18xx_usb_otg_phy_power_on()
59 ret = regmap_update_bits(lpc->reg, LPC18XX_CREG_CREG0, in lpc18xx_usb_otg_phy_power_on()
62 clk_disable(lpc->clk); in lpc18xx_usb_otg_phy_power_on()
69 static int lpc18xx_usb_otg_phy_power_off(struct phy *phy) in lpc18xx_usb_otg_phy_power_off() argument
71 struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy); in lpc18xx_usb_otg_phy_power_off()
74 ret = regmap_update_bits(lpc->reg, LPC18XX_CREG_CREG0, in lpc18xx_usb_otg_phy_power_off()
80 clk_disable(lpc->clk); in lpc18xx_usb_otg_phy_power_off()
98 lpc = devm_kzalloc(&pdev->dev, sizeof(*lpc), GFP_KERNEL); in lpc18xx_usb_otg_phy_probe()
100 return -ENOMEM; in lpc18xx_usb_otg_phy_probe()
102 lpc->reg = syscon_node_to_regmap(pdev->dev.of_node->parent); in lpc18xx_usb_otg_phy_probe()
103 if (IS_ERR(lpc->reg)) { in lpc18xx_usb_otg_phy_probe()
104 dev_err(&pdev->dev, "failed to get syscon\n"); in lpc18xx_usb_otg_phy_probe()
105 return PTR_ERR(lpc->reg); in lpc18xx_usb_otg_phy_probe()
108 lpc->clk = devm_clk_get(&pdev->dev, NULL); in lpc18xx_usb_otg_phy_probe()
109 if (IS_ERR(lpc->clk)) { in lpc18xx_usb_otg_phy_probe()
110 dev_err(&pdev->dev, "failed to get clock\n"); in lpc18xx_usb_otg_phy_probe()
111 return PTR_ERR(lpc->clk); in lpc18xx_usb_otg_phy_probe()
114 lpc->phy = devm_phy_create(&pdev->dev, NULL, &lpc18xx_usb_otg_phy_ops); in lpc18xx_usb_otg_phy_probe()
115 if (IS_ERR(lpc->phy)) { in lpc18xx_usb_otg_phy_probe()
116 dev_err(&pdev->dev, "failed to create PHY\n"); in lpc18xx_usb_otg_phy_probe()
117 return PTR_ERR(lpc->phy); in lpc18xx_usb_otg_phy_probe()
120 phy_set_drvdata(lpc->phy, lpc); in lpc18xx_usb_otg_phy_probe()
122 phy_provider = devm_of_phy_provider_register(&pdev->dev, in lpc18xx_usb_otg_phy_probe()
129 { .compatible = "nxp,lpc1850-usb-otg-phy" },
137 .name = "lpc18xx-usb-otg-phy",
144 MODULE_DESCRIPTION("NXP LPC18xx/43xx USB OTG PHY driver");