: Further update am33xx support
cover : Further update am33xx support
Hey all,
The following series depends on both Ilya's cpsw work (the parts I've said I would accept as-is) as well as the previous series I posted. This series does a few things. The main part is support for the next TI EVM (AM335x StarterKit EVM) which features DDR3 and re-works the board.c files based on the intention to have a single build support all boards, based on the system EEPROM. Based on the header we will setup pinmux and in the case of the StarterKit EVM, enable a GPIO that controls power to the DDR. While in here I enabled the EEPROM command as this should make it easier for people to program the EEPROM on their custom capes on beaglebones. And a bugfix to gpio0 support was required for toggling the GPIO I mentioned on the StarterKit. While reworking board.c a few printf's were changed to puts and when we find an invalid EEPROM header, we print out what we found (useful in seeing how you programmed it wrong).
Signature · 1 line
Tom
PATCH 1/5 am33xx: Enable gpio0 clock
--- arch/arm/cpu/armv7/am33xx/clock.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/am33xx/clock.c +4 -0
@@ -71,6 +71,10 @@ static void enable_interface_clocks(void)writel (PRCM_MOD_EN , &cmper->l4hsclkctrl);while (readl (&cmper->l4hsclkctrl) !=PRCM_MOD_EN ) ; + +writel (PRCM_MOD_EN , &cmwkup->wkgpio0clkctrl); +while (readl (&cmwkup->wkgpio0clkctrl) !=PRCM_MOD_EN ) + ; }/*
Signature · 1 line
1.7.9.5
PATCH 2/5 am33xx: Remove board/ti/am335x/evm.c
In reply to Tom RiniThe intention has always been (and boards are to support) an i2c EEPROM that will identify what hardware they are, allowing a single binary to support multiple boards. As such, remove the 'evm.c' file as there is nothing EVM centric in it currently, only SoC peripheral configuration.
--- arch/arm/cpu/armv7/am33xx/board.c | 173 ++++++++++++++++++++++++++++++++ board/ti/am335x/Makefile | 2 +- board/ti/am335x/evm.c | 199 ------------------------------------- 3 files changed, 174 insertions(+), 200 deletions(-) delete mode 100644 board/ti/am335x/evm.c
arch/arm/cpu/armv7/am33xx/board.c +173 -0
@@ -17,6 +17,7 @@*/ #include <common.h> +#include <errno.h> #include <asm/arch/cpu.h> #include <asm/arch/hardware.h> #include <asm/arch/omap.h>
@@ -28,6 +29,9 @@#include <asm/io.h> #include <asm/omap_common.h> #include <asm/emif.h> +#include <i2c.h> +#include <miiphy.h> +#include <cpsw.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -44,6 +48,79 @@ static const struct gpio_bank gpio_bank_am33xx[4] = {const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx; +/* MII mode defines */ +#define MII_MODE_ENABLE 0x0 +#define RGMII_MODE_ENABLE 0xA + +static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE ; + +/* +* I2C Address of on-board EEPROM +*/ +#define I2C_BASE_BOARD_ADDR 0x50 + +#define NO_OF_MAC_ADDR 3 +#define ETH_ALEN 6 +#define NAME_LEN 8 + +struct am335x_baseboard_id { +unsigned int magic; +char name[NAME_LEN ]; +char version[4 ]; +char serial[12 ]; +char config[32 ]; +char mac_addr[NO_OF_MAC_ADDR ][ETH_ALEN ]; +}; + +static struct am335x_baseboard_id header; + +static inline int board_is_bone (void ) +{ +return !strncmp (header.name,"A335BONE" ,NAME_LEN ); +} + +/* +* Read header information from EEPROM into global structure. +*/ +static int read_eeprom (void ) +{ +/* Check if baseboard eeprom is available */ +if (i2c_probe (I2C_BASE_BOARD_ADDR )) { +puts ("Could not probe the EEPROM; something fundamentally " +"wrong on the I2C bus.\n" ); +return -ENODEV ; + } + +/* read the eeprom using i2c */ +if (i2c_read (I2C_BASE_BOARD_ADDR ,0 ,2 , (uchar *)&header, +sizeof (header))) { +puts ("Could not read the EEPROM; something fundamentally" +" wrong on the I2C bus.\n" ); +return -EIO ; + } + +if (header.magic !=0xEE3355AA ) { +/* +* read the eeprom using i2c again, +* but use only a 1 byte address +*/ +if (i2c_read (I2C_BASE_BOARD_ADDR ,0 ,1 , (uchar *)&header, +sizeof (header))) { +puts ("Could not read the EEPROM; something " +"fundamentally wrong on the I2C bus.\n" ); +return -EIO ; + } + +if (header.magic !=0xEE3355AA ) { +printf ("Incorrect magic number (0x%x) in EEPROM\n" , + header.magic); +return -EINVAL ; + } + } + +return 0 ; +} +/* UART Defines */ #ifdef CONFIG_SPL_BUILD #define UART_RESET (0x1 << 1)
@@ -127,3 +204,99 @@ void setup_clocks_for_console(void)/* Not yet implemented */ return ; } + +/* +* Basic board specific setup +*/ +int board_init (void ) +{ +enable_uart0_pin_mux (); + +enable_i2c0_pin_mux (); +enable_i2c1_pin_mux (); +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +if (read_eeprom () <0 ) +puts ("Could not get board ID.\n" ); + + gd->bd->bi_boot_params =PHYS_DRAM_1 +0x100 ; + +return 0 ; +} + +#ifdef CONFIG_DRIVER_TI_CPSW +static void cpsw_control (int enabled) +{ +/* VTP can be added here */ + +return ; +} + +static struct cpsw_slave_data cpsw_slaves[] = { + { + .slave_reg_ofs =0x208 , + .sliver_reg_ofs =0xd80 , + .phy_id =0 , + }, + { + .slave_reg_ofs =0x308 , + .sliver_reg_ofs =0xdc0 , + .phy_id =1 , + }, +}; + +static struct cpsw_platform_data cpsw_data = { + .mdio_base =AM335X_CPSW_MDIO_BASE , + .cpsw_base =AM335X_CPSW_BASE , + .mdio_div =0xff , + .channels =8 , + .cpdma_reg_ofs =0x800 , + .slaves =1 , + .slave_data = cpsw_slaves, + .ale_reg_ofs =0xd00 , + .ale_entries =1024 , + .host_port_reg_ofs =0x108 , + .hw_stats_reg_ofs =0x900 , + .mac_control = (1 <<5 ), + .control = cpsw_control, + .host_port_num =0 , + .version =CPSW_CTRL_VERSION_2 , +}; + +int board_eth_init (bd_t *bis) +{ +uint8_t mac_addr[6 ]; +uint32_t mac_hi, mac_lo; + +if (!eth_getenv_enetaddr ("ethaddr" , mac_addr)) { +debug ("<ethaddr> not set. Reading from E-fuse\n" ); +/* try reading mac address from efuse */ + mac_lo =readl (&cdev->macid0l); + mac_hi =readl (&cdev->macid0h); + mac_addr[0 ] = mac_hi &0xFF ; + mac_addr[1 ] = (mac_hi &0xFF00 ) >>8 ; + mac_addr[2 ] = (mac_hi &0xFF0000 ) >>16 ; + mac_addr[3 ] = (mac_hi &0xFF000000 ) >>24 ; + mac_addr[4 ] = mac_lo &0xFF ; + mac_addr[5 ] = (mac_lo &0xFF00 ) >>8 ; + +if (is_valid_ether_addr (mac_addr)) +eth_setenv_enetaddr ("ethaddr" , mac_addr); +else +return -1 ; + } + +if (board_is_bone ()) { +enable_mii1_pin_mux (); +writel (MII_MODE_ENABLE , &cdev->miisel); + cpsw_slaves[0 ].phy_if = cpsw_slaves[1 ].phy_if = +PHY_INTERFACE_MODE_MII ; + }else { +enable_rgmii1_pin_mux (); +writel (RGMII_MODE_ENABLE , &cdev->miisel); + cpsw_slaves[0 ].phy_if = cpsw_slaves[1 ].phy_if = +PHY_INTERFACE_MODE_RGMII ; + } + +return cpsw_register (&cpsw_data); +} +#endif
board/ti/am335x/Makefile +1 -1
@@ -18,7 +18,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o -COBJS := evm.o mux.o +COBJS := mux.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/ti/am335x/evm.c deleted +0 -199
199 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/5 am33xx: Add support for TI AM335x StarterKit EVM
In reply to Tom Rini- Board requires gpio0 #7 to be set to power DDR3.
- Board uses DDR3, add a way to determine which DDR type to call config_ddr with.
- Both of the above require filling in the header structure early, move it into the data section.
--- arch/arm/cpu/armv7/am33xx/board.c | 41 +++++++++++++++++++++++-- arch/arm/include/asm/arch-am33xx/common_def.h | 1 + board/ti/am335x/mux.c | 10 ++++++ 3 files changed, 50 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +39 -2
@@ -29,6 +29,7 @@#include <asm/io.h> #include <asm/omap_common.h> #include <asm/emif.h> +#include <asm/gpio.h> #include <i2c.h> #include <miiphy.h> #include <cpsw.h>
@@ -52,6 +53,9 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;#define MII_MODE_ENABLE 0x0#define RGMII_MODE_ENABLE 0xA +/* GPIO that controls power to DDR on EVM-SK */ +#define GPIO_DDR_VTT_EN 7 +static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE ;/*
@@ -72,13 +76,18 @@ struct am335x_baseboard_id {char mac_addr[NO_OF_MAC_ADDR ][ETH_ALEN ]; }; -static struct am335x_baseboard_id header; +static struct am335x_baseboard_id __attribute__((section (".data" ))) header;static inline int board_is_bone (void ) {return !strncmp (header.name,"A335BONE" ,NAME_LEN ); } +static inline int board_is_evm_sk (void ) +{ +return !strncmp ("A335X_SK" , header.name,NAME_LEN ); +} +/* * Read header information from EEPROM into global structure. */
@@ -145,6 +154,18 @@ static void init_timer(void)#endif /* +* Determine what type of DDR we have. +*/ +static short inline board_memory_type (void ) +{ +/* The following boards are known to use DDR3. */ +if (board_is_evm_sk ()) +return EMIF_REG_SDRAM_TYPE_DDR3 ; + +return EMIF_REG_SDRAM_TYPE_DDR2 ; +} + +/* * early system init of muxing and clocks. */ void s_init (void )
@@ -185,7 +206,23 @@ void s_init(void)preloader_console_init (); -config_ddr (EMIF_REG_SDRAM_TYPE_DDR2 ); +/* Initalize the board header */ +enable_i2c0_pin_mux (); +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +if (read_eeprom () <0 ) +puts ("Could not get board ID.\n" ); + +if (board_is_evm_sk ()) { +/* +* EVM SK 1.2A and later use gpio0_7 to enable DDR3. +* This is safe enough to do on older revs. +*/ +enable_gpio0_7_pin_mux (); +gpio_request (GPIO_DDR_VTT_EN ,"ddr_vtt_en" ); +gpio_direction_output (GPIO_DDR_VTT_EN ,1 ); + } + +config_ddr (board_memory_type ());#endif /* Enable MMC0 */
arch/arm/include/asm/arch-am33xx/common_def.h +1 -0
@@ -18,6 +18,7 @@extern void enable_uart0_pin_mux (void );extern void enable_mmc0_pin_mux (void ); +extern void enable_gpio0_7_pin_mux (void );extern void enable_i2c0_pin_mux (void );extern void enable_mii1_pin_mux (void );extern void enable_rgmii1_pin_mux (void );
board/ti/am335x/mux.c +10 -0
@@ -288,6 +288,11 @@ static struct module_pin_mux i2c1_pin_mux[] = { {-1}, }; +static struct module_pin_mux gpio0_7_pin_mux[] = { + {OFFSET (ecap0_in_pwm0_out), (MODE (7 ) |PULLUDEN )},/* GPIO0_7 */ + {-1 }, +}; +static struct module_pin_mux rgmii1_pin_mux[] = { {OFFSET (mii1_txen),MODE (2 )},/* RGMII1_TCTL */ {OFFSET(mii1_rxdv), MODE(2) | RXACTIVE}, /* RGMII1_RCTL */
@@ -370,3 +375,8 @@ void enable_mii1_pin_mux(void) {configure_module_pin_mux (mii1_pin_mux); } + +void enable_gpio0_7_pin_mux (void ) +{ +configure_module_pin_mux (gpio0_7_pin_mux); +}
Signature · 1 line
1.7.9.5
PATCH 4/5 am33xx evm: Add CONFIG_CMD_EEPROM and related
In reply to Tom Riniam33xx boards have at least one eeprom and in the case of beaglebones with capes, more.
--- arch/arm/cpu/armv7/am33xx/board.c | 13 ++++--------- include/configs/am335x_evm.h | 4 ++++ 2 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +4 -9
@@ -58,11 +58,6 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE ; -/* -* I2C Address of on-board EEPROM -*/ -#define I2C_BASE_BOARD_ADDR 0x50 -#define NO_OF_MAC_ADDR 3#define ETH_ALEN 6#define NAME_LEN 8
@@ -94,14 +89,14 @@ static inline int board_is_evm_sk(void)static int read_eeprom (void ) {/* Check if baseboard eeprom is available */ -if (i2c_probe (I2C_BASE_BOARD_ADDR )) { +if (i2c_probe (CONFIG_SYS_I2C_EEPROM_ADDR )) {puts ("Could not probe the EEPROM; something fundamentally " "wrong on the I2C bus.\n" );return -ENODEV ; }/* read the eeprom using i2c */ -if (i2c_read (I2C_BASE_BOARD_ADDR ,0 ,2 , (uchar *)&header, +if (i2c_read (CONFIG_SYS_I2C_EEPROM_ADDR ,0 ,2 , (uchar *)&header,sizeof (header))) {puts ("Could not read the EEPROM; something fundamentally" " wrong on the I2C bus.\n" );
@@ -113,8 +108,8 @@ static int read_eeprom(void)* read the eeprom using i2c again, * but use only a 1 byte address */ -if (i2c_read (I2C_BASE_BOARD_ADDR ,0 ,1 , (uchar *)&header, -sizeof (header))) { +if (i2c_read (CONFIG_SYS_I2C_EEPROM_ADDR ,0 ,1 , + (uchar *)&header,sizeof (header))) {puts ("Could not read the EEPROM; something " "fundamentally wrong on the I2C bus.\n" );return -EIO ;
include/configs/am335x_evm.h +4 -0
@@ -161,6 +161,10 @@#define CONFIG_SYS_I2C_SLAVE 1#define CONFIG_I2C_MULTI_BUS #define CONFIG_DRIVER_OMAP24XX_I2C +#define CONFIG_CMD_EEPROM +#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */ +#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 +#define CONFIG_SYS_I2C_MULTI_EEPROMS #define CONFIG_BAUDRATE 115200#define CONFIG_SYS_BAUDRATE_TABLE { 110, 300, 600, 1200, 2400, \
Signature · 1 line
1.7.9.5
PATCH 5/5 am33xx: Rework pinmux functions
In reply to Tom Rini- Move definition of the EEPROM contents to <asm/arch/sys_proto.h>
- Make some defines a little less generic now.
- Pinmux must be done by done by SPL now.
- Create 3 pinmux functions, uart0, i2c0 and board.
- Add pinmux specific to Starter Kit EVM for MMC now.
--- arch/arm/cpu/armv7/am33xx/board.c | 32 +++----------- arch/arm/include/asm/arch-am33xx/common_def.h | 26 ----------- arch/arm/include/asm/arch-am33xx/sys_proto.h | 28 ++++++++++++ board/ti/am335x/Makefile | 2 + board/ti/am335x/mux.c | 58 ++++++++++++++----------- 5 files changed, 68 insertions(+), 78 deletions(-) delete mode 100644 arch/arm/include/asm/arch-am33xx/common_def.h
arch/arm/cpu/armv7/am33xx/board.c +5 -27
@@ -25,7 +25,7 @@#include <asm/arch/clock.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc_host_def.h> -#include <asm/arch/common_def.h> +#include <asm/arch/sys_proto.h> #include <asm/io.h> #include <asm/omap_common.h> #include <asm/emif.h>
@@ -58,29 +58,16 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE ; -#define NO_OF_MAC_ADDR 3 -#define ETH_ALEN 6 -#define NAME_LEN 8 - -struct am335x_baseboard_id { -unsigned int magic; -char name[NAME_LEN ]; -char version[4 ]; -char serial[12 ]; -char config[32 ]; -char mac_addr[NO_OF_MAC_ADDR ][ETH_ALEN ]; -}; -static struct am335x_baseboard_id __attribute__((section (".data" ))) header;static inline int board_is_bone (void ) { -return !strncmp (header.name,"A335BONE" ,NAME_LEN ); +return !strncmp (header.name,"A335BONE" ,HDR_NAME_LEN ); }static inline int board_is_evm_sk (void ) { -return !strncmp ("A335X_SK" , header.name,NAME_LEN ); +return !strncmp ("A335X_SK" , header.name,HDR_NAME_LEN ); }/*
@@ -207,21 +194,18 @@ void s_init(void)if (read_eeprom () <0 )puts ("Could not get board ID.\n" ); +enable_board_pin_mux (&header);if (board_is_evm_sk ()) {/* * EVM SK 1.2A and later use gpio0_7 to enable DDR3. * This is safe enough to do on older revs. */ -enable_gpio0_7_pin_mux ();gpio_request (GPIO_DDR_VTT_EN ,"ddr_vtt_en" );gpio_direction_output (GPIO_DDR_VTT_EN ,1 ); }config_ddr (board_memory_type ());#endif - -/* Enable MMC0 */ -enable_mmc0_pin_mux (); }#if defined(CONFIG_OMAP_HSMMC ) && !defined(CONFIG_SPL_BUILD )
@@ -238,14 +222,10 @@ void setup_clocks_for_console(void) }/* -* Basic board specific setup +* Basic board specific setup. Pinmux has been handled already. */ int board_init (void ) { -enable_uart0_pin_mux (); - -enable_i2c0_pin_mux (); -enable_i2c1_pin_mux ();i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE );if (read_eeprom () <0 )puts ("Could not get board ID.\n" );
@@ -318,12 +298,10 @@ int board_eth_init(bd_t *bis) }if (board_is_bone ()) { -enable_mii1_pin_mux ();writel (MII_MODE_ENABLE , &cdev->miisel); cpsw_slaves[0 ].phy_if = cpsw_slaves[1 ].phy_if =PHY_INTERFACE_MODE_MII ; }else { -enable_rgmii1_pin_mux ();writel (RGMII_MODE_ENABLE , &cdev->miisel); cpsw_slaves[0 ].phy_if = cpsw_slaves[1 ].phy_if =PHY_INTERFACE_MODE_RGMII ;
arch/arm/include/asm/arch-am33xx/common_def.h deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* common_def.h -* -* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation version 2. -* -* This program is distributed "as is" WITHOUT ANY WARRANTY of any -* kind, whether express or implied; without even the implied warranty -* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ - -#ifndef __COMMON_DEF_H__ -#define __COMMON_DEF_H__ - -extern void enable_uart0_pin_mux (void ); -extern void enable_mmc0_pin_mux (void ); -extern void enable_gpio0_7_pin_mux (void ); -extern void enable_i2c0_pin_mux (void ); -extern void enable_mii1_pin_mux (void ); -extern void enable_rgmii1_pin_mux (void ); - -#endif /*__COMMON_DEF_H__ */
arch/arm/include/asm/arch-am33xx/sys_proto.h +28 -0
@@ -19,6 +19,24 @@#ifndef _SYS_PROTO_H_#define _SYS_PROTO_H_ +/* +* AM335x parts define a system EEPROM that defines certain sub-fields. +* We use these fields to in turn see what board we are on, and what +* that might require us to set or not set. +*/ +#define HDR_NO_OF_MAC_ADDR 3 +#define HDR_ETH_ALEN 6 +#define HDR_NAME_LEN 8 + +struct am335x_baseboard_id { +unsigned int magic; +char name[HDR_NAME_LEN ]; +char version[4 ]; +char serial[12 ]; +char config[32 ]; +char mac_addr[HDR_NO_OF_MAC_ADDR ][HDR_ETH_ALEN ]; +}; +#define BOARD_REV_ID 0x0u32 get_cpu_rev (void );
@@ -31,4 +49,14 @@ int print_cpuinfo(void);u32 get_device_type (void );void setup_clocks_for_console (void );void ddr_pll_config (unsigned int ddrpll_M); + +/* +* We have three pin mux functions that must exist. We must be able to enable +* uart0, for initial output and i2c0 to read the main EEPROM. We then have a +* main pinmux function that can be overridden to enable all other pinmux that +* is required on the board. +*/ +void enable_uart0_pin_mux (void ); +void enable_i2c0_pin_mux (void ); +void enable_board_pin_mux (struct am335x_baseboard_id *header);#endif
board/ti/am335x/Makefile +2 -0
@@ -18,7 +18,9 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o +ifdef CONFIG_SPL_BUILD COBJS := mux.o +endif SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/ti/am335x/mux.c +33 -25
89 lines not on this page · raw message
Signature · 1 line
1.7.9.5