blob: 0ba743404b57e8afcded8b599cf31e2ce8ce3850 [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;
295 low &= ~(bank_size - 1);
296
297 if (high - low <= bank_size)
298 return;
299 apq8064_reserve_info.low_unstable_address = low + bank_size;
300 apq8064_reserve_info.max_unstable_size = high - low - bank_size;
301 apq8064_reserve_info.bank_size = bank_size;
302 pr_info("low unstable address %lx max size %lx bank size %lx\n",
303 apq8064_reserve_info.low_unstable_address,
304 apq8064_reserve_info.max_unstable_size,
305 apq8064_reserve_info.bank_size);
306}
307
308static void __init apq8064_reserve(void)
309{
310 reserve_info = &apq8064_reserve_info;
311 locate_unstable_memory();
312 msm_reserve();
313}
314
Hemant Kumar4933b072011-10-17 23:43:11 -0700315static struct platform_device android_usb_device = {
316 .name = "android_usb",
317 .id = -1,
318};
319
320static struct msm_otg_platform_data msm_otg_pdata = {
321 .mode = USB_PERIPHERAL,
322 .otg_control = OTG_PHY_CONTROL,
323 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700324};
325
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800326#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
327
328/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
329 * 4 micbiases are used to power various analog and digital
330 * microphones operating at 1800 mV. Technically, all micbiases
331 * can source from single cfilter since all microphones operate
332 * at the same voltage level. The arrangement below is to make
333 * sure all cfilters are exercised. LDO_H regulator ouput level
334 * does not need to be as high as 2.85V. It is choosen for
335 * microphone sensitivity purpose.
336 */
337static struct tabla_pdata apq8064_tabla_platform_data = {
338 .slimbus_slave_device = {
339 .name = "tabla-slave",
340 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
341 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800342 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800343 .irq_base = TABLA_INTERRUPT_BASE,
344 .num_irqs = NR_TABLA_IRQS,
345 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
346 .micbias = {
347 .ldoh_v = TABLA_LDOH_2P85_V,
348 .cfilt1_mv = 1800,
349 .cfilt2_mv = 1800,
350 .cfilt3_mv = 1800,
351 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
352 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
353 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
354 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
355 }
356};
357
358static struct slim_device apq8064_slim_tabla = {
359 .name = "tabla-slim",
360 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
361 .dev = {
362 .platform_data = &apq8064_tabla_platform_data,
363 },
364};
365
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800366static struct tabla_pdata apq8064_tabla20_platform_data = {
367 .slimbus_slave_device = {
368 .name = "tabla-slave",
369 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
370 },
371 .irq = MSM_GPIO_TO_INT(42),
372 .irq_base = TABLA_INTERRUPT_BASE,
373 .num_irqs = NR_TABLA_IRQS,
374 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
375 .micbias = {
376 .ldoh_v = TABLA_LDOH_2P85_V,
377 .cfilt1_mv = 1800,
378 .cfilt2_mv = 1800,
379 .cfilt3_mv = 1800,
380 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
381 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
382 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
383 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
384 }
385};
386
387static struct slim_device apq8064_slim_tabla20 = {
388 .name = "tabla2x-slim",
389 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
390 .dev = {
391 .platform_data = &apq8064_tabla20_platform_data,
392 },
393};
394
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700395#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
396 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
397 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
398 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
399
400#define QCE_SIZE 0x10000
401#define QCE_0_BASE 0x11000000
402
403#define QCE_HW_KEY_SUPPORT 0
404#define QCE_SHA_HMAC_SUPPORT 1
405#define QCE_SHARE_CE_RESOURCE 3
406#define QCE_CE_SHARED 0
407
408static struct resource qcrypto_resources[] = {
409 [0] = {
410 .start = QCE_0_BASE,
411 .end = QCE_0_BASE + QCE_SIZE - 1,
412 .flags = IORESOURCE_MEM,
413 },
414 [1] = {
415 .name = "crypto_channels",
416 .start = DMOV8064_CE_IN_CHAN,
417 .end = DMOV8064_CE_OUT_CHAN,
418 .flags = IORESOURCE_DMA,
419 },
420 [2] = {
421 .name = "crypto_crci_in",
422 .start = DMOV8064_CE_IN_CRCI,
423 .end = DMOV8064_CE_IN_CRCI,
424 .flags = IORESOURCE_DMA,
425 },
426 [3] = {
427 .name = "crypto_crci_out",
428 .start = DMOV8064_CE_OUT_CRCI,
429 .end = DMOV8064_CE_OUT_CRCI,
430 .flags = IORESOURCE_DMA,
431 },
432};
433
434static struct resource qcedev_resources[] = {
435 [0] = {
436 .start = QCE_0_BASE,
437 .end = QCE_0_BASE + QCE_SIZE - 1,
438 .flags = IORESOURCE_MEM,
439 },
440 [1] = {
441 .name = "crypto_channels",
442 .start = DMOV8064_CE_IN_CHAN,
443 .end = DMOV8064_CE_OUT_CHAN,
444 .flags = IORESOURCE_DMA,
445 },
446 [2] = {
447 .name = "crypto_crci_in",
448 .start = DMOV8064_CE_IN_CRCI,
449 .end = DMOV8064_CE_IN_CRCI,
450 .flags = IORESOURCE_DMA,
451 },
452 [3] = {
453 .name = "crypto_crci_out",
454 .start = DMOV8064_CE_OUT_CRCI,
455 .end = DMOV8064_CE_OUT_CRCI,
456 .flags = IORESOURCE_DMA,
457 },
458};
459
460#endif
461
462#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
463 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
464
465static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
466 .ce_shared = QCE_CE_SHARED,
467 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
468 .hw_key_support = QCE_HW_KEY_SUPPORT,
469 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800470 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700471};
472
473static struct platform_device qcrypto_device = {
474 .name = "qcrypto",
475 .id = 0,
476 .num_resources = ARRAY_SIZE(qcrypto_resources),
477 .resource = qcrypto_resources,
478 .dev = {
479 .coherent_dma_mask = DMA_BIT_MASK(32),
480 .platform_data = &qcrypto_ce_hw_suppport,
481 },
482};
483#endif
484
485#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
486 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
487
488static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
489 .ce_shared = QCE_CE_SHARED,
490 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
491 .hw_key_support = QCE_HW_KEY_SUPPORT,
492 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800493 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700494};
495
496static struct platform_device qcedev_device = {
497 .name = "qce",
498 .id = 0,
499 .num_resources = ARRAY_SIZE(qcedev_resources),
500 .resource = qcedev_resources,
501 .dev = {
502 .coherent_dma_mask = DMA_BIT_MASK(32),
503 .platform_data = &qcedev_ce_hw_suppport,
504 },
505};
506#endif
507
508
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600509#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510static void __init apq8064_map_io(void)
511{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600512 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700513 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700514 if (socinfo_init() < 0)
515 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700516}
517
518static void __init apq8064_init_irq(void)
519{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700520 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
521 (void *)MSM_QGIC_CPU_BASE);
522
523 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
524 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
525
526 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
527 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528}
529
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800530static struct platform_device msm8064_device_saw_regulator_core0 = {
531 .name = "saw-regulator",
532 .id = 0,
533 .dev = {
534 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
535 },
536};
537
538static struct platform_device msm8064_device_saw_regulator_core1 = {
539 .name = "saw-regulator",
540 .id = 1,
541 .dev = {
542 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
543 },
544};
545
546static struct platform_device msm8064_device_saw_regulator_core2 = {
547 .name = "saw-regulator",
548 .id = 2,
549 .dev = {
550 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
551 },
552};
553
554static struct platform_device msm8064_device_saw_regulator_core3 = {
555 .name = "saw-regulator",
556 .id = 3,
557 .dev = {
558 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
559 },
560};
561
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700562static void __init apq8064_init_buses(void)
563{
564 msm_bus_rpm_set_mt_mask();
565 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
566 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
567 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
568 msm_bus_8064_apps_fabric.dev.platform_data =
569 &msm_bus_8064_apps_fabric_pdata;
570 msm_bus_8064_sys_fabric.dev.platform_data =
571 &msm_bus_8064_sys_fabric_pdata;
572 msm_bus_8064_mm_fabric.dev.platform_data =
573 &msm_bus_8064_mm_fabric_pdata;
574 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
575 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
576}
577
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700578static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700579 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600580 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600581 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600582 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700583 &apq8064_device_ssbi_pmic1,
584 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600585 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700586 &apq8064_device_otg,
587 &apq8064_device_gadget_peripheral,
588 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800589#ifdef CONFIG_ANDROID_PMEM
590#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700591 &android_pmem_device,
592 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800593#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700594 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800595#endif
596#ifdef CONFIG_ION_MSM
597 &ion_dev,
598#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700599 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800600 &msm8064_device_saw_regulator_core0,
601 &msm8064_device_saw_regulator_core1,
602 &msm8064_device_saw_regulator_core2,
603 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700604#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
605 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
606 &qcrypto_device,
607#endif
608
609#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
610 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
611 &qcedev_device,
612#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700613
614#ifdef CONFIG_HW_RANDOM_MSM
615 &apq8064_device_rng,
616#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800617 &apq_pcm,
618 &apq_pcm_routing,
619 &apq_cpudai0,
620 &apq_cpudai1,
621 &apq_cpudai_hdmi_rx,
622 &apq_cpudai_bt_rx,
623 &apq_cpudai_bt_tx,
624 &apq_cpudai_fm_rx,
625 &apq_cpudai_fm_tx,
626 &apq_cpu_fe,
627 &apq_stub_codec,
628 &apq_voice,
629 &apq_voip,
630 &apq_lpa_pcm,
631 &apq_pcm_hostless,
632 &apq_cpudai_afe_01_rx,
633 &apq_cpudai_afe_01_tx,
634 &apq_cpudai_afe_02_rx,
635 &apq_cpudai_afe_02_tx,
636 &apq_pcm_afe,
637 &apq_cpudai_auxpcm_rx,
638 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700639 &msm_bus_8064_apps_fabric,
640 &msm_bus_8064_sys_fabric,
641 &msm_bus_8064_mm_fabric,
642 &msm_bus_8064_sys_fpb,
643 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600644};
645
Joel King4e7ad222011-08-17 15:47:38 -0700646static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700647 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700648 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700649};
650
651static struct platform_device *rumi3_devices[] __initdata = {
652 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800653 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700654};
655
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600656static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700657 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700658};
659
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700660#define KS8851_IRQ_GPIO 43
661
662static struct spi_board_info spi_board_info[] __initdata = {
663 {
664 .modalias = "ks8851",
665 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
666 .max_speed_hz = 19200000,
667 .bus_num = 0,
668 .chip_select = 2,
669 .mode = SPI_MODE_0,
670 },
671};
672
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600673static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800674 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800675 .bus_num = 1,
676 .slim_slave = &apq8064_slim_tabla,
677 },
678 {
679 .bus_num = 1,
680 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800681 },
682 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600683};
684
Kenneth Heitke748593a2011-07-15 15:45:11 -0600685static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
686 .clk_freq = 100000,
687 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600688};
689
690static void __init apq8064_i2c_init(void)
691{
692 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
693 &apq8064_i2c_qup_gsbi4_pdata;
694}
695
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700696#ifdef CONFIG_KS8851
697static int ethernet_init(void)
698{
699 int ret;
700 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
701 if (ret) {
702 pr_err("ks8851 gpio_request failed: %d\n", ret);
703 goto fail;
704 }
705
706 return 0;
707fail:
708 return ret;
709}
710#else
711static int ethernet_init(void)
712{
713 return 0;
714}
715#endif
716
Tianyi Gou41515e22011-09-01 19:37:43 -0700717static void __init apq8064_clock_init(void)
718{
719 if (machine_is_apq8064_sim())
720 msm_clock_init(&apq8064_clock_init_data);
721 else
722 msm_clock_init(&apq8064_dummy_clock_init_data);
723}
724
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700725static void __init apq8064_common_init(void)
726{
727 if (socinfo_init() < 0)
728 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700729 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800730 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600731 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600732
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600733 apq8064_device_qup_spi_gsbi5.dev.platform_data =
734 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800735 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700736 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700737 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530739 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600740 slim_register_board_info(apq8064_slim_devices,
741 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700742}
743
744static void __init apq8064_sim_init(void)
745{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700746 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
747 &msm8064_device_watchdog.dev.platform_data;
748
749 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700750 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700751 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
752}
753
754static void __init apq8064_rumi3_init(void)
755{
756 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700757 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700758 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700759 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700760}
761
762MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
763 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700764 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700765 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530766 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700767 .timer = &msm_timer,
768 .init_machine = apq8064_sim_init,
769MACHINE_END
770
Joel King4e7ad222011-08-17 15:47:38 -0700771MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
772 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700773 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700774 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530775 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700776 .timer = &msm_timer,
777 .init_machine = apq8064_rumi3_init,
778MACHINE_END
779