2 * drivers/pcmcia/sa1100_shannon.c
4 * PCMCIA implementation routines for Shannon
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/device.h>
11 #include <linux/init.h>
13 #include <asm/hardware.h>
14 #include <asm/mach-types.h>
15 #include <asm/arch/shannon.h>
17 #include "sa1100_generic.h"
19 static struct pcmcia_irqs irqs
[] = {
20 { 0, SHANNON_IRQ_GPIO_EJECT_0
, "PCMCIA_CD_0" },
21 { 1, SHANNON_IRQ_GPIO_EJECT_1
, "PCMCIA_CD_1" },
24 static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
26 /* All those are inputs */
27 GPDR
&= ~(SHANNON_GPIO_EJECT_0
| SHANNON_GPIO_EJECT_1
|
28 SHANNON_GPIO_RDY_0
| SHANNON_GPIO_RDY_1
);
29 GAFR
&= ~(SHANNON_GPIO_EJECT_0
| SHANNON_GPIO_EJECT_1
|
30 SHANNON_GPIO_RDY_0
| SHANNON_GPIO_RDY_1
);
32 skt
->irq
= skt
->nr
? SHANNON_IRQ_GPIO_RDY_1
: SHANNON_IRQ_GPIO_RDY_0
;
34 return soc_pcmcia_request_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
37 static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
39 soc_pcmcia_free_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
43 shannon_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
44 struct pcmcia_state
*state
)
46 unsigned long levels
= GPLR
;
50 state
->detect
= (levels
& SHANNON_GPIO_EJECT_0
) ? 0 : 1;
51 state
->ready
= (levels
& SHANNON_GPIO_RDY_0
) ? 1 : 0;
52 state
->wrprot
= 0; /* Not available on Shannon. */
55 state
->vs_3v
= 1; /* FIXME Can only apply 3.3V on Shannon. */
60 state
->detect
= (levels
& SHANNON_GPIO_EJECT_1
) ? 0 : 1;
61 state
->ready
= (levels
& SHANNON_GPIO_RDY_1
) ? 1 : 0;
62 state
->wrprot
= 0; /* Not available on Shannon. */
65 state
->vs_3v
= 1; /* FIXME Can only apply 3.3V on Shannon. */
72 shannon_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
73 const socket_state_t
*state
)
76 case 0: /* power off */
77 printk(KERN_WARNING
"%s(): CS asked for 0V, still applying 3.3V..\n", __FUNCTION__
);
80 printk(KERN_WARNING
"%s(): CS asked for 5V, applying 3.3V..\n", __FUNCTION__
);
84 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
85 __FUNCTION__
, state
->Vcc
);
89 printk(KERN_WARNING
"%s(): Warning, Can't perform reset\n", __FUNCTION__
);
91 /* Silently ignore Vpp, output enable, speaker enable. */
96 static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
98 soc_pcmcia_enable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
101 static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
103 soc_pcmcia_disable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
106 static struct pcmcia_low_level shannon_pcmcia_ops
= {
107 .owner
= THIS_MODULE
,
108 .hw_init
= shannon_pcmcia_hw_init
,
109 .hw_shutdown
= shannon_pcmcia_hw_shutdown
,
110 .socket_state
= shannon_pcmcia_socket_state
,
111 .configure_socket
= shannon_pcmcia_configure_socket
,
113 .socket_init
= shannon_pcmcia_socket_init
,
114 .socket_suspend
= shannon_pcmcia_socket_suspend
,
117 int __init
pcmcia_shannon_init(struct device
*dev
)
121 if (machine_is_shannon())
122 ret
= sa11xx_drv_pcmcia_probe(dev
, &shannon_pcmcia_ops
, 0, 2);