blob: 2ffd1df0d99f9ef5bfc5795391ac790762b22f32 [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 Hauganf45e2142012-01-19 11:01:01 -080070#define MSM_ION_HEAP_NUM 7
Olav Haugan7c6aa742012-01-16 16:47:37 -080071#else
72#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
73#define MSM_ION_HEAP_NUM 1
74#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070075
Olav Haugan7c6aa742012-01-16 16:47:37 -080076#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
77static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
78static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -070079{
Olav Haugan7c6aa742012-01-16 16:47:37 -080080 pmem_kernel_ebi1_size = memparse(p, NULL);
81 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -070082}
Olav Haugan7c6aa742012-01-16 16:47:37 -080083early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
84#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070085
Olav Haugan7c6aa742012-01-16 16:47:37 -080086#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070087static unsigned pmem_size = MSM_PMEM_SIZE;
88static int __init pmem_size_setup(char *p)
89{
90 pmem_size = memparse(p, NULL);
91 return 0;
92}
93early_param("pmem_size", pmem_size_setup);
94
95static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
96
97static int __init pmem_adsp_size_setup(char *p)
98{
99 pmem_adsp_size = memparse(p, NULL);
100 return 0;
101}
102early_param("pmem_adsp_size", pmem_adsp_size_setup);
103
104static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
105
106static int __init pmem_audio_size_setup(char *p)
107{
108 pmem_audio_size = memparse(p, NULL);
109 return 0;
110}
111early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800112#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700113
Olav Haugan7c6aa742012-01-16 16:47:37 -0800114#ifdef CONFIG_ANDROID_PMEM
115#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700116static struct android_pmem_platform_data android_pmem_pdata = {
117 .name = "pmem",
118 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
119 .cached = 1,
120 .memory_type = MEMTYPE_EBI1,
121};
122
123static struct platform_device android_pmem_device = {
124 .name = "android_pmem",
125 .id = 0,
126 .dev = {.platform_data = &android_pmem_pdata},
127};
128
129static struct android_pmem_platform_data android_pmem_adsp_pdata = {
130 .name = "pmem_adsp",
131 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
132 .cached = 0,
133 .memory_type = MEMTYPE_EBI1,
134};
Kevin Chan13be4e22011-10-20 11:30:32 -0700135static struct platform_device android_pmem_adsp_device = {
136 .name = "android_pmem",
137 .id = 2,
138 .dev = { .platform_data = &android_pmem_adsp_pdata },
139};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800140#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700141
142static struct android_pmem_platform_data android_pmem_audio_pdata = {
143 .name = "pmem_audio",
144 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
145 .cached = 0,
146 .memory_type = MEMTYPE_EBI1,
147};
148
149static struct platform_device android_pmem_audio_device = {
150 .name = "android_pmem",
151 .id = 4,
152 .dev = { .platform_data = &android_pmem_audio_pdata },
153};
Olav Haugan7c6aa742012-01-16 16:47:37 -0800154#endif
155
156static struct memtype_reserve apq8064_reserve_table[] __initdata = {
157 [MEMTYPE_SMI] = {
158 },
159 [MEMTYPE_EBI0] = {
160 .flags = MEMTYPE_FLAGS_1M_ALIGN,
161 },
162 [MEMTYPE_EBI1] = {
163 .flags = MEMTYPE_FLAGS_1M_ALIGN,
164 },
165};
Kevin Chan13be4e22011-10-20 11:30:32 -0700166
167static void __init size_pmem_devices(void)
168{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800169#ifdef CONFIG_ANDROID_PMEM
170#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700171 android_pmem_adsp_pdata.size = pmem_adsp_size;
172 android_pmem_pdata.size = pmem_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800173#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700174 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800175#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700176}
177
178static void __init reserve_memory_for(struct android_pmem_platform_data *p)
179{
180 apq8064_reserve_table[p->memory_type].size += p->size;
181}
182
Kevin Chan13be4e22011-10-20 11:30:32 -0700183static void __init reserve_pmem_memory(void)
184{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800185#ifdef CONFIG_ANDROID_PMEM
186#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700187 reserve_memory_for(&android_pmem_adsp_pdata);
188 reserve_memory_for(&android_pmem_pdata);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800189#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700190 reserve_memory_for(&android_pmem_audio_pdata);
191 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800192#endif
193}
194
195static int apq8064_paddr_to_memtype(unsigned int paddr)
196{
197 return MEMTYPE_EBI1;
198}
199
200#ifdef CONFIG_ION_MSM
201#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
202static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
203 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800204 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800205};
206
207static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
208 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800209 .align = PAGE_SIZE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800210};
211
212static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800213 .adjacent_mem_id = INVALID_HEAP_ID,
214 .align = PAGE_SIZE,
215};
216
217static struct ion_co_heap_pdata fw_co_ion_pdata = {
218 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
219 .align = SZ_128K,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800220};
221#endif
222static struct ion_platform_data ion_pdata = {
223 .nr = MSM_ION_HEAP_NUM,
224 .heaps = {
225 {
226 .id = ION_SYSTEM_HEAP_ID,
227 .type = ION_HEAP_TYPE_SYSTEM,
228 .name = ION_VMALLOC_HEAP_NAME,
229 },
230#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
231 {
232 .id = ION_SF_HEAP_ID,
233 .type = ION_HEAP_TYPE_CARVEOUT,
234 .name = ION_SF_HEAP_NAME,
235 .size = MSM_ION_SF_SIZE,
236 .memory_type = ION_EBI_TYPE,
237 .extra_data = (void *) &co_ion_pdata,
238 },
239 {
240 .id = ION_CP_MM_HEAP_ID,
241 .type = ION_HEAP_TYPE_CP,
242 .name = ION_MM_HEAP_NAME,
243 .size = MSM_ION_MM_SIZE,
244 .memory_type = ION_EBI_TYPE,
245 .extra_data = (void *) &cp_mm_ion_pdata,
246 },
247 {
Olav Haugand3d29682012-01-19 10:57:07 -0800248 .id = ION_MM_FIRMWARE_HEAP_ID,
249 .type = ION_HEAP_TYPE_CARVEOUT,
250 .name = ION_MM_FIRMWARE_HEAP_NAME,
251 .size = MSM_ION_MM_FW_SIZE,
252 .memory_type = ION_EBI_TYPE,
253 .extra_data = (void *) &fw_co_ion_pdata,
254 },
255 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800256 .id = ION_CP_MFC_HEAP_ID,
257 .type = ION_HEAP_TYPE_CP,
258 .name = ION_MFC_HEAP_NAME,
259 .size = MSM_ION_MFC_SIZE,
260 .memory_type = ION_EBI_TYPE,
261 .extra_data = (void *) &cp_mfc_ion_pdata,
262 },
263 {
264 .id = ION_IOMMU_HEAP_ID,
265 .type = ION_HEAP_TYPE_IOMMU,
266 .name = ION_IOMMU_HEAP_NAME,
267 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800268 {
269 .id = ION_QSECOM_HEAP_ID,
270 .type = ION_HEAP_TYPE_CARVEOUT,
271 .name = ION_QSECOM_HEAP_NAME,
272 .size = MSM_ION_QSECOM_SIZE,
273 .memory_type = ION_EBI_TYPE,
274 .extra_data = (void *) &co_ion_pdata,
275 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800276#endif
277 }
278};
279
280static struct platform_device ion_dev = {
281 .name = "ion-msm",
282 .id = 1,
283 .dev = { .platform_data = &ion_pdata },
284};
285#endif
286
287static void reserve_ion_memory(void)
288{
289#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
290 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
Olav Haugand3d29682012-01-19 10:57:07 -0800291 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800292 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
293 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
Olav Hauganf45e2142012-01-19 11:01:01 -0800294 apq8064_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Olav Haugan7c6aa742012-01-16 16:47:37 -0800295#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700296}
297
298static void __init apq8064_calculate_reserve_sizes(void)
299{
300 size_pmem_devices();
301 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800302 reserve_ion_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700303}
304
305static struct reserve_info apq8064_reserve_info __initdata = {
306 .memtype_reserve_table = apq8064_reserve_table,
307 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
308 .paddr_to_memtype = apq8064_paddr_to_memtype,
309};
310
311static int apq8064_memory_bank_size(void)
312{
313 return 1<<29;
314}
315
316static void __init locate_unstable_memory(void)
317{
318 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
319 unsigned long bank_size;
320 unsigned long low, high;
321
322 bank_size = apq8064_memory_bank_size();
323 low = meminfo.bank[0].start;
324 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800325
326 /* Check if 32 bit overflow occured */
327 if (high < mb->start)
328 high = ~0UL;
329
Kevin Chan13be4e22011-10-20 11:30:32 -0700330 low &= ~(bank_size - 1);
331
332 if (high - low <= bank_size)
333 return;
Jack Cheung46bfffa2012-01-19 15:26:24 -0800334 apq8064_reserve_info.low_unstable_address = mb->start -
335 MIN_MEMORY_BLOCK_SIZE + mb->size;
336 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
337
Kevin Chan13be4e22011-10-20 11:30:32 -0700338 apq8064_reserve_info.bank_size = bank_size;
339 pr_info("low unstable address %lx max size %lx bank size %lx\n",
340 apq8064_reserve_info.low_unstable_address,
341 apq8064_reserve_info.max_unstable_size,
342 apq8064_reserve_info.bank_size);
343}
344
345static void __init apq8064_reserve(void)
346{
347 reserve_info = &apq8064_reserve_info;
348 locate_unstable_memory();
349 msm_reserve();
350}
351
Hemant Kumar4933b072011-10-17 23:43:11 -0700352static struct platform_device android_usb_device = {
353 .name = "android_usb",
354 .id = -1,
355};
356
357static struct msm_otg_platform_data msm_otg_pdata = {
358 .mode = USB_PERIPHERAL,
359 .otg_control = OTG_PHY_CONTROL,
360 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumar4933b072011-10-17 23:43:11 -0700361};
362
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800363#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
364
365/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
366 * 4 micbiases are used to power various analog and digital
367 * microphones operating at 1800 mV. Technically, all micbiases
368 * can source from single cfilter since all microphones operate
369 * at the same voltage level. The arrangement below is to make
370 * sure all cfilters are exercised. LDO_H regulator ouput level
371 * does not need to be as high as 2.85V. It is choosen for
372 * microphone sensitivity purpose.
373 */
374static struct tabla_pdata apq8064_tabla_platform_data = {
375 .slimbus_slave_device = {
376 .name = "tabla-slave",
377 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
378 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800379 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800380 .irq_base = TABLA_INTERRUPT_BASE,
381 .num_irqs = NR_TABLA_IRQS,
382 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
383 .micbias = {
384 .ldoh_v = TABLA_LDOH_2P85_V,
385 .cfilt1_mv = 1800,
386 .cfilt2_mv = 1800,
387 .cfilt3_mv = 1800,
388 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
389 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
390 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
391 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
392 }
393};
394
395static struct slim_device apq8064_slim_tabla = {
396 .name = "tabla-slim",
397 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
398 .dev = {
399 .platform_data = &apq8064_tabla_platform_data,
400 },
401};
402
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800403static struct tabla_pdata apq8064_tabla20_platform_data = {
404 .slimbus_slave_device = {
405 .name = "tabla-slave",
406 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
407 },
408 .irq = MSM_GPIO_TO_INT(42),
409 .irq_base = TABLA_INTERRUPT_BASE,
410 .num_irqs = NR_TABLA_IRQS,
411 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
412 .micbias = {
413 .ldoh_v = TABLA_LDOH_2P85_V,
414 .cfilt1_mv = 1800,
415 .cfilt2_mv = 1800,
416 .cfilt3_mv = 1800,
417 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
418 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
419 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
420 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
421 }
422};
423
424static struct slim_device apq8064_slim_tabla20 = {
425 .name = "tabla2x-slim",
426 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
427 .dev = {
428 .platform_data = &apq8064_tabla20_platform_data,
429 },
430};
431
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700432#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
433 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
434 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
435 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
436
437#define QCE_SIZE 0x10000
438#define QCE_0_BASE 0x11000000
439
440#define QCE_HW_KEY_SUPPORT 0
441#define QCE_SHA_HMAC_SUPPORT 1
442#define QCE_SHARE_CE_RESOURCE 3
443#define QCE_CE_SHARED 0
444
445static struct resource qcrypto_resources[] = {
446 [0] = {
447 .start = QCE_0_BASE,
448 .end = QCE_0_BASE + QCE_SIZE - 1,
449 .flags = IORESOURCE_MEM,
450 },
451 [1] = {
452 .name = "crypto_channels",
453 .start = DMOV8064_CE_IN_CHAN,
454 .end = DMOV8064_CE_OUT_CHAN,
455 .flags = IORESOURCE_DMA,
456 },
457 [2] = {
458 .name = "crypto_crci_in",
459 .start = DMOV8064_CE_IN_CRCI,
460 .end = DMOV8064_CE_IN_CRCI,
461 .flags = IORESOURCE_DMA,
462 },
463 [3] = {
464 .name = "crypto_crci_out",
465 .start = DMOV8064_CE_OUT_CRCI,
466 .end = DMOV8064_CE_OUT_CRCI,
467 .flags = IORESOURCE_DMA,
468 },
469};
470
471static struct resource qcedev_resources[] = {
472 [0] = {
473 .start = QCE_0_BASE,
474 .end = QCE_0_BASE + QCE_SIZE - 1,
475 .flags = IORESOURCE_MEM,
476 },
477 [1] = {
478 .name = "crypto_channels",
479 .start = DMOV8064_CE_IN_CHAN,
480 .end = DMOV8064_CE_OUT_CHAN,
481 .flags = IORESOURCE_DMA,
482 },
483 [2] = {
484 .name = "crypto_crci_in",
485 .start = DMOV8064_CE_IN_CRCI,
486 .end = DMOV8064_CE_IN_CRCI,
487 .flags = IORESOURCE_DMA,
488 },
489 [3] = {
490 .name = "crypto_crci_out",
491 .start = DMOV8064_CE_OUT_CRCI,
492 .end = DMOV8064_CE_OUT_CRCI,
493 .flags = IORESOURCE_DMA,
494 },
495};
496
497#endif
498
499#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
500 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
501
502static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
503 .ce_shared = QCE_CE_SHARED,
504 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
505 .hw_key_support = QCE_HW_KEY_SUPPORT,
506 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800507 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700508};
509
510static struct platform_device qcrypto_device = {
511 .name = "qcrypto",
512 .id = 0,
513 .num_resources = ARRAY_SIZE(qcrypto_resources),
514 .resource = qcrypto_resources,
515 .dev = {
516 .coherent_dma_mask = DMA_BIT_MASK(32),
517 .platform_data = &qcrypto_ce_hw_suppport,
518 },
519};
520#endif
521
522#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
523 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
524
525static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
526 .ce_shared = QCE_CE_SHARED,
527 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
528 .hw_key_support = QCE_HW_KEY_SUPPORT,
529 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800530 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700531};
532
533static struct platform_device qcedev_device = {
534 .name = "qce",
535 .id = 0,
536 .num_resources = ARRAY_SIZE(qcedev_resources),
537 .resource = qcedev_resources,
538 .dev = {
539 .coherent_dma_mask = DMA_BIT_MASK(32),
540 .platform_data = &qcedev_ce_hw_suppport,
541 },
542};
543#endif
544
545
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600546#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700547static void __init apq8064_map_io(void)
548{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600549 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700550 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700551 if (socinfo_init() < 0)
552 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700553}
554
555static void __init apq8064_init_irq(void)
556{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
558 (void *)MSM_QGIC_CPU_BASE);
559
560 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
561 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
562
563 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
564 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700565}
566
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800567static struct platform_device msm8064_device_saw_regulator_core0 = {
568 .name = "saw-regulator",
569 .id = 0,
570 .dev = {
571 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
572 },
573};
574
575static struct platform_device msm8064_device_saw_regulator_core1 = {
576 .name = "saw-regulator",
577 .id = 1,
578 .dev = {
579 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
580 },
581};
582
583static struct platform_device msm8064_device_saw_regulator_core2 = {
584 .name = "saw-regulator",
585 .id = 2,
586 .dev = {
587 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
588 },
589};
590
591static struct platform_device msm8064_device_saw_regulator_core3 = {
592 .name = "saw-regulator",
593 .id = 3,
594 .dev = {
595 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
596 },
597};
598
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700599static void __init apq8064_init_buses(void)
600{
601 msm_bus_rpm_set_mt_mask();
602 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
603 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
604 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
605 msm_bus_8064_apps_fabric.dev.platform_data =
606 &msm_bus_8064_apps_fabric_pdata;
607 msm_bus_8064_sys_fabric.dev.platform_data =
608 &msm_bus_8064_sys_fabric_pdata;
609 msm_bus_8064_mm_fabric.dev.platform_data =
610 &msm_bus_8064_mm_fabric_pdata;
611 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
612 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
613}
614
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700615static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700616 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600617 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600618 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600619 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700620 &apq8064_device_ssbi_pmic1,
621 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600622 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700623 &apq8064_device_otg,
624 &apq8064_device_gadget_peripheral,
625 &android_usb_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800626#ifdef CONFIG_ANDROID_PMEM
627#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700628 &android_pmem_device,
629 &android_pmem_adsp_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800630#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700631 &android_pmem_audio_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800632#endif
633#ifdef CONFIG_ION_MSM
634 &ion_dev,
635#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700636 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800637 &msm8064_device_saw_regulator_core0,
638 &msm8064_device_saw_regulator_core1,
639 &msm8064_device_saw_regulator_core2,
640 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700641#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
642 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
643 &qcrypto_device,
644#endif
645
646#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
647 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
648 &qcedev_device,
649#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -0700650
651#ifdef CONFIG_HW_RANDOM_MSM
652 &apq8064_device_rng,
653#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800654 &apq_pcm,
655 &apq_pcm_routing,
656 &apq_cpudai0,
657 &apq_cpudai1,
658 &apq_cpudai_hdmi_rx,
659 &apq_cpudai_bt_rx,
660 &apq_cpudai_bt_tx,
661 &apq_cpudai_fm_rx,
662 &apq_cpudai_fm_tx,
663 &apq_cpu_fe,
664 &apq_stub_codec,
665 &apq_voice,
666 &apq_voip,
667 &apq_lpa_pcm,
668 &apq_pcm_hostless,
669 &apq_cpudai_afe_01_rx,
670 &apq_cpudai_afe_01_tx,
671 &apq_cpudai_afe_02_rx,
672 &apq_cpudai_afe_02_tx,
673 &apq_pcm_afe,
674 &apq_cpudai_auxpcm_rx,
675 &apq_cpudai_auxpcm_tx,
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700676 &msm_bus_8064_apps_fabric,
677 &msm_bus_8064_sys_fabric,
678 &msm_bus_8064_mm_fabric,
679 &msm_bus_8064_sys_fpb,
680 &msm_bus_8064_cpss_fpb,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600681};
682
Joel King4e7ad222011-08-17 15:47:38 -0700683static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700684 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700685 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700686};
687
688static struct platform_device *rumi3_devices[] __initdata = {
689 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -0800690 &msm_device_sps_apq8064,
Joel King4e7ad222011-08-17 15:47:38 -0700691};
692
Joel King82b7e3f2012-01-05 10:03:27 -0800693static struct platform_device *cdp_devices[] __initdata = {
694 &apq8064_device_uart_gsbi1,
695 &msm_device_sps_apq8064,
696};
697
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600698static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700699 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700700};
701
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700702#define KS8851_IRQ_GPIO 43
703
704static struct spi_board_info spi_board_info[] __initdata = {
705 {
706 .modalias = "ks8851",
707 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
708 .max_speed_hz = 19200000,
709 .bus_num = 0,
710 .chip_select = 2,
711 .mode = SPI_MODE_0,
712 },
713};
714
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600715static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800716 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800717 .bus_num = 1,
718 .slim_slave = &apq8064_slim_tabla,
719 },
720 {
721 .bus_num = 1,
722 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800723 },
724 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600725};
726
Kenneth Heitke748593a2011-07-15 15:45:11 -0600727static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
728 .clk_freq = 100000,
729 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600730};
731
732static void __init apq8064_i2c_init(void)
733{
734 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
735 &apq8064_i2c_qup_gsbi4_pdata;
736}
737
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700738#ifdef CONFIG_KS8851
739static int ethernet_init(void)
740{
741 int ret;
742 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
743 if (ret) {
744 pr_err("ks8851 gpio_request failed: %d\n", ret);
745 goto fail;
746 }
747
748 return 0;
749fail:
750 return ret;
751}
752#else
753static int ethernet_init(void)
754{
755 return 0;
756}
757#endif
758
Tianyi Gou41515e22011-09-01 19:37:43 -0700759static void __init apq8064_clock_init(void)
760{
761 if (machine_is_apq8064_sim())
762 msm_clock_init(&apq8064_clock_init_data);
763 else
764 msm_clock_init(&apq8064_dummy_clock_init_data);
765}
766
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700767static void __init apq8064_common_init(void)
768{
769 if (socinfo_init() < 0)
770 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700771 apq8064_clock_init();
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800772 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600773 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600774
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600775 apq8064_device_qup_spi_gsbi5.dev.platform_data =
776 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800777 apq8064_init_pmic();
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700778 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Gagan Mac8a7a5d32011-11-11 16:43:06 -0700779 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700780 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530781 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600782 slim_register_board_info(apq8064_slim_devices,
783 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700784}
785
786static void __init apq8064_sim_init(void)
787{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700788 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
789 &msm8064_device_watchdog.dev.platform_data;
790
791 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700792 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700793 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
794}
795
796static void __init apq8064_rumi3_init(void)
797{
798 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700799 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700800 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700801 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802}
803
Joel King82b7e3f2012-01-05 10:03:27 -0800804static void __init apq8064_cdp_init(void)
805{
806 apq8064_common_init();
807 ethernet_init();
808 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
809 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
810}
811
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700812MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
813 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700814 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700815 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530816 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817 .timer = &msm_timer,
818 .init_machine = apq8064_sim_init,
819MACHINE_END
820
Joel King4e7ad222011-08-17 15:47:38 -0700821MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
822 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700823 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700824 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530825 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -0700826 .timer = &msm_timer,
827 .init_machine = apq8064_rumi3_init,
828MACHINE_END
829
Joel King82b7e3f2012-01-05 10:03:27 -0800830MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
831 .map_io = apq8064_map_io,
832 .reserve = apq8064_reserve,
833 .init_irq = apq8064_init_irq,
834 .handle_irq = gic_handle_irq,
835 .timer = &msm_timer,
836 .init_machine = apq8064_cdp_init,
837MACHINE_END
838
839MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
840 .map_io = apq8064_map_io,
841 .reserve = apq8064_reserve,
842 .init_irq = apq8064_init_irq,
843 .handle_irq = gic_handle_irq,
844 .timer = &msm_timer,
845 .init_machine = apq8064_cdp_init,
846MACHINE_END
847
848MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
849 .map_io = apq8064_map_io,
850 .reserve = apq8064_reserve,
851 .init_irq = apq8064_init_irq,
852 .handle_irq = gic_handle_irq,
853 .timer = &msm_timer,
854 .init_machine = apq8064_cdp_init,
855MACHINE_END
856