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/device.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/delay.h>
24 #include <asm/hardware.h>
25 #include <asm/hardware/sa1111.h>
26 #include <asm/mach-types.h>
27 #include <asm/arch/pxa-regs.h>
28 #include <asm/arch/lubbock.h>
30 #include "sa1111_generic.h"
33 lubbock_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
36 * Setup default state of GPIO outputs
37 * before we enable them as outputs.
40 GPIO_bit(GPIO48_nPOE
) |
41 GPIO_bit(GPIO49_nPWE
) |
42 GPIO_bit(GPIO50_nPIOR
) |
43 GPIO_bit(GPIO51_nPIOW
) |
44 GPIO_bit(GPIO52_nPCE_1
) |
45 GPIO_bit(GPIO53_nPCE_2
);
47 pxa_gpio_mode(GPIO48_nPOE_MD
);
48 pxa_gpio_mode(GPIO49_nPWE_MD
);
49 pxa_gpio_mode(GPIO50_nPIOR_MD
);
50 pxa_gpio_mode(GPIO51_nPIOW_MD
);
51 pxa_gpio_mode(GPIO52_nPCE_1_MD
);
52 pxa_gpio_mode(GPIO53_nPCE_2_MD
);
53 pxa_gpio_mode(GPIO54_pSKTSEL_MD
);
54 pxa_gpio_mode(GPIO55_nPREG_MD
);
55 pxa_gpio_mode(GPIO56_nPWAIT_MD
);
56 pxa_gpio_mode(GPIO57_nIOIS16_MD
);
58 return sa1111_pcmcia_hw_init(skt
);
62 lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
63 const socket_state_t
*state
)
65 unsigned int pa_dwr_mask
, pa_dwr_set
, misc_mask
, misc_set
;
68 pa_dwr_mask
= pa_dwr_set
= misc_mask
= misc_set
= 0;
70 /* Lubbock uses the Maxim MAX1602, with the following connections:
73 * MAX1602 Lubbock Register
75 * ----- ------- ----------------------
76 * A0VPP S0_PWR0 SA-1111 GPIO A<0>
77 * A1VPP S0_PWR1 SA-1111 GPIO A<1>
78 * A0VCC S0_PWR2 SA-1111 GPIO A<2>
79 * A1VCC S0_PWR3 SA-1111 GPIO A<3>
83 * CODE +3.3V Cirrus Code, CODE = High (VY)
86 * MAX1602 Lubbock Register
88 * ----- ------- ----------------------
89 * A0VPP GND VPP is not connected
90 * A1VPP GND VPP is not connected
91 * A0VCC S1_PWR0 MISC_WR<14>
92 * A1VCC S1_PWR1 MISC_WR<15>
95 * 12IN GND VPP is not connected
96 * CODE +3.3V Cirrus Code, CODE = High (VY)
103 pa_dwr_mask
= GPIO_A0
| GPIO_A1
| GPIO_A2
| GPIO_A3
;
105 switch (state
->Vcc
) {
110 pa_dwr_set
|= GPIO_A3
;
114 pa_dwr_set
|= GPIO_A2
;
118 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
119 __FUNCTION__
, state
->Vcc
);
123 switch (state
->Vpp
) {
128 pa_dwr_set
|= GPIO_A1
;
132 if (state
->Vpp
== state
->Vcc
)
133 pa_dwr_set
|= GPIO_A0
;
135 printk(KERN_ERR
"%s(): unrecognized Vpp %u\n",
136 __FUNCTION__
, state
->Vpp
);
144 misc_mask
= (1 << 15) | (1 << 14);
146 switch (state
->Vcc
) {
159 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
160 __FUNCTION__
, state
->Vcc
);
165 if (state
->Vpp
!= state
->Vcc
&& state
->Vpp
!= 0) {
166 printk(KERN_ERR
"%s(): CF slot cannot support Vpp %u\n",
167 __FUNCTION__
, state
->Vpp
);
178 ret
= sa1111_pcmcia_configure_socket(skt
, state
);
181 lubbock_set_misc_wr(misc_mask
, misc_set
);
182 sa1111_set_io(SA1111_DEV(skt
->dev
), pa_dwr_mask
, pa_dwr_set
);
186 if (ret
== 0 && state
->Vcc
== 33) {
187 struct pcmcia_state new_state
;
191 * We can't sense the voltage properly on Lubbock before
192 * actually applying some power to the socket (catch 22).
193 * Resense the socket Voltage Sense pins after applying
196 * Note: It takes about 2.5ms for the MAX1602 VCC output
201 sa1111_pcmcia_socket_state(skt
, &new_state
);
203 if (!new_state
.vs_3v
&& !new_state
.vs_Xv
) {
205 * Switch to 5V, Configure socket with 5V voltage
207 lubbock_set_misc_wr(misc_mask
, 0);
208 sa1111_set_io(SA1111_DEV(skt
->dev
), pa_dwr_mask
, 0);
211 * It takes about 100ms to turn off Vcc.
216 * We need to hack around the const qualifier as
217 * well to keep this ugly workaround localized and
218 * not force it to the rest of the code. Barf bags
219 * avaliable in the seat pocket in front of you!
221 ((socket_state_t
*)state
)->Vcc
= 50;
222 ((socket_state_t
*)state
)->Vpp
= 50;
231 static struct pcmcia_low_level lubbock_pcmcia_ops
= {
232 .owner
= THIS_MODULE
,
233 .hw_init
= lubbock_pcmcia_hw_init
,
234 .hw_shutdown
= sa1111_pcmcia_hw_shutdown
,
235 .socket_state
= sa1111_pcmcia_socket_state
,
236 .configure_socket
= lubbock_pcmcia_configure_socket
,
237 .socket_init
= sa1111_pcmcia_socket_init
,
238 .socket_suspend
= sa1111_pcmcia_socket_suspend
,
243 #include "pxa2xx_base.h"
245 int __init
pcmcia_lubbock_init(struct sa1111_dev
*sadev
)
249 if (machine_is_lubbock()) {
251 * Set GPIO_A<3:0> to be outputs for the MAX1600,
252 * and switch to standby mode.
254 sa1111_set_io_dir(sadev
, GPIO_A0
|GPIO_A1
|GPIO_A2
|GPIO_A3
, 0, 0);
255 sa1111_set_io(sadev
, GPIO_A0
|GPIO_A1
|GPIO_A2
|GPIO_A3
, 0);
256 sa1111_set_sleep_io(sadev
, GPIO_A0
|GPIO_A1
|GPIO_A2
|GPIO_A3
, 0);
258 /* Set CF Socket 1 power to standby mode. */
259 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0);
261 sadev
->dev
.platform_data
= &lubbock_pcmcia_ops
;
262 ret
= __pxa2xx_drv_pcmcia_probe(&sadev
->dev
);
268 MODULE_LICENSE("GPL");