summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand: arasan_nfc: Add support for nand multi chip selectT Karthik Reddy2019-01-242-14/+20
| | | | | | | | | | This patch adds support for nand multi chip select. Also adding CONFIG_SYS_NAND_MAX_CHIPS to Kconfig to specify maximum number of nand chips. Signed-off-by: Tummala Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
* ARM: at91: Convert SPL_GENERATE_ATMEL_PMECC_HEADER to KconfigDerald D. Woods2019-01-211-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | This commit converts the following items to Kconfig: CONFIG_ATMEL_NAND_HWECC CONFIG_ATMEL_NAND_HW_PMECC CONFIG_PMECC_CAP CONFIG_PMECC_SECTOR_SIZE CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER [PMECC References] https://www.at91.com/linux4sam/bin/view/Linux4SAM/PmeccConfigure https://www.at91.com/linux4sam/bin/view/Linux4SAM/AT91Bootstrap [Mailing List Thread] https://lists.denx.de/pipermail/u-boot/2018-December/350666.html Fixes: 5541543f ("configs: at91: Remove CONFIG_SYS_EXTRA_OPTIONS assignment") [trini: Make the migration be size neutral and possibly not fix the above in all cases] Reported-by: Daniel Evans <photonthunder@gmail.com> Cc: Eugen Hristev <eugen.hristev@microchip.com> Signed-off-by: Derald D. Woods <woods.technical@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com>
* mtd: nand: raw: allow to disable unneeded ECC layoutsStefan Agner2019-01-162-0/+11
| | | | | | | | | | Each ECC layout consumes about 2984 bytes in the .data section. Allow to disable the default ECC layouts if a driver is known to provide its own ECC layout. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
* Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini2019-01-021-0/+4
|\
| * mtd: nand: raw: Add Hynix H27UBG8T2BTR id tableNikolai Zhubr2019-01-021-0/+4
| | | | | | | | | | | | | | | | | | This patch adds Hynix H27UBG8T2BTR id table as part of raw nand, these chips were available in some A20-olinuxino-micro boards. Signed-off-by: Nikolai Zhubr <n-a-zhubr@yandex.ru> [jagan: add proper commit message] Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
* | Merge tag 'u-boot-imx-20190101' of git://www.denx.de/git/u-boot-imxTom Rini2019-01-012-1/+59
|\ \ | |/ |/| | | | | | | | | | | | | imx for 2019.01 - introduce support for i.MX8M - fix size limit for Vhybrid / pico boards - several board fixes - w1 driver for MX2x / MX5x
| * nand: vybrid: Extend the vf610 NFC NAND driver to support device tree (and DM)Lukasz Majewski2019-01-011-0/+47
| | | | | | | | | | | | | | This commit adds support for device tree and enumeration via device model for the Vybrid's NFC NAND driver. Signed-off-by: Lukasz Majewski <lukma@denx.de>
| * Kconfig: Add entry for VF610 NAND NFC device tree aware driverLukasz Majewski2019-01-011-0/+11
| | | | | | | | | | | | | | This commit provides code to add proper entry to Kconfig to enable support for VF610 device tree aware driver. Signed-off-by: Lukasz Majewski <lukma@denx.de>
| * nand: vybrid: Use calloc() instead of malloc() to allocate struct nfcLukasz Majewski2019-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this change it is possible that Vybrid's NFC driver malloc() call will obtain some memory used (and correctly free'd) by some previous driver (in this case pinctrl for Vybrid). As a result some fields of struct nfc - in out case mtd->_get_device - are "pre initialized" with some random values. On the latter stage of booting, when e.g. somebody calls 'mtdparts default' the "data abort" is observed when __get_mtd_device() function is called. The mtd->_get_device pointer is not NULL and wrong value is referenced. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Stefan Agner <stefan.agner@toradex.com>
* | mtd: rawnand: denali: fix a race condition when DMA is kickedMasahiro Yamada2018-12-291-0/+6
| | | | | | | | | | | | | | | | Based on Linux commit cf51e4b9c34407bf0c3d9b582b7837e047e1df47 Add the register read-back, commenting why this is necessary. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* | mtd: rawnand: denali: optimize timing parameters for data interfaceMasahiro Yamada2018-12-293-24/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on Linux commit 1dfac31a5a63ac04a9b5fbc3f5105a586560f191 This commit improves the ->setup_data_interface() hook. The denali_setup_data_interface() needs the frequency of clk_x and the ratio of clk_x / clk. The latter is currently hardcoded in the driver, like this: #define DENALI_CLK_X_MULT 6 The IP datasheet requires that clk_x / clk be 4, 5, or 6. I just chose 6 because it is the most defensive value, but it is not optimal. By getting the clock rate of both "clk" and "clk_x", the driver can compute the timing values more precisely. To not break the existing platforms, the fallback value, 50 MHz is provided. It is true for all upstreamed platforms. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* | mtd: rawnand: denali_dt: add more clocks based on IP datasheetMasahiro Yamada2018-12-291-3/+35
|/ | | | | | | | | | | | | | | | | | | | | | Based on Linux commit 6f1fe97bec349a1fd6c5a8c7c5998d759fe721d5 Currently, denali_dt.c requires a single anonymous clock, but the Denali User's Guide requires three clocks for this IP: - clk: controller core clock - clk_x: bus interface clock - ecc_clk: clock at which ECC circuitry is run This commit supports these named clocks to represent the real hardware. For the backward compatibility, the driver still accepts a single clock just as before. The clk_x_rate is taken from the clock driver again if the named clock "clk_x" is available. This will happen only for future DT, hence the existing DT files are not affected. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini2018-12-056-81/+339
|\ | | | | | | | | | | | | | | - Various MTD fixes from Boris - Zap various unused / legacy paths. - pxa3xx NAND update from Miquel Signed-off-by: Tom Rini <trini@konsulko.com>
| * mtd: sf: Make sf_mtd.c more robustBoris Brezillon2018-12-061-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SPI flash based MTD devs can be registered/unregistered at any time through the sf probe command or the spi_flash_free() function. This commit does not try to fix the root cause as it would probably require rewriting most of the code and have an mtd_info object instance per spi_flash object (not to mention that the the spi-flash layer is likely to be replaced by a spi-nor layer ported from Linux). Instead, we try to be as safe as can be by checking the code returned by del_mtd_device() and complain loudly when there's nothing we can do about the deregistration failure. When that happens we also reset sf_mtd_info.priv to NULL, and check for NULL pointer in the mtd hooks so that -ENODEV is returned instead of hitting a NULL pointer dereference exception when the MTD instance is later accessed by a user. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: sf: Unregister the MTD device prior to removing the spi_flash objBoris Brezillon2018-12-061-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DM implementation of spi_flash_free() does not unregister the MTD device before removing the spi dev object. This leads to a use-after-free bug when the MTD device is later accessed by a MTD user (observed when attaching the device to UBI after env_sf_load() has called spi_flash_free()). Implement ->remove() and call spi_flash_mtd_unregister() from there. Fixes: 9fe6d8716e09 ("mtd, spi: Add MTD layer driver") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
| * mtd: Don't stop MTD partition creation when it fails on one deviceBoris Brezillon2018-12-062-28/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MTD partition creation code is a bit tricky. It tries to figure out when things have changed (either MTD dev list or mtdparts/mtdids vars) and when that happens it first deletes all the partitions that had been previously created and then creates the new ones based on the new mtdparts/mtdids values. But before deleting the old partitions, it ensures that none of the currently registered parts are being used and bails out when that's not the case. So, we end up in a situation where, if at least one MTD dev has one of its partitions used by someone (UBI for instance), the partitions update logic no longer works for other devs. Rework the code to relax the logic and allow updates of MTD parts on devices that are not being used (we still refuse to updates parts on devices who have at least one of their partitions used by someone). Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: Make sure we don't parse MTD partitions belonging to another devBoris Brezillon2018-12-061-5/+12
| | | | | | | | | | | | | | | | | | | | The mtdparts variable might contain partition definitions for several MTD devices. Each partition layout is separated by a ';', so let's make sure we don't pick a wrong name when mtdparts is malformed. Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: Make sure the name passed in mtdparts fits in mtd_name[]Boris Brezillon2018-12-061-3/+8
| | | | | | | | | | | | | | | | | | The local mtd_name[] variable is limited in size. Return an error if the name passed in mtdparts does not fit in this local var. Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: Be more strict on the "mtdparts=" prefix checkBoris Brezillon2018-12-061-1/+1
| | | | | | | | | | | | | | | | | | strstr() does not guarantee that the string we're searching for is placed at the beginning. Use strncmp() instead. Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: Use get_mtdids() instead of env_get("mtdids") in ↵Boris Brezillon2018-12-061-25/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | mtd_search_alternate_name() The environment is not guaranteed to contain a valid mtdids variable when called from mtd_search_alternate_name(). Call get_mtdids() instead of env_get("mtdids"). Fixes: ff4afa8a981e ("mtd: uboot: search for an equivalent MTD name with the mtdids") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: sf: Make sure we don't register the same device twiceBoris Brezillon2018-12-061-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | spi_flash_mtd_register() can be called several times and each time it will register the same mtd_info instance like if it was a new one. The MTD ID allocation gets crazy when that happens, so let's track the status of the sf_mtd_info object to avoid that. Fixes: 9fe6d8716e09 ("mtd, spi: Add MTD layer driver") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
| * mtd: Delete partitions attached to the device when a device is deletedBoris Brezillon2018-12-061-0/+7
| | | | | | | | | | | | | | | | | | If we don't do that, partitions might still be exposed while the underlying device is gone. Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: Parse mtdparts/mtdids again when the MTD list has been updatedBoris Brezillon2018-12-061-1/+17
| | | | | | | | | | | | | | | | | | Updates to the MTD device list should trigger a new parsing of the mtdids/mtdparts vars even if those vars haven't changed. Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: Add a function to report when the MTD dev list has been updatedBoris Brezillon2018-12-061-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | We need to parse mtdparts/mtids again everytime a device has been added/removed from the MTD list, but there's currently no way to know when such an update has been done. Add an ->updated field to the idr struct that we set to true every time a device is added/removed and expose a function returning the value of this field and resetting it to false. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de>
| * mtd: rawnand: pxa3xx: fix 2kiB pages with 8b strength chips layoutMiquel Raynal2018-11-221-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The initial layout for such NAND chips was the following: +----------------------------------------------------------------------------+ | 1024 (data) | 30 (ECC) | 1024 (data) | 30 (ECC) | 32 (free OOB) | 30 (ECC) | +----------------------------------------------------------------------------+ This layout has a weakness: reading empty pages trigger ECC errors (this is expected), but the hardware ECC engine tries to correct the data anyway and creates itself bitflips, hence bitflips are detected in erased pages while actually there are none in the NAND chip. Two solutions have been found at the same time. One was to enlarge the free OOB area to 64 bytes, changing the layout to be: +----------------------------------------------------------------------------+ | 1024 (data) | 30 (ECC) | 1024 (data) | 30 (ECC) | 64 (free OOB) | 30 (ECC) | +----------------------------------------------------------------------------+ ^^ The very big drawbacks of this solution are: 1/ It prevents booting from NAND. 2/ The current Linux driver (marvell_nand) does not have such problem because it already re-reads possible empty pages in raw mode before checking for bitflips. Using different layouts in U-Boot and Linux would simply not work. As this driver does support raw reads now and uses it to check for empty pages, let's forget about this broken hack and return to the initial layout with only 32 free OOB bytes. Fixes: ac56a3b30c ("mtd: nand: pxa3xx: add support for 2KB 8-bit flash") Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com>
| * mtd: nand: pxa3xx: re-read a page in raw mode on uncorrectable errorMiquel Raynal2018-11-221-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This only applies on BCH path. When an empty page is read, it triggers an uncorrectable error. While this is expected, the ECC engine might produce itself bitflips in the read data under certain layouts. To overcome this situation, always re-read the entire page in raw mode and check for the whole page to be empty. Also report the right number of bitflips if there are any. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com>
| * mtd: nand: pxa3xx: add raw read supportMiquel Raynal2018-11-221-6/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Raw read support is added by editing a few code sections: ->handle_data_pio() includes the ECC bytes that are not consumed anymore by the ECC engine. ->prepare_set_command() is changed so that the ECC bytes are requested as part of the data I/O length. ->drain_fifo() shall also avoid checking the R/B pin too often when in raw mode. ->read_page_raw()/->read_oob_raw() are written from scratch. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com>
* | mtd: nand: Arasan: Add subpage configuration supportMartin Lund2018-11-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for disabling subpage write support via CONFIG_SYS_NAND_NO_SUBPAGE_WRITE. Currently the Linux Arasan driver does not support subpage writes and in case of running UBI and accessing the same UBI volume from both U-Boot and Linux it is required to have the same subpage write configuration else the location of the UBI headers (EC + VID) will be misaligned (subpage vs page) and incompatible. Hence the need for disabling subpage write support in the U-Boot Arasan NAND driver. Signed-off-by: Martin Lund <malu@gomspace.com> Acked-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
* | sf: Add a method to obtain the block-protect settingSimon Glass2018-11-205-0/+42
|/ | | | | | | | | It is useful to obtain the block-protect setting of the SPI flash, so we know whether it is fully open or (perhaps partially) write-protected. Add a method for this. Update the sandbox driver to process this operation and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
* mtd: nand: lpc32xx slc: disable DMA support in SPL buildsVladimir Zapolskiy2018-11-161-46/+32
| | | | | | | | | | | | | | Testing and analysis shows that at the moment LPC32xx NAND SLC driver can not get PL080 DMA backbone support in SPL build, because SPL NAND loaders operate with subpage (ECC step to be precisely) reads, and this is not supported in the NAND SLC + DMA + hardware ECC calculation bundle. The change removes a cautious build time warning and explicitly disables DMA flavour of the driver for SPL builds, to reduce the amound of #ifdef sections the code blocks are minimally reorganized. Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
* mtd: nand: lpc32xx mlc: predefine number of NAND chips to supportVladimir Zapolskiy2018-11-161-0/+4
| | | | | | | | | | | Build option CONFIG_SYS_MAX_NAND_CHIPS is used by NXP LPC32xx NAND MLC driver only, as a preparation for potential removal or replacement of the option the change predefines CONFIG_SYS_MAX_NAND_CHIPS to 1, same value is used by the single user Work Microwave Work 92105 board, thus it will be safe now to remove the option as a board specific one. Signed-off-by: Vladimir Zapolskiy <vz@mleia.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
* mtd: Drop duplicate MTD_PARTITIONS Kconfig optionBoris Brezillon2018-11-131-6/+0
| | | | | | | | | | | | | | | | | | Commit 9c5b00973bce ("Convert CONFIG_MTD_PARTITIONS et al to Kconfig") introduced a publicly visible Kconfig entry for the CONFIG_MTD_PARTITIONS option, while the rework on MTD partitioning was in progress, and we somehow did not notice that the same Kconfig entry was added by commit 4048a5c519a8 ("mtd: declare MTD_PARTITIONS symbol in Kconfig"), but this time as an invisible entry (this can only be selected by other options). Keep the non-visible version of this symbol, since MTD_PARTITIONS is not something the user should be able to enable/disable directly. Fixes: 4048a5c519a8 ("mtd: declare MTD_PARTITIONS symbol in Kconfig") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
* mtd: Use default mtdparts/mtids when not defined in the environmentBoris Brezillon2018-11-131-2/+60
| | | | | | | | | | | | | | | | U-boot provides a mean to define default values for mtdids and mtdparts when they're not defined in the environment. Patch mtd_probe_devices() to use those default values when env_get("mtdparts") or env_get("mtdids") return NULL. This implementation is based on the logic found in cmd/mtdparts.c. Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Reported-by: Stefan Roese <sr@denx.de> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Stefan Roese <sr@denx.de> Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
* nand: atmel: Initialize pmecc smu with correct sizeBin Meng2018-10-221-1/+1
| | | | | | | | | | | | | | | | | | Currently in pmecc_get_sigma(), the code tries to clear the memory pointed by smu with wrong size 'sizeof(int16_t) * ARRAY_SIZE(smu)'. Since smu is actually a pointer, not an array, so ARRAY_SIZE(smu) does not generate correct size to be cleared. In fact, GCC 8.1.0 reports a warning against it: error: division 'sizeof (int16_t * {aka short int *}) / sizeof (int16_t {aka short int})' does not compute the number of array elements [-Werror=sizeof-pointer-div] Fix it by using the correct size. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
* Convert CONFIG_FLASH_CFI_DRIVER et al to KconfigAdam Ford2018-10-191-0/+38
| | | | | | | | | | | | | This converts the following to Kconfig: CONFIG_FLASH_CFI_DRIVER CONFIG_SYS_FLASH_USE_BUFFER_WRITE CONFIG_FLASH_CFI_MTD CONFIG_SYS_FLASH_PROTECTION CONFIG_SYS_FLASH_CFI Signed-off-by: Adam Ford <aford173@gmail.com> [trini: Re-migrate] Signed-off-by: Tom Rini <trini@konsulko.com>
* Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini2018-10-123-1/+11
|\
| * sf: Add MICRON manufacturer idAshish Kumar2018-10-122-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | NOR flash name MT35X_QLKA and MT25Q_** used on NXP board has manufacturer id as 0x2C, which are rather for newer flashes after the split of Micron from ST. So macro for this micron manufacturer id. Signed-off-by: Suresh Gupta <suresh.gupta@nxp.com> Signed-off-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com> Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com> [jagan: updated commit message] Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
| * mtd: uboot: Fix hanging during mtd list commandAdam Ford2018-10-101-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Some boards (like omap3_logic) hang when trying to access address 0. This happens when executing the new 'mtd list' command. This patch enhances the checks for conditions that would preclude mtd_probe_devices() from operating. Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Adam Ford <aford173@gmail.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
* | dm: spi: Add logging of some return valuesSimon Glass2018-10-093-8/+8
| | | | | | | | | | | | | | | | When SPI flash operations fail it is helpful to be able to see the error codes and where they are generated. Add logging to capture this information for read operations. Signed-off-by: Simon Glass <sjg@chromium.org>
* | sf: Avoid allocating memory on every read operationSimon Glass2018-10-091-7/+2
| | | | | | | | | | | | | | | | | | | | At present spi_flash_cmd_read_ops() allocates and frees a few bytes of memory every time it is called. It is faster to use the stack for this and this is now supported by the minimum GCC version required by U-Boot. Remove the allocation and use a variable-sized array instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: spi: Clean up detection of sandbox SPI emulatorSimon Glass2018-10-091-10/+8
| | | | | | | | | | | | | | | | Now that we don't have to deal with the command-line flag we can simplify the code for detecting the emulator. Remove the lookup based on the SPI specification, relying just on the device tree to locate the emulator. Signed-off-by: Simon Glass <sjg@chromium.org>
* | sandbox: spi: Add more loggingSimon Glass2018-10-091-25/+29
| | | | | | | | | | | | | | Add logging to aid debugging features in these drivers. Also drop some code in sandbox_spi_xfer() which is not used. Signed-off-by: Simon Glass <sjg@chromium.org>
* | sandbox: spi: Drop command-line SPI optionSimon Glass2018-10-091-113/+9
|/ | | | | | | | At present we support specifying SPI flash devices to use in the device tree and on the command line. Drop the second option, since it is a pain to support nicely with driver model, and unnecessary. Signed-off-by: Simon Glass <sjg@chromium.org>
* mtd: nand: spi: Add Gigadevice SPI NAND supportStefan Roese2018-10-043-1/+137
| | | | | | | | | | | | | This patch adds support for Gigadevices SPI NAND device to the new SPI NAND infrastructure in U-Boot. Currently only the 128MiB GD5F1GQ4UC device is supported. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Miquel Raynal <miquel.raynal@bootlin.com> Cc: Boris Brezillon <boris.brezillon@bootlin.com> Cc: Jagan Teki <jagan@openedev.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com>
* sf: Add XMC xm25qh64a and xm25qh128a entriesStefan Roese2018-10-042-0/+10
| | | | | | | | | | | This patch adds support for 2 new XMC (Wuhan Xinxin Semiconductor Manufacturing Corp) SPI NOR chips. This support can be enabled by selecting the SPI_FLASH_XMC Kconfig option. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
* cmd: mtd: add 'mtd' commandMiquel Raynal2018-10-022-2/+161
| | | | | | | | | | | | There should not be a 'nand' command, a 'sf' command and certainly not a new 'spi-nand' command. Write a 'mtd' command instead to manage all MTD devices/partitions at once. This should be the preferred way to access any MTD device. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: mtdpart: implement proper partition handlingMiquel Raynal2018-10-022-238/+177
| | | | | | | | | | | | | | | Instead of collecting partitions in a flat list, create a hierarchy within the mtd_info structure: use a partitions list to keep track of the partitions of an MTD device (which might be itself a partition of another MTD device), a pointer to the parent device (NULL when the MTD device is the root one, not a partition). By also saving directly in mtd_info the offset of the partition, we can get rid of the mtd_part structure. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: uboot: search for an equivalent MTD name with the mtdidsMiquel Raynal2018-10-021-1/+64
| | | | | | | | | | | | | | | Using an MTD device (resp. partition) name in mtdparts is simple and straightforward. However, for a long time already, another name was given in mtdparts to indicate a device (resp. partition) so the "mtdids" environment variable was created to do the match. Let's create a function that, from an MTD device (resp. partition) name, search for the equivalent name in the "mtdparts" environment variable thanks to the "mtdids" string. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: mtdpart: add a generic mtdparts-like parserMiquel Raynal2018-10-021-0/+210
| | | | | | | | | | | | | | | | | | | The current parser is very specific to U-Boot mtdparts implementation. It does not use MTD structures like mtd_info and mtd_partition. Copy and adapt the current parser in drivers/mtd/mtd-uclass.c (to not break the current use of mtdparts.c itself) and write some kind of a wrapper around the current implementation to allow other commands to benefit from this parsing in a user-friendly way. This new function will allocate an mtd_partition array for each successful call. This array must be freed after use by the caller. The given 'mtdparts' buffer pointer will be moved forward to the next MTD device (if any, it will point towards a '\0' character otherwise). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
* mtd: uclass: add probe functionMiquel Raynal2018-10-021-0/+16
| | | | | | | | | | The user might want to trigger the probe of any MTD device, export these functions so they can be called from a command source file. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jagan Teki <jagan@openedev.com> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>