[U-Boot] [RFC PATCH] arm: zynq: read mac address from SPI flash memory

Luis Araneda luaraneda at gmail.com
Thu Aug 16 06:04:25 UTC 2018


Hi,

On Tue, Aug 14, 2018 at 11:07 AM Michal Simek <michal.simek at xilinx.com> wrote:
> On 14.8.2018 06:55, Luis Araneda wrote:
> > Implement a method for reading the MAC address from an
> > SPI flash memory.
> > In particular, this method is used by the Zybo Z7 board
> > to read the MAC address from the OTP region in the SPI NOR
> > memory
> > [...]
> > +#if defined(CONFIG_MAC_ADDR_IN_SPI_FLASH)
> > +     struct spi_flash *flash;
> > +     struct udevice *dev;
> > +     int ret;
> > +
> > +     ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS,
> > +                                  CONFIG_SF_DEFAULT_CS,
> > +                                  0, 0, &dev);
> > +     if (ret) {
> > +             printf("SPI(bus:%u cs:%u) probe failed\n",
> > +                    CONFIG_SF_DEFAULT_BUS,
> > +                    CONFIG_SF_DEFAULT_CS);
> > +             return 0;
> > +     }
> > +
> > +     flash = dev_get_uclass_priv(dev);
> > +     flash->read_cmd = CONFIG_MAC_ADDR_SPI_FLASH_READ_CMD;
> > +
> > +     if (spi_flash_read_dm(dev,
> > +                           CONFIG_MAC_ADDR_SPI_FLASH_DATA_OFFSET,
> > +                           6, ethaddr))
> > +             printf("SPI MAC address read failed\n");
> > +
> > +     device_remove(dev, DM_REMOVE_NORMAL);
> > +#endif
> >       return 0;
> >  }
> >
> > diff --git a/configs/zynq_zybo_z7_defconfig b/configs/zynq_zybo_z7_defconfig
> > index ad44e772aa..ca402e3231 100644
> > --- a/configs/zynq_zybo_z7_defconfig
> > +++ b/configs/zynq_zybo_z7_defconfig
> > @@ -44,6 +44,9 @@ CONFIG_DM_GPIO=y
> >  CONFIG_SYS_I2C_ZYNQ=y
> >  CONFIG_ZYNQ_I2C0=y
> >  CONFIG_ZYNQ_I2C1=y
> > +CONFIG_MAC_ADDR_IN_SPI_FLASH=y
> > +CONFIG_MAC_ADDR_SPI_FLASH_READ_CMD=0x4b
>
> I am doing spi but isn't this any standard OTP read command which should
> put to spi framework.

I'm not sure if there is an standard OTP read command, they might be
vendor/model specific.
Jagan, is this possible currently, or might it be covered by the new
SPI-mem/SPI-NAND code?

In order to keep this moving, I would like to get some specific
question answered:
1: Should the final code be in the "zynq_board_read_rom_ethaddr"
function like it is now?
2: On an ideal solution, should I remove the probing and read_cmd, and
call a function to read from OTP at a certain offset? In that case the
CONFIG_MAC_ADDR_SPI_FLASH_READ_CMD would't be necessary.
3: Is the CONFIG_MAC_ADDR_IN_SPI_FLASH an acceptable solution to
enable the feature?

Thanks,

Luis Araneda.


More information about the U-Boot mailing list