Lines Matching +full:jz4770 +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
3 * Ingenic SoCs USB PHY driver
15 #include <linux/phy/phy.h>
87 void (*usb_phy_init)(struct phy *phy);
93 struct phy *phy; member
99 static int ingenic_usb_phy_init(struct phy *phy) in ingenic_usb_phy_init() argument
101 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_init()
105 err = clk_prepare_enable(priv->clk); in ingenic_usb_phy_init()
107 dev_err(&phy->dev, "Unable to start clock: %d\n", err); in ingenic_usb_phy_init()
111 priv->soc_info->usb_phy_init(phy); in ingenic_usb_phy_init()
113 /* Wait for PHY to reset */ in ingenic_usb_phy_init()
115 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_init()
116 writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_init()
122 static int ingenic_usb_phy_exit(struct phy *phy) in ingenic_usb_phy_exit() argument
124 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_exit()
126 clk_disable_unprepare(priv->clk); in ingenic_usb_phy_exit()
127 regulator_disable(priv->vcc_supply); in ingenic_usb_phy_exit()
132 static int ingenic_usb_phy_power_on(struct phy *phy) in ingenic_usb_phy_power_on() argument
134 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_power_on()
137 err = regulator_enable(priv->vcc_supply); in ingenic_usb_phy_power_on()
139 dev_err(&phy->dev, "Unable to enable VCC: %d\n", err); in ingenic_usb_phy_power_on()
146 static int ingenic_usb_phy_power_off(struct phy *phy) in ingenic_usb_phy_power_off() argument
148 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_power_off()
150 regulator_disable(priv->vcc_supply); in ingenic_usb_phy_power_off()
155 static int ingenic_usb_phy_set_mode(struct phy *phy, in ingenic_usb_phy_set_mode() argument
158 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_set_mode()
163 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
168 writel(reg, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
172 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
177 writel(reg, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
181 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
186 writel(reg, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
190 return -EINVAL; in ingenic_usb_phy_set_mode()
205 static void jz4770_usb_phy_init(struct phy *phy) in jz4770_usb_phy_init() argument
207 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in jz4770_usb_phy_init()
218 writel(reg, priv->base + REG_USBPCR_OFFSET); in jz4770_usb_phy_init()
221 static void jz4775_usb_phy_init(struct phy *phy) in jz4775_usb_phy_init() argument
223 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in jz4775_usb_phy_init()
226 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_USB_SEL | in jz4775_usb_phy_init()
228 writel(reg, priv->base + REG_USBPCR1_OFFSET); in jz4775_usb_phy_init()
232 writel(reg, priv->base + REG_USBPCR_OFFSET); in jz4775_usb_phy_init()
235 static void jz4780_usb_phy_init(struct phy *phy) in jz4780_usb_phy_init() argument
237 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in jz4780_usb_phy_init()
240 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_USB_SEL | in jz4780_usb_phy_init()
242 writel(reg, priv->base + REG_USBPCR1_OFFSET); in jz4780_usb_phy_init()
245 writel(reg, priv->base + REG_USBPCR_OFFSET); in jz4780_usb_phy_init()
248 static void x1000_usb_phy_init(struct phy *phy) in x1000_usb_phy_init() argument
250 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in x1000_usb_phy_init()
253 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_WORD_IF_16BIT; in x1000_usb_phy_init()
254 writel(reg, priv->base + REG_USBPCR1_OFFSET); in x1000_usb_phy_init()
260 writel(reg, priv->base + REG_USBPCR_OFFSET); in x1000_usb_phy_init()
263 static void x1830_usb_phy_init(struct phy *phy) in x1830_usb_phy_init() argument
265 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in x1830_usb_phy_init()
269 writel(USBRDT_VBFIL_EN | USBRDT_UTMI_RST, priv->base + REG_USBRDT_OFFSET); in x1830_usb_phy_init()
271 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_WORD_IF_16BIT | in x1830_usb_phy_init()
273 writel(reg, priv->base + REG_USBPCR1_OFFSET); in x1830_usb_phy_init()
277 writel(reg, priv->base + REG_USBPCR_OFFSET); in x1830_usb_phy_init()
280 static void x2000_usb_phy_init(struct phy *phy) in x2000_usb_phy_init() argument
282 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in x2000_usb_phy_init()
285 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_DPPD | USBPCR1_DMPD; in x2000_usb_phy_init()
286 writel(reg & ~USBPCR1_PORT_RST, priv->base + REG_USBPCR1_OFFSET); in x2000_usb_phy_init()
289 writel(reg, priv->base + REG_USBPCR_OFFSET); in x2000_usb_phy_init()
320 struct device *dev = &pdev->dev; in ingenic_usb_phy_probe()
325 return -ENOMEM; in ingenic_usb_phy_probe()
327 priv->soc_info = device_get_match_data(dev); in ingenic_usb_phy_probe()
328 if (!priv->soc_info) { in ingenic_usb_phy_probe()
330 return -ENODEV; in ingenic_usb_phy_probe()
333 priv->base = devm_platform_ioremap_resource(pdev, 0); in ingenic_usb_phy_probe()
334 if (IS_ERR(priv->base)) { in ingenic_usb_phy_probe()
336 return PTR_ERR(priv->base); in ingenic_usb_phy_probe()
339 priv->clk = devm_clk_get(dev, NULL); in ingenic_usb_phy_probe()
340 if (IS_ERR(priv->clk)) { in ingenic_usb_phy_probe()
341 err = PTR_ERR(priv->clk); in ingenic_usb_phy_probe()
342 if (err != -EPROBE_DEFER) in ingenic_usb_phy_probe()
347 priv->vcc_supply = devm_regulator_get(dev, "vcc"); in ingenic_usb_phy_probe()
348 if (IS_ERR(priv->vcc_supply)) { in ingenic_usb_phy_probe()
349 err = PTR_ERR(priv->vcc_supply); in ingenic_usb_phy_probe()
350 if (err != -EPROBE_DEFER) in ingenic_usb_phy_probe()
355 priv->phy = devm_phy_create(dev, NULL, &ingenic_usb_phy_ops); in ingenic_usb_phy_probe()
356 if (IS_ERR(priv->phy)) in ingenic_usb_phy_probe()
357 return PTR_ERR(priv->phy); in ingenic_usb_phy_probe()
359 phy_set_drvdata(priv->phy, priv); in ingenic_usb_phy_probe()
367 { .compatible = "ingenic,jz4770-phy", .data = &jz4770_soc_info },
368 { .compatible = "ingenic,jz4775-phy", .data = &jz4775_soc_info },
369 { .compatible = "ingenic,jz4780-phy", .data = &jz4780_soc_info },
370 { .compatible = "ingenic,x1000-phy", .data = &x1000_soc_info },
371 { .compatible = "ingenic,x1830-phy", .data = &x1830_soc_info },
372 { .compatible = "ingenic,x2000-phy", .data = &x2000_soc_info },
380 .name = "ingenic-usb-phy",
389 MODULE_DESCRIPTION("Ingenic SoCs USB PHY driver");