On Wed, 2019-08-21 at 01:19 +0000, Xiaowei Bao wrote:
> 
> > -----Original Message-----
> > From: Joakim Tjernlund <joakim.tjernl...@infinera.com>
> > Sent: 2019年8月20日 19:04
> > To: Prabhakar Kushwaha <prabhakar.kushw...@nxp.com>; Ruchika Gupta
> > <ruchika.gu...@nxp.com>; Xiaowei Bao <xiaowei....@nxp.com>;
> > Shengzhou Liu <shengzhou....@nxp.com>; w...@denx.de;
> > ja...@amarulasolutions.com
> > Cc: u-boot@lists.denx.de; Jiafei Pan <jiafei....@nxp.com>; Chuanhua Han
> > <chuanhua....@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....@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
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to