
On Wed, 2019-08-21 at 09:46 +0000, Xiaowei Bao wrote:
-----Original Message----- From: Joakim Tjernlund Joakim.Tjernlund@infinera.com Sent: 2019年8月21日 15:52 To: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Ruchika Gupta ruchika.gupta@nxp.com; Xiaowei Bao xiaowei.bao@nxp.com; Shengzhou Liu shengzhou.liu@nxp.com; wd@denx.de; jagan@amarulasolutions.com Cc: u-boot@lists.denx.de; Jiafei Pan jiafei.pan@nxp.com; Chuanhua Han chuanhua.han@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@infinera.com Sent: 2019年8月20日 19:04 To: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Ruchika
Gupta
ruchika.gupta@nxp.com; Xiaowei Bao xiaowei.bao@nxp.com; Shengzhou Liu shengzhou.liu@nxp.com; wd@denx.de; jagan@amarulasolutions.com Cc: u-boot@lists.denx.de; Jiafei Pan jiafei.pan@nxp.com; Chuanhua Han chuanhua.han@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@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://patch 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.
Thanks, I think random access(read/write) to SPI NOR flash will be enough for testing. It won't be any worse than today as it is broken already.
Jocke
Jocke
Jocke