ARM: OMAP: Allow platforms to hook reset cleanly
authorRussell King - ARM Linux <linux@arm.linux.org.uk>
Fri, 28 Jan 2011 00:39:45 +0000 (16:39 -0800)
committerTony Lindgren <tony@atomide.com>
Fri, 28 Jan 2011 00:39:48 +0000 (16:39 -0800)
This adds a clean method to allow platforms to hook into the reset
code if they require to.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap1/Makefile
arch/arm/mach-omap1/board-voiceblue.c
arch/arm/mach-omap1/reset.c [new file with mode: 0644]
arch/arm/mach-omap2/prcm.c
arch/arm/plat-omap/include/plat/prcm.h
arch/arm/plat-omap/include/plat/system.h

index ba6009f2767789040664995803d6f691cad2574a..af98117043d214f8e088e8fd1429656410300a14 100644 (file)
@@ -4,7 +4,7 @@
 
 # Common support
 obj-y := io.o id.o sram.o time.o irq.o mux.o flash.o serial.o devices.o dma.o
-obj-y += clock.o clock_data.o opp_data.o
+obj-y += clock.o clock_data.o opp_data.o reset.o
 
 obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
 
index 815a69ce821de8907af64098c2e74527cc89fb5a..6712817140995861d27dcf72a7c034b512e3d141 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/smc91x.h>
 
 #include <mach/hardware.h>
+#include <mach/system.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -163,52 +164,6 @@ static void __init voiceblue_init_irq(void)
        omap_init_irq();
 }
 
-static void __init voiceblue_init(void)
-{
-       /* mux pins for uarts */
-       omap_cfg_reg(UART1_TX);
-       omap_cfg_reg(UART1_RTS);
-       omap_cfg_reg(UART2_TX);
-       omap_cfg_reg(UART2_RTS);
-       omap_cfg_reg(UART3_TX);
-       omap_cfg_reg(UART3_RX);
-
-       /* Watchdog */
-       gpio_request(0, "Watchdog");
-       /* smc91x reset */
-       gpio_request(7, "SMC91x reset");
-       gpio_direction_output(7, 1);
-       udelay(2);      /* wait at least 100ns */
-       gpio_set_value(7, 0);
-       mdelay(50);     /* 50ms until PHY ready */
-       /* smc91x interrupt pin */
-       gpio_request(8, "SMC91x irq");
-       /* 16C554 reset*/
-       gpio_request(6, "16C554 reset");
-       gpio_direction_output(6, 0);
-       /* 16C554 interrupt pins */
-       gpio_request(12, "16C554 irq");
-       gpio_request(13, "16C554 irq");
-       gpio_request(14, "16C554 irq");
-       gpio_request(15, "16C554 irq");
-       set_irq_type(gpio_to_irq(12), IRQ_TYPE_EDGE_RISING);
-       set_irq_type(gpio_to_irq(13), IRQ_TYPE_EDGE_RISING);
-       set_irq_type(gpio_to_irq(14), IRQ_TYPE_EDGE_RISING);
-       set_irq_type(gpio_to_irq(15), IRQ_TYPE_EDGE_RISING);
-
-       platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
-       omap_board_config = voiceblue_config;
-       omap_board_config_size = ARRAY_SIZE(voiceblue_config);
-       omap_serial_init();
-       omap1_usb_init(&voiceblue_usb_config);
-       omap_register_i2c_bus(1, 100, NULL, 0);
-
-       /* There is a good chance board is going up, so enable power LED
-        * (it is connected through invertor) */
-       omap_writeb(0x00, OMAP_LPG1_LCR);
-       omap_writeb(0x00, OMAP_LPG1_PMR);       /* Disable clock */
-}
-
 static void __init voiceblue_map_io(void)
 {
        omap1_map_common_io();
@@ -275,8 +230,17 @@ void voiceblue_wdt_ping(void)
        gpio_set_value(0, wdt_gpio_state);
 }
 
-void voiceblue_reset(void)
+static void voiceblue_reset(char mode, const char *cmd)
 {
+       /*
+        * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
+        * "Global Software Reset Affects Traffic Controller Frequency".
+        */
+       if (cpu_is_omap5912()) {
+               omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4), DPLL_CTL);
+               omap_writew(0x8, ARM_RSTCT1);
+       }
+
        set_bit(MACHINE_REBOOT, &machine_state);
        voiceblue_wdt_enable();
        while (1) ;
@@ -286,6 +250,54 @@ EXPORT_SYMBOL(voiceblue_wdt_enable);
 EXPORT_SYMBOL(voiceblue_wdt_disable);
 EXPORT_SYMBOL(voiceblue_wdt_ping);
 
+static void __init voiceblue_init(void)
+{
+       /* mux pins for uarts */
+       omap_cfg_reg(UART1_TX);
+       omap_cfg_reg(UART1_RTS);
+       omap_cfg_reg(UART2_TX);
+       omap_cfg_reg(UART2_RTS);
+       omap_cfg_reg(UART3_TX);
+       omap_cfg_reg(UART3_RX);
+
+       /* Watchdog */
+       gpio_request(0, "Watchdog");
+       /* smc91x reset */
+       gpio_request(7, "SMC91x reset");
+       gpio_direction_output(7, 1);
+       udelay(2);      /* wait at least 100ns */
+       gpio_set_value(7, 0);
+       mdelay(50);     /* 50ms until PHY ready */
+       /* smc91x interrupt pin */
+       gpio_request(8, "SMC91x irq");
+       /* 16C554 reset*/
+       gpio_request(6, "16C554 reset");
+       gpio_direction_output(6, 0);
+       /* 16C554 interrupt pins */
+       gpio_request(12, "16C554 irq");
+       gpio_request(13, "16C554 irq");
+       gpio_request(14, "16C554 irq");
+       gpio_request(15, "16C554 irq");
+       set_irq_type(gpio_to_irq(12), IRQ_TYPE_EDGE_RISING);
+       set_irq_type(gpio_to_irq(13), IRQ_TYPE_EDGE_RISING);
+       set_irq_type(gpio_to_irq(14), IRQ_TYPE_EDGE_RISING);
+       set_irq_type(gpio_to_irq(15), IRQ_TYPE_EDGE_RISING);
+
+       platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
+       omap_board_config = voiceblue_config;
+       omap_board_config_size = ARRAY_SIZE(voiceblue_config);
+       omap_serial_init();
+       omap1_usb_init(&voiceblue_usb_config);
+       omap_register_i2c_bus(1, 100, NULL, 0);
+
+       /* There is a good chance board is going up, so enable power LED
+        * (it is connected through invertor) */
+       omap_writeb(0x00, OMAP_LPG1_LCR);
+       omap_writeb(0x00, OMAP_LPG1_PMR);       /* Disable clock */
+
+       arch_reset = voiceblue_reset;
+}
+
 MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
        /* Maintainer: Ladislav Michl <michl@2n.cz> */
        .boot_params    = 0x10000100,
diff --git a/arch/arm/mach-omap1/reset.c b/arch/arm/mach-omap1/reset.c
new file mode 100644 (file)
index 0000000..ad951ee
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * OMAP1 reset support
+ */
+#include <linux/kernel.h>
+#include <linux/io.h>
+
+#include <mach/hardware.h>
+#include <mach/system.h>
+#include <plat/prcm.h>
+
+void omap1_arch_reset(char mode, const char *cmd)
+{
+       /*
+        * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
+        * "Global Software Reset Affects Traffic Controller Frequency".
+        */
+       if (cpu_is_omap5912()) {
+               omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4), DPLL_CTL);
+               omap_writew(0x8, ARM_RSTCT1);
+       }
+
+       omap_writew(1, ARM_RSTCT1);
+}
+
+void (*arch_reset)(char, const char *) = omap1_arch_reset;
index 679bcd28576eca3efc6ad99a3faa57c43988d8f7..6be14389e4f3412a579750f7c056dbec99714d5e 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#include <mach/system.h>
 #include <plat/common.h>
 #include <plat/prcm.h>
 #include <plat/irqs.h>
@@ -57,7 +58,7 @@ u32 omap_prcm_get_reset_sources(void)
 EXPORT_SYMBOL(omap_prcm_get_reset_sources);
 
 /* Resets clock rates and reboots the system. Only called from system.h */
-void omap_prcm_arch_reset(char mode, const char *cmd)
+static void omap_prcm_arch_reset(char mode, const char *cmd)
 {
        s16 prcm_offs = 0;
 
@@ -108,6 +109,8 @@ void omap_prcm_arch_reset(char mode, const char *cmd)
        omap2_prm_read_mod_reg(prcm_offs, OMAP2_RM_RSTCTRL); /* OCP barrier */
 }
 
+void (*arch_reset)(char, const char *) = omap_prcm_arch_reset;
+
 /**
  * omap2_cm_wait_idlest - wait for IDLEST bit to indicate module readiness
  * @reg: physical address of module IDLEST register
index 2fdf8c80d390b2b7b191677d82e996b292921660..267f43bb2a4eaef5c948b752fc64db298b39b18b 100644 (file)
@@ -28,7 +28,6 @@
 #define __ASM_ARM_ARCH_OMAP_PRCM_H
 
 u32 omap_prcm_get_reset_sources(void);
-void omap_prcm_arch_reset(char mode, const char *cmd);
 int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
                         const char *name);
 
index d0a119f735b45d3db8e8a2aa7073f41d188a7a6c..c5fa9e92900947e3ca41be37c4edb397146aa069 100644 (file)
@@ -4,48 +4,14 @@
  */
 #ifndef __ASM_ARCH_SYSTEM_H
 #define __ASM_ARCH_SYSTEM_H
-#include <linux/clk.h>
 
-#include <asm/mach-types.h>
-#include <mach/hardware.h>
-
-#include <plat/prcm.h>
-
-#ifndef CONFIG_MACH_VOICEBLUE
-#define voiceblue_reset()              do {} while (0)
-#else
-extern void voiceblue_reset(void);
-#endif
+#include <asm/proc-fns.h>
 
 static inline void arch_idle(void)
 {
        cpu_do_idle();
 }
 
-static inline void omap1_arch_reset(char mode, const char *cmd)
-{
-       /*
-        * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
-        * "Global Software Reset Affects Traffic Controller Frequency".
-        */
-       if (cpu_is_omap5912()) {
-               omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4),
-                                DPLL_CTL);
-               omap_writew(0x8, ARM_RSTCT1);
-       }
-
-       if (machine_is_voiceblue())
-               voiceblue_reset();
-       else
-               omap_writew(1, ARM_RSTCT1);
-}
-
-static inline void arch_reset(char mode, const char *cmd)
-{
-       if (!cpu_class_is_omap2())
-               omap1_arch_reset(mode, cmd);
-       else
-               omap_prcm_arch_reset(mode, cmd);
-}
+extern void (*arch_reset)(char, const char *);
 
 #endif