aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Porter <mporter@linaro.org>2013-12-19 09:23:06 -0500
committerFelipe Balbi <balbi@ti.com>2013-12-23 15:31:16 -0500
commit74084844e8e7d5424e8b512b0ee6d46c72087b56 (patch)
tree6a612c9a8ef67a3d924f875f80342e625902c7d5
parent0d33d825632737c8d3353c80c8701252682bcb03 (diff)
usb: gadget: s3c-hsotg: enable generic phy support
Adds support for the generic PHY subsystem. Generic PHY support is probed and then the driver falls back to checking for an old style USB PHY and pdata if not found. Signed-off-by: Matt Porter <mporter@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 50b57b21d130..f39daf7a7dce 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -30,6 +30,8 @@
30#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/regulator/consumer.h> 31#include <linux/regulator/consumer.h>
32#include <linux/of_platform.h> 32#include <linux/of_platform.h>
33#include <linux/phy/phy.h>
34#include <linux/usb/phy.h>
33 35
34#include <linux/usb/ch9.h> 36#include <linux/usb/ch9.h>
35#include <linux/usb/gadget.h> 37#include <linux/usb/gadget.h>
@@ -138,6 +140,7 @@ struct s3c_hsotg_ep {
138 * @dev: The parent device supplied to the probe function 140 * @dev: The parent device supplied to the probe function
139 * @driver: USB gadget driver 141 * @driver: USB gadget driver
140 * @phy: The otg phy transceiver structure for phy control. 142 * @phy: The otg phy transceiver structure for phy control.
143 * @uphy: The otg phy transceiver structure for old USB phy control.
141 * @plat: The platform specific configuration data. This can be removed once 144 * @plat: The platform specific configuration data. This can be removed once
142 * all SoCs support usb transceiver. 145 * all SoCs support usb transceiver.
143 * @regs: The memory area mapped for accessing registers. 146 * @regs: The memory area mapped for accessing registers.
@@ -159,7 +162,8 @@ struct s3c_hsotg_ep {
159struct s3c_hsotg { 162struct s3c_hsotg {
160 struct device *dev; 163 struct device *dev;
161 struct usb_gadget_driver *driver; 164 struct usb_gadget_driver *driver;
162 struct usb_phy *phy; 165 struct phy *phy;
166 struct usb_phy *uphy;
163 struct s3c_hsotg_plat *plat; 167 struct s3c_hsotg_plat *plat;
164 168
165 spinlock_t lock; 169 spinlock_t lock;
@@ -2909,8 +2913,11 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
2909 2913
2910 dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); 2914 dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
2911 2915
2912 if (hsotg->phy) 2916 if (hsotg->phy) {
2913 usb_phy_init(hsotg->phy); 2917 phy_init(hsotg->phy);
2918 phy_power_on(hsotg->phy);
2919 } else if (hsotg->uphy)
2920 usb_phy_init(hsotg->uphy);
2914 else if (hsotg->plat->phy_init) 2921 else if (hsotg->plat->phy_init)
2915 hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); 2922 hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
2916} 2923}
@@ -2926,8 +2933,11 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
2926{ 2933{
2927 struct platform_device *pdev = to_platform_device(hsotg->dev); 2934 struct platform_device *pdev = to_platform_device(hsotg->dev);
2928 2935
2929 if (hsotg->phy) 2936 if (hsotg->phy) {
2930 usb_phy_shutdown(hsotg->phy); 2937 phy_power_off(hsotg->phy);
2938 phy_exit(hsotg->phy);
2939 } else if (hsotg->uphy)
2940 usb_phy_shutdown(hsotg->uphy);
2931 else if (hsotg->plat->phy_exit) 2941 else if (hsotg->plat->phy_exit)
2932 hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); 2942 hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
2933} 2943}
@@ -3534,7 +3544,8 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg)
3534static int s3c_hsotg_probe(struct platform_device *pdev) 3544static int s3c_hsotg_probe(struct platform_device *pdev)
3535{ 3545{
3536 struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev); 3546 struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev);
3537 struct usb_phy *phy; 3547 struct phy *phy;
3548 struct usb_phy *uphy;
3538 struct device *dev = &pdev->dev; 3549 struct device *dev = &pdev->dev;
3539 struct s3c_hsotg_ep *eps; 3550 struct s3c_hsotg_ep *eps;
3540 struct s3c_hsotg *hsotg; 3551 struct s3c_hsotg *hsotg;
@@ -3549,19 +3560,26 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
3549 return -ENOMEM; 3560 return -ENOMEM;
3550 } 3561 }
3551 3562
3552 phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); 3563 /*
3564 * Attempt to find a generic PHY, then look for an old style
3565 * USB PHY, finally fall back to pdata
3566 */
3567 phy = devm_phy_get(&pdev->dev, "usb2-phy");
3553 if (IS_ERR(phy)) { 3568 if (IS_ERR(phy)) {
3554 /* Fallback for pdata */ 3569 uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
3555 plat = dev_get_platdata(&pdev->dev); 3570 if (IS_ERR(uphy)) {
3556 if (!plat) { 3571 /* Fallback for pdata */
3557 dev_err(&pdev->dev, "no platform data or transceiver defined\n"); 3572 plat = dev_get_platdata(&pdev->dev);
3558 return -EPROBE_DEFER; 3573 if (!plat) {
3559 } else { 3574 dev_err(&pdev->dev,
3575 "no platform data or transceiver defined\n");
3576 return -EPROBE_DEFER;
3577 }
3560 hsotg->plat = plat; 3578 hsotg->plat = plat;
3561 } 3579 } else
3562 } else { 3580 hsotg->uphy = uphy;
3581 } else
3563 hsotg->phy = phy; 3582 hsotg->phy = phy;
3564 }
3565 3583
3566 hsotg->dev = dev; 3584 hsotg->dev = dev;
3567 3585
@@ -3628,6 +3646,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
3628 goto err_supplies; 3646 goto err_supplies;
3629 } 3647 }
3630 3648
3649 if (hsotg->phy)
3650 phy_init(hsotg->phy);
3651
3631 /* usb phy enable */ 3652 /* usb phy enable */
3632 s3c_hsotg_phy_enable(hsotg); 3653 s3c_hsotg_phy_enable(hsotg);
3633 3654
@@ -3721,6 +3742,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
3721 } 3742 }
3722 3743
3723 s3c_hsotg_phy_disable(hsotg); 3744 s3c_hsotg_phy_disable(hsotg);
3745 if (hsotg->phy)
3746 phy_exit(hsotg->phy);
3724 clk_disable_unprepare(hsotg->clk); 3747 clk_disable_unprepare(hsotg->clk);
3725 3748
3726 return 0; 3749 return 0;