diff options
author | Praveen Paneri <p.paneri@samsung.com> | 2012-11-14 05:27:16 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-18 08:08:36 -0500 |
commit | b2e587dbb7a7554b56d2f38e284ad975d2f00181 (patch) | |
tree | 28fef84f21136793ed3fa639abe500671a33c59e /drivers/usb/gadget | |
parent | 337dc3a7684cf6577b5595b9bb96e1af06baec41 (diff) |
usb: phy: s3c-hsotg: adding phy driver support
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it
Signed-off-by: Praveen Paneri <p.paneri@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/s3c-hsotg.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 141971d9051e..2143df358072 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -32,6 +32,7 @@ | |||
32 | 32 | ||
33 | #include <linux/usb/ch9.h> | 33 | #include <linux/usb/ch9.h> |
34 | #include <linux/usb/gadget.h> | 34 | #include <linux/usb/gadget.h> |
35 | #include <linux/usb/phy.h> | ||
35 | #include <linux/platform_data/s3c-hsotg.h> | 36 | #include <linux/platform_data/s3c-hsotg.h> |
36 | 37 | ||
37 | #include <mach/map.h> | 38 | #include <mach/map.h> |
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep { | |||
133 | * struct s3c_hsotg - driver state. | 134 | * struct s3c_hsotg - driver state. |
134 | * @dev: The parent device supplied to the probe function | 135 | * @dev: The parent device supplied to the probe function |
135 | * @driver: USB gadget driver | 136 | * @driver: USB gadget driver |
136 | * @plat: The platform specific configuration data. | 137 | * @phy: The otg phy transceiver structure for phy control. |
138 | * @plat: The platform specific configuration data. This can be removed once | ||
139 | * all SoCs support usb transceiver. | ||
137 | * @regs: The memory area mapped for accessing registers. | 140 | * @regs: The memory area mapped for accessing registers. |
138 | * @irq: The IRQ number we are using | 141 | * @irq: The IRQ number we are using |
139 | * @supplies: Definition of USB power supplies | 142 | * @supplies: Definition of USB power supplies |
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep { | |||
153 | struct s3c_hsotg { | 156 | struct s3c_hsotg { |
154 | struct device *dev; | 157 | struct device *dev; |
155 | struct usb_gadget_driver *driver; | 158 | struct usb_gadget_driver *driver; |
159 | struct usb_phy *phy; | ||
156 | struct s3c_hsotg_plat *plat; | 160 | struct s3c_hsotg_plat *plat; |
157 | 161 | ||
158 | spinlock_t lock; | 162 | spinlock_t lock; |
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) | |||
2854 | struct platform_device *pdev = to_platform_device(hsotg->dev); | 2858 | struct platform_device *pdev = to_platform_device(hsotg->dev); |
2855 | 2859 | ||
2856 | dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); | 2860 | dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); |
2857 | if (hsotg->plat->phy_init) | 2861 | |
2862 | if (hsotg->phy) | ||
2863 | usb_phy_init(hsotg->phy); | ||
2864 | else if (hsotg->plat->phy_init) | ||
2858 | hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); | 2865 | hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); |
2859 | } | 2866 | } |
2860 | 2867 | ||
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) | |||
2869 | { | 2876 | { |
2870 | struct platform_device *pdev = to_platform_device(hsotg->dev); | 2877 | struct platform_device *pdev = to_platform_device(hsotg->dev); |
2871 | 2878 | ||
2872 | if (hsotg->plat->phy_exit) | 2879 | if (hsotg->phy) |
2880 | usb_phy_shutdown(hsotg->phy); | ||
2881 | else if (hsotg->plat->phy_exit) | ||
2873 | hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); | 2882 | hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); |
2874 | } | 2883 | } |
2875 | 2884 | ||
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev) | |||
3493 | static int s3c_hsotg_probe(struct platform_device *pdev) | 3502 | static int s3c_hsotg_probe(struct platform_device *pdev) |
3494 | { | 3503 | { |
3495 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; | 3504 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; |
3505 | struct usb_phy *phy; | ||
3496 | struct device *dev = &pdev->dev; | 3506 | struct device *dev = &pdev->dev; |
3497 | struct s3c_hsotg_ep *eps; | 3507 | struct s3c_hsotg_ep *eps; |
3498 | struct s3c_hsotg *hsotg; | 3508 | struct s3c_hsotg *hsotg; |
@@ -3501,20 +3511,27 @@ static int s3c_hsotg_probe(struct platform_device *pdev) | |||
3501 | int ret; | 3511 | int ret; |
3502 | int i; | 3512 | int i; |
3503 | 3513 | ||
3504 | plat = pdev->dev.platform_data; | ||
3505 | if (!plat) { | ||
3506 | dev_err(&pdev->dev, "no platform data defined\n"); | ||
3507 | return -EINVAL; | ||
3508 | } | ||
3509 | |||
3510 | hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL); | 3514 | hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL); |
3511 | if (!hsotg) { | 3515 | if (!hsotg) { |
3512 | dev_err(dev, "cannot get memory\n"); | 3516 | dev_err(dev, "cannot get memory\n"); |
3513 | return -ENOMEM; | 3517 | return -ENOMEM; |
3514 | } | 3518 | } |
3515 | 3519 | ||
3520 | phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); | ||
3521 | if (IS_ERR_OR_NULL(phy)) { | ||
3522 | /* Fallback for pdata */ | ||
3523 | plat = pdev->dev.platform_data; | ||
3524 | if (!plat) { | ||
3525 | dev_err(&pdev->dev, "no platform data or transceiver defined\n"); | ||
3526 | return -EPROBE_DEFER; | ||
3527 | } else { | ||
3528 | hsotg->plat = plat; | ||
3529 | } | ||
3530 | } else { | ||
3531 | hsotg->phy = phy; | ||
3532 | } | ||
3533 | |||
3516 | hsotg->dev = dev; | 3534 | hsotg->dev = dev; |
3517 | hsotg->plat = plat; | ||
3518 | 3535 | ||
3519 | hsotg->clk = devm_clk_get(&pdev->dev, "otg"); | 3536 | hsotg->clk = devm_clk_get(&pdev->dev, "otg"); |
3520 | if (IS_ERR(hsotg->clk)) { | 3537 | if (IS_ERR(hsotg->clk)) { |