[U-Boot] [PATCH v5 2/5] dm: spi: Convert Freescale ESPI driver to driver model

Joakim Tjernlund Joakim.Tjernlund at infinera.com
Wed Aug 21 07:51:30 UTC 2019


On Wed, 2019-08-21 at 01:19 +0000, Xiaowei Bao wrote:
> 
> > -----Original Message-----
> > From: Joakim Tjernlund <Joakim.Tjernlund at infinera.com>
> > Sent: 2019年8月20日 19:04
> > To: Prabhakar Kushwaha <prabhakar.kushwaha at nxp.com>; Ruchika Gupta
> > <ruchika.gupta at nxp.com>; Xiaowei Bao <xiaowei.bao at nxp.com>;
> > Shengzhou Liu <shengzhou.liu at nxp.com>; wd at denx.de;
> > jagan at amarulasolutions.com
> > Cc: u-boot at lists.denx.de; Jiafei Pan <jiafei.pan at nxp.com>; Chuanhua Han
> > <chuanhua.han at nxp.com>
> > Subject: Re: [U-Boot] [PATCH v5 2/5] dm: spi: Convert Freescale ESPI driver to
> > driver model
> > 
> > On Tue, 2019-08-20 at 06:59 +0000, Xiaowei Bao wrote:
> > > From: Chuanhua Han <chuanhua.han at nxp.com>
> > > 
> > > Modify the Freescale ESPI driver to support the driver model.
> > > Also resolved the following problems:
> > > 
> > > ===================== WARNING ====================== This
> > board does
> > > not use CONFIG_DM_SPI. Please update the board before v2019.04 for no
> > > dm conversion and v2019.07 for partially dm converted drivers.
> > > Failure to update can lead to driver/board removal See
> > > doc/driver-model/MIGRATION.txt for more info.
> > > ====================================================
> > > ===================== WARNING ====================== This
> > board does
> > > not use CONFIG_DM_SPI_FLASH. Please update the board to use
> > > CONFIG_SPI_FLASH before the v2019.07 release.
> > > Failure to update by the deadline may result in board removal.
> > > See doc/driver-model/MIGRATION.txt for more info.
> > > ====================================================
> > 
> > These are not the only problems with this driver it is borken for anything but
> > loading small amount of data from SPI NOR flash.
> > Look at spi_xfer:
> >   overuse of malloc/memcpy
> >   misuse of word size(always 32 bits) making proper of
> > ESPI_EV_RNE/ESPI_EV_TNF impossible.
> >   random test of 0x0b:
> >               memcpy(data_in, buffer + 2 * cmd_len, tran_len);
> >               if (*buffer == 0x0b) {
> >                       data_in += tran_len;
> >                       data_len -= tran_len;
> >                       *(int *)buffer += tran_len;
> >               }
> > 
> > I think fixing the driver to work properly first is preferable to DM conversion.
> Thanks a lot for your comments, in fact, these code exist all the time, I never modify
> this part code, and I have verified the SPI flash use 4K data, the test result is ok,
> I will check and analyze this part code, and give the reply later, thanks.

Yes, this code has been borken for years and like I said, it only works for SPI NOR flash which is what you tested.
Try a simple SPI device, reading and writing registers.

Here is an old hack for loading FPGAs using ESPI_COM_TO, hopefully this can be of some use:
https://patchwork.ozlabs.org/patch/330242/

In short, the inner working of spi_xfer() needs a full rewrite, using the proper SPI word size, you have no chance
of supporting SPI_LSB_FIRST without correct word size.

 Jocke

> > Jocke


More information about the U-Boot mailing list