blob: 01922921dd32faa5215985057949cedc7fbce6c4 [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
Olav Haugand3d29682012-01-19 10:57:07 -080066#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -080067#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
68#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugand3d29682012-01-19 10:57:07 -080069#define MSM_ION_HEAP_NUM 6
Olav Haugan7c6aa742012-01-16 16:47:37 -080070#else
71#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
72#define MSM_ION_HEAP_NUM 1
73#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070074
Olav Haugan7c6aa742012-01-16 16:47:37 -080075#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
76static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
77static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070078{
Olav Haugan7c6aa742012-01-16 16:47:37 -080079 pmem_kernel_ebi1_size = memparse(p, NULL);
80 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070081}
Olav Haugan7c6aa742012-01-16 16:47:37 -080082early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
83#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070084
Olav Haugan7c6aa742012-01-16 16:47:37 -080085#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070086static unsigned pmem_size = MSM_PMEM_SIZE;
87static int __init pmem_size_setup(char *p)
88{
89 pmem_size = memparse(p, NULL);
90 return 0;
91}
92early_param("pmem_size", pmem_size_setup);
93
94static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
95
96static int __init pmem_adsp_size_setup(char *p)
97{
98 pmem_adsp_size = memparse(p, NULL);
99 return 0;
100}
101early_param("pmem_adsp_size", pmem_adsp_size_setup);
102
103static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
104
105static int __init pmem_audio_size_setup(char *p)
106{
107 pmem_audio_size = memparse(p, NULL);
108 return 0;
109}
110early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800111#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700112
Olav Haugan7c6aa742012-01-16 16:47:37 -0800113#ifdef CONFIG_ANDROID_PMEM
114#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700115static struct android_pmem_platform_data android_pmem_pdata = {
116 .name = "pmem",
117 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
118 .cached = 1,
119 .memory_type = MEMTYPE_EBI1,
120};
121
122static struct platform_device android_pmem_device = {
123 .name = "android_pmem",
124 .id = 0,
125 .dev = {.platform_data = &android_pmem_pdata},
126};
127
128static struct android_pmem_platform_data android_pmem_adsp_pdata = {
129 .name = "pmem_adsp",
130 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
131 .cached = 0,
132 .memory_type = MEMTYPE_EBI1,
133};
Kevin Chan13be4e22011-10-20 11:30:32 -0700134static struct platform_device android_pmem_adsp_device = {
135 .name = "android_pmem",
136 .id = 2,
137 .dev = { .platform_data = &android_pmem_adsp_pdata },
138};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800139#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700140
141static struct android_pmem_platform_data android_pmem_audio_pdata = {
142 .name = "pmem_audio",
143 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
144 .cached = 0,
145 .memory_type = MEMTYPE_EBI1,
146};
147
148static struct platform_device android_pmem_audio_device = {
149 .name = "android_pmem",
150 .id = 4,
151 .dev = { .platform_data = &android_pmem_audio_pdata },
152};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800153#endif
154
155static struct memtype_reserve apq8064_reserve_table[] __initdata = {
156 [MEMTYPE_SMI] = {
157 },
158 [MEMTYPE_EBI0] = {
159 .flags = MEMTYPE_FLAGS_1M_ALIGN,
160 },
161 [MEMTYPE_EBI1] = {
162 .flags = MEMTYPE_FLAGS_1M_ALIGN,
163 },
164};
Kevin Chan13be4e22011-10-20 11:30:32 -0700165
166static void __init size_pmem_devices(void)
167{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800168#ifdef CONFIG_ANDROID_PMEM
169#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700170 android_pmem_adsp_pdata.size = pmem_adsp_size;
171 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800172#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700173 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800174#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700175}
176
177static void __init reserve_memory_for(struct android_pmem_platform_data *p)
178{
179 apq8064_reserve_table[p->memory_type].size += p->size;
180}
181
Kevin Chan13be4e22011-10-20 11:30:32 -0700182static void __init reserve_pmem_memory(void)
183{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800184#ifdef CONFIG_ANDROID_PMEM
185#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700186 reserve_memory_for(&android_pmem_adsp_pdata);
187 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800188#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700189 reserve_memory_for(&android_pmem_audio_pdata);
190 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800191#endif
192}
193
194static int apq8064_paddr_to_memtype(unsigned int paddr)
195{
196 return MEMTYPE_EBI1;
197}
198
199#ifdef CONFIG_ION_MSM
200#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
201static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
202 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800203 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800204};
205
206static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
207 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800208 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800209};
210
211static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800212 .adjacent_mem_id = INVALID_HEAP_ID,
213 .align = PAGE_SIZE,
214};
215
216static struct ion_co_heap_pdata fw_co_ion_pdata = {
217 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
218 .align = SZ_128K,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800219};
220#endif
221static struct ion_platform_data ion_pdata = {
222 .nr = MSM_ION_HEAP_NUM,
223 .heaps = {
224 {
225 .id = ION_SYSTEM_HEAP_ID,
226 .type = ION_HEAP_TYPE_SYSTEM,
227 .name = ION_VMALLOC_HEAP_NAME,
228 },
229#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
230 {
231 .id = ION_SF_HEAP_ID,
232 .type = ION_HEAP_TYPE_CARVEOUT,
233 .name = ION_SF_HEAP_NAME,
234 .size = MSM_ION_SF_SIZE,
235 .memory_type = ION_EBI_TYPE,
236 .extra_data = (void *) &co_ion_pdata,
237 },
238 {
239 .id = ION_CP_MM_HEAP_ID,
240 .type = ION_HEAP_TYPE_CP,
241 .name = ION_MM_HEAP_NAME,
242 .size = MSM_ION_MM_SIZE,
243 .memory_type = ION_EBI_TYPE,
244 .extra_data = (void *) &cp_mm_ion_pdata,
245 },
246 {
Olav Haugand3d29682012-01-19 10:57:07 -0800247 .id = ION_MM_FIRMWARE_HEAP_ID,
248 .type = ION_HEAP_TYPE_CARVEOUT,
249 .name = ION_MM_FIRMWARE_HEAP_NAME,
250 .size = MSM_ION_MM_FW_SIZE,
251 .memory_type = ION_EBI_TYPE,
252 .extra_data = (void *) &fw_co_ion_pdata,
253 },
254 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800255 .id = ION_CP_MFC_HEAP_ID,
256 .type = ION_HEAP_TYPE_CP,
257 .name = ION_MFC_HEAP_NAME,
258 .size = MSM_ION_MFC_SIZE,
259 .memory_type = ION_EBI_TYPE,
260 .extra_data = (void *) &cp_mfc_ion_pdata,
261 },
262 {
263 .id = ION_IOMMU_HEAP_ID,
264 .type = ION_HEAP_TYPE_IOMMU,
265 .name = ION_IOMMU_HEAP_NAME,
266 },
267#endif
268 }
269};
270
271static struct platform_device ion_dev = {
272 .name = "ion-msm",
273 .id = 1,
274 .dev = { .platform_data = &ion_pdata },
275};
276#endif
277
278static void reserve_ion_memory(void)
279{
280#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
281 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
Olav Haugand3d29682012-01-19 10:57:07 -0800282 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800283 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
284 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
285#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700286}
287
288static void __init apq8064_calculate_reserve_sizes(void)
289{
290 size_pmem_devices();
291 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800292 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700293}
294
295static struct reserve_info apq8064_reserve_info __initdata = {
296 .memtype_reserve_table = apq8064_reserve_table,
297 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
298 .paddr_to_memtype = apq8064_paddr_to_memtype,
299};
300
301static int apq8064_memory_bank_size(void)
302{
303 return 1<<29;
304}
305
306static void __init locate_unstable_memory(void)
307{
308 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
309 unsigned long bank_size;
310 unsigned long low, high;
311
312 bank_size = apq8064_memory_bank_size();
313 low = meminfo.bank[0].start;
314 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800315
316 /* Check if 32 bit overflow occured */
317 if (high < mb->start)
318 high = ~0UL;
319
Kevin Chan13be4e22011-10-20 11:30:32 -0700320 low &= ~(bank_size - 1);
321
322 if (high - low <= bank_size)
323 return;
Jack Cheung46bfffa2012-01-19 15:26:24 -0800324 apq8064_reserve_info.low_unstable_address = mb->start -
325 MIN_MEMORY_BLOCK_SIZE + mb->size;
326 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
327
Kevin Chan13be4e22011-10-20 11:30:32 -0700328 apq8064_reserve_info.bank_size = bank_size;
329 pr_info("low unstable address %lx max size %lx bank size %lx\n",
330 apq8064_reserve_info.low_unstable_address,
331 apq8064_reserve_info.max_unstable_size,
332 apq8064_reserve_info.bank_size);
333}
334
335static void __init apq8064_reserve(void)
336{
337 reserve_info = &apq8064_reserve_info;
338 locate_unstable_memory();
339 msm_reserve();
340}
341
Hemant Kumar4933b072011-10-17 23:43:11 -0700342static struct platform_device android_usb_device = {
343 .name = "android_usb",
344 .id = -1,
345};
346
347static struct msm_otg_platform_data msm_otg_pdata = {
348 .mode = USB_PERIPHERAL,
349 .otg_control = OTG_PHY_CONTROL,
350 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700351};
352
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800353#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
354
355/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
356 * 4 micbiases are used to power various analog and digital
357 * microphones operating at 1800 mV. Technically, all micbiases
358 * can source from single cfilter since all microphones operate
359 * at the same voltage level. The arrangement below is to make
360 * sure all cfilters are exercised. LDO_H regulator ouput level
361 * does not need to be as high as 2.85V. It is choosen for
362 * microphone sensitivity purpose.
363 */
364static struct tabla_pdata apq8064_tabla_platform_data = {
365 .slimbus_slave_device = {
366 .name = "tabla-slave",
367 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
368 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800369 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800370 .irq_base = TABLA_INTERRUPT_BASE,
371 .num_irqs = NR_TABLA_IRQS,
372 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
373 .micbias = {
374 .ldoh_v = TABLA_LDOH_2P85_V,
375 .cfilt1_mv = 1800,
376 .cfilt2_mv = 1800,
377 .cfilt3_mv = 1800,
378 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
379 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
380 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
381 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
382 }
383};
384
385static struct slim_device apq8064_slim_tabla = {
386 .name = "tabla-slim",
387 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
388 .dev = {
389 .platform_data = &apq8064_tabla_platform_data,
390 },
391};
392
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800393static struct tabla_pdata apq8064_tabla20_platform_data = {
394 .slimbus_slave_device = {
395 .name = "tabla-slave",
396 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
397 },
398 .irq = MSM_GPIO_TO_INT(42),
399 .irq_base = TABLA_INTERRUPT_BASE,
400 .num_irqs = NR_TABLA_IRQS,
401 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
402 .micbias = {
403 .ldoh_v = TABLA_LDOH_2P85_V,
404 .cfilt1_mv = 1800,
405 .cfilt2_mv = 1800,
406 .cfilt3_mv = 1800,
407 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
408 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
409 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
410 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
411 }
412};
413
414static struct slim_device apq8064_slim_tabla20 = {
415 .name = "tabla2x-slim",
416 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
417 .dev = {
418 .platform_data = &apq8064_tabla20_platform_data,
419 },
420};
421
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700422#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
423 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
424 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
425 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
426
427#define QCE_SIZE 0x10000
428#define QCE_0_BASE 0x11000000
429
430#define QCE_HW_KEY_SUPPORT 0
431#define QCE_SHA_HMAC_SUPPORT 1
432#define QCE_SHARE_CE_RESOURCE 3
433#define QCE_CE_SHARED 0
434
435static struct resource qcrypto_resources[] = {
436 [0] = {
437 .start = QCE_0_BASE,
438 .end = QCE_0_BASE + QCE_SIZE - 1,
439 .flags = IORESOURCE_MEM,
440 },
441 [1] = {
442 .name = "crypto_channels",
443 .start = DMOV8064_CE_IN_CHAN,
444 .end = DMOV8064_CE_OUT_CHAN,
445 .flags = IORESOURCE_DMA,
446 },
447 [2] = {
448 .name = "crypto_crci_in",
449 .start = DMOV8064_CE_IN_CRCI,
450 .end = DMOV8064_CE_IN_CRCI,
451 .flags = IORESOURCE_DMA,
452 },
453 [3] = {
454 .name = "crypto_crci_out",
455 .start = DMOV8064_CE_OUT_CRCI,
456 .end = DMOV8064_CE_OUT_CRCI,
457 .flags = IORESOURCE_DMA,
458 },
459};
460
461static struct resource qcedev_resources[] = {
462 [0] = {
463 .start = QCE_0_BASE,
464 .end = QCE_0_BASE + QCE_SIZE - 1,
465 .flags = IORESOURCE_MEM,
466 },
467 [1] = {
468 .name = "crypto_channels",
469 .start = DMOV8064_CE_IN_CHAN,
470 .end = DMOV8064_CE_OUT_CHAN,
471 .flags = IORESOURCE_DMA,
472 },
473 [2] = {
474 .name = "crypto_crci_in",
475 .start = DMOV8064_CE_IN_CRCI,
476 .end = DMOV8064_CE_IN_CRCI,
477 .flags = IORESOURCE_DMA,
478 },
479 [3] = {
480 .name = "crypto_crci_out",
481 .start = DMOV8064_CE_OUT_CRCI,
482 .end = DMOV8064_CE_OUT_CRCI,
483 .flags = IORESOURCE_DMA,
484 },
485};
486
487#endif
488
489#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
490 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
491
492static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
493 .ce_shared = QCE_CE_SHARED,
494 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
495 .hw_key_support = QCE_HW_KEY_SUPPORT,
496 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800497 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700498};
499
500static struct platform_device qcrypto_device = {
501 .name = "qcrypto",
502 .id = 0,
503 .num_resources = ARRAY_SIZE(qcrypto_resources),
504 .resource = qcrypto_resources,
505 .dev = {
506 .coherent_dma_mask = DMA_BIT_MASK(32),
507 .platform_data = &qcrypto_ce_hw_suppport,
508 },
509};
510#endif
511
512#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
513 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
514
515static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
516 .ce_shared = QCE_CE_SHARED,
517 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
518 .hw_key_support = QCE_HW_KEY_SUPPORT,
519 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800520 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700521};
522
523static struct platform_device qcedev_device = {
524 .name = "qce",
525 .id = 0,
526 .num_resources = ARRAY_SIZE(qcedev_resources),
527 .resource = qcedev_resources,
528 .dev = {
529 .coherent_dma_mask = DMA_BIT_MASK(32),
530 .platform_data = &qcedev_ce_hw_suppport,
531 },
532};
533#endif
534
535
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600536#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700537static void __init apq8064_map_io(void)
538{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600539 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700540 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700541 if (socinfo_init() < 0)
542 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700543}
544
545static void __init apq8064_init_irq(void)
546{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700547 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
548 (void *)MSM_QGIC_CPU_BASE);
549
550 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
551 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
552
553 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
554 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700555}
556
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800557static struct platform_device msm8064_device_saw_regulator_core0 = {
558 .name = "saw-regulator",
559 .id = 0,
560 .dev = {
561 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
562 },
563};
564
565static struct platform_device msm8064_device_saw_regulator_core1 = {
566 .name = "saw-regulator",
567 .id = 1,
568 .dev = {
569 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
570 },
571};
572
573static struct platform_device msm8064_device_saw_regulator_core2 = {
574 .name = "saw-regulator",
575 .id = 2,
576 .dev = {
577 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
578 },
579};
580
581static struct platform_device msm8064_device_saw_regulator_core3 = {
582 .name = "saw-regulator",
583 .id = 3,
584 .dev = {
585 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
586 },
587};
588
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700589static void __init apq8064_init_buses(void)
590{
591 msm_bus_rpm_set_mt_mask();
592 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
593 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
594 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
595 msm_bus_8064_apps_fabric.dev.platform_data =
596 &msm_bus_8064_apps_fabric_pdata;
597 msm_bus_8064_sys_fabric.dev.platform_data =
598 &msm_bus_8064_sys_fabric_pdata;
599 msm_bus_8064_mm_fabric.dev.platform_data =
600 &msm_bus_8064_mm_fabric_pdata;
601 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
602 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
603}
604
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700605static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700606 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600607 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600608 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600609 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700610 &apq8064_device_ssbi_pmic1,
611 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600612 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700613 &apq8064_device_otg,
614 &apq8064_device_gadget_peripheral,
615 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800616#ifdef CONFIG_ANDROID_PMEM
617#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700618 &android_pmem_device,
619 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800620#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700621 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800622#endif
623#ifdef CONFIG_ION_MSM
624 &ion_dev,
625#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700626 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800627 &msm8064_device_saw_regulator_core0,
628 &msm8064_device_saw_regulator_core1,
629 &msm8064_device_saw_regulator_core2,
630 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700631#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
632 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
633 &qcrypto_device,
634#endif
635
636#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
637 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
638 &qcedev_device,
639#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700640
641#ifdef CONFIG_HW_RANDOM_MSM
642 &apq8064_device_rng,
643#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800644 &apq_pcm,
645 &apq_pcm_routing,
646 &apq_cpudai0,
647 &apq_cpudai1,
648 &apq_cpudai_hdmi_rx,
649 &apq_cpudai_bt_rx,
650 &apq_cpudai_bt_tx,
651 &apq_cpudai_fm_rx,
652 &apq_cpudai_fm_tx,
653 &apq_cpu_fe,
654 &apq_stub_codec,
655 &apq_voice,
656 &apq_voip,
657 &apq_lpa_pcm,
658 &apq_pcm_hostless,
659 &apq_cpudai_afe_01_rx,
660 &apq_cpudai_afe_01_tx,
661 &apq_cpudai_afe_02_rx,
662 &apq_cpudai_afe_02_tx,
663 &apq_pcm_afe,
664 &apq_cpudai_auxpcm_rx,
665 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700666 &msm_bus_8064_apps_fabric,
667 &msm_bus_8064_sys_fabric,
668 &msm_bus_8064_mm_fabric,
669 &msm_bus_8064_sys_fpb,
670 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600671};
672
Joel King4e7ad222011-08-17 15:47:38 -0700673static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700674 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700675 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700676};
677
678static struct platform_device *rumi3_devices[] __initdata = {
679 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800680 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700681};
682
Joel King82b7e3f2012-01-05 10:03:27 -0800683static struct platform_device *cdp_devices[] __initdata = {
684 &apq8064_device_uart_gsbi1,
685 &msm_device_sps_apq8064,
686};
687
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600688static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700689 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700690};
691
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700692#define KS8851_IRQ_GPIO 43
693
694static struct spi_board_info spi_board_info[] __initdata = {
695 {
696 .modalias = "ks8851",
697 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
698 .max_speed_hz = 19200000,
699 .bus_num = 0,
700 .chip_select = 2,
701 .mode = SPI_MODE_0,
702 },
703};
704
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600705static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800706 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800707 .bus_num = 1,
708 .slim_slave = &apq8064_slim_tabla,
709 },
710 {
711 .bus_num = 1,
712 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800713 },
714 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600715};
716
Kenneth Heitke748593a2011-07-15 15:45:11 -0600717static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
718 .clk_freq = 100000,
719 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600720};
721
722static void __init apq8064_i2c_init(void)
723{
724 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
725 &apq8064_i2c_qup_gsbi4_pdata;
726}
727
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700728#ifdef CONFIG_KS8851
729static int ethernet_init(void)
730{
731 int ret;
732 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
733 if (ret) {
734 pr_err("ks8851 gpio_request failed: %d\n", ret);
735 goto fail;
736 }
737
738 return 0;
739fail:
740 return ret;
741}
742#else
743static int ethernet_init(void)
744{
745 return 0;
746}
747#endif
748
Tianyi Gou41515e22011-09-01 19:37:43 -0700749static void __init apq8064_clock_init(void)
750{
751 if (machine_is_apq8064_sim())
752 msm_clock_init(&apq8064_clock_init_data);
753 else
754 msm_clock_init(&apq8064_dummy_clock_init_data);
755}
756
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757static void __init apq8064_common_init(void)
758{
759 if (socinfo_init() < 0)
760 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700761 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800762 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600763 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600764
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600765 apq8064_device_qup_spi_gsbi5.dev.platform_data =
766 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800767 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700768 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700769 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700770 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530771 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600772 slim_register_board_info(apq8064_slim_devices,
773 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700774}
775
776static void __init apq8064_sim_init(void)
777{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700778 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
779 &msm8064_device_watchdog.dev.platform_data;
780
781 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700782 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700783 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
784}
785
786static void __init apq8064_rumi3_init(void)
787{
788 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700789 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700790 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700791 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700792}
793
Joel King82b7e3f2012-01-05 10:03:27 -0800794static void __init apq8064_cdp_init(void)
795{
796 apq8064_common_init();
797 ethernet_init();
798 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
799 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
800}
801
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
803 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700804 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530806 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700807 .timer = &msm_timer,
808 .init_machine = apq8064_sim_init,
809MACHINE_END
810
Joel King4e7ad222011-08-17 15:47:38 -0700811MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
812 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700813 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700814 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530815 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700816 .timer = &msm_timer,
817 .init_machine = apq8064_rumi3_init,
818MACHINE_END
819
Joel King82b7e3f2012-01-05 10:03:27 -0800820MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
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
829MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
830 .map_io = apq8064_map_io,
831 .reserve = apq8064_reserve,
832 .init_irq = apq8064_init_irq,
833 .handle_irq = gic_handle_irq,
834 .timer = &msm_timer,
835 .init_machine = apq8064_cdp_init,
836MACHINE_END
837
838MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
839 .map_io = apq8064_map_io,
840 .reserve = apq8064_reserve,
841 .init_irq = apq8064_init_irq,
842 .handle_irq = gic_handle_irq,
843 .timer = &msm_timer,
844 .init_machine = apq8064_cdp_init,
845MACHINE_END
846