blob: 69f73670949a2163b75eeaebe487947e65c01fac [file] [log] [blame]
Marek Vašut6d341672008-08-16 15:35:57 +01001/*
2 * linux/drivers/pcmcia/pxa2xx_palmld.c
3 *
4 * Driver for Palm LifeDrive PCMCIA
5 *
6 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
Marek Vasut9ed3fbf2011-01-15 19:22:19 +01007 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
Marek Vašut6d341672008-08-16 15:35:57 +01008 *
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.
12 *
13 */
14
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/gpio.h>
18
19#include <asm/mach-types.h>
20#include <mach/palmld.h>
21#include "soc_common.h"
22
Marek Vasut20704172011-01-15 18:49:07 +010023static 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" },
27};
28
Marek Vašut6d341672008-08-16 15:35:57 +010029static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
30{
31 int ret;
32
Marek Vasut20704172011-01-15 18:49:07 +010033 ret = gpio_request_array(palmld_pcmcia_gpios,
34 ARRAY_SIZE(palmld_pcmcia_gpios));
Marek Vašut6d341672008-08-16 15:35:57 +010035
Russell King - ARM Linux66024db2009-03-29 22:45:26 +010036 skt->socket.pci_irq = IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY);
Marek Vašut6d341672008-08-16 15:35:57 +010037
Marek Vašut6d341672008-08-16 15:35:57 +010038 return ret;
39}
40
41static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
42{
Marek Vasut20704172011-01-15 18:49:07 +010043 gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
Marek Vašut6d341672008-08-16 15:35:57 +010044}
45
46static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
47 struct pcmcia_state *state)
48{
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;
56}
57
58static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
59 const socket_state_t *state)
60{
61 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
62 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
63 !!(state->flags & SS_RESET));
64
65 return 0;
66}
67
68static void palmld_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
69{
70}
71
72static void palmld_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
73{
74}
75
76static struct pcmcia_low_level palmld_pcmcia_ops = {
77 .owner = THIS_MODULE,
78
Marek Vasutd66ea8d2009-03-28 17:56:28 +080079 .first = 1,
80 .nr = 1,
Marek Vašut6d341672008-08-16 15:35:57 +010081
82 .hw_init = palmld_pcmcia_hw_init,
83 .hw_shutdown = palmld_pcmcia_hw_shutdown,
84
85 .socket_state = palmld_pcmcia_socket_state,
86 .configure_socket = palmld_pcmcia_configure_socket,
87
88 .socket_init = palmld_pcmcia_socket_init,
89 .socket_suspend = palmld_pcmcia_socket_suspend,
90};
91
92static struct platform_device *palmld_pcmcia_device;
93
94static int __init palmld_pcmcia_init(void)
95{
96 int ret;
97
98 if (!machine_is_palmld())
99 return -ENODEV;
100
101 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
102 if (!palmld_pcmcia_device)
103 return -ENOMEM;
104
105 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
106 sizeof(palmld_pcmcia_ops));
107
108 if (!ret)
109 ret = platform_device_add(palmld_pcmcia_device);
110
111 if (ret)
112 platform_device_put(palmld_pcmcia_device);
113
114 return ret;
115}
116
117static void __exit palmld_pcmcia_exit(void)
118{
119 platform_device_unregister(palmld_pcmcia_device);
120}
121
122module_init(palmld_pcmcia_init);
123module_exit(palmld_pcmcia_exit);
124
125MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
126 " Marek Vasut <marek.vasut@gmail.com>");
127MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
128MODULE_ALIAS("platform:pxa2xx-pcmcia");
129MODULE_LICENSE("GPL");