[PATCH 5/9] arm: mvebu: theadorable: Switch to using DM I2C API

Stefan Roese sr at denx.de
Sat Dec 18 14:44:08 CET 2021


On 11/18/21 09:19, Stefan Roese wrote:
> No functional change intended. This patch switches from the legacy I2C
> API to the DM I2C API, so that this code can be used with DM I2C
> enabled.
> 
> Signed-off-by: Stefan Roese <sr at denx.de>

Applied to u-boot-marvell/next

Thanks,
Stefan

> ---
>   board/theadorable/theadorable.c | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/board/theadorable/theadorable.c b/board/theadorable/theadorable.c
> index bb2d51495638..6e41ca239919 100644
> --- a/board/theadorable/theadorable.c
> +++ b/board/theadorable/theadorable.c
> @@ -298,10 +298,19 @@ int board_late_init(void)
>   		bootcount_inc();
>   
>   		if (bootcount > PEX_SWITCH_NOT_FOUNT_LIMIT) {
> -			printf("Issuing power-switch via uC!\n");
> +			struct udevice *dev;
>   
>   			printf("Issuing power-switch via uC!\n");
> -			i2c_set_bus_num(STM_I2C_BUS);
> +			ret = i2c_get_chip_for_busnum(STM_I2C_BUS, STM_I2C_ADDR,
> +						      1, &dev);
> +			if (ret) {
> +				printf("Error selecting STM on I2C bus (ret=%d)\n",
> +				       ret);
> +				printf("Issuing soft-reset...\n");
> +				/* default handling: SOFT reset */
> +				do_reset(NULL, 0, 0, NULL);
> +			}
> +
>   			i2c_buf[0] = STM_I2C_ADDR << 1;
>   			i2c_buf[1] = 0xc5;	/* cmd */
>   			i2c_buf[2] = 0x01;	/* enable */
> @@ -313,7 +322,7 @@ int board_late_init(void)
>   			i2c_buf[6] = 0x00;
>   			i2c_buf[7] = crc8(0x72, &i2c_buf[0], 7);
>   
> -			ret = i2c_write(STM_I2C_ADDR, 0, 0, &i2c_buf[1], 7);
> +			ret = dm_i2c_write(dev, 0, &i2c_buf[1], 7);
>   			if (ret) {
>   				printf("I2C write error (ret=%d)\n", ret);
>   				printf("Issuing soft-reset...\n");
> 

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de


More information about the U-Boot mailing list