sparc64: Fix MSIQ HV call ordering in pci_sun4v_msiq_build_irq().
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / pcmcia / sa1100_simpad.c
blob0fac9658b020194825388330d953de1744a0f49a
1 /*
2 * drivers/pcmcia/sa1100_simpad.c
4 * PCMCIA implementation routines for simpad
6 */
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/device.h>
10 #include <linux/init.h>
12 #include <mach/hardware.h>
13 #include <asm/mach-types.h>
14 #include <asm/irq.h>
15 #include <mach/simpad.h>
16 #include "sa1100_generic.h"
18 static struct pcmcia_irqs irqs[] = {
19 { 1, IRQ_GPIO_CF_CD, "CF_CD" },
22 static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
27 skt->socket.pci_irq = IRQ_GPIO_CF_IRQ;
29 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
32 static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
34 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
36 /* Disable CF bus: */
37 /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
38 simpad_clear_cs3_bit(PCMCIA_RESET);
41 static void
42 simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
43 struct pcmcia_state *state)
45 unsigned long levels = GPLR;
46 long cs3reg = simpad_get_cs3_ro();
48 state->detect=((levels & GPIO_CF_CD)==0)?1:0;
49 state->ready=(levels & GPIO_CF_IRQ)?1:0;
50 state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */
51 state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */
52 state->wrprot=0; /* Not available on Simpad. */
54 if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) ==
55 (PCMCIA_VS1|PCMCIA_VS2)) {
56 state->vs_3v=0;
57 state->vs_Xv=0;
58 } else {
59 state->vs_3v=1;
60 state->vs_Xv=0;
64 static int
65 simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
66 const socket_state_t *state)
68 unsigned long flags;
70 local_irq_save(flags);
72 /* Murphy: see table of MIC2562a-1 */
73 switch (state->Vcc) {
74 case 0:
75 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
76 break;
78 case 33:
79 simpad_clear_cs3_bit(VCC_3V_EN|EN1);
80 simpad_set_cs3_bit(VCC_5V_EN|EN0);
81 break;
83 case 50:
84 simpad_clear_cs3_bit(VCC_5V_EN|EN1);
85 simpad_set_cs3_bit(VCC_3V_EN|EN0);
86 break;
88 default:
89 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
90 __func__, state->Vcc);
91 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
92 local_irq_restore(flags);
93 return -1;
97 local_irq_restore(flags);
99 return 0;
102 static void simpad_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
104 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
107 static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
109 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
110 simpad_set_cs3_bit(PCMCIA_RESET);
113 static struct pcmcia_low_level simpad_pcmcia_ops = {
114 .owner = THIS_MODULE,
115 .hw_init = simpad_pcmcia_hw_init,
116 .hw_shutdown = simpad_pcmcia_hw_shutdown,
117 .socket_state = simpad_pcmcia_socket_state,
118 .configure_socket = simpad_pcmcia_configure_socket,
119 .socket_init = simpad_pcmcia_socket_init,
120 .socket_suspend = simpad_pcmcia_socket_suspend,
123 int __devinit pcmcia_simpad_init(struct device *dev)
125 int ret = -ENODEV;
127 if (machine_is_simpad())
128 ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
130 return ret;