UBI: fix bug in atomic_leb_change()
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / pcmcia / sa1100_h3600.c
blobe5491879acd9191a962293b0c83b12b65637b4e1
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/device.h>
10 #include <linux/interrupt.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
14 #include <asm/hardware.h>
15 #include <asm/irq.h>
16 #include <asm/mach-types.h>
17 #include <asm/arch/h3600.h>
19 #include "sa1100_generic.h"
21 static struct pcmcia_irqs irqs[] = {
22 { 0, IRQ_GPIO_H3600_PCMCIA_CD0, "PCMCIA CD0" },
23 { 1, IRQ_GPIO_H3600_PCMCIA_CD1, "PCMCIA CD1" }
26 static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
28 skt->irq = skt->nr ? IRQ_GPIO_H3600_PCMCIA_IRQ1
29 : IRQ_GPIO_H3600_PCMCIA_IRQ0;
32 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
35 static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
37 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
39 /* Disable CF bus: */
40 clr_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON);
41 clr_h3600_egpio(IPAQ_EGPIO_OPT_ON);
42 set_h3600_egpio(IPAQ_EGPIO_OPT_RESET);
45 static void
46 h3600_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
48 unsigned long levels = GPLR;
50 switch (skt->nr) {
51 case 0:
52 state->detect = levels & GPIO_H3600_PCMCIA_CD0 ? 0 : 1;
53 state->ready = levels & GPIO_H3600_PCMCIA_IRQ0 ? 1 : 0;
54 state->bvd1 = 0;
55 state->bvd2 = 0;
56 state->wrprot = 0; /* Not available on H3600. */
57 state->vs_3v = 0;
58 state->vs_Xv = 0;
59 break;
61 case 1:
62 state->detect = levels & GPIO_H3600_PCMCIA_CD1 ? 0 : 1;
63 state->ready = levels & GPIO_H3600_PCMCIA_IRQ1 ? 1 : 0;
64 state->bvd1 = 0;
65 state->bvd2 = 0;
66 state->wrprot = 0; /* Not available on H3600. */
67 state->vs_3v = 0;
68 state->vs_Xv = 0;
69 break;
73 static int
74 h3600_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
76 if (state->Vcc != 0 && state->Vcc != 33 && state->Vcc != 50) {
77 printk(KERN_ERR "h3600_pcmcia: unrecognized Vcc %u.%uV\n",
78 state->Vcc / 10, state->Vcc % 10);
79 return -1;
82 if (state->flags & SS_RESET)
83 set_h3600_egpio(IPAQ_EGPIO_CARD_RESET);
84 else
85 clr_h3600_egpio(IPAQ_EGPIO_CARD_RESET);
87 /* Silently ignore Vpp, output enable, speaker enable. */
89 return 0;
92 static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
94 /* Enable CF bus: */
95 set_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON);
96 set_h3600_egpio(IPAQ_EGPIO_OPT_ON);
97 clr_h3600_egpio(IPAQ_EGPIO_OPT_RESET);
99 msleep(10);
101 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
104 static void h3600_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
106 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
109 * FIXME: This doesn't fit well. We don't have the mechanism in
110 * the generic PCMCIA layer to deal with the idea of two sockets
111 * on one bus. We rely on the cs.c behaviour shutting down
112 * socket 0 then socket 1.
114 if (skt->nr == 1) {
115 clr_h3600_egpio(IPAQ_EGPIO_OPT_ON);
116 clr_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON);
117 /* hmm, does this suck power? */
118 set_h3600_egpio(IPAQ_EGPIO_OPT_RESET);
122 struct pcmcia_low_level h3600_pcmcia_ops = {
123 .owner = THIS_MODULE,
124 .hw_init = h3600_pcmcia_hw_init,
125 .hw_shutdown = h3600_pcmcia_hw_shutdown,
126 .socket_state = h3600_pcmcia_socket_state,
127 .configure_socket = h3600_pcmcia_configure_socket,
129 .socket_init = h3600_pcmcia_socket_init,
130 .socket_suspend = h3600_pcmcia_socket_suspend,
133 int __init pcmcia_h3600_init(struct device *dev)
135 int ret = -ENODEV;
137 if (machine_is_h3600())
138 ret = sa11xx_drv_pcmcia_probe(dev, &h3600_pcmcia_ops, 0, 2);
140 return ret;