All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <stf_xl@wp.pl>
To: linux-ide@vger.kernel.org, Andrew Victor <avictor.za@gmail.com>
Cc: linux-arm-kernel@lists.arm.linux.org.uk
Subject: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
Date: Fri, 6 Feb 2009 12:14:19 +0100	[thread overview]
Message-ID: <200902061214.19789.stf_xl@wp.pl> (raw)

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 arch/arm/mach-at91/at91sam9263_devices.c |  106 ++++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index b753cb8..7c950f1 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -15,6 +15,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/i2c-gpio.h>
+#include <linux/delay.h>
 
 #include <linux/fb.h>
 #include <video/atmel_lcdc.h>
@@ -347,6 +348,111 @@ 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
 
+/* --------------------------------------------------------------------
+ *  Compact Flash (PCMCIA or IDE)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) || \
+    defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
+
+static struct resource cf_resources[] = {
+	[0] = {
+		.start	= 0,
+		.end	= 0,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct at91_cf_data cf_data;
+
+static struct platform_device at91_cf_device = {
+	.id 	= -1,
+	.dev	= {
+		.platform_data = &cf_data,
+	},
+	.resource = cf_resources,
+	.num_resources = ARRAY_SIZE(cf_resources),
+};
+
+void __init at91_add_device_cf(struct at91_cf_data *data)
+{
+	unsigned long ebi0_csa, addr_space;
+
+	if (!data)
+		return;
+
+	/*
+	 * assign CS4 or CS5 to SMC with Compact Flash logic support,
+	 * we assume SMC timings are configured by board code,
+	 * except True IDE where timings are controlled by driver
+	 */
+	ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
+	switch (data->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: CF bad chip-select requested (%u)\n",
+		       data->chipselect);
+		return;
+	}
+	at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
+
+	cf_resources[0].start = addr_space;
+	cf_resources[0].end = addr_space + SZ_256M - 1;
+
+	if (data->det_pin) {
+		/* check if device is present */
+		at91_set_gpio_input(data->det_pin, 1);
+		at91_set_deglitch(data->det_pin, 1);
+		if (at91_get_gpio_value(data->det_pin) != 0) {
+			printk(KERN_ERR "AT91: no CF card detected\n");
+			return;
+		}
+	}
+
+	if (data->rst_pin) {
+		/* reset the card */
+		int reset = (data->flags & AT91_CF_TRUE_IDE) ? 0 : 1;
+
+		at91_set_gpio_output(data->rst_pin, reset);
+		udelay(25); /* taken from ATA docs, CFA not specify it ? */
+		at91_set_gpio_output(data->rst_pin, !reset);
+	}
+
+	if (data->irq_pin) {
+		at91_set_gpio_input(data->irq_pin, 1);
+		at91_set_deglitch(data->irq_pin, 1);
+	}
+
+	if (data->vcc_pin)
+		/* initially off */
+		at91_set_gpio_output(data->vcc_pin, 0);
+
+	/* enable EBI 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 */
+
+	if (data->flags & AT91_CF_TRUE_IDE)
+		at91_cf_device.name = "at91_ide";
+	else
+		at91_cf_device.name = "at91_cf";
+
+	cf_data = *data;
+	platform_device_register(&at91_cf_device);
+}
+#else
+void __init at91_add_device_cf(struct at91_ide_data *data) {}
+#endif
 
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
-- 
1.5.2.5

             reply	other threads:[~2009-02-06 11:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06 11:14 Stanislaw Gruszka [this message]
2009-02-06 12:03 ` [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu Sergei Shtylyov
2009-02-06 13:32   ` Stanislaw Gruszka
2009-02-15 16:00     ` Sergei Shtylyov
2009-02-15 16:07       ` Sergei Shtylyov
2009-02-06 12:17 ` Sergei Shtylyov
2009-02-06 13:33   ` Stanislaw Gruszka
2009-02-06 17:23     ` 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=200902061214.19789.stf_xl@wp.pl \
    --to=stf_xl@wp.pl \
    --cc=avictor.za@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-ide@vger.kernel.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.