aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/s3c-hsotg.c
diff options
context:
space:
mode:
authorLukasz Majewski <l.majewski@samsung.com>2012-05-04 08:17:02 -0400
committerFelipe Balbi <balbi@ti.com>2012-05-04 08:53:11 -0400
commitfc9a731ed0ef7138432f0f14981710aea8e83320 (patch)
treecb50438b7a796ca3558e2c886478935b8342395b /drivers/usb/gadget/s3c-hsotg.c
parent4118878697c76e5444a1d5db9c399ca5d923b0a8 (diff)
usb:hsotg:samsung: Use of regulator_bulk_* functions for USB regulators
This commit adds support for supply voltage management for s3c-hsotg IP block. For that purpose a convenient regulator_bulk_* functions have been used. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Liam Girdwood <lrg@ti.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.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 3484a09d1ddb..e1a54d21ecaf 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -27,6 +27,7 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/regulator/consumer.h>
30 31
31#include <linux/usb/ch9.h> 32#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h> 33#include <linux/usb/gadget.h>
@@ -38,6 +39,11 @@
38 39
39#define DMA_ADDR_INVALID (~((dma_addr_t)0)) 40#define DMA_ADDR_INVALID (~((dma_addr_t)0))
40 41
42static const char * const s3c_hsotg_supply_names[] = {
43 "vusb_d", /* digital USB supply, 1.2V */
44 "vusb_a", /* analog USB supply, 1.1V */
45};
46
41/* EP0_MPS_LIMIT 47/* EP0_MPS_LIMIT
42 * 48 *
43 * Unfortunately there seems to be a limit of the amount of data that can 49 * Unfortunately there seems to be a limit of the amount of data that can
@@ -132,6 +138,7 @@ struct s3c_hsotg_ep {
132 * @regs: The memory area mapped for accessing registers. 138 * @regs: The memory area mapped for accessing registers.
133 * @regs_res: The resource that was allocated when claiming register space. 139 * @regs_res: The resource that was allocated when claiming register space.
134 * @irq: The IRQ number we are using 140 * @irq: The IRQ number we are using
141 * @supplies: Definition of USB power supplies
135 * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. 142 * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
136 * @debug_root: root directrory for debugfs. 143 * @debug_root: root directrory for debugfs.
137 * @debug_file: main status file for debugfs. 144 * @debug_file: main status file for debugfs.
@@ -152,6 +159,8 @@ struct s3c_hsotg {
152 int irq; 159 int irq;
153 struct clk *clk; 160 struct clk *clk;
154 161
162 struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
163
155 unsigned int dedicated_fifos:1; 164 unsigned int dedicated_fifos:1;
156 165
157 struct dentry *debug_root; 166 struct dentry *debug_root;
@@ -3256,6 +3265,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3256 struct resource *res; 3265 struct resource *res;
3257 int epnum; 3266 int epnum;
3258 int ret; 3267 int ret;
3268 int i;
3259 3269
3260 plat = pdev->dev.platform_data; 3270 plat = pdev->dev.platform_data;
3261 if (!plat) { 3271 if (!plat) {
@@ -3350,6 +3360,26 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3350 3360
3351 clk_enable(hsotg->clk); 3361 clk_enable(hsotg->clk);
3352 3362
3363 /* regulators */
3364
3365 for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
3366 hsotg->supplies[i].supply = s3c_hsotg_supply_names[i];
3367
3368 ret = regulator_bulk_get(dev, ARRAY_SIZE(hsotg->supplies),
3369 hsotg->supplies);
3370 if (ret) {
3371 dev_err(dev, "failed to request supplies: %d\n", ret);
3372 goto err_supplies;
3373 }
3374
3375 ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
3376 hsotg->supplies);
3377
3378 if (ret) {
3379 dev_err(hsotg->dev, "failed to enable supplies: %d\n", ret);
3380 goto err_supplies;
3381 }
3382
3353 /* usb phy enable */ 3383 /* usb phy enable */
3354 s3c_hsotg_phy_enable(hsotg); 3384 s3c_hsotg_phy_enable(hsotg);
3355 3385
@@ -3362,7 +3392,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3362 3392
3363 ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget); 3393 ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget);
3364 if (ret) 3394 if (ret)
3365 goto err_add_udc; 3395 goto err_supplies;
3366 3396
3367 s3c_hsotg_create_debug(hsotg); 3397 s3c_hsotg_create_debug(hsotg);
3368 3398
@@ -3371,9 +3401,12 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
3371 our_hsotg = hsotg; 3401 our_hsotg = hsotg;
3372 return 0; 3402 return 0;
3373 3403
3374err_add_udc: 3404err_supplies:
3375 s3c_hsotg_phy_disable(hsotg); 3405 s3c_hsotg_phy_disable(hsotg);
3376 3406
3407 regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
3408 regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
3409
3377 clk_disable(hsotg->clk); 3410 clk_disable(hsotg->clk);
3378 clk_put(hsotg->clk); 3411 clk_put(hsotg->clk);
3379 3412
@@ -3408,6 +3441,10 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
3408 3441
3409 s3c_hsotg_phy_disable(hsotg); 3442 s3c_hsotg_phy_disable(hsotg);
3410 3443
3444
3445 regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
3446 regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
3447
3411 clk_disable(hsotg->clk); 3448 clk_disable(hsotg->clk);
3412 clk_put(hsotg->clk); 3449 clk_put(hsotg->clk);
3413 3450