2 * linux/drivers/pcmcia/pxa/pxa_cm_x270.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_S0_CD_VALID (84)
22 #define GPIO_PCMCIA_S0_RDYINT (82)
23 #define GPIO_PCMCIA_RESET (53)
25 static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
27 int ret
= gpio_request(GPIO_PCMCIA_RESET
, "PCCard reset");
30 gpio_direction_output(GPIO_PCMCIA_RESET
, 0);
32 skt
->stat
[SOC_STAT_CD
].gpio
= GPIO_PCMCIA_S0_CD_VALID
;
33 skt
->stat
[SOC_STAT_CD
].name
= "PCMCIA0 CD";
34 skt
->stat
[SOC_STAT_RDY
].gpio
= GPIO_PCMCIA_S0_RDYINT
;
35 skt
->stat
[SOC_STAT_RDY
].name
= "PCMCIA0 RDY";
40 static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket
*skt
)
42 gpio_free(GPIO_PCMCIA_RESET
);
46 static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
47 struct pcmcia_state
*state
)
54 static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
55 const socket_state_t
*state
)
59 if (state
->flags
& SS_RESET
) {
60 gpio_set_value(GPIO_PCMCIA_RESET
, 1);
62 gpio_set_value(GPIO_PCMCIA_RESET
, 0);
70 static struct pcmcia_low_level cmx270_pcmcia_ops __initdata
= {
72 .hw_init
= cmx270_pcmcia_hw_init
,
73 .hw_shutdown
= cmx270_pcmcia_shutdown
,
74 .socket_state
= cmx270_pcmcia_socket_state
,
75 .configure_socket
= cmx270_pcmcia_configure_socket
,
79 static struct platform_device
*cmx270_pcmcia_device
;
81 int __init
cmx270_pcmcia_init(void)
85 cmx270_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
87 if (!cmx270_pcmcia_device
)
90 ret
= platform_device_add_data(cmx270_pcmcia_device
, &cmx270_pcmcia_ops
,
91 sizeof(cmx270_pcmcia_ops
));
94 printk(KERN_INFO
"Registering cm-x270 PCMCIA interface.\n");
95 ret
= platform_device_add(cmx270_pcmcia_device
);
99 platform_device_put(cmx270_pcmcia_device
);
104 void __exit
cmx270_pcmcia_exit(void)
106 platform_device_unregister(cmx270_pcmcia_device
);