]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
siemens: eeprom: clean up definitions
authorEnrico Leto <enrico.leto@siemens.com>
Wed, 24 Jan 2024 14:43:49 +0000 (15:43 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 5 Feb 2024 18:32:48 +0000 (13:32 -0500)
Move the I2C and EEPROM address definitions in common board header.

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Signed-off-by: Enrico Leto <enrico.leto@siemens.com>
board/siemens/capricorn/board.c
board/siemens/common/board.c
board/siemens/common/eeprom.h [new file with mode: 0644]
board/siemens/common/factoryset.c
board/siemens/draco/board.c
board/siemens/pxm2/board.c
board/siemens/rut/board.c
include/configs/draco-etamin.h
include/configs/draco-rastaban.h
include/configs/draco-thuban.h

index 924c88e8fab39a177d972631a6338734c855315f..5f7e2b1e899eac8a3c369026523cb11486138eef 100644 (file)
@@ -28,6 +28,7 @@
 #include <asm/arch-imx8/clock.h>
 #endif
 #include <linux/delay.h>
+#include "../common/eeprom.h"
 #include "../common/factoryset.h"
 
 #define GPIO_PAD_CTRL \
@@ -337,13 +338,11 @@ void board_late_mmc_env_init(void)
 }
 
 #ifndef CONFIG_SPL_BUILD
-int factoryset_read_eeprom(int i2c_addr);
-
 static int load_parameters_from_factoryset(void)
 {
        int ret;
 
-       ret = factoryset_read_eeprom(EEPROM_I2C_ADDR);
+       ret = factoryset_read_eeprom(SIEMENS_EE_I2C_ADDR);
        if (ret)
                return ret;
 
index d077751cbe155e215c2b6d58822eb88583c42c9d..420c496581600bf6c980f6aa3b81cd4c77c4e9ac 100644 (file)
@@ -34,7 +34,8 @@
 #include <cpsw.h>
 #include <watchdog.h>
 #include <asm/mach-types.h>
-#include "../common/factoryset.h"
+#include "eeprom.h"
+#include "factoryset.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -70,7 +71,6 @@ void sdram_init(void)
 #endif /* #ifdef CONFIG_SPL_BUILD */
 
 #ifndef CONFIG_SPL_BUILD
-#define FACTORYSET_EEPROM_ADDR         0x50
 /*
  * Basic board specific setup.  Pinmux has been handled already.
  */
@@ -88,7 +88,7 @@ int board_init(void)
        gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
 
 #ifdef CONFIG_FACTORYSET
-       factoryset_read_eeprom(FACTORYSET_EEPROM_ADDR);
+       factoryset_read_eeprom(SIEMENS_EE_I2C_ADDR);
 #endif
 
        gpmc_init();
diff --git a/board/siemens/common/eeprom.h b/board/siemens/common/eeprom.h
new file mode 100644 (file)
index 0000000..a21d427
--- /dev/null
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright Siemens AG 2023
+ *
+ * Common board definitions for siemens boards
+ */
+
+#ifndef _COMMON_EEPROM_H_
+#define _COMMON_EEPROM_H_
+
+/* EEPROM @ I2C */
+#define SIEMENS_EE_I2C_BUS     0
+#define SIEMENS_EE_I2C_ADDR    0x50
+
+/* EEPROM mapping */
+#define SIEMENS_EE_ADDR_NAND_GEO       0x80
+#define SIEMENS_EE_ADDR_DDR3           0x90
+#define SIEMENS_EE_ADDR_CHIP           0x120
+#define SIEMENS_EE_ADDR_FACTORYSET     0x400
+
+#endif /* _COMMON_EEPROM_H_ */
index 4e36a6f319903701787f59a16342d29a90d5feb7..b5befab9f52fa5d9f81881234e4ddd51d2181660 100644 (file)
 #include <net.h>
 #include <errno.h>
 #include <g_dnl.h>
+#include "eeprom.h"
 #include "factoryset.h"
 
-#define EEPR_PG_SZ             0x80
-#define EEPROM_FATORYSET_OFFSET        0x400
-#define OFF_PG            EEPROM_FATORYSET_OFFSET/EEPR_PG_SZ
+#define EEPR_PG_SZ     0x80
+#define OFF_PG         (SIEMENS_EE_ADDR_FACTORYSET / EEPR_PG_SZ)
 
 /* Global variable that contains necessary information from FactorySet */
 struct factorysetcontainer factory_dat;
@@ -159,7 +159,7 @@ int factoryset_read_eeprom(int i2c_addr)
 #endif
 
 #if CONFIG_IS_ENABLED(DM_I2C)
-       ret = uclass_get_device_by_seq(UCLASS_I2C, EEPROM_I2C_BUS, &bus);
+       ret = uclass_get_device_by_seq(UCLASS_I2C, SIEMENS_EE_I2C_BUS, &bus);
        if (ret)
                goto err;
 
@@ -171,14 +171,14 @@ int factoryset_read_eeprom(int i2c_addr)
        if (ret)
                goto err;
 
-       ret = dm_i2c_read(dev, EEPROM_FATORYSET_OFFSET, hdr, sizeof(hdr));
+       ret = dm_i2c_read(dev, SIEMENS_EE_ADDR_FACTORYSET, hdr, sizeof(hdr));
        if (ret)
                goto err;
 #else
        if (i2c_probe(i2c_addr))
                goto err;
 
-       if (i2c_read(i2c_addr, EEPROM_FATORYSET_OFFSET, 2, hdr, sizeof(hdr)))
+       if (i2c_read(i2c_addr, SIEMENS_EE_ADDR_FACTORYSET, 2, hdr, sizeof(hdr)))
                goto err;
 #endif
 
index 8b13d23aca7006a5b28e853a95d8a42e5186fdc2..367a300b8978e712c7adf46d1768322bb85d15fd 100644 (file)
@@ -37,6 +37,7 @@
 #include <watchdog.h>
 #include <linux/delay.h>
 #include "board.h"
+#include "../common/eeprom.h"
 #include "../common/factoryset.h"
 #include <nand.h>
 
@@ -132,16 +133,12 @@ struct am335x_nand_geometry {
        u8 nand_bus;
 };
 
-#define EEPROM_ADDR            0x50
-#define EEPROM_ADDR_DDR3       0x90
-#define EEPROM_ADDR_CHIP       0x120
-
 static int draco_read_nand_geometry(void)
 {
        struct am335x_nand_geometry geo;
 
        /* Read NAND geometry */
-       if (i2c_read(EEPROM_ADDR, 0x80, 2,
+       if (i2c_read(SIEMENS_EE_I2C_ADDR, SIEMENS_EE_ADDR_NAND_GEO, 2,
                     (uchar *)&geo, sizeof(struct am335x_nand_geometry))) {
                printf("Could not read the NAND geomtery; something fundamentally wrong on the I2C bus.\n");
                return -EIO;
@@ -164,20 +161,20 @@ static int draco_read_nand_geometry(void)
 static int read_eeprom(void)
 {
        /* Check if baseboard eeprom is available */
-       if (i2c_probe(EEPROM_ADDR)) {
+       if (i2c_probe(SIEMENS_EE_I2C_ADDR)) {
                printf("Could not probe the EEPROM; something fundamentally wrong on the I2C bus.\n");
                return 1;
        }
 
 #ifdef CONFIG_SPL_BUILD
        /* Read Siemens eeprom data (DDR3) */
-       if (i2c_read(EEPROM_ADDR, EEPROM_ADDR_DDR3, 2,
+       if (i2c_read(SIEMENS_EE_I2C_ADDR, SIEMENS_EE_ADDR_DDR3, 2,
                     (uchar *)&settings.ddr3, sizeof(struct ddr3_data))) {
                printf("Could not read the EEPROM; something fundamentally wrong on the I2C bus.\nUse default DDR3 timings\n");
                set_default_ddr3_timings();
        }
        /* Read Siemens eeprom data (CHIP) */
-       if (i2c_read(EEPROM_ADDR, EEPROM_ADDR_CHIP, 2,
+       if (i2c_read(SIEMENS_EE_I2C_ADDR, SIEMENS_EE_ADDR_CHIP, 2,
                     (uchar *)&settings.chip, sizeof(settings.chip)))
                printf("Could not read chip settings\n");
 
index 40aee7c8b3e92c5c4a28a2d9f897700433e34f79..9e85d9b921daa7250799bb485923e950e2f312b6 100644 (file)
@@ -36,6 +36,7 @@
 #include <cpsw.h>
 #include <watchdog.h>
 #include "board.h"
+#include "../common/eeprom.h"
 #include "../common/factoryset.h"
 #include "pmic.h"
 #include <nand.h>
index bad0b71ce2dc190b3cb794ae2ea4f80b8d8e2c6f..49318b320352f9cb3e7231434b1a6e601832f7c9 100644 (file)
@@ -36,6 +36,7 @@
 #include <watchdog.h>
 #include <linux/delay.h>
 #include "board.h"
+#include "../common/eeprom.h"
 #include "../common/factoryset.h"
 
 /*
index 97585a4fd1261c0f625ca42b30180f408e310725..6ae85b575b74bb8f375423e4b41c2a63a05c6079 100644 (file)
@@ -69,9 +69,6 @@
 /* Physical Memory Map */
 #define CFG_MAX_RAM_BANK_SIZE       (1024 << 20)    /* 1GB */
 
-#define EEPROM_ADDR_DDR3 0x90
-#define EEPROM_ADDR_CHIP 0x120
-
 /* nedded by compliance test in read mode */
 
 #undef COMMON_ENV_DFU_ARGS
index 0991ebfd00cd89050ba10b8bd022be2ce05cd247..1b95606cca923ad94613f4eae940ee10ff331237 100644 (file)
@@ -34,9 +34,6 @@
  /* Physical Memory Map */
 #define CFG_MAX_RAM_BANK_SIZE  (1024 << 20)    /* 1GB */
 
-#define EEPROM_ADDR_DDR3 0x90
-#define EEPROM_ADDR_CHIP 0x120
-
 /* Default env settings */
 #define CFG_EXTRA_ENV_SETTINGS \
        "hostname=rastaban\0" \
index f4c04c55ebffec39ab84fbbcc8c992ba20e944ba..629558e27ec312bbe6a6b9f673fff9229b4616a5 100644 (file)
@@ -27,9 +27,6 @@
  /* Physical Memory Map */
 #define CFG_MAX_RAM_BANK_SIZE  (1024 << 20)    /* 1GB */
 
-#define EEPROM_ADDR_DDR3 0x90
-#define EEPROM_ADDR_CHIP 0x120
-
 /* Default env settings */
 #define CFG_EXTRA_ENV_SETTINGS \
        "hostname=thuban\0" \