mtd: atmel_nand: replace cpu_is_at32ap7000() with a nand platform data

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Aug 5 16:59:04 EDT 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=71b94e2e866aa35f40945d9e820fc3214b792d1f
Commit:     71b94e2e866aa35f40945d9e820fc3214b792d1f
Parent:     d1cb556c3feb238f11dc47f8fa56df7880022908
Author:     Josh Wu <josh.wu at atmel.com>
AuthorDate: Thu May 9 15:34:54 2013 +0800
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Aug 5 20:55:42 2013 +0100

    mtd: atmel_nand: replace cpu_is_at32ap7000() with a nand platform data
    
    The nand driver use cpu_is_at32ap7000() macro for a workaround. For the
    multi-platform support, we will remove this cpu_is_xxx() macro.
    
    This patch adds a boolean variable need_reset_workaround in structure
    atmel_nand_data. Using this variable we can remove cpu_is_at32ap7000() macro.
    
    Hans-Christian: Feel free to push this through the mtd tree, if they won't
    accept it I'm working on getting my workflow up on the linux-avr32.git tree.
    
    Signed-off-by: Josh Wu <josh.wu at atmel.com>
    Acked-by: Hans-Christian Egtvedt <egtvedt at samfundet.no>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 arch/avr32/mach-at32ap/at32ap700x.c |  3 +++
 drivers/mtd/nand/atmel_nand.c       | 13 ++++++-------
 include/linux/platform_data/atmel.h |  3 +++
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 7f8759a..a68f3cf 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1983,6 +1983,9 @@ at32_add_device_nand(unsigned int id, struct atmel_nand_data *data)
 				ARRAY_SIZE(smc_cs3_resource)))
 		goto fail;
 
+	/* For at32ap7000, we use the reset workaround for nand driver */
+	data->need_reset_workaround = true;
+
 	if (platform_device_add_data(pdev, data,
 				sizeof(struct atmel_nand_data)))
 		goto fail;
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 2d23d29..7bf912b 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1174,10 +1174,9 @@ static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 	 * Workaround: Reset the parity registers before reading the
 	 * actual data.
 	 */
-	if (cpu_is_at32ap7000()) {
-		struct atmel_nand_host *host = chip->priv;
+	struct atmel_nand_host *host = chip->priv;
+	if (host->board.need_reset_workaround)
 		ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
-	}
 
 	/* read the page */
 	chip->read_buf(mtd, p, eccsize);
@@ -1298,11 +1297,11 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
  */
 static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
 {
-	if (cpu_is_at32ap7000()) {
-		struct nand_chip *nand_chip = mtd->priv;
-		struct atmel_nand_host *host = nand_chip->priv;
+	struct nand_chip *nand_chip = mtd->priv;
+	struct atmel_nand_host *host = nand_chip->priv;
+
+	if (host->board.need_reset_workaround)
 		ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
-	}
 }
 
 #if defined(CONFIG_OF)
diff --git a/include/linux/platform_data/atmel.h b/include/linux/platform_data/atmel.h
index 6a293b7..59f558d 100644
--- a/include/linux/platform_data/atmel.h
+++ b/include/linux/platform_data/atmel.h
@@ -71,6 +71,9 @@ struct atmel_nand_data {
 	u8		on_flash_bbt;		/* bbt on flash */
 	struct mtd_partition *parts;
 	unsigned int	num_parts;
+
+	/* default is false, only for at32ap7000 chip is true */
+	bool		need_reset_workaround;
 };
 
  /* Serial */



More information about the linux-mtd-cvs mailing list