summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-xilinx.c
AgeCommit message (Collapse)Author
2015-02-02spi/xilinx: Fix access invalid memory on xilinx_spi_txRicardo Ribalda Delgado
On 1 and 2 bytes per word, the transfer of the 3 last bytes will access memory outside tx_ptr. Although this has not trigger any error on real hardware, we should better fix this. Fixes: 24ba5e593f391507 (Remove rx_fn and tx_fn pointer) Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-30spi: Revert "spi/xilinx: Remove iowrite/ioread wrappers"Mark Brown
This reverts commit 99082eab63449f9dfa83d5157fa6d78bfc1b04d7 since it breaks the build due to differing implementations of iowrite() and ioread(). Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Check number of slaves rangeRicardo Ribalda
The core only supports up to 32 slaves, and the chipselect function expects the same. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Use polling mode on small transfersRicardo Ribalda Delgado
Small transfers generally can be accomplished faster in polling mode. This patch select the transfer which size is bellow the buffer size to be done on polling mode Suggested-by: Mark Brown <broonie@kernel.org> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Remove remaining_words driver data variableRicardo Ribalda Delgado
The variable never leaves the scope of txrx_bufs. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Remove iowrite/ioread wrappersRicardo Ribalda Delgado
Save a stack level and cleanup code. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Convert bits_per_word in bytes_per_wordRicardo Ribalda Delgado
Simplify the code by using the unit used on most of the code logic. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Convert remainding_bytes in remaining wordsRicardo Ribalda Delgado
Simplify the code by using the unit used on most of the code logic. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Make spi_tx and spi_rx simmetricRicardo Ribalda Delgado
spi_rx handles the case where the buffer is null. Nevertheless spi_tx did not handle it, and was handled by the caller function. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Remove rx_fn and tx_fn pointerRicardo Ribalda Delgado
Simplify the code by removing the tx and and rx function pointers and substitute them by a single function. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Support for spi mode CS_HIGHRicardo Ribalda Delgado
The core controls the chip select lines individually. By default, all the lines are consider active_low. After spi_setup_transfer, it has its real value. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Do not inhibit transmission in polling modeRicardo Ribalda Delgado
When no irq is used, there is no need to inhibit the transmission for every transaction. This inhibition was implemented to avoid a race condition with the irq handler. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Support cores with no interruptRicardo Ribalda Delgado
The core can run in polling mode. In fact, the performance of the core is similar (or even better), due to the fact most of the spi transactions are just a couple of bytes and there is one irq per transactions. When an mtd device is connected via spi, reading 8MB of data produces more than 80K interrupts (with irq disabling, context swith....) Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Use cached value of registerRicardo Ribalda Delgado
The control register has not changed since the previous access. Therefore we can use the cached value and safe one bus access. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Code cleanupRicardo Ribalda Delgado
On the transmission loop, check for remaining bytes at the loop condition. This way we can handle transmissions of 0 bytes and clean the code. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Leave the IRQ always enabled.Ricardo Ribalda Delgado
Instead of enabling the IRQ and disabling it for every transaction. Specially the small transactions (1,2 words) benefit from removing 3 bus accesses. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-28spi/xilinx: Simplify spi_fill_tx_fifoRicardo Ribalda Delgado
Instead of checking the TX_FULL flag for every transaction, find out the size of the buffer at probe time and use it. To avoid situations where the core had some data on the buffer before initialization, the core is reseted before the buffer size is detected Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-27spi/xilinx: Simplify data read from the Rx FIFORicardo Ribalda Delgado
The number of words in the read buffer will be exactly the same as the number of words written on write buffer, once the transaction has finished. Instead of cheking the rx_empty flags for every word simply save the number of words written by fill_tx_fifo. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-26spi/xilinx: Support for spi mode LOOPRicardo Ribalda Delgado
Hardware supports LOOP mode. Support it also in the driver. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-01-26spi/xilinx: Support for spi mode LSB_FIRSTRicardo Ribalda Delgado
Hardware supports LSB_FIRST mode. Support it also in the driver. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2014-08-16spi: xilinx: Remove .owner field for driverMichal Simek
There is no need to init .owner field. Based on the patch from Peter Griffin <peter.griffin@linaro.org> "mmc: remove .owner field for drivers using module_platform_driver" This patch removes the superflous .owner field for drivers which use the module_platform_driver API, as this is overriden in platform_driver_register anyway." Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-10spi: xilinx: Use pdev->id instead of pdev->dev.id for the SPI bus numberLars-Peter Clausen
The Xilinx SPI driver initializes the bus_num field of the SPI master to pdev->dev.id. pdev->dev.id is always 0 for platform devices which causes bus number conflicts for the SPI controller when creating multiple device instances of the driver. Instead use pdev->id which will have the assignt platform device id. If the device is instantiated via devicetree pdev->id is -1 which will cause the SPI core to dynamically assign a id (or use the id defined via a alias in the devicetree). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-30Merge remote-tracking branches 'spi/topic/xilinx' and 'spi/topic/xtfpga' ↵Mark Brown
into spi-next
2014-02-27spi: xilinx: remove unnecessary spacesJingoo Han
Remove unnecessary space in order to fix the following checkpatch issues. WARNING: Unnecessary space after function pointer name Signed-off-by: Jingoo Han <jg1.han@samsung.com> Reviewed-by: Michal Simek <monstr@monstr.eu> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-23spi: xilinx: Convert to let spi core validate bits_per_wordAxel Lin
Set bits_per_word_mask so spi core will reject transfers that attempt to use an unsupported bits_per_word value. spi_bitbang requires custom setup_transfer() to be defined if there is a custom txrx_bufs(). Thus keep the empty xilinx_spi_setup_transfer() function in the code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Michal Simek <michal.simek@xilinx.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-15tree-wide: use reinit_completion instead of INIT_COMPLETIONWolfram Sang
Use this new function to make code more comprehensible, since we are reinitialzing the completion, not initializing. [akpm@linux-foundation.org: linux-next resyncs] Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> (personally at LCE13) Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-17spi: bitbang: Let spi_bitbang_start() take a reference to masterAxel Lin
Many drivers that use bitbang library have a leak on probe error paths. This is because once a spi_master_get() call succeeds, we need an additional spi_master_put() call to free the memory. Fix this issue by moving the code taking a reference to master to spi_bitbang_start(), so spi_bitbang_start() will take a reference to master on success. With this change, the caller is responsible for calling spi_bitbang_stop() to decrement the reference and spi_master_put() as counterpart of spi_alloc_master() to prevent a memory leak. So now we have below patten for drivers using bitbang library: probe: spi_alloc_master -> Init reference count to 1 spi_bitbang_start -> Increment reference count remove: spi_bitbang_stop -> Decrement reference count spi_master_put -> Decrement reference count (reference count reaches 0) Fixup all users accordingly. Signed-off-by: Axel Lin <axel.lin@ingics.com> Suggested-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> Acked-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-01Merge remote-tracking branch 'spi/topic/pdata' into spi-nextMark Brown
2013-08-29Merge remote-tracking branch 'spi/topic/rspi' into spi-pdataMark Brown
Conflicts: drivers/spi/spi-rspi.c
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-08-09spi/bitbang: Drop empty setup() functionsMark Brown
Now that the bitbang core does not require a setup() function we can drop the check in the altera, nuc900 and xilinx drivers. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-17spi/xilinx: signedness issue checking platform_get_irq()Dan Carpenter
In xilinx_spi_probe() we use xspi->irq to store negative error codes so it has to be signed. We weren't going to use the upper bit any way so this is fine. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15spi/xilinx: Simplify irq allocationMichal Simek
Use devm_request_irq() for irq allocation which simplify driver code. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15spi/xilinx: Use of_property_read_u32 for reading value from nodeMichal Simek
It simplifies driver probing. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15spi/xilinx: Clean ioremap callingMichal Simek
devm_ioremap_resource() automatically checks that struct resource is initialized. Also group platform_get_resource() and devm_ioremap_resource() together. And remove mem resource from struct xilinx_spi. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15spi/xilinx: Remove CONFIG_OF from the driverMichal Simek
dev.of_node is in struct device all the time. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15spi/xilinx: Refer to platform device as pdev in probe() and remove()Mark Brown
This is a more traditional name and makes things a bit clearer when referring to actual struct devices as we do frequently during probe(). Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Michal Simek <michal.simek@xilinx.com>
2013-07-15spi/xilinx: Remove remains of of_platform device registrationMark Brown
In the past there used to be a separate platform device type for device tree systems so the probe and removal functions were split into generic and bus sections. Since this is no longer the case simplify the code (and remove some unprototyped exports) by factoring everything into the bus probe() and remove(). Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15spi/xilinx: Convert to devm_ioremap_resource()Mark Brown
Saves code and reduces the possibility of error. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-10spi/xilinx: Revert master->setup function removalMichal Simek
master->setup() must be initialized to be able to successfully run spi_bitbang_start() and satisfy if/else logic there. "spi: convert drivers to use bits_per_word_mask" (sha1: 24778be20f87d5aadb19624fc768b3159fa43efc) Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-26Merge remote-tracking branch 'spi/topic/xilinx' into spi-nextMark Brown
2013-06-26Merge remote-tracking branch 'spi/topic/bpw' into spi-nextMark Brown
2013-06-10spi: spi-xilinx: cleanup a check in xilinx_spi_txrx_bufs()dan.carpenter@oracle.com
'!' has higher precedence than comparisons so the original condition is equivalent to "if (xspi->remaining_bytes == 0)". This makes the static checkers complain. xspi->remaining_bytes is signed and from looking at the code briefly, I think it might be able to go negative. I suspect that going negative may cause a bug, but I don't have the hardware and can't test. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-04spi: spi-xilinx: Remove redundant platform_set_drvdata()Sachin Kamat
Setting platform data to NULL is not necessary. Also fixes the following sparse warning: drivers/spi/spi-xilinx.c:508:35: warning: Using plain integer as NULL pointer Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-04spi: spi-xilinx: Add run run-time endian detectionMichal Simek
Do not load endian value from platform data and rather autodetect it. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-04spi: spi-xilinx: Remove ISR race conditionPeter Crosthwaite
The ISR currently consumes the rx buffer data and re-enables transmission from within interrupt context. This is bad because if the interrupt occurs again before the ISR exits, the new interrupt will be erroneously cleared by the still completing ISR. Simplified the ISR by just setting the completion variable and exiting with no action. Then just looped the transmit functionality in xilinx_spi_txrx_bufs(). Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.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>
2012-12-07spi: Remove HOTPLUG section attributesGrant Likely
CONFIG_HOTPLUG is going away as an option. As result the __dev* markings will be going away. Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit. Bill Pemberton has done most of the legwork on this series. I've used his script to purge the attributes from the drivers/gpio tree. Reported-by: Bill Pemberton <wfp5p@virginia.edu> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2011-10-24drivercore: Add helper macro for platform_driver boilerplateGrant Likely
For simple modules that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_platform_driver(), which replaces the module_init()/module_exit() registrations with template functions. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Reviewed-by: Magnus Damm <magnus.damm@gmail.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>