Commit graph

3914 commits

Author SHA1 Message Date
Varadarajan Narayanan
3b5ea2c981 spi: qup: call io_config in mode specific function
DMA transactions should only only need to call io_config only once, but
block mode might call it several times to setup several transactions so
it can handle reads/writes larger than the max size per transaction, so
we move the call to the do_ functions.

This is just refactoring, there should be no functional change

Signed-off-by: Matthew McClintock <mmcclint@codeaurora.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:35 +01:00
Varadarajan Narayanan
94b9149feb spi: qup: refactor spi_qup_io_config into two functions
This is in preparation for handling transactions larger than
64K-1 bytes in block mode, which is currently unsupported and
quietly fails.

We need to break these into two functions 1) prep is
called once per spi_message and 2) io_config is called
once per spi-qup bus transaction

This is just refactoring, there should be no functional
change

Signed-off-by: Matthew McClintock <mmcclint@codeaurora.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:31 +01:00
Varadarajan Narayanan
7538726f9d spi: qup: Do block sized read/write in block mode
This patch corrects the behavior of the BLOCK
transactions.  During block transactions, the controller
must be read/written to in block size transactions.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:27 +01:00
Varadarajan Narayanan
ce7dfc71c1 spi: qup: Fix transaction done signaling
Wait to signal done until we get all of the interrupts we are expecting
to get for a transaction.  If we don't wait for the input done flag, we
can be in between transactions when the done flag comes in and this can
mess up the next transaction.

While here cleaning up the code which sets controller->xfer = NULL and
restores it in the ISR. This looks to be some debug code which is not
required.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:22 +01:00
Varadarajan Narayanan
d9a09a6c0c spi: qup: Fix error handling in spi_qup_prep_sg
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:18 +01:00
Varadarajan Narayanan
ce00bab318 spi: qup: Place the QUP in run mode before DMA
Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:14 +01:00
Varadarajan Narayanan
5f13fd60b1 spi: qup: Add completion timeout
Add i/o completion timeout for DMA and PIO modes.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:10 +01:00
Varadarajan Narayanan
32ecab999f spi: qup: Setup DMA mode correctly
To operate in DMA mode, the buffer should be aligned and
the size of the transfer should be a multiple of block size
(for v1). And the no. of words being transferred should
be programmed in the count registers appropriately.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:06 +01:00
Varadarajan Narayanan
b702b9fb39 spi: qup: Enable chip select support
Enable chip select support for QUP versions later than v1. The
chip select support was broken in QUP version 1. Hence the chip
select support was removed earlier in an earlier commit
(4a8573abe "spi: qup: Remove chip select function"). Since the
chip select support is functional in recent versions of QUP,
re-enabling it for QUP versions later than v1.

Signed-off-by: Sham Muthayyan <smuthayy@codeaurora.org>
Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:15:02 +01:00
Gustavo A. R. Silva
378da4a65f spi/bcm63xx-hspi: fix error return code in bcm63xx_hsspi_probe()
platform_get_irq() returns an error code, but the spi-bcm63xx-hsspi
driver ignores it and always returns -ENXIO. This is not correct and,
prevents -EPROBE_DEFER from being propagated properly.

Notice that platform_get_irq() no longer returns 0 on error:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af

Print and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 11:36:39 +01:00
Gustavo A. R. Silva
ba8afe9472 spi/bcm63xx: fix error return code in bcm63xx_spi_probe()
platform_get_irq() returns an error code, but the spi-bcm63xx driver
ignores it and always returns -ENXIO. This is not correct and,
prevents -EPROBE_DEFER from being propagated properly.

Notice that platform_get_irq() no longer returns 0 on error:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af

Print and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 11:36:35 +01:00
Gustavo A. R. Silva
9a6b94796a spi: xlp: fix error return code in xlp_spi_probe()
platform_get_irq() returns an error code, but the spi-xlp driver ignores
it and always returns -EINVAL. This is not correct and, prevents
-EPROBE_DEFER from being propagated properly.

Notice that platform_get_irq() no longer returns 0 on error:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af

Print and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 11:36:07 +01:00
Shubhrajyoti Datta
802740890c spi: cadence: Add support for context loss
Context could be lost across the suspend and resume.
Reinit the driver to tide over.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 10:43:41 +01:00
Naga Sureshkumar Relli
48767fd898 spi: cadence: change sequence of calling runtime_enable
call pm_runtime_enable after set_active other wise it will
enable clock always.

Signed-off-by: Naga Sureshkumar Relli <nagasure@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 10:43:16 +01:00
Arnd Bergmann
128345b13d spi: fix building SPI_PXA on MMP
When the audio driver selects CONFIG_PXA_SSP on ARCH_MMP as a
loadable module, and the PXA SPI driver is built-in, we get
a link error in the SPI driver:

drivers/spi/spi-pxa2xx.o: In function `pxa2xx_spi_remove':
spi-pxa2xx.c:(.text+0x5f0): undefined reference to `pxa_ssp_free'
drivers/spi/spi-pxa2xx.o: In function `pxa2xx_spi_probe':
spi-pxa2xx.c:(.text+0xeac): undefined reference to `pxa_ssp_request'
spi-pxa2xx.c:(.text+0x1468): undefined reference to `pxa_ssp_free'
spi-pxa2xx.c:(.text+0x15bc): undefined reference to `pxa_ssp_free'

The problem is that the PXA SPI driver only uses 'select SSP'
specifically when building it for PXA, but we can also build it
for PCI, which is meant for Intel x86 SoCs that use the same SPI
block. When the sound driver forces the SSP to be a loadable
module, the IS_ENABLED() check in include/linux/pxa2xx_ssp.h
triggers but the spi driver can't reference the exported symbols.

I had a different approach before, making the PCI case depend
on X86, which fixed the problem by avoiding the MMP case.

This goes a different route, making the driver select PXA_SSP
also on MMP, which has an SSP that none of the boards in mainline
Linux use for SPI. There is no harm in always enabling the build
on MMP (PCI or not PCI), so I do that too, to document that this
hardware is actually available on MMP.

Link: https://patchwork.kernel.org/patch/8879921/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07 16:47:46 +01:00
Jeffy Chen
d38c4ae194 spi: rockchip: Fix clock handling in suspend/resume
The runtime suspend callback might be called by pm domain framework at
suspend_noirq stage. It would try to disable the clocks which already
been disabled by rockchip_spi_suspend.

Call pm_runtime_force_suspend/pm_runtime_force_resume when
suspend/resume to avoid that.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07 16:44:13 +01:00
Jeffy Chen
6a06e895b2 spi: rockchip: Fix clock handling in remove
We are assuming clocks enabled when calling rockchip_spi_remove, which
is not always true. Those clocks might already been disabled by the
runtime PM at that time.

Call pm_runtime_get_sync before trying to disable clocks to avoid that.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07 16:44:10 +01:00
Jeffy Chen
43de979ddc spi: rockchip: Slightly rework return value handling
Slightly rework return value handling, no functional changes.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07 16:44:07 +01:00
Sergei Shtylyov
e0bcb680b1 spi: use of_property_read_bool()
Use a bit more compact of_property_read_bool() calls instead of the
of_find_property() calls -- symmetrically with the of_property_read_u32()
calls already done in of_spi_parse_dt().

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07 12:49:00 +01:00
Jan Kiszka
c18d925fca spi: pxa2xx: Convert to GPIO descriptor API where possible
We still need to request/free GPIOs passed via the legacy path of
pxa2xx_spi_chip::gpio_cs, but we can use the gpiod API otherwise.

Consistently use the descriptor API instead of the legacy one.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-04 12:41:55 +01:00
Lukas Wunner
8a2e487e6f spi: Use Apple device properties in absence of ACPI resources
MacBooks and MacBook Pros introduced since 2015 return empty _CRS data
for SPI slaves, causing device initialization to fail.  Most of the
information that would normally be conveyed via _CRS is available
through ACPI device properties instead, so take advantage of them.

The meaning and appropriate usage of the device properties was reverse
engineered by Ronald Tschalär and carried over from these commits
authored by him:

https://github.com/cb22/macbook12-spi-driver/commit/9a416d699ef4
https://github.com/cb22/macbook12-spi-driver/commit/0c34936ed9a1

According to Ronald, the device properties have the following meaning:

spiSclkPeriod   /* period in ns */
spiWordSize     /* in number of bits */
spiBitOrder     /* 1 = MSB_FIRST, 0 = LSB_FIRST */
spiSPO          /* clock polarity: 0 = low, 1 = high */
spiSPH          /* clock phase: 0 = first, 1 = second */
spiCSDelay      /* delay between cs and receive on reads in 10 us */
resetA2RUsec    /* active-to-receive delay? */
resetRecUsec    /* receive delay? */

Reported-by: Leif Liddy <leif.liddy@gmail.com>
Tested-by: Ronald Tschalär <ronald@innovation.ch>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-08-03 23:26:23 +02:00
Andy Shevchenko
d35f2dc9a2 spi: pxa2xx: Don't touch CS pin until we have a transfer pending
GPIO descriptors, when being requested, may configure pin at the same
time. In case of SPI chip select we shouldn't do any assumptions of the
state of pin since we don't know yet what chip is connected there and if
it uses high or low active state. So, leave the state of pin as is until
transfer will start.

Fixes: 99f499cd65 ("spi: pxa2xx: Add support for GPIO descriptor chip selects")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westeberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-28 13:33:18 +01:00
Kamal Dasu
054e532f8f spi: bcm-qspi: Remove hardcoded settings and spi-nor.h dependency
The newly added broadcom qspi driver in drivers/spi produces a build
warning when CONFIG_MTD is disabled:
include/linux/mtd/cfi.h:76:2: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. [-Werror=cpp]

There has been discussion on this in the link provided below. This fix in
SPI controller drivers implementing the ->spi_flash_read handler, now uses the
settings provided inside the 'struct spi_flash_read_message' parameter instead
of hardcoding them. Made changes to bcm_qspi_bspi_set_flex_mode() to set the BSPI
controller using the passed msg structure and remove the need to include
<linux/mtd/spi-nor.h> file by removing all use of SPINOR_OP_READ* macros.

Fixes: 4e3b2d236f ("spi: bcm-qspi: Add BSPI spi-nor flash controller driver")
Link: https://patchwork.kernel.org/patch/9624585/
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-28 11:11:35 +01:00
Andy Shevchenko
6ac5a435ae spi: pxa2xx: Revert "Only claim CS GPIOs when the slave device is created"
There is a valid case to call setup() following by setup_cs() several
times for the same chip.

With the commit

  676a4e3bab ("spi: pxa2xx: Only claim CS GPIOs when the slave device is created")

it is not possible anymore due to GPIO line being requested already
during the first call to setup_cs().

For now, revert the commit to make things work again.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-27 17:11:24 +01:00
Andy Shevchenko
2856670f23 spi: core: Propagate error code of add_uevent_var()
add_uevent_var() can fail, let caller know about this.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-26 15:30:35 +01:00
Oleksij Rempel
ab2f357223 spi: imx: add SPI_NO_CS support
To run spi-loopback-tests on HW without modifications, we need to
disable Chip Select. This should avoid surprising side effects for SPI devices
by testing patterns.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-26 13:10:01 +01:00
Oleksij Rempel
8bc85a8714 spi: loopback-test: implement testing with no CS
To run spi-loopback-tests on HW without modifications, we need to
disable Chip Select. This should avoid surprising side effects for
SPI devices by testing patterns.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-26 13:08:56 +01:00
Colin Ian King
808f5154a7 spi: pic32: fix spelling mistakes on macro names
Trivial fix to spelling mistakes macros; fix EMPTY spellings:
RX_FIFO_EMTPY -> RX_FIFO_EMPTY
TX_FIFO_EMTPY -> TX_FIFO_EMPTY

Note that there are no other occurrances of these macros in the
source.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-26 13:04:21 +01:00
Philipp Zabel
e60dfe0782 spi: tegra20-sflash: explicitly request exclusive reset control
Commit a53e35db70 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-spi@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19 17:06:31 +01:00
Philipp Zabel
d006edb420 spi: tegra114: explicitly request exclusive reset control
Commit a53e35db70 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-spi@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19 17:06:28 +01:00
Philipp Zabel
73b32756ce spi: tegra20-slink: explicitly request exclusive reset control
Commit a53e35db70 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-spi@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19 17:06:26 +01:00
Philipp Zabel
36bc7491f9 spi: sun6i: explicitly request exclusive reset control
Commit a53e35db70 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Mark Brown <broonie@kernel.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: linux-spi@vger.kernel.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19 17:06:03 +01:00
Philipp Zabel
d5e9a4a433 spi: stm32: explicitly request exclusive reset control
Commit a53e35db70 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Mark Brown <broonie@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: linux-spi@vger.kernel.org
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19 17:05:46 +01:00
Rob Herring
25c56c88a4 spi: Convert to using %pOF instead of full_name
Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19 11:56:23 +01:00
Colin Ian King
59a8831da3 spi: loopback-test: make several module parameters static
Several module parameters are local to the source, so make them
static. Cleans up several sparse warnings such as:

"symbol 'loop_req' was not declared. Should it be static?"

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-18 14:10:01 +01:00
Oleksij Rempel
f12a616e0c spi: loopback-test: provide loop_req option.
Provide a module parameter to request internal loop by the SPI master
controller.
This should make loop testing easier without extra HW modification.

For test automation a logic analyzer is recommended for host
controller-independent verification.
An example test rig configuration and procedure:
  i.MX6S RIoRBoard           Logic Analyzer
  -----------------------------------------
  (J13  4) GND ------------- GND
  (J13  6) CSPI3-CLK ------> PIN 3
  (J13  8) CSPI3-MOSI <----- PIN 2
     ^ - internal loop configured by SPI_LOOP
     |   or can be user external jamper.
  (J13 10) CSPI3-MISO -----> PIN 1

grab some data and decode it:
sigrok-cli -d fx2lafw --time 160000 --config samplerate=10m  \
  --channels 0-2 -o dump.sr
sigrok-cli -i dump.sr -P spi:mosi=1:clk=2 > result_for_regression_tests

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 15:27:26 +01:00
Geert Uytterhoeven
61a8dec502 spi: sh-msiof: Limit minimum divider on R-Car Gen3
On R-Car Gen3 SoCs (excluding R-Car H3 ES1.x, which cannot be used for
SPI due to a hardware erratum), BRPS x BRDV = 1/1 is an invalid divider
setting.
Implement this limitation using an SoC/family-specific minimum divider.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 12:09:59 +01:00
Jan Kiszka
676a4e3bab spi: pxa2xx: Only claim CS GPIOs when the slave device is created
Avoid hogging chip select GPIOs just because they are listed for the
master. They might be mulitplexed and, if no slave device is attached,
used for different purposes. Moreover, this strategy avoids having to
allocate a cs_gpiods structure.

Tested on the IOT2000 where the second SPI bus is connected to an
Arduino-compatible connector and multiplexed between SPI, GPIO and PWM
usage.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 12:09:52 +01:00
jiada wang
26e4bb8670 spi: imx: add selection for iMX53 and iMX6 controller
ECSPI contorller for iMX53 and iMX6 has few hardware issues
comparing to iMX51.
The change add possibility to detect which controller is used
to apply possible workaround and limitations.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 12:09:48 +01:00
jiada wang
fd8d4e2d1f spi: imx: introduce fifo_size and has_dmamode in spi_imx_devtype_data
Different ECSPI controller has different fifosize and DMA capability,
instead of calling functions to identify these information by check
devtype. add fifo_size and has_dmamode to spi_imx_devtype_data.
so that these information can be directly accessed.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 12:09:47 +01:00
Aravind Thokala
c3c25ea712 spi/bcm63xx-hspi: Fix checkpatch warnings
This patch fixes the checkpatch.pl warnings on the driver
file.

Signed-off-by: Aravind Thokala <aravind.thk@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 12:09:43 +01:00
Aravind Thokala
da470d6ab8 spi/ath79: Fix checkpatch warnings
This patch fixes the checkpatch.pl warnings on the driver
file.

Signed-off-by: Aravind Thokala <aravind.thk@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 12:09:38 +01:00
Linus Torvalds
090a81d876 Merge branch 'for-spi' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull spi uaccess delousing from Al Viro:
 "Getting rid of pointless __get_user() and friends in drivers/spi.

  [ the only reason it's on a separate branch is that I hoped it would
    be picked by spi folks; looks like mail asking them to grab it got
    lost and I hadn't followed up on that ]"

* 'for-spi' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  spidev: quit messing with access_ok()
2017-07-08 10:41:53 -07:00
Mark Brown
082f6968bb Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/st-ssc4' and 'spi/topic/stm32' into spi-next 2017-07-03 16:21:12 +01:00
Mark Brown
cc7e35baca Merge remote-tracking branches 'spi/topic/orion', 'spi/topic/pxa2xx', 'spi/topic/rockchip', 'spi/topic/sh-msiof' and 'spi/topic/sirf' into spi-next 2017-07-03 16:21:10 +01:00
Mark Brown
15f8c9af83 Merge remote-tracking branches 'spi/topic/loopback', 'spi/topic/meson-spicc', 'spi/topic/mtk' and 'spi/topic/omap2-mcspi' into spi-next 2017-07-03 16:21:08 +01:00
Mark Brown
63a89274bd Merge remote-tracking branches 'spi/topic/atmel', 'spi/topic/bcm63xx', 'spi/topic/davinci' and 'spi/topic/imx' into spi-next 2017-07-03 16:21:06 +01:00
Mark Brown
9d540b0d49 Merge remote-tracking branch 'spi/topic/master' into spi-next 2017-07-03 16:21:05 +01:00
Mark Brown
096bf6b7f4 Merge remote-tracking branch 'spi/topic/core' into spi-next 2017-07-03 16:21:05 +01:00
Mark Brown
20e5c748d9 Merge remote-tracking branches 'spi/fix/atmel', 'spi/fix/bcm63xx', 'spi/fix/doc', 'spi/fix/fsl-dspi' and 'spi/fix/ti-qspi' into spi-linus 2017-07-03 16:21:02 +01:00
Al Viro
251d59515f spidev: quit messing with access_ok()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-06-29 18:00:52 -04:00
Arvind Yadav
704c3098e4 spi: loopback-test: Fix kfree() NULL pointer error.
Here, rx/tx allocation can fail. So avoid kvfree call
with NULL pointer.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:16:41 +01:00
Colin Ian King
478de2ba0d spi: loopback-test: fix spelling mistake: "reruning" -> "rerunning"
trivial fix to spelling mistake in dev_info error message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:03:09 +01:00
Colin Ian King
2d781e89e2 spi: sirf: fix spelling mistake: "registerred" -> "registered"
Trivial fix to spelling mistake in dev_info message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:02:52 +01:00
Amelie Delaunay
7b821a6485 spi: stm32: fix potential dereference null return value
This patch fixes the usage of rx_dma_desc and tx_dma_desc pointers
returned by dmaengine_prep_slave_sg, which can be null.

Detected by CoverityScan, CID#1446587 ("Dereference null return value")

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:00:55 +01:00
Amelie Delaunay
c67ad368cf spi: stm32: enhance DMA error management
This patch reworks DMA error management. In case the DMA callback is
called while EOT (End Of Transfer) flag is not set, that means that DMA
encountered an error. This error will result in an auto-suspend of SPI
flow, which could also result in an overrun. So, in DMA mode, SUSP and
OVR flags are a condition to stop the current transfer.

Moreover, stm32_spi_can_dma doesn't care about the state of dma channels.
During driver probe, master->can_dma is initialised if dma channel request
is successful. That's why we must use master->can_dma to know if dma
use is possible (dma channel are successfully requested and the transfer
size is greater than fifo size).

Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:00:54 +01:00
Amelie Delaunay
038ac869c9 spi: stm32: add runtime PM support
This patch reworks suspend and resume callbacks and add runtime_suspend
and runtime_resume callbacks.

Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:00:54 +01:00
Amelie Delaunay
128ebb89c5 spi: stm32: use normal conditional statements instead of ternary operator
This patch replace ternary operator use by normal condition statements
to ease code reading.
It also removes redundant !!.

Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:00:53 +01:00
Amelie Delaunay
042c1c60df spi: stm32: replace st, spi-midi with st, spi-midi-ns to fit bindings
This patch fixes the optional dt property used to set master inter-data
idleness.

Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:00:53 +01:00
Amelie Delaunay
c5fe2faaba spi: stm32: fix compatible to fit with new bindings
This patch updates of_device_id compatible string to fit with new
bindings.

Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 20:00:48 +01:00
Jeffy Chen
aa099382ac spi: rockchip: Disable Runtime PM when chip select is asserted
The rockchip spi would stop driving pins when runtime suspended, which
might break slave's xfer(for example cros_ec).

Since we have pullups on those pins, we only need to care about this
when the CS asserted.

So let's keep the spi alive when chip select is asserted.

Also use pm_runtime_put instead of pm_runtime_put_sync.

Suggested-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 19:43:18 +01:00
Jeffy Chen
c863795c4c spi: rockchip: Set GPIO_SS flag to enable Slave Select with GPIO CS
The rockchip spi still requires slave selection when using GPIO CS.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28 19:43:11 +01:00
Cyrille Pitchen
7094576ccd spi: atmel: fix corrupted data issue on SAM9 family SoCs
This patch disables the use of the DMA for data transfer and forces the
use of PIO transfers instead as a quick fixup to solve the cache aliasing
issue on ARM9 based cores, which embeds a VIVT data cache.

Indeed in the case of VIVT data caches, it is not safe to call dma_map_*()
functions to map buffers for DMA transfers when those buffers have been
allocated by vmalloc() or from any DMA-unsafe area.

Further patches may propose a better solution based on the use of a bounce
buffer at the SPI sub-system level but such solution needs more time to be
discussed. Then the use of DMA transfers could be enabled again to improve
the performances but before that, this patch already solves the issue.

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
2017-06-23 17:15:28 +01:00
Colin Ian King
a2f07d38d6 spi: stm32: fix error check on mbr being -ve
The error check of mbr < 0 is always false because mbr is a u32. Make
mbt an int so that a -ve error return from stm32_spi_prepare_mbr can be
detected.

Detected by CoverityScan, CID#1446586 ("Unsigned compared against 0")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-23 12:26:38 +01:00
Amelie Delaunay
dcbe0d84df spi: add driver for STM32 SPI controller
The STM32 Serial Peripheral Interface (SPI) can be used to communicate
with external devices while using the specific synchronous protocol. It
supports a half-duplex, full-duplex and simplex synchronous, serial
communication with external devices with 4-bit to 16/32-bit per word. It
has two 8x/16x 8-bit embedded Rx and TxFIFOs with DMA capability. It can
operate in master or slave mode.

Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-21 16:15:54 +01:00
Aravind Thokala
b85d65dd47 spi/bcm63xx: Fix checkpatch warnings
This patch fixes the checkpatch.pl warnings on the driver
file.

Signed-off-by: Aravind Thokala <aravind.thk@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-21 12:14:54 +01:00
Fabio Estevam
2c147776dc spi: imx: Check for allocation failure earlier
In case of spi_alloc_master() failure it is better to return the
error immediately, so move the error check right after the allocation.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-21 12:09:07 +01:00
leilk.liu@mediatek.com
b6b1f2d9cf spi: mediatek: add spi support for mt2712 IC
this patch add support for mt2712 IC.

Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-20 13:39:14 +01:00
Jeffy Chen
c351587e25 spi: rockchip: fix error handling when probe
After failed to request dma tx chain, we need to disable pm_runtime.
Also cleanup error labels for better readability.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-13 20:12:30 +01:00
Leilk Liu
fc4f226fec spi: mediatek: add spi support for mt7622 IC
this patch add support for mt7622 IC.

Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-13 19:42:31 +01:00
Leilk Liu
058fe49da3 spi: mediatek: adjust register to enhance time accuracy
this patch adjust register to enhance time accuracy.

Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-13 19:42:31 +01:00
Geert Uytterhoeven
8caab75fd2 spi: Generalize SPI "master" to "controller"
Now struct spi_master is used for both SPI master and slave controllers,
it makes sense to rename it to struct spi_controller, and replace
"master" by "controller" where appropriate.

For now this conversion is done for SPI core infrastructure only.
Wrappers are provided for backwards compatibility, until all SPI drivers
have been converted.

Noteworthy details:
  - SPI_MASTER_GPIO_SS is retained, as it only makes sense for SPI
    master controllers,
  - spi_busnum_to_master() is retained, as it looks up masters only,
  - A new field spi_device.controller is added, but spi_device.master is
    retained for compatibility (both are always initialized by
    spi_alloc_device()),
  - spi_flash_read() is used by SPI masters only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-13 18:51:11 +01:00
Mark Brown
c94085f587 Merge branches 'topic/core', 'topic/slave' and 'fix/doc' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-master 2017-06-13 18:51:05 +01:00
Baruch Siach
6aba9c6564 spi: atmel: print version only after successful registration
Don't print the version at the beginning of atmel_spi_probe(). This avoids
spamming the log whenever a deferred probe runs.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 20:01:45 +01:00
Jarkko Nikula
fc0b2acc75 spi: pxa2xx: Add support for Intel Cannonlake
Intel Cannonlake LPSS SPI has up to four chip selects per port like in
Broxton and is clocked like Sunrisepoint and Kaby Lake. Add a new type
LPSS_CNL_SSP and configuration that enable runtime chip select detection
and use the same FIFO thresholds than in Sunrisepoint.

Patch adds support for both Cannonlake SoC and PCH.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 20:01:15 +01:00
Sascha Hauer
2e312f6cdb spi: imx: rename 'bpw' variables
'bpw' is ambiguous and only the context makes sure if bytes_per_word
or bits_per_word is meant. Use the full names instead to make reading
the code easier.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:48:23 +01:00
Sascha Hauer
65017ee2cd spi: imx: remove bytes_per_word from private driver struct
We already have bits_per_word in the private driver struct and
bytes_per_word can be calculated from it, so remove bits_per_word.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:48:23 +01:00
Sascha Hauer
d6be7d1db5 spi: imx: drop bogus unnecessary dma config
It's unnecessary to call spi_imx_dma_configure() from probe(). It will
be called later anyway again when an actual DMA transfer is prepared.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:48:23 +01:00
Sascha Hauer
d52345b6cf spi: imx: put struct spi_imx_config members into driver private struct
struct spi_imx_config used to hold data specific to the current
transfer. However, other data is in the drivers private data struct.
Let's drop struct spi_imx_config and put the variables into the
drivers private data struct aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:48:23 +01:00
Sascha Hauer
494f3193bd spi: imx: Drop unnecessary check
__spi_validate makes sure that every transfer has a valid bits_per_word
and speed_hz setting. We do not need to fallback to values from the
spi_device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:48:23 +01:00
Sascha Hauer
abb1ff195a spi: imx: Nothing to do in setupxfer when transfer is NULL
When the spi_transfer given in spi_imx_setupxfer is NULL then
we have nothing to do. Bail out early in this case so that
we do not have to test for t != NULL multiple times later.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:48:22 +01:00
Arvind Yadav
35fc3b9ff6 spi: davinci: Handle return value of clk_prepare_enable
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:36:45 +01:00
Arvind Yadav
2b747a5f04 spi: davinci: Fix compilation warning.
If CONFIG_OF is disable, it'll through compilation warning.

drivers/spi/spi-davinci.c: In function ‘spi_davinci_get_pdata’:
drivers/spi/spi-davinci.c:880:2: warning: return makes pointer from integer without a cast [enabled by default]
  return -ENODEV;

drivers/spi/spi-davinci.c: In function ‘davinci_spi_probe’:
drivers/spi/spi-davinci.c:919:7: warning: assignment makes integer from pointer without a cast [enabled by default]
   ret = spi_davinci_get_pdata(pdev, dspi);

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Changes in v2:
             Add fix for both the warning.
Changes in v1:
             It has fix for first warning.
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 19:31:07 +01:00
Geert Uytterhoeven
ce70e06c09 spi: slave: Add SPI slave handler controlling system state
Add an example SPI slave handler to allow remote control of system
reboot, power off, halt, and suspend.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 13:12:19 +01:00
Geert Uytterhoeven
29f9ffa0e1 spi: slave: Add SPI slave handler reporting uptime at previous message
Add an example SPI slave handler responding with the uptime at the time
of reception of the last SPI message.

This can be used by an external microcontroller as a dead man's switch.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 13:12:04 +01:00
Hisashi Nakamura
cf9e4784f3 spi: sh-msiof: Add slave mode support
Add slave mode support to the MSIOF driver, in both PIO and DMA mode.

For now this only supports the transmission of messages with a size
that is known in advance.

Signed-off-by: Hisashi Nakamura <hisashi.nakamura.ak@renesas.com>
Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
[geert: Timeout handling cleanup, spi core integration, cancellation,
	rewording]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 13:11:54 +01:00
Geert Uytterhoeven
6c364062bf spi: core: Add support for registering SPI slave controllers
Add support for registering SPI slave controllers using the existing SPI
master framework:
  - SPI slave controllers must use spi_alloc_slave() instead of
    spi_alloc_master(), and should provide an additional callback
    "slave_abort" to abort an ongoing SPI transfer request,
  - SPI slave controllers are added to a new "spi_slave" device class,
  - SPI slave handlers can be bound to the SPI slave device represented
    by an SPI slave controller using a DT child node named "slave",
  - Alternatively, (un)binding an SPI slave handler to the SPI slave
    device represented by an SPI slave controller can be done by
    (un)registering the slave device through a sysfs virtual file named
    "slave".

From the point of view of an SPI slave protocol handler, an SPI slave
controller looks almost like an ordinary SPI master controller. The only
exception is that a transfer request will block on the remote SPI
master, and may be cancelled using spi_slave_abort().

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 13:11:00 +01:00
Chris Packham
0b0cda4102 spi: st-ssc4: whitespace cleanup
Remove stray single spaces after a leading hard-tab.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 12:41:07 +01:00
Colin Ian King
ad7449969d spi: omap2-mcspi: remove redundant check for error status
The check to see if status is less than zero is actually redundant
as all previous places where it is -ve have already branched to the
exit paths, so it is never less than zero at the check.

Detected by CoverityScan, CID#1357119 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 12:40:11 +01:00
Neil Armstrong
454fa271bc spi: Add Meson SPICC driver
The SPICC hardware block on the Amlogic SoCs is Communication oriented and
can do Full-Duplex 8- to 32-bit width SPI transfers up to 30MHz.

The current driver only supportd the PIO transfer mode since the DMA seems
broken on available hardware.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-24 18:19:25 +01:00
Chris Packham
b28b9149b3 spi: orion: Handle GPIO chip-selects
Some hardware designs use GPIOs to add (or supplement) the SPI
chip-select so that more than one SPI slave device can be used.

For this to work with the spi-orion driver the SPI_MASTER_GPIO_SS flag
needs to be set (because the other outputs are gated internally by the
CS) and the correct chip-select (in this case CS0) needs to be driven by
the controller.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-24 18:02:43 +01:00
Sascha Hauer
09b3ed2d59 spi: imx: Revert "spi: imx: dynamic burst length adjust for PIO mode"
This reverts commits 8d4a6cad7a and
179547e143.

Besides the problems already found with this patch it also modifies
the spi transfer tx_buf in spi_imx_u32_swap_u8() and spi_imx_u32_swap_u16().
This is hidden from the compiler with an explicit cast from const void*
to u32*, so no warning is issued.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-23 19:22:08 +01:00
Nikita Yushchenko
cddebdd19c spi: spi-fsl-dspi: ensure non-zero return on error path
Propagate error return from dspi_request_dma() into probe routine's
return.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-22 16:14:22 +01:00
Jiada Wang
179547e143 spi: imx: fix issue when tx_buf or rx_buf is NULL
In case either transfer->tx_buf or transfer->rx_buf is NULL,
manipulation of buffer in spi_imx_u32_swap_u[8|16]() will cause
NULL pointer dereference crash.

Add buffer check at very beginning of spi_imx_u32_swap_u[8|16](),
to avoid such crash.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Reported-by: Leonard Crestez <leonard.crestez@nxp.com>
Tested-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-19 17:57:08 +01:00
Jiada Wang
8d4a6cad7a spi: imx: dynamic burst length adjust for PIO mode
previously burst length (BURST_LENGTH) is always set to equal
to bits_per_word, causes a 10us gap between each word in
transfer, which significantly affects performance.

This patch uses 32 bits transfer to simulate lower bits transfer,
and adjusts burst length runtimely to use biggeest burst length
as possible to reduce the gaps in transfer for PIO mode.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 19:06:33 +09:00
Andres Galacho
0b85a84217 spi: bcm63xx-hsspi: Export OF device ID table as module aliases
The device table is required to load modules based on
modaliases. After adding MODULE_DEVICE_TABLE, below entries
for example will be added to module.alias:
alias:          of:N*T*Cbrcm,bcm6328-hsspiC*
alias:          of:N*T*Cbrcm,bcm6328-hsspi

Signed-off-by: Andres Galacho <andresgalacho@gmail.com>
Acked-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 19:01:38 +09:00
Geert Uytterhoeven
967d6941f4 spi: SPI_TI_QSPI should depend on HAS_DMA
If NO_DMA=y:

    ERROR: "bad_dma_ops" [drivers/spi/spi-ti-qspi.ko] undefined!

Add a dependency on HAS_DMA to fix this.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 18:49:55 +09:00
Geert Uytterhoeven
ad25c92ecb spi: core: Replace S_IRUGO permissions by 0444
Octal permissions are preferred over symbolic permissions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 18:48:10 +09:00
Geert Uytterhoeven
b56ffae899 spi: core: Fix devm_spi_register_master() function name in kerneldoc
Fixes: 666d5b4c74 ("spi: core: Add devm_spi_register_master()")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 18:47:48 +09:00
Geliang Tang
f7929436a2 spi: spidev: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 18:38:05 +09:00
Seraphime Kirkovski
76bf569466 spi: spidev: remove unused completion
This removes an unused completion from spidev_sync.

It was introduced in

	commit 25d5cb4b03 ("spi: remove some spidev oops-on-rmmod paths")

and it was no longer used after:

	commit 98d6f47958 ("spi: spidev: use spi_sync instead of spi_async")

Signed-off-by: Seraphime Kirkovski (Haapie) <kirkseraph@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-14 18:37:31 +09:00
Mark Brown
282ec0ea65 Merge remote-tracking branches 'spi/topic/ti-qspi' and 'spi/topic/xlp' into spi-next 2017-04-26 15:58:22 +01:00
Mark Brown
d8f520727f Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/spidev-test', 'spi/topic/sunxi', 'spi/topic/tegra' and 'spi/topic/test' into spi-next 2017-04-26 15:58:16 +01:00
Mark Brown
fbdd1b2aff Merge remote-tracking branches 'spi/topic/loopback', 'spi/topic/omap2-mcspi', 'spi/topic/orion', 'spi/topic/pl022' and 'spi/topic/sc18is602' into spi-next 2017-04-26 15:58:10 +01:00
Mark Brown
a2d5eda072 Merge remote-tracking branches 'spi/topic/devprop', 'spi/topic/fsl', 'spi/topic/fsl-dspi', 'spi/topic/imx' and 'spi/topic/lantiq' into spi-next 2017-04-26 15:58:04 +01:00
Mark Brown
2536374352 Merge remote-tracking branches 'spi/topic/atmel', 'spi/topic/bcm63xx', 'spi/topic/cadence' and 'spi/topic/davinci' into spi-next 2017-04-26 15:57:59 +01:00
Mark Brown
42b1eadf4e Merge remote-tracking branch 'spi/topic/core' into spi-next 2017-04-26 15:57:58 +01:00
Mark Brown
fbf3d36cb4 Merge remote-tracking branches 'spi/fix/dw', 'spi/fix/lantiq' and 'spi/fix/pl022' into spi-linus 2017-04-26 15:57:52 +01:00
Moritz Fischer
b42a33bd93 spi: cadence: Allow for GPIO pins to be used as chipselects
This adds support for using GPIOs for chipselects as described by the
default dt-bindings.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-26 15:23:45 +01:00
Leif Middelschulte
f72efa7e69 spi-imx: Implements handling of the SPI_READY mode flag.
This patch implements consideration of the SPI_READY mode flag as
defined in spi.h. It extends the device tree bindings to support
the values defined by the reference manual for the DRCTL field.

Thus supporting edge-triggered and level-triggered bursts.

Signed-off-by: Leif Middelschulte <Leif.Middelschulte@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-25 16:37:53 +01:00
Colin Ian King
bfca76185d spi: tegra: fix spelling mistake: "trasfer" -> "transfer"
trivial fix to spelling mistake in dbg_err messages

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-24 18:44:28 +01:00
Vignesh R
c687c46e9e spi: spi-ti-qspi: Use bounce buffer if read buffer is not DMA'ble
Flash filesystems like JFFS2, UBIFS and MTD block layer can provide
vmalloc'd or kmap'd buffers that cannot be mapped using dma_map_sg() and
can potentially be in memory region above 32bit addressable region(ie
buffers belonging to memory region backed by LPAE) of DMA, implement
spi_flash_can_dma() interface to inform SPI core not to map such
buffers.
When buffers are not mapped for DMA, then use a pre allocated bounce
buffer(64K = typical flash erase sector size) to read from flash and
then do a copy to actual destination buffer. This is approach is much
faster than using memcpy using CPU and also reduces CPU load.

With this patch, UBIFS read speed is ~18MB/s and CPU utilization <20% on
DRA74 Rev H EVM. Performance degradation is negligible when compared
with non bounce buffer case while using UBIFS.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 18:03:53 +01:00
Vignesh R
2bca34455b spi: Add can_dma like interface for spi_flash_read
Add an interface analogous to ->can_dma() for spi_flash_read()
interface. This will enable SPI controller drivers to inform SPI core
when not to do DMA mappings.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 18:03:53 +01:00
Marek Vasut
400c18e3dc spi: dw: Disable clock after unregistering the host
The dw_mmio driver disables the block clock before unregistering
the host. The code unregistering the host may access the SPI block
registers. If register access happens with block clock disabled,
this may lead to a bus hang. Disable the clock after unregistering
the host to prevent such situation.

This bug was observed on Altera Cyclone V SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 19:16:49 +01:00
Hauke Mehrtens
833bfade96 spi: double time out tolerance
The generic SPI code calculates how long the issued transfer would take
and adds 100ms in addition to the timeout as tolerance. On my 500 MHz
Lantiq Mips SoC I am getting timeouts from the SPI like this when the
system boots up:

m25p80 spi32766.4: SPI transfer timed out
blk_update_request: I/O error, dev mtdblock3, sector 2
SQUASHFS error: squashfs_read_data failed to read block 0x6e

After increasing the tolerance for the timeout to 200ms I haven't seen
these SPI transfer time outs any more.
The Lantiq SPI driver in use here has an extra work queue in between,
which gets triggered when the controller send the last word and the
hardware FIFOs used for reading and writing are only 8 words long.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:57:51 +01:00
Quentin Schulz
e53800787a spi: atmel: add deepest PM support to SAMA5D2
This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2
SoC's SPI controller.

When resuming from deepest state, it is required to restore MR register
as the registers are lost since VDD core has been shut down when
entering deepest state on the SAMA5D2.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:50:05 +01:00
Quentin Schulz
05514c8696 spi: atmel: factorize reusable code for SPI controller init
The SPI controller configuration during the init can be reused, for the
resume function for example.

Let's move this configuration to a separate function.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-12 10:47:52 +01:00
Bastian Stender
1017f42401 spi: orion: add LSB support
The orion spi driver currently only supports the normal (i.e. MSB) mode.
This patch adds LSB first mode.

Also correct the comment about supported SPI modes that was left over by
b15d5d7004 ("spi/orion: Add SPI_CHPA and SPI_CPOL support to kirkwood
driver.").

Signed-off-by: Bastian Stender <bst@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-07 18:15:20 +01:00
Rabin Vincent
849794c50b spi: pl022: don't use uninitialized variable
The num-cs property is a required property according to the binding
documentation.  However, if it is not present, the driver currently
simply uses random junk from the stack for the num-cs since the variable
whose pointer is passed to of_property_read_u32() is not initialized.

Signed-off-by: Rabin Vincent <rabinv@axis.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 11:55:22 +01:00
Colin Ian King
905e0b5ef9 spi: loopback-test: fix spelling mistake: "minimam" -> "minimum"
trivial fix to spelling mistake in dev_err error message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-30 11:15:53 +01:00
Vignesh R
cb3c8e5ade spi: spi-ti-qspi: Remove unused dma_dev variable
commit 1351aaeb50 ("spi: spi-ti-qspi: Use dma_engine wrapper for dma
memcpy call") introduced this warning:

drivers/spi/spi-ti-qspi.c: In function 'ti_qspi_dma_xfer':
drivers/spi/spi-ti-qspi.c:398:21: warning: unused variable 'dma_dev' [-Wunused-variable]
  struct dma_device *dma_dev = chan->device;

Fix it by removing the unused variable.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-27 10:56:15 +01:00
Akinobu Mita
812613591c spi: omap2-mcspi: poll OMAP2_MCSPI_CHSTAT_RXS for PIO transfer
When running the spi-loopback-test with slower clock rate like 10 KHz,
the test for 251 bytes transfer was failed.  This failure triggered an
spi-omap2-mcspi's error message "DMA RX last word empty".

This message means that PIO for reading the remaining bytes due to the
DMA transfer length reduction is failed.  This problem can be fixed by
polling OMAP2_MCSPI_CHSTAT_RXS bit in channel status register to wait
until the receive buffer register is filled.

Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-24 18:50:23 +00:00
Vignesh R
1351aaeb50 spi: spi-ti-qspi: Use dma_engine wrapper for dma memcpy call
Instead of calling device_prep_dma_memcpy() directly with dma_device
pointer, use the newly introduced dmaengine_prep_dma_memcpy() wrapper
API.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-24 18:39:53 +00:00
Colin Ian King
d2c14c64d6 spi: loopback-test: fix potential integer overflow on multiple
A multiplication of 8U * xfer-len with the type of a 32 bit unsigned int
is evaluated using 32 bit arithmetic and then used in a context that
expects an expression of type unsigned long long (64 bits).  Avoid any
potential overflow by casting BITS_PER_BYTE to unsigned long long.

Detected by CoverityScan, CID#1419691 ("Unintentional integer overflow")

Fixes: ea9936f324 ("spi: loopback-test: add elapsed time check")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-20 16:11:39 +00:00
Icenowy Zheng
3288d5cb40 spi: sun6i: update max transfer size reported
The spi-sun6i driver have already got the ability to do large transfers.
However, the max transfer size reported is still fifo depth - 1.

Update the max transfer size reported to the max value possible.

Reported-by: Martin Ayotte <martinayotte@gmail.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-20 15:38:51 +00:00
Frode Isaksen
1234e8398f spi: davinci: add comment about dummy tx buffer usage
Add explanation about using the the rx buffer as the
dummy tx buffer.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 22:00:51 +00:00
Akinobu Mita
8687113e15 spi: loopback-test: add test spi_message with delay after transfers
This adds a new test to check whether the spi_transfer.delay_usecs
setting has properly taken effect.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 21:54:12 +00:00
Akinobu Mita
ea9936f324 spi: loopback-test: add elapsed time check
This adds checks whether the elapsed time is longer than the minimam
estimated time.  The estimated time is calculated with the total
transfer length per clock rate and optional spi_transfer.delay_usecs.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 21:54:08 +00:00
Akinobu Mita
0bd7fda56b spi: loopback-test: test zero-length transfer
In order to test various spi_messages including zero-length transfer,
this adds zero length into the iterate_len list.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 21:54:05 +00:00
Akinobu Mita
8916671e93 spi: loopback-test: add ability to test zero-length transfer
The spi-loopback-test module currently cannot test the spi_message
including a zero-length transfer.  Because the zero-length transfer is
treated as a special value in several meanings.

1. The number of spi_transfer to execute in one test case is described
by spi_test.transfer_count.  It is normally computed by counting number
of transfers with len > 0 in spi_test.transfers array.

This change stops the detection for the number of spi_transfer.  Each
spi_test.transfer_count needs to be filled by hand now.

2. The spi_test.iterate_len is a list of transfer length to iterate on.
This list is terminated by zero, so zero-length transfer cannot be
included.

This changes the terminal value from 0 to -1.

3. The length for the spi_transfer masked by spi_test.iterate_transfer_mask
is iterated.  Before starting the iteration, the default value which
is statically initialized is applied.  In order to specify the default
value, zero-length is reserved.

Currently, the default values are always '1'.  So this removes this
trick and add '1' to iterate_len list.

By applying all these changes, the spi-loopback-test can execute spi
messages with zero-length transfer.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 21:54:00 +00:00
Akinobu Mita
8494801db1 spi: loopback-test: don't skip comparing the first byte of rx_buf
When the loopback parameter is set, rx_buf are compared with tx_buf
after the spi_message is executed.  But the first byte of buffer is
not checked.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 21:53:56 +00:00
Akinobu Mita
c4e121aeb7 spi: loopback-test: correct mismatched test description and configuration
The test "two tx-transfers - alter first" actually alters the second
not the first transfer.  Similarly the test "two tx-transfers - alter
second" actually alters the first not the second transfer.

The mismatches for the two symmetrical tests cancel each other's
mistakes.  But it's better to fix the mismatches to avoid confusion.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 21:53:53 +00:00
Frode Isaksen
e542f7e63c spi: loopback-test: fix compile error on x86
Fix compile error caused by missing vmalloc() definition
on x86 (and maybe other platforms) by including vmalloc.h.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-17 13:06:12 +00:00
Ben Whitten
91b4634632 spi: spidev: Add sx1301 to device tree compatibility list
Add entry for the semtech sx1301 baseband processor implementing a LoRa
concentrator IP.
At this time this chip requires an spidev userspace driver.

Signed-off-by: Ben Whitten <ben.whitten@lairdtech.com>
Signed-off-by: Steve deRosier <derosier@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-16 11:14:27 +00:00
Frode Isaksen
576333a1fb spi: loopback-test: add option to use vmalloc'ed buffers
Using vmalloc'ed buffers will use one SG entry for each page,
that may provoke DMA errors for large transfers.
Also vmalloc'ed buffers may cause errors on CPU's with VIVT cache.
Add this option to catch these errors when testing.
Note that to catch VIVT cache errors, checking the rx range
has to be disabled, so this option has been added as well.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-15 19:35:53 +00:00
Frode Isaksen
4dd9becbce spi: davinci: do not use DMA for vmalloc'ed buffers
Using vmalloc'ed buffers will fail since daVinci has
VIVT cache and only the kernel lowmem virtual address
is invalidated/flushed when performing DMA.
The virtual address returned from vmalloc() is not
invalidated/flushed and may contain stale data when
returning from spi_sync().
Fixes errors when running UBIFS over SPI NOR.
Revert this when all upper layer users of vmalloc'ed
buffers sent to SPI handles cache flushing/invalidating.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-15 19:35:39 +00:00
Frode Isaksen
0718b76488 spi: davinci: do not use DMA if transfer length is less than 16
Higher bitrate and lower CPU load if using PIO in this case.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-15 19:35:39 +00:00
Frode Isaksen
6b3a631e7f spi: davinci: use rx buffer as dummy tx buffer
When doing rx-only transfer, the transfer will fail
if the number of SG entries exceeds 20.
This happens because the eDMA DMA engine is limited
to 20 SG entries in one transaction, and when the
DMA transcation is resumed (which takes > 150us),
rx errors occurs because the slave is still transmitting.
Fix this by using the rx buffer as the dummy tx buffer,
so that resuming the rx transcation happens at the same
time as resuming the tx transcation.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-15 19:35:39 +00:00
Jayachandran C
251831bd4f spi: xlp: update for ARCH_VULCAN2
ARCH_VULCAN arm64 platform (for Broadcom Vulcan ARM64 processors) has
been discontinued. Cavium's ThunderX2 CN99XX (ARCH_THUNDER2) will be
the next revision of the platform.

Update compile dependencies and ACPI ID to reflect this change. There
is not need to retain ARCH_VULCAN since the Vulcan processor was never
in production and ARCH_VULCAN will be deleted soon.

Signed-off-by: Jayachandran C <jnair@caviumnetworks.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-13 16:48:40 +00:00
Liu Xiang
500a32abaf spi: fsl: Call irq_dispose_mapping in err path
Irq_dispose_mapping should be called in err path to release
the resources that irq_of_parse_and_map requested.

Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-13 16:16:08 +00:00
Jonas Gorski
7ab2463550 spi/bcm63xx-hsspi: allow for probing through devicetree
Add required binding support to probe through device tree.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-13 15:51:50 +00:00
Jonas Gorski
ff18e1ef04 spi/bcm63xx-hsspi: allow providing clock rate through a second clock
The HSSPI block actually has two clock inputs, one for gating the block,
and one for the PLL rate. To allow these to be represented as two clocks,
add support for retrieving the rate from a separate "pll" clock, if the
"hsspi" clock does not provide one.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-13 15:51:10 +00:00
Fabien Parent
3e2e125844 spi: davinci: enable DMA when channels are defined in DT
When booting with DT the SPI driver is always using
the SPI_IO_TYPE_INTR mode to transfer data even if DMA channels are
defined in the DT.

This commit changes the behaviour to select the SPI_IO_TYPE_DMA mode
if DMA channels are defined in the DT and will keep SPI_IO_TYPE_INTR
if the channels are not defined in it.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-07 15:10:25 +01:00
Fabien Parent
8aedbf580d spi: davinci: Use SPI framework to handle DMA mapping
Uppers layers like MTD can pass vmalloc'd buffers to the SPI driver,
and the current implementation will fail to map these kind of buffers.
The SPI framework is able to detect the best way to handle and map
buffers.
This commit updates the davinci SPI driver in order to use the SPI
framework to handle the DMA mapping of buffers coming from an upper
layer.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-07 15:10:25 +01:00
Icenowy Zheng
913f536c6c spi: sun6i: Allow transfers larger than FIFO size
The spi-sun6i driver have the same problem that spi-sun4i used to have
-- SPI transfers are limited to one FIFO depth.

This commit fixes this problem in the same way it's fixed in spi-sun4i.
See commit 196737912d ("spi: sun4i: Allow transfers larger than FIFO size")
for more information.

The sun6i SPI controllers features changeable interrupt trigger level, but I
set it to 3/4 of fifo depth, as same as the the sun4i SPI controllers.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-07 13:10:39 +01:00
Dmitry Torokhov
f974cf57b1 spi: allow registering empty spi_board_info lists
Many boards form list of spi_board_info entries depending on config,
and it is possible to end up with empty list. Do not report error
in such cases.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-06 11:38:04 +01:00
Dmitry Torokhov
826cf175ed spi: allow attaching device properties to SPI board info
Generic device properties support statically defined property sets. For
them to be usable, we need to attach these property sets before devices
are registered and probed. Allowing to attach property list to
spi_board_info structure will allow non-ACPI non-DT boards switch to using
generic properties and get rid of custom platform data.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-06 11:38:03 +01:00
Ingo Molnar
ae7e81c077 sched/headers: Prepare for new header dependencies before moving code to <uapi/linux/sched/types.h>
We are going to move scheduler ABI details to <uapi/linux/sched/types.h>,
which will be used from a number of .c files.

Create empty placeholder header that maps to <linux/types.h>.

Include the new header in the files that are going to need it.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-03-02 08:42:27 +01:00
Hauke Mehrtens
ad2fca0721 spi: lantiq-ssc: add LTQ_ prefix to defines
The blackfin architecture has a SPI_STAT define which conflicts with
the define from the spi-lantiq-ssc driver in compile test mode. Fix
this by adding a prefix in front of every define.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-01 11:43:03 +00:00
Javier Martinez Canillas
68c97b92c0 spi: sc18is602: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-22 10:50:09 -08:00
Jonas Gorski
ccd0657c33 spi/bcm63xx: fix typo in bcm63xx_spi_max_length breaking compilation
Fix compilation by renaming argument dev to spi as expected by the code.

Fixes the following error:

drivers/spi/spi-bcm63xx.c: In function ‘bcm63xx_spi_max_length’:
drivers/spi/spi-bcm63xx.c:434:50: error: ‘spi’ undeclared (first use in this function)
  struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
                                                  ^~~

Fixes: 0135c03df9 ("spi/bcm63xx: make spi subsystem aware of message size limits")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-21 16:25:48 -08:00
Jonas Gorski
c29f08890a spi/bcm63xx: allow for probing through devicetree
Add required binding support to probe through device tree.

Use the compatible instead of the resource size for identifiying the
block type, and allow reducing the number of cs lines through OF.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-21 15:04:14 -08:00
Jonas Gorski
0135c03df9 spi/bcm63xx: make spi subsystem aware of message size limits
The bcm63xx SPI controller does not allow manual control of the CS
lines and will toggle it automatically before and after sending data,
so we are limited to messages that fit in the FIFO buffer. Since the CS
lines aren't available as GPIOs either, we will need to make slave
drivers aware of this limitation so they can handle them accordingly.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-21 09:50:50 -08:00
kbuild test robot
a5b0443c9b spi: lantiq-ssc: fix platform_no_drv_owner.cocci warnings
drivers/spi/spi-lantiq-ssc.c:973:3-8: No need to set .owner here. The core will do it.

 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-21 09:49:58 -08:00
Linus Torvalds
43e31e4047 ACPI updates for v4.11-rc1
- Update of the ACPICA code in the kernel to upstream revision
    20170119 including:
    * Fixes related to the handling of the bit width and bit offset
      fields in Generic Address Structure (Lv Zheng).
    * ACPI resources handling fix related to invalid resource
      descriptors (Bob Moore).
    * Fix to enable implicit result conversion for several ASL
      library functions (Bob Moore).
    * Support for method invocations as target operands in AML
      (Bob Moore).
    * Fix to use a correct operand type for DeRefOf() in some
      situations (Bob Moore).
    * Utilities updates (Bob Moore, Lv Zheng).
    * Disassembler/debugger updates (David Box, Lv Zheng).
    * Build fixes (Colin Ian King, Lv Zheng).
    * Update of copyright notices in all files (Bob Moore).
 
  - Fix for modalias handling for SPI and I2C devices with
    DT-compatible identification strings (Dan O'Donovan).
 
  - Fixes for the ACPI EC and button drivers (Lv Zheng).
 
  - ACPI processor handling fix related to CPU hotplug (online/offline)
    on x86 (Vitaly Kuznetsov).
 
  - Suspend quirk to save/restore NVS memory over S3 transitions for
    Lenovo G50-45 (Zhang Rui).
 
  - Message formatting fix for the ACPI APEI code (Colin Ian King).
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJYq3J5AAoJEILEb/54YlRx9UcP/0434BwmytZkmo5vKGtmzyuE
 G4RoVNgCegq6BX8KxbML6UHHb+z7XlSHgH3mTU+Csin3OOQ4w3rgDyhwUEK2mWBO
 5bU1hwHRZfy4cpPGrAVDdAXSARJRaRBrl4Y8nZx2SD34WCVzMZJVEvBPPkjVFJP0
 1XQuGvteORcuOD5Sc1XfEStsJUVo5Uim9IaF0tHrdXhkrlsNWgMTIxt9TIKdUOJ0
 JtPK/qNQz5xK4DYo5ny9yLEAxhUFmHoQZzRLWST27eeIxtSZLAErk/Jp64sSQ1uK
 tsHD++7PrjfniHxp+uVPZKi3BexM1CyvQ7sv/amQILgH4cUhWBx7kNZtb85muwWw
 OlgkFZino19oKmdu0w/1KgLAQ71PDo+oMcc+yR1PFWwGhaYR3n/MEsjmQI8/VvcA
 PrCOOrsrW4CNZGf6nN9xunsXMMXacWMdQBV0TspXRRmtFnXdSixp7AurJl8UFg7u
 7j8vUgn2HVOIvEnBxVQCOFT2nZLyEzRL+gXNjWxGs3WJsUlYGKjD7f/SGgo3ztQh
 4VxX0aXWk1vSQ/X1sszhF4GWHIgeeYYY06gvH0cXImRZhI5X0hrLuJrNt5vxoP+u
 RzsXGuHZ5VA0YxEHOPq/o7EmG1va0JnbuyGFvdR3QUOsqIG1Z/+5DZzdJybm0chq
 E+/X0juoMuY/ZB0BXi6t
 =aJJ+
 -----END PGP SIGNATURE-----

Merge tag 'acpi-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These update the ACPICA code in the kernel to upstream revision
  20170119, which among other things updates copyright notices in all of
  the ACPICA files, fix a couple of issues in the ACPI EC and button
  drivers, fix modalias handling for non-discoverable devices with
  DT-compatible identification strings, add a suspend quirk for one
  platform and fix a message in the APEI code.

  Specifics:

   - Update of the ACPICA code in the kernel to upstream revision
     20170119 including:

      + Fixes related to the handling of the bit width and bit offset
        fields in Generic Address Structure (Lv Zheng)
      + ACPI resources handling fix related to invalid resource
        descriptors (Bob Moore)
      + Fix to enable implicit result conversion for several ASL library
        functions (Bob Moore)
      + Support for method invocations as target operands in AML (Bob
        Moore)
      + Fix to use a correct operand type for DeRefOf() in some
        situations (Bob Moore)
      + Utilities updates (Bob Moore, Lv Zheng)
      + Disassembler/debugger updates (David Box, Lv Zheng)
      + Build fixes (Colin Ian King, Lv Zheng)
      + Update of copyright notices in all files (Bob Moore)

   - Fix for modalias handling for SPI and I2C devices with
     DT-compatible identification strings (Dan O'Donovan)

   - Fixes for the ACPI EC and button drivers (Lv Zheng)

   - ACPI processor handling fix related to CPU hotplug (online/offline)
     on x86 (Vitaly Kuznetsov)

   - Suspend quirk to save/restore NVS memory over S3 transitions for
     Lenovo G50-45 (Zhang Rui)

   - Message formatting fix for the ACPI APEI code (Colin Ian King)"

* tag 'acpi-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (32 commits)
  ACPICA: Update version to 20170119
  ACPICA: Tools: Update common signon, remove compilation bit width
  ACPICA: Source tree: Update copyright notices to 2017
  ACPICA: Linuxize: Restore and fix Intel compiler build
  x86/ACPI: keep x86_cpu_to_acpiid mapping valid on CPU hotplug
  spi: acpi: Initialize modalias from of_compatible
  i2c: acpi: Initialize info.type from of_compatible
  ACPI / bus: Introduce acpi_of_modalias() equiv of of_modalias_node()
  ACPI: save NVS memory for Lenovo G50-45
  ACPI, APEI, EINJ: fix malformed newline escape
  ACPI / button: Remove lid_init_state=method mode
  ACPI / button: Change default behavior to lid_init_state=open
  ACPI / EC: Use busy polling mode when GPE is not enabled
  ACPI / EC: Remove old CLEAR_ON_RESUME quirk
  ACPICA: Update version to 20161222
  ACPICA: Parser: Update parse info table for some operators
  ACPICA: Fix a problem with recent extra support for control method invocations
  ACPICA: Parser: Allow method invocations as target operands
  ACPICA: Fix for implicit result conversion for the ToXXX functions
  ACPICA: Resources: Not a valid resource if buffer length too long
  ..
2017-02-20 17:55:15 -08:00
Linus Torvalds
85adbcd54f spi: Updates for v4.11
This release is mainly a collection of driver specific updates,
 including a few nice cleanups to make drivers use more core features.
 There
 
  - Automatically use the parent device to allocate DMA buffers if there
    wasn't an explicitly configured device.
  - Fixes for leaks on allocation.
  - A small piece of the start of SPI slave support, a feature that's
    been on the cards for over a decade!
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCAAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlirQToTHGJyb29uaWVA
 a2VybmVsLm9yZwAKCRAk1otyXVSH0F4oB/9MfUcxiuQtwKP7SCTx5w0IY3/VjCmp
 10tX7rV3pPVqiHJF7Oo/c6NZywLTbV028CIHzjsfH7onvYkFIKAMKbqSUQ37HNhr
 hGlber6qgu7qNwHQgQc2AgCaW8GsbGSmMgX7RXCYZTSyjogxdYPpQVasIM2r9Z19
 H7ov7DE3PSrRuRBjI+yfygjDHOSagLQqQRQYSdQCAExtRFd4saeprTNm2M4BB5DS
 PWuPwj4tGEi1pUg1j45pn92GHzKyuIi215lwQ0bxxSzINP3IRklJMzMhVHAxDVbi
 MQQZ2v/8bhLQBaWkht5W15ohhJn/ceRwyWPm+e+mCucNB1eB3+z2uf7H
 =PNTT
 -----END PGP SIGNATURE-----

Merge tag 'spi-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "This release is mainly a collection of driver specific updates,
  including a few nice cleanups to make drivers use more core features.

   - automatically use the parent device to allocate DMA buffers if
     there wasn't an explicitly configured device.

   - fixes for leaks on allocation.

   - a small piece of the start of SPI slave support, a feature that's
     been on the cards for over a decade!"

* tag 'spi-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (55 commits)
  spi: spi-ti-qspi: Fix error handling
  spi: spi-ti-qspi: Fix error handling
  spi: lantiq-ssc: activate under COMPILE_TEST
  spi: armada-3700: Remove spi_master_put in a3700_spi_remove()
  spi: ti-qspi: revise ti_qspi_probe() failure flow
  spi: spi-ep93xx: simplify GPIO chip selects
  spi: rspi: Replaces "n" by "len" in qspi_transfer_*()
  spi: rspi: Fixes bogus received byte in qspi_transfer_in()
  spi: bcm-qspi: Remove unnecessary platform_set_drvdata()
  spi: bcm-qspi: Fix bcm_qspi_bspi_read() performance
  spi: lantiq-ssc: add support for Lantiq SSC SPI controller
  spi: s3c64xx: fix inconsistency between binding and driver
  spi: armada-3700: Remove .owner field for driver
  spi: bcm-qspi: Added mspi read fallback in bcm_qspi_flash_read()
  spi: fix device-node leaks
  spi: mediatek: Only do dma for 4-byte aligned buffers
  spi: When no dma_chan map buffers with spi_master's parent
  spi: pca2xx-pci: Allow MSI
  spi: pxa2xx: Prepare for edge-triggered interrupts
  spi: pxa2xx: Add support for Intel Gemini Lake
  ...
2017-02-20 17:26:11 -08:00
Mark Brown
57f22cd29c Merge remote-tracking branches 'spi/topic/ti-qspi' and 'spi/topic/topcliff-pch' into spi-next 2017-02-19 16:41:17 +00:00
Mark Brown
e2a3b0df8d Merge remote-tracking branches 'spi/topic/rockchip', 'spi/topic/rspi', 'spi/topic/s3c64xx', 'spi/topic/sh-msiof' and 'spi/topic/slave' into spi-next 2017-02-19 16:41:05 +00:00
Mark Brown
2016d52a38 Merge remote-tracking branches 'spi/topic/imx', 'spi/topic/lantiq-ssc', 'spi/topic/mpc52xx', 'spi/topic/ppc4xx' and 'spi/topic/pxa2xx' into spi-next 2017-02-19 16:41:01 +00:00
Mark Brown
3470650057 Merge remote-tracking branches 'spi/topic/dw', 'spi/topic/ep93xx', 'spi/topic/falcon' and 'spi/topic/fsl-lpspi' into spi-next 2017-02-19 16:40:59 +00:00
Mark Brown
244a60c28d Merge remote-tracking branches 'spi/topic/armada', 'spi/topic/ath79', 'spi/topic/bcm-qspi' and 'spi/topic/bcm53xx' into spi-next 2017-02-19 16:40:55 +00:00
Mark Brown
3490462378 Merge remote-tracking branch 'spi/topic/dma' into spi-next 2017-02-19 16:40:55 +00:00
Mark Brown
42af2f5c52 Merge remote-tracking branch 'spi/topic/core' into spi-next 2017-02-19 16:40:55 +00:00
Mark Brown
e0afd0facf Merge remote-tracking branches 'spi/fix/pxa2xx', 'spi/fix/rspi' and 'spi/fix/s3c64xx' into spi-linus 2017-02-19 16:40:53 +00:00
Christophe JAILLET
fbad6c2439 spi: spi-fsl-dspi: Fix error handling
According to error handling in this function, it is likely that going to
'out_master_put' was expected here.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-19 16:39:21 +00:00
Christophe JAILLET
7abfe04c47 spi: spi-ti-qspi: Fix error handling
'dma_request_chan_by_mask()' can not return NULL.
Try to keep the logic in 'no_dma:' by resetting 'qspi->rx_chan' in case
of error.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-19 16:27:35 +00:00
Christophe JAILLET
30fb27239f spi: spi-ti-qspi: Fix error handling
'dma_request_chan_by_mask()' can not return NULL.
Try to keep the logic in 'no_dma:' by resetting 'qspi->rx_chan' in case
of error.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-19 16:11:56 +00:00
Hauke Mehrtens
582c97f686 spi: lantiq-ssc: activate under COMPILE_TEST
This driver should compile on all platforms, activate it under compile
test. The Lantiq specific parts are under ifdef and should be removed
when Lantiq platform supports common clock framework.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-19 16:11:01 +00:00
Wei Yongjun
e92f0051c0 spi: armada-3700: Remove spi_master_put in a3700_spi_remove()
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: 5762ab71eb ("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-19 16:10:44 +00:00
Prahlad V
cce59c2259 spi: ti-qspi: revise ti_qspi_probe() failure flow
call spi_master_put() in case of failures after spi_alloc_master().
call pm_runtime_disable() in case of failures after pm_runtime_enable().

Signed-off-by: Prahlad V <prahlad.eee@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-17 11:24:51 +00:00
H Hartley Sweeten
55f0cd3fb9 spi: spi-ep93xx: simplify GPIO chip selects
This driver requires a GPIO line to be used for the chip select of
each SPI device.

Remove the ep93xx_spi_chip_ops definition from the platform data
and use the spi core GPIO handling for the chip selects.

Fix all the ep93xx platforms that use this driver and remove the
old Documentation.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-16 20:10:26 +00:00
DongCV
ad16d4a83d spi: rspi: Replaces "n" by "len" in qspi_transfer_*()
This patch replaced "n" by "len" bytes of data in qspi_transfer_in() and
qspi_transfer_out() function. This will make improving readability.

Signed-off-by: DongCV <cv-dong@jinso.co.jp>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-16 18:25:27 +00:00
DongCV
7264abc700 spi: rspi: Fixes bogus received byte in qspi_transfer_in()
In qspi_transfer_in(), when receiving the last n (or len) bytes of data,
one bogus byte was written in the receive buffer.
This code leads to a buffer overflow.

"jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found
at 0x03b40000: 0x1900 instead
jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found
at 0x03b40004: 0x000c instead"

The error message above happens when trying to mount, unmount,
and remount a jffs2-formatted device.
This patch removed the bogus write to fixes: 3be09bec42
"spi: rspi: supports 32bytes buffer for DUAL and QUAD"

And here is Geert's comment:

"spi: rspi: Fix bogus received byte in qspi_transfer_in()
When there are less than QSPI_BUFFER_SIZE remaining bytes to be received,
qspi_transfer_in() writes one bogus byte in the receive buffer, possibly
leading to a buffer overflow.
This can be reproduced by mounting, unmounting, and remounting a
jffs2-formatted device, causing lots of warnings like:

"jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found
at 0x03b40000: 0x1900 instead"

Remove the bogus write to fix this. "

Signed-off-by: DongCV <cv-dong@jinso.co.jp>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-16 18:25:21 +00:00
Wei Yongjun
973f7dd575 spi: bcm-qspi: Remove unnecessary platform_set_drvdata()
The driver core clears the driver data to NULL after device_release
or on probe failure. Thus, it is not needed to manually clear the
device driver data to NULL.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-14 17:59:51 +00:00
Kamal Dasu
345309fa7c spi: bcm-qspi: Fix bcm_qspi_bspi_read() performance
Let bcm_qspi_bspi_flash_read() return all the requested bytes by breaking
up the reads for BSPI block into optimal chunks size that a BSPI block can
handle.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-14 17:59:36 +00:00
Hauke Mehrtens
17f84b793c spi: lantiq-ssc: add support for Lantiq SSC SPI controller
This driver supports the Lantiq SSC SPI controller in master
mode. This controller is found on Intel (former Lantiq) SoCs like
the Danube, Falcon, xRX200, xRX300.

The hardware uses two hardware FIFOs one for received and one for
transferred bytes. When the driver writes data into the transmit FIFO
the complete word is taken from the FIFO into a shift register. The
data from this shift register is then written to the wire. This driver
uses the interrupts signaling the status of the FIFOs and not the shift
register. It is also possible to use the interrupts for the shift
register, but they will send a signal after every word. When using the
interrupts for the shift register we get a signal when the last word is
written into the shift register and not when it is written to the wire.
After all FIFOs are empty the driver busy waits till the hardware is
not busy any more and returns the transfer status.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-14 17:10:40 +00:00
Andi Shyti
379f831a92 spi: s3c64xx: fix inconsistency between binding and driver
Commit a92e7c3d82 ("spi: s3c64xx: consider the case when the CS
line is not connected") introduced an inconsistency between the
binding, where the disconnected CS line was marked as
'no-cs-readback', and the driver.

The driver is erroneously checking for that attribute with
property name of 'broken-cs'.

Check for 'no-cs-readback' in the driver as well.

Fixes: a92e7c3d82 ("spi: s3c64xx: consider the case when the CS line is not connected")
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
2017-02-13 18:47:38 +00:00
Brian Norris
398d8739bb This pull request contains the following notable changes:
- add support to the 4-byte address instruction set.
 - add support to new memory parts.
 - add support to S3AN memories.
 - add support to the Intel SPI controller.
 - add support to the Aspeed AST2400 and AST2550 controllers.
 - fix max SPI transfer and message sizes in m25p80_read().
 - fix the Candence QSPI driver.
 - fix the Freescale QSPI driver.
 -----BEGIN PGP SIGNATURE-----
 
 iQI4BAABCAAiBQJYncJ7GxxjeXJpbGxlLnBpdGNoZW5Ad2VkZXY0dS5mcgAKCRDn
 4OgLHRpJcswfD/0dvIvhI9R9ne/kHUsXbW2tIAIc2vrl/jiEA0O90rinRRjxLyIi
 3EacSYpL8PXAh5diNannIw/DrjK0FiHB34jJ1NwMP7CQbYMbfb1SGwp5nmIP676W
 4iEaSOJDQu76Vbe5L2O4xHUIJoO1l9cr/bZDPXRachBD8H48ZRZUTx0ujff4LbiG
 lEwv1Bk35doTRHgmPErPIB/WOlYdvLaoiCUVe9ME0mEEzCmEjoZorTDwaSBpBAMB
 4Z04Lz06iP1aPFUm2VYvK5xMvkFN4tS+6xzWpUOUYj8Tty1YptYI7mQINa69J2NA
 O8A/elH39Yv1FYvWgrC2SIS/kbHTR/Bxz6napJ0hK3HasLFCwt7Eq2w/XBxr/Wn9
 +02buij0PWKywJfuj7tOiAId5IJW0hhEit2BcBFihwsiDDxix679beQoCZ/WRuW/
 kJmR+NLRNByVyKCOP239VobiYWjy8DhDTpH5XGwI7bPTiJuS6G6MCVH3f0tYnFTo
 8J3gXp4SH2mw6YzWrL8YtKzFKcLEfXTOGc/GFGQX2URV5Es1/Lw4Nh5lrkbEbVoy
 dc/S57Ftdde/56L4lDDbydn7pAU8FbuX2gSewvJRuFyhCBKSyw2JEoy27T7t50pd
 hN1JvuNYGQ5HP0Vqa/oe1g1GHnBfxiIOm5THX+Iv+3Y0jM1iUDeVeO4DTQ==
 =/fPM
 -----END PGP SIGNATURE-----

Merge tag 'spi-nor/for-4.11-v2' of git://github.com/spi-nor/linux

From Cyrille:

"""
This pull request contains the following notable changes:
- add support to the 4-byte address instruction set.
- add support to new memory parts.
- add support to S3AN memories.
- add support to the Intel SPI controller.
- add support to the Aspeed AST2400 and AST2550 controllers.
- fix max SPI transfer and message sizes in m25p80_read().
- fix the Candence QSPI driver.
- fix the Freescale QSPI driver.
"""
2017-02-10 10:05:51 -08:00
Cyrille Pitchen
902cc69a08 mtd: spi-nor: rename SPINOR_OP_* macros of the 4-byte address op codes
This patch renames the SPINOR_OP_* macros of the 4-byte address
instruction set so the new names all share a common pattern: the 4-byte
address name is built from the 3-byte address name appending the "_4B"
suffix.

The patch also introduces new op codes to support other SPI protocols such
as SPI 1-4-4 and SPI 1-2-2.

This is a transitional patch and will help a later patch of spi-nor.c
to automate the translation from the 3-byte address op codes into their
4-byte address version.

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
2017-02-10 13:55:03 +01:00
Wei Yongjun
d9928b4c48 spi: armada-3700: Remove .owner field for driver
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>
2017-02-09 16:35:26 +00:00
Dan O'Donovan
0c6543f6cd spi: acpi: Initialize modalias from of_compatible
When using devicetree spi_device.modalias is set to the compatible
string with the vendor prefix removed. For SPI devices described via
ACPI the spi_device.modalias string is initialized by acpi_device_hid.
When using ACPI and DT ids this string ends up something like "PRP0001".

Change acpi_register_spi_device to use the of_compatible property if
present. This makes it easier to instantiate spi drivers through ACPI
with DT ids.

Signed-off-by: Dan O'Donovan <dan@emutex.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-02-07 13:31:51 +01:00
Kamal Dasu
81ab52fd94 spi: bcm-qspi: Added mspi read fallback in bcm_qspi_flash_read()
Added mspi read fallback under certain circumstances like unaligned
buffer, address on short reads. Also takes care of version 3.0 spi
controller where flash address crosses 4MB boundary on transfers the
driver resorts to mspi reads.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-31 21:03:44 +00:00
Johan Hovold
8324147f38 spi: fix device-node leaks
Make sure to release the device-node reference taken in
of_register_spi_device() on errors and when deregistering the device.

Fixes: 284b018973 ("spi: Add OF binding support for SPI busses")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-31 21:00:58 +00:00
Daniel Kurtz
1ce24864bf spi: mediatek: Only do dma for 4-byte aligned buffers
Mediatek SPI DMA only works when tx and rx buffer addresses are 4-byte
aligned.

Unaligned DMA transactions appeared to work previously, since we the
spi core was incorrectly using the spi_master device for dma, which
had a 0 dma_mask, and therefore the swiotlb dma map operations were
falling back to using bounce buffers.  Since each DMA transaction would
use its own buffer, the mapped starting address of each transaction was
always aligned.  When doing real DMA, the mapped address will share the
alignment of the raw tx/rx buffer provided by the SPI user, which may or
may not be aligned.

If a buffer is not aligned, we cannot use DMA, and must use FIFO based
transaction instead.

So, this patch implements a scheme that allows using the FIFO for
arbitrary length transactions (larger than the 32-byte FIFO size) by
reloading the FIFO in the interrupt handler.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Cc: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-31 19:55:38 +00:00
Daniel Kurtz
88b0aa544a spi: When no dma_chan map buffers with spi_master's parent
Back before commit 1dccb598df ("arm64: simplify dma_get_ops"), for
arm64, devices for which dma_ops were not explicitly set were automatically
configured to use swiotlb_dma_ops, since this was hard-coded as the
global "dma_ops" in arm64_dma_init().

Now that global "dma_ops" has been removed, all devices much have their
dma_ops explicitly set by a call to arch_setup_dma_ops(), otherwise the
device is assigned dummy_dma_ops, and thus calls to map_sg for such a
device will fail (return 0).

Mediatek SPI uses DMA but does not use a dma channel.  Support for this
was added by commit c37f45b5f1 ("spi: support spi without dma channel
to use can_dma()"), which uses the master_spi dev to DMA map buffers.

The master_spi device is not a platform device, rather it is created
in spi_alloc_device(), and therefore its dma_ops are never set.

Therefore, when the mediatek SPI driver when it does DMA (for large SPI
transactions > 32 bytes), SPI will use spi_map_buf()->dma_map_sg() to
map the buffer for use in DMA.  But dma_map_sg()->dma_map_sg_attrs() returns
0, because ops->map_sg is dummy_dma_ops->__dummy_map_sg, and hence
spi_map_buf() returns -ENOMEM (-12).

Fix this by using the real spi_master's parent device which should be a
real physical device with DMA properties.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Fixes: c37f45b5f1 ("spi: support spi without dma channel to use can_dma()")
Cc: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-31 19:55:37 +00:00
Jan Kiszka
64e02cb0bd spi: pca2xx-pci: Allow MSI
Now that the core is ready for edge-triggered interrupts, we can safely
allow the PCI versions that provide this to enable the feature and,
thus, have less shared interrupts.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-23 18:09:37 +00:00
Jan Kiszka
e51e9b9304 spi: pxa2xx: Prepare for edge-triggered interrupts
When using the a device with edge-triggered interrupts, such as MSIs,
the interrupt handler has to ensure that there is a point in time during
its execution where all interrupts sources are silent so that a new
event can trigger a new interrupt again.

This is achieved here by disabling all interrupt sources for a moment
before processing them according to the status register. If a new
interrupt should have arrived after we read the status, it will now
re-trigger the interrupt, even in edge mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-23 18:09:37 +00:00
Linus Torvalds
cca112ecf2 spi: Fixes for v4.10
The usual small smattering of driver specific fixes.  A few bits that
 stand out here:
 
  - The R-Car patches adding fallbacks are just adding new compatible
    strings to the driver so that device trees are written in a more
    robustly future proof fashion, this isn't strictly a fix but it's
    just new IDs and it's better to get it into mainline sooner to
    improve the ABI.
  - The DesignWare "switch to new API part 2" patch is actually a
    misleadingly titled fix for a bit that got missed in the original
    conversion.
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCAAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAliA0xcTHGJyb29uaWVA
 a2VybmVsLm9yZwAKCRAk1otyXVSH0O/kB/9XpR63v5Ej1surlHLJdX7GEk1Oaoy9
 CoCHcwBCPfAlLstkVARbvQegdEl3WKZ7FFhIRKhuiW62hVPV8otOv6chyX++zdWo
 sYcLHESyuVDydvFdsoMZOvxP22tUNGom6Dhmsf2sXSbWwV/Q2yFahouhAeMPZJ+c
 kiZ1OUqae6YIL8EIt0fIFiLp1m2vVpXPLYAYr24a6G4P7nrnLwdMfD2+NnbE9YG8
 5zTkFrzh7d7izj3QqGGvW/zMPB7fvP+kY2MdDHx2/lEFjMB4qg/i6C+8bRZGRnWO
 FE3Z++LDQZmKpKcPKZlV53yiX1anEpR3mpKGEGSon9zZlBRZhvYJGZtN
 =EoLd
 -----END PGP SIGNATURE-----

Merge tag 'spi-fix-v4.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
 "The usual small smattering of driver specific fixes. A few bits that
  stand out here:

   - the R-Car patches adding fallbacks are just adding new compatible
     strings to the driver so that device trees are written in a more
     robustly future proof fashion, this isn't strictly a fix but it's
     just new IDs and it's better to get it into mainline sooner to
     improve the ABI

   - the DesignWare "switch to new API part 2" patch is actually a
     misleadingly titled fix for a bit that got missed in the original
     conversion"

* tag 'spi-fix-v4.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
  spi: davinci: use dma_mapping_error()
  spi: spi-axi: Free resources on error path
  spi: pxa2xx: add missed break
  spi: dw-mid: switch to new dmaengine_terminate_* API (part 2)
  spi: dw: Make debugfs name unique between instances
  spi: sh-msiof: Do not use C++ style comment
  spi: armada-3700: Set mode bits correctly
  spi: armada-3700: fix unsigned compare than zero on irq
  spi: sh-msiof: Add R-Car Gen 2 and 3 fallback bindings
  spi: SPI_FSL_DSPI should depend on HAS_DMA
2017-01-20 12:25:11 -08:00
David E. Box
e18a80acd1 spi: pxa2xx: Add support for Intel Gemini Lake
Gemini Lake reuses the same LPSS SPI configuration as Broxton

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-19 14:55:21 +00:00
Mark Brown
52cc720c56 Merge remote-tracking branch 'spi/fix/sh-msiof' into spi-linus 2017-01-17 18:48:13 +00:00
Mark Brown
3f95ba38e4 Merge remote-tracking branches 'spi/fix/armada', 'spi/fix/axi', 'spi/fix/davinci', 'spi/fix/dw', 'spi/fix/fsl-dspi' and 'spi/fix/pxa2xx' into spi-linus 2017-01-17 18:48:11 +00:00
Markus Elfring
45e861a1c1 spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx()
Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:38:02 +00:00
Markus Elfring
b996356d30 spi/topcliff-pch: Combine substrings for four messages
The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:38:02 +00:00
Markus Elfring
baa35f5734 spi/topcliff-pch: Improve size determinations in pch_spi_probe()
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:35:06 +00:00
Markus Elfring
84aa0ba124 spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma()
* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:35:06 +00:00
Markus Elfring
6ceb3b27b1 spi/topcliff-pch: Delete an unnecessary return statement in two functions
The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such statements here.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:35:06 +00:00
Markus Elfring
797236f10a spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe()
* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus reuse the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:34:25 +00:00
Markus Elfring
ffcaef5ac2 spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe()
The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:34:25 +00:00
Markus Elfring
9c4f0440ba spi/mpc52xx: Combine substrings for two messages
The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:28:19 +00:00
Markus Elfring
8b6c8955b5 spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe()
* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:28:18 +00:00
Markus Elfring
31ae779421 spi: fsl: Combine substrings for two messages
The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:27:38 +00:00
Markus Elfring
5223db0b10 spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects()
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus reuse the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:27:38 +00:00
Markus Elfring
d9bc4a8539 spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects()
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:27:38 +00:00
Markus Elfring
f9bdb7fdd2 spi: Use kcalloc() in spi_register_board_info()
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus reuse the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:21:12 +00:00
Jan Kiszka
b03124825b spi: pxa2xx: Factor out handle_bad_msg
As suggested by Andy Shevchenko: Decouple this corner cause from the
general handling logic in ssp_int.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 18:17:20 +00:00
Dan Carpenter
72bc7ae063 spi: s3c64xx: potential oops on probe error
We accidentally mixed up freeing the rx and tx channels which would a
leak and an oops.

Fixes: 3d63a47a38 ("spi: s3c64xx: Don't request/release DMA channels for each SPI transfer")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Andi Shyti <andi.shyti@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-17 17:58:51 +00:00
Kevin Hilman
c5a2a39483 spi: davinci: use dma_mapping_error()
The correct error checking for dma_map_single() is to use
dma_mapping_error().

Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-12 17:24:45 +00:00
Hauke Mehrtens
9c6a3af003 spi: make falcon-spi bool
Falcon spi accesses some ebu functions which are not exported and can
not be accessed when build as module. Make this module bool instead.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Thomas Langer <thomas.langer@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-10 12:26:19 +00:00
Gao Pan
102ecc471b spi: fsl-lpspi: fix indentation error
This patch fixes the indentation error in spi-fsl-lpspi.c.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-09 19:34:02 +00:00
Marek Szyprowski
3d63a47a38 spi: s3c64xx: Don't request/release DMA channels for each SPI transfer
Requesting a DMA channel might be a time consuming operation, so there is
no need to acquire and release DMA channel for each SPI transfer.
DMA channels can be requested during driver probe and kept all the time,
also because there are no shared nor dynamically allocated channels on
Samsung S3C/S5P/Exynos platforms.

While moving dma_requrest_slave_channel calls, lets switch to
dma_request_slave_channel_reason(), which returns error codes on failure,
which can be properly propagated to the caller (this for example defers
SPI probe when DMA controller is not yet available).

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Andi Shyti <andi.shyti@samsung.com>
Tested-by: Andi Shyti <andi.shyti@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-09 12:21:04 +00:00
Phil Reid
e70002c80d spi: dw: Make debugfs use bus num and make irq name unique
Instead of using device name it was suggested that bus number was more
appropriate to differentiate debugfs names. Also reduce buffer size to
more realistic 32 bytes instead of 128.

When request_irq is called the bus number may not be assigned. Therefore
the irq name was not unique when dynamic bus number was being used.
As per most of the spi drivers use the device name instead. No other
use of dws->name could be found so it was removed.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-09 11:22:14 +00:00
Christophe JAILLET
9620ca9011 spi: spi-axi: Free resources on error path
We should go to 'err_put_master' here instead of returning directly.
Otherwise a call to 'spi_master_put' is missing.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-09 11:20:46 +00:00
Rafał Miłecki
e360e72e71 spi: bcm53xx: (re)license code to the GPL v2
My intention was to release this code under GPL v2 license. For some
reason my initial commit 0fc6a323e1 ("spi: bcm53xx: driver for SPI
controller on Broadcom bcma SoC") totally missed licensing info.
MODULE_LICENSE was later added by Axel specifying "GNU Public License
v2 or later".

This patch clarifies situation by adding a proper header (with Copyright
line) and adjusting MODULE_LICENSE. It should be acked by every driver
contributor.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Nicholas Mc Guire <hofrat@osadl.org>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Acked-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-06 18:21:50 +00:00
Jiada Wang
66459c5a50 spi: imx: adjust watermark level according to transfer length
Previously DMA watermark level is configured to fifosize/2,
DMA mode can be used only when transfer length can be divided
by 'watermark level * bpw', which makes DMA mode not pratical.

This patch adjusts watermark level to largest number (no bigger
than fifosize/2) which can divide 'tranfer length / bpw' for
each transfer.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-06 18:09:22 +00:00
Andy Shevchenko
2501452160 spi: pxa2xx-pci: Enable DMA for Intel Merrifield
SPI controller on Intel Merrifield is backed by DMA engine. Add necessary bits
to support it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-04 18:36:41 +00:00
Andy Shevchenko
a2dd8af00c spi: pxa2xx: add missed break
The commit 7c7289a404 ("spi: pxa2xx: Default thresholds to PXA
configuration") while splitting up CE4100 code obviously missed a break
condition in one chunk. Add it here.

Looks like we have no active user of CE4100, though better to fix this later
than never.

Fixes: commit 7c7289a404 ("spi: pxa2xx: Default thresholds to PXA configuration")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-04 18:36:22 +00:00
Geert Uytterhoeven
e7ad4a7336 spi: sh-msiof: Remove useless memory allocation failure message
Printing an error on memory allocation failure is unnecessary.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-04 17:39:37 +00:00
Geert Uytterhoeven
ffcfae3823 spi: rspi: Remove useless memory allocation failure message
Printing an error on memory allocation failure is unnecessary.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-04 17:39:21 +00:00
Andy Shevchenko
cf1716e9da spi: dw-mid: switch to new dmaengine_terminate_* API (part 2)
The commit a3ff958236 ("spi: dw-mid: switch to new dmaengine_terminate_*
API") converted mid_spi_dma_exit() but missed mid_spi_dma_stop().

This is follow up to convert the rest.

Fixes: a3ff958236 ("spi: dw-mid: switch to new dmaengine_terminate_* API")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-04 12:27:00 +00:00
Romain Perier
85798e153e spi: armada-3700: Coding style fixes
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-31 18:53:16 +00:00
Romain Perier
cfd6693c06 spi: armada-3700: Replaced raw values for nbits by the SPI macros
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-31 18:53:16 +00:00
Phil Reid
13288bdf4a spi: dw: Make debugfs name unique between instances
Some system have multiple dw devices. Currently the driver uses a
fixed name for the debugfs dir. Append dev name to the debugfs dir
name to make it unique.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-31 18:51:03 +00:00
Rafał Miłecki
78d759dace spi: bcm53xx: set of_node to let DT specify device(s)
Setting of_node of master's dev seems to be a common way of letting it
work nicely with DT. This allows specifying device there instead of
hardcoding one in the driver code.

This was successfully tested with commit 1b47b98acc ("ARM: BCM5301X:
Add DT entry for SPI controller and NOR flash")

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-31 18:36:53 +00:00
Jaedon Shin
279e4af7b4 spi: bcm-qspi: Enable the driver on BMIPS_GENERIC
The Broadcom BCM7XXX ARM and MIPS based SoCs share a similar hardware
block for SPI.

Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-31 18:22:30 +00:00
Simon Horman
264c3e8de4 spi: sh-msiof: Do not use C++ style comment
4286db8456 ("spi: sh-msiof: Add R-Car Gen 2 and 3 fallback bindings")
added a C++ style comment. This is not in keeping with the style used
for comments elsewhere in this fine. Update it accordingly.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-20 11:40:57 +00:00
Brian Norris
23e291c2e4 spi: rockchip: support "sleep" pin configuration
In the pattern of many other devices, support a system-sleep pin
configuration.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-19 13:29:27 +00:00
Dan Carpenter
42cd4ed888 spi: armada-3700: Set mode bits correctly
We set SPI_RX_DUAL twice instead of setting SPI_TX_DUAL.

Fixes: 5762ab71eb ("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-16 12:28:36 +00:00
Dan Carpenter
0cc059abac spi: armada-3700: Remove unnecessary condition
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-16 12:28:10 +00:00
Geert Uytterhoeven
c2e51ac3d0 spi: core: Extract of_spi_parse_dt()
Extract the parsing of SPI slave-specific properties into its own
function, so it can be reused later for SPI slave controllers.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-15 17:44:23 +00:00
Linus Torvalds
e3842cbfe0 dmaengine updates for 4.10-rc1
Fairly routine update this time around with all changes specific to drivers.
 
  o New driver for STMicroelectronics FDMA
  o Memory-to-memory transfers on dw dmac
  o Support for slave maps on pl08x devices
  o Bunch of driver fixes to use dma_pool_zalloc
  o Bunch of compile and warning fixes spread across drivers
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJYUg7NAAoJEHwUBw8lI4NH5/gP/j81+2RzCUX8PiLQxNUt0Vj+
 tVJEizpWCwN1cnhc8ibZdI1DAwyj+GbN2lghYTjqqEng4yOm3czPzUl99grBrpQl
 t+Qylr9PSpck/paRhd2lgZzG8Nk+B5HJDcxBQbW4pwmbc69YAbqYzt44i4bDpR5K
 u3mBve1Ulng7peP45EZB8BA32ffCpOEAC/9SdkaPokrSv6XxxPEFvzewy+mLtioU
 a0zY0iuHqVGpOTABK65fXO/zkGiZLPXJ1T5vK7Iz8mOwuvtYVif0yktQSrx3BWbc
 9r64W7Si633wWt/C9LkuMMSmQ7nI/PyHk811cDOcxp3SA79JV5SWwdQl+5QPdtoP
 hyToaISfAY0BiNI9ltdscx3MPjlwSp08xXvi46RjSs8E2TXnbHUw+J5mTsxYuocl
 Yi61nlL5ClhCbySf9Q3GFsuAJ3O2Nq9WkCTNRIvJtrMhe3NeqDDTfBZJRD4Bfg1G
 q8RAc5oqGZDtqKHtLfwULr7Ec2Ru0hIZAyN907OwW+4jBR/eBJB1y+nGrNPtTWPT
 OOcvrxe85/+ZNROGCZKr0L8UA/MBBMZtjvMY8RMXjBE4YJbakq7tV+7l5VolKeNH
 G6I/1CC06qVPHrnetM6YejhtnmOQ4F8P1sE0wvpG0QTyHJoFq+aOhHNKJC8F9Eln
 CQM2apvL4BHvS7OHt9XL
 =Pf0d
 -----END PGP SIGNATURE-----

Merge tag 'dmaengine-4.10-rc1' of git://git.infradead.org/users/vkoul/slave-dma

Pull dmaengine updates from Vinod Koul:
 "Fairly routine update this time around with all changes specific to
  drivers:

   - New driver for STMicroelectronics FDMA
   - Memory-to-memory transfers on dw dmac
   - Support for slave maps on pl08x devices
   - Bunch of driver fixes to use dma_pool_zalloc
   - Bunch of compile and warning fixes spread across drivers"

[ The ST FDMA driver already came in earlier through the remoteproc tree ]

* tag 'dmaengine-4.10-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (68 commits)
  dmaengine: sirf-dma: remove unused ‘sdesc’
  dmaengine: pl330: remove unused ‘regs’
  dmaengine: s3c24xx: remove unused ‘cdata’
  dmaengine: stm32-dma: remove unused ‘src_addr’
  dmaengine: stm32-dma: remove unused ‘dst_addr’
  dmaengine: stm32-dma: remove unused ‘sfcr’
  dmaengine: pch_dma: remove unused ‘cookie’
  dmaengine: mic_x100_dma: remove unused ‘data’
  dmaengine: img-mdc: remove unused ‘prev_phys’
  dmaengine: usb-dmac: remove unused ‘uchan’
  dmaengine: ioat: remove unused ‘res’
  dmaengine: ioat: remove unused ‘ioat_dma’
  dmaengine: ioat: remove unused ‘is_raid_device’
  dmaengine: pl330: do not generate unaligned access
  dmaengine: k3dma: move to dma_pool_zalloc
  dmaengine: at_hdmac: move to dma_pool_zalloc
  dmaengine: at_xdmac: don't restore unsaved status
  dmaengine: ioat: set error code on failures
  dmaengine: ioat: set error code on failures
  dmaengine: DW DMAC: add multi-block property to device tree
  ...
2016-12-14 20:42:45 -08:00
Colin Ian King
f6f0083cca spi: armada-3700: fix unsigned compare than zero on irq
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-14 17:38:51 +00:00
Simon Horman
4286db8456 spi: sh-msiof: Add R-Car Gen 2 and 3 fallback bindings
In the case of Renesas R-Car hardware we know that there are generations of
SoCs, e.g. Gen 2 and Gen 3. But beyond that it's not clear what the
relationship between IP blocks might be. For example, I believe that
r8a7790 is older than r8a7791 but that doesn't imply that the latter is a
descendant of the former or vice versa.

We can, however, by examining the documentation and behaviour of the
hardware at run-time observe that the current driver implementation appears
to be compatible with the IP blocks on SoCs within a given generation.

For the above reasons and convenience when enabling new SoCs a
per-generation fallback compatibility string scheme is being adopted for
drivers for Renesas SoCs.

Also:
* Deprecate renesas,sh-msiof. It seems poorly named as it is only
  compatible with SH-Mobile. It also appears unused in mainline.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-14 17:38:18 +00:00
Felix Fietkau
91829a9a25 spi: spi-ath79: use gpio_set_value_cansleep for GPIO chip select
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-14 17:36:57 +00:00
Felix Fietkau
22c76326bf spi: spi-ath79: support multiple internal chip select lines
Several devices with multiple flash chips use the internal chip select
lines. Don't assume that chip select 1 and above are GPIO lines.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-14 17:36:57 +00:00
Geert Uytterhoeven
dadab2d4e3 spi: SPI_FSL_DSPI should depend on HAS_DMA
If NO_DMA=y:

    ERROR: "bad_dma_ops" [drivers/spi/spi-fsl-dspi.ko] undefined!

Add a dependency on HAS_DMA to fix this.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-14 14:37:36 +00:00
Geert Uytterhoeven
cc4a7ffe02 spi: fsl-lpspi: Pre-initialize ret in fsl_lpspi_transfer_one_msg()
With gcc 4.1.2:

    drivers/spi/spi-fsl-lpspi.c: In function ‘fsl_lpspi_transfer_one_msg’:
    drivers/spi/spi-fsl-lpspi.c:369: warning: ‘ret’ may be used uninitialized in this function

If the message contains no transfers, the function will set the
message's status to an uninitialized value, and will return that
uninitialized value.

While __spi_validate() should have been called in all paths leading to
this, and thus have rejected such messages, we better pre-initialize ret
to be safe for future modifications (spi_transfer_one_message() also
does this).

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-14 14:31:13 +00:00
Mark Brown
fafd679407 Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/sunxi', 'spi/topic/ti-qspi', 'spi/topic/topcliff-pch' and 'spi/topic/xlp' into spi-next 2016-12-12 15:54:20 +00:00
Mark Brown
6694430130 Merge remote-tracking branches 'spi/topic/orion', 'spi/topic/pxa2xx', 'spi/topic/rspi' and 'spi/topic/s3c64xx' into spi-next 2016-12-12 15:54:17 +00:00
Mark Brown
830d705f26 Merge remote-tracking branches 'spi/topic/fsl-lpspi', 'spi/topic/imx', 'spi/topic/jcore' and 'spi/topic/omap' into spi-next 2016-12-12 15:54:14 +00:00
Mark Brown
3bc1ad252d Merge remote-tracking branches 'spi/topic/delay', 'spi/topic/dw', 'spi/topic/fsl-dspi' and 'spi/topic/fsl-espi' into spi-next 2016-12-12 15:54:09 +00:00
Mark Brown
0afa0724df Merge remote-tracking branches 'spi/topic/armada', 'spi/topic/ath79', 'spi/topic/atmel' and 'spi/topic/axi' into spi-next 2016-12-12 15:54:05 +00:00
Mark Brown
9b12be6302 Merge remote-tracking branch 'spi/topic/rcar' into spi-next 2016-12-12 15:54:04 +00:00
Mark Brown
cc939939d8 Merge remote-tracking branch 'spi/topic/dma' into spi-next 2016-12-12 15:54:03 +00:00
Mark Brown
0523266950 Merge remote-tracking branch 'spi/topic/core' into spi-next 2016-12-12 15:54:03 +00:00
Mark Brown
b14a8a8028 Merge remote-tracking branches 'spi/fix/atmel', 'spi/fix/mvbeu' and 'spi/fix/spidev' into spi-linus 2016-12-12 15:53:58 +00:00
Uwe Kleine-König
7243e0b207 spi: mvebu: fix baudrate calculation for armada variant
The calculation of SPR and SPPR doesn't round correctly at several
places which might result in baud rates that are too big. For example
with tclk_hz = 250000001 and target rate 25000000 it determined a
divider of 10 which is wrong.

Instead of fixing all the corner cases replace the calculation by an
algorithm without a loop which should even be quicker to execute apart
from being correct.

Fixes: df59fa7f4b ("spi: orion: support armada extended baud rates")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-08 17:54:51 +00:00
Romain Perier
5762ab71eb spi: Add support for Armada 3700 SPI Controller
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>
2016-12-08 16:05:34 +00:00
Gao Pan
d989eed207 spi: fsl-lpspi: quit reading rx fifo under error condition
In case that error occurs during waiting for txfifo empty, it is
not necessary to read rx fifo. It's better to return directly.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-05 11:45:03 +00:00
Gao Pan
b6787b6807 spi: fsl-lpspi: use GPL as module license
At the beginning of lpspi driver, it is claimed that the dirver
is under the terms of the GNU General Public License, either
version 2 of the License. While at the end I only declared GPL V2.

This patch make the license consistent.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-05 11:45:03 +00:00
Heiner Kallweit
7e2ef00330 spi: fsl-espi: fix ioread16/iowrite16 endianness
fsl_espi_read_reg16 / fsl_espi_write_reg16 are supposed to read / write
big endian values. Therefore ioread16be / iowrite16be have to be used.

Fixes: 	0582343284 ("eliminate need for linearization when writing to hardware")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-12-01 18:50:59 +00:00