blob: dd6da2a2f1a0fa9030de803ebd3485fead7253e0 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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/io.h>
16#include <linux/irq.h>
Kenneth Heitke748593a2011-07-15 15:45:11 -060017#include <linux/i2c.h>
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -060018#include <linux/slimbus/slimbus.h>
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -080019#include <linux/mfd/wcd9310/core.h>
20#include <linux/mfd/wcd9310/pdata.h>
Kenneth Heitke36920d32011-07-20 16:44:30 -060021#include <linux/msm_ssbi.h>
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -070022#include <linux/spi/spi.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070023#include <linux/dma-mapping.h>
24#include <linux/platform_data/qcom_crypto_device.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080025#include <linux/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053029#include <asm/mach/mmc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030
31#include <mach/board.h>
32#include <mach/msm_iomap.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080033#include <mach/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include <linux/usb/msm_hsusb.h>
35#include <linux/usb/android.h>
36#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060037#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038#include "timer.h"
39#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070040#include <mach/gpio.h>
41#include <mach/gpiomux.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080042#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070043#include <linux/android_pmem.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080044#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070045#include <mach/msm_memtypes.h>
46#include <linux/bootmem.h>
47#include <asm/setup.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070048#include <mach/dma.h>
Gagan Mac8a7a5d32011-11-11 16:43:06 -070049#include <mach/msm_bus_board.h>
Joel King4ebccc62011-07-22 09:43:22 -070050
Jeff Ohlstein7e668552011-10-06 16:17:25 -070051#include "msm_watchdog.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080052#include "board-8064.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070053
Olav Haugan7c6aa742012-01-16 16:47:37 -080054#define MSM_PMEM_ADSP_SIZE 0x7800000
Ben Romberger3ffcd812011-12-08 19:12:10 -080055#define MSM_PMEM_AUDIO_SIZE 0x2B4000
Olav Haugan7c6aa742012-01-16 16:47:37 -080056#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
57#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
58#else
59#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
60#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070061
Olav Haugan7c6aa742012-01-16 16:47:37 -080062#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
63#define MSM_PMEM_KERNEL_EBI1_SIZE 0xB0C000
64#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
65#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
66#define MSM_ION_MFC_SIZE SZ_8K
67#define MSM_ION_HEAP_NUM 5
68#else
69#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
70#define MSM_ION_HEAP_NUM 1
71#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070072
Olav Haugan7c6aa742012-01-16 16:47:37 -080073#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
74static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
75static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070076{
Olav Haugan7c6aa742012-01-16 16:47:37 -080077 pmem_kernel_ebi1_size = memparse(p, NULL);
78 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070079}
Olav Haugan7c6aa742012-01-16 16:47:37 -080080early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
81#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070082
Olav Haugan7c6aa742012-01-16 16:47:37 -080083#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070084static unsigned pmem_size = MSM_PMEM_SIZE;
85static int __init pmem_size_setup(char *p)
86{
87 pmem_size = memparse(p, NULL);
88 return 0;
89}
90early_param("pmem_size", pmem_size_setup);
91
92static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
93
94static int __init pmem_adsp_size_setup(char *p)
95{
96 pmem_adsp_size = memparse(p, NULL);
97 return 0;
98}
99early_param("pmem_adsp_size", pmem_adsp_size_setup);
100
101static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
102
103static int __init pmem_audio_size_setup(char *p)
104{
105 pmem_audio_size = memparse(p, NULL);
106 return 0;
107}
108early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800109#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700110
Olav Haugan7c6aa742012-01-16 16:47:37 -0800111#ifdef CONFIG_ANDROID_PMEM
112#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700113static struct android_pmem_platform_data android_pmem_pdata = {
114 .name = "pmem",
115 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
116 .cached = 1,
117 .memory_type = MEMTYPE_EBI1,
118};
119
120static struct platform_device android_pmem_device = {
121 .name = "android_pmem",
122 .id = 0,
123 .dev = {.platform_data = &android_pmem_pdata},
124};
125
126static struct android_pmem_platform_data android_pmem_adsp_pdata = {
127 .name = "pmem_adsp",
128 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
129 .cached = 0,
130 .memory_type = MEMTYPE_EBI1,
131};
Kevin Chan13be4e22011-10-20 11:30:32 -0700132static struct platform_device android_pmem_adsp_device = {
133 .name = "android_pmem",
134 .id = 2,
135 .dev = { .platform_data = &android_pmem_adsp_pdata },
136};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800137#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700138
139static struct android_pmem_platform_data android_pmem_audio_pdata = {
140 .name = "pmem_audio",
141 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
142 .cached = 0,
143 .memory_type = MEMTYPE_EBI1,
144};
145
146static struct platform_device android_pmem_audio_device = {
147 .name = "android_pmem",
148 .id = 4,
149 .dev = { .platform_data = &android_pmem_audio_pdata },
150};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800151#endif
152
153static struct memtype_reserve apq8064_reserve_table[] __initdata = {
154 [MEMTYPE_SMI] = {
155 },
156 [MEMTYPE_EBI0] = {
157 .flags = MEMTYPE_FLAGS_1M_ALIGN,
158 },
159 [MEMTYPE_EBI1] = {
160 .flags = MEMTYPE_FLAGS_1M_ALIGN,
161 },
162};
Kevin Chan13be4e22011-10-20 11:30:32 -0700163
164static void __init size_pmem_devices(void)
165{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800166#ifdef CONFIG_ANDROID_PMEM
167#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700168 android_pmem_adsp_pdata.size = pmem_adsp_size;
169 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800170#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700171 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800172#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700173}
174
175static void __init reserve_memory_for(struct android_pmem_platform_data *p)
176{
177 apq8064_reserve_table[p->memory_type].size += p->size;
178}
179
Kevin Chan13be4e22011-10-20 11:30:32 -0700180static void __init reserve_pmem_memory(void)
181{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800182#ifdef CONFIG_ANDROID_PMEM
183#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700184 reserve_memory_for(&android_pmem_adsp_pdata);
185 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800186#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700187 reserve_memory_for(&android_pmem_audio_pdata);
188 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800189#endif
190}
191
192static int apq8064_paddr_to_memtype(unsigned int paddr)
193{
194 return MEMTYPE_EBI1;
195}
196
197#ifdef CONFIG_ION_MSM
198#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
199static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
200 .permission_type = IPT_TYPE_MM_CARVEOUT,
201};
202
203static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
204 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
205};
206
207static struct ion_co_heap_pdata co_ion_pdata = {
208};
209#endif
210static struct ion_platform_data ion_pdata = {
211 .nr = MSM_ION_HEAP_NUM,
212 .heaps = {
213 {
214 .id = ION_SYSTEM_HEAP_ID,
215 .type = ION_HEAP_TYPE_SYSTEM,
216 .name = ION_VMALLOC_HEAP_NAME,
217 },
218#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
219 {
220 .id = ION_SF_HEAP_ID,
221 .type = ION_HEAP_TYPE_CARVEOUT,
222 .name = ION_SF_HEAP_NAME,
223 .size = MSM_ION_SF_SIZE,
224 .memory_type = ION_EBI_TYPE,
225 .extra_data = (void *) &co_ion_pdata,
226 },
227 {
228 .id = ION_CP_MM_HEAP_ID,
229 .type = ION_HEAP_TYPE_CP,
230 .name = ION_MM_HEAP_NAME,
231 .size = MSM_ION_MM_SIZE,
232 .memory_type = ION_EBI_TYPE,
233 .extra_data = (void *) &cp_mm_ion_pdata,
234 },
235 {
236 .id = ION_CP_MFC_HEAP_ID,
237 .type = ION_HEAP_TYPE_CP,
238 .name = ION_MFC_HEAP_NAME,
239 .size = MSM_ION_MFC_SIZE,
240 .memory_type = ION_EBI_TYPE,
241 .extra_data = (void *) &cp_mfc_ion_pdata,
242 },
243 {
244 .id = ION_IOMMU_HEAP_ID,
245 .type = ION_HEAP_TYPE_IOMMU,
246 .name = ION_IOMMU_HEAP_NAME,
247 },
248#endif
249 }
250};
251
252static struct platform_device ion_dev = {
253 .name = "ion-msm",
254 .id = 1,
255 .dev = { .platform_data = &ion_pdata },
256};
257#endif
258
259static void reserve_ion_memory(void)
260{
261#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
262 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
263 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
264 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
265#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700266}
267
268static void __init apq8064_calculate_reserve_sizes(void)
269{
270 size_pmem_devices();
271 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800272 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700273}
274
275static struct reserve_info apq8064_reserve_info __initdata = {
276 .memtype_reserve_table = apq8064_reserve_table,
277 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
278 .paddr_to_memtype = apq8064_paddr_to_memtype,
279};
280
281static int apq8064_memory_bank_size(void)
282{
283 return 1<<29;
284}
285
286static void __init locate_unstable_memory(void)
287{
288 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
289 unsigned long bank_size;
290 unsigned long low, high;
291
292 bank_size = apq8064_memory_bank_size();
293 low = meminfo.bank[0].start;
294 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800295
296 /* Check if 32 bit overflow occured */
297 if (high < mb->start)
298 high = ~0UL;
299
Kevin Chan13be4e22011-10-20 11:30:32 -0700300 low &= ~(bank_size - 1);
301
302 if (high - low <= bank_size)
303 return;
304 apq8064_reserve_info.low_unstable_address = low + bank_size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800305 /* To avoid overflow of u32 compute max_unstable_size
306 * by first subtracting low from mb->start)
307 */
308 apq8064_reserve_info.max_unstable_size = (mb->start - low) +
309 mb->size - bank_size;
Kevin Chan13be4e22011-10-20 11:30:32 -0700310 apq8064_reserve_info.bank_size = bank_size;
311 pr_info("low unstable address %lx max size %lx bank size %lx\n",
312 apq8064_reserve_info.low_unstable_address,
313 apq8064_reserve_info.max_unstable_size,
314 apq8064_reserve_info.bank_size);
315}
316
317static void __init apq8064_reserve(void)
318{
319 reserve_info = &apq8064_reserve_info;
320 locate_unstable_memory();
321 msm_reserve();
322}
323
Hemant Kumar4933b072011-10-17 23:43:11 -0700324static struct platform_device android_usb_device = {
325 .name = "android_usb",
326 .id = -1,
327};
328
329static struct msm_otg_platform_data msm_otg_pdata = {
330 .mode = USB_PERIPHERAL,
331 .otg_control = OTG_PHY_CONTROL,
332 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700333};
334
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800335#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
336
337/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
338 * 4 micbiases are used to power various analog and digital
339 * microphones operating at 1800 mV. Technically, all micbiases
340 * can source from single cfilter since all microphones operate
341 * at the same voltage level. The arrangement below is to make
342 * sure all cfilters are exercised. LDO_H regulator ouput level
343 * does not need to be as high as 2.85V. It is choosen for
344 * microphone sensitivity purpose.
345 */
346static struct tabla_pdata apq8064_tabla_platform_data = {
347 .slimbus_slave_device = {
348 .name = "tabla-slave",
349 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
350 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800351 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800352 .irq_base = TABLA_INTERRUPT_BASE,
353 .num_irqs = NR_TABLA_IRQS,
354 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
355 .micbias = {
356 .ldoh_v = TABLA_LDOH_2P85_V,
357 .cfilt1_mv = 1800,
358 .cfilt2_mv = 1800,
359 .cfilt3_mv = 1800,
360 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
361 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
362 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
363 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
364 }
365};
366
367static struct slim_device apq8064_slim_tabla = {
368 .name = "tabla-slim",
369 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
370 .dev = {
371 .platform_data = &apq8064_tabla_platform_data,
372 },
373};
374
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800375static struct tabla_pdata apq8064_tabla20_platform_data = {
376 .slimbus_slave_device = {
377 .name = "tabla-slave",
378 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
379 },
380 .irq = MSM_GPIO_TO_INT(42),
381 .irq_base = TABLA_INTERRUPT_BASE,
382 .num_irqs = NR_TABLA_IRQS,
383 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
384 .micbias = {
385 .ldoh_v = TABLA_LDOH_2P85_V,
386 .cfilt1_mv = 1800,
387 .cfilt2_mv = 1800,
388 .cfilt3_mv = 1800,
389 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
390 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
391 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
392 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
393 }
394};
395
396static struct slim_device apq8064_slim_tabla20 = {
397 .name = "tabla2x-slim",
398 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
399 .dev = {
400 .platform_data = &apq8064_tabla20_platform_data,
401 },
402};
403
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700404#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
405 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
406 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
407 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
408
409#define QCE_SIZE 0x10000
410#define QCE_0_BASE 0x11000000
411
412#define QCE_HW_KEY_SUPPORT 0
413#define QCE_SHA_HMAC_SUPPORT 1
414#define QCE_SHARE_CE_RESOURCE 3
415#define QCE_CE_SHARED 0
416
417static struct resource qcrypto_resources[] = {
418 [0] = {
419 .start = QCE_0_BASE,
420 .end = QCE_0_BASE + QCE_SIZE - 1,
421 .flags = IORESOURCE_MEM,
422 },
423 [1] = {
424 .name = "crypto_channels",
425 .start = DMOV8064_CE_IN_CHAN,
426 .end = DMOV8064_CE_OUT_CHAN,
427 .flags = IORESOURCE_DMA,
428 },
429 [2] = {
430 .name = "crypto_crci_in",
431 .start = DMOV8064_CE_IN_CRCI,
432 .end = DMOV8064_CE_IN_CRCI,
433 .flags = IORESOURCE_DMA,
434 },
435 [3] = {
436 .name = "crypto_crci_out",
437 .start = DMOV8064_CE_OUT_CRCI,
438 .end = DMOV8064_CE_OUT_CRCI,
439 .flags = IORESOURCE_DMA,
440 },
441};
442
443static struct resource qcedev_resources[] = {
444 [0] = {
445 .start = QCE_0_BASE,
446 .end = QCE_0_BASE + QCE_SIZE - 1,
447 .flags = IORESOURCE_MEM,
448 },
449 [1] = {
450 .name = "crypto_channels",
451 .start = DMOV8064_CE_IN_CHAN,
452 .end = DMOV8064_CE_OUT_CHAN,
453 .flags = IORESOURCE_DMA,
454 },
455 [2] = {
456 .name = "crypto_crci_in",
457 .start = DMOV8064_CE_IN_CRCI,
458 .end = DMOV8064_CE_IN_CRCI,
459 .flags = IORESOURCE_DMA,
460 },
461 [3] = {
462 .name = "crypto_crci_out",
463 .start = DMOV8064_CE_OUT_CRCI,
464 .end = DMOV8064_CE_OUT_CRCI,
465 .flags = IORESOURCE_DMA,
466 },
467};
468
469#endif
470
471#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
472 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
473
474static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
475 .ce_shared = QCE_CE_SHARED,
476 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
477 .hw_key_support = QCE_HW_KEY_SUPPORT,
478 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800479 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700480};
481
482static struct platform_device qcrypto_device = {
483 .name = "qcrypto",
484 .id = 0,
485 .num_resources = ARRAY_SIZE(qcrypto_resources),
486 .resource = qcrypto_resources,
487 .dev = {
488 .coherent_dma_mask = DMA_BIT_MASK(32),
489 .platform_data = &qcrypto_ce_hw_suppport,
490 },
491};
492#endif
493
494#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
495 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
496
497static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
498 .ce_shared = QCE_CE_SHARED,
499 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
500 .hw_key_support = QCE_HW_KEY_SUPPORT,
501 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800502 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700503};
504
505static struct platform_device qcedev_device = {
506 .name = "qce",
507 .id = 0,
508 .num_resources = ARRAY_SIZE(qcedev_resources),
509 .resource = qcedev_resources,
510 .dev = {
511 .coherent_dma_mask = DMA_BIT_MASK(32),
512 .platform_data = &qcedev_ce_hw_suppport,
513 },
514};
515#endif
516
517
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600518#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700519static void __init apq8064_map_io(void)
520{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600521 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700522 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700523 if (socinfo_init() < 0)
524 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700525}
526
527static void __init apq8064_init_irq(void)
528{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700529 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
530 (void *)MSM_QGIC_CPU_BASE);
531
532 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
533 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
534
535 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
536 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700537}
538
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800539static struct platform_device msm8064_device_saw_regulator_core0 = {
540 .name = "saw-regulator",
541 .id = 0,
542 .dev = {
543 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
544 },
545};
546
547static struct platform_device msm8064_device_saw_regulator_core1 = {
548 .name = "saw-regulator",
549 .id = 1,
550 .dev = {
551 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
552 },
553};
554
555static struct platform_device msm8064_device_saw_regulator_core2 = {
556 .name = "saw-regulator",
557 .id = 2,
558 .dev = {
559 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
560 },
561};
562
563static struct platform_device msm8064_device_saw_regulator_core3 = {
564 .name = "saw-regulator",
565 .id = 3,
566 .dev = {
567 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
568 },
569};
570
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700571static void __init apq8064_init_buses(void)
572{
573 msm_bus_rpm_set_mt_mask();
574 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
575 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
576 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
577 msm_bus_8064_apps_fabric.dev.platform_data =
578 &msm_bus_8064_apps_fabric_pdata;
579 msm_bus_8064_sys_fabric.dev.platform_data =
580 &msm_bus_8064_sys_fabric_pdata;
581 msm_bus_8064_mm_fabric.dev.platform_data =
582 &msm_bus_8064_mm_fabric_pdata;
583 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
584 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
585}
586
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700587static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700588 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600589 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600590 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600591 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700592 &apq8064_device_ssbi_pmic1,
593 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600594 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700595 &apq8064_device_otg,
596 &apq8064_device_gadget_peripheral,
597 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800598#ifdef CONFIG_ANDROID_PMEM
599#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700600 &android_pmem_device,
601 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800602#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700603 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800604#endif
605#ifdef CONFIG_ION_MSM
606 &ion_dev,
607#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700608 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800609 &msm8064_device_saw_regulator_core0,
610 &msm8064_device_saw_regulator_core1,
611 &msm8064_device_saw_regulator_core2,
612 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700613#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
614 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
615 &qcrypto_device,
616#endif
617
618#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
619 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
620 &qcedev_device,
621#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700622
623#ifdef CONFIG_HW_RANDOM_MSM
624 &apq8064_device_rng,
625#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800626 &apq_pcm,
627 &apq_pcm_routing,
628 &apq_cpudai0,
629 &apq_cpudai1,
630 &apq_cpudai_hdmi_rx,
631 &apq_cpudai_bt_rx,
632 &apq_cpudai_bt_tx,
633 &apq_cpudai_fm_rx,
634 &apq_cpudai_fm_tx,
635 &apq_cpu_fe,
636 &apq_stub_codec,
637 &apq_voice,
638 &apq_voip,
639 &apq_lpa_pcm,
640 &apq_pcm_hostless,
641 &apq_cpudai_afe_01_rx,
642 &apq_cpudai_afe_01_tx,
643 &apq_cpudai_afe_02_rx,
644 &apq_cpudai_afe_02_tx,
645 &apq_pcm_afe,
646 &apq_cpudai_auxpcm_rx,
647 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700648 &msm_bus_8064_apps_fabric,
649 &msm_bus_8064_sys_fabric,
650 &msm_bus_8064_mm_fabric,
651 &msm_bus_8064_sys_fpb,
652 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600653};
654
Joel King4e7ad222011-08-17 15:47:38 -0700655static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700656 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700657 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700658};
659
660static struct platform_device *rumi3_devices[] __initdata = {
661 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800662 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700663};
664
Joel King82b7e3f2012-01-05 10:03:27 -0800665static struct platform_device *cdp_devices[] __initdata = {
666 &apq8064_device_uart_gsbi1,
667 &msm_device_sps_apq8064,
668};
669
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600670static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700671 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700672};
673
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700674#define KS8851_IRQ_GPIO 43
675
676static struct spi_board_info spi_board_info[] __initdata = {
677 {
678 .modalias = "ks8851",
679 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
680 .max_speed_hz = 19200000,
681 .bus_num = 0,
682 .chip_select = 2,
683 .mode = SPI_MODE_0,
684 },
685};
686
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600687static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800688 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800689 .bus_num = 1,
690 .slim_slave = &apq8064_slim_tabla,
691 },
692 {
693 .bus_num = 1,
694 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800695 },
696 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600697};
698
Kenneth Heitke748593a2011-07-15 15:45:11 -0600699static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
700 .clk_freq = 100000,
701 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600702};
703
704static void __init apq8064_i2c_init(void)
705{
706 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
707 &apq8064_i2c_qup_gsbi4_pdata;
708}
709
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700710#ifdef CONFIG_KS8851
711static int ethernet_init(void)
712{
713 int ret;
714 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
715 if (ret) {
716 pr_err("ks8851 gpio_request failed: %d\n", ret);
717 goto fail;
718 }
719
720 return 0;
721fail:
722 return ret;
723}
724#else
725static int ethernet_init(void)
726{
727 return 0;
728}
729#endif
730
Tianyi Gou41515e22011-09-01 19:37:43 -0700731static void __init apq8064_clock_init(void)
732{
733 if (machine_is_apq8064_sim())
734 msm_clock_init(&apq8064_clock_init_data);
735 else
736 msm_clock_init(&apq8064_dummy_clock_init_data);
737}
738
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700739static void __init apq8064_common_init(void)
740{
741 if (socinfo_init() < 0)
742 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700743 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800744 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600745 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600746
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600747 apq8064_device_qup_spi_gsbi5.dev.platform_data =
748 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800749 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700750 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700751 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700752 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530753 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600754 slim_register_board_info(apq8064_slim_devices,
755 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700756}
757
758static void __init apq8064_sim_init(void)
759{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700760 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
761 &msm8064_device_watchdog.dev.platform_data;
762
763 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700764 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700765 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
766}
767
768static void __init apq8064_rumi3_init(void)
769{
770 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700771 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700772 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700773 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700774}
775
Joel King82b7e3f2012-01-05 10:03:27 -0800776static void __init apq8064_cdp_init(void)
777{
778 apq8064_common_init();
779 ethernet_init();
780 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
781 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
782}
783
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700784MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
785 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700786 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700787 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530788 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700789 .timer = &msm_timer,
790 .init_machine = apq8064_sim_init,
791MACHINE_END
792
Joel King4e7ad222011-08-17 15:47:38 -0700793MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
794 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700795 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700796 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530797 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700798 .timer = &msm_timer,
799 .init_machine = apq8064_rumi3_init,
800MACHINE_END
801
Joel King82b7e3f2012-01-05 10:03:27 -0800802MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
803 .map_io = apq8064_map_io,
804 .reserve = apq8064_reserve,
805 .init_irq = apq8064_init_irq,
806 .handle_irq = gic_handle_irq,
807 .timer = &msm_timer,
808 .init_machine = apq8064_cdp_init,
809MACHINE_END
810
811MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
812 .map_io = apq8064_map_io,
813 .reserve = apq8064_reserve,
814 .init_irq = apq8064_init_irq,
815 .handle_irq = gic_handle_irq,
816 .timer = &msm_timer,
817 .init_machine = apq8064_cdp_init,
818MACHINE_END
819
820MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
821 .map_io = apq8064_map_io,
822 .reserve = apq8064_reserve,
823 .init_irq = apq8064_init_irq,
824 .handle_irq = gic_handle_irq,
825 .timer = &msm_timer,
826 .init_machine = apq8064_cdp_init,
827MACHINE_END
828