From: David Brownell <dbrown...@users.sourceforge.net> Start updating DaVinci board support to reduce dependencies on dm644x chips and EVM-like boards ... beginning with "psc.c", which hosts a bunch of those dependencies:
- Pinmux registers and their contents are SoC-specific, and are also unrelated to the Power and Sleep Controller. * Declare more of the pinmux registers; * Move their bitfield decls to a public header; * Renaming thse bitfields to be clearly SoC-specific. - Rename the errata workarounds to be clearly SoC-specific. - Add a CONFIG_SOC_DM6446; use it to prevent some mux goofs. - Don't include the I2C support if the I2C driver is not enabled. Plus two minor bugfixes: - Correct the PSC_MDSTAT mask ... it's six bits, not five. (Original DM6446 doces said five, FWIW.) - Correct the PWREMU_MGT mask ... don't set must-be-zero bits. The simplest always-correct way to handle pinmux is in board_init() calls; or possibly in SoC-specific device setup code. Currently these chips don't have such SoC-specific support. Signed-off-by: David Brownell <dbrown...@users.sourceforge.net> --- board/davinci/common/psc.c | 29 ++++++++++++++++------------- board/davinci/common/psc.h | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/schmoogie/schmoogie.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- include/asm-arm/arch-davinci/hardware.h | 23 +++++++++++++++++++++-- include/configs/davinci_dvevm.h | 1 + include/configs/davinci_schmoogie.h | 1 + include/configs/davinci_sffsdr.h | 1 + include/configs/davinci_sonata.h | 1 + 11 files changed, 46 insertions(+), 20 deletions(-) --- a/board/davinci/common/psc.c +++ b/board/davinci/common/psc.c @@ -26,13 +26,6 @@ #include <common.h> #include <asm/arch/hardware.h> -#define PINMUX0_EMACEN (1 << 31) -#define PINMUX0_AECS5 (1 << 11) -#define PINMUX0_AECS4 (1 << 10) - -#define PINMUX1_I2C (1 << 7) -#define PINMUX1_UART1 (1 << 1) -#define PINMUX1_UART0 (1 << 0) /* * The DM6446 includes two separate power domains: "Always On" and "DSP". The @@ -57,7 +50,7 @@ void lpsc_on(unsigned int id) while (REG(PSC_PTSTAT) & 0x01); - if ((*mdstat & 0x1f) == 0x03) + if ((*mdstat & 0x3f) == 0x03) return; /* Already on and enabled */ *mdctl |= 0x03; @@ -129,10 +122,12 @@ void davinci_enable_uart0(void) lpsc_on(DAVINCI_LPSC_UART0); /* Bringup UART0 out of reset */ - REG(UART0_PWREMU_MGMT) = 0x0000e003; + REG(UART0_PWREMU_MGMT) = 0x00006001; +#ifdef CONFIG_SOC_DM6446 /* Enable UART0 MUX lines */ - REG(PINMUX1) |= PINMUX1_UART0; + REG(PINMUX1) |= DM644X_PINMUX1_UART0; +#endif } #ifdef CONFIG_DRIVER_TI_EMAC @@ -145,20 +140,27 @@ void davinci_enable_emac(void) /* Enable GIO3.3V cells used for EMAC */ REG(VDD3P3V_PWDN) = 0; +#ifdef CONFIG_SOC_DM6446 /* Enable EMAC. */ - REG(PINMUX0) |= PINMUX0_EMACEN; + REG(PINMUX0) |= DM644X_PINMUX0_EMACEN; +#endif } #endif +#ifdef CONFIG_DRIVER_DAVINCI_I2C void davinci_enable_i2c(void) { lpsc_on(DAVINCI_LPSC_I2C); +#ifdef CONFIG_SOC_DM6446 /* Enable I2C pin Mux */ - REG(PINMUX1) |= PINMUX1_I2C; + REG(PINMUX1) |= DM644X_PINMUX1_I2C; +#endif } +#endif -void davinci_errata_workarounds(void) +#ifdef CONFIG_SOC_DM6446 +void dm6446_errata_workarounds(void) { /* * Workaround for TMS320DM6446 errata 1.3.22: @@ -180,3 +182,4 @@ void davinci_errata_workarounds(void) */ REG(VBPR) = 0x20; } +#endif --- a/board/davinci/common/psc.h +++ b/board/davinci/common/psc.h @@ -27,6 +27,6 @@ void dsp_on(void); void davinci_enable_uart0(void); void davinci_enable_emac(void); void davinci_enable_i2c(void); -void davinci_errata_workarounds(void); +void dm6446_errata_workarounds(void); #endif /* __PSC_H */ --- a/board/davinci/dvevm/dvevm.c +++ b/board/davinci/dvevm/dvevm.c @@ -44,7 +44,7 @@ int board_init(void) * with pull-up/pull-down resistors) */ REG(PINMUX0) = 0x00000c1f; - davinci_errata_workarounds(); + dm6446_errata_workarounds(); /* Power on required peripherals */ lpsc_on(DAVINCI_LPSC_GPIO); --- a/board/davinci/schmoogie/schmoogie.c +++ b/board/davinci/schmoogie/schmoogie.c @@ -44,7 +44,7 @@ int board_init(void) * with pull-up/pull-down resistors) */ REG(PINMUX0) = 0x00000c1f; - davinci_errata_workarounds(); + dm6446_errata_workarounds(); /* Power on required peripherals */ lpsc_on(DAVINCI_LPSC_GPIO); --- a/board/davinci/sffsdr/sffsdr.c +++ b/board/davinci/sffsdr/sffsdr.c @@ -50,7 +50,7 @@ int board_init(void) /* address of boot parameters */ gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; - davinci_errata_workarounds(); + dm6446_errata_workarounds(); /* Power on required peripherals */ lpsc_on(DAVINCI_LPSC_GPIO); --- a/board/davinci/sonata/sonata.c +++ b/board/davinci/sonata/sonata.c @@ -43,7 +43,7 @@ int board_init(void) * with pull-up/pull-down resistors) */ REG(PINMUX0) = 0x00000c1f; - davinci_errata_workarounds(); + dm6446_errata_workarounds(); /* Power on required peripherals */ lpsc_on(DAVINCI_LPSC_GPIO); --- a/include/asm-arm/arch-davinci/hardware.h +++ b/include/asm-arm/arch-davinci/hardware.h @@ -44,6 +44,10 @@ typedef volatile unsigned int * dv_reg_p /* * Base register addresses + * + * NOTE: some of these DM6446-specific addresses DO NOT WORK + * on other DaVinci chips. Double check them before you try + * using the addresses ... or PSC module identifiers, etc. */ #define DAVINCI_DMA_3PCC_BASE (0x01c00000) #define DAVINCI_DMA_3PTC0_BASE (0x01c10000) @@ -160,7 +164,22 @@ typedef volatile unsigned int * dv_reg_p /* Miscellania... */ #define VBPR (0x20000020) -#define PINMUX0 (0x01c40000) -#define PINMUX1 (0x01c40004) + +/* NOTE: system control modules are *highly* chip-specific, both + * as to register content (e.g. for muxing) and which registers exist. + */ +#define PINMUX0 0x01c40000 +#define DM644X_PINMUX0_EMACEN (1 << 31) +#define DM644X_PINMUX0_AECS5 (1 << 11) +#define DM644X_PINMUX0_AECS4 (1 << 10) + +#define PINMUX1 0x01c40004 +#define DM644X_PINMUX1_I2C (1 << 7) +#define DM644X_PINMUX1_UART1 (1 << 1) +#define DM644X_PINMUX1_UART0 (1 << 0) + +#define PINMUX2 0x01c40008 +#define PINMUX3 0x01c4000c +#define PINMUX4 0x01c40010 #endif /* __ASM_ARCH_HARDWARE_H */ --- a/include/configs/davinci_dvevm.h +++ b/include/configs/davinci_dvevm.h @@ -59,6 +59,7 @@ #define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */ #define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */ #define CONFIG_SYS_HZ 1000 +#define CONFIG_SOC_DM6446 /*====================================================*/ /* EEPROM definitions for Atmel 24C256BN SEEPROM chip */ /* on Sonata/DV_EVM board. No EEPROM on schmoogie. */ --- a/include/configs/davinci_schmoogie.h +++ b/include/configs/davinci_schmoogie.h @@ -34,6 +34,7 @@ #define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */ #define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */ #define CONFIG_SYS_HZ 1000 +#define CONFIG_SOC_DM6446 /*=============*/ /* Memory Info */ /*=============*/ --- a/include/configs/davinci_sffsdr.h +++ b/include/configs/davinci_sffsdr.h @@ -35,6 +35,7 @@ #define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */ #define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */ #define CONFIG_SYS_HZ 1000 +#define CONFIG_SOC_DM6446 /* EEPROM definitions for Atmel 24LC64 EEPROM chip */ #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 --- a/include/configs/davinci_sonata.h +++ b/include/configs/davinci_sonata.h @@ -59,6 +59,7 @@ #define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */ #define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */ #define CONFIG_SYS_HZ 1000 +#define CONFIG_SOC_DM6446 /*====================================================*/ /* EEPROM definitions for Atmel 24C256BN SEEPROM chip */ /* on Sonata/DV_EVM board. No EEPROM on schmoogie. */ _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot