blob: cfff41ac9ca29e47b594759241ef577528698785 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Marek Vašut6d341672008-08-16 15:35:57 +01002/*
3 * linux/drivers/pcmcia/pxa2xx_palmld.c
4 *
5 * Driver for Palm LifeDrive PCMCIA
6 *
7 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
Marek Vasut9ed3fbf2011-01-15 19:22:19 +01008 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
Marek Vašut6d341672008-08-16 15:35:57 +01009 */
10
11#include <linux/module.h>
12#include <linux/platform_device.h>
13#include <linux/gpio.h>
14
15#include <asm/mach-types.h>
16#include <mach/palmld.h>
17#include "soc_common.h"
18
Marek Vasut20704172011-01-15 18:49:07 +010019static struct gpio palmld_pcmcia_gpios[] = {
20 { GPIO_NR_PALMLD_PCMCIA_POWER, GPIOF_INIT_LOW, "PCMCIA Power" },
21 { GPIO_NR_PALMLD_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
Marek Vasut20704172011-01-15 18:49:07 +010022};
23
Marek Vašut6d341672008-08-16 15:35:57 +010024static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25{
26 int ret;
27
Marek Vasut20704172011-01-15 18:49:07 +010028 ret = gpio_request_array(palmld_pcmcia_gpios,
29 ARRAY_SIZE(palmld_pcmcia_gpios));
Marek Vašut6d341672008-08-16 15:35:57 +010030
Russell Kinga9bb5a42012-01-13 22:56:32 +000031 skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
32 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
Marek Vašut6d341672008-08-16 15:35:57 +010033
Marek Vašut6d341672008-08-16 15:35:57 +010034 return ret;
35}
36
37static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
38{
Marek Vasut20704172011-01-15 18:49:07 +010039 gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
Marek Vašut6d341672008-08-16 15:35:57 +010040}
41
42static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
43 struct pcmcia_state *state)
44{
45 state->detect = 1; /* always inserted */
Marek Vašut6d341672008-08-16 15:35:57 +010046 state->vs_3v = 1;
47 state->vs_Xv = 0;
48}
49
50static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
51 const socket_state_t *state)
52{
53 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
54 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
55 !!(state->flags & SS_RESET));
56
57 return 0;
58}
59
Marek Vašut6d341672008-08-16 15:35:57 +010060static struct pcmcia_low_level palmld_pcmcia_ops = {
61 .owner = THIS_MODULE,
62
Marek Vasutd66ea8d2009-03-28 17:56:28 +080063 .first = 1,
64 .nr = 1,
Marek Vašut6d341672008-08-16 15:35:57 +010065
66 .hw_init = palmld_pcmcia_hw_init,
67 .hw_shutdown = palmld_pcmcia_hw_shutdown,
68
69 .socket_state = palmld_pcmcia_socket_state,
70 .configure_socket = palmld_pcmcia_configure_socket,
Marek Vašut6d341672008-08-16 15:35:57 +010071};
72
73static struct platform_device *palmld_pcmcia_device;
74
75static int __init palmld_pcmcia_init(void)
76{
77 int ret;
78
79 if (!machine_is_palmld())
80 return -ENODEV;
81
82 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
83 if (!palmld_pcmcia_device)
84 return -ENOMEM;
85
86 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
87 sizeof(palmld_pcmcia_ops));
88
89 if (!ret)
90 ret = platform_device_add(palmld_pcmcia_device);
91
92 if (ret)
93 platform_device_put(palmld_pcmcia_device);
94
95 return ret;
96}
97
98static void __exit palmld_pcmcia_exit(void)
99{
100 platform_device_unregister(palmld_pcmcia_device);
101}
102
103module_init(palmld_pcmcia_init);
104module_exit(palmld_pcmcia_exit);
105
106MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
107 " Marek Vasut <marek.vasut@gmail.com>");
108MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
109MODULE_ALIAS("platform:pxa2xx-pcmcia");
110MODULE_LICENSE("GPL");