1 // SPDX-License-Identifier: GPL-1.0+
3 * Renesas USB driver R-Car Gen. 2 initialization and power control
5 * Copyright (C) 2014 Ulrich Hecht
8 #include <linux/gpio.h>
9 #include <linux/of_gpio.h>
10 #include <linux/phy/phy.h>
11 #include <linux/usb/phy.h>
15 static int usbhs_rcar2_hardware_init(struct platform_device *pdev)
17 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
19 if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
20 struct phy *phy = phy_get(&pdev->dev, "usb");
29 if (IS_ENABLED(CONFIG_USB_PHY)) {
30 struct usb_phy *usb_phy = usb_get_phy_dev(&pdev->dev, 0);
33 return PTR_ERR(usb_phy);
35 priv->usb_phy = usb_phy;
42 static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
44 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
52 usb_put_phy(priv->usb_phy);
59 static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
60 void __iomem *base, int enable)
62 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
67 retval = phy_init(priv->phy);
70 retval = phy_power_on(priv->phy);
72 phy_power_off(priv->phy);
80 retval = usb_phy_init(priv->usb_phy);
83 retval = usb_phy_set_suspend(priv->usb_phy, 0);
85 usb_phy_set_suspend(priv->usb_phy, 1);
86 usb_phy_shutdown(priv->usb_phy);
94 static int usbhs_rcar2_get_id(struct platform_device *pdev)
99 const struct renesas_usbhs_platform_callback usbhs_rcar2_ops = {
100 .hardware_init = usbhs_rcar2_hardware_init,
101 .hardware_exit = usbhs_rcar2_hardware_exit,
102 .power_ctrl = usbhs_rcar2_power_ctrl,
103 .get_id = usbhs_rcar2_get_id,