All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization
@ 2015-11-06  0:39 Steve Kipisz
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 2/7] ARM: OMAP4/5: Centralize gpi2c_init Steve Kipisz
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

Early clock initialization is currently done in two stages for OMAP4/5
SoCs. The first stage is the initialization of console clocks and
then we initialize basic clocks for functionality necessary for SoC
initialization and basic board functionality.

By splitting up prcm_init and centralizing this clock initialization,
we setup the code for follow on patches that can do board specific
initialization such as board detection which will depend on these
basic clocks.

As part of this change, since the early clock initialization
is centralized, we no longer need to expose the console clock
initialization.

NOTE: we change the sequence slightly by initializing console clocks
timer after the io settings are complete, but this is not expected
to have any functioanlity impact since we setup the basic IO drive
strength initialization as part of do_io_settings.

Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
---
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(-)

diff --git a/arch/arm/cpu/armv7/omap-common/clocks-common.c b/arch/arm/cpu/armv7/omap-common/clocks-common.c
index e28b79568d1d..367d224361be 100644
--- a/arch/arm/cpu/armv7/omap-common/clocks-common.c
+++ b/arch/arm/cpu/armv7/omap-common/clocks-common.c
@@ -769,7 +769,7 @@ void lock_dpll(u32 const base)
 	wait_for_lock(base);
 }
 
-void setup_clocks_for_console(void)
+static void setup_clocks_for_console(void)
 {
 	/* Do not add any spl_debug prints in this function */
 	clrsetbits_le32((*prcm)->cm_l4per_clkstctrl, CD_CLKCTRL_CLKTRCTRL_MASK,
@@ -853,14 +853,31 @@ void do_disable_clocks(u32 const *clk_domains,
 		disable_clock_domain(clk_domains[i]);
 }
 
-void prcm_init(void)
+/**
+ * setup_early_clocks() - Setup early clocks needed for SoC
+ *
+ * Setup clocks for console, SPL basic initialization clocks and initialize
+ * the timer. This is invoked prior prcm_init.
+ */
+void setup_early_clocks(void)
 {
 	switch (omap_hw_init_context()) {
 	case OMAP_INIT_CONTEXT_SPL:
 	case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
 	case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
+		setup_clocks_for_console();
 		enable_basic_clocks();
 		timer_init();
+		/* Fall through */
+	}
+}
+
+void prcm_init(void)
+{
+	switch (omap_hw_init_context()) {
+	case OMAP_INIT_CONTEXT_SPL:
+	case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
+	case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
 		scale_vcores(*omap_vcores);
 		setup_dplls();
 		setup_warmreset_time();
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
index 80794f9c611a..91f2dead364b 100644
--- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c
+++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
@@ -125,10 +125,9 @@ void s_init(void)
 	set_mux_conf_regs();
 #ifdef CONFIG_SPL_BUILD
 	srcomp_enable();
-	setup_clocks_for_console();
-
 	do_io_settings();
 #endif
+	setup_early_clocks();
 	prcm_init();
 }
 
diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h
index f30f86539130..71e3d776aa0d 100644
--- a/arch/arm/include/asm/arch-omap4/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap4/sys_proto.h
@@ -37,7 +37,7 @@ void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
 void set_muxconf_regs_essential(void);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
-void setup_clocks_for_console(void);
+void setup_early_clocks(void);
 void prcm_init(void);
 void bypass_dpll(u32 const base);
 void freq_update_core(void);
diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h
index 7fcb78389403..b9e09e7c52a8 100644
--- a/arch/arm/include/asm/arch-omap5/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap5/sys_proto.h
@@ -48,7 +48,7 @@ void do_set_mux32(u32 base, struct pad_conf_entry const *array, int size);
 void set_muxconf_regs_essential(void);
 u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
-void setup_clocks_for_console(void);
+void setup_early_clocks(void);
 void prcm_init(void);
 void bypass_dpll(u32 const base);
 void freq_update_core(void);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 2/7] ARM: OMAP4/5: Centralize gpi2c_init
  2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
@ 2015-11-06  0:39 ` Steve Kipisz
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
---
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(-)

diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h
index 71e3d776aa0d..26e9a194f036 100644
--- a/arch/arm/include/asm/arch-omap4/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap4/sys_proto.h
@@ -51,7 +51,6 @@ void save_omap_boot_params(void);
 void init_omap_revision(void);
 void do_io_settings(void);
 void sri2c_init(void);
-void gpi2c_init(void);
 int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
 u32 warm_reset(void);
 void force_emif_self_refresh(void);
diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h
index b9e09e7c52a8..18902628739b 100644
--- a/arch/arm/include/asm/arch-omap5/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap5/sys_proto.h
@@ -62,7 +62,6 @@ void save_omap_boot_params(void);
 void init_omap_revision(void);
 void do_io_settings(void);
 void sri2c_init(void);
-void gpi2c_init(void);
 int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
 u32 warm_reset(void);
 void force_emif_self_refresh(void);
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index d7b81c101b79..d773b0430ad4 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -617,6 +617,9 @@ void disable_edma3_clocks(void);
 
 void omap_die_id(unsigned int *die_id);
 
+/* Initialize general purpose I2C(0) on the SoC */
+void gpi2c_init(void);
+
 /* ABB */
 #define OMAP_ABB_NOMINAL_OPP		0
 #define OMAP_ABB_FAST_OPP		1
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM
  2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 2/7] ARM: OMAP4/5: Centralize gpi2c_init Steve Kipisz
@ 2015-11-06  0:39 ` Steve Kipisz
  2015-11-06  9:29   ` Igor Grinberg
                     ` (3 more replies)
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic Steve Kipisz
                   ` (3 subsequent siblings)
  5 siblings, 4 replies; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

From: Lokesh Vutla <lokeshvutla@ti.com>

Several TI EVMs have EEPROM that can contain board description information
such as revision, DDR definition, serial number, etc. In just about all
cases, these EEPROM are on the I2C bus and provides us the opportunity
to centralize the generic operations involved.

The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM,
AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format.
However, DRA-7* EVMs, OMAP4SDP use a modified format.

We hence introduce logic which is generic between these platforms
without enforcing any specific format. This allows the boards to use the
relevant format for operations that they might choose.

This module will compile for all TI SoC based boards when 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.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
---
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

diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index d773b0430ad4..aef31266ce9e 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -713,7 +713,9 @@ static inline u8 is_dra72x(void)
 #define OMAP_SRAM_SCRATCH_VCORES_PTR    (SRAM_SCRATCH_SPACE_ADDR + 0x1C)
 #define OMAP_SRAM_SCRATCH_SYS_CTRL	(SRAM_SCRATCH_SPACE_ADDR + 0x20)
 #define OMAP_SRAM_SCRATCH_BOOT_PARAMS	(SRAM_SCRATCH_SPACE_ADDR + 0x24)
-#define OMAP5_SRAM_SCRATCH_SPACE_END	(SRAM_SCRATCH_SPACE_ADDR + 0x28)
+#define OMAP_SRAM_SCRATCH_BOARD_EEPROM_START (SRAM_SCRATCH_SPACE_ADDR + 0x28)
+#define OMAP_SRAM_SCRATCH_BOARD_EEPROM_END (SRAM_SCRATCH_SPACE_ADDR + 0x200)
+#define OMAP_SRAM_SCRATCH_SPACE_END	(OMAP_SRAM_SCRATCH_BOARD_EEPROM_END)
 
 /* Boot parameters */
 #define DEVICE_DATA_OFFSET	0x18
diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile
new file mode 100644
index 000000000000..267d73556fd3
--- /dev/null
+++ b/board/ti/common/Makefile
@@ -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
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
new file mode 100644
index 000000000000..3d2b1bb1465e
--- /dev/null
+++ b/board/ti/common/board_detect.c
@@ -0,0 +1,189 @@
+/*
+ * 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_detect.h"
+
+/**
+ * ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device
+ * @i2c_bus: i2c bus number to initialize
+ * @dev_addr: Device address to probe for
+ *
+ * Return: 0 on success or corresponding error on failure.
+ */
+static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr)
+{
+	int rc;
+
+	if (i2c_bus >= 0) {
+		rc = i2c_set_bus_num(i2c_bus);
+		if (rc)
+			return rc;
+	}
+
+	return i2c_probe(dev_addr);
+}
+
+/**
+ * ti_i2c_eeprom_read - Read data from an EEPROM
+ * @dev_addr: The device address of the EEPROM
+ * @offset: Offset to start reading in the EEPROM
+ * @ep: Pointer to a buffer to read into
+ * @epsize: Size of buffer
+ *
+ * Return: 0 on success or corresponding result of i2c_read
+ */
+static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset,
+					     uchar *ep, int epsize)
+{
+	return i2c_read(dev_addr, offset, 2, ep, epsize);
+}
+
+/**
+ * ti_eeprom_string_cleanup() - Handle eeprom programming errors
+ * @s:	eeprom string (should be NULL terminated)
+ *
+ * Some Board manufacturers do not add a NULL termination at the
+ * end of string, instead some binary information is kludged in, hence
+ * convert the string to just printable characters of ASCII chart.
+ */
+static void __maybe_unused ti_eeprom_string_cleanup(char *s)
+{
+	int i, l;
+
+	l = strlen(s);
+	for (i = 0; i < l; i++, s++)
+		if (*s < ' ' || *s > '~') {
+			*s = 0;
+			break;
+		}
+}
+
+__weak void gpi2c_init(void)
+{
+}
+
+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) {
+		rc = i2c_read(dev_addr, 0x0, 2, (uint8_t *)ep, sizeof(*ep));
+		/*
+		 * read the eeprom using i2c again, but use only a 1 byte
+		 * address (some legacy boards need this..)
+		 */
+		if (rc)
+			rc = i2c_read(dev_addr, 0x0, 1, (uint8_t *)ep,
+				      sizeof(*ep));
+		if (rc)
+			return rc;
+	}
+	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;
+}
+
+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);
+}
+
+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;
+	return !strncmp(ep->version, rev_tag, l);
+}
+
+void __maybe_unused set_board_info_env(char *name, char *revision,
+				       char *serial)
+{
+	char *unknown = "unknown";
+
+	if (name)
+		setenv("board_name", name);
+	else
+		setenv("board_name", unknown);
+
+	if (revision)
+		setenv("board_rev", revision);
+	else
+		setenv("board_rev", unknown);
+
+	if (serial)
+		setenv("board_serial", serial);
+	else
+		setenv("board_serial", unknown);
+}
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
new file mode 100644
index 000000000000..7d5478ae65a3
--- /dev/null
+++ b/board/ti/common/board_detect.h
@@ -0,0 +1,117 @@
+/*
+ * Library to support early TI EVM EEPROM handling
+ *
+ * Copyright (C) 2015, Texas Instruments, Incorporated - http://www.ti.com
+ *
+ * SPDX-L	icense-Identifier:	GPL-2.0+
+ */
+
+#ifndef __BOARD_DETECT_H
+#define __BOARD_DETECT_H
+
+/* TI EEPROM MAGIC Header identifier */
+#define TI_EEPROM_HEADER_MAGIC	0xEE3355AA
+
+#define TI_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
+ * @epp:	Pointer to eeprom structure
+ *
+ * *epp 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 for AM* platforms.
+ */
+int ti_i2c_eeprom_am_get_print(int bus_addr, int dev_addr,
+			       struct ti_am_eeprom_printable *p);
+
+
+/**
+ * board_am_is() - Board detection logic for TI AM* EVMs
+ * @name_tag:	Tag used in eeprom for the board
+ *
+ * Return: false if board information does not match OR eeprom wasn't read.
+ *	   true otherwise
+ */
+bool board_am_is(char *name_tag);
+
+/**
+ * board_am_rev_is() - Compare board revision for AM* TI EVMs
+ * @rev_tag:	Revision tag to check in eeprom
+ * @cmp_len:	How many chars to compare?
+ *
+ * NOTE: revision information is often messed up (hence the str len match) :(
+ *
+ * Return: false if board information does not match OR eeprom was'nt read.
+ *	   true otherwise
+ */
+bool board_am_rev_is(char *rev_tag, int cmp_len);
+
+/**
+ * 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);
+
+#endif	/* __BOARD_DETECT_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic
  2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 2/7] ARM: OMAP4/5: Centralize gpi2c_init Steve Kipisz
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
@ 2015-11-06  0:39 ` Steve Kipisz
  2015-11-06  3:48   ` Lokesh Vutla
  2015-11-08 13:35   ` Tom Rini
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 5/7] ti: AM437x: " Steve Kipisz
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

From: Nishanth Menon <nm@ti.com>

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

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Steven Kipisz <s-kipisz2@ti.com>
---
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(-)

diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index f0cb1e204ad5..1f9707d60c1f 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -31,6 +31,7 @@
 #include <environment.h>
 #include <watchdog.h>
 #include <environment.h>
+#include <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();
 
diff --git a/board/ti/am335x/board.h b/board/ti/am335x/board.h
index bc700d56fece..14b2469df12d 100644
--- a/board/ti/am335x/board.h
+++ b/board/ti/am335x/board.h
@@ -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
diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c
index 28c29a2f9cba..6bffa91c24c9 100644
--- a/board/ti/am335x/mux.c
+++ b/board/ti/am335x/mux.c
@@ -19,6 +19,7 @@
 #include <asm/arch/mux.h>
 #include <asm/io.h>
 #include <i2c.h>
+#include <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);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 5/7] ti: AM437x: Use generic EEPROM detection logic
  2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
                   ` (2 preceding siblings ...)
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic Steve Kipisz
@ 2015-11-06  0:39 ` Steve Kipisz
  2015-11-06  3:49   ` Lokesh Vutla
  2015-11-08 13:36   ` Tom Rini
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook Steve Kipisz
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm Steve Kipisz
  5 siblings, 2 replies; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

From: Nishanth Menon <nm@ti.com>

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

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Steven Kipisz <s-kipisz2@ti.com>
---
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(-)

diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 770726c3f796..ea64672606e9 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -19,6 +19,7 @@
 #include <asm/arch/ddr_defs.h>
 #include <asm/arch/gpio.h>
 #include <asm/emif.h>
+#include <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;
 }
diff --git a/board/ti/am43xx/board.h b/board/ti/am43xx/board.h
index eb9493e191c6..9a6eeac4ac1f 100644
--- a/board/ti/am43xx/board.h
+++ b/board/ti/am43xx/board.h
@@ -14,58 +14,37 @@
 
 #include <asm/arch/omap.h>
 
-static char *const am43xx_board_name = (char *)AM4372_BOARD_NAME_START;
-static char *const am43xx_board_rev = (char *)AM4372_BOARD_VERSION_START;
-
-/*
- * TI AM437x EVMs define a system EEPROM that defines certain sub-fields.
- * We use these fields to in turn see what board we are on, and what
- * that might require us to set or not set.
- */
-#define HDR_NO_OF_MAC_ADDR	3
-#define HDR_ETH_ALEN		6
-#define HDR_NAME_LEN		8
-
-#define DEV_ATTR_MAX_OFFSET	5
-#define DEV_ATTR_MIN_OFFSET	0
-
-struct am43xx_board_id {
-	unsigned int  magic;
-	char name[HDR_NAME_LEN];
-	char version[4];
-	char serial[12];
-	char config[32];
-	char mac_addr[HDR_NO_OF_MAC_ADDR][HDR_ETH_ALEN];
-};
+#define DEV_ATTR_MAX_OFFSET    5
+#define DEV_ATTR_MIN_OFFSET    0
 
 static inline int board_is_eposevm(void)
 {
-	return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN);
+	return board_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);
diff --git a/board/ti/am43xx/mux.c b/board/ti/am43xx/mux.c
index 510477dad9e2..3902f4025028 100644
--- a/board/ti/am43xx/mux.c
+++ b/board/ti/am43xx/mux.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mux.h>
+#include <board_detect.h>
 #include "board.h"
 
 static struct module_pin_mux rmii1_pin_mux[] = {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook
  2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
                   ` (3 preceding siblings ...)
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 5/7] ti: AM437x: " Steve Kipisz
@ 2015-11-06  0:39 ` Steve Kipisz
  2015-11-06  3:49   ` Lokesh Vutla
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm Steve Kipisz
  5 siblings, 1 reply; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

Many TI EVMs have capability to store relevant board information
such as DDR description in EEPROM. Further many pad configuration
variations can occur as part of revision changes in the platform.
In-order to support these at runtime, we for a board detection hook
which is available for override from board files that may desire to do
so.

NOTE: All TI EVMs are capable of detecting board information based on
early clocks that are configured. However, in case of additional needs
this can be achieved within the override logic from within the board
file.

Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
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(+)

diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
index 91f2dead364b..9e9376d0e6e6 100644
--- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c
+++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
@@ -97,6 +97,16 @@ int arch_cpu_init(void)
 }
 #endif /* CONFIG_ARCH_CPU_INIT */
 
+/**
+ * do_board_detect() - Detect board description
+ *
+ * Function to detect board description. This is expected to be
+ * overridden in the SoC family board file where desired.
+ */
+void __weak do_board_detect(void)
+{
+}
+
 /*
  * Routine: s_init
  * Description: Does early system init of watchdog, muxing,  andclocks
@@ -128,6 +138,7 @@ void s_init(void)
 	do_io_settings();
 #endif
 	setup_early_clocks();
+	do_board_detect();
 	prcm_init();
 }
 
diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h
index 26e9a194f036..fbb52093c65a 100644
--- a/arch/arm/include/asm/arch-omap4/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap4/sys_proto.h
@@ -39,6 +39,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void setup_early_clocks(void);
 void prcm_init(void);
+void do_board_detect(void);
 void bypass_dpll(u32 const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h
index 18902628739b..23a33cb233bb 100644
--- a/arch/arm/include/asm/arch-omap5/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap5/sys_proto.h
@@ -50,6 +50,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void sdelay(unsigned long);
 void setup_early_clocks(void);
 void prcm_init(void);
+void do_board_detect(void);
 void bypass_dpll(u32 const base);
 void freq_update_core(void);
 u32 get_sys_clk_freq(void);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm
  2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
                   ` (4 preceding siblings ...)
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook Steve Kipisz
@ 2015-11-06  0:39 ` Steve Kipisz
  2015-11-06  9:35   ` Igor Grinberg
                     ` (2 more replies)
  5 siblings, 3 replies; 19+ messages in thread
From: Steve Kipisz @ 2015-11-06  0:39 UTC (permalink / raw)
  To: u-boot

Current AM57xx evm supports both BeagleBoard-X15
(http://beagleboard.org/x15) and AM57xx EVM
(http://www.ti.com/tool/tmdxevm5728).

The AM572x EValuation Module(EVM) provides an affordable platform to
quickly start evaluation of Sitara. ARM Cortex-A15 AM57x Processors
(AM5728, AM5726, AM5718, AM5716) and accelerate development for HMI,
machine vision, networking, medical imaging and many other industrial
applications. This EVM is based on the same BeagleBoard-X15 Chassis
and adds mPCIe, mSATA, LCD, touchscreen, Camera, push button and TI's
wlink8 offering.

Since the EEPROM contents are compatible between the BeagleBoard-X15 and
the AM57xx-evm, we add support for the detection logic to enable
support for various user programmable scripting capability.

NOTE: U-boot configuration is currently a superset of AM57xx evm and
BeagleBoard-X15 and no additional configuration tweaking is needed.

This change also sets up the stage for future support of TI AM57xx EVMs
to the same base bootloader build.

Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
---
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(+)

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 042f9ab1965a..15da8e66fee5 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -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.
diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index 6308cab8e680..1fffdb18fbcd 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -88,4 +88,8 @@
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
 						CONFIG_SYS_SCSI_MAX_LUN)
 
+/* EEPROM */
+#define CONFIG_EEPROM_CHIP_ADDRESS 0x50
+#define CONFIG_EEPROM_BUS_ADDRESS 0
+
 #endif /* __CONFIG_AM57XX_EVM_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic Steve Kipisz
@ 2015-11-06  3:48   ` Lokesh Vutla
  2015-11-08 13:35   ` Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Lokesh Vutla @ 2015-11-06  3:48 UTC (permalink / raw)
  To: u-boot



On Friday 06 November 2015 06:09 AM, Steve Kipisz wrote:
> From: Nishanth Menon <nm@ti.com>
> 
> Use the generic EEPROM detection logic instead of duplicating the AM
> eeprom logic.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Signed-off-by: Steven Kipisz <s-kipisz2@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

> ---
> 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(-)
> 
> diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
> index f0cb1e204ad5..1f9707d60c1f 100644
> --- a/board/ti/am335x/board.c
> +++ b/board/ti/am335x/board.c
> @@ -31,6 +31,7 @@
>  #include <environment.h>
>  #include <watchdog.h>
>  #include <environment.h>
> +#include <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();
>  
> diff --git a/board/ti/am335x/board.h b/board/ti/am335x/board.h
> index bc700d56fece..14b2469df12d 100644
> --- a/board/ti/am335x/board.h
> +++ b/board/ti/am335x/board.h
> @@ -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
> diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c
> index 28c29a2f9cba..6bffa91c24c9 100644
> --- a/board/ti/am335x/mux.c
> +++ b/board/ti/am335x/mux.c
> @@ -19,6 +19,7 @@
>  #include <asm/arch/mux.h>
>  #include <asm/io.h>
>  #include <i2c.h>
> +#include <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);
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 5/7] ti: AM437x: Use generic EEPROM detection logic
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 5/7] ti: AM437x: " Steve Kipisz
@ 2015-11-06  3:49   ` Lokesh Vutla
  2015-11-08 13:36   ` Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Lokesh Vutla @ 2015-11-06  3:49 UTC (permalink / raw)
  To: u-boot



On Friday 06 November 2015 06:09 AM, Steve Kipisz wrote:
> From: Nishanth Menon <nm@ti.com>
> 
> Now that we have a generic TI eeprom logic which can be reused accross
> platforms, reuse the same.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Signed-off-by: Steven Kipisz <s-kipisz2@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

> ---
> 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(-)
> 
> diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
> index 770726c3f796..ea64672606e9 100644
> --- a/board/ti/am43xx/board.c
> +++ b/board/ti/am43xx/board.c
> @@ -19,6 +19,7 @@
>  #include <asm/arch/ddr_defs.h>
>  #include <asm/arch/gpio.h>
>  #include <asm/emif.h>
> +#include <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;
>  }
> diff --git a/board/ti/am43xx/board.h b/board/ti/am43xx/board.h
> index eb9493e191c6..9a6eeac4ac1f 100644
> --- a/board/ti/am43xx/board.h
> +++ b/board/ti/am43xx/board.h
> @@ -14,58 +14,37 @@
>  
>  #include <asm/arch/omap.h>
>  
> -static char *const am43xx_board_name = (char *)AM4372_BOARD_NAME_START;
> -static char *const am43xx_board_rev = (char *)AM4372_BOARD_VERSION_START;
> -
> -/*
> - * TI AM437x EVMs define a system EEPROM that defines certain sub-fields.
> - * We use these fields to in turn see what board we are on, and what
> - * that might require us to set or not set.
> - */
> -#define HDR_NO_OF_MAC_ADDR	3
> -#define HDR_ETH_ALEN		6
> -#define HDR_NAME_LEN		8
> -
> -#define DEV_ATTR_MAX_OFFSET	5
> -#define DEV_ATTR_MIN_OFFSET	0
> -
> -struct am43xx_board_id {
> -	unsigned int  magic;
> -	char name[HDR_NAME_LEN];
> -	char version[4];
> -	char serial[12];
> -	char config[32];
> -	char mac_addr[HDR_NO_OF_MAC_ADDR][HDR_ETH_ALEN];
> -};
> +#define DEV_ATTR_MAX_OFFSET    5
> +#define DEV_ATTR_MIN_OFFSET    0
>  
>  static inline int board_is_eposevm(void)
>  {
> -	return !strncmp(am43xx_board_name, "AM43EPOS", HDR_NAME_LEN);
> +	return board_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);
> diff --git a/board/ti/am43xx/mux.c b/board/ti/am43xx/mux.c
> index 510477dad9e2..3902f4025028 100644
> --- a/board/ti/am43xx/mux.c
> +++ b/board/ti/am43xx/mux.c
> @@ -9,6 +9,7 @@
>  #include <common.h>
>  #include <asm/arch/sys_proto.h>
>  #include <asm/arch/mux.h>
> +#include <board_detect.h>
>  #include "board.h"
>  
>  static struct module_pin_mux rmii1_pin_mux[] = {
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook Steve Kipisz
@ 2015-11-06  3:49   ` Lokesh Vutla
  0 siblings, 0 replies; 19+ messages in thread
From: Lokesh Vutla @ 2015-11-06  3:49 UTC (permalink / raw)
  To: u-boot



On Friday 06 November 2015 06:09 AM, Steve Kipisz wrote:
> Many TI EVMs have capability to store relevant board information
> such as DDR description in EEPROM. Further many pad configuration
> variations can occur as part of revision changes in the platform.
> In-order to support these at runtime, we for a board detection hook
> which is available for override from board files that may desire to do
> so.
> 
> NOTE: All TI EVMs are capable of detecting board information based on
> early clocks that are configured. However, in case of additional needs
> this can be achieved within the override logic from within the board
> file.


Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh
> 
> Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> 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(+)
> 
> diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
> index 91f2dead364b..9e9376d0e6e6 100644
> --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c
> +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c
> @@ -97,6 +97,16 @@ int arch_cpu_init(void)
>  }
>  #endif /* CONFIG_ARCH_CPU_INIT */
>  
> +/**
> + * do_board_detect() - Detect board description
> + *
> + * Function to detect board description. This is expected to be
> + * overridden in the SoC family board file where desired.
> + */
> +void __weak do_board_detect(void)
> +{
> +}
> +
>  /*
>   * Routine: s_init
>   * Description: Does early system init of watchdog, muxing,  andclocks
> @@ -128,6 +138,7 @@ void s_init(void)
>  	do_io_settings();
>  #endif
>  	setup_early_clocks();
> +	do_board_detect();
>  	prcm_init();
>  }
>  
> diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h
> index 26e9a194f036..fbb52093c65a 100644
> --- a/arch/arm/include/asm/arch-omap4/sys_proto.h
> +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h
> @@ -39,6 +39,7 @@ u32 wait_on_value(u32, u32, void *, u32);
>  void sdelay(unsigned long);
>  void setup_early_clocks(void);
>  void prcm_init(void);
> +void do_board_detect(void);
>  void bypass_dpll(u32 const base);
>  void freq_update_core(void);
>  u32 get_sys_clk_freq(void);
> diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h
> index 18902628739b..23a33cb233bb 100644
> --- a/arch/arm/include/asm/arch-omap5/sys_proto.h
> +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h
> @@ -50,6 +50,7 @@ u32 wait_on_value(u32, u32, void *, u32);
>  void sdelay(unsigned long);
>  void setup_early_clocks(void);
>  void prcm_init(void);
> +void do_board_detect(void);
>  void bypass_dpll(u32 const base);
>  void freq_update_core(void);
>  u32 get_sys_clk_freq(void);
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
@ 2015-11-06  9:29   ` Igor Grinberg
  2015-11-08 13:34   ` Tom Rini
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Igor Grinberg @ 2015-11-06  9:29 UTC (permalink / raw)
  To: u-boot

On 11/06/15 02:39, Steve Kipisz wrote:
> From: Lokesh Vutla <lokeshvutla@ti.com>
> 
> Several TI EVMs have EEPROM that can contain board description information
> such as revision, DDR definition, serial number, etc. In just about all
> cases, these EEPROM are on the I2C bus and provides us the opportunity
> to centralize the generic operations involved.
> 
> The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM,
> AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format.
> However, DRA-7* EVMs, OMAP4SDP use a modified format.
> 
> We hence introduce logic which is generic between these platforms
> without enforcing any specific format. This allows the boards to use the
> relevant format for operations that they might choose.
> 
> This module will compile for all TI SoC based boards when 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.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>

Acked-by: Igor Grinberg <grinberg@compulab.co.il>

-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm Steve Kipisz
@ 2015-11-06  9:35   ` Igor Grinberg
  2015-11-08 13:36   ` Tom Rini
  2015-11-10  0:15   ` Nishanth Menon
  2 siblings, 0 replies; 19+ messages in thread
From: Igor Grinberg @ 2015-11-06  9:35 UTC (permalink / raw)
  To: u-boot

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

Acked-by: Igor Grinberg <grinberg@compulab.co.il>

-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
  2015-11-06  9:29   ` Igor Grinberg
@ 2015-11-08 13:34   ` Tom Rini
  2015-11-09 22:19   ` Nishanth Menon
  2015-11-09 23:47   ` Nishanth Menon
  3 siblings, 0 replies; 19+ messages in thread
From: Tom Rini @ 2015-11-08 13:34 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 05, 2015 at 06:39:32PM -0600, Steve Kipisz wrote:

> From: Lokesh Vutla <lokeshvutla@ti.com>
> 
> Several TI EVMs have EEPROM that can contain board description information
> such as revision, DDR definition, serial number, etc. In just about all
> cases, these EEPROM are on the I2C bus and provides us the opportunity
> to centralize the generic operations involved.
> 
> The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM,
> AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format.
> However, DRA-7* EVMs, OMAP4SDP use a modified format.
> 
> We hence introduce logic which is generic between these platforms
> without enforcing any specific format. This allows the boards to use the
> relevant format for operations that they might choose.
> 
> This module will compile for all TI SoC based boards when 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.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic Steve Kipisz
  2015-11-06  3:48   ` Lokesh Vutla
@ 2015-11-08 13:35   ` Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Tom Rini @ 2015-11-08 13:35 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 05, 2015 at 06:39:33PM -0600, Steve Kipisz wrote:

> From: Nishanth Menon <nm@ti.com>
> 
> Use the generic EEPROM detection logic instead of duplicating the AM
> eeprom logic.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Signed-off-by: Steven Kipisz <s-kipisz2@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 5/7] ti: AM437x: Use generic EEPROM detection logic
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 5/7] ti: AM437x: " Steve Kipisz
  2015-11-06  3:49   ` Lokesh Vutla
@ 2015-11-08 13:36   ` Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Tom Rini @ 2015-11-08 13:36 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 05, 2015 at 06:39:34PM -0600, Steve Kipisz wrote:

> From: Nishanth Menon <nm@ti.com>
> 
> Now that we have a generic TI eeprom logic which can be reused accross
> platforms, reuse the same.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Signed-off-by: Steven Kipisz <s-kipisz2@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm Steve Kipisz
  2015-11-06  9:35   ` Igor Grinberg
@ 2015-11-08 13:36   ` Tom Rini
  2015-11-10  0:15   ` Nishanth Menon
  2 siblings, 0 replies; 19+ messages in thread
From: Tom Rini @ 2015-11-08 13:36 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 05, 2015 at 06:39:36PM -0600, Steve Kipisz wrote:

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

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
  2015-11-06  9:29   ` Igor Grinberg
  2015-11-08 13:34   ` Tom Rini
@ 2015-11-09 22:19   ` Nishanth Menon
  2015-11-09 23:47   ` Nishanth Menon
  3 siblings, 0 replies; 19+ messages in thread
From: Nishanth Menon @ 2015-11-09 22:19 UTC (permalink / raw)
  To: u-boot

On 11/05/2015 06:39 PM, Steve Kipisz wrote:
[...]
> diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
> new file mode 100644
> index 000000000000..3d2b1bb1465e
> --- /dev/null
> +++ b/board/ti/common/board_detect.c

[...]

> +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);

s/TI_EEPROM_HDR_NAME_LEN/TI_EEPROM_HDR_REV_LEN ?

> +	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?

> +	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);
> +}
> +
> +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/ ?

> +	return !strncmp(ep->version, rev_tag, l);
> +}
> +
[...]



-- 
Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
                     ` (2 preceding siblings ...)
  2015-11-09 22:19   ` Nishanth Menon
@ 2015-11-09 23:47   ` Nishanth Menon
  3 siblings, 0 replies; 19+ messages in thread
From: Nishanth Menon @ 2015-11-09 23:47 UTC (permalink / raw)
  To: u-boot

On 11/05/2015 06:39 PM, Steve Kipisz wrote:
[...]
> +#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.

[...]

-- 
Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm
  2015-11-06  0:39 ` [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm Steve Kipisz
  2015-11-06  9:35   ` Igor Grinberg
  2015-11-08 13:36   ` Tom Rini
@ 2015-11-10  0:15   ` Nishanth Menon
  2 siblings, 0 replies; 19+ messages in thread
From: Nishanth Menon @ 2015-11-10  0:15 UTC (permalink / raw)
  To: u-boot

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

> diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
> index 042f9ab1965a..15da8e66fee5 100644
> --- a/board/ti/am57xx/board.c
> +++ b/board/ti/am57xx/board.c
	[...]
> +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";
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?
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 4ae484140608..30d358885fe0 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -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";
-- 
Regards,
Nishanth Menon

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-11-10  0:15 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-06  0:39 [U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization Steve Kipisz
2015-11-06  0:39 ` [U-Boot] [PATCH v4 2/7] ARM: OMAP4/5: Centralize gpi2c_init Steve Kipisz
2015-11-06  0:39 ` [U-Boot] [PATCH v4 3/7] ARM: omap-common: Add standard access for board description EEPROM Steve Kipisz
2015-11-06  9:29   ` Igor Grinberg
2015-11-08 13:34   ` Tom Rini
2015-11-09 22:19   ` Nishanth Menon
2015-11-09 23:47   ` Nishanth Menon
2015-11-06  0:39 ` [U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic Steve Kipisz
2015-11-06  3:48   ` Lokesh Vutla
2015-11-08 13:35   ` Tom Rini
2015-11-06  0:39 ` [U-Boot] [PATCH v4 5/7] ti: AM437x: " Steve Kipisz
2015-11-06  3:49   ` Lokesh Vutla
2015-11-08 13:36   ` Tom Rini
2015-11-06  0:39 ` [U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook Steve Kipisz
2015-11-06  3:49   ` Lokesh Vutla
2015-11-06  0:39 ` [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm Steve Kipisz
2015-11-06  9:35   ` Igor Grinberg
2015-11-08 13:36   ` Tom Rini
2015-11-10  0:15   ` Nishanth Menon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.