blob: f65750bd119e7aac5fe49146d2dc42e3dfe0e3a8 [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"
Matt Wagantall44f672e2011-09-07 20:31:16 -070033#include "acpuclock.h"
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -060034#include "mpm.h"
35#include "spm.h"
36#include "pm.h"
37#include "rpm_resources.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 Ohlsteind19bf442011-09-09 12:48:18 -070060static struct resource msm_dmov_resource[] = {
61 {
62 .start = ADM_0_SCSS_1_IRQ,
63 .end = (resource_size_t)MSM_DMOV_BASE,
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
68struct platform_device msm9615_device_dmov = {
69 .name = "msm_dmov",
70 .id = -1,
71 .resource = msm_dmov_resource,
72 .num_resources = ARRAY_SIZE(msm_dmov_resource),
73};
74
Amit Blay5e4ec192011-10-20 09:16:54 +020075static struct resource resources_otg[] = {
76 {
77 .start = MSM9615_HSUSB_PHYS,
78 .end = MSM9615_HSUSB_PHYS + MSM9615_HSUSB_SIZE - 1,
79 .flags = IORESOURCE_MEM,
80 },
81 {
82 .start = USB1_HS_IRQ,
83 .end = USB1_HS_IRQ,
84 .flags = IORESOURCE_IRQ,
85 },
86};
87
88struct platform_device msm_device_otg = {
89 .name = "msm_otg",
90 .id = -1,
91 .num_resources = ARRAY_SIZE(resources_otg),
92 .resource = resources_otg,
93 .dev = {
94 .coherent_dma_mask = DMA_BIT_MASK(32),
95 },
96};
97
98static struct resource resources_hsusb[] = {
99 {
100 .start = MSM9615_HSUSB_PHYS,
101 .end = MSM9615_HSUSB_PHYS + MSM9615_HSUSB_SIZE - 1,
102 .flags = IORESOURCE_MEM,
103 },
104 {
105 .start = USB1_HS_IRQ,
106 .end = USB1_HS_IRQ,
107 .flags = IORESOURCE_IRQ,
108 },
109};
110
111struct platform_device msm_device_gadget_peripheral = {
112 .name = "msm_hsusb",
113 .id = -1,
114 .num_resources = ARRAY_SIZE(resources_hsusb),
115 .resource = resources_hsusb,
116 .dev = {
117 .coherent_dma_mask = DMA_BIT_MASK(32),
118 },
119};
120
Rohit Vaswani09666872011-08-23 17:41:54 -0700121static struct resource resources_uart_gsbi4[] = {
122 {
123 .start = GSBI4_UARTDM_IRQ,
124 .end = GSBI4_UARTDM_IRQ,
125 .flags = IORESOURCE_IRQ,
126 },
127 {
128 .start = MSM_UART4DM_PHYS,
129 .end = MSM_UART4DM_PHYS + PAGE_SIZE - 1,
130 .name = "uartdm_resource",
131 .flags = IORESOURCE_MEM,
132 },
133 {
134 .start = MSM_GSBI4_PHYS,
135 .end = MSM_GSBI4_PHYS + PAGE_SIZE - 1,
136 .name = "gsbi_resource",
137 .flags = IORESOURCE_MEM,
138 },
139};
140
141struct platform_device msm9615_device_uart_gsbi4 = {
142 .name = "msm_serial_hsl",
143 .id = 0,
144 .num_resources = ARRAY_SIZE(resources_uart_gsbi4),
145 .resource = resources_uart_gsbi4,
146};
147
Harini Jayaramaneba52672011-09-08 15:13:00 -0600148static struct resource resources_qup_i2c_gsbi5[] = {
149 {
150 .name = "gsbi_qup_i2c_addr",
151 .start = MSM_GSBI5_PHYS,
Harini Jayaraman7a60bc12011-09-15 14:58:54 -0600152 .end = MSM_GSBI5_PHYS + 4 - 1,
Harini Jayaramaneba52672011-09-08 15:13:00 -0600153 .flags = IORESOURCE_MEM,
154 },
155 {
156 .name = "qup_phys_addr",
157 .start = MSM_GSBI5_QUP_PHYS,
Harini Jayaraman7a60bc12011-09-15 14:58:54 -0600158 .end = MSM_GSBI5_QUP_PHYS + MSM_QUP_SIZE - 1,
Harini Jayaramaneba52672011-09-08 15:13:00 -0600159 .flags = IORESOURCE_MEM,
160 },
161 {
162 .name = "qup_err_intr",
163 .start = GSBI5_QUP_IRQ,
164 .end = GSBI5_QUP_IRQ,
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
169struct platform_device msm9615_device_qup_i2c_gsbi5 = {
170 .name = "qup_i2c",
171 .id = 0,
172 .num_resources = ARRAY_SIZE(resources_qup_i2c_gsbi5),
173 .resource = resources_qup_i2c_gsbi5,
174};
175
Harini Jayaraman738c9312011-09-08 15:22:38 -0600176static struct resource resources_qup_spi_gsbi3[] = {
177 {
178 .name = "spi_base",
179 .start = MSM_GSBI3_QUP_PHYS,
180 .end = MSM_GSBI3_QUP_PHYS + SZ_4K - 1,
181 .flags = IORESOURCE_MEM,
182 },
183 {
184 .name = "gsbi_base",
185 .start = MSM_GSBI3_PHYS,
186 .end = MSM_GSBI3_PHYS + 4 - 1,
187 .flags = IORESOURCE_MEM,
188 },
189 {
190 .name = "spi_irq_in",
191 .start = GSBI3_QUP_IRQ,
192 .end = GSBI3_QUP_IRQ,
193 .flags = IORESOURCE_IRQ,
194 },
195};
196
197struct platform_device msm9615_device_qup_spi_gsbi3 = {
198 .name = "spi_qsd",
199 .id = 0,
200 .num_resources = ARRAY_SIZE(resources_qup_spi_gsbi3),
201 .resource = resources_qup_spi_gsbi3,
202};
203
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700204static struct resource resources_ssbi_pmic1[] = {
205 {
206 .start = MSM_PMIC1_SSBI_CMD_PHYS,
207 .end = MSM_PMIC1_SSBI_CMD_PHYS + MSM_PMIC_SSBI_SIZE - 1,
208 .flags = IORESOURCE_MEM,
209 },
210};
211
212struct platform_device msm9615_device_ssbi_pmic1 = {
213 .name = "msm_ssbi",
214 .id = 0,
215 .resource = resources_ssbi_pmic1,
216 .num_resources = ARRAY_SIZE(resources_ssbi_pmic1),
217};
218
Yan He092b7272011-09-21 15:25:03 -0700219static struct resource resources_sps[] = {
220 {
221 .name = "pipe_mem",
222 .start = 0x12800000,
223 .end = 0x12800000 + 0x4000 - 1,
224 .flags = IORESOURCE_MEM,
225 },
226 {
227 .name = "bamdma_dma",
228 .start = 0x12240000,
229 .end = 0x12240000 + 0x1000 - 1,
230 .flags = IORESOURCE_MEM,
231 },
232 {
233 .name = "bamdma_bam",
234 .start = 0x12244000,
235 .end = 0x12244000 + 0x4000 - 1,
236 .flags = IORESOURCE_MEM,
237 },
238 {
239 .name = "bamdma_irq",
240 .start = SPS_BAM_DMA_IRQ,
241 .end = SPS_BAM_DMA_IRQ,
242 .flags = IORESOURCE_IRQ,
243 },
244};
245
246struct msm_sps_platform_data msm_sps_pdata = {
247 .bamdma_restricted_pipes = 0x06,
248};
249
250struct platform_device msm_device_sps = {
251 .name = "msm_sps",
252 .id = -1,
253 .num_resources = ARRAY_SIZE(resources_sps),
254 .resource = resources_sps,
255 .dev.platform_data = &msm_sps_pdata,
256};
257
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700258static struct tsens_platform_data msm_tsens_pdata = {
259 .slope = 910,
260 .tsens_factor = 1000,
261 .hw_type = MSM_9615,
262 .tsens_num_sensor = 5,
263};
264
Sahitya Tummala38295432011-09-29 10:08:45 +0530265struct platform_device msm9615_device_tsens = {
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700266 .name = "tsens8960-tm",
267 .id = -1,
Sahitya Tummala38295432011-09-29 10:08:45 +0530268 .dev = {
269 .platform_data = &msm_tsens_pdata,
270 },
271};
272
273#define MSM_NAND_PHYS 0x1B400000
274static struct resource resources_nand[] = {
275 [0] = {
276 .name = "msm_nand_dmac",
277 .start = DMOV_NAND_CHAN,
278 .end = DMOV_NAND_CHAN,
279 .flags = IORESOURCE_DMA,
280 },
281 [1] = {
282 .name = "msm_nand_phys",
283 .start = MSM_NAND_PHYS,
284 .end = MSM_NAND_PHYS + 0x7FF,
285 .flags = IORESOURCE_MEM,
286 },
287};
288
289struct flash_platform_data msm_nand_data = {
290 .parts = NULL,
291 .nr_parts = 0,
292};
293
294struct platform_device msm_device_nand = {
295 .name = "msm_nand",
296 .id = -1,
297 .num_resources = ARRAY_SIZE(resources_nand),
298 .resource = resources_nand,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700299 .dev = {
Sahitya Tummala38295432011-09-29 10:08:45 +0530300 .platform_data = &msm_nand_data,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700301 },
302};
303
Jeff Hugo56b933a2011-09-28 14:42:05 -0600304struct platform_device msm_device_smd = {
305 .name = "msm_smd",
306 .id = -1,
307};
308
Ramesh Masavarapu5ad37392011-10-10 10:44:10 -0700309#ifdef CONFIG_HW_RANDOM_MSM
310/* PRNG device */
311#define MSM_PRNG_PHYS 0x1A500000
312static struct resource rng_resources = {
313 .flags = IORESOURCE_MEM,
314 .start = MSM_PRNG_PHYS,
315 .end = MSM_PRNG_PHYS + SZ_512 - 1,
316};
317
318struct platform_device msm_device_rng = {
319 .name = "msm_rng",
320 .id = 0,
321 .num_resources = 1,
322 .resource = &rng_resources,
323};
324#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700325
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700326#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
327 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
328 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
329 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
330
331#define QCE_SIZE 0x10000
332#define QCE_0_BASE 0x18500000
333
334#define QCE_HW_KEY_SUPPORT 0
335#define QCE_SHA_HMAC_SUPPORT 1
336#define QCE_SHARE_CE_RESOURCE 1
337#define QCE_CE_SHARED 0
338
339static struct resource qcrypto_resources[] = {
340 [0] = {
341 .start = QCE_0_BASE,
342 .end = QCE_0_BASE + QCE_SIZE - 1,
343 .flags = IORESOURCE_MEM,
344 },
345 [1] = {
346 .name = "crypto_channels",
347 .start = DMOV_CE_IN_CHAN,
348 .end = DMOV_CE_OUT_CHAN,
349 .flags = IORESOURCE_DMA,
350 },
351 [2] = {
352 .name = "crypto_crci_in",
353 .start = DMOV_CE_IN_CRCI,
354 .end = DMOV_CE_IN_CRCI,
355 .flags = IORESOURCE_DMA,
356 },
357 [3] = {
358 .name = "crypto_crci_out",
359 .start = DMOV_CE_OUT_CRCI,
360 .end = DMOV_CE_OUT_CRCI,
361 .flags = IORESOURCE_DMA,
362 },
363};
364
365static struct resource qcedev_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
391#endif
392
393#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
394 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
395
396static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
397 .ce_shared = QCE_CE_SHARED,
398 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
399 .hw_key_support = QCE_HW_KEY_SUPPORT,
400 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
401};
402
403struct platform_device msm9615_qcrypto_device = {
404 .name = "qcrypto",
405 .id = 0,
406 .num_resources = ARRAY_SIZE(qcrypto_resources),
407 .resource = qcrypto_resources,
408 .dev = {
409 .coherent_dma_mask = DMA_BIT_MASK(32),
410 .platform_data = &qcrypto_ce_hw_suppport,
411 },
412};
413#endif
414
415#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
416 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
417
418static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
419 .ce_shared = QCE_CE_SHARED,
420 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
421 .hw_key_support = QCE_HW_KEY_SUPPORT,
422 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
423};
424
425struct platform_device msm9615_qcedev_device = {
426 .name = "qce",
427 .id = 0,
428 .num_resources = ARRAY_SIZE(qcedev_resources),
429 .resource = qcedev_resources,
430 .dev = {
431 .coherent_dma_mask = DMA_BIT_MASK(32),
432 .platform_data = &qcedev_ce_hw_suppport,
433 },
434};
435#endif
436
Krishna Kondadd794462011-10-01 00:19:29 -0700437#define MSM_SDC1_BASE 0x12180000
438#define MSM_SDC1_DML_BASE (MSM_SDC1_BASE + 0x800)
439#define MSM_SDC1_BAM_BASE (MSM_SDC1_BASE + 0x2000)
Krishna Konda71aef182011-10-01 02:27:51 -0700440#define MSM_SDC2_BASE 0x12140000
441#define MSM_SDC2_DML_BASE (MSM_SDC2_BASE + 0x800)
442#define MSM_SDC2_BAM_BASE (MSM_SDC2_BASE + 0x2000)
Krishna Kondadd794462011-10-01 00:19:29 -0700443
444static struct resource resources_sdc1[] = {
445 {
446 .name = "core_mem",
447 .flags = IORESOURCE_MEM,
448 .start = MSM_SDC1_BASE,
449 .end = MSM_SDC1_DML_BASE - 1,
450 },
451 {
452 .name = "core_irq",
453 .flags = IORESOURCE_IRQ,
454 .start = SDC1_IRQ_0,
455 .end = SDC1_IRQ_0
456 },
457#ifdef CONFIG_MMC_MSM_SPS_SUPPORT
458 {
459 .name = "sdcc_dml_addr",
460 .start = MSM_SDC1_DML_BASE,
461 .end = MSM_SDC1_BAM_BASE - 1,
462 .flags = IORESOURCE_MEM,
463 },
464 {
465 .name = "sdcc_bam_addr",
466 .start = MSM_SDC1_BAM_BASE,
467 .end = MSM_SDC1_BAM_BASE + (2 * SZ_4K) - 1,
468 .flags = IORESOURCE_MEM,
469 },
470 {
471 .name = "sdcc_bam_irq",
472 .start = SDC1_BAM_IRQ,
473 .end = SDC1_BAM_IRQ,
474 .flags = IORESOURCE_IRQ,
475 },
476#endif
477};
478
Krishna Konda71aef182011-10-01 02:27:51 -0700479static struct resource resources_sdc2[] = {
480 {
481 .name = "core_mem",
482 .flags = IORESOURCE_MEM,
483 .start = MSM_SDC2_BASE,
484 .end = MSM_SDC2_DML_BASE - 1,
485 },
486 {
487 .name = "core_irq",
488 .flags = IORESOURCE_IRQ,
489 .start = SDC2_IRQ_0,
490 .end = SDC2_IRQ_0
491 },
492#ifdef CONFIG_MMC_MSM_SPS_SUPPORT
493 {
494 .name = "sdcc_dml_addr",
495 .start = MSM_SDC2_DML_BASE,
496 .end = MSM_SDC2_BAM_BASE - 1,
497 .flags = IORESOURCE_MEM,
498 },
499 {
500 .name = "sdcc_bam_addr",
501 .start = MSM_SDC2_BAM_BASE,
502 .end = MSM_SDC2_BAM_BASE + (2 * SZ_4K) - 1,
503 .flags = IORESOURCE_MEM,
504 },
505 {
506 .name = "sdcc_bam_irq",
507 .start = SDC2_BAM_IRQ,
508 .end = SDC2_BAM_IRQ,
509 .flags = IORESOURCE_IRQ,
510 },
511#endif
512};
513
Krishna Kondadd794462011-10-01 00:19:29 -0700514struct platform_device msm_device_sdc1 = {
515 .name = "msm_sdcc",
516 .id = 1,
517 .num_resources = ARRAY_SIZE(resources_sdc1),
518 .resource = resources_sdc1,
519 .dev = {
520 .coherent_dma_mask = 0xffffffff,
521 },
522};
523
Krishna Konda71aef182011-10-01 02:27:51 -0700524struct platform_device msm_device_sdc2 = {
525 .name = "msm_sdcc",
526 .id = 2,
527 .num_resources = ARRAY_SIZE(resources_sdc2),
528 .resource = resources_sdc2,
529 .dev = {
530 .coherent_dma_mask = 0xffffffff,
531 },
532};
533
Krishna Kondadd794462011-10-01 00:19:29 -0700534static struct platform_device *msm_sdcc_devices[] __initdata = {
535 &msm_device_sdc1,
Krishna Konda71aef182011-10-01 02:27:51 -0700536 &msm_device_sdc2,
Krishna Kondadd794462011-10-01 00:19:29 -0700537};
538
539int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat)
540{
541 struct platform_device *pdev;
542
543 if (controller < 1 || controller > 2)
544 return -EINVAL;
545
546 pdev = msm_sdcc_devices[controller - 1];
547 pdev->dev.platform_data = plat;
548 return platform_device_register(pdev);
549}
550
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700551#ifdef CONFIG_CACHE_L2X0
552static int __init l2x0_cache_init(void)
553{
554 int aux_ctrl = 0;
555
556 /* Way Size 010(0x2) 32KB */
557 aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \
558 (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \
559 (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT);
560
561 /* L2 Latency setting required by hardware. Default is 0x20
562 which is no good.
563 */
564 writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL);
565 l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK);
566
567 return 0;
568}
569#else
570static int __init l2x0_cache_init(void){ return 0; }
571#endif
572
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600573struct msm_rpm_map_data rpm_map_data[] __initdata = {
574 MSM_RPM_MAP(TRIGGER_TIMED_TO, TRIGGER_TIMED, 1),
575 MSM_RPM_MAP(TRIGGER_TIMED_SCLK_COUNT, TRIGGER_TIMED, 1),
576
577 MSM_RPM_MAP(RPM_CTL, RPM_CTL, 1),
578
579 MSM_RPM_MAP(CXO_CLK, CXO_CLK, 1),
580 MSM_RPM_MAP(SYSTEM_FABRIC_CLK, SYSTEM_FABRIC_CLK, 1),
581 MSM_RPM_MAP(DAYTONA_FABRIC_CLK, DAYTONA_FABRIC_CLK, 1),
582 MSM_RPM_MAP(SFPB_CLK, SFPB_CLK, 1),
583 MSM_RPM_MAP(CFPB_CLK, CFPB_CLK, 1),
584 MSM_RPM_MAP(EBI1_CLK, EBI1_CLK, 1),
585
586 MSM_RPM_MAP(SYS_FABRIC_CFG_HALT_0, SYS_FABRIC_CFG_HALT, 2),
587 MSM_RPM_MAP(SYS_FABRIC_CFG_CLKMOD_0, SYS_FABRIC_CFG_CLKMOD, 3),
588 MSM_RPM_MAP(SYS_FABRIC_CFG_IOCTL, SYS_FABRIC_CFG_IOCTL, 1),
589 MSM_RPM_MAP(SYSTEM_FABRIC_ARB_0, SYSTEM_FABRIC_ARB, 27),
590
591 MSM_RPM_MAP(PM8018_S1_0, PM8018_S1, 2),
592 MSM_RPM_MAP(PM8018_S2_0, PM8018_S2, 2),
593 MSM_RPM_MAP(PM8018_S3_0, PM8018_S3, 2),
594 MSM_RPM_MAP(PM8018_S4_0, PM8018_S4, 2),
595 MSM_RPM_MAP(PM8018_S5_0, PM8018_S5, 2),
596 MSM_RPM_MAP(PM8018_L1_0, PM8018_L1, 2),
597 MSM_RPM_MAP(PM8018_L2_0, PM8018_L2, 2),
598 MSM_RPM_MAP(PM8018_L3_0, PM8018_L3, 2),
599 MSM_RPM_MAP(PM8018_L4_0, PM8018_L4, 2),
600 MSM_RPM_MAP(PM8018_L5_0, PM8018_L5, 2),
601 MSM_RPM_MAP(PM8018_L6_0, PM8018_L6, 2),
602 MSM_RPM_MAP(PM8018_L7_0, PM8018_L7, 2),
603 MSM_RPM_MAP(PM8018_L8_0, PM8018_L8, 2),
604 MSM_RPM_MAP(PM8018_L9_0, PM8018_L9, 2),
605 MSM_RPM_MAP(PM8018_L10_0, PM8018_L10, 2),
606 MSM_RPM_MAP(PM8018_L11_0, PM8018_L11, 2),
607 MSM_RPM_MAP(PM8018_L12_0, PM8018_L12, 2),
608 MSM_RPM_MAP(PM8018_L13_0, PM8018_L13, 2),
609 MSM_RPM_MAP(PM8018_L14_0, PM8018_L14, 2),
610 MSM_RPM_MAP(PM8018_LVS1, PM8018_LVS1, 1),
611 MSM_RPM_MAP(NCP_0, NCP, 2),
612 MSM_RPM_MAP(CXO_BUFFERS, CXO_BUFFERS, 1),
613 MSM_RPM_MAP(USB_OTG_SWITCH, USB_OTG_SWITCH, 1),
614 MSM_RPM_MAP(HDMI_SWITCH, HDMI_SWITCH, 1),
615};
616unsigned int rpm_map_data_size = ARRAY_SIZE(rpm_map_data);
617
618static struct msm_rpm_platform_data msm_rpm_data = {
619 .reg_base_addrs = {
620 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
621 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
622 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
623 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
624 },
625
626 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
627 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
628 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
629 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
630 .msm_apps_ipc_rpm_val = 4,
631};
632
633struct platform_device msm_rpm_device = {
634 .name = "msm_rpm",
635 .id = -1,
636};
637
638static uint16_t msm_mpm_irqs_m2a[MSM_MPM_NR_MPM_IRQS] = {
639 [1] = MSM_GPIO_TO_INT(46),
640 [2] = MSM_GPIO_TO_INT(150),
641 [4] = MSM_GPIO_TO_INT(103),
642 [5] = MSM_GPIO_TO_INT(104),
643 [6] = MSM_GPIO_TO_INT(105),
644 [7] = MSM_GPIO_TO_INT(106),
645 [8] = MSM_GPIO_TO_INT(107),
646 [9] = MSM_GPIO_TO_INT(7),
647 [10] = MSM_GPIO_TO_INT(11),
648 [11] = MSM_GPIO_TO_INT(15),
649 [12] = MSM_GPIO_TO_INT(19),
650 [13] = MSM_GPIO_TO_INT(23),
651 [14] = MSM_GPIO_TO_INT(27),
652 [15] = MSM_GPIO_TO_INT(31),
653 [16] = MSM_GPIO_TO_INT(35),
654 [19] = MSM_GPIO_TO_INT(90),
655 [20] = MSM_GPIO_TO_INT(92),
656 [23] = MSM_GPIO_TO_INT(85),
657 [24] = MSM_GPIO_TO_INT(83),
658 [25] = USB1_HS_IRQ,
659 /*[27] = HDMI_IRQ,*/
660 [29] = MSM_GPIO_TO_INT(10),
661 [30] = MSM_GPIO_TO_INT(102),
662 [31] = MSM_GPIO_TO_INT(81),
663 [32] = MSM_GPIO_TO_INT(78),
664 [33] = MSM_GPIO_TO_INT(94),
665 [34] = MSM_GPIO_TO_INT(72),
666 [35] = MSM_GPIO_TO_INT(39),
667 [36] = MSM_GPIO_TO_INT(43),
668 [37] = MSM_GPIO_TO_INT(61),
669 [38] = MSM_GPIO_TO_INT(50),
670 [39] = MSM_GPIO_TO_INT(42),
671 [41] = MSM_GPIO_TO_INT(62),
672 [42] = MSM_GPIO_TO_INT(76),
673 [43] = MSM_GPIO_TO_INT(75),
674 [44] = MSM_GPIO_TO_INT(70),
675 [45] = MSM_GPIO_TO_INT(69),
676 [46] = MSM_GPIO_TO_INT(67),
677 [47] = MSM_GPIO_TO_INT(65),
678 [48] = MSM_GPIO_TO_INT(58),
679 [49] = MSM_GPIO_TO_INT(54),
680 [50] = MSM_GPIO_TO_INT(52),
681 [51] = MSM_GPIO_TO_INT(49),
682 [52] = MSM_GPIO_TO_INT(40),
683 [53] = MSM_GPIO_TO_INT(37),
684 [54] = MSM_GPIO_TO_INT(24),
685 [55] = MSM_GPIO_TO_INT(14),
686};
687
688static uint16_t msm_mpm_bypassed_apps_irqs[] = {
689 TLMM_MSM_SUMMARY_IRQ,
690 RPM_APCC_CPU0_GP_HIGH_IRQ,
691 RPM_APCC_CPU0_GP_MEDIUM_IRQ,
692 RPM_APCC_CPU0_GP_LOW_IRQ,
693 RPM_APCC_CPU0_WAKE_UP_IRQ,
694 LPASS_SCSS_GP_LOW_IRQ,
695 LPASS_SCSS_GP_MEDIUM_IRQ,
696 LPASS_SCSS_GP_HIGH_IRQ,
697 SPS_MTI_31,
698};
699
700struct msm_mpm_device_data msm_mpm_dev_data = {
701 .irqs_m2a = msm_mpm_irqs_m2a,
702 .irqs_m2a_size = ARRAY_SIZE(msm_mpm_irqs_m2a),
703 .bypassed_apps_irqs = msm_mpm_bypassed_apps_irqs,
704 .bypassed_apps_irqs_size = ARRAY_SIZE(msm_mpm_bypassed_apps_irqs),
705 .mpm_request_reg_base = MSM_RPM_BASE + 0x9d8,
706 .mpm_status_reg_base = MSM_RPM_BASE + 0xdf8,
707 .mpm_apps_ipc_reg = MSM_APCS_GCC_BASE + 0x008,
708 .mpm_apps_ipc_val = BIT(1),
709 .mpm_ipc_irq = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600710};
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600711
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600712static uint8_t spm_wfi_cmd_sequence[] __initdata = {
713 0x00, 0x03, 0x0B, 0x00,
714 0x0f,
715};
716
717static uint8_t spm_power_collapse_without_rpm[] __initdata = {
718 0x30, 0x20, 0x10, 0x00,
719 0x50, 0x03, 0x50, 0x00,
720 0x10, 0x20, 0x30, 0x0f,
721};
722
723static uint8_t spm_power_collapse_with_rpm[] __initdata = {
724 0x30, 0x20, 0x10, 0x00,
725 0x50, 0x07, 0x50, 0x00,
726 0x10, 0x20, 0x30, 0x0f,
727};
728
729static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
730 [0] = {
731 .mode = MSM_SPM_MODE_CLOCK_GATING,
732 .notify_rpm = false,
733 .cmd = spm_wfi_cmd_sequence,
734 },
735 [1] = {
736 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
737 .notify_rpm = false,
738 .cmd = spm_power_collapse_without_rpm,
739 },
740 [2] = {
741 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
742 .notify_rpm = true,
743 .cmd = spm_power_collapse_with_rpm,
744 },
745};
746
747static struct msm_spm_platform_data msm_spm_data[] __initdata = {
748 [0] = {
749 .reg_base_addr = MSM_SAW0_BASE,
750 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
751 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
752 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
753 .modes = msm_spm_seq_list,
754 },
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600755};
756
757static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
758 {
759 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
760 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
761 true,
762 1, 8000, 100000, 1,
763 },
764
765 {
766 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
767 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
768 true,
769 1500, 5000, 60100000, 3000,
770 },
771 {
772 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
773 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
774 false,
775 2800, 5000, 60350000, 3500,
776 },
777};
778
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700779void __init msm9615_device_init(void)
780{
Maheshkumar Sivasubramanianf07bd0b2011-09-06 17:33:17 -0600781 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
Vikram Mulukutla489e39e2011-08-31 18:04:05 -0700782 msm_clock_init(&msm9615_clock_init_data);
Matt Wagantall44f672e2011-09-07 20:31:16 -0700783 acpuclk_init(&acpuclk_9615_soc_data);
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -0600784 BUG_ON(msm_rpm_init(&msm_rpm_data));
785 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
786 ARRAY_SIZE(msm_rpmrs_levels)));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700787}
788
Jeff Hugo56b933a2011-09-28 14:42:05 -0600789#define MSM_SHARED_RAM_PHYS 0x40000000
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700790void __init msm9615_map_io(void)
791{
Jeff Hugo56b933a2011-09-28 14:42:05 -0600792 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700793 msm_map_msm9615_io();
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700794 l2x0_cache_init();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700795 if (socinfo_init() < 0)
796 pr_err("socinfo_init() failed!\n");
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700797}
798
799void __init msm9615_init_irq(void)
800{
801 unsigned int i;
Rohit Vaswanib2e42e12011-10-07 21:25:53 -0700802
803 msm_mpm_irq_extn_init();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700804 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
805 (void *)MSM_QGIC_CPU_BASE);
806
807 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
808 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
809
810 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
811 mb();
812
813 /*
814 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
815 * as they are configured as level, which does not play nice with
816 * handle_percpu_irq.
817 */
818 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
819 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
820 irq_set_handler(i, handle_percpu_irq);
821 }
822}