2 * linux/drivers/pcmcia/pxa2xx_vpac270.c
4 * Driver for Voipac PXA270 PCMCIA and CF sockets
6 * Copyright (C) 2010-2011 Marek Vasut <marek.vasut@gmail.com>
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.
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
17 #include <asm/mach-types.h>
19 #include <mach/gpio.h>
20 #include <mach/vpac270.h>
22 #include "soc_common.h"
24 static struct gpio vpac270_pcmcia_gpios
[] = {
25 { GPIO84_VPAC270_PCMCIA_CD
, GPIOF_IN
, "PCMCIA Card Detect" },
26 { GPIO35_VPAC270_PCMCIA_RDY
, GPIOF_IN
, "PCMCIA Ready" },
27 { GPIO107_VPAC270_PCMCIA_PPEN
, GPIOF_INIT_LOW
, "PCMCIA PPEN" },
28 { GPIO11_VPAC270_PCMCIA_RESET
, GPIOF_INIT_LOW
, "PCMCIA Reset" },
31 static struct gpio vpac270_cf_gpios
[] = {
32 { GPIO17_VPAC270_CF_CD
, GPIOF_IN
, "CF Card Detect" },
33 { GPIO12_VPAC270_CF_RDY
, GPIOF_IN
, "CF Ready" },
34 { GPIO16_VPAC270_CF_RESET
, GPIOF_INIT_LOW
, "CF Reset" },
37 static struct pcmcia_irqs cd_irqs
[] = {
40 .irq
= IRQ_GPIO(GPIO84_VPAC270_PCMCIA_CD
),
45 .irq
= IRQ_GPIO(GPIO17_VPAC270_CF_CD
),
50 static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
55 ret
= gpio_request_array(vpac270_pcmcia_gpios
,
56 ARRAY_SIZE(vpac270_pcmcia_gpios
));
58 skt
->socket
.pci_irq
= gpio_to_irq(GPIO35_VPAC270_PCMCIA_RDY
);
61 ret
= soc_pcmcia_request_irqs(skt
, &cd_irqs
[0], 1);
63 ret
= gpio_request_array(vpac270_cf_gpios
,
64 ARRAY_SIZE(vpac270_cf_gpios
));
66 skt
->socket
.pci_irq
= gpio_to_irq(GPIO12_VPAC270_CF_RDY
);
69 ret
= soc_pcmcia_request_irqs(skt
, &cd_irqs
[1], 1);
75 static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
78 gpio_request_array(vpac270_pcmcia_gpios
,
79 ARRAY_SIZE(vpac270_pcmcia_gpios
));
81 gpio_request_array(vpac270_cf_gpios
,
82 ARRAY_SIZE(vpac270_cf_gpios
));
85 static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
86 struct pcmcia_state
*state
)
89 state
->detect
= !gpio_get_value(GPIO84_VPAC270_PCMCIA_CD
);
90 state
->ready
= !!gpio_get_value(GPIO35_VPAC270_PCMCIA_RDY
);
92 state
->detect
= !gpio_get_value(GPIO17_VPAC270_CF_CD
);
93 state
->ready
= !!gpio_get_value(GPIO12_VPAC270_CF_RDY
);
103 vpac270_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
104 const socket_state_t
*state
)
107 gpio_set_value(GPIO11_VPAC270_PCMCIA_RESET
,
108 (state
->flags
& SS_RESET
));
109 gpio_set_value(GPIO107_VPAC270_PCMCIA_PPEN
,
110 !(state
->Vcc
== 33 || state
->Vcc
== 50));
112 gpio_set_value(GPIO16_VPAC270_CF_RESET
,
113 (state
->flags
& SS_RESET
));
119 static void vpac270_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
123 static void vpac270_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
127 static struct pcmcia_low_level vpac270_pcmcia_ops
= {
128 .owner
= THIS_MODULE
,
133 .hw_init
= vpac270_pcmcia_hw_init
,
134 .hw_shutdown
= vpac270_pcmcia_hw_shutdown
,
136 .socket_state
= vpac270_pcmcia_socket_state
,
137 .configure_socket
= vpac270_pcmcia_configure_socket
,
139 .socket_init
= vpac270_pcmcia_socket_init
,
140 .socket_suspend
= vpac270_pcmcia_socket_suspend
,
143 static struct platform_device
*vpac270_pcmcia_device
;
145 static int __init
vpac270_pcmcia_init(void)
149 if (!machine_is_vpac270())
152 vpac270_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
153 if (!vpac270_pcmcia_device
)
156 ret
= platform_device_add_data(vpac270_pcmcia_device
,
157 &vpac270_pcmcia_ops
, sizeof(vpac270_pcmcia_ops
));
160 ret
= platform_device_add(vpac270_pcmcia_device
);
163 platform_device_put(vpac270_pcmcia_device
);
168 static void __exit
vpac270_pcmcia_exit(void)
170 platform_device_unregister(vpac270_pcmcia_device
);
173 module_init(vpac270_pcmcia_init
);
174 module_exit(vpac270_pcmcia_exit
);
176 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
177 MODULE_DESCRIPTION("PCMCIA support for Voipac PXA270");
178 MODULE_ALIAS("platform:pxa2xx-pcmcia");
179 MODULE_LICENSE("GPL");