summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-atmel.c
AgeCommit message (Collapse)AuthorFilesLines
2015-02-26spi: atmel: Fix interrupt setup for PDC transfersTorsten Fleischer1-6/+6
Additionally to the current DMA transfer the PDC allows to set up a next DMA transfer. This is useful for larger SPI transfers. The driver currently waits for ENDRX as end of the transfer. But ENDRX is set when the current DMA transfer is done (RCR = 0), i.e. it doesn't include the next DMA transfer. Thus a subsequent SPI transfer could be started although there is currently a transfer in progress. This can cause invalid accesses to the SPI slave devices and to SPI transfer errors. This issue has been observed on a hardware with a M25P128 SPI NOR flash. So instead of ENDRX we should wait for RXBUFF. This flag is set if there is no more DMA transfer in progress (RCR = RNCR = 0). Signed-off-by: Torsten Fleischer <torfl6749@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2015-02-04spi: atmel: cleanup wait_for_completion return handlingNicholas Mc Guire1-7/+5
return type of wait_for_completion_timeout is unsigned long not int, this patch adds an appropriate variable and fixes up the assignment. It removes the else branch as the only thing it was doing is assigning ret = 0; - but ret is never used thereafter so that is not needed. As the string in dev_err already states "timeout" there is little point in printing the 0. A typo in "trasfer" -> transfer is also fixed. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-12-15Merge tag 'driver-core-3.19-rc1' of ↵Linus Torvalds1-1/+0
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core update from Greg KH: "Here's the set of driver core patches for 3.19-rc1. They are dominated by the removal of the .owner field in platform drivers. They touch a lot of files, but they are "simple" changes, just removing a line in a structure. Other than that, a few minor driver core and debugfs changes. There are some ath9k patches coming in through this tree that have been acked by the wireless maintainers as they relied on the debugfs changes. Everything has been in linux-next for a while" * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits) Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries" fs: debugfs: add forward declaration for struct device type firmware class: Deletion of an unnecessary check before the function call "vunmap" firmware loader: fix hung task warning dump devcoredump: provide a one-way disable function device: Add dev_<level>_once variants ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries ath: use seq_file api for ath9k debugfs files debugfs: add helper function to create device related seq_file drivers/base: cacheinfo: remove noisy error boot message Revert "core: platform: add warning if driver has no owner" drivers: base: support cpu cache information interface to userspace via sysfs drivers: base: add cpu_device_create to support per-cpu devices topology: replace custom attribute macros with standard DEVICE_ATTR* cpumask: factor out show_cpumap into separate helper function driver core: Fix unbalanced device reference in drivers_probe driver core: fix race with userland in device_add() sysfs/kernfs: make read requests on pre-alloc files use the buffer. sysfs/kernfs: allow attributes to request write buffer be pre-allocated. fs: sysfs: return EGBIG on write if offset is larger than file size ...
2014-11-24spi: atmel: introduce probe deferringLudovic Desroches1-4/+16
Return probe defer if requesting a dma channel without a dma controller probed. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-24spi: atmel: remove compat for non DT board when requesting dma chanLudovic Desroches1-23/+2
All boards with a dma controller have DT support so using dma_request_slave_channel_compat is no more needed. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-22spi/atmel: improve the system suspend/resume functions implementationWenyou Yang1-35/+26
To make it cleaner, the system suspend/resume directly call the runtime suspend/resume functions and remove the wapper of CONFIG_PM_RUNTIME, CONFIG_PM_SLEEP. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Acked-by: Kevin Hilman <khilman@linaro.org> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-20spi: drop owner assignment from platform_driversWolfram Sang1-1/+0
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-10-20spi/atmel: fix simple_return.cocci warningsFengguang Wu1-6/+1
drivers/spi/spi-atmel.c:1518:1-4: WARNING: end returns can be simpified and declaration on line 1514 can be dropped Simplify a trivial if-return sequence. Possibly combine with a preceding function call. Generated by: scripts/coccinelle/misc/simple_return.cocci Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-20spi/atmel: add support for runtime PMWenyou Yang1-7/+61
Drivers should put the device into low power states proactively whenever the device is not in use. Thus implement support for runtime PM and use the autosuspend feature to make sure that we can still perform well in case we see lots of SPI traffic within short period of time. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-10-20spi/atmel: use dmaengine_terminate_all() APIVinod Koul1-4/+2
The drivers should use dmaengine_terminate_all() API instead of accessing the device_control which will be deprecated soon Signed-off-by: Vinod Koul <vinod.koul@intel.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-08-01spi/atmel: Fix pointer to int conversion warnings on 64 bit buildsMark Brown1-2/+2
On 64 bit systems integers are generally still 32 bit but long values and pointers are usually 64 bit. GCC warns when casting a 64 bit pointer into a 32 bit integer so cast to a long instead in order to avoid warnings. Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-17spi: atmel: Use dmaengine_prep_slave_sg() APIGeert Uytterhoeven1-12/+6
Use the inline wrapper introduced by commit 16052827d98fbc13c31ebad560af4bd53e2b4dd5 ("dmaengine/dma_slave: introduce inline wrappers"). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-02Merge remote-tracking branches 'spi/topic/adi', 'spi/topic/atmel' and ↵Mark Brown1-3/+6
'spi/topic/cadence' into spi-next
2014-05-07spi: atmel: fix incorrect comparisonAlexandre Belloni1-2/+3
Found using smatch: drivers/spi/spi-atmel.c:878 atmel_spi_pump_pio_data() warn: unsigned 'as->current_remaining_bytes' is never less than zero. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-18spi: atmel: Fix scheduling while atomic bugAlexander Stein1-0/+3
atmel_spi_lock does a spin_lock_irqsave, so we need to renable the interrupts when we want to schedule. Signed-off-by: Alexander Stein <alexanders83@web.de> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14spi: atmel: Make current_remaining_bytes to be intAxel Lin1-1/+3
Don't use unsigned for current_remaining_bytes so we can check current_remaining_bytes < 0 case. Use int is enough for current_remaining_bytes. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-30Merge remote-tracking branches 'spi/topic/imx', 'spi/topic/init', ↵Mark Brown1-1/+0
'spi/topic/mpc512x-psc', 'spi/topic/mpc52xx', 'spi/topic/mxs', 'spi/topic/nuc900', 'spi/topic/oc-tiny' and 'spi/topic/octeon' into spi-next
2014-03-30Merge remote-tracking branches 'spi/topic/bus-num', 'spi/topic/cleanup', ↵Mark Brown1-7/+0
'spi/topic/clps711x', 'spi/topic/coldfire', 'spi/topic/completion' and 'spi/topic/davinci' into spi-next
2014-03-30Merge remote-tracking branches 'spi/topic/altera', 'spi/topic/atmel', ↵Mark Brown1-14/+12
'spi/topic/au1550', 'spi/topic/bcm63xx', 'spi/topic/bcm63xx-hsspi', 'spi/topic/bfin5xx', 'spi/topic/bitbang' and 'spi/topic/bpw' into spi-next
2014-03-21spi: atmel: fix printk format warningsRandy Dunlap1-3/+3
Fix printk format warning by using %p extension 'ad' for dma_addr_t. drivers/spi/spi-atmel.c:1228:3: warning: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'dma_addr_t' [-Wformat] drivers/spi/spi-atmel.c:1228:3: warning: format '%x' expects argument of type 'unsigned int', but argument 9 has type 'dma_addr_t' [-Wformat] Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-05spi: atmel: add missing spi_master_{resume,suspend} calls to PM callbacksWenyou Yang1-1/+16
The PM callbacks implemented by the spi-atmel driver don't call spi_master_{resume,suspend}, fix that. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-05spi: atmel: adopt pinctrl supportWenyou Yang1-0/+9
Amend the spi atmel pin controller to optionally take a pin control handle and set the state of the pins to: - "default" on boot, resume and before performing an spitransfer - "sleep" on suspend() This should make it possible to optimize energy usage for the pins both for the suspend/resume cycle Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-03spi: atmel: Let spi core handle validating transfer lengthAxel Lin1-8/+0
spi core will handle validating transfer length since commit 4d94bd21b333 "spi: core: Validate length of the transfers in message". So 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-03-03spi: atmel: Remove redundant list_empty checkingAxel Lin1-3/+0
This checking is already done in __spi_validate(). Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-12spi: Remove duplicate code to check chip_selectAxel Lin1-7/+0
In spi_add_device(), we have the code to validate spi->chip_select. So remove the duplicate code in various drivers. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-03spi: delete non-required instances of include <linux/init.h>Paul Gortmaker1-1/+0
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>
2014-01-09spi: atmel: Refactor spi-atmel to use SPI framework queueWenyou Yang1-458/+220
Replace the deprecated master->transfer with transfer_one_message() and allow the SPI subsystem handle all the queuing of messages. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Tested-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-08spi: atmel: add support for changing message transfer speedRichard Genoud1-37/+55
The only speed available was max_speed (the maximum speed declared for a device). This patch adds the support for spi_tranfer->speed_hz parameter. We can now set a different speed for each spi message. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-12-04spi: atmel: Use devm_*() functionsJingoo Han1-12/+6
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-23spi: atmel: fix return value check in atmel_spi_probe()Wei Yongjun1-1/+3
In case of error, the function devm_ioremap_resource() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-17spi/atmel: Convert to devm_ioremap_resource()Mark Brown1-3/+1
This simplifies error handling. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-17Merge remote-tracking branch 'spi/topic/trivial' into spi-atmelMark Brown1-2/+4
Conflicts (trivial overlapping cleanups): drivers/spi/spi-atmel.c
2013-10-16spi: Don't break user-visible strings to multiple source lines in driversJarkko Nikula1-2/+2
User-visible strings are more difficult to grep from sources if they are separated to multiple source lines. This is worse than over 80 columns long line code style violation. Fix this by making those to single-line strings or by breaking them between variables. While at there, convert if (printk_ratelimit()) dev_warn() to use dev_warn_ratelimited in spi-pxa2xx.c. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-14spi: atmel: Fix checkpatch issueJingoo Han1-2/+1
Fix the following checkpatch warning. WARNING: quoted string split across lines Signed-off-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07spi: atmel: Fix incorrect error pathSachin Kamat1-1/+2
'irq' was not released when clk_prepare_enable failed. Fix it. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17spi: atmel: Silence checkpatch errorsSachin Kamat1-8/+8
Fixes the following types of checkpatch errors and warning: ERROR: space required after that ',' (ctx:VxV) WARNING: sizeof *as should be sizeof(*as) Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17spi: atmel: convert from legacy pm ops to dev_pm_opsJingoo Han1-11/+11
Instead of using legacy suspend/resume methods, using newer dev_pm_ops structure allows better control over power management. Also, duplicated 'return' is removed from atmel_spi_resume(). Signed-off-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-31spi/atmel: Fix format specifier warningsEmil Goode1-9/+11
This patch fixes the following sparse warnings. dma_addr_t can be either u32 or u64 so we should cast to the largest type and use the format specifier %llx. drivers/spi/spi-atmel.c: In function ‘atmel_spi_next_xfer_dma_submit’: drivers/spi/spi-atmel.c:631:2: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 7 has type ‘dma_addr_t’ [-Wformat] drivers/spi/spi-atmel.c:631:2: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 9 has type ‘dma_addr_t’ [-Wformat] drivers/spi/spi-atmel.c: In function ‘atmel_spi_pdc_next_xfer’: drivers/spi/spi-atmel.c:734:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 7 has type ‘dma_addr_t’ [-Wformat] drivers/spi/spi-atmel.c:734:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 9 has type ‘dma_addr_t’ [-Wformat] drivers/spi/spi-atmel.c:773:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 7 has type ‘dma_addr_t’ [-Wformat] drivers/spi/spi-atmel.c:773:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 9 has type ‘dma_addr_t’ [-Wformat] Signed-off-by: Emil Goode <emilgoode@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-28spi/atmel: Annotate lock/unlock functionsMark Brown1-2/+2
Let checkers like sparse know that the locking imbalances are intentional in these functions. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-17spi: atmel: prepare clk before calling enableBoris BREZILLON1-5/+7
Replace clk_enable/disable with clk_prepare_enable/disable_unprepare to avoid common clk framework warnings. Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-26Merge remote-tracking branch 'spi/topic/bpw' into spi-nextMark Brown1-8/+1
2013-06-03spi: atmel: convert to dma_request_slave_channel_compat()Richard Genoud1-15/+27
Use generic DMA DT helper. Platforms booting with or without DT populated are both supported. Based on Ludovic Desroches <ludovic.desroches@atmel.com> patchset "ARM: at91: move to generic DMA device tree binding" Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Acked-by: Ludovic Desroches <ludovic.desroches@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-05-29spi: convert drivers to use bits_per_word_maskStephen Warren1-8/+1
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-13Merge remote-tracking branch 'spi/fix/grant' into spi-linusMark Brown1-2/+2
2013-05-02spi/spi-atmel: BUG: fix doesn' support 16 bits transfers using PIORichard Genoud1-9/+38
Fix using PIO transfer mode only support 8 bits transfer, doesn't support 16 bits. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> [wenyou.yang@atmel.com: submit the patch] Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-24spi/spi-atmel: add dmaengine supportNicolas Ferre1-21/+566
Add dmaengine support. Using "has_dma_support" member of struct is used to select the transfer mode: dmaengine or pdc. For the dmaengine transfer mode, it supports both 8 bits and 16 bits transfer. For the dmaengine transfer mode, if it fails to config dmaengine, or if the message length is less than 16 bytes, it will use the PIO transfer mode. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> [wenyou.yang@atmel.com: using "has_dma_support" to select dmaengine as the spi xfer mode] [wenyou.yang@atmel.com: fix DMA: OOPS if buffer > 4096 bytes] [wenyou.yang@atmel.com: submit the patch] Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Richard Genoud <richard.genoud@gmail.com> [richard.genoud@gmail.com: update with dmaengine interface] [richard.genoud@gmail.com: fix __init/__devinit sections mismatch] [richard.genoud@gmail.com: adapt to slave_config changes] [richard.genoud@gmail.com: add support t0 16 bits transfer] Tested-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-23spi/spi-atmel: add flag to controller data for lock operationsNicolas Ferre1-14/+21
Will allow to drop the lock during DMA operations. Replacing non-irqsave versions with irqsave versions of the lock to make it correct in both pdc and dmaengine transfer mode Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> [wenyou.yang@atmel.com: submit the patch] Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Tested-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-23spi/spi-atmel: add physical base addressNicolas Ferre1-0/+2
Needed for future use with dmaengine enabled driver. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> [wenyou.yang@atmel.com: submit the patch] Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Tested-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-07spi/atmel: fix speed_hz check in atmel_spi_transfer()Joachim Eastwood1-2/+2
atmel_spi_transfer() would check speed_hz and fail if the speed was changed in the transfer. After commit "spi: make sure all transfer has proper speed set" this would happen on all transfers. Change speed_hz check to only fail if a lower speed than max is requested. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2013-04-01spi/spi-atmel: status information passed through controller dataNicolas Ferre1-5/+8
The status of transfer is stored in controller data structure so that it can be used not only by atmel_spi_msg_done() function. This will be useful for upcoming dmaengine enabled driver. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>