diff options
Diffstat (limited to 'arch/arm/mach-msm')
-rw-r--r-- | arch/arm/mach-msm/Kconfig | 4 | ||||
-rw-r--r-- | arch/arm/mach-msm/Makefile | 8 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpio-v2.c | 433 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpio.c | 376 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpio_hw.h | 278 | ||||
-rw-r--r-- | arch/arm/mach-msm/gpiomux.h | 17 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_gpiomux.h (renamed from arch/arm/mach-msm/include/mach/clkdev.h) | 29 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_iomap-7x00.h | 10 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_iomap-7x30.h | 10 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_iomap-8x50.h | 10 | ||||
-rw-r--r-- | arch/arm/mach-msm/include/mach/msm_iomap.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-msm/io.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-msm/platsmp.c | 11 |
13 files changed, 58 insertions, 1142 deletions
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig index 888e92502e15..ebde97f5d5f0 100644 --- a/arch/arm/mach-msm/Kconfig +++ b/arch/arm/mach-msm/Kconfig | |||
@@ -11,6 +11,7 @@ config ARCH_MSM7X00A | |||
11 | select MSM_SMD | 11 | select MSM_SMD |
12 | select MSM_SMD_PKG3 | 12 | select MSM_SMD_PKG3 |
13 | select CPU_V6 | 13 | select CPU_V6 |
14 | select GPIO_MSM_V1 | ||
14 | select MSM_PROC_COMM | 15 | select MSM_PROC_COMM |
15 | select HAS_MSM_DEBUG_UART_PHYS | 16 | select HAS_MSM_DEBUG_UART_PHYS |
16 | 17 | ||
@@ -22,6 +23,7 @@ config ARCH_MSM7X30 | |||
22 | select MSM_VIC | 23 | select MSM_VIC |
23 | select CPU_V7 | 24 | select CPU_V7 |
24 | select MSM_GPIOMUX | 25 | select MSM_GPIOMUX |
26 | select GPIO_MSM_V1 | ||
25 | select MSM_PROC_COMM | 27 | select MSM_PROC_COMM |
26 | select HAS_MSM_DEBUG_UART_PHYS | 28 | select HAS_MSM_DEBUG_UART_PHYS |
27 | 29 | ||
@@ -33,6 +35,7 @@ config ARCH_QSD8X50 | |||
33 | select MSM_VIC | 35 | select MSM_VIC |
34 | select CPU_V7 | 36 | select CPU_V7 |
35 | select MSM_GPIOMUX | 37 | select MSM_GPIOMUX |
38 | select GPIO_MSM_V1 | ||
36 | select MSM_PROC_COMM | 39 | select MSM_PROC_COMM |
37 | select HAS_MSM_DEBUG_UART_PHYS | 40 | select HAS_MSM_DEBUG_UART_PHYS |
38 | 41 | ||
@@ -44,6 +47,7 @@ config ARCH_MSM8X60 | |||
44 | select ARM_GIC | 47 | select ARM_GIC |
45 | select CPU_V7 | 48 | select CPU_V7 |
46 | select MSM_V2_TLMM | 49 | select MSM_V2_TLMM |
50 | select GPIO_MSM_V2 | ||
47 | select MSM_GPIOMUX | 51 | select MSM_GPIOMUX |
48 | select MSM_SCM if SMP | 52 | select MSM_SCM if SMP |
49 | 53 | ||
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index b70658c5ae00..4285dfd80b6f 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile | |||
@@ -29,11 +29,3 @@ obj-$(CONFIG_ARCH_MSM8960) += board-msm8960.o devices-msm8960.o | |||
29 | obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-v1.o gpiomux.o | 29 | obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-v1.o gpiomux.o |
30 | obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-v1.o gpiomux.o | 30 | obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-v1.o gpiomux.o |
31 | obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o gpiomux-v2.o gpiomux.o | 31 | obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o gpiomux-v2.o gpiomux.o |
32 | ifdef CONFIG_MSM_V2_TLMM | ||
33 | ifndef CONFIG_ARCH_MSM8960 | ||
34 | # TODO: TLMM Mapping issues need to be resolved | ||
35 | obj-y += gpio-v2.o | ||
36 | endif | ||
37 | else | ||
38 | obj-y += gpio.o | ||
39 | endif | ||
diff --git a/arch/arm/mach-msm/gpio-v2.c b/arch/arm/mach-msm/gpio-v2.c deleted file mode 100644 index cc9c4fd7cccc..000000000000 --- a/arch/arm/mach-msm/gpio-v2.c +++ /dev/null | |||
@@ -1,433 +0,0 @@ | |||
1 | /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 and | ||
5 | * only version 2 as published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
15 | * 02110-1301, USA. | ||
16 | * | ||
17 | */ | ||
18 | #define pr_fmt(fmt) "%s: " fmt, __func__ | ||
19 | |||
20 | #include <linux/bitmap.h> | ||
21 | #include <linux/bitops.h> | ||
22 | #include <linux/gpio.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/irq.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <linux/spinlock.h> | ||
30 | |||
31 | #include <asm/mach/irq.h> | ||
32 | |||
33 | #include <mach/msm_iomap.h> | ||
34 | #include "gpiomux.h" | ||
35 | |||
36 | /* Bits of interest in the GPIO_IN_OUT register. | ||
37 | */ | ||
38 | enum { | ||
39 | GPIO_IN = 0, | ||
40 | GPIO_OUT = 1 | ||
41 | }; | ||
42 | |||
43 | /* Bits of interest in the GPIO_INTR_STATUS register. | ||
44 | */ | ||
45 | enum { | ||
46 | INTR_STATUS = 0, | ||
47 | }; | ||
48 | |||
49 | /* Bits of interest in the GPIO_CFG register. | ||
50 | */ | ||
51 | enum { | ||
52 | GPIO_OE = 9, | ||
53 | }; | ||
54 | |||
55 | /* Bits of interest in the GPIO_INTR_CFG register. | ||
56 | * When a GPIO triggers, two separate decisions are made, controlled | ||
57 | * by two separate flags. | ||
58 | * | ||
59 | * - First, INTR_RAW_STATUS_EN controls whether or not the GPIO_INTR_STATUS | ||
60 | * register for that GPIO will be updated to reflect the triggering of that | ||
61 | * gpio. If this bit is 0, this register will not be updated. | ||
62 | * - Second, INTR_ENABLE controls whether an interrupt is triggered. | ||
63 | * | ||
64 | * If INTR_ENABLE is set and INTR_RAW_STATUS_EN is NOT set, an interrupt | ||
65 | * can be triggered but the status register will not reflect it. | ||
66 | */ | ||
67 | enum { | ||
68 | INTR_ENABLE = 0, | ||
69 | INTR_POL_CTL = 1, | ||
70 | INTR_DECT_CTL = 2, | ||
71 | INTR_RAW_STATUS_EN = 3, | ||
72 | }; | ||
73 | |||
74 | /* Codes of interest in GPIO_INTR_CFG_SU. | ||
75 | */ | ||
76 | enum { | ||
77 | TARGET_PROC_SCORPION = 4, | ||
78 | TARGET_PROC_NONE = 7, | ||
79 | }; | ||
80 | |||
81 | |||
82 | #define GPIO_INTR_CFG_SU(gpio) (MSM_TLMM_BASE + 0x0400 + (0x04 * (gpio))) | ||
83 | #define GPIO_CONFIG(gpio) (MSM_TLMM_BASE + 0x1000 + (0x10 * (gpio))) | ||
84 | #define GPIO_IN_OUT(gpio) (MSM_TLMM_BASE + 0x1004 + (0x10 * (gpio))) | ||
85 | #define GPIO_INTR_CFG(gpio) (MSM_TLMM_BASE + 0x1008 + (0x10 * (gpio))) | ||
86 | #define GPIO_INTR_STATUS(gpio) (MSM_TLMM_BASE + 0x100c + (0x10 * (gpio))) | ||
87 | |||
88 | /** | ||
89 | * struct msm_gpio_dev: the MSM8660 SoC GPIO device structure | ||
90 | * | ||
91 | * @enabled_irqs: a bitmap used to optimize the summary-irq handler. By | ||
92 | * keeping track of which gpios are unmasked as irq sources, we avoid | ||
93 | * having to do readl calls on hundreds of iomapped registers each time | ||
94 | * the summary interrupt fires in order to locate the active interrupts. | ||
95 | * | ||
96 | * @wake_irqs: a bitmap for tracking which interrupt lines are enabled | ||
97 | * as wakeup sources. When the device is suspended, interrupts which are | ||
98 | * not wakeup sources are disabled. | ||
99 | * | ||
100 | * @dual_edge_irqs: a bitmap used to track which irqs are configured | ||
101 | * as dual-edge, as this is not supported by the hardware and requires | ||
102 | * some special handling in the driver. | ||
103 | */ | ||
104 | struct msm_gpio_dev { | ||
105 | struct gpio_chip gpio_chip; | ||
106 | DECLARE_BITMAP(enabled_irqs, NR_GPIO_IRQS); | ||
107 | DECLARE_BITMAP(wake_irqs, NR_GPIO_IRQS); | ||
108 | DECLARE_BITMAP(dual_edge_irqs, NR_GPIO_IRQS); | ||
109 | }; | ||
110 | |||
111 | static DEFINE_SPINLOCK(tlmm_lock); | ||
112 | |||
113 | static inline struct msm_gpio_dev *to_msm_gpio_dev(struct gpio_chip *chip) | ||
114 | { | ||
115 | return container_of(chip, struct msm_gpio_dev, gpio_chip); | ||
116 | } | ||
117 | |||
118 | static inline void set_gpio_bits(unsigned n, void __iomem *reg) | ||
119 | { | ||
120 | writel(readl(reg) | n, reg); | ||
121 | } | ||
122 | |||
123 | static inline void clear_gpio_bits(unsigned n, void __iomem *reg) | ||
124 | { | ||
125 | writel(readl(reg) & ~n, reg); | ||
126 | } | ||
127 | |||
128 | static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
129 | { | ||
130 | return readl(GPIO_IN_OUT(offset)) & BIT(GPIO_IN); | ||
131 | } | ||
132 | |||
133 | static void msm_gpio_set(struct gpio_chip *chip, unsigned offset, int val) | ||
134 | { | ||
135 | writel(val ? BIT(GPIO_OUT) : 0, GPIO_IN_OUT(offset)); | ||
136 | } | ||
137 | |||
138 | static int msm_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | ||
139 | { | ||
140 | unsigned long irq_flags; | ||
141 | |||
142 | spin_lock_irqsave(&tlmm_lock, irq_flags); | ||
143 | clear_gpio_bits(BIT(GPIO_OE), GPIO_CONFIG(offset)); | ||
144 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | ||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static int msm_gpio_direction_output(struct gpio_chip *chip, | ||
149 | unsigned offset, | ||
150 | int val) | ||
151 | { | ||
152 | unsigned long irq_flags; | ||
153 | |||
154 | spin_lock_irqsave(&tlmm_lock, irq_flags); | ||
155 | msm_gpio_set(chip, offset, val); | ||
156 | set_gpio_bits(BIT(GPIO_OE), GPIO_CONFIG(offset)); | ||
157 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int msm_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
162 | { | ||
163 | return msm_gpiomux_get(chip->base + offset); | ||
164 | } | ||
165 | |||
166 | static void msm_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
167 | { | ||
168 | msm_gpiomux_put(chip->base + offset); | ||
169 | } | ||
170 | |||
171 | static int msm_gpio_to_irq(struct gpio_chip *chip, unsigned offset) | ||
172 | { | ||
173 | return MSM_GPIO_TO_INT(chip->base + offset); | ||
174 | } | ||
175 | |||
176 | static inline int msm_irq_to_gpio(struct gpio_chip *chip, unsigned irq) | ||
177 | { | ||
178 | return irq - MSM_GPIO_TO_INT(chip->base); | ||
179 | } | ||
180 | |||
181 | static struct msm_gpio_dev msm_gpio = { | ||
182 | .gpio_chip = { | ||
183 | .base = 0, | ||
184 | .ngpio = NR_GPIO_IRQS, | ||
185 | .direction_input = msm_gpio_direction_input, | ||
186 | .direction_output = msm_gpio_direction_output, | ||
187 | .get = msm_gpio_get, | ||
188 | .set = msm_gpio_set, | ||
189 | .to_irq = msm_gpio_to_irq, | ||
190 | .request = msm_gpio_request, | ||
191 | .free = msm_gpio_free, | ||
192 | }, | ||
193 | }; | ||
194 | |||
195 | /* For dual-edge interrupts in software, since the hardware has no | ||
196 | * such support: | ||
197 | * | ||
198 | * At appropriate moments, this function may be called to flip the polarity | ||
199 | * settings of both-edge irq lines to try and catch the next edge. | ||
200 | * | ||
201 | * The attempt is considered successful if: | ||
202 | * - the status bit goes high, indicating that an edge was caught, or | ||
203 | * - the input value of the gpio doesn't change during the attempt. | ||
204 | * If the value changes twice during the process, that would cause the first | ||
205 | * test to fail but would force the second, as two opposite | ||
206 | * transitions would cause a detection no matter the polarity setting. | ||
207 | * | ||
208 | * The do-loop tries to sledge-hammer closed the timing hole between | ||
209 | * the initial value-read and the polarity-write - if the line value changes | ||
210 | * during that window, an interrupt is lost, the new polarity setting is | ||
211 | * incorrect, and the first success test will fail, causing a retry. | ||
212 | * | ||
213 | * Algorithm comes from Google's msmgpio driver, see mach-msm/gpio.c. | ||
214 | */ | ||
215 | static void msm_gpio_update_dual_edge_pos(unsigned gpio) | ||
216 | { | ||
217 | int loop_limit = 100; | ||
218 | unsigned val, val2, intstat; | ||
219 | |||
220 | do { | ||
221 | val = readl(GPIO_IN_OUT(gpio)) & BIT(GPIO_IN); | ||
222 | if (val) | ||
223 | clear_gpio_bits(BIT(INTR_POL_CTL), GPIO_INTR_CFG(gpio)); | ||
224 | else | ||
225 | set_gpio_bits(BIT(INTR_POL_CTL), GPIO_INTR_CFG(gpio)); | ||
226 | val2 = readl(GPIO_IN_OUT(gpio)) & BIT(GPIO_IN); | ||
227 | intstat = readl(GPIO_INTR_STATUS(gpio)) & BIT(INTR_STATUS); | ||
228 | if (intstat || val == val2) | ||
229 | return; | ||
230 | } while (loop_limit-- > 0); | ||
231 | pr_err("dual-edge irq failed to stabilize, " | ||
232 | "interrupts dropped. %#08x != %#08x\n", | ||
233 | val, val2); | ||
234 | } | ||
235 | |||
236 | static void msm_gpio_irq_ack(struct irq_data *d) | ||
237 | { | ||
238 | int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq); | ||
239 | |||
240 | writel(BIT(INTR_STATUS), GPIO_INTR_STATUS(gpio)); | ||
241 | if (test_bit(gpio, msm_gpio.dual_edge_irqs)) | ||
242 | msm_gpio_update_dual_edge_pos(gpio); | ||
243 | } | ||
244 | |||
245 | static void msm_gpio_irq_mask(struct irq_data *d) | ||
246 | { | ||
247 | int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq); | ||
248 | unsigned long irq_flags; | ||
249 | |||
250 | spin_lock_irqsave(&tlmm_lock, irq_flags); | ||
251 | writel(TARGET_PROC_NONE, GPIO_INTR_CFG_SU(gpio)); | ||
252 | clear_gpio_bits(INTR_RAW_STATUS_EN | INTR_ENABLE, GPIO_INTR_CFG(gpio)); | ||
253 | __clear_bit(gpio, msm_gpio.enabled_irqs); | ||
254 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | ||
255 | } | ||
256 | |||
257 | static void msm_gpio_irq_unmask(struct irq_data *d) | ||
258 | { | ||
259 | int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq); | ||
260 | unsigned long irq_flags; | ||
261 | |||
262 | spin_lock_irqsave(&tlmm_lock, irq_flags); | ||
263 | __set_bit(gpio, msm_gpio.enabled_irqs); | ||
264 | set_gpio_bits(INTR_RAW_STATUS_EN | INTR_ENABLE, GPIO_INTR_CFG(gpio)); | ||
265 | writel(TARGET_PROC_SCORPION, GPIO_INTR_CFG_SU(gpio)); | ||
266 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | ||
267 | } | ||
268 | |||
269 | static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type) | ||
270 | { | ||
271 | int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq); | ||
272 | unsigned long irq_flags; | ||
273 | uint32_t bits; | ||
274 | |||
275 | spin_lock_irqsave(&tlmm_lock, irq_flags); | ||
276 | |||
277 | bits = readl(GPIO_INTR_CFG(gpio)); | ||
278 | |||
279 | if (flow_type & IRQ_TYPE_EDGE_BOTH) { | ||
280 | bits |= BIT(INTR_DECT_CTL); | ||
281 | __irq_set_handler_locked(d->irq, handle_edge_irq); | ||
282 | if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) | ||
283 | __set_bit(gpio, msm_gpio.dual_edge_irqs); | ||
284 | else | ||
285 | __clear_bit(gpio, msm_gpio.dual_edge_irqs); | ||
286 | } else { | ||
287 | bits &= ~BIT(INTR_DECT_CTL); | ||
288 | __irq_set_handler_locked(d->irq, handle_level_irq); | ||
289 | __clear_bit(gpio, msm_gpio.dual_edge_irqs); | ||
290 | } | ||
291 | |||
292 | if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) | ||
293 | bits |= BIT(INTR_POL_CTL); | ||
294 | else | ||
295 | bits &= ~BIT(INTR_POL_CTL); | ||
296 | |||
297 | writel(bits, GPIO_INTR_CFG(gpio)); | ||
298 | |||
299 | if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) | ||
300 | msm_gpio_update_dual_edge_pos(gpio); | ||
301 | |||
302 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | /* | ||
308 | * When the summary IRQ is raised, any number of GPIO lines may be high. | ||
309 | * It is the job of the summary handler to find all those GPIO lines | ||
310 | * which have been set as summary IRQ lines and which are triggered, | ||
311 | * and to call their interrupt handlers. | ||
312 | */ | ||
313 | static void msm_summary_irq_handler(unsigned int irq, struct irq_desc *desc) | ||
314 | { | ||
315 | unsigned long i; | ||
316 | struct irq_chip *chip = irq_desc_get_chip(desc); | ||
317 | |||
318 | chained_irq_enter(chip, desc); | ||
319 | |||
320 | for (i = find_first_bit(msm_gpio.enabled_irqs, NR_GPIO_IRQS); | ||
321 | i < NR_GPIO_IRQS; | ||
322 | i = find_next_bit(msm_gpio.enabled_irqs, NR_GPIO_IRQS, i + 1)) { | ||
323 | if (readl(GPIO_INTR_STATUS(i)) & BIT(INTR_STATUS)) | ||
324 | generic_handle_irq(msm_gpio_to_irq(&msm_gpio.gpio_chip, | ||
325 | i)); | ||
326 | } | ||
327 | |||
328 | chained_irq_exit(chip, desc); | ||
329 | } | ||
330 | |||
331 | static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on) | ||
332 | { | ||
333 | int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq); | ||
334 | |||
335 | if (on) { | ||
336 | if (bitmap_empty(msm_gpio.wake_irqs, NR_GPIO_IRQS)) | ||
337 | irq_set_irq_wake(TLMM_SCSS_SUMMARY_IRQ, 1); | ||
338 | set_bit(gpio, msm_gpio.wake_irqs); | ||
339 | } else { | ||
340 | clear_bit(gpio, msm_gpio.wake_irqs); | ||
341 | if (bitmap_empty(msm_gpio.wake_irqs, NR_GPIO_IRQS)) | ||
342 | irq_set_irq_wake(TLMM_SCSS_SUMMARY_IRQ, 0); | ||
343 | } | ||
344 | |||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static struct irq_chip msm_gpio_irq_chip = { | ||
349 | .name = "msmgpio", | ||
350 | .irq_mask = msm_gpio_irq_mask, | ||
351 | .irq_unmask = msm_gpio_irq_unmask, | ||
352 | .irq_ack = msm_gpio_irq_ack, | ||
353 | .irq_set_type = msm_gpio_irq_set_type, | ||
354 | .irq_set_wake = msm_gpio_irq_set_wake, | ||
355 | }; | ||
356 | |||
357 | static int __devinit msm_gpio_probe(struct platform_device *dev) | ||
358 | { | ||
359 | int i, irq, ret; | ||
360 | |||
361 | bitmap_zero(msm_gpio.enabled_irqs, NR_GPIO_IRQS); | ||
362 | bitmap_zero(msm_gpio.wake_irqs, NR_GPIO_IRQS); | ||
363 | bitmap_zero(msm_gpio.dual_edge_irqs, NR_GPIO_IRQS); | ||
364 | msm_gpio.gpio_chip.label = dev->name; | ||
365 | ret = gpiochip_add(&msm_gpio.gpio_chip); | ||
366 | if (ret < 0) | ||
367 | return ret; | ||
368 | |||
369 | for (i = 0; i < msm_gpio.gpio_chip.ngpio; ++i) { | ||
370 | irq = msm_gpio_to_irq(&msm_gpio.gpio_chip, i); | ||
371 | irq_set_chip_and_handler(irq, &msm_gpio_irq_chip, | ||
372 | handle_level_irq); | ||
373 | set_irq_flags(irq, IRQF_VALID); | ||
374 | } | ||
375 | |||
376 | irq_set_chained_handler(TLMM_SCSS_SUMMARY_IRQ, | ||
377 | msm_summary_irq_handler); | ||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | static int __devexit msm_gpio_remove(struct platform_device *dev) | ||
382 | { | ||
383 | int ret = gpiochip_remove(&msm_gpio.gpio_chip); | ||
384 | |||
385 | if (ret < 0) | ||
386 | return ret; | ||
387 | |||
388 | irq_set_handler(TLMM_SCSS_SUMMARY_IRQ, NULL); | ||
389 | |||
390 | return 0; | ||
391 | } | ||
392 | |||
393 | static struct platform_driver msm_gpio_driver = { | ||
394 | .probe = msm_gpio_probe, | ||
395 | .remove = __devexit_p(msm_gpio_remove), | ||
396 | .driver = { | ||
397 | .name = "msmgpio", | ||
398 | .owner = THIS_MODULE, | ||
399 | }, | ||
400 | }; | ||
401 | |||
402 | static struct platform_device msm_device_gpio = { | ||
403 | .name = "msmgpio", | ||
404 | .id = -1, | ||
405 | }; | ||
406 | |||
407 | static int __init msm_gpio_init(void) | ||
408 | { | ||
409 | int rc; | ||
410 | |||
411 | rc = platform_driver_register(&msm_gpio_driver); | ||
412 | if (!rc) { | ||
413 | rc = platform_device_register(&msm_device_gpio); | ||
414 | if (rc) | ||
415 | platform_driver_unregister(&msm_gpio_driver); | ||
416 | } | ||
417 | |||
418 | return rc; | ||
419 | } | ||
420 | |||
421 | static void __exit msm_gpio_exit(void) | ||
422 | { | ||
423 | platform_device_unregister(&msm_device_gpio); | ||
424 | platform_driver_unregister(&msm_gpio_driver); | ||
425 | } | ||
426 | |||
427 | postcore_initcall(msm_gpio_init); | ||
428 | module_exit(msm_gpio_exit); | ||
429 | |||
430 | MODULE_AUTHOR("Gregory Bean <gbean@codeaurora.org>"); | ||
431 | MODULE_DESCRIPTION("Driver for Qualcomm MSM TLMMv2 SoC GPIOs"); | ||
432 | MODULE_LICENSE("GPL v2"); | ||
433 | MODULE_ALIAS("platform:msmgpio"); | ||
diff --git a/arch/arm/mach-msm/gpio.c b/arch/arm/mach-msm/gpio.c deleted file mode 100644 index 5ea273b00da8..000000000000 --- a/arch/arm/mach-msm/gpio.c +++ /dev/null | |||
@@ -1,376 +0,0 @@ | |||
1 | /* linux/arch/arm/mach-msm/gpio.c | ||
2 | * | ||
3 | * Copyright (C) 2007 Google, Inc. | ||
4 | * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved. | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/bitops.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/irq.h> | ||
22 | #include <linux/module.h> | ||
23 | #include "gpio_hw.h" | ||
24 | #include "gpiomux.h" | ||
25 | |||
26 | #define FIRST_GPIO_IRQ MSM_GPIO_TO_INT(0) | ||
27 | |||
28 | #define MSM_GPIO_BANK(bank, first, last) \ | ||
29 | { \ | ||
30 | .regs = { \ | ||
31 | .out = MSM_GPIO_OUT_##bank, \ | ||
32 | .in = MSM_GPIO_IN_##bank, \ | ||
33 | .int_status = MSM_GPIO_INT_STATUS_##bank, \ | ||
34 | .int_clear = MSM_GPIO_INT_CLEAR_##bank, \ | ||
35 | .int_en = MSM_GPIO_INT_EN_##bank, \ | ||
36 | .int_edge = MSM_GPIO_INT_EDGE_##bank, \ | ||
37 | .int_pos = MSM_GPIO_INT_POS_##bank, \ | ||
38 | .oe = MSM_GPIO_OE_##bank, \ | ||
39 | }, \ | ||
40 | .chip = { \ | ||
41 | .base = (first), \ | ||
42 | .ngpio = (last) - (first) + 1, \ | ||
43 | .get = msm_gpio_get, \ | ||
44 | .set = msm_gpio_set, \ | ||
45 | .direction_input = msm_gpio_direction_input, \ | ||
46 | .direction_output = msm_gpio_direction_output, \ | ||
47 | .to_irq = msm_gpio_to_irq, \ | ||
48 | .request = msm_gpio_request, \ | ||
49 | .free = msm_gpio_free, \ | ||
50 | } \ | ||
51 | } | ||
52 | |||
53 | #define MSM_GPIO_BROKEN_INT_CLEAR 1 | ||
54 | |||
55 | struct msm_gpio_regs { | ||
56 | void __iomem *out; | ||
57 | void __iomem *in; | ||
58 | void __iomem *int_status; | ||
59 | void __iomem *int_clear; | ||
60 | void __iomem *int_en; | ||
61 | void __iomem *int_edge; | ||
62 | void __iomem *int_pos; | ||
63 | void __iomem *oe; | ||
64 | }; | ||
65 | |||
66 | struct msm_gpio_chip { | ||
67 | spinlock_t lock; | ||
68 | struct gpio_chip chip; | ||
69 | struct msm_gpio_regs regs; | ||
70 | #if MSM_GPIO_BROKEN_INT_CLEAR | ||
71 | unsigned int_status_copy; | ||
72 | #endif | ||
73 | unsigned int both_edge_detect; | ||
74 | unsigned int int_enable[2]; /* 0: awake, 1: sleep */ | ||
75 | }; | ||
76 | |||
77 | static int msm_gpio_write(struct msm_gpio_chip *msm_chip, | ||
78 | unsigned offset, unsigned on) | ||
79 | { | ||
80 | unsigned mask = BIT(offset); | ||
81 | unsigned val; | ||
82 | |||
83 | val = readl(msm_chip->regs.out); | ||
84 | if (on) | ||
85 | writel(val | mask, msm_chip->regs.out); | ||
86 | else | ||
87 | writel(val & ~mask, msm_chip->regs.out); | ||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | static void msm_gpio_update_both_edge_detect(struct msm_gpio_chip *msm_chip) | ||
92 | { | ||
93 | int loop_limit = 100; | ||
94 | unsigned pol, val, val2, intstat; | ||
95 | do { | ||
96 | val = readl(msm_chip->regs.in); | ||
97 | pol = readl(msm_chip->regs.int_pos); | ||
98 | pol = (pol & ~msm_chip->both_edge_detect) | | ||
99 | (~val & msm_chip->both_edge_detect); | ||
100 | writel(pol, msm_chip->regs.int_pos); | ||
101 | intstat = readl(msm_chip->regs.int_status); | ||
102 | val2 = readl(msm_chip->regs.in); | ||
103 | if (((val ^ val2) & msm_chip->both_edge_detect & ~intstat) == 0) | ||
104 | return; | ||
105 | } while (loop_limit-- > 0); | ||
106 | printk(KERN_ERR "msm_gpio_update_both_edge_detect, " | ||
107 | "failed to reach stable state %x != %x\n", val, val2); | ||
108 | } | ||
109 | |||
110 | static int msm_gpio_clear_detect_status(struct msm_gpio_chip *msm_chip, | ||
111 | unsigned offset) | ||
112 | { | ||
113 | unsigned bit = BIT(offset); | ||
114 | |||
115 | #if MSM_GPIO_BROKEN_INT_CLEAR | ||
116 | /* Save interrupts that already triggered before we loose them. */ | ||
117 | /* Any interrupt that triggers between the read of int_status */ | ||
118 | /* and the write to int_clear will still be lost though. */ | ||
119 | msm_chip->int_status_copy |= readl(msm_chip->regs.int_status); | ||
120 | msm_chip->int_status_copy &= ~bit; | ||
121 | #endif | ||
122 | writel(bit, msm_chip->regs.int_clear); | ||
123 | msm_gpio_update_both_edge_detect(msm_chip); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int msm_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | ||
128 | { | ||
129 | struct msm_gpio_chip *msm_chip; | ||
130 | unsigned long irq_flags; | ||
131 | |||
132 | msm_chip = container_of(chip, struct msm_gpio_chip, chip); | ||
133 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
134 | writel(readl(msm_chip->regs.oe) & ~BIT(offset), msm_chip->regs.oe); | ||
135 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static int | ||
140 | msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) | ||
141 | { | ||
142 | struct msm_gpio_chip *msm_chip; | ||
143 | unsigned long irq_flags; | ||
144 | |||
145 | msm_chip = container_of(chip, struct msm_gpio_chip, chip); | ||
146 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
147 | msm_gpio_write(msm_chip, offset, value); | ||
148 | writel(readl(msm_chip->regs.oe) | BIT(offset), msm_chip->regs.oe); | ||
149 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
154 | { | ||
155 | struct msm_gpio_chip *msm_chip; | ||
156 | |||
157 | msm_chip = container_of(chip, struct msm_gpio_chip, chip); | ||
158 | return (readl(msm_chip->regs.in) & (1U << offset)) ? 1 : 0; | ||
159 | } | ||
160 | |||
161 | static void msm_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
162 | { | ||
163 | struct msm_gpio_chip *msm_chip; | ||
164 | unsigned long irq_flags; | ||
165 | |||
166 | msm_chip = container_of(chip, struct msm_gpio_chip, chip); | ||
167 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
168 | msm_gpio_write(msm_chip, offset, value); | ||
169 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
170 | } | ||
171 | |||
172 | static int msm_gpio_to_irq(struct gpio_chip *chip, unsigned offset) | ||
173 | { | ||
174 | return MSM_GPIO_TO_INT(chip->base + offset); | ||
175 | } | ||
176 | |||
177 | #ifdef CONFIG_MSM_GPIOMUX | ||
178 | static int msm_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
179 | { | ||
180 | return msm_gpiomux_get(chip->base + offset); | ||
181 | } | ||
182 | |||
183 | static void msm_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
184 | { | ||
185 | msm_gpiomux_put(chip->base + offset); | ||
186 | } | ||
187 | #else | ||
188 | #define msm_gpio_request NULL | ||
189 | #define msm_gpio_free NULL | ||
190 | #endif | ||
191 | |||
192 | struct msm_gpio_chip msm_gpio_chips[] = { | ||
193 | #if defined(CONFIG_ARCH_MSM7X00A) | ||
194 | MSM_GPIO_BANK(0, 0, 15), | ||
195 | MSM_GPIO_BANK(1, 16, 42), | ||
196 | MSM_GPIO_BANK(2, 43, 67), | ||
197 | MSM_GPIO_BANK(3, 68, 94), | ||
198 | MSM_GPIO_BANK(4, 95, 106), | ||
199 | MSM_GPIO_BANK(5, 107, 121), | ||
200 | #elif defined(CONFIG_ARCH_MSM7X25) || defined(CONFIG_ARCH_MSM7X27) | ||
201 | MSM_GPIO_BANK(0, 0, 15), | ||
202 | MSM_GPIO_BANK(1, 16, 42), | ||
203 | MSM_GPIO_BANK(2, 43, 67), | ||
204 | MSM_GPIO_BANK(3, 68, 94), | ||
205 | MSM_GPIO_BANK(4, 95, 106), | ||
206 | MSM_GPIO_BANK(5, 107, 132), | ||
207 | #elif defined(CONFIG_ARCH_MSM7X30) | ||
208 | MSM_GPIO_BANK(0, 0, 15), | ||
209 | MSM_GPIO_BANK(1, 16, 43), | ||
210 | MSM_GPIO_BANK(2, 44, 67), | ||
211 | MSM_GPIO_BANK(3, 68, 94), | ||
212 | MSM_GPIO_BANK(4, 95, 106), | ||
213 | MSM_GPIO_BANK(5, 107, 133), | ||
214 | MSM_GPIO_BANK(6, 134, 150), | ||
215 | MSM_GPIO_BANK(7, 151, 181), | ||
216 | #elif defined(CONFIG_ARCH_QSD8X50) | ||
217 | MSM_GPIO_BANK(0, 0, 15), | ||
218 | MSM_GPIO_BANK(1, 16, 42), | ||
219 | MSM_GPIO_BANK(2, 43, 67), | ||
220 | MSM_GPIO_BANK(3, 68, 94), | ||
221 | MSM_GPIO_BANK(4, 95, 103), | ||
222 | MSM_GPIO_BANK(5, 104, 121), | ||
223 | MSM_GPIO_BANK(6, 122, 152), | ||
224 | MSM_GPIO_BANK(7, 153, 164), | ||
225 | #endif | ||
226 | }; | ||
227 | |||
228 | static void msm_gpio_irq_ack(struct irq_data *d) | ||
229 | { | ||
230 | unsigned long irq_flags; | ||
231 | struct msm_gpio_chip *msm_chip = irq_data_get_irq_chip_data(d); | ||
232 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
233 | msm_gpio_clear_detect_status(msm_chip, | ||
234 | d->irq - gpio_to_irq(msm_chip->chip.base)); | ||
235 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
236 | } | ||
237 | |||
238 | static void msm_gpio_irq_mask(struct irq_data *d) | ||
239 | { | ||
240 | unsigned long irq_flags; | ||
241 | struct msm_gpio_chip *msm_chip = irq_data_get_irq_chip_data(d); | ||
242 | unsigned offset = d->irq - gpio_to_irq(msm_chip->chip.base); | ||
243 | |||
244 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
245 | /* level triggered interrupts are also latched */ | ||
246 | if (!(readl(msm_chip->regs.int_edge) & BIT(offset))) | ||
247 | msm_gpio_clear_detect_status(msm_chip, offset); | ||
248 | msm_chip->int_enable[0] &= ~BIT(offset); | ||
249 | writel(msm_chip->int_enable[0], msm_chip->regs.int_en); | ||
250 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
251 | } | ||
252 | |||
253 | static void msm_gpio_irq_unmask(struct irq_data *d) | ||
254 | { | ||
255 | unsigned long irq_flags; | ||
256 | struct msm_gpio_chip *msm_chip = irq_data_get_irq_chip_data(d); | ||
257 | unsigned offset = d->irq - gpio_to_irq(msm_chip->chip.base); | ||
258 | |||
259 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
260 | /* level triggered interrupts are also latched */ | ||
261 | if (!(readl(msm_chip->regs.int_edge) & BIT(offset))) | ||
262 | msm_gpio_clear_detect_status(msm_chip, offset); | ||
263 | msm_chip->int_enable[0] |= BIT(offset); | ||
264 | writel(msm_chip->int_enable[0], msm_chip->regs.int_en); | ||
265 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
266 | } | ||
267 | |||
268 | static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on) | ||
269 | { | ||
270 | unsigned long irq_flags; | ||
271 | struct msm_gpio_chip *msm_chip = irq_data_get_irq_chip_data(d); | ||
272 | unsigned offset = d->irq - gpio_to_irq(msm_chip->chip.base); | ||
273 | |||
274 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
275 | |||
276 | if (on) | ||
277 | msm_chip->int_enable[1] |= BIT(offset); | ||
278 | else | ||
279 | msm_chip->int_enable[1] &= ~BIT(offset); | ||
280 | |||
281 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type) | ||
286 | { | ||
287 | unsigned long irq_flags; | ||
288 | struct msm_gpio_chip *msm_chip = irq_data_get_irq_chip_data(d); | ||
289 | unsigned offset = d->irq - gpio_to_irq(msm_chip->chip.base); | ||
290 | unsigned val, mask = BIT(offset); | ||
291 | |||
292 | spin_lock_irqsave(&msm_chip->lock, irq_flags); | ||
293 | val = readl(msm_chip->regs.int_edge); | ||
294 | if (flow_type & IRQ_TYPE_EDGE_BOTH) { | ||
295 | writel(val | mask, msm_chip->regs.int_edge); | ||
296 | __irq_set_handler_locked(d->irq, handle_edge_irq); | ||
297 | } else { | ||
298 | writel(val & ~mask, msm_chip->regs.int_edge); | ||
299 | __irq_set_handler_locked(d->irq, handle_level_irq); | ||
300 | } | ||
301 | if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { | ||
302 | msm_chip->both_edge_detect |= mask; | ||
303 | msm_gpio_update_both_edge_detect(msm_chip); | ||
304 | } else { | ||
305 | msm_chip->both_edge_detect &= ~mask; | ||
306 | val = readl(msm_chip->regs.int_pos); | ||
307 | if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_HIGH)) | ||
308 | writel(val | mask, msm_chip->regs.int_pos); | ||
309 | else | ||
310 | writel(val & ~mask, msm_chip->regs.int_pos); | ||
311 | } | ||
312 | spin_unlock_irqrestore(&msm_chip->lock, irq_flags); | ||
313 | return 0; | ||
314 | } | ||
315 | |||
316 | static void msm_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | ||
317 | { | ||
318 | int i, j, mask; | ||
319 | unsigned val; | ||
320 | |||
321 | for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) { | ||
322 | struct msm_gpio_chip *msm_chip = &msm_gpio_chips[i]; | ||
323 | val = readl(msm_chip->regs.int_status); | ||
324 | val &= msm_chip->int_enable[0]; | ||
325 | while (val) { | ||
326 | mask = val & -val; | ||
327 | j = fls(mask) - 1; | ||
328 | /* printk("%s %08x %08x bit %d gpio %d irq %d\n", | ||
329 | __func__, v, m, j, msm_chip->chip.start + j, | ||
330 | FIRST_GPIO_IRQ + msm_chip->chip.start + j); */ | ||
331 | val &= ~mask; | ||
332 | generic_handle_irq(FIRST_GPIO_IRQ + | ||
333 | msm_chip->chip.base + j); | ||
334 | } | ||
335 | } | ||
336 | desc->irq_data.chip->irq_ack(&desc->irq_data); | ||
337 | } | ||
338 | |||
339 | static struct irq_chip msm_gpio_irq_chip = { | ||
340 | .name = "msmgpio", | ||
341 | .irq_ack = msm_gpio_irq_ack, | ||
342 | .irq_mask = msm_gpio_irq_mask, | ||
343 | .irq_unmask = msm_gpio_irq_unmask, | ||
344 | .irq_set_wake = msm_gpio_irq_set_wake, | ||
345 | .irq_set_type = msm_gpio_irq_set_type, | ||
346 | }; | ||
347 | |||
348 | static int __init msm_init_gpio(void) | ||
349 | { | ||
350 | int i, j = 0; | ||
351 | |||
352 | for (i = FIRST_GPIO_IRQ; i < FIRST_GPIO_IRQ + NR_GPIO_IRQS; i++) { | ||
353 | if (i - FIRST_GPIO_IRQ >= | ||
354 | msm_gpio_chips[j].chip.base + | ||
355 | msm_gpio_chips[j].chip.ngpio) | ||
356 | j++; | ||
357 | irq_set_chip_data(i, &msm_gpio_chips[j]); | ||
358 | irq_set_chip_and_handler(i, &msm_gpio_irq_chip, | ||
359 | handle_edge_irq); | ||
360 | set_irq_flags(i, IRQF_VALID); | ||
361 | } | ||
362 | |||
363 | for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) { | ||
364 | spin_lock_init(&msm_gpio_chips[i].lock); | ||
365 | writel(0, msm_gpio_chips[i].regs.int_en); | ||
366 | gpiochip_add(&msm_gpio_chips[i].chip); | ||
367 | } | ||
368 | |||
369 | irq_set_chained_handler(INT_GPIO_GROUP1, msm_gpio_irq_handler); | ||
370 | irq_set_chained_handler(INT_GPIO_GROUP2, msm_gpio_irq_handler); | ||
371 | irq_set_irq_wake(INT_GPIO_GROUP1, 1); | ||
372 | irq_set_irq_wake(INT_GPIO_GROUP2, 2); | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | postcore_initcall(msm_init_gpio); | ||
diff --git a/arch/arm/mach-msm/gpio_hw.h b/arch/arm/mach-msm/gpio_hw.h deleted file mode 100644 index 6b5066038baa..000000000000 --- a/arch/arm/mach-msm/gpio_hw.h +++ /dev/null | |||
@@ -1,278 +0,0 @@ | |||
1 | /* arch/arm/mach-msm/gpio_hw.h | ||
2 | * | ||
3 | * Copyright (C) 2007 Google, Inc. | ||
4 | * Author: Brian Swetland <swetland@google.com> | ||
5 | * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved. | ||
6 | * | ||
7 | * This software is licensed under the terms of the GNU General Public | ||
8 | * License version 2, as published by the Free Software Foundation, and | ||
9 | * may be copied, distributed, and modified under those terms. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #ifndef __ARCH_ARM_MACH_MSM_GPIO_HW_H | ||
19 | #define __ARCH_ARM_MACH_MSM_GPIO_HW_H | ||
20 | |||
21 | #include <mach/msm_iomap.h> | ||
22 | |||
23 | /* see 80-VA736-2 Rev C pp 695-751 | ||
24 | ** | ||
25 | ** These are actually the *shadow* gpio registers, since the | ||
26 | ** real ones (which allow full access) are only available to the | ||
27 | ** ARM9 side of the world. | ||
28 | ** | ||
29 | ** Since the _BASE need to be page-aligned when we're mapping them | ||
30 | ** to virtual addresses, adjust for the additional offset in these | ||
31 | ** macros. | ||
32 | */ | ||
33 | |||
34 | #if defined(CONFIG_ARCH_MSM7X30) | ||
35 | #define MSM_GPIO1_REG(off) (MSM_GPIO1_BASE + (off)) | ||
36 | #define MSM_GPIO2_REG(off) (MSM_GPIO2_BASE + 0x400 + (off)) | ||
37 | #else | ||
38 | #define MSM_GPIO1_REG(off) (MSM_GPIO1_BASE + 0x800 + (off)) | ||
39 | #define MSM_GPIO2_REG(off) (MSM_GPIO2_BASE + 0xC00 + (off)) | ||
40 | #endif | ||
41 | |||
42 | #if defined(CONFIG_ARCH_MSM7X00A) || defined(CONFIG_ARCH_MSM7X25) ||\ | ||
43 | defined(CONFIG_ARCH_MSM7X27) | ||
44 | |||
45 | /* output value */ | ||
46 | #define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00) /* gpio 15-0 */ | ||
47 | #define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00) /* gpio 42-16 */ | ||
48 | #define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04) /* gpio 67-43 */ | ||
49 | #define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08) /* gpio 94-68 */ | ||
50 | #define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C) /* gpio 106-95 */ | ||
51 | #define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x50) /* gpio 107-121 */ | ||
52 | |||
53 | /* same pin map as above, output enable */ | ||
54 | #define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x10) | ||
55 | #define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08) | ||
56 | #define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x14) | ||
57 | #define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x18) | ||
58 | #define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x1C) | ||
59 | #define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x54) | ||
60 | |||
61 | /* same pin map as above, input read */ | ||
62 | #define MSM_GPIO_IN_0 MSM_GPIO1_REG(0x34) | ||
63 | #define MSM_GPIO_IN_1 MSM_GPIO2_REG(0x20) | ||
64 | #define MSM_GPIO_IN_2 MSM_GPIO1_REG(0x38) | ||
65 | #define MSM_GPIO_IN_3 MSM_GPIO1_REG(0x3C) | ||
66 | #define MSM_GPIO_IN_4 MSM_GPIO1_REG(0x40) | ||
67 | #define MSM_GPIO_IN_5 MSM_GPIO1_REG(0x44) | ||
68 | |||
69 | /* same pin map as above, 1=edge 0=level interrup */ | ||
70 | #define MSM_GPIO_INT_EDGE_0 MSM_GPIO1_REG(0x60) | ||
71 | #define MSM_GPIO_INT_EDGE_1 MSM_GPIO2_REG(0x50) | ||
72 | #define MSM_GPIO_INT_EDGE_2 MSM_GPIO1_REG(0x64) | ||
73 | #define MSM_GPIO_INT_EDGE_3 MSM_GPIO1_REG(0x68) | ||
74 | #define MSM_GPIO_INT_EDGE_4 MSM_GPIO1_REG(0x6C) | ||
75 | #define MSM_GPIO_INT_EDGE_5 MSM_GPIO1_REG(0xC0) | ||
76 | |||
77 | /* same pin map as above, 1=positive 0=negative */ | ||
78 | #define MSM_GPIO_INT_POS_0 MSM_GPIO1_REG(0x70) | ||
79 | #define MSM_GPIO_INT_POS_1 MSM_GPIO2_REG(0x58) | ||
80 | #define MSM_GPIO_INT_POS_2 MSM_GPIO1_REG(0x74) | ||
81 | #define MSM_GPIO_INT_POS_3 MSM_GPIO1_REG(0x78) | ||
82 | #define MSM_GPIO_INT_POS_4 MSM_GPIO1_REG(0x7C) | ||
83 | #define MSM_GPIO_INT_POS_5 MSM_GPIO1_REG(0xBC) | ||
84 | |||
85 | /* same pin map as above, interrupt enable */ | ||
86 | #define MSM_GPIO_INT_EN_0 MSM_GPIO1_REG(0x80) | ||
87 | #define MSM_GPIO_INT_EN_1 MSM_GPIO2_REG(0x60) | ||
88 | #define MSM_GPIO_INT_EN_2 MSM_GPIO1_REG(0x84) | ||
89 | #define MSM_GPIO_INT_EN_3 MSM_GPIO1_REG(0x88) | ||
90 | #define MSM_GPIO_INT_EN_4 MSM_GPIO1_REG(0x8C) | ||
91 | #define MSM_GPIO_INT_EN_5 MSM_GPIO1_REG(0xB8) | ||
92 | |||
93 | /* same pin map as above, write 1 to clear interrupt */ | ||
94 | #define MSM_GPIO_INT_CLEAR_0 MSM_GPIO1_REG(0x90) | ||
95 | #define MSM_GPIO_INT_CLEAR_1 MSM_GPIO2_REG(0x68) | ||
96 | #define MSM_GPIO_INT_CLEAR_2 MSM_GPIO1_REG(0x94) | ||
97 | #define MSM_GPIO_INT_CLEAR_3 MSM_GPIO1_REG(0x98) | ||
98 | #define MSM_GPIO_INT_CLEAR_4 MSM_GPIO1_REG(0x9C) | ||
99 | #define MSM_GPIO_INT_CLEAR_5 MSM_GPIO1_REG(0xB4) | ||
100 | |||
101 | /* same pin map as above, 1=interrupt pending */ | ||
102 | #define MSM_GPIO_INT_STATUS_0 MSM_GPIO1_REG(0xA0) | ||
103 | #define MSM_GPIO_INT_STATUS_1 MSM_GPIO2_REG(0x70) | ||
104 | #define MSM_GPIO_INT_STATUS_2 MSM_GPIO1_REG(0xA4) | ||
105 | #define MSM_GPIO_INT_STATUS_3 MSM_GPIO1_REG(0xA8) | ||
106 | #define MSM_GPIO_INT_STATUS_4 MSM_GPIO1_REG(0xAC) | ||
107 | #define MSM_GPIO_INT_STATUS_5 MSM_GPIO1_REG(0xB0) | ||
108 | |||
109 | #endif | ||
110 | |||
111 | #if defined(CONFIG_ARCH_QSD8X50) | ||
112 | /* output value */ | ||
113 | #define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00) /* gpio 15-0 */ | ||
114 | #define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00) /* gpio 42-16 */ | ||
115 | #define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04) /* gpio 67-43 */ | ||
116 | #define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08) /* gpio 94-68 */ | ||
117 | #define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C) /* gpio 103-95 */ | ||
118 | #define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x10) /* gpio 121-104 */ | ||
119 | #define MSM_GPIO_OUT_6 MSM_GPIO1_REG(0x14) /* gpio 152-122 */ | ||
120 | #define MSM_GPIO_OUT_7 MSM_GPIO1_REG(0x18) /* gpio 164-153 */ | ||
121 | |||
122 | /* same pin map as above, output enable */ | ||
123 | #define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x20) | ||
124 | #define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08) | ||
125 | #define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x24) | ||
126 | #define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x28) | ||
127 | #define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x2C) | ||
128 | #define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x30) | ||
129 | #define MSM_GPIO_OE_6 MSM_GPIO1_REG(0x34) | ||
130 | #define MSM_GPIO_OE_7 MSM_GPIO1_REG(0x38) | ||
131 | |||
132 | /* same pin map as above, input read */ | ||
133 | #define MSM_GPIO_IN_0 MSM_GPIO1_REG(0x50) | ||
134 | #define MSM_GPIO_IN_1 MSM_GPIO2_REG(0x20) | ||
135 | #define MSM_GPIO_IN_2 MSM_GPIO1_REG(0x54) | ||
136 | #define MSM_GPIO_IN_3 MSM_GPIO1_REG(0x58) | ||
137 | #define MSM_GPIO_IN_4 MSM_GPIO1_REG(0x5C) | ||
138 | #define MSM_GPIO_IN_5 MSM_GPIO1_REG(0x60) | ||
139 | #define MSM_GPIO_IN_6 MSM_GPIO1_REG(0x64) | ||
140 | #define MSM_GPIO_IN_7 MSM_GPIO1_REG(0x68) | ||
141 | |||
142 | /* same pin map as above, 1=edge 0=level interrup */ | ||
143 | #define MSM_GPIO_INT_EDGE_0 MSM_GPIO1_REG(0x70) | ||
144 | #define MSM_GPIO_INT_EDGE_1 MSM_GPIO2_REG(0x50) | ||
145 | #define MSM_GPIO_INT_EDGE_2 MSM_GPIO1_REG(0x74) | ||
146 | #define MSM_GPIO_INT_EDGE_3 MSM_GPIO1_REG(0x78) | ||
147 | #define MSM_GPIO_INT_EDGE_4 MSM_GPIO1_REG(0x7C) | ||
148 | #define MSM_GPIO_INT_EDGE_5 MSM_GPIO1_REG(0x80) | ||
149 | #define MSM_GPIO_INT_EDGE_6 MSM_GPIO1_REG(0x84) | ||
150 | #define MSM_GPIO_INT_EDGE_7 MSM_GPIO1_REG(0x88) | ||
151 | |||
152 | /* same pin map as above, 1=positive 0=negative */ | ||
153 | #define MSM_GPIO_INT_POS_0 MSM_GPIO1_REG(0x90) | ||
154 | #define MSM_GPIO_INT_POS_1 MSM_GPIO2_REG(0x58) | ||
155 | #define MSM_GPIO_INT_POS_2 MSM_GPIO1_REG(0x94) | ||
156 | #define MSM_GPIO_INT_POS_3 MSM_GPIO1_REG(0x98) | ||
157 | #define MSM_GPIO_INT_POS_4 MSM_GPIO1_REG(0x9C) | ||
158 | #define MSM_GPIO_INT_POS_5 MSM_GPIO1_REG(0xA0) | ||
159 | #define MSM_GPIO_INT_POS_6 MSM_GPIO1_REG(0xA4) | ||
160 | #define MSM_GPIO_INT_POS_7 MSM_GPIO1_REG(0xA8) | ||
161 | |||
162 | /* same pin map as above, interrupt enable */ | ||
163 | #define MSM_GPIO_INT_EN_0 MSM_GPIO1_REG(0xB0) | ||
164 | #define MSM_GPIO_INT_EN_1 MSM_GPIO2_REG(0x60) | ||
165 | #define MSM_GPIO_INT_EN_2 MSM_GPIO1_REG(0xB4) | ||
166 | #define MSM_GPIO_INT_EN_3 MSM_GPIO1_REG(0xB8) | ||
167 | #define MSM_GPIO_INT_EN_4 MSM_GPIO1_REG(0xBC) | ||
168 | #define MSM_GPIO_INT_EN_5 MSM_GPIO1_REG(0xC0) | ||
169 | #define MSM_GPIO_INT_EN_6 MSM_GPIO1_REG(0xC4) | ||
170 | #define MSM_GPIO_INT_EN_7 MSM_GPIO1_REG(0xC8) | ||
171 | |||
172 | /* same pin map as above, write 1 to clear interrupt */ | ||
173 | #define MSM_GPIO_INT_CLEAR_0 MSM_GPIO1_REG(0xD0) | ||
174 | #define MSM_GPIO_INT_CLEAR_1 MSM_GPIO2_REG(0x68) | ||
175 | #define MSM_GPIO_INT_CLEAR_2 MSM_GPIO1_REG(0xD4) | ||
176 | #define MSM_GPIO_INT_CLEAR_3 MSM_GPIO1_REG(0xD8) | ||
177 | #define MSM_GPIO_INT_CLEAR_4 MSM_GPIO1_REG(0xDC) | ||
178 | #define MSM_GPIO_INT_CLEAR_5 MSM_GPIO1_REG(0xE0) | ||
179 | #define MSM_GPIO_INT_CLEAR_6 MSM_GPIO1_REG(0xE4) | ||
180 | #define MSM_GPIO_INT_CLEAR_7 MSM_GPIO1_REG(0xE8) | ||
181 | |||
182 | /* same pin map as above, 1=interrupt pending */ | ||
183 | #define MSM_GPIO_INT_STATUS_0 MSM_GPIO1_REG(0xF0) | ||
184 | #define MSM_GPIO_INT_STATUS_1 MSM_GPIO2_REG(0x70) | ||
185 | #define MSM_GPIO_INT_STATUS_2 MSM_GPIO1_REG(0xF4) | ||
186 | #define MSM_GPIO_INT_STATUS_3 MSM_GPIO1_REG(0xF8) | ||
187 | #define MSM_GPIO_INT_STATUS_4 MSM_GPIO1_REG(0xFC) | ||
188 | #define MSM_GPIO_INT_STATUS_5 MSM_GPIO1_REG(0x100) | ||
189 | #define MSM_GPIO_INT_STATUS_6 MSM_GPIO1_REG(0x104) | ||
190 | #define MSM_GPIO_INT_STATUS_7 MSM_GPIO1_REG(0x108) | ||
191 | |||
192 | #endif | ||
193 | |||
194 | #if defined(CONFIG_ARCH_MSM7X30) | ||
195 | |||
196 | /* output value */ | ||
197 | #define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00) /* gpio 15-0 */ | ||
198 | #define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00) /* gpio 43-16 */ | ||
199 | #define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04) /* gpio 67-44 */ | ||
200 | #define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08) /* gpio 94-68 */ | ||
201 | #define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C) /* gpio 106-95 */ | ||
202 | #define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x50) /* gpio 133-107 */ | ||
203 | #define MSM_GPIO_OUT_6 MSM_GPIO1_REG(0xC4) /* gpio 150-134 */ | ||
204 | #define MSM_GPIO_OUT_7 MSM_GPIO1_REG(0x214) /* gpio 181-151 */ | ||
205 | |||
206 | /* same pin map as above, output enable */ | ||
207 | #define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x10) | ||
208 | #define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08) | ||
209 | #define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x14) | ||
210 | #define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x18) | ||
211 | #define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x1C) | ||
212 | #define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x54) | ||
213 | #define MSM_GPIO_OE_6 MSM_GPIO1_REG(0xC8) | ||
214 | #define MSM_GPIO_OE_7 MSM_GPIO1_REG(0x218) | ||
215 | |||
216 | /* same pin map as above, input read */ | ||
217 | #define MSM_GPIO_IN_0 MSM_GPIO1_REG(0x34) | ||
218 | #define MSM_GPIO_IN_1 MSM_GPIO2_REG(0x20) | ||
219 | #define MSM_GPIO_IN_2 MSM_GPIO1_REG(0x38) | ||
220 | #define MSM_GPIO_IN_3 MSM_GPIO1_REG(0x3C) | ||
221 | #define MSM_GPIO_IN_4 MSM_GPIO1_REG(0x40) | ||
222 | #define MSM_GPIO_IN_5 MSM_GPIO1_REG(0x44) | ||
223 | #define MSM_GPIO_IN_6 MSM_GPIO1_REG(0xCC) | ||
224 | #define MSM_GPIO_IN_7 MSM_GPIO1_REG(0x21C) | ||
225 | |||
226 | /* same pin map as above, 1=edge 0=level interrup */ | ||
227 | #define MSM_GPIO_INT_EDGE_0 MSM_GPIO1_REG(0x60) | ||
228 | #define MSM_GPIO_INT_EDGE_1 MSM_GPIO2_REG(0x50) | ||
229 | #define MSM_GPIO_INT_EDGE_2 MSM_GPIO1_REG(0x64) | ||
230 | #define MSM_GPIO_INT_EDGE_3 MSM_GPIO1_REG(0x68) | ||
231 | #define MSM_GPIO_INT_EDGE_4 MSM_GPIO1_REG(0x6C) | ||
232 | #define MSM_GPIO_INT_EDGE_5 MSM_GPIO1_REG(0xC0) | ||
233 | #define MSM_GPIO_INT_EDGE_6 MSM_GPIO1_REG(0xD0) | ||
234 | #define MSM_GPIO_INT_EDGE_7 MSM_GPIO1_REG(0x240) | ||
235 | |||
236 | /* same pin map as above, 1=positive 0=negative */ | ||
237 | #define MSM_GPIO_INT_POS_0 MSM_GPIO1_REG(0x70) | ||
238 | #define MSM_GPIO_INT_POS_1 MSM_GPIO2_REG(0x58) | ||
239 | #define MSM_GPIO_INT_POS_2 MSM_GPIO1_REG(0x74) | ||
240 | #define MSM_GPIO_INT_POS_3 MSM_GPIO1_REG(0x78) | ||
241 | #define MSM_GPIO_INT_POS_4 MSM_GPIO1_REG(0x7C) | ||
242 | #define MSM_GPIO_INT_POS_5 MSM_GPIO1_REG(0xBC) | ||
243 | #define MSM_GPIO_INT_POS_6 MSM_GPIO1_REG(0xD4) | ||
244 | #define MSM_GPIO_INT_POS_7 MSM_GPIO1_REG(0x228) | ||
245 | |||
246 | /* same pin map as above, interrupt enable */ | ||
247 | #define MSM_GPIO_INT_EN_0 MSM_GPIO1_REG(0x80) | ||
248 | #define MSM_GPIO_INT_EN_1 MSM_GPIO2_REG(0x60) | ||
249 | #define MSM_GPIO_INT_EN_2 MSM_GPIO1_REG(0x84) | ||
250 | #define MSM_GPIO_INT_EN_3 MSM_GPIO1_REG(0x88) | ||
251 | #define MSM_GPIO_INT_EN_4 MSM_GPIO1_REG(0x8C) | ||
252 | #define MSM_GPIO_INT_EN_5 MSM_GPIO1_REG(0xB8) | ||
253 | #define MSM_GPIO_INT_EN_6 MSM_GPIO1_REG(0xD8) | ||
254 | #define MSM_GPIO_INT_EN_7 MSM_GPIO1_REG(0x22C) | ||
255 | |||
256 | /* same pin map as above, write 1 to clear interrupt */ | ||
257 | #define MSM_GPIO_INT_CLEAR_0 MSM_GPIO1_REG(0x90) | ||
258 | #define MSM_GPIO_INT_CLEAR_1 MSM_GPIO2_REG(0x68) | ||
259 | #define MSM_GPIO_INT_CLEAR_2 MSM_GPIO1_REG(0x94) | ||
260 | #define MSM_GPIO_INT_CLEAR_3 MSM_GPIO1_REG(0x98) | ||
261 | #define MSM_GPIO_INT_CLEAR_4 MSM_GPIO1_REG(0x9C) | ||
262 | #define MSM_GPIO_INT_CLEAR_5 MSM_GPIO1_REG(0xB4) | ||
263 | #define MSM_GPIO_INT_CLEAR_6 MSM_GPIO1_REG(0xDC) | ||
264 | #define MSM_GPIO_INT_CLEAR_7 MSM_GPIO1_REG(0x230) | ||
265 | |||
266 | /* same pin map as above, 1=interrupt pending */ | ||
267 | #define MSM_GPIO_INT_STATUS_0 MSM_GPIO1_REG(0xA0) | ||
268 | #define MSM_GPIO_INT_STATUS_1 MSM_GPIO2_REG(0x70) | ||
269 | #define MSM_GPIO_INT_STATUS_2 MSM_GPIO1_REG(0xA4) | ||
270 | #define MSM_GPIO_INT_STATUS_3 MSM_GPIO1_REG(0xA8) | ||
271 | #define MSM_GPIO_INT_STATUS_4 MSM_GPIO1_REG(0xAC) | ||
272 | #define MSM_GPIO_INT_STATUS_5 MSM_GPIO1_REG(0xB0) | ||
273 | #define MSM_GPIO_INT_STATUS_6 MSM_GPIO1_REG(0xE0) | ||
274 | #define MSM_GPIO_INT_STATUS_7 MSM_GPIO1_REG(0x234) | ||
275 | |||
276 | #endif | ||
277 | |||
278 | #endif | ||
diff --git a/arch/arm/mach-msm/gpiomux.h b/arch/arm/mach-msm/gpiomux.h index b178d9cb742f..00459f6ee13c 100644 --- a/arch/arm/mach-msm/gpiomux.h +++ b/arch/arm/mach-msm/gpiomux.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/bitops.h> | 20 | #include <linux/bitops.h> |
21 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
22 | #include <mach/msm_gpiomux.h> | ||
22 | 23 | ||
23 | #if defined(CONFIG_MSM_V2_TLMM) | 24 | #if defined(CONFIG_MSM_V2_TLMM) |
24 | #include "gpiomux-v2.h" | 25 | #include "gpiomux-v2.h" |
@@ -71,12 +72,6 @@ enum { | |||
71 | */ | 72 | */ |
72 | extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS]; | 73 | extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS]; |
73 | 74 | ||
74 | /* Increment a gpio's reference count, possibly activating the line. */ | ||
75 | int __must_check msm_gpiomux_get(unsigned gpio); | ||
76 | |||
77 | /* Decrement a gpio's reference count, possibly suspending the line. */ | ||
78 | int msm_gpiomux_put(unsigned gpio); | ||
79 | |||
80 | /* Install a new configuration to the gpio line. To avoid overwriting | 75 | /* Install a new configuration to the gpio line. To avoid overwriting |
81 | * a configuration, leave the VALID bit out. | 76 | * a configuration, leave the VALID bit out. |
82 | */ | 77 | */ |
@@ -94,16 +89,6 @@ int msm_gpiomux_write(unsigned gpio, | |||
94 | */ | 89 | */ |
95 | void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val); | 90 | void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val); |
96 | #else | 91 | #else |
97 | static inline int __must_check msm_gpiomux_get(unsigned gpio) | ||
98 | { | ||
99 | return -ENOSYS; | ||
100 | } | ||
101 | |||
102 | static inline int msm_gpiomux_put(unsigned gpio) | ||
103 | { | ||
104 | return -ENOSYS; | ||
105 | } | ||
106 | |||
107 | static inline int msm_gpiomux_write(unsigned gpio, | 92 | static inline int msm_gpiomux_write(unsigned gpio, |
108 | gpiomux_config_t active, | 93 | gpiomux_config_t active, |
109 | gpiomux_config_t suspended) | 94 | gpiomux_config_t suspended) |
diff --git a/arch/arm/mach-msm/include/mach/clkdev.h b/arch/arm/mach-msm/include/mach/msm_gpiomux.h index f87a57b59534..0c7d3936e02f 100644 --- a/arch/arm/mach-msm/include/mach/clkdev.h +++ b/arch/arm/mach-msm/include/mach/msm_gpiomux.h | |||
@@ -9,11 +9,30 @@ | |||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | * GNU General Public License for more details. | 10 | * GNU General Public License for more details. |
11 | */ | 11 | */ |
12 | #ifndef __ASM_ARCH_MSM_CLKDEV_H | ||
13 | #define __ASM_ARCH_MSM_CLKDEV_H | ||
14 | 12 | ||
15 | struct clk; | 13 | #ifndef _LINUX_MSM_GPIOMUX_H |
14 | #define _LINUX_MSM_GPIOMUX_H | ||
15 | |||
16 | #ifdef CONFIG_MSM_GPIOMUX | ||
17 | |||
18 | /* Increment a gpio's reference count, possibly activating the line. */ | ||
19 | int __must_check msm_gpiomux_get(unsigned gpio); | ||
20 | |||
21 | /* Decrement a gpio's reference count, possibly suspending the line. */ | ||
22 | int msm_gpiomux_put(unsigned gpio); | ||
23 | |||
24 | #else | ||
25 | |||
26 | static inline int __must_check msm_gpiomux_get(unsigned gpio) | ||
27 | { | ||
28 | return -ENOSYS; | ||
29 | } | ||
30 | |||
31 | static inline int msm_gpiomux_put(unsigned gpio) | ||
32 | { | ||
33 | return -ENOSYS; | ||
34 | } | ||
16 | 35 | ||
17 | static inline int __clk_get(struct clk *clk) { return 1; } | ||
18 | static inline void __clk_put(struct clk *clk) { } | ||
19 | #endif | 36 | #endif |
37 | |||
38 | #endif /* _LINUX_MSM_GPIOMUX_H */ | ||
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-7x00.h b/arch/arm/mach-msm/include/mach/msm_iomap-7x00.h index 8f99d97615a0..94fe9fe6feb3 100644 --- a/arch/arm/mach-msm/include/mach/msm_iomap-7x00.h +++ b/arch/arm/mach-msm/include/mach/msm_iomap-7x00.h | |||
@@ -55,13 +55,11 @@ | |||
55 | #define MSM_DMOV_PHYS 0xA9700000 | 55 | #define MSM_DMOV_PHYS 0xA9700000 |
56 | #define MSM_DMOV_SIZE SZ_4K | 56 | #define MSM_DMOV_SIZE SZ_4K |
57 | 57 | ||
58 | #define MSM_GPIO1_BASE IOMEM(0xE0003000) | 58 | #define MSM7X00_GPIO1_PHYS 0xA9200000 |
59 | #define MSM_GPIO1_PHYS 0xA9200000 | 59 | #define MSM7X00_GPIO1_SIZE SZ_4K |
60 | #define MSM_GPIO1_SIZE SZ_4K | ||
61 | 60 | ||
62 | #define MSM_GPIO2_BASE IOMEM(0xE0004000) | 61 | #define MSM7X00_GPIO2_PHYS 0xA9300000 |
63 | #define MSM_GPIO2_PHYS 0xA9300000 | 62 | #define MSM7X00_GPIO2_SIZE SZ_4K |
64 | #define MSM_GPIO2_SIZE SZ_4K | ||
65 | 63 | ||
66 | #define MSM_CLK_CTL_BASE IOMEM(0xE0005000) | 64 | #define MSM_CLK_CTL_BASE IOMEM(0xE0005000) |
67 | #define MSM_CLK_CTL_PHYS 0xA8600000 | 65 | #define MSM_CLK_CTL_PHYS 0xA8600000 |
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-7x30.h b/arch/arm/mach-msm/include/mach/msm_iomap-7x30.h index 4d84be15955e..37694442d1bd 100644 --- a/arch/arm/mach-msm/include/mach/msm_iomap-7x30.h +++ b/arch/arm/mach-msm/include/mach/msm_iomap-7x30.h | |||
@@ -46,13 +46,11 @@ | |||
46 | #define MSM_DMOV_PHYS 0xAC400000 | 46 | #define MSM_DMOV_PHYS 0xAC400000 |
47 | #define MSM_DMOV_SIZE SZ_4K | 47 | #define MSM_DMOV_SIZE SZ_4K |
48 | 48 | ||
49 | #define MSM_GPIO1_BASE IOMEM(0xE0003000) | 49 | #define MSM7X30_GPIO1_PHYS 0xAC001000 |
50 | #define MSM_GPIO1_PHYS 0xAC001000 | 50 | #define MSM7X30_GPIO1_SIZE SZ_4K |
51 | #define MSM_GPIO1_SIZE SZ_4K | ||
52 | 51 | ||
53 | #define MSM_GPIO2_BASE IOMEM(0xE0004000) | 52 | #define MSM7X30_GPIO2_PHYS 0xAC101000 |
54 | #define MSM_GPIO2_PHYS 0xAC101000 | 53 | #define MSM7X30_GPIO2_SIZE SZ_4K |
55 | #define MSM_GPIO2_SIZE SZ_4K | ||
56 | 54 | ||
57 | #define MSM_CLK_CTL_BASE IOMEM(0xE0005000) | 55 | #define MSM_CLK_CTL_BASE IOMEM(0xE0005000) |
58 | #define MSM_CLK_CTL_PHYS 0xAB800000 | 56 | #define MSM_CLK_CTL_PHYS 0xAB800000 |
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-8x50.h b/arch/arm/mach-msm/include/mach/msm_iomap-8x50.h index d4143201999f..d67cd73316f4 100644 --- a/arch/arm/mach-msm/include/mach/msm_iomap-8x50.h +++ b/arch/arm/mach-msm/include/mach/msm_iomap-8x50.h | |||
@@ -46,13 +46,11 @@ | |||
46 | #define MSM_DMOV_PHYS 0xA9700000 | 46 | #define MSM_DMOV_PHYS 0xA9700000 |
47 | #define MSM_DMOV_SIZE SZ_4K | 47 | #define MSM_DMOV_SIZE SZ_4K |
48 | 48 | ||
49 | #define MSM_GPIO1_BASE IOMEM(0xE0003000) | 49 | #define QSD8X50_GPIO1_PHYS 0xA9000000 |
50 | #define MSM_GPIO1_PHYS 0xA9000000 | 50 | #define QSD8X50_GPIO1_SIZE SZ_4K |
51 | #define MSM_GPIO1_SIZE SZ_4K | ||
52 | 51 | ||
53 | #define MSM_GPIO2_BASE IOMEM(0xE0004000) | 52 | #define QSD8X50_GPIO2_PHYS 0xA9100000 |
54 | #define MSM_GPIO2_PHYS 0xA9100000 | 53 | #define QSD8X50_GPIO2_SIZE SZ_4K |
55 | #define MSM_GPIO2_SIZE SZ_4K | ||
56 | 54 | ||
57 | #define MSM_CLK_CTL_BASE IOMEM(0xE0005000) | 55 | #define MSM_CLK_CTL_BASE IOMEM(0xE0005000) |
58 | #define MSM_CLK_CTL_PHYS 0xA8600000 | 56 | #define MSM_CLK_CTL_PHYS 0xA8600000 |
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap.h b/arch/arm/mach-msm/include/mach/msm_iomap.h index 2f494b6a9d0a..4ded15238b60 100644 --- a/arch/arm/mach-msm/include/mach/msm_iomap.h +++ b/arch/arm/mach-msm/include/mach/msm_iomap.h | |||
@@ -61,5 +61,7 @@ | |||
61 | #define MSM_QGIC_CPU_BASE IOMEM(0xF0001000) | 61 | #define MSM_QGIC_CPU_BASE IOMEM(0xF0001000) |
62 | #define MSM_TMR_BASE IOMEM(0xF0200000) | 62 | #define MSM_TMR_BASE IOMEM(0xF0200000) |
63 | #define MSM_TMR0_BASE IOMEM(0xF0201000) | 63 | #define MSM_TMR0_BASE IOMEM(0xF0201000) |
64 | #define MSM_GPIO1_BASE IOMEM(0xE0003000) | ||
65 | #define MSM_GPIO2_BASE IOMEM(0xE0004000) | ||
64 | 66 | ||
65 | #endif | 67 | #endif |
diff --git a/arch/arm/mach-msm/io.c b/arch/arm/mach-msm/io.c index cec6ed1c91d3..140ddbbc3a8a 100644 --- a/arch/arm/mach-msm/io.c +++ b/arch/arm/mach-msm/io.c | |||
@@ -43,8 +43,8 @@ static struct map_desc msm_io_desc[] __initdata = { | |||
43 | MSM_DEVICE(VIC), | 43 | MSM_DEVICE(VIC), |
44 | MSM_CHIP_DEVICE(CSR, MSM7X00), | 44 | MSM_CHIP_DEVICE(CSR, MSM7X00), |
45 | MSM_DEVICE(DMOV), | 45 | MSM_DEVICE(DMOV), |
46 | MSM_DEVICE(GPIO1), | 46 | MSM_CHIP_DEVICE(GPIO1, MSM7X00), |
47 | MSM_DEVICE(GPIO2), | 47 | MSM_CHIP_DEVICE(GPIO2, MSM7X00), |
48 | MSM_DEVICE(CLK_CTL), | 48 | MSM_DEVICE(CLK_CTL), |
49 | #ifdef CONFIG_MSM_DEBUG_UART | 49 | #ifdef CONFIG_MSM_DEBUG_UART |
50 | MSM_DEVICE(DEBUG_UART), | 50 | MSM_DEVICE(DEBUG_UART), |
@@ -76,8 +76,8 @@ static struct map_desc qsd8x50_io_desc[] __initdata = { | |||
76 | MSM_DEVICE(VIC), | 76 | MSM_DEVICE(VIC), |
77 | MSM_CHIP_DEVICE(CSR, QSD8X50), | 77 | MSM_CHIP_DEVICE(CSR, QSD8X50), |
78 | MSM_DEVICE(DMOV), | 78 | MSM_DEVICE(DMOV), |
79 | MSM_DEVICE(GPIO1), | 79 | MSM_CHIP_DEVICE(GPIO1, QSD8X50), |
80 | MSM_DEVICE(GPIO2), | 80 | MSM_CHIP_DEVICE(GPIO2, QSD8X50), |
81 | MSM_DEVICE(CLK_CTL), | 81 | MSM_DEVICE(CLK_CTL), |
82 | MSM_DEVICE(SIRC), | 82 | MSM_DEVICE(SIRC), |
83 | MSM_DEVICE(SCPLL), | 83 | MSM_DEVICE(SCPLL), |
@@ -135,8 +135,8 @@ static struct map_desc msm7x30_io_desc[] __initdata = { | |||
135 | MSM_DEVICE(VIC), | 135 | MSM_DEVICE(VIC), |
136 | MSM_CHIP_DEVICE(CSR, MSM7X30), | 136 | MSM_CHIP_DEVICE(CSR, MSM7X30), |
137 | MSM_DEVICE(DMOV), | 137 | MSM_DEVICE(DMOV), |
138 | MSM_DEVICE(GPIO1), | 138 | MSM_CHIP_DEVICE(GPIO1, MSM7X30), |
139 | MSM_DEVICE(GPIO2), | 139 | MSM_CHIP_DEVICE(GPIO2, MSM7X30), |
140 | MSM_DEVICE(CLK_CTL), | 140 | MSM_DEVICE(CLK_CTL), |
141 | MSM_DEVICE(CLK_CTL_SH2), | 141 | MSM_DEVICE(CLK_CTL_SH2), |
142 | MSM_DEVICE(AD5), | 142 | MSM_DEVICE(AD5), |
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c index 315b9f365329..1a1af9e56250 100644 --- a/arch/arm/mach-msm/platsmp.c +++ b/arch/arm/mach-msm/platsmp.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <asm/hardware/gic.h> | 19 | #include <asm/hardware/gic.h> |
20 | #include <asm/cacheflush.h> | 20 | #include <asm/cacheflush.h> |
21 | #include <asm/cputype.h> | ||
21 | #include <asm/mach-types.h> | 22 | #include <asm/mach-types.h> |
22 | 23 | ||
23 | #include <mach/msm_iomap.h> | 24 | #include <mach/msm_iomap.h> |
@@ -40,6 +41,12 @@ volatile int pen_release = -1; | |||
40 | 41 | ||
41 | static DEFINE_SPINLOCK(boot_lock); | 42 | static DEFINE_SPINLOCK(boot_lock); |
42 | 43 | ||
44 | static inline int get_core_count(void) | ||
45 | { | ||
46 | /* 1 + the PART[1:0] field of MIDR */ | ||
47 | return ((read_cpuid_id() >> 4) & 3) + 1; | ||
48 | } | ||
49 | |||
43 | void __cpuinit platform_secondary_init(unsigned int cpu) | 50 | void __cpuinit platform_secondary_init(unsigned int cpu) |
44 | { | 51 | { |
45 | /* Configure edge-triggered PPIs */ | 52 | /* Configure edge-triggered PPIs */ |
@@ -147,9 +154,9 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
147 | */ | 154 | */ |
148 | void __init smp_init_cpus(void) | 155 | void __init smp_init_cpus(void) |
149 | { | 156 | { |
150 | unsigned int i; | 157 | unsigned int i, ncores = get_core_count(); |
151 | 158 | ||
152 | for (i = 0; i < NR_CPUS; i++) | 159 | for (i = 0; i < ncores; i++) |
153 | set_cpu_possible(i, true); | 160 | set_cpu_possible(i, true); |
154 | 161 | ||
155 | set_smp_cross_call(gic_raise_softirq); | 162 | set_smp_cross_call(gic_raise_softirq); |