ARM: omap-common: Add board detection support for TI EVMs
Subsystems (2)
v3 cover 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.
Lokesh Vutla (1):
ARM: omap-common: Add standard access for board description EEPROM
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/cpu/armv7/omap-common/clocks-common.c | 21 +++- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 14 ++- 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 | 8 +- board/ti/am57xx/Makefile | 2 + board/ti/am57xx/board.c | 52 +++++++++ board/ti/common/board.c | 54 +++++++++ board/ti/common/board.h | 117 +++++++++++++++++++ board/ti/common/ti-i2c-eeprom.c | 148 +++++++++++++++++++++++++ include/configs/am57xx_evm.h | 4 + 11 files changed, 419 insertions(+), 9 deletions(-) create mode 100644 board/ti/common/board.c create mode 100644 board/ti/common/board.h create mode 100644 board/ti/common/ti-i2c-eeprom.c
Signature · 1 line
1.9.1
PATCH v3 1/5 ARM: OMAP4/5: Centralize early clock initialization
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
---
v3 Based on:
master 83bf0057 arm: at91: reworked meesc board support
Changes in v3 (since v2):
- Remove SPL-only build of setup_clocks_for_console since it needs to be built in u-boot for NOR boot
- Move setup_clocks_for_console from top of setup_early_clocks to inside the switch statement.
v2: http://marc.info/?t=144655363000001&r=1&w=2
(mailing list squashed original submission)
Changes in v2:
- New patch
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(-)
arch/arm/cpu/armv7/omap-common/clocks-common.c +19 -2
@@ -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 ();
arch/arm/cpu/armv7/omap-common/hwinit-common.c +1 -2
@@ -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 (); }
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -1
@@ -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 );
arch/arm/include/asm/arch-omap5/sys_proto.h +1 -1
@@ -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 );
Signature · 1 line
1.9.1
PATCH v3 1/5 ARM: OMAP4/5: Centralize early clock initialization
Quoted 10 lines · Steve Kipisz
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_initand 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.
Quoted 8 lines
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
Thanks and regards,
Lokesh
Quoted 114 lines
Signed-off-by Steve Kipisz <[email protected]>Reviewed-by Tom Rini <[email protected]<---
v3 Based on:
master83bf0057arm: at91: reworked meesc board supportChanges in v3 (since v2):
- Remove SPL-only build ofsetup_clocks_for_consolesince it needs to be built in u-boot for NOR boot
- Movesetup_clocks_for_consolefrom top ofsetup_early_clocksto inside the switch statement.v2: http://marc.info/?t=144655363000001&r=1&w=2
(mailing list squashed original submission)Changes in v2:
- New patcharch/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(-)arch/arm/cpu/armv7/omap-common/clocks-common.c +19
-2@@ -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 ();arch/arm/cpu/armv7/omap-common/hwinit-common.c +1
-2@@ -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 (); }arch/arm/include/asm/arch-omap4/sys_proto.h +1
-1@@ -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 );arch/arm/include/asm/arch-omap5/sys_proto.h +1
-1@@ -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 );
PATCH v3 2/5 ARM: OMAP4/5: Centralize gpi2c_init
In reply to Steve KipiszCentralize gpi2c_init into omap_common from the sys_proto header so that the information can be reused across SoCs.
---
v3 Based on:
master 83bf0057 arm: at91: reworked meesc board support
Changes in v3 (since v2):
- No changes
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(-)
arch/arm/include/asm/arch-omap4/sys_proto.h +0 -1
@@ -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 );
arch/arm/include/asm/arch-omap5/sys_proto.h +0 -1
@@ -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 );
arch/arm/include/asm/omap_common.h +3 -0
@@ -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
Signature · 1 line
1.9.1
PATCH v3 2/5 ARM: OMAP4/5: Centralize gpi2c_init
Quoted 2 lines · Steve Kipisz
Centralize
gpi2c_initintoomap_commonfrom thesys_protoheader so that the information can be reused across SoCs.
Thanks and regards,
Lokesh
Quoted 60 lines
Signed-off-by Steve Kipisz <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v3 Based on:
master83bf0057arm: at91: reworked meesc board supportChanges in v3 (since v2):
- No changesv2: http://marc.info/?t=144655344600007&r=1&w=2
(mailing list squashed original submission)Changes in v2:
- New Patcharch/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(-)arch/arm/include/asm/arch-omap4/sys_proto.h +0
-1@@ -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 );arch/arm/include/asm/arch-omap5/sys_proto.h +0
-1@@ -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 );arch/arm/include/asm/omap_common.h +3
-0@@ -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
PATCH v3 3/5 ARM: omap-common: Add standard access for board description EEPROM
In reply to Steve KipiszFrom: Lokesh Vutla <[email protected]>
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 I2C is enabled, even non-TI boards that do not have the EEPROM. If the functions are not used, they will not be linked in.
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.
The follow on patches introduce the use of this library for AM57x platform support. AM335x/AM43xx cleanups need to first ensure usage of omap_common prior to switch over to this generic solution.
---
v3 Based on:
master 83bf0057 arm: at91: reworked meesc board support
Changes in v3 (since v2):
- Create a new directory board/ti/common for code common to TI board
- Move the EEPROM code to the new directory
- Move the inline code that access the EEPROM data from omap_common.h to new files in the common directory
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 | 5 +- board/ti/am57xx/Makefile | 2 + board/ti/common/board.c | 54 ++++++++++++++ board/ti/common/board.h | 117 +++++++++++++++++++++++++++++ board/ti/common/ti-i2c-eeprom.c | 148 +++++++++++++++++++++++++++++++++++++ 5 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 board/ti/common/board.c create mode 100644 board/ti/common/board.h create mode 100644 board/ti/common/ti-i2c-eeprom.c
arch/arm/include/asm/omap_common.h +4 -1
@@ -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
@@ -728,4 +730,5 @@ static inline u8 is_dra72x(void)u32 omap_sys_boot_device (void );#endif +#endif /* _OMAP_COMMON_H_ */
board/ti/am57xx/Makefile +2 -0
@@ -6,3 +6,5 @@ # obj-y := board.o +obj-y += ../common/board.o +obj-${CONFIG_I2C} += ../common/ti-i2c-eeprom.o
board/ti/common/board.c new file +54 -0
54 lines not on this page · raw message
board/ti/common/board.h new file +117 -0
117 lines not on this page · raw message
board/ti/common/ti-i2c-eeprom.c new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 3/5 ARM: omap-common: Add standard access for board description EEPROM
Quoted 74 lines · Steve Kipisz
From: Lokesh Vutla <[email protected]>
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 I2C is enabled, even non-TI boards that do not have the EEPROM. If the functions are not used, they will not be linked in.
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.
The follow on patches introduce the use of this library for AM57x platform support. AM335x/AM43xx cleanups need to first ensure usage of
omap_commonprior to switch over to this generic solution.Signed-off-by Lokesh Vutla <[email protected]>Signed-off-by Steve Kipisz <[email protected]>---
v3 Based on:
master83bf0057arm: at91: reworked meesc board supportChanges in v3 (since v2):
- Create a new directory board/ti/common for code common to TI board
- Move the EEPROM code to the new directory
- Move the inline code that access the EEPROM data fromomap_common.hto new files in the common directoryv2: http://marc.info/?t=144655344800001&r=1&w=2
(mailing list squashed original submission)Changes in v2:
- New Patcharch/arm/include/asm/omap_common.h | 5 +- board/ti/am57xx/Makefile | 2 + board/ti/common/board.c | 54 ++++++++++++++ board/ti/common/board.h | 117 +++++++++++++++++++++++++++++ board/ti/common/ti-i2c-eeprom.c | 148 +++++++++++++++++++++++++++++++++++++ 5 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 board/ti/common/board.c create mode 100644 board/ti/common/board.h create mode 100644 board/ti/common/ti-i2c-eeprom.carch/arm/include/asm/omap_common.h +3
-1@@ -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
arch/arm/include/asm/omap_common.h static inline u8 is_dra72x(void) · line 733
Quoted 4 lines
arch/arm/include/asm/omap_common.h +1
-0@@ -728,4 +730,5 @@ static inline u8 is_dra72x(void)u32 omap_sys_boot_device (void );#endif +
Umm.. I think you should not have this.
Quoted 18 lines
arch/arm/include/asm/omap_common.h +0
-0#endif /* _OMAP_COMMON_H_ */ board/ti/am57xx/Makefile +2
-0@@ -6,3 +6,5 @@ # obj-y := board.o +obj-y += ../common/board.o +obj-${CONFIG_I2C} += ../common/ti-i2c-eeprom.oboard/ti/common/board.c new file +0
-0
board/ti/common/board.c line 2
Quoted 2 lines
board/ti/common/board.c new file +2
-0@@ -0,0 +1,54 @@ +/* +* board.c
please drop this.
board/ti/common/board.c line 4
Quoted 2 lines
board/ti/common/board.c new file +2
-0+* +* Common board functions for TI AMxxxx based boards.
why just AMxxxx? it is called board.c and can extend to dra7 platforms as well. why not call merge this with the eeprom code and call it board-detect.c ?
Quoted 7 lines
board/ti/common/board.c new file +7
-0+* +* Copyright (C) 2015, Texas Instruments Incorporated - http://www.ti.com +* +* Author: Steven Kipisz <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/
board/ti/common/board.c line 21
Quoted 10 lines
board/ti/common/board.c new file +10
-0+ +#include <common.h> +#include <asm/omap_common.h> + +#include "board.h" + +/** +* board_am_is() - Generic Board detection logic +* @name_tag: Tag used in eeprom for the board +*
Document that this is for AM* TI EVM platforms
board/ti/common/board.c line 25
Quoted 4 lines
board/ti/common/board.c new file +4
-0+* Return: false if board information does not match OR eeprom was'nt read. +* true otherwise +*/ +bool board_am_is (char *name_tag)
I dont see a usage on dra7 evm for example -> why not use unused for compile time optimization?
Quoted 4 lines
board/ti/common/board.c new file +4
-0+{ +struct ti_am_eeprom *ep =TI_AM_EEPROM_DATA ; + +if (ep->header !=TI_EEPROM_HEADER_MAGIC )
board/ti/common/board.c line 39
Quoted 10 lines
board/ti/common/board.c new file +10
-0+return false; +return !strncmp (ep->name, name_tag,TI_EEPROM_HDR_NAME_LEN ); +} + +/** +* board_am_rev_is() - Compare board revision +* @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) :(
Document that this is for AM* TI EVM platforms
board/ti/common/board.c line 44
Quoted 5 lines
board/ti/common/board.c new file +5
-0+* +* Return: false if board information does not match OR eeprom was'nt read. +* true otherwise +*/ +bool board_am_rev_is (char *rev_tag,int cmp_len)
here as well.
Quoted 16 lines
board/ti/common/board.c new file +10
-0+{ +struct ti_am_eeprom *ep =TI_AM_EEPROM_DATA ; +int l; + +if (ep->header !=TI_EEPROM_HEADER_MAGIC ) +return false; + + l = cmp_len >TI_EEPROM_HDR_REV_LEN ?TI_EEPROM_HDR_NAME_LEN : cmp_len; +return !strncmp (ep->version, rev_tag, l); +}board/ti/common/board.h new file +0
-0
board/ti/common/board.h line 2
Quoted 2 lines
board/ti/common/board.h new file +2
-0@@ -0,0 +1,117 @@ +/* +* board.h
I dont think this is needed: i can read the file name :)
board/ti/common/board.h line 11
Quoted 9 lines
board/ti/common/board.h new file +9
-0+* TI AMxxxx common board information header +* +* Copyright (C) 2015, Texas Instruments, Incorporated - http://www.ti.com +* +* SPDX-L icense-Identifier: GPL-2.0+ +*/ + +/* Common I2C eeprom definitions */ +#ifndef __ASSEMBLY__
you should not need this anymore. you should use a proper header guard instead.
Quoted 96 lines
board/ti/common/board.h new file +96
-0+ +/* TI EEPROM MAGIC Header identifier */ +#define TI_EEPROM_HEADER_MAGIC 0xEE3355AA + +#define TI_EEPROM_HDR_NAME_LEN 8 +#define TI_EEPROM_HDR_REV_LEN 12 +#define TI_EEPROM_HDR_SERIAL_LEN 4 +#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_am_eeprom_printable - Null terminated, printable EEPROM contents +* @name: NULL terminated name +* @version: NULL terminated version +* @serial: NULL terminated serial number +*/ +struct ti_am_eeprom_printable { +char name[TI_EEPROM_HDR_NAME_LEN +1 ]; +char version[TI_EEPROM_HDR_REV_LEN +1 ]; +char serial[TI_EEPROM_HDR_SERIAL_LEN +1 ]; +}; +#define TI_AM_EEPROM_DATA ((struct ti_am_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: Pointer to eeprom structure +* +* *ep is populated by the this AM generic function that consolidates +* the basic initialization logic common accross all AM* platforms. +*/ +int ti_i2c_eeprom_am_get (int bus_addr,int dev_addr,struct ti_am_eeprom **epp); + +/** +* ti_i2c_eeprom_am_get_print() - Get a printable representation of eeprom data +* @bus_addr: I2C bus address +* @dev_addr: I2C slave address +* @p: Pointer to eeprom structure +* +* This reads the eeprom and converts the data into a printable string for +* further processing. +*/ +int ti_i2c_eeprom_am_get_print (int bus_addr,int dev_addr, +struct ti_am_eeprom_printable *p); + +/** +* set_board_info_env() - Setup commonly used board information environment vars +* @name: Name of the board +* @revision: Revision of the board +* @serial: Serial Number of the board +* +* In case of NULL revision or serial information "unknown" is setup. +* If name is NULL, default_name is used. +*/ +void set_board_info_env (char *name,char *revision, +char *serial); + +/** +* board_am_is() - Generic Board detection logic +* @name_tag: Tag used in eeprom for the board +* +* Return: false if board information does not match OR eeprom was'nt read. +* true otherwise +*/ +bool board_am_is (char *name_tag); + +/** +* board_am_rev_is() - Compare board revision +* @rev_tag: Revision tag to check in eeprom
board/ti/common/board.h line 117
Quoted 10 lines
board/ti/common/board.h new file +10
-0+* @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_am_rev_is (char *rev_tag,int cmp_len); + +#endif /* __ASSEMBLY__ */
use a proper header guard
Quoted 145 lines
board/ti/common/ti-i2c-eeprom.c new file +138
-0@@ -0,0 +1,148 @@ +/* +* Library to support early TI EVM EEPROM handling +* +* Copyright (C) 2015 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.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. +*/ +int __maybe_unused ti_i2c_eeprom_init (int i2c_bus,int dev_addr) +{ +int rc; + + 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 +*/ +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. +*/ +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 ; + } +} + +int __maybe_unused ti_i2c_eeprom_am_get (int bus_addr,int dev_addr, +struct ti_am_eeprom **epp) +{ +int rc; +struct ti_am_eeprom *ep; + +if (!epp) +return -1 ; + + ep =TI_AM_EEPROM_DATA ; +if (ep->header ==TI_EEPROM_HEADER_MAGIC ) + goto already_read; + +/* Initialize with a known bad marker for i2c fails.. */ + ep->header =0xADEAD12C ; + +gpi2c_init (); + rc =ti_i2c_eeprom_init (bus_addr, dev_addr); +if (rc) +return rc; + rc =i2c_read (dev_addr,0x0 ,2 , (uint8_t *)ep,sizeof (*ep)); +if (rc) +return rc; + +/* Corrupted data??? */ +if (ep->header !=TI_EEPROM_HEADER_MAGIC ) +return -1 ; + +already_read: + *epp = ep; + +return 0 ; +} + +int __maybe_unused ti_i2c_eeprom_am_get_print (int bus_addr,int dev_addr, +struct ti_am_eeprom_printable *p) +{ +struct ti_am_eeprom *ep; +int rc; + +/* Incase of invalid eeprom contents */ + p->name[0 ] =0x00 ; + p->version[0 ] =0x00 ; + p->serial[0 ] =0x00 ; + + rc =ti_i2c_eeprom_am_get (bus_addr, dev_addr, &ep); +if (rc) +return rc; + +/* +* Alas! we have to null terminate and cleanup the strings! +*/ +strlcpy (p->name, ep->name,TI_EEPROM_HDR_NAME_LEN ); +ti_eeprom_string_cleanup (p->name); +strlcpy (p->version, ep->version,TI_EEPROM_HDR_NAME_LEN ); +ti_eeprom_string_cleanup (p->version); +strlcpy (p->serial, ep->serial,TI_EEPROM_HDR_NAME_LEN ); +ti_eeprom_string_cleanup (p->serial); +return 0 ; +} + +void __maybe_unused set_board_info_env (char *name,char *revision, +char *serial) +{ +char *unknown ="unknown" ; + +if (name) +setenv ("board_name" , name); +
board/ti/common/ti-i2c-eeprom.c line 148
Quoted 10 lines
board/ti/common/ti-i2c-eeprom.c new file +10
-0+if (revision) +setenv ("board_revision" , revision); +else +setenv ("board_revision" , unknown); + +if (serial) +setenv ("board_serial" , serial); +else +setenv ("board_serial" , unknown); +}
I just think a single file should be sufficient here.
Signature · 2 lines
Regards, Nishanth Menon
PATCH v3 3/5 ARM: omap-common: Add standard access for board description EEPROM
On 11/04/2015 05:43 PM, Nishanth Menon wrote:
[...]
Quoted 9 lines
board/ti/am57xx/Makefile line 9
Quoted 8 lines
index
5cd6873f5e97..9d85d31b2cf1100644board/ti/am57xx/Makefile +1
-0@@ -6,3 +6,5 @@ # obj-y := board.o +obj-y += ../common/board.o
One final comment on the ../common/board.o:
all we need is:
board/ti/common/Makefile
which contains:
obj-${CONFIG_I2C} += board-detect.o
That should build it for all TI platforms and then optimize link time using __maybe_unused.
This also removes the cruft of including specific headers since root Makefile already will enable flag HAVE_VENDOR_COMMON_LIB if a Makefile exists in board/{vendor}/common/ directory, and will build accordingly.
This makes sense now since the entire series claims commonality and should allow us to remove stuff from am335x/437x following this series by just using the APIs.
Signature · 2 lines
Regards, Nishanth Menon
PATCH v3 3/5 ARM: omap-common: Add standard access for board description EEPROM
In reply to Steve Kipiszboard/ti/common/board.h
Quoted 154 lines · Steve Kipisz
From: Lokesh Vutla <[email protected]>
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 I2C is enabled, even non-TI boards that do not have the EEPROM. If the functions are not used, they will not be linked in.
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.
The follow on patches introduce the use of this library for AM57x platform support. AM335x/AM43xx cleanups need to first ensure usage of
omap_commonprior to switch over to this generic solution.Signed-off-by Lokesh Vutla <[email protected]>Signed-off-by Steve Kipisz <[email protected]>---
v3 Based on:
master83bf0057arm: at91: reworked meesc board supportChanges in v3 (since v2):
- Create a new directory board/ti/common for code common to TI board
- Move the EEPROM code to the new directory
- Move the inline code that access the EEPROM data fromomap_common.hto new files in the common directoryv2: http://marc.info/?t=144655344800001&r=1&w=2
(mailing list squashed original submission)Changes in v2:
- New Patcharch/arm/include/asm/omap_common.h | 5 +- board/ti/am57xx/Makefile | 2 + board/ti/common/board.c | 54 ++++++++++++++ board/ti/common/board.h | 117 +++++++++++++++++++++++++++++ board/ti/common/ti-i2c-eeprom.c | 148 +++++++++++++++++++++++++++++++++++++ 5 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 board/ti/common/board.c create mode 100644 board/ti/common/board.h create mode 100644 board/ti/common/ti-i2c-eeprom.carch/arm/include/asm/omap_common.h +4
-1@@ -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@@ -728,4 +730,5 @@ static inline u8 is_dra72x(void)u32 omap_sys_boot_device (void );#endif +#endif /* _OMAP_COMMON_H_ */ board/ti/am57xx/Makefile +2
-0@@ -6,3 +6,5 @@ # obj-y := board.o +obj-y += ../common/board.o +obj-${CONFIG_I2C} += ../common/ti-i2c-eeprom.oboard/ti/common/board.c new file +54
-0@@ -0,0 +1,54 @@ +/* +* board.c +* +* Common board functions for TI AMxxxx based boards. +* +* Copyright (C) 2015, Texas Instruments Incorporated - http://www.ti.com +* +* Author: Steven Kipisz <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <asm/omap_common.h> + +#include "board.h" + +/** +* board_am_is() - Generic Board detection logic +* @name_tag: Tag used in eeprom for the board +* +* Return: false if board information does not match OR eeprom was'nt read. +* true otherwise +*/ +bool board_am_is (char *name_tag) +{ +struct ti_am_eeprom *ep =TI_AM_EEPROM_DATA ; + +if (ep->header !=TI_EEPROM_HEADER_MAGIC ) +return false; +return !strncmp (ep->name, name_tag,TI_EEPROM_HDR_NAME_LEN ); +} + +/** +* board_am_rev_is() - Compare board revision +* @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_am_rev_is (char *rev_tag,int cmp_len) +{ +struct ti_am_eeprom *ep =TI_AM_EEPROM_DATA ; +int l; + +if (ep->header !=TI_EEPROM_HEADER_MAGIC ) +return false; + + l = cmp_len >TI_EEPROM_HDR_REV_LEN ?TI_EEPROM_HDR_NAME_LEN : cmp_len; +return !strncmp (ep->version, rev_tag, l); +}board/ti/common/board.h new file +0
-0
May be keep this header file under arch/arm/include/asm/ so that it can be included properly.
Thanks and regards,
Lokesh
Quoted 273 lines
board/ti/common/board.h new file +117
-0@@ -0,0 +1,117 @@ +/* +* board.h +* TI AMxxxx common board information header +* +* Copyright (C) 2015, Texas Instruments, Incorporated - http://www.ti.com +* +* SPDX-L icense-Identifier: GPL-2.0+ +*/ + +/* Common I2C eeprom definitions */ +#ifndef __ASSEMBLY__ + +/* TI EEPROM MAGIC Header identifier */ +#define TI_EEPROM_HEADER_MAGIC 0xEE3355AA + +#define TI_EEPROM_HDR_NAME_LEN 8 +#define TI_EEPROM_HDR_REV_LEN 12 +#define TI_EEPROM_HDR_SERIAL_LEN 4 +#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_am_eeprom_printable - Null terminated, printable EEPROM contents +* @name: NULL terminated name +* @version: NULL terminated version +* @serial: NULL terminated serial number +*/ +struct ti_am_eeprom_printable { +char name[TI_EEPROM_HDR_NAME_LEN +1 ]; +char version[TI_EEPROM_HDR_REV_LEN +1 ]; +char serial[TI_EEPROM_HDR_SERIAL_LEN +1 ]; +}; +#define TI_AM_EEPROM_DATA ((struct ti_am_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: Pointer to eeprom structure +* +* *ep is populated by the this AM generic function that consolidates +* the basic initialization logic common accross all AM* platforms. +*/ +int ti_i2c_eeprom_am_get (int bus_addr,int dev_addr,struct ti_am_eeprom **epp); + +/** +* ti_i2c_eeprom_am_get_print() - Get a printable representation of eeprom data +* @bus_addr: I2C bus address +* @dev_addr: I2C slave address +* @p: Pointer to eeprom structure +* +* This reads the eeprom and converts the data into a printable string for +* further processing. +*/ +int ti_i2c_eeprom_am_get_print (int bus_addr,int dev_addr, +struct ti_am_eeprom_printable *p); + +/** +* set_board_info_env() - Setup commonly used board information environment vars +* @name: Name of the board +* @revision: Revision of the board +* @serial: Serial Number of the board +* +* In case of NULL revision or serial information "unknown" is setup. +* If name is NULL, default_name is used. +*/ +void set_board_info_env (char *name,char *revision, +char *serial); + +/** +* board_am_is() - Generic Board detection logic +* @name_tag: Tag used in eeprom for the board +* +* Return: false if board information does not match OR eeprom was'nt read. +* true otherwise +*/ +bool board_am_is (char *name_tag); + +/** +* board_am_rev_is() - Compare board revision +* @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_am_rev_is (char *rev_tag,int cmp_len); + +#endif /* __ASSEMBLY__ */ board/ti/common/ti-i2c-eeprom.c new file +148
-0@@ -0,0 +1,148 @@ +/* +* Library to support early TI EVM EEPROM handling +* +* Copyright (C) 2015 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.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. +*/ +int __maybe_unused ti_i2c_eeprom_init (int i2c_bus,int dev_addr) +{ +int rc; + + 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 +*/ +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. +*/ +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 ; + } +} + +int __maybe_unused ti_i2c_eeprom_am_get (int bus_addr,int dev_addr, +struct ti_am_eeprom **epp) +{ +int rc; +struct ti_am_eeprom *ep; + +if (!epp) +return -1 ; + + ep =TI_AM_EEPROM_DATA ; +if (ep->header ==TI_EEPROM_HEADER_MAGIC ) + goto already_read; + +/* Initialize with a known bad marker for i2c fails.. */ + ep->header =0xADEAD12C ; + +gpi2c_init (); + rc =ti_i2c_eeprom_init (bus_addr, dev_addr); +if (rc) +return rc; + rc =i2c_read (dev_addr,0x0 ,2 , (uint8_t *)ep,sizeof (*ep)); +if (rc) +return rc; + +/* Corrupted data??? */ +if (ep->header !=TI_EEPROM_HEADER_MAGIC ) +return -1 ; + +already_read: + *epp = ep; + +return 0 ; +} + +int __maybe_unused ti_i2c_eeprom_am_get_print (int bus_addr,int dev_addr, +struct ti_am_eeprom_printable *p) +{ +struct ti_am_eeprom *ep; +int rc; + +/* Incase of invalid eeprom contents */ + p->name[0 ] =0x00 ; + p->version[0 ] =0x00 ; + p->serial[0 ] =0x00 ; + + rc =ti_i2c_eeprom_am_get (bus_addr, dev_addr, &ep); +if (rc) +return rc; + +/* +* Alas! we have to null terminate and cleanup the strings! +*/ +strlcpy (p->name, ep->name,TI_EEPROM_HDR_NAME_LEN ); +ti_eeprom_string_cleanup (p->name); +strlcpy (p->version, ep->version,TI_EEPROM_HDR_NAME_LEN ); +ti_eeprom_string_cleanup (p->version); +strlcpy (p->serial, ep->serial,TI_EEPROM_HDR_NAME_LEN ); +ti_eeprom_string_cleanup (p->serial); +return 0 ; +} + +void __maybe_unused set_board_info_env (char *name,char *revision, +char *serial) +{ +char *unknown ="unknown" ; + +if (name) +setenv ("board_name" , name); + +if (revision) +setenv ("board_revision" , revision); +else +setenv ("board_revision" , unknown); + +if (serial) +setenv ("board_serial" , serial); +else +setenv ("board_serial" , unknown); +}
PATCH v3 3/5 ARM: omap-common: Add standard access for board description EEPROM
On 11/05/2015 12:00 AM, Lokesh Vutla wrote:
[...]
Quoted 9 lines
board/ti/common/board.h
Quoted 5 lines
board/ti/common/board.h new file +0
-0May be keep this header file under
arch/arm/include/asm/so that it can be included properly.
if we do something like this: then we'd not have to add cruft to the generic location..
Makefile +0 -0
@@ -620,6 +620,7 @@ c_flags := $(KBUILD_CFLAGS) $(cpp_flags) # U-Boot objects....order is important (i.e. start must be first) HAVE_VENDOR_COMMON_LIB = $(if $(wildcard
$(srctree)/board/$(VENDOR)/common/Makefile),y,n) +UBOOTINCLUDE += $(if $(HAVE_VENDOR_COMMON_LIB:y=1), -I$(srctree)/board/$(VENDOR)/common)
libs-y += lib/
libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
Signature · 2 lines
Regards, Nishanth Menon
PATCH v3 4/5 ARM: OMAP4/5: Add generic board detection hook
In reply to Steve KipiszMany 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.
---
v3 Based on:
master 83bf0057 arm: at91: reworked meesc board support
Changes in v3 (since v2):
- No changes
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(+)
arch/arm/cpu/armv7/omap-common/hwinit-common.c +11 -0
@@ -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 (); }
arch/arm/include/asm/arch-omap4/sys_proto.h +1 -0
@@ -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 );
arch/arm/include/asm/arch-omap5/sys_proto.h +1 -0
@@ -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 );
Signature · 1 line
1.9.1
PATCH v3 4/5 ARM: OMAP4/5: Add generic board detection hook
Quoted 11 lines · Steve Kipisz
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.
Thanks and regards,
Lokesh
Quoted 75 lines
Signed-off-by Steve Kipisz <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v3 Based on:
master83bf0057arm: at91: reworked meesc board supportChanges in v3 (since v2):
- No changesv2: http://marc.info/?t=144655344600006&r=1&w=2
(mailing list squashed original submission)Changes in v2:
- New patcharch/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(+)arch/arm/cpu/armv7/omap-common/hwinit-common.c +11
-0@@ -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 (); }arch/arm/include/asm/arch-omap4/sys_proto.h +1
-0@@ -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 );arch/arm/include/asm/arch-omap5/sys_proto.h +1
-0@@ -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 );
PATCH v3 5/5 board: ti: AM57xx: Add detection logic for AM57xx-evm
In reply to Steve KipiszCurrent 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.
---
v3 Based on:
master 83bf0057 arm: at91: reworked meesc board support
Build testing: MAKEALL -s omap4 -s omap5 (no warning/build errors)
Boot Testing: am57xx_evm_nodt_config: http://pastebin.ubuntu.com/13105264/
Changes in v3 (since v2):
- Rename is_xxx to board_is_xxx
- Remove usage of default_name and default to beagle_x15 if there are errors reading the EEPROM
v2: http://marc.info/?t=144655344600003&r=1&w=2
(mailing list squashed original submission)
Build testing: MAKEALL -s omap4 -s omap5 (no warnings/build errors)
Boot Testing: am57xx_evm_nodt_config: http://pastebin.ubuntu.com/13039296/ beagle_x15_config: http://pastebin.ubuntu.com/13039331/
Changes in v2 (since v1):
- move the board detection code into the new routine do_board_detect
- eliminate board.h and move the ix_xxx into board.c
- redo commit message to be more clear
v1: http://marc.info/?t=144608007900002&r=1&w=2
http://marc.info/?t=144608007900004&r=1&w=2
(mailing list squashed original submission)
board/ti/am57xx/board.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/configs/am57xx_evm.h | 4 ++++ 2 files changed, 56 insertions(+)
board/ti/am57xx/board.c +52 -0
@@ -31,6 +31,10 @@#include <ti-usb-phy-uboot.h> #include "mux_data.h" +#include "../common/board.h" + +#define board_is_x15 () board_am_is("BBRDX15_") +#define board_is_am572x_evm () board_am_is("AM572PM_")#ifdef CONFIG_DRIVER_TI_CPSW #include <cpsw.h>
@@ -246,6 +250,52 @@ 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 ) +{ +struct ti_am_eeprom *ep; +int rc; + + rc =ti_i2c_eeprom_am_get (CONFIG_EEPROM_BUS_ADDRESS , +CONFIG_EEPROM_CHIP_ADDRESS , &ep); +if (rc) +printf ("ti_i2c_eeprom_init failed %d\n" , rc); +} + +#else /* CONFIG_SPL_BUILD */ + +static void setup_board_eeprom_env (void ) +{ +char *name ="beagle_x15" ; +int rc; +struct ti_am_eeprom_printable p; + + rc =ti_i2c_eeprom_am_get_print (CONFIG_EEPROM_BUS_ADDRESS , +CONFIG_EEPROM_CHIP_ADDRESS , &p); +if (rc) { +printf ("Invalid EEPROM data(@0x%p). Default to X15\n" , +TI_AM_EEPROM_DATA ); + goto invalid_eeprom; + } + +if (board_is_am572x_evm ()) + name ="am57xx_evm" ; +else +printf ("Unidentified board claims %s in eeprom header\n" , + p.name); + +invalid_eeprom: +set_board_info_env (name, p.version, p.serial); +} + +/* Eeprom is alread read by SPL.. nothing more to do here.. */ + +#endif /* CONFIG_SPL_BUILD */ +void hw_data_init (void ) { *prcm = &dra7xx_prcm;
@@ -265,6 +315,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.
include/configs/am57xx_evm.h +4 -0
@@ -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 */
Signature · 1 line
1.9.1
v3 cover ARM: omap-common: Add board detection support for TI EVMs
In reply to Steve KipiszQuoted 17 lines · Steve Kipisz
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.
Lokesh Vutla (1):
ARM: omap-common: Add standard access for board description EEPROMSteve Kipisz (4):
ARM: OMAP4/5: Centralize early clock initialization
ARM: OMAP4/5: Centralizegpi2c_init
ARM: OMAP4/5: Add generic board detection hook
board: ti: AM57xx: Add detection logic for AM57xx-evm
Quoted 16 lines
arch/arm/cpu/armv7/omap-common/clocks-common.c | 21 +++- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 14 ++- 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 | 8 +- board/ti/am57xx/Makefile | 2 + board/ti/am57xx/board.c | 52 +++++++++ board/ti/common/board.c | 54 +++++++++ board/ti/common/board.h | 117 +++++++++++++++++++ board/ti/common/ti-i2c-eeprom.c | 148 +++++++++++++++++++++++++ include/configs/am57xx_evm.h | 4 + 11 files changed, 419 insertions(+), 9 deletions(-) create mode 100644 board/ti/common/board.c create mode 100644 board/ti/common/board.h create mode 100644 board/ti/common/ti-i2c-eeprom.c
In the future, please:
a) CC beagleboard-x15 mailing list (beagleboard-x15 <[email protected]>)
b) CC previous reviewers: I think I dont see Igor
(grinberg at compulab.co.il) in CC list. it is a good practice to cc previous reviewers because, we dont always watch all emails coming to the list and you'd like to respect the time and effort reviewers put in when sending newer revisions.
c) even though I see that you have provided in-context of each patch what the changes are (that is good), it is usually better to add to the covering letter what the v1,v2 links were, and also what the baseline for this series is - in this case, you do depend on
https://patchwork.ozlabs.org/patch/538046/ - and should be highlighted in cover-letter and reiterated in the corresponding patch.
d) provide links to test logs in cover-letter. most of folks do not possess x15 and evms - While I do realize that you have covered that data in the patch #5, personally, I dont usually review patches that are'nt even tested - and I personally respect the patches that tell me upfront in cover letter than the patches have been tested and links to the same.
e) provide the baseline for the patches in cover letter, instead of repeating them over and over in each of the patches. it is a series, and patches following will depend on previous patches. For example, your patch #5 claims:
"v3 Based on:
master 83bf0057 arm: at91: reworked meesc board support"
That is not really true - because you do depend on x15 rename patch. If I attempt to apply this series on current u-boot master, I will fail and that does not give me a good impression of the series overall.
Apologies on ranting about this, but I'd thought it might help you give a better perspective of what, at least I, as a reviewer would like to see in a series.
Signature · 2 lines
Regards, Nishanth Menon