From: ryan@bluewatersys.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V4 06/23] at91: Make NAND device common
Date: Tue, 3 May 2011 12:03:20 +1200 [thread overview]
Message-ID: <1304381017-17912-7-git-send-email-ryan@bluewatersys.com> (raw)
In-Reply-To: <1304381017-17912-1-git-send-email-ryan@bluewatersys.com>
Replace the individual NAND code for each at91 variant with a single
implementation in devices.c
Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
---
arch/arm/mach-at91/at572d940hf_devices.c | 65 ++++--------------------
arch/arm/mach-at91/at91cap9_devices.c | 62 ++--------------------
arch/arm/mach-at91/at91rm9200_devices.c | 81 +++++++-----------------------
arch/arm/mach-at91/at91sam9260_devices.c | 62 ++--------------------
arch/arm/mach-at91/at91sam9261_devices.c | 63 ++++-------------------
arch/arm/mach-at91/at91sam9263_devices.c | 62 ++--------------------
arch/arm/mach-at91/at91sam9g45_devices.c | 62 ++--------------------
arch/arm/mach-at91/at91sam9rl_devices.c | 66 ++----------------------
arch/arm/mach-at91/devices.c | 57 +++++++++++++++++++++
arch/arm/mach-at91/devices.h | 12 ++++
10 files changed, 139 insertions(+), 453 deletions(-)
diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c
index 2d029a7..771e1bf 100644
--- a/arch/arm/mach-at91/at572d940hf_devices.c
+++ b/arch/arm/mach-at91/at572d940hf_devices.c
@@ -104,64 +104,20 @@ static struct at91_dev_table_mmc device_mmc __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_pin_config nand_pins[] __initdata = {
+ {AT91_PIN_PB28, AT91_PIN_PERIPH_A, 0, 0, 0}, /* A[22] */
+ {AT91_PIN_PA28, AT91_PIN_PERIPH_B, 0, 0, 0}, /* NANDOE */
+ {AT91_PIN_PA29, AT91_PIN_PERIPH_B, 0, 0, 0}, /* NANDWE */
};
-static struct platform_device at572d940hf_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBICSA,
+ .enable = AT91_MATRIX_CS3A_SMC_SMARTMEDIA,
+ .pins = nand_pins,
+ .nr_pins = ARRAY_SIZE(nand_pins),
};
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBICSA);
- at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- at91_set_A_periph(AT91_PIN_PB28, 0); /* A[22] */
- at91_set_B_periph(AT91_PIN_PA28, 0); /* NANDOE */
- at91_set_B_periph(AT91_PIN_PA29, 0); /* NANDWE */
-
- nand_data = *data;
- platform_device_register(&at572d940hf_nand_device);
-}
-
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -787,6 +743,7 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
.usbh_ohci = &device_usbh_ohci,
.udc = &device_udc,
.mmc[0] = &device_mmc,
+ .nand = &device_nand,
};
void __init at572d940hf_init_devices(void)
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index 9a5c59c..773eb95 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -228,64 +228,13 @@ static struct at91_dev_table_mmc device_mmc1 __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- [0] = {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91_BASE_SYS + AT91_ECC,
- .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBICSA,
+ .enable = AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA,
+ .ecc_mmio_base = AT91_BASE_SYS + AT91_ECC,
};
-static struct platform_device at91cap9_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
-};
-
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBICSA);
- at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- nand_data = *data;
- platform_device_register(&at91cap9_nand_device);
-}
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -1101,6 +1050,7 @@ static struct at91_device_table at91cap9_device_table __initdata = {
.usbh_ohci = &device_usbh_ohci,
.mmc[0] = &device_mmc0,
.mmc[1] = &device_mmc1,
+ .nand = &device_nand,
};
void __init at91cap9_init_devices(void)
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 4763662..90ca534 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -198,70 +198,26 @@ static struct at91_dev_table_mmc device_mmc __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- }
-};
-
-static struct platform_device at91rm9200_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
-};
-
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned int csa;
-
- if (!data)
- return;
-
- /* enable the address range of CS3 */
- csa = at91_sys_read(AT91_EBI_CSA);
- at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
-
- /* set the bus interface characteristics */
- at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
+static struct at91_pin_config nand_pins[] __initdata = {
+ {AT91_PIN_PC1, AT91_PIN_PERIPH_A, 0, 0, 0}, /* SMOE */
+ {AT91_PIN_PC3, AT91_PIN_PERIPH_A, 0, 0, 0}, /* SMWE */
+};
+
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_EBI_CSA,
+ .enable = AT91_EBI_CS3A_SMC_SMARTMEDIA,
+ .flags_reg = AT91_SMC_CSR(3),
+ .flags = (
+ AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
| AT91_SMC_NWS_(5)
| AT91_SMC_TDF_(1)
- | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
- | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */
- );
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
- at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
-
- nand_data = *data;
- platform_device_register(&at91rm9200_nand_device);
-}
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
+ | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
+ | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */
+ ),
+ .pins = nand_pins,
+ .nr_pins = ARRAY_SIZE(nand_pins),
+};
/* --------------------------------------------------------------------
* TWI (i2c)
@@ -1005,6 +961,7 @@ static struct at91_device_table at91rm9200_device_table __initdata = {
.usbh_ohci = &device_usbh_ohci,
.udc = &device_udc,
.mmc[0] = &device_mmc,
+ .nand = &device_nand,
};
void __init at91rm9200_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 5f1aaca..f48ad70 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -113,64 +113,13 @@ static struct at91_dev_table_mmc device_mmc __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- [0] = {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91_BASE_SYS + AT91_ECC,
- .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBICSA,
+ .enable = AT91_MATRIX_CS3A_SMC_SMARTMEDIA,
+ .ecc_mmio_base = AT91_BASE_SYS + AT91_ECC,
};
-static struct platform_device at91sam9260_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
-};
-
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBICSA);
- at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- nand_data = *data;
- platform_device_register(&at91sam9260_nand_device);
-}
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -1065,6 +1014,7 @@ static struct at91_device_table at91sam9260_device_table __initdata = {
.usbh_ohci = &device_usbh_ohci,
.udc = &device_udc,
.mmc[0] = &device_mmc,
+ .nand = &device_nand,
};
void __init at91sam9260_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 4bf9a09..9505ae3 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -70,63 +70,19 @@ static struct at91_dev_table_mmc device_mmc __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_pin_config nand_pins[] __initdata = {
+ {AT91_PIN_PC0, AT91_PIN_PERIPH_A, 0, 0, 0}, /* NANDOE */
+ {AT91_PIN_PC1, AT91_PIN_PERIPH_A, 0, 0, 0}, /* NANDWE */
};
-static struct platform_device atmel_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBICSA,
+ .enable = AT91_MATRIX_CS3A_SMC_SMARTMEDIA,
+ .pins = nand_pins,
+ .nr_pins = ARRAY_SIZE(nand_pins),
};
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBICSA);
- at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */
- at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */
-
- nand_data = *data;
- platform_device_register(&atmel_nand_device);
-}
-
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -920,6 +876,7 @@ static struct at91_device_table at91sam9261_device_table __initdata = {
.usbh_ohci = &device_usbh_ohci,
.udc = &device_udc,
.mmc[0] = &device_mmc,
+ .nand = &device_nand,
};
void __init at91sam9261_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 708d24a..37b06f7 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -248,64 +248,13 @@ void __init at91_add_device_cf(struct at91_cf_data *data) {}
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- [0] = {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91_BASE_SYS + AT91_ECC0,
- .end = AT91_BASE_SYS + AT91_ECC0 + SZ_512 - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBI0CSA,
+ .enable = AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA,
+ .ecc_mmio_base = AT91_BASE_SYS + AT91_ECC0,
};
-static struct platform_device at91sam9263_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
-};
-
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
- at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- nand_data = *data;
- platform_device_register(&at91sam9263_nand_device);
-}
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -1222,6 +1171,7 @@ static struct at91_device_table at91sam9263_device_table __initdata = {
.udc = &device_udc,
.mmc[0] = &device_mmc0,
.mmc[1] = &device_mmc1,
+ .nand = &device_nand,
};
void __init at91sam9263_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 745b1a2..9650547 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -272,64 +272,13 @@ static struct at91_dev_table_mmc device_mmc1 __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- [0] = {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91_BASE_SYS + AT91_ECC,
- .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBICSA,
+ .enable = AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA,
+ .ecc_mmio_base = AT91_BASE_SYS + AT91_ECC,
};
-static struct platform_device at91sam9g45_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
-};
-
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBICSA);
- at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- nand_data = *data;
- platform_device_register(&at91sam9g45_nand_device);
-}
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -1347,6 +1296,7 @@ static struct at91_device_table at91sam9g45_device_table __initdata = {
.usbh_ehci = &device_usb_ehci,
.mmc[0] = &device_mmc0,
.mmc[1] = &device_mmc1,
+ .nand = &device_nand,
};
void __init at91sam9g45_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 352e30c..e0b7302 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -189,68 +189,13 @@ static struct at91_dev_table_mmc device_mmc __initdata = {
* NAND / SmartMedia
* -------------------------------------------------------------------- */
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
- [0] = {
- .start = NAND_BASE,
- .end = NAND_BASE + SZ_256M - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91_BASE_SYS + AT91_ECC,
- .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
- .flags = IORESOURCE_MEM,
- }
+static struct at91_dev_table_nand device_nand __initdata = {
+ .chip_select = 3,
+ .enable_reg = AT91_MATRIX_EBICSA,
+ .enable = AT91_MATRIX_CS3A_SMC_SMARTMEDIA,
+ .ecc_mmio_base = AT91_BASE_SYS + AT91_ECC,
};
-static struct platform_device atmel_nand_device = {
- .name = "atmel_nand",
- .id = -1,
- .dev = {
- .platform_data = &nand_data,
- },
- .resource = nand_resources,
- .num_resources = ARRAY_SIZE(nand_resources),
-};
-
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
- unsigned long csa;
-
- if (!data)
- return;
-
- csa = at91_sys_read(AT91_MATRIX_EBICSA);
- at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
-
- /* enable pin */
- if (data->enable_pin)
- at91_set_gpio_output(data->enable_pin, 1);
-
- /* ready/busy pin */
- if (data->rdy_pin)
- at91_set_gpio_input(data->rdy_pin, 1);
-
- /* card detect pin */
- if (data->det_pin)
- at91_set_gpio_input(data->det_pin, 1);
-
- at91_set_A_periph(AT91_PIN_PB4, 0); /* NANDOE */
- at91_set_A_periph(AT91_PIN_PB5, 0); /* NANDWE */
-
- nand_data = *data;
- platform_device_register(&atmel_nand_device);
-}
-
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* TWI (i2c)
* -------------------------------------------------------------------- */
@@ -1152,6 +1097,7 @@ void __init at91_add_device_serial(void) {}
static struct at91_device_table at91sam9rl_device_table __initdata = {
.mmc[0] = &device_mmc,
+ .nand = &device_nand,
};
void __init at91sam9rl_init_devices(void)
diff --git a/arch/arm/mach-at91/devices.c b/arch/arm/mach-at91/devices.c
index bf98964..1292f51 100644
--- a/arch/arm/mach-at91/devices.c
+++ b/arch/arm/mach-at91/devices.c
@@ -448,6 +448,63 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
}
#else
void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
+#endif
+
+/* --------------------------------------------------------------------
+ * NAND / SmartMedia
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
+static struct platform_device at91_nand_device = {
+ .name = "atmel_nand",
+ .id = -1,
+};
+
+void __init at91_add_device_nand(struct atmel_nand_data *data)
+{
+ struct at91_dev_table_nand *info = devices->nand;
+ struct resource resources[2] = {{0}};
+ int nr_resources = 1;
+ unsigned long csa;
+
+ BUG_ON(!info);
+ init_resource_mem(&resources[0], (info->chip_select + 1) * 0x10000000,
+ SZ_256M);
+ if (info->ecc_mmio_base) {
+ init_resource_mem(&resources[1], info->ecc_mmio_base, SZ_512);
+ nr_resources++;
+ }
+
+ if (!data)
+ return;
+
+ /* enable the address range for the chip-select */
+ csa = at91_sys_read(info->enable_reg);
+ at91_sys_write(info->enable_reg, csa | info->enable);
+
+ if (info->flags_reg && info->flags)
+ at91_sys_write(info->flags_reg, info->flags);
+
+ /* enable pin */
+ if (data->enable_pin)
+ at91_set_gpio_output(data->enable_pin, 1);
+
+ /* ready/busy pin */
+ if (data->rdy_pin)
+ at91_set_gpio_input(data->rdy_pin, 1);
+
+ /* card detect pin */
+ if (data->det_pin)
+ at91_set_gpio_input(data->det_pin, 1);
+
+ if (info->pins)
+ at91_config_pins(info->pins, info->nr_pins);
+
+ at91_add_platform_device(&at91_nand_device, resources, nr_resources,
+ data, sizeof(*data));
+}
+#else
+void __init at91_add_device_nand(struct atmel_nand_data *data) {}
#endif
void __init at91_init_devices(struct at91_device_table *device_table)
diff --git a/arch/arm/mach-at91/devices.h b/arch/arm/mach-at91/devices.h
index eab2f54..3e9ec54 100644
--- a/arch/arm/mach-at91/devices.h
+++ b/arch/arm/mach-at91/devices.h
@@ -62,12 +62,24 @@ struct at91_dev_table_mmc {
struct at91_mmc_pins slot[2];
};
+struct at91_dev_table_nand {
+ unsigned chip_select;
+ unsigned enable_reg;
+ unsigned enable;
+ unsigned ecc_mmio_base;
+ unsigned flags_reg;
+ unsigned flags;
+ struct at91_pin_config *pins;
+ int nr_pins;
+};
+
struct at91_device_table {
struct at91_dev_table_ethernet *ethernet;
struct at91_dev_table_usb_ohci *usbh_ohci;
struct at91_dev_table_basic_device *usbh_ehci;
struct at91_dev_table_basic_device *udc;
struct at91_dev_table_mmc *mmc[2];
+ struct at91_dev_table_nand *nand;
};
extern void __init at91_init_devices(struct at91_device_table *device_table);
--
1.7.0.4
next prev parent reply other threads:[~2011-05-03 0:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 0:03 [PATCH V4 00/23] Create common framework for AT91 device initialisation Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 01/23] at91: Add common devices framework Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 02/23] at91: Make Ethernet device common Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 03/23] at91: Make USB OHCI/EHCI devices common Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 04/23] at91: Make UDC device common Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 05/23] at91: Make MMC " Ryan Mallon
2011-05-03 0:03 ` Ryan Mallon [this message]
2011-05-03 0:03 ` [PATCH V4 07/23] at91: Make TWI " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 08/23] at91: Make SPI " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 09/23] at91: Make TCB " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 10/23] at91: Make RTT " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 11/23] at91: Make watchdog " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 12/23] at91: Make UART devices common Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 13/23] at91: Make PWM device common Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 14/23] at91: Make SSC " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 15/23] at91: Make AC97 " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 16/23] at91: Make LCD controller " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 17/23] at91: Make touchscreen " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 18/23] at91: Make HDMAC " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 19/23] at91: Make RTC " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 20/23] at91: Make high speed USB gadget " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 21/23] at91: Make compact flash " Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 22/23] at91: Move at91sam9263 CAN device to common devices Ryan Mallon
2011-05-03 0:03 ` [PATCH V4 23/23] at91: Remove mAgic and ISI device code Ryan Mallon
2011-05-03 0:08 ` [PATCH V4 00/23] Create common framework for AT91 device initialisation Jean-Christophe PLAGNIOL-VILLARD
2011-05-03 0:20 ` Ryan Mallon
2011-05-03 0:19 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304381017-17912-7-git-send-email-ryan@bluewatersys.com \
--to=ryan@bluewatersys.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.