Skip to contentSkip to conversation

board: shc: convert to DM_I2C

PATCH Superseded Anatolij Gustschin 5 participants 20 messages Aug 3, 2024 – Aug 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/11 board: shc: convert to DM_I2C

Conversion to DM_I2C is mandatory, rework to remove use of legacy I2C API.

---
Cc: Heiko Schocher <[email protected]>
Cc: Tom Rini <[email protected]>

---
 board/bosch/shc/board.c              | 22 +++++++++++-----------
 configs/am335x_shc_defconfig         |  4 +++-
 configs/am335x_shc_ict_defconfig     |  4 +++-
 configs/am335x_shc_netboot_defconfig |  4 +++-
 configs/am335x_shc_sdboot_defconfig  |  4 +++-
 5 files changed, 23 insertions(+), 15 deletions(-)
board/bosch/shc/board.c +11 -11
index ab68874593..92c7b20f75 100644
@@ -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");
 
configs/am335x_shc_defconfig +3 -1
index 47c08e5054..dbce4611de 100644
@@ -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
configs/am335x_shc_ict_defconfig +3 -1
index c7618c5c79..24c6d44840 100644
@@ -64,10 +64,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
configs/am335x_shc_netboot_defconfig +3 -1
index 934265815b..0971d64afb 100644
@@ -67,10 +67,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
configs/am335x_shc_sdboot_defconfig +3 -1
index 439f9b8188..14d4fa4d6d 100644
@@ -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
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/11 board: chiliboard: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

---
Cc: Marcin Niestroj <[email protected]>
Cc: Tom Rini <[email protected]>

---
 configs/chiliboard_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/chiliboard_defconfig +1 -1
index c574d93806..0e8737565f 100644
@@ -53,7 +53,7 @@ CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_MISC=y
 CONFIG_MMC_OMAP_HS=y
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/11 board: cm-t43: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Tom Rini <[email protected]>

---
 board/compulab/cm_t43/cm_t43.c | 2 --
 configs/cm_t43_defconfig       | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)
board/compulab/cm_t43/cm_t43.c +0 -2
index 181581926c..983991ea46 100644
@@ -48,8 +48,6 @@ int board_init(void)
 	gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
 	gpmc_init();
 	set_i2c_pin_mux();
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-	i2c_probe(TPS65218_CHIP_PM);
 
 	return 0;
 }
configs/cm_t43_defconfig +2 -1
index 32f126a517..1c9ae335e9 100644
@@ -38,6 +38,7 @@ CONFIG_SPL_SYS_MALLOC_SIZE=0x800000
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x480
 CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C=y
+# CONFIG_SPL_DM_I2C is not set
 CONFIG_SPL_MTD=y
 # CONFIG_SPL_NAND_SUPPORT is not set
 CONFIG_SPL_NAND_DRIVERS=y
@@ -72,7 +73,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_SYS_RX_ETH_BUFFER=64
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_HSMMC2_8BIT=y
Signature · 1 line
2.25.1
#3 lore raw

PATCH 4/11 board: igep003x: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

---
Cc: Javier Martínez Canillas <[email protected]>
Cc: Tom Rini <[email protected]>

---
 configs/am335x_igep003x_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/am335x_igep003x_defconfig +1 -1
index ddffd4f46f..25fa7818fa 100644
@@ -76,7 +76,7 @@ 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_MMC_OMAP_HS=y
 CONFIG_MTD=y
Signature · 1 line
2.25.1
#4 lore raw

PATCH 5/11 board: sl50: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

---
Cc: Enric Balletbo i Serra <[email protected]>
Cc: Tom Rini <[email protected]>

---
 configs/am335x_sl50_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/am335x_sl50_defconfig +1 -1
index 88122bd052..158458f532 100644
@@ -66,7 +66,7 @@ CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 CONFIG_MMC_OMAP_HS=y
Signature · 1 line
2.25.1
#5 lore raw

PATCH 6/11 board: rut: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C
to disable board removal warning.

---
Cc: Enrico Leto <[email protected]>
Cc: Tom Rini <[email protected]>

---
 configs/rut_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/rut_defconfig +1 -1
index 7e78f1d649..fb57565e06 100644
@@ -90,7 +90,7 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_NAND=y
 CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 # CONFIG_SPL_DM_MMC is not set
 CONFIG_MMC_OMAP_HS=y
Signature · 1 line
2.25.1
#6 lore raw

PATCH 7/11 board: novena: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning. Convert EEPROM and IT6251 access to use DM_I2C API.

---
Cc: Marek Vasut <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

---
 board/kosagi/novena/novena.c |  10 +--
 board/kosagi/novena/video.c  | 140 +++++++++++++++++++----------------
 configs/novena_defconfig     |   2 +-
 3 files changed, 81 insertions(+), 71 deletions(-)
board/kosagi/novena/novena.c +5 -5
index 3220727f23..f65551ece5 100644
@@ -137,23 +137,23 @@ struct novena_eeprom_data {
 int misc_init_r(void)
 {
 	struct novena_eeprom_data data;
-	uchar *datap = (uchar *)&data;
+	uint8_t *datap = (uint8_t *)&data;
 	const char *signature = "Novena";
+	struct udevice *eeprom;
 	int ret;
 
 	/* If 'ethaddr' is already set, do nothing. */
 	if (env_get("ethaddr"))
 		return 0;
 
-	/* EEPROM is at bus 2. */
-	ret = i2c_set_bus_num(2);
+	/* EEPROM is at bus 2, address 0x56 */
+	ret = i2c_get_chip_for_busnum(2, 0x56, 1, &eeprom);
 	if (ret) {
 		puts("Cannot select EEPROM I2C bus.\n");
 		return 0;
 	}
 
-	/* EEPROM is at address 0x56. */
-	ret = eeprom_read(0x56, 0, datap, sizeof(data));
+	ret = dm_i2c_read(eeprom, 0, datap, sizeof(data));
 	if (ret) {
 		puts("Cannot read I2C EEPROM.\n");
 		return 0;
board/kosagi/novena/video.c +75 -65

261 lines not on this page · raw message

configs/novena_defconfig +1 -1
index 322689ef3a..dd3541bc59 100644
@@ -67,7 +67,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_DWC_AHSATA=y
 CONFIG_LBA48=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
Signature · 1 line
2.25.1
Reviewed-by on v1 7/11
#7 lore raw

Re: [PATCH 07/11] board: novena: convert to DM_I2C

Quoted 9 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning. Convert EEPROM and IT6251 access to use DM_I2C API.

---
Cc: Marek Vasut <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

Thanks !

#8 lore raw

PATCH 8/11 board: vining_2000: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning.

---
Cc: Silvio Fricke <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

---
 board/softing/vining_2000/vining_2000.c | 25 -------------------------
 configs/vining_2000_defconfig           |  4 +---
 2 files changed, 1 insertion(+), 28 deletions(-)
board/softing/vining_2000/vining_2000.c +0 -25
index a0dbf97524..bd430cfaa7 100644
@@ -18,7 +18,6 @@
 #include <asm/gpio.h>
 #include <asm/mach-imx/iomux-v3.h>
 #include <asm/io.h>
-#include <asm/mach-imx/mxc_i2c.h>
 #include <asm/sections.h>
 #include <env.h>
 #include <linux/bitops.h>
@@ -27,7 +26,6 @@
 #include <config.h>
 #include <fsl_esdhc_imx.h>
 #include <mmc.h>
-#include <i2c.h>
 #include <miiphy.h>
 #include <netdev.h>
 #include <power/pmic.h>
@@ -53,10 +51,6 @@ DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_HIGH |		\
 	PAD_CTL_SRE_FAST)
 
-#define I2C_PAD_CTRL  (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP |	\
-	PAD_CTL_PKE | PAD_CTL_ODE | PAD_CTL_SPEED_MED |		\
-	PAD_CTL_DSE_40ohm)
-
 #define USDHC_CLK_PAD_CTRL  (PAD_CTL_HYS | PAD_CTL_SPEED_MED |	\
 	PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST)
 
@@ -120,21 +114,6 @@ eth_fail:
 	return ret;
 }
 
-#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
-/* I2C1 for PMIC */
-static struct i2c_pads_info i2c_pad_info1 = {
-	.scl = {
-		.i2c_mode = MX6_PAD_GPIO1_IO00__I2C1_SCL | PC,
-		.gpio_mode = MX6_PAD_GPIO1_IO00__GPIO1_IO_0 | PC,
-		.gp = IMX_GPIO_NR(1, 0),
-	},
-	.sda = {
-		.i2c_mode = MX6_PAD_GPIO1_IO01__I2C1_SDA | PC,
-		.gpio_mode = MX6_PAD_GPIO1_IO01__GPIO1_IO_1 | PC,
-		.gp = IMX_GPIO_NR(1, 1),
-	},
-};
-
 static struct pmic *pfuze_init(unsigned char i2cbus)
 {
 	struct pmic *p;
@@ -400,10 +379,6 @@ int board_init(void)
 	/* Address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
-#ifdef CONFIG_SYS_I2C_MXC
-	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
-#endif
-
 	return board_net_init();
 }
 
configs/vining_2000_defconfig +1 -3
index c39597cdf5..45012365e0 100644
@@ -12,8 +12,6 @@ CONFIG_ENV_OFFSET=0x80000
 CONFIG_MX6SX=y
 CONFIG_MX6_DDRCAL=y
 CONFIG_TARGET_SOFTING_VINING_2000=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6sx-softing-vining-2000"
 CONFIG_SPL_TEXT_BASE=0x00908000
@@ -70,7 +68,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_USE_ETHPRIME=y
 CONFIG_ETHPRIME="FEC"
 CONFIG_BOUNCE_BUFFER=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_RPMB=y
Signature · 1 line
2.25.1
#9 lore raw

PATCH v2 8/11 board: vining_2000: convert to DM_I2C

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning.

---
Cc: Silvio Fricke <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heiko Schocher <[email protected]>
Cc: Tom Rini <[email protected]>
---
Changes in v2:
do not remove CONFIG_SYS_I2C_MXC_I2C* to fix build warnings/errors

 board/softing/vining_2000/vining_2000.c | 25 -------------------------
 configs/vining_2000_defconfig           |  2 +-
 2 files changed, 1 insertion(+), 26 deletions(-)
board/softing/vining_2000/vining_2000.c +0 -25
index a0dbf97524..bd430cfaa7 100644
@@ -18,7 +18,6 @@
 #include <asm/gpio.h>
 #include <asm/mach-imx/iomux-v3.h>
 #include <asm/io.h>
-#include <asm/mach-imx/mxc_i2c.h>
 #include <asm/sections.h>
 #include <env.h>
 #include <linux/bitops.h>
@@ -27,7 +26,6 @@
 #include <config.h>
 #include <fsl_esdhc_imx.h>
 #include <mmc.h>
-#include <i2c.h>
 #include <miiphy.h>
 #include <netdev.h>
 #include <power/pmic.h>
@@ -53,10 +51,6 @@ DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_HIGH |		\
 	PAD_CTL_SRE_FAST)
 
-#define I2C_PAD_CTRL  (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP |	\
-	PAD_CTL_PKE | PAD_CTL_ODE | PAD_CTL_SPEED_MED |		\
-	PAD_CTL_DSE_40ohm)
-
 #define USDHC_CLK_PAD_CTRL  (PAD_CTL_HYS | PAD_CTL_SPEED_MED |	\
 	PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST)
 
@@ -120,21 +114,6 @@ eth_fail:
 	return ret;
 }
 
-#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
-/* I2C1 for PMIC */
-static struct i2c_pads_info i2c_pad_info1 = {
-	.scl = {
-		.i2c_mode = MX6_PAD_GPIO1_IO00__I2C1_SCL | PC,
-		.gpio_mode = MX6_PAD_GPIO1_IO00__GPIO1_IO_0 | PC,
-		.gp = IMX_GPIO_NR(1, 0),
-	},
-	.sda = {
-		.i2c_mode = MX6_PAD_GPIO1_IO01__I2C1_SDA | PC,
-		.gpio_mode = MX6_PAD_GPIO1_IO01__GPIO1_IO_1 | PC,
-		.gp = IMX_GPIO_NR(1, 1),
-	},
-};
-
 static struct pmic *pfuze_init(unsigned char i2cbus)
 {
 	struct pmic *p;
@@ -400,10 +379,6 @@ int board_init(void)
 	/* Address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
-#ifdef CONFIG_SYS_I2C_MXC
-	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
-#endif
-
 	return board_net_init();
 }
 
configs/vining_2000_defconfig +1 -1
index c39597cdf5..e5c9c2861e 100644
@@ -70,7 +70,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_USE_ETHPRIME=y
 CONFIG_ETHPRIME="FEC"
 CONFIG_BOUNCE_BUFFER=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_RPMB=y
Signature · 1 line
2.25.1
#10 lore raw

PATCH 9/11 board: sniper: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning. Also enable OF_UPSTREAM since we do not have a default device tree.

---
Cc: Paul Kocialkowski <[email protected]>
Cc: Tom Rini <[email protected]>

---
 arch/arm/mach-omap2/omap3/Kconfig | 1 +
 configs/sniper_defconfig          | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/omap3/Kconfig +1 -0
index f15f44fe7d..b56e379ca1 100644
@@ -115,6 +115,7 @@ config TARGET_SNIPER
 	select OMAP3_GPIO_5
 	select OMAP3_GPIO_6
 	imply CMD_DM
+	imply OF_UPSTREAM
 
 endchoice
 
configs/sniper_defconfig +4 -2
index 0243b15f31..29e783da8a 100644
@@ -7,6 +7,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x400
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x4020ff00
+CONFIG_DEFAULT_DEVICE_TREE="ti/omap/omap3-sniper"
 CONFIG_SPL_TEXT_BASE=0x40200000
 CONFIG_TARGET_SNIPER=y
 CONFIG_SPL_STACK=0x4020fffc
@@ -32,12 +33,13 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-CONFIG_SYS_I2C_LEGACY=y
+# CONFIG_TI_SYSC is not set
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SPEED=400000
 CONFIG_TWL4030_INPUT=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_CONS_INDEX=3
-CONFIG_OF_LIBFDT=y
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH 09/11] board: sniper: convert to DM_I2C

Hi,

Quoted 4 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning. Also enable OF_UPSTREAM since we do not have a default device tree.

Thanks for looking into this, but I already submitted a similar patch just a few days ago, with additional cleanups!

See https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Cheers,

Paul

Quoted 52 lines

---
Cc: Paul Kocialkowski <[email protected]>
Cc: Tom Rini <[email protected]>

---
 arch/arm/mach-omap2/omap3/Kconfig | 1 +
 configs/sniper_defconfig          | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/omap3/Kconfig +1 -0
index f15f44fe7d..b56e379ca1 100644
@@ -115,6 +115,7 @@ config TARGET_SNIPER
 	select OMAP3_GPIO_5
 	select OMAP3_GPIO_6
 	imply CMD_DM
+	imply OF_UPSTREAM
 
 endchoice
 
configs/sniper_defconfig +4 -2
index 0243b15f31..29e783da8a 100644
@@ -7,6 +7,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x400
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x4020ff00
+CONFIG_DEFAULT_DEVICE_TREE="ti/omap/omap3-sniper"
 CONFIG_SPL_TEXT_BASE=0x40200000
 CONFIG_TARGET_SNIPER=y
 CONFIG_SPL_STACK=0x4020fffc
@@ -32,12 +33,13 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-CONFIG_SYS_I2C_LEGACY=y
+# CONFIG_TI_SYSC is not set
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SPEED=400000
 CONFIG_TWL4030_INPUT=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_CONS_INDEX=3
-CONFIG_OF_LIBFDT=y
Signature · 1 line
2.25.1
Signature · 6 lines
Paul Kocialkowski,

Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/

Expertise in multimedia, graphics and embedded hardware support with Linux.
#12 lore raw

PATCH 10/11 board: cm_fx6: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board removal warning. Convert EEPROM access to use DM_I2C API.

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

---
 board/compulab/cm_fx6/cm_fx6.c |  3 ++-
 board/compulab/common/Makefile |  2 +-
 board/compulab/common/eeprom.c | 14 +++++---------
 board/compulab/common/eeprom.h |  2 +-
 configs/cm_fx6_defconfig       |  2 +-
 5 files changed, 10 insertions(+), 13 deletions(-)
board/compulab/cm_fx6/cm_fx6.c +2 -1
index c6d33c32cc..40047cf678 100644
@@ -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);
 
board/compulab/common/Makefile +1 -1
index 7c8226e6e1..863b50a98e 100644
@@ -5,5 +5,5 @@
 # Author: Igor Grinberg <[email protected]>
 
 obj-y				+= common.o
-obj-$(CONFIG_$(SPL_)SYS_I2C_LEGACY)	+= eeprom.o
+obj-$(CONFIG_$(SPL_)DM_I2C)	+= eeprom.o
 obj-$(CONFIG_SMC911X)		+= omap3_smc911x.o
board/compulab/common/eeprom.c +5 -9
index efdaf342d5..1b12d09604 100644
@@ -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)
board/compulab/common/eeprom.h +1 -1
index 9bd7604a99..ca8738db76 100644
@@ -10,7 +10,7 @@
 #define _EEPROM_
 #include <errno.h>
 
-#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
+#if CONFIG_IS_ENABLED(DM_I2C)
 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);
configs/cm_fx6_defconfig +1 -1
index 386616cc42..81a39f7073 100644
@@ -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
Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH 10/11] board: cm_fx6: convert to DM_I2C

Hello Anatolij,

Quoted 8 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board removal warning. Convert EEPROM access to use DM_I2C API.

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

Quoted 7 lines
---
  board/compulab/cm_fx6/cm_fx6.c |  3 ++-
  board/compulab/common/Makefile |  2 +-
  board/compulab/common/eeprom.c | 14 +++++---------
  board/compulab/common/eeprom.h |  2 +-
  configs/cm_fx6_defconfig       |  2 +-
  5 files changed, 10 insertions(+), 13 deletions(-)

This patch breaks world build ... could you take a look?

https://dev.azure.com/hs0298/hs/_build/results?buildId=114&view=logs&j=08d7dacc-cd40-5df3-6db5-bb431d28637a&t=8da0c77f-a38d-54ad-3682-1c9d5ed6f8aa&l=1228

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#14 lore raw

Re: [PATCH 10/11] board: cm_fx6: convert to DM_I2C

Hello Heiko,

Quoted 19 lines · On Wed, 7 Aug 2024 13:16:21 +0200 Heiko Schocher [email protected] wrote:

Hello Anatolij,

Quoted 8 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board removal warning. Convert EEPROM access to use DM_I2C API.

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

Quoted 7 lines
---
  board/compulab/cm_fx6/cm_fx6.c |  3 ++-
  board/compulab/common/Makefile |  2 +-
  board/compulab/common/eeprom.c | 14 +++++---------
  board/compulab/common/eeprom.h |  2 +-
  configs/cm_fx6_defconfig       |  2 +-
  5 files changed, 10 insertions(+), 13 deletions(-)  
Quoted 3 lines

This patch breaks world build ... could you take a look?

https://dev.azure.com/hs0298/hs/_build/results?buildId=114&view=logs&j=08d7dacc-cd40-5df3-6db5-bb431d28637a&t=8da0c77f-a38d-54ad-3682-1c9d5ed6f8aa&l=1228

I've sent a v2 patch to fix this. Thanks!

--
Anatolij

#15 lore raw

Re: [PATCH 10/11] board: cm_fx6: convert to DM_I2C

Hello Anatolij,

Quoted 24 lines · Anatolij Gustschin

Hello Heiko,

Quoted 19 lines · On Wed, 7 Aug 2024 13:16:21 +0200 Heiko Schocher [email protected] wrote:

Hello Anatolij,

Quoted 15 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board removal warning. Convert EEPROM access to use DM_I2C API.

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

---
   board/compulab/cm_fx6/cm_fx6.c |  3 ++-
   board/compulab/common/Makefile |  2 +-
   board/compulab/common/eeprom.c | 14 +++++---------
   board/compulab/common/eeprom.h |  2 +-
   configs/cm_fx6_defconfig       |  2 +-
   5 files changed, 10 insertions(+), 13 deletions(-)
Quoted 5 lines
Quoted 3 lines

This patch breaks world build ... could you take a look?

https://dev.azure.com/hs0298/hs/_build/results?buildId=114&view=logs&j=08d7dacc-cd40-5df3-6db5-bb431d28637a&t=8da0c77f-a38d-54ad-3682-1c9d5ed6f8aa&l=1228

I've sent a v2 patch to fix this. Thanks!

Thanks!

Applied to my local tree.. wait for response/fix from Fedor for another i2c patch ... than I start another round...

bye,
Heiko

Quoted 4 lines

--
Anatolij

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#16 lore raw

PATCH v2 10/11 board: cm_fx6: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board removal warning. Convert EEPROM access to use DM_I2C API.

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heiko Schocher <[email protected]>
Cc: Tom Rini <[email protected]>
---
Changes in v2: fix trimslice build errors

 board/compulab/cm_fx6/cm_fx6.c |  3 ++-
 board/compulab/common/Makefile |  8 +++++++-
 board/compulab/common/eeprom.c | 14 +++++---------
 board/compulab/common/eeprom.h |  2 +-
 configs/cm_fx6_defconfig       |  2 +-
 5 files changed, 16 insertions(+), 13 deletions(-)
board/compulab/cm_fx6/cm_fx6.c +2 -1
index c6d33c32cc..40047cf678 100644
@@ -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);
 
board/compulab/common/Makefile +7 -1
index 7c8226e6e1..c7b2237e5c 100644
@@ -4,6 +4,12 @@
 #
 # Author: Igor Grinberg <[email protected]>
 
+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
board/compulab/common/eeprom.c +5 -9
index efdaf342d5..1b12d09604 100644
@@ -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)
board/compulab/common/eeprom.h +1 -1
index 9bd7604a99..0a44926ebd 100644
@@ -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);
configs/cm_fx6_defconfig +1 -1
index 386616cc42..81a39f7073 100644
@@ -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
Signature · 1 line
2.25.1
Reviewed-by on v2 10/11
#17 lore raw

Re: [PATCH v2 10/11] board: cm_fx6: convert to DM_I2C

Hi Anatolij,

Quoted 4 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to fix board removal warning. Convert EEPROM access to use DM_I2C API.

Quoted 8 lines

---
Cc: Nikita Kiryanov <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heiko Schocher <[email protected]>
Cc: Tom Rini <[email protected]>
---
Changes in v2: fix trimslice build errors

Thanks

#18 lore raw

PATCH 11/11 board: vf610twr: convert to DM_I2C

In reply to Anatolij Gustschin

Conversion to DM_I2C is mandatory, enable DM_I2C to disable board removal warning.

---
Cc: Alison Wang <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Tom Rini <[email protected]>

---
 configs/vf610twr_defconfig      | 2 +-
 configs/vf610twr_nand_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
configs/vf610twr_defconfig +1 -1
index af889ec903..7713454136 100644
@@ -47,7 +47,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_VYBRID_GPIO=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_ESDHC_IMX=y
 CONFIG_MTD=y
configs/vf610twr_nand_defconfig +1 -1
index c50afc4bec..2cef898863 100644
@@ -48,7 +48,7 @@ CONFIG_ENV_IS_IN_NAND=y
 CONFIG_ENV_RANGE=0x80000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_VYBRID_GPIO=y
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_ESDHC_IMX=y
 CONFIG_MTD=y
Signature · 1 line
2.25.1
Reviewed-by on v1 1/11
#19 lore raw
In reply to Anatolij Gustschin

Hello Anatolij,

Quoted 7 lines · Anatolij Gustschin

Conversion to DM_I2C is mandatory, rework to remove use of legacy I2C API.

---
Cc: Heiko Schocher <[email protected]>
Cc: Tom Rini <[email protected]>

Quoted 7 lines
---
  board/bosch/shc/board.c              | 22 +++++++++++-----------
  configs/am335x_shc_defconfig         |  4 +++-
  configs/am335x_shc_ict_defconfig     |  4 +++-
  configs/am335x_shc_netboot_defconfig |  4 +++-
  configs/am335x_shc_sdboot_defconfig  |  4 +++-
  5 files changed, 23 insertions(+), 15 deletions(-)

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]