Lines Matching +full:jz4770 +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0
3 * Ingenic SoCs USB PHY driver
14 #include <linux/phy/phy.h>
86 void (*usb_phy_init)(struct phy *phy);
92 struct phy *phy; member
98 static int ingenic_usb_phy_init(struct phy *phy) in ingenic_usb_phy_init() argument
100 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_init()
104 err = clk_prepare_enable(priv->clk); in ingenic_usb_phy_init()
106 dev_err(&phy->dev, "Unable to start clock: %d\n", err); in ingenic_usb_phy_init()
110 priv->soc_info->usb_phy_init(phy); in ingenic_usb_phy_init()
112 /* Wait for PHY to reset */ in ingenic_usb_phy_init()
114 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_init()
115 writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_init()
121 static int ingenic_usb_phy_exit(struct phy *phy) in ingenic_usb_phy_exit() argument
123 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_exit()
125 clk_disable_unprepare(priv->clk); in ingenic_usb_phy_exit()
126 regulator_disable(priv->vcc_supply); in ingenic_usb_phy_exit()
131 static int ingenic_usb_phy_power_on(struct phy *phy) in ingenic_usb_phy_power_on() argument
133 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_power_on()
136 err = regulator_enable(priv->vcc_supply); in ingenic_usb_phy_power_on()
138 dev_err(&phy->dev, "Unable to enable VCC: %d\n", err); in ingenic_usb_phy_power_on()
145 static int ingenic_usb_phy_power_off(struct phy *phy) in ingenic_usb_phy_power_off() argument
147 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_power_off()
149 regulator_disable(priv->vcc_supply); in ingenic_usb_phy_power_off()
154 static int ingenic_usb_phy_set_mode(struct phy *phy, in ingenic_usb_phy_set_mode() argument
157 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in ingenic_usb_phy_set_mode()
162 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
167 writel(reg, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
171 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
176 writel(reg, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
180 reg = readl(priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
185 writel(reg, priv->base + REG_USBPCR_OFFSET); in ingenic_usb_phy_set_mode()
189 return -EINVAL; in ingenic_usb_phy_set_mode()
204 static void jz4770_usb_phy_init(struct phy *phy) in jz4770_usb_phy_init() argument
206 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in jz4770_usb_phy_init()
217 writel(reg, priv->base + REG_USBPCR_OFFSET); in jz4770_usb_phy_init()
220 static void jz4775_usb_phy_init(struct phy *phy) in jz4775_usb_phy_init() argument
222 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in jz4775_usb_phy_init()
225 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_USB_SEL | in jz4775_usb_phy_init()
227 writel(reg, priv->base + REG_USBPCR1_OFFSET); in jz4775_usb_phy_init()
231 writel(reg, priv->base + REG_USBPCR_OFFSET); in jz4775_usb_phy_init()
234 static void jz4780_usb_phy_init(struct phy *phy) in jz4780_usb_phy_init() argument
236 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in jz4780_usb_phy_init()
239 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_USB_SEL | in jz4780_usb_phy_init()
241 writel(reg, priv->base + REG_USBPCR1_OFFSET); in jz4780_usb_phy_init()
244 writel(reg, priv->base + REG_USBPCR_OFFSET); in jz4780_usb_phy_init()
247 static void x1000_usb_phy_init(struct phy *phy) in x1000_usb_phy_init() argument
249 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in x1000_usb_phy_init()
252 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_WORD_IF_16BIT; in x1000_usb_phy_init()
253 writel(reg, priv->base + REG_USBPCR1_OFFSET); in x1000_usb_phy_init()
259 writel(reg, priv->base + REG_USBPCR_OFFSET); in x1000_usb_phy_init()
262 static void x1830_usb_phy_init(struct phy *phy) in x1830_usb_phy_init() argument
264 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in x1830_usb_phy_init()
268 writel(USBRDT_VBFIL_EN | USBRDT_UTMI_RST, priv->base + REG_USBRDT_OFFSET); in x1830_usb_phy_init()
270 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_WORD_IF_16BIT | in x1830_usb_phy_init()
272 writel(reg, priv->base + REG_USBPCR1_OFFSET); in x1830_usb_phy_init()
276 writel(reg, priv->base + REG_USBPCR_OFFSET); in x1830_usb_phy_init()
279 static void x2000_usb_phy_init(struct phy *phy) in x2000_usb_phy_init() argument
281 struct ingenic_usb_phy *priv = phy_get_drvdata(phy); in x2000_usb_phy_init()
284 reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_DPPD | USBPCR1_DMPD; in x2000_usb_phy_init()
285 writel(reg & ~USBPCR1_PORT_RST, priv->base + REG_USBPCR1_OFFSET); in x2000_usb_phy_init()
288 writel(reg, priv->base + REG_USBPCR_OFFSET); in x2000_usb_phy_init()
319 struct device *dev = &pdev->dev; in ingenic_usb_phy_probe()
324 return -ENOMEM; in ingenic_usb_phy_probe()
326 priv->soc_info = device_get_match_data(dev); in ingenic_usb_phy_probe()
327 if (!priv->soc_info) { in ingenic_usb_phy_probe()
329 return -ENODEV; in ingenic_usb_phy_probe()
332 priv->base = devm_platform_ioremap_resource(pdev, 0); in ingenic_usb_phy_probe()
333 if (IS_ERR(priv->base)) { in ingenic_usb_phy_probe()
335 return PTR_ERR(priv->base); in ingenic_usb_phy_probe()
338 priv->clk = devm_clk_get(dev, NULL); in ingenic_usb_phy_probe()
339 if (IS_ERR(priv->clk)) { in ingenic_usb_phy_probe()
340 err = PTR_ERR(priv->clk); in ingenic_usb_phy_probe()
341 if (err != -EPROBE_DEFER) in ingenic_usb_phy_probe()
346 priv->vcc_supply = devm_regulator_get(dev, "vcc"); in ingenic_usb_phy_probe()
347 if (IS_ERR(priv->vcc_supply)) { in ingenic_usb_phy_probe()
348 err = PTR_ERR(priv->vcc_supply); in ingenic_usb_phy_probe()
349 if (err != -EPROBE_DEFER) in ingenic_usb_phy_probe()
354 priv->phy = devm_phy_create(dev, NULL, &ingenic_usb_phy_ops); in ingenic_usb_phy_probe()
355 if (IS_ERR(priv->phy)) in ingenic_usb_phy_probe()
356 return PTR_ERR(priv->phy); in ingenic_usb_phy_probe()
358 phy_set_drvdata(priv->phy, priv); in ingenic_usb_phy_probe()
366 { .compatible = "ingenic,jz4770-phy", .data = &jz4770_soc_info },
367 { .compatible = "ingenic,jz4775-phy", .data = &jz4775_soc_info },
368 { .compatible = "ingenic,jz4780-phy", .data = &jz4780_soc_info },
369 { .compatible = "ingenic,x1000-phy", .data = &x1000_soc_info },
370 { .compatible = "ingenic,x1830-phy", .data = &x1830_soc_info },
371 { .compatible = "ingenic,x2000-phy", .data = &x2000_soc_info },
379 .name = "ingenic-usb-phy",
388 MODULE_DESCRIPTION("Ingenic SoCs USB PHY driver");