MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / pcmcia / sa1100_pangolin.c
blob44d19f2dcf44f0c5cfaaec6e3eb4c1ced6e23394
1 /*
2 * drivers/pcmcia/sa1100_pangolin.c
4 * PCMCIA implementation routines for Pangolin
6 */
7 #include <linux/config.h>
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/device.h>
12 #include <linux/init.h>
14 #include <asm/hardware.h>
15 #include <asm/mach-types.h>
16 #include <asm/irq.h>
17 #include "sa1100_generic.h"
19 #ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
20 #define PANGOLIN_SOCK 1
21 #else
22 #define PANGOLIN_SOCK 0
23 #endif
25 static struct pcmcia_irqs irqs[] = {
26 { PANGOLIN_SOCK, IRQ_PCMCIA_CD, "PCMCIA CD" },
29 static int pangolin_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
31 int res;
33 #ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
34 /* Enable PCMCIA bus: */
35 GPCR = GPIO_PCMCIA_BUS_ON;
36 #endif
38 skt->irq = IRQ_PCMCIA_IRQ;
40 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
43 static void pangolin_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
45 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
47 #ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
48 /* Disable PCMCIA bus: */
49 GPSR = GPIO_PCMCIA_BUS_ON;
50 #endif
53 static void
54 pangolin_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
55 struct pcmcia_state *state)
57 unsigned long levels = GPLR;
59 state->detect=((levels & GPIO_PCMCIA_CD)==0)?1:0;
60 state->ready=(levels & GPIO_PCMCIA_IRQ)?1:0;
61 state->bvd1=1; /* Not available on Pangolin. */
62 state->bvd2=1; /* Not available on Pangolin. */
63 state->wrprot=0; /* Not available on Pangolin. */
64 state->vs_3v=1; /* Can only apply 3.3V on Pangolin. */
65 state->vs_Xv=0;
68 static int
69 pangolin_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
70 const socket_state_t *state)
72 unsigned long value, flags;
74 local_irq_save(flags);
76 /* Murphy: BUS_ON different from POWER ? */
78 switch (state->Vcc) {
79 case 0:
80 break;
81 #ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
82 case 50:
83 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
84 __FUNCTION__);
85 case 33: /* Can only apply 3.3V to the CF slot. */
86 break;
87 #else
88 case 50:
89 printk(KERN_WARNING "%s(): CS asked for 5V, determinded by "
90 "jumper setting...\n", __FUNCTION__);
91 break;
92 case 33:
93 printk(KERN_WARNING "%s(): CS asked for 3.3V, determined by "
94 "jumper setting...\n", __FUNCTION__);
95 break;
96 #endif
97 default:
98 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
99 __FUNCTION__, state->Vcc);
100 local_irq_restore(flags);
101 return -1;
103 #ifdef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
104 /* reset & unreset request */
105 if (skt->nr == 0) {
106 if (state->flags & SS_RESET) {
107 GPSR = GPIO_PCMCIA_RESET;
108 } else {
109 GPCR = GPIO_PCMCIA_RESET;
112 #endif
113 /* Silently ignore Vpp, output enable, speaker enable. */
114 local_irq_restore(flags);
115 return 0;
118 static void pangolin_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
120 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
123 static void pangolin_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
125 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
128 static struct pcmcia_low_level pangolin_pcmcia_ops = {
129 .owner = THIS_MODULE,
130 .hw_init = pangolin_pcmcia_hw_init,
131 .hw_shutdown = pangolin_pcmcia_hw_shutdown,
132 .socket_state = pangolin_pcmcia_socket_state,
133 .configure_socket = pangolin_pcmcia_configure_socket,
135 .socket_init = pangolin_pcmcia_socket_init,
136 .socket_suspend = pangolin_pcmcia_socket_suspend,
139 int __init pcmcia_pangolin_init(struct device *dev)
141 int ret = -ENODEV;
143 if (machine_is_pangolin())
144 ret = sa11xx_drv_pcmcia_probe(dev, &pangolin_pcmcia_ops, PANGOLIN_SOCK, 1);
146 return ret;