]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: shc: convert to DM_I2C
authorAnatolij Gustschin <agust@denx.de>
Sat, 3 Aug 2024 16:15:03 +0000 (18:15 +0200)
committerHeiko Schocher <hs@denx.de>
Fri, 9 Aug 2024 04:25:48 +0000 (06:25 +0200)
Conversion to DM_I2C is mandatory, rework to remove
use of legacy I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
board/bosch/shc/board.c
configs/am335x_shc_defconfig
configs/am335x_shc_ict_defconfig
configs/am335x_shc_netboot_defconfig
configs/am335x_shc_sdboot_defconfig

index 59628ce6f570507c8f5c00454015674b085ad723..1f9dc2d8df12275753430bfe04a6389a79720f43 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/emif.h>
 #include <asm/gpio.h>
 #include <i2c.h>
+#include <i2c_eeprom.h>
 #include <miiphy.h>
 #include <cpsw.h>
 #include <linux/delay.h>
@@ -51,21 +52,21 @@ static int shc_eeprom_valid;
 /*
  * Read header information from EEPROM into global structure.
  */
-#define EEPROM_ADDR    0x50
 static int read_eeprom(void)
 {
+       struct udevice *dev;
+       int ret;
+
        /* Check if baseboard eeprom is available */
-       if (i2c_probe(EEPROM_ADDR)) {
-               puts("Could not probe the EEPROM; something fundamentally wrong on the I2C bus.\n");
-               return -ENODEV;
+       ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
+       if (ret) {
+               puts("Could not find EEPROM.\n");
+               return ret;
        }
 
-       /* read the eeprom using i2c */
-       if (i2c_read(EEPROM_ADDR, 0, 2, (uchar *)&header,
-                    sizeof(header))) {
-               puts("Could not read the EEPROM; something fundamentally wrong on the I2C bus.\n");
-               return -EIO;
-       }
+       ret = i2c_eeprom_read(dev, 0, (uint8_t *)&header, sizeof(header));
+       if (ret)
+               return ret;
 
        if (header.magic != HDR_MAGIC) {
                printf("Incorrect magic number (0x%x) in EEPROM\n",
@@ -445,7 +446,6 @@ int board_init(void)
 #if defined(CONFIG_HW_WATCHDOG)
        hw_watchdog_init();
 #endif
-       i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
        if (read_eeprom() < 0)
                puts("EEPROM Content Invalid.\n");
 
index 8fb6e1a5a9bb1d7206486b96eb9bc196d0b92d37..72933ba1a64780e61ccab7197531f008bed07ef8 100644 (file)
@@ -65,10 +65,12 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SLAVE=0x1
 CONFIG_SYS_I2C_SPEED=400000
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_HSMMC2_8BIT=y
 CONFIG_PHY_ADDR_ENABLE=y
index b9f5db23053de81992b9f784882b8220cb05df43..b8a3227557dd3037887a07d838b850f9e30d6689 100644 (file)
@@ -63,10 +63,12 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SLAVE=0x1
 CONFIG_SYS_I2C_SPEED=400000
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_HSMMC2_8BIT=y
 CONFIG_PHY_ADDR_ENABLE=y
index 5c42bf423ff31b71c1d357f3fb51a459f04291be..b25a4de30c785f27d74dac524b97137c455622ff 100644 (file)
@@ -66,10 +66,12 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SLAVE=0x1
 CONFIG_SYS_I2C_SPEED=400000
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_HSMMC2_8BIT=y
 CONFIG_PHY_ADDR_ENABLE=y
index 9375bc93a2f9aea8096f1683252564fb6c96869f..8486ccb6d52c05d578a9ed7dc8988552d2a6033a 100644 (file)
@@ -65,10 +65,12 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SLAVE=0x1
 CONFIG_SYS_I2C_SPEED=400000
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_HSMMC2_8BIT=y
 CONFIG_PHY_ADDR_ENABLE=y