]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: keymile: convert to CONFIG_DM_I2C
authorAnatolij Gustschin <agust@denx.de>
Fri, 19 Jul 2024 23:24:22 +0000 (01:24 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 23 Jul 2024 16:38:20 +0000 (10:38 -0600)
The conversion to DM_I2C is mandatory, rework to remove
use of legacy I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Aleksandar Gerasimovski <aleksandar.gerasimovski@hitachienergy.com>
Cc: Holger Brunck <holger.brunck@hitachienergy.com>
Cc: Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
board/keymile/Kconfig
board/keymile/common/common.c
board/keymile/common/common.h
board/keymile/common/ivm.c
board/keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c
configs/pg_wcom_expu1_defconfig
configs/pg_wcom_expu1_update_defconfig
configs/pg_wcom_seli8_defconfig
configs/pg_wcom_seli8_update_defconfig
include/configs/km/pg-wcom-ls102xa.h

index f7e9b74f57827d3a60c2a7f29797d550941e2404..4145881385823d3f4cef66e5261795027d361f9f 100644 (file)
@@ -11,9 +11,6 @@ if VENDOR_KM
 
 menu "KM Board Setup"
 
-config SYS_I2C_INIT_BOARD
-       def_bool y if ARM
-
 config HUSH_INIT_VAR
        def_bool y
 
index 9358c25dcb05151547268bf4655aacfea78de3ee..25897af2d8a4b732ce1067b0dfdfc731bb246e11 100644 (file)
@@ -129,7 +129,6 @@ void check_for_uboot_update(void)
 }
 #endif
 
-#if defined(CONFIG_SYS_I2C_INIT_BOARD)
 static void i2c_write_start_seq(void)
 {
        set_sda(1);
@@ -187,17 +186,6 @@ int i2c_make_abort(void)
        return ret;
 }
 
-/**
- * i2c_init_board - reset i2c bus. When the board is powercycled during a
- * bus transfer it might hang; for details see doc/I2C_Edge_Conditions.
- */
-void i2c_init_board(void)
-{
-       /* Now run the AbortSequence() */
-       i2c_make_abort();
-}
-#endif
-
 #if defined(CONFIG_KM_COMMON_ETH_INIT)
 int board_eth_init(struct bd_info *bis)
 {
index d16c82487b85235469bc35921ed83fe631f3ddc9..7d2fdffe9837341dbf542d13731fae7383bc181b 100644 (file)
@@ -138,13 +138,12 @@ void early_bootcount_store(ulong ebootcount);
 void check_for_uboot_update(void);
 
 #define DELAY_ABORT_SEQ                62  /* @200kHz 9 clocks = 44us, 62us is ok */
-#define DELAY_HALF_PERIOD      (500 / (CONFIG_SYS_I2C_SPEED / 1000))
+#define DELAY_HALF_PERIOD      (500 / (I2C_SPEED_STANDARD_RATE / 1000))
 
 void set_sda(int state);
 void set_scl(int state);
 int get_sda(void);
 int get_scl(void);
 
-int i2c_soft_read_pin(void);
 int i2c_make_abort(void);
 #endif /* __KEYMILE_COMMON_H */
index f01fe44303c902df294701cb7130809ee9fdc64a..9360c86566f65d14209c61b082cc796ac613f54a 100644 (file)
@@ -342,9 +342,8 @@ static int ivm_populate_env(unsigned char *buf, int len, int mac_address_offset)
 
 int ivm_read_eeprom(unsigned char *buf, int len, int mac_address_offset)
 {
-       int ret;
-#if CONFIG_IS_ENABLED(DM_I2C)
        struct udevice *eedev = NULL;
+       int ret;
 
        ret = i2c_get_chip_for_busnum(CONFIG_KM_IVM_BUS,
                                      CONFIG_SYS_IVM_EEPROM_ADR, 1, &eedev);
@@ -354,22 +353,17 @@ int ivm_read_eeprom(unsigned char *buf, int len, int mac_address_offset)
                return 1;
        }
 
+#if CONFIG_IS_ENABLED(ARCH_LS1021A)
+       /* add deblocking here */
+       i2c_make_abort();
+#endif
+
        ret = dm_i2c_read(eedev, 0, buf, len);
        if (ret != 0) {
                printf("Error: Unable to read from I2C EEPROM at address %02X:%02X\n",
                       CONFIG_SYS_IVM_EEPROM_ADR, 0);
                return 1;
        }
-#else
-       i2c_set_bus_num(CONFIG_KM_IVM_BUS);
-       /* add deblocking here */
-       i2c_make_abort();
 
-       ret = i2c_read(CONFIG_SYS_IVM_EEPROM_ADR, 0, 1, buf, len);
-       if (ret != 0) {
-               printf("Error reading EEprom\n");
-               return -2;
-       }
-#endif
        return ivm_populate_env(buf, len, mac_address_offset);
 }
index cc3611e2dec1093e85522deaa37098a283c05366..409a55ebda6aefc125d1f4b17def76b24599609f 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <config.h>
 #include <event.h>
-#include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/immap_ls102xa.h>
 #include <asm/arch/clock.h>
@@ -107,6 +106,13 @@ int board_early_init_f(void)
 
        arch_soc_init();
 
+       /*
+        * Reset I2C bus. When the board is powercycled during a bus
+        * transfer it might hang; for details see doc/I2C_Edge_Conditions.
+        * Now run the AbortSequence()
+        */
+       i2c_make_abort();
+
        return 0;
 }
 
index 61513c9e2ec9d37b858e74b4ace7ccdbd8e89d6e..2f3ff9ac9c5b8f9b4aeff10989e4b0fa9f69979e 100644 (file)
@@ -8,9 +8,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SOURCE_FILE="pg-wcom-expu1"
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_SECT_SIZE=0x20000
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
+CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="ls1021a-pg-wcom-expu1"
 CONFIG_SYS_MONITOR_LEN=1048576
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
@@ -78,7 +76,9 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
 CONFIG_DDR_CLK_FREQ=50000000
 CONFIG_SYS_FSL_DDR3=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
+CONFIG_I2C_MUX=y
+CONFIG_I2C_MUX_PCA954x=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
index ec0f975ae36511ecd146178571fc63c6090ee077..d7ab3c86fd6099c72734dd6a67113f9b7b9bc755 100644 (file)
@@ -8,9 +8,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SOURCE_FILE="pg-wcom-expu1"
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_SECT_SIZE=0x20000
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
+CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="ls1021a-pg-wcom-expu1"
 CONFIG_SYS_MONITOR_LEN=1048576
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
@@ -76,7 +74,9 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
 CONFIG_DDR_CLK_FREQ=50000000
 CONFIG_SYS_FSL_DDR3=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
+CONFIG_I2C_MUX=y
+CONFIG_I2C_MUX_PCA954x=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
index 82923d32ca69a5cf35b6e935c298a0b9fed901ed..bd3ac2e18ace9d730127197d432b222c3c448368 100644 (file)
@@ -8,9 +8,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SOURCE_FILE="pg-wcom-seli8"
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_SECT_SIZE=0x20000
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
+CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="ls1021a-pg-wcom-seli8"
 CONFIG_SYS_MONITOR_LEN=1048576
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
@@ -78,7 +76,9 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
 CONFIG_DDR_CLK_FREQ=50000000
 CONFIG_SYS_FSL_DDR3=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
+CONFIG_I2C_MUX=y
+CONFIG_I2C_MUX_PCA954x=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
index 41931e2476889810db531c91b1ae7542de797e73..733050110b1d29673de525b6d3b8f14d1cdae584 100644 (file)
@@ -8,9 +8,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SOURCE_FILE="pg-wcom-seli8"
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_SECT_SIZE=0x20000
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
+CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="ls1021a-pg-wcom-seli8"
 CONFIG_SYS_MONITOR_LEN=1048576
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
@@ -76,7 +74,9 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
 CONFIG_DDR_CLK_FREQ=50000000
 CONFIG_SYS_FSL_DDR3=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
+CONFIG_I2C_MUX=y
+CONFIG_I2C_MUX_PCA954x=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
index 15ef68a05070f5288b57279117e1dbf00995a8d8..3a243d789c0d7044f17919f899d14ad54edd045d 100644 (file)
  */
 #define CFG_SYS_NS16550_CLK            get_serial_clock()
 
-/*
- * I2C
- */
-
-#define CFG_SYS_I2C_MAX_HOPS           1
-#define CFG_SYS_NUM_I2C_BUSES  3
-#define I2C_MUX_PCA_ADDR               0x70
-#define I2C_MUX_CH_DEFAULT             0x0
-#define CFG_SYS_I2C_BUSES      {       {0, {I2C_NULL_HOP} }, \
-                                       {0, {{I2C_MUX_PCA9547, 0x70, 1 } } }, \
-                                       {1, {I2C_NULL_HOP}                 }, \
-                               }
-
 #define CFG_SMP_PEN_ADDR               0x01ee0200
 
 #define HWCONFIG_BUFFER_SIZE           256