Commit 31ee04de authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Greg Kroah-Hartman

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: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1eb838d3
...@@ -152,6 +152,7 @@ struct s3c_hsotg { ...@@ -152,6 +152,7 @@ struct s3c_hsotg {
void __iomem *regs; void __iomem *regs;
struct resource *regs_res; struct resource *regs_res;
int irq; int irq;
struct clk *clk;
unsigned int dedicated_fifos:1; unsigned int dedicated_fifos:1;
...@@ -3258,13 +3259,20 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3258,13 +3259,20 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
hsotg->dev = dev; hsotg->dev = dev;
hsotg->plat = plat; hsotg->plat = plat;
hsotg->clk = clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
dev_err(dev, "cannot get otg clock\n");
ret = -EINVAL;
goto err_mem;
}
platform_set_drvdata(pdev, hsotg); platform_set_drvdata(pdev, hsotg);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(dev, "cannot find register resource 0\n"); dev_err(dev, "cannot find register resource 0\n");
ret = -EINVAL; ret = -EINVAL;
goto err_mem; goto err_clk;
} }
hsotg->regs_res = request_mem_region(res->start, resource_size(res), 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,7 +3280,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
if (!hsotg->regs_res) { if (!hsotg->regs_res) {
dev_err(dev, "cannot reserve registers\n"); dev_err(dev, "cannot reserve registers\n");
ret = -ENOENT; ret = -ENOENT;
goto err_mem; goto err_clk;
} }
hsotg->regs = ioremap(res->start, resource_size(res)); hsotg->regs = ioremap(res->start, resource_size(res));
...@@ -3325,6 +3333,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3325,6 +3333,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
/* reset the system */ /* reset the system */
clk_enable(hsotg->clk);
s3c_hsotg_gate(pdev, true); s3c_hsotg_gate(pdev, true);
s3c_hsotg_otgreset(hsotg); s3c_hsotg_otgreset(hsotg);
...@@ -3348,7 +3358,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3348,7 +3358,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
err_regs_res: err_regs_res:
release_resource(hsotg->regs_res); release_resource(hsotg->regs_res);
kfree(hsotg->regs_res); kfree(hsotg->regs_res);
err_clk:
clk_put(hsotg->clk);
err_mem: err_mem:
kfree(hsotg); kfree(hsotg);
return ret; return ret;
...@@ -3370,6 +3381,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) ...@@ -3370,6 +3381,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
s3c_hsotg_gate(pdev, false); s3c_hsotg_gate(pdev, false);
clk_disable(hsotg->clk);
clk_put(hsotg->clk);
kfree(hsotg); kfree(hsotg);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment