2 * drivers/pcmcia/sa1100_yopy.c
4 * PCMCIA implementation routines for Yopy
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
10 #include <asm/hardware.h>
12 #include "sa1100_generic.h"
15 static inline void pcmcia_power(int on) {
16 /* high for power up */
17 yopy_gpio_set(GPIO_CF_POWER, on);
20 static inline void pcmcia_reset(int reset)
23 yopy_gpio_set(GPIO_CF_RESET, reset);
26 static int yopy_pcmcia_init(struct pcmcia_init *init)
33 /* Set transition detect */
34 set_GPIO_IRQ_edge(GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1,
36 set_GPIO_IRQ_edge( GPIO_CF_IREQ, GPIO_FALLING_EDGE );
38 /* Register interrupts */
40 res = request_irq(irq, init->handler, SA_INTERRUPT, "CF_CD", NULL);
41 if (res < 0) goto irq_err;
43 res = request_irq(irq, init->handler, SA_INTERRUPT, "CF_BVD2", NULL);
44 if (res < 0) goto irq_err;
46 res = request_irq(irq, init->handler, SA_INTERRUPT, "CF_BVD1", NULL);
47 if (res < 0) goto irq_err;
51 printk(KERN_ERR "%s: Request for IRQ %d failed\n", __FUNCTION__, irq);
55 static int yopy_pcmcia_shutdown(void)
58 free_irq( IRQ_CF_CD, NULL );
59 free_irq( IRQ_CF_BVD2, NULL );
60 free_irq( IRQ_CF_BVD1, NULL );
69 static int yopy_pcmcia_socket_state(struct pcmcia_state_array *state_array)
73 if (state_array->size != 1)
76 memset(state_array->state, 0,
77 state_array->size * sizeof(struct pcmcia_state));
81 state_array->state[0].detect = (levels & GPIO_CF_CD) ? 0 : 1;
82 state_array->state[0].ready = (levels & GPIO_CF_READY) ? 1 : 0;
83 state_array->state[0].bvd1 = (levels & GPIO_CF_BVD1) ? 1 : 0;
84 state_array->state[0].bvd2 = (levels & GPIO_CF_BVD2) ? 1 : 0;
85 state_array->state[0].wrprot = 0; /* Not available on Yopy. */
86 state_array->state[0].vs_3v = 0; /* FIXME Can only apply 3.3V on Yopy. */
87 state_array->state[0].vs_Xv = 0;
92 static int yopy_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
97 info->irq = IRQ_CF_IREQ;
102 static int yopy_pcmcia_configure_socket(const struct pcmcia_configure *configure)
104 if (configure->sock != 0)
107 switch (configure->vcc) {
108 case 0: /* power off */;
112 printk(KERN_WARNING __FUNCTION__"(): CS asked for 5V, applying 3.3V..\n");
117 printk(KERN_ERR __FUNCTION__"(): unrecognized Vcc %u\n",
122 pcmcia_reset(configure->reset);
124 /* Silently ignore Vpp, output enable, speaker enable. */
129 static int yopy_pcmcia_socket_init(int sock)
131 set_GPIO_IRQ_edge(GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1,
136 static int yopy_pcmcia_socket_suspend(int sock)
138 set_GPIO_IRQ_edge(GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1,
143 struct pcmcia_low_level yopy_pcmcia_ops = {
144 init: yopy_pcmcia_init,
145 shutdown: yopy_pcmcia_shutdown,
146 socket_state: yopy_pcmcia_socket_state,
147 get_irq_info: yopy_pcmcia_get_irq_info,
148 configure_socket: yopy_pcmcia_configure_socket,
150 socket_init: yopy_pcmcia_socket_init,
151 socket_suspend: yopy_pcmcia_socket_suspend,