OSDN Git Service

spi: bcm2835: enable dma modes for transfers meeting certain conditions
authorMartin Sperl <kernel@martin.sperl.org>
Sun, 10 May 2015 20:47:28 +0000 (20:47 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 11 May 2015 18:24:27 +0000 (19:24 +0100)
commit3ecd37edaa2a6ba3246e2c35714be9316b1087fe
tree98124c0cdb4f3f541de9dbc799dee36cba1cbc8b
parente0d58cdcaedd90e42162772f9b642e4ee680dd03
spi: bcm2835: enable dma modes for transfers meeting certain conditions

Conditions per spi_transfer are:
* transfer.len >= 96 bytes (to avoid mapping overhead costs)
* transfer.len < 65536 bytes (limitaion by spi-hw block - could get extended)
* an individual scatter/gather transfer length must be a multiple of 4
  for anything but the last transfer - spi-hw block limit.
  (some shortcut has been taken in can_dma to avoid unnecessary mapping of
   pages which, for which there is a chance that there is a split with a
   transfer length not a multiple of 4)

If it becomes a necessity these restrictions can get removed by additional
code.

Note that this patch requires a patch to dma-bcm2835.c by Noralf to
enable scatter-gather mode inside the dmaengine, which has not been
merged yet.

That is why no patch to arch/arm/boot/dts/bcm2835.dtsi is included - the
code works as before without dma when tx/rx are not set, but it writes
a message warning about dma not used:
spi-bcm2835 20204000.spi: no tx-dma configuration found - not using dma mode

To enable dma-mode add the following lines to the device-tree:
        dmas = <&dma 6>, <&dma 7>;
        dma-names = "tx", "rx";

Tested-by: Noralf Trønnes <noralf@tronnes.org> (private communication)
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bcm2835.c