summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/spi-nor/fsl-quadspi.c
Commit message (Collapse)AuthorAgeFilesLines
* mtd: spi-nor: fsl-quadspi: fix read error for flash size larger than 16MBLiu Xiang2018-10-121-0/+1
| | | | | | | | | | | | If the size of spi-nor flash is larger than 16MB, the read_opcode is set to SPINOR_OP_READ_1_1_4_4B, and fsl_qspi_get_seqid() will return -EINVAL when cmd is SPINOR_OP_READ_1_1_4_4B. This can cause read operation fail. Fixes: e46ecda764dc ("mtd: spi-nor: Add Freescale QuadSPI driver") Cc: <stable@vger.kernel.org> Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: spi-nor: fsl-quadspi: Don't let -EINVAL on the busAhmad Fatoum2018-10-081-4/+10
| | | | | | | | | | | | | | | | | | | fsl_qspi_get_seqid() may return -EINVAL, but fsl_qspi_init_ahb_read() doesn't check for error codes with the result that -EINVAL could find itself signalled over the bus. In conjunction with the LS1046A SoC's A-009283 errata ("Illegal accesses to SPI flash memory can result in a system hang") this illegal access to SPI flash memory results in a system hang if userspace attempts reading later on. Avoid this by always checking fsl_qspi_get_seqid()'s return value and bail out otherwise. Fixes: e46ecda764dc ("mtd: spi-nor: Add Freescale QuadSPI driver") Cc: stable@vger.kernel.org Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: spi-nor: fsl-quadspi: add support for ls2080a/ls1080aYogesh Gaur2018-05-181-0/+11
| | | | | | | | | LS2080a/LS1088a supports Freescale Quad SPI controller. Add fsl-quadspi driver support for ls2080a and ls1088a chip. Signed-off-by: Suresh Gupta <suresh.gupta@nxp.com> Signed-off-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: spi-nor: fsl-quadspi: fix api naming typo _init_ahb_readYogesh Gaur2018-05-181-2/+2
| | | | | | | | | Fix api naming typo _init_ahb_read fsl_qspi_init_abh_read --> fsl_qspi_init_ahb_read Signed-off-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com> Acked-by: Han Xu <han.xu@nxp.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: fsl-quadspi: Distinguish the mtd device namesFabio Estevam2018-03-301-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently on a imx6sx-sdb board, which has two SPI NOR chips connected to QSPI2 the following output from /proc/mtd is seen: dev: size erasesize name mtd0: 01000000 00010000 "21e4000.qspi" mtd1: 01000000 00010000 "21e4000.qspi" Attempts to partition them on the kernel command line result in both chips with identical (and identically named) partitions, which is an inconvenient behavior. Assign a different mtd->name for each mtd device to avoid this problem. After this change the output from /proc/mtd becomes: dev: size erasesize name mtd0: 01000000 00010000 "21e4000.qspi-0" mtd1: 01000000 00010000 "21e4000.qspi-1" In order to keep mtdparts compatibility keep the mtd->name unchanged when a single SPI NOR is present. Reported-by: David Wolfe <david.wolfe@nxp.com> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Han Xu <han.xu@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: fsl-quadspi: Remove unneeded driver.bus assignmentBoris Brezillon2018-03-291-1/+0Star
| | | | | | | | | platform_driver_register() takes care of assigning driver->bus to &platform_bus_type, no need to explicitly assign it in the driver. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Acked-by: Han Xu <han.xu@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
* mtd: fsl-quadspi: account for const type of of_device_id.dataJulia Lawall2018-01-071-4/+4
| | | | | | | | | | | | | | This driver creates a number of const structures that it stores in the data field of an of_device_id array. The data field of an of_device_id structure has type const void *, so there is no need for a const-discarding cast when putting const values into such a structure. Done using Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
* mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocolsCyrille Pitchen2017-05-151-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* mtd: fsl-quadspi: Rename SEQID_QUAD_READ to SEQID_READYunhui Cui2017-02-101-4/+4
| | | | | | | | | | | There are some read modes for flash, such as NORMAL, FAST, QUAD, DDR QUAD. These modes will use the identical lut table base So rename SEQID_QUAD_READ to SEQID_READ. Signed-off-by: Yunhui Cui <B56489@freescale.com> Signed-off-by: Yunhui Cui <yunhui.cui@nxp.com> Acked-by: Han xu <han.xu@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
* mtd:fsl-quadspi:use the property fields of SPI-NORYunhui Cui2017-02-101-28/+12Star
| | | | | | | | | | | We can get the read/write/erase opcode from the spi nor framework directly. This patch uses the information stored in the SPI-NOR to remove the hardcode in the fsl_qspi_init_lut(). Signed-off-by: Yunhui Cui <B56489@freescale.com> Signed-off-by: Yunhui Cui <yunhui.cui@nxp.com> Acked-by: Han xu <han.xu@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
* mtd: spi-nor: constify fsl_qspi_devtype_dataLABBE Corentin2016-11-261-4/+4
| | | | | | | | | All fsl_qspi_devtype_data structures are never modified. This patch constify them. Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Acked-by: Han Xu <han.xu@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
* mtd: spi-nor: stop passing around retlenMichal Suchanek2016-06-021-11/+6Star
| | | | | | | | | | | Do not pass retlen to hardware driver read/write functions. Update it in spi-nor generic driver instead. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com> Acked-by: Michal Suchanek <hramrach@gmail.com> Tested-by: Michal Suchanek <hramrach@gmail.com>
* mtd: fsl-quadspi: return amount of data read/written or errorMichal Suchanek2016-06-021-6/+11
| | | | | | | Return amount of data read/written or error as read(2)/write(2) does. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: change return value of read/writeMichal Suchanek2016-06-021-2/+3
| | | | | | | | | | | | | | | | | | Change the return value of spi-nor device read and write methods to allow returning amount of data transferred and errors as read(2)/write(2) does. Also, start handling positive returns in spi_nor_read(), since we want to convert drivers to start returning the read-length both via *retlen and the return code. (We don't need to do the same transition process for spi_nor_write(), since ->write() didn't used to have a return code at all.) Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com> Acked-by: Michal Suchanek <hramrach@gmail.com> Tested-by: Michal Suchanek <hramrach@gmail.com>
* mtd: spi-nor: fsl-quadspi: add support for ls1021aYao Yuan2016-03-071-0/+10
| | | | | | | | | | | LS1021a also support Freescale Quad SPI controller. Add fsl-quadspi support for ls1021a chip and make SPI_FSL_QUADSPI selectable for LS1021A SOC hardwares. Signed-off-by: Yuan Yao <yao.yuan@nxp.com> Acked-by: Han xu <han.xu@freescale.com> Acked-by: Han xu <han.xu@nxp.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: add big-endian supportYao Yuan2016-03-071-60/+97
| | | | | | | | | | | Add R/W functions for big- or little-endian registers: The qSPI controller's endian is independent of the CPU core's endian. So far, the qSPI have two versions for big-endian and little-endian. Signed-off-by: Yuan Yao <yao.yuan@nxp.com> Acked-by: Han xu <han.xu@freescale.com> Acked-by: Han xu <han.xu@nxp.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: possible NULL dereferenceBrian Norris2015-11-181-4/+4
| | | | | | | | | | | | | It is theoretically possible to probe this driver without a matching device tree, so let's guard against this. Also, use the of_device_get_match_data() helper to make this a bit simpler. Coverity complained about this one. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Han xu <han.xu@freescale.com>
* mtd: spi-nor: drop unnecessary partition parser dataBrian Norris2015-11-111-3/+1Star
| | | | | | | | | | | Now that the SPI-NOR/MTD framework pass the 'flash_node' through to the partition parsing code, we don't have to do it ourselves. Also convert to mtd_device_register(), since we don't need the 2nd and 3rd parameters anymore. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* mtd: spi-nor: convert to spi_nor_{get, set}_flash_node()Brian Norris2015-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Used semantic patch with 'make coccicheck MODE=patch COCCI=script.cocci': ---8<---- virtual patch @@ struct spi_nor b; struct spi_nor *c; expression d; @@ ( -(b).flash_node = (d) +spi_nor_set_flash_node(&b, d) | -(c)->flash_node = (d) +spi_nor_set_flash_node(c, d) ) ---8<---- And a manual conversion for the one use of spi_nor_get_flash_node(). Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* mtd: fsl-quadspi: fix macro collision problems with READ/WRITEHan Xu2015-10-261-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the READ/WRITE to FSL_READ/FSL_WRITE to resolve any possible namespace collisions with READ/WRITE macros (e.g., from <linux/fs.h>). Problems have been seen, for example, on mips: >> drivers/mtd/spi-nor/fsl-quadspi.c:186:5: error: 'LUT_0' undeclared (first use in this function) ((LUT_##ins) << INSTR0_SHIFT)) ^ >> drivers/mtd/spi-nor/fsl-quadspi.c:188:30: note: in expansion of macro 'LUT0' On SPARC: drivers/mtd/spi-nor/fsl-quadspi.c: In function 'fsl_qspi_init_lut': drivers/mtd/spi-nor/fsl-quadspi.c:369:1: error: 'LUT_0' undeclared (first use in this function) drivers/mtd/spi-nor/fsl-quadspi.c:418:1: error: pasting "LUT_" and "(" does not give a valid preprocessing token drivers/mtd/spi-nor/fsl-quadspi.c:418:2: error: implicit declaration of function 'LUT_' And surely on others. Fixes: d26a22d06708 ("mtd: fsl-quadspi: allow building for other ARCHes with COMPILE_TEST") Reported-by: Guenter Roeck <linux@roeck-us.net> Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Han Xu <b45815@freescale.com> [Brian: rewrote commit description] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Include <linux/sizes.h> to avoid build errorFabio Estevam2015-10-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | Building for x86 results in the following build errors: drivers/mtd/spi-nor/fsl-quadspi.c: In function 'fsl_qspi_init_lut': >> drivers/mtd/spi-nor/fsl-quadspi.c:355:21: error: 'SZ_16M' undeclared (first use in this function) if (q->nor_size <= SZ_16M) { ^ drivers/mtd/spi-nor/fsl-quadspi.c:355:21: note: each undeclared identifier is reported only once for each function it appears in drivers/mtd/spi-nor/fsl-quadspi.c: In function 'fsl_qspi_read': >> drivers/mtd/spi-nor/fsl-quadspi.c:208:27: error: 'SZ_4M' undeclared (first use in this function) #define QUADSPI_MIN_IOMAP SZ_4M ^ >> drivers/mtd/spi-nor/fsl-quadspi.c:845:25: note: in expansion of macro 'QUADSPI_MIN_IOMAP' q->memmap_len = len > QUADSPI_MIN_IOMAP ? len : QUADSPI_MIN_IOMAP; Explicitly include <linux/sizes.h> to fix the problem. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: fix printk() format warning for size_tBrian Norris2015-10-191-1/+1
| | | | | | | | | | | | | | | | Seen when compile-testing on non-32-bit arch: CC drivers/mtd/spi-nor/fsl-quadspi.o drivers/mtd/spi-nor/fsl-quadspi.c: In function 'fsl_qspi_read': drivers/mtd/spi-nor/fsl-quadspi.c:873:2: warning: format '%d' expects argument of type 'int', but argument 6 has type 'size_t' [-Wformat=] dev_dbg(q->dev, "cmd [%x],read from 0x%p, len:%d\n", ^ Also drop the '0x' prefixing to the '%p' formatter, since %p already knows how to format pointers appropriately. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Han xu <han.xu@freescale.com>
* mtd: spi-nor: Zap unneeded write_enable from write_regJagan Teki2015-09-121-2/+1Star
| | | | | | | | | | | 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>
* mtd: spi-nor: Decouple SPI NOR's device_node from controller deviceMarek Vasut2015-09-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem this patch is trying to address is such, that SPI NOR flash devices attached to a dedicated SPI NOR controller cannot read their properties from the associated struct device_node. A couple of facts first: 1) Each SPI NOR flash has a struct spi_nor associated with it. 2) Each SPI NOR flash has certain device properties associated with it, for example the OF property 'm25p,fast-read' is a good pick. These properties are used by the SPI NOR core to select which opcodes are sent to such SPI NOR flash. These properties are coming from spi_nor .dev->of_node . The problem is, that for SPI NOR controllers, the struct spi_nor .dev element points to the struct device of the SPI NOR controller, not the SPI NOR flash. Therefore, the associated dev->of_node also is the one of the controller and therefore the SPI NOR core code is trying to parse the SPI NOR controller's properties, not the properties of the SPI NOR flash. Note: The m25p80 driver is not affected, because the controller and the flash are the same device, so the associated device_node of the controller and the flash are the same. This patch adjusts the SPI NOR core such that the device_node is not picked from spi_nor .dev directly, but from a new separate spi_nor .flash_node element. This let's the SPI NOR controller drivers set up a different spi_nor .flash_node element for each SPI NOR flash. This patch also fixes the controller drivers to be compatible with this modification and correctly set the spi_nor .flash_node element. This patch is inspired by 5844feeaa4154d1c46d3462c7a4653d22356d8b4 mtd: nand: add common DT init code Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: use automatic spi-nor detectionBrian Norris2015-09-021-7/+1Star
| | | | | | | | | We don't really need the flash information from the device tree here. Let's stick with autodetection here instead. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Han Xu <han.xu@freescale.com> Tested-by: Han Xu <han.xu@freescale.com>
* mtd: spi-nor: embed struct mtd_info within struct spi_norBrian Norris2015-09-021-6/+4Star
| | | | | | | This reflects the proper layering, so let's do it. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Tested-by: Joachim Eastwood <manabian@gmail.com>
* mtd: spi-nor: assign mtd->priv in spi_nor_scan()Brian Norris2015-09-021-1/+0Star
| | | | | | | | Layering suggests that the SPI NOR layer (not the hardware driver) should be initializing the MTD layer. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Tested-by: Joachim Eastwood <manabian@gmail.com>
* mtd: spi-nor: fsl-quadspi: fix unsupported cmd when run flash_eraseFrank Li2015-08-061-8/+4Star
| | | | | | | | | | | | | | Erase function will use cmd 0x20 (SPINOR_OP_BE_4K) if kenrel enable option CONFIG_MTD_SPI_NOR_USE_4K_SECTORS. This command is not in fsl-quadspi driver LUT. So driver continue report fsl-quadspi 21e0000.qspi: Unsupported cmd 0x20. This patch fix this issue. Signed-off-by: Frank Li <Frank.Li@freescale.com> Acked-by: Han Xu <Han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: reset the module in the probeFrank Li2015-08-061-0/+8
| | | | | | | | | | | | | The uboot may run the QuadSpi controler with command: #sf probe So we should reset the module in the probe. This patch also clear the pending interrupts which arised by the uboot code. Signed-off-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: Frank Li <Frank.Li@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: workaround qspi can't wakeup from wait modeFrank Li2015-08-061-5/+21
| | | | | | | | | QSPI1 cannot wake up CCM from WAIT mode on SX ARD board, add pmqos to let PM NOT enter WAIT mode when accessing QSPI1, refer to TKT245618. Signed-off-by: Frank Li <Frank.Li@freescale.com> Signed-off-by: Han Xu <Han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: i.MX6SX: fixed the random QSPI access failed issueAllen Xu2015-08-061-25/+56
| | | | | | | | | | | | | | | | | | | | | | We found there is a low probability(5%) QSPI access timeout issue, usually it happened on kernel boot stage, the first time kernel tried to access QSPI chip. The READ_ID command was sent but not executed, consequently the probe function failed. The root cause is that the divider is not glitchless in i.MX6SX chip. If qspi clock enabled then change clock frequency by call clk_set_rate, there will be glitch at low possiblity rate and pass to qspi controller. The controler will be hang by this glitch. Based on the new clock flag(CLK_SET_RATE_GATE) and new framework, we need to change the approach of seting clock rate. 1. Disable clock. 2. call clk_set_rate. 3. Enable clock again. Signed-off-by: Han Xu <han.xu@freescale.com> Signed-off-by: Frank Li <Frank.Li@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: add i.mx6ul supportFrank Li2015-08-061-0/+11
| | | | | | | | Add i.mx6ul chip support Signed-off-by: Frank Li <Frank.Li@freescale.com> Acked-by: Han xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: add imx7d supportFrank Li2015-08-061-0/+26
| | | | | | | | | | Support i.mx7d. quadspi in i.mx7d increase rxfifo. require fill at least 16byte to trigger data transfer. Signed-off-by: Frank Li <Frank.Li@freescale.com> Signed-off-by: Han Xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: use quirk to distinguish different qspi versionHan Xu2015-08-061-8/+16
| | | | | | | | add several quirk to distinguish different version of qspi module. Signed-off-by: Han Xu <han.xu@freescale.com> Signed-off-by: Frank Li <Frank.Li@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-quadspi: dynamically map memory space for AHB readHan Xu2015-08-061-7/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSPI may failed to map enough memory (256MB) for AHB read in previous implementation, especially in 3G/1G memory layout kernel. Dynamically map memory to avoid such issue. This implementation generally map QUADSPI_MAX_IOMAP (default 4MB) memory for AHB read, it should be enough for common scenarios, and the side effect (0.6% performance drop) is minor. Previous implementation root@imx6qdlsolo:~# dd if=/dev/mtd0 of=/dev/null bs=1K count=32K 32768+0 records in 32768+0 records out 33554432 bytes (34 MB) copied, 2.16006 s, 15.5 MB/s root@imx6qdlsolo:~# dd if=/dev/mtd0 of=/dev/null bs=32M count=1 1+0 records in 1+0 records out 33554432 bytes (34 MB) copied, 1.43149 s, 23.4 MB/s After applied the patch root@imx6qdlsolo:~# dd if=/dev/mtd0 of=/dev/null bs=1K count=32K 32768+0 records in 32768+0 records out 33554432 bytes (34 MB) copied, 2.1743 s, 15.4 MB/s root@imx6qdlsolo:~# dd if=/dev/mtd0 of=/dev/null bs=32M count=1 1+0 records in 1+0 records out 33554432 bytes (34 MB) copied, 1.43158 s, 23.4 MB/s Signed-off-by: Han Xu <han.xu@freescale.com> Signed-off-by: Frank Li <Frank.Li@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Actually clear TX FIFO upon writeAlexander Stein2015-07-201-1/+1
| | | | | | | QUADSPI_MCR_CLR_TXF_MASK is the correct mask for clearing the TX FIFO. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Access multiple chips simultaneouslyHan Xu2015-06-231-9/+23
| | | | | | | | | | Add supports for simultaneous access to multiple chips. Need to lock the mutex before any quad spi operations and unlock the mutex after operations complete. Signed-off-by: Han Xu <b45815@freescale.com> [Brian: reworked err path in fsl_qspi_prep()] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: constify of_device_id arrayFabian Frederick2015-05-071-1/+1
| | | | | | | | of_device_id is always used as const. (See driver.of_match_table and open firmware functions) Signed-off-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: cleanup wait_for_completion return handlingNicholas Mc Guire2015-03-311-2/+1Star
| | | | | | | | | | 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 adding a additional appropriately typed variable. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Acked-by: Han Xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Print the error valueFabio Estevam2015-03-311-4/+4
| | | | | | | | | When displaying dev_err() messages it is useful to print the error value. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Han Xu <han.xu@freescale.com> [Brian: fix up "can not" at the same time] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: improve read performance by increase AHB transfer sizeAllen Xu2015-02-061-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | Set AHB transfer size to 1K which improved the read performance. Add ahb_buf_size field in fsl_qspi_devtype_data to denote the size for different SoC. Before: root@imx6qdlsolo:~# dd if=/dev/mtd1 of=/dev/null bs=1M count=16 16+0 records in 16+0 records out 16777216 bytes (17 MB) copied, 0.472183 s, 25.1 MB/s After: root@imx6qdlsolo:~# dd if=/dev/mtd1 of=/dev/null bs=1M count=16 16+0 records in 16+0 records out 16777216 bytes (17 MB) copied, 0.369439 s, 29.5 MB/s Signed-off-by: Allen Xu <b45815@freescale.com> Signed-off-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: Frank Li <Frank.Li@freescale.com> Acked-by: Huang Shijie <shijie.huang@intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Remove unnecessary 'map_failed' labelFabio Estevam2015-02-061-18/+10Star
| | | | | | | | | There is no need to keep the 'map_failed' label. We can simply return the error code directly and let the code shorter and cleaner. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Han Xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Remove unneeded success/error messagesFabio Estevam2015-02-061-2/+0Star
| | | | | | | | | | | | | | | | | When the driver successfully probe we already have messages like: [ 1.140989] fsl-quadspi 21e4000.qspi: s25fl128s (16384 Kbytes) [ 1.150902] fsl-quadspi 21e4000.qspi: s25fl128s (16384 Kbytes) Or in case of error: [ 1.175920] fsl-quadspi: probe of 21e4000.qspi failed with error -12 , so remove the unneeded success/error messages. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Han Xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Fix the error pathsFabio Estevam2015-02-061-4/+4
| | | | | | | | | | | Jumping to 'map_failed' label is not correct at these points, as it misses to disable the clocks that were previously enabled. Jump to 'irq_failed' label instead that will correctly disable the clocks. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Han Xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: fsl-quadspi: Fix module unboundFabio Estevam2015-01-201-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When removing the fsl-quadspi module and running 'cat /proc/mtd' afterwards, we see garbage data like: $ rmmod fsl-quadspi $ cat /proc/mtd dev: size erasesize name mtd0: 00000000 00000000 "(null)" mtd0: 00000000 00000000 "(null)" mtd0: 00000000 00000000 "(null)" ... mtd0: a22296c6c756e28 00000000 "(null)" mtd0: a22296c6c756e28 3064746d "(null)" If we continue doing multiple module load/unload operations, then it will also lead to a kernel crash. The reason for this is due to the wrong mtd index used in mtd_device_unregister() in the remove function. We need to keep the mtd unregister index aligned with the one used in the probe function, which means we need to take into account the 'has_second_chip' property. By doing so we can guarantee that the mtd index is the same in the registration and unregistration functions. With this patch applied we can load/unload the fsl-quadspi driver several times and it will result in no crash. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Huang Shijie <shijie.huang@intel.com> Tested-by: Frank Li <Frank.Li@freescale.com> Acked-by: Allen Xu <han.xu@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* mtd: spi-nor: fsl-qspi: support deep sleep mode for imx6 sx chipAllen Xu2015-01-161-0/+18
| | | | | | | | | | | i.mx6 sx support turn off fastmix and megamix power. qpsi controller can be turned off and all status lost when suspend/resume. add suspend/resume functions and reset qspi controller when resume. Signed-off-by: Allen Xu <b45815@freescale.com> Signed-off-by: Frank Li <Frank.Li@freescale.com> Acked-by: Huang Shijie <shijie.huang@intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* Merge tag 'for-linus-20141215' of git://git.infradead.org/linux-mtdLinus Torvalds2014-12-171-19/+4Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull MTD updates from Brian Norris: "Summary: - Add device tree support for DoC3 - SPI NOR: Refactoring, for better layering between spi-nor.c and its driver users (e.g., m25p80.c) New flash device support Support 6-byte ID strings - NAND: New NAND driver for Allwinner SoC's (sunxi) GPMI NAND: add support for raw (no ECC) access, for testing purposes Add ATO manufacturer ID A few odd driver fixes - MTD tests: Allow testers to compensate for OOB bitflips in oobtest Fix a torturetest regression - nandsim: Support longer ID byte strings And more" * tag 'for-linus-20141215' of git://git.infradead.org/linux-mtd: (63 commits) mtd: tests: abort torturetest on erase errors mtd: physmap_of: fix potential NULL dereference mtd: spi-nor: allow NULL as chip name and try to auto detect it mtd: nand: gpmi: add raw oob access functions mtd: nand: gpmi: add proper raw access support mtd: nand: gpmi: add gpmi_copy_bits function mtd: spi-nor: factor out write_enable() for erase commands mtd: spi-nor: add support for s25fl128s mtd: spi-nor: remove the jedec_id/ext_id mtd: spi-nor: add id/id_len for flash_info{} mtd: nand: correct the comment of function nand_block_isreserved() jffs2: Drop bogus if in comment mtd: atmel_nand: replace memcpy32_toio/memcpy32_fromio with memcpy mtd: cafe_nand: drop duplicate .write_page implementation mtd: m25p80: Add support for serial flash Spansion S25FL132K MTD: m25p80: fix inconsistency in m25p_ids compared to spi_nor_ids mtd: spi-nor: improve wait-till-ready timeout loop mtd: delete unnecessary checks before two function calls mtd: nand: omap: Fix NAND enumeration on 3430 LDP mtd: nand: add ATO manufacturer info ...
| * mtd: spi-nor: factor out write_enable() for erase commandsBrian Norris2014-12-011-5/+0Star
| | | | | | | | | | | | | | | | | | | | | | write_enable() was being duplicated to both m25p80.c and fsl-quadspi.c. But this should be handled within the spi-nor abstraction layer. At the same time, let's add write_disable() after erasing, so we don't leave the flash in a write-enabled state afterward. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Huang Shijie <shijie.huang@intel.com>
| * mtd: fsl-quadspi: drop wait-till-ready checksBrian Norris2014-11-051-11/+0Star
| | | | | | | | | | | | | | | | spi-nor.c should be taking care of these now. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Huang Shijie <b32955@freescale.com> Reviewed-by: Marek Vasut <marex@denx.de>
| * mtd: fsl-quadspi: Let the clocks error path be clearerFabio Estevam2014-10-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | When clk_prepare_enable(q->clk) fails it is clearer to disable the previous acquired clock (q->clk_en) in the error path rather than doing it locally. So disable q->clk_en in the error path only. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>