Message ID | 20190202040653.1217-9-tudor.ambarus@microchip.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | spi: atmel-quadspi: introduce sam9x60 qspi controller | expand |
On Sat, 2 Feb 2019 04:07:33 +0000 <Tudor.Ambarus@microchip.com> wrote: > From: Tudor Ambarus <tudor.ambarus@microchip.com> > > Remove NOP when setting read transfer type. Remove useless > setting of write transfer type when > op->data.dir == SPI_MEM_DATA_IN && !op->data.nbytes. > > QSPI_IFR_TFRTYP_TRSFR_WRITE is specific just to sama5d2 qspi, > rename it to QSPI_IFR_SAMA5D2_WRITE_TRSFR. > > Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> > --- > v3: new patch > > drivers/spi/atmel-quadspi.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c > index d26d4cd0e36b..bfa5f5e92d96 100644 > --- a/drivers/spi/atmel-quadspi.c > +++ b/drivers/spi/atmel-quadspi.c > @@ -113,11 +113,7 @@ > #define QSPI_IFR_OPTL_4BIT (2 << 8) > #define QSPI_IFR_OPTL_8BIT (3 << 8) > #define QSPI_IFR_ADDRL BIT(10) > -#define QSPI_IFR_TFRTYP_MASK GENMASK(13, 12) > -#define QSPI_IFR_TFRTYP_TRSFR_READ (0 << 12) > -#define QSPI_IFR_TFRTYP_TRSFR_READ_MEM (1 << 12) > -#define QSPI_IFR_TFRTYP_TRSFR_WRITE (2 << 12) > -#define QSPI_IFR_TFRTYP_TRSFR_WRITE_MEM (3 << 13) > +#define QSPI_IFR_SAMA5D2_WRITE_TRSFR BIT(13) Can you define QSPI_IFR_TFRTYP_MEM (bit 12) even if it's not used yet? > #define QSPI_IFR_CRM BIT(14) > #define QSPI_IFR_NBDUM_MASK GENMASK(20, 16) > #define QSPI_IFR_NBDUM(n) (((n) << 16) & QSPI_IFR_NBDUM_MASK) > @@ -273,10 +269,8 @@ static int atmel_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) > if (op->data.nbytes) > ifr |= QSPI_IFR_DATAEN; > > - if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes) > - ifr |= QSPI_IFR_TFRTYP_TRSFR_READ; > - else > - ifr |= QSPI_IFR_TFRTYP_TRSFR_WRITE; > + if (op->data.dir == SPI_MEM_DATA_OUT) > + ifr |= QSPI_IFR_SAMA5D2_WRITE_TRSFR; > > /* Clear pending interrupts */ > (void)readl_relaxed(base + QSPI_SR);
On 02/02/2019 09:13 AM, Boris Brezillon wrote: > On Sat, 2 Feb 2019 04:07:33 +0000 > <Tudor.Ambarus@microchip.com> wrote: > >> From: Tudor Ambarus <tudor.ambarus@microchip.com> >> >> Remove NOP when setting read transfer type. Remove useless >> setting of write transfer type when >> op->data.dir == SPI_MEM_DATA_IN && !op->data.nbytes. >> >> QSPI_IFR_TFRTYP_TRSFR_WRITE is specific just to sama5d2 qspi, >> rename it to QSPI_IFR_SAMA5D2_WRITE_TRSFR. >> >> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> >> --- >> v3: new patch >> >> drivers/spi/atmel-quadspi.c | 12 +++--------- >> 1 file changed, 3 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c >> index d26d4cd0e36b..bfa5f5e92d96 100644 >> --- a/drivers/spi/atmel-quadspi.c >> +++ b/drivers/spi/atmel-quadspi.c >> @@ -113,11 +113,7 @@ >> #define QSPI_IFR_OPTL_4BIT (2 << 8) >> #define QSPI_IFR_OPTL_8BIT (3 << 8) >> #define QSPI_IFR_ADDRL BIT(10) >> -#define QSPI_IFR_TFRTYP_MASK GENMASK(13, 12) >> -#define QSPI_IFR_TFRTYP_TRSFR_READ (0 << 12) >> -#define QSPI_IFR_TFRTYP_TRSFR_READ_MEM (1 << 12) >> -#define QSPI_IFR_TFRTYP_TRSFR_WRITE (2 << 12) >> -#define QSPI_IFR_TFRTYP_TRSFR_WRITE_MEM (3 << 13) >> +#define QSPI_IFR_SAMA5D2_WRITE_TRSFR BIT(13) > > Can you define QSPI_IFR_TFRTYP_MEM (bit 12) even if it's not used yet? Shouldn't be introduced with the dir map support?
On Sat, 2 Feb 2019 08:46:38 +0000 <Tudor.Ambarus@microchip.com> wrote: > On 02/02/2019 09:13 AM, Boris Brezillon wrote: > > On Sat, 2 Feb 2019 04:07:33 +0000 > > <Tudor.Ambarus@microchip.com> wrote: > > > >> From: Tudor Ambarus <tudor.ambarus@microchip.com> > >> > >> Remove NOP when setting read transfer type. Remove useless > >> setting of write transfer type when > >> op->data.dir == SPI_MEM_DATA_IN && !op->data.nbytes. > >> > >> QSPI_IFR_TFRTYP_TRSFR_WRITE is specific just to sama5d2 qspi, > >> rename it to QSPI_IFR_SAMA5D2_WRITE_TRSFR. > >> > >> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> > >> --- > >> v3: new patch > >> > >> drivers/spi/atmel-quadspi.c | 12 +++--------- > >> 1 file changed, 3 insertions(+), 9 deletions(-) > >> > >> diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c > >> index d26d4cd0e36b..bfa5f5e92d96 100644 > >> --- a/drivers/spi/atmel-quadspi.c > >> +++ b/drivers/spi/atmel-quadspi.c > >> @@ -113,11 +113,7 @@ > >> #define QSPI_IFR_OPTL_4BIT (2 << 8) > >> #define QSPI_IFR_OPTL_8BIT (3 << 8) > >> #define QSPI_IFR_ADDRL BIT(10) > >> -#define QSPI_IFR_TFRTYP_MASK GENMASK(13, 12) > >> -#define QSPI_IFR_TFRTYP_TRSFR_READ (0 << 12) > >> -#define QSPI_IFR_TFRTYP_TRSFR_READ_MEM (1 << 12) > >> -#define QSPI_IFR_TFRTYP_TRSFR_WRITE (2 << 12) > >> -#define QSPI_IFR_TFRTYP_TRSFR_WRITE_MEM (3 << 13) > >> +#define QSPI_IFR_SAMA5D2_WRITE_TRSFR BIT(13) > > > > Can you define QSPI_IFR_TFRTYP_MEM (bit 12) even if it's not used yet? > > Shouldn't be introduced with the dir map support? I like when all regs/reg-fields are defined, even if they're not used. In this case, you're cleary splitting the TFRTYP_TRSFR_ bitfields in 2: one bit encoding the mem/reg transfer type and one bit encoding the direction of the transfer (read/write). Just think it's better to add bit 12 definition now.
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index d26d4cd0e36b..bfa5f5e92d96 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -113,11 +113,7 @@ #define QSPI_IFR_OPTL_4BIT (2 << 8) #define QSPI_IFR_OPTL_8BIT (3 << 8) #define QSPI_IFR_ADDRL BIT(10) -#define QSPI_IFR_TFRTYP_MASK GENMASK(13, 12) -#define QSPI_IFR_TFRTYP_TRSFR_READ (0 << 12) -#define QSPI_IFR_TFRTYP_TRSFR_READ_MEM (1 << 12) -#define QSPI_IFR_TFRTYP_TRSFR_WRITE (2 << 12) -#define QSPI_IFR_TFRTYP_TRSFR_WRITE_MEM (3 << 13) +#define QSPI_IFR_SAMA5D2_WRITE_TRSFR BIT(13) #define QSPI_IFR_CRM BIT(14) #define QSPI_IFR_NBDUM_MASK GENMASK(20, 16) #define QSPI_IFR_NBDUM(n) (((n) << 16) & QSPI_IFR_NBDUM_MASK) @@ -273,10 +269,8 @@ static int atmel_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) if (op->data.nbytes) ifr |= QSPI_IFR_DATAEN; - if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes) - ifr |= QSPI_IFR_TFRTYP_TRSFR_READ; - else - ifr |= QSPI_IFR_TFRTYP_TRSFR_WRITE; + if (op->data.dir == SPI_MEM_DATA_OUT) + ifr |= QSPI_IFR_SAMA5D2_WRITE_TRSFR; /* Clear pending interrupts */ (void)readl_relaxed(base + QSPI_SR);