blob: 6b87c7563a68723f6bf50fb56aab4f9c65acfdee [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, 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
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/dma-mapping.h>
16#include <linux/msm_kgsl.h>
17#include <linux/regulator/machine.h>
18#include <mach/irqs.h>
19#include <mach/msm_iomap.h>
20#include <mach/board.h>
21#include <mach/dma.h>
22#include <mach/dal_axi.h>
23#include <asm/mach/flash.h>
24#include <asm/hardware/cache-l2x0.h>
25#include <asm/mach/mmc.h>
26#include <mach/rpc_hsusb.h>
27#include <mach/socinfo.h>
28
29#include "devices.h"
30#include "devices-msm7x2xa.h"
31#include "footswitch.h"
32
33/* Address of GSBI blocks */
34#define MSM_GSBI0_PHYS 0xA1200000
35#define MSM_GSBI1_PHYS 0xA1300000
36
37/* GSBI QUPe devices */
38#define MSM_GSBI0_QUP_PHYS (MSM_GSBI0_PHYS + 0x80000)
39#define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000)
40
41static struct resource gsbi0_qup_i2c_resources[] = {
42 {
43 .name = "qup_phys_addr",
44 .start = MSM_GSBI0_QUP_PHYS,
45 .end = MSM_GSBI0_QUP_PHYS + SZ_4K - 1,
46 .flags = IORESOURCE_MEM,
47 },
48 {
49 .name = "gsbi_qup_i2c_addr",
50 .start = MSM_GSBI0_PHYS,
51 .end = MSM_GSBI0_PHYS + SZ_4K - 1,
52 .flags = IORESOURCE_MEM,
53 },
54 {
55 .name = "qup_err_intr",
56 .start = INT_PWB_I2C,
57 .end = INT_PWB_I2C,
58 .flags = IORESOURCE_IRQ,
59 },
60};
61
62/* Use GSBI0 QUP for /dev/i2c-0 */
63struct platform_device msm_gsbi0_qup_i2c_device = {
64 .name = "qup_i2c",
65 .id = MSM_GSBI0_QUP_I2C_BUS_ID,
66 .num_resources = ARRAY_SIZE(gsbi0_qup_i2c_resources),
67 .resource = gsbi0_qup_i2c_resources,
68};
69
70static struct resource gsbi1_qup_i2c_resources[] = {
71 {
72 .name = "qup_phys_addr",
73 .start = MSM_GSBI1_QUP_PHYS,
74 .end = MSM_GSBI1_QUP_PHYS + SZ_4K - 1,
75 .flags = IORESOURCE_MEM,
76 },
77 {
78 .name = "gsbi_qup_i2c_addr",
79 .start = MSM_GSBI1_PHYS,
80 .end = MSM_GSBI1_PHYS + SZ_4K - 1,
81 .flags = IORESOURCE_MEM,
82 },
83 {
84 .name = "qup_err_intr",
85 .start = INT_ARM11_DMA,
86 .end = INT_ARM11_DMA,
87 .flags = IORESOURCE_IRQ,
88 },
89};
90
91/* Use GSBI1 QUP for /dev/i2c-1 */
92struct platform_device msm_gsbi1_qup_i2c_device = {
93 .name = "qup_i2c",
94 .id = MSM_GSBI1_QUP_I2C_BUS_ID,
95 .num_resources = ARRAY_SIZE(gsbi1_qup_i2c_resources),
96 .resource = gsbi1_qup_i2c_resources,
97};
98
99#define MSM_HSUSB_PHYS 0xA0800000
100static struct resource resources_hsusb_otg[] = {
101 {
102 .start = MSM_HSUSB_PHYS,
103 .end = MSM_HSUSB_PHYS + SZ_1K - 1,
104 .flags = IORESOURCE_MEM,
105 },
106 {
107 .start = INT_USB_HS,
108 .end = INT_USB_HS,
109 .flags = IORESOURCE_IRQ,
110 },
111};
112
113static u64 dma_mask = 0xffffffffULL;
114struct platform_device msm_device_otg = {
115 .name = "msm_otg",
116 .id = -1,
117 .num_resources = ARRAY_SIZE(resources_hsusb_otg),
118 .resource = resources_hsusb_otg,
119 .dev = {
120 .dma_mask = &dma_mask,
121 .coherent_dma_mask = 0xffffffffULL,
122 },
123};
124
125static struct resource resources_gadget_peripheral[] = {
126 {
127 .start = MSM_HSUSB_PHYS,
128 .end = MSM_HSUSB_PHYS + SZ_1K - 1,
129 .flags = IORESOURCE_MEM,
130 },
131 {
132 .start = INT_USB_HS,
133 .end = INT_USB_HS,
134 .flags = IORESOURCE_IRQ,
135 },
136};
137
138struct platform_device msm_device_gadget_peripheral = {
139 .name = "msm_hsusb",
140 .id = -1,
141 .num_resources = ARRAY_SIZE(resources_gadget_peripheral),
142 .resource = resources_gadget_peripheral,
143 .dev = {
144 .dma_mask = &dma_mask,
145 .coherent_dma_mask = 0xffffffffULL,
146 },
147};
148
149static struct resource resources_hsusb_host[] = {
150 {
151 .start = MSM_HSUSB_PHYS,
152 .end = MSM_HSUSB_PHYS + SZ_1K - 1,
153 .flags = IORESOURCE_MEM,
154 },
155 {
156 .start = INT_USB_HS,
157 .end = INT_USB_HS,
158 .flags = IORESOURCE_IRQ,
159 },
160};
161
162struct platform_device msm_device_hsusb_host = {
163 .name = "msm_hsusb_host",
164 .id = 0,
165 .num_resources = ARRAY_SIZE(resources_hsusb_host),
166 .resource = resources_hsusb_host,
167 .dev = {
168 .dma_mask = &dma_mask,
169 .coherent_dma_mask = 0xffffffffULL,
170 },
171};
172
173static struct platform_device *msm_host_devices[] = {
174 &msm_device_hsusb_host,
175};
176
177int msm_add_host(unsigned int host, struct msm_usb_host_platform_data *plat)
178{
179 struct platform_device *pdev;
180
181 pdev = msm_host_devices[host];
182 if (!pdev)
183 return -ENODEV;
184 pdev->dev.platform_data = plat;
185 return platform_device_register(pdev);
186}
187
188static struct resource msm_dmov_resource[] = {
189 {
190 .start = INT_ADM_AARM,
191 .end = (resource_size_t)MSM_DMOV_BASE,
192 .flags = IORESOURCE_IRQ,
193 },
194};
195
196struct platform_device msm_device_dmov = {
197 .name = "msm_dmov",
198 .id = -1,
199 .resource = msm_dmov_resource,
200 .num_resources = ARRAY_SIZE(msm_dmov_resource),
201};
202
203struct platform_device msm_device_smd = {
204 .name = "msm_smd",
205 .id = -1,
206};
207
208static struct resource resources_uart1[] = {
209 {
210 .start = INT_UART1,
211 .end = INT_UART1,
212 .flags = IORESOURCE_IRQ,
213 },
214 {
215 .start = MSM_UART1_PHYS,
216 .end = MSM_UART1_PHYS + MSM_UART1_SIZE - 1,
217 .flags = IORESOURCE_MEM,
218 },
219};
220
221struct platform_device msm_device_uart1 = {
222 .name = "msm_serial",
223 .id = 0,
224 .num_resources = ARRAY_SIZE(resources_uart1),
225 .resource = resources_uart1,
226};
227
228#define MSM_UART1DM_PHYS 0xA0200000
229static struct resource msm_uart1_dm_resources[] = {
230 {
231 .start = MSM_UART1DM_PHYS,
232 .end = MSM_UART1DM_PHYS + PAGE_SIZE - 1,
233 .flags = IORESOURCE_MEM,
234 },
235 {
236 .start = INT_UART1DM_IRQ,
237 .end = INT_UART1DM_IRQ,
238 .flags = IORESOURCE_IRQ,
239 },
240 {
241 .start = INT_UART1DM_RX,
242 .end = INT_UART1DM_RX,
243 .flags = IORESOURCE_IRQ,
244 },
245 {
246 .start = DMOV_HSUART1_TX_CHAN,
247 .end = DMOV_HSUART1_RX_CHAN,
248 .name = "uartdm_channels",
249 .flags = IORESOURCE_DMA,
250 },
251 {
252 .start = DMOV_HSUART1_TX_CRCI,
253 .end = DMOV_HSUART1_RX_CRCI,
254 .name = "uartdm_crci",
255 .flags = IORESOURCE_DMA,
256 },
257};
258
259static u64 msm_uart_dm1_dma_mask = DMA_BIT_MASK(32);
260struct platform_device msm_device_uart_dm1 = {
261 .name = "msm_serial_hs",
262 .id = 0,
263 .num_resources = ARRAY_SIZE(msm_uart1_dm_resources),
264 .resource = msm_uart1_dm_resources,
265 .dev = {
266 .dma_mask = &msm_uart_dm1_dma_mask,
267 .coherent_dma_mask = DMA_BIT_MASK(32),
268 },
269};
270
271#define MSM_UART2DM_PHYS 0xA0300000
272static struct resource msm_uart2dm_resources[] = {
273 {
274 .start = MSM_UART2DM_PHYS,
275 .end = MSM_UART2DM_PHYS + PAGE_SIZE - 1,
276 .name = "uartdm_resource",
277 .flags = IORESOURCE_MEM,
278 },
279 {
280 .start = INT_UART2DM_IRQ,
281 .end = INT_UART2DM_IRQ,
282 .flags = IORESOURCE_IRQ,
283 },
284};
285
286struct platform_device msm_device_uart_dm2 = {
287 .name = "msm_serial_hsl",
288 .id = 0,
289 .num_resources = ARRAY_SIZE(msm_uart2dm_resources),
290 .resource = msm_uart2dm_resources,
291};
292
293#define MSM_NAND_PHYS 0xA0A00000
294#define MSM_NANDC01_PHYS 0xA0A40000
295#define MSM_NANDC10_PHYS 0xA0A80000
296#define MSM_NANDC11_PHYS 0xA0AC0000
297#define EBI2_REG_BASE 0xA0D00000
298static struct resource resources_nand[] = {
299 [0] = {
300 .name = "msm_nand_dmac",
301 .start = DMOV_NAND_CHAN,
302 .end = DMOV_NAND_CHAN,
303 .flags = IORESOURCE_DMA,
304 },
305 [1] = {
306 .name = "msm_nand_phys",
307 .start = MSM_NAND_PHYS,
308 .end = MSM_NAND_PHYS + 0x7FF,
309 .flags = IORESOURCE_MEM,
310 },
311 [2] = {
312 .name = "msm_nandc01_phys",
313 .start = MSM_NANDC01_PHYS,
314 .end = MSM_NANDC01_PHYS + 0x7FF,
315 .flags = IORESOURCE_MEM,
316 },
317 [3] = {
318 .name = "msm_nandc10_phys",
319 .start = MSM_NANDC10_PHYS,
320 .end = MSM_NANDC10_PHYS + 0x7FF,
321 .flags = IORESOURCE_MEM,
322 },
323 [4] = {
324 .name = "msm_nandc11_phys",
325 .start = MSM_NANDC11_PHYS,
326 .end = MSM_NANDC11_PHYS + 0x7FF,
327 .flags = IORESOURCE_MEM,
328 },
329 [5] = {
330 .name = "ebi2_reg_base",
331 .start = EBI2_REG_BASE,
332 .end = EBI2_REG_BASE + 0x60,
333 .flags = IORESOURCE_MEM,
334 },
335};
336
337struct flash_platform_data msm_nand_data;
338
339struct platform_device msm_device_nand = {
340 .name = "msm_nand",
341 .id = -1,
342 .num_resources = ARRAY_SIZE(resources_nand),
343 .resource = resources_nand,
344 .dev = {
345 .platform_data = &msm_nand_data,
346 },
347};
348
349#define MSM_SDC1_BASE 0xA0400000
350#define MSM_SDC2_BASE 0xA0500000
351#define MSM_SDC3_BASE 0xA0600000
352#define MSM_SDC4_BASE 0xA0700000
353static struct resource resources_sdc1[] = {
354 {
355 .start = MSM_SDC1_BASE,
356 .end = MSM_SDC1_BASE + SZ_4K - 1,
357 .flags = IORESOURCE_MEM,
358 },
359 {
360 .start = INT_SDC1_0,
361 .end = INT_SDC1_1,
362 .flags = IORESOURCE_IRQ,
363 },
364 {
365 .start = 8,
366 .end = 8,
367 .flags = IORESOURCE_DMA,
368 },
369};
370
371static struct resource resources_sdc2[] = {
372 {
373 .start = MSM_SDC2_BASE,
374 .end = MSM_SDC2_BASE + SZ_4K - 1,
375 .flags = IORESOURCE_MEM,
376 },
377 {
378 .start = INT_SDC2_0,
379 .end = INT_SDC2_1,
380 .flags = IORESOURCE_IRQ,
381 },
382 {
383 .start = 8,
384 .end = 8,
385 .flags = IORESOURCE_DMA,
386 },
387};
388
389static struct resource resources_sdc3[] = {
390 {
391 .start = MSM_SDC3_BASE,
392 .end = MSM_SDC3_BASE + SZ_4K - 1,
393 .flags = IORESOURCE_MEM,
394 },
395 {
396 .start = INT_SDC3_0,
397 .end = INT_SDC3_1,
398 .flags = IORESOURCE_IRQ,
399 },
400 {
401 .start = 8,
402 .end = 8,
403 .flags = IORESOURCE_DMA,
404 },
405};
406
407static struct resource resources_sdc4[] = {
408 {
409 .start = MSM_SDC4_BASE,
410 .end = MSM_SDC4_BASE + SZ_4K - 1,
411 .flags = IORESOURCE_MEM,
412 },
413 {
414 .start = INT_SDC4_0,
415 .end = INT_SDC4_1,
416 .flags = IORESOURCE_IRQ,
417 },
418 {
419 .start = 8,
420 .end = 8,
421 .flags = IORESOURCE_DMA,
422 },
423};
424
425struct platform_device msm_device_sdc1 = {
426 .name = "msm_sdcc",
427 .id = 1,
428 .num_resources = ARRAY_SIZE(resources_sdc1),
429 .resource = resources_sdc1,
430 .dev = {
431 .coherent_dma_mask = 0xffffffff,
432 },
433};
434
435struct platform_device msm_device_sdc2 = {
436 .name = "msm_sdcc",
437 .id = 2,
438 .num_resources = ARRAY_SIZE(resources_sdc2),
439 .resource = resources_sdc2,
440 .dev = {
441 .coherent_dma_mask = 0xffffffff,
442 },
443};
444
445struct platform_device msm_device_sdc3 = {
446 .name = "msm_sdcc",
447 .id = 3,
448 .num_resources = ARRAY_SIZE(resources_sdc3),
449 .resource = resources_sdc3,
450 .dev = {
451 .coherent_dma_mask = 0xffffffff,
452 },
453};
454
455struct platform_device msm_device_sdc4 = {
456 .name = "msm_sdcc",
457 .id = 4,
458 .num_resources = ARRAY_SIZE(resources_sdc4),
459 .resource = resources_sdc4,
460 .dev = {
461 .coherent_dma_mask = 0xffffffff,
462 },
463};
464
465static struct platform_device *msm_sdcc_devices[] __initdata = {
466 &msm_device_sdc1,
467 &msm_device_sdc2,
468 &msm_device_sdc3,
469 &msm_device_sdc4,
470};
471
472int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat)
473{
474 struct platform_device *pdev;
475
476 if (controller < 1 || controller > 4)
477 return -EINVAL;
478
479 pdev = msm_sdcc_devices[controller-1];
480 pdev->dev.platform_data = plat;
481 return platform_device_register(pdev);
482}
483
484#define MDP_BASE 0xAA200000
485#define MIPI_DSI_HW_BASE 0xA1100000
486
487static struct resource msm_mipi_dsi_resources[] = {
488 {
489 .name = "mipi_dsi",
490 .start = MIPI_DSI_HW_BASE,
491 .end = MIPI_DSI_HW_BASE + 0x000F0000 - 1,
492 .flags = IORESOURCE_MEM,
493 },
494 {
495 .start = INT_DSI_IRQ,
496 .end = INT_DSI_IRQ,
497 .flags = IORESOURCE_IRQ,
498 },
499};
500
501static struct platform_device msm_mipi_dsi_device = {
502 .name = "mipi_dsi",
503 .id = 1,
504 .num_resources = ARRAY_SIZE(msm_mipi_dsi_resources),
505 .resource = msm_mipi_dsi_resources,
506};
507
508static struct resource msm_mdp_resources[] = {
509 {
510 .name = "mdp",
511 .start = MDP_BASE,
512 .end = MDP_BASE + 0x000F1008 - 1,
513 .flags = IORESOURCE_MEM,
514 },
515 {
516 .start = INT_MDP,
517 .end = INT_MDP,
518 .flags = IORESOURCE_IRQ,
519 },
520};
521
522static struct platform_device msm_mdp_device = {
523 .name = "mdp",
524 .id = 0,
525 .num_resources = ARRAY_SIZE(msm_mdp_resources),
526 .resource = msm_mdp_resources,
527};
528
529static struct platform_device msm_lcdc_device = {
530 .name = "lcdc",
531 .id = 0,
532};
533
534static struct resource kgsl_3d0_resources[] = {
535 {
536 .name = KGSL_3D0_REG_MEMORY,
537 .start = 0xA0000000,
538 .end = 0xA001ffff,
539 .flags = IORESOURCE_MEM,
540 },
541 {
542 .name = KGSL_3D0_IRQ,
543 .start = INT_GRAPHICS,
544 .end = INT_GRAPHICS,
545 .flags = IORESOURCE_IRQ,
546 },
547};
548
549static struct kgsl_device_platform_data kgsl_3d0_pdata = {
550 .pwr_data = {
551 .pwrlevel = {
552 {
553 .gpu_freq = 245760000,
554 .bus_freq = 200000000,
555 },
556 {
557 .gpu_freq = 133330000,
558 .bus_freq = 0,
559 },
560 },
561 .init_level = 0,
562 .num_levels = 2,
563 .set_grp_async = set_grp_xbar_async,
564 .idle_timeout = HZ/5,
565 .nap_allowed = false,
566 },
567 .clk = {
568 .name = {
569 .clk = "grp_clk",
570 .pclk = "grp_pclk",
571 },
572 },
573 .imem_clk_name = {
574 .clk = "imem_clk",
575 .pclk = NULL,
576 },
577
578};
579
580struct platform_device msm_kgsl_3d0 = {
581 .name = "kgsl-3d0",
582 .id = 0,
583 .num_resources = ARRAY_SIZE(kgsl_3d0_resources),
584 .resource = kgsl_3d0_resources,
585 .dev = {
586 .platform_data = &kgsl_3d0_pdata,
587 },
588};
589
590void __init msm7x25a_kgsl_3d0_init(void)
591{
592 if (cpu_is_msm7x25a() || cpu_is_msm7x25aa()) {
593 kgsl_3d0_pdata.pwr_data.pwrlevel[0].gpu_freq = 133330000;
Lynus Vaz8d3208c2011-07-06 20:27:46 +0530594 kgsl_3d0_pdata.pwr_data.pwrlevel[0].bus_freq = 160000000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700595 kgsl_3d0_pdata.pwr_data.pwrlevel[1].gpu_freq = 96000000;
596 kgsl_3d0_pdata.pwr_data.pwrlevel[1].bus_freq = 0;
597 }
598}
599
600static void __init msm_register_device(struct platform_device *pdev, void *data)
601{
602 int ret;
603
604 pdev->dev.platform_data = data;
605
606 ret = platform_device_register(pdev);
607
608 if (ret)
609 dev_err(&pdev->dev,
610 "%s: platform_device_register() failed = %d\n",
611 __func__, ret);
612}
613
614void __init msm_fb_register_device(char *name, void *data)
615{
616 if (!strncmp(name, "mdp", 3))
617 msm_register_device(&msm_mdp_device, data);
618 else if (!strncmp(name, "mipi_dsi", 8))
619 msm_register_device(&msm_mipi_dsi_device, data);
620 else if (!strncmp(name, "lcdc", 4))
621 msm_register_device(&msm_lcdc_device, data);
622 else
623 printk(KERN_ERR "%s: unknown device! %s\n", __func__, name);
624}
625
626#define PERPH_WEB_BLOCK_ADDR (0xA9D00040)
627#define PDM0_CTL_OFFSET (0x04)
628#define SIZE_8B (0x08)
629
630static struct resource resources_led[] = {
631 {
632 .start = PERPH_WEB_BLOCK_ADDR,
633 .end = PERPH_WEB_BLOCK_ADDR + (SIZE_8B) - 1,
634 .name = "led-gpio-pdm",
635 .flags = IORESOURCE_MEM,
636 },
637};
638
639static struct led_info msm_kpbl_pdm_led_pdata = {
640 .name = "keyboard-backlight",
641};
642
643struct platform_device led_pdev = {
644 .name = "leds-msm-pdm",
645 /* use pdev id to represent pdm id */
646 .id = 0,
647 .num_resources = ARRAY_SIZE(resources_led),
648 .resource = resources_led,
649 .dev = {
650 .platform_data = &msm_kpbl_pdm_led_pdata,
651 },
652};
653
654static struct msm_acpu_clock_platform_data msm7x2x_clock_data = {
655 .acpu_switch_time_us = 50,
656 .max_speed_delta_khz = 400000,
657 .vdd_switch_time_us = 62,
658 .max_axi_khz = 200000,
659};
660
661int __init msm7x2x_misc_init(void)
662{
663 if (socinfo_init() < 0)
664 pr_err("%s: socinfo_init() failed!\n", __func__);
665
666 msm_clock_init(msm_clocks_7x27a, msm_num_clocks_7x27a);
667 msm_acpu_clock_init(&msm7x2x_clock_data);
668
669 return 0;
670}
671
672#ifdef CONFIG_CACHE_L2X0
673static int __init msm7x27x_cache_init(void)
674{
675 int aux_ctrl = 0;
676
677 /* Way Size 010(0x2) 32KB */
678 aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \
679 (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \
680 (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT);
681
682 l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK);
683
684 return 0;
685}
686#else
687static int __init msm_cache_init(void){ return 0; }
688#endif
689
690void __init msm_common_io_init(void)
691{
692 msm_map_common_io();
693 msm7x27x_cache_init();
694}
695
696struct platform_device *msm_footswitch_devices[] = {
697 FS_PCOM(FS_GFX3D, "fs_gfx3d"),
698};
699unsigned msm_num_footswitch_devices = ARRAY_SIZE(msm_footswitch_devices);