[PATCH] x86_64: CPU hotplug sibling map cleanup
[linux/fpc-iii.git] / drivers / pcmcia / sa1100_h3600.c
blob64fd5e37f2d22d12617bc6066dcaab33a6e95098
1 /*
2 * drivers/pcmcia/sa1100_h3600.c
4 * PCMCIA implementation routines for H3600
6 */
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/device.h>
11 #include <linux/interrupt.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
15 #include <asm/hardware.h>
16 #include <asm/irq.h>
17 #include <asm/mach-types.h>
18 #include <asm/arch/h3600.h>
20 #include "sa1100_generic.h"
22 static struct pcmcia_irqs irqs[] = {
23 { 0, IRQ_GPIO_H3600_PCMCIA_CD0, "PCMCIA CD0" },
24 { 1, IRQ_GPIO_H3600_PCMCIA_CD1, "PCMCIA CD1" }
27 static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
29 skt->irq = skt->nr ? IRQ_GPIO_H3600_PCMCIA_IRQ1
30 : IRQ_GPIO_H3600_PCMCIA_IRQ0;
33 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
36 static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
38 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
40 /* Disable CF bus: */
41 clr_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON);
42 clr_h3600_egpio(IPAQ_EGPIO_OPT_ON);
43 set_h3600_egpio(IPAQ_EGPIO_OPT_RESET);
46 static void
47 h3600_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
49 unsigned long levels = GPLR;
51 switch (skt->nr) {
52 case 0:
53 state->detect = levels & GPIO_H3600_PCMCIA_CD0 ? 0 : 1;
54 state->ready = levels & GPIO_H3600_PCMCIA_IRQ0 ? 1 : 0;
55 state->bvd1 = 0;
56 state->bvd2 = 0;
57 state->wrprot = 0; /* Not available on H3600. */
58 state->vs_3v = 0;
59 state->vs_Xv = 0;
60 break;
62 case 1:
63 state->detect = levels & GPIO_H3600_PCMCIA_CD1 ? 0 : 1;
64 state->ready = levels & GPIO_H3600_PCMCIA_IRQ1 ? 1 : 0;
65 state->bvd1 = 0;
66 state->bvd2 = 0;
67 state->wrprot = 0; /* Not available on H3600. */
68 state->vs_3v = 0;
69 state->vs_Xv = 0;
70 break;
74 static int
75 h3600_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
77 if (state->Vcc != 0 && state->Vcc != 33 && state->Vcc != 50) {
78 printk(KERN_ERR "h3600_pcmcia: unrecognized Vcc %u.%uV\n",
79 state->Vcc / 10, state->Vcc % 10);
80 return -1;
83 if (state->flags & SS_RESET)
84 set_h3600_egpio(IPAQ_EGPIO_CARD_RESET);
85 else
86 clr_h3600_egpio(IPAQ_EGPIO_CARD_RESET);
88 /* Silently ignore Vpp, output enable, speaker enable. */
90 return 0;
93 static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
95 /* Enable CF bus: */
96 set_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON);
97 set_h3600_egpio(IPAQ_EGPIO_OPT_ON);
98 clr_h3600_egpio(IPAQ_EGPIO_OPT_RESET);
100 msleep(10);
102 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
105 static void h3600_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
107 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
110 * FIXME: This doesn't fit well. We don't have the mechanism in
111 * the generic PCMCIA layer to deal with the idea of two sockets
112 * on one bus. We rely on the cs.c behaviour shutting down
113 * socket 0 then socket 1.
115 if (skt->nr == 1) {
116 clr_h3600_egpio(IPAQ_EGPIO_OPT_ON);
117 clr_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON);
118 /* hmm, does this suck power? */
119 set_h3600_egpio(IPAQ_EGPIO_OPT_RESET);
123 struct pcmcia_low_level h3600_pcmcia_ops = {
124 .owner = THIS_MODULE,
125 .hw_init = h3600_pcmcia_hw_init,
126 .hw_shutdown = h3600_pcmcia_hw_shutdown,
127 .socket_state = h3600_pcmcia_socket_state,
128 .configure_socket = h3600_pcmcia_configure_socket,
130 .socket_init = h3600_pcmcia_socket_init,
131 .socket_suspend = h3600_pcmcia_socket_suspend,
134 int __init pcmcia_h3600_init(struct device *dev)
136 int ret = -ENODEV;
138 if (machine_is_h3600())
139 ret = sa11xx_drv_pcmcia_probe(dev, &h3600_pcmcia_ops, 0, 2);
141 return ret;