1 #warning "REVISIT_PFS168: Need to verify and test GPIO power encodings."
2 /*
3 * drivers/pcmcia/sa1100_pfs168.c
4 *
5 * PFS168 PCMCIA specific routines
6 *
7 */
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10
11 #include <asm/delay.h>
12 #include <asm/hardware.h>
13 #include <asm/irq.h>
14
15 #include "sa1100_generic.h"
16 #include "sa1111_generic.h"
17
pfs168_pcmcia_init(struct pcmcia_init * init)18 static int pfs168_pcmcia_init(struct pcmcia_init *init)
19 {
20 /* TPS2211 to standby mode: */
21 PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
22
23 /* Set GPIO_A<3:0> to be outputs for PCMCIA (socket 0) power controller: */
24 PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
25
26 return sa1111_pcmcia_init(init);
27 }
28
29 static int
pfs168_pcmcia_configure_socket(const struct pcmcia_configure * conf)30 pfs168_pcmcia_configure_socket(const struct pcmcia_configure *conf)
31 {
32 unsigned int pa_dwr_mask = 0, pa_dwr_set = 0;
33 int ret;
34
35 /* PFS168 uses the Texas Instruments TPS2211 for PCMCIA (socket 0) voltage control only,
36 * with the following connections:
37 *
38 * TPS2211 PFS168
39 *
40 * -VCCD0 SA-1111 GPIO A<0>
41 * -VCCD0 SA-1111 GPIO A<1>
42 * VPPD0 SA-1111 GPIO A<2>
43 * VPPD0 SA-1111 GPIO A<2>
44 *
45 */
46
47 switch (conf->sock) {
48 case 0:
49 pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
50
51 switch (conf->vcc) {
52 default:
53 case 0: pa_dwr_set = 0; break;
54 case 33: pa_dwr_set = GPIO_GPIO0; break;
55 case 50: pa_dwr_set = GPIO_GPIO1; break;
56 }
57
58 switch (conf->vpp) {
59 case 0:
60 break;
61
62 case 120:
63 printk(KERN_ERR "%s(): PFS-168 does not support VPP %uV\n",
64 __FUNCTION__, conf->vpp / 10);
65 return -1;
66 break;
67
68 default:
69 if (conf->vpp == conf->vcc)
70 pa_dwr_set |= GPIO_GPIO3;
71 else {
72 printk(KERN_ERR "%s(): unrecognized VPP %u\n", __FUNCTION__,
73 conf->vpp);
74 return -1;
75 }
76 }
77 break;
78
79 case 1:
80 pa_dwr_mask = 0;
81 pa_dwr_set = 0;
82
83 switch (conf->vcc) {
84 case 0:
85 case 33:
86 break;
87
88 case 50:
89 printk(KERN_ERR "%s(): PFS-168 CompactFlash socket does not support VCC %uV\n",
90 __FUNCTION__, conf->vcc / 10);
91 return -1;
92
93 default:
94 printk(KERN_ERR "%s(): unrecognized VCC %u\n", __FUNCTION__,
95 conf->vcc);
96 return -1;
97 }
98
99 if (conf->vpp != conf->vcc && conf->vpp != 0) {
100 printk(KERN_ERR "%s(): CompactFlash socket does not support VPP %uV\n"
101 __FUNCTION__, conf->vpp/10);
102 return -1;
103 }
104 break;
105 }
106
107 ret = sa1111_pcmcia_configure_socket(conf);
108 if (ret == 0) {
109 unsigned long flags;
110
111 local_irq_save(flags);
112 PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
113 local_irq_restore(flags);
114 }
115
116 return 0;
117 }
118
119 struct pcmcia_low_level pfs168_pcmcia_ops = {
120 init: pfs168_pcmcia_init,
121 shutdown: sa1111_pcmcia_shutdown,
122 socket_state: sa1111_pcmcia_socket_state,
123 get_irq_info: sa1111_pcmcia_get_irq_info,
124 configure_socket: pfs168_pcmcia_configure_socket,
125
126 socket_init: sa1111_pcmcia_socket_init,
127 socket_suspend: sa1111_pcmcia_socket_suspend,
128 };
129