diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-10-31 07:21:44 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-12-22 04:42:51 -0500 |
commit | a42b6dd69cb1c61c5f5a24061a227c22071786de (patch) | |
tree | 998ac6532b649ab39ff63ec4c637b6fe8d202187 | |
parent | 090d951b69f29a8d5777c63570d4cd61d7efeb22 (diff) |
sh: sh_mobile ceu clock framework support
Add clock framework support to the sh_mobile ceu and
adjust the board specific code accordingly.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/boards/board-ap325rxa.c | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-migor/setup.c | 2 | ||||
-rw-r--r-- | drivers/media/video/sh_mobile_ceu_camera.c | 20 |
3 files changed, 21 insertions, 3 deletions
diff --git a/arch/sh/boards/board-ap325rxa.c b/arch/sh/boards/board-ap325rxa.c index 8881a643ac32..0afaebad7b76 100644 --- a/arch/sh/boards/board-ap325rxa.c +++ b/arch/sh/boards/board-ap325rxa.c | |||
@@ -303,6 +303,7 @@ static struct resource ceu_resources[] = { | |||
303 | 303 | ||
304 | static struct platform_device ceu_device = { | 304 | static struct platform_device ceu_device = { |
305 | .name = "sh_mobile_ceu", | 305 | .name = "sh_mobile_ceu", |
306 | .id = 0, /* "ceu0" clock */ | ||
306 | .num_resources = ARRAY_SIZE(ceu_resources), | 307 | .num_resources = ARRAY_SIZE(ceu_resources), |
307 | .resource = ceu_resources, | 308 | .resource = ceu_resources, |
308 | .dev = { | 309 | .dev = { |
@@ -375,7 +376,6 @@ static int __init ap325rxa_devices_setup(void) | |||
375 | gpio_direction_output(GPIO_PTS3, 1); | 376 | gpio_direction_output(GPIO_PTS3, 1); |
376 | 377 | ||
377 | /* CEU */ | 378 | /* CEU */ |
378 | clk_always_enable("mstp203"); | ||
379 | gpio_request(GPIO_FN_VIO_CLK2, NULL); | 379 | gpio_request(GPIO_FN_VIO_CLK2, NULL); |
380 | gpio_request(GPIO_FN_VIO_VD2, NULL); | 380 | gpio_request(GPIO_FN_VIO_VD2, NULL); |
381 | gpio_request(GPIO_FN_VIO_HD2, NULL); | 381 | gpio_request(GPIO_FN_VIO_HD2, NULL); |
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c index 95dea1b02565..3684f198cfdf 100644 --- a/arch/sh/boards/mach-migor/setup.c +++ b/arch/sh/boards/mach-migor/setup.c | |||
@@ -433,6 +433,7 @@ static struct resource migor_ceu_resources[] = { | |||
433 | 433 | ||
434 | static struct platform_device migor_ceu_device = { | 434 | static struct platform_device migor_ceu_device = { |
435 | .name = "sh_mobile_ceu", | 435 | .name = "sh_mobile_ceu", |
436 | .id = 0, /* "ceu0" clock */ | ||
436 | .num_resources = ARRAY_SIZE(migor_ceu_resources), | 437 | .num_resources = ARRAY_SIZE(migor_ceu_resources), |
437 | .resource = migor_ceu_resources, | 438 | .resource = migor_ceu_resources, |
438 | .dev = { | 439 | .dev = { |
@@ -554,7 +555,6 @@ static int __init migor_devices_setup(void) | |||
554 | #endif | 555 | #endif |
555 | 556 | ||
556 | /* CEU */ | 557 | /* CEU */ |
557 | clk_always_enable("mstp203"); /* CEU */ | ||
558 | gpio_request(GPIO_FN_VIO_CLK2, NULL); | 558 | gpio_request(GPIO_FN_VIO_CLK2, NULL); |
559 | gpio_request(GPIO_FN_VIO_VD2, NULL); | 559 | gpio_request(GPIO_FN_VIO_VD2, NULL); |
560 | gpio_request(GPIO_FN_VIO_HD2, NULL); | 560 | gpio_request(GPIO_FN_VIO_HD2, NULL); |
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 2407607f2eff..536b1a9b310c 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
33 | #include <linux/videodev2.h> | 33 | #include <linux/videodev2.h> |
34 | #include <linux/clk.h> | ||
34 | 35 | ||
35 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
36 | #include <media/v4l2-dev.h> | 37 | #include <media/v4l2-dev.h> |
@@ -89,6 +90,7 @@ struct sh_mobile_ceu_dev { | |||
89 | 90 | ||
90 | unsigned int irq; | 91 | unsigned int irq; |
91 | void __iomem *base; | 92 | void __iomem *base; |
93 | struct clk *clk; | ||
92 | unsigned long video_limit; | 94 | unsigned long video_limit; |
93 | 95 | ||
94 | /* lock used to protect videobuf */ | 96 | /* lock used to protect videobuf */ |
@@ -309,6 +311,8 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) | |||
309 | if (ret) | 311 | if (ret) |
310 | goto err; | 312 | goto err; |
311 | 313 | ||
314 | clk_enable(pcdev->clk); | ||
315 | |||
312 | ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ | 316 | ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ |
313 | while (ceu_read(pcdev, CSTSR) & 1) | 317 | while (ceu_read(pcdev, CSTSR) & 1) |
314 | msleep(1); | 318 | msleep(1); |
@@ -342,6 +346,8 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) | |||
342 | } | 346 | } |
343 | spin_unlock_irqrestore(&pcdev->lock, flags); | 347 | spin_unlock_irqrestore(&pcdev->lock, flags); |
344 | 348 | ||
349 | clk_disable(pcdev->clk); | ||
350 | |||
345 | icd->ops->release(icd); | 351 | icd->ops->release(icd); |
346 | 352 | ||
347 | dev_info(&icd->dev, | 353 | dev_info(&icd->dev, |
@@ -550,6 +556,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) | |||
550 | struct sh_mobile_ceu_dev *pcdev; | 556 | struct sh_mobile_ceu_dev *pcdev; |
551 | struct resource *res; | 557 | struct resource *res; |
552 | void __iomem *base; | 558 | void __iomem *base; |
559 | char clk_name[8]; | ||
553 | unsigned int irq; | 560 | unsigned int irq; |
554 | int err = 0; | 561 | int err = 0; |
555 | 562 | ||
@@ -615,6 +622,14 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) | |||
615 | goto exit_release_mem; | 622 | goto exit_release_mem; |
616 | } | 623 | } |
617 | 624 | ||
625 | snprintf(clk_name, sizeof(clk_name), "ceu%d", pdev->id); | ||
626 | pcdev->clk = clk_get(&pdev->dev, clk_name); | ||
627 | if (IS_ERR(pcdev->clk)) { | ||
628 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | ||
629 | err = PTR_ERR(pcdev->clk); | ||
630 | goto exit_free_irq; | ||
631 | } | ||
632 | |||
618 | pcdev->ici.priv = pcdev; | 633 | pcdev->ici.priv = pcdev; |
619 | pcdev->ici.dev.parent = &pdev->dev; | 634 | pcdev->ici.dev.parent = &pdev->dev; |
620 | pcdev->ici.nr = pdev->id; | 635 | pcdev->ici.nr = pdev->id; |
@@ -623,10 +638,12 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) | |||
623 | 638 | ||
624 | err = soc_camera_host_register(&pcdev->ici); | 639 | err = soc_camera_host_register(&pcdev->ici); |
625 | if (err) | 640 | if (err) |
626 | goto exit_free_irq; | 641 | goto exit_free_clk; |
627 | 642 | ||
628 | return 0; | 643 | return 0; |
629 | 644 | ||
645 | exit_free_clk: | ||
646 | clk_put(pcdev->clk); | ||
630 | exit_free_irq: | 647 | exit_free_irq: |
631 | free_irq(pcdev->irq, pcdev); | 648 | free_irq(pcdev->irq, pcdev); |
632 | exit_release_mem: | 649 | exit_release_mem: |
@@ -645,6 +662,7 @@ static int sh_mobile_ceu_remove(struct platform_device *pdev) | |||
645 | struct sh_mobile_ceu_dev *pcdev = platform_get_drvdata(pdev); | 662 | struct sh_mobile_ceu_dev *pcdev = platform_get_drvdata(pdev); |
646 | 663 | ||
647 | soc_camera_host_unregister(&pcdev->ici); | 664 | soc_camera_host_unregister(&pcdev->ici); |
665 | clk_put(pcdev->clk); | ||
648 | free_irq(pcdev->irq, pcdev); | 666 | free_irq(pcdev->irq, pcdev); |
649 | if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) | 667 | if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) |
650 | dma_release_declared_memory(&pdev->dev); | 668 | dma_release_declared_memory(&pdev->dev); |