History log of /linux-master/drivers/spi/spi-rspi.c
Revision Date Author Comments
# 1405efe7 18-Aug-2023 Yang Yingliang <yangyingliang@huawei.com>

spi: rspi: switch to use spi_alloc_host()

Switch to use modern name function spi_alloc_host().

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230818093154.1183529-15-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 749396cb 14-Jul-2023 Rob Herring <robh@kernel.org>

spi: Explicitly include correct DT includes

The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230714174955.4064174-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# b778d967 05-Jul-2023 Yangtao Li <frank.li@vivo.com>

spi: rspi: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230706032727.9180-5-frank.li@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# edfa9703 10-Mar-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

spi: rspi: Mark OF related data as maybe unused

Driver can match via ID or OF ID table, thus several OF-related methods
will be unused. Mark the OF structures as __maybe_unused so compiler
can drop them:

drivers/spi/spi-rspi.c:1203:29: error: ‘qspi_ops’ defined but not used [-Werror=unused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230310222857.315629-16-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9e264f3f 10-Mar-2023 Amit Kumar Mahapatra via Alsa-devel <alsa-devel@alsa-project.org>

spi: Replace all spi->chip_select and spi->cs_gpiod references with function call

Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod
members of struct spi_device to be an array. But changing the type of these
members to array would break the spi driver functionality. To make the
transition smoother introduced four new APIs to get/set the
spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and
spi->cs_gpiod references with get or set API calls.
While adding multi-cs support in further patches the chip_select & cs_gpiod
members of the spi_device structure would be converted to arrays & the
"idx" parameter of the APIs would be used as array index i.e.,
spi->chip_select[idx] & spi->cs_gpiod[idx] respectively.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Acked-by: Heiko Stuebner <heiko@sntech.de> # Rockchip drivers
Reviewed-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org> # Aspeed driver
Reviewed-by: Dhruva Gole <d-gole@ti.com> # SPI Cadence QSPI
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> # spi-stm32-qspi
Acked-by: William Zhang <william.zhang@broadcom.com> # bcm63xx-hsspi driver
Reviewed-by: Serge Semin <fancer.lancer@gmail.com> # DW SSI part
Link: https://lore.kernel.org/r/167847070432.26.15076794204368669839@mailman-core.alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 72ec0e8f 03-Mar-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

spi: rspi: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230303172041.2103336-62-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# b620aa3a 21-Jul-2022 Biju Das <biju.das.jz@bp.renesas.com>

spi: spi-rspi: Fix PIO fallback on RZ platforms

RSPI IP on RZ/{A, G2L} SoC's has the same signal for both interrupt
and DMA transfer request. Setting DMARS register for DMA transfer
makes the signal to work as a DMA transfer request signal and
subsequent interrupt requests to the interrupt controller
are masked.

PIO fallback does not work as interrupt signal is disabled.

This patch fixes this issue by re-enabling the interrupts by
calling dmaengine_synchronize().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20220721143449.879257-1-biju.das.jz@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6f381481 11-Apr-2022 Biju Das <biju.das.jz@bp.renesas.com>

spi: spi-rspi: Remove setting {src,dst}_{addr,addr_width} based on DMA direction

The direction field in the DMA config is deprecated. The rspi driver
sets {src,dst}_{addr,addr_width} based on the DMA direction and
it results in dmaengine_slave_config() failure as RZ DMAC driver
validates {src,dst}_addr_width values independent of DMA direction.

This patch fixes the issue by passing both {src,dst}_{addr,addr_width}
values independent of DMA direction.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Suggested-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20220411173115.6619-1-biju.das.jz@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1d734f59 17-Nov-2021 Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

spi: spi-rspi: Drop redeclaring ret variable in qspi_transfer_in()

"ret" variable is already declared in qspi_transfer_in() at the
beginning of function, drop redeclaring ret in the if block, fixing
below:

spi-rspi.c: In function ‘qspi_transfer_in’:
spi-rspi.c:838:7: warning: declaration of ‘ret’ shadows a previous local
838 | int ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
| ^~~
spi-rspi.c:835:6: note: shadowed declaration is here
835 | int ret;

Fixes: db30083813b55 ("spi: rspi: avoid uninitialized variable access")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20211118031041.2312-4-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# aadbff4a 17-Nov-2021 Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

spi: spi-rspi: Add support to deassert/assert reset line

On RZ/G2L SoC we need to explicitly deassert the reset line
for the device to work, use this opportunity to deassert/assert
reset line in spi-rspi driver.

This patch adds support to read the "resets" property (if available)
from DT and perform deassert/assert when required.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20211118031041.2312-3-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 98c29b35 16-Sep-2021 Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

spi: rspi: drop unneeded MODULE_ALIAS

The MODULE_DEVICE_TABLE already creates proper alias for platform
driver. Having another MODULE_ALIAS causes the alias to be duplicated.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20210916164423.134603-1-krzysztof.kozlowski@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 29176edd 23-Jun-2021 Wolfram Sang <wsa+renesas@sang-engineering.com>

spi: spi-rspi: : use proper DMAENGINE API for termination

dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20210623095843.3228-2-wsa+renesas@sang-engineering.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# c3197974 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fill in controller speed limits

Fill in the controller speed limits, so the SPI core can use them for
validating SPI transfers, and adjusting them where needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-8-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# cb588254 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fill in spi_transfer.effective_speed_hz

Fill in the effective bit rate used for transfers, so the SPI core can
calculate instead of estimate delays.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-7-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6a195f24 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Increase bit rate range for QSPI

Increase bit rate range for QSPI by extending the range of supported
dividers:
1. QSPI supports a divider of 1, by setting SPBR to zero, increasing
the upper limit from 48.75 to 97.5 MHz on R-Car Gen2,
2. Make use of the Bit Rate Frequency Division Setting field in
Command Registers, to decrease the lower limit from 191 to 24 kbps
on R-Car Gen2.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-6-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4e71d926 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Increase bit rate range for RSPI on SH

Increase bit rate range for RSPI on legacy SH by making use of the Bit
Rate Frequency Division Setting field in Command Registers, just like is
already done on RZ/A. This decreases the lower limit by a factor of 8.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-5-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# feace902 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Increase bit rate accuracy on RZ/A

rspi_rz_set_config_register() favors high values of "brdv" over high
values of "spbr". As "brdv" is not a plain divider, but controls a
power-of-two divider, this may cause the selection of non-optimal
divider values. E.g. on RSK+RZA1, when 3.8 MHz is requested, the actual
configured bit rate is 2.08 MHz (spbr = 1, brdv = 3), while 3.7 MHz
would be possible (spbr = 8, brdv = 0).

Fix this by only resorting to higher "brdv" values when really needed.
This makes the driver always pick optimal divider values on RZ/A.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-4-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8dd71698 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Clean up Bit Rate Division Setting handling

Add a macro for configuring the Bit Rate Division Setting field in
Command Registers, instead of open-coding the same operation using a
hardcoded shift.
Rename "div" to "brdv", as it is not a plain divider value, but controls
a power-of-two divider.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-3-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7ffe363b 19-Aug-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Remove useless .set_config_register() check

Not implementing spi_ops.set_config_register() is a driver bug that
would prevent the driver from working at all.
Hence remove the run-time check.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200819125904.20938-2-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# e0fe7005 08-Jun-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use requested instead of maximum bit rate

Currently, the RSPI driver always tries to use the maximum configured
bit rate for communicating with a slave device, even if the transfer(s)
in the current message specify a lower rate.

Use the mininum rate specified in the message instead.
Rename rspi_data.max_speed_hz accordingly.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200608095940.30516-3-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# f3a14a3a 09-Mar-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add support for active-high chip selects

All RSPI variants support setting the polarity of the SSL signal.
Advertize support for active-high chip selects, and configure polarity
according to the state of the flag.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200309171537.21551-1-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# c046f8fd 18-Feb-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add support for LSB-first word order

All RSPI variants support selecting the word order.
Advertize support for LSB-first order, and act upon the flag being set.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200218105810.902-3-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# cd982e6c 18-Feb-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Factor out handling of common mode bits

Basic SPI features like clock phase/polarity and loopback mode are
common to all RSPI variants. Factor them out to reduce duplication.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200218105810.902-2-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 144d8f97 02-Jan-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add support for GPIO chip selects

Add support for GPIO chip selects using GPIO descriptors. As the RSPI
controller always drives a native chip select when performing a
transfer, at least one native chip select must be left unused.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200102133822.29346-7-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9815ed87 02-Jan-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add support for multiple native chip selects

RSPI variants on some SuperH or R-Mobile SoCs support multiple native
chip selects. Add support for this by configuring the SSL Assert Signal
Setting.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200102133822.29346-6-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8f2344fa 02-Jan-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Remove set_config_register() macro

The set_config_register() macro is used in a single place.
Make the code easier to read by just removing it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200102133822.29346-5-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1bec84dd 02-Jan-2020 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use dev_warn_once() instead of open-coding

Use the helper introduced by commit e135303bd5bebcd2 ("device: Add
dev_<level>_once variants") instead of open-coding the same operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200102133822.29346-4-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 851c902f 11-Dec-2019 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Remove obsolete platform_device_id entries

Since commits 05104c266ae9a167 ("ARM: shmobile: r7s72100: genmai: Remove
legacy board file") and a483dcbfa21f919c ("ARM: shmobile: lager: Remove
legacy board support", RZ/A1 and R-Car Gen2 SoCs are only supported in
generic DT-only ARM multi-platform builds. The driver doesn't need to
match platform devices by name anymore for these platforms, hence remove
the corresponding platform_device_id entries.

The platform_device_id entry for "rspi" is retained, as it is used by
the SH7757 platform, which hasn't been converted to DT yet.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Link: https://lore.kernel.org/r/20191211131553.23960-1-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2de860b4 16-Oct-2019 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use platform_get_irq_byname_optional() for optional irqs

As platform_get_irq_byname() now prints an error when the interrupt
does not exist, scary warnings may be printed for optional interrupts:

renesas_spi e6b10000.spi: IRQ rx not found
renesas_spi e6b10000.spi: IRQ mux not found

Fix this by calling platform_get_irq_byname_optional() instead.
Remove the no longer needed printing of platform_get_irq errors, as the
remaining calls to platform_get_irq() and platform_get_irq_byname() take
care of that.

Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20191016143101.28738-1-geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7e95b166 23-Apr-2019 Hoan Nguyen An <na-hoan@jinso.co.jp>

spi: rspi: Fix handling of QSPI code when transmit and receive

Process handling QSPI when transmit/receive at qspi_trigger_transfer_out_in() as follows:
Setting the trigger, is the number of bytes in the FIFO buffer to determine
when there is an interrupt. Then check if the value of triggering number is
32-bytes or 1-byte, there will be corresponding processing
Handling (if (n == QSPI_BUFFER_SIZE) esle) this is unnecessary, leads to the
same processing of data transmission or reception, The difference here are with
ret = rspi_wait_for_tx_empty(rspi);
ret = rspi_wait_for_rx_full(rspi);

When the nummber trigger is 32 bytes, we only write into FIFO when the FIFO is completely empty
(interrupt transmission), and only receive if FIFO is full of 32 bytes of data.

In the case of a nummber trigger that is 1 byte, in principle we still need to process
rspi_wait_for_tx_empty/full so that FIFO is empty only with the amount of data we need to write to
or equal to the number of bytes we need to receive, There is currently no processing of this.
And in the current case with this patch, at this time it only needs at least 1 byte received in
FIFO that has interrupt received, or FIFO at least 1bytes free can be written into FIFO,
This patch therefore does not affect this processing.
So we need to eliminate unnecessary waste processing (if (n == QSPI_BUFFER_SIZE) esle),
more precisely in waiting for FIFO status.
The same with handling in qspi_transfer_out()/qspi_transfer_in().

Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 26843bb1 12-Mar-2019 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fix sequencer reset during initialization

While the sequencer is reset after each SPI message since commit
880c6d114fd79a69 ("spi: rspi: Add support for Quad and Dual SPI
Transfers on QSPI"), it was never reset for the first message, thus
relying on reset state or bootloader settings.

Fix this by initializing it explicitly during configuration.

Fixes: 0b2182ddac4b8837 ("spi: add support for Renesas RSPI")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 42bdaaec 12-Mar-2019 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fix register initialization while runtime-suspended

The Renesas RSPI/QSPI driver performs SPI controller register
initialization in its spi_operations.setup() callback, without calling
pm_runtime_get_sync() first, which may cause spurious failures.

So far this went unnoticed, as this SPI controller is typically used
with a single SPI NOR FLASH containing the boot loader:
1. If the device's module clock is still enabled (left enabled by the
bootloader, and not yet disabled by the clk_disable_unused() late
initcall), register initialization succeeds,
2. If the device's module clock is disabled, register writes don't
seem to cause lock-ups or crashes.
Data received in the first SPI message may be corrupted, though.
Subsequent SPI messages seem to be OK.
E.g. on r8a7791/koelsch, one bit is lost while receiving the 6th
byte of the JEDEC ID for the s25fl512s FLASH, corrupting that byte
and all later bytes. But until commit a2126b0a010905e5 ("mtd:
spi-nor: refine Spansion S25FL512S ID"), the 6th byte was not
considered for FLASH identification.

Fix this by moving all initialization from the .setup() to the
.prepare_message() callback. The latter is always called after the
device has been runtime-resumed by the SPI core.

This also makes the driver follow the rule that .setup() must not change
global driver state or register values, as that might break a transfer
in progress.

Fixes: 490c97747d5dc77d ("spi: rspi: Add runtime PM support, using spi core auto_runtime_pm")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9428a073 08-Feb-2019 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Replace spi_master by spi_controller

As of commit 8caab75fd2c2a926 ('spi: Generalize SPI "master" to
"controller"'), the old master-centric names are compatibility wrappers
for the new controller-centric names.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# be0bf62e 21-Oct-2018 Wolfram Sang <wsa+renesas@sang-engineering.com>

spi: spi-rspi: simplify getting .driver_data

We should get 'driver_data' from 'struct device' directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8dbbaa47 05-Sep-2018 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fix interrupted DMA transfers

When interrupted, wait_event_interruptible_timeout() returns
-ERESTARTSYS, and the SPI transfer in progress will fail, as expected:

m25p80 spi0.0: SPI transfer failed: -512
spi_master spi0: failed to transfer one message from queue

However, as the underlying DMA transfers may not have completed, all
subsequent SPI transfers may start to fail:

spi_master spi0: receive timeout
qspi_transfer_out_in() returned -110
m25p80 spi0.0: SPI transfer failed: -110
spi_master spi0: failed to transfer one message from queue

Fix this by calling dmaengine_terminate_all() not only for timeouts, but
also for errors.

This can be reproduced on r8a7991/koelsch, using "hd /dev/mtd0" followed
by CTRL-C.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# c1ca59c2 05-Sep-2018 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fix invalid SPI use during system suspend

If the SPI queue is running during system suspend, the system may lock
up.

Fix this by stopping/restarting the queue during system suspend/resume,
by calling spi_master_suspend()/spi_master_resume() from the PM
callbacks. In-kernel users will receive an -ESHUTDOWN error while
system suspend/resume is in progress.

Based on a patch for sh-msiof by Gaku Inami.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# 9135bac3 21-Aug-2018 Wolfram Sang <wsa+renesas@sang-engineering.com>

spi: use SPDX identifier for Renesas drivers

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 768d59f5 19-Mar-2018 Stefan Agner <stefan@agner.ch>

spi: rspi: use correct enum for DMA transfer direction

Use enum dma_transfer_direction as required by dmaengine_prep_slave_sg
instead of enum dma_data_direction. This won't change behavior in
practice as the enum values are equivalent.

This fixes two warnings when building with clang:
drivers/spi/spi-rspi.c:538:26: warning: implicit conversion from enumeration
type 'enum dma_data_direction' to different enumeration type
'enum dma_transfer_direction' [-Wenum-conversion]
rx->sgl, rx->nents, DMA_FROM_DEVICE,
^~~~~~~~~~~~~~~
drivers/spi/spi-rspi.c:558:26: warning: implicit conversion from enumeration
type 'enum dma_data_direction' to different enumeration type
'enum dma_transfer_direction' [-Wenum-conversion]
tx->sgl, tx->nents, DMA_TO_DEVICE,
^~~~~~~~~~~~~

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b458a349 07-Dec-2017 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Do not set SPCR_SPE in qspi_set_config_register()

The R-Car Gen2 Hardware User Manual Rev. 2.00 states:

If the master/slave mode select bit (MSTR) is modified while the SPI
function enable bit (SPE) is set to 1 (that is, this module is
enabled), the subsequent operation cannot be guaranteed.

Hence do not set SPCR_SPE when setting SPCR_MSTR, just like the
.set_config_register() implementations for other RSPI variants do.

Note that when booted from QSPI, the boot loader will have set SPCR_MSTR
already, hence usually the bit is never modified by the Linux driver.

Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 219a7bc5 04-Oct-2017 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use of_device_get_match_data() helper

Use the of_device_get_match_data() helper instead of open coding.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ad16d4a8 15-Feb-2017 DongCV <cv-dong@jinso.co.jp>

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>


# 7264abc7 15-Feb-2017 DongCV <cv-dong@jinso.co.jp>

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: 3be09bec42a800d4
"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>


# ffcfae38 04-Jan-2017 Geert Uytterhoeven <geert+renesas@glider.be>

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>


# db300838 08-Nov-2016 Arnd Bergmann <arnd@arndb.de>

spi: rspi: avoid uninitialized variable access

The newly introduced rspi_pio_transfer_in_or_our() function must
take either a valid 'rx' or 'tx' pointer, and has undefined behavior
if both are NULL, as found by 'gcc -Wmaybe-unintialized':

drivers/spi/spi-rspi.c: In function 'rspi_pio_transfer_in_or_our':
drivers/spi/spi-rspi.c:558:5: error: 'len' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The analysis of the function is correct in principle, but the code
is currently safe because both callers always pass exactly one
of the two pointers.

Looking closer at this function shows that having a combined
method for rx and tx here actually increases the complexity
and the size of the file. This simplifies it again by keeping
the two separate, which then ends up avoiding that warning.

Fixes: 3be09bec42a8 ("spi: rspi: supports 32bytes buffer for DUAL and QUAD")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3be09bec 04-Nov-2016 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi: rspi: supports 32bytes buffer for DUAL and QUAD

This patch supports 32bytes of buffer for DUAL and QUAD in QSPI by
Using Transmit/Receive Buffer Data Triggering Number.
In order to improve the DUAL and QUAD's performance of SPI
while transferring data in PIO mode, it sends/receives each 32bytes
data instead of each byte data as current situation.

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>


# aeb8f8cb 05-Aug-2016 Chris Brandt <chris.brandt@renesas.com>

spi: rspi: Increase accuracy of bit rate for RZ

When you leave the clock divider at 0, 130kHz is the lowest you can go.
Also, by adjusting the clock divider you can get more accurate resolutions
for clock speeds lower than 16MHz. This patch uses the clock divider as
part of the bit rate setup.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# cb76b1ca 23-Jun-2015 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Make qspi_set_send_trigger() return "unsigned int"

qspi_set_send_trigger() returns an unsigned value, so make it return
"unsigned int".
Update the loop variables qspi_trigger_transfer_out_int() to match the
above.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5d4db691 23-Jun-2015 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Drop variable "error" in qspi_trigger_transfer_out_in()

Just use "ret" instead, for consistency with other similar functions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# cc2e9328 22-May-2015 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi: rspi: Re-do the returning value of qspi_transfer_out_in

To reduce complexity of code, drop "ret" then qspi_transfer_out_in function
should return the value of "qspi_trigger_transfer_out_in" directly.

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a91bbe7d 22-May-2015 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi: rspi: modify the name of "qspi_trigger_transfer_out_int" function

The name of "qspi_trigger_transfer_out_int" function should be
"qspi_trigger_transfer_out_in" without "t".

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6310372d 29-Apr-2015 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi: rspi: Re-do the returning value of rspi_dma_check_then_transfer

To reduce indentation and complexity of code, insteeds of returning zero
the function rspi_dma_check_then_transfer should return rspi_dma_transfer
directly after checking error.

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8634dafa 01-May-2015 Krzysztof Kozlowski <krzk@kernel.org>

spi: rspi: Constify platform_device_id

The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c9bc3e8b 03-Apr-2015 Dan Carpenter <dan.carpenter@oracle.com>

spi: signedness bug in qspi_trigger_transfer_out_int()

We need "ret" to be unsigned for the error handling to work. The
signedness of "i" and "n" don't matter but qspi_set_send_trigger()
returns an int so I've changed them to int as well.

Fixes: 4b6fe3edcbba ('spi: Using Trigger number to transmit/receive data')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4b6fe3ed 22-Oct-2014 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi: Using Trigger number to transmit/receive data

In order to transmit and receive data when have 32 bytes of data that
ready has prepared on Transmit/Receive Buffer to transmit or receive.
Instead transmits/receives a byte data using Transmit/Receive Buffer
Data Triggering Number will improve the speed of transfer data.

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 118dad43 16-Feb-2015 Arnd Bergmann <arnd@arndb.de>

spi: rspi: remove slave_id settings for DMAEngine

Current rspi sets dma_slave_config :: slave_id field for DMAEngine,
but it is no longer needed. Let's remove it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>


# 2c658e21 18-Dec-2014 Jarkko Nikula <jarkko.nikula@linux.intel.com>

spi: Remove FSF mailing addresses

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 14ac00e0 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

spi: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 6089af77 28-Aug-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add support for new R-Car Gen2 SoCs

Add support for QSPI in:
- r8a7792 (R-Car V2H)
- r8a7793 (R-Car M2-N)
- r8a7794 (R-Car E2)

r8a7791 is now called "R-Car M2-W".

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# e825b8dd 06-Aug-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add DT support to DMA setup

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# a30b95a7 06-Aug-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Configure DMA slave bus width to 8 bit

The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
explicit configuration of the DMA slave bus width.
Hardcode the DMA transfer size to 1 byte for both directions, as that's
the only supported configuration (16-bit DMA support was removed in
commit 9c5de2c1754c2bb3c69c4d7bf0d0edc0a61d8232 ("spi: rspi: Remove
unused 16-bit DMA support")).

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 43937455 06-Aug-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use devm_kasprintf()

Use the devm_kasprintf() helper function instead of open coding
error-prone buffer handling and string formatting.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# d64b4726 06-Aug-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Remove unneeded semicolon

Introduced by commit 426ef76dd8a394a0e04d096941cd9acb49539a3e ("spi:
rspi: Add DT support").

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 3819bc87 06-Aug-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Fix leaking of unused DMA descriptors

If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
unused DMA descriptors.

As per Documentation/dmaengine.txt, once a DMA descriptor has been
obtained, it must be submitted. Hence:
- First prepare and submit all DMA descriptors,
- Prepare the SPI controller for DMA,
- Start DMA by calling dma_async_issue_pending(),
- Make sure to call dmaengine_terminate_all() on all descriptors that
haven't completed.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 85912a88 08-Jul-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Handle dmaengine_prep_slave_sg() failures gracefully

As typically a shmobile SoC has less DMA channels than devices that can use
DMA, we may want to prioritize access to the DMA channels in the future.
This means that dmaengine_prep_slave_sg() may start failing arbitrarily.

Handle dmaengine_prep_slave_sg() failures gracefully by falling back to
PIO.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# afcc98de 06-Jun-2014 Geert Uytterhoeven <geert@linux-m68k.org>

spi: rspi: Pass spi_master pointer to rspi_release_dma()

rspi_release_dma() doesn't need access to any fields in the driver private
data, except for the pointer to the SPI master object. Hence just pass the
needed pointer.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 95029a00 06-Jun-2014 Geert Uytterhoeven <geert@linux-m68k.org>

spi: rspi: Remove unused variable in rspi_rz_transfer_one()

Introduced by commit 8b983e90ea1a3dd82070f96c062ad521a06b7cc0 ("spi: rspi:
Extract rspi_common_transfer()"), which removed its users.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8b983e90 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Extract rspi_common_transfer()

Extract the common parts of rspi_transfer_one(), rspi_rz_transfer_one(),
and qspi_transfer_out_in() into the new function rspi_common_transfer().

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# e7fb921d 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add DMA support for RSPI on RZ/A1H

Enable DMA support for RSPI on r7s72100 (RZ/A1H).

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 4f12b5e5 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Add DMA support for QSPI on R-Car Gen2

Enable DMA support for QSPI on R-Car Gen2, for Single, Dual, and Quad SPI
Transfers.

Performance figures for reading from a QSPI FLASH driven at 24.375 MHz
on r8a7791/koelsch:
- Single: 1.1 Mbps PIO, 23 Mbps DMA
- Dual : 12.7 Mbps PIO, 48 Mbps DMA
- Quad : 13 Mbps PIO, 70 Mbps DMA

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 03e627c5 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Absorb rspi_rz_transfer_out_in() into rspi_rz_transfer_one()

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# c52fb6d6 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Merge rspi_*_dma() into rspi_dma_transfer()

rspi_send_dma() and rspi_send_receive_dma() are very similar. Consolidate
into a single function rspi_dma_transfer(), and add missing checks for
dmaengine_submit() failures.

Both sg_table pointer parameters can be NULL, as RSPI supports TX-only
mode, and unidirectional DMA transfers will also be needed later for
Dual/Quad DMA support.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# e4b52dc4 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Pass sg_tables instead of spi_tranfer to rspi_*_dma()

The DMA routines only need access to the scatter-gather tables inside the
spi_transfer structures, hence just pass those.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8393fa78 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Move RSPI-specific setup out of DMA routines

Refactor RSPI (on SH) DMA handling to make it reusable for other RSPI
implementations:
- Call the DMA routines after configuring the TX Mode bit and after
calling rspi_receive_init(), so these RSPI-specific operations can be
removed from the DMA routines,
- Absorb rspi_transfer_out_in() into rspi_transfer_one().

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 2f777ec9 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use SPI core DMA mapping framework

Use the SPI core DMA mapping framework instead of our own.
If available, DMA is used for transfers larger than the FIFO size
(8 or 32 bytes).

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5f338d0c 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: SPI DMA core needs both RX and TX DMA to function

The SPI DMA core framework needs both RX and TX DMA to function. As a
preparation for converting the driver to use this framework, fall back to
PIO if no DMA channel or only one DMA channel is available.

This affects only RSPI, which could do DMA transfers for TX-only before.
RSPI-RZ and QSPI (at least for Single SPI Transfers) will need both RX and
TX DMA anyway.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# fcdc49ae 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Remove unneeded resource test in DMA setup

The resource is know to exist, as rspi_probe() already mapped it.
Remove the test, and just pass the resource.
Pass the device pointer instead of the platform device pointer, as the
latter is no longer needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 65bf2205 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Extract rspi_request_dma_chan()

Setup of the receive and transmit DMA channels is very similar, so let's
consolidate.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 27e105a6 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Don't consider DMA configuration failures fatal

Fall back to PIO if DMA configuration failed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 6837b8e9 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Extract rspi_pio_transfer()

The various PIO loops are very similar. Consolidate into a single
function rspi_pio_transfer().

Both buffer pointers can be NULL, as RSPI supports TX-only mode, and
Dual/Quad SPI Transfers are unidirectional.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# b42e0359 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Use core SPI_MASTER_MUST_[RT]X handling

RSPI needs dummy transfers to generate the SPI clock on receive.
RSPI-RZ and QSPI always do both transmit and receive.

Use the SPI core SPI_MASTER_MUST_RX/SPI_MASTER_MUST_TX infrastructure
instead of checking for the presence of buffers and providing dummy data
ourselves (for PIO), or providing a dummy buffer (for DMA).

rspi_receive_dma() now provides full duplex DMA transfers on RSPI, and is
renamed to rspi_send_receive_dma().

As the SPI core will always provide a TX buffer, the logic to choose
between DMA send and DMA send/receive in rspi_transfer_one() now has to
check for the presence of an RX buffer. Likewise for the DMA availability
tests in rspi_is_dma().

The buffer tests in qspi_transfer_one() are now always true, so they're
removed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 9c5de2c1 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Remove unused 16-bit DMA support

The 16-bit DMA support doesn't fit well within the SPI core DMA framework,
as it needs to manage its own double-sized temporary buffers, for handling
the interleaved data.
Remove it, as there is no in-tree board code that sets
rspi_plat_data.dma_width_16bit.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 32c64261 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Do not call rspi_receive_init() for TX-only

Since commit 8449fd76deb9ac67a15a6fb8ead7bb4595d019d2 ("spi: rspi: Merge
rspi_send_pio() and rspi_receive_pio()"), rspi_receive_init() is called
for transmit-only transfers too, while this is not needed.
Only call rspi_receive_init() when receiving, to preserve behavior on
RSPI on SH.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5f684c34 02-Jun-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Extract rspi_wait_for_{tx_empty,rx_full}()

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 3beb61db 22-May-2014 Geert Uytterhoeven <geert+renesas@glider.be>

spi: rspi: Round up division to avoid slave overclocking

The calculation of the bit rate divider used a standard C division, which
rounds down the quotient. This may lead to a higher bitrate than requested.
Round up to avoid this.

E.g. on Koelsch, the SPI flash (configured for 30 MHz) was driven at 48.75
MHz. After this patch it's driven at a safe 24.375 MHz.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 490c9774 11-Mar-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add runtime PM support, using spi core auto_runtime_pm

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# ba824d49 21-Feb-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Fix loopback mode for Dual/Quad SPI Transfers

While normal Dual and Quad SPI Transfers are unidirectional, we must do
a bidirectional transfer if loopback mode is enabled, else rx_buf is not
filled.

With spidev it seemed to work, as spidev uses the same buffer for
tranmission and reception.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# ab98fcba 21-Feb-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Remove empty rspi_cleanup()

If spi_master.cleanup() is not needed, it can be left unimplemented.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5dd1ad23 04-Feb-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Only enable interrupts when there's a need to wait

rspi_wait_for_interrupt() unconditionally enables interrupts, even when the
wait condition is already satisfied. This causes a high interrupt load (2
interrupts/byte for full-duplex Single SPI transfers, 1 interrupt/byte for
RSPI with TX Only mode, or QSPI in unidirectional Dual or Quad Transfer
mode).

Change this to return immediately when the wait condition is satisfied.
This dramatically reduces the interrupt load, especially in high-speed
Quad Transfer mode, and increases transfer speed, as no interrupts need to
be handled when there's space available in the output FIFO, or data
available in the input FIFO.

Benchmark results for QSPI on r8a7791 while reading 1 MiB from 30 MHz SPI
FLASH on the Koelsch development board:

Before:
Single SPI Dual SPI Quad SPI
Interrupts: 2096856 1048592 1048594
Mbps: 0.9 1.6 1.6

After:

Single SPI Dual SPI Quad SPI
Interrupts: 1048569 21295 8
Mbps: 0.7 10.8 12.9

I don't know why Single SPI slowed down a bit.

I've also verified functionality for RSPI-RZ on r7s72100, but don't have
benchmark results as there's no SPI FLASH connected to RSPI on the Genmai
development board. Unlike RSPI and QSPI, RSPI-RZ has separate interrupts
for RX and TX, which shows that Single SPI transfers now generate (mostly)
RX interrupts, as expected.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 64b67def 02-Feb-2014 Shimoda, Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

spi: rspi: fix build error when CONFIG_OF is not set

This patch fixes an issue that the following build error happens when
the CONFIG_OF is not set:

drivers/spi/spi-rspi.c: In function 'rspi_probe':
drivers/spi/spi-rspi.c:1203:26: error: 'rspi_of_match' undeclared (first use in this function)

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 880c6d11 30-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add support for Quad and Dual SPI Transfers on QSPI

Add support for Quad and Dual SPI Transfers on the Renesas Quad Serial
Peripheral Interface, as found in R-Car Gen2 SoCs like R-Car H2 (r8a7790)
and R-Car M2 (r8a7791):
- Add unidirectional transfer methods for Quad/Dual SPI Transfers.
- Program the sequencer to handle SPI messages with multiple transfer
modes when Quad or Dual transfers are enabled for an SPI slave.
Up to 4 transfer modes per SPI message are supported by the hardware.
- Advertise the availability of Quad and Dual SPI modes on QSPI.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 426ef76d 28-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add DT support

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 29f397b7 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Use NULL as the clock ID

There's only one RSPI/QSPI clock, so we can use NULL as the clock ID

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 17fe0d9a 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Convert to clk_prepare_enable/disable_unprepare

Get the driver ready for the migration to the common clock framework by
calling clk_prepare_enable() and clk_disable_unprepare().

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 06a7a3cf 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add support for loopback mode

Add support for specifying loopback mode.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 862d357f 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add support for RSPI on RZ/A1H

Add support for the RSPI variant in the RZ/A1H (r7s72100) SoC.

Main differences with RSPI on SH are:
- Lack of TX only mode, hence we always have to use full duplex
transfers,
- The Data Register must be accessed used 8-bit operations.

RSPI on RZ is matched using the new "rspi-rz" platform device name.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 93722206 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add support for more than one interrupt

Add support for multiple interrupts, based on the SDK reference code.
This is needed for RZ/A1H, which supports 3 interrupts.

When using multiple interrupts, they must be called "rx" (SPRI) and "tx"
(SPTI). The error interrupt (SPEI) is not used, as it matters for slave
mode only.

When using a single interrupt, it may be called "mux". If it cannot be
found, the first interrupt in the device's resources will be used.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 340a15e6 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Merge qspi_send_pio() and qspi_receive_pio()

qspi_send_pio() and qspi_receive_pio() are very similar: they both send
and receive full duplex data to/from the hardware, but ignore the data
stream in the unused direction.
Merge them into qspi_transfer_out_in(), now supporting real full duplex.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8449fd76 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Merge rspi_send_pio() and rspi_receive_pio()

rspi_send_pio() and rspi_receive_pio() are very similar:
- the former only sends data, using TX Only Mode,
- the latter sends and receives full duplex data to/from the hardware,
but uses dummy transmit data.
Merge them into rspi_transfer_out_in(), now supporting full duplex if
needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# eb557f75 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Abstract transfer_one() for RSPI and QSPI

Split off qspi_transfer_one() (which doesn't support DMA yet) from
rspi_transfer_one().
Replace the abstraction of send_pio()/receive_pio() by the abstracrion of
transfer_one().

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 35301c99 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add rspi_data_{out,in,out_in}() helpers

Add helpers rspi_data_{out,in,out_in}() to write, read, or write and
read data to/from the Data Register, taking care of waiting until data
or space is available in the buffers.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 74da7686 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Abstract 8/16-bit Data Register access

Add rspi_{write,read}_data(), to abstract 8-bit (QSPI, and RSPI on RZ/A1H)
versus 16-bit (RSPI) Data Register access.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 79d23495 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Use core message handling

Let the generic SPI core handle SPI messages, calling into our
rspi_transfer_one() method.

rspi_assert_ssl() and rspi_negate_ssl() are absorbed into
rspi_prepare_message() and rspi_unprepare_message(), as they actually
enable/disable the whole SPI function, instead of just (de)asserting the
chip select line.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 91949a2d 24-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Remove unused mesg parameter from {send,receive}_pio()

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 23061f1e 17-Jan-2014 Axel Lin <axel.lin@ingics.com>

spi: Remove duplicate code to set default bits_per_word setting

The implementation in spi_setup() already set spi->bits_per_word = 8 when
spi->bits_per_word is 0 before calling spi->master->setup.
So we don't need to do it again in setup() callback.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Barry Song <Baohua.Song@csr.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mark Brown <broonie@linaro.org>


# fcb4ed74 14-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add missing clk_disable() calls in error and cleanup paths

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# b7ed6b88 14-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Spelling s/transmition/transmission/

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 348e5153 12-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add support for specifying CPHA/CPOL

Add support for specifying the SPI clock phase and polarity, based on the
SDK reference code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# fbe5072b 12-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add more QSPI register documentation

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 6ab4865b 12-Jan-2014 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Add more RSPI register documentation

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 97b95c11 24-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Use u8 for 8-bit register values

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 2aae80b2 24-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Use DUMMY_DATA macro instead of hardcoded value

Make it more obvious that this value is dummy data.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# baf588f4 24-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Make more pointers const

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# c132f094 24-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Remove casts

Remove useless casts, and do not cast away const.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# fc671a90 24-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Use dev_get_platdata() instead of raw dev.platform_data access

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# df900e67 23-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Fix typo when clearing SPSR_OVRF

The overrun flag should be cleared in the SPI Status Register, not in the
SPI Control Register, based on the SDK sample code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Mark Brown <broonie@linaro.org>


# efd85acb 23-Dec-2013 Geert Uytterhoeven <geert+renesas@linux-m68k.org>

spi: rspi: Fix NULL pointer dereference on SH7757

SH7757 doesn't pass platform data, in which case spi-rspi uses default
parameters.

However, commit 5ce0ba88650f2606244a761d92e2b725f4ab3583 ("spi: rcar: add
Renesas QSPI support on RSPI") added a new user of the platform data, but
forgot to check for its validity first, causing a NULL pointer dereference
on SH7757.

Add the missing check to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 9e03d05e 03-Dec-2013 Jingoo Han <jg1.han@samsung.com>

spi: rcar: Use devm_spi_register_master()

Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5d79e9ac 26-Nov-2013 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

spi: rcar: Use devm_* managed allocators

This simplies error and cleanup code paths.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5ffbe2d9 26-Nov-2013 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

spi: rcar: Fix pointer cast in the remove function

The platform driver data is set to point to the rspi_data structure at
probe time. Calling spi_master_get() on the pointer is just plain wrong
and only works by chance. Fix it by using the platform driver data
directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8e1c8096 26-Nov-2013 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

spi: rcar: Fix uninitialized variable warning

The transfer data length variable is set based on the desired access
size, without a default case. This results in a compiler warning, even
though the access size is always set to a supported value. Create a
default case to silence the warning.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 53063ec6 15-Nov-2013 Wei Yongjun <yongjun_wei@trendmicro.com.cn>

spi: rspi: use platform drvdata correctly in rspi_remove()

We had set the platform drvdata in rspi_probe() as a type of
struct rspi_data, but use it as struct spi_master in rspi_remove()
Fix by remove the unnecessary spi_master_[get|put]() since rspi->master
is no longer used after spi_unregister_master().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mark Brown <broonie@linaro.org>


# cb52c673 10-Oct-2013 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi/rspi: Fix 8bit data access, clear buffer

The R8A7790 has QSPI module which added into RSPI together.
The transmit or receive data should be read from or written to
with the longword-, word-, or byte-access width. Modify word-
access to byte-access. In 16-bit data register, QSPI send or
receive datas access from high 8-bit while RSPI send or receive
datas access from low 8-bit on single mode.
Modify to reset transmit-receive buffer data and reading dummy
after data are transmited. RSPI has a TXMD bit on control
register(SPCR) to set transmit-only mode when transmit data or
Full-duplex synchronous mode when receive data. In QSPI the TXMD
bit is not supported, so after transmit data, dummy should be
read and before transmit or receive data the bufer register
should be reset.
This driver is the implementation of send and receive pio only,
DMA is not supported at this time.
Without this patch, it will occur error when transmit and receive

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5ce0ba88 02-Sep-2013 Hiep Cao Minh <cm-hiep@jinso.co.jp>

spi: rcar: add Renesas QSPI support on RSPI

The R8A7790 has QSPI module which is very similar to RSPI.
This patch adds into RSPI module together to supports QSPI module.

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 9d3405db 31-Aug-2013 Axel Lin <axel.lin@ingics.com>

spi: rspi: Add spi_master_get() call to prevent use after free

In rspi_remove(), current code dereferences rspi after spi_unregister_master(),
thus add an extra spi_master_get() call is necessary to prevent use after free.

Current code already has an extra spi_master_put() call in rspi_remove(), so
this patch just adds a spi_master_get() call rather than a spi_master_get() with
spi_master_put() calls.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8074cf06 30-Jul-2013 Jingoo Han <jg1.han@samsung.com>

spi: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8d4d08ce 26-Aug-2013 Shimoda, Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

spi: spi-rspi: fix inconsistent spin_lock_irqsave

This patch fixes the following Smatch warning:

CHECK drivers/spi/spi-rspi.c
drivers/spi/spi-rspi.c:606 rspi_work() warn: inconsistent returns spin_lock:&rspi->lock: locked (602) unlocked (606)
drivers/spi/spi-rspi.c:606 rspi_work() warn: inconsistent returns irqsave:flags: locked (602) unlocked (606)

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# e2b05099 02-Aug-2013 Guennadi Liakhovetski <g.liakhovetski@gmx.de>

spi: rspi: provide port addresses to dmaengine driver via slave configuration

Don't rely on shdma dhaengine driver getting DMA slave addresses from its
slave configuration. Instead provide those addresses, using a
dmaengine_slave_config() call.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 24b5a82c 23-May-2013 Jingoo Han <jg1.han@samsung.com>

spi: use platform_{get,set}_drvdata()

Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# fd4a319b 07-Dec-2012 Grant Likely <grant.likely@secretlab.ca>

spi: Remove HOTPLUG section attributes

CONFIG_HOTPLUG is going away as an option. As result the __dev*
markings will be going away.

Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst,
and __devexit.

Bill Pemberton has done most of the legwork on this series. I've used
his script to purge the attributes from the drivers/gpio tree.

Reported-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 0243c536 02-Aug-2012 Shimoda, Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

spi: spi-rspi: fix build error for the latest shdma driver

Because the latest shdma driver changed, it caused build error in
the spi-rspi driver. This patch fixed the build error.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# a3633fe7 19-Apr-2012 Shimoda, Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

spi/rspi: add dmaengine support

This patch adds dmaengine supporting using sh_dma driver. The module
receives data by DMAC, it also needs TX DMAC to generate SPI's clocks.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 0b2182dd 06-Mar-2012 Shimoda, Yoshihiro <yoshihiro.shimoda.uh@renesas.com>

spi: add support for Renesas RSPI

The SH7757 has RSPI module. This patch supports it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>