summaryrefslogtreecommitdiff
path: root/drivers/spi
AgeCommit message (Collapse)Author
2019-09-16spi: Add spi_write_then_readJagan Teki
Add support for SPI synchronous write followed by read, this is common interface call from spi-nor to spi drivers. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Tested-by: Adam Ford <aford173@gmail.com> #da850-evm
2019-09-16spi: Kconfig: Unmark DEPRECATED for MXS_SPILukasz Majewski
MXS_SPI driver now partially converted into driver-model, so unmark the DEPRECATED option for the same. Signed-off-by: Lukasz Majewski <lukma@denx.de> [jagan: update the commit message] Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-09-16spi: soft_spi: Fix data abort if slave is not probedChristophe Kerello
In case spi_get_bus_and_cs callback is used, spi bus is first probed then slave devices are probed. To avoid a data abort in soft_spi probe function, we need to check that (slave != NULL). If slave is NULL, cs_flags and clk_flags will be initialized with respectively GPIOD_ACTIVE_LOW and 0. Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-09-16spi: mvebu_a3700_spi: Fix clock prescale computationMarek Behún
The prescaler value computation can yield wrong result if given 0x1f at the beginning: the value is computed to be 0x20, but the maximum value the register can hold 0x1f, so the actual stored value in this case is 0, which is obviously wrong. Set the upper bound of the value to 0x1f with the min macro. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-08-09x86: ich-spi: Convert driver to spi-mem opsBernhard Messerklinger
With the introduction of the new spi-mem model operations changed slightly. The new spi-mem operations make things a bit easier to handle for ich-spi flash interface. This patch converts the ich-spi driver by using spi-mem operations. Signed-off-by: Bernhard Messerklinger <bernhard.messerklinger@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested on Intel CrownBay and MinnowMax Tested-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: fix compiler warnings when building the driver for 64-bit] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2019-07-27Merge tag 'u-boot-imx-20190719' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-imx u-boot-imx-20190719 - CCF for i.MX6 - nandbcb command to write SPL into NAND - Switch to DM (i.MX28) - Boards: Toradex, engicam, DH - Fixes for i.MX8 - Fixes for i.MX7ULP Travis: https://travis-ci.org/sbabic/u-boot-imx/builds/561147504
2019-07-27Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-spiTom Rini
- fix for fsl_qspi read timeout (Thomas) - spi-mem read data size fix (Ye Li) - SiFive SPI driver, mmc_spi flags (Bhargav, Anup) - Micron spi-nor parts (Ashish) - MT7629 spi-mem driver(Weijie)
2019-07-25spi: Drop obsolete mtk_qspi driver referencesWeijie Gao
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the mtk_qspi is no longer compatible with the new spi-nor driver. Remove this driver along with replacing config item with new mtk spi-nor driver. Signed-off-by: Weijie Gao <weijie.gao@mediatek.com> [jagan: squash related changes and update commit message] Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-07-25spi: add spi-mem driver for MediaTek MT7629 SoCWeijie Gao
This patch adds spi-mem driver for MediaTek MT7629 SoC to access SPI-NOR and SPI-NAND flashes. Signed-off-by: Weijie Gao <weijie.gao@mediatek.com> [jagan: squash MAINTAINERS file] Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-07-22spi: stm32_qspi: Remove "st, stm32-qspi" compatible stringPatrice Chotard
"st,stm32-qspi" is no more used, remove it. Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
2019-07-19spi: mxs: Add support DM/DTS for i.MX28 mxs SPI driver (DM_SPI conversion)Lukasz Majewski
This patch converts mxs_spi driver to support DM/DTS. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Marek Vasut <marex@denx.de>
2019-07-18spi: Add SiFive SPI driverBhargav Shah
This patch adds SiFive SPI driver. The driver is 100% DM driver and it determines input clock using clk framework. The SiFive SPI block is found on SiFive FU540 SOC and is used to access flash and MMC devices on SiFive Unleashed board. This driver implementation is inspired from the Linux SiFive SPI driver available in Linux-5.2 or higher and SiFive FSBL sources. Signed-off-by: Bhargav Shah <bhargavshah1988@gmail.com> Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-07-18drivers/spi: fsl_qspi: improve timeout calculationThomas Schaefer
Use readl_poll_timeout instead of explicit calculation Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com> Reviewed-by: Fabio Estevam <festevam@gmail.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-07-18drivers/spi: fsl_qspi: fix read timeoutThomas Schaefer
During QSPI reads, current is_controller_busy function sporadically fails with -ETIMEDOUT due to fixed number of 5 test loops. Using timer functions to wait 1000 us instead will fix this. Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com> Reviewed-by: Fabio Estevam <festevam@gmail.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-07-18spi: spi-mem: Fix read data size issueYe Li
When slave drivers don't set the max_read_size, the spi-mem should directly use data.nbytes and not limit to any size. But current logic will limit to the max_write_size. Signed-off-by: Ye Li <ye.li@nxp.com> Acked-by: Vignesh Raghavendra <vigneshr@ti.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-07-14Merge tag 'u-boot-stm32-20190712' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-stm - syscon: add support for power off - stm32mp1: add op-tee config - stm32mp1: add specific commands: stboard and stm32key - add stm32 mailbox driver - solve many stm32 warnings when building with W=1 - update stm32 gpio driver
2019-07-12spi: stm32: Fix warnings when compiling with W=1Patrick Delaunay
This patch solves the following warnings: drivers/spi/stm32_spi.c: In function 'stm32_spi_write_txfifo': drivers/spi/stm32_spi.c:116:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (priv->tx_len >= sizeof(u32) && ^~ drivers/spi/stm32_spi.c:122:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] } else if (priv->tx_len >= sizeof(u16) && ^~ drivers/spi/stm32_spi.c: In function 'stm32_spi_read_rxfifo': drivers/spi/stm32_spi.c:150:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] (priv->rx_len >= sizeof(u32) || (sr & SPI_SR_RXWNE))) { ^~ drivers/spi/stm32_spi.c:156:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] (priv->rx_len >= sizeof(u16) || ^~ drivers/core/simple-bus.c:15:12: warning: no previous prototype for 'simple_bus_translate' [-Wmissing-prototypes] fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr) ^~~~~~~~~~~~~~~~~~~~ drivers/spi/stm32_spi.c: In function 'stm32_spi_set_speed': drivers/spi/stm32_spi.c:335:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] div > STM32_MBR_DIV_MAX) ^ drivers/spi/stm32_spi.c:344:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] if ((mbrdiv - 1) < 0) ^ drivers/spi/stm32_spi.c: In function 'stm32_spi_probe': drivers/spi/stm32_spi.c:531:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (i = 0; i < ARRAY_SIZE(priv->cs_gpios); i++) { ^ Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-07-12spi: stm32_qspi: avoid warnings when building with W=1 optionPatrick Delaunay
This patch solves warnings detected by setting W=1 when building. Warnings type detected: - [-Wtype-limits] - [-Wsign-compare] Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-07-11Merge tag 'dm-pull-9jul19-take2' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-dm - Sandbox improvements including .dts refactor - Minor tracing and PCI improvements - Various other minor fixes - Conversion of patman, dtoc and binman to support Python 3
2019-07-11Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvellTom Rini
- SPL SATA enhancements to allow booting from RAW SATA device needed for Clearfog (Baruch) - Enable SATA booting on Clearfog (Baruch) - Misc changes to Turris Omnia (Marek) - Enable CMD_BOOTZ and increase SYS_BOOTM_LEN on crs305-1g-4s (Luka) - Enable FIT support for db-xc3-24g4xg (Chris) - Enable DM_SPI on Keymile Kirkwood board with necessary changes for this (Pascal) - Set 38x and 39x AVS on lower frequency (Baruch)
2019-07-11km/spi: remove deprecated SPI flash driver code for KM Kirkwood boardsPascal Linder
KM Kirkwood boards now implement the driver model for its SPI flash interface. Therefore, the old board specific claim and release functions can be deleted. The preprocessor definition CONFIG_SYS_KW_SPI_MPP is yet unused as well. All its appearances and dependencies are removed in the kirkwood_spi driver, header files and finally the configuration whitelist. Signed-off-by: Pascal Linder <pascal.linder@edu.hefr.ch> Signed-off-by: Holger Brunck <holger.brunck@ch.abb.com> Signed-off-by: Stefan Roese <sr@denx.de>
2019-07-11km/spi: add weak functions to kirkwood_spi driver (DM part)Pascal Linder
The weak functions, known from the legacy code, are added to the DM part as well. For this purpose, the release operation first needs to be implemented. KM Kirkwood boards will overwrite those weak functions to change the MPP configuration when claiming/releasing the bus, because the hardware pins are shared between the SPI NOR and NAND devices. Signed-off-by: Pascal Linder <pascal.linder@edu.hefr.ch> Signed-off-by: Holger Brunck <holger.brunck@ch.abb.com> Signed-off-by: Stefan Roese <sr@denx.de>
2019-07-10spi: Avoid using malloc() in a critical functionSimon Glass
In general we should avoid calling malloc() and free() repeatedly in U-Boot lest we turn it into tianocore. In SPL this can make SPI flash unusable since free() is often a nop and allocation space is limited. In any case, these seems no need for malloc() since the number of bytes is very small, perhaps less than 8. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: d13f5b254a (spi: Extend the core to ease integration of SPI memory controllers)
2019-07-10sandbox: Correct spi flash operationSimon Glass
Since the SPI nor conversion, 'sf probe' does not work on sandbox. Fix this by using the expected compatible string in the flash node. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: cd35365762 (mtd: sf_probe: remove spi-flash compatible)
2019-07-10spi: Add SPI controller driver for UniPhier SoCsKunihiko Hayashi
Add SPI controller driver implemented in Socionext UniPhier SoCs. This controller has the SPI master mode only. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
2019-07-09spi: Add Atmel QuadSPI driverTudor Ambarus
Backport the driver from linux v5.1-rc5 and adapt it for u-boot. Tested on sama5d2_xplained Rev B with mx25l25635e spi-nor flash. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-17Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini
- Drop zipitz2 board (Tom) - Add DEPRECATED option (Tom) - Mark legacy or non-dm drivers as DEPRECATED (Jagan)
2019-06-13spi: Kconfig: Mark LPC32XX_SSP as DEPRECATEDJagan Teki
Mark LPC32XX_SSP as DEPRECATED, this so the resulting build shows warning for deprecated configuration enabled and associated code will remove in v2019.07 release. Cc: Albert ARIBAUD <albert.aribaud@3adev.fr> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Acked-by: Vladimir Zapolskiy <vz@mleia.com> Acked-by: Sylvain Lemieux <slemieux@tycoint.com> [trini: Switch to DEPRECATED] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-06-13spi: Kconfig: Mark SOFT_SPI as DEPRECATEDJagan Teki
Mark SOFT_SPI as DEPRECATED, this so the resulting build shows warning for deprecated configuration enabled and associated code will remove in v2019.07 release. Cc: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> [trini: Switch to DEPRECATED] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-06-13spi: Kconfig: Mark SH_SPI as DEPRECATEDJagan Teki
Mark SH_SPI as DEPRECATED, this so the resulting build shows warning for a deprecated configuration enabled and associated code will remove in v2019.07 release. Acked-by: Marek Vasut <marex@denx.de> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> [trini: Switch to DEPRECATED] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-06-13spi: Kconfig: Mark MXS_SPI has DEPRECATEDJagan Teki
Mark MXS_SPI as DEPRECATED, this so the resulting build shows warning for broken configuration enabled and associated code will remove in v2019.07 release. Cc: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <fabio.estevam@nxp.com> Cc: Michael Trimarchi <michael@amarulasolutions.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> [trini: Switch to DEPRECATED] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-06-11Merge tag 'u-boot-stm32-20190606' of https://github.com/pchotard/u-bootTom Rini
- Add Ethernet support for STM32MP1 - Add saveenv support for STM32MP1 - Add STM32MP1 Avenger96 board support - Add SPI driver suport for STM32MP1 - Add watchdog support for STM32MP1 - Update power supply check via USB TYPE-C for STM32MP1 discovery board
2019-06-11Merge tag 'u-boot-imx-20190612' of git://git.denx.de/u-boot-imxTom Rini
u-boot-imx-20190612 -------------------- - Board fixes: - imx6logic - wandboard - mx6sabre boots again - imx8qm_mek - pico-* boards - Toradex apalis / colibri - engicam imx6 (environment) - KP MX53 - opos6ul - Switch to DM: - vining2000 - dh MX6 - Toradex colibri i.MX7 - Novena - Security : fix CSF size for HAB - Other: - imx: fix building for i.mx8 without spl - pcie and switch to DM mx6sabreauto: Enable SPL SDP support
2019-06-11spi: imx: work with cs greater 0Heiko Schocher
currently spi mxc driver can only handle cs 0. Allow it to handle also cs > 0. Signed-off-by: Heiko Schocher <hs@denx.de>
2019-06-11spi: imx: remove doubled pointer from mxc_spi_probeHeiko Schocher
in mxc_spi_probe() plat and mxcs pointer are created: struct mxc_spi_slave *plat = bus->platdata; struct mxc_spi_slave *mxcs = dev_get_platdata(bus); which have the same value. Remove plat pointer. Signed-off-by: Heiko Schocher <hs@denx.de>
2019-06-10Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini
- mpc8xxx spi driver fixes (Mario) - mpc8xxx spi dm conversion (Mario, Jagan) - SPI DM Migration update (Jagan)
2019-06-10spi: mpc8xxx: Convert to DMJagan Teki
Support DM in the MPC8xxx SPI driver, and remove the legacy SPI interface. Signed-off-by: Mario Six <mario.six@gdsys.cc> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Use get_timerMario Six
The comment before the transmission loop in conjunction with the definition of SPI_TIMEOUT as 1000 implies that the loop is supposed to have a timeout value of 1000 ms. But since there is no mdelay(1) or similar in the loop body, the loop just runs 1000 times, without regard for the time elapsed. To correct this, use the standard get_timer functionality to properly time out the loop after 1000 ms. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Fix if checkMario Six
Decreasing the bit length and increasing the write data pointer should be done when there are more than 32 bit of data, not 16 bit. This did not produce incorrect behavior, because the only time where the two checks produce different outcomes is the case of 16 < bitlen < 32, and in this case the subsequent transmission is the last one regardless, hence the additional bit length decrease and write data pointer increase has no effect anyway. Still, the correct check is the check for "bitlen > 32", so correct this behavior. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Re-order transfer setupMario Six
Minize the time the adapter is disabled (via SPI_MODE_EN clearing/setting) to just the character length setting, and only set up the temporary data writing variable right before we need it, so there is a more clear distinction between setting up the SPI adapter, and setting up the data to be written. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Document LEN setting betterMario Six
Instead of having a table right before the code implementing the length setting for documentation, have inline comments for the if branches actually implementing the length setting described table's entries (which is readable thanks to the set_char_len function). Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Rename variableMario Six
The variable "char_size" holds the number of bits to be transferred in the current loop iteration. A better name would be "xfer_bitlen", which we rename this variable to. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Make code more readableMario Six
Introduce the to_prescale_mod and set_char_len inline functions to make the code more readable. Note that the added "if (bitlen > 16)" check does not change the semantics of the current code, and hence only preserves the current error (this will be fixed in a later patch in the series). Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Reduce scope of loop variablesMario Six
The transmission loop starts with setting some variables, which are only used inside the loop. Reduce the scope to the loop to make the declaration and initialization of these variables coincide. In the case of char_size this also always initializes the variable immediately with the final value actually used in the loop (instead of the placeholder value 32). Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Simplify logic a bitMario Six
We do nothing in the loop if the "not empty" event was not detected. To simplify the logic, check if this is the case, and skip the execution of the loop early to reduce the nesting level and flag checking. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Get rid of is_readMario Six
Get rid of the is_read variable, and just keep the state of the "not empty" and "not full" events in two boolean variables within the loop body. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Simplify ifMario Six
Instead of having a nested if block, just have two branches within the overarching if block to eliminate one nesting level. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Use IO accessorsMario Six
Accesses to the register map are currently done by directly reading and writing the structure. Switch to the appropriate IO accessors instead. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Replace defines with enumsMario Six
Replace pre-processor defines with proper enums, and use the BIT macro where applicable. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
2019-06-10spi: mpc8xxx: Fix function names in stringsMario Six
Replace the function name with a "%s" format string and the __func__ variable in debug statements (as proposed by checkpatch). Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>