spi: sirf: fix word width configuration
PATCH 1/2 spi: sirf: fix word width configuration
From: Qipan Li <[email protected]>
commit 8c328a262f ("spi: sirf: Avoid duplicate code in various bits_per_word cases") is wrong in setting data width register of fifo is not right, it should use sspi->word_width >> 1 to set related bits. According to hardware spec, the mapping between register value and data width:
0 - byte
1 - WORD
2 - DWORD
--- drivers/spi/spi-sirf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-sirf.c +2 -2
@@ -562,9 +562,9 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) sspi->word_width =DIV_ROUND_UP (bits_per_word,8 ); txfifo_ctrl =SIRFSOC_SPI_FIFO_THD (SIRFSOC_SPI_FIFO_SIZE /2 ) | - sspi->word_width; + (sspi->word_width >>1 ); rxfifo_ctrl =SIRFSOC_SPI_FIFO_THD (SIRFSOC_SPI_FIFO_SIZE /2 ) | - sspi->word_width; + (sspi->word_width >>1 );if (!(spi->mode &SPI_CS_HIGH )) regval |=SIRFSOC_SPI_CS_IDLE_STAT ;
Signature · 6 lines
2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1416237423-3606-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/2 spi: sirf: assign spi_master's max_speed_hz member
From: Qipan Li <[email protected]>
if spi device has no frequency, spi core will setup the default frequency to max_speed_hz of spi_master according to
int spi_setup(struct spi_device *spi)
{
...
if (!spi->max_speed_hz)
spi->max_speed_hz = spi->master->max_speed_hz;
...
}this patch moves CSR SiRFSoC SPI frequency set to follow SPI core behaviour.
--- drivers/spi/spi-sirf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/spi/spi-sirf.c +2 -3
@@ -134,6 +134,7 @@ ALIGNED(x->len) && (x->len < 2 * PAGE_SIZE))#define SIRFSOC_MAX_CMD_BYTES 4 +#define SIRFSOC_SPI_DEFAULT_FRQ 1000000struct sirfsoc_spi {struct spi_bitbang bitbang;
@@ -629,9 +630,6 @@ static int spi_sirfsoc_setup(struct spi_device *spi) {struct sirfsoc_spi *sspi; -if (!spi->max_speed_hz) -return -EINVAL ; - sspi =spi_master_get_devdata (spi->master);if (spi->cs_gpio == -ENOENT )
@@ -683,6 +681,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) master->mode_bits =SPI_CPOL |SPI_CPHA |SPI_LSB_FIRST |SPI_CS_HIGH ; master->bits_per_word_mask =SPI_BPW_MASK (8 ) |SPI_BPW_MASK (12 ) |SPI_BPW_MASK (16 ) |SPI_BPW_MASK (32 ); + master->max_speed_hz =SIRFSOC_SPI_DEFAULT_FRQ ; sspi->bitbang.master->dev.of_node = pdev->dev.of_node;/* request DMA channels */
Signature · 6 lines
2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1416237423-3606-2-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Mark Brown
AppliedRe: [PATCH 2/2] spi: sirf: assign spi_master's max_speed_hz member
Quoted 5 lines · Barry Song
From: Qipan Li <[email protected]>
if spi device has no frequency, spi core will setup the default frequency to
max_speed_hzofspi_masteraccording to
intspi_setup(struct spi_device *spi)
Applied, thanks.
Mark Brown
AppliedQuoted 7 lines · Barry Song
From: Qipan Li <[email protected]>
commit
8c328a262f("spi: sirf: Avoid duplicate code in variousbits_per_wordcases") is wrong in setting data width register of fifo is not right, it should usesspi->word_width>> 1 to set related bits. According to hardware spec, the mapping between register value and data width:
Applied, thanks.