blob: 3cf7d48fb567acb341c6949e58620f9c2f5433ca [file] [log] [blame]
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -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
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/irq.h>
17#include <linux/io.h>
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -070018#include <linux/msm_tsens.h>
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -070019#include <linux/platform_data/qcom_crypto_device.h>
Amit Blay5e4ec192011-10-20 09:16:54 +020020#include <linux/dma-mapping.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070021#include <asm/hardware/gic.h>
Sahitya Tummala38295432011-09-29 10:08:45 +053022#include <asm/mach/flash.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070023#include <mach/board.h>
24#include <mach/msm_iomap.h>
Amit Blay5e4ec192011-10-20 09:16:54 +020025#include <mach/msm_hsusb.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070026#include <mach/irqs.h>
27#include <mach/socinfo.h>
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -060028#include <mach/rpm.h>
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -070029#include <asm/hardware/cache-l2x0.h>
Yan He092b7272011-09-21 15:25:03 -070030#include <mach/msm_sps.h>
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070031#include <mach/dma.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070032#include "devices.h"
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -060033#include "mpm.h"
34#include "spm.h"
35#include "pm.h"
36#include "rpm_resources.h"
Jeff Ohlstein7e668552011-10-06 16:17:25 -070037#include "msm_watchdog.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070038
Harini Jayaramaneba52672011-09-08 15:13:00 -060039/* Address of GSBI blocks */
40#define MSM_GSBI1_PHYS 0x16000000
41#define MSM_GSBI2_PHYS 0x16100000
42#define MSM_GSBI3_PHYS 0x16200000
Rohit Vaswani09666872011-08-23 17:41:54 -070043#define MSM_GSBI4_PHYS 0x16300000
Harini Jayaramaneba52672011-09-08 15:13:00 -060044#define MSM_GSBI5_PHYS 0x16400000
45
Rohit Vaswani09666872011-08-23 17:41:54 -070046#define MSM_UART4DM_PHYS (MSM_GSBI4_PHYS + 0x40000)
47
Harini Jayaramaneba52672011-09-08 15:13:00 -060048/* GSBI QUP devices */
49#define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000)
50#define MSM_GSBI2_QUP_PHYS (MSM_GSBI2_PHYS + 0x80000)
51#define MSM_GSBI3_QUP_PHYS (MSM_GSBI3_PHYS + 0x80000)
52#define MSM_GSBI4_QUP_PHYS (MSM_GSBI4_PHYS + 0x80000)
53#define MSM_GSBI5_QUP_PHYS (MSM_GSBI5_PHYS + 0x80000)
54#define MSM_QUP_SIZE SZ_4K
55
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070056/* Address of SSBI CMD */
57#define MSM_PMIC1_SSBI_CMD_PHYS 0x00500000
58#define MSM_PMIC_SSBI_SIZE SZ_4K
59
Jeff Ohlstein7e668552011-10-06 16:17:25 -070060static struct msm_watchdog_pdata msm_watchdog_pdata = {
61 .pet_time = 10000,
62 .bark_time = 11000,
63 .has_secure = true,
64};
65
66struct platform_device msm9615_device_watchdog = {
67 .name = "msm_watchdog",
68 .id = -1,
69 .dev = {
70 .platform_data = &msm_watchdog_pdata,
71 },
72};
73
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070074static struct resource msm_dmov_resource[] = {
75 {
76 .start = ADM_0_SCSS_1_IRQ,
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070077 .flags = IORESOURCE_IRQ,
78 },
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070079 {
80 .start = 0x18320000,
81 .end = 0x18320000 + SZ_1M - 1,
82 .flags = IORESOURCE_MEM,
83 },
84};
85
86static struct msm_dmov_pdata msm_dmov_pdata = {
87 .sd = 1,
88 .sd_size = 0x800,
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070089};
90
91struct platform_device msm9615_device_dmov = {
92 .name = "msm_dmov",
93 .id = -1,
94 .resource = msm_dmov_resource,
95 .num_resources = ARRAY_SIZE(msm_dmov_resource),
Jeff Ohlstein905f1ce2011-09-07 18:50:18 -070096 .dev = {
97 .platform_data = &msm_dmov_pdata,
98 },
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070099};
100
Amit Blay5e4ec192011-10-20 09:16:54 +0200101static struct resource resources_otg[] = {
102 {
103 .start = MSM9615_HSUSB_PHYS,
104 .end = MSM9615_HSUSB_PHYS + MSM9615_HSUSB_SIZE - 1,
105 .flags = IORESOURCE_MEM,
106 },
107 {
108 .start = USB1_HS_IRQ,
109 .end = USB1_HS_IRQ,
110 .flags = IORESOURCE_IRQ,
111 },
112};
113
114struct platform_device msm_device_otg = {
115 .name = "msm_otg",
116 .id = -1,
117 .num_resources = ARRAY_SIZE(resources_otg),
118 .resource = resources_otg,
119 .dev = {
120 .coherent_dma_mask = DMA_BIT_MASK(32),
121 },
122};
123
124static struct resource resources_hsusb[] = {
125 {
126 .start = MSM9615_HSUSB_PHYS,
127 .end = MSM9615_HSUSB_PHYS + MSM9615_HSUSB_SIZE - 1,
128 .flags = IORESOURCE_MEM,
129 },
130 {
131 .start = USB1_HS_IRQ,
132 .end = USB1_HS_IRQ,
133 .flags = IORESOURCE_IRQ,
134 },
135};
136
137struct platform_device msm_device_gadget_peripheral = {
138 .name = "msm_hsusb",
139 .id = -1,
140 .num_resources = ARRAY_SIZE(resources_hsusb),
141 .resource = resources_hsusb,
142 .dev = {
143 .coherent_dma_mask = DMA_BIT_MASK(32),
144 },
145};
146
Rohit Vaswani09666872011-08-23 17:41:54 -0700147static struct resource resources_uart_gsbi4[] = {
148 {
149 .start = GSBI4_UARTDM_IRQ,
150 .end = GSBI4_UARTDM_IRQ,
151 .flags = IORESOURCE_IRQ,
152 },
153 {
154 .start = MSM_UART4DM_PHYS,
155 .end = MSM_UART4DM_PHYS + PAGE_SIZE - 1,
156 .name = "uartdm_resource",
157 .flags = IORESOURCE_MEM,
158 },
159 {
160 .start = MSM_GSBI4_PHYS,
161 .end = MSM_GSBI4_PHYS + PAGE_SIZE - 1,
162 .name = "gsbi_resource",
163 .flags = IORESOURCE_MEM,
164 },
165};
166
167struct platform_device msm9615_device_uart_gsbi4 = {
168 .name = "msm_serial_hsl",
169 .id = 0,
170 .num_resources = ARRAY_SIZE(resources_uart_gsbi4),
171 .resource = resources_uart_gsbi4,
172};
173
Harini Jayaramaneba52672011-09-08 15:13:00 -0600174static struct resource resources_qup_i2c_gsbi5[] = {
175 {
176 .name = "gsbi_qup_i2c_addr",
177 .start = MSM_GSBI5_PHYS,
Harini Jayaraman7a60bc12011-09-15 14:58:54 -0600178 .end = MSM_GSBI5_PHYS + 4 - 1,
Harini Jayaramaneba52672011-09-08 15:13:00 -0600179 .flags = IORESOURCE_MEM,
180 },
181 {
182 .name = "qup_phys_addr",
183 .start = MSM_GSBI5_QUP_PHYS,
Harini Jayaraman7a60bc12011-09-15 14:58:54 -0600184 .end = MSM_GSBI5_QUP_PHYS + MSM_QUP_SIZE - 1,
Harini Jayaramaneba52672011-09-08 15:13:00 -0600185 .flags = IORESOURCE_MEM,
186 },
187 {
188 .name = "qup_err_intr",
189 .start = GSBI5_QUP_IRQ,
190 .end = GSBI5_QUP_IRQ,
191 .flags = IORESOURCE_IRQ,
192 },
193};
194
195struct platform_device msm9615_device_qup_i2c_gsbi5 = {
196 .name = "qup_i2c",
197 .id = 0,
198 .num_resources = ARRAY_SIZE(resources_qup_i2c_gsbi5),
199 .resource = resources_qup_i2c_gsbi5,
200};
201
Harini Jayaraman738c9312011-09-08 15:22:38 -0600202static struct resource resources_qup_spi_gsbi3[] = {
203 {
204 .name = "spi_base",
205 .start = MSM_GSBI3_QUP_PHYS,
206 .end = MSM_GSBI3_QUP_PHYS + SZ_4K - 1,
207 .flags = IORESOURCE_MEM,
208 },
209 {
210 .name = "gsbi_base",
211 .start = MSM_GSBI3_PHYS,
212 .end = MSM_GSBI3_PHYS + 4 - 1,
213 .flags = IORESOURCE_MEM,
214 },
215 {
216 .name = "spi_irq_in",
217 .start = GSBI3_QUP_IRQ,
218 .end = GSBI3_QUP_IRQ,
219 .flags = IORESOURCE_IRQ,
220 },
221};
222
223struct platform_device msm9615_device_qup_spi_gsbi3 = {
224 .name = "spi_qsd",
225 .id = 0,
226 .num_resources = ARRAY_SIZE(resources_qup_spi_gsbi3),
227 .resource = resources_qup_spi_gsbi3,
228};
229
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700230static struct resource resources_ssbi_pmic1[] = {
231 {
232 .start = MSM_PMIC1_SSBI_CMD_PHYS,
233 .end = MSM_PMIC1_SSBI_CMD_PHYS + MSM_PMIC_SSBI_SIZE - 1,
234 .flags = IORESOURCE_MEM,
235 },
236};
237
238struct platform_device msm9615_device_ssbi_pmic1 = {
239 .name = "msm_ssbi",
240 .id = 0,
241 .resource = resources_ssbi_pmic1,
242 .num_resources = ARRAY_SIZE(resources_ssbi_pmic1),
243};
244
Yan He092b7272011-09-21 15:25:03 -0700245static struct resource resources_sps[] = {
246 {
247 .name = "pipe_mem",
248 .start = 0x12800000,
249 .end = 0x12800000 + 0x4000 - 1,
250 .flags = IORESOURCE_MEM,
251 },
252 {
253 .name = "bamdma_dma",
254 .start = 0x12240000,
255 .end = 0x12240000 + 0x1000 - 1,
256 .flags = IORESOURCE_MEM,
257 },
258 {
259 .name = "bamdma_bam",
260 .start = 0x12244000,
261 .end = 0x12244000 + 0x4000 - 1,
262 .flags = IORESOURCE_MEM,
263 },
264 {
265 .name = "bamdma_irq",
266 .start = SPS_BAM_DMA_IRQ,
267 .end = SPS_BAM_DMA_IRQ,
268 .flags = IORESOURCE_IRQ,
269 },
270};
271
272struct msm_sps_platform_data msm_sps_pdata = {
273 .bamdma_restricted_pipes = 0x06,
274};
275
276struct platform_device msm_device_sps = {
277 .name = "msm_sps",
278 .id = -1,
279 .num_resources = ARRAY_SIZE(resources_sps),
280 .resource = resources_sps,
281 .dev.platform_data = &msm_sps_pdata,
282};
283
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700284static struct tsens_platform_data msm_tsens_pdata = {
285 .slope = 910,
286 .tsens_factor = 1000,
287 .hw_type = MSM_9615,
288 .tsens_num_sensor = 5,
289};
290
Sahitya Tummala38295432011-09-29 10:08:45 +0530291struct platform_device msm9615_device_tsens = {
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700292 .name = "tsens8960-tm",
293 .id = -1,
Sahitya Tummala38295432011-09-29 10:08:45 +0530294 .dev = {
295 .platform_data = &msm_tsens_pdata,
296 },
297};
298
299#define MSM_NAND_PHYS 0x1B400000
300static struct resource resources_nand[] = {
301 [0] = {
302 .name = "msm_nand_dmac",
303 .start = DMOV_NAND_CHAN,
304 .end = DMOV_NAND_CHAN,
305 .flags = IORESOURCE_DMA,
306 },
307 [1] = {
308 .name = "msm_nand_phys",
309 .start = MSM_NAND_PHYS,
310 .end = MSM_NAND_PHYS + 0x7FF,
311 .flags = IORESOURCE_MEM,
312 },
313};
314
315struct flash_platform_data msm_nand_data = {
316 .parts = NULL,
317 .nr_parts = 0,
318};
319
320struct platform_device msm_device_nand = {
321 .name = "msm_nand",
322 .id = -1,
323 .num_resources = ARRAY_SIZE(resources_nand),
324 .resource = resources_nand,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700325 .dev = {
Sahitya Tummala38295432011-09-29 10:08:45 +0530326 .platform_data = &msm_nand_data,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700327 },
328};
329
Jeff Hugo56b933a2011-09-28 14:42:05 -0600330struct platform_device msm_device_smd = {
331 .name = "msm_smd",
332 .id = -1,
333};
334
Ramesh Masavarapu5ad37392011-10-10 10:44:10 -0700335#ifdef CONFIG_HW_RANDOM_MSM
336/* PRNG device */
337#define MSM_PRNG_PHYS 0x1A500000
338static struct resource rng_resources = {
339 .flags = IORESOURCE_MEM,
340 .start = MSM_PRNG_PHYS,
341 .end = MSM_PRNG_PHYS + SZ_512 - 1,
342};
343
344struct platform_device msm_device_rng = {
345 .name = "msm_rng",
346 .id = 0,
347 .num_resources = 1,
348 .resource = &rng_resources,
349};
350#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700351
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700352#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
353 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
354 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
355 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
356
357#define QCE_SIZE 0x10000
358#define QCE_0_BASE 0x18500000
359
360#define QCE_HW_KEY_SUPPORT 0
361#define QCE_SHA_HMAC_SUPPORT 1
362#define QCE_SHARE_CE_RESOURCE 1
363#define QCE_CE_SHARED 0
364
365static struct resource qcrypto_resources[] = {
366 [0] = {
367 .start = QCE_0_BASE,
368 .end = QCE_0_BASE + QCE_SIZE - 1,
369 .flags = IORESOURCE_MEM,
370 },
371 [1] = {
372 .name = "crypto_channels",
373 .start = DMOV_CE_IN_CHAN,
374 .end = DMOV_CE_OUT_CHAN,
375 .flags = IORESOURCE_DMA,
376 },
377 [2] = {
378 .name = "crypto_crci_in",
379 .start = DMOV_CE_IN_CRCI,
380 .end = DMOV_CE_IN_CRCI,
381 .flags = IORESOURCE_DMA,
382 },
383 [3] = {
384 .name = "crypto_crci_out",
385 .start = DMOV_CE_OUT_CRCI,
386 .end = DMOV_CE_OUT_CRCI,
387 .flags = IORESOURCE_DMA,
388 },
389};
390
391static struct resource qcedev_resources[] = {
392 [0] = {
393 .start = QCE_0_BASE,
394 .end = QCE_0_BASE + QCE_SIZE - 1,
395 .flags = IORESOURCE_MEM,
396 },
397 [1] = {
398 .name = "crypto_channels",
399 .start = DMOV_CE_IN_CHAN,
400 .end = DMOV_CE_OUT_CHAN,
401 .flags = IORESOURCE_DMA,
402 },
403 [2] = {
404 .name = "crypto_crci_in",
405 .start = DMOV_CE_IN_CRCI,
406 .end = DMOV_CE_IN_CRCI,
407 .flags = IORESOURCE_DMA,
408 },
409 [3] = {
410 .name = "crypto_crci_out",
411 .start = DMOV_CE_OUT_CRCI,
412 .end = DMOV_CE_OUT_CRCI,
413 .flags = IORESOURCE_DMA,
414 },
415};
416
417#endif
418
419#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
420 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
421
422static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
423 .ce_shared = QCE_CE_SHARED,
424 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
425 .hw_key_support = QCE_HW_KEY_SUPPORT,
426 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
427};
428
429struct platform_device msm9615_qcrypto_device = {
430 .name = "qcrypto",
431 .id = 0,
432 .num_resources = ARRAY_SIZE(qcrypto_resources),
433 .resource = qcrypto_resources,
434 .dev = {
435 .coherent_dma_mask = DMA_BIT_MASK(32),
436 .platform_data = &qcrypto_ce_hw_suppport,
437 },
438};
439#endif
440
441#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
442 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
443
444static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
445 .ce_shared = QCE_CE_SHARED,
446 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
447 .hw_key_support = QCE_HW_KEY_SUPPORT,
448 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
449};
450
451struct platform_device msm9615_qcedev_device = {
452 .name = "qce",
453 .id = 0,
454 .num_resources = ARRAY_SIZE(qcedev_resources),
455 .resource = qcedev_resources,
456 .dev = {
457 .coherent_dma_mask = DMA_BIT_MASK(32),
458 .platform_data = &qcedev_ce_hw_suppport,
459 },
460};
461#endif
462
Krishna Kondadd794462011-10-01 00:19:29 -0700463#define MSM_SDC1_BASE 0x12180000
464#define MSM_SDC1_DML_BASE (MSM_SDC1_BASE + 0x800)
465#define MSM_SDC1_BAM_BASE (MSM_SDC1_BASE + 0x2000)
Krishna Konda71aef182011-10-01 02:27:51 -0700466#define MSM_SDC2_BASE 0x12140000
467#define MSM_SDC2_DML_BASE (MSM_SDC2_BASE + 0x800)
468#define MSM_SDC2_BAM_BASE (MSM_SDC2_BASE + 0x2000)
Krishna Kondadd794462011-10-01 00:19:29 -0700469
470static struct resource resources_sdc1[] = {
471 {
472 .name = "core_mem",
473 .flags = IORESOURCE_MEM,
474 .start = MSM_SDC1_BASE,
475 .end = MSM_SDC1_DML_BASE - 1,
476 },
477 {
478 .name = "core_irq",
479 .flags = IORESOURCE_IRQ,
480 .start = SDC1_IRQ_0,
481 .end = SDC1_IRQ_0
482 },
483#ifdef CONFIG_MMC_MSM_SPS_SUPPORT
484 {
485 .name = "sdcc_dml_addr",
486 .start = MSM_SDC1_DML_BASE,
487 .end = MSM_SDC1_BAM_BASE - 1,
488 .flags = IORESOURCE_MEM,
489 },
490 {
491 .name = "sdcc_bam_addr",
492 .start = MSM_SDC1_BAM_BASE,
493 .end = MSM_SDC1_BAM_BASE + (2 * SZ_4K) - 1,
494 .flags = IORESOURCE_MEM,
495 },
496 {
497 .name = "sdcc_bam_irq",
498 .start = SDC1_BAM_IRQ,
499 .end = SDC1_BAM_IRQ,
500 .flags = IORESOURCE_IRQ,
501 },
502#endif
503};
504
Krishna Konda71aef182011-10-01 02:27:51 -0700505static struct resource resources_sdc2[] = {
506 {
507 .name = "core_mem",
508 .flags = IORESOURCE_MEM,
509 .start = MSM_SDC2_BASE,
510 .end = MSM_SDC2_DML_BASE - 1,
511 },
512 {
513 .name = "core_irq",
514 .flags = IORESOURCE_IRQ,
515 .start = SDC2_IRQ_0,
516 .end = SDC2_IRQ_0
517 },
518#ifdef CONFIG_MMC_MSM_SPS_SUPPORT
519 {
520 .name = "sdcc_dml_addr",
521 .start = MSM_SDC2_DML_BASE,
522 .end = MSM_SDC2_BAM_BASE - 1,
523 .flags = IORESOURCE_MEM,
524 },
525 {
526 .name = "sdcc_bam_addr",
527 .start = MSM_SDC2_BAM_BASE,
528 .end = MSM_SDC2_BAM_BASE + (2 * SZ_4K) - 1,
529 .flags = IORESOURCE_MEM,
530 },
531 {
532 .name = "sdcc_bam_irq",
533 .start = SDC2_BAM_IRQ,
534 .end = SDC2_BAM_IRQ,
535 .flags = IORESOURCE_IRQ,
536 },
537#endif
538};
539
Krishna Kondadd794462011-10-01 00:19:29 -0700540struct platform_device msm_device_sdc1 = {
541 .name = "msm_sdcc",
542 .id = 1,
543 .num_resources = ARRAY_SIZE(resources_sdc1),
544 .resource = resources_sdc1,
545 .dev = {
546 .coherent_dma_mask = 0xffffffff,
547 },
548};
549
Krishna Konda71aef182011-10-01 02:27:51 -0700550struct platform_device msm_device_sdc2 = {
551 .name = "msm_sdcc",
552 .id = 2,
553 .num_resources = ARRAY_SIZE(resources_sdc2),
554 .resource = resources_sdc2,
555 .dev = {
556 .coherent_dma_mask = 0xffffffff,
557 },
558};
559
Krishna Kondadd794462011-10-01 00:19:29 -0700560static struct platform_device *msm_sdcc_devices[] __initdata = {
561 &msm_device_sdc1,
Krishna Konda71aef182011-10-01 02:27:51 -0700562 &msm_device_sdc2,
Krishna Kondadd794462011-10-01 00:19:29 -0700563};
564
565int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat)
566{
567 struct platform_device *pdev;
568
569 if (controller < 1 || controller > 2)
570 return -EINVAL;
571
572 pdev = msm_sdcc_devices[controller - 1];
573 pdev->dev.platform_data = plat;
574 return platform_device_register(pdev);
575}
576
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700577#ifdef CONFIG_CACHE_L2X0
578static int __init l2x0_cache_init(void)
579{
580 int aux_ctrl = 0;
581
582 /* Way Size 010(0x2) 32KB */
583 aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \
584 (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \
585 (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT);
586
587 /* L2 Latency setting required by hardware. Default is 0x20
588 which is no good.
589 */
590 writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL);
591 l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK);
592
593 return 0;
594}
595#else
596static int __init l2x0_cache_init(void){ return 0; }
597#endif
598
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600599struct msm_rpm_map_data rpm_map_data[] __initdata = {
600 MSM_RPM_MAP(TRIGGER_TIMED_TO, TRIGGER_TIMED, 1),
601 MSM_RPM_MAP(TRIGGER_TIMED_SCLK_COUNT, TRIGGER_TIMED, 1),
602
603 MSM_RPM_MAP(RPM_CTL, RPM_CTL, 1),
604
605 MSM_RPM_MAP(CXO_CLK, CXO_CLK, 1),
606 MSM_RPM_MAP(SYSTEM_FABRIC_CLK, SYSTEM_FABRIC_CLK, 1),
607 MSM_RPM_MAP(DAYTONA_FABRIC_CLK, DAYTONA_FABRIC_CLK, 1),
608 MSM_RPM_MAP(SFPB_CLK, SFPB_CLK, 1),
609 MSM_RPM_MAP(CFPB_CLK, CFPB_CLK, 1),
610 MSM_RPM_MAP(EBI1_CLK, EBI1_CLK, 1),
611
612 MSM_RPM_MAP(SYS_FABRIC_CFG_HALT_0, SYS_FABRIC_CFG_HALT, 2),
613 MSM_RPM_MAP(SYS_FABRIC_CFG_CLKMOD_0, SYS_FABRIC_CFG_CLKMOD, 3),
614 MSM_RPM_MAP(SYS_FABRIC_CFG_IOCTL, SYS_FABRIC_CFG_IOCTL, 1),
615 MSM_RPM_MAP(SYSTEM_FABRIC_ARB_0, SYSTEM_FABRIC_ARB, 27),
616
617 MSM_RPM_MAP(PM8018_S1_0, PM8018_S1, 2),
618 MSM_RPM_MAP(PM8018_S2_0, PM8018_S2, 2),
619 MSM_RPM_MAP(PM8018_S3_0, PM8018_S3, 2),
620 MSM_RPM_MAP(PM8018_S4_0, PM8018_S4, 2),
621 MSM_RPM_MAP(PM8018_S5_0, PM8018_S5, 2),
622 MSM_RPM_MAP(PM8018_L1_0, PM8018_L1, 2),
623 MSM_RPM_MAP(PM8018_L2_0, PM8018_L2, 2),
624 MSM_RPM_MAP(PM8018_L3_0, PM8018_L3, 2),
625 MSM_RPM_MAP(PM8018_L4_0, PM8018_L4, 2),
626 MSM_RPM_MAP(PM8018_L5_0, PM8018_L5, 2),
627 MSM_RPM_MAP(PM8018_L6_0, PM8018_L6, 2),
628 MSM_RPM_MAP(PM8018_L7_0, PM8018_L7, 2),
629 MSM_RPM_MAP(PM8018_L8_0, PM8018_L8, 2),
630 MSM_RPM_MAP(PM8018_L9_0, PM8018_L9, 2),
631 MSM_RPM_MAP(PM8018_L10_0, PM8018_L10, 2),
632 MSM_RPM_MAP(PM8018_L11_0, PM8018_L11, 2),
633 MSM_RPM_MAP(PM8018_L12_0, PM8018_L12, 2),
634 MSM_RPM_MAP(PM8018_L13_0, PM8018_L13, 2),
635 MSM_RPM_MAP(PM8018_L14_0, PM8018_L14, 2),
636 MSM_RPM_MAP(PM8018_LVS1, PM8018_LVS1, 1),
637 MSM_RPM_MAP(NCP_0, NCP, 2),
638 MSM_RPM_MAP(CXO_BUFFERS, CXO_BUFFERS, 1),
639 MSM_RPM_MAP(USB_OTG_SWITCH, USB_OTG_SWITCH, 1),
640 MSM_RPM_MAP(HDMI_SWITCH, HDMI_SWITCH, 1),
641};
642unsigned int rpm_map_data_size = ARRAY_SIZE(rpm_map_data);
643
644static struct msm_rpm_platform_data msm_rpm_data = {
645 .reg_base_addrs = {
646 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
647 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
648 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
649 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
650 },
651
652 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
653 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
654 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
655 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
656 .msm_apps_ipc_rpm_val = 4,
657};
658
659struct platform_device msm_rpm_device = {
660 .name = "msm_rpm",
661 .id = -1,
662};
663
664static uint16_t msm_mpm_irqs_m2a[MSM_MPM_NR_MPM_IRQS] = {
665 [1] = MSM_GPIO_TO_INT(46),
666 [2] = MSM_GPIO_TO_INT(150),
667 [4] = MSM_GPIO_TO_INT(103),
668 [5] = MSM_GPIO_TO_INT(104),
669 [6] = MSM_GPIO_TO_INT(105),
670 [7] = MSM_GPIO_TO_INT(106),
671 [8] = MSM_GPIO_TO_INT(107),
672 [9] = MSM_GPIO_TO_INT(7),
673 [10] = MSM_GPIO_TO_INT(11),
674 [11] = MSM_GPIO_TO_INT(15),
675 [12] = MSM_GPIO_TO_INT(19),
676 [13] = MSM_GPIO_TO_INT(23),
677 [14] = MSM_GPIO_TO_INT(27),
678 [15] = MSM_GPIO_TO_INT(31),
679 [16] = MSM_GPIO_TO_INT(35),
680 [19] = MSM_GPIO_TO_INT(90),
681 [20] = MSM_GPIO_TO_INT(92),
682 [23] = MSM_GPIO_TO_INT(85),
683 [24] = MSM_GPIO_TO_INT(83),
684 [25] = USB1_HS_IRQ,
685 /*[27] = HDMI_IRQ,*/
686 [29] = MSM_GPIO_TO_INT(10),
687 [30] = MSM_GPIO_TO_INT(102),
688 [31] = MSM_GPIO_TO_INT(81),
689 [32] = MSM_GPIO_TO_INT(78),
690 [33] = MSM_GPIO_TO_INT(94),
691 [34] = MSM_GPIO_TO_INT(72),
692 [35] = MSM_GPIO_TO_INT(39),
693 [36] = MSM_GPIO_TO_INT(43),
694 [37] = MSM_GPIO_TO_INT(61),
695 [38] = MSM_GPIO_TO_INT(50),
696 [39] = MSM_GPIO_TO_INT(42),
697 [41] = MSM_GPIO_TO_INT(62),
698 [42] = MSM_GPIO_TO_INT(76),
699 [43] = MSM_GPIO_TO_INT(75),
700 [44] = MSM_GPIO_TO_INT(70),
701 [45] = MSM_GPIO_TO_INT(69),
702 [46] = MSM_GPIO_TO_INT(67),
703 [47] = MSM_GPIO_TO_INT(65),
704 [48] = MSM_GPIO_TO_INT(58),
705 [49] = MSM_GPIO_TO_INT(54),
706 [50] = MSM_GPIO_TO_INT(52),
707 [51] = MSM_GPIO_TO_INT(49),
708 [52] = MSM_GPIO_TO_INT(40),
709 [53] = MSM_GPIO_TO_INT(37),
710 [54] = MSM_GPIO_TO_INT(24),
711 [55] = MSM_GPIO_TO_INT(14),
712};
713
714static uint16_t msm_mpm_bypassed_apps_irqs[] = {
715 TLMM_MSM_SUMMARY_IRQ,
716 RPM_APCC_CPU0_GP_HIGH_IRQ,
717 RPM_APCC_CPU0_GP_MEDIUM_IRQ,
718 RPM_APCC_CPU0_GP_LOW_IRQ,
719 RPM_APCC_CPU0_WAKE_UP_IRQ,
720 LPASS_SCSS_GP_LOW_IRQ,
721 LPASS_SCSS_GP_MEDIUM_IRQ,
722 LPASS_SCSS_GP_HIGH_IRQ,
723 SPS_MTI_31,
724};
725
726struct msm_mpm_device_data msm_mpm_dev_data = {
727 .irqs_m2a = msm_mpm_irqs_m2a,
728 .irqs_m2a_size = ARRAY_SIZE(msm_mpm_irqs_m2a),
729 .bypassed_apps_irqs = msm_mpm_bypassed_apps_irqs,
730 .bypassed_apps_irqs_size = ARRAY_SIZE(msm_mpm_bypassed_apps_irqs),
731 .mpm_request_reg_base = MSM_RPM_BASE + 0x9d8,
732 .mpm_status_reg_base = MSM_RPM_BASE + 0xdf8,
733 .mpm_apps_ipc_reg = MSM_APCS_GCC_BASE + 0x008,
734 .mpm_apps_ipc_val = BIT(1),
735 .mpm_ipc_irq = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600736};
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600737
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600738static uint8_t spm_wfi_cmd_sequence[] __initdata = {
Maheshkumar Sivasubramanian343c9912011-10-17 11:00:33 -0600739 0x00, 0x03, 0x00, 0x0f,
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600740};
741
742static uint8_t spm_power_collapse_without_rpm[] __initdata = {
Maheshkumar Sivasubramanian343c9912011-10-17 11:00:33 -0600743 0x34, 0x24, 0x14, 0x04,
744 0x54, 0x03, 0x54, 0x04,
745 0x14, 0x24, 0x3e, 0x0f,
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600746};
747
748static uint8_t spm_power_collapse_with_rpm[] __initdata = {
Maheshkumar Sivasubramanian343c9912011-10-17 11:00:33 -0600749 0x34, 0x24, 0x14, 0x04,
750 0x54, 0x07, 0x54, 0x04,
751 0x14, 0x24, 0x3e, 0x0f,
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600752};
753
754static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
755 [0] = {
756 .mode = MSM_SPM_MODE_CLOCK_GATING,
757 .notify_rpm = false,
758 .cmd = spm_wfi_cmd_sequence,
759 },
760 [1] = {
761 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
762 .notify_rpm = false,
763 .cmd = spm_power_collapse_without_rpm,
764 },
765 [2] = {
766 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
767 .notify_rpm = true,
768 .cmd = spm_power_collapse_with_rpm,
769 },
770};
771
772static struct msm_spm_platform_data msm_spm_data[] __initdata = {
773 [0] = {
774 .reg_base_addr = MSM_SAW0_BASE,
775 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Maheshkumar Sivasubramanian343c9912011-10-17 11:00:33 -0600776 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1001,
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600777 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
778 .modes = msm_spm_seq_list,
779 },
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600780};
781
782static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
783 {
784 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
785 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
786 true,
787 1, 8000, 100000, 1,
788 },
789
790 {
791 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
792 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
793 true,
794 1500, 5000, 60100000, 3000,
795 },
796 {
797 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
798 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
799 false,
800 2800, 5000, 60350000, 3500,
801 },
802};
803
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700804void __init msm9615_device_init(void)
805{
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600806 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600807 BUG_ON(msm_rpm_init(&msm_rpm_data));
808 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
809 ARRAY_SIZE(msm_rpmrs_levels)));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700810}
811
Jeff Hugo56b933a2011-09-28 14:42:05 -0600812#define MSM_SHARED_RAM_PHYS 0x40000000
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700813void __init msm9615_map_io(void)
814{
Jeff Hugo56b933a2011-09-28 14:42:05 -0600815 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700816 msm_map_msm9615_io();
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700817 l2x0_cache_init();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700818 if (socinfo_init() < 0)
819 pr_err("socinfo_init() failed!\n");
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700820}
821
822void __init msm9615_init_irq(void)
823{
824 unsigned int i;
Rohit Vaswanib2e42e12011-10-07 21:25:53 -0700825
826 msm_mpm_irq_extn_init();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700827 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
828 (void *)MSM_QGIC_CPU_BASE);
829
830 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
831 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
832
833 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
834 mb();
835
836 /*
837 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
838 * as they are configured as level, which does not play nice with
839 * handle_percpu_irq.
840 */
841 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
842 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
843 irq_set_handler(i, handle_percpu_irq);
844 }
845}