initial commit with v2.6.9
[linux-2.6.9-moxart.git] / drivers / pcmcia / sa1100_pfs168.c
blob6dab93a494113fec2d23d10dcb2e4dd026a45c64
1 #warning "REVISIT_PFS168: Need to verify and test GPIO power encodings."
2 /*
3 * drivers/pcmcia/sa1100_pfs168.c
5 * PFS168 PCMCIA specific routines
7 */
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/delay.h>
12 #include <linux/device.h>
13 #include <linux/init.h>
15 #include <asm/hardware.h>
16 #include <asm/mach-types.h>
17 #include <asm/irq.h>
19 #include "sa1111_generic.h"
21 static int pfs168_pcmcia_init(struct soc_pcmcia_socket *skt)
23 /* TPS2211 to standby mode: */
24 PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
26 /* Set GPIO_A<3:0> to be outputs for PCMCIA (socket 0) power controller: */
27 PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
29 return sa1111_pcmcia_init(skt);
32 static int
33 pfs168_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
34 const socket_state_t *state)
36 unsigned int pa_dwr_mask = 0, pa_dwr_set = 0;
37 int ret;
39 /* PFS168 uses the Texas Instruments TPS2211 for PCMCIA (socket 0) voltage control only,
40 * with the following connections:
42 * TPS2211 PFS168
44 * -VCCD0 SA-1111 GPIO A<0>
45 * -VCCD0 SA-1111 GPIO A<1>
46 * VPPD0 SA-1111 GPIO A<2>
47 * VPPD0 SA-1111 GPIO A<2>
51 switch (skt->nr) {
52 case 0:
53 pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
55 switch (state->Vcc) {
56 default:
57 case 0: pa_dwr_set = 0; break;
58 case 33: pa_dwr_set = GPIO_GPIO0; break;
59 case 50: pa_dwr_set = GPIO_GPIO1; break;
62 switch (state->Vpp) {
63 case 0:
64 break;
66 case 120:
67 printk(KERN_ERR "%s(): PFS-168 does not support VPP %uV\n",
68 __FUNCTION__, state->Vpp / 10);
69 return -1;
70 break;
72 default:
73 if (state->Vpp == state->Vcc)
74 pa_dwr_set |= GPIO_GPIO3;
75 else {
76 printk(KERN_ERR "%s(): unrecognized VPP %u\n", __FUNCTION__,
77 state->Vpp);
78 return -1;
81 break;
83 case 1:
84 pa_dwr_mask = 0;
85 pa_dwr_set = 0;
87 switch (conf->vcc) {
88 case 0:
89 case 33:
90 break;
92 case 50:
93 printk(KERN_ERR "%s(): PFS-168 CompactFlash socket does not support VCC %uV\n",
94 __FUNCTION__, state->Vcc / 10);
95 return -1;
97 default:
98 printk(KERN_ERR "%s(): unrecognized VCC %u\n", __FUNCTION__,
99 state->Vcc);
100 return -1;
103 if (state->Vpp != state->Vcc && state->Vpp != 0) {
104 printk(KERN_ERR "%s(): CompactFlash socket does not support VPP %uV\n",
105 __FUNCTION__, state->Vpp / 10);
106 return -1;
108 break;
111 ret = sa1111_pcmcia_configure_socket(skt, state);
112 if (ret == 0) {
113 unsigned long flags;
115 local_irq_save(flags);
116 PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
117 local_irq_restore(flags);
120 return 0;
123 static struct pcmcia_low_level pfs168_pcmcia_ops = {
124 .owner = THIS_MODULE,
125 .hw_init = pfs168_pcmcia_hw_init,
126 .hw_shutdown = sa1111_pcmcia_hw_shutdown,
127 .socket_state = sa1111_pcmcia_socket_state,
128 .configure_socket = pfs168_pcmcia_configure_socket,
129 .socket_init = sa1111_pcmcia_socket_init,
130 .socket_suspend = sa1111_pcmcia_socket_suspend,
133 int __init pcmcia_pfs168_init(struct device *dev)
135 int ret = -ENODEV;
137 if (machine_is_pfs168())
138 ret = sa11xx_drv_pcmcia_probe(dev, &pfs168_pcmcia_ops, 0, 2);
140 return ret;