From c5c01c9700e59a5b20d7bdd15808d33ab9d9e877 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Fri, 19 Oct 2007 04:44:14 +1000 Subject: [POWERPC] Add mpc52xx_find_and_map_path(), refactor utility functions Add helper routine mpc52xx_find_and_map_path(). Extract common code to mpc52xx_map_node() and refactor mpc52xx_find_and_map(). Signed-off-by: Jan Wrobel Signed-off-by: Grant Likely --- arch/powerpc/platforms/52xx/mpc52xx_common.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'arch/powerpc/platforms') diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index 3bc201e07e6b..74b4b4183842 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -19,14 +19,12 @@ #include -void __iomem * -mpc52xx_find_and_map(const char *compatible) +static void __iomem * +mpc52xx_map_node(struct device_node *ofn) { - struct device_node *ofn; const u32 *regaddr_p; u64 regaddr64, size64; - ofn = of_find_compatible_node(NULL, NULL, compatible); if (!ofn) return NULL; @@ -42,8 +40,23 @@ mpc52xx_find_and_map(const char *compatible) return ioremap((u32)regaddr64, (u32)size64); } + +void __iomem * +mpc52xx_find_and_map(const char *compatible) +{ + return mpc52xx_map_node( + of_find_compatible_node(NULL, NULL, compatible)); +} + EXPORT_SYMBOL(mpc52xx_find_and_map); +void __iomem * +mpc52xx_find_and_map_path(const char *path) +{ + return mpc52xx_map_node(of_find_node_by_path(path)); +} + +EXPORT_SYMBOL(mpc52xx_find_and_map_path); /** * mpc52xx_find_ipb_freq - Find the IPB bus frequency for a device -- cgit v1.2.3-59-g8ed1b From 86b92cdda9e997dd305851cb16292c67076d58cb Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Fri, 19 Oct 2007 04:44:33 +1000 Subject: [POWERPC] Add restart support for mpc52xx based platforms Add common helper routines: mpc52xx_map_wdt() and mpc52xx_restart(). Signed-off-by: Marian Balakowicz Signed-off-by: Sascha Hauer Signed-off-by: Grant Likely --- arch/powerpc/platforms/52xx/mpc52xx_common.c | 50 ++++++++++++++++++++++++++++ include/asm-powerpc/mpc52xx.h | 3 ++ 2 files changed, 53 insertions(+) (limited to 'arch/powerpc/platforms') diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index 74b4b4183842..9850685c5429 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c @@ -18,6 +18,13 @@ #include #include +/* + * This variable is mapped in mpc52xx_map_wdt() and used in mpc52xx_restart(). + * Permanent mapping is required because mpc52xx_restart() can be called + * from interrupt context while node mapping (which calls ioremap()) + * cannot be used at such point. + */ +static volatile struct mpc52xx_gpt *mpc52xx_wdt = NULL; static void __iomem * mpc52xx_map_node(struct device_node *ofn) @@ -126,3 +133,46 @@ mpc52xx_declare_of_platform_devices(void) "Error while probing of_platform bus\n"); } +void __init +mpc52xx_map_wdt(void) +{ + const void *has_wdt; + struct device_node *np; + + /* mpc52xx_wdt is mapped here and used in mpc52xx_restart, + * possibly from a interrupt context. wdt is only implement + * on a gpt0, so check has-wdt property before mapping. + */ + for_each_compatible_node(np, NULL, "fsl,mpc5200-gpt") { + has_wdt = of_get_property(np, "fsl,has-wdt", NULL); + if (has_wdt) { + mpc52xx_wdt = mpc52xx_map_node(np); + return; + } + } + for_each_compatible_node(np, NULL, "mpc5200-gpt") { + has_wdt = of_get_property(np, "has-wdt", NULL); + if (has_wdt) { + mpc52xx_wdt = mpc52xx_map_node(np); + return; + } + } +} + +void +mpc52xx_restart(char *cmd) +{ + local_irq_disable(); + + /* Turn on the watchdog and wait for it to expire. + * It effectively does a reset. */ + if (mpc52xx_wdt) { + out_be32(&mpc52xx_wdt->mode, 0x00000000); + out_be32(&mpc52xx_wdt->count, 0x000000ff); + out_be32(&mpc52xx_wdt->mode, 0x00009004); + } else + printk("mpc52xx_restart: Can't access wdt. " + "Restart impossible, system halted.\n"); + + while (1); +} diff --git a/include/asm-powerpc/mpc52xx.h b/include/asm-powerpc/mpc52xx.h index 8e428466a60f..fcb2ebbfddbc 100644 --- a/include/asm-powerpc/mpc52xx.h +++ b/include/asm-powerpc/mpc52xx.h @@ -259,6 +259,9 @@ extern unsigned int mpc52xx_get_irq(void); extern int __init mpc52xx_add_bridge(struct device_node *node); +extern void __init mpc52xx_map_wdt(void); +extern void mpc52xx_restart(char *cmd); + #endif /* __ASSEMBLY__ */ #ifdef CONFIG_PM -- cgit v1.2.3-59-g8ed1b From 9dda78b711ca4d507251a7e896b2f41ec019fc58 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Fri, 19 Oct 2007 04:44:39 +1000 Subject: [POWERPC] Enable restart support for lite5200 board Use the watchdog timer to implement board restart support. Signed-off-by: Marian Balakowicz Signed-off-by: Grant Likely --- arch/powerpc/platforms/52xx/lite5200.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch/powerpc/platforms') diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c index 65b7ae426238..25d2bfa3d9dc 100644 --- a/arch/powerpc/platforms/52xx/lite5200.c +++ b/arch/powerpc/platforms/52xx/lite5200.c @@ -145,6 +145,9 @@ static void __init lite5200_setup_arch(void) /* Some mpc5200 & mpc5200b related configuration */ mpc5200_setup_xlb_arbiter(); + /* Map wdt for mpc52xx_restart() */ + mpc52xx_map_wdt(); + #ifdef CONFIG_PM mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare; mpc52xx_suspend.board_resume_finish = lite5200_resume_finish; @@ -183,5 +186,6 @@ define_machine(lite5200) { .init = mpc52xx_declare_of_platform_devices, .init_IRQ = mpc52xx_init_irq, .get_irq = mpc52xx_get_irq, + .restart = mpc52xx_restart, .calibrate_decr = generic_calibrate_decr, }; -- cgit v1.2.3-59-g8ed1b