Fix i2c interface to use new DM interface

This commit is contained in:
Alexandre Bard 2021-01-06 20:54:29 +01:00
parent 4e0582e76e
commit 91093df176
1 changed files with 7 additions and 5 deletions

View File

@ -24,6 +24,7 @@
#include <config.h>
#include <command.h>
#include <i2c.h>
#include <dm/uclass.h>
#include <eeprom_layout.h>
#ifndef CONFIG_SYS_I2C_SPEED
@ -138,14 +139,15 @@ static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
spi_write(addr, alen, buffer, len);
#else /* I2C */
#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
#endif
struct udevice* bus;
uclass_get_device_by_seq(UCLASS_I2C, CONFIG_SYS_I2C_EEPROM_BUS, &bus);
struct udevice *chip;
i2c_get_chip(bus, addr[0], offset, &chip);
if (read)
ret = i2c_read(addr[0], offset, alen - 1, buffer, len);
ret = dm_i2c_read(chip, alen - 1, buffer, len);
else
ret = i2c_write(addr[0], offset, alen - 1, buffer, len);
ret = dm_i2c_write(chip, alen - 1, buffer, len);
if (ret)
ret = 1;