[PATCH] Make msp7120_reset generic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Anoop P A <anoop.pa@xxxxxxxxx>

Remove platform dependency code from msp7120 reset code and make it generic.
Now the code can be reused for other boards running msp71xx family SoC.

Signed-off-by: Anoop P A <anoop.pa@xxxxxxxxx>
---
 arch/mips/pmc-sierra/msp71xx/msp_setup.c |   85 ++++++++++++++++++------------
 1 files changed, 52 insertions(+), 33 deletions(-)

diff --git a/arch/mips/pmc-sierra/msp71xx/msp_setup.c b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
index fb37a10..4a6cc0d 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_setup.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
@@ -18,30 +18,33 @@
 
 #include <msp_prom.h>
 #include <msp_regs.h>
+#include <msp_gpio_macros.h>
 
 #if defined(CONFIG_PMC_MSP7120_GW)
-#include <msp_regops.h>
+	/* GPIO 9 is the 4th GPIO of register 3
+	 */
 #define MSP_BOARD_RESET_GPIO	9
+#else
+#undef MSP_BOARD_RESET_GPIO
 #endif
 
 extern void msp_serial_setup(void);
 extern void pmctwiled_setup(void);
 
-#if defined(CONFIG_PMC_MSP7120_EVAL) || \
-    defined(CONFIG_PMC_MSP7120_GW) || \
-    defined(CONFIG_PMC_MSP7120_FPGA)
 /*
- * Performs the reset for MSP7120-based boards
+ * Performs the reset for MSP71xx-based boards
  */
-void msp7120_reset(void)
+void msp71xx_reset(void)
 {
 	void *start, *end, *iptr;
 	register int i;
+	register u32 temp __maybe_unused;
 
 	/* Diasble all interrupts */
 	local_irq_disable();
 #ifdef CONFIG_SYS_SUPPORTS_MULTITHREADING
 	dvpe();
+	dmt();
 #endif
 
 	/* Cache the reset code of this function */
@@ -78,49 +81,56 @@ void msp7120_reset(void)
 	/* Wait a bit for the DDRC to settle */
 	for (i = 0; i < 100000000; i++);
 
-#if defined(CONFIG_PMC_MSP7120_GW)
+#if defined MSP_BOARD_RESET_GPIO
 	/*
-	 * Set GPIO 9 HI, (tied to board reset logic)
-	 * GPIO 9 is the 4th GPIO of register 3
+	 * Set reset GPIO  HI, (tied to board reset logic)
 	 *
 	 * NOTE: We cannot use the higher-level msp_gpio_mode()/out()
 	 * as GPIO char driver may not be enabled and it would look up
 	 * data inRAM!
 	 */
-	set_value_reg32(GPIO_CFG3_REG, 0xf000, 0x8000);
-	set_reg32(GPIO_DATA3_REG, 8);
+	temp = __raw_readl(MSP_GPIO_MODE_REGISTER[MSP_BOARD_RESET_GPIO]) &
+					~BASIC_MODE_MASK(MSP_BOARD_RESET_GPIO);
+	__raw_writel(temp | BASIC_MODE(MSP_GPIO_OUTPUT, MSP_BOARD_RESET_GPIO),
+				MSP_GPIO_MODE_REGISTER[MSP_BOARD_RESET_GPIO]);
+	/* Now set the reset gpio pin hi */
+	temp = __raw_readl(MSP_GPIO_DATA_REGISTER[MSP_BOARD_RESET_GPIO]);
+	__raw_writel(temp | BASIC_DATA_MASK(MSP_BOARD_RESET_GPIO),
+			MSP_GPIO_DATA_REGISTER[MSP_BOARD_RESET_GPIO]);
 
 	/*
-	 * In case GPIO9 doesn't reset the board (jumper configurable!)
+	 * In case GPIO doesn't reset the board (jumper configurable!)
 	 * fallback to device reset below.
 	 */
 #endif
-	/* Set bit 1 of the MSP7120 reset register */
-	*RST_SET_REG = 0x00000001;
+	/* Set bit 1 of the MSP71xx reset register */
+	__raw_writel(0x00000001, RST_SET_REG);
 
 	__asm__ __volatile__ (
-		"endpoint:					\n"
+		"endpoint:\n"
 	);
 }
-#endif
 
 void msp_restart(char *command)
 {
-	printk(KERN_WARNING "Now rebooting .......\n");
-
-#if defined(CONFIG_PMC_MSP7120_EVAL) || \
-    defined(CONFIG_PMC_MSP7120_GW) || \
-    defined(CONFIG_PMC_MSP7120_FPGA)
-	msp7120_reset();
-#else
-	/* No chip-specific reset code, just jump to the ROM reset vector */
-	set_c0_status(ST0_BEV | ST0_ERL);
-	change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
-	flush_cache_all();
-	write_c0_wired(0);
 
-	__asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
-#endif
+	unsigned long family = identify_family();
+	switch (family)	{
+	case FAMILY_MSP7100:
+		msp71xx_reset();
+		break;
+	default:
+		/* No chip-specific reset code, just jump
+		 * to the ROM reset vector
+		 */
+		set_c0_status(ST0_BEV | ST0_ERL);
+		change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
+		flush_cache_all();
+		write_c0_wired(0);
+
+		__asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000));
+		break;
+	}
 }
 
 void msp_halt(void)
@@ -141,9 +151,7 @@ void msp_power_off(void)
 
 void __init plat_mem_setup(void)
 {
-	_machine_restart = msp_restart;
-	_machine_halt = msp_halt;
-	pm_power_off = msp_power_off;
+/*TODO: Move mem setup here */
 }
 
 extern struct plat_smp_ops msp_smtc_smp_ops;
@@ -244,3 +252,14 @@ void __init prom_init(void)
 	pmctwiled_setup();
 #endif
 }
+
+static int __init mips_reboot_setup(void)
+{
+	_machine_restart = msp_restart;
+	_machine_halt = msp_halt;
+	pm_power_off = msp_power_off;
+
+	return 0;
+}
+
+arch_initcall(mips_reboot_setup);
-- 
1.7.0.4




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux