summaryrefslogtreecommitdiffstats
path: root/drivers/spi
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>
* spi: omap: make locally used functions staticSascha Hauer2018-11-191-4/+4
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-1/+1
|\
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: at91: remove mach/io.hSascha Hauer2018-11-061-1/+0
|/ | | | | | | Remove at91_sys_read() and at91_sys_write() since these are no longer used. This makes mach/io.h empty so remove that aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: atmel_spi: fix duplicate const warningLadislav Michl2018-09-261-1/+1
| | | | | Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: Select DRIVER_SPI_IMX_2_3 for i.MX8MQAndrey Smirnov2018-08-131-1/+1
| | | | | | | | Select DRIVER_SPI_IMX_2_3 for i.MX8MQ since that is the variant that's being used Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: Select DRIVER_SPI_IMX_2_3 for i.MX7Andrey Smirnov2018-01-111-1/+1
| | | | | | | | Select DRIVER_SPI_IMX_2_3 for i.MX7 since that is the variant that's being used. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> 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>
* of: use of_property_read_bool where appropriateSascha Hauer2017-04-121-4/+4
| | | | | | Use of_property_read_bool where boolean properties are read. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: atmel_spi: Add DT supportAndrey Smirnov2017-03-301-3/+26
| | | | | | Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: atmel_spi: Use VERSION register instead of CPU typeAndrey Smirnov2017-03-092-6/+30
| | | | | | | | Use VERSION register instead of CPU type to determine IP block's version and capabilities. This what corresponding Linux kernel driver does. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: atmel_spi: Configure CS GPIO as outputAndrey Smirnov2017-03-091-1/+5
| | | | | | | | On AT91 GPIOs default to being inputs, so we need to explicitly configure CS gpio to being an output. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: i.MX: Add driver for DSPIAndrey Smirnov2017-01-303-0/+423
| | | | | | | | Add driver for DSPI - SPI IP core found on various Freescale/NXP products (including Vybrid/VF610). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mvebu'Sascha Hauer2017-01-111-31/+56
|\
| * spi: mvebu: improve error reportingUwe Kleine-König2017-01-101-3/+11
| | | | | | | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: add LSB supportUwe Kleine-König2017-01-101-4/+24
| | | | | | | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: use wait_on_timeout instead of a loop with udelay.Uwe Kleine-König2017-01-101-7/+5
| | | | | | | | | | | | | | | | This looks nicer and reduces the time to transfer 40 MB at 50 MHz from 203 seconds to 87 seconds. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: only read from bus when data is neededUwe Kleine-König2017-01-101-5/+5
| | | | | | | | | | | | | | | | This optimization reduced the time to transfer 40 MB at 50 MHz from 214 seconds to 203 seconds. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: various non-critical improvements to armada_370_xp_spi_set_baudrateUwe Kleine-König2017-01-101-4/+3
| | | | | | | | | | | | | | | | | | - Initialize pdiv in declaration - fix format specifiers - simplify range check, pdiv can never be > 7 Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: make sure the value calculated for PSCL is also usedUwe Kleine-König2017-01-101-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | The function used a separate variable to hold the value calculated and only used it for range checking but then didn't use it. This fixes calculation for slow baud rate that require a divider > 15. Additionally fix the rounding. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: fix register macros for Armada 370/XP clock dividerUwe Kleine-König2017-01-101-2/+2
| | | | | | | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: mvebu: fix error handling for transfer problemsUwe Kleine-König2017-01-101-4/+4
| | | | | | | | | | | | | | | | | | When a message transfer fails no further messages are transferred, but the error value was not propagated to the caller. Fixes: 5db1a578d6ed ("spi: add Marvell MVEBU SoC SPI driver") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@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>
* spi: mvebu: fix baudrate selection for Armada 370/XPUwe Kleine-König2016-12-071-3/+5
| | | | | | | | | | | | | | | | | | There are two problems that made the driver choose the wrong baudrate calculation algorithm: a) The compatible used on 370/XP isn't marvell,armada-370-xp-spi but marvell,armada-370-spi or marvell,armada-xp-spi respectively. b) The probe function uses match = of_match_node(mvebu_spi_dt_ids, dev->device_node); to determine the right algorithm. As the devices are also compatible to marvell,orion-spi and this comes first in mvebu_spi_dt_ids[] it's always the older Orion algorithm that is used. This patch fixes both problems. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi: mvebu: make more than one device on a bus workUwe Kleine-König2016-10-191-1/+1
| | | | | | | The mvebu socs support up to 8 chip selects. Make use of them. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX drivers: enable i.MX50 where already supportedAlexander Kurz2016-09-121-2/+2
| | | | | | | | The i.MX50 SOC includes one ESDHCv3, three ESDHCv2, one cspi and two ecspi instances which are supported by existing drivers. Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM i.MX31: add SPI supportAlexander Kurz2016-08-032-4/+13
| | | | | | | | | | | | | | | | | 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>
* MIPS: ath79: dts: sync spi stuff with linux v4.7-rc2Antony Pavlov2016-06-141-1/+1
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-05-091-1/+1
|\
| * 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>
* | string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-1/+1
|/ | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-077-13/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/misc'Sascha Hauer2015-08-061-1/+1
|\
| * spi: only register enabled child nodesJan Luebbe2015-07-091-1/+1
| | | | | | | | | | Signed-off-by: Jan Luebbe <jluebbe@debian.org> 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>
* Abolish cpu_read* and cpu_write* accessorsMasahiro Yamada2015-05-201-2/+2
| | | | | | | | | | | | | | Commit 2e6a88f2101d (add cpu native ordered io accessors) introduced these macros and then commit be57f20cdd7d (Fix big endian MMIO primitives) figured out they are equivalent to __raw_{read,write}*. They turned out unnecessary after all. Anyway, most source files use __raw_read* and __raw_write*. Let's replace a few remaining references and abolish them. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-063-10/+10
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-303-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'for-next/mvebu'Sascha Hauer2015-05-065-2/+247
|\ \
| * | spi: Add SPI GPIO bitbang driverSebastian Hesselbarth2015-04-273-0/+245
| | | | | | | | | | | | | | | | | | | | | This adds a driver for SPI master by GPIO pins. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>