2 * linux/drivers/pcmcia/pxa2xx_trizeps4.c
4 * TRIZEPS PCMCIA specific routines.
6 * Author: Jürgen Schindele
8 * Copyright: Jürgen Schindele
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/gpio.h>
19 #include <linux/interrupt.h>
20 #include <linux/platform_device.h>
22 #include <asm/mach-types.h>
25 #include <mach/pxa2xx-regs.h>
26 #include <mach/trizeps4.h>
28 #include "soc_common.h"
30 extern void board_pcmcia_power(int power
);
32 static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
34 /* we dont have voltage/card/ready detection
35 * so we dont need interrupts for it
39 skt
->stat
[SOC_STAT_CD
].gpio
= GPIO_PCD
;
40 skt
->stat
[SOC_STAT_CD
].name
= "cs0_cd";
41 skt
->stat
[SOC_STAT_RDY
].gpio
= GPIO_PRDY
;
42 skt
->stat
[SOC_STAT_RDY
].name
= "cs0_rdy";
47 /* release the reset of this card */
48 pr_debug("%s: sock %d irq %d\n", __func__
, skt
->nr
, skt
->socket
.pci_irq
);
53 static unsigned long trizeps_pcmcia_status
[2];
55 static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
56 struct pcmcia_state
*state
)
58 unsigned short status
= 0, change
;
59 status
= CFSR_readw();
60 change
= (status
^ trizeps_pcmcia_status
[skt
->nr
]) &
63 trizeps_pcmcia_status
[skt
->nr
] = status
;
64 if (status
& ConXS_CFSR_BVD1
) {
65 /* enable_irq empty */
67 /* disable_irq empty */
73 /* just fill in fix states */
74 state
->bvd1
= (status
& ConXS_CFSR_BVD1
) ? 1 : 0;
75 state
->bvd2
= (status
& ConXS_CFSR_BVD2
) ? 1 : 0;
76 state
->vs_3v
= (status
& ConXS_CFSR_VS1
) ? 0 : 1;
77 state
->vs_Xv
= (status
& ConXS_CFSR_VS2
) ? 0 : 1;
80 #ifndef CONFIG_MACH_TRIZEPS_CONXS
81 /* on ConXS we only have one slot. Second is inactive */
95 static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
96 const socket_state_t
*state
)
99 unsigned short power
= 0;
101 /* we do nothing here just check a bit */
102 switch (state
->Vcc
) {
103 case 0: power
&= 0xfc; break;
104 case 33: power
|= ConXS_BCR_S0_VCC_3V3
; break;
106 pr_err("%s(): Vcc 5V not supported in socket\n", __func__
);
109 pr_err("%s(): bad Vcc %u\n", __func__
, state
->Vcc
);
113 switch (state
->Vpp
) {
114 case 0: power
&= 0xf3; break;
115 case 33: power
|= ConXS_BCR_S0_VPP_3V3
; break;
117 pr_err("%s(): Vpp 12V not supported in socket\n", __func__
);
120 if (state
->Vpp
!= state
->Vcc
) {
121 pr_err("%s(): bad Vpp %u\n", __func__
, state
->Vpp
);
127 case 0: /* we only have 3.3V */
128 board_pcmcia_power(power
);
131 #ifndef CONFIG_MACH_TRIZEPS_CONXS
132 /* on ConXS we only have one slot. Second is inactive */
142 static void trizeps_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
145 board_pcmcia_power(0x9);
148 static void trizeps_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
150 board_pcmcia_power(0x0);
153 static struct pcmcia_low_level trizeps_pcmcia_ops
= {
154 .owner
= THIS_MODULE
,
155 .hw_init
= trizeps_pcmcia_hw_init
,
156 .socket_state
= trizeps_pcmcia_socket_state
,
157 .configure_socket
= trizeps_pcmcia_configure_socket
,
158 .socket_init
= trizeps_pcmcia_socket_init
,
159 .socket_suspend
= trizeps_pcmcia_socket_suspend
,
160 #ifdef CONFIG_MACH_TRIZEPS_CONXS
168 static struct platform_device
*trizeps_pcmcia_device
;
170 static int __init
trizeps_pcmcia_init(void)
174 if (!machine_is_trizeps4() && !machine_is_trizeps4wl())
177 trizeps_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
178 if (!trizeps_pcmcia_device
)
181 ret
= platform_device_add_data(trizeps_pcmcia_device
,
182 &trizeps_pcmcia_ops
, sizeof(trizeps_pcmcia_ops
));
185 ret
= platform_device_add(trizeps_pcmcia_device
);
188 platform_device_put(trizeps_pcmcia_device
);
193 static void __exit
trizeps_pcmcia_exit(void)
195 platform_device_unregister(trizeps_pcmcia_device
);
198 fs_initcall(trizeps_pcmcia_init
);
199 module_exit(trizeps_pcmcia_exit
);
201 MODULE_LICENSE("GPL");
202 MODULE_AUTHOR("Juergen Schindele");
203 MODULE_ALIAS("platform:pxa2xx-pcmcia");