1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/pcmcia/pxa2xx_trizeps4.c
5 * TRIZEPS PCMCIA specific routines.
7 * Author: Jürgen Schindele
9 * Copyright: Jürgen Schindele
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/gpio.h>
16 #include <linux/interrupt.h>
17 #include <linux/platform_device.h>
19 #include <asm/mach-types.h>
22 #include <mach/pxa2xx-regs.h>
23 #include <mach/trizeps4.h>
25 #include "soc_common.h"
27 extern void board_pcmcia_power(int power
);
29 static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
31 /* we dont have voltage/card/ready detection
32 * so we dont need interrupts for it
36 skt
->stat
[SOC_STAT_CD
].gpio
= GPIO_PCD
;
37 skt
->stat
[SOC_STAT_CD
].name
= "cs0_cd";
38 skt
->stat
[SOC_STAT_RDY
].gpio
= GPIO_PRDY
;
39 skt
->stat
[SOC_STAT_RDY
].name
= "cs0_rdy";
44 /* release the reset of this card */
45 pr_debug("%s: sock %d irq %d\n", __func__
, skt
->nr
, skt
->socket
.pci_irq
);
50 static unsigned long trizeps_pcmcia_status
[2];
52 static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
53 struct pcmcia_state
*state
)
55 unsigned short status
= 0, change
;
56 status
= CFSR_readw();
57 change
= (status
^ trizeps_pcmcia_status
[skt
->nr
]) &
60 trizeps_pcmcia_status
[skt
->nr
] = status
;
61 if (status
& ConXS_CFSR_BVD1
) {
62 /* enable_irq empty */
64 /* disable_irq empty */
70 /* just fill in fix states */
71 state
->bvd1
= (status
& ConXS_CFSR_BVD1
) ? 1 : 0;
72 state
->bvd2
= (status
& ConXS_CFSR_BVD2
) ? 1 : 0;
73 state
->vs_3v
= (status
& ConXS_CFSR_VS1
) ? 0 : 1;
74 state
->vs_Xv
= (status
& ConXS_CFSR_VS2
) ? 0 : 1;
77 #ifndef CONFIG_MACH_TRIZEPS_CONXS
78 /* on ConXS we only have one slot. Second is inactive */
92 static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
93 const socket_state_t
*state
)
96 unsigned short power
= 0;
98 /* we do nothing here just check a bit */
100 case 0: power
&= 0xfc; break;
101 case 33: power
|= ConXS_BCR_S0_VCC_3V3
; break;
103 pr_err("%s(): Vcc 5V not supported in socket\n", __func__
);
106 pr_err("%s(): bad Vcc %u\n", __func__
, state
->Vcc
);
110 switch (state
->Vpp
) {
111 case 0: power
&= 0xf3; break;
112 case 33: power
|= ConXS_BCR_S0_VPP_3V3
; break;
114 pr_err("%s(): Vpp 12V not supported in socket\n", __func__
);
117 if (state
->Vpp
!= state
->Vcc
) {
118 pr_err("%s(): bad Vpp %u\n", __func__
, state
->Vpp
);
124 case 0: /* we only have 3.3V */
125 board_pcmcia_power(power
);
128 #ifndef CONFIG_MACH_TRIZEPS_CONXS
129 /* on ConXS we only have one slot. Second is inactive */
139 static void trizeps_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
142 board_pcmcia_power(0x9);
145 static void trizeps_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
147 board_pcmcia_power(0x0);
150 static struct pcmcia_low_level trizeps_pcmcia_ops
= {
151 .owner
= THIS_MODULE
,
152 .hw_init
= trizeps_pcmcia_hw_init
,
153 .socket_state
= trizeps_pcmcia_socket_state
,
154 .configure_socket
= trizeps_pcmcia_configure_socket
,
155 .socket_init
= trizeps_pcmcia_socket_init
,
156 .socket_suspend
= trizeps_pcmcia_socket_suspend
,
157 #ifdef CONFIG_MACH_TRIZEPS_CONXS
165 static struct platform_device
*trizeps_pcmcia_device
;
167 static int __init
trizeps_pcmcia_init(void)
171 if (!machine_is_trizeps4() && !machine_is_trizeps4wl())
174 trizeps_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
175 if (!trizeps_pcmcia_device
)
178 ret
= platform_device_add_data(trizeps_pcmcia_device
,
179 &trizeps_pcmcia_ops
, sizeof(trizeps_pcmcia_ops
));
182 ret
= platform_device_add(trizeps_pcmcia_device
);
185 platform_device_put(trizeps_pcmcia_device
);
190 static void __exit
trizeps_pcmcia_exit(void)
192 platform_device_unregister(trizeps_pcmcia_device
);
195 fs_initcall(trizeps_pcmcia_init
);
196 module_exit(trizeps_pcmcia_exit
);
198 MODULE_LICENSE("GPL");
199 MODULE_AUTHOR("Juergen Schindele");
200 MODULE_ALIAS("platform:pxa2xx-pcmcia");