]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: beagle: convert to CONFIG_DM_I2C
authorAnatolij Gustschin <agust@denx.de>
Fri, 19 Jul 2024 21:51:23 +0000 (23:51 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 23 Jul 2024 16:36:46 +0000 (10:36 -0600)
Rework to remove use of legacy I2C API.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Tom Rini <trini@konsulko.com>
board/beagle/beagle/beagle.c
configs/omap3_beagle_defconfig
include/configs/omap3_beagle.h

index ac2f89cf213aa664ae8b7d4e4d048e39fb4eae65..ae258817e9ca6686d95126afc3073b61ffb9675a 100644 (file)
@@ -41,7 +41,6 @@
 #include "beagle.h"
 #include <command.h>
 
-#define TWL4030_I2C_BUS                        0
 #define EXPANSION_EEPROM_I2C_BUS       1
 #define EXPANSION_EEPROM_I2C_ADDRESS   0x50
 
@@ -213,27 +212,37 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
  */
 static unsigned int get_expansion_id(void)
 {
-       i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
+       struct udevice *eeprom = NULL;
+       int ret;
 
-       /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
-       if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
-               i2c_set_bus_num(TWL4030_I2C_BUS);
+       ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
+                                     EXPANSION_EEPROM_I2C_ADDRESS, 1, &eeprom);
+       if (ret)
                return BEAGLE_NO_EEPROM;
-       }
 
        /* read configuration data */
-       i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
-                sizeof(expansion_config));
+       ret = dm_i2c_read(eeprom, 0, (uint8_t *)&expansion_config,
+                         sizeof(expansion_config));
+       if (ret != 0) {
+               /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
+               return BEAGLE_NO_EEPROM;
+       }
 
-       /* retry reading configuration data with 16bit addressing */
        if ((expansion_config.device_vendor == 0xFFFFFF00) ||
            (expansion_config.device_vendor == 0xFFFFFFFF)) {
                printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n");
-               i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config,
-                        sizeof(expansion_config));
        }
 
-       i2c_set_bus_num(TWL4030_I2C_BUS);
+       /* retry reading configuration data with 16bit addressing */
+       ret = i2c_get_chip_for_busnum(EXPANSION_EEPROM_I2C_BUS,
+                                     EXPANSION_EEPROM_I2C_ADDRESS, 2, &eeprom);
+       if (ret)
+               return BEAGLE_NO_EEPROM;
+
+       ret = dm_i2c_read(eeprom, 0, (uint8_t *)&expansion_config,
+                         sizeof(expansion_config));
+       if (ret != 0)
+               return BEAGLE_NO_EEPROM;
 
        return expansion_config.device_vendor;
 }
@@ -281,13 +290,13 @@ static void beagle_dvi_pup(void)
                #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
                #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
 
-               i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
+               twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, GPIODATADIR1, &val);
                val |= 4;
-               i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
+               twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, GPIODATADIR1, val);
 
-               i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
+               twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, GPIODATAOUT1, &val);
                val |= 4;
-               i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
+               twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, GPIODATAOUT1, val);
                break;
        }
 }
index 8a709243a900a595f84ceaff4e23a44b554456a0..f76709389ce5852a463c944ad2209d19633e935e 100644 (file)
@@ -61,7 +61,7 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_LED_STATUS=y
 CONFIG_LED_STATUS0=y
index af7cb3513f8f820439950cc51a3d68c18dadd1de..b616dd2608cb182078dcc0e604b9abb7aa76ffe0 100644 (file)
@@ -28,9 +28,6 @@
 /* NAND: SPL falcon mode configs */
 #endif /* CONFIG_MTD_RAW_NAND */
 
-/* Enable Multi Bus support for I2C */
-#define CFG_I2C_MULTI_BUS
-
 /* DSS Support */
 
 /* TWL4030 LED Support */