ATMEL: fix nand ecc support
Subsystems (8)
PATCH 1/6 ATMEL: fix nand ecc support
so we can now choose for the board the ecc mode (ecc soft, soft bch, no ecc and hardware)
set ecc mode in the boards to soft as currently in the driver
move platform data to a common headerinclude/linux/platform_data/atmel_nand.h
--- arch/arm/mach-at91/board-afeb-9260v1.c | 1 + arch/arm/mach-at91/board-cam60.c | 1 + arch/arm/mach-at91/board-cap9adk.c | 1 + arch/arm/mach-at91/board-cpu9krea.c | 1 + arch/arm/mach-at91/board-dt.c | 1 + arch/arm/mach-at91/board-kb9202.c | 1 + arch/arm/mach-at91/board-neocore926.c | 1 + arch/arm/mach-at91/board-qil-a9260.c | 1 + arch/arm/mach-at91/board-rm9200dk.c | 1 + arch/arm/mach-at91/board-sam9-l9260.c | 1 + arch/arm/mach-at91/board-sam9260ek.c | 1 + arch/arm/mach-at91/board-sam9261ek.c | 1 + arch/arm/mach-at91/board-sam9263ek.c | 1 + arch/arm/mach-at91/board-sam9g20ek.c | 1 + arch/arm/mach-at91/board-sam9m10g45ek.c | 1 + arch/arm/mach-at91/board-sam9rlek.c | 1 + arch/arm/mach-at91/board-snapper9260.c | 1 + arch/arm/mach-at91/board-stamp9g20.c | 1 + arch/arm/mach-at91/board-usb-a926x.c | 1 + arch/arm/mach-at91/board-yl-9200.c | 1 + arch/arm/mach-at91/include/mach/board.h | 13 +------------ arch/avr32/boards/atngw100/setup.c | 1 + arch/avr32/boards/atstk1000/atstk1002.c | 1 + arch/avr32/mach-at32ap/include/mach/board.h | 13 +------------ drivers/mtd/nand/atmel_nand.c | 25 ++++++------------------- include/linux/platform_data/atmel.h | 26 ++++++++++++++++++++++++++ 26 files changed, 56 insertions(+), 43 deletions(-) create mode 100644 include/linux/platform_data/atmel.h
arch/arm/mach-at91/board-afeb-9260v1.c +1 -0
@@ -138,6 +138,7 @@ static struct atmel_nand_data __initdata afeb9260_nand_data = { .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, .bus_width_16 = 0, + .ecc_mode = NAND_ECC_SOFT, .parts = afeb9260_nand_partition, .num_parts = ARRAY_SIZE(afeb9260_nand_partition), .det_pin = -EINVAL,
arch/arm/mach-at91/board-cam60.c +1 -0
@@ -140,6 +140,7 @@ static struct atmel_nand_data __initdata cam60_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PA9, .enable_pin = AT91_PIN_PA7, + .ecc_mode = NAND_ECC_SOFT, .parts = cam60_nand_partition, .num_parts = ARRAY_SIZE(cam60_nand_partition), };
arch/arm/mach-at91/board-cap9adk.c +1 -0
@@ -178,6 +178,7 @@ static struct atmel_nand_data __initdata cap9adk_nand_data = { .det_pin = -EINVAL, .rdy_pin = -EINVAL, .enable_pin = AT91_PIN_PD15, + .ecc_mode = NAND_ECC_SOFT, .parts = cap9adk_nand_partitions, .num_parts = ARRAY_SIZE(cap9adk_nand_partitions), };
arch/arm/mach-at91/board-cpu9krea.c +1 -0
@@ -116,6 +116,7 @@ static struct atmel_nand_data __initdata cpu9krea_nand_data = { .enable_pin = AT91_PIN_PC14, .bus_width_16 = 0, .det_pin = -EINVAL, + .ecc_mode = NAND_ECC_SOFT, };#ifdef CONFIG_MACH_CPU9260
arch/arm/mach-at91/board-dt.c +1 -0
@@ -53,6 +53,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC8, .enable_pin = AT91_PIN_PC14, + .ecc_mode = NAND_ECC_SOFT, };static struct sam9_smc_config __initdata ek_nand_smc_config = {
arch/arm/mach-at91/board-kb9202.c +1 -0
@@ -107,6 +107,7 @@ static struct atmel_nand_data __initdata kb9202_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC29, .enable_pin = AT91_PIN_PC28, + .ecc_mode = NAND_ECC_SOFT, .parts = kb9202_nand_partition, .num_parts = ARRAY_SIZE(kb9202_nand_partition), };
arch/arm/mach-at91/board-neocore926.c +1 -0
@@ -190,6 +190,7 @@ static struct atmel_nand_data __initdata neocore926_nand_data = { .rdy_pin = AT91_PIN_PB19, .rdy_pin_active_low = 1, .enable_pin = AT91_PIN_PD15, + .ecc_mode = NAND_ECC_SOFT, .parts = neocore926_nand_partition, .num_parts = ARRAY_SIZE(neocore926_nand_partition), .det_pin = -EINVAL,
arch/arm/mach-at91/board-qil-a9260.c +1 -0
@@ -138,6 +138,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-rm9200dk.c +1 -0
@@ -149,6 +149,7 @@ static struct atmel_nand_data __initdata dk_nand_data = { .det_pin = AT91_PIN_PB1, .rdy_pin = AT91_PIN_PC2, .enable_pin = -EINVAL, + .ecc_mode = NAND_ECC_SOFT, .parts = dk_nand_partition, .num_parts = ARRAY_SIZE(dk_nand_partition), };
arch/arm/mach-at91/board-sam9-l9260.c +1 -0
@@ -139,6 +139,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9260ek.c +1 -0
@@ -181,6 +181,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9261ek.c +1 -0
@@ -187,6 +187,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC15, .enable_pin = AT91_PIN_PC14, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9263ek.c +1 -0
@@ -187,6 +187,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PA22, .enable_pin = AT91_PIN_PD15, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9g20ek.c +1 -0
@@ -166,6 +166,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, .det_pin = -EINVAL, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9m10g45ek.c +1 -0
@@ -146,6 +146,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PC8, .enable_pin = AT91_PIN_PC14, .det_pin = -EINVAL, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9rlek.c +1 -0
@@ -94,6 +94,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PD17, .enable_pin = AT91_PIN_PB6, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-snapper9260.c +1 -0
@@ -110,6 +110,7 @@ static struct atmel_nand_data __initdata snapper9260_nand_data = { .bus_width_16 = 0, .enable_pin = -EINVAL, .det_pin = -EINVAL, + .ecc_mode = NAND_ECC_SOFT, };static struct sam9_smc_config __initdata snapper9260_nand_smc_config = {
arch/arm/mach-at91/board-stamp9g20.c +1 -0
@@ -86,6 +86,7 @@ static struct atmel_nand_data __initdata nand_data = { .enable_pin = AT91_PIN_PC14, .bus_width_16 = 0, .det_pin = -EINVAL, + .ecc_mode = NAND_ECC_SOFT, };static struct sam9_smc_config __initdata nand_smc_config = {
arch/arm/mach-at91/board-usb-a926x.c +1 -0
@@ -198,6 +198,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PA22, .enable_pin = AT91_PIN_PD15, + .ecc_mode = NAND_ECC_SOFT, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-yl-9200.c +1 -0
@@ -181,6 +181,7 @@ static struct atmel_nand_data __initdata yl9200_nand_data = { .det_pin = -EINVAL, .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */ .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */ + .ecc_mode = NAND_ECC_SOFT, .parts = yl9200_nand_partition, .num_parts = ARRAY_SIZE(yl9200_nand_partition), };
arch/arm/mach-at91/include/mach/board.h +1 -12
@@ -41,6 +41,7 @@#include <sound/atmel-ac97c.h> #include <linux/serial.h> #include <linux/platform_data/macb.h> +#include <linux/platform_data/atmel.h> /* USB Device */ struct at91_udc_data {
@@ -98,18 +99,6 @@ extern void __init at91_add_device_usbh(struct at91_usbh_data *data);extern void __init at91_add_device_usbh_ohci (struct at91_usbh_data *data);extern void __init at91_add_device_usbh_ehci (struct at91_usbh_data *data); -/* NAND / SmartMedia */ -struct atmel_nand_data { -int enable_pin;/* chip enable */ -int det_pin;/* card detect */ -int rdy_pin;/* ready/busy */ -u8 rdy_pin_active_low;/* rdy_pin value is inverted */ -u8 ale;/* address line number connected to ALE */ -u8 cle;/* address line number connected to CLE */ -u8 bus_width_16;/* buswidth is 16 bit */ -struct mtd_partition *parts; -unsigned int num_parts; -};extern void __init at91_add_device_nand (struct atmel_nand_data *data);/* I2C*/
arch/avr32/boards/atngw100/setup.c +1 -0
@@ -97,6 +97,7 @@ static struct atmel_nand_data atngw100mkii_nand_data __initdata = { .rdy_pin = GPIO_PIN_PB(28), .enable_pin = GPIO_PIN_PE(23), .bus_width_16 = true, + .ecc_mode = NAND_ECC_SOFT, .parts = nand_partitions, .num_parts = ARRAY_SIZE(nand_partitions), };
arch/avr32/boards/atstk1000/atstk1002.c +1 -0
@@ -95,6 +95,7 @@ static struct atmel_nand_data atstk1006_nand_data __initdata = { .ale = 22, .rdy_pin = GPIO_PIN_PB(30), .enable_pin = GPIO_PIN_PB(29), + .ecc_mode = NAND_ECC_SOFT, .parts = nand_partitions, .num_parts = ARRAY_SIZE(num_partitions), };
arch/avr32/mach-at32ap/include/mach/board.h +1 -12
@@ -7,6 +7,7 @@#include <linux/types.h> #include <linux/serial.h> #include <linux/platform_data/macb.h> +#include <linux/platform_data/atmel_nand.h> #define GPIO_PIN_NONE (-1)
@@ -116,18 +117,6 @@ struct platform_device * at32_add_device_cf(unsigned int id, unsigned int extint, struct cf_platform_data *data); -/* NAND / SmartMedia */ -struct atmel_nand_data { -int enable_pin;/* chip enable */ -int det_pin;/* card detect */ -int rdy_pin;/* ready/busy */ -u8 rdy_pin_active_low;/* rdy_pin value is inverted */ -u8 ale;/* address line number connected to ALE */ -u8 cle;/* address line number connected to CLE */ -u8 bus_width_16;/* buswidth is 16 bit */ -struct mtd_partition *parts; -unsigned int num_parts; -};struct platform_device *at32_add_device_nand (unsigned int id,struct atmel_nand_data *data);
drivers/mtd/nand/atmel_nand.c +6 -19
@@ -34,22 +34,10 @@#include <linux/dmaengine.h> #include <linux/gpio.h> #include <linux/io.h> +#include <linux/platform_data/atmel.h> -#include <mach/board.h> #include <mach/cpu.h> -#ifdef CONFIG_MTD_NAND_ATMEL_ECC_HW -#define hard_ecc 1 -#else -#define hard_ecc 0 -#endif - -#ifdef CONFIG_MTD_NAND_ATMEL_ECC_NONE -#define no_ecc 1 -#else -#define no_ecc 0 -#endif -static int use_dma =1 ;module_param (use_dma, int,0 );
@@ -495,23 +483,22 @@ static int __init atmel_nand_probe(struct platform_device *pdev)if (gpio_is_valid (host->board->rdy_pin)) nand_chip->dev_ready = atmel_nand_device_ready; + nand_chip->ecc.mode = host->board->ecc_mode; + regs =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (!regs && hard_ecc) { +if (!regs && nand_chip->ecc.mode ==NAND_ECC_HW ) {printk (KERN_ERR "atmel_nand: can't get I/O resource " "regs\nFalling back on software ECC\n" ); + nand_chip->ecc.mode =NAND_ECC_SOFT ; } - nand_chip->ecc.mode =NAND_ECC_SOFT ;/* enable ECC */ -if (no_ecc) - nand_chip->ecc.mode =NAND_ECC_NONE ; -if (hard_ecc && regs) { +if (nand_chip->ecc.mode ==NAND_ECC_HW ) { host->ecc =ioremap (regs->start,resource_size (regs));if (host->ecc ==NULL ) {printk (KERN_ERR "atmel_nand: ioremap failed\n" ); res = -EIO ; goto err_ecc_ioremap; } - nand_chip->ecc.mode =NAND_ECC_HW ; nand_chip->ecc.calculate = atmel_nand_calculate; nand_chip->ecc.correct = atmel_nand_correct; nand_chip->ecc.hwctl = atmel_nand_hwctl;
include/linux/platform_data/atmel.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* atmel platform data +* +* GPL v2 Only +*/ + +#ifndef __ATMEL_NAND_H__ +#define __ATMEL_NAND_H__ + +#include <linux/mtd/nand.h> + +/* NAND / SmartMedia */ +struct atmel_nand_data { +int enable_pin;/* chip enable */ +int det_pin;/* card detect */ +int rdy_pin;/* ready/busy */ +u8 rdy_pin_active_low;/* rdy_pin value is inverted */ +u8 ale;/* address line number connected to ALE */ +u8 cle;/* address line number connected to CLE */ +u8 bus_width_16;/* buswidth is 16 bit */ +u8 ecc_mode;/* ecc mode */ +struct mtd_partition *parts; +unsigned int num_parts; +}; + +#endif /* __ATMEL_NAND_H__ */
Signature · 1 line
1.7.7
PATCH 2/6 mtd/atmel_nand: add on_flash_bbt to enable the use of On Flash BBT
from the board
--- drivers/mtd/nand/atmel_nand.c | 2 +- include/linux/platform_data/atmel.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/mtd/nand/atmel_nand.c +1 -1
@@ -525,7 +525,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) } } -if (on_flash_bbt) { +if (host->board->on_flash_bbt || on_flash_bbt) {printk (KERN_INFO "atmel_nand: Use On Flash BBT\n" ); nand_chip->bbt_options |=NAND_BBT_USE_FLASH ; }
include/linux/platform_data/atmel.h +1 -0
@@ -19,6 +19,7 @@ struct atmel_nand_data {u8 cle;/* address line number connected to CLE */ u8 bus_width_16;/* buswidth is 16 bit */ u8 ecc_mode;/* ecc mode */ +u8 on_flash_bbt;/* bbt on flash */ struct mtd_partition *parts;unsigned int num_parts; };
Signature · 1 line
1.7.7
PATCH 3/6 ARM: at91: enable on flash bbt for Atmel Reference and DT boards
In reply to Jean-Christophe PLAGNIOL-VILLARDenable it on Calao board too
--- arch/arm/mach-at91/board-cap9adk.c | 1 + arch/arm/mach-at91/board-dt.c | 1 + arch/arm/mach-at91/board-qil-a9260.c | 1 + arch/arm/mach-at91/board-rm9200dk.c | 1 + arch/arm/mach-at91/board-sam9260ek.c | 1 + arch/arm/mach-at91/board-sam9261ek.c | 1 + arch/arm/mach-at91/board-sam9263ek.c | 1 + arch/arm/mach-at91/board-sam9g20ek.c | 1 + arch/arm/mach-at91/board-sam9m10g45ek.c | 1 + arch/arm/mach-at91/board-sam9rlek.c | 1 + arch/arm/mach-at91/board-usb-a926x.c | 1 + 11 files changed, 11 insertions(+), 0 deletions(-)
arch/arm/mach-at91/board-cap9adk.c +1 -0
@@ -179,6 +179,7 @@ static struct atmel_nand_data __initdata cap9adk_nand_data = { .rdy_pin = -EINVAL, .enable_pin = AT91_PIN_PD15, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = cap9adk_nand_partitions, .num_parts = ARRAY_SIZE(cap9adk_nand_partitions), };
arch/arm/mach-at91/board-dt.c +1 -0
@@ -54,6 +54,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PC8, .enable_pin = AT91_PIN_PC14, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, };static struct sam9_smc_config __initdata ek_nand_smc_config = {
arch/arm/mach-at91/board-qil-a9260.c +1 -0
@@ -139,6 +139,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-rm9200dk.c +1 -0
@@ -150,6 +150,7 @@ static struct atmel_nand_data __initdata dk_nand_data = { .rdy_pin = AT91_PIN_PC2, .enable_pin = -EINVAL, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = dk_nand_partition, .num_parts = ARRAY_SIZE(dk_nand_partition), };
arch/arm/mach-at91/board-sam9260ek.c +1 -0
@@ -182,6 +182,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PC13, .enable_pin = AT91_PIN_PC14, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9261ek.c +1 -0
@@ -188,6 +188,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PC15, .enable_pin = AT91_PIN_PC14, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9263ek.c +1 -0
@@ -188,6 +188,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PA22, .enable_pin = AT91_PIN_PD15, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9g20ek.c +1 -0
@@ -167,6 +167,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .enable_pin = AT91_PIN_PC14, .det_pin = -EINVAL, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9m10g45ek.c +1 -0
@@ -147,6 +147,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .enable_pin = AT91_PIN_PC14, .det_pin = -EINVAL, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-sam9rlek.c +1 -0
@@ -95,6 +95,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PD17, .enable_pin = AT91_PIN_PB6, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
arch/arm/mach-at91/board-usb-a926x.c +1 -0
@@ -199,6 +199,7 @@ static struct atmel_nand_data __initdata ek_nand_data = { .rdy_pin = AT91_PIN_PA22, .enable_pin = AT91_PIN_PD15, .ecc_mode = NAND_ECC_SOFT, + .on_flash_bbt = 1, .parts = ek_nand_partition, .num_parts = ARRAY_SIZE(ek_nand_partition), };
Signature · 1 line
1.7.7
PATCH 4/6 of/mtd/nand: add generic bindings and helpers
In reply to Jean-Christophe PLAGNIOL-VILLARD- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
--- Documentation/devicetree/bindings/mtd/nand.txt | 7 ++ drivers/of/Kconfig | 4 + drivers/of/Makefile | 1 + drivers/of/of_mtd.c | 90 ++++++++++++++++++++++++ include/linux/of_mtd.h | 19 +++++ 5 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/nand.txt create mode 100644 drivers/of/of_mtd.c create mode 100644 include/linux/of_mtd.h
Documentation/devicetree/bindings/mtd/nand.txt new file +7 -0
@@ -0,0 +1,7 @@ +* MTD generic binding + +- nand-ecc-mode : String, operation mode of the NAND ecc mode. + Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", + "soft_bch". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
drivers/of/Kconfig +4 -0
@@ -90,4 +90,8 @@ config OF_PCI_IRQ help OpenFirmware PCI IRQ routing helpers +config OF_MTD + depends on MTD + def_bool y + endmenu # OF
drivers/of/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.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_NET) += of_mtd.o
drivers/of/of_mtd.c new file +90 -0
90 lines not on this page · raw message
include/linux/of_mtd.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* 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_NET_H + +#ifdef CONFIG_OF_MTD +#include <linux/of.h> +extern const int of_get_nand_ecc_mode (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); +#endif + +#endif /* __LINUX_OF_MTD_H */
Signature · 1 line
1.7.7
PATCH 4/6 of/mtd/nand: add generic bindings and helpers
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "
hw_syndrome", "hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present falseSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org
Fine by me.
Quoted 175 lines
--- Documentation/devicetree/bindings/mtd/nand.txt | 7 ++ drivers/of/Kconfig | 4 + drivers/of/Makefile | 1 + drivers/of/of_mtd.c | 90 ++++++++++++++++++++++++ include/linux/of_mtd.h | 19 +++++ 5 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/nand.txt create mode 100644 drivers/of/of_mtd.c create mode 100644 include/linux/of_mtd.hDocumentation/devicetree/bindings/mtd/nand.txt new file +7
-0@@ -0,0 +1,7 @@ +* MTD generic binding + +- nand-ecc-mode : String, operation mode of the NAND ecc mode. + Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", + "soft_bch". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present falsedrivers/of/Kconfig +4
-0@@ -90,4 +90,8 @@ config OF_PCI_IRQ help OpenFirmware PCI IRQ routing helpers +config OF_MTD + depends on MTD + def_bool y + endmenu # OFdrivers/of/Makefile +1
-0@@ -12,3 +12,4 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.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_NET) += of_mtd.odrivers/of/of_mtd.c new file +90
-0@@ -0,0 +1,90 @@ +/* +* 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 'phy-mode', so that Ethernet +* device driver can get phy interface 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. +*/ +const 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_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 1 false other wise +*/ +bool of_get_nand_on_flash_bbt (struct device_node *np) +{ +u32 val; + +if (of_property_read_u32 (np,"nand-on-flash-bbt" , &val)) +return false; + +return val ? true : false; +} +EXPORT_SYMBOL_GPL (of_get_nand_on_flash_bbt);include/linux/of_mtd.h new file +19
-0@@ -0,0 +1,19 @@ +/* +* 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_NET_H + +#ifdef CONFIG_OF_MTD +#include <linux/of.h> +extern const int of_get_nand_ecc_mode (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); +#endif + +#endif /* __LINUX_OF_MTD_H */ Signature · 7 lines
1.7.7 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/6 atmel/nand: add DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDuse a local copy of board informatin and fill with DT data
--- .../devicetree/bindings/mtd/atmel-nand.txt | 41 ++++++++ drivers/mtd/nand/atmel_nand.c | 107 ++++++++++++++++---- 2 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txt
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +41 -0
@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties: +- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + optional gpio and may be set to 0 if not present. + +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + nand-on-flash-bbt = <1>; + nand-ecc-mode = "soft"; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + partition at 0 { + ... + }; +};
drivers/mtd/nand/atmel_nand.c +89 -18
206 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH 5/6 atmel/nand: add DT support
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org
Nitpicks below, but otherwise:
Quoted 146 lines
--- .../devicetree/bindings/mtd/atmel-nand.txt | 41 ++++++++ drivers/mtd/nand/atmel_nand.c | 107 ++++++++++++++++---- 2 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txtDocumentation/devicetree/bindings/mtd/atmel-nand.txt new file +41
-0@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties: +- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + optional gpio and may be set to 0 if not present. + +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + nand-on-flash-bbt = <1>; + nand-ecc-mode = "soft"; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + partition at 0 { + ... + }; +};drivers/mtd/nand/atmel_nand.c +33
-9@@ -27,6 +27,10 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/platform_device.h> +#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> @@ -83,7 +87,7 @@ struct atmel_nand_host {struct mtd_info mtd;void __iomem *io_base;dma_addr_t io_phys; -struct atmel_nand_data *board; +struct atmel_nand_data board;struct device *dev;void __iomem *ecc;@@ -101,8 +105,8 @@ static int cpu_has_dma(void)*/ static void atmel_nand_enable (struct atmel_nand_host *host) { -if (gpio_is_valid (host->board->enable_pin)) -gpio_set_value (host->board->enable_pin,0 ); +if (gpio_is_valid (host->board.enable_pin)) +gpio_set_value (host->board.enable_pin,0 ); }/* @@ -110,8 +114,8 @@ static void atmel_nand_enable(struct atmel_nand_host *host)*/ static void atmel_nand_disable (struct atmel_nand_host *host) { -if (gpio_is_valid (host->board->enable_pin)) -gpio_set_value (host->board->enable_pin,1 ); +if (gpio_is_valid (host->board.enable_pin)) +gpio_set_value (host->board.enable_pin,1 ); }/* @@ -132,9 +136,9 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrlreturn ;if (ctrl &NAND_CLE ) -writeb (cmd, host->io_base + (1 << host->board->cle)); +writeb (cmd, host->io_base + (1 << host->board.cle));else -writeb (cmd, host->io_base + (1 << host->board->ale)); +writeb (cmd, host->io_base + (1 << host->board.ale)); }/* @@ -145,8 +149,8 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)struct nand_chip *nand_chip = mtd->priv;struct atmel_nand_host *host = nand_chip->priv; -return gpio_get_value (host->board->rdy_pin) ^ - !!host->board->rdy_pin_active_low; +return gpio_get_value (host->board.rdy_pin) ^ + !!host->board.rdy_pin_active_low; }static void dma_complete_func (void *completion)@@ -432,6 +436,54 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) } } +static int __devinit atmel_of_init_port (struct atmel_nand_host *host, +struct device_node *np) +{ +u32 val; +int ecc_mode; +struct atmel_nand_data *board = &host->board; +enum of_gpio_flags flags; + +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 ;
drivers/mtd/nand/atmel_nand.c static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) · line 468
Quoted 10 lines
drivers/mtd/nand/atmel_nand.c +10
-0+ } + board->cle = val; + } + + ecc_mode =of_get_nand_ecc_mode (np); + +if (ecc_mode <0 ) + board->ecc_mode =NAND_ECC_SOFT ; +else + board->ecc_mode = ecc_mode;
Nit: board->ecc_mode = ecc_mode < 0 ? NAND_ECC_SOFT : ecc_mode;
drivers/mtd/nand/atmel_nand.c static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) · line 479
Quoted 11 lines
drivers/mtd/nand/atmel_nand.c +11
-0+ + 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); +if (flags ==OF_GPIO_ACTIVE_LOW ) + board->rdy_pin_active_low =1 ; +else + board->rdy_pin_active_low =0 ;
Nit: board->rdy_pin_active_low = (flags == OF_GPIO_ACTIVE_LOW);
Just a bit more compact that way.
Quoted 118 lines
drivers/mtd/nand/atmel_nand.c +35
-9+ + board->enable_pin =of_get_gpio (np,1 ); + board->det_pin =of_get_gpio (np,2 ); + +return 0 ; +} +/* * Probe for the NAND device. */ @@ -442,6 +494,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)struct nand_chip *nand_chip;struct resource *regs;struct resource *mem; +struct mtd_part_parser_data ppdata = {};int res; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -468,8 +521,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev) mtd = &host->mtd; nand_chip = &host->nand_chip; - host->board = pdev->dev.platform_data; host->dev = &pdev->dev; +if (pdev->dev.of_node) { + res =atmel_of_init_port (host, pdev->dev.of_node); +if (res) + goto err_nand_ioremap; + }else { +memcpy (&host->board, pdev->dev.platform_data, +sizeof (struct atmel_nand_data )); + } nand_chip->priv = host;/* link the private data structures */ mtd->priv = nand_chip;@@ -480,10 +540,10 @@ static int __init atmel_nand_probe(struct platform_device *pdev) nand_chip->IO_ADDR_W = host->io_base; nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; -if (gpio_is_valid (host->board->rdy_pin)) +if (gpio_is_valid (host->board.rdy_pin)) nand_chip->dev_ready = atmel_nand_device_ready; - nand_chip->ecc.mode = host->board->ecc_mode; + nand_chip->ecc.mode = host->board.ecc_mode; regs =platform_get_resource (pdev,IORESOURCE_MEM ,1 );if (!regs && nand_chip->ecc.mode ==NAND_ECC_HW ) {@@ -508,7 +568,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) nand_chip->chip_delay =20 ;/* 20us command delay time */ -if (host->board->bus_width_16)/* 16-bit bus width */ +if (host->board.bus_width_16)/* 16-bit bus width */ nand_chip->options |=NAND_BUSWIDTH_16 ; nand_chip->read_buf = atmel_read_buf;@@ -517,15 +577,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev)platform_set_drvdata (pdev, host);atmel_nand_enable (host); -if (gpio_is_valid (host->board->det_pin)) { -if (gpio_get_value (host->board->det_pin)) { +if (gpio_is_valid (host->board.det_pin)) { +if (gpio_get_value (host->board.det_pin)) {printk (KERN_INFO "No SmartMedia card inserted.\n" ); res = -ENXIO ; goto err_no_card; } } -if (host->board->on_flash_bbt || on_flash_bbt) { +if (host->board.on_flash_bbt || on_flash_bbt) {printk (KERN_INFO "atmel_nand: Use On Flash BBT\n" ); nand_chip->bbt_options |=NAND_BBT_USE_FLASH ; }@@ -600,8 +660,9 @@ static int __init atmel_nand_probe(struct platform_device *pdev) } mtd->name ="atmel_nand" ; - res =mtd_device_parse_register (mtd,NULL ,0 , - host->board->parts, host->board->num_parts); + ppdata.of_node = pdev->dev.of_node; + res =mtd_device_parse_register (mtd,NULL , &ppdata, + host->board.parts, host->board.num_parts);if (!res)return res;@@ -645,11 +706,21 @@ static int __exit atmel_nand_remove(struct platform_device *pdev)return 0 ; } +#if defined(CONFIG_OF ) +static const struct of_device_id atmel_nand_dt_ids[] = { + { .compatible ="atmel,at91rm9200-nand" }, + {/* sentinel */ } +}; + +MODULE_DEVICE_TABLE (of, atmel_nand_dt_ids); +#endif +static struct platform_driver atmel_nand_driver = { .remove =__exit_p (atmel_nand_remove), .driver = { .name ="atmel_nand" , .owner =THIS_MODULE , + .of_match_table =of_match_ptr (atmel_nand_dt_ids), }, };Signature · 7 lines
1.7.7 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/6 atmel/nand: add DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDHi,
Quoted 21 lines · Jean-Christophe PLAGNIOL-VILLARD
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org---
?.../devicetree/bindings/mtd/atmel-nand.txt ? ? ? ? | ? 41 ++++++++ ?drivers/mtd/nand/atmel_nand.c ? ? ? ? ? ? ? ? ? ? ?| ?107 ++++++++++++++++---- ?2 files changed, 130 insertions(+), 18 deletions(-)
?create mode 100644Documentation/devicetree/bindings/mtd/atmel-nand.txtDocumentation/devicetree/bindings/mtd/atmel-nand.txt new file +3
-0@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties:
Documentation/devicetree/bindings/mtd/atmel-nand.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +10
-0+- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + ? ? ? and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + ?representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + ?optional gpio and may be set to 0 if not present.
What does this mean please? What is 'detect' and what 'control' do the gpios provide?
Below you have two GPIOs pioC 13 and pioC 14. I think the binding should document the two GPIOs, the order, and what they are for.
Quoted 13 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +13
-0+ +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + ? ? ? compatible = "atmel,at91rm9200-nand"; + ? ? ? #address-cells = <1>; + ? ? ? #size-cells = <1>;
Documentation/devicetree/bindings/mtd/atmel-nand.txt line 36
Quoted 10 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +10
-0+ ? ? ? reg = <0x40000000 0x10000000 + ? ? ? ? ? ? ?0xffffe800 0x200 + ? ? ? ? ? ? >; + ? ? ? atmel,nand-addr-offset = <21>; + ? ? ? atmel,nand-cmd-offset = <22>; + ? ? ? nand-on-flash-bbt = <1>; + ? ? ? nand-ecc-mode = "soft"; + ? ? ? gpios = <&pioC 13 0 + ? ? ? ? ? ? ? ?&pioC 14 0 + ? ? ? ? ? ? ? ?0
Sorry, I haven't seen this before, perhaps it is a standard thing in Linux. Does 0 mean end of list? Can we not just use the property's size value for this?
Regards,
Simon
Quoted 237 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +5
-0+ ? ? ? ? ? ? ? >; + ? ? ? partition at 0 { + ? ? ? ? ? ? ? ... + ? ? ? }; +};drivers/mtd/nand/atmel_nand.c +0
-0@@ -27,6 +27,10 @@?#include <
linux/module.h>
?#include <linux/moduleparam.h>
?#include <linux/platform_device.h>drivers/mtd/nand/atmel_nand.c +4
-0+#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>drivers/mtd/nand/atmel_nand.c +1
-1@@ -83,7 +87,7 @@ struct atmel_nand_host { ? ? ? ?struct mtd_info ? ? ? ? mtd; ? ? ? ?void __iomem ? ? ? ? ? ?*io_base; ? ? ? ?dma_addr_t ? ? ? ? ? ? ?io_phys; - ? ? ? struct atmel_nand_data ?*board; + ? ? ? struct atmel_nand_data ?board; ? ? ? ?struct device ? ? ? ? ? *dev; ? ? ? ?void __iomem ? ? ? ? ? ?*ecc;@@ -101,8 +105,8 @@ static int cpu_has_dma(void)?*/
?static voidatmel_nand_enable(struct atmel_nand_host *host)?{
- ? ? ? if (gpio_is_valid(host->board->enable_pin))
- ? ? ? ? ? ? ?gpio_set_value(host->board->enable_pin, 0);
+ ? ? ? if (gpio_is_valid(host->board.enable_pin))
+ ? ? ? ? ? ? ?gpio_set_value(host->board.enable_pin, 0); ?}?/*
drivers/mtd/nand/atmel_nand.c +0
-0@@ -110,8 +114,8 @@ static void atmel_nand_enable(struct atmel_nand_host *host)?*/
?static voidatmel_nand_disable(struct atmel_nand_host *host)?{
- ? ? ? if (gpio_is_valid(host->board->enable_pin))
- ? ? ? ? ? ? ?gpio_set_value(host->board->enable_pin, 1);
+ ? ? ? if (gpio_is_valid(host->board.enable_pin))
+ ? ? ? ? ? ? ?gpio_set_value(host->board.enable_pin, 1); ?}?/*
drivers/mtd/nand/atmel_nand.c +1
-1@@ -132,9 +136,9 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl ? ? ? ? ? ? ? ?return; ? ? ? ?if (ctrl & NAND_CLE) - ? ? ? ? ? ? ? writeb(cmd, host->io_base + (1 << host->board->cle)); + ? ? ? ? ? ? ? writeb(cmd, host->io_base + (1 << host->board.cle));? ? ? ?else
- ? ? ? ? ? ? ?writeb(cmd, host->io_base + (1 << host->board->ale));
+ ? ? ? ? ? ? ?writeb(cmd, host->io_base + (1 << host->board.ale)); ?}?/*
drivers/mtd/nand/atmel_nand.c +50
-2@@ -145,8 +149,8 @@ static int atmel_nand_device_ready(struct mtd_info *mtd) ? ? ? ?struct nand_chip *nand_chip = mtd->priv; ? ? ? ?struct atmel_nand_host *host = nand_chip->priv; - ? ? ? return gpio_get_value(host->board->rdy_pin) ^ - ? ? ? ? ? ? ? ?!!host->board->rdy_pin_active_low; + ? ? ? return gpio_get_value(host->board.rdy_pin) ^ + ? ? ? ? ? ? ? ?!!host->board.rdy_pin_active_low; ?} ?static void dma_complete_func(void *completion)@@ -432,6 +436,54 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) ? ? ? ?} ?} +static int __devinit atmel_of_init_port (struct atmel_nand_host *host, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct device_node *np) +{ + ? ? ? u32 val; + ? ? ? int ecc_mode; + ? ? ? struct atmel_nand_data *board = &host->board; + ? ? ? enum of_gpio_flags flags; + + ? ? ? 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); + + ? ? ? if (ecc_mode < 0) + ? ? ? ? ? ? ? board->ecc_mode = NAND_ECC_SOFT; + ? ? ? else + ? ? ? ? ? ? ? board->ecc_mode = 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); + ? ? ? if (flags == OF_GPIO_ACTIVE_LOW) + ? ? ? ? ? ? ? board->rdy_pin_active_low = 1; + ? ? ? else + ? ? ? ? ? ? ? board->rdy_pin_active_low = 0; + + ? ? ? board->enable_pin = of_get_gpio(np, 1); + ? ? ? board->det_pin = of_get_gpio(np, 2); + + ? ? ? return 0; +} +?/*
?* Probe for the NAND device.
?*/drivers/mtd/nand/atmel_nand.c +9
-1@@ -442,6 +494,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) ? ? ? ?struct nand_chip *nand_chip; ? ? ? ?struct resource *regs; ? ? ? ?struct resource *mem; + ? ? ? struct mtd_part_parser_data ppdata = {}; ? ? ? ?int res; ? ? ? ?mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);@@ -468,8 +521,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev) ? ? ? ?mtd = &host->mtd; ? ? ? ?nand_chip = &host->nand_chip; - ? ? ? host->board = pdev->dev.platform_data; ? ? ? ?host->dev = &pdev->dev; + ? ? ? if (pdev->dev.of_node) { + ? ? ? ? ? ? ? res = atmel_of_init_port(host, pdev->dev.of_node); + ? ? ? ? ? ? ? if (res) + ? ? ? ? ? ? ? ? ? ? ? goto err_nand_ioremap; + ? ? ? } else { + ? ? ? ? ? ? ? memcpy(&host->board, pdev->dev.platform_data, + ? ? ? ? ? ? ? ? ? ? ?sizeof(struct atmel_nand_data)); + ? ? ? }? ? ? ?nand_chip->priv = host; ? ? ? ? /* link the private data structures */ ? ? ? ?mtd->priv =
nand_chip;drivers/mtd/nand/atmel_nand.c +2
-2@@ -480,10 +540,10 @@ static int __init atmel_nand_probe(struct platform_device *pdev) ? ? ? ?nand_chip->IO_ADDR_W = host->io_base; ? ? ? ?nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; - ? ? ? if (gpio_is_valid(host->board->rdy_pin)) + ? ? ? if (gpio_is_valid(host->board.rdy_pin)) ? ? ? ? ? ? ? ?nand_chip->dev_ready = atmel_nand_device_ready; - ? ? ? nand_chip->ecc.mode = host->board->ecc_mode; + ? ? ? nand_chip->ecc.mode = host->board.ecc_mode; ? ? ? ?regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); ? ? ? ?if (!regs && nand_chip->ecc.mode == NAND_ECC_HW) {@@ -508,7 +568,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)? ? ? ?nand_chip->chip_delay = 20; ? ? ? ? ? ? /* 20us command delay time */
- ? ? ? if (
host->board->bus_width_16) ?/* 16-bit bus width */
+ ? ? ? if (host->board.bus_width_16) ? /* 16-bit bus width */ ? ? ? ? ? ? ? ?nand_chip->options |=NAND_BUSWIDTH_16;? ? ? ?nand_chip->read_buf =
atmel_read_buf;drivers/mtd/nand/atmel_nand.c +16
-6@@ -517,15 +577,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev) ? ? ? ?platform_set_drvdata(pdev, host); ? ? ? ?atmel_nand_enable(host); - ? ? ? if (gpio_is_valid(host->board->det_pin)) { - ? ? ? ? ? ? ? if (gpio_get_value(host->board->det_pin)) { + ? ? ? if (gpio_is_valid(host->board.det_pin)) { + ? ? ? ? ? ? ? if (gpio_get_value(host->board.det_pin)) { ? ? ? ? ? ? ? ? ? ? ? ?printk(KERN_INFO "No SmartMedia card inserted.\n"); ? ? ? ? ? ? ? ? ? ? ? ?res = -ENXIO; ? ? ? ? ? ? ? ? ? ? ? ?goto err_no_card; ? ? ? ? ? ? ? ?} ? ? ? ?} - ? ? ? if (host->board->on_flash_bbt || on_flash_bbt) { + ? ? ? if (host->board.on_flash_bbt || on_flash_bbt) { ? ? ? ? ? ? ? ?printk(KERN_INFO "atmel_nand: Use On Flash BBT\n"); ? ? ? ? ? ? ? ?nand_chip->bbt_options |= NAND_BBT_USE_FLASH; ? ? ? ?}@@ -600,8 +660,9 @@ static int __init atmel_nand_probe(struct platform_device *pdev) ? ? ? ?} ? ? ? ?mtd->name = "atmel_nand"; - ? ? ? res = mtd_device_parse_register(mtd, NULL, 0, - ? ? ? ? ? ? ? ? ? ? ? host->board->parts, host->board->num_parts); + ? ? ? ppdata.of_node = pdev->dev.of_node; + ? ? ? res = mtd_device_parse_register(mtd, NULL, &ppdata, + ? ? ? ? ? ? ? ? ? ? ? host->board.parts, host->board.num_parts); ? ? ? ?if (!res) ? ? ? ? ? ? ? ?return res;@@ -645,11 +706,21 @@ static int __exit atmel_nand_remove(struct platform_device *pdev) ? ? ? ?return 0; ?} +#if defined(CONFIG_OF ) +static const struct of_device_id atmel_nand_dt_ids[] = { + ? ? ? { .compatible = "atmel,at91rm9200-nand" }, + ? ? ? { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE (of, atmel_nand_dt_ids); +#endif + ?static struct platform_driver atmel_nand_driver = { ? ? ? ?.remove ? ? ? ? = __exit_p(atmel_nand_remove), ? ? ? ?.driver ? ? ? ? = { ? ? ? ? ? ? ? ?.name ? = "atmel_nand", ? ? ? ? ? ? ? ?.owner ?= THIS_MODULE, + ? ? ? ? ? ? ? .of_match_table = of_match_ptr(atmel_nand_dt_ids), ? ? ? ?}, ?}; --1.7.7
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/6 atmel/nand: add DT support
Quoted 39 lines · Simon Glass
Hi,
Quoted 21 lines · Jean-Christophe PLAGNIOL-VILLARD
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org---
?.../devicetree/bindings/mtd/atmel-nand.txt ? ? ? ? | ? 41 ++++++++ ?drivers/mtd/nand/atmel_nand.c ? ? ? ? ? ? ? ? ? ? ?| ?107 ++++++++++++++++---- ?2 files changed, 130 insertions(+), 18 deletions(-)
?create mode 100644Documentation/devicetree/bindings/mtd/atmel-nand.txtDocumentation/devicetree/bindings/mtd/atmel-nand.txt new file +3
-0@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties:Documentation/devicetree/bindings/mtd/atmel-nand.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +10
-0+- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + ? ? ? and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + ?representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + ?optional gpio and may be set to 0 if not present.What does this mean please? What is 'detect' and what 'control' do the gpios provide?
Quoted 2 lines
Below you have two GPIOs pioC 13 and pioC 14. I think the binding should document the two GPIOs, the order, and what they are for.
no as it's said in the binding the detect pin is optional
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +19
-0+ +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + ? ? ? compatible = "atmel,at91rm9200-nand"; + ? ? ? #address-cells = <1>; + ? ? ? #size-cells = <1>; + ? ? ? reg = <0x40000000 0x10000000 + ? ? ? ? ? ? ?0xffffe800 0x200 + ? ? ? ? ? ? >; + ? ? ? atmel,nand-addr-offset = <21>; + ? ? ? atmel,nand-cmd-offset = <22>; + ? ? ? nand-on-flash-bbt = <1>;
Quoted 8 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt line 36
Quoted 4 lines
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +4
-0+ ? ? ? nand-ecc-mode = "soft"; + ? ? ? gpios = <&pioC 13 0 + ? ? ? ? ? ? ? ?&pioC 14 0 + ? ? ? ? ? ? ? ?0Sorry, I haven't seen this before, perhaps it is a standard thing in Linux. Does 0 mean end of list? Can we not just use the property's size value for this?
0 means not used as specified in the DT
Best Regards,
J.
PATCH 6/6 ARM: at91: board-dt nand switch to DT
In reply to Jean-Christophe PLAGNIOL-VILLARDremove the C nand devices registration
until we have the pinmux support let the bootloader initialise the pin
--- arch/arm/boot/dts/at91sam9g20.dtsi | 17 ++++++++++ arch/arm/boot/dts/at91sam9g45.dtsi | 15 +++++++++ arch/arm/boot/dts/at91sam9m10g45ek.dts | 27 ++++++++++++++++- arch/arm/boot/dts/usb_a9g20.dts | 46 +++++++++++++++++++++++++++- arch/arm/mach-at91/board-dt.c | 52 -------------------------------- 5 files changed, 103 insertions(+), 54 deletions(-)
arch/arm/boot/dts/at91sam9g20.dtsi +17 -0
@@ -178,6 +178,23 @@ interrupts = <20>; status = "disabled"; }; + + nand0: nand at 40000000 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + status = "disabled"; + }; + }; }; };
arch/arm/boot/dts/at91sam9g45.dtsi +15 -0
@@ -178,6 +178,21 @@ interrupts = <22>; status = "disabled"; }; + + nand0: nand at 40000000 { + compatible = "atmel,at91rm9200-nand"; + reg = <0x40000000 0x10000000 + 0xffffe200 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + gpios = <&pioC 8 0 + &pioC 14 0 + 0 + >; + status = "disabled"; + }; + }; }; };
arch/arm/boot/dts/at91sam9m10g45ek.dts +26 -1
@@ -14,7 +14,7 @@ compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9"; chosen { - bootargs = "mem=64M console=ttyS0,115200 mtdparts=atmel_nand:4M(bootstrap/uboot/kernel)ro,60M(rootfs),-(data) root=/dev/mtdblock1 rw rootfstype=jffs2"; + bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"; }; memory at 70000000 {
@@ -36,6 +36,31 @@ status = "okay"; }; + nand0: nand at 40000000 { + nand-bus-width = <8>; + nand-ecc-mode = "soft"; + nand-on-flash-bbt = <1>; + status = "okay"; + + boot at 0 { + label = "bootstrap/uboot/kernel"; + reg = <0x0 0x400000>; + }; + + rootfs at 400000 { + label = "rootfs"; + reg = <0x400000 0x3C00000>; + }; + + data at 4000000 { + label = "data"; + reg = <0x4000000 0xC000000>; + }; + + }; + }; + }; + usb0: ohci at 00700000 { status = "okay"; num-ports = <2>;
arch/arm/boot/dts/usb_a9g20.dts +45 -1
58 lines not on this page · raw message
arch/arm/mach-at91/board-dt.c +0 -52
79 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v2 4/6 of/mtd/nand: add generic bindings and helpers
In reply to Jean-Christophe PLAGNIOL-VILLARD- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
--- Documentation/devicetree/bindings/mtd/nand.txt | 7 ++ drivers/of/Kconfig | 4 + drivers/of/Makefile | 1 + drivers/of/of_mtd.c | 90 ++++++++++++++++++++++++ include/linux/of_mtd.h | 19 +++++ 5 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/nand.txt create mode 100644 drivers/of/of_mtd.c create mode 100644 include/linux/of_mtd.h
Documentation/devicetree/bindings/mtd/nand.txt new file +7 -0
@@ -0,0 +1,7 @@ +* MTD generic binding + +- nand-ecc-mode : String, operation mode of the NAND ecc mode. + Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", + "soft_bch". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
drivers/of/Kconfig +4 -0
@@ -90,4 +90,8 @@ config OF_PCI_IRQ help OpenFirmware PCI IRQ routing helpers +config OF_MTD + depends on MTD + def_bool y + endmenu # OF
drivers/of/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.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_NET) += of_mtd.o
drivers/of/of_mtd.c new file +90 -0
90 lines not on this page · raw message
include/linux/of_mtd.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* 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_NET_H + +#ifdef CONFIG_OF_MTD +#include <linux/of.h> +extern const int of_get_nand_ecc_mode (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); +#endif + +#endif /* __LINUX_OF_MTD_H */
Signature · 1 line
1.7.7
PATCH v2 4/6 of/mtd/nand: add generic bindings and helpers
Hi Jean-Christophe,
Quoted 6 lines · On Monday 06 February 2012 11:35:11 Jean-Christophe PLAGNIOL-VILLARD wrote:
- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "
hw_syndrome",
"hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
Why not use an "empty" type (without argument) for nand-on-flash-bbt then?
Thanks,
Stefan
PATCH v2 4/6 of/mtd/nand: add generic bindings and helpers
Quoted 11 lines · Stefan Roese
Hi Jean-Christophe,
Quoted 6 lines · On Monday 06 February 2012 11:35:11 Jean-Christophe PLAGNIOL-VILLARD wrote:
- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "
hw_syndrome",
"hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present falseWhy not use an "empty" type (without argument) for nand-on-flash-bbt then?
I want to be able to disable it
I send a patch to add a helper to manage boolean
this will allow to disable a boolean
is-ok; => true
is-ok = <1>; => true
is-ok = <0>; => falseBest Regards,
J.
PATCH v2 4/6 of/mtd/nand: add generic bindings and helpers
Quoted 7 lines · On Tuesday 07 February 2012 05:16:06 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 5 lines
Quoted 2 lines
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
Why not use an "empty" type (without argument) for nand-on-flash-bbt then?
I want to be able to disable it
Then just don't add this property.
Quoted 7 lines
I send a patch to add a helper to manage boolean
this will allow to disable a boolean
is-ok; => true is-ok = <1>; => true is-ok = <0>; => false
Okay, fine with me.
Thanks,
Stefan
PATCH v2 4/6 of/mtd/nand: add generic bindings and helpers
Quoted 10 lines · Stefan Roese
Quoted 7 lines · On Tuesday 07 February 2012 05:16:06 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 5 lines
Quoted 2 lines
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
Why not use an "empty" type (without argument) for nand-on-flash-bbt then?
I want to be able to disable it
Then just don't add this property.
except if it's it done via include a cpu module enable it but the motherboard dts want to disable it
Quoted 8 lines
Quoted 8 lines
I send a patch to add a helper to manage boolean
this will allow to disable a boolean
is-ok; => true is-ok = <1>; => true is-ok = <0>; => false
Best Regrds,
J.
PATCH v3 4/6 of/mtd/nand: add generic bindings and helpers
In reply to Jean-Christophe PLAGNIOL-VILLARD- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
---
v3:
rebase over "of: introduce helper to manage boolean"
Best Regards,
J.
Documentation/devicetree/bindings/mtd/nand.txt | 7 ++ drivers/of/Kconfig | 4 + drivers/of/Makefile | 1 + drivers/of/of_mtd.c | 85 ++++++++++++++++++++++++ include/linux/of_mtd.h | 19 +++++ 5 files changed, 116 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/nand.txt create mode 100644 drivers/of/of_mtd.c create mode 100644 include/linux/of_mtd.h
Documentation/devicetree/bindings/mtd/nand.txt new file +7 -0
@@ -0,0 +1,7 @@ +* MTD generic binding + +- nand-ecc-mode : String, operation mode of the NAND ecc mode. + Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", + "soft_bch". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
drivers/of/Kconfig +4 -0
@@ -90,4 +90,8 @@ config OF_PCI_IRQ help OpenFirmware PCI IRQ routing helpers +config OF_MTD + depends on MTD + def_bool y + endmenu # OF
drivers/of/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.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_NET) += of_mtd.o
drivers/of/of_mtd.c new file +85 -0
85 lines not on this page · raw message
include/linux/of_mtd.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* 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_NET_H + +#ifdef CONFIG_OF_MTD +#include <linux/of.h> +extern const int of_get_nand_ecc_mode (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); +#endif + +#endif /* __LINUX_OF_MTD_H */
Signature · 1 line
1.7.7
PATCH v3 4/6 of/mtd/nand: add generic bindings and helpers
Quoted 11 lines · On Tuesday 07 February 2012 17:18:30 Jean-Christophe PLAGNIOL-VILLARD wrote:
- nand-ecc-mode : String, operation mode of the NAND ecc mode. Supported values are: "none", "soft", "hw", "
hw_syndrome",
"hw_oob_first", "soft_bch".
- nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present falseSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Rob Herring <[email protected]>Cc devicetree-discuss at lists.ozlabs.org
Thanks,
Stefan
PATCH v2 5/6 atmel/nand: add DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDuse a local copy of board informatin and fill with DT data
---
V2:
comment from Grant
rebase over rc3
Best Regards,
J.
.../devicetree/bindings/mtd/atmel-nand.txt | 41 ++++++++ drivers/mtd/nand/atmel_nand.c | 105 ++++++++++++++++---- 2 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txt
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +41 -0
@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties: +- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + optional gpio and may be set to 0 if not present. + +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + nand-on-flash-bbt = <1>; + nand-ecc-mode = "soft"; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + partition at 0 { + ... + }; +};
drivers/mtd/nand/atmel_nand.c +85 -20
216 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v2 5/6 atmel/nand: add DT support
On 02/06/2012 11:35 AM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 7 lines
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org
[..]
drivers/mtd/nand/atmel_nand.c static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) · line 477
Quoted 2 lines
drivers/mtd/nand/atmel_nand.c +2
-0+static int __devinit atmel_of_init_port (struct atmel_nand_host *host, +struct device_node *np)
Maybe you will need to protect this function in case of !DT builds: I suspect that some of the of_xxxxx() calls are not provided if !CONFIG_OF.
Quoted 52 lines
drivers/mtd/nand/atmel_nand.c +41
-0+{ +u32 val; +int ecc_mode; +struct atmel_nand_data *board = &host->board; +enum of_gpio_flags flags; + +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->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 ); + +return 0 ; +} +/* * Probe for the NAND device. */ @@ -479,6 +525,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)struct nand_chip *nand_chip;struct resource *regs;struct resource *mem; +struct mtd_part_parser_data ppdata = {};int res; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
drivers/mtd/nand/atmel_nand.c static int __init atmel_nand_probe(struct platform_device *pdev) · line 557
Quoted 7 lines
drivers/mtd/nand/atmel_nand.c +2
-1@@ -505,8 +552,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev) mtd = &host->mtd; nand_chip = &host->nand_chip; - host->board = pdev->dev.platform_data; host->dev = &pdev->dev; +if (pdev->dev.of_node) { + res =atmel_of_init_port (host, pdev->dev.of_node);
Called here: must compile with !CONFIG_OF
drivers/mtd/nand/atmel_nand.c static int __init atmel_nand_probe(struct platform_device *pdev) · line 566
Quoted 9 lines
drivers/mtd/nand/atmel_nand.c +6
-0+if (res) + goto err_nand_ioremap; + }else { +memcpy (&host->board, pdev->dev.platform_data, +sizeof (struct atmel_nand_data )); + } nand_chip->priv = host;/* link the private data structures */ mtd->priv = nand_chip;
Best regards,
Signature · 1 line
Nicolas Ferre
PATCH v2 5/6 atmel/nand: add DT support
Quoted 9 lines · Nicolas Ferre
On 02/06/2012 11:35 AM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 7 lines
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org
Quoted 7 lines
[..]
drivers/mtd/nand/atmel_nand.c static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) · line 477
Quoted 2 lines
drivers/mtd/nand/atmel_nand.c +2
-0+static int __devinit atmel_of_init_port (struct atmel_nand_host *host, +struct device_node *np)Maybe you will need to protect this function in case of !DT builds: I suspect that some of the
of_xxxxx()calls are not provided if !CONFIG_OF.
no-need on the of_ function are static inline it !CONFIG_OF
Best Regards,
J.
PATCH v2 5/6 atmel/nand: add DT support
On 02/07/2012 12:53 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 10 lines · Nicolas Ferre
Quoted 9 lines
On 02/06/2012 11:35 AM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 7 lines
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org
Quoted 8 lines
Quoted 7 lines
[..]
drivers/mtd/nand/atmel_nand.c static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) · line 477
Quoted 2 lines
drivers/mtd/nand/atmel_nand.c +2
-0+static int __devinit atmel_of_init_port (struct atmel_nand_host *host, +struct device_node *np)Maybe you will need to protect this function in case of !DT builds: I suspect that some of the
of_xxxxx()calls are not provided if !CONFIG_OF.no-need on the
of_function are static inline it !CONFIG_OF
Sorry to come back to this but:
of_get_nand_ecc_mode(np);of_get_nand_on_flash_bbt(np);
for example are not available in case of non-DT compilation: so we must protect the atmel_of_init_port() against this error.
Can you please rework another patch.
Bye,
Signature · 1 line
Nicolas Ferre
PATCH v2 5/6 atmel/nand: add DT support
Quoted 22 lines · Nicolas Ferre
On 02/07/2012 12:53 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 10 lines · Nicolas Ferre
Quoted 9 lines
On 02/06/2012 11:35 AM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 7 lines
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.orgQuoted 8 lines
Quoted 7 lines
[..]
drivers/mtd/nand/atmel_nand.c static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) · line 477
Quoted 2 lines
drivers/mtd/nand/atmel_nand.c +2
-0+static int __devinit atmel_of_init_port (struct atmel_nand_host *host, +struct device_node *np)Maybe you will need to protect this function in case of !DT builds: I suspect that some of the
of_xxxxx()calls are not provided if !CONFIG_OF.no-need on the
of_function are static inline it !CONFIG_OFSorry to come back to this but:
Quoted 7 lines
of_get_nand_ecc_mode(np);of_get_nand_on_flash_bbt(np);for example are not available in case of non-DT compilation: so we must protect the
atmel_of_init_port()against this error.Can you please rework another patch.
yes seen too update send
Best Regards,
J.
PATCH v2 5/6 atmel/nand: add DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
use a local copy of board informatin and fill with DT data
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org---
V2:
comment from Grant
rebase over rc3
HI David,
I've depeancy on other at91 patch can I apply this series via at91 tree?
Best Regards,
J.
Quoted 293 lines
Best Regards,
J..../devicetree/bindings/mtd/atmel-nand.txt | 41 ++++++++ drivers/mtd/nand/atmel_nand.c | 105 ++++++++++++++++---- 2 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txtDocumentation/devicetree/bindings/mtd/atmel-nand.txt new file +41
-0@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties: +- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + optional gpio and may be set to 0 if not present. + +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + nand-on-flash-bbt = <1>; + nand-ecc-mode = "soft"; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + partition at 0 { + ... + }; +};drivers/mtd/nand/atmel_nand.c +85
-20@@ -27,6 +27,10 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/platform_device.h> +#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> @@ -83,7 +87,7 @@ struct atmel_nand_host {struct mtd_info mtd;void __iomem *io_base;dma_addr_t io_phys; -struct atmel_nand_data *board; +struct atmel_nand_data board;struct device *dev;void __iomem *ecc;@@ -101,8 +105,8 @@ static int cpu_has_dma(void)*/ static void atmel_nand_enable (struct atmel_nand_host *host) { -if (gpio_is_valid (host->board->enable_pin)) -gpio_set_value (host->board->enable_pin,0 ); +if (gpio_is_valid (host->board.enable_pin)) +gpio_set_value (host->board.enable_pin,0 ); }/* @@ -110,8 +114,8 @@ static void atmel_nand_enable(struct atmel_nand_host *host)*/ static void atmel_nand_disable (struct atmel_nand_host *host) { -if (gpio_is_valid (host->board->enable_pin)) -gpio_set_value (host->board->enable_pin,1 ); +if (gpio_is_valid (host->board.enable_pin)) +gpio_set_value (host->board.enable_pin,1 ); }/* @@ -132,9 +136,9 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrlreturn ;if (ctrl &NAND_CLE ) -writeb (cmd, host->io_base + (1 << host->board->cle)); +writeb (cmd, host->io_base + (1 << host->board.cle));else -writeb (cmd, host->io_base + (1 << host->board->ale)); +writeb (cmd, host->io_base + (1 << host->board.ale)); }/* @@ -145,8 +149,8 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)struct nand_chip *nand_chip = mtd->priv;struct atmel_nand_host *host = nand_chip->priv; -return gpio_get_value (host->board->rdy_pin) ^ - !!host->board->rdy_pin_active_low; +return gpio_get_value (host->board.rdy_pin) ^ + !!host->board.rdy_pin_active_low; }/* @@ -261,7 +265,7 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)if (atmel_nand_dma_op (mtd, buf, len,1 ) ==0 )return ; -if (host->board->bus_width_16) +if (host->board.bus_width_16)atmel_read_buf16 (mtd, buf, len);else atmel_read_buf8 (mtd, buf, len);@@ -277,7 +281,7 @@ static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)if (atmel_nand_dma_op (mtd, (void *)buf, len,0 ) ==0 )return ; -if (host->board->bus_width_16) +if (host->board.bus_width_16)atmel_write_buf16 (mtd, buf, len);else atmel_write_buf8 (mtd, buf, len);@@ -469,6 +473,48 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) } } +static int __devinit atmel_of_init_port (struct atmel_nand_host *host, +struct device_node *np) +{ +u32 val; +int ecc_mode; +struct atmel_nand_data *board = &host->board; +enum of_gpio_flags flags; + +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->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 ); + +return 0 ; +} +/* * Probe for the NAND device. */ @@ -479,6 +525,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)struct nand_chip *nand_chip;struct resource *regs;struct resource *mem; +struct mtd_part_parser_data ppdata = {};int res; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -505,8 +552,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev) mtd = &host->mtd; nand_chip = &host->nand_chip; - host->board = pdev->dev.platform_data; host->dev = &pdev->dev; +if (pdev->dev.of_node) { + res =atmel_of_init_port (host, pdev->dev.of_node); +if (res) + goto err_nand_ioremap; + }else { +memcpy (&host->board, pdev->dev.platform_data, +sizeof (struct atmel_nand_data )); + } nand_chip->priv = host;/* link the private data structures */ mtd->priv = nand_chip;@@ -517,10 +571,10 @@ static int __init atmel_nand_probe(struct platform_device *pdev) nand_chip->IO_ADDR_W = host->io_base; nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; -if (gpio_is_valid (host->board->rdy_pin)) +if (gpio_is_valid (host->board.rdy_pin)) nand_chip->dev_ready = atmel_nand_device_ready; - nand_chip->ecc.mode = host->board->ecc_mode; + nand_chip->ecc.mode = host->board.ecc_mode; regs =platform_get_resource (pdev,IORESOURCE_MEM ,1 );if (!regs && nand_chip->ecc.mode ==NAND_ECC_HW ) {@@ -545,7 +599,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) nand_chip->chip_delay =20 ;/* 20us command delay time */ -if (host->board->bus_width_16)/* 16-bit bus width */ +if (host->board.bus_width_16)/* 16-bit bus width */ nand_chip->options |=NAND_BUSWIDTH_16 ; nand_chip->read_buf = atmel_read_buf;@@ -554,15 +608,15 @@ static int __init atmel_nand_probe(struct platform_device *pdev)platform_set_drvdata (pdev, host);atmel_nand_enable (host); -if (gpio_is_valid (host->board->det_pin)) { -if (gpio_get_value (host->board->det_pin)) { +if (gpio_is_valid (host->board.det_pin)) { +if (gpio_get_value (host->board.det_pin)) {printk (KERN_INFO "No SmartMedia card inserted.\n" ); res = -ENXIO ; goto err_no_card; } } -if (host->board->on_flash_bbt || on_flash_bbt) { +if (host->board.on_flash_bbt || on_flash_bbt) {printk (KERN_INFO "atmel_nand: Use On Flash BBT\n" ); nand_chip->bbt_options |=NAND_BBT_USE_FLASH ; }@@ -637,8 +691,9 @@ static int __init atmel_nand_probe(struct platform_device *pdev) } mtd->name ="atmel_nand" ; - res =mtd_device_parse_register (mtd,NULL ,0 , - host->board->parts, host->board->num_parts); + ppdata.of_node = pdev->dev.of_node; + res =mtd_device_parse_register (mtd,NULL , &ppdata, + host->board.parts, host->board.num_parts);if (!res)return res;@@ -682,11 +737,21 @@ static int __exit atmel_nand_remove(struct platform_device *pdev)return 0 ; } +#if defined(CONFIG_OF ) +static const struct of_device_id atmel_nand_dt_ids[] = { + { .compatible ="atmel,at91rm9200-nand" }, + {/* sentinel */ } +}; + +MODULE_DEVICE_TABLE (of, atmel_nand_dt_ids); +#endif +static struct platform_driver atmel_nand_driver = { .remove =__exit_p (atmel_nand_remove), .driver = { .name ="atmel_nand" , .owner =THIS_MODULE , + .of_match_table =of_match_ptr (atmel_nand_dt_ids), }, };Signature · 1 line
1.7.7
PATCH v2 5/6 atmel/nand: add DT support
On Mon, 2012-02-20 at 18:17 +0100, Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines
HI David,
I've depeancy on other at91 patch can I apply this series via at91 tree?
Yes, please do.
Signature · 8 lines
dwmw2 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 5818 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120220/c1e046f9/attachment.bin>
PATCH v3 5/6 atmel/nand: add DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDUse a local copy of board informatin and fill with DT data.
---
v3:
protect against !CONFIG_OF
Best Regards,
J.
.../devicetree/bindings/mtd/atmel-nand.txt | 41 +++++++ arch/arm/boot/dts/at91sam9g20.dtsi | 17 +++ arch/arm/boot/dts/at91sam9g45.dtsi | 17 +++ arch/arm/boot/dts/at91sam9m10g45ek.dts | 26 +++++- arch/arm/boot/dts/usb_a9g20.dts | 46 ++++++++- arch/arm/mach-at91/at91sam9x5.c | 5 - arch/arm/mach-at91/board-dt.c | 52 --------- drivers/mtd/nand/atmel_nand.c | 113 ++++++++++++++++---- 8 files changed, 238 insertions(+), 79 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txt
Documentation/devicetree/bindings/mtd/atmel-nand.txt new file +41 -0
@@ -0,0 +1,41 @@ +Atmel NAND flash + +Required properties: +- compatible : "atmel,at91rm9200-nand". +- reg : should specify localbus address and size used for the chip, + and if availlable the ECC. +- atmel,nand-addr-offset : offset for the address latch. +- atmel,nand-cmd-offset : offset for the command latch. +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +- gpios : specifies the gpio pins to control the NAND device. detect is an + optional gpio and may be set to 0 if not present. + +Optional properties: +- 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". +- nand-bus-width : 8 or 16 bus width if not present 8 +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false + +Examples: +nand0: nand at 40000000,0 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + nand-on-flash-bbt = <1>; + nand-ecc-mode = "soft"; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + partition at 0 { + ... + }; +};
arch/arm/boot/dts/at91sam9g20.dtsi +17 -0
@@ -151,6 +151,23 @@ interrupts = <21 4>; status = "disabled"; }; + + nand0: nand at 40000000 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe800 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + gpios = <&pioC 13 0 + &pioC 14 0 + 0 + >; + status = "disabled"; + }; + }; }; };
arch/arm/boot/dts/at91sam9g45.dtsi +17 -0
@@ -158,6 +158,23 @@ interrupts = <25 4>; status = "disabled"; }; + + nand0: nand at 40000000 { + compatible = "atmel,at91rm9200-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x40000000 0x10000000 + 0xffffe200 0x200 + >; + atmel,nand-addr-offset = <21>; + atmel,nand-cmd-offset = <22>; + gpios = <&pioC 8 0 + &pioC 14 0 + 0 + >; + status = "disabled"; + }; + }; }; };
arch/arm/boot/dts/at91sam9m10g45ek.dts +25 -1
@@ -14,7 +14,7 @@ compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9"; chosen { - bootargs = "mem=64M console=ttyS0,115200 mtdparts=atmel_nand:4M(bootstrap/uboot/kernel)ro,60M(rootfs),-(data) root=/dev/mtdblock1 rw rootfstype=jffs2"; + bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"; }; memory at 70000000 {
@@ -35,6 +35,30 @@ phy-mode = "rmii"; status = "okay"; }; + + nand0: nand at 40000000 { + nand-bus-width = <8>; + nand-ecc-mode = "soft"; + nand-on-flash-bbt = <1>; + status = "okay"; + + boot at 0 { + label = "bootstrap/uboot/kernel"; + reg = <0x0 0x400000>; + }; + + rootfs at 400000 { + label = "rootfs"; + reg = <0x400000 0x3C00000>; + }; + + data at 4000000 { + label = "data"; + reg = <0x4000000 0xC000000>; + }; + + }; + }; }; };
arch/arm/boot/dts/usb_a9g20.dts +45 -1
58 lines not on this page · raw message
arch/arm/mach-at91/at91sam9x5.c +0 -5
@@ -316,11 +316,6 @@ void __init at91sam9x5_initialize(void) }/* -------------------------------------------------------------------- -* AT91SAM9x5 devices (temporary before modification of code) -* -------------------------------------------------------------------- */ -void __init at91_add_device_nand (struct atmel_nand_data *data) {} - -/* -------------------------------------------------------------------- * Interrupt initialization * -------------------------------------------------------------------- */ /*
arch/arm/mach-at91/board-dt.c +0 -52
73 lines not on this page · raw message
drivers/mtd/nand/atmel_nand.c +93 -20
224 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v3 5/6 atmel/nand: add DT support
On 02/21/2012 10:46 AM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 12 lines
Use a local copy of board informatin and fill with DT data.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org---
v3:protect against !CONFIG_OF
Quoted 8 lines
Best Regards,
J..../devicetree/bindings/mtd/atmel-nand.txt | 41 +++++++ arch/arm/boot/dts/at91sam9g20.dtsi | 17 +++ arch/arm/boot/dts/at91sam9g45.dtsi | 17 +++ arch/arm/boot/dts/at91sam9m10g45ek.dts | 26 +++++- arch/arm/boot/dts/usb_a9g20.dts | 46 ++++++++- arch/arm/mach-at91/at91sam9x5.c | 5 -
As we will put this series on top of 9x5, we may also add the entries in at91sam9x5.dtsi / at91sam9x5cm.dtsi ...
Quoted 4 lines
arch/arm/mach-at91/board-dt.c | 52 --------- drivers/mtd/nand/atmel_nand.c | 113 ++++++++++++++++---- 8 files changed, 238 insertions(+), 79 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txt
Otherwise,
Bye,
Signature · 1 line
Nicolas Ferre
PATCH v3 5/6 atmel/nand: add DT support
Quoted 22 lines · Nicolas Ferre
On 02/21/2012 10:46 AM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 12 lines
Use a local copy of board informatin and fill with DT data.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Grant Likely <[email protected]>Cc Nicolas Ferre <[email protected]>Cc devicetree-discuss at lists.ozlabs.orgCc linux-mtd at lists.infradead.org---
v3:protect against !CONFIG_OF
Quoted 8 lines
Best Regards,
J..../devicetree/bindings/mtd/atmel-nand.txt | 41 +++++++ arch/arm/boot/dts/at91sam9g20.dtsi | 17 +++ arch/arm/boot/dts/at91sam9g45.dtsi | 17 +++ arch/arm/boot/dts/at91sam9m10g45ek.dts | 26 +++++- arch/arm/boot/dts/usb_a9g20.dts | 46 ++++++++- arch/arm/mach-at91/at91sam9x5.c | 5 -
Quoted 2 lines
As we will put this series on top of 9x5, we may also add the entries in
at91sam9x5.dtsi/at91sam9x5cm.dtsi...
will add the sam9x5 support on an other patch
Best Regards,
J.
Quoted 18 lines
Quoted 5 lines
arch/arm/mach-at91/board-dt.c | 52 --------- drivers/mtd/nand/atmel_nand.c | 113 ++++++++++++++++---- 8 files changed, 238 insertions(+), 79 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-nand.txtOtherwise,
Acked-by Nicolas Ferre <[email protected]>Bye,
Signature · 6 lines
Nicolas Ferre _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel