[U-Boot] [PATCH 2/6] board: ge: Move VPD EEPROM configuration to the defconfig
Sebastian Reichel
sebastian.reichel at collabora.co.uk
Tue Jun 26 17:43:00 UTC 2018
From: Denis Zalevskiy <denis.zalevskiy at ge.com>
Use standard configuration logic to define EEPROM constants. Names are based on
VPD_EEPROM_ prefix because EEPROM_ is already used by i2c_eeprom driver.
Signed-off-by: Denis Zalevskiy <denis.zalevskiy at ge.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>
---
board/ge/bx50v3/Kconfig | 2 ++
board/ge/bx50v3/bx50v3.c | 17 ++++-------------
board/ge/mx53ppd/Kconfig | 2 ++
board/ge/mx53ppd/mx53ppd.c | 14 ++++----------
configs/ge_bx50v3_defconfig | 9 +++++++++
configs/mx53ppd_defconfig | 10 ++++++++++
6 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/board/ge/bx50v3/Kconfig b/board/ge/bx50v3/Kconfig
index 993b0559302b..05938560abda 100644
--- a/board/ge/bx50v3/Kconfig
+++ b/board/ge/bx50v3/Kconfig
@@ -15,4 +15,6 @@ config SYS_SOC
config SYS_CONFIG_NAME
default "ge_bx50v3"
+source "board/ge/common/Kconfig"
+
endif
diff --git a/board/ge/bx50v3/bx50v3.c b/board/ge/bx50v3/bx50v3.c
index 60d600c50c8b..c703aca7cab3 100644
--- a/board/ge/bx50v3/bx50v3.c
+++ b/board/ge/bx50v3/bx50v3.c
@@ -39,15 +39,6 @@ struct vpd_cache;
static int confidx = 3; /* Default to b850v3. */
static struct vpd_cache vpd;
-#ifndef CONFIG_SYS_I2C_EEPROM_ADDR
-# define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
-# define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
-#endif
-
-#ifndef CONFIG_SYS_I2C_EEPROM_BUS
-#define CONFIG_SYS_I2C_EEPROM_BUS 4
-#endif
-
#define NC_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
PAD_CTL_HYS)
@@ -627,11 +618,11 @@ static void process_vpd(struct vpd_cache *vpd)
static int read_vpd()
{
int res;
- int size = 1024;
+ static const int size = CONFIG_SYS_VPD_EEPROM_SIZE;
uint8_t *data;
unsigned int current_i2c_bus = i2c_get_bus_num();
- res = i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
+ res = i2c_set_bus_num(CONFIG_SYS_VPD_EEPROM_I2C_BUS);
if (res < 0)
return res;
@@ -639,8 +630,8 @@ static int read_vpd()
if (!data)
return -ENOMEM;
- res = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,
- CONFIG_SYS_I2C_EEPROM_ADDR_LEN, data, size);
+ res = i2c_read(CONFIG_SYS_VPD_EEPROM_I2C_ADDR, 0,
+ CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN, data, size);
if (res == 0) {
memset(&vpd, 0, sizeof(vpd));
diff --git a/board/ge/mx53ppd/Kconfig b/board/ge/mx53ppd/Kconfig
index 781c1cf59f61..cc43d839cf92 100644
--- a/board/ge/mx53ppd/Kconfig
+++ b/board/ge/mx53ppd/Kconfig
@@ -14,4 +14,6 @@ config SYS_SOC
config SYS_CONFIG_NAME
default "mx53ppd"
+source "board/ge/common/Kconfig"
+
endif
diff --git a/board/ge/mx53ppd/mx53ppd.c b/board/ge/mx53ppd/mx53ppd.c
index 317d7f69d5a1..47f6e9649cbe 100644
--- a/board/ge/mx53ppd/mx53ppd.c
+++ b/board/ge/mx53ppd/mx53ppd.c
@@ -41,13 +41,6 @@
DECLARE_GLOBAL_DATA_PTR;
-/* Index of I2C1, SEGMENT 1 (see CONFIG_SYS_I2C_BUSES). */
-#define VPD_EEPROM_BUS 2
-
-/* Address of 24C08 EEPROM. */
-#define VPD_EEPROM_ADDR 0x50
-#define VPD_EEPROM_ADDR_LEN 1
-
static u32 mx53_dram_size[2];
phys_size_t get_effective_memsize(void)
@@ -333,11 +326,11 @@ static int read_vpd()
{
struct vpd_cache vpd;
int res;
- int size = 1024;
+ static const int size = CONFIG_SYS_VPD_EEPROM_SIZE;
u8 *data;
unsigned int current_i2c_bus = i2c_get_bus_num();
- res = i2c_set_bus_num(VPD_EEPROM_BUS);
+ res = i2c_set_bus_num(CONFIG_SYS_VPD_EEPROM_I2C_BUS);
if (res < 0)
return res;
@@ -345,7 +338,8 @@ static int read_vpd()
if (!data)
return -ENOMEM;
- res = i2c_read(VPD_EEPROM_ADDR, 0, VPD_EEPROM_ADDR_LEN, data, size);
+ res = i2c_read(CONFIG_SYS_VPD_EEPROM_I2C_ADDR, 0,
+ CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN, data, size);
if (res == 0) {
memset(&vpd, 0, sizeof(vpd));
vpd_reader(size, data, &vpd, vpd_callback);
diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig
index a37df05d0994..829a39e08567 100644
--- a/configs/ge_bx50v3_defconfig
+++ b/configs/ge_bx50v3_defconfig
@@ -7,6 +7,15 @@ CONFIG_FIT=y
CONFIG_BOOTDELAY=1
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+
+# monitor's EEPROM is connected to the bus through the mux channel 1
+# (the number is the offset in CONFIG_SYS_I2C_BUSES)
+CONFIG_SYS_VPD_EEPROM_I2C_BUS=4
+# Address of Atmel 24C08 EEPROM
+CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
+CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN=1
+CONFIG_SYS_VPD_EEPROM_SIZE=1024
+
CONFIG_SUPPORT_RAW_INITRD=y
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_LAST_STAGE_INIT=y
diff --git a/configs/mx53ppd_defconfig b/configs/mx53ppd_defconfig
index 8a0cc5d481ad..4a7e8eee0df1 100644
--- a/configs/mx53ppd_defconfig
+++ b/configs/mx53ppd_defconfig
@@ -8,6 +8,16 @@ CONFIG_BOOTDELAY=1
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+
+# monitor's EEPROM is connected to the bus through the mux channel 1
+# (the number is the offset in CONFIG_SYS_I2C_BUSES)
+# (there is also Frame EEPROM connected to the channel 4 (bus 4))
+CONFIG_SYS_VPD_EEPROM_I2C_BUS=2
+# Address of Atmel 24C08 EEPROM
+CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
+CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN=1
+CONFIG_SYS_VPD_EEPROM_SIZE=1024
+
CONFIG_SUPPORT_RAW_INITRD=y
CONFIG_HUSH_PARSER=y
CONFIG_CMD_BOOTZ=y
--
2.18.0
More information about the U-Boot
mailing list