spi: s3c64xx: Enable Word transfer
Subsystems (3)
PATCH v2 1/1 spi: s3c64xx: Enable Word transfer
This patch enables word transfer for s3c64xx spi driver. User can set bits_per_word to 32 before calling spi_setup, which would enable the word transfer mode.
---
Chnages in V2:
- Reduced the call for s3c64xx_spi_config
drivers/spi/spi-s3c64xx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/spi/spi-s3c64xx.c +17 -7
@@ -498,6 +498,17 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, chcfg =readl (regs +S3C64XX_SPI_CH_CFG ); chcfg &= ~S3C64XX_SPI_CH_TXCH_ON ; +if (sdd->cur_bpw ==32 ) { +/* For word transfer we need to swap bytes */ +u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN |S3C64XX_SPI_SWAP_TX_BYTE | +S3C64XX_SPI_SWAP_TX_HALF_WORD | +S3C64XX_SPI_SWAP_RX_EN | +S3C64XX_SPI_SWAP_RX_BYTE | +S3C64XX_SPI_SWAP_RX_HALF_WORD ); +writel (swapcfg, regs +S3C64XX_SPI_SWAP_CFG ); + }else +writel (0 , regs +S3C64XX_SPI_SWAP_CFG ); +if (dma_mode) { chcfg &= ~S3C64XX_SPI_CH_RXCH_ON ; }else {
@@ -905,13 +916,12 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, bpw = xfer->bits_per_word; speed = xfer->speed_hz ? : spi->max_speed_hz; -if (xfer->len % (bpw /8 )) { -dev_err (&spi->dev, -"Xfer length(%u) not a multiple of word size(%u)\n" , - xfer->len, bpw /8 ); - status = -EIO ; - goto out; - } +/* +* Enable byte tranfer if transfer length not a multiple of +* word size +*/ +if (xfer->len % (bpw /8 )) + bpw =8 ;if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) { sdd->cur_bpw = bpw;
Signature · 1 line
1.7.12.4
drivers/spi/spi-s3c64xx.c static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, · line 510
Quoted 10 lines · Rajeshwari S Shinde
drivers/spi/spi-s3c64xx.c +10
-0+if (sdd->cur_bpw ==32 ) { +/* For word transfer we need to swap bytes */ +u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN |S3C64XX_SPI_SWAP_TX_BYTE | +S3C64XX_SPI_SWAP_TX_HALF_WORD | +S3C64XX_SPI_SWAP_RX_EN | +S3C64XX_SPI_SWAP_RX_BYTE | +S3C64XX_SPI_SWAP_RX_HALF_WORD ); +writel (swapcfg, regs +S3C64XX_SPI_SWAP_CFG ); + }else +writel (0 , regs +S3C64XX_SPI_SWAP_CFG );
coding style: braces needed around else as 'if' block has it. I had pointed this out on v1 of this patch too.
[snip]
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_transfer_one_message(struct spi_master *master, · line 920
Quoted 2 lines
drivers/spi/spi-s3c64xx.c +2
-0+/* +* Enable byte tranfer if transfer length not a multiple of
typo: s/tranfer/transfer
Signature · 2 lines
With warm regards, Sachin
Hi Sachin,
Quoted 12 lines · Sachin Kamat
drivers/spi/spi-s3c64xx.c static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, · line 510
Quoted 10 lines · Rajeshwari S Shinde
drivers/spi/spi-s3c64xx.c +10
-0+if (sdd->cur_bpw ==32 ) { +/* For word transfer we need to swap bytes */ +u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN |S3C64XX_SPI_SWAP_TX_BYTE | +S3C64XX_SPI_SWAP_TX_HALF_WORD | +S3C64XX_SPI_SWAP_RX_EN | +S3C64XX_SPI_SWAP_RX_BYTE | +S3C64XX_SPI_SWAP_RX_HALF_WORD ); +writel (swapcfg, regs +S3C64XX_SPI_SWAP_CFG ); + }else +writel (0 , regs +S3C64XX_SPI_SWAP_CFG );
Quoted 2 lines
coding style: braces needed around else as 'if' block has it. I had pointed this out on v1 of this patch too.
Yes my mistake, missed correcting them, will correct in next version.
Quoted 7 lines
[snip]
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_transfer_one_message(struct spi_master *master, · line 920
Quoted 2 lines
drivers/spi/spi-s3c64xx.c +2
-0+/* +* Enable byte tranfer if transfer length not a multiple of typo: s/tranfer/transfer
will correct this.
Signature · 2 lines
Regards, Rajeshwari Shinde
Quoted 8 lines
--
With warm regards,
Sachin
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Rajeshwari,
Quoted 17 lines · Rajeshwari S Shinde
This patch enables word transfer for s3c64xx spi driver. User can set
bits_per_wordto 32 before callingspi_setup, which would enable the word transfer mode.Signed-off-by Rajeshwari S Shinde <[email protected]>---
Chnages in V2:
- Reduced the call fors3c64xx_spi_configdrivers/spi/spi-s3c64xx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)drivers/spi/spi-s3c64xx.c +0
-0@@ -498,6 +498,17 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, chcfg =readl (regs +S3C64XX_SPI_CH_CFG );
drivers/spi/spi-s3c64xx.c static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, · line 508
Quoted 10 lines
drivers/spi/spi-s3c64xx.c +8
-0chcfg &= ~S3C64XX_SPI_CH_TXCH_ON ; +if (sdd->cur_bpw ==32 ) { +/* For word transfer we need to swap bytes */ +u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN |S3C64XX_SPI_SWAP_TX_BYTE | +S3C64XX_SPI_SWAP_TX_HALF_WORD | +S3C64XX_SPI_SWAP_RX_EN | +S3C64XX_SPI_SWAP_RX_BYTE | +S3C64XX_SPI_SWAP_RX_HALF_WORD ); +writel (swapcfg, regs +S3C64XX_SPI_SWAP_CFG );
In s3c64xx_spi_probe() functionsdd->cur_bpw is hard coded to 8
is there any provision somehow to configure cur_bpw to 32 ?
wouldn't 16 bits per word transfers also need swapping?
Best Wishes,
Leela Krishna.
Quoted 33 lines
drivers/spi/spi-s3c64xx.c +9
-8+ }else +writel (0 , regs +S3C64XX_SPI_SWAP_CFG ); +if (dma_mode) { chcfg &= ~S3C64XX_SPI_CH_RXCH_ON ; }else {@@ -905,13 +916,12 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, bpw = xfer->bits_per_word; speed = xfer->speed_hz ? : spi->max_speed_hz; -if (xfer->len % (bpw /8 )) { -dev_err (&spi->dev, -"Xfer length(%u) not a multiple of word size(%u)\n" , - xfer->len, bpw /8 ); - status = -EIO ; - goto out; - } +/* +* Enable byte tranfer if transfer length not a multiple of +* word size +*/ +if (xfer->len % (bpw /8 )) + bpw =8 ;if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) { sdd->cur_bpw = bpw; --1.7.12.4
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Leela,
Quoted 23 lines · Leela Krishna Amudala
Hi Rajeshwari,
Quoted 19 lines · Rajeshwari S Shinde
This patch enables word transfer for s3c64xx spi driver. User can set
bits_per_wordto 32 before callingspi_setup, which would enable the word transfer mode.Signed-off-by Rajeshwari S Shinde <[email protected]>---
Chnages in V2:
- Reduced the call fors3c64xx_spi_configdrivers/spi/spi-s3c64xx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)drivers/spi/spi-s3c64xx.c +0
-0@@ -498,6 +498,17 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, chcfg =readl (regs +S3C64XX_SPI_CH_CFG ); chcfg &= ~S3C64XX_SPI_CH_TXCH_ON ;
Quoted 11 lines
drivers/spi/spi-s3c64xx.c static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, · line 508
Quoted 8 lines
drivers/spi/spi-s3c64xx.c +8
-0+if (sdd->cur_bpw ==32 ) { +/* For word transfer we need to swap bytes */ +u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN |S3C64XX_SPI_SWAP_TX_BYTE | +S3C64XX_SPI_SWAP_TX_HALF_WORD | +S3C64XX_SPI_SWAP_RX_EN | +S3C64XX_SPI_SWAP_RX_BYTE | +S3C64XX_SPI_SWAP_RX_HALF_WORD ); +writel (swapcfg, regs +S3C64XX_SPI_SWAP_CFG );In
s3c64xx_spi_probe()functionsdd->cur_bpwis hard coded to 8
By default sdd->cur_bpw is set to 8 bits transfer.
Quoted 2 lines
is there any provision somehow to configure
cur_bpwto 32 ?
The user can set bits_per_word to 32 later as per his requirement.
Quoted 2 lines
wouldn't 16 bits per word transfers also need swapping?
This patch is tested for Word transfer.
Quoted 41 lines
Best Wishes,
Leela Krishna.Quoted 29 lines
drivers/spi/spi-s3c64xx.c +9
-8+ }else +writel (0 , regs +S3C64XX_SPI_SWAP_CFG ); +if (dma_mode) { chcfg &= ~S3C64XX_SPI_CH_RXCH_ON ; }else {@@ -905,13 +916,12 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, bpw = xfer->bits_per_word; speed = xfer->speed_hz ? : spi->max_speed_hz; -if (xfer->len % (bpw /8 )) { -dev_err (&spi->dev, -"Xfer length(%u) not a multiple of word size(%u)\n" , - xfer->len, bpw /8 ); - status = -EIO ; - goto out; - } +/* +* Enable byte tranfer if transfer length not a multiple of +* word size +*/ +if (xfer->len % (bpw /8 )) + bpw =8 ;if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) { sdd->cur_bpw = bpw; --1.7.12.4
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Regards, Rajeshwari Shinde