summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/spi-nor/spi-nor.c
Commit message (Collapse)AuthorAgeFilesLines
* mtd: Add underscore prefix to mtd hooksSascha Hauer2020-11-061-6/+6
| | | | | | | In the Kernel the mtd function hooks begin with an underscore. Do the same in barebox to be better comparable to the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Drop asynchronous erase supportSascha Hauer2020-11-061-4/+0
| | | | | | | asynchronous erase support is unused and also dropped from the Kernel, so remove it from barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for cy15x104qSascha Hauer2020-04-141-0/+3
| | | | | | | The Cypress cy15b104q and cy15v104q are 4Mbit serial SPI F-RAM devices. Add support for them to the spi-nor driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for en25qh64Ulrich Ölmann2019-12-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | This is a port of Linux kernel commit | commit 30a2c8aa3c520d54bcaf3015ca8141b0156448b1 | Author: Roger Pueyo Centelles <roger.pueyo@guifi.net> | Date: Thu Feb 7 20:09:35 2019 +0100 | | mtd: spi-nor: Add support for en25qh64 | | The Eon EN25QH64 is a 64 Mbit SPI NOR flash memory chip found | on recent wireless routers. Its 32, 128 and 256 Mbit siblings | are already supported. | | Tested on a COMFAST CF-E120A v3 router board. | | Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net> | Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com> | Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for is25lp01gClement Leger2019-11-251-0/+2
| | | | | | | Add ISSI 128Mb nor flash. Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2019-09-121-0/+7
|\
| * mtd: spi-nor: Import missing Micron devicesAndrey Smirnov2019-09-091-0/+3
| | | | | | | | | | | | | | | | Import entries for n25q00a, mt25qu02g, mt25ql02g, supported by latest Linux kernel. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: Add support for s25fl128s0 s25fl128s1 flashes from LinuxDU HUANPENG2019-09-021-0/+4
| | | | | | | | | | | | | | These definitions are taken from Linux's spi-nor driver as of v5.2-rc4 Signed-off-by: DU HUANPENG <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: add support for sst26vf seriesOleksij Rempel2019-08-211-0/+25
| | | | | | | | | | | | | | | | Ported from linux-4.19-at91 linux4sam_6.1 and needed for SAMA5D27 SOM1 EK. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: add UNLOCK_GLOBAL_BLOCK supportOleksij Rempel2019-08-211-1/+24
|/ | | | | | | | Ported from linux-4.19-at91 linux4sam_6.1 and needed for SAMA5D27 SOM1 EK. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: fix page offset/remains calculation in spi_nor_writeBastian Krause2019-08-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | nor->write() simply adds the number of written bytes to the pointer given. Thus retval is incremented in each loop cycle for each spi_nor_write() call without ever resetting it. This leads to wrong page offset/remains calculations and an incorrect number of bytes written to retlen. This becomes apparant only if the calling function actually compares len and retlen (e.g. mtd_peb_write() ). Otherwise wrong data is written: $ memcpy -s /dev/prng -d prng_data 0 0 10k $ erase /dev/mtd0.mypart $ cp prng_data /dev/mtd0.mypart $ memcmp -s prng_data -d /dev/mtd0.mypart 0 0 memcmp returned "files differ" before, with this patch it returns "OK". Fixes: c8516869c4 ("spi: Extend the core to ease integration of SPI memory controllers") Signed-off-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for ISSI flashes from LinuxUwe Kleine-König2019-06-171-0/+21
| | | | | | | The definitions are taken from Linux's spi-nor driver as of v5.2-rc4. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/qspi'Sascha Hauer2019-05-101-178/+494
|\
| * mtd: spi-nor: Add support for more Macronix devicesSascha Hauer2019-05-081-0/+3
| | | | | | | | | | | | Add support for the Macronix mx66u51235f, mx66l1g45g and mx66l1g55g. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: provide default erase_sector implementationSteffen Trumtrar2019-05-081-4/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on the Linux v4.4 patch commit c67cbb839da9cc2757eabfa128556db6a2baf160 Author: Brian Norris <computersforpeace@gmail.com> AuthorDate: Tue Nov 10 12:15:27 2015 -0800 Commit: Brian Norris <computersforpeace@gmail.com> CommitDate: Thu Nov 19 13:34:44 2015 -0800 mtd: spi-nor: provide default erase_sector implementation Some spi-nor drivers perform sector erase by duplicating their write_reg() command. Let's not require that the driver fill this out, and provide a default instead. Tested on m25p80.c and Medatek's MT8173 SPI NOR flash driver. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocolsSteffen Trumtrar2019-05-081-146/+438
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync the driver with Linux v4.12 and apply the patch commit cfc5604c488ccd17936b69008af0c9ae050f4a08 Author: Cyrille Pitchen <cyrille.pitchen@atmel.com> AuthorDate: Tue Apr 25 22:08:46 2017 +0200 Commit: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> CommitDate: Mon May 15 21:56:17 2017 +0200 mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocols This patch changes the prototype of spi_nor_scan(): its 3rd parameter is replaced by a 'struct spi_nor_hwcaps' pointer, which tells the spi-nor framework about the actual hardware capabilities supported by the SPI controller and its driver. Besides, this patch also introduces a new 'struct spi_nor_flash_parameter' telling the spi-nor framework about the hardware capabilities supported by the SPI flash memory and the associated settings required to use those hardware caps. Then, to improve the readability of spi_nor_scan(), the discovery of the memory settings and the memory initialization are now split into two dedicated functions. 1 - spi_nor_init_params() The spi_nor_init_params() function is responsible for initializing the 'struct spi_nor_flash_parameter'. Currently this structure is filled with legacy values but further patches will allow to override some parameter values dynamically, for instance by reading the JESD216 Serial Flash Discoverable Parameter (SFDP) tables from the SPI memory. The spi_nor_init_params() function only deals with the hardware capabilities of the SPI flash memory: especially it doesn't care about the hardware capabilities supported by the SPI controller. 2 - spi_nor_setup() The second function is called once the 'struct spi_nor_flash_parameter' has been initialized by spi_nor_init_params(). With both 'struct spi_nor_flash_parameter' and 'struct spi_nor_hwcaps', the new argument of spi_nor_scan(), spi_nor_setup() computes the best match between hardware caps supported by both the (Q)SPI memory and controller hence selecting the relevant settings for (Fast) Read and Page Program operations. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: spi-nor: remove unused write_enable from write_regSteffen Trumtrar2019-05-081-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on the Linux v4.2 commit: commit f9f3ce835ddce3c669eee869253105f88819888b Author: Jagan Teki <jteki@openedev.com> AuthorDate: Wed Aug 19 15:26:44 2015 +0530 Commit: Brian Norris <computersforpeace@gmail.com> CommitDate: Fri Sep 11 16:04:55 2015 -0700 mtd: spi-nor: Zap unneeded write_enable from write_reg The 'write_enable' argument is unused and unneeded, so remove it from the API. Signed-off-by: Jagan Teki <jteki@openedev.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Han Xu <han.xu@freescale.com> [Brian: fixed for nxp-spifi.c] Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * spi: Extend the core to ease integration of SPI memory controllersSteffen Trumtrar2019-05-081-23/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync with Linux v5.1-rc1. This is the barebox adoption of the commit commit c36ff266dc82f4ae797a6f3513c6ffa344f7f1c7 Author: Boris Brezillon <boris.brezillon@bootlin.com> Date: Thu Apr 26 18:18:14 2018 +0200 spi: Extend the core to ease integration of SPI memory controllers Some controllers are exposing high-level interfaces to access various kind of SPI memories. Unfortunately they do not fit in the current spi_controller model and usually have drivers placed in drivers/mtd/spi-nor which are only supporting SPI NORs and not SPI memories in general. This is an attempt at defining a SPI memory interface which works for all kinds of SPI memories (NORs, NANDs, SRAMs). Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@exceet.de> Tested-by: Frieder Schrempf <frieder.schrempf@exceet.de> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: add Winbond W25Q40BWAlexander Kurz2019-04-231-0/+1
|/ | | | | | | This 4MBit SPI chip can be found in Kindle Voyage devices Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for sst25wf040bYao Yuan2018-12-051-0/+1
| | | | | | | | Signed-off-by: Yuan Yao <yao.yuan@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> [Linux upstream commit: c887be71cc39] Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for sst25wf020aAlexis Ballier2018-12-051-0/+1
| | | | | | | | | | | | | | It is a 256KiB flash with 4 KiB erase sectors and 64KiB overlay blocks. This is the one available on Hardkernel's Odroid U3 shield. Signed-off-by: Alexis Ballier <aballier@gentoo.org> [Brian: seems like this does NOT require the usual SST_WRITE hacks] Signed-off-by: Brian Norris <computersforpeace@gmail.com> [Linux upstream commit: a1d97ef96e38] Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add manufacturer IDs for ISSI and Winbondmichael grassmann2018-03-221-0/+4
| | | | | | | | | | This patch includes new NOR flash IDs to support flashes from the manufacturers ISSI and Winbond - ISSI IS25LP128-JBLA3 and IS25LP128-JBLE - Winbond W25Q128JVSIM Signed-off-by: michael grassmann <m.grassmann@phytec.de> Signed-off-by: Christian Hemp <c.hemp@phytec.de>
* mtd: spi-nor: add support for w25q16dwMichael Grzeschik2018-03-051-0/+1
| | | | | Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: mx25l3205d/mx25l6405d: append SECT_4KUlrich Ölmann2017-11-281-2/+2
| | | | | | | | | | | | | | | | | | This is a port of Linux kernel commit | commit 0501f2e5ff28a02295e42fc9e7164a20ef4c30d5 | Author: Andreas Fenkart <afenkart@gmail.com> | Date: Thu Nov 5 10:04:23 2015 +0100 | | mtd: spi-nor: mx25l3205d/mx25l6405d: append SECT_4K | | according datasheet both chips can erase 4kByte sectors individually | | Signed-off-by: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org> | Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: sync definition of Spansion chips from LinuxUwe Kleine-König2017-06-191-10/+12
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add support for s25fl208kPeter Mamonov2017-01-301-0/+1
| | | | | Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: m25p80: add support for Everspin MR25H40Uwe Kleine-König2017-01-101-0/+1
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add MX25U2033EAlexander Kurz2016-11-111-0/+1
| | | | | | | This chip can be found in 4th generation Kindle devices Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add new variantsAlexander Kurz2016-08-031-0/+5
| | | | | | | Read access tested on W25Q20BW and MX25U4035. Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add support for s25fl116kSascha Hauer2016-02-111-0/+1
| | | | | | | The Spansion s25fl116k is a 16MBit flash memory. Add the flash info entry for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* spi-nor: Port erase timeout fix from LinuxAndrey Smirnov2016-02-081-3/+34
| | | | | | | | | | | Large SPI-NOR (>2MB) chips reuire more than 40 seconds to perform all-chip erase. This patch adapts 09b6a377687b885565339e60bc62566433a0406f from Linux kernel, which implements simple heuristics in order to calculate appropriate wait time (see orignal commit's description for more details of the fix) Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add Spansion S25FL204K supportAntony Pavlov2015-09-021-0/+1
| | | | | | | | | | Spansion S25FL204K is a 4-Mbit 3.0V Serial Flash Memory with Uniform 4 kB Sectors. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Acked-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2015-09-011-69/+12
|\
| * mtd: spi-nor: mostly drop lock/unlock codeSascha Hauer2015-08-281-66/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lock/unlock code is broken beyond repair. First of all the algorithm doesn't work properly. SPI NOR flashes can only protect a certain amount of blocks from the end of the device which is incompatible to the protect(start,len) API we have. The algorithm tries to be clever by doing protection only when it does not protect unrelated blocks and unprotection only when it does not unprotect unrelated blocks. This breaks for example when some code protects the last blocks (which may contain the bootloader), then protects the blocks before the last ones (which may contain the environment). Then if we try to overwrite the bootloader this won't work since it would unprotect the environment aswell, so the driver will not unprotect anything resulting in a failed erase/write later. Then the protection behaviour is different between different flashes. Some have three protection bits, some have four. For some the smallest protection are is 1/16 of the device, others have 1/256 or 1/64. Some have a bit which selects the lower area instead of upper area for protection. The position of this bit differs on different flashes. This patch removes the lock code completely and always unprotects the whole device. This way we can unprotect a device for writing to it and never protect it again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: m25p80: make it possible to use large blocks if desiredSascha Hauer2015-08-261-3/+4
| | | | | | | | | | | | | | | | | | | | Some SPI NOR flashes support 4K erase blocks. 4K erase blocks do not work with UBIFS which needs a minimum erase block size of 15360 bytes. Also bigger sectors are faster to erase. This patch adds a device tree option to use the bigger blocks instead of the default 4K blocks. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
* | spi-nor: Align spi_nor_ids[] with kernel 4.1Fabio Estevam2015-08-191-7/+12
|/ | | | | | | Sync the spi_nor_ids[] struct with the one from kernel 4.1. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add SPI-NOR frameworkSteffen Trumtrar2015-05-291-0/+1148
Import the SPI-NOR framework from linux kernel v3.19. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>