Make msp7120_reset generic
PATCH 1/1 Make msp7120_reset generic
From: Anoop P A <[email protected]>
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.
--- arch/mips/pmc-sierra/msp71xx/msp_setup.c | 85 ++++++++++++++++++------------ 1 files changed, 52 insertions(+), 33 deletions(-)
arch/mips/pmc-sierra/msp71xx/msp_setup.c +52 -33
@@ -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; registerint i; + registeru32 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 definedMSP_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);
Signature · 1 line
1.7.0.4
Hello.
Quoted 6 lines · Anoop P.A
From: Anoop P A<[email protected]>
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<[email protected]>
[...]
Quoted 5 lines
arch/mips/pmc-sierra/msp71xx/msp_setup.c +0
-0
arch/mips/pmc-sierra/msp71xx/msp_setup.c line 25
Quoted 9 lines
arch/mips/pmc-sierra/msp71xx/msp_setup.c +3
-1@@ -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 +*/
Not clear why you're using a multi-line comment where a single-one line
one (and not indented) would be enough?
arch/mips/pmc-sierra/msp71xx/msp_setup.c void msp7120_reset(void) · line 84
Quoted 6 lines
arch/mips/pmc-sierra/msp71xx/msp_setup.c +1
-1@@ -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 definedMSP_BOARD_RESET_GPIO
Hm, didn't know that the 'defined' syntax without parens is valid too...
arch/mips/pmc-sierra/msp71xx/msp_setup.c void msp_power_off(void) · line 154
Quoted 8 lines
arch/mips/pmc-sierra/msp71xx/msp_setup.c +1
-3@@ -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 */
This line should be indented.
WBR, Sergei
PATCH RESEND 1/1 Make msp7120_reset generic
From: Anoop P A <[email protected]>
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.
---
Fixing comments indentations as suggested by sergei
arch/mips/pmc-sierra/msp71xx/msp_setup.c | 84 ++++++++++++++++++------------ 1 files changed, 51 insertions(+), 33 deletions(-)
arch/mips/pmc-sierra/msp71xx/msp_setup.c +51 -33
@@ -18,30 +18,32 @@#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; registerint i; + registeru32 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 +80,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 +150,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 +251,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);
Signature · 1 line
1.7.0.4