Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-1.0+
0002 /*
0003  * Renesas USB driver R-Car Gen. 2 initialization and power control
0004  *
0005  * Copyright (C) 2014 Ulrich Hecht
0006  * Copyright (C) 2019 Renesas Electronics Corporation
0007  */
0008 
0009 #include <linux/phy/phy.h>
0010 #include "common.h"
0011 #include "rcar2.h"
0012 
0013 static int usbhs_rcar2_hardware_init(struct platform_device *pdev)
0014 {
0015     struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
0016 
0017     if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
0018         struct phy *phy = phy_get(&pdev->dev, "usb");
0019 
0020         if (IS_ERR(phy))
0021             return PTR_ERR(phy);
0022 
0023         priv->phy = phy;
0024         return 0;
0025     }
0026 
0027     return -ENXIO;
0028 }
0029 
0030 static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
0031 {
0032     struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
0033 
0034     if (priv->phy) {
0035         phy_put(&pdev->dev, priv->phy);
0036         priv->phy = NULL;
0037     }
0038 
0039     return 0;
0040 }
0041 
0042 static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
0043                 void __iomem *base, int enable)
0044 {
0045     struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
0046     int retval = -ENODEV;
0047 
0048     if (priv->phy) {
0049         if (enable) {
0050             retval = phy_init(priv->phy);
0051 
0052             if (!retval)
0053                 retval = phy_power_on(priv->phy);
0054         } else {
0055             phy_power_off(priv->phy);
0056             phy_exit(priv->phy);
0057             retval = 0;
0058         }
0059     }
0060 
0061     return retval;
0062 }
0063 
0064 const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info = {
0065     .platform_callback = {
0066         .hardware_init = usbhs_rcar2_hardware_init,
0067         .hardware_exit = usbhs_rcar2_hardware_exit,
0068         .power_ctrl = usbhs_rcar2_power_ctrl,
0069         .get_id = usbhs_get_id_as_gadget,
0070     },
0071     .driver_param = {
0072         .has_usb_dmac = 1,
0073         .has_new_pipe_configs = 1,
0074     },
0075 };