summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/atmel_nand.c
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand: atmel: Fix pmecc ecc settingsSascha Hauer2020-11-101-42/+16
| | | | | | | | | | | pmecc has hardcoded steps of 1 and ecc size of the nand chips page size. This is wrong, the ECC engine does 512 or 1024 bytes per step. Adjust ecc size and step size accordingly. Also, fix ecc strength which was hardcoded to 1. With this the correct number of bitflips is reported, which should be the number of bitflips per ecc step, not the one for the whole page. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: atmel: drop dead codeSascha Hauer2020-11-101-22/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: atmel: Return number of bitflipsSascha Hauer2020-11-101-5/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Update to Linux-5.9Sascha Hauer2020-11-101-37/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates the barebox NAND layer and parts of the mtd layer to Linux-5.9. This patch is huge, but the barebox NAND layer is so far away from the Linux NAND layer that a step by step update would have taken ages. Unlike Linux barebox has functions to mark a block as good. This feature has been preserved. Also barebox used to make NAND write support optional, this feature is lost during the update for the sake of better compatibility to the Linux NAND layer. This patch has been tested: - GPMI aka nand_mxs on i.MX6 - nand_imx on i.MX25 - nand_omap_gpmc on AM335x - atmel_nand on Atmel sama5d3 - nand_denali on SoCFPGA Currently untested: - nand_orion - nand_mrvl_nfc - nand_s3c24xx The nand_denali driver is tested with the update of that driver to Linux-5.9 following in the next patch. I could only test the drivers with the NAND chips found on my boards, so there's still enough room for regressions, especially given that the NAND drivers themselves are mostly not updated. With the NAND layer being up-to-date with Linux it should hopefully be easy to update drivers to their Linux counterpart as well if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: move function hooks to struct nand_legacySascha Hauer2020-11-091-22/+22
| | | | | | | Linux had moved the traditional nand function hooks to an extra struct nand_legacy. Do the same in barebox for compatibility. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: rename class_dev to devSascha Hauer2020-11-091-1/+1
| | | | | | | | The mtds own device is named 'dev' in the Kernel whereas it's named 'class_dev' in barebox. Rename it to 'dev' for better compatilibility to the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Use classdev->parentSascha Hauer2020-11-091-1/+1
| | | | | | | | | | Instead of mtd->parent we can use mtd->classdev.parent which points to the same device. With this we can remove the 'parent' member of struct mtd_info. This member exists in the Linux kernel as well, but is of type struct mtd_info, so this is done as preparation to re-add mtd->parent with the same type as in Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Pass struct nand_chip aroundSascha Hauer2020-11-061-42/+32
| | | | | | | | | Traditionally Linux passed a struct mtd_info * around as context between the different functions. This has been changed to a struct nand_chip *. Do the same for barebox as well as another step towards updating the NAND layer to current Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Embed struct mtd_info into struct nand_chipSascha Hauer2019-08-261-5/+3
| | | | | | | | | Similar to what is done in the Kernel. In the Kernel we have a struct nand_device embedded into struct nand_chip and the nand_device has an mtd_info embedded into it. Until we have struct nand_device we embed mtd_info directly into the nand_chip. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Add and use static inline wrapper for getting nand_chip from mtdSascha Hauer2019-08-261-16/+16
| | | | | | | | | All drivers in tree use mtd->priv for the nand_chip. Add and use a static inline wrapper mtd_to_nand() which we already have in the kernel for getting the nand_chip from the mtd_info struct. Next step would be to embed a struct mtd_info into struct nand_chip. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: Add per board ECC setupLadislav Michl2018-12-141-0/+3
| | | | | Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: remove erroneous caseOleksij Rempel2018-11-211-1/+0
| | | | | | | | If mm would be 15, then we will corrupt the stack, since p[15]. And as input for this function, mm has only two variants 13 and 14. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: replace printk with dev_infoLadislav Michl2018-10-261-2/+2
| | | | | Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove checks for xzalloc() returning NULLUwe Kleine-König2017-09-261-2/+0
| | | | | | | xzalloc() either returns memory or panics, so checking for NULL is useless. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Fix return check of dev_request_mem_regionSascha Hauer2016-02-231-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region returns an ERR_PTR, fix places which check for a NULL pointer instead. This patch has been generated with this semantic patch, written by me and improved by Andrey Smirnov: // <smpl> @@ expression e; expression e1; @@ e = dev_request_mem_region(...); ... -if (!e) - return e1; +if (IS_ERR(e)) + return PTR_ERR(e); @ rule1 @ expression e; @@ e = dev_request_mem_region(...); @@ expression rule1.e; identifier ret, label; constant errno; @@ if (!e) { ... ( - ret = -errno; + ret = PTR_ERR(e); ... goto label; | - return -errno; + return PTR_ERR(e); ) } @depends on rule1@ expression rule1.e; @@ - if (e == NULL) + if (IS_ERR(e)) { ... } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
* Merge branch 'for-next/resource-err-ptr'Sascha Hauer2014-10-021-0/+3
|\
| * resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-0/+3
| | | | | | | | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nand: atmel: runtime to generate galois tableBo Shen2014-09-221-4/+117
|/ | | | | Signed-off-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: add support for device treeRaphaël Poggi2014-09-031-1/+110
| | | | | Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: retrieve ecc_mode from pdataRaphaël Poggi2014-09-021-1/+1
| | | | | | | | | By retrieving the ecc_mode from pdata we can use the same code for device tree and non device tree probing. Which was not possible before, because ecc_mode was arbitrarily set to NAND_ECC_SOFT. Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: add has_pmecc memberRaphaël Poggi2014-09-021-1/+1
| | | | | | | By adding this structure member, we can retrieve the pmecc config, through the device tree. Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: enable PMECC for 8k page nandRaphael Poggi2014-07-181-0/+1
| | | | | | | | Enable the PMECC to support 8k page. Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Acked-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: fix bit error correctionRaphael Poggi2014-07-181-1/+2
| | | | | | | | | | When pmecc uses a 1024 sector size to correct bit error, the gf dimension must be 14. So this commit chooses the right degree for different sector size (512 or 1024). Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: increase chip_delayRaphael Poggi2014-07-181-1/+1
| | | | | | | | Some nand like Micron MT29F32G08ABAAAWP need more than 20us. Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Acked-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: add SOFT_BCH supportRaphael Poggi2014-07-171-0/+5
| | | | | | | | To use soft ecc with nand with 8k page, we need the BCH support. This commit adds the possibilty for atmel_nand to enable SOFT_BCH. Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: atmel pmecc: disable subpage writesHerve Codina2014-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | I am using an sam5d35 and its pmecc nand ecc controller. In barebox, using similar atmel_nand.c the system crashes. The problem was a call to chip->ecc.hwctl from nand_write_subpage_hwecc (nand_base.c) when we write a sub page. chip->ecc.hwctl function is not set when we are using PMECC controller. As a workaround, i set NAND_NO_SUBPAGE_WRITE for PMECC controller in order to disable sub page access in nand_write_page. I think we can have the same problem in Linux. I do not performed subpage nand writes from Linux but i made the following patch according to my Barebox defect. Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* atmel_nand: check gpio validity before using itEric Bénard2013-12-121-2/+2
| | | | | | | | | | | else we get : "invalid GPIO -22" (as enable_pin is EINVAL) tested on SAMA5D35 Signed-off-by: Eric Bénard <eric@eukrea.com> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: update to v3.11-rc1Sascha Hauer2013-07-231-6/+9
| | | | | | | | | | | | | | | | | | This updates the NAND stuff to Linux-3.11-rc1. It is synchronized as best as we can get: - locks removed - The splitting in different files we had to better support different features has been dropped. Instead this is now done mostly with the use of __maybe_unused Some barebox adjustments are forward ported, like: - Allow partial page writes - Optionally allow to erase bad blocks - check for all_ff before writing a page Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: replace NAND_USE_FLASH_BBT with NAND_BBT_USE_FLASHSascha Hauer2013-03-041-1/+1
| | | | | | To sync with the kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: register nand flashes with nand specific functionSascha Hauer2013-03-041-1/+1
| | | | | | | This allows us to have some NAND specific stuff during registration, like for example adding NAND specific device parameters. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Use new device_platform_driver() macro for driversAlexander Shiyan2013-02-131-7/+1
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: request and configure pio via gpiolibJean-Christophe PLAGNIOL-VILLARD2013-01-021-2/+51
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* at91: use gpio_is_valid to check gpioJean-Christophe PLAGNIOL-VILLARD2012-12-221-2/+2
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "mtd: atmel_nand: optimize read/write buffer functions"Jean-Christophe PLAGNIOL-VILLARD2012-11-261-8/+25
| | | | | | | | | | | As in the kernel we revert as this was supposed to work but does not yet this may need more work on the smc to be able to use it So for now revert it This reverts commit 809f0f6327241504b5071622a8d573255f91a875. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: atmel add pmecc supportJean-Christophe PLAGNIOL-VILLARD2012-10-211-44/+738
| | | | | | | This patch is from linux 3.7-rc1 and adapt to Barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: add parent supportJean-Christophe PLAGNIOL-VILLARD2012-10-171-0/+1
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+1
| | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* atmel_nand: add on_flash_btt option to enable bbt optionJean-Christophe PLAGNIOL-VILLARD2012-04-021-0/+6
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* atmel_nand: disable hardware ecc if not enableJean-Christophe PLAGNIOL-VILLARD2012-01-171-2/+4
| | | | | | | allow to save 1360 bytes Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* atmel_nand: drop dead codeJean-Christophe PLAGNIOL-VILLARD2012-01-021-13/+0
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: atmel_nand: optimize read/write buffer functionsJean-Christophe PLAGNIOL-VILLARD2012-01-021-25/+8
| | | | | | | | | | | For PIO NAND access functions, we use the features of the SMC: - no need to take into account the NAND bus width: SMC will deal with this - use of an IO memcpy on the NAND chip-select space is able to generate proper SMC behavior. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/mtd: transfer NAND notions to MTD coreRobert Jarzmik2011-12-221-1/+1
| | | | | | | | | | | | | Change NAND_WRITE into MTD_WRITE. Change "page_shift" references in the core, which are purely NAND, into mtd->writesize which is MTD generic. Rename all "info" (struct mtd_info) into "mtd". Also provide a parameter to add_mtd_device() so that legacy nand devices still appear as nand<N>. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* introduce io.hSascha Hauer2011-09-221-1/+1
| | | | | | | To allow for some generic io accessors introduce io.h and use this instead of asm/io.h throughout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* at91: nand switch ecc base to resourceJean-Christophe PLAGNIOL-VILLARD2011-09-201-4/+4
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* atmel/drivers: switch to dev_request_mem_regionJean-Christophe PLAGNIOL-VILLARD2011-07-201-1/+1
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* atmel_nand: switch to "struct resource"Jean-Christophe PLAGNIOL-VILLARD2011-07-181-1/+1
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* atmel_nand: fix comment where this code is derived fromSascha Hauer2010-07-231-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move drivers/nand to drivers/mtd/nandSascha Hauer2010-07-051-0/+516
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>