2 * Renesas USB driver R-Car Gen. 2 initialization and power control
4 * Copyright (C) 2014 Ulrich Hecht
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
13 #include <linux/gpio.h>
14 #include <linux/of_gpio.h>
15 #include <linux/phy/phy.h>
16 #include <linux/platform_data/gpio-rcar.h>
17 #include <linux/usb/phy.h>
21 static int usbhs_rcar2_hardware_init(struct platform_device *pdev)
23 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
25 if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
26 struct phy *phy = phy_get(&pdev->dev, "usb");
35 if (IS_ENABLED(CONFIG_USB_PHY)) {
36 struct usb_phy *usb_phy = usb_get_phy_dev(&pdev->dev, 0);
39 return PTR_ERR(usb_phy);
41 priv->usb_phy = usb_phy;
48 static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
50 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
58 usb_put_phy(priv->usb_phy);
65 static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
66 void __iomem *base, int enable)
68 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
73 retval = phy_init(priv->phy);
76 retval = phy_power_on(priv->phy);
78 phy_power_off(priv->phy);
86 retval = usb_phy_init(priv->usb_phy);
89 retval = usb_phy_set_suspend(priv->usb_phy, 0);
91 usb_phy_set_suspend(priv->usb_phy, 1);
92 usb_phy_shutdown(priv->usb_phy);
100 static int usbhs_rcar2_get_id(struct platform_device *pdev)
105 const struct renesas_usbhs_platform_callback usbhs_rcar2_ops = {
106 .hardware_init = usbhs_rcar2_hardware_init,
107 .hardware_exit = usbhs_rcar2_hardware_exit,
108 .power_ctrl = usbhs_rcar2_power_ctrl,
109 .get_id = usbhs_rcar2_get_id,