blob: 4bf68144c36503196d8df7f35b4fc5acf29222f9 [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" },
Marek Vasut20704172011-01-15 18:49:07 +010026};
27
Marek Vašut6d341672008-08-16 15:35:57 +010028static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
29{
30 int ret;
31
Marek Vasut20704172011-01-15 18:49:07 +010032 ret = gpio_request_array(palmld_pcmcia_gpios,
33 ARRAY_SIZE(palmld_pcmcia_gpios));
Marek Vašut6d341672008-08-16 15:35:57 +010034
Russell Kinga9bb5a42012-01-13 22:56:32 +000035 skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
36 skt->stat[SOC_STAT_RDY].name = "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 */
Marek Vašut6d341672008-08-16 15:35:57 +010050 state->wrprot = 0;
51 state->vs_3v = 1;
52 state->vs_Xv = 0;
53}
54
55static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
56 const socket_state_t *state)
57{
58 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
59 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
60 !!(state->flags & SS_RESET));
61
62 return 0;
63}
64
Marek Vašut6d341672008-08-16 15:35:57 +010065static struct pcmcia_low_level palmld_pcmcia_ops = {
66 .owner = THIS_MODULE,
67
Marek Vasutd66ea8d2009-03-28 17:56:28 +080068 .first = 1,
69 .nr = 1,
Marek Vašut6d341672008-08-16 15:35:57 +010070
71 .hw_init = palmld_pcmcia_hw_init,
72 .hw_shutdown = palmld_pcmcia_hw_shutdown,
73
74 .socket_state = palmld_pcmcia_socket_state,
75 .configure_socket = palmld_pcmcia_configure_socket,
Marek Vašut6d341672008-08-16 15:35:57 +010076};
77
78static struct platform_device *palmld_pcmcia_device;
79
80static int __init palmld_pcmcia_init(void)
81{
82 int ret;
83
84 if (!machine_is_palmld())
85 return -ENODEV;
86
87 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
88 if (!palmld_pcmcia_device)
89 return -ENOMEM;
90
91 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
92 sizeof(palmld_pcmcia_ops));
93
94 if (!ret)
95 ret = platform_device_add(palmld_pcmcia_device);
96
97 if (ret)
98 platform_device_put(palmld_pcmcia_device);
99
100 return ret;
101}
102
103static void __exit palmld_pcmcia_exit(void)
104{
105 platform_device_unregister(palmld_pcmcia_device);
106}
107
108module_init(palmld_pcmcia_init);
109module_exit(palmld_pcmcia_exit);
110
111MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
112 " Marek Vasut <marek.vasut@gmail.com>");
113MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
114MODULE_ALIAS("platform:pxa2xx-pcmcia");
115MODULE_LICENSE("GPL");