summaryrefslogtreecommitdiffstats
path: root/drivers/spi/imx_spi.c
Commit message (Collapse)AuthorAgeFilesLines
* spi: i.MX: Fix wrong bus nubering with devicetreeAlexander Shiyan2018-12-141-4/+7
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ecspi: Enable imx->clk as a part of initializationAndrey Smirnov2018-01-111-0/+7
| | | | | | | | Some SoCs (e. g. i.MX7) do not enable this clock by default, so add code to take care of that in the driver. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: imx: make xchg_single timeout value compatible for older boardsAlexander Kurz2017-12-151-2/+5
| | | | | | | | | | | A call of xchg_single will issue the transfer of 24 data bits with a given maximum frequency. Since there exist some i.MX based boards with spi-max-frequency = <100000>, change the xchg_single timeout to still support those boards. Fixes: 1439cdf7c6fc ("spi: imx: add timeout to xchg_single") Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: imx: add timeout to xchg_singleUwe Kleine-König2017-08-151-4/+24
| | | | | | | | If there is a problem STAT_RR might never be set which results in an endless loop. Break out after 10 µs with -ETIMEOUT instead. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* spi: imx: add error checkingUwe Kleine-König2017-08-151-29/+48
| | | | | | | | | This makes it possible that the xchg_single callbacks return an error code that is then passed to the caller of spi_transfer. There is no change in behaviour intended as up to now the callbacks always return 0. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* spi: i.MX: reset controller on initSascha Hauer2017-01-101-0/+8
| | | | | | | | | | | | In rare cases the controller is does not work right after probe. When this happens the registers show that the TXFIFO contains words, but the transfer is never started. We observed that on some boards which boot from SPI NOR. The xload SPI code leaves the controller enabled, so the SPI controller is enabled during probe(). Disabling it before usage (and thus resetting it) helps. We haven't found out why exactly this happens. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM i.MX31: add SPI supportAlexander Kurz2016-08-031-3/+12
| | | | | | | | | | | | | | | | | The i.MX31 SPI interface was refered by freescale as spi_ver_0_4 in one of their older vendor extended linux releases. spi_ver_0_4 differs only in minor aspects to spi_ver_0_7 (i.MX35) which is already supported by barebox. Regarding barebox, the differences boil down to the location and length of the CHIP SELECT and BIT COUNT/BURST LENGTH elements of CONREG. The spi_ver_0_4 variant is limited to single word bursts with a maximum of 32 bits_per_word. Add support for the i.MX31 SPI interface to the barebox spi_ver_0_7 implementation. Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: imx: Remove the use of property "fsl, spi-num-chipselects"Alexander Shiyan2016-06-271-12/+5
| | | | | | | | The "fsl,spi-num-chipselects" property will be marked obsolete soon. This patch updates the driver to be ready to such changes. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* whole tree: remove trailing whitespacesDu Huanpeng2016-04-211-1/+1
| | | | | Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: i.MX: optimize transfers for ECSPI v2.3Sascha Hauer2015-11-301-1/+72
| | | | | | | | | | | | | | Instead of writing one word to the txfifo and then wait until one is received in the rxfifo we can write while the txfifos are not full and read as long the rxfifos contain data. This makes transfers for the m25p80 driver around 7 times faster here. Unlike the last version this time we only optimize the common case with 8 bits per word and SPI_LSB_FIRST cleared. The other cases would require more bit shuffling of the data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "spi: i.MX: optimize transfers for ECSPI v2.3"Sascha Hauer2015-10-051-72/+1
| | | | | | | This does not work on the Efika MX Smartbook which uses SPI to connect the MC13892. Needs some rework. This reverts commit 746a5530bee37c8d2ffc75609447641b3f3cb55b.
* spi: i.MX: optimize transfers for ECSPI v2.3Sascha Hauer2015-08-311-1/+72
| | | | | | | | | | Instead of writing one word to the txfifo and then wait until one is received in the rxfifo we can write until the txfifos are not full and read as long the rxfifos contain data. This makes transfers for the m25p80 driver around 7 times faster here. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: i.MX: create SoC specific transfer functionsSascha Hauer2015-08-311-14/+31
| | | | | | | There are SoC specific ways to optimize transfers. Make the way free to implement these by creating SoC specific transfer functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: i.MX: use start mode control bitSascha Hauer2015-08-311-6/+2
| | | | | | | | The i.MX SPI controller in version 2.3 can immediately start a transfer when the txfifo is written to. In this mode we no longer have to trigger the transfer with the xch bit which makes the code a bit simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: i.MX: move register defines to include/Sascha Hauer2015-07-161-79/+1
| | | | | | | The register defines will be used by the SPI xload code, so move them to a place where the xload code can include them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-061-4/+4
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | spi: i.MX: Respect the value of 'cs_change'Andrey Smirnov2015-04-141-1/+19
|/ | | | | | | | Add the code to correctly handle 'cs_change' field in 'struct spi_transfer'(base on the similar code from altera_spi.c) Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: SPI: Respect SPI_LSB_FIRST flag in mode settingsAndrey Smirnov2015-01-161-4/+37
| | | | | | | | | | Add code to support SPI transfers that have data shifted out least significant bit first. This is useful in many cases, but specifically it is needed for drivers/firmware/altera_serial.c to work on i.MX platform. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: i.MX: Move to coredevice_initcallSascha Hauer2014-05-191-1/+1
| | | | | | | SPI is often used by other devices, so make sure it's initialized early. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2014-05-051-1/+1
|\
| * SPI: i.MX: Remove redundant assignmentAlexander Shiyan2014-04-291-1/+1
| | | | | | | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2014-05-051-15/+7
|\ \ | |/ |/|
| * spi: i.MX: Optimise driver private structureAlexander Shiyan2014-04-231-8/+2
| | | | | | | | | | | | | | | | No need to store init() function in the driver private structure since it called only once during startup. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: i.MX: Simplify cspi_0_0_init()Alexander Shiyan2014-04-231-7/+5
| | | | | | | | | | | | | | Use SPI module software reset to simplify cspi_0_0_init(). Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | spi: i.MX: Fix direction for CS GPIOsAlexander Shiyan2014-04-081-2/+2
|/ | | | | | | | Direction for CS GPIOs (for some targets) is undefined. This patch fixes this issue. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: imx: Use device idsSascha Hauer2014-02-101-18/+48
| | | | | | To let the driver work on all SoCs without the use of cpu_is_*() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: imx: Use IS_ENABLED to drop ifdefsSascha Hauer2014-02-091-21/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: imx: drop use of enumSascha Hauer2014-02-091-45/+24
| | | | | | | | | enum imx_spi_devtype is used as index into an array of controller types. This makes the controller type handling unnecessarily complicated. Just drop the enum and instead of an array use different statically initialized structs and referene them by name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2013-11-081-0/+1
| | | | | | | | A lot of files rely on include/driver.h including include/of.h (and this including include/errno.h. include the files explicitly so we can eventually get rid of including of.h from driver.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: Call spi_of_register_slaves from coreSascha Hauer2013-10-311-2/+0
| | | | | | Makes individual handling of OF spi slaves unnecessary in the bus drivers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* OF: gpio: convert DT based gpio handling to new OF APISebastian Hesselbarth2013-07-051-0/+1
| | | | | | | | | | | This creates a Linux OF API compatible counterpart of of_get_named_gpio_flags. Existing of_get_named_gpio is converted to a static inline function, which is in the corresponding of_gpio.h include. While at it, drivers/of/gpio.c is also renamed to drivers/of/of_gpio.c to follow the of_ prefix naming scheme. The new include is also added to existing users of of_get_named_gpio. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2013-03-041-9/+1
|\
| * Use new device_platform_driver() macro for driversAlexander Shiyan2013-02-131-9/+1
| | | | | | | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | imx_spi: fix bus-num setupHubert Feurstein2013-02-211-0/+1
|/ | | | | Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx-clk'Sascha Hauer2012-10-041-3/+19
|\
| * ARM i.MX: Remove old clock supportSascha Hauer2012-10-041-1/+0
| | | | | | | | | | | | | | The old clock support is now unused. Remove it. The former i.MX clko command is superseeded by generic clock manipulation commands. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi i.MX: Switch to clk supportSascha Hauer2012-10-041-2/+19
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+1
|/ | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-4/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | | | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | spi imx: dt supportSascha Hauer2012-09-231-2/+47
|/ | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX35: add cspi1 supportEric Bénard2012-08-291-1/+1
| | | | | | | tested with a m25p128 flash both in nand boot & spi boot. Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* SPI i.MX: Add support for i.MX6Sascha Hauer2012-07-311-3/+3
| | | | | | | | | The i.MX5 does not have a valid function to get the spi clock. This patch introduces a function for i.MX6, and moves the bogus spi clock speed to the speed-imx5*.c. Not nice, but preserves the current status quo for i.MX5 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX SPI: Setup SPI chipselect to inactive state while initializing deviceAlexander Shiyan2012-05-161-0/+4
| | | | | | | | To avoid unnecessary preset initial state chipselect lines for SPI, set it to inactive state when adding devices to the system. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* introduce io.hSascha Hauer2011-09-221-1/+1
| | | | | | | To allow for some generic io accessors introduce io.h and use this instead of asm/io.h throughout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imx25: imx_spi: support CSPI v0.7 as found on i.MX25Paul Fertser2011-09-211-0/+111
| | | | | | | | | | Based on the Linux driver. Tested with m25p80 with CS in GPIO mode. Clock setting support is ad-hoc as the corresponding mach is not using the generic clock infrastructure. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imx_spi: rework transfer according to the API, fix compatibility with ↵Paul Fertser2011-09-121-11/+44
| | | | | | | | | | spi_write_then_read() This code was tested barely with m25p80 driver, reading jedec id and some data from the chip worked fine. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: add support for the i.MX53Marc Kleine-Budde2011-07-291-1/+1
| | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>