2 * linux/drivers/pcmcia/pxa/pxa_cm_x255.c
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compulab Ltd., 2003, 2007, 2008
9 * Mike Rapoport <mike@compulab.co.il>
13 #include <linux/platform_device.h>
14 #include <linux/irq.h>
15 #include <linux/delay.h>
16 #include <linux/gpio.h>
17 #include <linux/export.h>
19 #include "soc_common.h"
21 #define GPIO_PCMCIA_SKTSEL (54)
22 #define GPIO_PCMCIA_S0_CD_VALID (16)
23 #define GPIO_PCMCIA_S1_CD_VALID (17)
24 #define GPIO_PCMCIA_S0_RDYINT (6)
25 #define GPIO_PCMCIA_S1_RDYINT (8)
26 #define GPIO_PCMCIA_RESET (9)
28 static int cmx255_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
30 int ret
= gpio_request(GPIO_PCMCIA_RESET
, "PCCard reset");
33 gpio_direction_output(GPIO_PCMCIA_RESET
, 0);
36 skt
->stat
[SOC_STAT_CD
].gpio
= GPIO_PCMCIA_S0_CD_VALID
;
37 skt
->stat
[SOC_STAT_CD
].name
= "PCMCIA0 CD";
38 skt
->stat
[SOC_STAT_RDY
].gpio
= GPIO_PCMCIA_S0_RDYINT
;
39 skt
->stat
[SOC_STAT_RDY
].name
= "PCMCIA0 RDY";
41 skt
->stat
[SOC_STAT_CD
].gpio
= GPIO_PCMCIA_S1_CD_VALID
;
42 skt
->stat
[SOC_STAT_CD
].name
= "PCMCIA1 CD";
43 skt
->stat
[SOC_STAT_RDY
].gpio
= GPIO_PCMCIA_S1_RDYINT
;
44 skt
->stat
[SOC_STAT_RDY
].name
= "PCMCIA1 RDY";
50 static void cmx255_pcmcia_shutdown(struct soc_pcmcia_socket
*skt
)
52 gpio_free(GPIO_PCMCIA_RESET
);
56 static void cmx255_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
57 struct pcmcia_state
*state
)
64 static int cmx255_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
65 const socket_state_t
*state
)
69 if (state
->flags
& SS_RESET
) {
70 gpio_set_value(GPIO_PCMCIA_SKTSEL
, 0);
72 gpio_set_value(GPIO_PCMCIA_RESET
, 1);
74 gpio_set_value(GPIO_PCMCIA_RESET
, 0);
78 if (state
->flags
& SS_RESET
) {
79 gpio_set_value(GPIO_PCMCIA_SKTSEL
, 1);
81 gpio_set_value(GPIO_PCMCIA_RESET
, 1);
83 gpio_set_value(GPIO_PCMCIA_RESET
, 0);
91 static struct pcmcia_low_level cmx255_pcmcia_ops __initdata
= {
93 .hw_init
= cmx255_pcmcia_hw_init
,
94 .hw_shutdown
= cmx255_pcmcia_shutdown
,
95 .socket_state
= cmx255_pcmcia_socket_state
,
96 .configure_socket
= cmx255_pcmcia_configure_socket
,
100 static struct platform_device
*cmx255_pcmcia_device
;
102 int __init
cmx255_pcmcia_init(void)
106 cmx255_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
108 if (!cmx255_pcmcia_device
)
111 ret
= platform_device_add_data(cmx255_pcmcia_device
, &cmx255_pcmcia_ops
,
112 sizeof(cmx255_pcmcia_ops
));
115 printk(KERN_INFO
"Registering cm-x255 PCMCIA interface.\n");
116 ret
= platform_device_add(cmx255_pcmcia_device
);
120 platform_device_put(cmx255_pcmcia_device
);
125 void __exit
cmx255_pcmcia_exit(void)
127 platform_device_unregister(cmx255_pcmcia_device
);