summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-armada-3700.c
AgeCommit message (Collapse)AuthorFilesLines
2017-10-10spi: a3700: Change SPI mode before asserting chip-selectMaxime Chevallier1-13/+4
The spi device mode should be configured in the controller before the chip-select is asserted, so that a clock polarity configuration change is not interpreted as a clock tick by the device. This patch moves the mode setting to the 'prepare_message' function instead of the 'transfer_one' function. By doing so, this patch also removes redundant code in a3700_spi_clock_set. This was tested on EspressoBin board, with spidev. Signed-off-by: Maxime Chevallier <maxime.chevallier@smile.fr> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-10spi: a3700: Return correct value on timeout detectionMaxime Chevallier1-1/+2
When waiting for transfer completion, a3700_spi_wait_completion returns a boolean indicating if a timeout occurred. The function was returning 'true' everytime, failing to detect any timeout. This patch makes it return 'false' when a timeout is reached. Signed-off-by: Maxime Chevallier <maxime.chevallier@smile.fr> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2017-09-13spi: armada-3700: Fix padding when sending not 4-byte aligned dataZachary Zhang1-94/+41
In 4-byte transfer mode, extra padding/dummy bytes '0xff' would be sent in write operation if TX data is not 4-byte aligned since the SPI data register is always shifted out as whole 4 bytes. Fix this by using the header count feature that allows to transfer 0 to 4 bytes. Use it to actually send the first 1 to 3 bytes of data before the rest of the buffer that will hence be 4-byte aligned. Signed-off-by: Zachary Zhang <zhangzg@marvell.com> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-13spi: armada-3700: Fix failing commands with quad-SPIMiquel Raynal1-2/+5
A3700 SPI controller datasheet states that only the first line (IO0) is used to receive and send instructions, addresses and dummy bytes, unless for addresses during an RX operation in a quad SPI configuration (see p.821 of the Armada-3720-DB datasheet). Otherwise, some commands such as SPI NOR commands like READ_FROM_CACHE_DUAL_IO(0xeb) and READ_FROM_CACHE_DUAL_IO(0xbb) will fail because these commands must send address bytes through the four pins. Data transfer always use the four bytes with this setup. Thus, in quad SPI configuration, the A3700_SPI_ADDR_PIN bit must be set only in this case to inform the controller that it must use the number of pins indicated in the {A3700_SPI_DATA_PIN1,A3700_SPI_DATA_PIN0} field during the address cycles of an RX operation. Suggested-by: Ken Ma <make@marvell.com> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2017-02-19Merge remote-tracking branches 'spi/topic/armada', 'spi/topic/ath79', ↵Mark Brown1-8/+6
'spi/topic/bcm-qspi' and 'spi/topic/bcm53xx' into spi-next
2017-02-19spi: armada-3700: Remove spi_master_put in a3700_spi_remove()Wei Yongjun1-1/+0
The call to spi_master_put() in a3700_spi_remove() is redundant since the master is registered using devm_spi_register_master() and no reference hold by using spi_master_get() in a3700_spi_remove(). This is detected by Coccinelle semantic patch. Fixes: 5762ab71eb24 ("spi: Add support for Armada 3700 SPI Controller") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-09spi: armada-3700: Remove .owner field for driverWei Yongjun1-1/+0
Remove .owner field if calls are used which set it automatically. Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-31spi: armada-3700: Coding style fixesRomain Perier1-1/+2
The following warning are reported by checkpatch.pl: CHECK: Alignment should match open parenthesis +static void a3700_spi_transfer_setup(struct spi_device *spi, + struct spi_transfer *xfer) WARNING: Missing a blank line after declarations + u32 data = le32_to_cpu(val); + memcpy(a3700_spi->rx_buf, &data, 4); total: 0 errors, 1 warnings, 1 checks, 923 lines checked Signed-off-by: Romain Perier <romain.perier@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-31spi: armada-3700: Replaced raw values for nbits by the SPI macrosRomain Perier1-3/+3
Currently, function a3700_spi_pin_mode_set() configures the SPI transfer mode according to the value passed as second argument. This value is detected using the raw values from a switch case. This commit replaces these raw values by the corresponding macro constants in linux/spi/spi.h Signed-off-by: Romain Perier <romain.perier@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-16spi: armada-3700: Set mode bits correctlyDan Carpenter1-1/+1
We set SPI_RX_DUAL twice instead of setting SPI_TX_DUAL. Fixes: 5762ab71eb24 ("spi: Add support for Armada 3700 SPI Controller") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Romain Perier <romain.perier@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-16spi: armada-3700: Remove unnecessary conditionDan Carpenter1-2/+1
We checked that "a3700_spi->wait_mask & cause" was set at the beginning of the function so we don't need to check again here. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Romain Perier <romain.perier@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-14spi: armada-3700: fix unsigned compare than zero on irqColin Ian King1-4/+5
spi->irq is an unsigned integer hence the check if status is less than zero has no effect. Fix this by replacing spi->irq with an int irq so the less than zero compare will correctly detect errors. Issue found with static analysis with CoverityScan, CID1388567 Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Romain Perier <romain.perier@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-08spi: Add support for Armada 3700 SPI ControllerRomain Perier1-0/+923
Marvell Armada 3700 SoC comprises an SPI Controller. This Controller supports up to 4 SPI slave devices, with dedicated chip selects,supports SPI mode 0/1/2 and 3, CPIO or Fifo mode with DMA transfers and different SPI transfer mode (Single, Dual or Quad). This commit adds basic driver support for FIFO mode. In this mode, dedicated registers are used to store the instruction, the address, the read mode and the data. Write and Read FIFO are used to store the outcoming or incoming data. The data FIFOs are accessible via DMA or by the CPU. Only the CPU is supported for now. Signed-off-by: Romain Perier <romain.perier@free-electrons.com> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>