aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-sh-msiof.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2014-08-28spi: sh-msiof: Add support for new R-Car Gen2 SoCsGeert Uytterhoeven1-0/+6
Add support for MSIOF in: - r8a7792 (R-Car V2H) - r8a7793 (R-Car M2-N) - r8a7794 (R-Car E2) r8a7791 is now called "R-Car M2-W". Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16spi: sh-msiof: Fix transmit-only DMA transfersGeert Uytterhoeven1-2/+2
Fix tx/rx mixup, which broke transmit-only transfers. Introduced by commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839 ("spi: sh-msiof: Fix leaking of unused DMA descriptors"). Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16spi: sh-msiof: Return early in sh_msiof_dma_once() where possibleGeert Uytterhoeven1-9/+4
Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16spi: sh-msiof: Add DT support to DMA setupGeert Uytterhoeven1-7/+18
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16spi: sh-msiof: Configure DMA slave bus widthGeert Uytterhoeven1-2/+5
The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires explicit configuration of the DMA slave bus width. Hardcode the DMA transfer size to 4 bytes, as MSIOF DMA is limited to 32-bit words. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-08-16spi: sh-msiof: Fix leaking of unused DMA descriptorsGeert Uytterhoeven1-33/+38
If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak unused DMA descriptors. As per Documentation/dmaengine.txt, once a DMA descriptor has been obtained, it must be submitted. Hence: - First prepare and submit all DMA descriptors, - Prepare the SPI controller for DMA, - Start DMA by calling dma_async_issue_pending(), - Make sure to call dmaengine_terminate_all() on all descriptors that haven't completed. Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-16spi: sh-msiof: Use correct device for DMA mapping with IOMMUGeert Uytterhoeven1-10/+16
To function correctly in the presence of an IOMMU, the DMA buffers must be mapped using the DMA channel's device instead of the MSIOF platform device's device. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-16spi: sh-msiof: Handle dmaengine_prep_slave_single() failures gracefullyGeert Uytterhoeven1-8/+15
As typically a shmobile SoC has less DMA channels than devices that can use DMA, we may want to prioritize access to the DMA channels in the future. This means that dmaengine_prep_slave_single() may start failing arbitrarily. Handle dmaengine_prep_slave_single() failures gracefully by falling back to PIO. This requires moving DMA-specific configuration of the MSIOF device after the call(s) to dmaengine_prep_slave_single(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-30spi: sh-msiof: Add DMA supportGeert Uytterhoeven1-7/+341
Add DMA support to the MSIOF driver using platform data. As MSIOF DMA is limited to 32-bit words (requiring byte/wordswapping for smaller wordsizes), and the group length is limited to 256 words, DMA is performed on two fixed pages, allocated and mapped at driver initialization time. Performance figures (in Mbps) on r8a7791/koelsch at different SPI clock frequencies for 1024-byte and 4096-byte transfers: 1024 bytes 4096 bytes - 3.25 MHz: PIO 2.1, DMA 2.6 | PIO 2.8, DMA 3.1 - 6.5 MHz: PIO 3.2, DMA 4.4 | PIO 5.0, DMA 5.9 - 13 MHz: PIO 4.2, DMA 6.6 | PIO 8.2, DMA 10.7 - 26 MHz: PIO 5.9, DMA 10.4 | PIO 12.4, DMA 18.4 Note that DMA is only faster than PIO for transfers that exceed the FIFO size (typically 64 words / 256 bytes). Also note that large transfers (larger than the group length for DMA, or larger than the FIFO size for PIO), should use cs-gpio (with the appropriate pinmux setup), as the hardware chipselect will be deasserted in between chunks. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21spi: sh-msiof: Refactor sh_msiof_transfer_one()Geert Uytterhoeven1-22/+21
- Move buffer pointer and length setup to the top, - Make unsigned values unsigned, - Loop over words and increment pointers instead of recalculating them, which allows to kill bytes_done. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21spi: sh-msiof: Improve transfer error handlingGeert Uytterhoeven1-5/+13
- Add a timeout when waiting for the transfer complete interrupt, - If sh_msiof_spi_stop() fails, there's no need to clear IER, as the interrupt handler has already done that, - Propagate transfer failures in sh_msiof_transfer_one(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21spi: sh-msiof: Extract sh_msiof_spi_{start,stop}() helpersGeert Uytterhoeven1-14/+37
Based on an old patch by Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21spi: sh-msiof: Add more register documentationGeert Uytterhoeven1-1/+53
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-29spi: sh-msiof: remove unnecessary OOM messagesJingoo Han1-3/+1
The site-specific OOM messages are unnecessary, because they duplicate the MM subsystem generic OOM message. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-30Merge remote-tracking branches 'spi/topic/s3c64xx', 'spi/topic/sc18is602', 'spi/topic/sh-hspi', 'spi/topic/sh-msiof', 'spi/topic/sh-sci', 'spi/topic/sirf' and 'spi/topic/spidev' into spi-nextMark Brown1-179/+205
2014-03-11spi: sh-msiof: Convert to spi core auto_runtime_pm frameworkGeert Uytterhoeven1-24/+1
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-03spi: sh-msiof: Kill sh_msiof_spi_bits and sh_msiof_spi_hz functionsAxel Lin1-23/+2
In the implementation of __spi_validate(), spi core will set transfer bits_per_word and max speed as spi device default if it is not set for this transfer. So we can remove the same implementation in this driver. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-27spi: sh-msiof: Use core message handling instead of spi-bitbangGeert Uytterhoeven1-47/+20
The only remaining feature of spi-bitbang used by this driver is the chipselect() callback, which just does conditional GPIO. This is handled fine by the SPI core's spi_set_cs(), hence switch the driver to use the core message handling through our own transfer_one() method. As the (optional) GPIO CS is no longer deasserted at spi_master.setup() time (through spi_bitbang_setup() and the spi_bitbang.chipselect() callback), we now have to take care of that ourselves. Remove the call to spi_master_put() in sh_msiof_spi_remove(), as our SPI master is now registered using devm_spi_register_master() (spi_bitbang_start() uses the non-managed version). Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-27spi: sh-msiof: Convert to let spi core validate xfer->bits_per_wordGeert Uytterhoeven1-17/+2
Set bits_per_word_mask so the spi core will reject transfers that attempt to use an unsupported bits_per_word value. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-27spi: sh-msiof: Move clock management to (un)prepare_message()Geert Uytterhoeven1-23/+38
Move clock management and pin configuration from the bitbang chipselect() method to the SPI core prepare_message() and unprepare_message() methods. As spi_master.{,un}prepare_message() is guaranteed to be called in matching pairs, the clock management synchronization is no longer needed. As sh_msiof_spi_set_pin_regs() is no longer called at spi_master.setup() time (through spi_bitbang_setup() and the spi_bitbang.chipselect() callback), we now have to take care of that ourselves. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-27spi: sh-msiof: Add support for R-Car H2 and M2Geert Uytterhoeven1-3/+20
Add support for the MSIOF variant in the R-Car H2 (r8a7790) and M2 (r8a7791) SoCs. Binding documentation: - Add future-proof "renesas,msiof-<soctype>" compatible values, - The default for "renesas,rx-fifo-size" is 256 on R-Car H2 and M2, - "renesas,tx-fifo-size" and "renesas,rx-fifo-size" are deprecated for soctype-specific bindings, - Add example bindings. Implementation: - MSIOF on R-Car H2 and M2 requires the transmission of dummy data if data is being received only (cfr. "Set SICTR.TSCKE to 1" and "Write dummy transmission data to SITFDR" in paragraph "Transmit and Receive Procedures" of the Hardware User's Manual). - As RX depends on TX, MSIOF on R-Car H2 and M2 also lacks the RSCR register (Receive Clock Select Register), and some bits in the RMDR1 (Receive Mode Register 1) and TMDR2 (Transmit Mode Register 2) registers. - Use the recently introduced SPI_MASTER_MUST_TX flag to enable support for dummy transmission in the SPI core, and to differentiate from other MSIOF implementations in code paths that need this. - New DT compatible values ("renesas,msiof-r8a7790" and "renesas,msiof-r8a7791") are added, as well as new platform device names ("spi_r8a7790_msiof" and "spi_r8a7791_msiof"). - The default RX FIFO size is 256 words on R-Car H2 and M2. This is loosely based on a set of patches from Takashi Yoshii <takasi-y@ops.dti.ne.jp>. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-27spi: sh-msiof: Move default FIFO sizes to device ID dataGeert Uytterhoeven1-16/+34
As different variants of MSIOF have different FIFO sizes, move the default FIFO sizes to a new struct sh_msiof_chipdata, pointed to from the device ID data. [Moved ifdef to fix build -- broonie] Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-27spi: sh-msiof: Improve bindingsGeert Uytterhoeven1-1/+1
Documentation: - Add missing "interrupt-parent", "#address-cells", "#size-cells", and "clocks" properties, - Add missing default values for "num-cs", "renesas,tx-fifo-size" and "renesas,rx-fifo-size", - Add a reference to the pinctrl documentation. Implementation: - As "num-cs" is marked optional, provide a sensible default. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-22spi: sh-msiof: Use the core cs_gpio field, and make it optionalGeert Uytterhoeven1-3/+18
In current implementation, CS is controlled by GPIO, which is passed through spi->controller_data. However, the MSIOF HW module has a function to output CS by itself, which is already enabled and actual switch will be done by pinmux. Store the GPIO number in the core cs_gpio field, and ignore it if it is an invalid (negative) GPIO number. Loosely based on a patch from Takashi Yoshii <takasi-y@ops.dti.ne.jp>. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-22spi: sh-msiof: Add more register documentationGeert Uytterhoeven1-52/+100
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-22spi: sh-msiof: Change hz from unsigned long to u32Geert Uytterhoeven1-5/+3
Both spi_transfer.speed_hz and spi_master.max_speed_hz are u32 Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-22spi: sh-msiof: Typo in comment s/tx/rx/Geert Uytterhoeven1-1/+1
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
2014-02-22spi: sh-msiof: Fix SPI bus population from DTGeert Uytterhoeven1-0/+1
DT doesn't instantiate SPI children if spi_master.dev.of_node is not set up properly. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> 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-23Merge remote-tracking branches 'spi/topic/fsl-espi', 'spi/topic/gpio', 'spi/topic/hspi', 'spi/topic/mpc512x', 'spi/topic/msiof', 'spi/topic/nuc900', 'spi/topic/oc-tiny', 'spi/topic/omap', 'spi/topic/orion' and 'spi/topic/pci' into spi-linusMark Brown1-28/+32
2013-12-02spi: spi-sh-msiof: set hi/low Active for HW CSTakashi Yoshii1-4/+9
Set hardware CS(CS control function on MSIOF <-> GPIO CS) polarity according to SPI_CS_HIGH flag on spi->mode. Signed-off-by: Takashi Yoshii <takasi-y@ops.dti.ne.jp> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-12-02spi: spi-sh-msiof: round up div to fix freq calculationTakashi Yoshii1-1/+1
Truncation on integer division in sh_msiof_spi_set_clk_regs() results in insufficient transfer frequency (> max_speed_freq). For example, source 52MHz, required max 6MHz 52/6 = 8.6 --> 8, then 1/8 table selected, and result in 52/8 = 6.5 MHz (>6MHz) Rounding it up is a simple solution. 52/6 = 8.6 --> 9, then 1/16 table selected, and result in 52/16 = 3.25 MHz Signed-off-by: Takashi Yoshii <takasi-y@ops.dti.ne.jp> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-11-28spi: sh-msiof: Convert to clk_prepare/unprepareLaurent Pinchart1-0/+8
Get the driver ready for the migration to the common clock framework by calling clk_prepare() and clk_unprepare(). The calls are added in the probe and remove handlers as the clk_enable() and clk_disable() calls are located in atomic context and there's no callback function in non-atomic context that can be used to prepare/unprepare the clock. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-11-28spi: sh-msiof: Use devm_* managed allocatorsLaurent Pinchart1-23/+14
This simplifies error and cleanup code paths. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-11-27spi: sh-msiof: Fix warnings due to improper castsLaurent Pinchart1-1/+1
Cast pointers to uintptr_t instead of unsigned int. This fixes warnings on platforms where pointers have a different size than int. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-11-15tree-wide: use reinit_completion instead of INIT_COMPLETIONWolfram Sang1-1/+1
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-01Merge remote-tracking branch 'spi/topic/sh-msiof' into spi-nextMark Brown1-18/+0
2013-08-29spi: use dev_get_platdata()Jingoo Han1-1/+1
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-28spi/sh-msiof: Remove unneeded empty runtime PM callbacksMark Brown1-18/+0
Previously the runtime PM API insisted on having callbacks for everything but this requirement was removed a while ago so the empty callbacks can also be removed. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-04-01spi: spi-sh-msiof: Use of_match_ptr() macroSachin Kamat1-3/+1
This eliminates having an #ifdef returning NULL for the case when OF is disabled. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-02-05spi/sh-msiof: Add device tree parsing to driverBastian Hecht1-1/+55
This adds the capability to retrieve setup data from the device tree node. The usage of platform data is still available. Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-12-06spi/sh-msiof: Remove unneeded clock nameBastian Hecht1-4/+2
clk_get() no longer needs a character string for associating the right clock as this is done via the device struct now. Signed-off-by: Bastian Hecht <hechtb@gmail.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2011-10-31spi: Add module.h to implicit users in drivers/spiPaul Gortmaker1-0/+1
We are clipping down the presence of module.h, since it was everywhere. If you really need it, you better call it out, as per this changeset. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-25drivercore: Add helper macro for platform_driver boilerplateGrant Likely1-12/+1
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>
2011-10-24spi: irq: Remove IRQF_DISABLEDYong Zhang1-1/+1
Since commit [e58aa3d2: genirq: Run irq handlers with interrupts disabled], We run all interrupt handlers with interrupts disabled and we even check and yell when an interrupt handler returns with interrupts enabled (see commit [b738a50a: genirq: Warn when handler enables interrupts]). So now this flag is a NOOP and can be removed. Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2011-06-06spi: reorganize driversGrant Likely1-0/+749
Sort the SPI makefile and enforce the naming convention spi_*.c for spi drivers. This change also rolls the contents of atmel_spi.h into the .c file since there is only one user of that particular include file. v2: - Use 'spi-' prefix instead of 'spi_' to match what seems to be be the predominant pattern for subsystem prefixes. - Clean up filenames in Kconfig and header comment blocks Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Linus Walleij <linus.walleij@linaro.org>