1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/pcmcia/pxa2xx_vpac270.c
5 * Driver for Voipac PXA270 PCMCIA and CF sockets
7 * Copyright (C) 2010-2011 Marek Vasut <marek.vasut@gmail.com>
10 #include <linux/gpio.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
14 #include <asm/mach-types.h>
16 #include <mach/vpac270.h>
18 #include "soc_common.h"
20 static struct gpio vpac270_pcmcia_gpios[] = {
21 { GPIO107_VPAC270_PCMCIA_PPEN, GPIOF_INIT_LOW, "PCMCIA PPEN" },
22 { GPIO11_VPAC270_PCMCIA_RESET, GPIOF_INIT_LOW, "PCMCIA Reset" },
25 static struct gpio vpac270_cf_gpios[] = {
26 { GPIO16_VPAC270_CF_RESET, GPIOF_INIT_LOW, "CF Reset" },
29 static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
34 ret = gpio_request_array(vpac270_pcmcia_gpios,
35 ARRAY_SIZE(vpac270_pcmcia_gpios));
37 skt->stat[SOC_STAT_CD].gpio = GPIO84_VPAC270_PCMCIA_CD;
38 skt->stat[SOC_STAT_CD].name = "PCMCIA CD";
39 skt->stat[SOC_STAT_RDY].gpio = GPIO35_VPAC270_PCMCIA_RDY;
40 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
42 ret = gpio_request_array(vpac270_cf_gpios,
43 ARRAY_SIZE(vpac270_cf_gpios));
45 skt->stat[SOC_STAT_CD].gpio = GPIO17_VPAC270_CF_CD;
46 skt->stat[SOC_STAT_CD].name = "CF CD";
47 skt->stat[SOC_STAT_RDY].gpio = GPIO12_VPAC270_CF_RDY;
48 skt->stat[SOC_STAT_RDY].name = "CF Ready";
54 static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
57 gpio_free_array(vpac270_pcmcia_gpios,
58 ARRAY_SIZE(vpac270_pcmcia_gpios));
60 gpio_free_array(vpac270_cf_gpios,
61 ARRAY_SIZE(vpac270_cf_gpios));
64 static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
65 struct pcmcia_state *state)
72 vpac270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
73 const socket_state_t *state)
76 gpio_set_value(GPIO11_VPAC270_PCMCIA_RESET,
77 (state->flags & SS_RESET));
78 gpio_set_value(GPIO107_VPAC270_PCMCIA_PPEN,
79 !(state->Vcc == 33 || state->Vcc == 50));
81 gpio_set_value(GPIO16_VPAC270_CF_RESET,
82 (state->flags & SS_RESET));
88 static struct pcmcia_low_level vpac270_pcmcia_ops = {
94 .hw_init = vpac270_pcmcia_hw_init,
95 .hw_shutdown = vpac270_pcmcia_hw_shutdown,
97 .socket_state = vpac270_pcmcia_socket_state,
98 .configure_socket = vpac270_pcmcia_configure_socket,
101 static struct platform_device *vpac270_pcmcia_device;
103 static int __init vpac270_pcmcia_init(void)
107 if (!machine_is_vpac270())
110 vpac270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
111 if (!vpac270_pcmcia_device)
114 ret = platform_device_add_data(vpac270_pcmcia_device,
115 &vpac270_pcmcia_ops, sizeof(vpac270_pcmcia_ops));
118 ret = platform_device_add(vpac270_pcmcia_device);
121 platform_device_put(vpac270_pcmcia_device);
126 static void __exit vpac270_pcmcia_exit(void)
128 platform_device_unregister(vpac270_pcmcia_device);
131 module_init(vpac270_pcmcia_init);
132 module_exit(vpac270_pcmcia_exit);
134 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
135 MODULE_DESCRIPTION("PCMCIA support for Voipac PXA270");
136 MODULE_ALIAS("platform:pxa2xx-pcmcia");
137 MODULE_LICENSE("GPL");