ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held
[linux/fpc-iii.git] / drivers / pcmcia / sa1100_cerf.c
blob30560df8c76b6893151ae1f22654492177bdb78f
1 /*
2 * drivers/pcmcia/sa1100_cerf.c
4 * PCMCIA implementation routines for CerfBoard
5 * Based off the Assabet.
7 */
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/device.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
14 #include <mach/hardware.h>
15 #include <asm/mach-types.h>
16 #include <asm/irq.h>
17 #include <mach/cerf.h>
18 #include "sa1100_generic.h"
20 #define CERF_SOCKET 1
22 static struct pcmcia_irqs irqs[] = {
23 { CERF_SOCKET, CERF_IRQ_GPIO_CF_CD, "CF_CD" },
24 { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD2, "CF_BVD2" },
25 { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD1, "CF_BVD1" }
28 static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
30 skt->socket.pci_irq = CERF_IRQ_GPIO_CF_IRQ;
32 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
35 static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
37 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
40 static void
41 cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
43 unsigned long levels = GPLR;
45 state->detect = (levels & CERF_GPIO_CF_CD) ?0:1;
46 state->ready = (levels & CERF_GPIO_CF_IRQ) ?1:0;
47 state->bvd1 = (levels & CERF_GPIO_CF_BVD1)?1:0;
48 state->bvd2 = (levels & CERF_GPIO_CF_BVD2)?1:0;
49 state->wrprot = 0;
50 state->vs_3v = 1;
51 state->vs_Xv = 0;
54 static int
55 cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
56 const socket_state_t *state)
58 switch (state->Vcc) {
59 case 0:
60 case 50:
61 case 33:
62 break;
64 default:
65 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
66 __func__, state->Vcc);
67 return -1;
70 if (state->flags & SS_RESET) {
71 GPSR = CERF_GPIO_CF_RESET;
72 } else {
73 GPCR = CERF_GPIO_CF_RESET;
76 return 0;
79 static void cerf_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
81 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
84 static void cerf_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
86 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
89 static struct pcmcia_low_level cerf_pcmcia_ops = {
90 .owner = THIS_MODULE,
91 .hw_init = cerf_pcmcia_hw_init,
92 .hw_shutdown = cerf_pcmcia_hw_shutdown,
93 .socket_state = cerf_pcmcia_socket_state,
94 .configure_socket = cerf_pcmcia_configure_socket,
96 .socket_init = cerf_pcmcia_socket_init,
97 .socket_suspend = cerf_pcmcia_socket_suspend,
100 int __devinit pcmcia_cerf_init(struct device *dev)
102 int ret = -ENODEV;
104 if (machine_is_cerf())
105 ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1);
107 return ret;