mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Add device tree support of Atmel NAND driver
@ 2014-08-05  9:14 Raphaël Poggi
  2014-08-05  9:14 ` [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC Raphaël Poggi
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:14 UTC (permalink / raw)
  To: barebox

Change since v1:
	* Reorder patchs
	* Fix some clean style issue.

This patchset adds the device tree support for the Atmel NAND driver.

The first patch removes the NAND_ATMEL_PMECC config. With this removal
we can manage in a better way the device tree / non device tree probing of the driver, because the plateform data
and device tree share the same structure member and logics.

The second patch adds the has_pmecc on boards which need it.

The third patch retrieves the ecc_mode from the plateform data and remove this code:

        nand_chip->ecc.mode = NAND_ECC_SOFT;

which arbitrary sets the ecc.mode to NAND_ECC_SOFT and changes the value depending of the config and plateform data.
With this, we can use the same logics for device tree and non device tree probing of the driver.

The fourth patch adds the ecc_mode on boards which are missing it (boards which use NAND_ECC_SOFT).

The fifth patch adds the device tree in the atmel_nand driver.

Raphaël Poggi (5) :
        (1) mtd: nand: remove NAND_ATMEL_PMECC
        (2) board: atmel: initialise the has_pmecc member
        (3) mtd: atmel_nand: retrieve ecc_mode from pdata
        (4) board: atmel: initialise ecc_mode
        (5) mtd: atmel_nand: add support for device tree

 arch/arm/boards/at91sam9260ek/init.c    |    1 +
 arch/arm/boards/at91sam9261ek/init.c    |    1 +
 arch/arm/boards/at91sam9263ek/init.c    |    1 +
 arch/arm/boards/at91sam9m10g45ek/init.c |    1 +
 arch/arm/boards/at91sam9m10ihd/init.c   |    1 +
 arch/arm/boards/at91sam9n12ek/init.c    |    1 +
 arch/arm/boards/at91sam9x5ek/init.c     |    1 +
 arch/arm/boards/sama5d3_xplained/init.c |    1 +
 arch/arm/boards/sama5d3xek/init.c       |    1 +
 arch/arm/mach-at91/include/mach/board.h |    1 +
 drivers/mtd/nand/Kconfig                |    8 ---
 drivers/mtd/nand/atmel_nand.c           |  115 ++++++++++++++++++++++++++++++-
 12 files changed, 122 insertions(+), 11 deletions(-)


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC
  2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
@ 2014-08-05  9:14 ` Raphaël Poggi
  2014-08-06  4:08   ` Jean-Christophe PLAGNIOL-VILLARD
  2014-08-05  9:14 ` [PATCH 2/5] board: atmel: initialise the has_pmecc member Raphaël Poggi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

By removing this CONFIG_, we can use a structure member to retrieve the config,
either through the plateform data or through the device tree. So we can handle cases
when the driver is probed using device tree or not.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 arch/arm/mach-at91/include/mach/board.h |    1 +
 drivers/mtd/nand/Kconfig                |    8 --------
 drivers/mtd/nand/atmel_nand.c           |    2 +-
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index aa0fdae..e2307ed 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -63,6 +63,7 @@ struct atmel_nand_data {
 	u8		bus_width_16;	/* buswidth is 16 bit */
 	u8		ecc_mode;	/* NAND_ECC_* */
 	u8		on_flash_bbt;	/* Use flash based bbt */
+	u8		has_pmecc;	/* Use PMECC */
 	u8		bus_on_d0;
 
 	u8		pmecc_corr_cap;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 04fe3c8..d49eae3 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -95,14 +95,6 @@ config NAND_ATMEL
 	prompt "Atmel (AT91SAM9xxx) NAND driver"
 	depends on ARCH_AT91
 
-config NAND_ATMEL_PMECC
-	bool
-	prompt "PMECC support"
-	depends on NAND_ATMEL
-	select NAND_ECC_HW
-	help
-	  Support for PMECC present on the SoC sam9x5 and sam9n12
-
 config NAND_S3C24XX
 	bool
 	prompt "Samsung S3C24XX NAND driver"
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 337e225..3ec6450 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1219,7 +1219,7 @@ static int __init atmel_nand_probe(struct device_d *dev)
 
 	if (IS_ENABLED(CONFIG_NAND_ECC_HW) &&
 	    nand_chip->ecc.mode == NAND_ECC_HW) {
-		if (IS_ENABLED(CONFIG_NAND_ATMEL_PMECC))
+		if (pdata->has_pmecc)
 			res = atmel_pmecc_nand_init_params(dev, host);
 		else
 			res = atmel_hw_nand_init_params(dev, host);
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/5] board: atmel: initialise the has_pmecc member
  2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
  2014-08-05  9:14 ` [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC Raphaël Poggi
@ 2014-08-05  9:14 ` Raphaël Poggi
  2014-08-05  9:14 ` [PATCH 3/5] mtd: atmel_nand: retrieve ecc_mode from pdata Raphaël Poggi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

---
 arch/arm/boards/at91sam9n12ek/init.c    |    1 +
 arch/arm/boards/at91sam9x5ek/init.c     |    1 +
 arch/arm/boards/sama5d3_xplained/init.c |    1 +
 arch/arm/boards/sama5d3xek/init.c       |    1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm/boards/at91sam9n12ek/init.c b/arch/arm/boards/at91sam9n12ek/init.c
index a206d6b..818a598 100644
--- a/arch/arm/boards/at91sam9n12ek/init.c
+++ b/arch/arm/boards/at91sam9n12ek/init.c
@@ -47,6 +47,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PD5,
 	.enable_pin	= AT91_PIN_PD4,
+	.has_pmecc	= 1,
 	.ecc_mode	= NAND_ECC_HW,
 	.pmecc_sector_size = 512,
 	.pmecc_corr_cap = 2,
diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 62e5652..183ddc7 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -57,6 +57,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PD5,
 	.enable_pin	= AT91_PIN_PD4,
+	.has_pmecc	= 1,
 	.ecc_mode	= NAND_ECC_HW,
 	.pmecc_sector_size = 512,
 	.pmecc_corr_cap = 2,
diff --git a/arch/arm/boards/sama5d3_xplained/init.c b/arch/arm/boards/sama5d3_xplained/init.c
index ae18863..b182802 100644
--- a/arch/arm/boards/sama5d3_xplained/init.c
+++ b/arch/arm/boards/sama5d3_xplained/init.c
@@ -48,6 +48,7 @@ static struct atmel_nand_data nand_pdata = {
 	.rdy_pin	= -EINVAL,
 	.enable_pin	= -EINVAL,
 	.ecc_mode	= NAND_ECC_HW,
+	.has_pmecc	= 1,
 	.pmecc_sector_size = 512,
 	.pmecc_corr_cap = 4,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
index 743197f..49d2b37 100644
--- a/arch/arm/boards/sama5d3xek/init.c
+++ b/arch/arm/boards/sama5d3xek/init.c
@@ -63,6 +63,7 @@ static struct atmel_nand_data nand_pdata = {
 	.rdy_pin	= -EINVAL,
 	.enable_pin	= -EINVAL,
 	.ecc_mode	= NAND_ECC_HW,
+	.has_pmecc	= 1,
 	.pmecc_sector_size = 512,
 	.pmecc_corr_cap = 4,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/5] mtd: atmel_nand: retrieve ecc_mode from pdata
  2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
  2014-08-05  9:14 ` [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC Raphaël Poggi
  2014-08-05  9:14 ` [PATCH 2/5] board: atmel: initialise the has_pmecc member Raphaël Poggi
@ 2014-08-05  9:14 ` Raphaël Poggi
  2014-08-05  9:14 ` [PATCH 4/5] board: atmel: initialise ecc_mode Raphaël Poggi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

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>
---
 drivers/mtd/nand/atmel_nand.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 3ec6450..780d266 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1157,7 +1157,7 @@ static int __init atmel_nand_probe(struct device_d *dev)
 		}
 	}
 
-	nand_chip->ecc.mode = NAND_ECC_SOFT;
+	nand_chip->ecc.mode = pdata->ecc_mode;
 
 	if (IS_ENABLED(CONFIG_NAND_ECC_HW) &&
 	    pdata->ecc_mode == NAND_ECC_HW) {
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/5] board: atmel: initialise ecc_mode
  2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
                   ` (2 preceding siblings ...)
  2014-08-05  9:14 ` [PATCH 3/5] mtd: atmel_nand: retrieve ecc_mode from pdata Raphaël Poggi
@ 2014-08-05  9:14 ` Raphaël Poggi
  2014-09-01  9:54   ` Sascha Hauer
  2014-08-05  9:14 ` [PATCH 5/5] mtd: atmel_nand: add support for device tree Raphaël Poggi
  2014-08-05  9:40 ` [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
  5 siblings, 1 reply; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

This commit initialise the ecc_mode (NAND_ECC_SOFT) on atmel board init which missing it.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 arch/arm/boards/at91sam9260ek/init.c    |    1 +
 arch/arm/boards/at91sam9261ek/init.c    |    1 +
 arch/arm/boards/at91sam9263ek/init.c    |    1 +
 arch/arm/boards/at91sam9m10g45ek/init.c |    1 +
 arch/arm/boards/at91sam9m10ihd/init.c   |    1 +
 5 files changed, 5 insertions(+)

diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index 1298dde..76e0195 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -51,6 +51,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PC13,
 	.enable_pin	= AT91_PIN_PC14,
+	.ecc_mode	= NAND_ECC_SOFT,
 	.on_flash_bbt	= 1,
 };
 
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index 9ebc16a..7b8ce98 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -46,6 +46,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PC15,
 	.enable_pin	= AT91_PIN_PC14,
+	.ecc_mode	= NAND_ECC_SOFT,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
 	.bus_width_16	= 1,
 #else
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index 889b4c2..c8a9d5c 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -43,6 +43,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PA22,
 	.enable_pin	= AT91_PIN_PD15,
+	.ecc_mode	= NAND_ECC_SOFT,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
 	.bus_width_16	= 1,
 #else
diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c
index 6503ebb..cdd7806 100644
--- a/arch/arm/boards/at91sam9m10g45ek/init.c
+++ b/arch/arm/boards/at91sam9m10g45ek/init.c
@@ -67,6 +67,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PC8,
 	.enable_pin	= AT91_PIN_PC14,
+	.ecc_mode	= NAND_ECC_SOFT,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
 	.bus_width_16	= 1,
 #else
diff --git a/arch/arm/boards/at91sam9m10ihd/init.c b/arch/arm/boards/at91sam9m10ihd/init.c
index fc37af4..a432e5c 100644
--- a/arch/arm/boards/at91sam9m10ihd/init.c
+++ b/arch/arm/boards/at91sam9m10ihd/init.c
@@ -44,6 +44,7 @@ static struct atmel_nand_data nand_pdata = {
 	.det_pin	= -EINVAL,
 	.rdy_pin	= AT91_PIN_PC15,
 	.enable_pin	= AT91_PIN_PC14,
+	.ecc_mode	= NAND_ECC_SOFT,
 	.bus_width_16	= 0,
 	.on_flash_bbt	= 1,
 };
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 5/5] mtd: atmel_nand: add support for device tree
  2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
                   ` (3 preceding siblings ...)
  2014-08-05  9:14 ` [PATCH 4/5] board: atmel: initialise ecc_mode Raphaël Poggi
@ 2014-08-05  9:14 ` Raphaël Poggi
  2014-08-05  9:40 ` [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
  5 siblings, 0 replies; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/mtd/nand/atmel_nand.c |  111 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 780d266..a5d05d8 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -28,6 +28,10 @@
 #include <init.h>
 #include <gpio.h>
 
+#include <of.h>
+#include <of_gpio.h>
+#include <of_mtd.h>
+
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 
@@ -1038,6 +1042,92 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
 #endif
 }
 
+static int atmel_nand_of_init(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;
+
+	if (!IS_ENABLED(CONFIG_OFDEVICE))
+		return -ENOSYS;
+
+	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);
+
+	if (of_get_nand_bus_width(np) == 16)
+		board->bus_width_16 = 1;
+
+	board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
+	board->enable_pin = of_get_gpio(np, 1);
+	board->det_pin = of_get_gpio(np, 2);
+
+	board->has_pmecc = of_property_read_bool(np, "atmel,has-pmecc");
+
+	if (!(board->ecc_mode == NAND_ECC_HW) || !board->has_pmecc)
+		return 0;	/* Not using PMECC */
+
+	/* use PMECC, get correction capability, sector size and lookup
+	* table offset.
+	* If correction bits and sector size are not specified, then
+	*   find
+	* them from NAND ONFI parameters.
+	*/
+	if (of_property_read_u32(np, "atmel,pmecc-cap", &val) == 0) {
+		if ((val != 2) && (val != 4) && (val != 8) && (val != 12) && (val != 24)) {
+			dev_err(host->dev, "Unsupported PMECC correction capability: %d"
+					" should be 2, 4, 8, 12 or 24\n", val);
+			return -EINVAL;
+		}
+
+		board->pmecc_corr_cap = (u8)val;
+	}
+
+	if (of_property_read_u32(np, "atmel,pmecc-sector-size", &val) == 0) {
+		if ((val != 512) && (val != 1024)) {
+				dev_err(host->dev, "Unsupported PMECC sector size: %d"
+					" should be 512 or 1024 bytes\n", val);
+			return -EINVAL;
+		}
+
+		board->pmecc_sector_size = (u16)val;
+	}
+
+	if (of_property_read_u32_array(np, "atmel,pmecc-lookup-table-offset", offset, 2) != 0) {
+		dev_err(host->dev, "Cannot get PMECC lookup table offset\n");
+		return -EINVAL;
+	}
+
+	if (!offset[0] && !offset[1]) {
+		dev_err(host->dev, "Invalid PMECC lookup table offset\n");
+		return -EINVAL;
+	}
+
+	board->pmecc_lookup_table_offset = (board->pmecc_sector_size == 512) ? offset[0] : offset[1];
+
+	return 0;
+}
+
 static int atmel_hw_nand_init_params(struct device_d *dev,
 					 struct atmel_nand_host *host)
 {
@@ -1093,7 +1183,7 @@ static int atmel_hw_nand_init_params(struct device_d *dev,
  */
 static int __init atmel_nand_probe(struct device_d *dev)
 {
-	struct atmel_nand_data *pdata = dev->platform_data;
+	struct atmel_nand_data *pdata = NULL;
 	struct atmel_nand_host *host;
 	struct mtd_info *mtd;
 	struct nand_chip *nand_chip;
@@ -1111,6 +1201,18 @@ static int __init atmel_nand_probe(struct device_d *dev)
 	host->board = pdata;
 	host->dev = dev;
 
+	if (dev->device_node) {
+		res = atmel_nand_of_init(host, dev->device_node);
+		if (res)
+			goto err_no_card;
+	} else {
+		pdata = kzalloc(sizeof(struct atmel_nand_data), GFP_KERNEL);
+		if (!pdata)
+			return -ENOMEM;
+
+		memcpy(host->board, dev->platform_data, sizeof(struct atmel_nand_data));
+	}
+
 	nand_chip->priv = host;		/* link the private data structures */
 	mtd->priv = nand_chip;
 	mtd->parent = dev;
@@ -1245,13 +1347,20 @@ err_hw_ecc:
 err_scan_ident:
 err_no_card:
 	atmel_nand_disable(host);
+	kfree(pdata);
 	kfree(host);
 	return res;
 }
 
+static struct of_device_id atmel_nand_dt_ids[] = {
+	{ .compatible = "atmel,at91rm9200-nand" },
+	{ /* sentinel */ }
+};
+
 static struct driver_d atmel_nand_driver = {
 	.name	= "atmel_nand",
 	.probe	= atmel_nand_probe,
+	.of_compatible	= DRV_OF_COMPAT(atmel_nand_dt_ids),
 };
 device_platform_driver(atmel_nand_driver);
 
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/5] Add device tree support of Atmel NAND driver
  2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
                   ` (4 preceding siblings ...)
  2014-08-05  9:14 ` [PATCH 5/5] mtd: atmel_nand: add support for device tree Raphaël Poggi
@ 2014-08-05  9:40 ` Raphaël Poggi
  5 siblings, 0 replies; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-05  9:40 UTC (permalink / raw)
  To: barebox

I forget to add a "v2" tag on the patches, do I need to resend all the serie ?

Thanks,
Raphaël Poggi

2014-08-05 11:14 GMT+02:00 Raphaël Poggi <poggi.raph@gmail.com>:
> Change since v1:
>         * Reorder patchs
>         * Fix some clean style issue.
>
> This patchset adds the device tree support for the Atmel NAND driver.
>
> The first patch removes the NAND_ATMEL_PMECC config. With this removal
> we can manage in a better way the device tree / non device tree probing of the driver, because the plateform data
> and device tree share the same structure member and logics.
>
> The second patch adds the has_pmecc on boards which need it.
>
> The third patch retrieves the ecc_mode from the plateform data and remove this code:
>
>         nand_chip->ecc.mode = NAND_ECC_SOFT;
>
> which arbitrary sets the ecc.mode to NAND_ECC_SOFT and changes the value depending of the config and plateform data.
> With this, we can use the same logics for device tree and non device tree probing of the driver.
>
> The fourth patch adds the ecc_mode on boards which are missing it (boards which use NAND_ECC_SOFT).
>
> The fifth patch adds the device tree in the atmel_nand driver.
>
> Raphaël Poggi (5) :
>         (1) mtd: nand: remove NAND_ATMEL_PMECC
>         (2) board: atmel: initialise the has_pmecc member
>         (3) mtd: atmel_nand: retrieve ecc_mode from pdata
>         (4) board: atmel: initialise ecc_mode
>         (5) mtd: atmel_nand: add support for device tree
>
>  arch/arm/boards/at91sam9260ek/init.c    |    1 +
>  arch/arm/boards/at91sam9261ek/init.c    |    1 +
>  arch/arm/boards/at91sam9263ek/init.c    |    1 +
>  arch/arm/boards/at91sam9m10g45ek/init.c |    1 +
>  arch/arm/boards/at91sam9m10ihd/init.c   |    1 +
>  arch/arm/boards/at91sam9n12ek/init.c    |    1 +
>  arch/arm/boards/at91sam9x5ek/init.c     |    1 +
>  arch/arm/boards/sama5d3_xplained/init.c |    1 +
>  arch/arm/boards/sama5d3xek/init.c       |    1 +
>  arch/arm/mach-at91/include/mach/board.h |    1 +
>  drivers/mtd/nand/Kconfig                |    8 ---
>  drivers/mtd/nand/atmel_nand.c           |  115 ++++++++++++++++++++++++++++++-
>  12 files changed, 122 insertions(+), 11 deletions(-)
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC
  2014-08-05  9:14 ` [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC Raphaël Poggi
@ 2014-08-06  4:08   ` Jean-Christophe PLAGNIOL-VILLARD
  2014-08-06  7:21     ` Raphaël Poggi
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-08-06  4:08 UTC (permalink / raw)
  To: Rapha??l Poggi; +Cc: barebox

On 11:14 Tue 05 Aug     , Rapha??l Poggi wrote:
> By removing this CONFIG_, we can use a structure member to retrieve the config,
> either through the plateform data or through the device tree. So we can handle cases
> when the driver is probed using device tree or not.
NACK

this is use to reduce barebox size

keep the NAND_ATMEL_PMECC

so we choose to enable it or not

Best Regards,
J.
> 
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
> ---
>  arch/arm/mach-at91/include/mach/board.h |    1 +
>  drivers/mtd/nand/Kconfig                |    8 --------
>  drivers/mtd/nand/atmel_nand.c           |    2 +-
>  3 files changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
> index aa0fdae..e2307ed 100644
> --- a/arch/arm/mach-at91/include/mach/board.h
> +++ b/arch/arm/mach-at91/include/mach/board.h
> @@ -63,6 +63,7 @@ struct atmel_nand_data {
>  	u8		bus_width_16;	/* buswidth is 16 bit */
>  	u8		ecc_mode;	/* NAND_ECC_* */
>  	u8		on_flash_bbt;	/* Use flash based bbt */
> +	u8		has_pmecc;	/* Use PMECC */
>  	u8		bus_on_d0;
>  
>  	u8		pmecc_corr_cap;
> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
> index 04fe3c8..d49eae3 100644
> --- a/drivers/mtd/nand/Kconfig
> +++ b/drivers/mtd/nand/Kconfig
> @@ -95,14 +95,6 @@ config NAND_ATMEL
>  	prompt "Atmel (AT91SAM9xxx) NAND driver"
>  	depends on ARCH_AT91
>  
> -config NAND_ATMEL_PMECC
> -	bool
> -	prompt "PMECC support"
> -	depends on NAND_ATMEL
> -	select NAND_ECC_HW
> -	help
> -	  Support for PMECC present on the SoC sam9x5 and sam9n12
> -
>  config NAND_S3C24XX
>  	bool
>  	prompt "Samsung S3C24XX NAND driver"
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 337e225..3ec6450 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -1219,7 +1219,7 @@ static int __init atmel_nand_probe(struct device_d *dev)
>  
>  	if (IS_ENABLED(CONFIG_NAND_ECC_HW) &&
>  	    nand_chip->ecc.mode == NAND_ECC_HW) {
> -		if (IS_ENABLED(CONFIG_NAND_ATMEL_PMECC))
> +		if (pdata->has_pmecc)
>  			res = atmel_pmecc_nand_init_params(dev, host);
>  		else
>  			res = atmel_hw_nand_init_params(dev, host);
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC
  2014-08-06  4:08   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2014-08-06  7:21     ` Raphaël Poggi
  2014-09-01  9:49       ` Sascha Hauer
  0 siblings, 1 reply; 11+ messages in thread
From: Raphaël Poggi @ 2014-08-06  7:21 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Ok, I did it because we need a structure member to retrieve
"atmel,has-pmecc" from device tree.

Is this ok if I add the has_pmecc member (feed by atmel_nand_of_init),
let the NAND_ATMEL_PMECC, and the if will be like :

if (IS_ENABLED(CONFIG_NAND_ATMEL_PMECC) || pdata->has_pmecc)

With this we can handle device tree/non device tree probing.

Or maybe you have a better idea.

Best regards,
Raphaël Poggi

2014-08-06 6:08 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com>:
> On 11:14 Tue 05 Aug     , Rapha??l Poggi wrote:
>> By removing this CONFIG_, we can use a structure member to retrieve the config,
>> either through the plateform data or through the device tree. So we can handle cases
>> when the driver is probed using device tree or not.
> NACK
>
> this is use to reduce barebox size
>
> keep the NAND_ATMEL_PMECC
>
> so we choose to enable it or not
>
> Best Regards,
> J.
>>
>> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
>> ---
>>  arch/arm/mach-at91/include/mach/board.h |    1 +
>>  drivers/mtd/nand/Kconfig                |    8 --------
>>  drivers/mtd/nand/atmel_nand.c           |    2 +-
>>  3 files changed, 2 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
>> index aa0fdae..e2307ed 100644
>> --- a/arch/arm/mach-at91/include/mach/board.h
>> +++ b/arch/arm/mach-at91/include/mach/board.h
>> @@ -63,6 +63,7 @@ struct atmel_nand_data {
>>       u8              bus_width_16;   /* buswidth is 16 bit */
>>       u8              ecc_mode;       /* NAND_ECC_* */
>>       u8              on_flash_bbt;   /* Use flash based bbt */
>> +     u8              has_pmecc;      /* Use PMECC */
>>       u8              bus_on_d0;
>>
>>       u8              pmecc_corr_cap;
>> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
>> index 04fe3c8..d49eae3 100644
>> --- a/drivers/mtd/nand/Kconfig
>> +++ b/drivers/mtd/nand/Kconfig
>> @@ -95,14 +95,6 @@ config NAND_ATMEL
>>       prompt "Atmel (AT91SAM9xxx) NAND driver"
>>       depends on ARCH_AT91
>>
>> -config NAND_ATMEL_PMECC
>> -     bool
>> -     prompt "PMECC support"
>> -     depends on NAND_ATMEL
>> -     select NAND_ECC_HW
>> -     help
>> -       Support for PMECC present on the SoC sam9x5 and sam9n12
>> -
>>  config NAND_S3C24XX
>>       bool
>>       prompt "Samsung S3C24XX NAND driver"
>> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
>> index 337e225..3ec6450 100644
>> --- a/drivers/mtd/nand/atmel_nand.c
>> +++ b/drivers/mtd/nand/atmel_nand.c
>> @@ -1219,7 +1219,7 @@ static int __init atmel_nand_probe(struct device_d *dev)
>>
>>       if (IS_ENABLED(CONFIG_NAND_ECC_HW) &&
>>           nand_chip->ecc.mode == NAND_ECC_HW) {
>> -             if (IS_ENABLED(CONFIG_NAND_ATMEL_PMECC))
>> +             if (pdata->has_pmecc)
>>                       res = atmel_pmecc_nand_init_params(dev, host);
>>               else
>>                       res = atmel_hw_nand_init_params(dev, host);
>> --
>> 1.7.9.5
>>
>>
>> _______________________________________________
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC
  2014-08-06  7:21     ` Raphaël Poggi
@ 2014-09-01  9:49       ` Sascha Hauer
  0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2014-09-01  9:49 UTC (permalink / raw)
  To: Raphaël Poggi; +Cc: barebox

On Wed, Aug 06, 2014 at 09:21:52AM +0200, Raphaël Poggi wrote:
> Ok, I did it because we need a structure member to retrieve
> "atmel,has-pmecc" from device tree.
> 
> Is this ok if I add the has_pmecc member (feed by atmel_nand_of_init),
> let the NAND_ATMEL_PMECC, and the if will be like :
> 
> if (IS_ENABLED(CONFIG_NAND_ATMEL_PMECC) || pdata->has_pmecc)

Shouldn't this be && instead of ||?

Otherwise this approach should be fine.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] board: atmel: initialise ecc_mode
  2014-08-05  9:14 ` [PATCH 4/5] board: atmel: initialise ecc_mode Raphaël Poggi
@ 2014-09-01  9:54   ` Sascha Hauer
  0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2014-09-01  9:54 UTC (permalink / raw)
  To: Raphaël Poggi; +Cc: barebox

On Tue, Aug 05, 2014 at 11:14:48AM +0200, Raphaël Poggi wrote:
> This commit initialise the ecc_mode (NAND_ECC_SOFT) on atmel board init which missing it.
> 
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
> ---
>  arch/arm/boards/at91sam9260ek/init.c    |    1 +
>  arch/arm/boards/at91sam9261ek/init.c    |    1 +
>  arch/arm/boards/at91sam9263ek/init.c    |    1 +
>  arch/arm/boards/at91sam9m10g45ek/init.c |    1 +
>  arch/arm/boards/at91sam9m10ihd/init.c   |    1 +
>  5 files changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
> index 1298dde..76e0195 100644
> --- a/arch/arm/boards/at91sam9260ek/init.c
> +++ b/arch/arm/boards/at91sam9260ek/init.c
> @@ -51,6 +51,7 @@ static struct atmel_nand_data nand_pdata = {
>  	.det_pin	= -EINVAL,
>  	.rdy_pin	= AT91_PIN_PC13,
>  	.enable_pin	= AT91_PIN_PC14,
> +	.ecc_mode	= NAND_ECC_SOFT,

You have to combine 3/5 and 4/5 in a single patch. Otherwise the ecc
mode is not initialized correctly between both patches.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-09-01  9:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05  9:14 [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi
2014-08-05  9:14 ` [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC Raphaël Poggi
2014-08-06  4:08   ` Jean-Christophe PLAGNIOL-VILLARD
2014-08-06  7:21     ` Raphaël Poggi
2014-09-01  9:49       ` Sascha Hauer
2014-08-05  9:14 ` [PATCH 2/5] board: atmel: initialise the has_pmecc member Raphaël Poggi
2014-08-05  9:14 ` [PATCH 3/5] mtd: atmel_nand: retrieve ecc_mode from pdata Raphaël Poggi
2014-08-05  9:14 ` [PATCH 4/5] board: atmel: initialise ecc_mode Raphaël Poggi
2014-09-01  9:54   ` Sascha Hauer
2014-08-05  9:14 ` [PATCH 5/5] mtd: atmel_nand: add support for device tree Raphaël Poggi
2014-08-05  9:40 ` [PATCH v2 0/5] Add device tree support of Atmel NAND driver Raphaël Poggi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox