From: Stanislaw Gruszka <stf_xl@wp.pl>
To: linux-ide@vger.kernel.org, Andrew Victor <linux@maxim.org.za>
Cc: linux-arm-kernel@lists.arm.linux.org.uk
Subject: [PATCH 3/3] AT91: initialize IDE driver on AT91SAM9263 cpu
Date: Tue, 3 Feb 2009 11:47:41 +0100 [thread overview]
Message-ID: <200902031147.41822.stf_xl@wp.pl> (raw)
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
arch/arm/mach-at91/at91sam9263_devices.c | 97 ++++++++++++++++++++++++++++++
1 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index b753cb8..503651a 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -347,6 +347,103 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
#endif
+/* --------------------------------------------------------------------
+ * IDE
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
+
+/* Proper CS address space will be added */
+#define AT91_IDE_TASK_FILE 0x00c00000
+#define AT91_IDE_CTRL_REG 0x00e00000
+
+static struct resource ide_resources[] = {
+ [0] = {
+ .start = AT91_IDE_TASK_FILE,
+ .end = AT91_IDE_TASK_FILE + 16 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = AT91_IDE_CTRL_REG,
+ .end = AT91_IDE_CTRL_REG + 16 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct at91_ide_data ide_data;
+
+static struct platform_device at91_ide_device = {
+ .name = "at91_ide",
+ .id = -1,
+ .dev = {
+ .platform_data = &ide_data,
+ },
+ .resource = ide_resources,
+ .num_resources = ARRAY_SIZE(ide_resources),
+};
+
+void __init at91_add_device_ide(struct at91_ide_data *data)
+{
+ unsigned long ebi0_csa, addr_space;
+ u8 chipselect = data->chipselect;
+
+ /* enable PIO controlled pins, inputs with pull ups */
+ if (data->rst_pin)
+ at91_set_gpio_output(data->rst_pin, 0); /* reset card */
+
+ at91_set_gpio_input(data->irq_pin, 1);
+ at91_set_deglitch(data->irq_pin, 1);
+
+ if (data->det_pin) {
+ at91_set_gpio_input(data->det_pin, 1);
+ at91_set_deglitch(data->det_pin, 1);
+ }
+
+ /* enable EBI SMC controlled pins */
+ at91_set_A_periph(AT91_PIN_PD5, 1); /* NWAIT */
+ at91_set_A_periph(AT91_PIN_PD8, 0); /* CFCE1 */
+ at91_set_A_periph(AT91_PIN_PD9, 0); /* CFCE2 */
+ at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */
+
+ /* assign CS4/5 to SMC with Compact Flash logic support
+ * and fix resources addresses */
+ ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
+ switch (chipselect) {
+ case 4:
+ at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
+ ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1;
+ addr_space = AT91_CHIPSELECT_4;
+ break;
+ case 5:
+ at91_set_A_periph(AT91_PIN_PD7, 0); /* EBI0_NCS5/CFCS1 */
+ ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2;
+ addr_space = AT91_CHIPSELECT_5;
+ break;
+ default:
+ printk(KERN_ERR "at91_ide: bad chip select %u\n", chipselect);
+ return;
+ }
+ at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
+ ide_resources[0].start += addr_space;
+ ide_resources[0].end += addr_space;
+ ide_resources[1].start += addr_space;
+ ide_resources[1].end += addr_space;
+
+ /* turn on the card if reset pin is GPIO */
+ if (data->rst_pin)
+ at91_set_gpio_value(data->rst_pin, 1);
+
+ if (data->det_pin && at91_get_gpio_value(data->det_pin) != 0) {
+ printk(KERN_ERR "at91_ide: no Compact Flash card detected\n");
+ return;
+ }
+
+ ide_data = *data;
+ platform_device_register(&at91_ide_device);
+}
+#else
+void __init at91_add_device_ide(struct at91_ide_data *data) {}
+#endif
/* --------------------------------------------------------------------
* NAND / SmartMedia
--
1.5.2.5
next reply other threads:[~2009-02-03 10:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 10:47 Stanislaw Gruszka [this message]
2009-02-03 20:27 ` [PATCH 3/3] AT91: initialize IDE driver on AT91SAM9263 cpu Andrew Victor
2009-02-04 9:36 ` Stanislaw Gruszka
2009-02-05 12:03 ` Sergei Shtylyov
2009-02-05 19:43 ` Andrew Victor
2009-02-05 20:01 ` Sergei Shtylyov
2009-02-05 23:52 ` Sergei Shtylyov
2009-02-05 15:06 ` Stanislaw Gruszka
2009-02-04 12:18 ` Sergei Shtylyov
2009-02-04 14:15 ` Stanislaw Gruszka
2009-02-04 15:46 ` Sergei Shtylyov
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=200902031147.41822.stf_xl@wp.pl \
--to=stf_xl@wp.pl \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-ide@vger.kernel.org \
--cc=linux@maxim.org.za \
/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.