* [PATCH 1/2] atmel_nand: at91/avr32/: Replace cpu_is_at32ap7000() with a nand platform data
2013-05-09 7:34 [PATCH 0/2] atmel_nand: remove cpu_is_xxx() in nand driver Josh Wu
@ 2013-05-09 7:34 ` Josh Wu
2013-05-09 18:12 ` Hans-Christian Egtvedt
2013-05-09 7:34 ` [PATCH 2/2] mtd: atmel_nand: add a new dt binding item for nand dma support Josh Wu
2013-07-01 6:25 ` [PATCH 0/2] atmel_nand: remove cpu_is_xxx() in nand driver Artem Bityutskiy
2 siblings, 1 reply; 5+ messages in thread
From: Josh Wu @ 2013-05-09 7:34 UTC (permalink / raw)
To: linux-arm-kernel
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.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
---
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 b323d8d..697ef58 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1979,6 +1979,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 */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 1/2] atmel_nand: at91/avr32/: Replace cpu_is_at32ap7000() with a nand platform data
2013-05-09 7:34 ` [PATCH 1/2] atmel_nand: at91/avr32/: Replace cpu_is_at32ap7000() with a nand platform data Josh Wu
@ 2013-05-09 18:12 ` Hans-Christian Egtvedt
0 siblings, 0 replies; 5+ messages in thread
From: Hans-Christian Egtvedt @ 2013-05-09 18:12 UTC (permalink / raw)
To: linux-arm-kernel
Around Thu 09 May 2013 15:34:54 +0800 or thereabout, Josh Wu wrote:
> 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.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
> ---
> 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(-)
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.
<snipp diff>
--
HcE
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] mtd: atmel_nand: add a new dt binding item for nand dma support
2013-05-09 7:34 [PATCH 0/2] atmel_nand: remove cpu_is_xxx() in nand driver Josh Wu
2013-05-09 7:34 ` [PATCH 1/2] atmel_nand: at91/avr32/: Replace cpu_is_at32ap7000() with a nand platform data Josh Wu
@ 2013-05-09 7:34 ` Josh Wu
2013-07-01 6:25 ` [PATCH 0/2] atmel_nand: remove cpu_is_xxx() in nand driver Artem Bityutskiy
2 siblings, 0 replies; 5+ messages in thread
From: Josh Wu @ 2013-05-09 7:34 UTC (permalink / raw)
To: linux-arm-kernel
This patch will set the nand dma support in dts. Since we will not use
cpu_is_xxx() in nand driver. We needn't include the mach/cpu.h any more.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
.../devicetree/bindings/mtd/atmel-nand.txt | 1 +
drivers/mtd/nand/atmel_nand.c | 11 +++--------
include/linux/platform_data/atmel.h | 1 +
3 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
index d555421..b6eb484 100644
--- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
@@ -15,6 +15,7 @@ Required properties:
optional gpio and may be set to 0 if not present.
Optional properties:
+- atmel,nand-has-dma : boolean to support dma transfer for nand read/write.
- nand-ecc-mode : String, operation mode of the NAND ecc mode, soft by default.
Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
"soft_bch".
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 7bf912b..61d3869 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -43,8 +43,6 @@
#include <linux/platform_data/atmel.h>
#include <linux/pinctrl/consumer.h>
-#include <mach/cpu.h>
-
static int use_dma = 1;
module_param(use_dma, int, 0);
@@ -128,11 +126,6 @@ struct atmel_nand_host {
static struct nand_ecclayout atmel_pmecc_oobinfo;
-static int cpu_has_dma(void)
-{
- return cpu_is_at91sam9rl() || cpu_is_at91sam9g45();
-}
-
/*
* Enable NAND.
*/
@@ -1336,6 +1329,8 @@ static int atmel_of_init_port(struct atmel_nand_host *host,
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;
@@ -1600,7 +1595,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
}
- if (!cpu_has_dma())
+ if (!host->board.has_dma)
use_dma = 0;
if (use_dma) {
diff --git a/include/linux/platform_data/atmel.h b/include/linux/platform_data/atmel.h
index 59f558d..cea9f70 100644
--- a/include/linux/platform_data/atmel.h
+++ b/include/linux/platform_data/atmel.h
@@ -71,6 +71,7 @@ struct atmel_nand_data {
u8 on_flash_bbt; /* bbt on flash */
struct mtd_partition *parts;
unsigned int num_parts;
+ bool has_dma; /* support dma transfer */
/* default is false, only for at32ap7000 chip is true */
bool need_reset_workaround;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 0/2] atmel_nand: remove cpu_is_xxx() in nand driver
2013-05-09 7:34 [PATCH 0/2] atmel_nand: remove cpu_is_xxx() in nand driver Josh Wu
2013-05-09 7:34 ` [PATCH 1/2] atmel_nand: at91/avr32/: Replace cpu_is_at32ap7000() with a nand platform data Josh Wu
2013-05-09 7:34 ` [PATCH 2/2] mtd: atmel_nand: add a new dt binding item for nand dma support Josh Wu
@ 2013-07-01 6:25 ` Artem Bityutskiy
2 siblings, 0 replies; 5+ messages in thread
From: Artem Bityutskiy @ 2013-07-01 6:25 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, 2013-05-09 at 15:34 +0800, Josh Wu wrote:
> avoid to use cpu_is_xxx() macro in driver, we use platform data and dts
> for the different cpu.
>
> Josh Wu (2):
> atmel_nand: at91/avr32/: Replace cpu_is_at32ap7000() with a nand
> platform data
> mtd: atmel_nand: add a new dt binding item for nand dma support
Pushed these 2 to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 5+ messages in thread