0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/delay.h>
0010 #include <linux/io.h>
0011 #include <linux/of_device.h>
0012 #include <linux/phy/phy.h>
0013 #include "common.h"
0014 #include "rza.h"
0015
0016 static int usbhs_rza2_hardware_init(struct platform_device *pdev)
0017 {
0018 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
0019 struct phy *phy = phy_get(&pdev->dev, "usb");
0020
0021 if (IS_ERR(phy))
0022 return PTR_ERR(phy);
0023
0024 priv->phy = phy;
0025 return 0;
0026 }
0027
0028 static int usbhs_rza2_hardware_exit(struct platform_device *pdev)
0029 {
0030 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
0031
0032 phy_put(&pdev->dev, priv->phy);
0033 priv->phy = NULL;
0034
0035 return 0;
0036 }
0037
0038 static int usbhs_rza2_power_ctrl(struct platform_device *pdev,
0039 void __iomem *base, int enable)
0040 {
0041 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
0042 int retval = 0;
0043
0044 if (!priv->phy)
0045 return -ENODEV;
0046
0047 if (enable) {
0048 retval = phy_init(priv->phy);
0049 usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM);
0050 udelay(100);
0051 if (!retval)
0052 retval = phy_power_on(priv->phy);
0053 } else {
0054 usbhs_bset(priv, SUSPMODE, SUSPM, 0);
0055 phy_power_off(priv->phy);
0056 phy_exit(priv->phy);
0057 }
0058
0059 return retval;
0060 }
0061
0062 const struct renesas_usbhs_platform_info usbhs_rza2_plat_info = {
0063 .platform_callback = {
0064 .hardware_init = usbhs_rza2_hardware_init,
0065 .hardware_exit = usbhs_rza2_hardware_exit,
0066 .power_ctrl = usbhs_rza2_power_ctrl,
0067 .get_id = usbhs_get_id_as_gadget,
0068 },
0069 .driver_param = {
0070 .has_cnen = 1,
0071 .cfifo_byte_addr = 1,
0072 .has_new_pipe_configs = 1,
0073 },
0074 };