diff options
author | Lukasz Majewski <l.majewski@samsung.com> | 2012-05-04 08:17:01 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-05-04 08:53:11 -0400 |
commit | 4118878697c76e5444a1d5db9c399ca5d923b0a8 (patch) | |
tree | 8ad29548714fcd261f9e2d1f8484eeb019c9c7e5 /drivers/usb/gadget/s3c-hsotg.c | |
parent | d77039c111565614f07887b44b098ca38360f720 (diff) |
usb:hsotg:samsung: Wrappers for USB PHY methods
Wrappers for PHY methods have been added for readability and reduction
of code repetition.
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/s3c-hsotg.c')
-rw-r--r-- | drivers/usb/gadget/s3c-hsotg.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 34069dc55cb0..3484a09d1ddb 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include <mach/map.h> | 34 | #include <mach/map.h> |
35 | 35 | ||
36 | #include <plat/regs-usb-hsotg-phy.h> | ||
37 | #include "s3c-hsotg.h" | 36 | #include "s3c-hsotg.h" |
38 | #include <linux/platform_data/s3c-hsotg.h> | 37 | #include <linux/platform_data/s3c-hsotg.h> |
39 | 38 | ||
@@ -2571,6 +2570,39 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg) | |||
2571 | return 0; | 2570 | return 0; |
2572 | } | 2571 | } |
2573 | 2572 | ||
2573 | /** | ||
2574 | * s3c_hsotg_phy_enable - enable platform phy dev | ||
2575 | * | ||
2576 | * @param: The driver state | ||
2577 | * | ||
2578 | * A wrapper for platform code responsible for controlling | ||
2579 | * low-level USB code | ||
2580 | */ | ||
2581 | static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) | ||
2582 | { | ||
2583 | struct platform_device *pdev = to_platform_device(hsotg->dev); | ||
2584 | |||
2585 | dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); | ||
2586 | if (hsotg->plat->phy_init) | ||
2587 | hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); | ||
2588 | } | ||
2589 | |||
2590 | /** | ||
2591 | * s3c_hsotg_phy_disable - disable platform phy dev | ||
2592 | * | ||
2593 | * @param: The driver state | ||
2594 | * | ||
2595 | * A wrapper for platform code responsible for controlling | ||
2596 | * low-level USB code | ||
2597 | */ | ||
2598 | static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) | ||
2599 | { | ||
2600 | struct platform_device *pdev = to_platform_device(hsotg->dev); | ||
2601 | |||
2602 | if (hsotg->plat->phy_exit) | ||
2603 | hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); | ||
2604 | } | ||
2605 | |||
2574 | static int s3c_hsotg_start(struct usb_gadget_driver *driver, | 2606 | static int s3c_hsotg_start(struct usb_gadget_driver *driver, |
2575 | int (*bind)(struct usb_gadget *)) | 2607 | int (*bind)(struct usb_gadget *)) |
2576 | { | 2608 | { |
@@ -3216,8 +3248,6 @@ static void __devexit s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) | |||
3216 | debugfs_remove(hsotg->debug_root); | 3248 | debugfs_remove(hsotg->debug_root); |
3217 | } | 3249 | } |
3218 | 3250 | ||
3219 | static struct s3c_hsotg_plat s3c_hsotg_default_pdata; | ||
3220 | |||
3221 | static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | 3251 | static int __devinit s3c_hsotg_probe(struct platform_device *pdev) |
3222 | { | 3252 | { |
3223 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; | 3253 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; |
@@ -3227,8 +3257,11 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3227 | int epnum; | 3257 | int epnum; |
3228 | int ret; | 3258 | int ret; |
3229 | 3259 | ||
3230 | if (!plat) | 3260 | plat = pdev->dev.platform_data; |
3231 | plat = &s3c_hsotg_default_pdata; | 3261 | if (!plat) { |
3262 | dev_err(&pdev->dev, "no platform data defined\n"); | ||
3263 | return -EINVAL; | ||
3264 | } | ||
3232 | 3265 | ||
3233 | hsotg = kzalloc(sizeof(struct s3c_hsotg) + | 3266 | hsotg = kzalloc(sizeof(struct s3c_hsotg) + |
3234 | sizeof(struct s3c_hsotg_ep) * S3C_HSOTG_EPS, | 3267 | sizeof(struct s3c_hsotg_ep) * S3C_HSOTG_EPS, |
@@ -3317,6 +3350,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3317 | 3350 | ||
3318 | clk_enable(hsotg->clk); | 3351 | clk_enable(hsotg->clk); |
3319 | 3352 | ||
3353 | /* usb phy enable */ | ||
3354 | s3c_hsotg_phy_enable(hsotg); | ||
3320 | 3355 | ||
3321 | s3c_hsotg_corereset(hsotg); | 3356 | s3c_hsotg_corereset(hsotg); |
3322 | s3c_hsotg_init(hsotg); | 3357 | s3c_hsotg_init(hsotg); |
@@ -3337,6 +3372,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3337 | return 0; | 3372 | return 0; |
3338 | 3373 | ||
3339 | err_add_udc: | 3374 | err_add_udc: |
3375 | s3c_hsotg_phy_disable(hsotg); | ||
3376 | |||
3340 | clk_disable(hsotg->clk); | 3377 | clk_disable(hsotg->clk); |
3341 | clk_put(hsotg->clk); | 3378 | clk_put(hsotg->clk); |
3342 | 3379 | ||
@@ -3369,6 +3406,7 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) | |||
3369 | release_resource(hsotg->regs_res); | 3406 | release_resource(hsotg->regs_res); |
3370 | kfree(hsotg->regs_res); | 3407 | kfree(hsotg->regs_res); |
3371 | 3408 | ||
3409 | s3c_hsotg_phy_disable(hsotg); | ||
3372 | 3410 | ||
3373 | clk_disable(hsotg->clk); | 3411 | clk_disable(hsotg->clk); |
3374 | clk_put(hsotg->clk); | 3412 | clk_put(hsotg->clk); |