2016-04-01 12:54:50

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 00/12] mtd: get rid of of_mtd.{c,h} and of_get_nand_xx()

Hello,

of_mtd.{h,c} are providing the of_get_nand_xxx() helpers to help NAND
controller drivers parse some generic NAND DT properties.
An infrastructure has recently been added to NAND core to automatically
parse those properties when nand_scan_ident() is called, thus removing
the need for NAND controller drivers to manually parse them.

This series modifies drivers still making use of those helpers to rely
on NAND core initialization, and get rid of the of_mtd.{c,h} files by
moving the of_get_nand_xx() helpers into nand_base.c.

Best Regards,

Boris

Boris Brezillon (12):
mtd: nand: remove unneeded of_mtd.h inclusions
mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()
mtd: nand: omap2: rely on generic DT parsing done in nand_scan_ident()
mtd: nand: brcm: rely on generic DT parsing done in nand_scan_ident()
mtd: nand: davinci: rely on generic DT parsing done in
nand_scan_ident()
mtd: nand: gpmi: rely on generic DT parsing done in nand_scan_ident()
mtd: nand: hisi504: rely on generic DT parsing done in
nand_scan_ident()
mtd: nand: lpc32xx: rely on generic DT parsing done in
nand_scan_ident()
mtd: nand: mxc: rely on generic DT parsing done in nand_scan_ident()
mtd: nand: pxa3xx: rely on generic DT parsing done in
nand_scan_ident()
mtd: nand: sh_flctl: rely on generic DT parsing done in
nand_scan_ident()
mtd: nand: move of_get_nand_xxx() helpers into nand_base.c

drivers/memory/omap-gpmc.c | 7 --
drivers/mtd/nand/atmel_nand.c | 133 +++++++++++++++-------------
drivers/mtd/nand/brcmnand/brcmnand.c | 5 +-
drivers/mtd/nand/davinci_nand.c | 85 +++++++++---------
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 +++--
drivers/mtd/nand/hisi504_nand.c | 14 +--
drivers/mtd/nand/jz4780_nand.c | 1 -
drivers/mtd/nand/lpc32xx_mlc.c | 1 -
drivers/mtd/nand/lpc32xx_slc.c | 24 ++---
drivers/mtd/nand/mxc_nand.c | 50 +++++------
drivers/mtd/nand/nand_base.c | 99 ++++++++++++++++++++-
drivers/mtd/nand/omap2.c | 9 +-
drivers/mtd/nand/pxa3xx_nand.c | 28 +++---
drivers/mtd/nand/qcom_nandc.c | 1 -
drivers/mtd/nand/sh_flctl.c | 31 +++----
drivers/mtd/nand/sunxi_nand.c | 1 -
drivers/mtd/nand/vf610_nfc.c | 1 -
drivers/of/Makefile | 1 -
drivers/of/of_mtd.c | 155 ---------------------------------
include/linux/of_mtd.h | 56 ------------
20 files changed, 291 insertions(+), 432 deletions(-)
delete mode 100644 drivers/of/of_mtd.c
delete mode 100644 include/linux/of_mtd.h

--
2.5.0


2016-04-01 12:54:59

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 11/12] mtd: nand: sh_flctl: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/sh_flctl.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 4814402..8d4e97c 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -31,7 +31,6 @@
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_mtd.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/sh_dma.h>
@@ -1044,8 +1043,6 @@ static struct sh_flctl_platform_data *flctl_parse_dt(struct device *dev)
const struct of_device_id *match;
struct flctl_soc_config *config;
struct sh_flctl_platform_data *pdata;
- struct device_node *dn = dev->of_node;
- int ret;

match = of_match_device(of_flctl_match, dev);
if (match)
@@ -1065,15 +1062,6 @@ static struct sh_flctl_platform_data *flctl_parse_dt(struct device *dev)
pdata->has_hwecc = config->has_hwecc;
pdata->use_holden = config->use_holden;

- /* parse user defined options */
- ret = of_get_nand_bus_width(dn);
- if (ret == 16)
- pdata->flcmncr_val |= SEL_16BIT;
- else if (ret != 8) {
- dev_err(dev, "%s: invalid bus width\n", __func__);
- return NULL;
- }
-
return pdata;
}

@@ -1141,20 +1129,29 @@ static int flctl_probe(struct platform_device *pdev)
nand->select_chip = flctl_select_chip;
nand->cmdfunc = flctl_cmdfunc;

- if (pdata->flcmncr_val & SEL_16BIT) {
- nand->options |= NAND_BUSWIDTH_16;
- nand->read_word = flctl_read_word;
- }
-
pm_runtime_enable(&pdev->dev);
pm_runtime_resume(&pdev->dev);

flctl_setup_dma(flctl);

+ if (pdata->flcmncr_val & SEL_16BIT)
+ nand->options |= NAND_BUSWIDTH_16;
+
ret = nand_scan_ident(flctl_mtd, 1, NULL);
if (ret)
goto err_chip;

+ if (nand->options & NAND_BUSWIDTH_16) {
+ /*
+ * NAND_BUSWIDTH_16 may have been set by nand_scan_ident().
+ * Add the SEL_16BIT flag in pdata->flcmncr_val and re-assign
+ * flctl->flcmncr_base to pdata->flcmncr_val.
+ */
+ pdata->flcmncr_val |= SEL_16BIT;
+ flctl->flcmncr_base = pdata->flcmncr_val;
+ nand->read_word = flctl_read_word;
+ }
+
ret = flctl_chip_init_tail(flctl_mtd);
if (ret)
goto err_chip;
--
2.5.0

2016-04-01 12:54:58

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 10/12] mtd: nand: pxa3xx: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/pxa3xx_nand.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index d650885..38d26ab 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -29,7 +29,6 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_mtd.h>
#include <linux/platform_data/mtd-nand-pxa3xx.h>

#define CHIP_DELAY_TIMEOUT msecs_to_jiffies(200)
@@ -1651,6 +1650,12 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370)
nand_writel(info, NDECCCTRL, 0x0);

+ if (pdata->flash_bbt)
+ chip->bbt_options |= NAND_BBT_USE_FLASH;
+
+ chip->ecc.strength = pdata->ecc_strength;
+ chip->ecc.size = pdata->ecc_step_size;
+
if (nand_scan_ident(mtd, 1, NULL))
return -ENODEV;

@@ -1663,13 +1668,12 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
}
}

- if (pdata->flash_bbt) {
+ if (chip->bbt_options & NAND_BBT_USE_FLASH) {
/*
* We'll use a bad block table stored in-flash and don't
* allow writing the bad block marker to the flash.
*/
- chip->bbt_options |= NAND_BBT_USE_FLASH |
- NAND_BBT_NO_OOB_BBM;
+ chip->bbt_options |= NAND_BBT_NO_OOB_BBM;
chip->bbt_td = &bbt_main_descr;
chip->bbt_md = &bbt_mirror_descr;
}
@@ -1689,10 +1693,9 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
}
}

- if (pdata->ecc_strength && pdata->ecc_step_size) {
- ecc_strength = pdata->ecc_strength;
- ecc_step = pdata->ecc_step_size;
- } else {
+ ecc_strength = chip->ecc.strength;
+ ecc_step = chip->ecc.size;
+ if (!ecc_strength || !ecc_step) {
ecc_strength = chip->ecc_strength_ds;
ecc_step = chip->ecc_step_ds;
}
@@ -1903,15 +1906,6 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
if (of_get_property(np, "marvell,nand-keep-config", NULL))
pdata->keep_config = 1;
of_property_read_u32(np, "num-cs", &pdata->num_cs);
- pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
-
- pdata->ecc_strength = of_get_nand_ecc_strength(np);
- if (pdata->ecc_strength < 0)
- pdata->ecc_strength = 0;
-
- pdata->ecc_step_size = of_get_nand_ecc_step_size(np);
- if (pdata->ecc_step_size < 0)
- pdata->ecc_step_size = 0;

pdev->dev.platform_data = pdata;

--
2.5.0

2016-04-01 12:55:41

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 12/12] mtd: nand: move of_get_nand_xxx() helpers into nand_base.c

Now that all drivers go through nand_set_flash_node() to parse the generic
NAND properties, we can move all of_get_nand_xxx() helpers in to
nand_base.c, make them static and remove of_mtd.c and of_mtd.h.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/nand_base.c | 99 ++++++++++++++++++++++++++-
drivers/of/Makefile | 1 -
drivers/of/of_mtd.c | 155 -------------------------------------------
include/linux/of_mtd.h | 56 ----------------
4 files changed, 98 insertions(+), 213 deletions(-)
delete mode 100644 drivers/of/of_mtd.c
delete mode 100644 include/linux/of_mtd.h

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index c3733a1..21f43e3 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -46,7 +46,7 @@
#include <linux/leds.h>
#include <linux/io.h>
#include <linux/mtd/partitions.h>
-#include <linux/of_mtd.h>
+#include <linux/of.h>

/* Define default oob placement schemes for large and small page devices */
static struct nand_ecclayout nand_oob_8 = {
@@ -3964,6 +3964,103 @@ ident_done:
return type;
}

+/**
+ * It maps 'enum nand_ecc_modes_t' found in include/linux/mtd/nand.h
+ * into the device tree binding of 'nand-ecc', so that MTD
+ * device driver can get nand ecc from device tree.
+ */
+static const char * const nand_ecc_modes[] = {
+ [NAND_ECC_NONE] = "none",
+ [NAND_ECC_SOFT] = "soft",
+ [NAND_ECC_HW] = "hw",
+ [NAND_ECC_HW_SYNDROME] = "hw_syndrome",
+ [NAND_ECC_HW_OOB_FIRST] = "hw_oob_first",
+ [NAND_ECC_SOFT_BCH] = "soft_bch",
+};
+
+static int of_get_nand_ecc_mode(struct device_node *np)
+{
+ const char *pm;
+ int err, i;
+
+ err = of_property_read_string(np, "nand-ecc-mode", &pm);
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < ARRAY_SIZE(nand_ecc_modes); i++)
+ if (!strcasecmp(pm, nand_ecc_modes[i]))
+ return i;
+
+ return -ENODEV;
+}
+
+static int of_get_nand_ecc_algo(struct device_node *np)
+{
+ const char *pm;
+ int err;
+
+ /*
+ * TODO: Read ECC algo OF property and map it to enum nand_ecc_algo.
+ * It's not implemented yet as currently NAND subsystem ignores
+ * algorithm explicitly set this way. Once it's handled we should
+ * document & support new property.
+ */
+
+ /*
+ * For backward compatibility we also read "nand-ecc-mode" checking
+ * for some obsoleted values that were specifying ECC algorithm.
+ */
+ err = of_property_read_string(np, "nand-ecc-mode", &pm);
+ if (err < 0)
+ return err;
+
+ if (!strcasecmp(pm, "soft"))
+ return NAND_ECC_HAMMING;
+ else if (!strcasecmp(pm, "soft_bch"))
+ return NAND_ECC_BCH;
+
+ return -ENODEV;
+}
+
+static int of_get_nand_ecc_step_size(struct device_node *np)
+{
+ int ret;
+ u32 val;
+
+ ret = of_property_read_u32(np, "nand-ecc-step-size", &val);
+ return ret ? ret : val;
+}
+
+static int of_get_nand_ecc_strength(struct device_node *np)
+{
+ int ret;
+ u32 val;
+
+ ret = of_property_read_u32(np, "nand-ecc-strength", &val);
+ return ret ? ret : val;
+}
+
+static int of_get_nand_bus_width(struct device_node *np)
+{
+ u32 val;
+
+ if (of_property_read_u32(np, "nand-bus-width", &val))
+ return 8;
+
+ switch (val) {
+ case 8:
+ case 16:
+ return val;
+ default:
+ return -EIO;
+ }
+}
+
+static bool of_get_nand_on_flash_bbt(struct device_node *np)
+{
+ return of_property_read_bool(np, "nand-on-flash-bbt");
+}
+
static int nand_dt_init(struct nand_chip *chip)
{
struct device_node *dn = nand_get_flash_node(chip);
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index 156c072..e31bdc1 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -10,7 +10,6 @@ obj-$(CONFIG_OF_UNITTEST) += unittest.o
obj-$(CONFIG_OF_MDIO) += of_mdio.o
obj-$(CONFIG_OF_PCI) += of_pci.o
obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o
-obj-$(CONFIG_OF_MTD) += of_mtd.o
obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
obj-$(CONFIG_OF_RESOLVE) += resolver.o
obj-$(CONFIG_OF_OVERLAY) += overlay.o
diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c
deleted file mode 100644
index 15d056e..0000000
--- a/drivers/of/of_mtd.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
- *
- * OF helpers for mtd.
- *
- * This file is released under the GPLv2
- *
- */
-#include <linux/kernel.h>
-#include <linux/of_mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/export.h>
-
-/**
- * It maps 'enum nand_ecc_modes_t' found in include/linux/mtd/nand.h
- * into the device tree binding of 'nand-ecc', so that MTD
- * device driver can get nand ecc from device tree.
- */
-static const char *nand_ecc_modes[] = {
- [NAND_ECC_NONE] = "none",
- [NAND_ECC_SOFT] = "soft",
- [NAND_ECC_HW] = "hw",
- [NAND_ECC_HW_SYNDROME] = "hw_syndrome",
- [NAND_ECC_HW_OOB_FIRST] = "hw_oob_first",
- [NAND_ECC_SOFT_BCH] = "soft_bch",
-};
-
-/**
- * of_get_nand_ecc_mode - Get nand ecc mode for given device_node
- * @np: Pointer to the given device_node
- *
- * The function gets ecc mode string from property 'nand-ecc-mode',
- * and return its index in nand_ecc_modes table, or errno in error case.
- */
-int of_get_nand_ecc_mode(struct device_node *np)
-{
- const char *pm;
- int err, i;
-
- err = of_property_read_string(np, "nand-ecc-mode", &pm);
- if (err < 0)
- return err;
-
- for (i = 0; i < ARRAY_SIZE(nand_ecc_modes); i++)
- if (!strcasecmp(pm, nand_ecc_modes[i]))
- return i;
-
- return -ENODEV;
-}
-EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
-
-/**
- * of_get_nand_ecc_algo - Get nand ecc algorithm for given device_node
- * @np: Pointer to the given device_node
- *
- * The function gets ecc algorithm and returns its enum value, or errno in error
- * case.
- */
-int of_get_nand_ecc_algo(struct device_node *np)
-{
- const char *pm;
- int err;
-
- /*
- * TODO: Read ECC algo OF property and map it to enum nand_ecc_algo.
- * It's not implemented yet as currently NAND subsystem ignores
- * algorithm explicitly set this way. Once it's handled we should
- * document & support new property.
- */
-
- /*
- * For backward compatibility we also read "nand-ecc-mode" checking
- * for some obsoleted values that were specifying ECC algorithm.
- */
- err = of_property_read_string(np, "nand-ecc-mode", &pm);
- if (err < 0)
- return err;
-
- if (!strcasecmp(pm, "soft"))
- return NAND_ECC_HAMMING;
- else if (!strcasecmp(pm, "soft_bch"))
- return NAND_ECC_BCH;
-
- return -ENODEV;
-}
-EXPORT_SYMBOL_GPL(of_get_nand_ecc_algo);
-
-/**
- * of_get_nand_ecc_step_size - Get ECC step size associated to
- * the required ECC strength (see below).
- * @np: Pointer to the given device_node
- *
- * return the ECC step size, or errno in error case.
- */
-int of_get_nand_ecc_step_size(struct device_node *np)
-{
- int ret;
- u32 val;
-
- ret = of_property_read_u32(np, "nand-ecc-step-size", &val);
- return ret ? ret : val;
-}
-EXPORT_SYMBOL_GPL(of_get_nand_ecc_step_size);
-
-/**
- * of_get_nand_ecc_strength - Get required ECC strength over the
- * correspnding step size as defined by 'nand-ecc-size'
- * @np: Pointer to the given device_node
- *
- * return the ECC strength, or errno in error case.
- */
-int of_get_nand_ecc_strength(struct device_node *np)
-{
- int ret;
- u32 val;
-
- ret = of_property_read_u32(np, "nand-ecc-strength", &val);
- return ret ? ret : val;
-}
-EXPORT_SYMBOL_GPL(of_get_nand_ecc_strength);
-
-/**
- * of_get_nand_bus_width - Get nand bus witdh for given device_node
- * @np: Pointer to the given device_node
- *
- * return bus width option, or errno in error case.
- */
-int of_get_nand_bus_width(struct device_node *np)
-{
- u32 val;
-
- if (of_property_read_u32(np, "nand-bus-width", &val))
- return 8;
-
- switch(val) {
- case 8:
- case 16:
- return val;
- default:
- return -EIO;
- }
-}
-EXPORT_SYMBOL_GPL(of_get_nand_bus_width);
-
-/**
- * of_get_nand_on_flash_bbt - Get nand on flash bbt for given device_node
- * @np: Pointer to the given device_node
- *
- * return true if present false other wise
- */
-bool of_get_nand_on_flash_bbt(struct device_node *np)
-{
- return of_property_read_bool(np, "nand-on-flash-bbt");
-}
-EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt);
diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
deleted file mode 100644
index 0f6aca5..0000000
--- a/include/linux/of_mtd.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
- *
- * OF helpers for mtd.
- *
- * This file is released under the GPLv2
- */
-
-#ifndef __LINUX_OF_MTD_H
-#define __LINUX_OF_MTD_H
-
-#ifdef CONFIG_OF_MTD
-
-#include <linux/of.h>
-int of_get_nand_ecc_mode(struct device_node *np);
-int of_get_nand_ecc_algo(struct device_node *np);
-int of_get_nand_ecc_step_size(struct device_node *np);
-int of_get_nand_ecc_strength(struct device_node *np);
-int of_get_nand_bus_width(struct device_node *np);
-bool of_get_nand_on_flash_bbt(struct device_node *np);
-
-#else /* CONFIG_OF_MTD */
-
-static inline int of_get_nand_ecc_mode(struct device_node *np)
-{
- return -ENOSYS;
-}
-
-static inline int of_get_nand_ecc_algo(struct device_node *np)
-{
- return -ENOSYS;
-}
-
-static inline int of_get_nand_ecc_step_size(struct device_node *np)
-{
- return -ENOSYS;
-}
-
-static inline int of_get_nand_ecc_strength(struct device_node *np)
-{
- return -ENOSYS;
-}
-
-static inline int of_get_nand_bus_width(struct device_node *np)
-{
- return -ENOSYS;
-}
-
-static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
-{
- return false;
-}
-
-#endif /* CONFIG_OF_MTD */
-
-#endif /* __LINUX_OF_MTD_H */
--
2.5.0

2016-04-01 12:54:56

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 09/12] mtd: nand: mxc: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/mxc_nand.c | 50 ++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 854c832..f25913b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -34,7 +34,6 @@
#include <linux/completion.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_mtd.h>

#include <asm/mach/flash.h>
#include <linux/platform_data/mtd-mxc_nand.h>
@@ -1461,25 +1460,12 @@ MODULE_DEVICE_TABLE(of, mxcnd_dt_ids);
static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
{
struct device_node *np = host->dev->of_node;
- struct mxc_nand_platform_data *pdata = &host->pdata;
const struct of_device_id *of_id =
of_match_device(mxcnd_dt_ids, host->dev);
- int buswidth;

if (!np)
return 1;

- if (of_get_nand_ecc_mode(np) >= 0)
- pdata->hw_ecc = 1;
-
- pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
-
- buswidth = of_get_nand_bus_width(np);
- if (buswidth < 0)
- return buswidth;
-
- pdata->width = buswidth / 8;
-
host->devtype_data = of_id->data;

return 0;
@@ -1578,25 +1564,18 @@ static int mxcnd_probe(struct platform_device *pdev)
this->ecc.size = 512;
this->ecc.layout = host->devtype_data->ecclayout_512;

- if (host->pdata.hw_ecc) {
- this->ecc.calculate = mxc_nand_calculate_ecc;
- this->ecc.hwctl = mxc_nand_enable_hwecc;
- this->ecc.correct = host->devtype_data->correct_data;
+ if (host->pdata.hw_ecc)
this->ecc.mode = NAND_ECC_HW;
- } else {
+ else
this->ecc.mode = NAND_ECC_SOFT;
- }

/* NAND bus width determines access functions used by upper layer */
if (host->pdata.width == 2)
this->options |= NAND_BUSWIDTH_16;

- if (host->pdata.flash_bbt) {
- this->bbt_td = &bbt_main_descr;
- this->bbt_md = &bbt_mirror_descr;
- /* update flash based bbt */
+ /* update flash based bbt */
+ if (host->pdata.flash_bbt)
this->bbt_options |= NAND_BBT_USE_FLASH;
- }

init_completion(&host->op_completion);

@@ -1637,6 +1616,27 @@ static int mxcnd_probe(struct platform_device *pdev)
goto escan;
}

+ switch (this->ecc.mode) {
+ case NAND_ECC_HW:
+ this->ecc.calculate = mxc_nand_calculate_ecc;
+ this->ecc.hwctl = mxc_nand_enable_hwecc;
+ this->ecc.correct = host->devtype_data->correct_data;
+ break;
+
+ case NAND_ECC_SOFT:
+ case NAND_ECC_SOFT_BCH:
+ break;
+
+ default:
+ err = -EINVAL;
+ goto escan;
+ }
+
+ if (this->bbt_options & NAND_BBT_USE_FLASH) {
+ this->bbt_td = &bbt_main_descr;
+ this->bbt_md = &bbt_mirror_descr;
+ }
+
/* allocate the right size buffer now */
devm_kfree(&pdev->dev, (void *)host->data_buf);
host->data_buf = devm_kzalloc(&pdev->dev, mtd->writesize + mtd->oobsize,
--
2.5.0

2016-04-01 12:54:54

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 04/12] mtd: nand: brcm: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/brcmnand/brcmnand.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
index e052839..6e2a52d 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -32,7 +32,6 @@
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/of.h>
-#include <linux/of_mtd.h>
#include <linux/of_platform.h>
#include <linux/slab.h>
#include <linux/list.h>
@@ -2001,8 +2000,8 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
*/
chip->options |= NAND_USE_BOUNCE_BUFFER;

- if (of_get_nand_on_flash_bbt(dn))
- chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
+ if (chip->bbt_options & NAND_BBT_USE_FLASH)
+ chip->bbt_options |= NAND_BBT_NO_OOB;

if (brcmnand_setup_dev(host))
return -ENXIO;
--
2.5.0

2016-04-01 12:56:34

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 08/12] mtd: nand: lpc32xx: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/lpc32xx_slc.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index 3b8f373..99925a2 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -194,7 +194,6 @@ struct lpc32xx_nand_cfg_slc {
uint32_t rwidth;
uint32_t rhold;
uint32_t rsetup;
- bool use_bbt;
int wp_gpio;
struct mtd_partition *parts;
unsigned num_parts;
@@ -747,7 +746,6 @@ static struct lpc32xx_nand_cfg_slc *lpc32xx_parse_dt(struct device *dev)
return NULL;
}

- ncfg->use_bbt = of_get_nand_on_flash_bbt(np);
ncfg->wp_gpio = of_get_named_gpio(np, "gpios", 0);

return ncfg;
@@ -882,19 +880,15 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
chip->ecc.bytes = LPC32XX_SLC_DEV_ECC_BYTES;
chip->ecc.prepad = chip->ecc.postpad = 0;

- /* Avoid extra scan if using BBT, setup BBT support */
- if (host->ncfg->use_bbt) {
- chip->bbt_options |= NAND_BBT_USE_FLASH;
-
- /*
- * Use a custom BBT marker setup for small page FLASH that
- * won't interfere with the ECC layout. Large and huge page
- * FLASH use the standard layout.
- */
- if (mtd->writesize <= 512) {
- chip->bbt_td = &bbt_smallpage_main_descr;
- chip->bbt_md = &bbt_smallpage_mirror_descr;
- }
+ /*
+ * Use a custom BBT marker setup for small page FLASH that
+ * won't interfere with the ECC layout. Large and huge page
+ * FLASH use the standard layout.
+ */
+ if ((chip->bbt_options & NAND_BBT_USE_FLASH) &&
+ mtd->writesize <= 512) {
+ chip->bbt_td = &bbt_smallpage_main_descr;
+ chip->bbt_md = &bbt_smallpage_mirror_descr;
}

/*
--
2.5.0

2016-04-01 12:56:50

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 07/12] mtd: nand: hisi504: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/hisi504_nand.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c
index 96502b6..38cdc84 100644
--- a/drivers/mtd/nand/hisi504_nand.c
+++ b/drivers/mtd/nand/hisi504_nand.c
@@ -19,7 +19,6 @@
* GNU General Public License for more details.
*/
#include <linux/of.h>
-#include <linux/of_mtd.h>
#include <linux/mtd/mtd.h>
#include <linux/sizes.h>
#include <linux/clk.h>
@@ -642,10 +641,9 @@ static int hisi_nfc_ecc_probe(struct hinfc_host *host)
struct device *dev = host->dev;
struct nand_chip *chip = &host->chip;
struct mtd_info *mtd = nand_to_mtd(chip);
- struct device_node *np = host->dev->of_node;

- size = of_get_nand_ecc_step_size(np);
- strength = of_get_nand_ecc_strength(np);
+ size = chip->ecc.size;
+ strength = chip->ecc.strength;
if (size != 1024) {
dev_err(dev, "error ecc size: %d\n", size);
return -EINVAL;
@@ -695,7 +693,7 @@ static int hisi_nfc_ecc_probe(struct hinfc_host *host)

static int hisi_nfc_probe(struct platform_device *pdev)
{
- int ret = 0, irq, buswidth, flag, max_chips = HINFC504_MAX_CHIP;
+ int ret = 0, irq, flag, max_chips = HINFC504_MAX_CHIP;
struct device *dev = &pdev->dev;
struct hinfc_host *host;
struct nand_chip *chip;
@@ -747,12 +745,6 @@ static int hisi_nfc_probe(struct platform_device *pdev)
chip->read_buf = hisi_nfc_read_buf;
chip->chip_delay = HINFC504_CHIP_DELAY;

- chip->ecc.mode = of_get_nand_ecc_mode(np);
-
- buswidth = of_get_nand_bus_width(np);
- if (buswidth == 16)
- chip->options |= NAND_BUSWIDTH_16;
-
hisi_nfc_host_init(host);

ret = devm_request_irq(dev, irq, hinfc_irq_handle, 0x0, "nandc", host);
--
2.5.0

2016-04-01 12:54:52

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 01/12] mtd: nand: remove unneeded of_mtd.h inclusions

Some drivers are including linux/of_mtd.h even if they don't use any of
the of_get_nand_xxx() helpers.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/jz4780_nand.c | 1 -
drivers/mtd/nand/lpc32xx_mlc.c | 1 -
drivers/mtd/nand/qcom_nandc.c | 1 -
drivers/mtd/nand/sunxi_nand.c | 1 -
drivers/mtd/nand/vf610_nfc.c | 1 -
5 files changed, 5 deletions(-)

diff --git a/drivers/mtd/nand/jz4780_nand.c b/drivers/mtd/nand/jz4780_nand.c
index e1c016c..23a1999 100644
--- a/drivers/mtd/nand/jz4780_nand.c
+++ b/drivers/mtd/nand/jz4780_nand.c
@@ -17,7 +17,6 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/gpio/consumer.h>
-#include <linux/of_mtd.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
index d8c3e7a..8e43978 100644
--- a/drivers/mtd/nand/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/lpc32xx_mlc.c
@@ -35,7 +35,6 @@
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/of.h>
-#include <linux/of_mtd.h>
#include <linux/of_gpio.h>
#include <linux/mtd/lpc32xx_mlc.h>
#include <linux/io.h>
diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index f550a57..f3de983 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -21,7 +21,6 @@
#include <linux/mtd/partitions.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_mtd.h>
#include <linux/delay.h>

/* NANDc reg offsets */
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 1c03eee..3a97093 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -30,7 +30,6 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
-#include <linux/of_mtd.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
index 293feb1..a7f2756 100644
--- a/drivers/mtd/nand/vf610_nfc.c
+++ b/drivers/mtd/nand/vf610_nfc.c
@@ -33,7 +33,6 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
-#include <linux/of_mtd.h>
#include <linux/of_device.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
--
2.5.0

2016-04-01 12:57:11

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 06/12] mtd: nand: gpmi: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 8122c69..c6e8a1c 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -25,7 +25,6 @@
#include <linux/mtd/partitions.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_mtd.h>
#include "gpmi-nand.h"
#include "bch-regs.h"

@@ -1914,16 +1913,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
this->swap_block_mark = !GPMI_IS_MX23(this);

- if (of_get_nand_on_flash_bbt(this->dev->of_node)) {
- chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
-
- if (of_property_read_bool(this->dev->of_node,
- "fsl,no-blockmark-swap"))
- this->swap_block_mark = false;
- }
- dev_dbg(this->dev, "Blockmark swapping %sabled\n",
- this->swap_block_mark ? "en" : "dis");
-
/*
* Allocate a temporary DMA buffer for reading ID in the
* nand_scan_ident().
@@ -1938,6 +1927,16 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
if (ret)
goto err_out;

+ if (chip->bbt_options & NAND_BBT_USE_FLASH) {
+ chip->bbt_options |= NAND_BBT_NO_OOB;
+
+ if (of_property_read_bool(this->dev->of_node,
+ "fsl,no-blockmark-swap"))
+ this->swap_block_mark = false;
+ }
+ dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+ this->swap_block_mark ? "en" : "dis");
+
ret = gpmi_init_last(this);
if (ret)
goto err_out;
--
2.5.0

2016-04-01 12:57:37

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 05/12] mtd: nand: davinci: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/davinci_nand.c | 85 +++++++++++++++++++----------------------
1 file changed, 40 insertions(+), 45 deletions(-)

diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 8cb821b..5bb6245 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -34,7 +34,6 @@
#include <linux/slab.h>
#include <linux/of_device.h>
#include <linux/of.h>
-#include <linux/of_mtd.h>

#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/mtd-davinci-aemif.h>
@@ -576,9 +575,9 @@ static struct davinci_nand_pdata
if (!of_property_read_u32(pdev->dev.of_node,
"ti,davinci-mask-chipsel", &prop))
pdata->mask_chipsel = prop;
+
+
if (!of_property_read_string(pdev->dev.of_node,
- "nand-ecc-mode", &mode) ||
- !of_property_read_string(pdev->dev.of_node,
"ti,davinci-ecc-mode", &mode)) {
if (!strncmp("none", mode, 4))
pdata->ecc_mode = NAND_ECC_NONE;
@@ -591,14 +590,11 @@ static struct davinci_nand_pdata
"ti,davinci-ecc-bits", &prop))
pdata->ecc_bits = prop;

- prop = of_get_nand_bus_width(pdev->dev.of_node);
- if (0 < prop || !of_property_read_u32(pdev->dev.of_node,
- "ti,davinci-nand-buswidth", &prop))
- if (prop == 16)
- pdata->options |= NAND_BUSWIDTH_16;
+ if (!of_property_read_u32(pdev->dev.of_node,
+ "ti,davinci-nand-buswidth", &prop) && prop == 16)
+ pdata->options |= NAND_BUSWIDTH_16;
+
if (of_property_read_bool(pdev->dev.of_node,
- "nand-on-flash-bbt") ||
- of_property_read_bool(pdev->dev.of_node,
"ti,davinci-nand-use-bbt"))
pdata->bbt_options = NAND_BBT_USE_FLASH;

@@ -628,7 +624,6 @@ static int nand_davinci_probe(struct platform_device *pdev)
void __iomem *base;
int ret;
uint32_t val;
- nand_ecc_modes_t ecc_mode;
struct mtd_info *mtd;

pdata = nand_davinci_get_pdata(pdev);
@@ -712,10 +707,41 @@ static int nand_davinci_probe(struct platform_device *pdev)
info->chip.write_buf = nand_davinci_write_buf;

/* Use board-specific ECC config */
- ecc_mode = pdata->ecc_mode;
+ info->chip.ecc.mode = pdata->ecc_mode;

ret = -EINVAL;
- switch (ecc_mode) {
+
+ info->clk = devm_clk_get(&pdev->dev, "aemif");
+ if (IS_ERR(info->clk)) {
+ ret = PTR_ERR(info->clk);
+ dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret);
+ return ret;
+ }
+
+ ret = clk_prepare_enable(info->clk);
+ if (ret < 0) {
+ dev_dbg(&pdev->dev, "unable to enable AEMIF clock, err %d\n",
+ ret);
+ goto err_clk_enable;
+ }
+
+ spin_lock_irq(&davinci_nand_lock);
+
+ /* put CSxNAND into NAND mode */
+ val = davinci_nand_readl(info, NANDFCR_OFFSET);
+ val |= BIT(info->core_chipsel);
+ davinci_nand_writel(info, NANDFCR_OFFSET, val);
+
+ spin_unlock_irq(&davinci_nand_lock);
+
+ /* Scan to find existence of the device(s) */
+ ret = nand_scan_ident(mtd, pdata->mask_chipsel ? 2 : 1, NULL);
+ if (ret < 0) {
+ dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
+ goto err;
+ }
+
+ switch (info->chip.ecc.mode) {
case NAND_ECC_NONE:
case NAND_ECC_SOFT:
pdata->ecc_bits = 0;
@@ -754,37 +780,6 @@ static int nand_davinci_probe(struct platform_device *pdev)
default:
return -EINVAL;
}
- info->chip.ecc.mode = ecc_mode;
-
- info->clk = devm_clk_get(&pdev->dev, "aemif");
- if (IS_ERR(info->clk)) {
- ret = PTR_ERR(info->clk);
- dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret);
- return ret;
- }
-
- ret = clk_prepare_enable(info->clk);
- if (ret < 0) {
- dev_dbg(&pdev->dev, "unable to enable AEMIF clock, err %d\n",
- ret);
- goto err_clk_enable;
- }
-
- spin_lock_irq(&davinci_nand_lock);
-
- /* put CSxNAND into NAND mode */
- val = davinci_nand_readl(info, NANDFCR_OFFSET);
- val |= BIT(info->core_chipsel);
- davinci_nand_writel(info, NANDFCR_OFFSET, val);
-
- spin_unlock_irq(&davinci_nand_lock);
-
- /* Scan to find existence of the device(s) */
- ret = nand_scan_ident(mtd, pdata->mask_chipsel ? 2 : 1, NULL);
- if (ret < 0) {
- dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
- goto err;
- }

/* Update ECC layout if needed ... for 1-bit HW ECC, the default
* is OK, but it allocates 6 bytes when only 3 are needed (for
@@ -850,7 +845,7 @@ err:

err_clk_enable:
spin_lock_irq(&davinci_nand_lock);
- if (ecc_mode == NAND_ECC_HW_SYNDROME)
+ if (info->chip.ecc.mode == NAND_ECC_HW_SYNDROME)
ecc4_busy = false;
spin_unlock_irq(&davinci_nand_lock);
return ret;
--
2.5.0

2016-04-01 12:58:12

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 03/12] mtd: nand: omap2: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/memory/omap-gpmc.c | 7 -------
drivers/mtd/nand/omap2.c | 9 ++++++---
2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 21825dd..85aa85e 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -25,7 +25,6 @@
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_address.h>
-#include <linux/of_mtd.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/omap-gpmc.h>
@@ -1876,12 +1875,6 @@ static int gpmc_probe_nand_child(struct platform_device *pdev,
break;
}

- gpmc_nand_data->flash_bbt = of_get_nand_on_flash_bbt(child);
-
- val = of_get_nand_bus_width(child);
- if (val == 16)
- gpmc_nand_data->devsize = NAND_BUSWIDTH_16;
-
gpmc_read_timings_dt(child, &gpmc_t);
gpmc_nand_init(gpmc_nand_data, &gpmc_t);

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 0749ca1..8921283 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1704,9 +1704,7 @@ static int omap_nand_probe(struct platform_device *pdev)
}

if (pdata->flash_bbt)
- nand_chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
- else
- nand_chip->options |= NAND_SKIP_BBTSCAN;
+ nand_chip->bbt_options |= NAND_BBT_USE_FLASH;

/* scan NAND device connected to chip controller */
nand_chip->options |= pdata->devsize & NAND_BUSWIDTH_16;
@@ -1716,6 +1714,11 @@ static int omap_nand_probe(struct platform_device *pdev)
goto return_error;
}

+ if (nand_chip->bbt_options & NAND_BBT_USE_FLASH)
+ nand_chip->bbt_options |= NAND_BBT_NO_OOB;
+ else
+ nand_chip->options |= NAND_SKIP_BBTSCAN;
+
/* re-populate low-level callbacks based on xfer modes */
switch (pdata->xfer_type) {
case NAND_OMAP_PREFETCH_POLLED:
--
2.5.0

2016-04-01 12:58:34

by Boris Brezillon

[permalink] [raw]
Subject: [PATCH 02/12] mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()

The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <[email protected]>
---
drivers/mtd/nand/atmel_nand.c | 133 +++++++++++++++++++++++-------------------
1 file changed, 73 insertions(+), 60 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0b5da72..5e716f2 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -36,7 +36,6 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
-#include <linux/of_mtd.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
@@ -434,14 +433,13 @@ err_buf:
static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
{
struct nand_chip *chip = mtd_to_nand(mtd);
- struct atmel_nand_host *host = nand_get_controller_data(chip);

if (use_dma && len > mtd->oobsize)
/* only use DMA for bigger than oob size: better performances */
if (atmel_nand_dma_op(mtd, buf, len, 1) == 0)
return;

- if (host->board.bus_width_16)
+ if (chip->options & NAND_BUSWIDTH_16)
atmel_read_buf16(mtd, buf, len);
else
atmel_read_buf8(mtd, buf, len);
@@ -450,14 +448,13 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
{
struct nand_chip *chip = mtd_to_nand(mtd);
- struct atmel_nand_host *host = nand_get_controller_data(chip);

if (use_dma && len > mtd->oobsize)
/* only use DMA for bigger than oob size: better performances */
if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0)
return;

- if (host->board.bus_width_16)
+ if (chip->options & NAND_BUSWIDTH_16)
atmel_write_buf16(mtd, buf, len);
else
atmel_write_buf8(mtd, buf, len);
@@ -1507,58 +1504,17 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
}

-static int atmel_of_init_port(struct atmel_nand_host *host,
- struct device_node *np)
+static int atmel_of_init_ecc(struct atmel_nand_host *host,
+ struct device_node *np)
{
- u32 val;
u32 offset[2];
- int ecc_mode;
- struct atmel_nand_data *board = &host->board;
- enum of_gpio_flags flags = 0;
-
- host->caps = (struct atmel_nand_caps *)
- of_device_get_match_data(host->dev);
-
- if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
- if (val >= 32) {
- dev_err(host->dev, "invalid addr-offset %u\n", val);
- return -EINVAL;
- }
- board->ale = val;
- }
-
- if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
- if (val >= 32) {
- dev_err(host->dev, "invalid cmd-offset %u\n", val);
- return -EINVAL;
- }
- board->cle = val;
- }
-
- ecc_mode = of_get_nand_ecc_mode(np);
-
- board->ecc_mode = ecc_mode < 0 ? NAND_ECC_SOFT : ecc_mode;
-
- board->on_flash_bbt = of_get_nand_on_flash_bbt(np);
-
- board->has_dma = of_property_read_bool(np, "atmel,nand-has-dma");
-
- if (of_get_nand_bus_width(np) == 16)
- board->bus_width_16 = 1;
-
- board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
- board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
-
- board->enable_pin = of_get_gpio(np, 1);
- board->det_pin = of_get_gpio(np, 2);
+ u32 val;

host->has_pmecc = of_property_read_bool(np, "atmel,has-pmecc");

- /* load the nfc driver if there is */
- of_platform_populate(np, NULL, NULL, host->dev);
-
- if (!(board->ecc_mode == NAND_ECC_HW) || !host->has_pmecc)
- return 0; /* Not using PMECC */
+ /* Not using PMECC */
+ if (!(host->nand_chip.ecc.mode == NAND_ECC_HW) || !host->has_pmecc)
+ return 0;

/* use PMECC, get correction capability, sector size and lookup
* table offset.
@@ -1599,16 +1555,64 @@ static int atmel_of_init_port(struct atmel_nand_host *host,
/* Will build a lookup table and initialize the offset later */
return 0;
}
+
if (!offset[0] && !offset[1]) {
dev_err(host->dev, "Invalid PMECC lookup table offset\n");
return -EINVAL;
}
+
host->pmecc_lookup_table_offset_512 = offset[0];
host->pmecc_lookup_table_offset_1024 = offset[1];

return 0;
}

+static int atmel_of_init_port(struct atmel_nand_host *host,
+ struct device_node *np)
+{
+ u32 val;
+ struct atmel_nand_data *board = &host->board;
+ enum of_gpio_flags flags = 0;
+
+ host->caps = (struct atmel_nand_caps *)
+ of_device_get_match_data(host->dev);
+
+ if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
+ if (val >= 32) {
+ dev_err(host->dev, "invalid addr-offset %u\n", val);
+ return -EINVAL;
+ }
+ board->ale = val;
+ }
+
+ if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
+ if (val >= 32) {
+ dev_err(host->dev, "invalid cmd-offset %u\n", val);
+ return -EINVAL;
+ }
+ board->cle = val;
+ }
+
+ board->has_dma = of_property_read_bool(np, "atmel,nand-has-dma");
+
+ board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
+ board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
+
+ board->enable_pin = of_get_gpio(np, 1);
+ board->det_pin = of_get_gpio(np, 2);
+
+ /* load the nfc driver if there is */
+ of_platform_populate(np, NULL, NULL, host->dev);
+
+ /*
+ * Initialize ECC mode to NAND_ECC_SOFT so that we have a correct value
+ * even if the nand-ecc-mode property is not defined.
+ */
+ host->nand_chip.ecc.mode = NAND_ECC_SOFT;
+
+ return 0;
+}
+
static int atmel_hw_nand_init_params(struct platform_device *pdev,
struct atmel_nand_host *host)
{
@@ -2150,6 +2154,11 @@ static int atmel_nand_probe(struct platform_device *pdev)
} else {
memcpy(&host->board, dev_get_platdata(&pdev->dev),
sizeof(struct atmel_nand_data));
+ nand_chip->ecc.mode = host->board.ecc_mode;
+
+ /* 16-bit bus width */
+ if (host->board.bus_width_16)
+ nand_chip->options |= NAND_BUSWIDTH_16;
}

/* link the private data structures */
@@ -2191,11 +2200,8 @@ static int atmel_nand_probe(struct platform_device *pdev)
nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
}

- nand_chip->ecc.mode = host->board.ecc_mode;
nand_chip->chip_delay = 40; /* 40us command delay time */

- if (host->board.bus_width_16) /* 16-bit bus width */
- nand_chip->options |= NAND_BUSWIDTH_16;

nand_chip->read_buf = atmel_read_buf;
nand_chip->write_buf = atmel_write_buf;
@@ -2228,11 +2234,6 @@ static int atmel_nand_probe(struct platform_device *pdev)
}
}

- if (host->board.on_flash_bbt || on_flash_bbt) {
- dev_info(&pdev->dev, "Use On Flash BBT\n");
- nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
- }
-
if (!host->board.has_dma)
use_dma = 0;

@@ -2259,6 +2260,18 @@ static int atmel_nand_probe(struct platform_device *pdev)
goto err_scan_ident;
}

+ if (host->board.on_flash_bbt || on_flash_bbt)
+ nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
+
+ if (nand_chip->bbt_options & NAND_BBT_USE_FLASH)
+ dev_info(&pdev->dev, "Use On Flash BBT\n");
+
+ if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
+ res = atmel_of_init_ecc(host, pdev->dev.of_node);
+ if (res)
+ goto err_hw_ecc;
+ }
+
if (nand_chip->ecc.mode == NAND_ECC_HW) {
if (host->has_pmecc)
res = atmel_pmecc_nand_init_params(pdev, host);
--
2.5.0

2016-04-01 13:09:34

by Harvey Hunt

[permalink] [raw]
Subject: Re: [PATCH 01/12] mtd: nand: remove unneeded of_mtd.h inclusions

Hi Boris,

On 01/04/16 13:54, Boris Brezillon wrote:
> Some drivers are including linux/of_mtd.h even if they don't use any of
> the of_get_nand_xxx() helpers.
>
> Signed-off-by: Boris Brezillon <[email protected]>
> ---
> drivers/mtd/nand/jz4780_nand.c | 1 -
> drivers/mtd/nand/lpc32xx_mlc.c | 1 -
> drivers/mtd/nand/qcom_nandc.c | 1 -
> drivers/mtd/nand/sunxi_nand.c | 1 -
> drivers/mtd/nand/vf610_nfc.c | 1 -
> 5 files changed, 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/jz4780_nand.c b/drivers/mtd/nand/jz4780_nand.c
> index e1c016c..23a1999 100644
> --- a/drivers/mtd/nand/jz4780_nand.c
> +++ b/drivers/mtd/nand/jz4780_nand.c
> @@ -17,7 +17,6 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/gpio/consumer.h>
> -#include <linux/of_mtd.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
> #include <linux/mtd/mtd.h>

Looks good to me.

Acked-by: Harvey Hunt <[email protected]>

Thanks,

Harvey

2016-04-01 14:15:43

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 12/12] mtd: nand: move of_get_nand_xxx() helpers into nand_base.c

Hi Boris,

[auto build test WARNING on next-20160401]
[cannot apply to v4.6-rc1 v4.5-rc7 v4.5-rc6 v4.6-rc1]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url: https://github.com/0day-ci/linux/commits/Boris-Brezillon/mtd-get-rid-of-of_mtd-c-h-and-of_get_nand_xx/20160401-210220
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

>> drivers/mtd/nand/nand_base.c:3972: warning: cannot understand function prototype: 'const char * const nand_ecc_modes[] = '
drivers/mtd/nand/nand_bbt.c:1: warning: no structured comments found
>> drivers/mtd/nand/nand_base.c:3972: warning: cannot understand function prototype: 'const char * const nand_ecc_modes[] = '

vim +3972 drivers/mtd/nand/nand_base.c

3956 chip->jedec_params.model);
3957 else
3958 pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,
3959 type->name);
3960
3961 pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n",
3962 (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
3963 mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
3964 return type;
3965 }
3966
3967 /**
3968 * It maps 'enum nand_ecc_modes_t' found in include/linux/mtd/nand.h
3969 * into the device tree binding of 'nand-ecc', so that MTD
3970 * device driver can get nand ecc from device tree.
3971 */
> 3972 static const char * const nand_ecc_modes[] = {
3973 [NAND_ECC_NONE] = "none",
3974 [NAND_ECC_SOFT] = "soft",
3975 [NAND_ECC_HW] = "hw",
3976 [NAND_ECC_HW_SYNDROME] = "hw_syndrome",
3977 [NAND_ECC_HW_OOB_FIRST] = "hw_oob_first",
3978 [NAND_ECC_SOFT_BCH] = "soft_bch",
3979 };
3980

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.82 kB)
.config.gz (6.16 kB)
Download all attachments

2016-04-01 15:35:07

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 12/12] mtd: nand: move of_get_nand_xxx() helpers into nand_base.c

On Fri, 1 Apr 2016 22:13:43 +0800
kbuild test robot <[email protected]> wrote:

> Hi Boris,
>
> [auto build test WARNING on next-20160401]
> [cannot apply to v4.6-rc1 v4.5-rc7 v4.5-rc6 v4.6-rc1]
> [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
>
> url: https://github.com/0day-ci/linux/commits/Boris-Brezillon/mtd-get-rid-of-of_mtd-c-h-and-of_get_nand_xx/20160401-210220
> reproduce: make htmldocs
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/mtd/nand/nand_base.c:3972: warning: cannot understand function prototype: 'const char * const nand_ecc_modes[] = '
> drivers/mtd/nand/nand_bbt.c:1: warning: no structured comments found
> >> drivers/mtd/nand/nand_base.c:3972: warning: cannot understand function prototype: 'const char * const nand_ecc_modes[] = '
>
> vim +3972 drivers/mtd/nand/nand_base.c
>
> 3956 chip->jedec_params.model);
> 3957 else
> 3958 pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,
> 3959 type->name);
> 3960
> 3961 pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n",
> 3962 (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
> 3963 mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
> 3964 return type;
> 3965 }
> 3966
> 3967 /**
> 3968 * It maps 'enum nand_ecc_modes_t' found in include/linux/mtd/nand.h
> 3969 * into the device tree binding of 'nand-ecc', so that MTD
> 3970 * device driver can get nand ecc from device tree.
> 3971 */

I'll remove this kerneldoc header to avoid this warning.

> > 3972 static const char * const nand_ecc_modes[] = {
> 3973 [NAND_ECC_NONE] = "none",
> 3974 [NAND_ECC_SOFT] = "soft",
> 3975 [NAND_ECC_HW] = "hw",
> 3976 [NAND_ECC_HW_SYNDROME] = "hw_syndrome",
> 3977 [NAND_ECC_HW_OOB_FIRST] = "hw_oob_first",
> 3978 [NAND_ECC_SOFT_BCH] = "soft_bch",
> 3979 };
> 3980
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-04 07:25:03

by Roger Quadros

[permalink] [raw]
Subject: Re: [PATCH 03/12] mtd: nand: omap2: rely on generic DT parsing done in nand_scan_ident()

On 01/04/16 15:54, Boris Brezillon wrote:
> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Acked-by: Roger Quadros <[email protected]>

cheers,
-roger

> ---
> drivers/memory/omap-gpmc.c | 7 -------
> drivers/mtd/nand/omap2.c | 9 ++++++---
> 2 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index 21825dd..85aa85e 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -25,7 +25,6 @@
> #include <linux/platform_device.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> -#include <linux/of_mtd.h>
> #include <linux/of_device.h>
> #include <linux/of_platform.h>
> #include <linux/omap-gpmc.h>
> @@ -1876,12 +1875,6 @@ static int gpmc_probe_nand_child(struct platform_device *pdev,
> break;
> }
>
> - gpmc_nand_data->flash_bbt = of_get_nand_on_flash_bbt(child);
> -
> - val = of_get_nand_bus_width(child);
> - if (val == 16)
> - gpmc_nand_data->devsize = NAND_BUSWIDTH_16;
> -
> gpmc_read_timings_dt(child, &gpmc_t);
> gpmc_nand_init(gpmc_nand_data, &gpmc_t);
>
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index 0749ca1..8921283 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1704,9 +1704,7 @@ static int omap_nand_probe(struct platform_device *pdev)
> }
>
> if (pdata->flash_bbt)
> - nand_chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> - else
> - nand_chip->options |= NAND_SKIP_BBTSCAN;
> + nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
>
> /* scan NAND device connected to chip controller */
> nand_chip->options |= pdata->devsize & NAND_BUSWIDTH_16;
> @@ -1716,6 +1714,11 @@ static int omap_nand_probe(struct platform_device *pdev)
> goto return_error;
> }
>
> + if (nand_chip->bbt_options & NAND_BBT_USE_FLASH)
> + nand_chip->bbt_options |= NAND_BBT_NO_OOB;
> + else
> + nand_chip->options |= NAND_SKIP_BBTSCAN;
> +
> /* re-populate low-level callbacks based on xfer modes */
> switch (pdata->xfer_type) {
> case NAND_OMAP_PREFETCH_POLLED:
>

2016-04-06 23:35:05

by Franklin S Cooper Jr

[permalink] [raw]
Subject: Re: [PATCH 00/12] mtd: get rid of of_mtd.{c,h} and of_get_nand_xx()



On 04/01/2016 07:54 AM, Boris Brezillon wrote:
> Hello,
>
> of_mtd.{h,c} are providing the of_get_nand_xxx() helpers to help NAND
> controller drivers parse some generic NAND DT properties.
> An infrastructure has recently been added to NAND core to automatically
> parse those properties when nand_scan_ident() is called, thus removing
> the need for NAND controller drivers to manually parse them.
>
> This series modifies drivers still making use of those helpers to rely
> on NAND core initialization, and get rid of the of_mtd.{c,h} files by
> moving the of_get_nand_xx() helpers into nand_base.c.
>

Nothing broke when I ran some NAND tests on my AM335x GP EVM (OMAP SOC).
Tested-by: Franklin S Cooper Jr. <[email protected]>

> Best Regards,
>
> Boris
>
> Boris Brezillon (12):
> mtd: nand: remove unneeded of_mtd.h inclusions
> mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: omap2: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: brcm: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: davinci: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: gpmi: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: hisi504: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: lpc32xx: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: mxc: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: pxa3xx: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: sh_flctl: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: move of_get_nand_xxx() helpers into nand_base.c
>
> drivers/memory/omap-gpmc.c | 7 --
> drivers/mtd/nand/atmel_nand.c | 133 +++++++++++++++-------------
> drivers/mtd/nand/brcmnand/brcmnand.c | 5 +-
> drivers/mtd/nand/davinci_nand.c | 85 +++++++++---------
> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 +++--
> drivers/mtd/nand/hisi504_nand.c | 14 +--
> drivers/mtd/nand/jz4780_nand.c | 1 -
> drivers/mtd/nand/lpc32xx_mlc.c | 1 -
> drivers/mtd/nand/lpc32xx_slc.c | 24 ++---
> drivers/mtd/nand/mxc_nand.c | 50 +++++------
> drivers/mtd/nand/nand_base.c | 99 ++++++++++++++++++++-
> drivers/mtd/nand/omap2.c | 9 +-
> drivers/mtd/nand/pxa3xx_nand.c | 28 +++---
> drivers/mtd/nand/qcom_nandc.c | 1 -
> drivers/mtd/nand/sh_flctl.c | 31 +++----
> drivers/mtd/nand/sunxi_nand.c | 1 -
> drivers/mtd/nand/vf610_nfc.c | 1 -
> drivers/of/Makefile | 1 -
> drivers/of/of_mtd.c | 155 ---------------------------------
> include/linux/of_mtd.h | 56 ------------
> 20 files changed, 291 insertions(+), 432 deletions(-)
> delete mode 100644 drivers/of/of_mtd.c
> delete mode 100644 include/linux/of_mtd.h
>

2016-04-12 22:22:21

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 01/12] mtd: nand: remove unneeded of_mtd.h inclusions

On Fri, 1 Apr 2016 14:54:21 +0200
Boris Brezillon <[email protected]> wrote:

> Some drivers are including linux/of_mtd.h even if they don't use any of
> the of_get_nand_xxx() helpers.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Applied.

> ---
> drivers/mtd/nand/jz4780_nand.c | 1 -
> drivers/mtd/nand/lpc32xx_mlc.c | 1 -
> drivers/mtd/nand/qcom_nandc.c | 1 -
> drivers/mtd/nand/sunxi_nand.c | 1 -
> drivers/mtd/nand/vf610_nfc.c | 1 -
> 5 files changed, 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/jz4780_nand.c b/drivers/mtd/nand/jz4780_nand.c
> index e1c016c..23a1999 100644
> --- a/drivers/mtd/nand/jz4780_nand.c
> +++ b/drivers/mtd/nand/jz4780_nand.c
> @@ -17,7 +17,6 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/gpio/consumer.h>
> -#include <linux/of_mtd.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
> #include <linux/mtd/mtd.h>
> diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
> index d8c3e7a..8e43978 100644
> --- a/drivers/mtd/nand/lpc32xx_mlc.c
> +++ b/drivers/mtd/nand/lpc32xx_mlc.c
> @@ -35,7 +35,6 @@
> #include <linux/completion.h>
> #include <linux/interrupt.h>
> #include <linux/of.h>
> -#include <linux/of_mtd.h>
> #include <linux/of_gpio.h>
> #include <linux/mtd/lpc32xx_mlc.h>
> #include <linux/io.h>
> diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
> index f550a57..f3de983 100644
> --- a/drivers/mtd/nand/qcom_nandc.c
> +++ b/drivers/mtd/nand/qcom_nandc.c
> @@ -21,7 +21,6 @@
> #include <linux/mtd/partitions.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> -#include <linux/of_mtd.h>
> #include <linux/delay.h>
>
> /* NANDc reg offsets */
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index 1c03eee..3a97093 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -30,7 +30,6 @@
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/of_gpio.h>
> -#include <linux/of_mtd.h>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/nand.h>
> #include <linux/mtd/partitions.h>
> diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
> index 293feb1..a7f2756 100644
> --- a/drivers/mtd/nand/vf610_nfc.c
> +++ b/drivers/mtd/nand/vf610_nfc.c
> @@ -33,7 +33,6 @@
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/nand.h>
> #include <linux/mtd/partitions.h>
> -#include <linux/of_mtd.h>
> #include <linux/of_device.h>
> #include <linux/pinctrl/consumer.h>
> #include <linux/platform_device.h>



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-12 22:22:37

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 03/12] mtd: nand: omap2: rely on generic DT parsing done in nand_scan_ident()

On Fri, 1 Apr 2016 14:54:23 +0200
Boris Brezillon <[email protected]> wrote:

> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Applied.

> ---
> drivers/memory/omap-gpmc.c | 7 -------
> drivers/mtd/nand/omap2.c | 9 ++++++---
> 2 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index 21825dd..85aa85e 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -25,7 +25,6 @@
> #include <linux/platform_device.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> -#include <linux/of_mtd.h>
> #include <linux/of_device.h>
> #include <linux/of_platform.h>
> #include <linux/omap-gpmc.h>
> @@ -1876,12 +1875,6 @@ static int gpmc_probe_nand_child(struct platform_device *pdev,
> break;
> }
>
> - gpmc_nand_data->flash_bbt = of_get_nand_on_flash_bbt(child);
> -
> - val = of_get_nand_bus_width(child);
> - if (val == 16)
> - gpmc_nand_data->devsize = NAND_BUSWIDTH_16;
> -
> gpmc_read_timings_dt(child, &gpmc_t);
> gpmc_nand_init(gpmc_nand_data, &gpmc_t);
>
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index 0749ca1..8921283 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1704,9 +1704,7 @@ static int omap_nand_probe(struct platform_device *pdev)
> }
>
> if (pdata->flash_bbt)
> - nand_chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> - else
> - nand_chip->options |= NAND_SKIP_BBTSCAN;
> + nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
>
> /* scan NAND device connected to chip controller */
> nand_chip->options |= pdata->devsize & NAND_BUSWIDTH_16;
> @@ -1716,6 +1714,11 @@ static int omap_nand_probe(struct platform_device *pdev)
> goto return_error;
> }
>
> + if (nand_chip->bbt_options & NAND_BBT_USE_FLASH)
> + nand_chip->bbt_options |= NAND_BBT_NO_OOB;
> + else
> + nand_chip->options |= NAND_SKIP_BBTSCAN;
> +
> /* re-populate low-level callbacks based on xfer modes */
> switch (pdata->xfer_type) {
> case NAND_OMAP_PREFETCH_POLLED:



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-12 22:31:18

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH 04/12] mtd: nand: brcm: rely on generic DT parsing done in nand_scan_ident()

On Fri, Apr 01, 2016 at 02:54:24PM +0200, Boris Brezillon wrote:
> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Acked-by: Brian Norris <[email protected]>

2016-04-13 07:42:30

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 04/12] mtd: nand: brcm: rely on generic DT parsing done in nand_scan_ident()

On Tue, 12 Apr 2016 15:31:11 -0700
Brian Norris <[email protected]> wrote:

> On Fri, Apr 01, 2016 at 02:54:24PM +0200, Boris Brezillon wrote:
> > The core now takes care of parsing generic DT properties in
> > nand_scan_ident() when nand_set_flash_node() has been called.
> > Rely on this initialization instead of calling of_get_nand_xxx()
> > manually.
> >
> > Signed-off-by: Boris Brezillon <[email protected]>
>
> Acked-by: Brian Norris <[email protected]>

Applied.

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-13 12:31:49

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 02/12] mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()

On Fri, 1 Apr 2016 14:54:22 +0200
Boris Brezillon <[email protected]> wrote:

> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Tested on sama5d4ek.

Tested-by: Boris Brezillon <[email protected]>

> ---
> drivers/mtd/nand/atmel_nand.c | 133 +++++++++++++++++++++++-------------------
> 1 file changed, 73 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 0b5da72..5e716f2 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -36,7 +36,6 @@
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/of_gpio.h>
> -#include <linux/of_mtd.h>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/nand.h>
> #include <linux/mtd/partitions.h>
> @@ -434,14 +433,13 @@ err_buf:
> static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
> {
> struct nand_chip *chip = mtd_to_nand(mtd);
> - struct atmel_nand_host *host = nand_get_controller_data(chip);
>
> if (use_dma && len > mtd->oobsize)
> /* only use DMA for bigger than oob size: better performances */
> if (atmel_nand_dma_op(mtd, buf, len, 1) == 0)
> return;
>
> - if (host->board.bus_width_16)
> + if (chip->options & NAND_BUSWIDTH_16)
> atmel_read_buf16(mtd, buf, len);
> else
> atmel_read_buf8(mtd, buf, len);
> @@ -450,14 +448,13 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
> static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
> {
> struct nand_chip *chip = mtd_to_nand(mtd);
> - struct atmel_nand_host *host = nand_get_controller_data(chip);
>
> if (use_dma && len > mtd->oobsize)
> /* only use DMA for bigger than oob size: better performances */
> if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0)
> return;
>
> - if (host->board.bus_width_16)
> + if (chip->options & NAND_BUSWIDTH_16)
> atmel_write_buf16(mtd, buf, len);
> else
> atmel_write_buf8(mtd, buf, len);
> @@ -1507,58 +1504,17 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
> ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
> }
>
> -static int atmel_of_init_port(struct atmel_nand_host *host,
> - struct device_node *np)
> +static int atmel_of_init_ecc(struct atmel_nand_host *host,
> + struct device_node *np)
> {
> - u32 val;
> u32 offset[2];
> - int ecc_mode;
> - struct atmel_nand_data *board = &host->board;
> - enum of_gpio_flags flags = 0;
> -
> - host->caps = (struct atmel_nand_caps *)
> - of_device_get_match_data(host->dev);
> -
> - if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
> - if (val >= 32) {
> - dev_err(host->dev, "invalid addr-offset %u\n", val);
> - return -EINVAL;
> - }
> - board->ale = val;
> - }
> -
> - if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
> - if (val >= 32) {
> - dev_err(host->dev, "invalid cmd-offset %u\n", val);
> - return -EINVAL;
> - }
> - board->cle = val;
> - }
> -
> - ecc_mode = of_get_nand_ecc_mode(np);
> -
> - board->ecc_mode = ecc_mode < 0 ? NAND_ECC_SOFT : ecc_mode;
> -
> - board->on_flash_bbt = of_get_nand_on_flash_bbt(np);
> -
> - board->has_dma = of_property_read_bool(np, "atmel,nand-has-dma");
> -
> - if (of_get_nand_bus_width(np) == 16)
> - board->bus_width_16 = 1;
> -
> - board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
> - board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
> -
> - board->enable_pin = of_get_gpio(np, 1);
> - board->det_pin = of_get_gpio(np, 2);
> + u32 val;
>
> host->has_pmecc = of_property_read_bool(np, "atmel,has-pmecc");
>
> - /* load the nfc driver if there is */
> - of_platform_populate(np, NULL, NULL, host->dev);
> -
> - if (!(board->ecc_mode == NAND_ECC_HW) || !host->has_pmecc)
> - return 0; /* Not using PMECC */
> + /* Not using PMECC */
> + if (!(host->nand_chip.ecc.mode == NAND_ECC_HW) || !host->has_pmecc)
> + return 0;
>
> /* use PMECC, get correction capability, sector size and lookup
> * table offset.
> @@ -1599,16 +1555,64 @@ static int atmel_of_init_port(struct atmel_nand_host *host,
> /* Will build a lookup table and initialize the offset later */
> return 0;
> }
> +
> if (!offset[0] && !offset[1]) {
> dev_err(host->dev, "Invalid PMECC lookup table offset\n");
> return -EINVAL;
> }
> +
> host->pmecc_lookup_table_offset_512 = offset[0];
> host->pmecc_lookup_table_offset_1024 = offset[1];
>
> return 0;
> }
>
> +static int atmel_of_init_port(struct atmel_nand_host *host,
> + struct device_node *np)
> +{
> + u32 val;
> + struct atmel_nand_data *board = &host->board;
> + enum of_gpio_flags flags = 0;
> +
> + host->caps = (struct atmel_nand_caps *)
> + of_device_get_match_data(host->dev);
> +
> + if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
> + if (val >= 32) {
> + dev_err(host->dev, "invalid addr-offset %u\n", val);
> + return -EINVAL;
> + }
> + board->ale = val;
> + }
> +
> + if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
> + if (val >= 32) {
> + dev_err(host->dev, "invalid cmd-offset %u\n", val);
> + return -EINVAL;
> + }
> + board->cle = val;
> + }
> +
> + board->has_dma = of_property_read_bool(np, "atmel,nand-has-dma");
> +
> + board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
> + board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
> +
> + board->enable_pin = of_get_gpio(np, 1);
> + board->det_pin = of_get_gpio(np, 2);
> +
> + /* load the nfc driver if there is */
> + of_platform_populate(np, NULL, NULL, host->dev);
> +
> + /*
> + * Initialize ECC mode to NAND_ECC_SOFT so that we have a correct value
> + * even if the nand-ecc-mode property is not defined.
> + */
> + host->nand_chip.ecc.mode = NAND_ECC_SOFT;
> +
> + return 0;
> +}
> +
> static int atmel_hw_nand_init_params(struct platform_device *pdev,
> struct atmel_nand_host *host)
> {
> @@ -2150,6 +2154,11 @@ static int atmel_nand_probe(struct platform_device *pdev)
> } else {
> memcpy(&host->board, dev_get_platdata(&pdev->dev),
> sizeof(struct atmel_nand_data));
> + nand_chip->ecc.mode = host->board.ecc_mode;
> +
> + /* 16-bit bus width */
> + if (host->board.bus_width_16)
> + nand_chip->options |= NAND_BUSWIDTH_16;
> }
>
> /* link the private data structures */
> @@ -2191,11 +2200,8 @@ static int atmel_nand_probe(struct platform_device *pdev)
> nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
> }
>
> - nand_chip->ecc.mode = host->board.ecc_mode;
> nand_chip->chip_delay = 40; /* 40us command delay time */
>
> - if (host->board.bus_width_16) /* 16-bit bus width */
> - nand_chip->options |= NAND_BUSWIDTH_16;
>
> nand_chip->read_buf = atmel_read_buf;
> nand_chip->write_buf = atmel_write_buf;
> @@ -2228,11 +2234,6 @@ static int atmel_nand_probe(struct platform_device *pdev)
> }
> }
>
> - if (host->board.on_flash_bbt || on_flash_bbt) {
> - dev_info(&pdev->dev, "Use On Flash BBT\n");
> - nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
> - }
> -
> if (!host->board.has_dma)
> use_dma = 0;
>
> @@ -2259,6 +2260,18 @@ static int atmel_nand_probe(struct platform_device *pdev)
> goto err_scan_ident;
> }
>
> + if (host->board.on_flash_bbt || on_flash_bbt)
> + nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
> +
> + if (nand_chip->bbt_options & NAND_BBT_USE_FLASH)
> + dev_info(&pdev->dev, "Use On Flash BBT\n");
> +
> + if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
> + res = atmel_of_init_ecc(host, pdev->dev.of_node);
> + if (res)
> + goto err_hw_ecc;
> + }
> +
> if (nand_chip->ecc.mode == NAND_ECC_HW) {
> if (host->has_pmecc)
> res = atmel_pmecc_nand_init_params(pdev, host);



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-13 12:55:34

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 02/12] mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()

Le 01/04/2016 14:54, Boris Brezillon a ?crit :
> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

It seems okay:
Reviewed-by: Nicolas Ferre <[email protected]>

Thanks Boris, bye,


> ---
> drivers/mtd/nand/atmel_nand.c | 133 +++++++++++++++++++++++-------------------
> 1 file changed, 73 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 0b5da72..5e716f2 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -36,7 +36,6 @@
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/of_gpio.h>
> -#include <linux/of_mtd.h>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/nand.h>
> #include <linux/mtd/partitions.h>
> @@ -434,14 +433,13 @@ err_buf:
> static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
> {
> struct nand_chip *chip = mtd_to_nand(mtd);
> - struct atmel_nand_host *host = nand_get_controller_data(chip);
>
> if (use_dma && len > mtd->oobsize)
> /* only use DMA for bigger than oob size: better performances */
> if (atmel_nand_dma_op(mtd, buf, len, 1) == 0)
> return;
>
> - if (host->board.bus_width_16)
> + if (chip->options & NAND_BUSWIDTH_16)
> atmel_read_buf16(mtd, buf, len);
> else
> atmel_read_buf8(mtd, buf, len);
> @@ -450,14 +448,13 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
> static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
> {
> struct nand_chip *chip = mtd_to_nand(mtd);
> - struct atmel_nand_host *host = nand_get_controller_data(chip);
>
> if (use_dma && len > mtd->oobsize)
> /* only use DMA for bigger than oob size: better performances */
> if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0)
> return;
>
> - if (host->board.bus_width_16)
> + if (chip->options & NAND_BUSWIDTH_16)
> atmel_write_buf16(mtd, buf, len);
> else
> atmel_write_buf8(mtd, buf, len);
> @@ -1507,58 +1504,17 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
> ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
> }
>
> -static int atmel_of_init_port(struct atmel_nand_host *host,
> - struct device_node *np)
> +static int atmel_of_init_ecc(struct atmel_nand_host *host,
> + struct device_node *np)
> {
> - u32 val;
> u32 offset[2];
> - int ecc_mode;
> - struct atmel_nand_data *board = &host->board;
> - enum of_gpio_flags flags = 0;
> -
> - host->caps = (struct atmel_nand_caps *)
> - of_device_get_match_data(host->dev);
> -
> - if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
> - if (val >= 32) {
> - dev_err(host->dev, "invalid addr-offset %u\n", val);
> - return -EINVAL;
> - }
> - board->ale = val;
> - }
> -
> - if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
> - if (val >= 32) {
> - dev_err(host->dev, "invalid cmd-offset %u\n", val);
> - return -EINVAL;
> - }
> - board->cle = val;
> - }
> -
> - ecc_mode = of_get_nand_ecc_mode(np);
> -
> - board->ecc_mode = ecc_mode < 0 ? NAND_ECC_SOFT : ecc_mode;
> -
> - board->on_flash_bbt = of_get_nand_on_flash_bbt(np);
> -
> - board->has_dma = of_property_read_bool(np, "atmel,nand-has-dma");
> -
> - if (of_get_nand_bus_width(np) == 16)
> - board->bus_width_16 = 1;
> -
> - board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
> - board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
> -
> - board->enable_pin = of_get_gpio(np, 1);
> - board->det_pin = of_get_gpio(np, 2);
> + u32 val;
>
> host->has_pmecc = of_property_read_bool(np, "atmel,has-pmecc");
>
> - /* load the nfc driver if there is */
> - of_platform_populate(np, NULL, NULL, host->dev);
> -
> - if (!(board->ecc_mode == NAND_ECC_HW) || !host->has_pmecc)
> - return 0; /* Not using PMECC */
> + /* Not using PMECC */
> + if (!(host->nand_chip.ecc.mode == NAND_ECC_HW) || !host->has_pmecc)
> + return 0;
>
> /* use PMECC, get correction capability, sector size and lookup
> * table offset.
> @@ -1599,16 +1555,64 @@ static int atmel_of_init_port(struct atmel_nand_host *host,
> /* Will build a lookup table and initialize the offset later */
> return 0;
> }
> +
> if (!offset[0] && !offset[1]) {
> dev_err(host->dev, "Invalid PMECC lookup table offset\n");
> return -EINVAL;
> }
> +
> host->pmecc_lookup_table_offset_512 = offset[0];
> host->pmecc_lookup_table_offset_1024 = offset[1];
>
> return 0;
> }
>
> +static int atmel_of_init_port(struct atmel_nand_host *host,
> + struct device_node *np)
> +{
> + u32 val;
> + struct atmel_nand_data *board = &host->board;
> + enum of_gpio_flags flags = 0;
> +
> + host->caps = (struct atmel_nand_caps *)
> + of_device_get_match_data(host->dev);
> +
> + if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
> + if (val >= 32) {
> + dev_err(host->dev, "invalid addr-offset %u\n", val);
> + return -EINVAL;
> + }
> + board->ale = val;
> + }
> +
> + if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
> + if (val >= 32) {
> + dev_err(host->dev, "invalid cmd-offset %u\n", val);
> + return -EINVAL;
> + }
> + board->cle = val;
> + }
> +
> + board->has_dma = of_property_read_bool(np, "atmel,nand-has-dma");
> +
> + board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
> + board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
> +
> + board->enable_pin = of_get_gpio(np, 1);
> + board->det_pin = of_get_gpio(np, 2);
> +
> + /* load the nfc driver if there is */
> + of_platform_populate(np, NULL, NULL, host->dev);
> +
> + /*
> + * Initialize ECC mode to NAND_ECC_SOFT so that we have a correct value
> + * even if the nand-ecc-mode property is not defined.
> + */
> + host->nand_chip.ecc.mode = NAND_ECC_SOFT;
> +
> + return 0;
> +}
> +
> static int atmel_hw_nand_init_params(struct platform_device *pdev,
> struct atmel_nand_host *host)
> {
> @@ -2150,6 +2154,11 @@ static int atmel_nand_probe(struct platform_device *pdev)
> } else {
> memcpy(&host->board, dev_get_platdata(&pdev->dev),
> sizeof(struct atmel_nand_data));
> + nand_chip->ecc.mode = host->board.ecc_mode;
> +
> + /* 16-bit bus width */
> + if (host->board.bus_width_16)
> + nand_chip->options |= NAND_BUSWIDTH_16;
> }
>
> /* link the private data structures */
> @@ -2191,11 +2200,8 @@ static int atmel_nand_probe(struct platform_device *pdev)
> nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
> }
>
> - nand_chip->ecc.mode = host->board.ecc_mode;
> nand_chip->chip_delay = 40; /* 40us command delay time */
>
> - if (host->board.bus_width_16) /* 16-bit bus width */
> - nand_chip->options |= NAND_BUSWIDTH_16;
>
> nand_chip->read_buf = atmel_read_buf;
> nand_chip->write_buf = atmel_write_buf;
> @@ -2228,11 +2234,6 @@ static int atmel_nand_probe(struct platform_device *pdev)
> }
> }
>
> - if (host->board.on_flash_bbt || on_flash_bbt) {
> - dev_info(&pdev->dev, "Use On Flash BBT\n");
> - nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
> - }
> -
> if (!host->board.has_dma)
> use_dma = 0;
>
> @@ -2259,6 +2260,18 @@ static int atmel_nand_probe(struct platform_device *pdev)
> goto err_scan_ident;
> }
>
> + if (host->board.on_flash_bbt || on_flash_bbt)
> + nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
> +
> + if (nand_chip->bbt_options & NAND_BBT_USE_FLASH)
> + dev_info(&pdev->dev, "Use On Flash BBT\n");
> +
> + if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
> + res = atmel_of_init_ecc(host, pdev->dev.of_node);
> + if (res)
> + goto err_hw_ecc;
> + }
> +
> if (nand_chip->ecc.mode == NAND_ECC_HW) {
> if (host->has_pmecc)
> res = atmel_pmecc_nand_init_params(pdev, host);
>


--
Nicolas Ferre

2016-04-13 13:51:48

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 02/12] mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()

On Fri, 1 Apr 2016 14:54:22 +0200
Boris Brezillon <[email protected]> wrote:

> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Applied.


--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-13 14:48:30

by Ezequiel Garcia

[permalink] [raw]
Subject: Re: [PATCH 10/12] mtd: nand: pxa3xx: rely on generic DT parsing done in nand_scan_ident()

On 01 Apr 02:54 PM, Boris Brezillon wrote:
> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.
>
> Signed-off-by: Boris Brezillon <[email protected]>

Acked-by: Ezequiel Garcia <[email protected]>

Thanks,

> ---
> drivers/mtd/nand/pxa3xx_nand.c | 28 +++++++++++-----------------
> 1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> index d650885..38d26ab 100644
> --- a/drivers/mtd/nand/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/pxa3xx_nand.c
> @@ -29,7 +29,6 @@
> #include <linux/slab.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> -#include <linux/of_mtd.h>
> #include <linux/platform_data/mtd-nand-pxa3xx.h>
>
> #define CHIP_DELAY_TIMEOUT msecs_to_jiffies(200)
> @@ -1651,6 +1650,12 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
> if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370)
> nand_writel(info, NDECCCTRL, 0x0);
>
> + if (pdata->flash_bbt)
> + chip->bbt_options |= NAND_BBT_USE_FLASH;
> +
> + chip->ecc.strength = pdata->ecc_strength;
> + chip->ecc.size = pdata->ecc_step_size;
> +
> if (nand_scan_ident(mtd, 1, NULL))
> return -ENODEV;
>
> @@ -1663,13 +1668,12 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
> }
> }
>
> - if (pdata->flash_bbt) {
> + if (chip->bbt_options & NAND_BBT_USE_FLASH) {
> /*
> * We'll use a bad block table stored in-flash and don't
> * allow writing the bad block marker to the flash.
> */
> - chip->bbt_options |= NAND_BBT_USE_FLASH |
> - NAND_BBT_NO_OOB_BBM;
> + chip->bbt_options |= NAND_BBT_NO_OOB_BBM;
> chip->bbt_td = &bbt_main_descr;
> chip->bbt_md = &bbt_mirror_descr;
> }
> @@ -1689,10 +1693,9 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
> }
> }
>
> - if (pdata->ecc_strength && pdata->ecc_step_size) {
> - ecc_strength = pdata->ecc_strength;
> - ecc_step = pdata->ecc_step_size;
> - } else {
> + ecc_strength = chip->ecc.strength;
> + ecc_step = chip->ecc.size;
> + if (!ecc_strength || !ecc_step) {
> ecc_strength = chip->ecc_strength_ds;
> ecc_step = chip->ecc_step_ds;
> }
> @@ -1903,15 +1906,6 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
> if (of_get_property(np, "marvell,nand-keep-config", NULL))
> pdata->keep_config = 1;
> of_property_read_u32(np, "num-cs", &pdata->num_cs);
> - pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
> -
> - pdata->ecc_strength = of_get_nand_ecc_strength(np);
> - if (pdata->ecc_strength < 0)
> - pdata->ecc_strength = 0;
> -
> - pdata->ecc_step_size = of_get_nand_ecc_step_size(np);
> - if (pdata->ecc_step_size < 0)
> - pdata->ecc_step_size = 0;
>
> pdev->dev.platform_data = pdata;
>
> --
> 2.5.0
>

--
Ezequiel Garcia, VanguardiaSur
http://www.vanguardiasur.com.ar

2016-04-13 14:53:59

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 10/12] mtd: nand: pxa3xx: rely on generic DT parsing done in nand_scan_ident()

On Wed, 13 Apr 2016 11:48:22 -0300
Ezequiel Garcia <[email protected]> wrote:

> On 01 Apr 02:54 PM, Boris Brezillon wrote:
> > The core now takes care of parsing generic DT properties in
> > nand_scan_ident() when nand_set_flash_node() has been called.
> > Rely on this initialization instead of calling of_get_nand_xxx()
> > manually.
> >
> > Signed-off-by: Boris Brezillon <[email protected]>
>
> Acked-by: Ezequiel Garcia <[email protected]>

Applied.

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-16 09:07:28

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 06/12] mtd: nand: gpmi: rely on generic DT parsing done in nand_scan_ident()

Hi Han,

On Fri, 1 Apr 2016 14:54:26 +0200
Boris Brezillon <[email protected]> wrote:

> The core now takes care of parsing generic DT properties in
> nand_scan_ident() when nand_set_flash_node() has been called.
> Rely on this initialization instead of calling of_get_nand_xxx()
> manually.

Can you review/test this patch? I'd like to have the whole series
merged in this release.

Thanks,

Boris

>
> Signed-off-by: Boris Brezillon <[email protected]>
> ---
> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 8122c69..c6e8a1c 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -25,7 +25,6 @@
> #include <linux/mtd/partitions.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> -#include <linux/of_mtd.h>
> #include "gpmi-nand.h"
> #include "bch-regs.h"
>
> @@ -1914,16 +1913,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
> /* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
> this->swap_block_mark = !GPMI_IS_MX23(this);
>
> - if (of_get_nand_on_flash_bbt(this->dev->of_node)) {
> - chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> -
> - if (of_property_read_bool(this->dev->of_node,
> - "fsl,no-blockmark-swap"))
> - this->swap_block_mark = false;
> - }
> - dev_dbg(this->dev, "Blockmark swapping %sabled\n",
> - this->swap_block_mark ? "en" : "dis");
> -
> /*
> * Allocate a temporary DMA buffer for reading ID in the
> * nand_scan_ident().
> @@ -1938,6 +1927,16 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
> if (ret)
> goto err_out;
>
> + if (chip->bbt_options & NAND_BBT_USE_FLASH) {
> + chip->bbt_options |= NAND_BBT_NO_OOB;
> +
> + if (of_property_read_bool(this->dev->of_node,
> + "fsl,no-blockmark-swap"))
> + this->swap_block_mark = false;
> + }
> + dev_dbg(this->dev, "Blockmark swapping %sabled\n",
> + this->swap_block_mark ? "en" : "dis");
> +
> ret = gpmi_init_last(this);
> if (ret)
> goto err_out;



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-22 09:14:42

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 00/12] mtd: get rid of of_mtd.{c,h} and of_get_nand_xx()

On Fri, 1 Apr 2016 14:54:20 +0200
Boris Brezillon <[email protected]> wrote:

> Hello,
>
> of_mtd.{h,c} are providing the of_get_nand_xxx() helpers to help NAND
> controller drivers parse some generic NAND DT properties.
> An infrastructure has recently been added to NAND core to automatically
> parse those properties when nand_scan_ident() is called, thus removing
> the need for NAND controller drivers to manually parse them.
>
> This series modifies drivers still making use of those helpers to rely
> on NAND core initialization, and get rid of the of_mtd.{c,h} files by
> moving the of_get_nand_xx() helpers into nand_base.c.

Applied remaining patches.

>
> Best Regards,
>
> Boris
>
> Boris Brezillon (12):
> mtd: nand: remove unneeded of_mtd.h inclusions
> mtd: nand: atmel: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: omap2: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: brcm: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: davinci: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: gpmi: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: hisi504: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: lpc32xx: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: mxc: rely on generic DT parsing done in nand_scan_ident()
> mtd: nand: pxa3xx: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: sh_flctl: rely on generic DT parsing done in
> nand_scan_ident()
> mtd: nand: move of_get_nand_xxx() helpers into nand_base.c
>
> drivers/memory/omap-gpmc.c | 7 --
> drivers/mtd/nand/atmel_nand.c | 133 +++++++++++++++-------------
> drivers/mtd/nand/brcmnand/brcmnand.c | 5 +-
> drivers/mtd/nand/davinci_nand.c | 85 +++++++++---------
> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 +++--
> drivers/mtd/nand/hisi504_nand.c | 14 +--
> drivers/mtd/nand/jz4780_nand.c | 1 -
> drivers/mtd/nand/lpc32xx_mlc.c | 1 -
> drivers/mtd/nand/lpc32xx_slc.c | 24 ++---
> drivers/mtd/nand/mxc_nand.c | 50 +++++------
> drivers/mtd/nand/nand_base.c | 99 ++++++++++++++++++++-
> drivers/mtd/nand/omap2.c | 9 +-
> drivers/mtd/nand/pxa3xx_nand.c | 28 +++---
> drivers/mtd/nand/qcom_nandc.c | 1 -
> drivers/mtd/nand/sh_flctl.c | 31 +++----
> drivers/mtd/nand/sunxi_nand.c | 1 -
> drivers/mtd/nand/vf610_nfc.c | 1 -
> drivers/of/Makefile | 1 -
> drivers/of/of_mtd.c | 155 ---------------------------------
> include/linux/of_mtd.h | 56 ------------
> 20 files changed, 291 insertions(+), 432 deletions(-)
> delete mode 100644 drivers/of/of_mtd.c
> delete mode 100644 include/linux/of_mtd.h
>



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com