summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand: stm32: fix wrong regmap_bulk_read() usageSascha Hauer10 days1-2/+2
| | | | | | | | | | Compilation of the STM32 NAND driver fails with: error: call to '__regmap_bulk_api_changed' declared with attribute error: Last argument is now number of registers, not bytes. Fix it and include <linux/regmap.h instead Do exactly this to make the driver compile again Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: don't try to detect UBI in too small flash partitionsAhmad Fatoum2024-03-041-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | The detect callback will try to detect an UBI volume inside a partition. This can misbehave for partitions without UBI: - For partitions smaller than 512 bytes, detect fails with -EINVAL, because it wasn't possible to read as much - For partitions smaller than 64 PEBs, detect will erroneously do 64 lookups and attempt reading beyond the partition - For partition bigger than 64 PEBs, but without UBI, detect will read 512 bytes off each PEB without ever finding the UBI. Fix this by not attempting to read more PEBs than they are and ensure that there at least 5 PEBs, because anything lower wouldn't account for UBI overhead[1]. [1]: http://www.linux-mtd.infradead.org/doc/ubi.html#L_overhead Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240229162322.1480141-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: fix format specifier in debug messageAhmad Fatoum2024-02-011-2/+2
| | | | | | | | | | | | | The type size_t is to be printed with the %zu modifier as it's not necessarily typedef'ed as unsigned long, even if for barebox purposes, the sizeof(size_t) is always equal to sizeof(ulong). Building the dw-ospi-nor driver for 32-bit warns about this, so fix that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240131230347.1747216-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: denali: Make partition binding configurableSascha Hauer2024-01-191-11/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The binding for the denali NAND driver changed over time. Originally the partitions were placed directly under the controller node. Nowadays there is an additional chip node between the controller node and the partitions. So what originally was: nand: nand@ff900000 { compatible = "altr,socfpga-denali-nand"; partitions { ... }; }; has now become: nand: nand@ff900000 { compatible = "altr,socfpga-denali-nand"; nand@0 { partitions { ... }; }; }; The new binding has been introduced with Linux-5.2 and after a grace period it has been made mandatory in Linux-5.5. We want however to be able to start old Kernels supporting only the old binding as well, so make the binding we fix up the kernel device tree with configurable. This introduces the globalvar nandx.denali_partition_binding with three different settings: chip: Fixup the Kernel device tree according to the new binding. This is the default controller: Fixup the Kernel device tree according to the old binding auto: When the Kernel device tree has a "nand@0" node then use the new binding, otherwise use the old binding. The previous (only) implemented default before this patch was "auto". This deliberately is changed with this patch as Kernels older than Linux-5.2 are quite old already and likely contains the least surprises for the user. Link: https://lore.barebox.org/20240110131557.1289602-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add support for Winbond w25q256jwmMarco Felsch2024-01-021-0/+2
| | | | | | | | | Add entry for Winbond w25q256jwm. Flags are aligned with the Linux spi-nor/winbond driver. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20240102091837.250238-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: add support for Winbond w25q512nwqSascha Hauer2023-11-211-0/+1
| | | | | | | Add entry for the Winbond w25q512nwq. Link: https://lore.barebox.org/20231110130259.2228089-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/regmap'Sascha Hauer2023-10-271-1/+1
|\
| * treewide: switch regmap.h include to linux/regmap.hAhmad Fatoum2023-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that there are no longer any users of regmap.h in headers, let's switch all users in the source files to linux/regmap.h. That way, the only users of regmap.h whether directly or indirectly will be out-of-tree code, which will fail with an error if they are dependent on the old semantics of regmap_bulk_read and regmap_bulk_write. After a transitory period, we can then drop regmap.h. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2023-10-271-2/+2
|\ \
| * | mtd: initialize partitions_entrySascha Hauer2023-10-121-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | &mtd->partitions_entry is added to the parents partition list only when DEVFS_PARTITION_FIXED is not set, but later this check is not done when removing it from the list again. This results in NULL pointer derefs when a mtd partition is added with DEVFS_PARTITION_FIXED set and removed later. Do a INIT_LIST_HEAD() on &mtd->partitions_entry so we can safely call list_del() on it later without additional checks. This means we can remove the existing check as well. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / Revert "mtd: nand: drop DT support in legacy driver"Ahmad Fatoum2023-10-042-3/+109
|/ | | | | | | | | | | | | DT support was removed with the rationale that all DT-enabled platforms are supported by the new driver ported from Linux. The new driver however refuses to work the AT91SAM9263. Until that's figured it, restore DT support in the legacy driver. This reverts commit 1fd8336bb0fe46856d2881121dd61bf560910448. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230926183835.2617909-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Add driver for NAND controller on STM32MP SoCsAlexander Shiyan2023-09-043-0/+1367
| | | | | | | | | This adds support for NAND controller on STM32MP SoCs. The original source is taken from linux-6.4. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20230830104747.43193-2-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: Add Synopsys DesignWare Octal SPI driverJules Maselbas2023-08-143-0/+936
| | | | Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
* mtd: spi-nor: move SPI_NOR_MAX_ADDR_WIDTH define to spi-nor.hJules Maselbas2023-08-141-1/+0
| | | | | | | Move the SPI_NOR_MAX_ADDR_WIDTH define into spi-nor.h to be used by drivers. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
* mtd: spi-nor: enable quad-write for is25lp01gJules Maselbas2023-08-141-1/+1
| | | | Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
* mtd: spi-nor: enable {dual,quad}-read and quad-write for w25q256Clement Leger2023-08-141-1/+2
| | | | | | | The w25q256 flash supports these modes. Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
* mtd: spi-nor: Add SPI_NOR_QUAD_WRITE hwcapJules Maselbas2023-08-141-0/+8
| | | | Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-032-6/+4
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* gpio: have gpiod_ functions return and accept pointersAhmad Fatoum2023-06-232-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | The gpiod_ (GPIO descriptor) API used with Linux differs from barebox' normal GPIO API: - gpiod handles are opaque pointers and not an integer, which users have an expectation of stability for - gpiod API uses logic levels by default with separate raw API for physical level instead of physical level by default and separate API taking active level into account. The barebox gpiod_ API mimics the latter point, but still uses integers requiring ugly and arguably error prone conversions when porting kernel code. Let's improve upon that by just encoding the integer into a pointer variable for API compatibility. Later commits will switch barebox GPIO support to use actual GPIO descriptors without consulting the numeric indices, but we do this temporary switch here, so we can split up provider and consumer changes. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230622072329.1339317-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc-fixes-sandbox'Sascha Hauer2023-06-221-5/+3
|\
| * mtd: spi-nor: cadence: fix typesAhmad Fatoum2023-06-131-5/+3
| | | | | | | | | | | | | | | | | | | | | | The JH7100 for which we have basic support has 64-bit CPUs and a cadence quad SPI controller. Building the driver for that CPU would result in a couple of warning due to casting 64-bit pointers to 32-bit integers. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612130239.1087599-16-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2023-06-221-0/+1
|\ \ | |/ |/|
| * mtd: nand: omap: Depend on BUS_OMAP_GPMCYegor Yefremov2023-06-121-0/+1
| | | | | | | | | | | | | | | | NAND OMAP driver requires GPMC bus driver. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Link: https://lore.barebox.org/20230612082109.3300950-1-yegorslists@googlemail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-1313-0/+13
|/ | | | | | | | | | | | | | | | Syncing device trees with Linux upstream can lead to breakage, when the device trees are switched to newer bindings, which are not yet supported in barebox. To make it easier to spot such issues, we want to start applying some heuristics to flag possibly problematic DT changes. One step towards being able to do that is to know what nodes barebox actually consumes. Most of the nodes have a compatible entry, which is matched by an array of of_device_id, so let's have MODULE_DEVICE_TABLE point at it for future extraction. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125908.1087340-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-05-242-2/+2
|\
| * treewide: drop trailing spaceAhmad Fatoum2023-05-022-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by manual inspection of the output of: rg '\s+$' | rg -v dts/ Patch can be verified by observing that no diff results from: git show --ignore-space-at-eol Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230424121805.150434-4-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: platform: remap memory when encountering virtual-reg propertyAhmad Fatoum2023-05-231-1/+4
|/ | | | | | | | | | | | | | | | | | | | | Quoting the Device Tree specification v0.4-rc1[1]: The virtual-reg property specifies an effective address that maps to the first physical address specified in the reg property of the device node. This property enables boot programs to provide client programs with virtual- to-physical mappings that have been set up. The only upstream use of this device tree property are some PowerPC device trees that use it to find the virtual address of the early UART. Let's start handling this property in barebox as well by remapping the device to start at virtual-reg. [1]: https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.4-rc1 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230522052835.1039143-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx-image'Sascha Hauer2023-04-193-18/+2
|\
| * spi: remove flash_platform_data supportMarco Felsch2023-03-173-18/+2
| | | | | | | | | | | | | | | | | | Drop the non-dt platform data since the last user was removed by commit 1266831db8 ("ARM: OMAP: PCM051: Remove spi platform data"). Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230228-v2023-02-0-topic-flexspi-v2-1-3d33126d2434@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: atmel: legacy: remove superfluous codeWolfram Sang2023-03-221-9/+0
| | | | | | | | | | | | | | | | | | | | | | 54bccadddd always populates 'ecc_mode' but forgot to remove the code which overwrote the previously hardcoded 'NAND_ECC_SOFT' when needed. This is obsolete now. Fixes: 54bccadddd ("mtd: atmel_nand: retrieve ecc_mode from pdata") Signed-off-by: Wolfram Sang <wsa@kernel.org> Link: https://lore.barebox.org/20230319154909.24047-4-wsa@kernel.org Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: atmel: legacy: use proper ecc_shiftWolfram Sang2023-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The logic of the ternary operator is broken because '1 << x' is always true even if 'x' is 0. Convert the logic to really use either the pdata value or a sane default. Fixes "WARNING: Total number of ECC bytes exceeded oobsize" on my USB-A9G20. Fixes: babffbb193 ("mtd: atmel_nand: Add per board ECC setup") Signed-off-by: Wolfram Sang <wsa@kernel.org> Link: https://lore.barebox.org/20230319154909.24047-3-wsa@kernel.org Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: atmel: legacy: add 'algo' to useWolfram Sang2023-03-221-0/+4
|/ | | | | | | | | Fixes "WARNING: Unsupported ECC algorithm!" on my USB-A9G20. Fixes: b6bcd96de5 ("mtd: nand: Update to Linux-5.9") Signed-off-by: Wolfram Sang <wsa@kernel.org> Link: https://lore.barebox.org/20230319154909.24047-2-wsa@kernel.org Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: at91: Move mach header files to include/mach/at91Sascha Hauer2023-03-061-1/+1
| | | | | | | | | | Currently arch specific headers can be included with longer possible as there won't be a single mach anymore. Move all at91 specific header files to include/mach/at91/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: nomadik: Move mach header files to include/mach/nomadikSascha Hauer2023-03-061-2/+2
| | | | | | | | | | Currently arch specific headers can be included with longer possible as there won't be a single mach anymore. Move all nomadik specific header files to include/mach/nomadik/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: omap: Move mach header files to include/mach/omapSascha Hauer2023-03-061-2/+2
| | | | | | | | | | Currently arch specific headers can be included with longer possible as there won't be a single mach anymore. Move all omap specific header files to include/mach/omap/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: Move mach header files to include/mach/imxSascha Hauer2023-03-062-3/+3
| | | | | | | | | | | Currently arch specific headers can be included with #include <mach/xxx.h>. With upcoming multi-arch support this is no longer possible as there won't be a single mach anymore. Move all i.MX specific header files to include/mach/imx/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: remove s3c driverSascha Hauer2023-03-013-658/+0
| | | | | | | | | The Samsung architecture has been removed, remove the NAND driver only used on this architecture as well. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230228135727.1602351-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: rename leftover device_dAhmad Fatoum2023-02-211-1/+1
| | | | | | | | | We have some instances of device_d and driver_d still lingering in documentation and commented out code. Let's drop these as well. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230221070758.1130869-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: drop DT support in legacy driverAhmad Fatoum2023-01-182-106/+3
| | | | | | | | | | | | | | With the legacy binding removed from the barebox sama5d3_xplained DT, the only remaining user of "atmel,at91rm9200-nand" is dts/src/arm/at91rm9200.dtsi, which we don't use. Should DT support ever be added to that platform, we should invest the time to update the kernel DT to use the new EBI binding. Thus drop the now unused DT support in the legacy driver, so only the new EBI binding is supported with the new driver. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-15-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: atmel: import Linux NAND controller driverAhmad Fatoum2023-01-188-3/+3125
| | | | | | | | | | | | | For a few years, Linux has been using the new EBI bindings for NAND controllers on all AT91 SoCs newer than the AT91RM2000. We have so far only supported the old bindings by hacking the DT, but this doesn't suffice for the SAMA5D4. Therefore import a new state of the Linux NAND controller driver. We still keep around the old barebox driver to support the non-DT enabled AT91 platforms. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: define nand_get_(small|large)_page_ooblayoutAhmad Fatoum2023-01-163-6/+16
| | | | | | | | | Adopt the Linux nomenclature to make future ports easier. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: rename nand_device::eccreq to Linux' ecc.requirementsAhmad Fatoum2023-01-168-61/+63
| | | | | | | | | Adopt the Linux nomenclature to make future ports easier. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: prefix enum nand_ecc_algo constants with NAND_ECC_ALGO_Ahmad Fatoum2023-01-163-15/+15
| | | | | | | | | This aligns us with how Linux now names these constants. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: base: implement nand_gpio_waitrdyAhmad Fatoum2023-01-161-0/+22
| | | | | | | | | | To simplify porting kernel NAND drivers a tiny bit, provide the Linux nand_gpio_waitrdy. This is readily implementable with barebox' own gpio_poll_timeout_us. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111174023.1719129-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-1017-17/+17
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-1023-43/+44
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-1012-21/+21
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx7-nand-xload'Sascha Hauer2022-12-121-301/+111
|\
| * ARM: i.MX: xload nand: Move mxs_nand_mode_fcb_62bit() to header fileSascha Hauer2022-11-021-32/+2
| | | | | | | | | | | | | | mxs_nand_mode_fcb_62bit() can be shared between the regular MTD NAND driver and the upcoming i.MX7 xload driver. Move to header file. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * dma: apbh-dma: unify register definesSascha Hauer2022-11-021-12/+12
| | | | | | | | | | | | | | | | We have different register defines for the apbh-dma controller. One set is used in the regular driver, the other one in the xload code. Move the register defines to a common place and unify their names. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>