aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-ti-qspi.c
Commit message (Collapse)AuthorAgeFilesLines
* spi: ti-qspi: Use syscon_regmap_lookup_by_phandle_argsKrzysztof Kozlowski2025-01-141-10/+2
| | | | | | | | | | | | | | | | Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over syscon_regmap_lookup_by_phandle() combined with getting the syscon argument. Except simpler code this annotates within one line that given phandle has arguments, so grepping for code would be easier. There is also no real benefit in printing errors on missing syscon argument, because this is done just too late: runtime check on static/build-time data. Dtschema and Devicetree bindings offer the static/build-time check for this already. Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Support per spi-mem operation frequency switchesMiquel Raynal2025-01-091-1/+6
| | | | | | | | | | | | | | | | Every ->exec_op() call correctly configures the spi bus speed to the maximum allowed frequency for the memory using the constant spi default parameter. Since we can now have per-operation constraints, let's use the value that comes from the spi-mem operation structure instead. In case there is no specific limitation for this operation, the default spi device value will be given anyway. The per-operation frequency capability is thus advertised to the spi-mem core. Signed-off-by: Miquel Raynal <[email protected]> Link: https://patch.msgid.link/20241224-winbond-6-11-rc1-quad-support-v2-15-ad218dbc406f@bootlin.com Signed-off-by: Mark Brown <[email protected]>
* spi: Use of_property_present() for non-boolean propertiesRob Herring (Arm)2024-11-041-1/+1
| | | | | | | | | | The use of of_property_read_bool() for non-boolean properties is deprecated in favor of of_property_present() when testing for property presence. Signed-off-by: Rob Herring (Arm) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: remove redundant assignment to variable retColin Ian King2024-10-021-1/+0
| | | | | | | | | | Variable ret is being assigned a value but it is never read, instead the variable is being reassigned later in the exit path via label no_dma. Remove the redundant assignment. Signed-off-by: Colin Ian King <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: Switch back to struct platform_driver::remove()Uwe Kleine-König2024-09-291-1/+1
| | | | | | | | | | | | | | | | | | | After commit 0edb555a65d1 ("platform: Make platform_driver::remove() return void") .remove() is (again) the right callback to implement for platform drivers. Convert all platform drivers below drivers/spi to use .remove(), with the eventual goal to drop struct platform_driver::remove_new(). As .remove() and .remove_new() have the same prototypes, conversion is done by just changing the structure member name in the driver initializer. The change for the spi-npcm-fiu stands out in the diffstat because the inconsistent formatting style of the platform_driver initializer is fixed to match the other struct initializer in the file. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: switch to use modern nameYang Yingliang2023-12-111-44/+44
| | | | | | | | | | Change legacy name master to modern name host or controller. No functional changed. Signed-off-by: Yang Yingliang <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: Unify error codes by replacing -ENOTSUPP with -EOPNOTSUPPChia-Lin Kao (AceLan)2023-11-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit updates the SPI subsystem, particularly affecting "SPI MEM" drivers and core parts, by replacing the -ENOTSUPP error code with -EOPNOTSUPP. The key motivations for this change are as follows: 1. The spi-nor driver currently uses EOPNOTSUPP, whereas calls to spi-mem might return ENOTSUPP. This update aims to unify the error reporting within the SPI subsystem for clarity and consistency. 2. The use of ENOTSUPP has been flagged by checkpatch as inappropriate, mainly being reserved for NFS-related errors. To align with kernel coding standards and recommendations, this change is being made. 3. By using EOPNOTSUPP, we provide more specific context to the error, indicating that a particular operation is not supported. This helps differentiate from the more generic ENOTSUPP error, allowing drivers to better handle and respond to different error scenarios. Risks and Considerations: While this change is primarily intended as a code cleanup and error code unification, there is a minor risk of breaking user-space applications that rely on specific return codes for unsupported operations. However, this risk is considered low, as such use-cases are unlikely to be common or critical. Nevertheless, developers and users should be aware of this change, especially if they have scripts or tools that specifically handle SPI error codes. This commit does not introduce any functional changes to the SPI subsystem or the affected drivers. Signed-off-by: "Chia-Lin Kao (AceLan)" <[email protected]> Acked-by: Tudor Ambarus <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Acked-by: Miquel Raynal <[email protected]> Acked-by: Michael Walle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Convert to platform remove callback returning voidUwe Kleine-König2023-11-131-6/+7
| | | | | | | | | | | | | | | | | | | | | The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Add an error message to the error path that returned an error before to replace the core's error message with more information. Apart from the different wording of the error message, this patch doesn't introduce a semantic difference. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: Explicitly include correct DT includesRob Herring2023-07-141-1/+0
| | | | | | | | | | | | | | | The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Signed-off-by: Rob Herring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: Convert to SPI_CONTROLLER_HALF_DUPLEXAndy Shevchenko2023-07-111-1/+1
| | | | | | | | Convert the users under SPI subsystem to SPI_CONTROLLER_HALF_DUPLEX. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: Replace all spi->chip_select and spi->cs_gpiod references with function ↵Amit Kumar Mahapatra via Alsa-devel2023-03-111-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | call Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra <[email protected]> Acked-by: Heiko Stuebner <[email protected]> # Rockchip drivers Reviewed-by: Michal Simek <[email protected]> Reviewed-by: Cédric Le Goater <[email protected]> # Aspeed driver Reviewed-by: Dhruva Gole <[email protected]> # SPI Cadence QSPI Reviewed-by: Patrice Chotard <[email protected]> # spi-stm32-qspi Acked-by: William Zhang <[email protected]> # bcm63xx-hsspi driver Reviewed-by: Serge Semin <[email protected]> # DW SSI part Link: https://lore.kernel.org/r/167847070432.26.15076794204368669839@mailman-core.alsa-project.org Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Support per-transfer and per-slave speed_hz settingsAtsushi Nemoto2022-06-061-36/+39
| | | | | | | | | | | | | | | | | The spi-ti-qspi driver initializes its spi clock by the spi-max-frequency property from the controller node, and ignores per-transfer (and per-slave) speed_hz settings. Isolate clock settings out from ti_qspi_setup() and call it from ti_qspi_start_transfer_one() and ti_qspi_exec_mem_op(), using per-transfer speed_hz and per-slave max_speed_hz settings. Also drop spi_max_frequency from struct ti_qspi and use spi_master's max_speed_hz. Signed-off-by: Atsushi Nemoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: using pm_runtime_resume_and_get instead of pm_runtime_get_syncMinghao Chi2022-04-191-2/+1
| | | | | | | | | | Using pm_runtime_resume_and_get is more appropriate for simplifing code Reported-by: Zeal Robot <[email protected]> Signed-off-by: Minghao Chi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Fix return value handling of wait_for_completion_timeoutMiaoqian Lin2022-04-111-2/+3
| | | | | | | | | | | | wait_for_completion_timeout() returns unsigned long not int. It returns 0 if timed out, and positive if completed. The check for <= 0 is ambiguous and should be == 0 here indicating timeout which is the only error case. Fixes: 5720ec0a6d26 ("spi: spi-ti-qspi: Add DMA support for QSPI mmap read") Signed-off-by: Miaoqian Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Free DMA resourcesTudor Ambarus2021-03-101-6/+14
| | | | | | | | | | | Release the RX channel and free the dma coherent memory when devm_spi_register_master() fails. Fixes: 5720ec0a6d26 ("spi: spi-ti-qspi: Add DMA support for QSPI mmap read") Cc: [email protected] Signed-off-by: Tudor Ambarus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: fix reference leak in ti_qspi_setupZhang Qilong2020-11-091-0/+1
| | | | | | | | | | | pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to pm_runtime_put_noidle will result in reference leak in ti_qspi_setup, so we should fix it. Fixes: 505a14954e2d7 ("spi/qspi: Add qspi flash controller") Signed-off-by: Zhang Qilong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* SPI SUBSYSTEM: Replace HTTP links with HTTPS onesAlexander A. Klimov2020-07-091-1/+1
| | | | | | | | | | | | | | | | | | | | | Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: fix warningJean Pihet2020-01-171-0/+1
| | | | | | | | | | | | | | | | | drivers/spi/spi-ti-qspi.c: In function ‘ti_qspi_start_transfer_one’: drivers/spi/spi-ti-qspi.c:392:8: warning: ‘rx_wlen’ may be used uninitialized in this function [-Wmaybe-uninitialized] 392 | if (rx_wlen >= 32) | ^ drivers/spi/spi-ti-qspi.c:318:12: note: ‘rx_wlen’ was declared here 318 | u8 rxlen, rx_wlen; | ^~~~~~~ The warning is a false positive; it is not thrown by all compiler versions, e.g. Red Hat Cross 9.2.1-1 but not Linaro GCC 7.5-2019.12. Signed-off-by: Jean Pihet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: optimize byte-transfersJean Pihet2020-01-141-3/+51
| | | | | | | | | | | | | | | Optimize the 8-bit based transfers, as used by the SPI flash devices, by reading the data registers by 32 and 128 bits when possible and copy the contents to the receive buffer. The speed improvement is 4.9x using quad read. Signed-off-by: Jean Pihet <[email protected]> Cc: Ryan Barnett <[email protected]> Cc: Conrad Ratschan <[email protected]> Cc: Arnout Vandecappelle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: support large flash devicesJean Pihet2020-01-141-0/+30
| | | | | | | | | | | | | | | | | The TI QSPI IP has limitations: - the MMIO region is 64MB in size - in non-MMIO mode, the transfer can handle 4096 words max. Add support for bigger devices. Use MMIO and DMA transfers below the 64MB boundary, use software generated transfers above. Signed-off-by: Jean Pihet <[email protected]> Cc: Ryan Barnett <[email protected]> Cc: Conrad Ratschan <[email protected]> Cc: Arnout Vandecappelle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* Merge branch 'for-5.5' of ↵Mark Brown2019-12-251-1/+5
|\ | | | | | | https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-5.6
| * spi: spi-ti-qspi: Fix a bug when accessing non default CSVignesh Raghavendra2019-12-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When switching ChipSelect from default CS0 to any other CS, driver fails to update the bits in system control module register that control which CS is mapped for MMIO access. This causes reads to fail when driver tries to access QSPI flash on CS1/2/3. Fix this by updating appropriate bits whenever active CS changes. Reported-by: Andreas Dannenberg <[email protected]> Signed-off-by: Vignesh Raghavendra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* | spi: spi-ti-qspi: Remove unused macro for fclk frequencyJean Pihet2019-12-171-2/+0
|/ | | | | | | | | | | The fclk and its rate are retrieved from DT. Signed-off-by: Jean Pihet <[email protected]> Cc: Ryan Barnett <[email protected]> Cc: Conrad Ratschan <[email protected]> Cc: Arnout Vandecappelle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* spi: Remove dev_err() usage after platform_get_irq()Stephen Boyd2019-08-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // <smpl> @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // </smpl> While we're here, remove braces on if statements that only have one statement (manually). Cc: Mark Brown <[email protected]> Cc: [email protected] Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 296Thomas Gleixner2019-06-051-8/+1
| | | | | | | | | | | | | | | | | | | | | | | Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gplv2 this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 1 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Alexios Zavras <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
* spi: ti-qspi: Fix mmap read when more than one CS in useVignesh R2019-01-291-3/+3
| | | | | | | | | | | | | | Commit 4dea6c9b0b64 ("spi: spi-ti-qspi: add mmap mode read support") has has got order of parameter wrong when calling regmap_update_bits() to select CS for mmap access. Mask and value arguments are interchanged. Code will work on a system with single slave, but fails when more than one CS is in use. Fix this by correcting the order of parameters when calling regmap_update_bits(). Fixes: 4dea6c9b0b64 ("spi: spi-ti-qspi: add mmap mode read support") Cc: [email protected] Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: ti-qspi: Make sure res_mmap != NULL before dereferencing itBoris Brezillon2018-05-171-1/+3
| | | | | | | | | | resource_size() is dereferencing the res without checking that it is not NULL, so we need to do the check before calling resource_size(). Fixes: b95cb394ab59 ("spi: ti-qspi: Implement the spi_mem interface") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: Get rid of the spi_flash_read() APIBoris Brezillon2018-05-111-41/+0
| | | | | | | | | | | | This API has been replaced by the spi_mem_xx() one, its only user (spi-nor) has been converted to spi_mem_xx() and all SPI controller drivers that were implementing the ->spi_flash_xxx() hooks are also implementing the spi_mem ones. So we can safely get rid of this API. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Tested-by: Frieder Schrempf <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: ti-qspi: Implement the spi_mem interfaceBoris Brezillon2018-05-111-13/+71
| | | | | | | | | | | The spi_mem interface is meant to replace the spi_flash_read() one. Implement the ->exec_op() method so that we can smoothly get rid of the old interface. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Vignesh R <[email protected]> Tested-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
*-. Merge remote-tracking branches 'spi/topic/ti-qspi' and 'spi/topic/xlp' into ↵Mark Brown2017-04-261-10/+60
|\ \ | | | | | | | | | spi-next
| * | spi: spi-ti-qspi: Use bounce buffer if read buffer is not DMA'bleVignesh R2017-04-211-7/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flash filesystems like JFFS2, UBIFS and MTD block layer can provide vmalloc'd or kmap'd buffers that cannot be mapped using dma_map_sg() and can potentially be in memory region above 32bit addressable region(ie buffers belonging to memory region backed by LPAE) of DMA, implement spi_flash_can_dma() interface to inform SPI core not to map such buffers. When buffers are not mapped for DMA, then use a pre allocated bounce buffer(64K = typical flash erase sector size) to read from flash and then do a copy to actual destination buffer. This is approach is much faster than using memcpy using CPU and also reduces CPU load. With this patch, UBIFS read speed is ~18MB/s and CPU utilization <20% on DRA74 Rev H EVM. Performance degradation is negligible when compared with non bounce buffer case while using UBIFS. Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
| * | spi: spi-ti-qspi: Remove unused dma_dev variableVignesh R2017-03-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 1351aaeb50b2 ("spi: spi-ti-qspi: Use dma_engine wrapper for dma memcpy call") introduced this warning: drivers/spi/spi-ti-qspi.c: In function 'ti_qspi_dma_xfer': drivers/spi/spi-ti-qspi.c:398:21: warning: unused variable 'dma_dev' [-Wunused-variable] struct dma_device *dma_dev = chan->device; Fix it by removing the unused variable. Signed-off-by: Vignesh R <[email protected]> Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Mark Brown <[email protected]>
| * | spi: spi-ti-qspi: Use dma_engine wrapper for dma memcpy callVignesh R2017-03-241-2/+1
| |/ | | | | | | | | | | | | | | | | Instead of calling device_prep_dma_memcpy() directly with dma_device pointer, use the newly introduced dmaengine_prep_dma_memcpy() wrapper API. Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* | spi: spi-ti-qspi: Fix error handlingChristophe JAILLET2017-02-191-1/+2
| | | | | | | | | | | | | | | | | | 'dma_request_chan_by_mask()' can not return NULL. Try to keep the logic in 'no_dma:' by resetting 'qspi->rx_chan' in case of error. Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* | spi: ti-qspi: revise ti_qspi_probe() failure flowPrahlad V2017-02-171-5/+10
|/ | | | | | | | call spi_master_put() in case of failures after spi_alloc_master(). call pm_runtime_disable() in case of failures after pm_runtime_enable(). Signed-off-by: Prahlad V <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: reinit of completion variablePrahlad V2016-11-151-0/+1
| | | | | | | completion variable should be reinitialized before reusing. Signed-off-by: Prahlad V <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Add DMA support for QSPI mmap readVignesh R2016-08-171-17/+122
| | | | | | | | | | | Use mem-to-mem DMA to read from flash when reading in mmap mode. This gives improved read performance and reduces CPU load. With this patch the raw-read throughput is ~16MB/s on DRA74 EVM. And CPU load is <20%. UBIFS read throughput ~13 MB/s. Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
*-. Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/sunxi', ↵Mark Brown2016-07-241-1/+1
|\ \ | | | | | | | | | 'spi/topic/ti-qspi', 'spi/topic/topcliff-pch' and 'spi/topic/txx9' into spi-next
| | * spi: ti-qspi: spelling mistake: "trasnfers" -> "transfers"Colin Ian King2016-06-261-1/+1
| |/ | | | | | | | | | | | | trivial fix to spelling mistake in dev_dbg message Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* / spi: spi-ti-qspi: Suspend the queue before removing the deviceJean-Jacques Hiblot2016-05-311-0/+7
|/ | | | | | | | | | | Before disabling the pm_runtime, we must ensure that there is no transfer in progress nor will a new one be started. Otherwise the message pump will fail and in the end, the process requesting the transfer will be stuck. This behavior has been observed when transferring data from a SPI flash with dd while removing the module on a DRA7x-evm. Signed-off-by: Jean-Jacques Hiblot <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: spi-ti-qspi: Handle truncated frames properlyBen Hutchings2016-04-131-12/+20
| | | | | | | | | | | | | | | We clamp frame_len_words to a maximum of 4096, but do not actually limit the number of words written or read through the DATA registers or the length added to spi_message::actual_length. This results in silent data corruption for commands longer than this maximum. Recalculate the length of each transfer, taking frame_len_words into account. Use this length in qspi_{read,write}_msg(), and to increment spi_message::actual_length. Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Mark Brown <[email protected]> Cc: [email protected]
* spi: spi-ti-qspi: Fix FLEN and WLEN settings if bits_per_word is overriddenBen Hutchings2016-04-131-6/+9
| | | | | | | | | | | | | | | | | | Each transfer can specify 8, 16 or 32 bits per word independently of the default for the device being addressed. However, currently we calculate the number of words in the frame assuming that the word size is the device default. If multiple transfers in the same message have differing bits_per_word, we bitwise-or the different values in the WLEN register field. Fix both of these. Also rename 'frame_length' to 'frame_len_words' to make clear that it's not a byte count like spi_message::frame_length. Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Mark Brown <[email protected]> Cc: [email protected]
* spi: spi-ti-qspi: add mmap mode read supportVignesh R2016-02-091-28/+109
| | | | | | | | | | | | | | | | | | | | ti-qspi controller provides mmap port to read data from SPI flashes. mmap port is enabled in QSPI_SPI_SWITCH_REG. ctrl module register may also need to be accessed for some SoCs. The QSPI_SPI_SETUP_REGx needs to be populated with flash specific information like read opcode, read mode(quad, dual, normal), address width and dummy bytes. Once, controller is in mmap mode, the whole flash memory is available as a memory region at SoC specific address. This region can be accessed using normal memcpy() (or mem-to-mem dma copy). The ti-qspi controller hardware will internally communicate with SPI flash over SPI bus and get the requested data. Implement spi_flash_read() callback to support mmap read over SPI flash devices. With this, the read throughput increases from ~100kB/s to ~2.5 MB/s. Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
*-. Merge remote-tracking branches 'spi/topic/s3c64xx', 'spi/topic/ti-qspi' and ↵Mark Brown2015-11-041-64/+21
|\ \ | | | | | | | | | 'spi/topic/txx9' into spi-next
| | * spi: ti-qspi: improve ->remove() callbackFelipe Balbi2015-10-301-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable(). Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Mark Brown <[email protected]>
| | * spi: spi-ti-qspi: switch to polling mode for better r/w performanceVignesh R2015-10-161-54/+20
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently word completion interrupt is fired for transfer of every word(8bit to 128bit in size). This adds a lot of overhead, and decreases r/w throughput. It hardly takes 3us(@48MHz) for 128bit r/w to complete, hence its better to poll on word complete bit to be set in QSPI_SPI_STATUS_REG instead of using interrupts. This increases the throughput by 30% in both read and write case. So, switch to polling mode instead of interrupts to determine completion of word transfer. Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* / spi: ti-qspi: Fix data corruption seen on r/w stress testVignesh R2015-10-121-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: [email protected] # v3.12+ Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: ti-qspi: use 128 bit transfer mode where possibleVignesh R2015-08-201-4/+30
| | | | | | | | | | | | | | | | | | | | | TI QSPI has four 32 bit data regsiters which can be used to transfer 16 bytes of data at once. The register group QSPI_SPI_DATA_REG_3, QSPI_SPI_DATA_REG_2, QSPI_SPI_DATA_REG_1 and QSPI_SPI_DATA_REG is treated as a single 128-bit word for shifting data in and out. The bit at QSPI_SPI_DATA_REG_3[31] position is the first bit to be shifted out in case of 128 bit transfer mode. Therefore the first byte to be written to flash should be at QSPI_SPI_DATA_REG_3[31-25] position. Instead of writing 1 byte at a time when interacting with spi-nor flash, make use of all the four registers so that 16 bytes can be transferred in one go. This reduces number of register writes and Word Complete interrupts for a given transfer message size, thereby increasing the write performance. Without this patch the raw flash write speed is ~100KB/s, with this patch the write speed increases to ~400 kB/s on DRA74 EVM. Signed-off-by: Vignesh R <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* drivers: spi: ti-qspi: wait for busy bit clear before data write/readMugunthan V N2015-02-211-0/+22
| | | | | | | | | | Data corruption is seen while reading/writing large data from/to qspi device because the data register is over written or read before data is ready which is denoted by busy bit in status register. SO adding a busy bit check before writing/reading data to/from qspi device. Signed-off-by: Mugunthan V N <[email protected]> Signed-off-by: Mark Brown <[email protected]>
* spi: ti-qspi: cleanup wait_for_completion return handlingNicholas Mc Guire2015-02-051-8/+6
| | | | | | | | | return type of wait_for_completion_timeout is unsigned long not int, this patch uses the return value of wait_for_completion_timeout in the condition directly rather than assigning it to an incorrect type variable. Signed-off-by: Nicholas Mc Guire <[email protected]> Signed-off-by: Mark Brown <[email protected]>