summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-06-27 20:35:49 +0300
committerTom Rini <trini@konsulko.com>2022-07-09 00:57:34 +0300
commitba39d90728ee9a51861dc4803e9a41925d52ad55 (patch)
treeeb12b9373be100dfeb61dd053eb1793e363f14d9
parentedcbd6e38899589b8d03d1f1f8ebc01beb3b574b (diff)
downloadu-boot-ba39d90728ee9a51861dc4803e9a41925d52ad55.tar.xz
legoev3: Migrate to DM_I2C
Perform a basic migration of the calls in setup_serial_number() to DM so that we can switch to using DM_I2C on this platform. Cc: David Lechner <david@lechnology.com> Signed-off-by: Tom Rini <trini@konsulko.com> Acked-by: David Lechner <david@lechnology.com>
-rw-r--r--board/lego/ev3/legoev3.c15
-rw-r--r--configs/legoev3_defconfig2
2 files changed, 14 insertions, 3 deletions
diff --git a/board/lego/ev3/legoev3.c b/board/lego/ev3/legoev3.c
index 980ffef4cd..8349260131 100644
--- a/board/lego/ev3/legoev3.c
+++ b/board/lego/ev3/legoev3.c
@@ -27,6 +27,7 @@
#include <hwconfig.h>
#include <asm/mach-types.h>
#include <asm/setup.h>
+#include <dm/uclass.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -57,6 +58,8 @@ const int lpsc_size = ARRAY_SIZE(lpsc);
*/
static void setup_serial_number(void)
{
+ struct udevice *idev, *ibus;
+ int ret;
u32 offset;
char serial_number[13];
u8 buf[6];
@@ -65,7 +68,15 @@ static void setup_serial_number(void)
if (env_get("serial#"))
return;
- if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) {
+ ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &ibus);
+ if (ret)
+ return;
+
+ ret = dm_i2c_probe(ibus, EEPROM_I2C_ADDR, 0, &idev);
+ if (ret)
+ return;
+
+ if (dm_i2c_read(idev, EEPROM_REV_OFFSET, buf, 2)) {
printf("\nEEPROM revision read failed!\n");
return;
}
@@ -83,7 +94,7 @@ static void setup_serial_number(void)
/* EEPROM rev 3 has Bluetooth address where rev should be */
offset = (eeprom_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_BDADDR_OFFSET;
- if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) {
+ if (dm_i2c_read(idev, offset, buf, 6)) {
printf("\nEEPROM serial read failed!\n");
return;
}
diff --git a/configs/legoev3_defconfig b/configs/legoev3_defconfig
index 3612afb463..36e3d70692 100644
--- a/configs/legoev3_defconfig
+++ b/configs/legoev3_defconfig
@@ -46,7 +46,7 @@ CONFIG_VERSION_VARIABLE=y
# CONFIG_NET is not set
CONFIG_DM=y
# CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
CONFIG_SYS_I2C_DAVINCI=y
CONFIG_MTD=y
CONFIG_DM_SPI_FLASH=y