]>
Commit | Line | Data |
---|---|---|
35978408 MV |
1 | /* |
2 | * linux/drivers/pcmcia/pxa2xx_palmtx.c | |
3 | * | |
4 | * Driver for Palm T|X PCMCIA | |
5 | * | |
9ed3fbf1 | 6 | * Copyright (C) 2007-2011 Marek Vasut <[email protected]> |
35978408 MV |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | * | |
12 | */ | |
13 | ||
14 | #include <linux/module.h> | |
15 | #include <linux/platform_device.h> | |
235a175c | 16 | #include <linux/gpio.h> |
35978408 MV |
17 | |
18 | #include <asm/mach-types.h> | |
a09e64fb | 19 | #include <mach/palmtx.h> |
35978408 MV |
20 | #include "soc_common.h" |
21 | ||
235a175c MV |
22 | static struct gpio palmtx_pcmcia_gpios[] = { |
23 | { GPIO_NR_PALMTX_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" }, | |
24 | { GPIO_NR_PALMTX_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" }, | |
25 | { GPIO_NR_PALMTX_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" }, | |
235a175c MV |
26 | }; |
27 | ||
35978408 MV |
28 | static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
29 | { | |
574047f9 MV |
30 | int ret; |
31 | ||
235a175c MV |
32 | ret = gpio_request_array(palmtx_pcmcia_gpios, |
33 | ARRAY_SIZE(palmtx_pcmcia_gpios)); | |
574047f9 | 34 | |
a9bb5a4b RK |
35 | skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMTX_PCMCIA_READY; |
36 | skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready"; | |
574047f9 | 37 | |
574047f9 | 38 | return ret; |
35978408 MV |
39 | } |
40 | ||
41 | static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | |
42 | { | |
235a175c | 43 | gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios)); |
35978408 MV |
44 | } |
45 | ||
46 | static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | |
47 | struct pcmcia_state *state) | |
48 | { | |
49 | state->detect = 1; /* always inserted */ | |
35978408 MV |
50 | state->vs_3v = 1; |
51 | state->vs_Xv = 0; | |
52 | } | |
53 | ||
54 | static int | |
55 | palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | |
56 | const socket_state_t *state) | |
57 | { | |
58 | gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1); | |
59 | gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1); | |
60 | gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET, | |
61 | !!(state->flags & SS_RESET)); | |
62 | ||
63 | return 0; | |
64 | } | |
65 | ||
35978408 MV |
66 | static struct pcmcia_low_level palmtx_pcmcia_ops = { |
67 | .owner = THIS_MODULE, | |
68 | ||
69 | .first = 0, | |
70 | .nr = 1, | |
71 | ||
72 | .hw_init = palmtx_pcmcia_hw_init, | |
73 | .hw_shutdown = palmtx_pcmcia_hw_shutdown, | |
74 | ||
75 | .socket_state = palmtx_pcmcia_socket_state, | |
76 | .configure_socket = palmtx_pcmcia_configure_socket, | |
35978408 MV |
77 | }; |
78 | ||
79 | static struct platform_device *palmtx_pcmcia_device; | |
80 | ||
81 | static int __init palmtx_pcmcia_init(void) | |
82 | { | |
83 | int ret; | |
84 | ||
85 | if (!machine_is_palmtx()) | |
86 | return -ENODEV; | |
87 | ||
88 | palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | |
89 | if (!palmtx_pcmcia_device) | |
90 | return -ENOMEM; | |
91 | ||
92 | ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops, | |
93 | sizeof(palmtx_pcmcia_ops)); | |
94 | ||
95 | if (!ret) | |
96 | ret = platform_device_add(palmtx_pcmcia_device); | |
97 | ||
98 | if (ret) | |
99 | platform_device_put(palmtx_pcmcia_device); | |
100 | ||
101 | return ret; | |
102 | } | |
103 | ||
104 | static void __exit palmtx_pcmcia_exit(void) | |
105 | { | |
106 | platform_device_unregister(palmtx_pcmcia_device); | |
107 | } | |
108 | ||
574047f9 | 109 | module_init(palmtx_pcmcia_init); |
35978408 MV |
110 | module_exit(palmtx_pcmcia_exit); |
111 | ||
112 | MODULE_AUTHOR("Marek Vasut <[email protected]>"); | |
113 | MODULE_DESCRIPTION("PCMCIA support for Palm T|X"); | |
114 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | |
115 | MODULE_LICENSE("GPL"); |