diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2010-07-19 10:01:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 17:35:43 -0400 |
commit | 31ee04de7e670de4199572595cce4aaa7f7f6351 (patch) | |
tree | 87757aa24d1654239d96fdaa152ec1f198e96ae6 /drivers/usb | |
parent | 1eb838d3e2a473acbb9b21278e75b79640fb2c7b (diff) |
USB: s3c-hsotg: add support for clock gating
This patch adds support for clock gating of the HS/OTG block. On S5PV210
otg gating clock is initally disabled so the driver needs to get and
enable it before it can access its registers.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/s3c-hsotg.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 258ca01ac679..521ebed0118d 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -152,6 +152,7 @@ struct s3c_hsotg { | |||
152 | void __iomem *regs; | 152 | void __iomem *regs; |
153 | struct resource *regs_res; | 153 | struct resource *regs_res; |
154 | int irq; | 154 | int irq; |
155 | struct clk *clk; | ||
155 | 156 | ||
156 | unsigned int dedicated_fifos:1; | 157 | unsigned int dedicated_fifos:1; |
157 | 158 | ||
@@ -3258,13 +3259,20 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3258 | hsotg->dev = dev; | 3259 | hsotg->dev = dev; |
3259 | hsotg->plat = plat; | 3260 | hsotg->plat = plat; |
3260 | 3261 | ||
3262 | hsotg->clk = clk_get(&pdev->dev, "otg"); | ||
3263 | if (IS_ERR(hsotg->clk)) { | ||
3264 | dev_err(dev, "cannot get otg clock\n"); | ||
3265 | ret = -EINVAL; | ||
3266 | goto err_mem; | ||
3267 | } | ||
3268 | |||
3261 | platform_set_drvdata(pdev, hsotg); | 3269 | platform_set_drvdata(pdev, hsotg); |
3262 | 3270 | ||
3263 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 3271 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
3264 | if (!res) { | 3272 | if (!res) { |
3265 | dev_err(dev, "cannot find register resource 0\n"); | 3273 | dev_err(dev, "cannot find register resource 0\n"); |
3266 | ret = -EINVAL; | 3274 | ret = -EINVAL; |
3267 | goto err_mem; | 3275 | goto err_clk; |
3268 | } | 3276 | } |
3269 | 3277 | ||
3270 | hsotg->regs_res = request_mem_region(res->start, resource_size(res), | 3278 | hsotg->regs_res = request_mem_region(res->start, resource_size(res), |
@@ -3272,7 +3280,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3272 | if (!hsotg->regs_res) { | 3280 | if (!hsotg->regs_res) { |
3273 | dev_err(dev, "cannot reserve registers\n"); | 3281 | dev_err(dev, "cannot reserve registers\n"); |
3274 | ret = -ENOENT; | 3282 | ret = -ENOENT; |
3275 | goto err_mem; | 3283 | goto err_clk; |
3276 | } | 3284 | } |
3277 | 3285 | ||
3278 | hsotg->regs = ioremap(res->start, resource_size(res)); | 3286 | hsotg->regs = ioremap(res->start, resource_size(res)); |
@@ -3325,6 +3333,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3325 | 3333 | ||
3326 | /* reset the system */ | 3334 | /* reset the system */ |
3327 | 3335 | ||
3336 | clk_enable(hsotg->clk); | ||
3337 | |||
3328 | s3c_hsotg_gate(pdev, true); | 3338 | s3c_hsotg_gate(pdev, true); |
3329 | 3339 | ||
3330 | s3c_hsotg_otgreset(hsotg); | 3340 | s3c_hsotg_otgreset(hsotg); |
@@ -3348,7 +3358,8 @@ err_regs: | |||
3348 | err_regs_res: | 3358 | err_regs_res: |
3349 | release_resource(hsotg->regs_res); | 3359 | release_resource(hsotg->regs_res); |
3350 | kfree(hsotg->regs_res); | 3360 | kfree(hsotg->regs_res); |
3351 | 3361 | err_clk: | |
3362 | clk_put(hsotg->clk); | ||
3352 | err_mem: | 3363 | err_mem: |
3353 | kfree(hsotg); | 3364 | kfree(hsotg); |
3354 | return ret; | 3365 | return ret; |
@@ -3370,6 +3381,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) | |||
3370 | 3381 | ||
3371 | s3c_hsotg_gate(pdev, false); | 3382 | s3c_hsotg_gate(pdev, false); |
3372 | 3383 | ||
3384 | clk_disable(hsotg->clk); | ||
3385 | clk_put(hsotg->clk); | ||
3386 | |||
3373 | kfree(hsotg); | 3387 | kfree(hsotg); |
3374 | return 0; | 3388 | return 0; |
3375 | } | 3389 | } |