Skip to contentSkip to conversation

spi: sirf: fix word width configuration

PATCH Applied Barry Song 2 participants 4 messages Nov 17, 2014 – Nov 18, 2014 2 messages not in the archive SPI

lore
Share & tools
lore

Barry Song

author
#0 lore raw

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
index 39e2c0a..f63de78 100644
@@ -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
author
#2 lore raw

PATCH 2/2 spi: sirf: assign spi_master's max_speed_hz member

In reply to a message not in the archive

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
index f63de78..90dc05b 100644
@@ -134,6 +134,7 @@
 	ALIGNED(x->len) && (x->len < 2 * PAGE_SIZE))
 
 #define SIRFSOC_MAX_CMD_BYTES	4
+#define SIRFSOC_SPI_DEFAULT_FRQ 1000000
 
 struct 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
Applied
#5 lore raw
In reply to a message not in the archive
Quoted 7 lines · Barry Song

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:

Applied, thanks.

Applied
#4 lore raw

Re: [PATCH 2/2] spi: sirf: assign spi_master's max_speed_hz member

In reply to a message not in the archive
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_hz of spi_master according to
int spi_setup(struct spi_device *spi)

Applied, thanks.