Skip to contentSkip to conversation

ARM: OMAP4/5: Centralize early clock initialization

PATCH Superseded Steve Kipisz 5 participants 19 messages Nov 6, 2015 – Nov 10, 2015 Arm (32-bit)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/7 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.

---
Changes in v4 (since v3):
- Picked up Reviewed-by

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(-)
arch/arm/cpu/armv7/omap-common/clocks-common.c +19 -2
index e28b79568d1d..367d224361be 100644
@@ -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
index 80794f9c611a..91f2dead364b 100644
@@ -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
index f30f86539130..71e3d776aa0d 100644
@@ -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
index 7fcb78389403..b9e09e7c52a8 100644
@@ -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
#1 lore raw

PATCH v4 2/7 ARM: OMAP4/5: Centralize gpi2c_init

Centralize gpi2c_init into omap_common from the sys_proto header so that the information can be reused across SoCs.

---
Changes in v4 (since v3):
- Picked up Reviewed-by

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(-)
arch/arm/include/asm/arch-omap4/sys_proto.h +0 -1
index 71e3d776aa0d..26e9a194f036 100644
@@ -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
index b9e09e7c52a8..18902628739b 100644
@@ -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
index d7b81c101b79..d773b0430ad4 100644
@@ -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
#2 lore raw

PATCH v4 3/7 ARM: omap-common: Add standard access for board description EEPROM

In reply to 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 AM335x, AM437x, and AM57xx.

---
Changes in v4 (since v3):
- Now depends on https://patchwork.ozlabs.org/patch/540280/
- Started using __maybe_unused for compiler optimization for platforms that do not require it
- Added a weak function for gpi2c_init
- Merge board.c and ti-i2c-eeprom.c into one file board-detect.c
- Rename board.h to board-detect.h
- unexported functions are static
- exported function documentation exists only in header
- in case of 2 byte read fail, attempt 1 byte read (to keep am335x legacy platforms functional)

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/Makefile           |   6 ++
 board/ti/common/board_detect.c     | 189 +++++++++++++++++++++++++++++++++++++
 board/ti/common/board_detect.h     | 117 +++++++++++++++++++++++
 4 files changed, 315 insertions(+), 1 deletion(-)
 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
arch/arm/include/asm/omap_common.h +3 -1
index d773b0430ad4..aef31266ce9e 100644
@@ -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
board/ti/common/Makefile new file +6 -0
new file mode 100644
index 000000000000..267d73556fd3
@@ -0,0 +1,6 @@
+# Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-${CONFIG_I2C} += board_detect.o
board/ti/common/board_detect.c new file +189 -0

189 lines not on this page · raw message

board/ti/common/board_detect.h new file +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v4 3/7 ARM: omap-common: Add standard access for board description EEPROM

Quoted 26 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.

Quoted 5 lines

The follow on patches introduce the use of this library for AM335x, AM437x, and AM57xx.

Signature · 2 lines
Regards,
Igor.
#4 lore raw

PATCH v4 3/7 ARM: omap-common: Add standard access for board description EEPROM

In reply to Steve Kipisz
Quoted 26 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.

Quoted 5 lines

The follow on patches introduce the use of this library for AM335x, AM437x, and AM57xx.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/85e1d045/attachment.sig>
#5 lore raw

PATCH v4 3/7 ARM: omap-common: Add standard access for board description EEPROM

In reply to Steve Kipisz

On 11/05/2015 06:39 PM, Steve Kipisz wrote:
[...]

Quoted 5 lines
board/ti/common/board_detect.c new file +0 -0
new file mode 100644
index 000000000000..3d2b1bb1465e

[...]

Quoted 11 lines
board/ti/common/board_detect.c new file +11 -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;
+

board/ti/common/board_detect.c line 142

Quoted 10 lines
board/ti/common/board_detect.c new file +10 -0
+	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);

s/TI_EEPROM_HDR_NAME_LEN/TI_EEPROM_HDR_REV_LEN ?

board/ti/common/board_detect.c line 144

Quoted 2 lines
board/ti/common/board_detect.c new file +2 -0
+	ti_eeprom_string_cleanup(p->version);
+	strlcpy(p->serial, ep->serial, TI_EEPROM_HDR_NAME_LEN);

s/TI_EEPROM_HDR_NAME_LEN/TI_EEPROM_HDR_SERIAL_LEN?

Quoted 12 lines
board/ti/common/board_detect.c new file +12 -0
+	ti_eeprom_string_cleanup(p->serial);
+	return 0;
+}
+
+bool __maybe_unused 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/ti/common/board_detect.c line 166

Quoted 10 lines
board/ti/common/board_detect.c new file +10 -0
+
+bool __maybe_unused 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;

s/TI_EEPROM_HDR_NAME_LEN/TI_EEPROM_HDR_REV_LEN/ ?

Quoted 3 lines
board/ti/common/board_detect.c new file +3 -0
+	return !strncmp(ep->version, rev_tag, l);
+}
+

[...]

Signature · 2 lines
Regards,
Nishanth Menon
#6 lore raw

PATCH v4 3/7 ARM: omap-common: Add standard access for board description EEPROM

In reply to Steve Kipisz

On 11/05/2015 06:39 PM, Steve Kipisz wrote:
[...]

board/ti/common/board_detect.h line 17

Quoted 3 lines
board/ti/common/board_detect.h new file +3 -0
+#define TI_EEPROM_HDR_NAME_LEN		8
+#define TI_EEPROM_HDR_REV_LEN		12
+#define TI_EEPROM_HDR_SERIAL_LEN	4

^^ minor typo here as well. Serial should be 12 and REV is 4.

[...]

Signature · 2 lines
Regards,
Nishanth Menon
#7 lore raw

PATCH v4 4/7 ti: am335x: Use generic EEPROM detection logic

In reply to Steve Kipisz

From: Nishanth Menon <[email protected]>

Use the generic EEPROM detection logic instead of duplicating the AM eeprom logic.

---
Changes in v4:
- New Patch
- Depends on https://patchwork.ozlabs.org/patch/540280/

 board/ti/am335x/board.c | 99 +++++++++++++++----------------------------------
 board/ti/am335x/board.h | 42 ++++++---------------
 board/ti/am335x/mux.c   | 11 +++---
 3 files changed, 48 insertions(+), 104 deletions(-)
board/ti/am335x/board.c +30 -69
index f0cb1e204ad5..1f9707d60c1f 100644
@@ -31,6 +31,7 @@
 #include <environment.h>
 #include <watchdog.h>
 #include <environment.h>
+#include <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 int __maybe_unused read_eeprom(struct ti_am_eeprom **header)
 {
-	/* 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, header);
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -223,7 +190,7 @@ const struct dpll_params dpll_ddr_bone_black = {
 
 void am33xx_spl_board_init(void)
 {
-	struct am335x_baseboard_id header;
+	struct ti_am_eeprom *header;
 	int mpu_vdd;
 
 	if (read_eeprom(&header) < 0)
@@ -232,7 +199,7 @@ void am33xx_spl_board_init(void)
 	/* 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,7 +207,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,
+		if (board_is_bone() && !strncmp(header->version,
 						       "00A1", 4))
 			return;
 
@@ -251,7 +218,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 +233,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 +274,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 +334,18 @@ void am33xx_spl_board_init(void)
 
 const struct dpll_params *get_dpll_ddr_params(void)
 {
-	struct am335x_baseboard_id header;
+	struct ti_am_eeprom *header;
 
 	enable_i2c0_pin_mux();
 	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 	if (read_eeprom(&header) < 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(header))
 		return &dpll_ddr_evm_sk;
 	else
 		return &dpll_ddr;
@@ -403,12 +370,12 @@ void set_uart_mux_conf(void)
 
 void set_mux_conf_regs(void)
 {
-	__maybe_unused struct am335x_baseboard_id header;
+	__maybe_unused struct ti_am_eeprom *header;
 
 	if (read_eeprom(&header) < 0)
 		puts("Could not get board ID.\n");
 
-	enable_board_pin_mux(&header);
+	enable_board_pin_mux(header);
 }
 
 const struct ctrl_ioregs ioregs_evmsk = {
@@ -445,12 +412,12 @@ const struct ctrl_ioregs ioregs = {
 
 void sdram_init(void)
 {
-	__maybe_unused struct am335x_baseboard_id header;
+	__maybe_unused struct ti_am_eeprom *header;
 
 	if (read_eeprom(&header) < 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 +426,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(header))
 		config_ddr(303, &ioregs_evm15, &ddr3_evm_data,
 			   &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);
 	else
@@ -496,20 +463,14 @@ 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;
+	struct ti_am_eeprom_printable p;
+	int rc;
 
-	if (read_eeprom(&header) < 0)
-		puts("Could not get board ID.\n");
+	rc = ti_i2c_eeprom_am_get_print(-1, CONFIG_SYS_I2C_EEPROM_ADDR, &p);
 
-	/* 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);
+	if (rc)
+		puts("Could not get board ID.\n");
+	set_board_info_env(p.name, p.version, p.serial);
 #endif
 
 	return 0;
@@ -581,7 +542,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);
@@ -621,8 +582,8 @@ int board_eth_init(bd_t *bis)
 	if (read_eeprom(&header) < 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(header)) {
 		writel(MII_MODE_ENABLE, &cdev->miisel);
 		cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
 				PHY_INTERFACE_MODE_MII;
@@ -651,7 +612,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();
 
board/ti/am335x/board.h +12 -30

69 lines not on this page · raw message

board/ti/am335x/mux.c +6 -5
index 28c29a2f9cba..6bffa91c24c9 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/mux.h>
 #include <asm/io.h>
 #include <i2c.h>
+#include <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(struct ti_am_eeprom *header)
 {
 	/* Do board-specific muxes. */
-	if (board_is_bone(header)) {
+	if (board_is_bone()) {
 		/* Beaglebone pinmux */
 		configure_module_pin_mux(i2c1_pin_mux);
 		configure_module_pin_mux(mii1_pin_mux);
@@ -327,7 +328,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);
@@ -348,13 +349,13 @@ void enable_board_pin_mux(struct am335x_baseboard_id *header)
 		/* 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(i2c1_pin_mux);
 		configure_module_pin_mux(mii1_pin_mux);
Signature · 1 line
1.9.1
#8 lore raw

PATCH v4 4/7 ti: am335x: Use generic EEPROM detection logic

Quoted 7 lines · Steve Kipisz

From: Nishanth Menon <[email protected]>

Use the generic EEPROM detection logic instead of duplicating the AM eeprom logic.

Thanks and regards,
Lokesh

Quoted 376 lines

---
Changes in v4:
- New Patch
- Depends on https://patchwork.ozlabs.org/patch/540280/

 board/ti/am335x/board.c | 99 +++++++++++++++----------------------------------
 board/ti/am335x/board.h | 42 ++++++---------------
 board/ti/am335x/mux.c   | 11 +++---
 3 files changed, 48 insertions(+), 104 deletions(-)
board/ti/am335x/board.c +30 -69
index f0cb1e204ad5..1f9707d60c1f 100644
@@ -31,6 +31,7 @@
 #include <environment.h>
 #include <watchdog.h>
 #include <environment.h>
+#include <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 int __maybe_unused read_eeprom(struct ti_am_eeprom **header)
 {
-	/* 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, header);
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -223,7 +190,7 @@ const struct dpll_params dpll_ddr_bone_black = {
 
 void am33xx_spl_board_init(void)
 {
-	struct am335x_baseboard_id header;
+	struct ti_am_eeprom *header;
 	int mpu_vdd;
 
 	if (read_eeprom(&header) < 0)
@@ -232,7 +199,7 @@ void am33xx_spl_board_init(void)
 	/* 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,7 +207,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,
+		if (board_is_bone() && !strncmp(header->version,
 						       "00A1", 4))
 			return;
 
@@ -251,7 +218,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 +233,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 +274,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 +334,18 @@ void am33xx_spl_board_init(void)
 
 const struct dpll_params *get_dpll_ddr_params(void)
 {
-	struct am335x_baseboard_id header;
+	struct ti_am_eeprom *header;
 
 	enable_i2c0_pin_mux();
 	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 	if (read_eeprom(&header) < 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(header))
 		return &dpll_ddr_evm_sk;
 	else
 		return &dpll_ddr;
@@ -403,12 +370,12 @@ void set_uart_mux_conf(void)
 
 void set_mux_conf_regs(void)
 {
-	__maybe_unused struct am335x_baseboard_id header;
+	__maybe_unused struct ti_am_eeprom *header;
 
 	if (read_eeprom(&header) < 0)
 		puts("Could not get board ID.\n");
 
-	enable_board_pin_mux(&header);
+	enable_board_pin_mux(header);
 }
 
 const struct ctrl_ioregs ioregs_evmsk = {
@@ -445,12 +412,12 @@ const struct ctrl_ioregs ioregs = {
 
 void sdram_init(void)
 {
-	__maybe_unused struct am335x_baseboard_id header;
+	__maybe_unused struct ti_am_eeprom *header;
 
 	if (read_eeprom(&header) < 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 +426,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(header))
 		config_ddr(303, &ioregs_evm15, &ddr3_evm_data,
 			   &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);
 	else
@@ -496,20 +463,14 @@ 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;
+	struct ti_am_eeprom_printable p;
+	int rc;
 
-	if (read_eeprom(&header) < 0)
-		puts("Could not get board ID.\n");
+	rc = ti_i2c_eeprom_am_get_print(-1, CONFIG_SYS_I2C_EEPROM_ADDR, &p);
 
-	/* 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);
+	if (rc)
+		puts("Could not get board ID.\n");
+	set_board_info_env(p.name, p.version, p.serial);
 #endif
 
 	return 0;
@@ -581,7 +542,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);
@@ -621,8 +582,8 @@ int board_eth_init(bd_t *bis)
 	if (read_eeprom(&header) < 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(header)) {
 		writel(MII_MODE_ENABLE, &cdev->miisel);
 		cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
 				PHY_INTERFACE_MODE_MII;
@@ -651,7 +612,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();
 
board/ti/am335x/board.h +12 -30
index bc700d56fece..14b2469df12d 100644
@@ -11,52 +11,34 @@
 #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(struct am335x_baseboard_id *header)
+static inline int board_is_bone(void)
 {
-	return !strncmp(header->name, "A335BONE", HDR_NAME_LEN);
+	return board_am_is("A335BONE");
 }
 
-static inline int board_is_bone_lt(struct am335x_baseboard_id *header)
+static inline int board_is_bone_lt(void)
 {
-	return !strncmp(header->name, "A335BNLT", HDR_NAME_LEN);
+	return board_am_is("A335BNLT");
 }
 
-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_am_is("A335X_SK");
 }
 
-static inline int board_is_idk(struct am335x_baseboard_id *header)
+static inline int board_is_idk(struct ti_am_eeprom *header)
 {
 	return !strncmp(header->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_am_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(struct ti_am_eeprom *header)
 {
-	return (board_is_gp_evm(header) &&
+	return (board_is_gp_evm() &&
 		strncmp("1.5", header->version, 3) <= 0);
 }
 
@@ -73,5 +55,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(struct ti_am_eeprom *header);
 #endif
board/ti/am335x/mux.c +6 -5
index 28c29a2f9cba..6bffa91c24c9 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/mux.h>
 #include <asm/io.h>
 #include <i2c.h>
+#include <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(struct ti_am_eeprom *header)
 {
 	/* Do board-specific muxes. */
-	if (board_is_bone(header)) {
+	if (board_is_bone()) {
 		/* Beaglebone pinmux */
 		configure_module_pin_mux(i2c1_pin_mux);
 		configure_module_pin_mux(mii1_pin_mux);
@@ -327,7 +328,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);
@@ -348,13 +349,13 @@ void enable_board_pin_mux(struct am335x_baseboard_id *header)
 		/* 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(i2c1_pin_mux);
 		configure_module_pin_mux(mii1_pin_mux);
#9 lore raw

PATCH v4 4/7 ti: am335x: Use generic EEPROM detection logic

In reply to Steve Kipisz
Quoted 7 lines · Steve Kipisz

From: Nishanth Menon <[email protected]>

Use the generic EEPROM detection logic instead of duplicating the AM eeprom logic.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/7ce7625c/attachment.sig>
#10 lore raw

PATCH v4 5/7 ti: AM437x: Use generic EEPROM detection logic

In reply to Steve Kipisz

From: Nishanth Menon <[email protected]>

Now that we have a generic TI eeprom logic which can be reused accross platforms, reuse the same.

---
Changes in v4:
- New patch
- depends on https://patchwork.ozlabs.org/patch/540280/

 board/ti/am43xx/board.c | 86 ++++++++++++++++---------------------------------
 board/ti/am43xx/board.h | 41 ++++++-----------------
 board/ti/am43xx/mux.c   |  1 +
 3 files changed, 38 insertions(+), 90 deletions(-)
board/ti/am43xx/board.c +27 -59
index 770726c3f796..ea64672606e9 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/ddr_defs.h>
 #include <asm/arch/gpio.h>
 #include <asm/emif.h>
+#include <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 int __maybe_unused read_eeprom(struct ti_am_eeprom **header)
 {
-	/* 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, header);
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -373,6 +335,10 @@ static u32 get_sys_clk_index(void)
 const struct dpll_params *get_dpll_ddr_params(void)
 {
 	int ind = get_sys_clk_index();
+	struct ti_am_eeprom *header;
+
+	if (read_eeprom(&header) < 0)
+		return NULL;
 
 	if (board_is_eposevm())
 		return &epos_evm_dpll_ddr[ind];
@@ -381,7 +347,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", header->name);
 	return NULL;
 }
 
@@ -512,13 +478,17 @@ void scale_vcores_idk(u32 m)
 	}
 }
 
+void gpi2c_init(void)
+{
+	enable_i2c0_pin_mux();
+	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
+}
+
 void scale_vcores(void)
 {
 	const struct dpll_params *mpu_params;
-	struct am43xx_board_id header;
+	struct ti_am_eeprom *header;
 
-	enable_i2c0_pin_mux();
-	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 	if (read_eeprom(&header) < 0)
 		puts("Could not get board ID.\n");
 
@@ -558,6 +528,10 @@ static void enable_vtt_regulator(void)
 
 void sdram_init(void)
 {
+	struct ti_am_eeprom *header;
+
+	if (read_eeprom(&header) < 0)
+		return;
 	/*
 	 * EPOS EVM has 1GB LPDDR2 connected to EMIF.
 	 * GP EMV has 1GB DDR3 connected to EMIF
@@ -565,11 +539,11 @@ void sdram_init(void)
 	 */
 	if (board_is_eposevm()) {
 		config_ddr(0, &ioregs_lpddr2, NULL, NULL, &emif_regs_lpddr2, 0);
-	} else if (board_is_evm_14_or_later()) {
+	} else if (board_is_evm_14_or_later(header)) {
 		enable_vtt_regulator();
 		config_ddr(0, &ioregs_ddr3, NULL, NULL,
 			   &ddr3_emif_regs_400Mhz_production, 0);
-	} else if (board_is_evm_12_or_later()) {
+	} else if (board_is_evm_12_or_later(header)) {
 		enable_vtt_regulator();
 		config_ddr(0, &ioregs_ddr3, NULL, NULL,
 			   &ddr3_emif_regs_400Mhz_beta, 0);
@@ -655,20 +629,14 @@ 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;
+	struct ti_am_eeprom_printable p;
+	int rc;
 
-	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);
+	rc = ti_i2c_eeprom_am_get_print(-1, CONFIG_SYS_I2C_EEPROM_ADDR, &p);
 
-	strncpy(safe_string, (char *)header.version, sizeof(header.version));
-	safe_string[sizeof(header.version)] = 0;
-	setenv("board_rev", safe_string);
+	if (rc)
+		puts("Could not get board ID.\n");
+	set_board_info_env(p.name, p.version, p.serial);
 #endif
 	return 0;
 }
board/ti/am43xx/board.h +10 -31

68 lines not on this page · raw message

board/ti/am43xx/mux.c +1 -0
index 510477dad9e2..3902f4025028 100644
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mux.h>
+#include <board_detect.h>
 #include "board.h"
 
 static struct module_pin_mux rmii1_pin_mux[] = {
Signature · 1 line
1.9.1
#11 lore raw

PATCH v4 5/7 ti: AM437x: Use generic EEPROM detection logic

Quoted 7 lines · Steve Kipisz

From: Nishanth Menon <[email protected]>

Now that we have a generic TI eeprom logic which can be reused accross platforms, reuse the same.

Thanks and regards,
Lokesh

Quoted 252 lines

---
Changes in v4:
- New patch
- depends on https://patchwork.ozlabs.org/patch/540280/

 board/ti/am43xx/board.c | 86 ++++++++++++++++---------------------------------
 board/ti/am43xx/board.h | 41 ++++++-----------------
 board/ti/am43xx/mux.c   |  1 +
 3 files changed, 38 insertions(+), 90 deletions(-)
board/ti/am43xx/board.c +27 -59
index 770726c3f796..ea64672606e9 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/ddr_defs.h>
 #include <asm/arch/gpio.h>
 #include <asm/emif.h>
+#include <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 int __maybe_unused read_eeprom(struct ti_am_eeprom **header)
 {
-	/* 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, header);
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -373,6 +335,10 @@ static u32 get_sys_clk_index(void)
 const struct dpll_params *get_dpll_ddr_params(void)
 {
 	int ind = get_sys_clk_index();
+	struct ti_am_eeprom *header;
+
+	if (read_eeprom(&header) < 0)
+		return NULL;
 
 	if (board_is_eposevm())
 		return &epos_evm_dpll_ddr[ind];
@@ -381,7 +347,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", header->name);
 	return NULL;
 }
 
@@ -512,13 +478,17 @@ void scale_vcores_idk(u32 m)
 	}
 }
 
+void gpi2c_init(void)
+{
+	enable_i2c0_pin_mux();
+	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
+}
+
 void scale_vcores(void)
 {
 	const struct dpll_params *mpu_params;
-	struct am43xx_board_id header;
+	struct ti_am_eeprom *header;
 
-	enable_i2c0_pin_mux();
-	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 	if (read_eeprom(&header) < 0)
 		puts("Could not get board ID.\n");
 
@@ -558,6 +528,10 @@ static void enable_vtt_regulator(void)
 
 void sdram_init(void)
 {
+	struct ti_am_eeprom *header;
+
+	if (read_eeprom(&header) < 0)
+		return;
 	/*
 	 * EPOS EVM has 1GB LPDDR2 connected to EMIF.
 	 * GP EMV has 1GB DDR3 connected to EMIF
@@ -565,11 +539,11 @@ void sdram_init(void)
 	 */
 	if (board_is_eposevm()) {
 		config_ddr(0, &ioregs_lpddr2, NULL, NULL, &emif_regs_lpddr2, 0);
-	} else if (board_is_evm_14_or_later()) {
+	} else if (board_is_evm_14_or_later(header)) {
 		enable_vtt_regulator();
 		config_ddr(0, &ioregs_ddr3, NULL, NULL,
 			   &ddr3_emif_regs_400Mhz_production, 0);
-	} else if (board_is_evm_12_or_later()) {
+	} else if (board_is_evm_12_or_later(header)) {
 		enable_vtt_regulator();
 		config_ddr(0, &ioregs_ddr3, NULL, NULL,
 			   &ddr3_emif_regs_400Mhz_beta, 0);
@@ -655,20 +629,14 @@ 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;
+	struct ti_am_eeprom_printable p;
+	int rc;
 
-	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);
+	rc = ti_i2c_eeprom_am_get_print(-1, CONFIG_SYS_I2C_EEPROM_ADDR, &p);
 
-	strncpy(safe_string, (char *)header.version, sizeof(header.version));
-	safe_string[sizeof(header.version)] = 0;
-	setenv("board_rev", safe_string);
+	if (rc)
+		puts("Could not get board ID.\n");
+	set_board_info_env(p.name, p.version, p.serial);
 #endif
 	return 0;
 }
board/ti/am43xx/board.h +10 -31
index eb9493e191c6..9a6eeac4ac1f 100644
@@ -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_am_is("AM43EPOS");
 }
 
 static inline int board_is_gpevm(void)
 {
-	return !strncmp(am43xx_board_name, "AM43__GP", HDR_NAME_LEN);
+	return board_am_is("AM43__GP");
 }
 
 static inline int board_is_sk(void)
 {
-	return !strncmp(am43xx_board_name, "AM43__SK", HDR_NAME_LEN);
+	return board_am_is("AM43__SK");
 }
 
 static inline int board_is_idk(void)
 {
-	return !strncmp(am43xx_board_name, "AM43_IDK", HDR_NAME_LEN);
+	return board_am_is("AM43_IDK");
 }
 
-static inline int board_is_evm_14_or_later(void)
+static inline int board_is_evm_14_or_later(struct ti_am_eeprom *header)
 {
-	return (board_is_gpevm() && strncmp("1.4", am43xx_board_rev, 3) <= 0);
+	return (board_is_gpevm() && strncmp("1.4", header->version, 3) <= 0);
 }
 
-static inline int board_is_evm_12_or_later(void)
+static inline int board_is_evm_12_or_later(struct ti_am_eeprom *header)
 {
-	return (board_is_gpevm() && strncmp("1.2", am43xx_board_rev, 3) <= 0);
+	return (board_is_gpevm() && strncmp("1.2", header->version, 3) <= 0);
 }
 
 void enable_uart0_pin_mux(void);
board/ti/am43xx/mux.c +1 -0
index 510477dad9e2..3902f4025028 100644
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mux.h>
+#include <board_detect.h>
 #include "board.h"
 
 static struct module_pin_mux rmii1_pin_mux[] = {
#12 lore raw

PATCH v4 5/7 ti: AM437x: Use generic EEPROM detection logic

In reply to Steve Kipisz
Quoted 7 lines · Steve Kipisz

From: Nishanth Menon <[email protected]>

Now that we have a generic TI eeprom logic which can be reused accross platforms, reuse the same.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/e7e60114/attachment.sig>
#13 lore raw

PATCH v4 6/7 ARM: OMAP4/5: Add generic board detection hook

In reply to 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.

---
Changes in v4 (since v3):
- No changes
- Picked up Reviewed-by from previous post

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(+)
arch/arm/cpu/armv7/omap-common/hwinit-common.c +11 -0
index 91f2dead364b..9e9376d0e6e6 100644
@@ -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
index 26e9a194f036..fbb52093c65a 100644
@@ -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
index 18902628739b..23a33cb233bb 100644
@@ -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
#14 lore raw

PATCH v4 6/7 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

---
Changes in v4 (since v3):
- No changes
- Picked up Reviewed-by from previous post

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(+)
arch/arm/cpu/armv7/omap-common/hwinit-common.c +11 -0
index 91f2dead364b..9e9376d0e6e6 100644
@@ -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
index 26e9a194f036..fbb52093c65a 100644
@@ -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
index 18902628739b..23a33cb233bb 100644
@@ -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);
#15 lore raw

PATCH v4 7/7 board: ti: AM57xx: Add detection logic for AM57xx-evm

In reply to Steve Kipisz

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.

---
Changes in v4 (since v3):
- No changes (except for rebase)

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)

 board/ti/am57xx/board.c      | 52 ++++++++++++++++++++++++++++++++++++++++++++
 include/configs/am57xx_evm.h |  4 ++++
 2 files changed, 56 insertions(+)
board/ti/am57xx/board.c +52 -0
index 042f9ab1965a..15da8e66fee5 100644
@@ -31,6 +31,10 @@
 #include <ti-usb-phy-uboot.h>
 
 #include "mux_data.h"
+#include <board_detect.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
index 6308cab8e680..1fffdb18fbcd 100644
@@ -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
#16 lore raw

PATCH v4 7/7 board: ti: AM57xx: Add detection logic for AM57xx-evm

Quoted 16 lines · Steve Kipisz

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.

Quoted 7 lines

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.

Signature · 2 lines
Regards,
Igor.
#17 lore raw

PATCH v4 7/7 board: ti: AM57xx: Add detection logic for AM57xx-evm

In reply to Steve Kipisz
Quoted 16 lines · Steve Kipisz

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.

Quoted 7 lines

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.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/2773bc97/attachment.sig>
#18 lore raw

PATCH v4 7/7 board: ti: AM57xx: Add detection logic for AM57xx-evm

In reply to Steve Kipisz

On 18:39-20151105, Steve Kipisz wrote:
[...]

board/ti/am57xx/board.c

Quoted 4 lines
board/ti/am57xx/board.c +0 -0
index 042f9ab1965a..15da8e66fee5 100644
	[...]
Quoted 6 lines
board/ti/am57xx/board.c +6 -0
+static void setup_board_eeprom_env(void)
+{
+	char *name = "beagle_x15";
+	int rc;
+	struct ti_am_eeprom_printable p;
+

board/ti/am57xx/board.c

Quoted 10 lines
board/ti/am57xx/board.c +10 -0
+	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";

I suggest adding:

	else if (board_is_x15())
		name = "beagle_x15";

If we dont do that, we end up with the "Unidentified board claim" print even if we have a valid eeprom.

Also, at this point, we can reasonably detect and update our prints (to prevent folks from being confused :))

How about squashing the following to this patch?

board/ti/am57xx/board.c +22 -1
index 4ae484140608..30d358885fe0 100644
@@ -46,7 +46,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define GPIO_DDR_VTT_EN 203
 
 const struct omap_sysinfo sysinfo = {
-	"Board: BeagleBoard x15\n"
+	"Board: UNKNOWN(BeagleBoard X15?)\n"
 };
 
 static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
@@ -262,6 +262,27 @@ void do_board_detect(void)
 
 #else	/* CONFIG_SPL_BUILD */
 
+void do_board_detect(void)
+{
+	struct ti_am_eeprom *ep;
+	char *bname = NULL;
+	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);
+
+	if (board_is_x15())
+		bname = "BeagleBoard X15";
+	else if (board_is_am572x_evm())
+		bname = "AM572x EVM";
+
+	if (bname)
+		snprintf(sysinfo.board_string, sizeof(sysinfo.board_string),
+			 "Board: %s\n", bname);
+}
+
 static void setup_board_eeprom_env(void)
 {
 	char *name = "beagle_x15";
Signature · 2 lines
Regards,
Nishanth Menon