]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: ge: Move VPD EEPROM configuration to the defconfig
authorDenis Zalevskiy <denis.zalevskiy@ge.com>
Wed, 17 Oct 2018 08:33:27 +0000 (10:33 +0200)
committerStefano Babic <sbabic@denx.de>
Mon, 17 Dec 2018 09:46:04 +0000 (10:46 +0100)
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@ge.com>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
board/ge/bx50v3/Kconfig
board/ge/bx50v3/bx50v3.c
board/ge/common/Kconfig [new file with mode: 0644]
board/ge/mx53ppd/Kconfig
board/ge/mx53ppd/mx53ppd.c
configs/ge_bx50v3_defconfig
configs/mx53ppd_defconfig

index 993b0559302b717cd10be12dbd8235f1bdc70144..05938560abdadda08989f9506a51cf271365e7bb 100644 (file)
@@ -15,4 +15,6 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "ge_bx50v3"
 
+source "board/ge/common/Kconfig"
+
 endif
index 7f32af3c0f2b994ae6bc1ff96f2181a4868915b8..13cc4c1ad7143ae75cee010f17232c1dda5195de 100644 (file)
@@ -38,15 +38,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)
@@ -634,11 +625,11 @@ static void process_vpd(struct vpd_cache *vpd)
 static int read_vpd(void)
 {
        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;
 
@@ -646,8 +637,8 @@ static int read_vpd(void)
        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/common/Kconfig b/board/ge/common/Kconfig
new file mode 100644 (file)
index 0000000..637b264
--- /dev/null
@@ -0,0 +1,14 @@
+config SYS_VPD_EEPROM_I2C_ADDR
+       hex "I2C address of the EEPROM device used for VPD"
+       help
+         VPD = Vital Product Data
+
+config SYS_VPD_EEPROM_I2C_BUS
+       int "I2C bus of the EEPROM device used for VPD."
+
+config SYS_VPD_EEPROM_SIZE
+       int "Size in bytes of the EEPROM device used for VPD"
+
+config SYS_VPD_EEPROM_I2C_ADDR_LEN
+       int "Number of bytes to use for VPD EEPROM address"
+       default 1
index 6dc3818cb7bb212a236542d66272a5c508195e92..bebb2fab0173d9794fd67818666709f2a157e825 100644 (file)
@@ -13,4 +13,6 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "mx53ppd"
 
+source "board/ge/common/Kconfig"
+
 endif
index 62137f6b28f5047e750bb2cb5b2ac4b30c036051..3fa53ffe0af54ff7c6d446ef9ade27afbd536c71 100644 (file)
 
 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)
@@ -332,11 +325,11 @@ static int read_vpd(void)
 {
        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;
 
@@ -344,7 +337,8 @@ static int read_vpd(void)
        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);
index c907779636a51c44a6aa249ee8ac5f9ee93abda7..a937ce3892e7b8df735dbc6766ba28efeda8fc1b 100644 (file)
@@ -8,6 +8,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
index 34328fd016205c5f872d969dcc96159be0207a2f..9c8ed880479605f9381e446169d96fa6e19f43ea 100644 (file)
@@ -9,6 +9,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_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y