Lines Matching +full:rcar +full:- +full:gen2 +full:- +full:can

1 // SPDX-License-Identifier: GPL-2.0
3 * Renesas R-Car Gen2 PHY driver
80 struct rcar_gen2_channel *channel = phy->channel; in rcar_gen2_phy_init()
81 struct rcar_gen2_phy_driver *drv = channel->drv; in rcar_gen2_phy_init()
89 * driver. Achieving this with cmpxcgh() should be SMP-safe. in rcar_gen2_phy_init()
91 if (cmpxchg(&channel->selected_phy, -1, phy->number) != -1) in rcar_gen2_phy_init()
92 return -EBUSY; in rcar_gen2_phy_init()
94 clk_prepare_enable(drv->clk); in rcar_gen2_phy_init()
96 spin_lock_irqsave(&drv->lock, flags); in rcar_gen2_phy_init()
97 ugctrl2 = readl(drv->base + USBHS_UGCTRL2); in rcar_gen2_phy_init()
98 ugctrl2 &= ~channel->select_mask; in rcar_gen2_phy_init()
99 ugctrl2 |= phy->select_value; in rcar_gen2_phy_init()
100 writel(ugctrl2, drv->base + USBHS_UGCTRL2); in rcar_gen2_phy_init()
101 spin_unlock_irqrestore(&drv->lock, flags); in rcar_gen2_phy_init()
108 struct rcar_gen2_channel *channel = phy->channel; in rcar_gen2_phy_exit()
110 clk_disable_unprepare(channel->drv->clk); in rcar_gen2_phy_exit()
112 channel->selected_phy = -1; in rcar_gen2_phy_exit()
120 struct rcar_gen2_phy_driver *drv = phy->channel->drv; in rcar_gen2_phy_power_on()
121 void __iomem *base = drv->base; in rcar_gen2_phy_power_on()
127 if (phy->select_value != USBHS_UGCTRL2_USB0SEL_HS_USB) in rcar_gen2_phy_power_on()
130 spin_lock_irqsave(&drv->lock, flags); in rcar_gen2_phy_power_on()
153 err = -ETIMEDOUT; in rcar_gen2_phy_power_on()
156 spin_unlock_irqrestore(&drv->lock, flags); in rcar_gen2_phy_power_on()
164 struct rcar_gen2_phy_driver *drv = phy->channel->drv; in rcar_gen2_phy_power_off()
165 void __iomem *base = drv->base; in rcar_gen2_phy_power_off()
170 if (phy->select_value != USBHS_UGCTRL2_USB0SEL_HS_USB) in rcar_gen2_phy_power_off()
173 spin_lock_irqsave(&drv->lock, flags); in rcar_gen2_phy_power_off()
188 spin_unlock_irqrestore(&drv->lock, flags); in rcar_gen2_phy_power_off()
196 struct rcar_gen2_phy_driver *drv = phy->channel->drv; in rz_g1c_phy_power_on()
197 void __iomem *base = drv->base; in rz_g1c_phy_power_on()
201 spin_lock_irqsave(&drv->lock, flags); in rz_g1c_phy_power_on()
211 if (phy->select_value == USBHS_UGCTRL2_USB0SEL_HS_USB20) { in rz_g1c_phy_power_on()
217 spin_unlock_irqrestore(&drv->lock, flags); in rz_g1c_phy_power_on()
225 struct rcar_gen2_phy_driver *drv = phy->channel->drv; in rz_g1c_phy_power_off()
226 void __iomem *base = drv->base; in rz_g1c_phy_power_off()
230 spin_lock_irqsave(&drv->lock, flags); in rz_g1c_phy_power_off()
232 if (phy->select_value == USBHS_UGCTRL2_USB0SEL_HS_USB20) { in rz_g1c_phy_power_off()
242 spin_unlock_irqrestore(&drv->lock, flags); in rz_g1c_phy_power_off()
286 .compatible = "renesas,usb-phy-r8a77470",
290 .compatible = "renesas,usb-phy-r8a7790",
294 .compatible = "renesas,usb-phy-r8a7791",
298 .compatible = "renesas,usb-phy-r8a7794",
302 .compatible = "renesas,rcar-gen2-usb-phy",
313 struct device_node *np = args->np; in rcar_gen2_phy_xlate()
318 return ERR_PTR(-EINVAL); in rcar_gen2_phy_xlate()
320 for (i = 0; i < drv->num_channels; i++) { in rcar_gen2_phy_xlate()
321 if (np == drv->channels[i].of_node) in rcar_gen2_phy_xlate()
325 if (i >= drv->num_channels || args->args[0] >= 2) in rcar_gen2_phy_xlate()
326 return ERR_PTR(-ENODEV); in rcar_gen2_phy_xlate()
328 return drv->channels[i].phys[args->args[0]].phy; in rcar_gen2_phy_xlate()
338 struct device *dev = &pdev->dev; in rcar_gen2_phy_probe()
347 if (!dev->of_node) { in rcar_gen2_phy_probe()
350 return -EINVAL; in rcar_gen2_phy_probe()
355 dev_err(dev, "Can't get USBHS clock\n"); in rcar_gen2_phy_probe()
365 return -ENOMEM; in rcar_gen2_phy_probe()
367 spin_lock_init(&drv->lock); in rcar_gen2_phy_probe()
369 drv->clk = clk; in rcar_gen2_phy_probe()
370 drv->base = base; in rcar_gen2_phy_probe()
374 return -EINVAL; in rcar_gen2_phy_probe()
376 drv->num_channels = of_get_child_count(dev->of_node); in rcar_gen2_phy_probe()
377 drv->channels = devm_kcalloc(dev, drv->num_channels, in rcar_gen2_phy_probe()
380 if (!drv->channels) in rcar_gen2_phy_probe()
381 return -ENOMEM; in rcar_gen2_phy_probe()
383 for_each_child_of_node(dev->of_node, np) { in rcar_gen2_phy_probe()
384 struct rcar_gen2_channel *channel = drv->channels + i; in rcar_gen2_phy_probe()
388 channel->of_node = np; in rcar_gen2_phy_probe()
389 channel->drv = drv; in rcar_gen2_phy_probe()
390 channel->selected_phy = -1; in rcar_gen2_phy_probe()
393 if (error || channel_num >= data->num_channels) { in rcar_gen2_phy_probe()
398 channel->select_mask = select_mask[channel_num]; in rcar_gen2_phy_probe()
401 struct rcar_gen2_phy *phy = &channel->phys[n]; in rcar_gen2_phy_probe()
403 phy->channel = channel; in rcar_gen2_phy_probe()
404 phy->number = n; in rcar_gen2_phy_probe()
405 phy->select_value = data->select_value[channel_num][n]; in rcar_gen2_phy_probe()
407 phy->phy = devm_phy_create(dev, NULL, in rcar_gen2_phy_probe()
408 data->gen2_phy_ops); in rcar_gen2_phy_probe()
409 if (IS_ERR(phy->phy)) { in rcar_gen2_phy_probe()
412 return PTR_ERR(phy->phy); in rcar_gen2_phy_probe()
414 phy_set_drvdata(phy->phy, phy); in rcar_gen2_phy_probe()
442 MODULE_DESCRIPTION("Renesas R-Car Gen2 PHY");