summaryrefslogtreecommitdiffstats
path: root/drivers/spi
AgeCommit message (Collapse)AuthorFilesLines
2017-05-22spi: spi-fsl-dspi: ensure non-zero return on error pathNikita Yushchenko1-1/+2
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-19spi: imx: fix issue when tx_buf or rx_buf is NULLJiada Wang1-0/+6
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-14spi: imx: dynamic burst length adjust for PIO modeJiada Wang1-8/+149
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-14spi: bcm63xx-hsspi: Export OF device ID table as module aliasesAndres Galacho1-0/+1
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-14spi: SPI_TI_QSPI should depend on HAS_DMAGeert Uytterhoeven1-0/+1
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-14spi: core: Replace S_IRUGO permissions by 0444Geert Uytterhoeven1-2/+2
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-14spi: core: Fix devm_spi_register_master() function name in kerneldocGeert Uytterhoeven1-1/+1
Fixes: 666d5b4c742ba666 ("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-14spi: spidev: use memdup_userGeliang Tang1-9/+1
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-14spi: spidev: remove unused completionSeraphime Kirkovski1-1/+0
This removes an unused completion from spidev_sync. It was introduced in commit 25d5cb4b0375e ("spi: remove some spidev oops-on-rmmod paths") and it was no longer used after: commit 98d6f47958001 ("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-04-26Merge remote-tracking branches 'spi/topic/ti-qspi' and 'spi/topic/xlp' into ↵Mark Brown4-12/+63
spi-next
2017-04-26Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/spidev-test', ↵Mark Brown7-66/+175
'spi/topic/sunxi', 'spi/topic/tegra' and 'spi/topic/test' into spi-next
2017-04-26Merge remote-tracking branches 'spi/topic/loopback', ↵Mark Brown4-14/+65
'spi/topic/omap2-mcspi', 'spi/topic/orion', 'spi/topic/pl022' and 'spi/topic/sc18is602' into spi-next
2017-04-26Merge remote-tracking branches 'spi/topic/devprop', 'spi/topic/fsl', ↵Mark Brown5-10/+51
'spi/topic/fsl-dspi', 'spi/topic/imx' and 'spi/topic/lantiq' into spi-next
2017-04-26Merge remote-tracking branches 'spi/topic/atmel', 'spi/topic/bcm63xx', ↵Mark Brown5-80/+210
'spi/topic/cadence' and 'spi/topic/davinci' into spi-next
2017-04-26Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown1-1/+1
2017-04-26Merge remote-tracking branches 'spi/fix/dw', 'spi/fix/lantiq' and ↵Mark Brown3-217/+224
'spi/fix/pl022' into spi-linus
2017-04-26spi: cadence: Allow for GPIO pins to be used as chipselectsMoritz Fischer1-0/+65
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-25spi-imx: Implements handling of the SPI_READY mode flag.Leif Middelschulte1-2/+18
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-24spi: tegra: fix spelling mistake: "trasfer" -> "transfer"Colin Ian King3-3/+3
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-21spi: spi-ti-qspi: Use bounce buffer if read buffer is not DMA'bleVignesh R1-7/+59
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-21spi: Add can_dma like interface for spi_flash_readVignesh R1-1/+1
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-18spi: dw: Disable clock after unregistering the hostMarek Vasut1-1/+1
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-18spi: double time out toleranceHauke Mehrtens1-1/+1
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-18spi: atmel: add deepest PM support to SAMA5D2Quentin Schulz1-0/+9
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-12spi: atmel: factorize reusable code for SPI controller initQuentin Schulz1-14/+21
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-07spi: orion: add LSB supportBastian Stender1-2/+9
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 b15d5d7004e2 ("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-06spi: pl022: don't use uninitialized variableRabin Vincent1-1/+1
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-03-30spi: loopback-test: fix spelling mistake: "minimam" -> "minimum"Colin Ian King1-1/+1
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-27spi: spi-ti-qspi: Remove unused dma_dev variableVignesh R1-1/+0
commit 1351aaeb50b2 ("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-24spi: omap2-mcspi: poll OMAP2_MCSPI_CHSTAT_RXS for PIO transferAkinobu Mita1-4/+5
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-24spi: spi-ti-qspi: Use dma_engine wrapper for dma memcpy callVignesh R1-2/+1
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-20spi: loopback-test: fix potential integer overflow on multipleColin Ian King1-1/+2
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: ea9936f324356 ("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-20spi: sun6i: update max transfer size reportedIcenowy Zheng1-3/+1
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-17spi: davinci: add comment about dummy tx buffer usageFrode Isaksen1-1/+5
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-17spi: loopback-test: add test spi_message with delay after transfersAkinobu Mita1-0/+19
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-17spi: loopback-test: add elapsed time checkAkinobu Mita2-0/+40
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-17spi: loopback-test: test zero-length transferAkinobu Mita1-1/+1
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-17spi: loopback-test: add ability to test zero-length transferAkinobu Mita2-48/+26
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-17spi: loopback-test: don't skip comparing the first byte of rx_bufAkinobu Mita1-1/+1
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-17spi: loopback-test: correct mismatched test description and configurationAkinobu Mita1-2/+2
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-17spi: loopback-test: fix compile error on x86Frode Isaksen1-0/+1
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-16spi: spidev: Add sx1301 to device tree compatibility listBen Whitten1-0/+1
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-15spi: loopback-test: add option to use vmalloc'ed buffersFrode Isaksen1-7/+27
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-15spi: davinci: do not use DMA for vmalloc'ed buffersFrode Isaksen1-1/+3
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-15spi: davinci: do not use DMA if transfer length is less than 16Frode Isaksen1-6/+8
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-15spi: davinci: use rx buffer as dummy tx bufferFrode Isaksen1-1/+7
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-13spi: xlp: update for ARCH_VULCAN2Jayachandran C2-1/+2
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-13spi: fsl: Call irq_dispose_mapping in err pathLiu Xiang1-1/+2
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-13spi/bcm63xx-hsspi: allow for probing through devicetreeJonas Gorski1-3/+20
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-13spi/bcm63xx-hsspi: allow providing clock rate through a second clockJonas Gorski1-2/+10
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>