blob: 1aedd554041b3167e2279563a4f8c1fe6b652784 [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>
Joel King4ebccc62011-07-22 09:43:22 -070049
Jeff Ohlstein7e668552011-10-06 16:17:25 -070050#include "msm_watchdog.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080051#include "board-8064.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070052
Olav Haugan7c6aa742012-01-16 16:47:37 -080053#define MSM_PMEM_ADSP_SIZE 0x7800000
Ben Romberger3ffcd812011-12-08 19:12:10 -080054#define MSM_PMEM_AUDIO_SIZE 0x2B4000
Olav Haugan7c6aa742012-01-16 16:47:37 -080055#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
56#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
57#else
58#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
59#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070060
Olav Haugan7c6aa742012-01-16 16:47:37 -080061#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
62#define MSM_PMEM_KERNEL_EBI1_SIZE 0xB0C000
63#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
64#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
65#define MSM_ION_MFC_SIZE SZ_8K
66#define MSM_ION_HEAP_NUM 5
67#else
68#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
69#define MSM_ION_HEAP_NUM 1
70#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070071
Olav Haugan7c6aa742012-01-16 16:47:37 -080072#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
73static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
74static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070075{
Olav Haugan7c6aa742012-01-16 16:47:37 -080076 pmem_kernel_ebi1_size = memparse(p, NULL);
77 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070078}
Olav Haugan7c6aa742012-01-16 16:47:37 -080079early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
80#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070081
Olav Haugan7c6aa742012-01-16 16:47:37 -080082#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070083static unsigned pmem_size = MSM_PMEM_SIZE;
84static int __init pmem_size_setup(char *p)
85{
86 pmem_size = memparse(p, NULL);
87 return 0;
88}
89early_param("pmem_size", pmem_size_setup);
90
91static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
92
93static int __init pmem_adsp_size_setup(char *p)
94{
95 pmem_adsp_size = memparse(p, NULL);
96 return 0;
97}
98early_param("pmem_adsp_size", pmem_adsp_size_setup);
99
100static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
101
102static int __init pmem_audio_size_setup(char *p)
103{
104 pmem_audio_size = memparse(p, NULL);
105 return 0;
106}
107early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800108#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700109
Olav Haugan7c6aa742012-01-16 16:47:37 -0800110#ifdef CONFIG_ANDROID_PMEM
111#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700112static struct android_pmem_platform_data android_pmem_pdata = {
113 .name = "pmem",
114 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
115 .cached = 1,
116 .memory_type = MEMTYPE_EBI1,
117};
118
119static struct platform_device android_pmem_device = {
120 .name = "android_pmem",
121 .id = 0,
122 .dev = {.platform_data = &android_pmem_pdata},
123};
124
125static struct android_pmem_platform_data android_pmem_adsp_pdata = {
126 .name = "pmem_adsp",
127 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
128 .cached = 0,
129 .memory_type = MEMTYPE_EBI1,
130};
Kevin Chan13be4e22011-10-20 11:30:32 -0700131static struct platform_device android_pmem_adsp_device = {
132 .name = "android_pmem",
133 .id = 2,
134 .dev = { .platform_data = &android_pmem_adsp_pdata },
135};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800136#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700137
138static struct android_pmem_platform_data android_pmem_audio_pdata = {
139 .name = "pmem_audio",
140 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
141 .cached = 0,
142 .memory_type = MEMTYPE_EBI1,
143};
144
145static struct platform_device android_pmem_audio_device = {
146 .name = "android_pmem",
147 .id = 4,
148 .dev = { .platform_data = &android_pmem_audio_pdata },
149};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800150#endif
151
152static struct memtype_reserve apq8064_reserve_table[] __initdata = {
153 [MEMTYPE_SMI] = {
154 },
155 [MEMTYPE_EBI0] = {
156 .flags = MEMTYPE_FLAGS_1M_ALIGN,
157 },
158 [MEMTYPE_EBI1] = {
159 .flags = MEMTYPE_FLAGS_1M_ALIGN,
160 },
161};
Kevin Chan13be4e22011-10-20 11:30:32 -0700162
163static void __init size_pmem_devices(void)
164{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800165#ifdef CONFIG_ANDROID_PMEM
166#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700167 android_pmem_adsp_pdata.size = pmem_adsp_size;
168 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800169#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700170 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800171#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700172}
173
174static void __init reserve_memory_for(struct android_pmem_platform_data *p)
175{
176 apq8064_reserve_table[p->memory_type].size += p->size;
177}
178
Kevin Chan13be4e22011-10-20 11:30:32 -0700179static void __init reserve_pmem_memory(void)
180{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800181#ifdef CONFIG_ANDROID_PMEM
182#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700183 reserve_memory_for(&android_pmem_adsp_pdata);
184 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800185#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700186 reserve_memory_for(&android_pmem_audio_pdata);
187 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800188#endif
189}
190
191static int apq8064_paddr_to_memtype(unsigned int paddr)
192{
193 return MEMTYPE_EBI1;
194}
195
196#ifdef CONFIG_ION_MSM
197#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
198static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
199 .permission_type = IPT_TYPE_MM_CARVEOUT,
200};
201
202static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
203 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
204};
205
206static struct ion_co_heap_pdata co_ion_pdata = {
207};
208#endif
209static struct ion_platform_data ion_pdata = {
210 .nr = MSM_ION_HEAP_NUM,
211 .heaps = {
212 {
213 .id = ION_SYSTEM_HEAP_ID,
214 .type = ION_HEAP_TYPE_SYSTEM,
215 .name = ION_VMALLOC_HEAP_NAME,
216 },
217#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
218 {
219 .id = ION_SF_HEAP_ID,
220 .type = ION_HEAP_TYPE_CARVEOUT,
221 .name = ION_SF_HEAP_NAME,
222 .size = MSM_ION_SF_SIZE,
223 .memory_type = ION_EBI_TYPE,
224 .extra_data = (void *) &co_ion_pdata,
225 },
226 {
227 .id = ION_CP_MM_HEAP_ID,
228 .type = ION_HEAP_TYPE_CP,
229 .name = ION_MM_HEAP_NAME,
230 .size = MSM_ION_MM_SIZE,
231 .memory_type = ION_EBI_TYPE,
232 .extra_data = (void *) &cp_mm_ion_pdata,
233 },
234 {
235 .id = ION_CP_MFC_HEAP_ID,
236 .type = ION_HEAP_TYPE_CP,
237 .name = ION_MFC_HEAP_NAME,
238 .size = MSM_ION_MFC_SIZE,
239 .memory_type = ION_EBI_TYPE,
240 .extra_data = (void *) &cp_mfc_ion_pdata,
241 },
242 {
243 .id = ION_IOMMU_HEAP_ID,
244 .type = ION_HEAP_TYPE_IOMMU,
245 .name = ION_IOMMU_HEAP_NAME,
246 },
247#endif
248 }
249};
250
251static struct platform_device ion_dev = {
252 .name = "ion-msm",
253 .id = 1,
254 .dev = { .platform_data = &ion_pdata },
255};
256#endif
257
258static void reserve_ion_memory(void)
259{
260#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
261 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
262 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
263 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
264#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700265}
266
267static void __init apq8064_calculate_reserve_sizes(void)
268{
269 size_pmem_devices();
270 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800271 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700272}
273
274static struct reserve_info apq8064_reserve_info __initdata = {
275 .memtype_reserve_table = apq8064_reserve_table,
276 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
277 .paddr_to_memtype = apq8064_paddr_to_memtype,
278};
279
280static int apq8064_memory_bank_size(void)
281{
282 return 1<<29;
283}
284
285static void __init locate_unstable_memory(void)
286{
287 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
288 unsigned long bank_size;
289 unsigned long low, high;
290
291 bank_size = apq8064_memory_bank_size();
292 low = meminfo.bank[0].start;
293 high = mb->start + mb->size;
294 low &= ~(bank_size - 1);
295
296 if (high - low <= bank_size)
297 return;
298 apq8064_reserve_info.low_unstable_address = low + bank_size;
299 apq8064_reserve_info.max_unstable_size = high - low - bank_size;
300 apq8064_reserve_info.bank_size = bank_size;
301 pr_info("low unstable address %lx max size %lx bank size %lx\n",
302 apq8064_reserve_info.low_unstable_address,
303 apq8064_reserve_info.max_unstable_size,
304 apq8064_reserve_info.bank_size);
305}
306
307static void __init apq8064_reserve(void)
308{
309 reserve_info = &apq8064_reserve_info;
310 locate_unstable_memory();
311 msm_reserve();
312}
313
Hemant Kumar4933b072011-10-17 23:43:11 -0700314static struct platform_device android_usb_device = {
315 .name = "android_usb",
316 .id = -1,
317};
318
319static struct msm_otg_platform_data msm_otg_pdata = {
320 .mode = USB_PERIPHERAL,
321 .otg_control = OTG_PHY_CONTROL,
322 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700323};
324
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800325#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
326
327/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
328 * 4 micbiases are used to power various analog and digital
329 * microphones operating at 1800 mV. Technically, all micbiases
330 * can source from single cfilter since all microphones operate
331 * at the same voltage level. The arrangement below is to make
332 * sure all cfilters are exercised. LDO_H regulator ouput level
333 * does not need to be as high as 2.85V. It is choosen for
334 * microphone sensitivity purpose.
335 */
336static struct tabla_pdata apq8064_tabla_platform_data = {
337 .slimbus_slave_device = {
338 .name = "tabla-slave",
339 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
340 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800341 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800342 .irq_base = TABLA_INTERRUPT_BASE,
343 .num_irqs = NR_TABLA_IRQS,
344 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
345 .micbias = {
346 .ldoh_v = TABLA_LDOH_2P85_V,
347 .cfilt1_mv = 1800,
348 .cfilt2_mv = 1800,
349 .cfilt3_mv = 1800,
350 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
351 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
352 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
353 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
354 }
355};
356
357static struct slim_device apq8064_slim_tabla = {
358 .name = "tabla-slim",
359 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
360 .dev = {
361 .platform_data = &apq8064_tabla_platform_data,
362 },
363};
364
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800365static struct tabla_pdata apq8064_tabla20_platform_data = {
366 .slimbus_slave_device = {
367 .name = "tabla-slave",
368 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
369 },
370 .irq = MSM_GPIO_TO_INT(42),
371 .irq_base = TABLA_INTERRUPT_BASE,
372 .num_irqs = NR_TABLA_IRQS,
373 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
374 .micbias = {
375 .ldoh_v = TABLA_LDOH_2P85_V,
376 .cfilt1_mv = 1800,
377 .cfilt2_mv = 1800,
378 .cfilt3_mv = 1800,
379 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
380 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
381 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
382 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
383 }
384};
385
386static struct slim_device apq8064_slim_tabla20 = {
387 .name = "tabla2x-slim",
388 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
389 .dev = {
390 .platform_data = &apq8064_tabla20_platform_data,
391 },
392};
393
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700394#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
395 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
396 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
397 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
398
399#define QCE_SIZE 0x10000
400#define QCE_0_BASE 0x11000000
401
402#define QCE_HW_KEY_SUPPORT 0
403#define QCE_SHA_HMAC_SUPPORT 1
404#define QCE_SHARE_CE_RESOURCE 3
405#define QCE_CE_SHARED 0
406
407static struct resource qcrypto_resources[] = {
408 [0] = {
409 .start = QCE_0_BASE,
410 .end = QCE_0_BASE + QCE_SIZE - 1,
411 .flags = IORESOURCE_MEM,
412 },
413 [1] = {
414 .name = "crypto_channels",
415 .start = DMOV8064_CE_IN_CHAN,
416 .end = DMOV8064_CE_OUT_CHAN,
417 .flags = IORESOURCE_DMA,
418 },
419 [2] = {
420 .name = "crypto_crci_in",
421 .start = DMOV8064_CE_IN_CRCI,
422 .end = DMOV8064_CE_IN_CRCI,
423 .flags = IORESOURCE_DMA,
424 },
425 [3] = {
426 .name = "crypto_crci_out",
427 .start = DMOV8064_CE_OUT_CRCI,
428 .end = DMOV8064_CE_OUT_CRCI,
429 .flags = IORESOURCE_DMA,
430 },
431};
432
433static struct resource qcedev_resources[] = {
434 [0] = {
435 .start = QCE_0_BASE,
436 .end = QCE_0_BASE + QCE_SIZE - 1,
437 .flags = IORESOURCE_MEM,
438 },
439 [1] = {
440 .name = "crypto_channels",
441 .start = DMOV8064_CE_IN_CHAN,
442 .end = DMOV8064_CE_OUT_CHAN,
443 .flags = IORESOURCE_DMA,
444 },
445 [2] = {
446 .name = "crypto_crci_in",
447 .start = DMOV8064_CE_IN_CRCI,
448 .end = DMOV8064_CE_IN_CRCI,
449 .flags = IORESOURCE_DMA,
450 },
451 [3] = {
452 .name = "crypto_crci_out",
453 .start = DMOV8064_CE_OUT_CRCI,
454 .end = DMOV8064_CE_OUT_CRCI,
455 .flags = IORESOURCE_DMA,
456 },
457};
458
459#endif
460
461#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
462 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
463
464static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
465 .ce_shared = QCE_CE_SHARED,
466 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
467 .hw_key_support = QCE_HW_KEY_SUPPORT,
468 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800469 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700470};
471
472static struct platform_device qcrypto_device = {
473 .name = "qcrypto",
474 .id = 0,
475 .num_resources = ARRAY_SIZE(qcrypto_resources),
476 .resource = qcrypto_resources,
477 .dev = {
478 .coherent_dma_mask = DMA_BIT_MASK(32),
479 .platform_data = &qcrypto_ce_hw_suppport,
480 },
481};
482#endif
483
484#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
485 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
486
487static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
488 .ce_shared = QCE_CE_SHARED,
489 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
490 .hw_key_support = QCE_HW_KEY_SUPPORT,
491 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800492 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700493};
494
495static struct platform_device qcedev_device = {
496 .name = "qce",
497 .id = 0,
498 .num_resources = ARRAY_SIZE(qcedev_resources),
499 .resource = qcedev_resources,
500 .dev = {
501 .coherent_dma_mask = DMA_BIT_MASK(32),
502 .platform_data = &qcedev_ce_hw_suppport,
503 },
504};
505#endif
506
507
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600508#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700509static void __init apq8064_map_io(void)
510{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600511 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700512 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700513 if (socinfo_init() < 0)
514 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700515}
516
517static void __init apq8064_init_irq(void)
518{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700519 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
520 (void *)MSM_QGIC_CPU_BASE);
521
522 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
523 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
524
525 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
526 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700527}
528
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800529static struct platform_device msm8064_device_saw_regulator_core0 = {
530 .name = "saw-regulator",
531 .id = 0,
532 .dev = {
533 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
534 },
535};
536
537static struct platform_device msm8064_device_saw_regulator_core1 = {
538 .name = "saw-regulator",
539 .id = 1,
540 .dev = {
541 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
542 },
543};
544
545static struct platform_device msm8064_device_saw_regulator_core2 = {
546 .name = "saw-regulator",
547 .id = 2,
548 .dev = {
549 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
550 },
551};
552
553static struct platform_device msm8064_device_saw_regulator_core3 = {
554 .name = "saw-regulator",
555 .id = 3,
556 .dev = {
557 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
558 },
559};
560
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700561static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700562 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600563 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600564 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600565 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700566 &apq8064_device_ssbi_pmic1,
567 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600568 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700569 &apq8064_device_otg,
570 &apq8064_device_gadget_peripheral,
571 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800572#ifdef CONFIG_ANDROID_PMEM
573#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700574 &android_pmem_device,
575 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800576#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700577 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800578#endif
579#ifdef CONFIG_ION_MSM
580 &ion_dev,
581#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700582 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800583 &msm8064_device_saw_regulator_core0,
584 &msm8064_device_saw_regulator_core1,
585 &msm8064_device_saw_regulator_core2,
586 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700587#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
588 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
589 &qcrypto_device,
590#endif
591
592#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
593 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
594 &qcedev_device,
595#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700596
597#ifdef CONFIG_HW_RANDOM_MSM
598 &apq8064_device_rng,
599#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800600 &apq_pcm,
601 &apq_pcm_routing,
602 &apq_cpudai0,
603 &apq_cpudai1,
604 &apq_cpudai_hdmi_rx,
605 &apq_cpudai_bt_rx,
606 &apq_cpudai_bt_tx,
607 &apq_cpudai_fm_rx,
608 &apq_cpudai_fm_tx,
609 &apq_cpu_fe,
610 &apq_stub_codec,
611 &apq_voice,
612 &apq_voip,
613 &apq_lpa_pcm,
614 &apq_pcm_hostless,
615 &apq_cpudai_afe_01_rx,
616 &apq_cpudai_afe_01_tx,
617 &apq_cpudai_afe_02_rx,
618 &apq_cpudai_afe_02_tx,
619 &apq_pcm_afe,
620 &apq_cpudai_auxpcm_rx,
621 &apq_cpudai_auxpcm_tx,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600622};
623
Joel King4e7ad222011-08-17 15:47:38 -0700624static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700625 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700626 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700627};
628
629static struct platform_device *rumi3_devices[] __initdata = {
630 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800631 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700632};
633
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600634static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700635 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700636};
637
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700638#define KS8851_IRQ_GPIO 43
639
640static struct spi_board_info spi_board_info[] __initdata = {
641 {
642 .modalias = "ks8851",
643 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
644 .max_speed_hz = 19200000,
645 .bus_num = 0,
646 .chip_select = 2,
647 .mode = SPI_MODE_0,
648 },
649};
650
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600651static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800652 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800653 .bus_num = 1,
654 .slim_slave = &apq8064_slim_tabla,
655 },
656 {
657 .bus_num = 1,
658 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800659 },
660 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600661};
662
Kenneth Heitke748593a2011-07-15 15:45:11 -0600663static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
664 .clk_freq = 100000,
665 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600666};
667
668static void __init apq8064_i2c_init(void)
669{
670 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
671 &apq8064_i2c_qup_gsbi4_pdata;
672}
673
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700674#ifdef CONFIG_KS8851
675static int ethernet_init(void)
676{
677 int ret;
678 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
679 if (ret) {
680 pr_err("ks8851 gpio_request failed: %d\n", ret);
681 goto fail;
682 }
683
684 return 0;
685fail:
686 return ret;
687}
688#else
689static int ethernet_init(void)
690{
691 return 0;
692}
693#endif
694
Tianyi Gou41515e22011-09-01 19:37:43 -0700695static void __init apq8064_clock_init(void)
696{
697 if (machine_is_apq8064_sim())
698 msm_clock_init(&apq8064_clock_init_data);
699 else
700 msm_clock_init(&apq8064_dummy_clock_init_data);
701}
702
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700703static void __init apq8064_common_init(void)
704{
705 if (socinfo_init() < 0)
706 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700707 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800708 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600709 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600710
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600711 apq8064_device_qup_spi_gsbi5.dev.platform_data =
712 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800713 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700714 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700715 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530716 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600717 slim_register_board_info(apq8064_slim_devices,
718 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700719}
720
721static void __init apq8064_sim_init(void)
722{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700723 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
724 &msm8064_device_watchdog.dev.platform_data;
725
726 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700727 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700728 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
729}
730
731static void __init apq8064_rumi3_init(void)
732{
733 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700734 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700735 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700736 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700737}
738
739MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
740 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700741 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700742 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530743 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700744 .timer = &msm_timer,
745 .init_machine = apq8064_sim_init,
746MACHINE_END
747
Joel King4e7ad222011-08-17 15:47:38 -0700748MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
749 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700750 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700751 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530752 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700753 .timer = &msm_timer,
754 .init_machine = apq8064_rumi3_init,
755MACHINE_END
756