[U-Boot] [PATCH V5 0/7] ARM: omap-common: Add board detection support for TI EVMs

Several TI EVMs have onboard EEPROM that contain board description information. The onboard EEPROM on Beaglebone, Beaglebone Black, AM335x EVM, AM43x EVM, AM57xx EVM, Beagleboard-x15 all share the same format.
This series of patches introduces code which is generic among these platforms. The boards can use the data for any operations they might choose.
V5 of the series now updates the v4 series to ensure that latest u-boot platform support including BBG is supported as well. This also setsup easier introduction of DRA7-evm variant of eeproms as well.
Testing: AM335x: BeagleBone-Green: http://pastebin.ubuntu.com/15183845/ BeagleBone-Black: http://pastebin.ubuntu.com/15183885/ AM335x-SK: http://pastebin.ubuntu.com/15188966/
AM437x: AM437x-GPEVM: http://pastebin.ubuntu.com/15188896/ AM437x-SK: http://pastebin.ubuntu.com/15188940/
Am57xx: AM57xx-gpevm: http://pastebin.ubuntu.com/15188997/
baseline: master 595af9db2422 Merge branch 'master' of git://www.denx.de/git/u-boot-imx
Lokesh Vutla (1): ARM: omap-common: Add standard access for board description EEPROM
Nishanth Menon (2): ti: AM335x: Use generic EEPROM detection logic ti: AM437x: Use generic EEPROM detection logic
Steve Kipisz (4): ARM: OMAP4/5: Centralize early clock initialization ARM: OMAP4/5: Centralize gpi2c_init ARM: OMAP4/5: Add generic board detection hook board: ti: AM57xx: Add detection logic for AM57xx-evm
arch/arm/Kconfig | 2 + arch/arm/cpu/armv7/omap-common/clocks-common.c | 21 +- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 14 +- arch/arm/cpu/armv7/omap5/Kconfig | 1 + arch/arm/include/asm/arch-omap4/sys_proto.h | 4 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 4 +- arch/arm/include/asm/omap_common.h | 7 +- board/ti/am335x/Kconfig | 2 + board/ti/am335x/board.c | 115 ++++------- board/ti/am335x/board.h | 49 ++--- board/ti/am335x/mux.c | 13 +- board/ti/am43xx/Kconfig | 2 + board/ti/am43xx/board.c | 87 +++------ board/ti/am43xx/board.h | 37 +--- board/ti/am43xx/mux.c | 1 + board/ti/am57xx/Kconfig | 2 + board/ti/am57xx/board.c | 70 ++++++- board/ti/common/Kconfig | 5 + board/ti/common/Makefile | 6 + board/ti/common/board_detect.c | 254 +++++++++++++++++++++++++ board/ti/common/board_detect.h | 140 ++++++++++++++ include/configs/am57xx_evm.h | 4 + include/configs/ti_omap5_common.h | 2 + 23 files changed, 623 insertions(+), 219 deletions(-) create mode 100644 board/ti/common/Kconfig create mode 100644 board/ti/common/Makefile create mode 100644 board/ti/common/board_detect.c create mode 100644 board/ti/common/board_detect.h

Early clock initialization is currently done in two stages for OMAP4/5 SoCs. The first stage is the initialization of console clocks and then we initialize basic clocks for functionality necessary for SoC initialization and basic board functionality.
By splitting up prcm_init and centralizing this clock initialization, we setup the code for follow on patches that can do board specific initialization such as board detection which will depend on these basic clocks.
As part of this change, since the early clock initialization is centralized, we no longer need to expose the console clock initialization.
NOTE: we change the sequence slightly by initializing console clocks timer after the io settings are complete, but this is not expected to have any functioanlity impact since we setup the basic IO drive strength initialization as part of do_io_settings.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com --- V5: No changes v4: https://patchwork.ozlabs.org/patch/540775/ v3: https://patchwork.ozlabs.org/patch/540193/
v2: http://marc.info/?t=144655363000001&r=1&w=2 (mailing list squashed original submission)
v1: Did not exist
arch/arm/cpu/armv7/omap-common/clocks-common.c | 21 +++++++++++++++++++-- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 3 +-- arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/clocks-common.c b/arch/arm/cpu/armv7/omap-common/clocks-common.c index e28b79568d1d..367d224361be 100644 --- a/arch/arm/cpu/armv7/omap-common/clocks-common.c +++ b/arch/arm/cpu/armv7/omap-common/clocks-common.c @@ -769,7 +769,7 @@ void lock_dpll(u32 const base) wait_for_lock(base); }
-void setup_clocks_for_console(void) +static void setup_clocks_for_console(void) { /* Do not add any spl_debug prints in this function */ clrsetbits_le32((*prcm)->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK, @@ -853,14 +853,31 @@ void do_disable_clocks(u32 const *clk_domains, disable_clock_domain(clk_domains[i]); }
-void prcm_init(void) +/** + * setup_early_clocks() - Setup early clocks needed for SoC + * + * Setup clocks for console, SPL basic initialization clocks and initialize + * the timer. This is invoked prior prcm_init. + */ +void setup_early_clocks(void) { switch (omap_hw_init_context()) { case OMAP_INIT_CONTEXT_SPL: case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR: case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH: + setup_clocks_for_console(); enable_basic_clocks(); timer_init(); + /* Fall through */ + } +} + +void prcm_init(void) +{ + switch (omap_hw_init_context()) { + case OMAP_INIT_CONTEXT_SPL: + case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR: + case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH: scale_vcores(*omap_vcores); setup_dplls(); setup_warmreset_time(); diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index 80794f9c611a..91f2dead364b 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -125,10 +125,9 @@ void s_init(void) set_mux_conf_regs(); #ifdef CONFIG_SPL_BUILD srcomp_enable(); - setup_clocks_for_console(); - do_io_settings(); #endif + setup_early_clocks(); prcm_init(); }
diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h index f30f86539130..71e3d776aa0d 100644 --- a/arch/arm/include/asm/arch-omap4/sys_proto.h +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h @@ -37,7 +37,7 @@ void do_set_mux(u32 base, struct pad_conf_entry const *array, int size); void set_muxconf_regs_essential(void); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); -void setup_clocks_for_console(void); +void setup_early_clocks(void); void prcm_init(void); void bypass_dpll(u32 const base); void freq_update_core(void); diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h index 7fcb78389403..b9e09e7c52a8 100644 --- a/arch/arm/include/asm/arch-omap5/sys_proto.h +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h @@ -48,7 +48,7 @@ void do_set_mux32(u32 base, struct pad_conf_entry const *array, int size); void set_muxconf_regs_essential(void); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); -void setup_clocks_for_console(void); +void setup_early_clocks(void); void prcm_init(void); void bypass_dpll(u32 const base); void freq_update_core(void);

On Wed, Feb 24, 2016 at 12:30:52PM -0600, Steve Kipisz wrote:
Early clock initialization is currently done in two stages for OMAP4/5 SoCs. The first stage is the initialization of console clocks and then we initialize basic clocks for functionality necessary for SoC initialization and basic board functionality.
By splitting up prcm_init and centralizing this clock initialization, we setup the code for follow on patches that can do board specific initialization such as board detection which will depend on these basic clocks.
As part of this change, since the early clock initialization is centralized, we no longer need to expose the console clock initialization.
NOTE: we change the sequence slightly by initializing console clocks timer after the io settings are complete, but this is not expected to have any functioanlity impact since we setup the basic IO drive strength initialization as part of do_io_settings.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:52PM -0600, Kipisz, Steven wrote:
Early clock initialization is currently done in two stages for OMAP4/5 SoCs. The first stage is the initialization of console clocks and then we initialize basic clocks for functionality necessary for SoC initialization and basic board functionality.
By splitting up prcm_init and centralizing this clock initialization, we setup the code for follow on patches that can do board specific initialization such as board detection which will depend on these basic clocks.
As part of this change, since the early clock initialization is centralized, we no longer need to expose the console clock initialization.
NOTE: we change the sequence slightly by initializing console clocks timer after the io settings are complete, but this is not expected to have any functioanlity impact since we setup the basic IO drive strength initialization as part of do_io_settings.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

Centralize gpi2c_init into omap_common from the sys_proto header so that the information can be reused across SoCs.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com --- V5: No changes V4: https://patchwork.ozlabs.org/patch/540771/
v3: https://patchwork.ozlabs.org/patch/540196/
v2: http://marc.info/?t=144655344600007&r=1&w=2 (mailing list squashed original submission)
Changes in v2: - New patch
arch/arm/include/asm/arch-omap4/sys_proto.h | 1 - arch/arm/include/asm/arch-omap5/sys_proto.h | 1 - arch/arm/include/asm/omap_common.h | 3 +++ 3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h index 71e3d776aa0d..26e9a194f036 100644 --- a/arch/arm/include/asm/arch-omap4/sys_proto.h +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h @@ -51,7 +51,6 @@ void save_omap_boot_params(void); void init_omap_revision(void); void do_io_settings(void); void sri2c_init(void); -void gpi2c_init(void); int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data); u32 warm_reset(void); void force_emif_self_refresh(void); diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h index b9e09e7c52a8..18902628739b 100644 --- a/arch/arm/include/asm/arch-omap5/sys_proto.h +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h @@ -62,7 +62,6 @@ void save_omap_boot_params(void); void init_omap_revision(void); void do_io_settings(void); void sri2c_init(void); -void gpi2c_init(void); int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data); u32 warm_reset(void); void force_emif_self_refresh(void); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index d7b81c101b79..d773b0430ad4 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -617,6 +617,9 @@ void disable_edma3_clocks(void);
void omap_die_id(unsigned int *die_id);
+/* Initialize general purpose I2C(0) on the SoC */ +void gpi2c_init(void); + /* ABB */ #define OMAP_ABB_NOMINAL_OPP 0 #define OMAP_ABB_FAST_OPP 1

On Wed, Feb 24, 2016 at 12:30:53PM -0600, Steve Kipisz wrote:
Centralize gpi2c_init into omap_common from the sys_proto header so that the information can be reused across SoCs.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:53PM -0600, Kipisz, Steven wrote:
Centralize gpi2c_init into omap_common from the sys_proto header so that the information can be reused across SoCs.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

From: Lokesh Vutla lokeshvutla@ti.com
Several TI EVMs have EEPROM that can contain board description information such as revision, DDR definition, serial number, etc. In just about all cases, these EEPROM are on the I2C bus and provides us the opportunity to centralize the generic operations involved.
The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM, AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format. However, DRA-7* EVMs, OMAP4SDP use a modified format.
We hence introduce logic which is generic between these platforms without enforcing any specific format. This allows the boards to use the relevant format for operations that they might choose.
This module will compile for all TI SoC based boards when CONFIG_TI_I2C_BOARD_DETECT is enabled to have optimal build times for platforms that require this support.
It is important to note that this logic is fundamental to the board configuration process such as DDR configuration which is needed in SPL, hence cannot be part of the standard u-boot driver model (which is available later in the process). Hence, to aid efficiency, the eeprom contents are copied over to SRAM scratchpad memory area at the first invocation to retrieve data.
To prevent churn with cases such as DRA7, where eeprom format maybe incompatible, we introduce a generic common format in eeprom which is made available over accessor functions for usage.
Special handling for BBG1 EEPROM had to be introduced thanks to the weird eeprom rev contents used.
The follow on patches introduce the use of this library for AM335x, AM437x, and AM57xx.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Signed-off-by: Steve Kipisz s-kipisz2@ti.com Signed-off-by: Roger Quadros rogerq@ti.com Signed-off-by: Nishanth Menon nm@ti.com --- Changes in V5: - Dropped dependency on https://patchwork.ozlabs.org/patch/540280/ - library now completely abstracts eeprom format away from consumers - data access over apis to the library - now made reusable for dra7 (follow on series) - mac address api access introduced (Thanks to Roger) - a "generic" eeprom structure which is board independent is stored in sram (instead of actual eeprom contents) - To optimize compile time usage, TI_I2C_BOARD_DETECT introduced - BBG hack incorporated
V4: https://patchwork.ozlabs.org/patch/540773/ v3: https://patchwork.ozlabs.org/patch/540197/
v2: http://marc.info/?t=144655344800001&r=1&w=2 (mailing list squashed original submission)
Changes in v2: - New patch
arch/arm/include/asm/omap_common.h | 4 +- board/ti/common/Kconfig | 5 + board/ti/common/Makefile | 6 + board/ti/common/board_detect.c | 254 +++++++++++++++++++++++++++++++++++++ board/ti/common/board_detect.h | 140 ++++++++++++++++++++ 5 files changed, 408 insertions(+), 1 deletion(-) create mode 100644 board/ti/common/Kconfig create mode 100644 board/ti/common/Makefile create mode 100644 board/ti/common/board_detect.c create mode 100644 board/ti/common/board_detect.h
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index d773b0430ad4..aef31266ce9e 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -713,7 +713,9 @@ static inline u8 is_dra72x(void) #define OMAP_SRAM_SCRATCH_VCORES_PTR (SRAM_SCRATCH_SPACE_ADDR + 0x1C) #define OMAP_SRAM_SCRATCH_SYS_CTRL (SRAM_SCRATCH_SPACE_ADDR + 0x20) #define OMAP_SRAM_SCRATCH_BOOT_PARAMS (SRAM_SCRATCH_SPACE_ADDR + 0x24) -#define OMAP5_SRAM_SCRATCH_SPACE_END (SRAM_SCRATCH_SPACE_ADDR + 0x28) +#define OMAP_SRAM_SCRATCH_BOARD_EEPROM_START (SRAM_SCRATCH_SPACE_ADDR + 0x28) +#define OMAP_SRAM_SCRATCH_BOARD_EEPROM_END (SRAM_SCRATCH_SPACE_ADDR + 0x200) +#define OMAP_SRAM_SCRATCH_SPACE_END (OMAP_SRAM_SCRATCH_BOARD_EEPROM_END)
/* Boot parameters */ #define DEVICE_DATA_OFFSET 0x18 diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig new file mode 100644 index 000000000000..adf73abc9358 --- /dev/null +++ b/board/ti/common/Kconfig @@ -0,0 +1,5 @@ +config TI_I2C_BOARD_DETECT + bool "Support for Board detection for TI platforms" + help + Support for detection board information on Texas Instrument's + Evaluation Boards which have I2C based EEPROM detection diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile new file mode 100644 index 000000000000..7170eac81e87 --- /dev/null +++ b/board/ti/common/Makefile @@ -0,0 +1,6 @@ +# Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c new file mode 100644 index 000000000000..6cf4859967b9 --- /dev/null +++ b/board/ti/common/board_detect.c @@ -0,0 +1,254 @@ +/* + * Library to support early TI EVM EEPROM handling + * + * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ + * Lokesh Vutla + * Steve Kipisz + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <asm/omap_common.h> +#include <i2c.h> + +#include "board_detect.h" + +/** + * ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device + * @i2c_bus: i2c bus number to initialize + * @dev_addr: Device address to probe for + * + * Return: 0 on success or corresponding error on failure. + */ +static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr) +{ + int rc; + + if (i2c_bus >= 0) { + rc = i2c_set_bus_num(i2c_bus); + if (rc) + return rc; + } + + return i2c_probe(dev_addr); +} + +/** + * ti_i2c_eeprom_read - Read data from an EEPROM + * @dev_addr: The device address of the EEPROM + * @offset: Offset to start reading in the EEPROM + * @ep: Pointer to a buffer to read into + * @epsize: Size of buffer + * + * Return: 0 on success or corresponding result of i2c_read + */ +static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset, + uchar *ep, int epsize) +{ + return i2c_read(dev_addr, offset, 2, ep, epsize); +} + +/** + * ti_eeprom_string_cleanup() - Handle eeprom programming errors + * @s: eeprom string (should be NULL terminated) + * + * Some Board manufacturers do not add a NULL termination at the + * end of string, instead some binary information is kludged in, hence + * convert the string to just printable characters of ASCII chart. + */ +static void __maybe_unused ti_eeprom_string_cleanup(char *s) +{ + int i, l; + + l = strlen(s); + for (i = 0; i < l; i++, s++) + if (*s < ' ' || *s > '~') { + *s = 0; + break; + } +} + +__weak void gpi2c_init(void) +{ +} + +static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, + u32 header, u32 size, uint8_t *ep) +{ + u32 byte, hdr_read; + int rc; + + gpi2c_init(); + rc = ti_i2c_eeprom_init(bus_addr, dev_addr); + if (rc) + return rc; + + /* + * Read the header first then only read the other contents. + */ + byte = 2; + rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); + if (rc) + return rc; + + /* Corrupted data??? */ + if (hdr_read != header) { + rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); + /* + * read the eeprom header using i2c again, but use only a + * 1 byte address (some legacy boards need this..) + */ + byte = 1; + if (rc) + rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, + 4); + if (rc) + return rc; + } + if (hdr_read != header) + return -1; + + rc = i2c_read(dev_addr, 0x0, byte, ep, size); + if (rc) + return rc; + + return 0; +} + +int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr) +{ + int rc; + struct ti_am_eeprom am_ep; + struct ti_common_eeprom *ep; + + ep = TI_EEPROM_DATA; + if (ep->header == TI_EEPROM_HEADER_MAGIC) + goto already_read; + + /* Initialize with a known bad marker for i2c fails.. */ + ep->header = TI_DEAD_EEPROM_MAGIC; + ep->name[0] = 0x0; + ep->version[0] = 0x0; + ep->serial[0] = 0x0; + + rc = ti_i2c_eeprom_get(bus_addr, dev_addr, TI_EEPROM_HEADER_MAGIC, + sizeof(am_ep), (uint8_t *)&am_ep); + if (rc) + return rc; + + ep->header = am_ep.header; + strlcpy(ep->name, am_ep.name, TI_EEPROM_HDR_NAME_LEN + 1); + ti_eeprom_string_cleanup(ep->name); + + /* BeagleBone Green '1' eeprom, board_rev: 0x1a 0x00 0x00 0x00 */ + if (am_ep.version[0] == 0x1a && am_ep.version[1] == 0x00 && + am_ep.version[2] == 0x00 && am_ep.version[3] == 0x00) + strlcpy(ep->version, "BBG1", TI_EEPROM_HDR_REV_LEN + 1); + else + strlcpy(ep->version, am_ep.version, TI_EEPROM_HDR_REV_LEN + 1); + ti_eeprom_string_cleanup(ep->version); + strlcpy(ep->serial, am_ep.serial, TI_EEPROM_HDR_SERIAL_LEN + 1); + ti_eeprom_string_cleanup(ep->serial); + strlcpy(ep->config, am_ep.config, TI_EEPROM_HDR_CONFIG_LEN + 1); + ti_eeprom_string_cleanup(ep->config); + + memcpy(ep->mac_addr, am_ep.mac_addr, + TI_EEPROM_HDR_NO_OF_MAC_ADDR * TI_EEPROM_HDR_ETH_ALEN); + +already_read: + return 0; +} + +bool __maybe_unused board_ti_is(char *name_tag) +{ + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + + if (ep->header == TI_DEAD_EEPROM_MAGIC) + return false; + return !strncmp(ep->name, name_tag, TI_EEPROM_HDR_NAME_LEN); +} + +bool __maybe_unused board_ti_rev_is(char *rev_tag, int cmp_len) +{ + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + int l; + + if (ep->header == TI_DEAD_EEPROM_MAGIC) + return false; + + l = cmp_len > TI_EEPROM_HDR_REV_LEN ? TI_EEPROM_HDR_REV_LEN : cmp_len; + return !strncmp(ep->version, rev_tag, l); +} + +char * __maybe_unused board_ti_get_rev(void) +{ + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + + if (ep->header == TI_DEAD_EEPROM_MAGIC) + return NULL; + + return ep->version; +} + +char * __maybe_unused board_ti_get_config(void) +{ + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + + if (ep->header == TI_DEAD_EEPROM_MAGIC) + return NULL; + + return ep->config; +} + +char * __maybe_unused board_ti_get_name(void) +{ + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + + if (ep->header == TI_DEAD_EEPROM_MAGIC) + return NULL; + + return ep->name; +} + +void __maybe_unused +board_ti_get_eth_mac_addr(int index, + u8 mac_addr[TI_EEPROM_HDR_ETH_ALEN]) +{ + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + + if (ep->header == TI_DEAD_EEPROM_MAGIC) + goto fail; + + if (index < 0 || index >= TI_EEPROM_HDR_NO_OF_MAC_ADDR) + goto fail; + + memcpy(mac_addr, ep->mac_addr[index], TI_EEPROM_HDR_ETH_ALEN); + return; + +fail: + memset(mac_addr, 0, TI_EEPROM_HDR_ETH_ALEN); +} + +void __maybe_unused set_board_info_env(char *name) +{ + char *unknown = "unknown"; + struct ti_common_eeprom *ep = TI_EEPROM_DATA; + + if (name) + setenv("board_name", name); + else if (ep->name) + setenv("board_name", ep->name); + else + setenv("board_name", unknown); + + if (ep->version) + setenv("board_rev", ep->version); + else + setenv("board_rev", unknown); + + if (ep->serial) + setenv("board_serial", ep->serial); + else + setenv("board_serial", unknown); +} diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h new file mode 100644 index 000000000000..c17ab347c1c0 --- /dev/null +++ b/board/ti/common/board_detect.h @@ -0,0 +1,140 @@ +/* + * Library to support early TI EVM EEPROM handling + * + * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __BOARD_DETECT_H +#define __BOARD_DETECT_H + +/* TI EEPROM MAGIC Header identifier */ +#define TI_EEPROM_HEADER_MAGIC 0xEE3355AA +#define TI_DEAD_EEPROM_MAGIC 0xADEAD12C + +#define TI_EEPROM_HDR_NAME_LEN 8 +#define TI_EEPROM_HDR_REV_LEN 4 +#define TI_EEPROM_HDR_SERIAL_LEN 12 +#define TI_EEPROM_HDR_CONFIG_LEN 32 +#define TI_EEPROM_HDR_NO_OF_MAC_ADDR 3 +#define TI_EEPROM_HDR_ETH_ALEN 6 + +/** + * struct ti_am_eeprom - This structure holds data read in from the + * AM335x, AM437x, AM57xx TI EVM EEPROMs. + * @header: This holds the magic number + * @name: The name of the board + * @version: Board revision + * @serial: Board serial number + * @config: Reserved + * @mac_addr: Any MAC addresses written in the EEPROM + * + * The data is this structure is read from the EEPROM on the board. + * It is used for board detection which is based on name. It is used + * to configure specific TI boards. This allows booting of multiple + * TI boards with a single MLO and u-boot. + */ +struct ti_am_eeprom { + unsigned int header; + char name[TI_EEPROM_HDR_NAME_LEN]; + char version[TI_EEPROM_HDR_REV_LEN]; + char serial[TI_EEPROM_HDR_SERIAL_LEN]; + char config[TI_EEPROM_HDR_CONFIG_LEN]; + char mac_addr[TI_EEPROM_HDR_NO_OF_MAC_ADDR][TI_EEPROM_HDR_ETH_ALEN]; +} __attribute__ ((__packed__)); + +/** + * struct ti_common_eeprom - Null terminated, usable EEPROM contents. + * header: Magic number + * @name: NULL terminated name + * @version: NULL terminated version + * @serial: NULL terminated serial number + * @config: NULL terminated Board specific config options + * @mac_addr: MAC addresses + */ +struct ti_common_eeprom { + u32 header; + char name[TI_EEPROM_HDR_NAME_LEN + 1]; + char version[TI_EEPROM_HDR_REV_LEN + 1]; + char serial[TI_EEPROM_HDR_SERIAL_LEN + 1]; + char config[TI_EEPROM_HDR_CONFIG_LEN + 1]; + char mac_addr[TI_EEPROM_HDR_NO_OF_MAC_ADDR][TI_EEPROM_HDR_ETH_ALEN]; +}; + +#define TI_EEPROM_DATA ((struct ti_common_eeprom *)\ + OMAP_SRAM_SCRATCH_BOARD_EEPROM_START) + +/** + * ti_i2c_eeprom_am_get() - Consolidated eeprom data collection for AM* TI EVMs + * @bus_addr: I2C bus address + * @dev_addr: I2C slave address + * + * ep in SRAM is populated by the this AM generic function that consolidates + * the basic initialization logic common across all AM* platforms. + */ +int ti_i2c_eeprom_am_get(int bus_addr, int dev_addr); + +/** + * board_ti_is() - Board detection logic for TI EVMs + * @name_tag: Tag used in eeprom for the board + * + * Return: false if board information does not match OR eeprom wasn't read. + * true otherwise + */ +bool board_ti_is(char *name_tag); + +/** + * board_ti_rev_is() - Compare board revision for TI EVMs + * @rev_tag: Revision tag to check in eeprom + * @cmp_len: How many chars to compare? + * + * NOTE: revision information is often messed up (hence the str len match) :( + * + * Return: false if board information does not match OR eeprom was'nt read. + * true otherwise + */ +bool board_ti_rev_is(char *rev_tag, int cmp_len); + +/** + * board_ti_get_rev() - Get board revision for TI EVMs + * + * Return: NULL if eeprom was'nt read. + * Board revision otherwise + */ +char *board_ti_get_rev(void); + +/** + * board_ti_get_config() - Get board config for TI EVMs + * + * Return: NULL if eeprom was'nt read. + * Board config otherwise + */ +char *board_ti_get_config(void); + +/** + * board_ti_get_name() - Get board name for TI EVMs + * + * Return: NULL if eeprom was'nt read. + * Board name otherwise + */ +char *board_ti_get_name(void); + +/** + * board_ti_get_eth_mac_addr() - Get Ethernet MAC address from EEPROM MAC list + * @index: 0 based index within the list of MAC addresses + * @mac_addr: MAC address contained at the index is returned here + * + * Does not sanity check the mac_addr. Whatever is stored in EEPROM is returned. + */ +void board_ti_get_eth_mac_addr(int index, u8 mac_addr[TI_EEPROM_HDR_ETH_ALEN]); + +/** + * set_board_info_env() - Setup commonly used board information environment vars + * @name: Name of the board + * + * If name is NULL, default_name is used. + */ +void set_board_info_env(char *name); + +#endif /* __BOARD_DETECT_H */

On Wed, Feb 24, 2016 at 12:30:54PM -0600, Steve Kipisz wrote:
From: Lokesh Vutla lokeshvutla@ti.com
Several TI EVMs have EEPROM that can contain board description information such as revision, DDR definition, serial number, etc. In just about all cases, these EEPROM are on the I2C bus and provides us the opportunity to centralize the generic operations involved.
The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM, AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format. However, DRA-7* EVMs, OMAP4SDP use a modified format.
We hence introduce logic which is generic between these platforms without enforcing any specific format. This allows the boards to use the relevant format for operations that they might choose.
This module will compile for all TI SoC based boards when CONFIG_TI_I2C_BOARD_DETECT is enabled to have optimal build times for platforms that require this support.
It is important to note that this logic is fundamental to the board configuration process such as DDR configuration which is needed in SPL, hence cannot be part of the standard u-boot driver model (which is available later in the process). Hence, to aid efficiency, the eeprom contents are copied over to SRAM scratchpad memory area at the first invocation to retrieve data.
To prevent churn with cases such as DRA7, where eeprom format maybe incompatible, we introduce a generic common format in eeprom which is made available over accessor functions for usage.
Special handling for BBG1 EEPROM had to be introduced thanks to the weird eeprom rev contents used.
The follow on patches introduce the use of this library for AM335x, AM437x, and AM57xx.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Signed-off-by: Steve Kipisz s-kipisz2@ti.com Signed-off-by: Roger Quadros rogerq@ti.com Signed-off-by: Nishanth Menon nm@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:54PM -0600, Kipisz, Steven wrote:
From: Lokesh Vutla lokeshvutla@ti.com
Several TI EVMs have EEPROM that can contain board description information such as revision, DDR definition, serial number, etc. In just about all cases, these EEPROM are on the I2C bus and provides us the opportunity to centralize the generic operations involved.
The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM, AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format. However, DRA-7* EVMs, OMAP4SDP use a modified format.
We hence introduce logic which is generic between these platforms without enforcing any specific format. This allows the boards to use the relevant format for operations that they might choose.
This module will compile for all TI SoC based boards when CONFIG_TI_I2C_BOARD_DETECT is enabled to have optimal build times for platforms that require this support.
It is important to note that this logic is fundamental to the board configuration process such as DDR configuration which is needed in SPL, hence cannot be part of the standard u-boot driver model (which is available later in the process). Hence, to aid efficiency, the eeprom contents are copied over to SRAM scratchpad memory area at the first invocation to retrieve data.
To prevent churn with cases such as DRA7, where eeprom format maybe incompatible, we introduce a generic common format in eeprom which is made available over accessor functions for usage.
Special handling for BBG1 EEPROM had to be introduced thanks to the weird eeprom rev contents used.
The follow on patches introduce the use of this library for AM335x, AM437x, and AM57xx.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Signed-off-by: Steve Kipisz s-kipisz2@ti.com Signed-off-by: Roger Quadros rogerq@ti.com Signed-off-by: Nishanth Menon nm@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

From: Nishanth Menon nm@ti.com
Use the generic EEPROM detection logic instead of duplicating the AM eeprom logic.
Signed-off-by: Nishanth Menon nm@ti.com Signed-off-by: Steven Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- V5: - Drops dependency on https://patchwork.ozlabs.org/patch/540280/ - newer API usage v4: https://patchwork.ozlabs.org/patch/540772/
V3-v1: did not exist
arch/arm/Kconfig | 1 + board/ti/am335x/Kconfig | 2 + board/ti/am335x/board.c | 115 ++++++++++++++---------------------------------- board/ti/am335x/board.h | 49 ++++++++------------- board/ti/am335x/mux.c | 13 +++--- 5 files changed, 60 insertions(+), 120 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index d8b63e940768..38dd19a7197b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -368,6 +368,7 @@ config TARGET_AM335X_EVM select DM select DM_SERIAL select DM_GPIO + select TI_I2C_BOARD_DETECT
config TARGET_AM335X_SL50 bool "Support am335x_sl50" diff --git a/board/ti/am335x/Kconfig b/board/ti/am335x/Kconfig index 49b73abc2090..11ef3caf3908 100644 --- a/board/ti/am335x/Kconfig +++ b/board/ti/am335x/Kconfig @@ -38,4 +38,6 @@ config NOR_BOOT as the ROM only partially sets up pinmux. We also default to using NOR for environment.
+source "board/ti/common/Kconfig" + endif diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index f56d17ec58e1..4330be64994d 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -31,6 +31,7 @@ #include <environment.h> #include <watchdog.h> #include <environment.h> +#include "../common/board_detect.h" #include "board.h"
DECLARE_GLOBAL_DATA_PTR; @@ -46,43 +47,9 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; /* * Read header information from EEPROM into global structure. */ -static int read_eeprom(struct am335x_baseboard_id *header) +static inline int __maybe_unused read_eeprom(void) { - /* Check if baseboard eeprom is available */ - 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(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, - sizeof(struct am335x_baseboard_id))) { - 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(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, - sizeof(struct am335x_baseboard_id))) { - 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; + return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR); }
#ifndef CONFIG_SKIP_LOWLEVEL_INIT @@ -223,16 +190,15 @@ const struct dpll_params dpll_ddr_bone_black = {
void am33xx_spl_board_init(void) { - struct am335x_baseboard_id header; int mpu_vdd;
- if (read_eeprom(&header) < 0) + if (read_eeprom() < 0) puts("Could not get board ID.\n");
/* Get the frequency */ dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
- if (board_is_bone(&header) || board_is_bone_lt(&header)) { + if (board_is_bone() || board_is_bone_lt()) { /* BeagleBone PMIC Code */ int usb_cur_lim;
@@ -240,8 +206,7 @@ void am33xx_spl_board_init(void) * Only perform PMIC configurations if board rev > A1 * on Beaglebone White */ - if (board_is_bone(&header) && !strncmp(header.version, - "00A1", 4)) + if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4)) return;
if (i2c_probe(TPS65217_CHIP_PM)) @@ -251,7 +216,7 @@ void am33xx_spl_board_init(void) * On Beaglebone White we need to ensure we have AC power * before increasing the frequency. */ - if (board_is_bone(&header)) { + if (board_is_bone()) { uchar pmic_status_reg; if (tps65217_reg_read(TPS65217_STATUS, &pmic_status_reg)) @@ -266,7 +231,7 @@ void am33xx_spl_board_init(void) * Override what we have detected since we know if we have * a Beaglebone Black it supports 1GHz. */ - if (board_is_bone_lt(&header)) + if (board_is_bone_lt()) dpll_mpu_opp100.m = MPUPLL_M_1000;
/* @@ -307,7 +272,7 @@ void am33xx_spl_board_init(void) * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. */ - if (board_is_bone(&header)) { + if (board_is_bone()) { if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, TPS65217_DEFLS1, TPS65217_LDO_VOLTAGE_OUT_3_3, @@ -367,18 +332,16 @@ void am33xx_spl_board_init(void)
const struct dpll_params *get_dpll_ddr_params(void) { - struct am335x_baseboard_id header; - enable_i2c0_pin_mux(); i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); - if (read_eeprom(&header) < 0) + if (read_eeprom() < 0) puts("Could not get board ID.\n");
- if (board_is_evm_sk(&header)) + if (board_is_evm_sk()) return &dpll_ddr_evm_sk; - else if (board_is_bone_lt(&header)) + else if (board_is_bone_lt()) return &dpll_ddr_bone_black; - else if (board_is_evm_15_or_later(&header)) + else if (board_is_evm_15_or_later()) return &dpll_ddr_evm_sk; else return &dpll_ddr; @@ -403,12 +366,10 @@ void set_uart_mux_conf(void)
void set_mux_conf_regs(void) { - __maybe_unused struct am335x_baseboard_id header; - - if (read_eeprom(&header) < 0) + if (read_eeprom() < 0) puts("Could not get board ID.\n");
- enable_board_pin_mux(&header); + enable_board_pin_mux(); }
const struct ctrl_ioregs ioregs_evmsk = { @@ -445,12 +406,10 @@ const struct ctrl_ioregs ioregs = {
void sdram_init(void) { - __maybe_unused struct am335x_baseboard_id header; - - if (read_eeprom(&header) < 0) + if (read_eeprom() < 0) puts("Could not get board ID.\n");
- if (board_is_evm_sk(&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. @@ -459,15 +418,15 @@ void sdram_init(void) gpio_direction_output(GPIO_DDR_VTT_EN, 1); }
- if (board_is_evm_sk(&header)) + if (board_is_evm_sk()) config_ddr(303, &ioregs_evmsk, &ddr3_data, &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); - else if (board_is_bone_lt(&header)) + else if (board_is_bone_lt()) config_ddr(400, &ioregs_bonelt, &ddr3_beagleblack_data, &ddr3_beagleblack_cmd_ctrl_data, &ddr3_beagleblack_emif_reg_data, 0); - else if (board_is_evm_15_or_later(&header)) + else if (board_is_evm_15_or_later()) config_ddr(303, &ioregs_evm15, &ddr3_evm_data, &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); else @@ -496,26 +455,16 @@ int board_init(void) int board_late_init(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG - char safe_string[HDR_NAME_LEN + 1]; - struct am335x_baseboard_id header; + int rc; + char *name = NULL;
- if (read_eeprom(&header) < 0) + rc = read_eeprom(); + if (rc) puts("Could not get board ID.\n");
- /* Now set variables based on the header. */ - strncpy(safe_string, (char *)header.name, sizeof(header.name)); - safe_string[sizeof(header.name)] = 0; - setenv("board_name", safe_string); - - /* BeagleBone Green eeprom, board_rev: 0x1a 0x00 0x00 0x00 */ - if ( (header.version[0] == 0x1a) && (header.version[1] == 0x00) && - (header.version[2] == 0x00) && (header.version[3] == 0x00) ) { - setenv("board_rev", "BBG1"); - } else { - strncpy(safe_string, (char *)header.version, sizeof(header.version)); - safe_string[sizeof(header.version)] = 0; - setenv("board_rev", safe_string); - } + if (board_is_bbg1()) + name = "BBG1"; + set_board_info_env(name); #endif
return 0; @@ -587,7 +536,7 @@ int board_eth_init(bd_t *bis) int rv, n = 0; uint8_t mac_addr[6]; uint32_t mac_hi, mac_lo; - __maybe_unused struct am335x_baseboard_id header; + __maybe_unused struct ti_am_eeprom *header;
/* try reading mac address from efuse */ mac_lo = readl(&cdev->macid0l); @@ -624,11 +573,11 @@ int board_eth_init(bd_t *bis) eth_setenv_enetaddr("eth1addr", mac_addr); }
- if (read_eeprom(&header) < 0) + if (read_eeprom() < 0) puts("Could not get board ID.\n");
- if (board_is_bone(&header) || board_is_bone_lt(&header) || - board_is_idk(&header)) { + if (board_is_bone() || board_is_bone_lt() || + board_is_idk()) { writel(MII_MODE_ENABLE, &cdev->miisel); cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_MII; @@ -657,7 +606,7 @@ int board_eth_init(bd_t *bis) #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5 #define AR8051_RGMII_TX_CLK_DLY 0x100
- if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) { + if (board_is_evm_sk() || board_is_gp_evm()) { const char *devname; devname = miiphy_get_current_dev();
diff --git a/board/ti/am335x/board.h b/board/ti/am335x/board.h index bc700d56fece..062c34512f4d 100644 --- a/board/ti/am335x/board.h +++ b/board/ti/am335x/board.h @@ -11,53 +11,40 @@ #ifndef _BOARD_H_ #define _BOARD_H_
-/* - * TI 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]; -}; +static inline int board_is_bone(void) +{ + return board_ti_is("A335BONE"); +}
-static inline int board_is_bone(struct am335x_baseboard_id *header) +static inline int board_is_bone_lt(void) { - return !strncmp(header->name, "A335BONE", HDR_NAME_LEN); + return board_ti_is("A335BNLT"); }
-static inline int board_is_bone_lt(struct am335x_baseboard_id *header) +static inline int board_is_bbg1(void) { - return !strncmp(header->name, "A335BNLT", HDR_NAME_LEN); + return board_is_bone_lt() && !strncmp(board_ti_get_rev(), "BBG1", 4); }
-static inline int board_is_evm_sk(struct am335x_baseboard_id *header) +static inline int board_is_evm_sk(void) { - return !strncmp("A335X_SK", header->name, HDR_NAME_LEN); + return board_ti_is("A335X_SK"); }
-static inline int board_is_idk(struct am335x_baseboard_id *header) +static inline int board_is_idk(void) { - return !strncmp(header->config, "SKU#02", 6); + return !strncmp(board_ti_get_config(), "SKU#02", 6); }
-static inline int board_is_gp_evm(struct am335x_baseboard_id *header) +static inline int board_is_gp_evm(void) { - return !strncmp("A33515BB", header->name, HDR_NAME_LEN); + return board_ti_is("A33515BB"); }
-static inline int board_is_evm_15_or_later(struct am335x_baseboard_id *header) +static inline int board_is_evm_15_or_later(void) { - return (board_is_gp_evm(header) && - strncmp("1.5", header->version, 3) <= 0); + return (board_is_gp_evm() && + strncmp("1.5", board_ti_get_rev(), 3) <= 0); }
/* @@ -73,5 +60,5 @@ void enable_uart3_pin_mux(void); void enable_uart4_pin_mux(void); void enable_uart5_pin_mux(void); void enable_i2c0_pin_mux(void); -void enable_board_pin_mux(struct am335x_baseboard_id *header); +void enable_board_pin_mux(void); #endif diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c index 79ed02f68f77..fdf827fe541d 100644 --- a/board/ti/am335x/mux.c +++ b/board/ti/am335x/mux.c @@ -19,6 +19,7 @@ #include <asm/arch/mux.h> #include <asm/io.h> #include <i2c.h> +#include "../common/board_detect.h" #include "board.h"
static struct module_pin_mux uart0_pin_mux[] = { @@ -312,10 +313,10 @@ static unsigned short detect_daughter_board_profile(void) return (1 << (val & PROFILE_MASK)); }
-void enable_board_pin_mux(struct am335x_baseboard_id *header) +void enable_board_pin_mux(void) { /* Do board-specific muxes. */ - if (board_is_bone(header)) { + if (board_is_bone()) { /* Beaglebone pinmux */ configure_module_pin_mux(mii1_pin_mux); configure_module_pin_mux(mmc0_pin_mux); @@ -326,7 +327,7 @@ void enable_board_pin_mux(struct am335x_baseboard_id *header) #else configure_module_pin_mux(mmc1_pin_mux); #endif - } else if (board_is_gp_evm(header)) { + } else if (board_is_gp_evm()) { /* General Purpose EVM */ unsigned short profile = detect_daughter_board_profile(); configure_module_pin_mux(rgmii1_pin_mux); @@ -343,17 +344,17 @@ void enable_board_pin_mux(struct am335x_baseboard_id *header) configure_module_pin_mux(mmc1_pin_mux); configure_module_pin_mux(spi0_pin_mux); } - } else if (board_is_idk(header)) { + } else if (board_is_idk()) { /* Industrial Motor Control (IDK) */ configure_module_pin_mux(mii1_pin_mux); configure_module_pin_mux(mmc0_no_cd_pin_mux); - } else if (board_is_evm_sk(header)) { + } else if (board_is_evm_sk()) { /* Starter Kit EVM */ configure_module_pin_mux(i2c1_pin_mux); configure_module_pin_mux(gpio0_7_pin_mux); configure_module_pin_mux(rgmii1_pin_mux); configure_module_pin_mux(mmc0_pin_mux_sk_evm); - } else if (board_is_bone_lt(header)) { + } else if (board_is_bone_lt()) { /* Beaglebone LT pinmux */ configure_module_pin_mux(mii1_pin_mux); configure_module_pin_mux(mmc0_pin_mux);

On Wed, Feb 24, 2016 at 12:30:55PM -0600, Steve Kipisz wrote:
From: Nishanth Menon nm@ti.com
Use the generic EEPROM detection logic instead of duplicating the AM eeprom logic.
Signed-off-by: Nishanth Menon nm@ti.com Signed-off-by: Steven Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:55PM -0600, Kipisz, Steven wrote:
From: Nishanth Menon nm@ti.com
Use the generic EEPROM detection logic instead of duplicating the AM eeprom logic.
Signed-off-by: Nishanth Menon nm@ti.com Signed-off-by: Steven Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

From: Nishanth Menon nm@ti.com
Now that we have a generic TI eeprom logic which can be reused across platforms, reuse the same.
This revision also includes fixes identified by Dave Gerlach d-gerlach@ti.com
Cc: Dave Gerlach d-gerlach@ti.com Signed-off-by: Nishanth Menon nm@ti.com Signed-off-by: Steven Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- V5: - updated fixes from Dave on i2c init - rebased to latest api changes V4: https://patchwork.ozlabs.org/patch/540280/ V1-v3: did not exist
arch/arm/Kconfig | 1 + board/ti/am43xx/Kconfig | 2 ++ board/ti/am43xx/board.c | 87 +++++++++++++++---------------------------------- board/ti/am43xx/board.h | 37 +++++---------------- board/ti/am43xx/mux.c | 1 + 5 files changed, 39 insertions(+), 89 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 38dd19a7197b..3f2faf0d595e 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -381,6 +381,7 @@ config TARGET_AM43XX_EVM bool "Support am43xx_evm" select CPU_V7 select SUPPORT_SPL + select TI_I2C_BOARD_DETECT
config TARGET_BAV335X bool "Support bav335x" diff --git a/board/ti/am43xx/Kconfig b/board/ti/am43xx/Kconfig index 8d1c16883d8b..9cb80cc3f1da 100644 --- a/board/ti/am43xx/Kconfig +++ b/board/ti/am43xx/Kconfig @@ -12,4 +12,6 @@ config SYS_SOC config SYS_CONFIG_NAME default "am43xx_evm"
+source "board/ti/common/Kconfig" + endif diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c index 770726c3f796..d208d2fa8918 100644 --- a/board/ti/am43xx/board.c +++ b/board/ti/am43xx/board.c @@ -19,6 +19,7 @@ #include <asm/arch/ddr_defs.h> #include <asm/arch/gpio.h> #include <asm/emif.h> +#include "../common/board_detect.h" #include "board.h" #include <power/pmic.h> #include <power/tps65218.h> @@ -37,48 +38,9 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; /* * Read header information from EEPROM into global structure. */ -static int read_eeprom(struct am43xx_board_id *header) +static inline int __maybe_unused read_eeprom(void) { - /* Check if baseboard eeprom is available */ - if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { - printf("Could not probe the EEPROM at 0x%x\n", - CONFIG_SYS_I2C_EEPROM_ADDR); - return -ENODEV; - } - - /* read the eeprom using i2c */ - if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, - sizeof(struct am43xx_board_id))) { - printf("Could not read the EEPROM\n"); - return -EIO; - } - - if (header->magic != 0xEE3355AA) { - /* - * read the eeprom using i2c again, - * but use only a 1 byte address - */ - if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, - sizeof(struct am43xx_board_id))) { - printf("Could not read the EEPROM at 0x%x\n", - CONFIG_SYS_I2C_EEPROM_ADDR); - return -EIO; - } - - if (header->magic != 0xEE3355AA) { - printf("Incorrect magic number (0x%x) in EEPROM\n", - header->magic); - return -EINVAL; - } - } - - strncpy(am43xx_board_name, (char *)header->name, sizeof(header->name)); - am43xx_board_name[sizeof(header->name)] = 0; - - strncpy(am43xx_board_rev, (char *)header->version, sizeof(header->version)); - am43xx_board_rev[sizeof(header->version)] = 0; - - return 0; + return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR); }
#ifndef CONFIG_SKIP_LOWLEVEL_INIT @@ -374,6 +336,9 @@ const struct dpll_params *get_dpll_ddr_params(void) { int ind = get_sys_clk_index();
+ if (read_eeprom() < 0) + return NULL; + if (board_is_eposevm()) return &epos_evm_dpll_ddr[ind]; else if (board_is_gpevm() || board_is_sk()) @@ -381,7 +346,7 @@ const struct dpll_params *get_dpll_ddr_params(void) else if (board_is_idk()) return &idk_dpll_ddr;
- printf(" Board '%s' not supported\n", am43xx_board_name); + printf(" Board '%s' not supported\n", board_ti_get_name()); return NULL; }
@@ -512,16 +477,29 @@ void scale_vcores_idk(u32 m) } }
+void gpi2c_init(void) +{ + /* When needed to be invoked prior to BSS initialization */ + static bool first_time = true; + + if (first_time) { + enable_i2c0_pin_mux(); + i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, + CONFIG_SYS_OMAP24_I2C_SLAVE); + first_time = false; + } +} + void scale_vcores(void) { const struct dpll_params *mpu_params; - struct am43xx_board_id header;
- enable_i2c0_pin_mux(); - i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); - if (read_eeprom(&header) < 0) + if (read_eeprom() < 0) puts("Could not get board ID.\n");
+ /* Ensure I2C is initialized for PMIC configuration */ + gpi2c_init(); + /* Get the frequency */ mpu_params = get_dpll_mpu_params();
@@ -558,6 +536,8 @@ static void enable_vtt_regulator(void)
void sdram_init(void) { + if (read_eeprom() < 0) + return; /* * EPOS EVM has 1GB LPDDR2 connected to EMIF. * GP EMV has 1GB DDR3 connected to EMIF @@ -655,20 +635,7 @@ int board_init(void) int board_late_init(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG - char safe_string[HDR_NAME_LEN + 1]; - struct am43xx_board_id header; - - if (read_eeprom(&header) < 0) - puts("Could not get board ID.\n"); - - /* Now set variables based on the header. */ - strncpy(safe_string, (char *)header.name, sizeof(header.name)); - safe_string[sizeof(header.name)] = 0; - setenv("board_name", safe_string); - - strncpy(safe_string, (char *)header.version, sizeof(header.version)); - safe_string[sizeof(header.version)] = 0; - setenv("board_rev", safe_string); + set_board_info_env(NULL); #endif return 0; } diff --git a/board/ti/am43xx/board.h b/board/ti/am43xx/board.h index eb9493e191c6..2cf7a7751d41 100644 --- a/board/ti/am43xx/board.h +++ b/board/ti/am43xx/board.h @@ -14,58 +14,37 @@
#include <asm/arch/omap.h>
-static char *const am43xx_board_name = (char *)AM4372_BOARD_NAME_START; -static char *const am43xx_board_rev = (char *)AM4372_BOARD_VERSION_START; - -/* - * TI AM437x EVMs 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 - -#define DEV_ATTR_MAX_OFFSET 5 -#define DEV_ATTR_MIN_OFFSET 0 - -struct am43xx_board_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 DEV_ATTR_MAX_OFFSET 5 +#define DEV_ATTR_MIN_OFFSET 0
static inline int board_is_eposevm(void) { - return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN); + return board_ti_is("AM43EPOS"); }
static inline int board_is_gpevm(void) { - return !strncmp(am43xx_board_name, "AM43__GP", HDR_NAME_LEN); + return board_ti_is("AM43__GP"); }
static inline int board_is_sk(void) { - return !strncmp(am43xx_board_name, "AM43__SK", HDR_NAME_LEN); + return board_ti_is("AM43__SK"); }
static inline int board_is_idk(void) { - return !strncmp(am43xx_board_name, "AM43_IDK", HDR_NAME_LEN); + return board_ti_is("AM43_IDK"); }
static inline int board_is_evm_14_or_later(void) { - return (board_is_gpevm() && strncmp("1.4", am43xx_board_rev, 3) <= 0); + return (board_is_gpevm() && strncmp("1.4", board_ti_get_rev(), 3) <= 0); }
static inline int board_is_evm_12_or_later(void) { - return (board_is_gpevm() && strncmp("1.2", am43xx_board_rev, 3) <= 0); + return (board_is_gpevm() && strncmp("1.2", board_ti_get_rev(), 3) <= 0); }
void enable_uart0_pin_mux(void); diff --git a/board/ti/am43xx/mux.c b/board/ti/am43xx/mux.c index 510477dad9e2..e03b1bcfaaa8 100644 --- a/board/ti/am43xx/mux.c +++ b/board/ti/am43xx/mux.c @@ -9,6 +9,7 @@ #include <common.h> #include <asm/arch/sys_proto.h> #include <asm/arch/mux.h> +#include "../common/board_detect.h" #include "board.h"
static struct module_pin_mux rmii1_pin_mux[] = {

On Wed, Feb 24, 2016 at 12:30:56PM -0600, Steve Kipisz wrote:
From: Nishanth Menon nm@ti.com
Now that we have a generic TI eeprom logic which can be reused across platforms, reuse the same.
This revision also includes fixes identified by Dave Gerlach d-gerlach@ti.com
Cc: Dave Gerlach d-gerlach@ti.com Signed-off-by: Nishanth Menon nm@ti.com Signed-off-by: Steven Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:56PM -0600, Kipisz, Steven wrote:
From: Nishanth Menon nm@ti.com
Now that we have a generic TI eeprom logic which can be reused across platforms, reuse the same.
This revision also includes fixes identified by Dave Gerlach d-gerlach@ti.com
Cc: Dave Gerlach d-gerlach@ti.com Signed-off-by: Nishanth Menon nm@ti.com Signed-off-by: Steven Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

Many TI EVMs have capability to store relevant board information such as DDR description in EEPROM. Further many pad configuration variations can occur as part of revision changes in the platform. In-order to support these at runtime, we for a board detection hook which is available for override from board files that may desire to do so.
NOTE: All TI EVMs are capable of detecting board information based on early clocks that are configured. However, in case of additional needs this can be achieved within the override logic from within the board file.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com --- V5: - reviewed by picked up - no functional changes V4: https://patchwork.ozlabs.org/patch/540774/ v3: https://patchwork.ozlabs.org/patch/540194/
v2: http://marc.info/?t=144655344600006&r=1&w=2 (mailing list squashed original submission)
Changes in v2: - New patch
arch/arm/cpu/armv7/omap-common/hwinit-common.c | 11 +++++++++++ arch/arm/include/asm/arch-omap4/sys_proto.h | 1 + arch/arm/include/asm/arch-omap5/sys_proto.h | 1 + 3 files changed, 13 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index 91f2dead364b..9e9376d0e6e6 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -97,6 +97,16 @@ int arch_cpu_init(void) } #endif /* CONFIG_ARCH_CPU_INIT */
+/** + * do_board_detect() - Detect board description + * + * Function to detect board description. This is expected to be + * overridden in the SoC family board file where desired. + */ +void __weak do_board_detect(void) +{ +} + /* * Routine: s_init * Description: Does early system init of watchdog, muxing, andclocks @@ -128,6 +138,7 @@ void s_init(void) do_io_settings(); #endif setup_early_clocks(); + do_board_detect(); prcm_init(); }
diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h index 26e9a194f036..fbb52093c65a 100644 --- a/arch/arm/include/asm/arch-omap4/sys_proto.h +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h @@ -39,6 +39,7 @@ u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); void setup_early_clocks(void); void prcm_init(void); +void do_board_detect(void); void bypass_dpll(u32 const base); void freq_update_core(void); u32 get_sys_clk_freq(void); diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h index 18902628739b..23a33cb233bb 100644 --- a/arch/arm/include/asm/arch-omap5/sys_proto.h +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h @@ -50,6 +50,7 @@ u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); void setup_early_clocks(void); void prcm_init(void); +void do_board_detect(void); void bypass_dpll(u32 const base); void freq_update_core(void); u32 get_sys_clk_freq(void);

On Wed, Feb 24, 2016 at 12:30:57PM -0600, Steve Kipisz wrote:
Many TI EVMs have capability to store relevant board information such as DDR description in EEPROM. Further many pad configuration variations can occur as part of revision changes in the platform. In-order to support these at runtime, we for a board detection hook which is available for override from board files that may desire to do so.
NOTE: All TI EVMs are capable of detecting board information based on early clocks that are configured. However, in case of additional needs this can be achieved within the override logic from within the board file.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:57PM -0600, Kipisz, Steven wrote:
Many TI EVMs have capability to store relevant board information such as DDR description in EEPROM. Further many pad configuration variations can occur as part of revision changes in the platform. In-order to support these at runtime, we for a board detection hook which is available for override from board files that may desire to do so.
NOTE: All TI EVMs are capable of detecting board information based on early clocks that are configured. However, in case of additional needs this can be achieved within the override logic from within the board file.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

Current AM57xx evm supports both BeagleBoard-X15 (http://beagleboard.org/x15) and AM57xx EVM (http://www.ti.com/tool/tmdxevm5728).
The AM572x EValuation Module(EVM) provides an affordable platform to quickly start evaluation of Sitara. ARM Cortex-A15 AM57x Processors (AM5728, AM5726, AM5718, AM5716) and accelerate development for HMI, machine vision, networking, medical imaging and many other industrial applications. This EVM is based on the same BeagleBoard-X15 Chassis and adds mPCIe, mSATA, LCD, touchscreen, Camera, push button and TI's wlink8 offering.
Since the EEPROM contents are compatible between the BeagleBoard-X15 and the AM57xx-evm, we add support for the detection logic to enable support for various user programmable scripting capability.
NOTE: U-boot configuration is currently a superset of AM57xx evm and BeagleBoard-X15 and no additional configuration tweaking is needed.
This change also sets up the stage for future support of TI AM57xx EVMs to the same base bootloader build.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Signed-off-by: Nishanth Menon nm@ti.com ---
V5: - bug fixes for sys_info updates - updated for newer API usage - beagle-x15 and gpevm share the same dtb in findfdt - to ensure backward compatibility.
v4: https://patchwork.ozlabs.org/patch/540769/
v3: https://patchwork.ozlabs.org/patch/540195/
v2: http://marc.info/?t=144655344600003&r=1&w=2
v1: http://marc.info/?t=144608007900002&r=1&w=2 http://marc.info/?t=144608007900004&r=1&w=2 (mailing list squashed original submission)
arch/arm/cpu/armv7/omap5/Kconfig | 1 + board/ti/am57xx/Kconfig | 2 ++ board/ti/am57xx/board.c | 70 ++++++++++++++++++++++++++++++++++++++- include/configs/am57xx_evm.h | 4 +++ include/configs/ti_omap5_common.h | 2 ++ 5 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv7/omap5/Kconfig b/arch/arm/cpu/armv7/omap5/Kconfig index bfa264eccc57..f265b34b6383 100644 --- a/arch/arm/cpu/armv7/omap5/Kconfig +++ b/arch/arm/cpu/armv7/omap5/Kconfig @@ -15,6 +15,7 @@ config TARGET_DRA7XX_EVM
config TARGET_BEAGLE_X15 bool "BeagleBoard X15" + select TI_I2C_BOARD_DETECT
endchoice
diff --git a/board/ti/am57xx/Kconfig b/board/ti/am57xx/Kconfig index bdb779511b66..17745ff7ea65 100644 --- a/board/ti/am57xx/Kconfig +++ b/board/ti/am57xx/Kconfig @@ -9,4 +9,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "am57xx_evm"
+source "board/ti/common/Kconfig" + endif diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index 042f9ab1965a..d712ab0571ea 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -30,8 +30,12 @@ #include <dwc3-omap-uboot.h> #include <ti-usb-phy-uboot.h>
+#include "../common/board_detect.h" #include "mux_data.h"
+#define board_is_x15() board_ti_is("BBRDX15_") +#define board_is_am572x_evm() board_ti_is("AM572PM_") + #ifdef CONFIG_DRIVER_TI_CPSW #include <cpsw.h> #endif @@ -41,8 +45,10 @@ DECLARE_GLOBAL_DATA_PTR; /* GPIO 7_11 */ #define GPIO_DDR_VTT_EN 203
+#define SYSINFO_BOARD_NAME_MAX_LEN 45 + const struct omap_sysinfo sysinfo = { - "Board: BeagleBoard x15\n" + "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n" };
static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = { @@ -246,6 +252,66 @@ struct vcores_data beagle_x15_volts = { .iva.pmic = &tps659038, };
+#ifdef CONFIG_SPL_BUILD +/* No env to setup for SPL */ +static inline void setup_board_eeprom_env(void) { } + +/* Override function to read eeprom information */ +void do_board_detect(void) +{ + int rc; + + rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, + CONFIG_EEPROM_CHIP_ADDRESS); + if (rc) + printf("ti_i2c_eeprom_init failed %d\n", rc); +} + +#else /* CONFIG_SPL_BUILD */ + +/* Override function to read eeprom information: actual i2c read done by SPL*/ +void do_board_detect(void) +{ + char *bname = NULL; + int rc; + + rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, + CONFIG_EEPROM_CHIP_ADDRESS); + if (rc) + printf("ti_i2c_eeprom_init failed %d\n", rc); + + if (board_is_x15()) + bname = "BeagleBoard X15"; + else if (board_is_am572x_evm()) + bname = "AM572x EVM"; + + if (bname) + snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN, + "Board: %s REV %s\n", bname, board_ti_get_rev()); +} + +static void setup_board_eeprom_env(void) +{ + char *name = "beagle_x15"; + int rc; + + rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, + CONFIG_EEPROM_CHIP_ADDRESS); + if (rc) + goto invalid_eeprom; + + if (board_is_am572x_evm()) + name = "am57xx_evm"; + else + printf("Unidentified board claims %s in eeprom header\n", + board_ti_get_name()); + +invalid_eeprom: + set_board_info_env(name); +} + +#endif /* CONFIG_SPL_BUILD */ + void hw_data_init(void) { *prcm = &dra7xx_prcm; @@ -265,6 +331,8 @@ int board_init(void) int board_late_init(void) { init_sata(0); + setup_board_eeprom_env(); + /* * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds * This is the POWERHOLD-in-Low behavior. diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h index 6308cab8e680..1fffdb18fbcd 100644 --- a/include/configs/am57xx_evm.h +++ b/include/configs/am57xx_evm.h @@ -88,4 +88,8 @@ #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \ CONFIG_SYS_SCSI_MAX_LUN)
+/* EEPROM */ +#define CONFIG_EEPROM_CHIP_ADDRESS 0x50 +#define CONFIG_EEPROM_BUS_ADDRESS 0 + #endif /* __CONFIG_AM57XX_EVM_H */ diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index d164e6abd450..d373cbc44a16 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -117,6 +117,8 @@ "setenv fdtfile dra72-evm.dtb; fi;" \ "if test $board_name = beagle_x15; then " \ "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ + "if test $board_name = am57xx_evm; then " \ + "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ "if test $fdtfile = undefined; then " \ "echo WARNING: Could not determine device tree to use; fi; \0" \ "loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \

[..snip..]
diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h index 6308cab8e680..1fffdb18fbcd 100644 --- a/include/configs/am57xx_evm.h +++ b/include/configs/am57xx_evm.h @@ -88,4 +88,8 @@ #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \ CONFIG_SYS_SCSI_MAX_LUN)
+/* EEPROM */ +#define CONFIG_EEPROM_CHIP_ADDRESS 0x50 +#define CONFIG_EEPROM_BUS_ADDRESS 0
- #endif /* __CONFIG_AM57XX_EVM_H */
diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index d164e6abd450..d373cbc44a16 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -117,6 +117,8 @@ "setenv fdtfile dra72-evm.dtb; fi;" \ "if test $board_name = beagle_x15; then " \ "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
"if test $board_name = am57xx_evm; then " \
"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
Is it the same dtb file for am57xx_evm as well? or is this intentional and will be updated later?
Thanks and regards, Lokesh
"if test $fdtfile = undefined; then " \ "echo WARNING: Could not determine device tree to use; fi; \0" \
"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \

On 02/25/2016 01:06 AM, Lokesh Vutla wrote:
[..snip..]
[...]
"setenv fdtfile dra72-evm.dtb; fi;" \ "if test $board_name = beagle_x15; then " \ "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
"if test $board_name = am57xx_evm; then " \
"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
Is it the same dtb file for am57xx_evm as well? or is this intentional and will be updated later?
Yes - it should be the same dtb file for 2 reasons: A) At this point in patch, we dont want to break am57xx-evm - mentioned in diffstat to remind ourselves. B) we are attempting to move all these "cape" like variants into device tree overlays -> in which case the same dtb is reused even for am57xx-evm, and overlay with panel and touchscreen for the "gpevm" panel board.
So, in almost with 80% certainty, we might not introduce a am57xx_evm.dtb in upstream - we really dont need to. In fact, upstream kernel and current master u-boot does bootup successfully, and would like to maintain it so (point A).

On Wed, Feb 24, 2016 at 12:30:58PM -0600, Steve Kipisz wrote:
Current AM57xx evm supports both BeagleBoard-X15 (http://beagleboard.org/x15) and AM57xx EVM (http://www.ti.com/tool/tmdxevm5728).
The AM572x EValuation Module(EVM) provides an affordable platform to quickly start evaluation of Sitara. ARM Cortex-A15 AM57x Processors (AM5728, AM5726, AM5718, AM5716) and accelerate development for HMI, machine vision, networking, medical imaging and many other industrial applications. This EVM is based on the same BeagleBoard-X15 Chassis and adds mPCIe, mSATA, LCD, touchscreen, Camera, push button and TI's wlink8 offering.
Since the EEPROM contents are compatible between the BeagleBoard-X15 and the AM57xx-evm, we add support for the detection logic to enable support for various user programmable scripting capability.
NOTE: U-boot configuration is currently a superset of AM57xx evm and BeagleBoard-X15 and no additional configuration tweaking is needed.
This change also sets up the stage for future support of TI AM57xx EVMs to the same base bootloader build.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Signed-off-by: Nishanth Menon nm@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Wed, Feb 24, 2016 at 12:30:58PM -0600, Kipisz, Steven wrote:
Current AM57xx evm supports both BeagleBoard-X15 (http://beagleboard.org/x15) and AM57xx EVM (http://www.ti.com/tool/tmdxevm5728).
The AM572x EValuation Module(EVM) provides an affordable platform to quickly start evaluation of Sitara. ARM Cortex-A15 AM57x Processors (AM5728, AM5726, AM5718, AM5716) and accelerate development for HMI, machine vision, networking, medical imaging and many other industrial applications. This EVM is based on the same BeagleBoard-X15 Chassis and adds mPCIe, mSATA, LCD, touchscreen, Camera, push button and TI's wlink8 offering.
Since the EEPROM contents are compatible between the BeagleBoard-X15 and the AM57xx-evm, we add support for the detection logic to enable support for various user programmable scripting capability.
NOTE: U-boot configuration is currently a superset of AM57xx evm and BeagleBoard-X15 and no additional configuration tweaking is needed.
This change also sets up the stage for future support of TI AM57xx EVMs to the same base bootloader build.
Signed-off-by: Steve Kipisz s-kipisz2@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Signed-off-by: Nishanth Menon nm@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

On Wed, Feb 24, 2016 at 12:30:51PM -0600, Steve Kipisz wrote:
Several TI EVMs have onboard EEPROM that contain board description information. The onboard EEPROM on Beaglebone, Beaglebone Black, AM335x EVM, AM43x EVM, AM57xx EVM, Beagleboard-x15 all share the same format.
This series of patches introduces code which is generic among these platforms. The boards can use the data for any operations they might choose.
V5 of the series now updates the v4 series to ensure that latest u-boot platform support including BBG is supported as well. This also setsup easier introduction of DRA7-evm variant of eeproms as well.
Testing: AM335x: BeagleBone-Green: http://pastebin.ubuntu.com/15183845/ BeagleBone-Black: http://pastebin.ubuntu.com/15183885/ AM335x-SK: http://pastebin.ubuntu.com/15188966/
AM437x: AM437x-GPEVM: http://pastebin.ubuntu.com/15188896/ AM437x-SK: http://pastebin.ubuntu.com/15188940/
Am57xx: AM57xx-gpevm: http://pastebin.ubuntu.com/15188997/
baseline: master 595af9db2422 Merge branch 'master' of git://www.denx.de/git/u-boot-imx
I like this, it all looks good. But it's too late to take in for this release given the number of different boards that get changed in the end. I'll pick this up after the v2016.03 release, thanks!
participants (4)
-
Lokesh Vutla
-
Nishanth Menon
-
Steve Kipisz
-
Tom Rini