]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/pcmcia/sa1111_lubbock.c
Merge tag 'perf-core-for-mingo-5.2-20190517' of git://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-hirsute-kernel.git] / drivers / pcmcia / sa1111_lubbock.c
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>
19 #include <linux/device.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/delay.h>
23
24 #include <mach/hardware.h>
25 #include <asm/hardware/sa1111.h>
26 #include <asm/mach-types.h>
27
28 #include "sa1111_generic.h"
29 #include "max1600.h"
30
31 static 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 }
44
45 static int
46 lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
47 const socket_state_t *state)
48 {
49 struct max1600 *m = skt->driver_data;
50 int ret = 0;
51
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:
85 case 1:
86 break;
87
88 default:
89 ret = -1;
90 }
91
92 if (ret == 0)
93 ret = sa1111_pcmcia_configure_socket(skt, state);
94 if (ret == 0)
95 ret = max1600_configure(m, state->Vcc, state->Vpp);
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 */
119 max1600_configure(m, 0, 0);
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
130 * available in the seat pocket in front of you!
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
142 static struct pcmcia_low_level lubbock_pcmcia_ops = {
143 .owner = THIS_MODULE,
144 .hw_init = lubbock_pcmcia_hw_init,
145 .configure_socket = lubbock_pcmcia_configure_socket,
146 .first = 0,
147 .nr = 2,
148 };
149
150 #include "pxa2xx_base.h"
151
152 int pcmcia_lubbock_init(struct sa1111_dev *sadev)
153 {
154 pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops);
155 pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops);
156 return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops,
157 pxa2xx_drv_pcmcia_add_one);
158 }
159
160 MODULE_LICENSE("GPL");