[U-Boot] [PATCH V5 1/7] ARM: OMAP4/5: Centralize early clock initialization

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

By splitting up prcm_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-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvu...@ti.com>
---
V5: No changes
v4: https://patchwork.ozlabs.org/patch/540775/
v3:  https://patchwork.ozlabs.org/patch/540193/

v2:  http://marc.info/?t=14465536301=1=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);
-- 
2.7.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V5 3/7] ARM: omap-common: Add standard access for board description EEPROM

2016-02-24 Thread Steve Kipisz
From: Lokesh Vutla <lokeshvu...@ti.com>

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

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

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

This module will compile for all TI SoC based boards when
CONFIG_TI_I2C_BOARD_DETECT is enabled to have optimal build times for
platforms that require this support.

It is important to note that this logic is fundamental to the board
configuration process such as DDR configuration which is needed in
SPL, hence cannot be part of the standard u-boot driver model (which
is available later in the process). Hence, to aid efficiency, the
eeprom contents are copied over to SRAM scratchpad memory area at the
first invocation to retrieve data.

To prevent churn with cases such as DRA7, where eeprom format maybe
incompatible, we introduce a generic common format in eeprom which
is made available over accessor functions for usage.

Special handling for BBG1 EEPROM had to be introduced thanks to the
weird eeprom rev contents used.

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

Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Signed-off-by: Roger Quadros <rog...@ti.com>
Signed-off-by: Nishanth Menon <n...@ti.com>
---
Changes in V5:
- Dropped dependency on https://patchwork.ozlabs.org/patch/540280/
- library now completely abstracts eeprom format away from consumers
- data access over apis to the library - now made reusable for dra7 
(follow on series)
- mac address api access introduced (Thanks to Roger)
- a "generic" eeprom structure which is board independent is stored in
sram (instead of actual eeprom contents)
- To optimize compile time usage, TI_I2C_BOARD_DETECT introduced
- BBG hack incorporated

V4: https://patchwork.ozlabs.org/patch/540773/
v3:  https://patchwork.ozlabs.org/patch/540197/

v2:  http://marc.info/?t=14465534481=1=2
  (mailing list squashed original submission)

Changes in v2:
 - New patch

 arch/arm/include/asm/omap_common.h |   4 +-
 board/ti/common/Kconfig|   5 +
 board/ti/common/Makefile   |   6 +
 board/ti/common/board_detect.c | 254 +
 board/ti/common/board_detect.h | 140 
 5 files changed, 408 insertions(+), 1 deletion(-)
 create mode 100644 board/ti/common/Kconfig
 create mode 100644 board/ti/common/Makefile
 create mode 100644 board/ti/common/board_detect.c
 create mode 100644 board/ti/common/board_detect.h

diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index d773b0430ad4..aef31266ce9e 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -713,7 +713,9 @@ static inline u8 is_dra72x(void)
 #define OMAP_SRAM_SCRATCH_VCORES_PTR(SRAM_SCRATCH_SPACE_ADDR + 0x1C)
 #define OMAP_SRAM_SCRATCH_SYS_CTRL (SRAM_SCRATCH_SPACE_ADDR + 0x20)
 #define OMAP_SRAM_SCRATCH_BOOT_PARAMS  (SRAM_SCRATCH_SPACE_ADDR + 0x24)
-#define OMAP5_SRAM_SCRATCH_SPACE_END   (SRAM_SCRATCH_SPACE_ADDR + 0x28)
+#define OMAP_SRAM_SCRATCH_BOARD_EEPROM_START (SRAM_SCRATCH_SPACE_ADDR + 0x28)
+#define OMAP_SRAM_SCRATCH_BOARD_EEPROM_END (SRAM_SCRATCH_SPACE_ADDR + 0x200)
+#define OMAP_SRAM_SCRATCH_SPACE_END(OMAP_SRAM_SCRATCH_BOARD_EEPROM_END)
 
 /* Boot parameters */
 #define DEVICE_DATA_OFFSET 0x18
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
new file mode 100644
index ..adf73abc9358
--- /dev/null
+++ b/board/ti/common/Kconfig
@@ -0,0 +1,5 @@
+config TI_I2C_BOARD_DETECT
+   bool "Support for Board detection for TI platforms"
+   help
+  Support for detection board information on Texas Instrument's
+  Evaluation Boards which have I2C based EEPROM detection
diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile
new file mode 100644
index ..7170eac81e87
--- /dev/null
+++ b/board/ti/common/Makefile
@@ -0,0 +1,6 @@
+# Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
new file mode 100644
index ..6cf4859967b9
--- /dev/null
+++ b/board/ti/common/board_detect.c
@@ -0,0 +1,254 @@
+/*
+

[U-Boot] [PATCH V5 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm

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

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

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

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Nishanth Menon <n...@ti.com>
---

V5:
  - bug fixes for sys_info updates
  - updated for newer API usage
  - beagle-x15 and gpevm share the same dtb in findfdt - to ensure backward 
compatibility.

v4: https://patchwork.ozlabs.org/patch/540769/

v3:  https://patchwork.ozlabs.org/patch/540195/

v2:  http://marc.info/?t=14465534463=1=2

v1:  http://marc.info/?t=14460800792=1=2
http://marc.info/?t=14460800794=1=2
(mailing list squashed original submission)

 arch/arm/cpu/armv7/omap5/Kconfig  |  1 +
 board/ti/am57xx/Kconfig   |  2 ++
 board/ti/am57xx/board.c   | 70 ++-
 include/configs/am57xx_evm.h  |  4 +++
 include/configs/ti_omap5_common.h |  2 ++
 5 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/omap5/Kconfig b/arch/arm/cpu/armv7/omap5/Kconfig
index bfa264eccc57..f265b34b6383 100644
--- a/arch/arm/cpu/armv7/omap5/Kconfig
+++ b/arch/arm/cpu/armv7/omap5/Kconfig
@@ -15,6 +15,7 @@ config TARGET_DRA7XX_EVM
 
 config TARGET_BEAGLE_X15
bool "BeagleBoard X15"
+   select TI_I2C_BOARD_DETECT
 
 endchoice
 
diff --git a/board/ti/am57xx/Kconfig b/board/ti/am57xx/Kconfig
index bdb779511b66..17745ff7ea65 100644
--- a/board/ti/am57xx/Kconfig
+++ b/board/ti/am57xx/Kconfig
@@ -9,4 +9,6 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
default "am57xx_evm"
 
+source "board/ti/common/Kconfig"
+
 endif
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 042f9ab1965a..d712ab0571ea 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -30,8 +30,12 @@
 #include 
 #include 
 
+#include "../common/board_detect.h"
 #include "mux_data.h"
 
+#define board_is_x15() board_ti_is("BBRDX15_")
+#define board_is_am572x_evm()  board_ti_is("AM572PM_")
+
 #ifdef CONFIG_DRIVER_TI_CPSW
 #include 
 #endif
@@ -41,8 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
 /* GPIO 7_11 */
 #define GPIO_DDR_VTT_EN 203
 
+#define SYSINFO_BOARD_NAME_MAX_LEN 45
+
 const struct omap_sysinfo sysinfo = {
-   "Board: BeagleBoard x15\n"
+   "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n"
 };
 
 static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = {
@@ -246,6 +252,66 @@ struct vcores_data beagle_x15_volts = {
.iva.pmic   = ,
 };
 
+#ifdef CONFIG_SPL_BUILD
+/* No env to setup for SPL */
+static inline void setup_board_eeprom_env(void) { }
+
+/* Override function to read eeprom information */
+void do_board_detect(void)
+{
+   int rc;
+
+   rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
+ CONFIG_EEPROM_CHIP_ADDRESS);
+   if (rc)
+   printf("ti_i2c_eeprom_init failed %d\n", rc);
+}
+
+#else  /* CONFIG_SPL_BUILD */
+
+/* Override function to read eeprom information: actual i2c read done by SPL*/
+void do_board_detect(void)
+{
+   char *bname = NULL;
+   int rc;
+
+   rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
+ CONFIG_EEPROM_CHIP_ADDRESS);
+   if (rc)
+   printf("ti_i2c_eeprom_init failed %d\n", rc);
+
+   if (board_is_x15())
+   bname = "BeagleBoard X15";
+   else if (board_is_am572x_evm())
+   bname = "AM572x EVM";
+
+   if (bname)
+   snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
+"Board: %s REV %s\n", bname, board_ti_get_rev());
+}
+
+static void setup_board_eeprom_env(void)
+{
+   char *name = "beagle_x15";
+   int rc;
+
+   rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
+ CONFIG_EEPROM_CHIP_ADDRESS);
+   if (rc)
+   goto invali

[U-Boot] [PATCH V5 2/7] ARM: OMAP4/5: Centralize gpi2c_init

2016-02-24 Thread Steve Kipisz
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-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvu...@ti.com>
---
V5: No changes
V4: https://patchwork.ozlabs.org/patch/540771/

v3:  https://patchwork.ozlabs.org/patch/540196/

v2:  http://marc.info/?t=14465534467=1=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
-- 
2.7.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2016-02-24 Thread Steve Kipisz
Several TI EVMs have onboard EEPROM that contain board description
information. The onboard EEPROM on Beaglebone, Beaglebone Black, AM335x
EVM, AM43x EVM, AM57xx EVM, Beagleboard-x15 all share the same format.

This series of patches introduces code which is generic among these
platforms. The boards can use the data for any operations they might
choose.

V5 of the series now updates the v4 series to ensure that latest u-boot
platform support including BBG is supported as well.
This also setsup easier introduction of DRA7-evm variant of eeproms as well.

Testing:
AM335x:
BeagleBone-Green: http://pastebin.ubuntu.com/15183845/
BeagleBone-Black: http://pastebin.ubuntu.com/15183885/
AM335x-SK: http://pastebin.ubuntu.com/15188966/

AM437x:
AM437x-GPEVM: http://pastebin.ubuntu.com/15188896/
AM437x-SK: http://pastebin.ubuntu.com/15188940/

Am57xx:
AM57xx-gpevm: http://pastebin.ubuntu.com/15188997/

baseline:
  master 595af9db2422 Merge branch 'master' of git://www.denx.de/git/u-boot-imx


Lokesh Vutla (1):
  ARM: omap-common: Add standard access for board description EEPROM

Nishanth Menon (2):
  ti: AM335x: Use generic EEPROM detection logic
  ti: AM437x: Use generic EEPROM detection logic

Steve Kipisz (4):
  ARM: OMAP4/5: Centralize early clock initialization
  ARM: OMAP4/5: Centralize gpi2c_init
  ARM: OMAP4/5: Add generic board detection hook
  board: ti: AM57xx: Add detection logic for AM57xx-evm

 arch/arm/Kconfig   |   2 +
 arch/arm/cpu/armv7/omap-common/clocks-common.c |  21 +-
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |  14 +-
 arch/arm/cpu/armv7/omap5/Kconfig   |   1 +
 arch/arm/include/asm/arch-omap4/sys_proto.h|   4 +-
 arch/arm/include/asm/arch-omap5/sys_proto.h|   4 +-
 arch/arm/include/asm/omap_common.h |   7 +-
 board/ti/am335x/Kconfig|   2 +
 board/ti/am335x/board.c| 115 ---
 board/ti/am335x/board.h|  49 ++---
 board/ti/am335x/mux.c  |  13 +-
 board/ti/am43xx/Kconfig|   2 +
 board/ti/am43xx/board.c|  87 +++--
 board/ti/am43xx/board.h|  37 +---
 board/ti/am43xx/mux.c  |   1 +
 board/ti/am57xx/Kconfig|   2 +
 board/ti/am57xx/board.c|  70 ++-
 board/ti/common/Kconfig|   5 +
 board/ti/common/Makefile   |   6 +
 board/ti/common/board_detect.c | 254 +
 board/ti/common/board_detect.h | 140 ++
 include/configs/am57xx_evm.h   |   4 +
 include/configs/ti_omap5_common.h  |   2 +
 23 files changed, 623 insertions(+), 219 deletions(-)
 create mode 100644 board/ti/common/Kconfig
 create mode 100644 board/ti/common/Makefile
 create mode 100644 board/ti/common/board_detect.c
 create mode 100644 board/ti/common/board_detect.h

-- 
2.7.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V5 6/7] ARM: OMAP4/5: Add generic board detection hook

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvu...@ti.com>
---
V5:
- reviewed by picked up
- no functional changes
V4: https://patchwork.ozlabs.org/patch/540774/
v3:  https://patchwork.ozlabs.org/patch/540194/

v2:  http://marc.info/?t=14465534466=1=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);
-- 
2.7.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V5 5/7] ti: AM437x: Use generic EEPROM detection logic

2016-02-24 Thread Steve Kipisz
From: Nishanth Menon 

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

This revision also includes fixes identified by Dave Gerlach


Cc: Dave Gerlach 
Signed-off-by: Nishanth Menon 
Signed-off-by: Steven Kipisz 
Signed-off-by: Lokesh Vutla 
---
V5:
- updated fixes from Dave on i2c init
- rebased to latest api changes
V4: https://patchwork.ozlabs.org/patch/540280/
V1-v3: did not exist

 arch/arm/Kconfig|  1 +
 board/ti/am43xx/Kconfig |  2 ++
 board/ti/am43xx/board.c | 87 +++--
 board/ti/am43xx/board.h | 37 +
 board/ti/am43xx/mux.c   |  1 +
 5 files changed, 39 insertions(+), 89 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 38dd19a7197b..3f2faf0d595e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -381,6 +381,7 @@ config TARGET_AM43XX_EVM
bool "Support am43xx_evm"
select CPU_V7
select SUPPORT_SPL
+   select TI_I2C_BOARD_DETECT
 
 config TARGET_BAV335X
bool "Support bav335x"
diff --git a/board/ti/am43xx/Kconfig b/board/ti/am43xx/Kconfig
index 8d1c16883d8b..9cb80cc3f1da 100644
--- a/board/ti/am43xx/Kconfig
+++ b/board/ti/am43xx/Kconfig
@@ -12,4 +12,6 @@ config SYS_SOC
 config SYS_CONFIG_NAME
default "am43xx_evm"
 
+source "board/ti/common/Kconfig"
+
 endif
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 770726c3f796..d208d2fa8918 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include "../common/board_detect.h"
 #include "board.h"
 #include 
 #include 
@@ -37,48 +38,9 @@ static struct ctrl_dev *cdev = (struct ctrl_dev 
*)CTRL_DEVICE_BASE;
 /*
  * Read header information from EEPROM into global structure.
  */
-static int read_eeprom(struct am43xx_board_id *header)
+static inline int __maybe_unused read_eeprom(void)
 {
-   /* Check if baseboard eeprom is available */
-   if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
-   printf("Could not probe the EEPROM at 0x%x\n",
-  CONFIG_SYS_I2C_EEPROM_ADDR);
-   return -ENODEV;
-   }
-
-   /* read the eeprom using i2c */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header,
-sizeof(struct am43xx_board_id))) {
-   printf("Could not read the EEPROM\n");
-   return -EIO;
-   }
-
-   if (header->magic != 0xEE3355AA) {
-   /*
-* read the eeprom using i2c again,
-* but use only a 1 byte address
-*/
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header,
-sizeof(struct am43xx_board_id))) {
-   printf("Could not read the EEPROM at 0x%x\n",
-  CONFIG_SYS_I2C_EEPROM_ADDR);
-   return -EIO;
-   }
-
-   if (header->magic != 0xEE3355AA) {
-   printf("Incorrect magic number (0x%x) in EEPROM\n",
-  header->magic);
-   return -EINVAL;
-   }
-   }
-
-   strncpy(am43xx_board_name, (char *)header->name, sizeof(header->name));
-   am43xx_board_name[sizeof(header->name)] = 0;
-
-   strncpy(am43xx_board_rev, (char *)header->version, 
sizeof(header->version));
-   am43xx_board_rev[sizeof(header->version)] = 0;
-
-   return 0;
+   return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR);
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -374,6 +336,9 @@ const struct dpll_params *get_dpll_ddr_params(void)
 {
int ind = get_sys_clk_index();
 
+   if (read_eeprom() < 0)
+   return NULL;
+
if (board_is_eposevm())
return _evm_dpll_ddr[ind];
else if (board_is_gpevm() || board_is_sk())
@@ -381,7 +346,7 @@ const struct dpll_params *get_dpll_ddr_params(void)
else if (board_is_idk())
return _dpll_ddr;
 
-   printf(" Board '%s' not supported\n", am43xx_board_name);
+   printf(" Board '%s' not supported\n", board_ti_get_name());
return NULL;
 }
 
@@ -512,16 +477,29 @@ void scale_vcores_idk(u32 m)
}
 }
 
+void gpi2c_init(void)
+{
+   /* When needed to be invoked prior to BSS initialization */
+   static bool first_time = true;
+
+   if (first_time) {
+   enable_i2c0_pin_mux();
+   i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED,
+CONFIG_SYS_OMAP24_I2C_SLAVE);
+   first_time = false;
+   }
+}
+
 void scale_vcores(void)
 {
const struct dpll_params *mpu_params;
-   struct am43xx_board_id header;
 
-   enable_i2c0_pin_mux();
-   i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
-   

[U-Boot] [PATCH V5 4/7] ti: AM335x: Use generic EEPROM detection logic

2016-02-24 Thread Steve Kipisz
From: Nishanth Menon 

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

Signed-off-by: Nishanth Menon 
Signed-off-by: Steven Kipisz 
Signed-off-by: Lokesh Vutla 
---
V5:
- Drops dependency on https://patchwork.ozlabs.org/patch/540280/
- newer API usage
v4: https://patchwork.ozlabs.org/patch/540772/

V3-v1: did not exist

 arch/arm/Kconfig|   1 +
 board/ti/am335x/Kconfig |   2 +
 board/ti/am335x/board.c | 115 ++--
 board/ti/am335x/board.h |  49 -
 board/ti/am335x/mux.c   |  13 +++---
 5 files changed, 60 insertions(+), 120 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d8b63e940768..38dd19a7197b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -368,6 +368,7 @@ config TARGET_AM335X_EVM
select DM
select DM_SERIAL
select DM_GPIO
+   select TI_I2C_BOARD_DETECT
 
 config TARGET_AM335X_SL50
bool "Support am335x_sl50"
diff --git a/board/ti/am335x/Kconfig b/board/ti/am335x/Kconfig
index 49b73abc2090..11ef3caf3908 100644
--- a/board/ti/am335x/Kconfig
+++ b/board/ti/am335x/Kconfig
@@ -38,4 +38,6 @@ config NOR_BOOT
  as the ROM only partially sets up pinmux.  We also default to using
  NOR for environment.
 
+source "board/ti/common/Kconfig"
+
 endif
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index f56d17ec58e1..4330be64994d 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include "../common/board_detect.h"
 #include "board.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -46,43 +47,9 @@ static struct ctrl_dev *cdev = (struct ctrl_dev 
*)CTRL_DEVICE_BASE;
 /*
  * Read header information from EEPROM into global structure.
  */
-static int read_eeprom(struct am335x_baseboard_id *header)
+static inline int __maybe_unused read_eeprom(void)
 {
-   /* Check if baseboard eeprom is available */
-   if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
-   puts("Could not probe the EEPROM; something fundamentally "
-   "wrong on the I2C bus.\n");
-   return -ENODEV;
-   }
-
-   /* read the eeprom using i2c */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header,
-sizeof(struct am335x_baseboard_id))) {
-   puts("Could not read the EEPROM; something fundamentally"
-   " wrong on the I2C bus.\n");
-   return -EIO;
-   }
-
-   if (header->magic != 0xEE3355AA) {
-   /*
-* read the eeprom using i2c again,
-* but use only a 1 byte address
-*/
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header,
-sizeof(struct am335x_baseboard_id))) {
-   puts("Could not read the EEPROM; something "
-   "fundamentally wrong on the I2C bus.\n");
-   return -EIO;
-   }
-
-   if (header->magic != 0xEE3355AA) {
-   printf("Incorrect magic number (0x%x) in EEPROM\n",
-   header->magic);
-   return -EINVAL;
-   }
-   }
-
-   return 0;
+   return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR);
 }
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -223,16 +190,15 @@ const struct dpll_params dpll_ddr_bone_black = {
 
 void am33xx_spl_board_init(void)
 {
-   struct am335x_baseboard_id header;
int mpu_vdd;
 
-   if (read_eeprom() < 0)
+   if (read_eeprom() < 0)
puts("Could not get board ID.\n");
 
/* Get the frequency */
dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
 
-   if (board_is_bone() || board_is_bone_lt()) {
+   if (board_is_bone() || board_is_bone_lt()) {
/* BeagleBone PMIC Code */
int usb_cur_lim;
 
@@ -240,8 +206,7 @@ void am33xx_spl_board_init(void)
 * Only perform PMIC configurations if board rev > A1
 * on Beaglebone White
 */
-   if (board_is_bone() && !strncmp(header.version,
-  "00A1", 4))
+   if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4))
return;
 
if (i2c_probe(TPS65217_CHIP_PM))
@@ -251,7 +216,7 @@ void am33xx_spl_board_init(void)
 * On Beaglebone White we need to ensure we have AC power
 * before increasing the frequency.
 */
-   if (board_is_bone()) {
+   if (board_is_bone()) {
uchar pmic_status_reg;
if (tps65217_reg_read(TPS65217_STATUS,
  

[U-Boot] [PATCH v4 4/7] ti: am335x: Use generic EEPROM detection logic

2015-11-05 Thread Steve Kipisz
From: Nishanth Menon 

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

Signed-off-by: Nishanth Menon 
Signed-off-by: Steven Kipisz 
---
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 
 #include 
 #include 
+#include 
 #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() < 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() || board_is_bone_lt()) {
+   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() && !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()) {
+   if (board_is_bone()) {
uchar pmic_status_reg;
if (tps65217_reg_read(TPS65217_STATUS,
  _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())
+   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()) {
+   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)
 
 

[U-Boot] [PATCH v4 2/7] ARM: OMAP4/5: Centralize gpi2c_init

2015-11-05 Thread Steve Kipisz
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-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvu...@ti.com>
---
Changes in v4 (since v3):
 - Picked up Reviewed-by 

v3:  https://patchwork.ozlabs.org/patch/540196/

v2:  http://marc.info/?t=14465534467=1=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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2015-11-05 Thread Steve Kipisz
From: Lokesh Vutla <lokeshvu...@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 <lokeshvu...@ti.com>
Signed-off-by: Steve Kipisz <s-kipi...@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=14465534481=1=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 ..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 ..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 
+#include 
+#include 
+
+#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 i

[U-Boot] [PATCH v4 5/7] ti: AM437x: Use generic EEPROM detection logic

2015-11-05 Thread Steve Kipisz
From: Nishanth Menon 

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

Signed-off-by: Nishanth Menon 
Signed-off-by: Steven Kipisz 
---
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 
 #include 
 #include 
+#include 
 #include "board.h"
 #include 
 #include 
@@ -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() < 0)
+   return NULL;
 
if (board_is_eposevm())
return _evm_dpll_ddr[ind];
@@ -381,7 +347,7 @@ const struct dpll_params *get_dpll_ddr_params(void)
else if (board_is_idk())
return _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() < 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() < 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, _lpddr2, NULL, NULL, _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, _ddr3, NULL, NULL,
   _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, _ddr3, NULL, NULL,
   _emif_regs_400Mhz_beta, 0);
@@ -655,20 +629,14 @@ int board_init(void)
 int board_late_init(void)
 {
 #ifdef 

[U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm

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

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

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

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
Changes in v4 (since v3):
 - No changes (except for rebase)

v3:  https://patchwork.ozlabs.org/patch/540195/

v2:  http://marc.info/?t=14465534463=1=2

v1:  http://marc.info/?t=14460800792=1=2
 http://marc.info/?t=14460800794=1=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 
 
 #include "mux_data.h"
+#include 
+
+#define board_is_x15() board_am_is("BBRDX15_")
+#define board_is_am572x_evm()  board_am_is("AM572PM_")
 
 #ifdef CONFIG_DRIVER_TI_CPSW
 #include 
@@ -246,6 +250,52 @@ struct vcores_data beagle_x15_volts = {
.iva.pmic   = ,
 };
 
+#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, );
+   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, );
+   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 = _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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 6/7] ARM: OMAP4/5: Add generic board detection hook

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@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=14465534466=1=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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/7] ARM: OMAP4/5: Centralize early clock initialization

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

By splitting up prcm_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-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvu...@ti.com>
---
Changes in v4 (since v3):
 - Picked up Reviewed-by

v3:  https://patchwork.ozlabs.org/patch/540193/

v2:  http://marc.info/?t=14465536301=1=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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 2/5] ARM: OMAP4/5: Centralize gpi2c_init

2015-11-04 Thread Steve Kipisz
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-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
v3 Based on:
 master 83bf0057 arm: at91: reworked meesc board support

Changes in v3 (since v2):
 - No changes

v2:  http://marc.info/?t=14465534467=1=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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 5/5] board: ti: AM57xx: Add detection logic for AM57xx-evm

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

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

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

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
v3 Based on:
 master 83bf0057 arm: at91: reworked meesc board support

Build testing: MAKEALL -s omap4 -s omap5 (no warning/build errors)
Boot Testing:
am57xx_evm_nodt_config: http://pastebin.ubuntu.com/13105264/

Changes in v3 (since v2):
 - Rename is_xxx to board_is_xxx
 - Remove usage of default_name and default to beagle_x15 if there
   are errors reading the EEPROM

v2:  http://marc.info/?t=14465534463=1=2
  (mailing list squashed original submission)

Build testing: MAKEALL -s omap4 -s omap5 (no warnings/build errors)
Boot Testing:
am57xx_evm_nodt_config: http://pastebin.ubuntu.com/13039296/
beagle_x15_config: http://pastebin.ubuntu.com/13039331/

Changes in v2 (since v1):
- move the board detection code into the new routine
  do_board_detect
- eliminate board.h and move the ix_xxx into board.c
- redo commit message to be more clear

v1:  http://marc.info/?t=14460800792=1=2
 http://marc.info/?t=14460800794=1=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..4aa8424e975e 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -31,6 +31,10 @@
 #include 
 
 #include "mux_data.h"
+#include "../common/board.h"
+
+#define board_is_x15() board_am_is("BBRDX15_")
+#define board_is_am572x_evm()  board_am_is("AM572PM_")
 
 #ifdef CONFIG_DRIVER_TI_CPSW
 #include 
@@ -246,6 +250,52 @@ struct vcores_data beagle_x15_volts = {
.iva.pmic   = ,
 };
 
+#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, );
+   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, );
+   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 = _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_

[U-Boot] [PATCH v3 3/5] ARM: omap-common: Add standard access for board description EEPROM

2015-11-04 Thread Steve Kipisz
From: Lokesh Vutla <lokeshvu...@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 AM57x
platform support. AM335x/AM43xx cleanups need to first ensure usage of
omap_common prior to switch over to this generic solution.

Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
v3 Based on:
 master  83bf0057 arm: at91: reworked meesc board support

Changes in v3 (since v2):
 - Create a new directory board/ti/common for code common to TI board
 - Move the EEPROM code to the new directory
 - Move the inline code that access the EEPROM data from omap_common.h
   to new files in the common directory

v2:  http://marc.info/?t=14465534481=1=2
   (mailing list squashed original submission)

Changes in v2:
 - New Patch

 arch/arm/include/asm/omap_common.h |   5 +-
 board/ti/am57xx/Makefile   |   2 +
 board/ti/common/board.c|  54 ++
 board/ti/common/board.h| 117 +
 board/ti/common/ti-i2c-eeprom.c| 148 +
 5 files changed, 325 insertions(+), 1 deletion(-)
 create mode 100644 board/ti/common/board.c
 create mode 100644 board/ti/common/board.h
 create mode 100644 board/ti/common/ti-i2c-eeprom.c

diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index d773b0430ad4..f6d929b15e82 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
@@ -728,4 +730,5 @@ static inline u8 is_dra72x(void)
 u32 omap_sys_boot_device(void);
 #endif
 
+
 #endif /* _OMAP_COMMON_H_ */
diff --git a/board/ti/am57xx/Makefile b/board/ti/am57xx/Makefile
index 5cd6873f5e97..9d85d31b2cf1 100644
--- a/board/ti/am57xx/Makefile
+++ b/board/ti/am57xx/Makefile
@@ -6,3 +6,5 @@
 #
 
 obj-y  := board.o
+obj-y  += ../common/board.o
+obj-${CONFIG_I2C} += ../common/ti-i2c-eeprom.o
diff --git a/board/ti/common/board.c b/board/ti/common/board.c
new file mode 100644
index ..1c02e44916f0
--- /dev/null
+++ b/board/ti/common/board.c
@@ -0,0 +1,54 @@
+/*
+ * board.c
+ *
+ * Common board functions for TI AM based boards.
+ *
+ * Copyright (C) 2015, Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author: Steven Kipisz <s-kipi...@ti.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+
+#include "board.h"
+
+/**
+ * board_am_is() - Generic Board detection logic
+ * @name_tag:  Tag used in eeprom for the board
+ *
+ * Return: false if board information does not match OR eeprom was'nt read.
+ *true otherwise
+ */
+bool board_am_is(char *name_tag)
+{
+   struct ti_am_eeprom *ep = TI_AM_EEPROM_DATA;
+
+   if (ep->header != TI_EEPROM_HEADER_MAGIC)
+   return false;
+   return !strncmp(ep->name, name_tag, TI_EEPROM_HDR_NAME_LEN);
+}
+
+/**
+ * board_am_rev_is() - Compare board revision
+ * @rev_tag:   Revision tag to check in eeprom
+ * @cmp_len:   How many chars to compare?
+ *
+ * NOTE: revision information is often messed up (hence the str len match) :(
+ *
+ * Return: false if board inf

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

2015-11-04 Thread Steve Kipisz
Several TI EVMs have onboard EEPROM that contain board description
information. The onboard EEPROM on Beaglebone, Beaglebone Black, AM335x
EVM, AM43x EVM, AM57xx EVM, Beagleboard-x15 all share the same format.

This series of patches introduces code which is generic among these
platforms. The boards can use the data for any operations they might
choose.

Lokesh Vutla (1):
  ARM: omap-common: Add standard access for board description EEPROM

Steve Kipisz (4):
  ARM: OMAP4/5: Centralize early clock initialization
  ARM: OMAP4/5: Centralize gpi2c_init
  ARM: OMAP4/5: Add generic board detection hook
  board: ti: AM57xx: Add detection logic for AM57xx-evm

 arch/arm/cpu/armv7/omap-common/clocks-common.c |  21 +++-
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |  14 ++-
 arch/arm/include/asm/arch-omap4/sys_proto.h|   4 +-
 arch/arm/include/asm/arch-omap5/sys_proto.h|   4 +-
 arch/arm/include/asm/omap_common.h |   8 +-
 board/ti/am57xx/Makefile   |   2 +
 board/ti/am57xx/board.c|  52 +
 board/ti/common/board.c|  54 +
 board/ti/common/board.h| 117 +++
 board/ti/common/ti-i2c-eeprom.c| 148 +
 include/configs/am57xx_evm.h   |   4 +
 11 files changed, 419 insertions(+), 9 deletions(-)
 create mode 100644 board/ti/common/board.c
 create mode 100644 board/ti/common/board.h
 create mode 100644 board/ti/common/ti-i2c-eeprom.c

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 1/5] ARM: OMAP4/5: Centralize early clock initialization

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

By splitting up prcm_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-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com<
---
v3 Based on:
 master  83bf0057 arm: at91: reworked meesc board support

Changes in v3 (since v2):
 - Remove SPL-only build of setup_clocks_for_console since it needs
   to be built in u-boot for NOR boot
 - Move setup_clocks_for_console from top of setup_early_clocks to inside
   the switch statement.

v2:  http://marc.info/?t=14465536301=1=2
  (mailing list squashed original submission)

Changes in v2:
 - New patch

 arch/arm/cpu/armv7/omap-common/clocks-common.c | 21 +++--
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |  3 +--
 arch/arm/include/asm/arch-omap4/sys_proto.h|  2 +-
 arch/arm/include/asm/arch-omap5/sys_proto.h|  2 +-
 4 files changed, 22 insertions(+), 6 deletions(-)

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 f

[U-Boot] [PATCH v3 4/5] ARM: OMAP4/5: Add generic board detection hook

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
v3 Based on:
 master 83bf0057 arm: at91: reworked meesc board support

Changes in v3 (since v2):
 - No changes

v2:  http://marc.info/?t=14465534466=1=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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/5] ARM: OMAP4/5: Centralize early clock initialization

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

By splitting up prcm_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 and build it just for SPL.

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-kipi...@ti.com>
---
v2 Based on:
 master  a6104737 ARM: at91: sama5: change the environment address to 0x6000

Changes in v2:
 - New patch

 arch/arm/cpu/armv7/omap-common/clocks-common.c | 26 --
 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, 27 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..2ede0818e444 100644
--- a/arch/arm/cpu/armv7/omap-common/clocks-common.c
+++ b/arch/arm/cpu/armv7/omap-common/clocks-common.c
@@ -769,7 +769,8 @@ void lock_dpll(u32 const base)
wait_for_lock(base);
 }
 
-void setup_clocks_for_console(void)
+#ifdef CONFIG_SPL_BUILD
+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,
@@ -801,6 +802,9 @@ void setup_clocks_for_console(void)
CD_CLKCTRL_CLKTRCTRL_HW_AUTO <<
CD_CLKCTRL_CLKTRCTRL_SHIFT);
 }
+#else
+static inline void setup_clocks_for_console(void) { }
+#endif
 
 void do_enable_clocks(u32 const *clk_domains,
u32 const *clk_modules_hw_auto,
@@ -853,14 +857,32 @@ 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)
 {
+   setup_clocks_for_console();
+
switch (omap_hw_init_context()) {
case OMAP_INIT_CONTEXT_SPL:
case OMAP_INIT_CONTEXT_UBOOT_FROM_NOR:
case OMAP_INIT_CONTEXT_UBOOT_AFTER_CH:
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_in

[U-Boot] [PATCH v2 3/5] ARM: omap-common: Add standard access for board description EEPROM

2015-11-03 Thread Steve Kipisz
From: Lokesh Vutla <lokeshvu...@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.

It is important to note that this logic is fundamental to the board
configuration process such as DDR configuration which is needed in
SPL, hence cannot be part of the standard u-boot driver model (which
is available later in the process). Hence, to aid efficiency, the
eeprom contents are copied over to SRAM scratchpad memory area at the
first invocation to retrieve data.

The follow on patches introduce the use of this library for AM57x
platform support. AM335x/AM43xx cleanups need to first ensure usage of
omap_common prior to switch over to this generic solution.

Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
v2 Based on
 master  a6104737  ARM: at91: sama5: change the environment address to 
0x6000

Changes in v2 (since v1)
- make the EEPROM code mor generic for TI EVMs
- rename structures/subroutines to ti_am_x
- add routines to access the EEPROM data
- redo commit message to be more clear

v1:   http://marc.info/?t=14460800791=1=2
(mailing list squashed original submission)

 arch/arm/cpu/armv7/omap-common/Makefile|   1 +
 arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c | 148 +
 arch/arm/include/asm/omap_common.h | 130 +-
 3 files changed, 278 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c

diff --git a/arch/arm/cpu/armv7/omap-common/Makefile 
b/arch/arm/cpu/armv7/omap-common/Makefile
index 464a5d1d732a..53a9fdb81100 100644
--- a/arch/arm/cpu/armv7/omap-common/Makefile
+++ b/arch/arm/cpu/armv7/omap-common/Makefile
@@ -15,6 +15,7 @@ obj-y += clocks-common.o
 obj-y  += emif-common.o
 obj-y  += vc.o
 obj-y  += abb.o
+obj-$(CONFIG_I2C) += ti-i2c-eeprom.o
 endif
 
 ifneq ($(CONFIG_OMAP54XX),)
diff --git a/arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c 
b/arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c
new file mode 100644
index ..f59ebbdb4ee8
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c
@@ -0,0 +1,148 @@
+/*
+ * Library to support early TI EVM EEPROM handling
+ *
+ * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
+ * Lokesh Vutla
+ * Steve Kipisz
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+/**
+ * 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 inline int ti_i2c_eeprom_init(int i2c_bus, int dev_addr)
+{
+   int rc;
+
+   rc = i2c_set_bus_num(i2c_bus);
+   if (rc)
+   return rc;
+
+   return i2c_probe(dev_addr);
+}
+
+/**
+ * ti_i2c_eeprom_read - Read data from an EEPROM
+ * @dev_addr: The device address of the EEPROM
+ * @offset: Offset to start reading in the EEPROM
+ * @ep: Pointer to a buffer to read into
+ * @epsize: Size of buffer
+ *
+ * Return: 0 on success or corresponding result of i2c_read
+ */
+static inline int 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 inline void ti_eeprom_string_cleanup(char *s)
+{
+   int i, l;
+
+   l = strlen(s);
+   for (i = 0; i < l; i++, s++)
+   if (*s < ' ' || *s > '~') {
+   *s = 0;
+   break;
+   }
+}
+
+int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr,
+   struct ti_am_eeprom **epp)
+{
+   int rc;
+   struct ti_am_eeprom *ep;
+
+   if (!epp)
+   return -1;
+
+   ep = TI_AM_EEPROM_DATA;
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   goto already_read;
+
+   /* Initialize with a 

[U-Boot] [PATCH v2 5/5] board: ti: AM57xx: Add detection logic for AM57xx-evm

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

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

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

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
v2 Based on:
 master a6104737 ARM: at91: sama5: change the environment address to 0x6000

Build testing: MAKEALL -s omap4 -s omap5 (no warnings/build errors)
Boot Testing:
am57xx_evm_nodt_config: http://pastebin.ubuntu.com/13039296/
beagle_x15_config: http://pastebin.ubuntu.com/13039331/

Changes in v2 (since v1):
- move the board detection code into the new routine
  do_board_detect
- eliminate board.h and move the ix_xxx into board.c
- redo commit message to be more clear

v1:  http://marc.info/?t=14460800792=1=2
 http://marc.info/?t=14460800794=1=2
(mailing list squashed original submission)

 board/ti/am57xx/board.c   | 53 +++
 include/configs/am57xx_evm.h  |  4 +++
 include/configs/ti_omap5_common.h |  2 ++
 3 files changed, 59 insertions(+)

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 042f9ab1965a..41dd8333b1eb 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -32,6 +32,9 @@
 
 #include "mux_data.h"
 
+#define is_x15()   board_am_is("BBRDX15_")
+#define is_am572x_evm()board_am_is("AM572PM_")
+
 #ifdef CONFIG_DRIVER_TI_CPSW
 #include 
 #endif
@@ -246,6 +249,54 @@ struct vcores_data beagle_x15_volts = {
.iva.pmic   = ,
 };
 
+#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, );
+   if (rc)
+   printf("ti_i2c_eeprom_init failed %d\n", rc);
+}
+
+#else  /* CONFIG_SPL_BUILD */
+
+static void setup_board_eeprom_env(void)
+{
+   char *name = NULL;
+   int rc;
+   struct ti_am_eeprom_printable p;
+
+   rc = ti_i2c_eeprom_am_get_print(CONFIG_EEPROM_BUS_ADDRESS,
+   CONFIG_EEPROM_CHIP_ADDRESS, );
+   if (rc) {
+   printf("Invalid EEPROM data(@0x%p). Default to X15\n",
+  TI_AM_EEPROM_DATA);
+   goto invalid_eeprom;
+   }
+
+   if (is_x15())
+   name = "beagle_x15";
+   else if (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, "beagle_x15", 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 = _prcm;
@@ -265,6 +316,8 @@ int board_init(void)
 int board_late_init(void)
 {
init_sata(0);
+   setup_board_eeprom_env();
+
/*
 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
 * This is the POWERHOLD-in-Low behavior.
diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index 6308cab8e680..1fffdb18fbcd 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -88,4 +88,8 @@
 #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
CONFIG_SYS_SCSI_MAX_LUN)
 
+/* EEPROM */
+#define CONFIG_EEPROM_CHIP_ADDRESS 0x50
+#define CONFIG_EEPROM_BUS_ADDRESS 0
+
 #endif /* __CONFIG_AM57XX_EVM_H */
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index 5acbc92c3f60..ae6e2a556a93 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -120,6 +120,8 @@
"setenv fdtfile dra72-evm.dtb; fi;" \
   

[U-Boot] [PATCH v2 2/5] ARM: OMAP4/5: Centralize gpi2c_init

2015-11-03 Thread Steve Kipisz
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-kipi...@ti.com>
---
v2 Based on:
 master  a6104737 ARM: at91: sama5: change the environment address to 0x6000

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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2015-11-03 Thread Steve Kipisz
Several TI EVMs have onboard EEPROM that contain board description
information. The onboard EEPROM on Beaglebone, Beaglebone Black, AM335x
EVM, AM43x EVM, AM57xx EVM, Beagleboard-x15 all share the same format.

This series of patches introduces code which is generic among these
platforms. The boards can use the data for any operations they might
choose.

Lokesh Vutla (1):
  ARM: omap-common: Add standard access for board description EEPROM

Steve Kipisz (4):
  ARM: OMAP4/5: Centralize early clock initialization
  ARM: OMAP4/5: Centralize gpi2c_init
  ARM: OMAP4/5: Add generic board detection hook
  board: ti: AM57xx: Add detection logic for AM57xx-evm

 arch/arm/cpu/armv7/omap-common/Makefile|   1 +
 arch/arm/cpu/armv7/omap-common/clocks-common.c |  26 -
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |  14 ++-
 arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c | 148 +
 arch/arm/include/asm/arch-omap4/sys_proto.h|   4 +-
 arch/arm/include/asm/arch-omap5/sys_proto.h|   4 +-
 arch/arm/include/asm/omap_common.h | 133 +-
 board/ti/am57xx/board.c|  53 +
 include/configs/am57xx_evm.h   |   4 +
 include/configs/ti_omap5_common.h  |   2 +
 10 files changed, 380 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/ti-i2c-eeprom.c

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/5] ARM: OMAP4/5: Add generic board detection hook

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

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

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
v2 Based on:
 master a61047370d0b73ab886c5863e952695b5ee0d75b

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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] board: ti: beagle_x15: Rename to indicate support for TI am57xx evms

2015-10-29 Thread Steve Kipisz
BeagleBoard X15 (http://beagleboard.org/x15) support in u-boot does
actually support two different platform configuration offered by
TI. In addition to BeagleBoard X15, it also supports the TMDXEVM5728
(or more commonly known as AM5728-evm).

Information about the TI AM57xx EVM can be found here
http://www.ti.com/tool/tmdxevm5728

The EVM configuration is 1-1 compatible with BeagleBoard X15 with the
additional support for mPCIe, mSATA, LCD, touchscreen, Camera, push
button and TI's wlink8 offering.

Hence, we rename the beagle_x15 directory to am57xx to support TI
EVMs that use the AM57xx processor. By doing this we have common code
reuse. This sets the stage to have a common u-boot image solution for
multiple TI EVMs such as that already done for am335x and am437x. This
sets the stage for upcoming multiple TI EVMs that share the same code
base.

NOTE: Commit eae7ae185335 ("am437x: Add am57xx_evm_defconfig using
CONFIG_DM") introduced DT support for beagle_x15 under am57xx_evm
platform name. However, this ignored the potential confusion arising for
users as a result. To prevent this, existing beagle_x15_defconfig is
renamed as am57xx_evm_nodt_defconfig to denote that this is the "non
device tree" configuration for the same platform. We still retain
am57xx-beagle-x15.dts at this point, since we just require the common
minimum dts.

As a result of this change, users should expect changes in build
procedures('make am57xx_evm_nodt_defconfig' instead of 'make
beagle_x15_defconfig'). Hopefully, this would be a one-time change.

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Signed-off-by: Schuyler Patton <spat...@ti.com>
---
v2 Based on:
 master 677f970 common/board_f.c: modify the macro to use get_clocks() more 
common

Build testing: MAKEALL -s omap5 (no warnings/build errors)
Boot Testing:
am57xx_evm_config: http://pastebin.ubuntu.com/13002904/
am57xx_evm_config: http://pastebin.ubuntu.com/13002955/
am57xx_evm_nodt_config: http://pastebin.ubuntu.com/13003008/

Changes in V2 (since v1):
- keep the dt version alive(going with Tom's suggestion:
http://marc.info/?l=u-boot=144615230220768=2 )
- redo commit message to be more clear
v1:  http://marc.info/?t=144607224500010=1=2
(mailing list squashed original submission)

 arch/arm/cpu/armv7/omap5/Kconfig| 2 +-
 board/ti/{beagle_x15 => am57xx}/Kconfig | 4 ++--
 board/ti/am57xx/MAINTAINERS | 7 +++
 board/ti/{beagle_x15 => am57xx}/Makefile| 0
 board/ti/{beagle_x15 => am57xx}/board.c | 0
 board/ti/{beagle_x15 => am57xx}/mux_data.h  | 0
 board/ti/beagle_x15/MAINTAINERS | 6 --
 configs/{beagle_x15_defconfig => am57xx_evm_nodt_defconfig} | 0
 include/configs/{beagle_x15.h => am57xx_evm.h}  | 6 +++---
 9 files changed, 13 insertions(+), 12 deletions(-)
 rename board/ti/{beagle_x15 => am57xx}/Kconfig (70%)
 create mode 100644 board/ti/am57xx/MAINTAINERS
 rename board/ti/{beagle_x15 => am57xx}/Makefile (100%)
 rename board/ti/{beagle_x15 => am57xx}/board.c (100%)
 rename board/ti/{beagle_x15 => am57xx}/mux_data.h (100%)
 delete mode 100644 board/ti/beagle_x15/MAINTAINERS
 rename configs/{beagle_x15_defconfig => am57xx_evm_nodt_defconfig} (100%)
 rename include/configs/{beagle_x15.h => am57xx_evm.h} (96%)

diff --git a/arch/arm/cpu/armv7/omap5/Kconfig b/arch/arm/cpu/armv7/omap5/Kconfig
index 20c3bd9..bfa264e 100644
--- a/arch/arm/cpu/armv7/omap5/Kconfig
+++ b/arch/arm/cpu/armv7/omap5/Kconfig
@@ -24,6 +24,6 @@ config SYS_SOC
 source "board/compulab/cm_t54/Kconfig"
 source "board/ti/omap5_uevm/Kconfig"
 source "board/ti/dra7xx/Kconfig"
-source "board/ti/beagle_x15/Kconfig"
+source "board/ti/am57xx/Kconfig"
 
 endif
diff --git a/board/ti/beagle_x15/Kconfig b/board/ti/am57xx/Kconfig
similarity index 70%
rename from board/ti/beagle_x15/Kconfig
rename to board/ti/am57xx/Kconfig
index a305ff1..bdb7795 100644
--- a/board/ti/beagle_x15/Kconfig
+++ b/board/ti/am57xx/Kconfig
@@ -1,12 +1,12 @@
 if TARGET_BEAGLE_X15
 
 config SYS_BOARD
-   default "beagle_x15"
+   default "am57xx"
 
 config SYS_VENDOR
default "ti"
 
 config SYS_CONFIG_NAME
-   default "beagle_x15"
+   default "am57xx_evm"
 
 endif
diff --git a/board/ti/am57xx/MAINTAINERS b/board/ti/am57xx/MAINTAINERS
new file mode 100644
index 000..b8ae019
--- /dev/null
+++ b/board/ti/am57xx/MAINTAINERS
@@ -0,0 +1,7 @@
+AM57XX EVM
+M: Felipe Balbi <ba...@ti.com>
+S: Maintained
+F: board/ti/am57xx/
+F: include/configs/am57xx_evm.h
+F: configs/am57xx_evm_defconfig
+F: configs/am57xx_evm_nodt_defconfig
diff --git a/board/ti/beagle_x15/Makefile b/board/ti/am57xx/Makefile
similarity index 100%
re

[U-Boot] [PATCH v1] board: ti: beagle_x15: Reused to support am57xx_evm

2015-10-28 Thread Steve Kipisz
Rename the beagle_x15 directory to am57xx to support TI EVMs that use
the AM57xx processor. By doing this we have common code reuse. There
will be multiple TI EVMs that use the same code base.

This will cause changes in build procedures for existing
beagleboard-x15 users.

This is in perparation for follow on patches that will introduce
support for follow on TI EVMs.

Information about the TI AM57xx EVM can be found here
http://www.ti.com/tool/tmdxevm5728

For now, we did turn off CONFIG_DM and CONFIG_DEFAULT_DEVICE_TREE
as we are expecting to add additional boards shortly.

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
Signed-off-by: Schuyler Patton <spat...@ti.com>
---
 arch/arm/cpu/armv7/omap5/Kconfig   |  6 +++---
 board/ti/{beagle_x15 => am57xx}/Kconfig|  6 +++---
 board/ti/am57xx/MAINTAINERS|  6 ++
 board/ti/{beagle_x15 => am57xx}/Makefile   |  0
 board/ti/{beagle_x15 => am57xx}/board.c|  0
 board/ti/{beagle_x15 => am57xx}/mux_data.h |  0
 board/ti/beagle_x15/MAINTAINERS|  6 --
 configs/am57xx_evm_defconfig   | 13 +
 configs/beagle_x15_defconfig   |  8 
 include/configs/{beagle_x15.h => am57xx_evm.h} |  6 +++---
 10 files changed, 16 insertions(+), 35 deletions(-)
 rename board/ti/{beagle_x15 => am57xx}/Kconfig (55%)
 create mode 100644 board/ti/am57xx/MAINTAINERS
 rename board/ti/{beagle_x15 => am57xx}/Makefile (100%)
 rename board/ti/{beagle_x15 => am57xx}/board.c (100%)
 rename board/ti/{beagle_x15 => am57xx}/mux_data.h (100%)
 delete mode 100644 board/ti/beagle_x15/MAINTAINERS
 delete mode 100644 configs/beagle_x15_defconfig
 rename include/configs/{beagle_x15.h => am57xx_evm.h} (96%)

diff --git a/arch/arm/cpu/armv7/omap5/Kconfig b/arch/arm/cpu/armv7/omap5/Kconfig
index 20c3bd9..7734c50 100644
--- a/arch/arm/cpu/armv7/omap5/Kconfig
+++ b/arch/arm/cpu/armv7/omap5/Kconfig
@@ -13,8 +13,8 @@ config TARGET_OMAP5_UEVM
 config TARGET_DRA7XX_EVM
bool "TI DRA7XX"
 
-config TARGET_BEAGLE_X15
-   bool "BeagleBoard X15"
+config TARGET_AM57XX_EVM
+   bool "TI AM57XX EVM board"
 
 endchoice
 
@@ -24,6 +24,6 @@ config SYS_SOC
 source "board/compulab/cm_t54/Kconfig"
 source "board/ti/omap5_uevm/Kconfig"
 source "board/ti/dra7xx/Kconfig"
-source "board/ti/beagle_x15/Kconfig"
+source "board/ti/am57xx/Kconfig"
 
 endif
diff --git a/board/ti/beagle_x15/Kconfig b/board/ti/am57xx/Kconfig
similarity index 55%
rename from board/ti/beagle_x15/Kconfig
rename to board/ti/am57xx/Kconfig
index a305ff1..0302dad 100644
--- a/board/ti/beagle_x15/Kconfig
+++ b/board/ti/am57xx/Kconfig
@@ -1,12 +1,12 @@
-if TARGET_BEAGLE_X15
+if TARGET_AM57XX_EVM
 
 config SYS_BOARD
-   default "beagle_x15"
+   default "am57xx"
 
 config SYS_VENDOR
default "ti"
 
 config SYS_CONFIG_NAME
-   default "beagle_x15"
+   default "am57xx_evm"
 
 endif
diff --git a/board/ti/am57xx/MAINTAINERS b/board/ti/am57xx/MAINTAINERS
new file mode 100644
index 000..d0bb67a
--- /dev/null
+++ b/board/ti/am57xx/MAINTAINERS
@@ -0,0 +1,6 @@
+AM57XX EVM
+M: Felipe Balbi <ba...@ti.com>
+S: Maintained
+F: board/ti/iam57xx_evm/
+F: include/configs/am57xx_evm.h
+F: configs/am57xx_evm_defconfig
diff --git a/board/ti/beagle_x15/Makefile b/board/ti/am57xx/Makefile
similarity index 100%
rename from board/ti/beagle_x15/Makefile
rename to board/ti/am57xx/Makefile
diff --git a/board/ti/beagle_x15/board.c b/board/ti/am57xx/board.c
similarity index 100%
rename from board/ti/beagle_x15/board.c
rename to board/ti/am57xx/board.c
diff --git a/board/ti/beagle_x15/mux_data.h b/board/ti/am57xx/mux_data.h
similarity index 100%
rename from board/ti/beagle_x15/mux_data.h
rename to board/ti/am57xx/mux_data.h
diff --git a/board/ti/beagle_x15/MAINTAINERS b/board/ti/beagle_x15/MAINTAINERS
deleted file mode 100644
index 3f84def..000
--- a/board/ti/beagle_x15/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-BEAGLE X15
-M: Felipe Balbi <ba...@ti.com>
-S: Maintained
-F: board/ti/beagle_x15/
-F: include/configs/beagle_x15.h
-F: configs/beagle_x15_defconfig
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index f6566bf..7573246 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -1,19 +1,8 @@
 CONFIG_ARM=y
 CONFIG_OMAP54XX=y
-CONFIG_TARGET_BEAGLE_X15=y
-CONFIG_DEFAULT_DEVICE_TREE="am57xx-beagle-x15"
+CONFIG_TARGET_AM57XX_EVM=y
 CONFIG_SPL=y
-CONFIG_SPL_STACK_R=y
-CONFIG_SPL_STACK_R_ADDR=0x8200
 CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=3"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
-# CONFIG_CMD_NFS is not set
-CONFIG_OF_CONTROL=y
-CONFIG_DM=y
-CONFIG_SPI_FLASH=y
-CONFIG_S

[U-Boot] [PATCH v1] board: ti: am57xx Add board detection logic

2015-10-28 Thread Steve Kipisz
Add board detection logic for the Beagleboard-x15. This patch
takes advantage of recent infrastructure to allow common means
of board detection.

- Read the EEPROM only once in MLO and store the board name and
  revision in scratchpad memory so it is also available in u-boot.
- Use the board name to detect the Beagleboard-x15 board and
  set it up accordingly.

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
 arch/arm/include/asm/omap_common.h | 10 +-
 board/ti/am57xx/board.c| 29 ++---
 board/ti/am57xx/board.h| 29 +
 3 files changed, 64 insertions(+), 4 deletions(-)
 create mode 100644 board/ti/am57xx/board.h

diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index 9a9b154..7e6ac0b 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -765,7 +765,15 @@ 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)
+#ifdef CONFIG_AM57XX
+#define AM57XX_BOARD_NAME_START (SRAM_SCRATCH_SPACE_ADDR + 0x28)
+#define AM57XX_BOARD_NAME_END   (SRAM_SCRATCH_SPACE_ADDR + 0x34)
+#define AM57XX_BOARD_VERSION_START  (SRAM_SCRATCH_SPACE_ADDR + 0x35)
+#define AM57XX_BOARD_VERSION_END(SRAM_SCRATCH_SPACE_ADDR + 0x49)
+#define OMAP5_SRAM_SCRATCH_SPACE_END   (SRAM_SCRATCH_SPACE_ADDR + 0x4D)
+#else
+#define OMAP5_SRAM_SCRATCH_SPACE_END   (SRAM_SCRATCH_SPACE_ADDR + 0x28)
+#endif
 
 /* Boot parameters */
 #define DEVICE_DATA_OFFSET 0x18
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 042f9ab..869bbe7 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -31,6 +31,7 @@
 #include 
 
 #include "mux_data.h"
+#include "board.h"
 
 #ifdef CONFIG_DRIVER_TI_CPSW
 #include 
@@ -270,6 +271,13 @@ int board_late_init(void)
 * This is the POWERHOLD-in-Low behavior.
 */
palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
+
+   /*
+* Set board_name based on the name in the EEPROM.
+*/
+   if (board_is_x15())
+   setenv("board_name", "beagle_x15");
+
return 0;
 }
 
@@ -282,9 +290,24 @@ void set_muxconf_regs_essential(void)
 #ifdef CONFIG_IODELAY_RECALIBRATION
 void recalibrate_iodelay(void)
 {
-   __recalibrate_iodelay(core_padconf_array_essential,
- ARRAY_SIZE(core_padconf_array_essential),
- iodelay_cfg_array, ARRAY_SIZE(iodelay_cfg_array));
+   struct omap_eeprom ep;
+
+   /*
+* omap_eeprom_init and omap_eeprom_read print a message
+* to the console if they failed.
+*/
+   if (!omap_eeprom_init(CONFIG_SYS_OMAP_I2C0, CONFIG_EEPROM_CHIP_ADDR)) {
+   if (!omap_eeprom_read(CONFIG_EEPROM_CHIP_ADDR, 0, )) {
+   strncpy(am57xx_board_name, (char *)ep.name,
+   sizeof(ep.name));
+   am57xx_board_name[sizeof(ep.name)] = 0;
+   }
+   }
+
+   if (board_is_x15())
+   __recalibrate_iodelay(core_padconf_array_essential,
+   ARRAY_SIZE(core_padconf_array_essential),
+   iodelay_cfg_array, ARRAY_SIZE(iodelay_cfg_array));
 }
 #endif
 
diff --git a/board/ti/am57xx/board.h b/board/ti/am57xx/board.h
new file mode 100644
index 000..55719ce
--- /dev/null
+++ b/board/ti/am57xx/board.h
@@ -0,0 +1,29 @@
+/*
+ * board.h
+ *
+ * TI AM57xx boards information header
+ *
+ * Copyright (C) 2015, Texas Instruments, Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+#include 
+
+static char *const am57xx_board_name = (char *)AM57XX_BOARD_NAME_START;
+static char *const am57xx_board_rev = (char *)AM57XX_BOARD_VERSION_START;
+
+/*
+ * TI AM57xx 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.
+ */
+
+static inline int board_is_x15(void)
+{
+   return !strncmp(am57xx_board_name, "BBRDX15_", HDR_NAME_LEN);
+}
+#endif
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1] ARM: omap-common: Add support for EEPROM

2015-10-28 Thread Steve Kipisz
From: Lokesh Vutla <lokeshvu...@ti.com>

Add support for EEPROM init and read. The am57xx boards have EEPROMs
that have board name, version, serial data and other data. The init
routine will initialize an i2c bus and then probe for the EEPROM
device. The read routine will read data from the EEPROM and store
it in an omap_eeprom structure. The data read will be used later in
board detection of TI EVMs.

This code is in omap-common since it can be reused by other TI EVMs
that have EEPROMs that use the same format. The onboard EEPROM on the
Beaglebone Black, Bealgebone, AM335x EVM, AM34x GP EVM, DRA-74 EVM also
follows the same format. So its better to define a common function,
insted of redefining everywhere.

Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
 arch/arm/cpu/armv7/omap-common/Makefile  |  1 +
 arch/arm/cpu/armv7/omap-common/omap_eeprom.c | 54 +++
 arch/arm/include/asm/omap_common.h   | 55 
 include/configs/am57xx_evm.h | 10 +
 4 files changed, 120 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/omap-common/omap_eeprom.c

diff --git a/arch/arm/cpu/armv7/omap-common/Makefile 
b/arch/arm/cpu/armv7/omap-common/Makefile
index 464a5d1..99ea897 100644
--- a/arch/arm/cpu/armv7/omap-common/Makefile
+++ b/arch/arm/cpu/armv7/omap-common/Makefile
@@ -30,3 +30,4 @@ obj-y += boot-common.o
 obj-y  += lowlevel_init.o
 
 obj-y  += mem-common.o
+obj-$(CONFIG_ENV_EEPROM_IS_ON_I2C) += omap_eeprom.o
diff --git a/arch/arm/cpu/armv7/omap-common/omap_eeprom.c 
b/arch/arm/cpu/armv7/omap-common/omap_eeprom.c
new file mode 100644
index 000..98de51e
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap-common/omap_eeprom.c
@@ -0,0 +1,54 @@
+/*
+ * omap_eeprom.c
+ *
+ * Copyright (C) 2015 Texas Instruments Incorporated -
+ * http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+int omap_eeprom_init(int i2c_bus, int dev_addr)
+{
+   int rc = 0;
+
+   rc = i2c_set_bus_num(i2c_bus);
+   if (rc) {
+   printf("I2C bus %d Initialization failed err=%d\n",
+  i2c_bus, rc);
+   return -1;
+   }
+
+   rc = i2c_probe(dev_addr);
+   if (rc) {
+   printf("I2c probe at address %d on bus %d failed err=%d\n",
+  dev_addr, i2c_bus, rc);
+   return -1;
+   }
+
+   return 0;
+}
+
+int omap_eeprom_read(int dev_addr, int offset, struct omap_eeprom *ep)
+{
+   int ret = 0;
+
+   ret = i2c_read(dev_addr, offset, 2, (uchar *)ep,
+   sizeof(struct omap_eeprom));
+
+   if (!ret) {
+   /*
+* Return error if proper header
+* is not found.
+*/
+   if (ep->header != OMAP_EEPROM_HEADER)
+   ret = -1;
+   } else {
+   printf("i2c read error err=%d\n", ret);
+   }
+
+   return ret;
+}
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index d7b81c1..9a9b154 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -552,6 +552,61 @@ struct vcores_data {
struct volts iva;
 };
 
+/*
+ * TI AM57xx 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 OMAP_EEPROM_HEADER 0xEE3355AA
+
+/**
+ * struct omap_eeprom - This structure holds data read in from the
+ * EEPROM.
+ * @header: This holds the magic number
+ * @name: The name of the board
+ * @version: Board revision
+ * @serail: Board serial number
+ * @config: Reserved
+ * @mac_addr: Any MAC addresses written in the EEPROM
+ *
+ * The data is this struction 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 multible
+ * TI boards with a single MLO and u-boot.
+ */
+struct omap_eeprom {
+   unsigned int header;
+   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];
+};
+
+/**
+ * omap_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 -1 on failure.
+ */
+int omap_eeprom_init(int i2c_bus, int dev_addr);
+
+/**
+ * omap_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 the omap_eeprom structure to read into
+ *
+ * Return: 0 on su

[U-Boot] [PATCH v1] board: ti: am57xx: Add board detection logic for am57xx evm

2015-10-28 Thread Steve Kipisz
Add board detection logic for the AM57xx EVM. More information about
the EVM can be found here
http://www.ti.com/tool/tmdxevm5728

The AM572x Evaluation Module 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. It is a development platform based on the dual ARM
Cortex-A15, dual C66x DSP processor that is integrated with tons of
connectivity such as PCIe, SATA, HDMI, USB 3.0/2.0, Dual Gigabit
Ethernet, and more.

The AM572x Evaluation Module also integrates video and 3D/2D graphics
acceleration, as well as a quad-core Programmable Real-time Unit (PRU)
and dual ARM Cortex-M4 cores.

Signed-off-by: Steve Kipisz <s-kipi...@ti.com>
---
 board/ti/am57xx/board.c   | 4 +++-
 board/ti/am57xx/board.h   | 5 +
 include/configs/ti_omap5_common.h | 2 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 869bbe7..d075a49 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -277,6 +277,8 @@ int board_late_init(void)
 */
if (board_is_x15())
setenv("board_name", "beagle_x15");
+   if (board_is_evm())
+   setenv("board_name", "am57xx_evm");
 
return 0;
 }
@@ -304,7 +306,7 @@ void recalibrate_iodelay(void)
}
}
 
-   if (board_is_x15())
+   if ((board_is_x15() || board_is_evm()))
__recalibrate_iodelay(core_padconf_array_essential,
ARRAY_SIZE(core_padconf_array_essential),
iodelay_cfg_array, ARRAY_SIZE(iodelay_cfg_array));
diff --git a/board/ti/am57xx/board.h b/board/ti/am57xx/board.h
index 55719ce..a380a58 100644
--- a/board/ti/am57xx/board.h
+++ b/board/ti/am57xx/board.h
@@ -26,4 +26,9 @@ static inline int board_is_x15(void)
 {
return !strncmp(am57xx_board_name, "BBRDX15_", HDR_NAME_LEN);
 }
+
+static inline int board_is_evm(void)
+{
+   return !strncmp(am57xx_board_name, "AM572PM_", HDR_NAME_LEN);
+}
 #endif
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index 5acbc92..ae6e2a5 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -120,6 +120,8 @@
"setenv fdtfile dra72-evm.dtb; fi;" \
"if test $board_name = beagle_x15; then " \
"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
+   "if test $board_name = am57xx_evm; then " \
+   "setenv fdtfile am57xx-evm.dtb; fi;" \
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine device tree to use; 
fi; \0" \
"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot