]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: cm_fx6: convert to DM_I2C
authorAnatolij Gustschin <agust@denx.de>
Wed, 7 Aug 2024 13:09:33 +0000 (15:09 +0200)
committerHeiko Schocher <hs@denx.de>
Fri, 9 Aug 2024 04:26:35 +0000 (06:26 +0200)
Conversion to DM_I2C is mandatory, enable DM_I2C to fix board
removal warning. Convert EEPROM access to use DM_I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
board/compulab/cm_fx6/cm_fx6.c
board/compulab/common/Makefile
board/compulab/common/eeprom.c
board/compulab/common/eeprom.h
configs/cm_fx6_defconfig

index c6d33c32ccd2e5d9b2f7ae24e6e76c2822855f9f..40047cf678306bd49928e31a6483fbe2c1ef7f2e 100644 (file)
@@ -14,6 +14,7 @@
 #include <env.h>
 #include <fsl_esdhc_imx.h>
 #include <init.h>
+#include <i2c.h>
 #include <miiphy.h>
 #include <mtd_node.h>
 #include <net.h>
@@ -256,7 +257,7 @@ static int cm_fx6_setup_one_i2c(int busnum, struct i2c_pads_info *pads)
 {
        int ret;
 
-       ret = setup_i2c(busnum, CONFIG_SYS_I2C_SPEED, 0x7f, pads);
+       ret = setup_i2c(busnum, I2C_SPEED_STANDARD_RATE, 0x7f, pads);
        if (ret)
                printf("Warning: I2C%d setup failed: %d\n", busnum, ret);
 
index 7c8226e6e1645ce1cfb7e52136fba751a0b046d1..c7b2237e5c11bcbd36b0f9d116f1273a8e610d60 100644 (file)
@@ -4,6 +4,12 @@
 #
 # Author: Igor Grinberg <grinberg@compulab.co.il>
 
+CL_EEPROM=y
+
+ifdef CONFIG_TARGET_TRIMSLICE
+CL_EEPROM=
+endif
+
 obj-y                          += common.o
-obj-$(CONFIG_$(SPL_)SYS_I2C_LEGACY)    += eeprom.o
+obj-$(CL_EEPROM)               += eeprom.o
 obj-$(CONFIG_SMC911X)          += omap3_smc911x.o
index efdaf342d5c31be4ac2cdeb728615885946f31dc..1b12d096041ecd20ec623948abcf1c715dbd4da3 100644 (file)
@@ -34,19 +34,15 @@ static int cl_eeprom_layout; /* Implicitly LAYOUT_INVALID */
 
 static int cl_eeprom_read(uint offset, uchar *buf, int len)
 {
+       struct udevice *eeprom;
        int res;
-       unsigned int current_i2c_bus = i2c_get_bus_num();
 
-       res = i2c_set_bus_num(cl_eeprom_bus);
-       if (res < 0)
+       res = i2c_get_chip_for_busnum(cl_eeprom_bus, CONFIG_SYS_I2C_EEPROM_ADDR,
+                                     CONFIG_SYS_I2C_EEPROM_ADDR_LEN, &eeprom);
+       if (res)
                return res;
 
-       res = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, offset,
-                       CONFIG_SYS_I2C_EEPROM_ADDR_LEN, buf, len);
-
-       i2c_set_bus_num(current_i2c_bus);
-
-       return res;
+       return dm_i2c_read(eeprom, offset, (uint8_t *)buf, len);
 }
 
 static int cl_eeprom_setup(uint eeprom_bus)
index 9bd7604a999c66f8848664ae453e276ead01843d..0a44926ebd179e67e0302a093ed22bbe55f3b378 100644 (file)
@@ -10,7 +10,7 @@
 #define _EEPROM_
 #include <errno.h>
 
-#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
+#if !CONFIG_IS_ENABLED(TARGET_TRIMSLICE)
 int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus);
 u32 cl_eeprom_get_board_rev(uint eeprom_bus);
 int cl_eeprom_get_product_name(uchar *buf, uint eeprom_bus);
index 386616cc420f78cf1faf00912ebfdb0c3b6e056c..81a39f70735eb9fa105708be65ba32d975f7bfc5 100644 (file)
@@ -80,7 +80,7 @@ CONFIG_BOUNCE_BUFFER=y
 CONFIG_DWC_AHSATA=y
 # CONFIG_DWC_AHSATA_AHCI is not set
 CONFIG_LBA48=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SYS_MXC_I2C3_SPEED=400000