Dear Joakim, Thanks for raising a concern.
It's not fair to blame the last person who submitted a patch. We are all working to make it better as an opensource comminuty. You have done a good job to hack it to work. Would it be nicer if you can submit this or improved patch to u-boot community for further review and testing, after putting informing commit message? The mailing list address is CC'ed. York On 10/09/2014 09:14 AM, Joakim Tjernlund wrote: > Guys, I noticed you have added to the fsl eSPI driver and you work for > Freescale. > This driver is broken beyond words, just look what I had to hack to load a > FPGA over SPI(below). > I hope you can take the time to fix the driver. > > From e73b8bd36b42e39ee9e22b48deca3a54fbffe4ac Mon Sep 17 00:00:00 2001 > From: Joakim Tjernlund <joakim.tjernl...@transmode.se> > Date: Mon, 3 Mar 2014 16:30:35 +0100 > Subject: [PATCH] Fast fixes to make eSPI driver work. > > The whole driver stinks, needs to be rewritten. > --- > drivers/spi/fsl_espi.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c > index ae0fe58..f5a8fcc 100644 > --- a/drivers/spi/fsl_espi.c > +++ b/drivers/spi/fsl_espi.c > @@ -45,6 +45,8 @@ struct fsl_spi_slave { > > #define ESPI_COM_CS(x) ((x) << 30) > #define ESPI_COM_TRANLEN(x) ((x) << 0) > +#define ESPI_COM_TO (1 << (31 - 4)) > + > > #define ESPI_CSMODE_CI_INACTIVEHIGH (1 << 31) > #define ESPI_CSMODE_CP_BEGIN_EDGCLK (1 << 30) > @@ -165,8 +167,9 @@ int spi_claim_bus(struct spi_slave *slave) > | ESPI_CSMODE_CI_INACTIVEHIGH); > /* Character bit order: msb first */ > - out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs]) > - | ESPI_CSMODE_REV_MSB_FIRST); > + if (!(mode & SPI_LSB_FIRST)) > + out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs]) > + | ESPI_CSMODE_REV_MSB_FIRST); > > /* Character length in bits, between 0x3~0xf, i.e. 4bits~16bits */ > out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs]) > @@ -302,14 +305,15 @@ int spi_xfer(struct spi_slave *slave, unsigned int > bitlen, const void *data_out, > *(uint *)data_out, data_out, *(uint *)data_in, data_in, > len); > > num_chunks = DIV_ROUND_UP(data_len, max_tran_len); > + dout = buffer; > while (num_chunks--) { > if (data_in) > din = buffer + rx_offset; > - dout = buffer; > tran_len = min(data_len , max_tran_len); > num_blks = DIV_ROUND_UP(tran_len + cmd_len, 4); > num_bytes = (tran_len + cmd_len) % 4; > fsl->data_len = tran_len + cmd_len; > + data_len -= tran_len; > spi_cs_activate(slave); > > /* Clear all eSPI events */ > @@ -320,12 +324,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int > bitlen, const void *data_out, > if (event & ESPI_EV_TNF) { > fsl_espi_tx(fsl, dout); > /* Set up the next iteration */ > - if (len > 4) { > - len -= 4; > - dout += 4; > - } > + len -= 4; > + dout += 4; > } > > + num_blks--; > event = in_be32(&espi->event); > if (event & ESPI_EV_RNE) { > rf_cnt = ((event & ESPI_EV_RFCNT_MASK) > @@ -338,7 +341,6 @@ int spi_xfer(struct spi_slave *slave, unsigned int > bitlen, const void *data_out, > continue; > if (fsl_espi_rx(fsl, din, rx_bytes) > == rx_bytes) { > - num_blks--; > if (din) > din = (unsigned char *)din > + rx_bytes; > @@ -374,6 +376,7 @@ void spi_cs_activate(struct spi_slave *slave) > > com &= ~(ESPI_COM_CS(0x3) | ESPI_COM_TRANLEN(0xFFFF)); > com |= ESPI_COM_CS(slave->cs); > + com |= ESPI_COM_TO; > com |= ESPI_COM_TRANLEN(data_len - 1); > out_be32(&espi->com, com); > } > _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot