Merge tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-block.git] / drivers / pcmcia / sa1111_lubbock.c
CommitLineData
1da177e4
LT
1/*
2 * linux/drivers/pcmcia/pxa2xx_lubbock.c
3 *
4 * Author: George Davis
5 * Created: Jan 10, 2002
6 * Copyright: MontaVista Software Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Originally based upon linux/drivers/pcmcia/sa1100_neponset.c
13 *
14 * Lubbock PCMCIA specific routines.
15 *
16 */
17#include <linux/module.h>
18#include <linux/kernel.h>
1da177e4
LT
19#include <linux/device.h>
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23
a09e64fb 24#include <mach/hardware.h>
1da177e4
LT
25#include <asm/hardware/sa1111.h>
26#include <asm/mach-types.h>
1da177e4
LT
27
28#include "sa1111_generic.h"
f1f05ee1
RK
29#include "max1600.h"
30
31static int lubbock_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
32{
33 struct max1600 *m;
34 int ret;
35
36 ret = max1600_init(skt->socket.dev.parent, &m,
37 skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A,
38 MAX1600_CODE_HIGH);
39 if (ret == 0)
40 skt->driver_data = m;
41
42 return ret;
43}
1da177e4 44
1da177e4
LT
45static int
46lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
47 const socket_state_t *state)
48{
f1f05ee1 49 struct max1600 *m = skt->driver_data;
1da177e4
LT
50 int ret = 0;
51
1da177e4
LT
52 /* Lubbock uses the Maxim MAX1602, with the following connections:
53 *
54 * Socket 0 (PCMCIA):
55 * MAX1602 Lubbock Register
56 * Pin Signal
57 * ----- ------- ----------------------
58 * A0VPP S0_PWR0 SA-1111 GPIO A<0>
59 * A1VPP S0_PWR1 SA-1111 GPIO A<1>
60 * A0VCC S0_PWR2 SA-1111 GPIO A<2>
61 * A1VCC S0_PWR3 SA-1111 GPIO A<3>
62 * VX VCC
63 * VY +3.3V
64 * 12IN +12V
65 * CODE +3.3V Cirrus Code, CODE = High (VY)
66 *
67 * Socket 1 (CF):
68 * MAX1602 Lubbock Register
69 * Pin Signal
70 * ----- ------- ----------------------
71 * A0VPP GND VPP is not connected
72 * A1VPP GND VPP is not connected
73 * A0VCC S1_PWR0 MISC_WR<14>
74 * A1VCC S1_PWR1 MISC_WR<15>
75 * VX VCC
76 * VY +3.3V
77 * 12IN GND VPP is not connected
78 * CODE +3.3V Cirrus Code, CODE = High (VY)
79 *
80 */
81
82 again:
83 switch (skt->nr) {
84 case 0:
1da177e4 85 case 1:
1da177e4
LT
86 break;
87
88 default:
89 ret = -1;
90 }
91
92 if (ret == 0)
93 ret = sa1111_pcmcia_configure_socket(skt, state);
f1f05ee1
RK
94 if (ret == 0)
95 ret = max1600_configure(m, state->Vcc, state->Vpp);
1da177e4
LT
96
97#if 1
98 if (ret == 0 && state->Vcc == 33) {
99 struct pcmcia_state new_state;
100
101 /*
102 * HACK ALERT:
103 * We can't sense the voltage properly on Lubbock before
104 * actually applying some power to the socket (catch 22).
105 * Resense the socket Voltage Sense pins after applying
106 * socket power.
107 *
108 * Note: It takes about 2.5ms for the MAX1602 VCC output
109 * to rise.
110 */
111 mdelay(3);
112
113 sa1111_pcmcia_socket_state(skt, &new_state);
114
115 if (!new_state.vs_3v && !new_state.vs_Xv) {
116 /*
117 * Switch to 5V, Configure socket with 5V voltage
118 */
f1f05ee1 119 max1600_configure(m, 0, 0);
1da177e4
LT
120
121 /*
122 * It takes about 100ms to turn off Vcc.
123 */
124 mdelay(100);
125
126 /*
127 * We need to hack around the const qualifier as
128 * well to keep this ugly workaround localized and
129 * not force it to the rest of the code. Barf bags
25985edc 130 * available in the seat pocket in front of you!
1da177e4
LT
131 */
132 ((socket_state_t *)state)->Vcc = 50;
133 ((socket_state_t *)state)->Vpp = 50;
134 goto again;
135 }
136 }
137#endif
138
139 return ret;
140}
141
142static struct pcmcia_low_level lubbock_pcmcia_ops = {
143 .owner = THIS_MODULE,
f1f05ee1 144 .hw_init = lubbock_pcmcia_hw_init,
1da177e4 145 .configure_socket = lubbock_pcmcia_configure_socket,
1da177e4
LT
146 .first = 0,
147 .nr = 2,
148};
149
150#include "pxa2xx_base.h"
151
7bbaac12 152int pcmcia_lubbock_init(struct sa1111_dev *sadev)
1da177e4 153{
3f8df892 154 pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops);
817ed574 155 pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops);
3f8df892
RK
156 return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops,
157 pxa2xx_drv_pcmcia_add_one);
1da177e4
LT
158}
159
160MODULE_LICENSE("GPL");