* [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
@ 2009-02-06 11:14 Stanislaw Gruszka
2009-02-06 12:03 ` Sergei Shtylyov
2009-02-06 12:17 ` Sergei Shtylyov
0 siblings, 2 replies; 8+ messages in thread
From: Stanislaw Gruszka @ 2009-02-06 11:14 UTC (permalink / raw)
To: linux-ide, Andrew Victor; +Cc: linux-arm-kernel
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-06 11:14 [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu Stanislaw Gruszka
@ 2009-02-06 12:03 ` Sergei Shtylyov
2009-02-06 13:32 ` Stanislaw Gruszka
2009-02-06 12:17 ` Sergei Shtylyov
1 sibling, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2009-02-06 12:03 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: linux-ide, Andrew Victor, linux-arm-kernel
Hello.
Stanislaw Gruszka wrote:
> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>
[...]
> @@ -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)
>
Ugh... what are trying to achieve with this, marginal memory save?
> +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)
> +{
>
[...]
> + cf_resources[0].start = addr_space;
> + cf_resources[0].end = addr_space + SZ_256M - 1;
>
In the datasheet the CF mode address space is just 0x1000000, i.e. 16
MB, not 256. Moreover, address lines above A22 are not connected to CF
at all.
> +
> + 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;
> + }
> + }
>
Bart, I'm not sure: don't we support warm-plug now? Or it won't avail
us with CF?
> + 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);
> + }
>
Is there really a need to hard reset CF on every reboot?
> + if (data->vcc_pin)
> + /* initially off */
> + at91_set_gpio_output(data->vcc_pin, 0);
>
Why? Moreover, resetting CF without power applied (or cutting off
power afterwards) just doesn't make sense...
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-06 11:14 [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu Stanislaw Gruszka
2009-02-06 12:03 ` Sergei Shtylyov
@ 2009-02-06 12:17 ` Sergei Shtylyov
2009-02-06 13:33 ` Stanislaw Gruszka
1 sibling, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2009-02-06 12:17 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: linux-ide, Andrew Victor, linux-arm-kernel
Hello.
Stanislaw Gruszka wrote:
> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>
[...]
> 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
[...]
> +void __init at91_add_device_cf(struct at91_cf_data *data)
> +{
>
[...]
> + /* 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)
>
Again, I've probably missed something but this structre doesn't have
the 'flags' field. How is this suppoed to compile?
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-06 12:03 ` Sergei Shtylyov
@ 2009-02-06 13:32 ` Stanislaw Gruszka
2009-02-15 16:00 ` Sergei Shtylyov
0 siblings, 1 reply; 8+ messages in thread
From: Stanislaw Gruszka @ 2009-02-06 13:32 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: linux-ide, Andrew Victor, linux-arm-kernel
Friday 06 February 2009 13:03:54 Sergei Shtylyov napisał(a):
> > +/* --------------------------------------------------------------------
> > + * 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)
> >
>
> Ugh... what are trying to achieve with this, marginal memory save?
Some memory save. There are users which count every byte.
> > + cf_resources[0].start = addr_space;
> > + cf_resources[0].end = addr_space + SZ_256M - 1;
> >
>
> In the datasheet the CF mode address space is just 0x1000000, i.e. 16
> MB, not 256. Moreover, address lines above A22 are not connected to CF
> at all.
We take here all particular chip select address space
CS5: 0x50000000 - 0x5fffffff
CS6: 0x60000000 - 0x6fffffff
> > + 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;
> > + }
> > + }
> >
>
> Bart, I'm not sure: don't we support warm-plug now? Or it won't avail
> us with CF?
Uhh, this code is wrong at least for PCMCIA as we hotplug there. I don't think
hotplug is supported for ATA devices.
> > + 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);
> > + }
> >
>
> Is there really a need to hard reset CF on every reboot?
I think this have sense for ATA devices.
> > + if (data->vcc_pin)
> > + /* initially off */
> > + at91_set_gpio_output(data->vcc_pin, 0);
> >
>
> Why? Moreover, resetting CF without power applied (or cutting off
> power afterwards) just doesn't make sense...
Right.
Stanislaw Gruszka
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-06 12:17 ` Sergei Shtylyov
@ 2009-02-06 13:33 ` Stanislaw Gruszka
2009-02-06 17:23 ` Sergei Shtylyov
0 siblings, 1 reply; 8+ messages in thread
From: Stanislaw Gruszka @ 2009-02-06 13:33 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: linux-ide, Andrew Victor, linux-arm-kernel
Friday 06 February 2009 13:17:27 Sergei Shtylyov napisał(a):
> > +void __init at91_add_device_cf(struct at91_cf_data *data)
> > +{
> >
> [...]
> > + /* 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)
> >
>
> Again, I've probably missed something but this structre doesn't have
> the 'flags' field. How is this suppoed to compile?
Patch 2/3 add flags to the at91_cf_data structure.
Stanislaw Gruszka
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-06 13:33 ` Stanislaw Gruszka
@ 2009-02-06 17:23 ` Sergei Shtylyov
0 siblings, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2009-02-06 17:23 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: linux-ide, Andrew Victor, linux-arm-kernel
Stanislaw Gruszka wrote:
>>>+void __init at91_add_device_cf(struct at91_cf_data *data)
>>>+{
>>[...]
>>>+ /* 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)
>> Again, I've probably missed something but this structre doesn't have
>>the 'flags' field. How is this suppoed to compile?
> Patch 2/3 add flags to the at91_cf_data structure.
Ah, stupid me. Haven't looked at that patch yet. :-<
> Stanislaw Gruszka
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-06 13:32 ` Stanislaw Gruszka
@ 2009-02-15 16:00 ` Sergei Shtylyov
2009-02-15 16:07 ` Sergei Shtylyov
0 siblings, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2009-02-15 16:00 UTC (permalink / raw)
To: Stanislaw Gruszka, Bartlomiej Zolnierkiewicz
Cc: linux-ide, Andrew Victor, linux-arm-kernel
Hello.
Stanislaw Gruszka wrote:
>>>+ 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;
>>>+ }
>>>+ }
>> Bart, I'm not sure: don't we support warm-plug now? Or it won't avail
>>us with CF?
> Uhh, this code is wrong at least for PCMCIA as we hotplug there. I don't think
> hotplug is supported for ATA devices.
I didn't say hot plug, I said *warm* plug. You can force port probing via
sysfs, if I don't mistake... Bart?
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu
2009-02-15 16:00 ` Sergei Shtylyov
@ 2009-02-15 16:07 ` Sergei Shtylyov
0 siblings, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2009-02-15 16:07 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Bartlomiej Zolnierkiewicz, linux-ide, Andrew Victor,
linux-arm-kernel
Hello, I wrote:
>>>> + 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;
>>>> + }
>>>> + }
>>> Bart, I'm not sure: don't we support warm-plug now? Or it won't
>>> avail us with CF?
>> Uhh, this code is wrong at least for PCMCIA as we hotplug there. I
>> don't think
>> hotplug is supported for ATA devices.
> I didn't say hot plug, I said *warm* plug. You can force port probing
> via sysfs, if I don't mistake... Bart?
See Documentation/ide/warm-plug-howto.txt
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-02-15 16:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-06 11:14 [PATCH 3/3 v2] AT91: initialize Compact Flash on AT91SAM9263 cpu Stanislaw Gruszka
2009-02-06 12:03 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).