2 * linux/drivers/pcmcia/pxa2xx_lubbock.c
5 * Created: Jan 10, 2002
6 * Copyright: MontaVista Software Inc.
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.
12 * Originally based upon linux/drivers/pcmcia/sa1100_neponset.c
14 * Lubbock PCMCIA specific routines.
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
20 #include <linux/device.h>
21 #include <linux/errno.h>
22 #include <linux/init.h>
23 #include <linux/delay.h>
25 #include <asm/hardware.h>
26 #include <asm/hardware/sa1111.h>
27 #include <asm/mach-types.h>
28 #include <asm/arch/pxa-regs.h>
29 #include <asm/arch/lubbock.h>
31 #include "sa1111_generic.h"
34 lubbock_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
37 * Setup default state of GPIO outputs
38 * before we enable them as outputs.
41 GPIO_bit(GPIO48_nPOE
) |
42 GPIO_bit(GPIO49_nPWE
) |
43 GPIO_bit(GPIO50_nPIOR
) |
44 GPIO_bit(GPIO51_nPIOW
) |
45 GPIO_bit(GPIO52_nPCE_1
) |
46 GPIO_bit(GPIO53_nPCE_2
);
48 pxa_gpio_mode(GPIO48_nPOE_MD
);
49 pxa_gpio_mode(GPIO49_nPWE_MD
);
50 pxa_gpio_mode(GPIO50_nPIOR_MD
);
51 pxa_gpio_mode(GPIO51_nPIOW_MD
);
52 pxa_gpio_mode(GPIO52_nPCE_1_MD
);
53 pxa_gpio_mode(GPIO53_nPCE_2_MD
);
54 pxa_gpio_mode(GPIO54_pSKTSEL_MD
);
55 pxa_gpio_mode(GPIO55_nPREG_MD
);
56 pxa_gpio_mode(GPIO56_nPWAIT_MD
);
57 pxa_gpio_mode(GPIO57_nIOIS16_MD
);
59 return sa1111_pcmcia_hw_init(skt
);
63 lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
64 const socket_state_t
*state
)
66 unsigned int pa_dwr_mask
, pa_dwr_set
, misc_mask
, misc_set
;
69 pa_dwr_mask
= pa_dwr_set
= misc_mask
= misc_set
= 0;
71 /* Lubbock uses the Maxim MAX1602, with the following connections:
74 * MAX1602 Lubbock Register
76 * ----- ------- ----------------------
77 * A0VPP S0_PWR0 SA-1111 GPIO A<0>
78 * A1VPP S0_PWR1 SA-1111 GPIO A<1>
79 * A0VCC S0_PWR2 SA-1111 GPIO A<2>
80 * A1VCC S0_PWR3 SA-1111 GPIO A<3>
84 * CODE +3.3V Cirrus Code, CODE = High (VY)
87 * MAX1602 Lubbock Register
89 * ----- ------- ----------------------
90 * A0VPP GND VPP is not connected
91 * A1VPP GND VPP is not connected
92 * A0VCC S1_PWR0 MISC_WR<14>
93 * A1VCC S1_PWR1 MISC_WR<15>
96 * 12IN GND VPP is not connected
97 * CODE +3.3V Cirrus Code, CODE = High (VY)
104 pa_dwr_mask
= GPIO_A0
| GPIO_A1
| GPIO_A2
| GPIO_A3
;
106 switch (state
->Vcc
) {
111 pa_dwr_set
|= GPIO_A3
;
115 pa_dwr_set
|= GPIO_A2
;
119 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
120 __FUNCTION__
, state
->Vcc
);
124 switch (state
->Vpp
) {
129 pa_dwr_set
|= GPIO_A1
;
133 if (state
->Vpp
== state
->Vcc
)
134 pa_dwr_set
|= GPIO_A0
;
136 printk(KERN_ERR
"%s(): unrecognized Vpp %u\n",
137 __FUNCTION__
, state
->Vpp
);
145 misc_mask
= (1 << 15) | (1 << 14);
147 switch (state
->Vcc
) {
160 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
161 __FUNCTION__
, state
->Vcc
);
166 if (state
->Vpp
!= state
->Vcc
&& state
->Vpp
!= 0) {
167 printk(KERN_ERR
"%s(): CF slot cannot support Vpp %u\n",
168 __FUNCTION__
, state
->Vpp
);
179 ret
= sa1111_pcmcia_configure_socket(skt
, state
);
182 lubbock_set_misc_wr(misc_mask
, misc_set
);
183 sa1111_set_io(SA1111_DEV(skt
->dev
), pa_dwr_mask
, pa_dwr_set
);
187 if (ret
== 0 && state
->Vcc
== 33) {
188 struct pcmcia_state new_state
;
192 * We can't sense the voltage properly on Lubbock before
193 * actually applying some power to the socket (catch 22).
194 * Resense the socket Voltage Sense pins after applying
197 * Note: It takes about 2.5ms for the MAX1602 VCC output
202 sa1111_pcmcia_socket_state(skt
, &new_state
);
204 if (!new_state
.vs_3v
&& !new_state
.vs_Xv
) {
206 * Switch to 5V, Configure socket with 5V voltage
208 lubbock_set_misc_wr(misc_mask
, 0);
209 sa1111_set_io(SA1111_DEV(skt
->dev
), pa_dwr_mask
, 0);
212 * It takes about 100ms to turn off Vcc.
217 * We need to hack around the const qualifier as
218 * well to keep this ugly workaround localized and
219 * not force it to the rest of the code. Barf bags
220 * avaliable in the seat pocket in front of you!
222 ((socket_state_t
*)state
)->Vcc
= 50;
223 ((socket_state_t
*)state
)->Vpp
= 50;
232 static struct pcmcia_low_level lubbock_pcmcia_ops
= {
233 .owner
= THIS_MODULE
,
234 .hw_init
= lubbock_pcmcia_hw_init
,
235 .hw_shutdown
= sa1111_pcmcia_hw_shutdown
,
236 .socket_state
= sa1111_pcmcia_socket_state
,
237 .configure_socket
= lubbock_pcmcia_configure_socket
,
238 .socket_init
= sa1111_pcmcia_socket_init
,
239 .socket_suspend
= sa1111_pcmcia_socket_suspend
,
244 #include "pxa2xx_base.h"
246 int __init
pcmcia_lubbock_init(struct sa1111_dev
*sadev
)
250 if (machine_is_lubbock()) {
252 * Set GPIO_A<3:0> to be outputs for the MAX1600,
253 * and switch to standby mode.
255 sa1111_set_io_dir(sadev
, GPIO_A0
|GPIO_A1
|GPIO_A2
|GPIO_A3
, 0, 0);
256 sa1111_set_io(sadev
, GPIO_A0
|GPIO_A1
|GPIO_A2
|GPIO_A3
, 0);
257 sa1111_set_sleep_io(sadev
, GPIO_A0
|GPIO_A1
|GPIO_A2
|GPIO_A3
, 0);
259 /* Set CF Socket 1 power to standby mode. */
260 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0);
262 sadev
->dev
.platform_data
= &lubbock_pcmcia_ops
;
263 ret
= pxa2xx_drv_pcmcia_probe(&sadev
->dev
);
269 MODULE_LICENSE("GPL");