diff options
author | Paul Parsons <lost.distance@yahoo.com> | 2012-05-05 20:09:19 -0400 |
---|---|---|
committer | Haojian Zhuang <haojian.zhuang@gmail.com> | 2012-05-06 21:56:39 -0400 |
commit | 95244306f6fb4f685dd8a672a6e6ea9f7dd1fd89 (patch) | |
tree | 3cab4f3f4d6a6c94909ffe09f07706a3701ae1d8 /drivers/pcmcia | |
parent | 0de91b618281251beb9f73eaa436337779ae25f2 (diff) |
pcmcia: add driver for hx4700
This patch adds support for the HP iPAQ hx4700 to the existing
pxa2xx-pcmcia driver.
Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
Cc: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/Kconfig | 2 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 1 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_hx4700.c | 121 |
3 files changed, 123 insertions, 1 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index bba3ab2066ee..8fd255f7ee40 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -217,7 +217,7 @@ config PCMCIA_PXA2XX | |||
217 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ | 217 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ |
218 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ | 218 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ |
219 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ | 219 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ |
220 | || MACH_COLIBRI320) | 220 | || MACH_COLIBRI320 || MACH_H4700) |
221 | select PCMCIA_SA1111 if ARCH_LUBBOCK && SA1111 | 221 | select PCMCIA_SA1111 if ARCH_LUBBOCK && SA1111 |
222 | select PCMCIA_SOC_COMMON | 222 | select PCMCIA_SOC_COMMON |
223 | help | 223 | help |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 47525de6a631..7745b512a87c 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -69,6 +69,7 @@ pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o | |||
69 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o | 69 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o |
70 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += pxa2xx_colibri.o | 70 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += pxa2xx_colibri.o |
71 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o | 71 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o |
72 | pxa2xx-obj-$(CONFIG_MACH_H4700) += pxa2xx_hx4700.o | ||
72 | 73 | ||
73 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) | 74 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) |
74 | 75 | ||
diff --git a/drivers/pcmcia/pxa2xx_hx4700.c b/drivers/pcmcia/pxa2xx_hx4700.c new file mode 100644 index 000000000000..7dfef3ee5b53 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_hx4700.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Paul Parsons <lost.distance@yahoo.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/err.h> | ||
12 | #include <linux/gpio.h> | ||
13 | #include <linux/irq.h> | ||
14 | |||
15 | #include <asm/mach-types.h> | ||
16 | #include <mach/hx4700.h> | ||
17 | |||
18 | #include "soc_common.h" | ||
19 | |||
20 | static struct gpio gpios[] = { | ||
21 | { GPIO114_HX4700_CF_RESET, GPIOF_OUT_INIT_LOW, "CF reset" }, | ||
22 | { EGPIO4_CF_3V3_ON, GPIOF_OUT_INIT_LOW, "CF 3.3V enable" }, | ||
23 | }; | ||
24 | |||
25 | static int hx4700_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
26 | { | ||
27 | int ret; | ||
28 | |||
29 | ret = gpio_request_array(gpios, ARRAY_SIZE(gpios)); | ||
30 | if (ret) | ||
31 | goto out; | ||
32 | |||
33 | /* | ||
34 | * IRQ type must be set before soc_pcmcia_hw_init() calls request_irq(). | ||
35 | * The asic3 default IRQ type is level trigger low level detect, exactly | ||
36 | * the the signal present on GPIOD4_CF_nCD when a CF card is inserted. | ||
37 | * If the IRQ type is not changed, the asic3 interrupt handler will loop | ||
38 | * repeatedly because it is unable to clear the level trigger interrupt. | ||
39 | */ | ||
40 | irq_set_irq_type(gpio_to_irq(GPIOD4_CF_nCD), IRQ_TYPE_EDGE_BOTH); | ||
41 | |||
42 | skt->stat[SOC_STAT_CD].gpio = GPIOD4_CF_nCD; | ||
43 | skt->stat[SOC_STAT_CD].name = "PCMCIA CD"; | ||
44 | skt->stat[SOC_STAT_RDY].gpio = GPIO60_HX4700_CF_RNB; | ||
45 | skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready"; | ||
46 | |||
47 | out: | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | static void hx4700_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
52 | { | ||
53 | gpio_free_array(gpios, ARRAY_SIZE(gpios)); | ||
54 | } | ||
55 | |||
56 | static void hx4700_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
57 | struct pcmcia_state *state) | ||
58 | { | ||
59 | state->vs_3v = 1; | ||
60 | state->vs_Xv = 0; | ||
61 | } | ||
62 | |||
63 | static int hx4700_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
64 | const socket_state_t *state) | ||
65 | { | ||
66 | switch (state->Vcc) { | ||
67 | case 0: | ||
68 | gpio_set_value(EGPIO4_CF_3V3_ON, 0); | ||
69 | break; | ||
70 | case 33: | ||
71 | gpio_set_value(EGPIO4_CF_3V3_ON, 1); | ||
72 | break; | ||
73 | default: | ||
74 | printk(KERN_ERR "pcmcia: Unsupported Vcc: %d\n", state->Vcc); | ||
75 | return -EINVAL; | ||
76 | } | ||
77 | |||
78 | gpio_set_value(GPIO114_HX4700_CF_RESET, (state->flags & SS_RESET) != 0); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static struct pcmcia_low_level hx4700_pcmcia_ops = { | ||
84 | .owner = THIS_MODULE, | ||
85 | .nr = 1, | ||
86 | .hw_init = hx4700_pcmcia_hw_init, | ||
87 | .hw_shutdown = hx4700_pcmcia_hw_shutdown, | ||
88 | .socket_state = hx4700_pcmcia_socket_state, | ||
89 | .configure_socket = hx4700_pcmcia_configure_socket, | ||
90 | }; | ||
91 | |||
92 | static struct platform_device *hx4700_pcmcia_device; | ||
93 | |||
94 | static int __init hx4700_pcmcia_init(void) | ||
95 | { | ||
96 | struct platform_device *pdev; | ||
97 | |||
98 | if (!machine_is_h4700()) | ||
99 | return -ENODEV; | ||
100 | |||
101 | pdev = platform_device_register_data(NULL, "pxa2xx-pcmcia", -1, | ||
102 | &hx4700_pcmcia_ops, sizeof(hx4700_pcmcia_ops)); | ||
103 | if (IS_ERR(pdev)) | ||
104 | return PTR_ERR(pdev); | ||
105 | |||
106 | hx4700_pcmcia_device = pdev; | ||
107 | |||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static void __exit hx4700_pcmcia_exit(void) | ||
112 | { | ||
113 | platform_device_unregister(hx4700_pcmcia_device); | ||
114 | } | ||
115 | |||
116 | module_init(hx4700_pcmcia_init); | ||
117 | module_exit(hx4700_pcmcia_exit); | ||
118 | |||
119 | MODULE_AUTHOR("Paul Parsons <lost.distance@yahoo.com>"); | ||
120 | MODULE_DESCRIPTION("HP iPAQ hx4700 PCMCIA driver"); | ||
121 | MODULE_LICENSE("GPL"); | ||