summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-rspi.c
Commit message (Collapse)AuthorAgeFilesLines
...
* spi: rspi: Fix loopback mode for Dual/Quad SPI TransfersGeert Uytterhoeven2014-02-231-1/+3
| | | | | | | | | | | | While normal Dual and Quad SPI Transfers are unidirectional, we must do a bidirectional transfer if loopback mode is enabled, else rx_buf is not filled. With spidev it seemed to work, as spidev uses the same buffer for tranmission and reception. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Remove empty rspi_cleanup()Geert Uytterhoeven2014-02-231-5/+0Star
| | | | | | | If spi_master.cleanup() is not needed, it can be left unimplemented. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Only enable interrupts when there's a need to waitGeert Uytterhoeven2014-02-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rspi_wait_for_interrupt() unconditionally enables interrupts, even when the wait condition is already satisfied. This causes a high interrupt load (2 interrupts/byte for full-duplex Single SPI transfers, 1 interrupt/byte for RSPI with TX Only mode, or QSPI in unidirectional Dual or Quad Transfer mode). Change this to return immediately when the wait condition is satisfied. This dramatically reduces the interrupt load, especially in high-speed Quad Transfer mode, and increases transfer speed, as no interrupts need to be handled when there's space available in the output FIFO, or data available in the input FIFO. Benchmark results for QSPI on r8a7791 while reading 1 MiB from 30 MHz SPI FLASH on the Koelsch development board: Before: Single SPI Dual SPI Quad SPI Interrupts: 2096856 1048592 1048594 Mbps: 0.9 1.6 1.6 After: Single SPI Dual SPI Quad SPI Interrupts: 1048569 21295 8 Mbps: 0.7 10.8 12.9 I don't know why Single SPI slowed down a bit. I've also verified functionality for RSPI-RZ on r7s72100, but don't have benchmark results as there's no SPI FLASH connected to RSPI on the Genmai development board. Unlike RSPI and QSPI, RSPI-RZ has separate interrupts for RX and TX, which shows that Single SPI transfers now generate (mostly) RX interrupts, as expected. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: fix build error when CONFIG_OF is not setShimoda, Yoshihiro2014-02-031-0/+1
| | | | | | | | | | | This patch fixes an issue that the following build error happens when the CONFIG_OF is not set: drivers/spi/spi-rspi.c: In function 'rspi_probe': drivers/spi/spi-rspi.c:1203:26: error: 'rspi_of_match' undeclared (first use in this function) Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Add support for Quad and Dual SPI Transfers on QSPIGeert Uytterhoeven2014-01-301-14/+148
| | | | | | | | | | | | | | Add support for Quad and Dual SPI Transfers on the Renesas Quad Serial Peripheral Interface, as found in R-Car Gen2 SoCs like R-Car H2 (r8a7790) and R-Car M2 (r8a7791): - Add unidirectional transfer methods for Quad/Dual SPI Transfers. - Program the sequencer to handle SPI messages with multiple transfer modes when Quad or Dual transfers are enabled for an SPI slave. Up to 4 transfer modes per SPI message are supported by the hardware. - Advertise the availability of Quad and Dual SPI modes on QSPI. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Add DT supportGeert Uytterhoeven2014-01-291-29/+77
| | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Use NULL as the clock IDGeert Uytterhoeven2014-01-271-3/+1Star
| | | | | | | There's only one RSPI/QSPI clock, so we can use NULL as the clock ID Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Convert to clk_prepare_enable/disable_unprepareGeert Uytterhoeven2014-01-271-3/+8
| | | | | | | | Get the driver ready for the migration to the common clock framework by calling clk_prepare_enable() and clk_disable_unprepare(). Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Add support for loopback modeGeert Uytterhoeven2014-01-271-8/+14
| | | | | | | Add support for specifying loopback mode. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Add support for RSPI on RZ/A1HGeert Uytterhoeven2014-01-271-9/+92
| | | | | | | | | | | | | | Add support for the RSPI variant in the RZ/A1H (r7s72100) SoC. Main differences with RSPI on SH are: - Lack of TX only mode, hence we always have to use full duplex transfers, - The Data Register must be accessed used 8-bit operations. RSPI on RZ is matched using the new "rspi-rz" platform device name. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Add support for more than one interruptGeert Uytterhoeven2014-01-271-19/+87
| | | | | | | | | | | | | | | Add support for multiple interrupts, based on the SDK reference code. This is needed for RZ/A1H, which supports 3 interrupts. When using multiple interrupts, they must be called "rx" (SPRI) and "tx" (SPTI). The error interrupt (SPEI) is not used, as it matters for slave mode only. When using a single interrupt, it may be called "mux". If it cannot be found, the first interrupt in the device's resources will be used. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Merge qspi_send_pio() and qspi_receive_pio()Geert Uytterhoeven2014-01-271-51/+28Star
| | | | | | | | | | qspi_send_pio() and qspi_receive_pio() are very similar: they both send and receive full duplex data to/from the hardware, but ignore the data stream in the unused direction. Merge them into qspi_transfer_out_in(), now supporting real full duplex. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Merge rspi_send_pio() and rspi_receive_pio()Geert Uytterhoeven2014-01-271-55/+46Star
| | | | | | | | | | | | rspi_send_pio() and rspi_receive_pio() are very similar: - the former only sends data, using TX Only Mode, - the latter sends and receives full duplex data to/from the hardware, but uses dummy transmit data. Merge them into rspi_transfer_out_in(), now supporting full duplex if needed. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Abstract transfer_one() for RSPI and QSPIGeert Uytterhoeven2014-01-271-13/+23
| | | | | | | | | | Split off qspi_transfer_one() (which doesn't support DMA yet) from rspi_transfer_one(). Replace the abstraction of send_pio()/receive_pio() by the abstracrion of transfer_one(). Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Add rspi_data_{out,in,out_in}() helpersGeert Uytterhoeven2014-01-271-61/+56Star
| | | | | | | | | Add helpers rspi_data_{out,in,out_in}() to write, read, or write and read data to/from the Data Register, taking care of waiting until data or space is available in the buffers. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Abstract 8/16-bit Data Register accessGeert Uytterhoeven2014-01-271-21/+35
| | | | | | | | Add rspi_{write,read}_data(), to abstract 8-bit (QSPI, and RSPI on RZ/A1H) versus 16-bit (RSPI) Data Register access. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Use core message handlingGeert Uytterhoeven2014-01-271-77/+34Star
| | | | | | | | | | | | | Let the generic SPI core handle SPI messages, calling into our rspi_transfer_one() method. rspi_assert_ssl() and rspi_negate_ssl() are absorbed into rspi_prepare_message() and rspi_unprepare_message(), as they actually enable/disable the whole SPI function, instead of just (de)asserting the chip select line. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rspi: Remove unused mesg parameter from {send,receive}_pio()Geert Uytterhoeven2014-01-271-17/+10Star
| | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* Merge commit 'spi/fix/rcar' into spi-linusMark Brown2014-01-231-3/+4
|\
| * spi: rspi: Fix typo when clearing SPSR_OVRFGeert Uytterhoeven2013-12-241-1/+1
| | | | | | | | | | | | | | | | | | The overrun flag should be cleared in the SPI Status Register, not in the SPI Control Register, based on the SDK sample code. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Mark Brown <broonie@linaro.org>
| * spi: rspi: Fix NULL pointer dereference on SH7757Geert Uytterhoeven2013-12-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SH7757 doesn't pass platform data, in which case spi-rspi uses default parameters. However, commit 5ce0ba88650f2606244a761d92e2b725f4ab3583 ("spi: rcar: add Renesas QSPI support on RSPI") added a new user of the platform data, but forgot to check for its validity first, causing a NULL pointer dereference on SH7757. Add the missing check to fix this. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: Remove duplicate code to set default bits_per_word settingAxel Lin2014-01-171-2/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | The implementation in spi_setup() already set spi->bits_per_word = 8 when spi->bits_per_word is 0 before calling spi->master->setup. So we don't need to do it again in setup() callback. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Marek Vasut <marex@denx.de> Acked-by: Barry Song <Baohua.Song@csr.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Add missing clk_disable() calls in error and cleanup pathsGeert Uytterhoeven2014-01-141-4/+7
| | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge branch 'topic/rcar' of ↵Mark Brown2014-01-141-30/+16Star
|\ \ | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-rspi
| * | spi: rcar: Use devm_spi_register_master()Jingoo Han2013-12-091-2/+1Star
| | | | | | | | | | | | | | | | | | | | | Use devm_spi_register_master() to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: rcar: Use devm_* managed allocatorsLaurent Pinchart2013-11-271-25/+13Star
| | | | | | | | | | | | | | | | | | | | | This simplies error and cleanup code paths. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: rcar: Fix pointer cast in the remove functionLaurent Pinchart2013-11-271-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The platform driver data is set to point to the rspi_data structure at probe time. Calling spi_master_get() on the pointer is just plain wrong and only works by chance. Fix it by using the platform driver data directly. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | spi: rcar: Fix uninitialized variable warningLaurent Pinchart2013-11-271-1/+1
| |/ | | | | | | | | | | | | | | | | | | The transfer data length variable is set based on the desired access size, without a default case. This results in a compiler warning, even though the access size is always set to a supported value. Create a default case to silence the warning. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Spelling s/transmition/transmission/Geert Uytterhoeven2014-01-141-2/+2
| | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Add support for specifying CPHA/CPOLGeert Uytterhoeven2014-01-131-2/+10
| | | | | | | | | | | | | | | | | | Add support for specifying the SPI clock phase and polarity, based on the SDK reference code. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Add more QSPI register documentationGeert Uytterhoeven2014-01-131-6/+19
| | | | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Add more RSPI register documentationGeert Uytterhoeven2014-01-131-86/+99
| | | | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Use u8 for 8-bit register valuesGeert Uytterhoeven2013-12-241-5/+5
| | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Use DUMMY_DATA macro instead of hardcoded valueGeert Uytterhoeven2013-12-241-2/+4
| | | | | | | | | | | | | | Make it more obvious that this value is dummy data. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Make more pointers constGeert Uytterhoeven2013-12-241-17/+20
| | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Remove castsGeert Uytterhoeven2013-12-241-15/+14Star
| | | | | | | | | | | | | | Remove useless casts, and do not cast away const. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: rspi: Use dev_get_platdata() instead of raw dev.platform_data accessGeert Uytterhoeven2013-12-241-1/+1
|/ | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi/rspi: Fix 8bit data access, clear bufferHiep Cao Minh2013-10-101-2/+93
| | | | | | | | | | | | | | | | | | | | | | The R8A7790 has QSPI module which added into RSPI together. The transmit or receive data should be read from or written to with the longword-, word-, or byte-access width. Modify word- access to byte-access. In 16-bit data register, QSPI send or receive datas access from high 8-bit while RSPI send or receive datas access from low 8-bit on single mode. Modify to reset transmit-receive buffer data and reading dummy after data are transmited. RSPI has a TXMD bit on control register(SPCR) to set transmit-only mode when transmit data or Full-duplex synchronous mode when receive data. In QSPI the TXMD bit is not supported, so after transmit data, dummy should be read and before transmit or receive data the bufer register should be reset. This driver is the implementation of send and receive pio only, DMA is not supported at this time. Without this patch, it will occur error when transmit and receive Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: rcar: add Renesas QSPI support on RSPIHiep Cao Minh2013-09-171-41/+142
| | | | | | | | The R8A7790 has QSPI module which is very similar to RSPI. This patch adds into RSPI module together to supports QSPI module. Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp> Signed-off-by: Mark Brown <broonie@linaro.org>
* Merge remote-tracking branch 'spi/topic/rspi' into spi-nextMark Brown2013-09-011-1/+1
|\
| * spi: rspi: Add spi_master_get() call to prevent use after freeAxel Lin2013-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In rspi_remove(), current code dereferences rspi after spi_unregister_master(), thus add an extra spi_master_get() call is necessary to prevent use after free. Current code already has an extra spi_master_put() call in rspi_remove(), so this patch just adds a spi_master_get() call rather than a spi_master_get() with spi_master_put() calls. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'spi/topic/rspi' into spi-pdataMark Brown2013-08-291-5/+12
|\| | | | | | | | | Conflicts: drivers/spi/spi-rspi.c
| * spi: spi-rspi: fix inconsistent spin_lock_irqsaveShimoda, Yoshihiro2013-08-271-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the following Smatch warning: CHECK drivers/spi/spi-rspi.c drivers/spi/spi-rspi.c:606 rspi_work() warn: inconsistent returns spin_lock:&rspi->lock: locked (602) unlocked (606) drivers/spi/spi-rspi.c:606 rspi_work() warn: inconsistent returns irqsave:flags: locked (602) unlocked (606) Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * spi: rspi: provide port addresses to dmaengine driver via slave configurationGuennadi Liakhovetski2013-08-021-1/+6
| | | | | | | | | | | | | | | | | | Don't rely on shdma dhaengine driver getting DMA slave addresses from its slave configuration. Instead provide those addresses, using a dmaengine_slave_config() call. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | spi: use dev_get_platdata()Jingoo Han2013-08-291-1/+1
|/ | | | | | | | Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* spi: use platform_{get,set}_drvdata()Jingoo Han2013-05-231-2/+2
| | | | | | | | | Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* spi: Remove HOTPLUG section attributesGrant Likely2012-12-071-5/+5
| | | | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option. As result the __dev* markings will be going away. Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit. Bill Pemberton has done most of the legwork on this series. I've used his script to purge the attributes from the drivers/gpio tree. Reported-by: Bill Pemberton <wfp5p@virginia.edu> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* spi: spi-rspi: fix build error for the latest shdma driverShimoda, Yoshihiro2012-10-171-22/+34
| | | | | | | | Because the latest shdma driver changed, it caused build error in the spi-rspi driver. This patch fixed the build error. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* spi/rspi: add dmaengine supportShimoda, Yoshihiro2012-05-201-6/+314
| | | | | | | | This patch adds dmaengine supporting using sh_dma driver. The module receives data by DMAC, it also needs TX DMAC to generate SPI's clocks. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* spi: add support for Renesas RSPIShimoda, Yoshihiro2012-03-081-0/+521
The SH7757 has RSPI module. This patch supports it. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>