ARM: Orion: WDT: Add clk/clkdev support
authorAndrew Lunn <andrew@lunn.ch>
Sun, 4 Mar 2012 15:57:31 +0000 (16:57 +0100)
committerMike Turquette <mturquette@linaro.org>
Tue, 8 May 2012 23:33:57 +0000 (16:33 -0700)
Remove tclk from platform data.  This makes the platform data
structure empty, so remove it.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
arch/arm/mach-kirkwood/common.c
arch/arm/mach-orion5x/common.c
arch/arm/plat-orion/common.c
arch/arm/plat-orion/include/plat/common.h
arch/arm/plat-orion/include/plat/orion_wdt.h [deleted file]
drivers/watchdog/orion_wdt.c

index c223544..880f366 100644 (file)
@@ -112,6 +112,7 @@ void __init kirkwood_clk_init(void)
        orion_clkdev_add(NULL, "orion_spi.1", runit);
        orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", ge0);
        orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", ge1);
+       orion_clkdev_add(NULL, "orion_wdt", tclk);
 }
 
 /*****************************************************************************
@@ -351,7 +352,7 @@ void __init kirkwood_xor1_init(void)
  ****************************************************************************/
 void __init kirkwood_wdt_init(void)
 {
-       orion_wdt_init(kirkwood_tclk);
+       orion_wdt_init();
 }
 
 
index 3fc7318..067bdd7 100644 (file)
@@ -193,7 +193,7 @@ static void __init orion5x_crypto_init(void)
  ****************************************************************************/
 void __init orion5x_wdt_init(void)
 {
-       orion_wdt_init(orion5x_tclk);
+       orion_wdt_init();
 }
 
 
index a33733b..d349998 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/mv643xx_eth.h>
 #include <linux/mv643xx_i2c.h>
 #include <net/dsa.h>
-#include <plat/orion_wdt.h>
 #include <plat/mv_xor.h>
 #include <plat/ehci-orion.h>
 #include <mach/bridge-regs.h>
@@ -47,6 +46,7 @@ void __init orion_clkdev_init(struct clk *tclk)
        orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk);
        orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk);
        orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk);
+       orion_clkdev_add(NULL, "orion_wdt", tclk);
 }
 
 /* Fill in the resources structure and link it into the platform
@@ -575,24 +575,18 @@ void __init orion_spi_1_init(unsigned long mapbase)
 /*****************************************************************************
  * Watchdog
  ****************************************************************************/
-static struct orion_wdt_platform_data orion_wdt_data;
-
 static struct resource orion_wdt_resource =
                DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28);
 
 static struct platform_device orion_wdt_device = {
        .name           = "orion_wdt",
        .id             = -1,
-       .dev            = {
-               .platform_data  = &orion_wdt_data,
-       },
-       .resource       = &orion_wdt_resource,
        .num_resources  = 1,
+       .resource       = &orion_wdt_resource,
 };
 
-void __init orion_wdt_init(unsigned long tclk)
+void __init orion_wdt_init(void)
 {
-       orion_wdt_data.tclk = tclk;
        platform_device_register(&orion_wdt_device);
 }
 
index 00d8761..c3bfa91 100644 (file)
@@ -71,7 +71,7 @@ void __init orion_spi_init(unsigned long mapbase);
 
 void __init orion_spi_1_init(unsigned long mapbase);
 
-void __init orion_wdt_init(unsigned long tclk);
+void __init orion_wdt_init(void);
 
 void __init orion_xor0_init(unsigned long mapbase_low,
                            unsigned long mapbase_high,
diff --git a/arch/arm/plat-orion/include/plat/orion_wdt.h b/arch/arm/plat-orion/include/plat/orion_wdt.h
deleted file mode 100644 (file)
index 665c362..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * arch/arm/plat-orion/include/plat/orion_wdt.h
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#ifndef __PLAT_ORION_WDT_H
-#define __PLAT_ORION_WDT_H
-
-struct orion_wdt_platform_data {
-       u32     tclk;           /* no <linux/clk.h> support yet */
-};
-
-
-#endif
-
index 788aa15..0f57369 100644 (file)
@@ -24,8 +24,8 @@
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/clk.h>
 #include <mach/bridge-regs.h>
-#include <plat/orion_wdt.h>
 
 /*
  * Watchdog timer block registers.
@@ -41,6 +41,7 @@
 static bool nowayout = WATCHDOG_NOWAYOUT;
 static int heartbeat = -1;             /* module parameter (seconds) */
 static unsigned int wdt_max_duration;  /* (seconds) */
+static struct clk *clk;
 static unsigned int wdt_tclk;
 static void __iomem *wdt_reg;
 static unsigned long wdt_status;
@@ -237,16 +238,16 @@ static struct miscdevice orion_wdt_miscdev = {
 
 static int __devinit orion_wdt_probe(struct platform_device *pdev)
 {
-       struct orion_wdt_platform_data *pdata = pdev->dev.platform_data;
        struct resource *res;
        int ret;
 
-       if (pdata) {
-               wdt_tclk = pdata->tclk;
-       } else {
-               pr_err("misses platform data\n");
+       clk = clk_get(&pdev->dev, NULL);
+       if (IS_ERR(clk)) {
+               printk(KERN_ERR "Orion Watchdog missing clock\n");
                return -ENODEV;
        }
+       clk_prepare_enable(clk);
+       wdt_tclk = clk_get_rate(clk);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
@@ -282,6 +283,9 @@ static int __devexit orion_wdt_remove(struct platform_device *pdev)
        if (!ret)
                orion_wdt_miscdev.parent = NULL;
 
+       clk_disable_unprepare(clk);
+       clk_put(clk);
+
        return ret;
 }