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

Xiaowei Bao xiaowei.bao at nxp.com
Wed Aug 21 09:46:46 UTC 2019



> -----Original Message-----
> From: Joakim Tjernlund <Joakim.Tjernlund at infinera.com>
> Sent: 2019年8月21日 15:52
> 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 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://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
> work.ozlabs.org%2Fpatch%2F330242%2F&data=02%7C01%7Cxiaowei.b
> ao%40nxp.com%7Cbb03e40adaf14ddabb3308d7260c624a%7C686ea1d3bc2
> b4c6fa92cd99c5c301635%7C0%7C0%7C637019706960729747&sdata=
> LBnGwExukwfx4Txln7gbC797CK0Nuu1Q%2BG8iK4lCR4M%3D&reserved
> =0
> 
> 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.
Thanks a lot, I think I need to do another new patch which reimplement the xfer function,
This is better, because this issue fix should not in DM patch, I will submit another new patch to fix
this issue, but maybe spend some time, because I am not very clear about the FSL ESPI
driver, and the verification will be a problem, because I don't find other SPI device except
SPI flash device in our RDB or QDS board, but I am going to do this.
> 
>  Jocke
> 
> > > Jocke


More information about the U-Boot mailing list