Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / drivers / pcmcia / pxa2xx_palmld.c
blobd589ad1dcd4c7f9f15552c889eec5e187687d8d5
1 /*
2 * linux/drivers/pcmcia/pxa2xx_palmld.c
4 * Driver for Palm LifeDrive PCMCIA
6 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
7 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/platform_device.h>
17 #include <linux/gpio.h>
19 #include <asm/mach-types.h>
20 #include <mach/palmld.h>
21 #include "soc_common.h"
23 static struct gpio palmld_pcmcia_gpios[] = {
24 { GPIO_NR_PALMLD_PCMCIA_POWER, GPIOF_INIT_LOW, "PCMCIA Power" },
25 { GPIO_NR_PALMLD_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
26 { GPIO_NR_PALMLD_PCMCIA_READY, GPIOF_IN, "PCMCIA Ready" },
29 static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
31 int ret;
33 ret = gpio_request_array(palmld_pcmcia_gpios,
34 ARRAY_SIZE(palmld_pcmcia_gpios));
36 skt->socket.pci_irq = IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY);
38 return ret;
41 static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
43 gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
46 static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
47 struct pcmcia_state *state)
49 state->detect = 1; /* always inserted */
50 state->ready = !!gpio_get_value(GPIO_NR_PALMLD_PCMCIA_READY);
51 state->bvd1 = 1;
52 state->bvd2 = 1;
53 state->wrprot = 0;
54 state->vs_3v = 1;
55 state->vs_Xv = 0;
58 static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
59 const socket_state_t *state)
61 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
62 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
63 !!(state->flags & SS_RESET));
65 return 0;
68 static struct pcmcia_low_level palmld_pcmcia_ops = {
69 .owner = THIS_MODULE,
71 .first = 1,
72 .nr = 1,
74 .hw_init = palmld_pcmcia_hw_init,
75 .hw_shutdown = palmld_pcmcia_hw_shutdown,
77 .socket_state = palmld_pcmcia_socket_state,
78 .configure_socket = palmld_pcmcia_configure_socket,
81 static struct platform_device *palmld_pcmcia_device;
83 static int __init palmld_pcmcia_init(void)
85 int ret;
87 if (!machine_is_palmld())
88 return -ENODEV;
90 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
91 if (!palmld_pcmcia_device)
92 return -ENOMEM;
94 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
95 sizeof(palmld_pcmcia_ops));
97 if (!ret)
98 ret = platform_device_add(palmld_pcmcia_device);
100 if (ret)
101 platform_device_put(palmld_pcmcia_device);
103 return ret;
106 static void __exit palmld_pcmcia_exit(void)
108 platform_device_unregister(palmld_pcmcia_device);
111 module_init(palmld_pcmcia_init);
112 module_exit(palmld_pcmcia_exit);
114 MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
115 " Marek Vasut <marek.vasut@gmail.com>");
116 MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
117 MODULE_ALIAS("platform:pxa2xx-pcmcia");
118 MODULE_LICENSE("GPL");