blob: d14db50356d86b2910c1ac68906a8b155ad4d3ae [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>
Jack Cheung46bfffa2012-01-19 15:26:24 -080026#include <linux/memory.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053030#include <asm/mach/mmc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031
32#include <mach/board.h>
33#include <mach/msm_iomap.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080034#include <mach/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035#include <linux/usb/msm_hsusb.h>
36#include <linux/usb/android.h>
37#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060038#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039#include "timer.h"
40#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070041#include <mach/gpio.h>
42#include <mach/gpiomux.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080043#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070044#include <linux/android_pmem.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080045#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070046#include <mach/msm_memtypes.h>
47#include <linux/bootmem.h>
48#include <asm/setup.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070049#include <mach/dma.h>
Gagan Mac8a7a5d32011-11-11 16:43:06 -070050#include <mach/msm_bus_board.h>
Joel King4ebccc62011-07-22 09:43:22 -070051
Jeff Ohlstein7e668552011-10-06 16:17:25 -070052#include "msm_watchdog.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080053#include "board-8064.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070054
Olav Haugan7c6aa742012-01-16 16:47:37 -080055#define MSM_PMEM_ADSP_SIZE 0x7800000
Ben Romberger3ffcd812011-12-08 19:12:10 -080056#define MSM_PMEM_AUDIO_SIZE 0x2B4000
Olav Haugan7c6aa742012-01-16 16:47:37 -080057#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
58#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
59#else
60#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
61#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070062
Olav Haugan7c6aa742012-01-16 16:47:37 -080063#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
64#define MSM_PMEM_KERNEL_EBI1_SIZE 0xB0C000
65#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
66#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
67#define MSM_ION_MFC_SIZE SZ_8K
68#define MSM_ION_HEAP_NUM 5
69#else
70#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
71#define MSM_ION_HEAP_NUM 1
72#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070073
Olav Haugan7c6aa742012-01-16 16:47:37 -080074#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
75static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
76static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070077{
Olav Haugan7c6aa742012-01-16 16:47:37 -080078 pmem_kernel_ebi1_size = memparse(p, NULL);
79 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070080}
Olav Haugan7c6aa742012-01-16 16:47:37 -080081early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
82#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070083
Olav Haugan7c6aa742012-01-16 16:47:37 -080084#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070085static unsigned pmem_size = MSM_PMEM_SIZE;
86static int __init pmem_size_setup(char *p)
87{
88 pmem_size = memparse(p, NULL);
89 return 0;
90}
91early_param("pmem_size", pmem_size_setup);
92
93static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
94
95static int __init pmem_adsp_size_setup(char *p)
96{
97 pmem_adsp_size = memparse(p, NULL);
98 return 0;
99}
100early_param("pmem_adsp_size", pmem_adsp_size_setup);
101
102static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
103
104static int __init pmem_audio_size_setup(char *p)
105{
106 pmem_audio_size = memparse(p, NULL);
107 return 0;
108}
109early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800110#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700111
Olav Haugan7c6aa742012-01-16 16:47:37 -0800112#ifdef CONFIG_ANDROID_PMEM
113#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700114static struct android_pmem_platform_data android_pmem_pdata = {
115 .name = "pmem",
116 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
117 .cached = 1,
118 .memory_type = MEMTYPE_EBI1,
119};
120
121static struct platform_device android_pmem_device = {
122 .name = "android_pmem",
123 .id = 0,
124 .dev = {.platform_data = &android_pmem_pdata},
125};
126
127static struct android_pmem_platform_data android_pmem_adsp_pdata = {
128 .name = "pmem_adsp",
129 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
130 .cached = 0,
131 .memory_type = MEMTYPE_EBI1,
132};
Kevin Chan13be4e22011-10-20 11:30:32 -0700133static struct platform_device android_pmem_adsp_device = {
134 .name = "android_pmem",
135 .id = 2,
136 .dev = { .platform_data = &android_pmem_adsp_pdata },
137};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800138#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700139
140static struct android_pmem_platform_data android_pmem_audio_pdata = {
141 .name = "pmem_audio",
142 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
143 .cached = 0,
144 .memory_type = MEMTYPE_EBI1,
145};
146
147static struct platform_device android_pmem_audio_device = {
148 .name = "android_pmem",
149 .id = 4,
150 .dev = { .platform_data = &android_pmem_audio_pdata },
151};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800152#endif
153
154static struct memtype_reserve apq8064_reserve_table[] __initdata = {
155 [MEMTYPE_SMI] = {
156 },
157 [MEMTYPE_EBI0] = {
158 .flags = MEMTYPE_FLAGS_1M_ALIGN,
159 },
160 [MEMTYPE_EBI1] = {
161 .flags = MEMTYPE_FLAGS_1M_ALIGN,
162 },
163};
Kevin Chan13be4e22011-10-20 11:30:32 -0700164
165static void __init size_pmem_devices(void)
166{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800167#ifdef CONFIG_ANDROID_PMEM
168#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700169 android_pmem_adsp_pdata.size = pmem_adsp_size;
170 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800171#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700172 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800173#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700174}
175
176static void __init reserve_memory_for(struct android_pmem_platform_data *p)
177{
178 apq8064_reserve_table[p->memory_type].size += p->size;
179}
180
Kevin Chan13be4e22011-10-20 11:30:32 -0700181static void __init reserve_pmem_memory(void)
182{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800183#ifdef CONFIG_ANDROID_PMEM
184#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700185 reserve_memory_for(&android_pmem_adsp_pdata);
186 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800187#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700188 reserve_memory_for(&android_pmem_audio_pdata);
189 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800190#endif
191}
192
193static int apq8064_paddr_to_memtype(unsigned int paddr)
194{
195 return MEMTYPE_EBI1;
196}
197
198#ifdef CONFIG_ION_MSM
199#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
200static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
201 .permission_type = IPT_TYPE_MM_CARVEOUT,
202};
203
204static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
205 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
206};
207
208static struct ion_co_heap_pdata co_ion_pdata = {
209};
210#endif
211static struct ion_platform_data ion_pdata = {
212 .nr = MSM_ION_HEAP_NUM,
213 .heaps = {
214 {
215 .id = ION_SYSTEM_HEAP_ID,
216 .type = ION_HEAP_TYPE_SYSTEM,
217 .name = ION_VMALLOC_HEAP_NAME,
218 },
219#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
220 {
221 .id = ION_SF_HEAP_ID,
222 .type = ION_HEAP_TYPE_CARVEOUT,
223 .name = ION_SF_HEAP_NAME,
224 .size = MSM_ION_SF_SIZE,
225 .memory_type = ION_EBI_TYPE,
226 .extra_data = (void *) &co_ion_pdata,
227 },
228 {
229 .id = ION_CP_MM_HEAP_ID,
230 .type = ION_HEAP_TYPE_CP,
231 .name = ION_MM_HEAP_NAME,
232 .size = MSM_ION_MM_SIZE,
233 .memory_type = ION_EBI_TYPE,
234 .extra_data = (void *) &cp_mm_ion_pdata,
235 },
236 {
237 .id = ION_CP_MFC_HEAP_ID,
238 .type = ION_HEAP_TYPE_CP,
239 .name = ION_MFC_HEAP_NAME,
240 .size = MSM_ION_MFC_SIZE,
241 .memory_type = ION_EBI_TYPE,
242 .extra_data = (void *) &cp_mfc_ion_pdata,
243 },
244 {
245 .id = ION_IOMMU_HEAP_ID,
246 .type = ION_HEAP_TYPE_IOMMU,
247 .name = ION_IOMMU_HEAP_NAME,
248 },
249#endif
250 }
251};
252
253static struct platform_device ion_dev = {
254 .name = "ion-msm",
255 .id = 1,
256 .dev = { .platform_data = &ion_pdata },
257};
258#endif
259
260static void reserve_ion_memory(void)
261{
262#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
263 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
264 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
265 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
266#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700267}
268
269static void __init apq8064_calculate_reserve_sizes(void)
270{
271 size_pmem_devices();
272 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800273 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700274}
275
276static struct reserve_info apq8064_reserve_info __initdata = {
277 .memtype_reserve_table = apq8064_reserve_table,
278 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
279 .paddr_to_memtype = apq8064_paddr_to_memtype,
280};
281
282static int apq8064_memory_bank_size(void)
283{
284 return 1<<29;
285}
286
287static void __init locate_unstable_memory(void)
288{
289 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
290 unsigned long bank_size;
291 unsigned long low, high;
292
293 bank_size = apq8064_memory_bank_size();
294 low = meminfo.bank[0].start;
295 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800296
297 /* Check if 32 bit overflow occured */
298 if (high < mb->start)
299 high = ~0UL;
300
Kevin Chan13be4e22011-10-20 11:30:32 -0700301 low &= ~(bank_size - 1);
302
303 if (high - low <= bank_size)
304 return;
Jack Cheung46bfffa2012-01-19 15:26:24 -0800305 apq8064_reserve_info.low_unstable_address = mb->start -
306 MIN_MEMORY_BLOCK_SIZE + mb->size;
307 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
308
Kevin Chan13be4e22011-10-20 11:30:32 -0700309 apq8064_reserve_info.bank_size = bank_size;
310 pr_info("low unstable address %lx max size %lx bank size %lx\n",
311 apq8064_reserve_info.low_unstable_address,
312 apq8064_reserve_info.max_unstable_size,
313 apq8064_reserve_info.bank_size);
314}
315
316static void __init apq8064_reserve(void)
317{
318 reserve_info = &apq8064_reserve_info;
319 locate_unstable_memory();
320 msm_reserve();
321}
322
Hemant Kumar4933b072011-10-17 23:43:11 -0700323static struct platform_device android_usb_device = {
324 .name = "android_usb",
325 .id = -1,
326};
327
328static struct msm_otg_platform_data msm_otg_pdata = {
329 .mode = USB_PERIPHERAL,
330 .otg_control = OTG_PHY_CONTROL,
331 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700332};
333
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800334#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
335
336/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
337 * 4 micbiases are used to power various analog and digital
338 * microphones operating at 1800 mV. Technically, all micbiases
339 * can source from single cfilter since all microphones operate
340 * at the same voltage level. The arrangement below is to make
341 * sure all cfilters are exercised. LDO_H regulator ouput level
342 * does not need to be as high as 2.85V. It is choosen for
343 * microphone sensitivity purpose.
344 */
345static struct tabla_pdata apq8064_tabla_platform_data = {
346 .slimbus_slave_device = {
347 .name = "tabla-slave",
348 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
349 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800350 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800351 .irq_base = TABLA_INTERRUPT_BASE,
352 .num_irqs = NR_TABLA_IRQS,
353 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
354 .micbias = {
355 .ldoh_v = TABLA_LDOH_2P85_V,
356 .cfilt1_mv = 1800,
357 .cfilt2_mv = 1800,
358 .cfilt3_mv = 1800,
359 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
360 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
361 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
362 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
363 }
364};
365
366static struct slim_device apq8064_slim_tabla = {
367 .name = "tabla-slim",
368 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
369 .dev = {
370 .platform_data = &apq8064_tabla_platform_data,
371 },
372};
373
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800374static struct tabla_pdata apq8064_tabla20_platform_data = {
375 .slimbus_slave_device = {
376 .name = "tabla-slave",
377 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
378 },
379 .irq = MSM_GPIO_TO_INT(42),
380 .irq_base = TABLA_INTERRUPT_BASE,
381 .num_irqs = NR_TABLA_IRQS,
382 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
383 .micbias = {
384 .ldoh_v = TABLA_LDOH_2P85_V,
385 .cfilt1_mv = 1800,
386 .cfilt2_mv = 1800,
387 .cfilt3_mv = 1800,
388 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
389 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
390 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
391 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
392 }
393};
394
395static struct slim_device apq8064_slim_tabla20 = {
396 .name = "tabla2x-slim",
397 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
398 .dev = {
399 .platform_data = &apq8064_tabla20_platform_data,
400 },
401};
402
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700403#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
404 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
405 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
406 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
407
408#define QCE_SIZE 0x10000
409#define QCE_0_BASE 0x11000000
410
411#define QCE_HW_KEY_SUPPORT 0
412#define QCE_SHA_HMAC_SUPPORT 1
413#define QCE_SHARE_CE_RESOURCE 3
414#define QCE_CE_SHARED 0
415
416static struct resource qcrypto_resources[] = {
417 [0] = {
418 .start = QCE_0_BASE,
419 .end = QCE_0_BASE + QCE_SIZE - 1,
420 .flags = IORESOURCE_MEM,
421 },
422 [1] = {
423 .name = "crypto_channels",
424 .start = DMOV8064_CE_IN_CHAN,
425 .end = DMOV8064_CE_OUT_CHAN,
426 .flags = IORESOURCE_DMA,
427 },
428 [2] = {
429 .name = "crypto_crci_in",
430 .start = DMOV8064_CE_IN_CRCI,
431 .end = DMOV8064_CE_IN_CRCI,
432 .flags = IORESOURCE_DMA,
433 },
434 [3] = {
435 .name = "crypto_crci_out",
436 .start = DMOV8064_CE_OUT_CRCI,
437 .end = DMOV8064_CE_OUT_CRCI,
438 .flags = IORESOURCE_DMA,
439 },
440};
441
442static struct resource qcedev_resources[] = {
443 [0] = {
444 .start = QCE_0_BASE,
445 .end = QCE_0_BASE + QCE_SIZE - 1,
446 .flags = IORESOURCE_MEM,
447 },
448 [1] = {
449 .name = "crypto_channels",
450 .start = DMOV8064_CE_IN_CHAN,
451 .end = DMOV8064_CE_OUT_CHAN,
452 .flags = IORESOURCE_DMA,
453 },
454 [2] = {
455 .name = "crypto_crci_in",
456 .start = DMOV8064_CE_IN_CRCI,
457 .end = DMOV8064_CE_IN_CRCI,
458 .flags = IORESOURCE_DMA,
459 },
460 [3] = {
461 .name = "crypto_crci_out",
462 .start = DMOV8064_CE_OUT_CRCI,
463 .end = DMOV8064_CE_OUT_CRCI,
464 .flags = IORESOURCE_DMA,
465 },
466};
467
468#endif
469
470#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
471 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
472
473static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
474 .ce_shared = QCE_CE_SHARED,
475 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
476 .hw_key_support = QCE_HW_KEY_SUPPORT,
477 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800478 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700479};
480
481static struct platform_device qcrypto_device = {
482 .name = "qcrypto",
483 .id = 0,
484 .num_resources = ARRAY_SIZE(qcrypto_resources),
485 .resource = qcrypto_resources,
486 .dev = {
487 .coherent_dma_mask = DMA_BIT_MASK(32),
488 .platform_data = &qcrypto_ce_hw_suppport,
489 },
490};
491#endif
492
493#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
494 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
495
496static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
497 .ce_shared = QCE_CE_SHARED,
498 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
499 .hw_key_support = QCE_HW_KEY_SUPPORT,
500 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800501 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700502};
503
504static struct platform_device qcedev_device = {
505 .name = "qce",
506 .id = 0,
507 .num_resources = ARRAY_SIZE(qcedev_resources),
508 .resource = qcedev_resources,
509 .dev = {
510 .coherent_dma_mask = DMA_BIT_MASK(32),
511 .platform_data = &qcedev_ce_hw_suppport,
512 },
513};
514#endif
515
516
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600517#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700518static void __init apq8064_map_io(void)
519{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600520 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700521 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700522 if (socinfo_init() < 0)
523 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524}
525
526static void __init apq8064_init_irq(void)
527{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
529 (void *)MSM_QGIC_CPU_BASE);
530
531 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
532 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
533
534 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
535 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536}
537
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800538static struct platform_device msm8064_device_saw_regulator_core0 = {
539 .name = "saw-regulator",
540 .id = 0,
541 .dev = {
542 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
543 },
544};
545
546static struct platform_device msm8064_device_saw_regulator_core1 = {
547 .name = "saw-regulator",
548 .id = 1,
549 .dev = {
550 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
551 },
552};
553
554static struct platform_device msm8064_device_saw_regulator_core2 = {
555 .name = "saw-regulator",
556 .id = 2,
557 .dev = {
558 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
559 },
560};
561
562static struct platform_device msm8064_device_saw_regulator_core3 = {
563 .name = "saw-regulator",
564 .id = 3,
565 .dev = {
566 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
567 },
568};
569
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700570static void __init apq8064_init_buses(void)
571{
572 msm_bus_rpm_set_mt_mask();
573 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
574 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
575 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
576 msm_bus_8064_apps_fabric.dev.platform_data =
577 &msm_bus_8064_apps_fabric_pdata;
578 msm_bus_8064_sys_fabric.dev.platform_data =
579 &msm_bus_8064_sys_fabric_pdata;
580 msm_bus_8064_mm_fabric.dev.platform_data =
581 &msm_bus_8064_mm_fabric_pdata;
582 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
583 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
584}
585
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700586static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700587 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600588 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600589 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600590 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700591 &apq8064_device_ssbi_pmic1,
592 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600593 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700594 &apq8064_device_otg,
595 &apq8064_device_gadget_peripheral,
596 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800597#ifdef CONFIG_ANDROID_PMEM
598#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700599 &android_pmem_device,
600 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800601#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700602 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800603#endif
604#ifdef CONFIG_ION_MSM
605 &ion_dev,
606#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700607 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800608 &msm8064_device_saw_regulator_core0,
609 &msm8064_device_saw_regulator_core1,
610 &msm8064_device_saw_regulator_core2,
611 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700612#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
613 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
614 &qcrypto_device,
615#endif
616
617#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
618 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
619 &qcedev_device,
620#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700621
622#ifdef CONFIG_HW_RANDOM_MSM
623 &apq8064_device_rng,
624#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800625 &apq_pcm,
626 &apq_pcm_routing,
627 &apq_cpudai0,
628 &apq_cpudai1,
629 &apq_cpudai_hdmi_rx,
630 &apq_cpudai_bt_rx,
631 &apq_cpudai_bt_tx,
632 &apq_cpudai_fm_rx,
633 &apq_cpudai_fm_tx,
634 &apq_cpu_fe,
635 &apq_stub_codec,
636 &apq_voice,
637 &apq_voip,
638 &apq_lpa_pcm,
639 &apq_pcm_hostless,
640 &apq_cpudai_afe_01_rx,
641 &apq_cpudai_afe_01_tx,
642 &apq_cpudai_afe_02_rx,
643 &apq_cpudai_afe_02_tx,
644 &apq_pcm_afe,
645 &apq_cpudai_auxpcm_rx,
646 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700647 &msm_bus_8064_apps_fabric,
648 &msm_bus_8064_sys_fabric,
649 &msm_bus_8064_mm_fabric,
650 &msm_bus_8064_sys_fpb,
651 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600652};
653
Joel King4e7ad222011-08-17 15:47:38 -0700654static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700655 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700656 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700657};
658
659static struct platform_device *rumi3_devices[] __initdata = {
660 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800661 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700662};
663
Joel King82b7e3f2012-01-05 10:03:27 -0800664static struct platform_device *cdp_devices[] __initdata = {
665 &apq8064_device_uart_gsbi1,
666 &msm_device_sps_apq8064,
667};
668
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600669static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700670 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700671};
672
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700673#define KS8851_IRQ_GPIO 43
674
675static struct spi_board_info spi_board_info[] __initdata = {
676 {
677 .modalias = "ks8851",
678 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
679 .max_speed_hz = 19200000,
680 .bus_num = 0,
681 .chip_select = 2,
682 .mode = SPI_MODE_0,
683 },
684};
685
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600686static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800687 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800688 .bus_num = 1,
689 .slim_slave = &apq8064_slim_tabla,
690 },
691 {
692 .bus_num = 1,
693 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800694 },
695 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600696};
697
Kenneth Heitke748593a2011-07-15 15:45:11 -0600698static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
699 .clk_freq = 100000,
700 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600701};
702
703static void __init apq8064_i2c_init(void)
704{
705 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
706 &apq8064_i2c_qup_gsbi4_pdata;
707}
708
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700709#ifdef CONFIG_KS8851
710static int ethernet_init(void)
711{
712 int ret;
713 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
714 if (ret) {
715 pr_err("ks8851 gpio_request failed: %d\n", ret);
716 goto fail;
717 }
718
719 return 0;
720fail:
721 return ret;
722}
723#else
724static int ethernet_init(void)
725{
726 return 0;
727}
728#endif
729
Tianyi Gou41515e22011-09-01 19:37:43 -0700730static void __init apq8064_clock_init(void)
731{
732 if (machine_is_apq8064_sim())
733 msm_clock_init(&apq8064_clock_init_data);
734 else
735 msm_clock_init(&apq8064_dummy_clock_init_data);
736}
737
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738static void __init apq8064_common_init(void)
739{
740 if (socinfo_init() < 0)
741 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700742 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800743 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600744 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600745
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600746 apq8064_device_qup_spi_gsbi5.dev.platform_data =
747 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800748 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700749 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700750 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700751 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530752 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600753 slim_register_board_info(apq8064_slim_devices,
754 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755}
756
757static void __init apq8064_sim_init(void)
758{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700759 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
760 &msm8064_device_watchdog.dev.platform_data;
761
762 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700763 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700764 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
765}
766
767static void __init apq8064_rumi3_init(void)
768{
769 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700770 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700771 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700772 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700773}
774
Joel King82b7e3f2012-01-05 10:03:27 -0800775static void __init apq8064_cdp_init(void)
776{
777 apq8064_common_init();
778 ethernet_init();
779 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
780 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
781}
782
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700783MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
784 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700785 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700786 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530787 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700788 .timer = &msm_timer,
789 .init_machine = apq8064_sim_init,
790MACHINE_END
791
Joel King4e7ad222011-08-17 15:47:38 -0700792MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
793 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700794 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700795 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530796 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700797 .timer = &msm_timer,
798 .init_machine = apq8064_rumi3_init,
799MACHINE_END
800
Joel King82b7e3f2012-01-05 10:03:27 -0800801MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
802 .map_io = apq8064_map_io,
803 .reserve = apq8064_reserve,
804 .init_irq = apq8064_init_irq,
805 .handle_irq = gic_handle_irq,
806 .timer = &msm_timer,
807 .init_machine = apq8064_cdp_init,
808MACHINE_END
809
810MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
811 .map_io = apq8064_map_io,
812 .reserve = apq8064_reserve,
813 .init_irq = apq8064_init_irq,
814 .handle_irq = gic_handle_irq,
815 .timer = &msm_timer,
816 .init_machine = apq8064_cdp_init,
817MACHINE_END
818
819MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
820 .map_io = apq8064_map_io,
821 .reserve = apq8064_reserve,
822 .init_irq = apq8064_init_irq,
823 .handle_irq = gic_handle_irq,
824 .timer = &msm_timer,
825 .init_machine = apq8064_cdp_init,
826MACHINE_END
827