Commit graph

1974 commits

Author SHA1 Message Date
Geert Uytterhoeven
9372220678 spi: rspi: Add support for more than one interrupt
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>
2014-01-27 20:05:34 +00:00
Geert Uytterhoeven
340a15e6f0 spi: rspi: Merge qspi_send_pio() and qspi_receive_pio()
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>
2014-01-27 20:02:10 +00:00
Geert Uytterhoeven
8449fd76de spi: rspi: Merge rspi_send_pio() and rspi_receive_pio()
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>
2014-01-27 20:02:10 +00:00
Geert Uytterhoeven
eb557f7526 spi: rspi: Abstract transfer_one() for RSPI and QSPI
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>
2014-01-27 20:02:09 +00:00
Geert Uytterhoeven
35301c9960 spi: rspi: Add rspi_data_{out,in,out_in}() helpers
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>
2014-01-27 20:02:09 +00:00
Geert Uytterhoeven
74da76865d spi: rspi: Abstract 8/16-bit Data Register access
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>
2014-01-27 20:02:09 +00:00
Geert Uytterhoeven
79d2349542 spi: rspi: Use core message handling
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>
2014-01-27 20:02:09 +00:00
Geert Uytterhoeven
91949a2d4a spi: rspi: Remove unused mesg parameter from {send,receive}_pio()
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-27 20:02:09 +00:00
Mark Brown
8b8b773e6b Merge commit 'spi/topic/sc18is602' into spi-linus 2014-01-23 13:14:15 +00:00
Mark Brown
341e6df6c8 Merge commit 'spi/fix/rcar' into spi-linus 2014-01-23 13:13:30 +00:00
Mark Brown
8aeab58e56 Merge remote-tracking branches 'spi/topic/pxa2xx', 'spi/topic/qspi', 'spi/topic/s3c24xx', 'spi/topic/s3c64xx', 'spi/topic/sh', 'spi/topic/tegra114', 'spi/topic/tegra20-sflash', 'spi/topic/tegra20-slink', 'spi/topic/txx9' and 'spi/topic/xcomm' into spi-linus 2014-01-23 13:07:14 +00:00
Mark Brown
907e26b6f5 Merge remote-tracking branches 'spi/topic/fsl-espi', 'spi/topic/gpio', 'spi/topic/hspi', 'spi/topic/mpc512x', 'spi/topic/msiof', 'spi/topic/nuc900', 'spi/topic/oc-tiny', 'spi/topic/omap', 'spi/topic/orion' and 'spi/topic/pci' into spi-linus 2014-01-23 13:07:09 +00:00
Mark Brown
36e66bf84f Merge remote-tracking branches 'spi/topic/bcm2835', 'spi/topic/bcm63xx', 'spi/topic/bcm63xx-hsspi', 'spi/topic/bitbang', 'spi/topic/bpw', 'spi/topic/clps711x', 'spi/topic/coldfire', 'spi/topic/davinci', 'spi/topic/dw' and 'spi/topic/falcon' into spi-linus 2014-01-23 13:07:05 +00:00
Mark Brown
1504d226f7 Merge remote-tracking branches 'spi/fix/bcm63xx', 'spi/fix/dspi', 'spi/fix/hspi', 'spi/fix/imx', 'spi/fix/msiof', 'spi/fix/pxa2xx', 'spi/fix/qspi', 'spi/topic/altera', 'spi/topic/ath79' and 'spi/topic/atmel' into spi-linus 2014-01-23 13:07:01 +00:00
Mark Brown
3c1039745e Merge remote-tracking branch 'spi/topic/core' into spi-linus 2014-01-23 13:07:01 +00:00
Mark Brown
7e2c225d58 Merge remote-tracking branch 'spi/fix/core' into spi-linus 2014-01-23 13:07:00 +00:00
Axel Lin
13a4279880 spi: core: Fix transfer failure when master->transfer_one returns positive value
master->transfer_one returns positive value is not a error.
So set ret to 0 when master->transfer_one returns positive value.
Otherwise, I hit "spi_master spi0: failed to transfer one message from queue"
error when my transfer_one callback returns 1.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-21 18:45:34 +00:00
Geert Uytterhoeven
9e8f4882cc spi: Spelling s/finised/finished/
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-21 18:11:45 +00:00
Axel Lin
463654cec2 spi: sc18is602: Convert to use bits_per_word_mask
Since commit 543bb25 "spi: add ability to validate xfer->bits_per_word in SPI
core", the driver can set bits_per_word_mask for the master then the SPI core
will reject transfers that attempt to use an unsupported bits_per_word value.
So we can remove the bits_per_word checking in sc18is602_check_transfer() and
let SPI core handle the checking.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-17 15:55:54 +00:00
Axel Lin
23061f1eb8 spi: Remove duplicate code to set default bits_per_word setting
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>
2014-01-17 15:54:22 +00:00
Mark Brown
81e53d0470 Merge branches 'topic/sc18is602' and 'topic/rspi' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-bpw 2014-01-17 15:52:17 +00:00
Mika Westerberg
382cebb02a spi/pxa2xx: fix compilation warning when !CONFIG_PM_SLEEP
CONFIG_PM will be set if either or both CONFIG_PM_SLEEP and
CONFIG_PM_RUNTIME is set. Compiling the driver with !CONFIG_PM_SLEEP causes
following compilation warning:

drivers/spi/spi-pxa2xx.c:1270:12: warning: ‘pxa2xx_spi_suspend’ defined but not used [-Wunused-function]

Fix this by using CONFIG_PM_SLEEP instead.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-16 14:07:48 +00:00
Axel Lin
350a9b3304 spi: clps711x: Add MODULE_ALIAS to support module auto-loading
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-14 14:21:43 +00:00
Geert Uytterhoeven
fcb4ed749c spi: rspi: Add missing clk_disable() calls in error and cleanup paths
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-14 14:14:54 +00:00
Mark Brown
13ea330010 Merge branch 'topic/rcar' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-rspi 2014-01-14 14:14:47 +00:00
Geert Uytterhoeven
b7ed6b88b2 spi: rspi: Spelling s/transmition/transmission/
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-14 14:02:11 +00:00
Geert Uytterhoeven
348e5153bc spi: rspi: Add support for specifying CPHA/CPOL
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>
2014-01-13 17:24:04 +00:00
Mika Westerberg
483c319188 spi/pxa2xx: initialize DMA channels to -1 to prevent inadvertent match
Commit cddb339bad (spi/pxa2xx: convert to dma_request_slave_channel_compat())
converted the driver to use ACPI provided DMA helpers but it forgot to
initialize the platform data for the channels to -1. Failing to do so will
result inadvertent match in the filter function because 0 is a valid
channel number.

Prevent this from happening by initializing both platform data channels
correctly to -1.

Fixes: cddb339bad (spi/pxa2xx: convert to dma_request_slave_channel_compat())
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Cc: stable@vger.kernel.org
2014-01-13 12:39:19 +00:00
Geert Uytterhoeven
fbe5072bbe spi: rspi: Add more QSPI register documentation
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>
2014-01-13 12:10:01 +00:00
Geert Uytterhoeven
6ab4865b7e spi: rspi: Add more RSPI register documentation
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>
2014-01-13 12:10:01 +00:00
Geert Uytterhoeven
e2e5ed79fe spi: rspi: Remove dependency on DMAE for SHMOBILE
On ARM-based SHMOBILE, the rspi driver builds and works fine without the
DMA controller driver, hence relax the dependencies.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 11:53:44 +00:00
Geert Uytterhoeven
3e83c19497 spi/s3c64xx: Correct indentation
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 11:30:41 +00:00
Axel Lin
909e709c77 spi: sh: Use spi_sh_clear_bit() instead of open-coded
We have a spi_sh_clear_bit() function, there's no reason not to use it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 11:26:28 +00:00
Geert Uytterhoeven
f21524f5bc spi: bitbang: Grammar s/make to make/to make/
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 11:24:21 +00:00
Geert Uytterhoeven
c6c07b4f6d spi: sh-hspi: Spelling s/recive/receive/
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 11:21:45 +00:00
Geert Uytterhoeven
1afd9989a6 spi: core: Improve tx/rx_nbits check comments
- Rephrase the comments about tx/rx_nbits validity checks,
  - Remove the stale comment about SPI_3WIRE (the code it refers to was
    removed in commit 368ca4e0c7 ("spi:
    Eliminate 3WIRE spi_transfer check")).

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 11:20:46 +00:00
Axel Lin
5a33d30ff1 spi: ti-qspi: Fixup driver name
The driver name in current code looks like a compatible string which is not
the naming convention for platform drivers.
Fix it and also add modalias since this driver can be built as a module.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Sourav Poddar <sourav.poddar@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 10:16:16 +00:00
Axel Lin
3ab5462054 spi: ti-qspi: Simplify qspi_write_msg and qspi_read_msg implementation
Make the unit of wlen to be byte, and simplify the code to avoid duplicate
code for different wlen cases.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Sourav Poddar <sourav.poddar@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 10:15:13 +00:00
Axel Lin
646d79b2d7 spi: altera: Remove unneeded NULL checking for hw->bitbang.master
We already has NULL test for master after calling spi_alloc_master().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-13 10:12:45 +00:00
Alexander Shiyan
989847967c spi: clps711x: Use devm_gpio_request()
This patch replaces gpio_request() with devm_ API.
As a result this simplifies error path and eliminates "remove"
function.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-10 13:27:24 +00:00
Axel Lin
e826a7ff69 spi: oc-tiny: Simplify tiny_spi_txrx_bufs implementation when irq is not used
Currently we have similar code for (txp && rxp), (txp && !rxp), (!rxp & txp),
and (!txp && !rxp) cases. This patch refactors the code a bit to avoid
duplicate similar code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-09 17:58:28 +00:00
Wenyou Yang
8090d6d1a4 spi: atmel: Refactor spi-atmel to use SPI framework queue
Replace the deprecated master->transfer with transfer_one_message()
and allow the SPI subsystem handle all the queuing of messages.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Tested-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-09 17:41:23 +00:00
Axel Lin
e07725be73 spi: fsl-dspi: Add missing breaks for switch cases
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-09 17:29:26 +00:00
Sekhar Nori
dd5c1f936a spi/davinci: Don't select EDMA
There is no need to force selection of TI EDMA DMA engine
driver when DaVinci SPI driver is selected. The driver
builds just fine even with CONFIG_TI_EDMA disabled.

Forcing this selection causes warnings of the sort:

warning: (ARCH_KEYSTONE && SPI_DAVINCI) selects TI_EDMA which has unmet direct dependencies (DMADEVICES && (ARCH_DAVINCI || ARCH_OMAP || ARCH_KEYSTONE))

This reverts commit b5f1433059.

Reported-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-09 14:07:53 +00:00
Mika Westerberg
b6fb8d3a1f spi: Check conflicting CS based on spi->chip_select instead of device name
Commit e13ac47bec (spi: Use stable dev_name for ACPI enumerated SPI
slaves) changed the SPI device naming to be based on ACPI device name
instead of carrying bus number and chip select for devices enumerated
from ACPI namespace.

In case of a buggy BIOS that lists multiple SPI devices sharing the same
chip select (even though they should use different) the current code fails
to detect that and allows the devices to be added to the bus.

Fix this by walking through the bus and comparing spi->chip_select instead
of device name. This should work regardless what the device name will be in
future.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-09 14:07:08 +00:00
Axel Lin
a89e2d2754 spi: core: Use list_first_entry to extract head of queue
For slightly better readability.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-09 13:54:07 +00:00
Sachin Kamat
85a9012446 spi: s3c24xx: Remove reference to plat/fiq.h
fiq.h contains only a function declaration and is not used by anyone
else. Move the declaration to the driver header file and remove the
unnecessary platform dependency from the driver.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-08 13:06:21 +00:00
Richard Genoud
d3b72c7e6b spi: atmel: add support for changing message transfer speed
The only speed available was max_speed (the maximum speed declared for a
device).
This patch adds the support for spi_tranfer->speed_hz parameter.
We can now set a different speed for each spi message.

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-08 13:00:24 +00:00
Axel Lin
caedb997a4 spi: sh-hspi: Fix modalias for sh-hspi
Make the modalias matches the driver name.
Seems the MODULE_ALIAS is copied from drivers/spi/spi-sh-spi.c.
So both spi-sh.ko and spi-sh-hspi.ko have the same alias. Fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-08 12:14:22 +00:00
Wei Yongjun
136c8bf374 spi: dw-pci: remove free for resources allocated with devm_*
It's not necessary to free resources allocated with devm_*
and free them may lead to double free.

Fixes: 04f421e7b0 ('spi: dw: use managed resources')
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-07 15:47:18 +00:00