blob: 0f1550d603348c2d0dee1aa99a319e87958f8752 [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
Olav Hauganf45e2142012-01-19 11:01:01 -080068#define MSM_ION_QSECOM_SIZE 0x100000 /* (1MB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -080069#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan2c43fac2012-01-19 11:06:37 -080070#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
71#define MSM_ION_HEAP_NUM 8
Olav Haugan7c6aa742012-01-16 16:47:37 -080072#else
73#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
74#define MSM_ION_HEAP_NUM 1
75#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070076
Olav Haugan7c6aa742012-01-16 16:47:37 -080077#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
78static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
79static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070080{
Olav Haugan7c6aa742012-01-16 16:47:37 -080081 pmem_kernel_ebi1_size = memparse(p, NULL);
82 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070083}
Olav Haugan7c6aa742012-01-16 16:47:37 -080084early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
85#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070086
Olav Haugan7c6aa742012-01-16 16:47:37 -080087#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070088static unsigned pmem_size = MSM_PMEM_SIZE;
89static int __init pmem_size_setup(char *p)
90{
91 pmem_size = memparse(p, NULL);
92 return 0;
93}
94early_param("pmem_size", pmem_size_setup);
95
96static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
97
98static int __init pmem_adsp_size_setup(char *p)
99{
100 pmem_adsp_size = memparse(p, NULL);
101 return 0;
102}
103early_param("pmem_adsp_size", pmem_adsp_size_setup);
104
105static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
106
107static int __init pmem_audio_size_setup(char *p)
108{
109 pmem_audio_size = memparse(p, NULL);
110 return 0;
111}
112early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800113#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700114
Olav Haugan7c6aa742012-01-16 16:47:37 -0800115#ifdef CONFIG_ANDROID_PMEM
116#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700117static struct android_pmem_platform_data android_pmem_pdata = {
118 .name = "pmem",
119 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
120 .cached = 1,
121 .memory_type = MEMTYPE_EBI1,
122};
123
124static struct platform_device android_pmem_device = {
125 .name = "android_pmem",
126 .id = 0,
127 .dev = {.platform_data = &android_pmem_pdata},
128};
129
130static struct android_pmem_platform_data android_pmem_adsp_pdata = {
131 .name = "pmem_adsp",
132 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
133 .cached = 0,
134 .memory_type = MEMTYPE_EBI1,
135};
Kevin Chan13be4e22011-10-20 11:30:32 -0700136static struct platform_device android_pmem_adsp_device = {
137 .name = "android_pmem",
138 .id = 2,
139 .dev = { .platform_data = &android_pmem_adsp_pdata },
140};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800141#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700142
143static struct android_pmem_platform_data android_pmem_audio_pdata = {
144 .name = "pmem_audio",
145 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
146 .cached = 0,
147 .memory_type = MEMTYPE_EBI1,
148};
149
150static struct platform_device android_pmem_audio_device = {
151 .name = "android_pmem",
152 .id = 4,
153 .dev = { .platform_data = &android_pmem_audio_pdata },
154};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800155#endif
156
157static struct memtype_reserve apq8064_reserve_table[] __initdata = {
158 [MEMTYPE_SMI] = {
159 },
160 [MEMTYPE_EBI0] = {
161 .flags = MEMTYPE_FLAGS_1M_ALIGN,
162 },
163 [MEMTYPE_EBI1] = {
164 .flags = MEMTYPE_FLAGS_1M_ALIGN,
165 },
166};
Kevin Chan13be4e22011-10-20 11:30:32 -0700167
168static void __init size_pmem_devices(void)
169{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800170#ifdef CONFIG_ANDROID_PMEM
171#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700172 android_pmem_adsp_pdata.size = pmem_adsp_size;
173 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800174#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700175 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800176#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700177}
178
179static void __init reserve_memory_for(struct android_pmem_platform_data *p)
180{
181 apq8064_reserve_table[p->memory_type].size += p->size;
182}
183
Kevin Chan13be4e22011-10-20 11:30:32 -0700184static void __init reserve_pmem_memory(void)
185{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800186#ifdef CONFIG_ANDROID_PMEM
187#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700188 reserve_memory_for(&android_pmem_adsp_pdata);
189 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800190#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700191 reserve_memory_for(&android_pmem_audio_pdata);
192 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800193#endif
194}
195
196static int apq8064_paddr_to_memtype(unsigned int paddr)
197{
198 return MEMTYPE_EBI1;
199}
200
201#ifdef CONFIG_ION_MSM
202#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
203static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
204 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800205 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800206};
207
208static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
209 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800210 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800211};
212
213static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800214 .adjacent_mem_id = INVALID_HEAP_ID,
215 .align = PAGE_SIZE,
216};
217
218static struct ion_co_heap_pdata fw_co_ion_pdata = {
219 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
220 .align = SZ_128K,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800221};
222#endif
223static struct ion_platform_data ion_pdata = {
224 .nr = MSM_ION_HEAP_NUM,
225 .heaps = {
226 {
227 .id = ION_SYSTEM_HEAP_ID,
228 .type = ION_HEAP_TYPE_SYSTEM,
229 .name = ION_VMALLOC_HEAP_NAME,
230 },
231#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
232 {
233 .id = ION_SF_HEAP_ID,
234 .type = ION_HEAP_TYPE_CARVEOUT,
235 .name = ION_SF_HEAP_NAME,
236 .size = MSM_ION_SF_SIZE,
237 .memory_type = ION_EBI_TYPE,
238 .extra_data = (void *) &co_ion_pdata,
239 },
240 {
241 .id = ION_CP_MM_HEAP_ID,
242 .type = ION_HEAP_TYPE_CP,
243 .name = ION_MM_HEAP_NAME,
244 .size = MSM_ION_MM_SIZE,
245 .memory_type = ION_EBI_TYPE,
246 .extra_data = (void *) &cp_mm_ion_pdata,
247 },
248 {
Olav Haugand3d29682012-01-19 10:57:07 -0800249 .id = ION_MM_FIRMWARE_HEAP_ID,
250 .type = ION_HEAP_TYPE_CARVEOUT,
251 .name = ION_MM_FIRMWARE_HEAP_NAME,
252 .size = MSM_ION_MM_FW_SIZE,
253 .memory_type = ION_EBI_TYPE,
254 .extra_data = (void *) &fw_co_ion_pdata,
255 },
256 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800257 .id = ION_CP_MFC_HEAP_ID,
258 .type = ION_HEAP_TYPE_CP,
259 .name = ION_MFC_HEAP_NAME,
260 .size = MSM_ION_MFC_SIZE,
261 .memory_type = ION_EBI_TYPE,
262 .extra_data = (void *) &cp_mfc_ion_pdata,
263 },
264 {
265 .id = ION_IOMMU_HEAP_ID,
266 .type = ION_HEAP_TYPE_IOMMU,
267 .name = ION_IOMMU_HEAP_NAME,
268 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800269 {
270 .id = ION_QSECOM_HEAP_ID,
271 .type = ION_HEAP_TYPE_CARVEOUT,
272 .name = ION_QSECOM_HEAP_NAME,
273 .size = MSM_ION_QSECOM_SIZE,
274 .memory_type = ION_EBI_TYPE,
275 .extra_data = (void *) &co_ion_pdata,
276 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800277 {
278 .id = ION_AUDIO_HEAP_ID,
279 .type = ION_HEAP_TYPE_CARVEOUT,
280 .name = ION_AUDIO_HEAP_NAME,
281 .size = MSM_ION_AUDIO_SIZE,
282 .memory_type = ION_EBI_TYPE,
283 .extra_data = (void *) &co_ion_pdata,
284 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800285#endif
286 }
287};
288
289static struct platform_device ion_dev = {
290 .name = "ion-msm",
291 .id = 1,
292 .dev = { .platform_data = &ion_pdata },
293};
294#endif
295
296static void reserve_ion_memory(void)
297{
298#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
299 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
Olav Haugand3d29682012-01-19 10:57:07 -0800300 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800301 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
302 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
Olav Hauganf45e2142012-01-19 11:01:01 -0800303 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Olav Haugan2c43fac2012-01-19 11:06:37 -0800304 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800305#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700306}
307
308static void __init apq8064_calculate_reserve_sizes(void)
309{
310 size_pmem_devices();
311 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800312 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700313}
314
315static struct reserve_info apq8064_reserve_info __initdata = {
316 .memtype_reserve_table = apq8064_reserve_table,
317 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
318 .paddr_to_memtype = apq8064_paddr_to_memtype,
319};
320
321static int apq8064_memory_bank_size(void)
322{
323 return 1<<29;
324}
325
326static void __init locate_unstable_memory(void)
327{
328 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
329 unsigned long bank_size;
330 unsigned long low, high;
331
332 bank_size = apq8064_memory_bank_size();
333 low = meminfo.bank[0].start;
334 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800335
336 /* Check if 32 bit overflow occured */
337 if (high < mb->start)
338 high = ~0UL;
339
Kevin Chan13be4e22011-10-20 11:30:32 -0700340 low &= ~(bank_size - 1);
341
342 if (high - low <= bank_size)
343 return;
Jack Cheung46bfffa2012-01-19 15:26:24 -0800344 apq8064_reserve_info.low_unstable_address = mb->start -
345 MIN_MEMORY_BLOCK_SIZE + mb->size;
346 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
347
Kevin Chan13be4e22011-10-20 11:30:32 -0700348 apq8064_reserve_info.bank_size = bank_size;
349 pr_info("low unstable address %lx max size %lx bank size %lx\n",
350 apq8064_reserve_info.low_unstable_address,
351 apq8064_reserve_info.max_unstable_size,
352 apq8064_reserve_info.bank_size);
353}
354
355static void __init apq8064_reserve(void)
356{
357 reserve_info = &apq8064_reserve_info;
358 locate_unstable_memory();
359 msm_reserve();
360}
361
Hemant Kumar4933b072011-10-17 23:43:11 -0700362static struct platform_device android_usb_device = {
363 .name = "android_usb",
364 .id = -1,
365};
366
367static struct msm_otg_platform_data msm_otg_pdata = {
368 .mode = USB_PERIPHERAL,
369 .otg_control = OTG_PHY_CONTROL,
370 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700371};
372
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800373#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
374
375/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
376 * 4 micbiases are used to power various analog and digital
377 * microphones operating at 1800 mV. Technically, all micbiases
378 * can source from single cfilter since all microphones operate
379 * at the same voltage level. The arrangement below is to make
380 * sure all cfilters are exercised. LDO_H regulator ouput level
381 * does not need to be as high as 2.85V. It is choosen for
382 * microphone sensitivity purpose.
383 */
384static struct tabla_pdata apq8064_tabla_platform_data = {
385 .slimbus_slave_device = {
386 .name = "tabla-slave",
387 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
388 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800389 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800390 .irq_base = TABLA_INTERRUPT_BASE,
391 .num_irqs = NR_TABLA_IRQS,
392 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
393 .micbias = {
394 .ldoh_v = TABLA_LDOH_2P85_V,
395 .cfilt1_mv = 1800,
396 .cfilt2_mv = 1800,
397 .cfilt3_mv = 1800,
398 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
399 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
400 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
401 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
402 }
403};
404
405static struct slim_device apq8064_slim_tabla = {
406 .name = "tabla-slim",
407 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
408 .dev = {
409 .platform_data = &apq8064_tabla_platform_data,
410 },
411};
412
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800413static struct tabla_pdata apq8064_tabla20_platform_data = {
414 .slimbus_slave_device = {
415 .name = "tabla-slave",
416 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
417 },
418 .irq = MSM_GPIO_TO_INT(42),
419 .irq_base = TABLA_INTERRUPT_BASE,
420 .num_irqs = NR_TABLA_IRQS,
421 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
422 .micbias = {
423 .ldoh_v = TABLA_LDOH_2P85_V,
424 .cfilt1_mv = 1800,
425 .cfilt2_mv = 1800,
426 .cfilt3_mv = 1800,
427 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
428 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
429 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
430 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
431 }
432};
433
434static struct slim_device apq8064_slim_tabla20 = {
435 .name = "tabla2x-slim",
436 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
437 .dev = {
438 .platform_data = &apq8064_tabla20_platform_data,
439 },
440};
441
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700442#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
443 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
444 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
445 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
446
447#define QCE_SIZE 0x10000
448#define QCE_0_BASE 0x11000000
449
450#define QCE_HW_KEY_SUPPORT 0
451#define QCE_SHA_HMAC_SUPPORT 1
452#define QCE_SHARE_CE_RESOURCE 3
453#define QCE_CE_SHARED 0
454
455static struct resource qcrypto_resources[] = {
456 [0] = {
457 .start = QCE_0_BASE,
458 .end = QCE_0_BASE + QCE_SIZE - 1,
459 .flags = IORESOURCE_MEM,
460 },
461 [1] = {
462 .name = "crypto_channels",
463 .start = DMOV8064_CE_IN_CHAN,
464 .end = DMOV8064_CE_OUT_CHAN,
465 .flags = IORESOURCE_DMA,
466 },
467 [2] = {
468 .name = "crypto_crci_in",
469 .start = DMOV8064_CE_IN_CRCI,
470 .end = DMOV8064_CE_IN_CRCI,
471 .flags = IORESOURCE_DMA,
472 },
473 [3] = {
474 .name = "crypto_crci_out",
475 .start = DMOV8064_CE_OUT_CRCI,
476 .end = DMOV8064_CE_OUT_CRCI,
477 .flags = IORESOURCE_DMA,
478 },
479};
480
481static struct resource qcedev_resources[] = {
482 [0] = {
483 .start = QCE_0_BASE,
484 .end = QCE_0_BASE + QCE_SIZE - 1,
485 .flags = IORESOURCE_MEM,
486 },
487 [1] = {
488 .name = "crypto_channels",
489 .start = DMOV8064_CE_IN_CHAN,
490 .end = DMOV8064_CE_OUT_CHAN,
491 .flags = IORESOURCE_DMA,
492 },
493 [2] = {
494 .name = "crypto_crci_in",
495 .start = DMOV8064_CE_IN_CRCI,
496 .end = DMOV8064_CE_IN_CRCI,
497 .flags = IORESOURCE_DMA,
498 },
499 [3] = {
500 .name = "crypto_crci_out",
501 .start = DMOV8064_CE_OUT_CRCI,
502 .end = DMOV8064_CE_OUT_CRCI,
503 .flags = IORESOURCE_DMA,
504 },
505};
506
507#endif
508
509#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
510 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
511
512static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
513 .ce_shared = QCE_CE_SHARED,
514 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
515 .hw_key_support = QCE_HW_KEY_SUPPORT,
516 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800517 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700518};
519
520static struct platform_device qcrypto_device = {
521 .name = "qcrypto",
522 .id = 0,
523 .num_resources = ARRAY_SIZE(qcrypto_resources),
524 .resource = qcrypto_resources,
525 .dev = {
526 .coherent_dma_mask = DMA_BIT_MASK(32),
527 .platform_data = &qcrypto_ce_hw_suppport,
528 },
529};
530#endif
531
532#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
533 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
534
535static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
536 .ce_shared = QCE_CE_SHARED,
537 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
538 .hw_key_support = QCE_HW_KEY_SUPPORT,
539 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800540 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700541};
542
543static struct platform_device qcedev_device = {
544 .name = "qce",
545 .id = 0,
546 .num_resources = ARRAY_SIZE(qcedev_resources),
547 .resource = qcedev_resources,
548 .dev = {
549 .coherent_dma_mask = DMA_BIT_MASK(32),
550 .platform_data = &qcedev_ce_hw_suppport,
551 },
552};
553#endif
554
555
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600556#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557static void __init apq8064_map_io(void)
558{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600559 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700560 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700561 if (socinfo_init() < 0)
562 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700563}
564
565static void __init apq8064_init_irq(void)
566{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700567 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
568 (void *)MSM_QGIC_CPU_BASE);
569
570 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
571 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
572
573 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
574 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700575}
576
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800577static struct platform_device msm8064_device_saw_regulator_core0 = {
578 .name = "saw-regulator",
579 .id = 0,
580 .dev = {
581 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
582 },
583};
584
585static struct platform_device msm8064_device_saw_regulator_core1 = {
586 .name = "saw-regulator",
587 .id = 1,
588 .dev = {
589 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
590 },
591};
592
593static struct platform_device msm8064_device_saw_regulator_core2 = {
594 .name = "saw-regulator",
595 .id = 2,
596 .dev = {
597 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
598 },
599};
600
601static struct platform_device msm8064_device_saw_regulator_core3 = {
602 .name = "saw-regulator",
603 .id = 3,
604 .dev = {
605 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
606 },
607};
608
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700609static void __init apq8064_init_buses(void)
610{
611 msm_bus_rpm_set_mt_mask();
612 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
613 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
614 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
615 msm_bus_8064_apps_fabric.dev.platform_data =
616 &msm_bus_8064_apps_fabric_pdata;
617 msm_bus_8064_sys_fabric.dev.platform_data =
618 &msm_bus_8064_sys_fabric_pdata;
619 msm_bus_8064_mm_fabric.dev.platform_data =
620 &msm_bus_8064_mm_fabric_pdata;
621 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
622 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
623}
624
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700625static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700626 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600627 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600628 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600629 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700630 &apq8064_device_ssbi_pmic1,
631 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600632 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700633 &apq8064_device_otg,
634 &apq8064_device_gadget_peripheral,
635 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800636#ifdef CONFIG_ANDROID_PMEM
637#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700638 &android_pmem_device,
639 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800640#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700641 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800642#endif
643#ifdef CONFIG_ION_MSM
644 &ion_dev,
645#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700646 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800647 &msm8064_device_saw_regulator_core0,
648 &msm8064_device_saw_regulator_core1,
649 &msm8064_device_saw_regulator_core2,
650 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700651#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
652 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
653 &qcrypto_device,
654#endif
655
656#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
657 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
658 &qcedev_device,
659#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700660
661#ifdef CONFIG_HW_RANDOM_MSM
662 &apq8064_device_rng,
663#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800664 &apq_pcm,
665 &apq_pcm_routing,
666 &apq_cpudai0,
667 &apq_cpudai1,
668 &apq_cpudai_hdmi_rx,
669 &apq_cpudai_bt_rx,
670 &apq_cpudai_bt_tx,
671 &apq_cpudai_fm_rx,
672 &apq_cpudai_fm_tx,
673 &apq_cpu_fe,
674 &apq_stub_codec,
675 &apq_voice,
676 &apq_voip,
677 &apq_lpa_pcm,
678 &apq_pcm_hostless,
679 &apq_cpudai_afe_01_rx,
680 &apq_cpudai_afe_01_tx,
681 &apq_cpudai_afe_02_rx,
682 &apq_cpudai_afe_02_tx,
683 &apq_pcm_afe,
684 &apq_cpudai_auxpcm_rx,
685 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700686 &msm_bus_8064_apps_fabric,
687 &msm_bus_8064_sys_fabric,
688 &msm_bus_8064_mm_fabric,
689 &msm_bus_8064_sys_fpb,
690 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600691};
692
Joel King4e7ad222011-08-17 15:47:38 -0700693static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700694 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700695 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700696};
697
698static struct platform_device *rumi3_devices[] __initdata = {
699 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800700 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700701};
702
Joel King82b7e3f2012-01-05 10:03:27 -0800703static struct platform_device *cdp_devices[] __initdata = {
704 &apq8064_device_uart_gsbi1,
705 &msm_device_sps_apq8064,
706};
707
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600708static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700709 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700710};
711
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700712#define KS8851_IRQ_GPIO 43
713
714static struct spi_board_info spi_board_info[] __initdata = {
715 {
716 .modalias = "ks8851",
717 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
718 .max_speed_hz = 19200000,
719 .bus_num = 0,
720 .chip_select = 2,
721 .mode = SPI_MODE_0,
722 },
723};
724
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600725static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800726 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800727 .bus_num = 1,
728 .slim_slave = &apq8064_slim_tabla,
729 },
730 {
731 .bus_num = 1,
732 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800733 },
734 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600735};
736
Kenneth Heitke748593a2011-07-15 15:45:11 -0600737static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
738 .clk_freq = 100000,
739 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600740};
741
742static void __init apq8064_i2c_init(void)
743{
744 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
745 &apq8064_i2c_qup_gsbi4_pdata;
746}
747
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700748#ifdef CONFIG_KS8851
749static int ethernet_init(void)
750{
751 int ret;
752 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
753 if (ret) {
754 pr_err("ks8851 gpio_request failed: %d\n", ret);
755 goto fail;
756 }
757
758 return 0;
759fail:
760 return ret;
761}
762#else
763static int ethernet_init(void)
764{
765 return 0;
766}
767#endif
768
Tianyi Gou41515e22011-09-01 19:37:43 -0700769static void __init apq8064_clock_init(void)
770{
771 if (machine_is_apq8064_sim())
772 msm_clock_init(&apq8064_clock_init_data);
773 else
774 msm_clock_init(&apq8064_dummy_clock_init_data);
775}
776
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700777static void __init apq8064_common_init(void)
778{
779 if (socinfo_init() < 0)
780 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700781 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800782 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600783 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600784
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600785 apq8064_device_qup_spi_gsbi5.dev.platform_data =
786 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800787 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700788 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700789 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700790 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530791 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600792 slim_register_board_info(apq8064_slim_devices,
793 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794}
795
796static void __init apq8064_sim_init(void)
797{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700798 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
799 &msm8064_device_watchdog.dev.platform_data;
800
801 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700803 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
804}
805
806static void __init apq8064_rumi3_init(void)
807{
808 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700809 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700810 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700811 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700812}
813
Joel King82b7e3f2012-01-05 10:03:27 -0800814static void __init apq8064_cdp_init(void)
815{
816 apq8064_common_init();
817 ethernet_init();
818 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
819 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
820}
821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700822MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
823 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700824 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530826 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700827 .timer = &msm_timer,
828 .init_machine = apq8064_sim_init,
829MACHINE_END
830
Joel King4e7ad222011-08-17 15:47:38 -0700831MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
832 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700833 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700834 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530835 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700836 .timer = &msm_timer,
837 .init_machine = apq8064_rumi3_init,
838MACHINE_END
839
Joel King82b7e3f2012-01-05 10:03:27 -0800840MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
841 .map_io = apq8064_map_io,
842 .reserve = apq8064_reserve,
843 .init_irq = apq8064_init_irq,
844 .handle_irq = gic_handle_irq,
845 .timer = &msm_timer,
846 .init_machine = apq8064_cdp_init,
847MACHINE_END
848
849MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
850 .map_io = apq8064_map_io,
851 .reserve = apq8064_reserve,
852 .init_irq = apq8064_init_irq,
853 .handle_irq = gic_handle_irq,
854 .timer = &msm_timer,
855 .init_machine = apq8064_cdp_init,
856MACHINE_END
857
858MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
859 .map_io = apq8064_map_io,
860 .reserve = apq8064_reserve,
861 .init_irq = apq8064_init_irq,
862 .handle_irq = gic_handle_irq,
863 .timer = &msm_timer,
864 .init_machine = apq8064_cdp_init,
865MACHINE_END
866