blob: d7c7aabb2276884926262ae874b8bc0a72def1c2 [file] [log] [blame]
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -07001/* linux/arch/arm/mach-msm/devices.c
2 *
3 * Copyright (C) 2008 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#include <linux/kernel.h>
17#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/interrupt.h>
19#include <linux/dma-mapping.h>
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070020
Russell King80b02c12009-01-08 10:01:47 +000021#include <mach/irqs.h>
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070022#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <mach/dma.h>
24#include <asm/clkdev.h>
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070025#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include "proc_comm.h"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070027
28#include <asm/mach/flash.h>
29#include <linux/mtd/nand.h>
30#include <linux/mtd/partitions.h>
31
San Mehat5d4f77f2008-11-10 16:30:27 -080032#include <mach/mmc.h>
33
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070034static struct resource resources_uart1[] = {
35 {
36 .start = INT_UART1,
37 .end = INT_UART1,
38 .flags = IORESOURCE_IRQ,
39 },
40 {
41 .start = MSM_UART1_PHYS,
42 .end = MSM_UART1_PHYS + MSM_UART1_SIZE - 1,
43 .flags = IORESOURCE_MEM,
Stepan Moskovchenkod41cb8c2011-01-17 20:33:32 -080044 .name = "uart_resource"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070045 },
46};
47
48static struct resource resources_uart2[] = {
49 {
50 .start = INT_UART2,
51 .end = INT_UART2,
52 .flags = IORESOURCE_IRQ,
53 },
54 {
55 .start = MSM_UART2_PHYS,
56 .end = MSM_UART2_PHYS + MSM_UART2_SIZE - 1,
57 .flags = IORESOURCE_MEM,
Stepan Moskovchenkod41cb8c2011-01-17 20:33:32 -080058 .name = "uart_resource"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070059 },
60};
61
62static struct resource resources_uart3[] = {
63 {
64 .start = INT_UART3,
65 .end = INT_UART3,
66 .flags = IORESOURCE_IRQ,
67 },
68 {
69 .start = MSM_UART3_PHYS,
70 .end = MSM_UART3_PHYS + MSM_UART3_SIZE - 1,
71 .flags = IORESOURCE_MEM,
Stepan Moskovchenkod41cb8c2011-01-17 20:33:32 -080072 .name = "uart_resource"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070073 },
74};
75
76struct platform_device msm_device_uart1 = {
77 .name = "msm_serial",
78 .id = 0,
79 .num_resources = ARRAY_SIZE(resources_uart1),
80 .resource = resources_uart1,
81};
82
83struct platform_device msm_device_uart2 = {
84 .name = "msm_serial",
85 .id = 1,
86 .num_resources = ARRAY_SIZE(resources_uart2),
87 .resource = resources_uart2,
88};
89
90struct platform_device msm_device_uart3 = {
91 .name = "msm_serial",
92 .id = 2,
93 .num_resources = ARRAY_SIZE(resources_uart3),
94 .resource = resources_uart3,
95};
96
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097static struct resource msm_uart1_dm_resources[] = {
98 {
99 .start = MSM_UART1DM_PHYS,
100 .end = MSM_UART1DM_PHYS + PAGE_SIZE - 1,
101 .flags = IORESOURCE_MEM,
102 },
103 {
104 .start = INT_UART1DM_IRQ,
105 .end = INT_UART1DM_IRQ,
106 .flags = IORESOURCE_IRQ,
107 },
108 {
109 .start = INT_UART1DM_RX,
110 .end = INT_UART1DM_RX,
111 .flags = IORESOURCE_IRQ,
112 },
113 {
114 .start = DMOV_HSUART1_TX_CHAN,
115 .end = DMOV_HSUART1_RX_CHAN,
116 .name = "uartdm_channels",
117 .flags = IORESOURCE_DMA,
118 },
119 {
120 .start = DMOV_HSUART1_TX_CRCI,
121 .end = DMOV_HSUART1_RX_CRCI,
122 .name = "uartdm_crci",
123 .flags = IORESOURCE_DMA,
124 },
125};
126
127static u64 msm_uart_dm1_dma_mask = DMA_BIT_MASK(32);
128
129struct platform_device msm_device_uart_dm1 = {
130 .name = "msm_serial_hs",
131 .id = 0,
132 .num_resources = ARRAY_SIZE(msm_uart1_dm_resources),
133 .resource = msm_uart1_dm_resources,
134 .dev = {
135 .dma_mask = &msm_uart_dm1_dma_mask,
136 .coherent_dma_mask = DMA_BIT_MASK(32),
137 },
138};
139
140static struct resource msm_uart2_dm_resources[] = {
141 {
142 .start = MSM_UART2DM_PHYS,
143 .end = MSM_UART2DM_PHYS + PAGE_SIZE - 1,
144 .flags = IORESOURCE_MEM,
145 },
146 {
147 .start = INT_UART2DM_IRQ,
148 .end = INT_UART2DM_IRQ,
149 .flags = IORESOURCE_IRQ,
150 },
151 {
152 .start = INT_UART2DM_RX,
153 .end = INT_UART2DM_RX,
154 .flags = IORESOURCE_IRQ,
155 },
156 {
157 .start = DMOV_HSUART2_TX_CHAN,
158 .end = DMOV_HSUART2_RX_CHAN,
159 .name = "uartdm_channels",
160 .flags = IORESOURCE_DMA,
161 },
162 {
163 .start = DMOV_HSUART2_TX_CRCI,
164 .end = DMOV_HSUART2_RX_CRCI,
165 .name = "uartdm_crci",
166 .flags = IORESOURCE_DMA,
167 },
168};
169
170static u64 msm_uart_dm2_dma_mask = DMA_BIT_MASK(32);
171
172struct platform_device msm_device_uart_dm2 = {
173 .name = "msm_serial_hs",
174 .id = 1,
175 .num_resources = ARRAY_SIZE(msm_uart2_dm_resources),
176 .resource = msm_uart2_dm_resources,
177 .dev = {
178 .dma_mask = &msm_uart_dm2_dma_mask,
179 .coherent_dma_mask = DMA_BIT_MASK(32),
180 },
181};
182
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700183static struct resource resources_i2c[] = {
184 {
185 .start = MSM_I2C_PHYS,
186 .end = MSM_I2C_PHYS + MSM_I2C_SIZE - 1,
187 .flags = IORESOURCE_MEM,
188 },
189 {
190 .start = INT_PWB_I2C,
191 .end = INT_PWB_I2C,
192 .flags = IORESOURCE_IRQ,
193 },
194};
195
196struct platform_device msm_device_i2c = {
197 .name = "msm_i2c",
198 .id = 0,
199 .num_resources = ARRAY_SIZE(resources_i2c),
200 .resource = resources_i2c,
201};
202
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700203#define GPIO_I2C_CLK 60
204#define GPIO_I2C_DAT 61
205void msm_set_i2c_mux(bool gpio, int *gpio_clk, int *gpio_dat)
206{
207 unsigned id;
208 if (gpio) {
209 id = PCOM_GPIO_CFG(GPIO_I2C_CLK, 0, GPIO_OUTPUT,
210 GPIO_NO_PULL, GPIO_2MA);
211 msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
212 id = PCOM_GPIO_CFG(GPIO_I2C_DAT, 0, GPIO_OUTPUT,
213 GPIO_NO_PULL, GPIO_2MA);
214 msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
215 *gpio_clk = GPIO_I2C_CLK;
216 *gpio_dat = GPIO_I2C_DAT;
217 } else {
218 id = PCOM_GPIO_CFG(GPIO_I2C_CLK, 1, GPIO_INPUT,
219 GPIO_NO_PULL, GPIO_8MA);
220 msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
221 id = PCOM_GPIO_CFG(GPIO_I2C_DAT , 1, GPIO_INPUT,
222 GPIO_NO_PULL, GPIO_8MA);
223 msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
224 }
225}
226
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700227static struct resource resources_hsusb[] = {
228 {
229 .start = MSM_HSUSB_PHYS,
230 .end = MSM_HSUSB_PHYS + MSM_HSUSB_SIZE,
231 .flags = IORESOURCE_MEM,
232 },
233 {
234 .start = INT_USB_HS,
235 .end = INT_USB_HS,
236 .flags = IORESOURCE_IRQ,
237 },
238};
239
240struct platform_device msm_device_hsusb = {
241 .name = "msm_hsusb",
242 .id = -1,
243 .num_resources = ARRAY_SIZE(resources_hsusb),
244 .resource = resources_hsusb,
245 .dev = {
246 .coherent_dma_mask = 0xffffffff,
247 },
248};
249
250struct flash_platform_data msm_nand_data = {
251 .parts = NULL,
252 .nr_parts = 0,
253};
254
255static struct resource resources_nand[] = {
256 [0] = {
257 .start = 7,
258 .end = 7,
259 .flags = IORESOURCE_DMA,
260 },
261};
262
263struct platform_device msm_device_nand = {
264 .name = "msm_nand",
265 .id = -1,
266 .num_resources = ARRAY_SIZE(resources_nand),
267 .resource = resources_nand,
268 .dev = {
269 .platform_data = &msm_nand_data,
270 },
271};
272
273struct platform_device msm_device_smd = {
274 .name = "msm_smd",
275 .id = -1,
276};
277
278static struct resource resources_sdc1[] = {
279 {
280 .start = MSM_SDC1_PHYS,
281 .end = MSM_SDC1_PHYS + MSM_SDC1_SIZE - 1,
282 .flags = IORESOURCE_MEM,
283 },
284 {
285 .start = INT_SDC1_0,
Dima Zavin830d8432009-05-22 20:21:50 -0700286 .end = INT_SDC1_0,
287 .flags = IORESOURCE_IRQ,
288 .name = "cmd_irq",
289 },
290 {
291 .start = INT_SDC1_1,
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700292 .end = INT_SDC1_1,
293 .flags = IORESOURCE_IRQ,
Dima Zavin830d8432009-05-22 20:21:50 -0700294 .name = "pio_irq",
295 },
296 {
297 .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
298 .name = "status_irq"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700299 },
300 {
301 .start = 8,
302 .end = 8,
303 .flags = IORESOURCE_DMA,
304 },
305};
306
307static struct resource resources_sdc2[] = {
308 {
309 .start = MSM_SDC2_PHYS,
310 .end = MSM_SDC2_PHYS + MSM_SDC2_SIZE - 1,
311 .flags = IORESOURCE_MEM,
312 },
313 {
314 .start = INT_SDC2_0,
Dima Zavin830d8432009-05-22 20:21:50 -0700315 .end = INT_SDC2_0,
316 .flags = IORESOURCE_IRQ,
317 .name = "cmd_irq",
318 },
319 {
320 .start = INT_SDC2_1,
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700321 .end = INT_SDC2_1,
322 .flags = IORESOURCE_IRQ,
Dima Zavin830d8432009-05-22 20:21:50 -0700323 .name = "pio_irq",
324 },
325 {
326 .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
327 .name = "status_irq"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700328 },
329 {
330 .start = 8,
331 .end = 8,
332 .flags = IORESOURCE_DMA,
333 },
334};
335
336static struct resource resources_sdc3[] = {
337 {
338 .start = MSM_SDC3_PHYS,
339 .end = MSM_SDC3_PHYS + MSM_SDC3_SIZE - 1,
340 .flags = IORESOURCE_MEM,
341 },
342 {
343 .start = INT_SDC3_0,
Dima Zavin830d8432009-05-22 20:21:50 -0700344 .end = INT_SDC3_0,
345 .flags = IORESOURCE_IRQ,
346 .name = "cmd_irq",
347 },
348 {
349 .start = INT_SDC3_1,
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700350 .end = INT_SDC3_1,
351 .flags = IORESOURCE_IRQ,
Dima Zavin830d8432009-05-22 20:21:50 -0700352 .name = "pio_irq",
353 },
354 {
355 .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
356 .name = "status_irq"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700357 },
358 {
359 .start = 8,
360 .end = 8,
361 .flags = IORESOURCE_DMA,
362 },
363};
364
365static struct resource resources_sdc4[] = {
366 {
367 .start = MSM_SDC4_PHYS,
368 .end = MSM_SDC4_PHYS + MSM_SDC4_SIZE - 1,
369 .flags = IORESOURCE_MEM,
370 },
371 {
372 .start = INT_SDC4_0,
Dima Zavin830d8432009-05-22 20:21:50 -0700373 .end = INT_SDC4_0,
374 .flags = IORESOURCE_IRQ,
375 .name = "cmd_irq",
376 },
377 {
378 .start = INT_SDC4_1,
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700379 .end = INT_SDC4_1,
380 .flags = IORESOURCE_IRQ,
Dima Zavin830d8432009-05-22 20:21:50 -0700381 .name = "pio_irq",
382 },
383 {
384 .flags = IORESOURCE_IRQ | IORESOURCE_DISABLED,
385 .name = "status_irq"
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -0700386 },
387 {
388 .start = 8,
389 .end = 8,
390 .flags = IORESOURCE_DMA,
391 },
392};
393
394struct platform_device msm_device_sdc1 = {
395 .name = "msm_sdcc",
396 .id = 1,
397 .num_resources = ARRAY_SIZE(resources_sdc1),
398 .resource = resources_sdc1,
399 .dev = {
400 .coherent_dma_mask = 0xffffffff,
401 },
402};
403
404struct platform_device msm_device_sdc2 = {
405 .name = "msm_sdcc",
406 .id = 2,
407 .num_resources = ARRAY_SIZE(resources_sdc2),
408 .resource = resources_sdc2,
409 .dev = {
410 .coherent_dma_mask = 0xffffffff,
411 },
412};
413
414struct platform_device msm_device_sdc3 = {
415 .name = "msm_sdcc",
416 .id = 3,
417 .num_resources = ARRAY_SIZE(resources_sdc3),
418 .resource = resources_sdc3,
419 .dev = {
420 .coherent_dma_mask = 0xffffffff,
421 },
422};
423
424struct platform_device msm_device_sdc4 = {
425 .name = "msm_sdcc",
426 .id = 4,
427 .num_resources = ARRAY_SIZE(resources_sdc4),
428 .resource = resources_sdc4,
429 .dev = {
430 .coherent_dma_mask = 0xffffffff,
431 },
432};
San Mehat5d4f77f2008-11-10 16:30:27 -0800433
434static struct platform_device *msm_sdcc_devices[] __initdata = {
435 &msm_device_sdc1,
436 &msm_device_sdc2,
437 &msm_device_sdc3,
438 &msm_device_sdc4,
439};
440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700441int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat,
Dima Zavin830d8432009-05-22 20:21:50 -0700442 unsigned int stat_irq, unsigned long stat_irq_flags)
San Mehat5d4f77f2008-11-10 16:30:27 -0800443{
444 struct platform_device *pdev;
Dima Zavin830d8432009-05-22 20:21:50 -0700445 struct resource *res;
San Mehat5d4f77f2008-11-10 16:30:27 -0800446
447 if (controller < 1 || controller > 4)
448 return -EINVAL;
449
450 pdev = msm_sdcc_devices[controller-1];
451 pdev->dev.platform_data = plat;
Dima Zavin830d8432009-05-22 20:21:50 -0700452
453 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "status_irq");
454 if (!res)
455 return -EINVAL;
456 else if (stat_irq) {
457 res->start = res->end = stat_irq;
458 res->flags &= ~IORESOURCE_DISABLED;
459 res->flags |= stat_irq_flags;
460 }
461
San Mehat5d4f77f2008-11-10 16:30:27 -0800462 return platform_device_register(pdev);
463}
464
Daniel Walker50bc0ef2010-12-13 14:35:11 -0800465static struct resource resources_mddi0[] = {
466 {
467 .start = MSM_PMDH_PHYS,
468 .end = MSM_PMDH_PHYS + MSM_PMDH_SIZE - 1,
469 .flags = IORESOURCE_MEM,
470 },
471 {
472 .start = INT_MDDI_PRI,
473 .end = INT_MDDI_PRI,
474 .flags = IORESOURCE_IRQ,
475 },
476};
477
478static struct resource resources_mddi1[] = {
479 {
480 .start = MSM_EMDH_PHYS,
481 .end = MSM_EMDH_PHYS + MSM_EMDH_SIZE - 1,
482 .flags = IORESOURCE_MEM,
483 },
484 {
485 .start = INT_MDDI_EXT,
486 .end = INT_MDDI_EXT,
487 .flags = IORESOURCE_IRQ,
488 },
489};
490
491struct platform_device msm_device_mddi0 = {
492 .name = "msm_mddi",
493 .id = 0,
494 .num_resources = ARRAY_SIZE(resources_mddi0),
495 .resource = resources_mddi0,
496 .dev = {
497 .coherent_dma_mask = 0xffffffff,
498 },
499};
500
501struct platform_device msm_device_mddi1 = {
502 .name = "msm_mddi",
503 .id = 1,
504 .num_resources = ARRAY_SIZE(resources_mddi1),
505 .resource = resources_mddi1,
506 .dev = {
507 .coherent_dma_mask = 0xffffffff,
508 },
509};
510
511static struct resource resources_mdp[] = {
512 {
513 .start = MSM_MDP_PHYS,
514 .end = MSM_MDP_PHYS + MSM_MDP_SIZE - 1,
515 .name = "mdp",
516 .flags = IORESOURCE_MEM
517 },
518 {
519 .start = INT_MDP,
520 .end = INT_MDP,
521 .flags = IORESOURCE_IRQ,
522 },
523};
524
525struct platform_device msm_device_mdp = {
526 .name = "msm_mdp",
527 .id = 0,
528 .num_resources = ARRAY_SIZE(resources_mdp),
529 .resource = resources_mdp,
530};
531
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700532static struct resource resources_tssc[] = {
533 {
534 .start = MSM_TSSC_PHYS,
535 .end = MSM_TSSC_PHYS + MSM_TSSC_SIZE - 1,
536 .name = "tssc",
537 .flags = IORESOURCE_MEM,
538 },
539 {
540 .start = INT_TCHSCRN1,
541 .end = INT_TCHSCRN1,
542 .name = "tssc1",
543 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
544 },
545 {
546 .start = INT_TCHSCRN2,
547 .end = INT_TCHSCRN2,
548 .name = "tssc2",
549 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
550 },
Daniel Walker5e96da52010-05-12 13:43:28 -0700551};
552
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700553struct platform_device msm_device_touchscreen = {
554 .name = "msm_touchscreen",
555 .id = 0,
556 .num_resources = ARRAY_SIZE(resources_tssc),
557 .resource = resources_tssc,
558};