[U-Boot] [PATCH 4/4] arm: zynq: use i2c cadence DM driver

Michal Simek monstr at monstr.eu
Fri Jul 20 10:57:52 UTC 2018


On 9.7.2018 07:00, Luis Araneda wrote:
> Migrate most boards to the Cadence I2C driver and
> use DM functions to read the MAC address from EEPROM
> 
> Additionally, remove the legacy eeprom command from
> defconfig since it was only used to provide the functions
> to read the MAC address
> 
> Boards ZC702 and ZC706 were not migrated because they have
> I2C multiplexers and require extended validation and testing
> 
> Signed-off-by: Luis Araneda <luaraneda at gmail.com>
> ---
>  arch/arm/dts/zynq-syzygy-hub.dts  |  1 +
>  arch/arm/dts/zynq-zybo.dts        | 10 ++++++++++
>  board/xilinx/zynq/board.c         | 24 ++++++++++++++++++++----
>  configs/syzygy_hub_defconfig      |  5 ++---
>  configs/topic_miami_defconfig     |  5 ++---
>  configs/topic_miamilite_defconfig |  5 ++---
>  configs/topic_miamiplus_defconfig |  5 ++---
>  configs/zynq_zybo_defconfig       |  6 ++----
>  include/configs/syzygy_hub.h      |  2 --
>  include/configs/zynq_zybo.h       |  1 -
>  10 files changed, 41 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/arm/dts/zynq-syzygy-hub.dts b/arch/arm/dts/zynq-syzygy-hub.dts
> index a30d667146..d89e669b71 100644
> --- a/arch/arm/dts/zynq-syzygy-hub.dts
> +++ b/arch/arm/dts/zynq-syzygy-hub.dts
> @@ -15,6 +15,7 @@
>  	aliases {
>  		ethernet0 = &gem0;
>  		serial0 = &uart0;
> +		i2c0 = &i2c1;
>  		mmc0 = &sdhci0;
>  	};
>  

This can be separate patch.

> diff --git a/arch/arm/dts/zynq-zybo.dts b/arch/arm/dts/zynq-zybo.dts
> index 3844822305..b5e0f3d9b3 100644
> --- a/arch/arm/dts/zynq-zybo.dts
> +++ b/arch/arm/dts/zynq-zybo.dts
> @@ -14,6 +14,8 @@
>  		ethernet0 = &gem0;
>  		serial0 = &uart1;
>  		spi0 = &qspi;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
>  		mmc0 = &sdhci0;
>  	};
>  
> @@ -49,6 +51,14 @@
>  	};
>  };
>  
> +&i2c0 {
> +	status = "okay";
> +};
> +
> +&i2c1 {
> +	status = "okay";
> +};
> +

IIRC zybo has no connection from PS to i2c and it is done via PL.
And deal was that only things which are in PS part should be listed in
DTS file. It means this shouldn't be here.


>  &qspi {
>  	u-boot,dm-pre-reloc;
>  	status = "okay";
> diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
> index dcbf788918..5b9ee10a90 100644
> --- a/board/xilinx/zynq/board.c
> +++ b/board/xilinx/zynq/board.c
> @@ -8,6 +8,7 @@
>  #include <dm/uclass.h>
>  #include <fdtdec.h>
>  #include <fpga.h>
> +#include <i2c.h>
>  #include <mmc.h>
>  #include <watchdog.h>
>  #include <wdt.h>
> @@ -76,10 +77,25 @@ int board_late_init(void)
>  int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
>  {
>  #if defined(CONFIG_MAC_ADDR_IN_I2C_EEPROM)
> -	if (eeprom_read(CONFIG_MAC_ADDR_I2C_EEPROM_CHIP_ADDR,
> -			CONFIG_MAC_ADDR_I2C_EEPROM_DATA_ADDR_START,
> -			ethaddr, 6))
> -		printf("I2C EEPROM MAC address read failed\n");
> +	int ret;
> +	struct udevice *bus, *dev;
> +
> +	ret = uclass_get_device_by_seq(UCLASS_I2C,
> +				       CONFIG_MAC_ADDR_I2C_EEPROM_BUS,
> +				       &bus);
> +	if (!ret)
> +		ret = i2c_get_chip(bus,
> +				   CONFIG_MAC_ADDR_I2C_EEPROM_CHIP_ADDR,
> +				   1, &dev);
> +	if (!ret)
> +		ret = i2c_set_chip_offset_len(dev,
> +					      CONFIG_MAC_ADDR_I2C_EEPROM_DATA_ADDR_LEN);
> +	if (!ret)
> +		ret = dm_i2c_read(dev,
> +				  CONFIG_MAC_ADDR_I2C_EEPROM_DATA_ADDR_START,
> +				  ethaddr, 6);
> +	if (ret)
> +		printf("I2C EEPROM MAC address read failed (%i)\n", ret);
>  #endif

In ZynqMP there is also call i2c_set_bus_num which is what you do above.

I don't think that make sense to duplicate this code in board files.
This should go to core. I think eeprom hasn't been converted to DM and
that's the thing which should happen first. Then calling sequence should
be the same in board files.


>  
>  	return 0;
> diff --git a/configs/syzygy_hub_defconfig b/configs/syzygy_hub_defconfig
> index 221349ba6f..bcc3ecda49 100644
> --- a/configs/syzygy_hub_defconfig
> +++ b/configs/syzygy_hub_defconfig
> @@ -18,7 +18,6 @@ CONFIG_BOOTCOMMAND="run $modeboot || run distro_bootcmd"
>  CONFIG_SPL_STACK_R=y
>  CONFIG_SPL_OS_BOOT=y
>  CONFIG_SYS_PROMPT="Zynq> "
> -CONFIG_CMD_EEPROM=y

this will caused regression.

>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_FPGA_LOADBP=y
>  CONFIG_CMD_FPGA_LOADFS=y
> @@ -37,8 +36,8 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQPL=y
>  CONFIG_DM_GPIO=y
> -CONFIG_SYS_I2C_ZYNQ=y
> -CONFIG_ZYNQ_I2C1=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_CADENCE=y
>  CONFIG_MAC_ADDR_IN_I2C_EEPROM=y
>  CONFIG_MAC_ADDR_I2C_EEPROM_CHIP_ADDR=0x57
>  CONFIG_MAC_ADDR_I2C_EEPROM_DATA_ADDR_START=0xFA
> diff --git a/configs/topic_miami_defconfig b/configs/topic_miami_defconfig
> index af5b92cd34..408a5485f3 100644
> --- a/configs/topic_miami_defconfig
> +++ b/configs/topic_miami_defconfig
> @@ -34,9 +34,8 @@ CONFIG_DFU_RAM=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQPL=y
>  CONFIG_DM_GPIO=y
> -CONFIG_SYS_I2C_ZYNQ=y
> -CONFIG_ZYNQ_I2C0=y
> -CONFIG_ZYNQ_I2C1=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_CADENCE=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_ZYNQ=y
>  CONFIG_SPI_FLASH=y

convert this board is fine. Mike: Are you ok with it?

> diff --git a/configs/topic_miamilite_defconfig b/configs/topic_miamilite_defconfig
> index ad7ba04d85..ee5f512513 100644
> --- a/configs/topic_miamilite_defconfig
> +++ b/configs/topic_miamilite_defconfig
> @@ -34,9 +34,8 @@ CONFIG_DFU_RAM=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQPL=y
>  CONFIG_DM_GPIO=y
> -CONFIG_SYS_I2C_ZYNQ=y
> -CONFIG_ZYNQ_I2C0=y
> -CONFIG_ZYNQ_I2C1=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_CADENCE=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_ZYNQ=y
>  CONFIG_SPI_FLASH=y

convert this board is fine.

> diff --git a/configs/topic_miamiplus_defconfig b/configs/topic_miamiplus_defconfig
> index 7455e86622..89512df26d 100644
> --- a/configs/topic_miamiplus_defconfig
> +++ b/configs/topic_miamiplus_defconfig
> @@ -33,9 +33,8 @@ CONFIG_DFU_RAM=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQPL=y
>  CONFIG_DM_GPIO=y
> -CONFIG_SYS_I2C_ZYNQ=y
> -CONFIG_ZYNQ_I2C0=y
> -CONFIG_ZYNQ_I2C1=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_CADENCE=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_ZYNQ=y
>  CONFIG_SPI_FLASH=y

ditto

> diff --git a/configs/zynq_zybo_defconfig b/configs/zynq_zybo_defconfig
> index 03958f399d..236bc4ff70 100644
> --- a/configs/zynq_zybo_defconfig
> +++ b/configs/zynq_zybo_defconfig
> @@ -19,7 +19,6 @@ CONFIG_SPL_OS_BOOT=y
>  CONFIG_SPL_SPI_LOAD=y
>  CONFIG_SYS_PROMPT="Zynq> "
>  CONFIG_CMD_THOR_DOWNLOAD=y
> -CONFIG_CMD_EEPROM=y

regression.

>  CONFIG_CMD_DFU=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_FPGA_LOADBP=y
> @@ -43,9 +42,8 @@ CONFIG_DFU_RAM=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQPL=y
>  CONFIG_DM_GPIO=y
> -CONFIG_SYS_I2C_ZYNQ=y
> -CONFIG_ZYNQ_I2C0=y
> -CONFIG_ZYNQ_I2C1=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_CADENCE=y
>  CONFIG_MAC_ADDR_IN_I2C_EEPROM=y
>  CONFIG_MAC_ADDR_I2C_EEPROM_CHIP_ADDR=0x50
>  CONFIG_MAC_ADDR_I2C_EEPROM_DATA_ADDR_START=0xFA
> diff --git a/include/configs/syzygy_hub.h b/include/configs/syzygy_hub.h
> index 17938398c2..e31b77c0c0 100644
> --- a/include/configs/syzygy_hub.h
> +++ b/include/configs/syzygy_hub.h
> @@ -10,8 +10,6 @@
>  #ifndef __CONFIG_SYZYGY_HUB_H
>  #define __CONFIG_SYZYGY_HUB_H
>  
> -#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
> -
>  #define CONFIG_EXTRA_ENV_SETTINGS       \
>  	"fit_image=fit.itb\0"		\
>  	"bitstream_image=download.bit\0"    \
> diff --git a/include/configs/zynq_zybo.h b/include/configs/zynq_zybo.h
> index c3abf41f76..f3b628cbac 100644
> --- a/include/configs/zynq_zybo.h
> +++ b/include/configs/zynq_zybo.h
> @@ -10,7 +10,6 @@
>  #ifndef __CONFIG_ZYNQ_ZYBO_H
>  #define __CONFIG_ZYNQ_ZYBO_H
>  
> -#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1
>  #define CONFIG_DISPLAY
>  #define CONFIG_I2C_EDID
>  
> 

as above.

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180720/d7e19702/attachment.sig>


More information about the U-Boot mailing list