]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: McSPI: handle clock enable / disable in omap2_mcspi
authorImre Deak <imre.deak@solidboot.com>
Wed, 14 Jun 2006 17:42:47 +0000 (20:42 +0300)
committerJuha Yrjola <juha.yrjola@solidboot.com>
Wed, 14 Jun 2006 17:42:47 +0000 (20:42 +0300)
Enable / disable the mcspi_ick and mcspi_fck clocks in omap2_mcspi_probe
and omap2_mcspi_remove respectively.

Drop the ref count on the class device in omap2_mcspi_remove.

Change the clock names for mcspi_ick[123] and mcspi_fck[123] to mcspi_ick
and mcspi_fck, use instead the clk.id field for the bus id.

Signed-off-by: Imre Deak <imre.deak@solidboot.com>
Signed-off-by: Juha Yrjola <juha.yrjola@solidboot.com>
arch/arm/mach-omap2/clock.h
drivers/spi/omap2_mcspi.c

index 2781dfbc51644815f778e84b047fc3d02eac0525..971743a090a3e15594e26f8f9c25ba5c527e9f32 100644 (file)
@@ -1368,7 +1368,8 @@ static struct clk mcbsp5_fck = {
 };
 
 static struct clk mcspi1_ick = {
-       .name           = "mcspi1_ick",
+       .name           = "mcspi_ick",
+       .id             = 1,
        .parent         = &l4_ck,
        .flags          = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_ICLKEN1_CORE,
@@ -1377,7 +1378,8 @@ static struct clk mcspi1_ick = {
 };
 
 static struct clk mcspi1_fck = {
-       .name           = "mcspi1_fck",
+       .name           = "mcspi_fck",
+       .id             = 1,
        .parent         = &func_48m_ck,
        .flags          = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_FCLKEN1_CORE,
@@ -1386,7 +1388,8 @@ static struct clk mcspi1_fck = {
 };
 
 static struct clk mcspi2_ick = {
-       .name           = "mcspi2_ick",
+       .name           = "mcspi_ick",
+       .id             = 2,
        .parent         = &l4_ck,
        .flags          = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_ICLKEN1_CORE,
@@ -1395,7 +1398,8 @@ static struct clk mcspi2_ick = {
 };
 
 static struct clk mcspi2_fck = {
-       .name           = "mcspi2_fck",
+       .name           = "mcspi_fck",
+       .id             = 2,
        .parent         = &func_48m_ck,
        .flags          = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_FCLKEN1_CORE,
@@ -1404,7 +1408,8 @@ static struct clk mcspi2_fck = {
 };
 
 static struct clk mcspi3_ick = {
-       .name           = "mcspi3_ick",
+       .name           = "mcspi_ick",
+       .id             = 3,
        .parent         = &l4_ck,
        .flags          = CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_ICLKEN2_CORE,
@@ -1413,7 +1418,8 @@ static struct clk mcspi3_ick = {
 };
 
 static struct clk mcspi3_fck = {
-       .name           = "mcspi3_fck",
+       .name           = "mcspi_fck",
+       .id             = 3,
        .parent         = &func_48m_ck,
        .flags          = CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_FCLKEN2_CORE,
index 8b70d3821faa61cbce6498ac2871911b79bc80fd..336f5c58a5649282555a6bb18c3a4d5f0ebb45dd 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/clk.h>
 
 #include <linux/spi/spi.h>
 
@@ -84,6 +86,8 @@ struct omap2_mcspi {
        spinlock_t              lock;
        struct list_head        msg_queue;
        struct spi_master       *master;
+       struct clk              *ick;
+       struct clk              *fck;
 };
 
 struct omap2_mcspi_cs {
@@ -456,7 +460,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
                return -EINVAL;
 
        master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
-       if (!master) {
+       if (master == NULL) {
                dev_err(&pdev->dev, "master allocation failed\n");
                return -ENOMEM;
        }
@@ -485,28 +489,56 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
        spin_lock_init(&mcspi->lock);
        INIT_LIST_HEAD(&mcspi->msg_queue);
 
+       mcspi->ick = clk_get(&pdev->dev, "mcspi_ick");
+       if (IS_ERR(mcspi->ick)) {
+               dev_err(&pdev->dev, "can't get mcspi_ick\n");
+               status = PTR_ERR(mcspi->ick);
+               goto err1;
+       }
+       clk_enable(mcspi->ick);
+       mcspi->fck = clk_get(&pdev->dev, "mcspi_fck");
+       if (IS_ERR(mcspi->fck)) {
+               dev_err(&pdev->dev, "can't get mcspi_fck\n");
+               status = PTR_ERR(mcspi->fck);
+               goto err2;
+       }
+       clk_enable(mcspi->fck);
+
        if (omap2_mcspi_reset(master) < 0)
-                goto err1;
+                goto err3;
 
        status = spi_register_master(master);
        if (status < 0)
-               goto err1;
+               goto err3;
 
        return status;
 
- err1:
+err3:
+       clk_disable(mcspi->fck);
+       clk_put(mcspi->fck);
+err2:
+       clk_disable(mcspi->ick);
+       clk_put(mcspi->ick);
+err1:
        class_device_put(&master->cdev);
- err0:
+err0:
        return status;
 }
 
 static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 {
        struct spi_master               *master;
+       struct omap2_mcspi              *mcspi;
 
        master = dev_get_drvdata(&pdev->dev);
 
        spi_unregister_master(master);
+       mcspi = class_get_devdata(&master->cdev);
+       clk_disable(mcspi->fck);
+       clk_put(mcspi->fck);
+       clk_disable(mcspi->ick);
+       clk_put(mcspi->ick);
+       class_device_put(&master->cdev);
 
        return 0;
 }