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

2016-02-26 Thread Tom Rini
On Wed, Feb 24, 2016 at 12:30:55PM -0600, Steve Kipisz wrote:

> 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 

Reviewed-by: Tom Rini 

-- 
Tom


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


[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(&header) < 0)
+   if (read_eeprom() < 0)
puts("Could not get board ID.\n");
 
/* Get the frequency */
dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
 
-   if (board_is_bone(&header) || board_is_bone_lt(&header)) {
+   if (board_is_bone() || board_is_bone_lt()) {
/* BeagleBone PMIC Code */
int usb_cur_lim;
 
@@ -240,8 +206,7 @@ void am33xx_spl_board_init(void)
 * Only perform PMIC configurations if board rev > A1
 * on Beaglebone White
 */
-   if (board_is_bone(&header) && !strncmp(header.version,
-  "00A1", 4))
+   if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4))
return;
 
if (i2c_probe(TPS65217_CHIP_PM))
@@ -251,7 +216,7 @@ void am33xx_spl_board_init(void)
 * On Beaglebone White we need to ensure we have AC power
 * before increasing the frequency.
 */
-   if (board_is_bone(&header)) {
+   if (board_is_bone()) {
uchar pmic_status_reg;
if (tps65217_reg_read(TPS65217_STATUS,
  &pmic_status_reg)