i2c: rcar: add compatibles for additional SoC

Signed-off-by: Wolfram Sang <wsa@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit 819a39510ed8e7f473309d071ede0fb02f0d0e79)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
i2c: sh_mobile: replace magic hex values with constants

No functional change, binaries are identical.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit a78f6a4140f95cbedc0b28c4c883e8aa9ba044f1)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
pinctrl: sh-pfc: Don't set the pinmux_irq irq field for multiplatform

In the multiplatform kernel case the IRQs associated with the PFC GPIOs
are specified through DT. The pinmux_irq irq field is thus ignored by
the code, and doesn't need to be set.

This will allow removing the mach/irq.h include from pfc-*.c files that
was required for the irq_pin() macro used to initialize the irq field.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 0e26e8dfb9dddb0559fb7cd7b53a8b497a8d4121)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 5f684c34fc82be84ece158aa5c5c7c5072daa9a0)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 32c64261c6f50a4e71ec7546f7e2f48eba91c985)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 9c5de2c1754c2bb3c69c4d7bf0d0edc0a61d8232)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit b42e03596db3d45980c976c8124fdc323f031dc4)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 6837b8e91d2a080293c30d5fe42d9692390091fa)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 27e105a6006b8ce1b55709c5e24f63959981475d)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 65bf220571f131a7c3a564a88793bd0f16fd7c96)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit fcdc49ae53dc8cfc1a7758607bca68935f568ca2)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 5f338d0ce0b4c9e6c554b92cfb288789a41bfbc1)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 2f777ec91aa0623e058c43dd4aaf0b3325d3c3e8)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 8393fa787bf63c05cb6f9cf0a58ba1ea213c3f01)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit e4b52dc4625ee739195189d40c6ddc7d55ddf312)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit c52fb6d63425248bd4152451a2cc74b7df8fa989)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 03e627c55752fa434d5b3eba5ee3e489c51672b6)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 4f12b5e529e4ff274eb478ec1c2ef41358ed9577)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit e7fb921d9f62df05240ad1a74b5a0f623e503c9c)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
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>
(cherry picked from commit 8b983e90ea1a3dd82070f96c062ad521a06b7cc0)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>