blob: 187b92ee59219ebefedd4d83b752e27451b04dd8 [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"
Vikram Mulukutlabc2e9572011-11-04 03:41:38 -070054#include "acpuclock.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070055
Olav Haugan7c6aa742012-01-16 16:47:37 -080056#define MSM_PMEM_ADSP_SIZE 0x7800000
Ben Romberger3ffcd812011-12-08 19:12:10 -080057#define MSM_PMEM_AUDIO_SIZE 0x2B4000
Olav Haugan7c6aa742012-01-16 16:47:37 -080058#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
59#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
60#else
61#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
62#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070063
Olav Haugan7c6aa742012-01-16 16:47:37 -080064#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
65#define MSM_PMEM_KERNEL_EBI1_SIZE 0xB0C000
66#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Haugand3d29682012-01-19 10:57:07 -080067#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -080068#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
Olav Hauganf45e2142012-01-19 11:01:01 -080069#define MSM_ION_QSECOM_SIZE 0x100000 /* (1MB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -080070#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan2c43fac2012-01-19 11:06:37 -080071#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
72#define MSM_ION_HEAP_NUM 8
Olav Haugan7c6aa742012-01-16 16:47:37 -080073#else
74#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
75#define MSM_ION_HEAP_NUM 1
76#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070077
Olav Haugan7c6aa742012-01-16 16:47:37 -080078#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
79static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
80static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070081{
Olav Haugan7c6aa742012-01-16 16:47:37 -080082 pmem_kernel_ebi1_size = memparse(p, NULL);
83 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070084}
Olav Haugan7c6aa742012-01-16 16:47:37 -080085early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
86#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070087
Olav Haugan7c6aa742012-01-16 16:47:37 -080088#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070089static unsigned pmem_size = MSM_PMEM_SIZE;
90static int __init pmem_size_setup(char *p)
91{
92 pmem_size = memparse(p, NULL);
93 return 0;
94}
95early_param("pmem_size", pmem_size_setup);
96
97static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
98
99static int __init pmem_adsp_size_setup(char *p)
100{
101 pmem_adsp_size = memparse(p, NULL);
102 return 0;
103}
104early_param("pmem_adsp_size", pmem_adsp_size_setup);
105
106static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
107
108static int __init pmem_audio_size_setup(char *p)
109{
110 pmem_audio_size = memparse(p, NULL);
111 return 0;
112}
113early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800114#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700115
Olav Haugan7c6aa742012-01-16 16:47:37 -0800116#ifdef CONFIG_ANDROID_PMEM
117#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700118static struct android_pmem_platform_data android_pmem_pdata = {
119 .name = "pmem",
120 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
121 .cached = 1,
122 .memory_type = MEMTYPE_EBI1,
123};
124
125static struct platform_device android_pmem_device = {
126 .name = "android_pmem",
127 .id = 0,
128 .dev = {.platform_data = &android_pmem_pdata},
129};
130
131static struct android_pmem_platform_data android_pmem_adsp_pdata = {
132 .name = "pmem_adsp",
133 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
134 .cached = 0,
135 .memory_type = MEMTYPE_EBI1,
136};
Kevin Chan13be4e22011-10-20 11:30:32 -0700137static struct platform_device android_pmem_adsp_device = {
138 .name = "android_pmem",
139 .id = 2,
140 .dev = { .platform_data = &android_pmem_adsp_pdata },
141};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800142#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700143
144static struct android_pmem_platform_data android_pmem_audio_pdata = {
145 .name = "pmem_audio",
146 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
147 .cached = 0,
148 .memory_type = MEMTYPE_EBI1,
149};
150
151static struct platform_device android_pmem_audio_device = {
152 .name = "android_pmem",
153 .id = 4,
154 .dev = { .platform_data = &android_pmem_audio_pdata },
155};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800156#endif
157
158static struct memtype_reserve apq8064_reserve_table[] __initdata = {
159 [MEMTYPE_SMI] = {
160 },
161 [MEMTYPE_EBI0] = {
162 .flags = MEMTYPE_FLAGS_1M_ALIGN,
163 },
164 [MEMTYPE_EBI1] = {
165 .flags = MEMTYPE_FLAGS_1M_ALIGN,
166 },
167};
Kevin Chan13be4e22011-10-20 11:30:32 -0700168
169static void __init size_pmem_devices(void)
170{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800171#ifdef CONFIG_ANDROID_PMEM
172#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700173 android_pmem_adsp_pdata.size = pmem_adsp_size;
174 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800175#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700176 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800177#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700178}
179
180static void __init reserve_memory_for(struct android_pmem_platform_data *p)
181{
182 apq8064_reserve_table[p->memory_type].size += p->size;
183}
184
Kevin Chan13be4e22011-10-20 11:30:32 -0700185static void __init reserve_pmem_memory(void)
186{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800187#ifdef CONFIG_ANDROID_PMEM
188#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700189 reserve_memory_for(&android_pmem_adsp_pdata);
190 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800191#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700192 reserve_memory_for(&android_pmem_audio_pdata);
193 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800194#endif
195}
196
197static int apq8064_paddr_to_memtype(unsigned int paddr)
198{
199 return MEMTYPE_EBI1;
200}
201
202#ifdef CONFIG_ION_MSM
203#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
204static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
205 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800206 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800207};
208
209static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
210 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800211 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800212};
213
214static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800215 .adjacent_mem_id = INVALID_HEAP_ID,
216 .align = PAGE_SIZE,
217};
218
219static struct ion_co_heap_pdata fw_co_ion_pdata = {
220 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
221 .align = SZ_128K,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800222};
223#endif
224static struct ion_platform_data ion_pdata = {
225 .nr = MSM_ION_HEAP_NUM,
226 .heaps = {
227 {
228 .id = ION_SYSTEM_HEAP_ID,
229 .type = ION_HEAP_TYPE_SYSTEM,
230 .name = ION_VMALLOC_HEAP_NAME,
231 },
232#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
233 {
234 .id = ION_SF_HEAP_ID,
235 .type = ION_HEAP_TYPE_CARVEOUT,
236 .name = ION_SF_HEAP_NAME,
237 .size = MSM_ION_SF_SIZE,
238 .memory_type = ION_EBI_TYPE,
239 .extra_data = (void *) &co_ion_pdata,
240 },
241 {
242 .id = ION_CP_MM_HEAP_ID,
243 .type = ION_HEAP_TYPE_CP,
244 .name = ION_MM_HEAP_NAME,
245 .size = MSM_ION_MM_SIZE,
246 .memory_type = ION_EBI_TYPE,
247 .extra_data = (void *) &cp_mm_ion_pdata,
248 },
249 {
Olav Haugand3d29682012-01-19 10:57:07 -0800250 .id = ION_MM_FIRMWARE_HEAP_ID,
251 .type = ION_HEAP_TYPE_CARVEOUT,
252 .name = ION_MM_FIRMWARE_HEAP_NAME,
253 .size = MSM_ION_MM_FW_SIZE,
254 .memory_type = ION_EBI_TYPE,
255 .extra_data = (void *) &fw_co_ion_pdata,
256 },
257 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800258 .id = ION_CP_MFC_HEAP_ID,
259 .type = ION_HEAP_TYPE_CP,
260 .name = ION_MFC_HEAP_NAME,
261 .size = MSM_ION_MFC_SIZE,
262 .memory_type = ION_EBI_TYPE,
263 .extra_data = (void *) &cp_mfc_ion_pdata,
264 },
265 {
266 .id = ION_IOMMU_HEAP_ID,
267 .type = ION_HEAP_TYPE_IOMMU,
268 .name = ION_IOMMU_HEAP_NAME,
269 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800270 {
271 .id = ION_QSECOM_HEAP_ID,
272 .type = ION_HEAP_TYPE_CARVEOUT,
273 .name = ION_QSECOM_HEAP_NAME,
274 .size = MSM_ION_QSECOM_SIZE,
275 .memory_type = ION_EBI_TYPE,
276 .extra_data = (void *) &co_ion_pdata,
277 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800278 {
279 .id = ION_AUDIO_HEAP_ID,
280 .type = ION_HEAP_TYPE_CARVEOUT,
281 .name = ION_AUDIO_HEAP_NAME,
282 .size = MSM_ION_AUDIO_SIZE,
283 .memory_type = ION_EBI_TYPE,
284 .extra_data = (void *) &co_ion_pdata,
285 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800286#endif
287 }
288};
289
290static struct platform_device ion_dev = {
291 .name = "ion-msm",
292 .id = 1,
293 .dev = { .platform_data = &ion_pdata },
294};
295#endif
296
297static void reserve_ion_memory(void)
298{
299#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
300 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
Olav Haugand3d29682012-01-19 10:57:07 -0800301 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800302 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
303 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
Olav Hauganf45e2142012-01-19 11:01:01 -0800304 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Olav Haugan2c43fac2012-01-19 11:06:37 -0800305 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800306#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700307}
308
309static void __init apq8064_calculate_reserve_sizes(void)
310{
311 size_pmem_devices();
312 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800313 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700314}
315
316static struct reserve_info apq8064_reserve_info __initdata = {
317 .memtype_reserve_table = apq8064_reserve_table,
318 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
319 .paddr_to_memtype = apq8064_paddr_to_memtype,
320};
321
322static int apq8064_memory_bank_size(void)
323{
324 return 1<<29;
325}
326
327static void __init locate_unstable_memory(void)
328{
329 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
330 unsigned long bank_size;
331 unsigned long low, high;
332
333 bank_size = apq8064_memory_bank_size();
334 low = meminfo.bank[0].start;
335 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800336
337 /* Check if 32 bit overflow occured */
338 if (high < mb->start)
339 high = ~0UL;
340
Kevin Chan13be4e22011-10-20 11:30:32 -0700341 low &= ~(bank_size - 1);
342
343 if (high - low <= bank_size)
344 return;
Jack Cheung46bfffa2012-01-19 15:26:24 -0800345 apq8064_reserve_info.low_unstable_address = mb->start -
346 MIN_MEMORY_BLOCK_SIZE + mb->size;
347 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
348
Kevin Chan13be4e22011-10-20 11:30:32 -0700349 apq8064_reserve_info.bank_size = bank_size;
350 pr_info("low unstable address %lx max size %lx bank size %lx\n",
351 apq8064_reserve_info.low_unstable_address,
352 apq8064_reserve_info.max_unstable_size,
353 apq8064_reserve_info.bank_size);
354}
355
356static void __init apq8064_reserve(void)
357{
358 reserve_info = &apq8064_reserve_info;
359 locate_unstable_memory();
360 msm_reserve();
361}
362
Hemant Kumar4933b072011-10-17 23:43:11 -0700363static struct platform_device android_usb_device = {
364 .name = "android_usb",
365 .id = -1,
366};
367
368static struct msm_otg_platform_data msm_otg_pdata = {
369 .mode = USB_PERIPHERAL,
370 .otg_control = OTG_PHY_CONTROL,
371 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700372};
373
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800374#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
375
376/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
377 * 4 micbiases are used to power various analog and digital
378 * microphones operating at 1800 mV. Technically, all micbiases
379 * can source from single cfilter since all microphones operate
380 * at the same voltage level. The arrangement below is to make
381 * sure all cfilters are exercised. LDO_H regulator ouput level
382 * does not need to be as high as 2.85V. It is choosen for
383 * microphone sensitivity purpose.
384 */
385static struct tabla_pdata apq8064_tabla_platform_data = {
386 .slimbus_slave_device = {
387 .name = "tabla-slave",
388 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
389 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800390 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800391 .irq_base = TABLA_INTERRUPT_BASE,
392 .num_irqs = NR_TABLA_IRQS,
393 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
394 .micbias = {
395 .ldoh_v = TABLA_LDOH_2P85_V,
396 .cfilt1_mv = 1800,
397 .cfilt2_mv = 1800,
398 .cfilt3_mv = 1800,
399 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
400 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
401 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
402 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
403 }
404};
405
406static struct slim_device apq8064_slim_tabla = {
407 .name = "tabla-slim",
408 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
409 .dev = {
410 .platform_data = &apq8064_tabla_platform_data,
411 },
412};
413
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800414static struct tabla_pdata apq8064_tabla20_platform_data = {
415 .slimbus_slave_device = {
416 .name = "tabla-slave",
417 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
418 },
419 .irq = MSM_GPIO_TO_INT(42),
420 .irq_base = TABLA_INTERRUPT_BASE,
421 .num_irqs = NR_TABLA_IRQS,
422 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
423 .micbias = {
424 .ldoh_v = TABLA_LDOH_2P85_V,
425 .cfilt1_mv = 1800,
426 .cfilt2_mv = 1800,
427 .cfilt3_mv = 1800,
428 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
429 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
430 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
431 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
432 }
433};
434
435static struct slim_device apq8064_slim_tabla20 = {
436 .name = "tabla2x-slim",
437 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
438 .dev = {
439 .platform_data = &apq8064_tabla20_platform_data,
440 },
441};
442
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700443#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
444 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
445 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
446 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
447
448#define QCE_SIZE 0x10000
449#define QCE_0_BASE 0x11000000
450
451#define QCE_HW_KEY_SUPPORT 0
452#define QCE_SHA_HMAC_SUPPORT 1
453#define QCE_SHARE_CE_RESOURCE 3
454#define QCE_CE_SHARED 0
455
456static struct resource qcrypto_resources[] = {
457 [0] = {
458 .start = QCE_0_BASE,
459 .end = QCE_0_BASE + QCE_SIZE - 1,
460 .flags = IORESOURCE_MEM,
461 },
462 [1] = {
463 .name = "crypto_channels",
464 .start = DMOV8064_CE_IN_CHAN,
465 .end = DMOV8064_CE_OUT_CHAN,
466 .flags = IORESOURCE_DMA,
467 },
468 [2] = {
469 .name = "crypto_crci_in",
470 .start = DMOV8064_CE_IN_CRCI,
471 .end = DMOV8064_CE_IN_CRCI,
472 .flags = IORESOURCE_DMA,
473 },
474 [3] = {
475 .name = "crypto_crci_out",
476 .start = DMOV8064_CE_OUT_CRCI,
477 .end = DMOV8064_CE_OUT_CRCI,
478 .flags = IORESOURCE_DMA,
479 },
480};
481
482static struct resource qcedev_resources[] = {
483 [0] = {
484 .start = QCE_0_BASE,
485 .end = QCE_0_BASE + QCE_SIZE - 1,
486 .flags = IORESOURCE_MEM,
487 },
488 [1] = {
489 .name = "crypto_channels",
490 .start = DMOV8064_CE_IN_CHAN,
491 .end = DMOV8064_CE_OUT_CHAN,
492 .flags = IORESOURCE_DMA,
493 },
494 [2] = {
495 .name = "crypto_crci_in",
496 .start = DMOV8064_CE_IN_CRCI,
497 .end = DMOV8064_CE_IN_CRCI,
498 .flags = IORESOURCE_DMA,
499 },
500 [3] = {
501 .name = "crypto_crci_out",
502 .start = DMOV8064_CE_OUT_CRCI,
503 .end = DMOV8064_CE_OUT_CRCI,
504 .flags = IORESOURCE_DMA,
505 },
506};
507
508#endif
509
510#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
511 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
512
513static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
514 .ce_shared = QCE_CE_SHARED,
515 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
516 .hw_key_support = QCE_HW_KEY_SUPPORT,
517 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800518 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700519};
520
521static struct platform_device qcrypto_device = {
522 .name = "qcrypto",
523 .id = 0,
524 .num_resources = ARRAY_SIZE(qcrypto_resources),
525 .resource = qcrypto_resources,
526 .dev = {
527 .coherent_dma_mask = DMA_BIT_MASK(32),
528 .platform_data = &qcrypto_ce_hw_suppport,
529 },
530};
531#endif
532
533#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
534 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
535
536static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
537 .ce_shared = QCE_CE_SHARED,
538 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
539 .hw_key_support = QCE_HW_KEY_SUPPORT,
540 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800541 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700542};
543
544static struct platform_device qcedev_device = {
545 .name = "qce",
546 .id = 0,
547 .num_resources = ARRAY_SIZE(qcedev_resources),
548 .resource = qcedev_resources,
549 .dev = {
550 .coherent_dma_mask = DMA_BIT_MASK(32),
551 .platform_data = &qcedev_ce_hw_suppport,
552 },
553};
554#endif
555
556
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600557#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700558static void __init apq8064_map_io(void)
559{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600560 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700561 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700562 if (socinfo_init() < 0)
563 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700564}
565
566static void __init apq8064_init_irq(void)
567{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700568 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
569 (void *)MSM_QGIC_CPU_BASE);
570
571 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
572 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
573
574 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
575 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700576}
577
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800578static struct platform_device msm8064_device_saw_regulator_core0 = {
579 .name = "saw-regulator",
580 .id = 0,
581 .dev = {
582 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
583 },
584};
585
586static struct platform_device msm8064_device_saw_regulator_core1 = {
587 .name = "saw-regulator",
588 .id = 1,
589 .dev = {
590 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
591 },
592};
593
594static struct platform_device msm8064_device_saw_regulator_core2 = {
595 .name = "saw-regulator",
596 .id = 2,
597 .dev = {
598 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
599 },
600};
601
602static struct platform_device msm8064_device_saw_regulator_core3 = {
603 .name = "saw-regulator",
604 .id = 3,
605 .dev = {
606 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
607 },
608};
609
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700610static void __init apq8064_init_buses(void)
611{
612 msm_bus_rpm_set_mt_mask();
613 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
614 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
615 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
616 msm_bus_8064_apps_fabric.dev.platform_data =
617 &msm_bus_8064_apps_fabric_pdata;
618 msm_bus_8064_sys_fabric.dev.platform_data =
619 &msm_bus_8064_sys_fabric_pdata;
620 msm_bus_8064_mm_fabric.dev.platform_data =
621 &msm_bus_8064_mm_fabric_pdata;
622 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
623 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
624}
625
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700626static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700627 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600628 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600629 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600630 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700631 &apq8064_device_ssbi_pmic1,
632 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600633 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700634 &apq8064_device_otg,
635 &apq8064_device_gadget_peripheral,
636 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800637#ifdef CONFIG_ANDROID_PMEM
638#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700639 &android_pmem_device,
640 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800641#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700642 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800643#endif
644#ifdef CONFIG_ION_MSM
645 &ion_dev,
646#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700647 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800648 &msm8064_device_saw_regulator_core0,
649 &msm8064_device_saw_regulator_core1,
650 &msm8064_device_saw_regulator_core2,
651 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700652#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
653 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
654 &qcrypto_device,
655#endif
656
657#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
658 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
659 &qcedev_device,
660#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700661
662#ifdef CONFIG_HW_RANDOM_MSM
663 &apq8064_device_rng,
664#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800665 &apq_pcm,
666 &apq_pcm_routing,
667 &apq_cpudai0,
668 &apq_cpudai1,
669 &apq_cpudai_hdmi_rx,
670 &apq_cpudai_bt_rx,
671 &apq_cpudai_bt_tx,
672 &apq_cpudai_fm_rx,
673 &apq_cpudai_fm_tx,
674 &apq_cpu_fe,
675 &apq_stub_codec,
676 &apq_voice,
677 &apq_voip,
678 &apq_lpa_pcm,
679 &apq_pcm_hostless,
680 &apq_cpudai_afe_01_rx,
681 &apq_cpudai_afe_01_tx,
682 &apq_cpudai_afe_02_rx,
683 &apq_cpudai_afe_02_tx,
684 &apq_pcm_afe,
685 &apq_cpudai_auxpcm_rx,
686 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700687 &msm_bus_8064_apps_fabric,
688 &msm_bus_8064_sys_fabric,
689 &msm_bus_8064_mm_fabric,
690 &msm_bus_8064_sys_fpb,
691 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600692};
693
Joel King4e7ad222011-08-17 15:47:38 -0700694static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700695 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700696 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700697};
698
699static struct platform_device *rumi3_devices[] __initdata = {
700 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800701 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700702};
703
Joel King82b7e3f2012-01-05 10:03:27 -0800704static struct platform_device *cdp_devices[] __initdata = {
705 &apq8064_device_uart_gsbi1,
706 &msm_device_sps_apq8064,
707};
708
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600709static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700710 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700711};
712
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700713#define KS8851_IRQ_GPIO 43
714
715static struct spi_board_info spi_board_info[] __initdata = {
716 {
717 .modalias = "ks8851",
718 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
719 .max_speed_hz = 19200000,
720 .bus_num = 0,
721 .chip_select = 2,
722 .mode = SPI_MODE_0,
723 },
724};
725
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600726static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800727 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800728 .bus_num = 1,
729 .slim_slave = &apq8064_slim_tabla,
730 },
731 {
732 .bus_num = 1,
733 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800734 },
735 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600736};
737
Kenneth Heitke748593a2011-07-15 15:45:11 -0600738static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
739 .clk_freq = 100000,
740 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600741};
742
743static void __init apq8064_i2c_init(void)
744{
745 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
746 &apq8064_i2c_qup_gsbi4_pdata;
747}
748
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700749#ifdef CONFIG_KS8851
750static int ethernet_init(void)
751{
752 int ret;
753 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
754 if (ret) {
755 pr_err("ks8851 gpio_request failed: %d\n", ret);
756 goto fail;
757 }
758
759 return 0;
760fail:
761 return ret;
762}
763#else
764static int ethernet_init(void)
765{
766 return 0;
767}
768#endif
769
Tianyi Gou41515e22011-09-01 19:37:43 -0700770static void __init apq8064_clock_init(void)
771{
772 if (machine_is_apq8064_sim())
773 msm_clock_init(&apq8064_clock_init_data);
774 else
775 msm_clock_init(&apq8064_dummy_clock_init_data);
776}
777
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700778static void __init apq8064_common_init(void)
779{
780 if (socinfo_init() < 0)
781 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700782 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800783 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600784 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600785
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600786 apq8064_device_qup_spi_gsbi5.dev.platform_data =
787 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800788 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700789 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700790 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530792 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600793 slim_register_board_info(apq8064_slim_devices,
794 ARRAY_SIZE(apq8064_slim_devices));
Vikram Mulukutlabc2e9572011-11-04 03:41:38 -0700795 acpuclk_init(&acpuclk_8064_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700796}
797
798static void __init apq8064_sim_init(void)
799{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700800 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
801 &msm8064_device_watchdog.dev.platform_data;
802
803 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700805 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
806}
807
808static void __init apq8064_rumi3_init(void)
809{
810 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700811 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700812 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700813 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700814}
815
Joel King82b7e3f2012-01-05 10:03:27 -0800816static void __init apq8064_cdp_init(void)
817{
818 apq8064_common_init();
819 ethernet_init();
820 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
821 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
822}
823
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700824MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
825 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700826 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700827 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530828 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700829 .timer = &msm_timer,
830 .init_machine = apq8064_sim_init,
831MACHINE_END
832
Joel King4e7ad222011-08-17 15:47:38 -0700833MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
834 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700835 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700836 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530837 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700838 .timer = &msm_timer,
839 .init_machine = apq8064_rumi3_init,
840MACHINE_END
841
Joel King82b7e3f2012-01-05 10:03:27 -0800842MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
843 .map_io = apq8064_map_io,
844 .reserve = apq8064_reserve,
845 .init_irq = apq8064_init_irq,
846 .handle_irq = gic_handle_irq,
847 .timer = &msm_timer,
848 .init_machine = apq8064_cdp_init,
849MACHINE_END
850
851MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
852 .map_io = apq8064_map_io,
853 .reserve = apq8064_reserve,
854 .init_irq = apq8064_init_irq,
855 .handle_irq = gic_handle_irq,
856 .timer = &msm_timer,
857 .init_machine = apq8064_cdp_init,
858MACHINE_END
859
860MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
861 .map_io = apq8064_map_io,
862 .reserve = apq8064_reserve,
863 .init_irq = apq8064_init_irq,
864 .handle_irq = gic_handle_irq,
865 .timer = &msm_timer,
866 .init_machine = apq8064_cdp_init,
867MACHINE_END
868