Davinci: watchdog reset separation across socs
authorCyril Chemparathy <cyril@ti.com>
Sat, 1 May 2010 22:38:28 +0000 (18:38 -0400)
committerKevin Hilman <khilman@deeprootsystems.com>
Thu, 6 May 2010 22:02:09 +0000 (15:02 -0700)
The earlier watchdog reset mechanism had a couple of limitations.  First, it
embedded a reference to "davinci_wdt_device" inside common code.  This
forced all derived platforms (da8xx and tnetv107x) to define such a device.
This also would have caused problems in including multiple socs in a single
build due to symbol redefinition.

With this patch, davinci_watchdog_reset() now takes the platform device as an
argument.  The davinci_soc_info struct has been extended to include a reset
function and a watchdog platform_device.  arch_reset() then uses these
elements to reset the system in a SoC specific fashion.

Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Tested-by: Sandeep Paulraj <s-paulraj@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
13 files changed:
arch/arm/mach-davinci/clock.h
arch/arm/mach-davinci/common.c
arch/arm/mach-davinci/da830.c
arch/arm/mach-davinci/da850.c
arch/arm/mach-davinci/devices-da8xx.c
arch/arm/mach-davinci/dm355.c
arch/arm/mach-davinci/dm365.c
arch/arm/mach-davinci/dm644x.c
arch/arm/mach-davinci/dm646x.c
arch/arm/mach-davinci/include/mach/common.h
arch/arm/mach-davinci/include/mach/da8xx.h
arch/arm/mach-davinci/include/mach/system.h
arch/arm/mach-davinci/time.c

index ce260153a717ad1fc6402368e6206c587f075008..01e36483ac3d0b4e5e32b768f556982ec20dd713 100644 (file)
@@ -120,6 +120,7 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
                                unsigned int mult, unsigned int postdiv);
 
 extern struct platform_device davinci_wdt_device;
+extern void davinci_watchdog_reset(struct platform_device *);
 
 #endif
 
index 94f27cbcd55af69aeb6580023676c5543892a1cd..f8221c5ee380b9eb66c6ce590094b2063aab1314 100644 (file)
@@ -77,6 +77,9 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info)
        local_flush_tlb_all();
        flush_cache_all();
 
+       if (!davinci_soc_info.reset)
+               davinci_soc_info.reset = davinci_watchdog_reset;
+
        /*
         * We want to check CPU revision early for cpu_is_xxxx() macros.
         * IO space mapping must be initialized before we can do that.
index 68e52337a1d96d77847582f51d9e95190e8a195d..83879f894a2105e8437bf6f87f33b74a21aae532 100644 (file)
@@ -1206,6 +1206,7 @@ static struct davinci_soc_info davinci_soc_info_da830 = {
        .gpio_irq               = IRQ_DA8XX_GPIO0,
        .serial_dev             = &da8xx_serial_device,
        .emac_pdata             = &da8xx_emac_pdata,
+       .reset_device           = &da8xx_wdt_device,
 };
 
 void __init da830_init(void)
index 8aefcffa5ae22305981b972b036801ce99984ccc..2b6dd59d72f2d20877c56e8bcde116d4887e1e92 100644 (file)
@@ -1093,6 +1093,7 @@ static struct davinci_soc_info davinci_soc_info_da850 = {
        .emac_pdata             = &da8xx_emac_pdata,
        .sram_dma               = DA8XX_ARM_RAM_BASE,
        .sram_len               = SZ_8K,
+       .reset_device           = &da8xx_wdt_device,
 };
 
 void __init da850_init(void)
index 0a96791d3b0f6dd8238c4e0826f3f452b3905477..67a6fbcb2e095c5ca1494ff0e21f046de596181d 100644 (file)
@@ -326,7 +326,7 @@ static struct resource da8xx_watchdog_resources[] = {
        },
 };
 
-struct platform_device davinci_wdt_device = {
+struct platform_device da8xx_wdt_device = {
        .name           = "watchdog",
        .id             = -1,
        .num_resources  = ARRAY_SIZE(da8xx_watchdog_resources),
@@ -335,7 +335,7 @@ struct platform_device davinci_wdt_device = {
 
 int __init da8xx_register_watchdog(void)
 {
-       return platform_device_register(&davinci_wdt_device);
+       return platform_device_register(&da8xx_wdt_device);
 }
 
 static struct resource da8xx_emac_resources[] = {
index f91e9a1ab9212829e9bff3f3aea0934a34252acd..0c62a68a90a389b018731cf450276d28bce4e785 100644 (file)
@@ -861,6 +861,7 @@ static struct davinci_soc_info davinci_soc_info_dm355 = {
        .serial_dev             = &dm355_serial_device,
        .sram_dma               = 0x00010000,
        .sram_len               = SZ_32K,
+       .reset_device           = &davinci_wdt_device,
 };
 
 void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata)
index f2b1d93b2256ccf0d9918e61e8e40cc69ba8d19c..ed7645088052abeb21641f54194ff94f15295287 100644 (file)
@@ -1068,6 +1068,7 @@ static struct davinci_soc_info davinci_soc_info_dm365 = {
        .emac_pdata             = &dm365_emac_pdata,
        .sram_dma               = 0x00010000,
        .sram_len               = SZ_32K,
+       .reset_device           = &davinci_wdt_device,
 };
 
 void __init dm365_init_asp(struct snd_platform_data *pdata)
index 85c88ecd6cf06e98f78a6bcd7efdd584e325dfa4..7f36c22a2684e372c31f195bbb4107e7632cf72f 100644 (file)
@@ -753,6 +753,7 @@ static struct davinci_soc_info davinci_soc_info_dm644x = {
        .emac_pdata             = &dm644x_emac_pdata,
        .sram_dma               = 0x00008000,
        .sram_len               = SZ_16K,
+       .reset_device           = &davinci_wdt_device,
 };
 
 void __init dm644x_init_asp(struct snd_platform_data *pdata)
index a8189c919e927c33a0aac3ab549ee440cd5aeaab..8dd0afee75939ef97211769dafa50e580efaa015 100644 (file)
@@ -837,6 +837,7 @@ static struct davinci_soc_info davinci_soc_info_dm646x = {
        .emac_pdata             = &dm646x_emac_pdata,
        .sram_dma               = 0x10010000,
        .sram_len               = SZ_32K,
+       .reset_device           = &davinci_wdt_device,
 };
 
 void __init dm646x_init_mcasp0(struct snd_platform_data *pdata)
index 8ffef5bbd9cf0a483a4f7046d4ca1250226ea1dd..a58bd88ba02d4761a60164bf43114c7cc255e18e 100644 (file)
@@ -70,6 +70,8 @@ struct davinci_soc_info {
        struct emac_platform_data       *emac_pdata;
        dma_addr_t                      sram_dma;
        unsigned                        sram_len;
+       struct platform_device          *reset_device;
+       void                            (*reset)(struct platform_device *);
 };
 
 extern struct davinci_soc_info davinci_soc_info;
index dbb4ebe4d114aabe064a281083130777f5da4dc9..1b31a9aa8fba088827c56586befca0297f2e702a 100644 (file)
@@ -87,6 +87,8 @@ extern struct emac_platform_data da8xx_emac_pdata;
 extern struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata;
 extern struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata;
 
+extern struct platform_device da8xx_wdt_device;
+
 extern const short da830_emif25_pins[];
 extern const short da830_spi0_pins[];
 extern const short da830_spi1_pins[];
index 5a7d7581b8cee0de932eed96e29a128c9a7d9dbe..e65629c20769047ec4900d89f3bee1e09ac552fc 100644 (file)
@@ -11,7 +11,7 @@
 #ifndef __ASM_ARCH_SYSTEM_H
 #define __ASM_ARCH_SYSTEM_H
 
-extern void davinci_watchdog_reset(void);
+#include <mach/common.h>
 
 static inline void arch_idle(void)
 {
@@ -20,7 +20,8 @@ static inline void arch_idle(void)
 
 static inline void arch_reset(char mode, const char *cmd)
 {
-       davinci_watchdog_reset();
+       if (davinci_soc_info.reset)
+               davinci_soc_info.reset(davinci_soc_info.reset_device);
 }
 
 #endif /* __ASM_ARCH_SYSTEM_H */
index b21f7633d9a8e05953e7b611e2df345540c3e74b..e5c598a387bedc4f4d0c8512934056a88e8af8b3 100644 (file)
@@ -399,13 +399,16 @@ struct sys_timer davinci_timer = {
 
 
 /* reset board using watchdog timer */
-void davinci_watchdog_reset(void)
+void davinci_watchdog_reset(struct platform_device *pdev)
 {
        u32 tgcr, wdtcr;
-       struct platform_device *pdev = &davinci_wdt_device;
-       void __iomem *base = IO_ADDRESS(pdev->resource[0].start);
+       void __iomem *base;
        struct clk *wd_clk;
 
+       base = ioremap(pdev->resource[0].start, SZ_4K);
+       if (WARN_ON(!base))
+               return;
+
        wd_clk = clk_get(&pdev->dev, NULL);
        if (WARN_ON(IS_ERR(wd_clk)))
                return;