OMAP3: Clean up EVM board file
- Use readx/writex instead of direct pointer access
- Replace hardcoded values by macros
- Minor space to tab conversion
Notes:
- Instead of read/modify/write GPIO_DATAOUT register use SET/CLEARDATAOUT register for GPIO64
- GPIO 1-6 CM_FCLKEN_PER and CM_ICLKEN_PER are already configured in per_clocks_enable(), remove it here
- Remove pin mux. Is done in set_muxconf_regs.
No functional change.
--- board/omap3/evm/evm.c | 143 +++++++++---------------------------- board/omap3/evm/evm.h | 64 ++++++++-------- include/asm-arm/arch-omap3/cpu.h | 2 include/asm-arm/arch-omap3/mem.h | 8 ++ include/asm-arm/arch-omap3/omap3.h | 1 5 files changed, 78 insertions(+), 140 deletions(-)
board/omap3/evm/evm.c +35 -108
@@ -3,12 +3,11 @@* Texas Instruments, <www.ti.com> * * Author : -* Manikandan Pillai <[email protected]> +* Manikandan Pillai <[email protected]> * * Derived from Beagle Board and 3430 SDP code by -* Richard Woodruff <[email protected]> -* Syed Mohammed Khasim <[email protected]> -* +* Richard Woodruff <[email protected]> +* Syed Mohammed Khasim <[email protected]> * * See file CREDITS for list of people who contributed to this * project.
@@ -30,6 +29,7 @@*/ #include <common.h> #include <asm/io.h> +#include <asm/arch/mem.h> #include <asm/arch/mux.h> #include <asm/arch/sys_proto.h> #include <i2c.h>
@@ -74,8 +74,8 @@ int misc_init_r(void)/****************************************************************************** * Routine: set_muxconf_regs * Description: Setting up the configuration Mux registers specific to the -* hardware. Many pins need to be moved from protect to primary -* mode. +* hardware. Many pins need to be moved from protect to primary +* mode. *****************************************************************************/ void set_muxconf_regs (void ) {
@@ -85,115 +85,42 @@ void set_muxconf_regs(void)/****************************************************************************** * Routine: setup_net_chip * Description: Setting up the configuration GPMC registers specific to the -* Ethernet hardware. Pin Muxing for the SMC9118 is initialized -* here. +* Ethernet hardware. *****************************************************************************/ -static int setup_net_chip (void ) +static void setup_net_chip (void ) { -int i =0 ; +unsigned int *gpio3_base = (unsigned int *)OMAP34XX_GPIO3_BASE ; +unsigned int *gpmc_cs6_base = (unsigned int *)GPMC_CONFIG_CS6_BASE ; +unsigned short *ctrl_base = (unsigned short *)OMAP34XX_CTRL_BASE ;/* Configure GPMC registers */ - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x0150 )) =0x00001000 ; - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x0154 )) =0x001e1e01 ; - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x0158 )) =0x00080300 ; - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x015C )) =0x1c091c09 ; - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x0160 )) =0x04181f1f ; - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x0164 )) =0x00000FCF ; - (*(volatile int *)(OMAP34XX_GPMC_BASE +0x0168 )) =0x00000f6c ; - -/* -* Configure PIN MUX registers -* Enable GPMC Pin Mux Registers -* Enable GPMC_CLK Pin in CONTROL_PADCONF_gpmc_ncs7 register -*/ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xBC )) |=0x00180000 ; -/* Enable CS5 Pin in CONTROL_PADCONF_gpmc_ncs5 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xB8 )) |=0x00000018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xB8 )) &=0xFFFFFFF8 ; -/* Enable offmode for nwe in CONTROL_PADCONF_GPMC_NWE register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xC4 )) |=0x00000F00 ; -/* En off mode for noe and ale in CONTROL_PADCONF_GPMC_NADV_ALE reg */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xC0 )) |=0x0E000E00 ; -/* Enable gpmc_nbe0_cle in CONTROL_PADCONF_GPMC_NWE register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xC4 )) |=0x00180000 ; - -/* -* Enable gpmc_nbe1 in CONTROL_PADCONF_GPMC_NBE1 register and -* configuring the mux mode to 0 -*/ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xC8 )) |=0x00000018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xC8 )) &=0xFFFFFFF8 ; -/* Enable d15 in CONTROL_PADCONF_GPMC_D15 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xAC )) |=0x00000018 ; -/* Enable d14 - d13 in CONTROL_PADCONF_GPMC_D13 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xA8 )) |=0x00180018 ; -/* Enable d12 - d11 in CONTROL_PADCONF_GPMC_D11 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xA4 )) |=0x00180018 ; -/* Enable d10 - d9 in CONTROL_PADCONF_GPMC_D9 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xA0 )) |=0x00180018 ; -/* Enable d8 - d7 in CONTROL_PADCONF_GPMC_D7 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x9C )) |=0x00180018 ; -/* Enable d6 - d5 in CONTROL_PADCONF_GPMC_D5 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x98 )) |=0x00180018 ; -/* Enable d4 - d3 in CONTROL_PADCONF_GPMC_D3 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x94 )) |=0x00180018 ; -/* Enable d2 - d1 in CONTROL_PADCONF_GPMC_D1 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x90 )) |=0x00180018 ; -/* Enable d0 and a10 in CONTROL_PADCONF_GPMC_a10 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x8C )) |=0x00180018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x8C )) &=0xFFFFFFF8 ; -/* Enable a9 - a8 in CONTROL_PADCONF_GPMC_a8 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x88 )) |=0x00180018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x88 )) &=0xFFF8FFF8 ; -/* Enable a7 - a6 in CONTROL_PADCONF_GPMC_a6 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x84 )) |=0x00180018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x84 )) &=0xFFF8FFF8 ; -/* Enable a5 - a4 in CONTROL_PADCONF_GPMC_a4 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x80 )) |=0x00180018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x80 )) &=0xFFF8FFF8 ; -/* Enable a3 - a2 in CONTROL_PADCONF_GPMC_a2 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x7C )) |=0x00180018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x7C )) &=0xFFF8FFF8 ; -/* Enable a1 - a0 in CONTROL_PADCONF_GPMC_a0 register */ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x78 )) |=0x00000018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x78 )) &=0xFFFFFFF8 ; - -#if defined(CPU_3430_ES1 ) || defined(CPU_3430_ES2 ) -/* -* GPIO 64 configuration in CONTROL_PADCONF_GPMC_WAIT2 -* register mux mode is 4. -*/ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xD0 )) |=0x00000018 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xD0 )) &=0xFFFFFFF8 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0xD0 )) |=0x00000004 ; - -/* -* Configure GPIO 176 in CONTROL_PADCONF_MCSPI1_CS1 -* register for ethernet ISR mux mode is 4 -*/ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x1D0 )) |=0x00180000 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x1D0 )) &=0xFFF8FFFF ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x1D0 )) |=0x00040000 ; - -/* -* Enable Clock for GPIO 1-6 module in CM_FCLKEN_PER -* and CM_ICLKEN_PER registers -*/ - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x5000 )) |=0x0003E800 ; - (*(volatile int *)(OMAP34XX_CTRL_BASE +0x5010 )) |=0x0003E800 ; +writel (NET_GPMC_CONFIG1 , gpmc_cs6_base +OFFS (GPMC_CONFIG1 )); +writel (NET_GPMC_CONFIG2 , gpmc_cs6_base +OFFS (GPMC_CONFIG2 )); +writel (NET_GPMC_CONFIG3 , gpmc_cs6_base +OFFS (GPMC_CONFIG3 )); +writel (NET_GPMC_CONFIG4 , gpmc_cs6_base +OFFS (GPMC_CONFIG4 )); +writel (NET_GPMC_CONFIG5 , gpmc_cs6_base +OFFS (GPMC_CONFIG5 )); +writel (NET_GPMC_CONFIG6 , gpmc_cs6_base +OFFS (GPMC_CONFIG6 )); +writel (NET_GPMC_CONFIG7 , gpmc_cs6_base +OFFS (GPMC_CONFIG7 )); + +/* Enable off mode for NWE in PADCONF_GPMC_NWE register */ +writew (readw (ctrl_base + (CONTROL_PADCONF_GPMC_NWE >>1 )) |0x0E00 , + ctrl_base + (CONTROL_PADCONF_GPMC_NWE >>1 )); +/* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ +writew (readw (ctrl_base + (CONTROL_PADCONF_GPMC_NOE >>1 )) |0x0E00 , + ctrl_base + (CONTROL_PADCONF_GPMC_NOE >>1 )); +/* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ +writew (readw (ctrl_base + (CONTROL_PADCONF_GPMC_NADV_ALE >>1 )) |0x0E00 , + ctrl_base + (CONTROL_PADCONF_GPMC_NADV_ALE >>1 ));/* Make GPIO 64 as output pin */ - (*(volatile int *)(OMAP34XX_GPIO3_BASE +0x34 )) &= ~(0x00000001 ); +writel (readl (gpio3_base +OFFS (GPIO_OE )) & ~(GPIO0 ), + gpio3_base +OFFS (GPIO_OE ));/* Now send a pulse on the GPIO pin */ - (*(volatile int *)(OMAP34XX_GPIO3_BASE +0x3C )) |=0x00000001 ; -for (i =0 ; i <99 ; i++); - (*(volatile int *)(OMAP34XX_GPIO3_BASE +0x3C )) &= ~(0x00000001 ); -for (i =0 ; i <99 ; i++); - (*(volatile int *)(OMAP34XX_GPIO3_BASE +0x3C )) |=0x00000001 ; -#else -printf ("Unknown revision... \n\n" ); -#endif -return 0 ; +writel (GPIO0 , gpio3_base +OFFS (GPIO_SETDATAOUT )); +udelay (1 ); +writel (GPIO0 , gpio3_base +OFFS (GPIO_CLEARDATAOUT )); +udelay (1 ); +writel (GPIO0 , gpio3_base +OFFS (GPIO_SETDATAOUT )); }
board/omap3/evm/evm.h +32 -32
92 lines not on this page · raw message
include/asm-arm/arch-omap3/cpu.h +2 -0
@@ -56,9 +56,11 @@#define GPMC_CONFIG 0x50#define GPMC_STATUS 0x54#define GPMC_CONFIG_CS0 0x60 +#define GPMC_CONFIG_CS6 0x150#define GPMC_CONFIG_REG (GPMC_BASE + GPMC_CONFIG)#define GPMC_CONFIG_CS0_BASE (GPMC_BASE + GPMC_CONFIG_CS0) +#define GPMC_CONFIG_CS6_BASE (GPMC_BASE + GPMC_CONFIG_CS6)#define GPMC_CONFIG_WP 0x10#define GPMC_CONFIG_WIDTH 0x30
include/asm-arm/arch-omap3/mem.h +8 -0
@@ -197,6 +197,14 @@ typedef enum {#define ONENAND_GPMC_CONFIG5 0x010F1010#define ONENAND_GPMC_CONFIG6 0x1F060000 +#define NET_GPMC_CONFIG1 0x00001000 +#define NET_GPMC_CONFIG2 0x001e1e01 +#define NET_GPMC_CONFIG3 0x00080300 +#define NET_GPMC_CONFIG4 0x1c091c09 +#define NET_GPMC_CONFIG5 0x04181f1f +#define NET_GPMC_CONFIG6 0x00000FCF +#define NET_GPMC_CONFIG7 0x00000f6c +/* max number of GPMC Chip Selects */ #define GPMC_MAX_CS 8/* max number of GPMC regs */
include/asm-arm/arch-omap3/omap3.h +1 -0
@@ -86,6 +86,7 @@#define OMAP34XX_GPIO6_BASE 0x49058000#define GPIO_OE 0x34 +#define GPIO_CLEARDATAOUT 0x90#define GPIO_SETDATAOUT 0x94#define GPIO0 (0x1 << 0)
Quoted 16 lines · dirk.behme at googlemail.com
- Use readx/writex instead of direct pointer access
- Replace hardcoded values by macros
- Minor space to tab conversionNotes:
- Instead of read/modify/write
GPIO_DATAOUTregister use SET/CLEARDATAOUT register for GPIO64
- GPIO 1-6CM_FCLKEN_PERandCM_ICLKEN_PERare already configured inper_clocks_enable(), remove it here
- Remove pin mux. Is done inset_muxconf_regs.No functional change.
Signed-off-by Dirk Behme <[email protected]>
Quoted 7 lines
--- board/omap3/evm/evm.c | 143 +++++++++---------------------------- board/omap3/evm/evm.h | 64 ++++++++-------- include/asm-arm/arch-omap3/cpu.h | 2 include/asm-arm/arch-omap3/mem.h | 8 ++ include/asm-arm/arch-omap3/omap3.h | 1 5 files changed, 78 insertions(+), 140 deletions(-)
apply to u-boot-arm/omap3
Quoted 17 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 16 lines · dirk.behme at googlemail.com
- Use readx/writex instead of direct pointer access
- Replace hardcoded values by macros
- Minor space to tab conversionNotes:
- Instead of read/modify/write
GPIO_DATAOUTregister use SET/CLEARDATAOUT register for GPIO64
- GPIO 1-6CM_FCLKEN_PERandCM_ICLKEN_PERare already configured inper_clocks_enable(), remove it here
- Remove pin mux. Is done inset_muxconf_regs.No functional change.
Signed-off-by Dirk Behme <[email protected]>
Quoted 8 lines
Quoted 7 lines
--- board/omap3/evm/evm.c | 143 +++++++++---------------------------- board/omap3/evm/evm.h | 64 ++++++++-------- include/asm-arm/arch-omap3/cpu.h | 2 include/asm-arm/arch-omap3/mem.h | 8 ++ include/asm-arm/arch-omap3/omap3.h | 1 5 files changed, 78 insertions(+), 140 deletions(-)apply to u-boot-arm/omap3
please not that I've to remove the modification of include/asm-arm/arch-omap3/omap3.h which does not apply
please send an incremental patch and please number them to known the order to apply them
Best Regards,
J.