diff options
author | Mike Rapoport <mike@compulab.co.il> | 2008-10-05 05:27:22 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-10-07 07:08:02 -0400 |
commit | 8616e2fb6930103a8408998777ec8a2332f5e89d (patch) | |
tree | 4701da5b57b8aad1f9e3d0b42ff261a0bcfd3f60 | |
parent | a7f3f0309b68d8d07a97a54c492802c294bccacd (diff) |
[ARM] 5283/1: pxa: add CM-X255 pcmcia support
Signed-off-by: Russ Dill <russ.dill@gmail.com>
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | drivers/pcmcia/Makefile | 2 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_cm_x255.c | 154 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_cm_x270.c | 14 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_cm_x2xx.c | 49 |
4 files changed, 206 insertions, 13 deletions
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 269a9e913ba2..749dff209d34 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -71,6 +71,6 @@ sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o | |||
71 | pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock.o sa1111_generic.o | 71 | pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock.o sa1111_generic.o |
72 | pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o | 72 | pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o |
73 | pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o | 73 | pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o |
74 | pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x270.o | 74 | pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx.o pxa2xx_cm_x255.o pxa2xx_cm_x270.o |
75 | pxa2xx_cs-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o | 75 | pxa2xx_cs-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o |
76 | 76 | ||
diff --git a/drivers/pcmcia/pxa2xx_cm_x255.c b/drivers/pcmcia/pxa2xx_cm_x255.c new file mode 100644 index 000000000000..7c8bcb476622 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_cm_x255.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa/pxa_cm_x255.c | ||
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 | * Compulab Ltd., 2003, 2007, 2008 | ||
9 | * Mike Rapoport <mike@compulab.co.il> | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/irq.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/gpio.h> | ||
17 | |||
18 | #include <asm/mach-types.h> | ||
19 | #include <mach/pxa-regs.h> | ||
20 | |||
21 | #include "soc_common.h" | ||
22 | |||
23 | #define GPIO_PCMCIA_SKTSEL (54) | ||
24 | #define GPIO_PCMCIA_S0_CD_VALID (16) | ||
25 | #define GPIO_PCMCIA_S1_CD_VALID (17) | ||
26 | #define GPIO_PCMCIA_S0_RDYINT (6) | ||
27 | #define GPIO_PCMCIA_S1_RDYINT (8) | ||
28 | #define GPIO_PCMCIA_RESET (9) | ||
29 | |||
30 | #define PCMCIA_S0_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID) | ||
31 | #define PCMCIA_S1_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S1_CD_VALID) | ||
32 | #define PCMCIA_S0_RDYINT IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT) | ||
33 | #define PCMCIA_S1_RDYINT IRQ_GPIO(GPIO_PCMCIA_S1_RDYINT) | ||
34 | |||
35 | |||
36 | static struct pcmcia_irqs irqs[] = { | ||
37 | { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" }, | ||
38 | { 1, PCMCIA_S1_CD_VALID, "PCMCIA1 CD" }, | ||
39 | }; | ||
40 | |||
41 | static int cmx255_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
42 | { | ||
43 | int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset"); | ||
44 | if (ret) | ||
45 | return ret; | ||
46 | gpio_direction_output(GPIO_PCMCIA_RESET, 0); | ||
47 | |||
48 | skt->irq = skt->nr == 0 ? PCMCIA_S0_RDYINT : PCMCIA_S1_RDYINT; | ||
49 | ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
50 | if (!ret) | ||
51 | gpio_free(GPIO_PCMCIA_RESET); | ||
52 | |||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | static void cmx255_pcmcia_shutdown(struct soc_pcmcia_socket *skt) | ||
57 | { | ||
58 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
59 | gpio_free(GPIO_PCMCIA_RESET); | ||
60 | } | ||
61 | |||
62 | |||
63 | static void cmx255_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
64 | struct pcmcia_state *state) | ||
65 | { | ||
66 | int cd = skt->nr ? GPIO_PCMCIA_S1_CD_VALID : GPIO_PCMCIA_S0_CD_VALID; | ||
67 | int rdy = skt->nr ? GPIO_PCMCIA_S0_RDYINT : GPIO_PCMCIA_S1_RDYINT; | ||
68 | |||
69 | state->detect = !gpio_get_value(cd); | ||
70 | state->ready = !!gpio_get_value(rdy); | ||
71 | state->bvd1 = 1; | ||
72 | state->bvd2 = 1; | ||
73 | state->vs_3v = 0; | ||
74 | state->vs_Xv = 0; | ||
75 | state->wrprot = 0; /* not available */ | ||
76 | } | ||
77 | |||
78 | |||
79 | static int cmx255_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
80 | const socket_state_t *state) | ||
81 | { | ||
82 | switch (skt->nr) { | ||
83 | case 0: | ||
84 | if (state->flags & SS_RESET) { | ||
85 | gpio_set_value(GPIO_PCMCIA_SKTSEL, 0); | ||
86 | udelay(1); | ||
87 | gpio_set_value(GPIO_PCMCIA_RESET, 1); | ||
88 | udelay(10); | ||
89 | gpio_set_value(GPIO_PCMCIA_RESET, 0); | ||
90 | } | ||
91 | break; | ||
92 | case 1: | ||
93 | if (state->flags & SS_RESET) { | ||
94 | gpio_set_value(GPIO_PCMCIA_SKTSEL, 1); | ||
95 | udelay(1); | ||
96 | gpio_set_value(GPIO_PCMCIA_RESET, 1); | ||
97 | udelay(10); | ||
98 | gpio_set_value(GPIO_PCMCIA_RESET, 0); | ||
99 | } | ||
100 | break; | ||
101 | } | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static void cmx255_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
107 | { | ||
108 | } | ||
109 | |||
110 | static void cmx255_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
111 | { | ||
112 | } | ||
113 | |||
114 | |||
115 | static struct pcmcia_low_level cmx255_pcmcia_ops __initdata = { | ||
116 | .owner = THIS_MODULE, | ||
117 | .hw_init = cmx255_pcmcia_hw_init, | ||
118 | .hw_shutdown = cmx255_pcmcia_shutdown, | ||
119 | .socket_state = cmx255_pcmcia_socket_state, | ||
120 | .configure_socket = cmx255_pcmcia_configure_socket, | ||
121 | .socket_init = cmx255_pcmcia_socket_init, | ||
122 | .socket_suspend = cmx255_pcmcia_socket_suspend, | ||
123 | .nr = 1, | ||
124 | }; | ||
125 | |||
126 | static struct platform_device *cmx255_pcmcia_device; | ||
127 | |||
128 | int __init cmx255_pcmcia_init(void) | ||
129 | { | ||
130 | int ret; | ||
131 | |||
132 | cmx255_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
133 | |||
134 | if (!cmx255_pcmcia_device) | ||
135 | return -ENOMEM; | ||
136 | |||
137 | ret = platform_device_add_data(cmx255_pcmcia_device, &cmx255_pcmcia_ops, | ||
138 | sizeof(cmx255_pcmcia_ops)); | ||
139 | |||
140 | if (ret == 0) { | ||
141 | printk(KERN_INFO "Registering cm-x255 PCMCIA interface.\n"); | ||
142 | ret = platform_device_add(cmx255_pcmcia_device); | ||
143 | } | ||
144 | |||
145 | if (ret) | ||
146 | platform_device_put(cmx255_pcmcia_device); | ||
147 | |||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | void __exit cmx255_pcmcia_exit(void) | ||
152 | { | ||
153 | platform_device_unregister(cmx255_pcmcia_device); | ||
154 | } | ||
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c index bcff5cfed051..6c3aac377126 100644 --- a/drivers/pcmcia/pxa2xx_cm_x270.c +++ b/drivers/pcmcia/pxa2xx_cm_x270.c | |||
@@ -105,13 +105,10 @@ static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = { | |||
105 | 105 | ||
106 | static struct platform_device *cmx270_pcmcia_device; | 106 | static struct platform_device *cmx270_pcmcia_device; |
107 | 107 | ||
108 | static int __init cmx270_pcmcia_init(void) | 108 | int __init cmx270_pcmcia_init(void) |
109 | { | 109 | { |
110 | int ret; | 110 | int ret; |
111 | 111 | ||
112 | if (!machine_is_armcore()) | ||
113 | return -ENODEV; | ||
114 | |||
115 | cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | 112 | cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); |
116 | 113 | ||
117 | if (!cmx270_pcmcia_device) | 114 | if (!cmx270_pcmcia_device) |
@@ -131,14 +128,7 @@ static int __init cmx270_pcmcia_init(void) | |||
131 | return ret; | 128 | return ret; |
132 | } | 129 | } |
133 | 130 | ||
134 | static void __exit cmx270_pcmcia_exit(void) | 131 | void __exit cmx270_pcmcia_exit(void) |
135 | { | 132 | { |
136 | platform_device_unregister(cmx270_pcmcia_device); | 133 | platform_device_unregister(cmx270_pcmcia_device); |
137 | } | 134 | } |
138 | |||
139 | module_init(cmx270_pcmcia_init); | ||
140 | module_exit(cmx270_pcmcia_exit); | ||
141 | |||
142 | MODULE_LICENSE("GPL"); | ||
143 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | ||
144 | MODULE_DESCRIPTION("CM-x270 PCMCIA driver"); | ||
diff --git a/drivers/pcmcia/pxa2xx_cm_x2xx.c b/drivers/pcmcia/pxa2xx_cm_x2xx.c new file mode 100644 index 000000000000..4f09506ad8d4 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_cm_x2xx.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa/pxa_cm_x2xx.c | ||
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 | * Compulab Ltd., 2003, 2007, 2008 | ||
9 | * Mike Rapoport <mike@compulab.co.il> | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | |||
15 | #include <asm/system.h> | ||
16 | #include <asm/mach-types.h> | ||
17 | #include <mach/system.h> | ||
18 | |||
19 | int cmx255_pcmcia_init(void); | ||
20 | int cmx270_pcmcia_init(void); | ||
21 | void cmx255_pcmcia_exit(void); | ||
22 | void cmx270_pcmcia_exit(void); | ||
23 | |||
24 | static int __init cmx2xx_pcmcia_init(void) | ||
25 | { | ||
26 | int ret = -ENODEV; | ||
27 | |||
28 | if (machine_is_armcore() && cpu_is_pxa25x()) | ||
29 | ret = cmx255_pcmcia_init(); | ||
30 | else if (machine_is_armcore() && cpu_is_pxa27x()) | ||
31 | ret = cmx270_pcmcia_init(); | ||
32 | |||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | static void __exit cmx2xx_pcmcia_exit(void) | ||
37 | { | ||
38 | if (machine_is_armcore() && cpu_is_pxa25x()) | ||
39 | cmx255_pcmcia_exit(); | ||
40 | else if (machine_is_armcore() && cpu_is_pxa27x()) | ||
41 | cmx270_pcmcia_exit(); | ||
42 | } | ||
43 | |||
44 | module_init(cmx2xx_pcmcia_init); | ||
45 | module_exit(cmx2xx_pcmcia_exit); | ||
46 | |||
47 | MODULE_LICENSE("GPL"); | ||
48 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | ||
49 | MODULE_DESCRIPTION("CM-x2xx PCMCIA driver"); | ||