Loading...
1/*
2 * linux/drivers/pcmcia/pxa2xx_palmld.c
3 *
4 * Driver for Palm LifeDrive PCMCIA
5 *
6 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
7 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
8 *
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
23static 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
29static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
30{
31 int ret;
32
33 ret = gpio_request_array(palmld_pcmcia_gpios,
34 ARRAY_SIZE(palmld_pcmcia_gpios));
35
36 skt->socket.pci_irq = IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY);
37
38 return ret;
39}
40
41static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
42{
43 gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
44}
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 struct pcmcia_low_level palmld_pcmcia_ops = {
69 .owner = THIS_MODULE,
70
71 .first = 1,
72 .nr = 1,
73
74 .hw_init = palmld_pcmcia_hw_init,
75 .hw_shutdown = palmld_pcmcia_hw_shutdown,
76
77 .socket_state = palmld_pcmcia_socket_state,
78 .configure_socket = palmld_pcmcia_configure_socket,
79};
80
81static struct platform_device *palmld_pcmcia_device;
82
83static int __init palmld_pcmcia_init(void)
84{
85 int ret;
86
87 if (!machine_is_palmld())
88 return -ENODEV;
89
90 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
91 if (!palmld_pcmcia_device)
92 return -ENOMEM;
93
94 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
95 sizeof(palmld_pcmcia_ops));
96
97 if (!ret)
98 ret = platform_device_add(palmld_pcmcia_device);
99
100 if (ret)
101 platform_device_put(palmld_pcmcia_device);
102
103 return ret;
104}
105
106static void __exit palmld_pcmcia_exit(void)
107{
108 platform_device_unregister(palmld_pcmcia_device);
109}
110
111module_init(palmld_pcmcia_init);
112module_exit(palmld_pcmcia_exit);
113
114MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
115 " Marek Vasut <marek.vasut@gmail.com>");
116MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
117MODULE_ALIAS("platform:pxa2xx-pcmcia");
118MODULE_LICENSE("GPL");
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/drivers/pcmcia/pxa2xx_palmld.c
4 *
5 * Driver for Palm LifeDrive PCMCIA
6 *
7 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
8 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
9 */
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
19static 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" },
22};
23
24static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25{
26 int ret;
27
28 ret = gpio_request_array(palmld_pcmcia_gpios,
29 ARRAY_SIZE(palmld_pcmcia_gpios));
30
31 skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
32 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
33
34 return ret;
35}
36
37static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
38{
39 gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
40}
41
42static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
43 struct pcmcia_state *state)
44{
45 state->detect = 1; /* always inserted */
46 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
60static struct pcmcia_low_level palmld_pcmcia_ops = {
61 .owner = THIS_MODULE,
62
63 .first = 1,
64 .nr = 1,
65
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,
71};
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");