summaryrefslogtreecommitdiffstats
path: root/drivers/spi
AgeCommit message (Collapse)AuthorFilesLines
2015-10-16spi: pxa2xx: choose closest lower speedAndy Shevchenko1-4/+4
As per discussion [1] the best choice is to set closest speed which is not going over the asked one. Do the same approach for Intel Quark boards. [1] http://www.spinics.net/lists/linux-spi/msg03389.html Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-16spi: core: propagate return code of __spi_validate_bits_per_word()Andy Shevchenko1-3/+4
Propagate the actual return code of __spi_validate_bits_per_word() in spi_setup(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-16spi: bcm2835aux: change initialization order and switch to platform_get_irqMartin Sperl1-4/+4
Change the initialization order of the HW so that the interrupt is only requested after the HW is initialized Also the use of irq_of_parse_and_map is replaced by platform_get_irq. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-16spi: bcm2835aux: fixed bad data on longer transfersMartin Sperl1-12/+31
There are strange issues with the auxiliary spi device that result in "lost" data in the RX path if the fifo is filled by too much (even though the status register is checked if new data can get filled in). This has been observed primarily for the interrupt case. Polling works fine, probably because the RX fifo is pulled immediately when in the tight polling loop. For that reason we have to limit the pending bytes to less than 15 when filling the fifo in interrupt mode. There also was an issue returning the "wrong" last 1/2 bytes of a transfer when the transfer is not a multiple of 3 bytes. (this impacted polling and interrupt modes) Also fixed an overflow in the estimation of the transfer time used to decide if we run in interrupt or polling mode (found with the spi-bcm2835.c driver originally). Reported-by: Georgii Staroselskii <georgii.staroselskii@emlid.com> Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-16spi: bcm2835: change initialization order and switch to platform_get_irqMartin Sperl1-7/+7
Change the initialization order of the HW so that the interrupt is only requested after the HW is initialized Also the use of irq_of_parse_and_map is replaced by platform_get_irq. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-12spi: ti-qspi: Fix data corruption seen on r/w stress testVignesh R1-2/+1
Writing invalid command to QSPI_SPI_CMD_REG will terminate current transfer and de-assert the chip select. This has to be done before calling spi_finalize_current_message(). Because spi_finalize_current_message() will mark the end of current message transfer and schedule the next transfer. If the chipselect is not de-asserted before calling spi_finalize_current_message() then the next transfer will overlap with the previous transfer leading to data corruption. __spi_pump_message() can be called either from kthread worker context or directly from the calling process's context. It is possible that these two calls can race against each other. But race is serialized by checking whether master->cur_msg == NULL (pointer to msg being handled by transfer_one() at present). The master->cur_msg is set to NULL when spi_finalize_current_message() is called on that message, which means calling spi_finalize_current_message() allows __spi_sync() to pump next message in calling process context. Now if spi-ti-qspi calls spi_finalize_current_message() before we terminate transfer at hardware side, if __spi_pump_message() is called from process context then the successive transactions can overlap. Fix this by moving writing invalid command to QSPI_SPI_CMD_REG to before calling spi_finalize_current_message() call. Cc: stable@vger.kernel.org # v3.12+ Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-12spi: Map SPI OF client IRQ at probe timeJon Hunter1-4/+10
Currently the IRQs for SPI client devices, registered via device-tree, are mapped when the client devices are registered. If the corresponding irq-chip has not been probed yet, then the probing of the client device will fail and will not be retried. Resolve this by mapping the IRQ at probe time and allow the probe to be deferred if the IRQ is not yet available. If of_irq_get() returns an error that is not -EPROBE_DEFER, then assume that the SPI client does not have an IRQ and set the IRQ number to zero (which is equivalent to irq_of_parse_and_map()). This is based on some inputs from Thierry Reding <treding@nvidia.com>. Cc: Thierry Reding <treding@nvidia.com> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com> Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-12spi/bcm63xx: move message control word description to register offsetsJonas Gorski1-4/+3
Make the message control word parameters part of the register offsets array so we have them all in one struct. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-12spi/bcm63xx: fix standard accessors and compile guardJonas Gorski1-4/+4
Use the correct guard CONFIG_CPU_BIG_ENDIAN and the *be accessors to follow native endianness on big endian systems. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-12spi: spi-coldfire-qspi: enable RuntimePM before registering to the coreWolfram Sang1-1/+2
The core may register clients attached to this master which may use funtionality from the master. So, RuntimePM must be enabled before, otherwise this will fail. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-07Merge remote-tracking branches 'spi/fix/davinci' and 'spi/fix/sh-msiof' into ↵Mark Brown1-3/+4
spi-linus
2015-10-07spi: bcm2835aux: add bcm2835 auxiliary spi device driverMartin Sperl3-0/+505
The bcm2835 has 2 auxiliary spi bus masters spi1 and spi2. This implements the driver to enable these devices. The driver does not implement native chip-selects but uses the aribtrary GPIO-chip-selects provided by the spi-chipselect. Note that this driver relies on the fact that the clock is implemented by the clk-bcm2835-aux driver, which enables/disables the HW block when requesting/releasing the clock. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Acked-by: Eric Anholt <eric@anholt.net> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-05spi: bitbang: switch to the generic implementation of transfer_one_messageHeiner Kallweit1-89/+36
Change the bitbang driver to use the generic implementation of transfer_one_message. This simplifies the bitbang driver code and provides benefits like the statistics in the generic implementation. Successfully tested on a IMX6-based system (spi-imx) and on a MIPS-based router (OpenWRT with spi-ath79). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-05spi: bitbang: remove unneeded checkHeiner Kallweit1-14/+4
Remove an unneeded check. The SPI core (__spi_validate) takes care that these fields are always populated. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-02spi: pxa2xx: Remove unused psp member variable from struct chip_dataJarkko Nikula1-1/+0
It is not used since commit 8d94cc50aa4f ("[PATCH] spi: stabilize PIO mode transfers on PXA2xx systems"). Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-01spi: pxa2xx: Remove empty function pxa2xx_spi_dma_resume()Mika Westerberg3-8/+0
This was leftover from the legacy pxa2xx DMA implementation and not needed anymore so remove it. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-30spi: ath79: simplify iomem resource mappingHeiner Kallweit1-8/+3
Simplify the code by switching from devm_ioremap to devm_ioremap_resource. Checking the result of platform_get_resource is not needed as devm_ioremap_resource checks the provided resource argument for NULL. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-25spi: davinci: fix handling platform_get_irq resultAndrzej Hajda1-3/+4
The function can return negative value. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-25spi: atmel: Remove needless bits_per_word and speed_hz testsJarkko Nikula1-15/+6
SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. This makes possible to remove two if statements and remove one code block that is never executed. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-25spi: pxa2xx: Use ACPI_COMPANION() instead of acpi_bus_get_device()Jarkko Nikula1-2/+2
Get pointer to the struct acpi_device by using ACPI_COMPANION() macro. This is more efficient than using ACPI_HANDLE() and acpi_bus_get_device(). Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-25spi: pxa2xx: Set the max_speed_hz of the masterJarkko Nikula2-9/+6
Carry input clock of the controller in max_speed_hz of struct spi_master instead of in own driver data. They mean the same thing and more over now the max_speed_hz is not even set here. As an added bonus this allows SPI core to validate that transfer speed is not beyond the maximum input clock. This is not a problem in spi-pxa2xx as the driver doesn't use transfer speed parameter directly but via input clock divider calculation which will top at divide by one. However it's better to validate speed before passing it here. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-22Merge remote-tracking branches 'spi/fix/spidev' and 'spi/fix/xtfpga' into ↵Mark Brown2-3/+4
spi-linus
2015-09-22Merge remote-tracking branches 'spi/fix/atmel', 'spi/fix/bcm2835', ↵Mark Brown6-35/+34
'spi/fix/doc', 'spi/fix/mediatek', 'spi/fix/meson', 'spi/fix/mtk' and 'spi/fix/pxa2xx' into spi-linus
2015-09-22spi: xtensa-xtfpga: fix register endiannessMax Filippov1-2/+2
XTFPGA SPI controller has native endian registers. Fix register acessors so that they work in big-endian configurations. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2015-09-19spi: add transfer histogram statistics via sysfsMartin Sperl1-0/+61
report transfer sizes as a histogram via the following files: /sys/class/spi_master/spi*/statistics/transfer_bytes_histo_* /sys/class/spi_master/spi*/spi*.*/statistics/transfer_bytes_histo_* Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-19spi: meson: Fix module autoload for OF platform driverLuis de Bethencourt1-0/+1
This platform driver has a OF device ID table but the OF module alias information is not created so module autoloading won't work. Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: pxa2xx: Remove cr0 variable from struct chip_dataJarkko Nikula2-7/+4
There hasn't been need to carry chip->cr0 after SPI core started to validate speed_hz and bits_per_word transfer parameters. That effectively caused that pump_transfers() always recalculated it and practically chip->cr0 is used locally in setup() for debug prints only. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: pxa2xx: Remove if statement that is always true in pump_transfers()Jarkko Nikula1-39/+37
This is continuation to previous commit by separating unindentation from variable removal done in previous commit. As said SPI core have validated both the speed_hz and bits_per_word and the if statement here evaluates always to true. Remove the test and unindent the code block accordingly. While at it remove also needless "cr0 = chip->cr0" as cr0 will be overwritten anyway and fix block comment style. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: pxa2xx: Remove two variables from struct chip_dataJarkko Nikula2-12/+2
There is no need to carry spi->max_speed_hz and spi->bits_per_word from setup() in "struct chip_data" since pump_transfers() will anyway take the transfer parameters from "struct spi_transfer". This is since SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: spi-fsl-dspi: Remove duplicated register writeJarkko Nikula1-3/+0
SPI core makes sure that transfer speed is always set so code here writes the same register with the same value twice. Code has been doing this from the beginning. This looks to me some sort of copy paste error so I'm removing the second write. If this is not the case we can bring it back with a comment. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: dw: Remove test for non-zero spi->max_speed_hzJarkko Nikula1-5/+0
Test for non-zero spi->max_speed_hz in dw_spi_setup() looks needless as spi_setup() defaults to master->max_speed_hz in case it is not set. This drivers sets the master->max_speed_hz based on max_freq data passed to it via dw_spi_add_host() call. I suppose things have already fallen apart if dw_spi_mmio_probe() or spi_pci_probe() ever passes zero max_freq. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: dw: Remove needless if statementsJarkko Nikula1-23/+18
SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. This allows to remove related if statements as they evaluate always to true and reduce indentation. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: omap-100k: Rely on validations done by spi coreJarkko Nikula1-18/+8
SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. This allows to remove a few if statements around per transfer bits_per_word and speed_hz tests as they evaluate always to true. Also defaulting word_len to 8 is needless since spi_setup() has already made sure spi->bits_per_word is 8 in case it is not set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: omap-uwire: Remove needless bits_per_word and speed_hz testsJarkko Nikula1-3/+4
SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. This allows to remove two needless tests from uwire_txrx() and uwire_setup_transfer(). Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: mpc512x: Call mpc512x_psc_spi_transfer_setup() unconditionallyJarkko Nikula1-5/+3
SPI core validates both bits_per_word and speed_hz transfer parameters and thus the if statement here is needless as it will always call the mpc512x_psc_spi_transfer_setup(). Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-17spi: bitbang: Replace spinlock by mutexNicolas Boichat3-14/+11
chipselect (in the case of spi-gpio: spi_gpio_chipselect, which calls gpiod_set_raw_value_cansleep) can sleep, so we should not hold a spinlock while calling it from spi_bitbang_setup. This issue was introduced by this commit, which converted spi-gpio to cansleep variants: d9dda5a191 "spi: spi-gpio: Use 'cansleep' variants to access GPIO" Replacing the lock variable by a mutex fixes the issue: This is safe as all instances where the lock is used are called from contexts that can sleep. Finally, update spi-ppc4xx and and spi-s3c24xx to use mutex functions, as they directly hold the lock for similar purpose. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: au1550: Simplify au1550_spi_setupxfer()Jarkko Nikula1-6/+5
SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. This can simplify a little the au1550_spi_setupxfer() as there is need to check only for valid "struct spi_transfer" pointer. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: spi-bfin5xx: Calculate transfer speed unconditionallyJarkko Nikula1-5/+1
SPI core validates the transfer speed and defaults to spi->max_speed_hz in case the transfer speed is not set so code here won't use the chip->baud value (which is derived from spi->max_speed_hz). Please note driver uses chip->baud at the beginning of message transmission by calling the bfin_spi_restore_state() but then programs per transfer speed in bfin_spi_pump_transfers(). I'm not familiar with the HW so I don't know would it be possible to remove chip->baud completely by either using constant value in bfin_spi_restore_state() or by removing the baud register write there. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: bfin-sport: Calculate transfer speed unconditionallyJarkko Nikula1-4/+1
SPI core validates the transfer speed and defaults to spi->max_speed_hz in case the transfer speed is not set so code here won't use the chip->baud value (which is derived from spi->max_speed_hz). Please note driver uses chip->baud at the beginning of message transmission by calling the bfin_sport_spi_restore_state() but then programs per transfer speed in bfin_sport_spi_pump_transfers(). I'm not familiar with the HW so I don't know would it be possible to remove chip->baud completely by either using constant value in bfin_sport_spi_restore_state() or by removing the tclkdiv register write there. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: octeon: Use transfer speed unconditionallyJarkko Nikula1-1/+1
SPI core validates the transfer speed and defaults to spi->max_speed_hz in case the transfer speed is not set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: s3c64xx: Use transfer speed unconditionallyJarkko Nikula1-1/+1
SPI core validates the transfer speed and defaults to spi->max_speed_hz in case the transfer speed is not set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: txx9: Use transfer speed unconditionallyJarkko Nikula1-1/+1
SPI core validates the transfer speed and defaults to spi->max_speed_hz in case the transfer speed is not set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: mediatek: fix wrong error return value on probeJavier Martinez Canillas1-2/+2
Commit adcbcfea15d62 ("spi: mediatek: fix spi clock usage error") added a new sel_clk but introduced bugs in the error paths since the wrong struct clk pointers are passed to PTR_ERR(). Fixes: adcbcfea15d62 ("spi: mediatek: fix spi clock usage error") Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16Merge tag 'v4.3-rc1' into spi-fix-docMark Brown35-223/+1917
Linux 4.3-rc1
2015-09-16spi: oc-tiny: Use of_property_read_u32 instead of open-coding itTobias Klauser1-9/+5
Use of_property_read_u32 instead of of_get_property with return value checks and endianness conversion. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-16spi: bcm53xx: Adjust devm usageVaishali Thakkar1-11/+2
Remove use of spi_unregister_master in remove function as devm_spi_register_master in probe function automatically handles it. To be compatible with the change, use direct return instead of goto and remove unnedded label out. Also, remove bcm53xxspi_bcma_remove as it is now redundant. Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-14spi/bcm63xx: replace custom io accessors with standard onesJonas Gorski1-4/+12
Replace all bcm_read* with (io)read. Due to this block following system endianness, make sure we match that. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-14spi/bcm63xx: hardcode busnum to 0Jonas Gorski1-1/+2
We always pass 0 as the spi bus number, so we might as well hard code it. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-14spi/bcm63xx: always use a fixed number of CSJonas Gorski1-1/+3
We always pass 8 for the number of chip selects, so we can as well hardcode it to this number. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-09-14spi/bcm63xx: remove unused rx_tail variableJonas Gorski1-1/+0
Fixes the following warning: drivers/spi/spi-bcm63xx.c:125:5: warning: unused variable 'rx_tail' [-Wunused-variable] u8 rx_tail; ^ Signed-off-by: Jonas Gorski <jogo@openwrt.org> Signed-off-by: Mark Brown <broonie@kernel.org>