summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
AgeCommit message (Collapse)Author
2017-08-18spi: omap: Allocate bus number from spi frameworkSuniel Mahesh
spi framework should allocate bus number dynamically either via Linux IDR or spi alias for master drivers. This patch deletes code pertaining to manual allocation of spi bus number in spi omap2 master driver. Signed-off-by: Suniel Mahesh <sunil.m@techveda.org> Signed-off-by: Karthik Tummala <karthik@techveda.org> Tested-by: Karthik Tummala <karthik@techveda.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26spi: omap2-mcspi: remove redundant check for error statusColin Ian King
The check to see if status is less than zero is actually redundant as all previous places where it is -ve have already branched to the exit paths, so it is never less than zero at the check. Detected by CoverityScan, CID#1357119 ("Logically dead code") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-24spi: omap2-mcspi: poll OMAP2_MCSPI_CHSTAT_RXS for PIO transferAkinobu Mita
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>
2016-10-24spi: omap2-mcspi: Remove redundant return value check of platform_get_resource()Wei Yongjun
Remove unneeded error handling on the result of a call to platform_get_resource() when the value is passed to devm_ioremap_resource(). Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-10-21spi: omap2-mcspi: Fix modifying platform resource dataVikram N
currently during probe the resource data gets modified and device physical address remains valid only during first load. If the module is unloaded and loaded again, the ioremp will be done on a incorrect address as the resource was modified during previous module load. This patch fixes this issue. Signed-off-by: Vikram N <vicky773@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-07-08spi: omap2-mcspi: Use the SPI framework to handle DMA mappingFranklin S Cooper Jr
Currently, the driver handles mapping buffers to be used by the DMA. However, there are times that the current mapping implementation will fail for certain buffers. Fortunately, the SPI framework can detect and map buffers so its usable by the DMA. Update the driver to utilize the SPI framework for buffer mapping instead. Also incorporate hooks that the framework uses to determine if the DMA can or can not be used. This will result in the original omap2_mcspi_transfer_one function being deleted and omap2_mcspi_work_one being renamed to omap2_mcspi_transfer_one. Previously transfer_one was only responsible for mapping and work_one handled the transfer. But now only transferring needs to be handled by the driver. Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-07-05spi: omap2-mcspi: Add comments for RX only DMA buffer workaroundFranklin S Cooper Jr
OMAP35x and OMAP37x mentions in the McSPI End-of-Transfer Sequences section that if the McSPI is configured as a Master and only DMA RX is being performed then the DMA transfer size needs to be reduced by 1 or 2. This was originally implemented by: commit 57c5c28dbc83 ("spi: omap2_mcspi rxdma bugfix") This patch adds comments to clarify what is going on in the code since its not obvious what problem its addressing. Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-04-29spi: omap2-mcspi: Use dma_request_chan() for requesting DMA channelPeter Ujfalusi
With the new dma_request_chan() the client driver does not need to look for the DMA resource and it does not need to pass filter_fn anymore. By switching to the new API the driver can now support deferred probing against DMA. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-02-12spi: omap2-mcspi: Fix PM regression with deferred probe for pm_runtime_reinitTony Lindgren
Commit 5de85b9d57ab ("PM / runtime: Re-init runtime PM states at probe error and driver unbind") introduced pm_runtime_reinit() that is used to reinitialize PM runtime after -EPROBE_DEFER. This allows shutting down the device after a failed probe. However, for drivers using pm_runtime_use_autosuspend() this can cause a state where suspend callback is never called after -EPROBE_DEFER. On the following device driver probe, hardware state is different from the PM runtime state causing omap_device to produce the following error: omap_device_enable() called from invalid state 1 And with omap_device and omap hardware being picky for PM, this will block any deeper idle states in hardware. The solution is to fix the drivers to follow the PM runtime documentation: 1. For sections of code that needs the device disabled, use pm_runtime_put_sync_suspend() if pm_runtime_set_autosuspend() has been set. 2. For driver exit code, use pm_runtime_dont_use_autosuspend() before pm_runtime_put_sync() if pm_runtime_use_autosuspend() has been set. Fixes: 5de85b9d57ab ("PM / runtime: Re-init runtime PM states at probe error and driver unbind") Cc: linux-spi@vger.kernel.org Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Kevin Hilman <khilman@baylibre.com> Cc: Mark Brown <broonie@kernel.org> Cc: Nishanth Menon <nm@ti.com> Cc: Rafael J. Wysocki <rafael@kernel.org> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-12-01spi: omap2-mcspi: Prevent duplicate gpio_requestMichael Welling
Occasionally the setup function will be called multiple times. Only request the gpio the first time otherwise -EBUSY will occur on subsequent calls to setup. Reported-by: Joseph Bell <joe@iachieved.it> Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-11-19spi: omap2-mcspi: Add calls for pinctrl state selectPascal Huerst
This adds calls to pinctrl subsystem in order to switch pin states on suspend/resume if you provide a "sleep" state in DT. If no "sleep" state is provided in DT, these calls turn to NOPs. Signed-off-by: Pascal Huerst <pascal.huerst@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-22spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_messageNeil Armstrong
Since the "Switch driver to use transfer_one" change, the cs_change behavior has changed and a channel chip select can still be asserted when changing channel from a previous last transfer in a message having the cs_change attribute. Since there is no sense having multiple chip select being asserted at the same time, disable all the remaining forced chip selects in a the prepare_message called right before a spi_transfer_one_message call. It ignores the current channel configuration in order to keep the possibility to leave the chip select asserted between messages. It fixes this bug on a DM8168 SoC ES2.1 Soc and an OMAP4 ES2.1 SoC. It was hanging all the other channels transfers when a CHCONF_FORCE is present on the wrong channel. Fixes: b28cb9414db9 ("spi: omap2-mcspi: Switch driver to use transfer_one") Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-07-24spi: omap2-mcspi: add runtime PM to set_cs()Sebastian Reichel
Since commit ddcad7e9068eb omap2_mcspi_set_cs() is called without runtime power management requested. This patch fixes the problem by requesting runtime power management in omap2_mcspi_set_cs(). Reported-By: Pali Rohár <pali.rohar@gmail.com> Fixes: ddcad7e9068eb (spi: omap2-mcspi: Fix native cs with new set_cs) Tested-By: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sre@kernel.org> Acked-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-25spi: omap2-mcspi: Handle error on gpio_requestMichael Welling
If a valid GPIO is specified but cannot be requested by the driver, print a message and error out of omap2_mcspi_setup. Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-25spi: omap2-mcspi: Fix GPIO chip select supportMichael Welling
The OMAP2_MCSPI_CHCONF_FORCE must be toggled even when using GPIO chip selects. This patch conditionally calls the omap2_mcspi_set_cs function to do so when using GPIO chip selects. Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-25spi: omap2-mcspi: Fix set_cs function for active highMichael Welling
The core spi driver swaps the polarity of the enable based on SPI_CS_HIGH. The omap2 controller has an internal configuration register bit called OMAP2_MCSPI_CHCONF_EPOL to handle active high chip selects as well. So we have to revert swap the polarity back for the correct setting of the OMAP2_MCSPI_CHCONF_FORCE bit in omap2_mcspi_set_cs. Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-25spi: omap2-mcspi: Remove unnecessary delayMichael Welling
The core spi driver handles the delay between transactions. This is a remanant from the transfer_one conversion. Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-12spi: omap2-mcspi: Fix native cs with new set_csMichael Welling
GPIO chip select patch series appears to have broken the native chip select support. This patch pulls the manual native chip select toggling out of the transfer_one routine and adds a set_cs routine. Tested natively on AM3354 with SPI serial flash on spi0cs0. Reported-by: Nishanth Menon <nm@ti.com> Signed-off-by: Michael Welling <mwelling@ieee.org> Tested-by: Nishanth Menon <nm@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-08spi: omap2-mcspi: Add gpio_request and init CSMichael Welling
If GPIO chip select is specified, request the GPIO in the setup function and release it in the cleanup function. Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-05-08spi: omap2-mcspi: Switch driver to use transfer_oneMichael Welling
Switches from transfer_one_message to transfer_one to prepare driver for use of GPIO chip selects. Signed-off-by: Michael Welling <mwelling@ieee.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-04-24spi/omap2-mcpsi: Always call spi_finalize_current_message()Fionn Cleary
The spi queue waits forever for spi_finalize_current_message() to be called, blocking the bus. Ensure that all error paths from omap2_mcspi_transfer_one_message() call spi_finalize_current_message(). Signed-off-by: Fionn Cleary <fionn.cleary@streamunlimited.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-12-22spi: Remove FSF mailing addressesJarkko Nikula
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-20spi: drop owner assignment from platform_driversWolfram Sang
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>
2014-08-11spi/omap-mcspi: Fix the spi task hangs waiting dma_rxJorge A. Ventura
The spi hangs waiting the completion of omap2_mcspi_rx_callback. Signed-off-by: Jorge A. Ventura <jorge.araujo.ventura@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org
2014-07-03spi: omap2-mcspi: Configure hardware when slave driver changes modeMark A. Greer
Commit id 2bd16e3e23d9df41592c6b257c59b6860a9cc3ea (spi: omap2-mcspi: Do not configure the controller on each transfer unless needed) does its job too well so omap2_mcspi_setup_transfer() isn't called even when an SPI slave driver changes 'spi->mode'. The result is that the mode requested by the SPI slave driver never takes effect. Fix this by adding the 'mode' member to the omap2_mcspi_cs structure which holds the mode value that the hardware is configured for. When the SPI slave driver changes 'spi->mode' it will be different than the value of this new member and the SPI master driver will know that the hardware must be reconfigured (by calling omap2_mcspi_setup_transfer()). Fixes: 2bd16e3e23 (spi: omap2-mcspi: Do not configure the controller on each transfer unless needed) Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org
2014-04-10Merge remote-tracking branches 'spi/fix/complete', 'spi/fix/efm32', ↵Mark Brown
'spi/fix/omap2-mcspi' and 'spi/fix/qup' into spi-linus
2014-04-03spi: omap2-mcspi: Convert to use devm_kcallocAxel Lin
This saves a few unwind code and return proper error if devm_kcalloc fails. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-30Merge remote-tracking branches 'spi/topic/omap-uwire', 'spi/topic/omap100k', ↵Mark Brown
'spi/topic/omap2', 'spi/topic/orion', 'spi/topic/pl022', 'spi/topic/qup', 'spi/topic/rspi' and 'spi/topic/s3c24xx' into spi-next
2014-02-19spi: omap2-mcspi: Convert to let spi core validate transfer speedAxel Lin
Set master->max_speed_hz and master->min_speed_hz then spi core will handle checking transfer speed. So we can remove the same checking in this driver. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-19spi: omap2-mcspi: Remove list_empty checking in omap2_mcspi_transfer_one_messageAxel Lin
This checking is done in __spi_validate(). Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03spi: omap2-mcspi: Support divide-by-n clock dividersStefan Sørensen
Currently a divide-by-2^n clock is used, causing a very coarse clock selection, i.e. a 10MHz device will need to use a 6MHz clock. The McSPI can also use a divide-by-n clock, this patch adds support for selecting that when possible. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03spi: omap2-mcspi: Do not configure the controller on each transfer unless neededStefan Sørensen
spi_transfer->speed_hz and spi_transfer->bits_per_word used to only be set when not using the default settings but are not set on every transfer, causing omap2_mcspi_setup_transfer to be called on each transfer. This patch changes the check to only call omap2_mcspi_setup_transfer if the settings needs to be changed. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03spi: delete non-required instances of include <linux/init.h>Paul Gortmaker
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-11-24spi: omap2-mcspi: raw read and write endian fixVictor Kamensky
All OMAP IP blocks expect LE data, but CPU may operate in BE mode. Need to use endian neutral functions to read/write h/w registers. I.e instead of __raw_read[lw] and __raw_write[lw] functions code need to use read[lw]_relaxed and write[lw]_relaxed functions. If the first simply reads/writes register, the second will byteswap it if host operates in BE mode. Changes are trivial sed like replacement of __raw_xxx functions with xxx_relaxed variant. Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-25Merge remote-tracking branch 'spi/topic/bfin' into spi-nextMark Brown
2013-10-25Merge remote-tracking branch 'spi/topic/atmel' into spi-nextMark Brown
2013-10-16spi: Add missing newline to dev_ prints in driversJarkko Nikula
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09spi: omap2-mcspi: Fix FIFO support for transmit-and-receive modeIllia Smyrnov
This patch fixes MCSPI FIFO buffer support when transmit-and-receive (full duplex) mode is used. In this mode FIFO can be used for RX or for TX or for both directions. If FIFO used for both directions the buffer is split into two 32-byte buffers - one for each direction. Also for full duplex mode both AEL and AFL need to be set in CHCONF0 register. Signed-off-by: Illia Smyrnov <illia.smyrnov@globallogic.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26spi: omap2-mcspi: use devm_spi_register_master()Jingoo Han
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>
2013-09-01Merge remote-tracking branch 'spi/topic/qspi' into spi-nextMark Brown
2013-08-29spi: use dev_get_platdata()Jingoo Han
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>
2013-07-29spi/omap2: Covert to core runtime PMMark Brown
Signed-off-by: Mark Brown <broonie@linaro.org> Reviewed-by: Felipe Balbi <balbi@ti.com>
2013-06-26Merge remote-tracking branch 'spi/topic/pdata' into spi-nextMark Brown
2013-06-26Merge remote-tracking branch 'spi/topic/omap' into spi-nextMark Brown
2013-06-24spi: omap2-mcspi: convert to dma_request_slave_channel_compat()Matt Porter
Convert dmaengine channel requests to use dma_request_slave_channel_compat(). This supports the DT case of platforms requiring channel selection from either the OMAP DMA or the EDMA engine. AM33xx only boots from DT and is the only user implementing EDMA so in the !DT case we can default to the OMAP DMA filter. Signed-off-by: Matt Porter <mporter@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Joel A Fernandes <joelagnel@ti.com> Signed-off-by: Sourav Poddar <sourav.poddar@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-17spi: omap2-mcspi: Add FIFO buffer supportIllia Smyrnov
The MCSPI controller has a built-in FIFO buffer to unload the DMA or interrupt handler and improve data throughput. This patch adds FIFO buffer support for SPI transfers in DMA mode. For SPI transfers in DMA mode, the largest possible FIFO buffer size will be calculated and set up. The FIFO won't be used for the SPI transfers in DMA mode if: calculated FIFO buffer size is less then 2 bytes or the FIFO buffer size isn't multiple of the SPI word length. Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-17spi: omap2-mcspi: Move bytes per word calculation to the functionIllia Smyrnov
Introduce mcspi_bytes_per_word function as replacement for the next code fragment: int c = (word_len <= 8) ? 1 : (word_len <= 16) ? 2 : /* word_len <= 32 */ 4; This code used 2 times in current driver code and will be used 2 times in the next FIFO buffer support patch. Replace it with inline function with clear name to improve code legibility. Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-05-29spi: convert drivers to use bits_per_word_maskStephen Warren
Fill in the recently added spi_master.bits_per_word_mask field in as many drivers as possible. Make related cleanups, such as removing any redundant error-checking, or empty setup callbacks. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-23spi: use platform_{get,set}_drvdata()Jingoo Han
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>
2013-05-13spi/omap2: Let device core handle pinctrlMark Brown
Since commit ab78029 (drivers/pinctrl: grab default handles from device core) we can rely on device core for handling pinctrl so remove devm_pinctrl_get_select_default() from the driver. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>