blob: b846c439cc0304e076c8912b18f313be860b34b4 [file] [log] [blame]
David Collinsb4558422012-01-05 10:50:49 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002 *
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>
17#include <linux/i2c.h>
18#include <linux/i2c/sx150x.h>
19#include <linux/i2c/isl9519.h>
20#include <linux/gpio.h>
21#include <linux/msm_ssbi.h>
22#include <linux/regulator/gpio-regulator.h>
23#include <linux/mfd/pm8xxx/pm8921.h>
24#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
25#include <linux/regulator/consumer.h>
26#include <linux/spi/spi.h>
27#include <linux/slimbus/slimbus.h>
28#include <linux/bootmem.h>
29#include <linux/msm_kgsl.h>
30#ifdef CONFIG_ANDROID_PMEM
31#include <linux/android_pmem.h>
32#endif
33#include <linux/cyttsp.h>
34#include <linux/dma-mapping.h>
35#include <linux/platform_data/qcom_crypto_device.h>
36#include <linux/platform_data/qcom_wcnss_device.h>
37#include <linux/leds.h>
38#include <linux/leds-pm8xxx.h>
39#include <linux/i2c/atmel_mxt_ts.h>
40#include <linux/msm_tsens.h>
41#include <linux/ks8851.h>
42#include <linux/i2c/isa1200.h>
Anirudh Ghayaleb3af972011-12-13 17:29:06 +053043#include <linux/gpio_keys.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080044
45#include <asm/mach-types.h>
46#include <asm/mach/arch.h>
47#include <asm/setup.h>
48#include <asm/hardware/gic.h>
49#include <asm/mach/mmc.h>
50
51#include <mach/board.h>
52#include <mach/msm_iomap.h>
53#include <mach/msm_spi.h>
54#ifdef CONFIG_USB_MSM_OTG_72K
55#include <mach/msm_hsusb.h>
56#else
57#include <linux/usb/msm_hsusb.h>
58#endif
59#include <linux/usb/android.h>
60#include <mach/usbdiag.h>
61#include <mach/socinfo.h>
62#include <mach/rpm.h>
63#include <mach/gpio.h>
64#include <mach/gpiomux.h>
65#include <mach/msm_bus_board.h>
66#include <mach/msm_memtypes.h>
67#include <mach/dma.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080068#include <mach/msm_xo.h>
69#include <mach/restart.h>
70
71#ifdef CONFIG_WCD9310_CODEC
72#include <linux/slimbus/slimbus.h>
73#include <linux/mfd/wcd9310/core.h>
74#include <linux/mfd/wcd9310/pdata.h>
75#endif
76
77#include <linux/ion.h>
78#include <mach/ion.h>
79#include <mach/mdm2.h>
80
81#include "timer.h"
82#include "devices.h"
83#include "devices-msm8x60.h"
84#include "spm.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080085#include <mach/pm.h>
86#include <mach/cpuidle.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080087#include "rpm_resources.h"
88#include "mpm.h"
89#include "acpuclock.h"
90#include "rpm_log.h"
91#include "smd_private.h"
92#include "pm-boot.h"
93#include "msm_watchdog.h"
Jay Chokshi06fa7542011-12-07 13:09:17 -080094#include "board-8930.h"
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080095
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080096static struct platform_device msm_fm_platform_init = {
97 .name = "iris_fm",
98 .id = -1,
99};
100
101#define KS8851_RST_GPIO 89
102#define KS8851_IRQ_GPIO 90
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800103#define HAP_SHIFT_LVL_OE_GPIO 47
104
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800105#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
106
107struct sx150x_platform_data msm8930_sx150x_data[] = {
108 [SX150X_CAM] = {
109 .gpio_base = GPIO_CAM_EXPANDER_BASE,
110 .oscio_is_gpo = false,
111 .io_pullup_ena = 0x0,
112 .io_pulldn_ena = 0xc0,
113 .io_open_drain_ena = 0x0,
114 .irq_summary = -1,
115 },
116};
117
118#endif
119
120#define MSM_PMEM_ADSP_SIZE 0x3800000
Ben Romberger3ffcd812011-12-08 19:12:10 -0800121#define MSM_PMEM_AUDIO_SIZE 0x2B4000
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800122#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
123#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
124#else
125#define MSM_PMEM_SIZE 0x1C00000 /* 28 Mbytes */
126#endif
127
128
129#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
130#define MSM_PMEM_KERNEL_EBI1_SIZE 0xB0C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800131#define MSM_ION_SF_SIZE 0x1800000 /* 24MB */
132#define MSM_ION_MM_SIZE 0x4000000 /* (64MB) */
133#define MSM_ION_MFC_SIZE SZ_8K
134#define MSM_ION_HEAP_NUM 5
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800135#else
136#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800137#define MSM_ION_HEAP_NUM 1
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800138#endif
139
140#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
141static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
142static int __init pmem_kernel_ebi1_size_setup(char *p)
143{
144 pmem_kernel_ebi1_size = memparse(p, NULL);
145 return 0;
146}
147early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
148#endif
149
150#ifdef CONFIG_ANDROID_PMEM
151static unsigned pmem_size = MSM_PMEM_SIZE;
152static int __init pmem_size_setup(char *p)
153{
154 pmem_size = memparse(p, NULL);
155 return 0;
156}
157early_param("pmem_size", pmem_size_setup);
158
159static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
160
161static int __init pmem_adsp_size_setup(char *p)
162{
163 pmem_adsp_size = memparse(p, NULL);
164 return 0;
165}
166early_param("pmem_adsp_size", pmem_adsp_size_setup);
167
168static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
169
170static int __init pmem_audio_size_setup(char *p)
171{
172 pmem_audio_size = memparse(p, NULL);
173 return 0;
174}
175early_param("pmem_audio_size", pmem_audio_size_setup);
176#endif
177
178#ifdef CONFIG_ANDROID_PMEM
179#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
180static struct android_pmem_platform_data android_pmem_pdata = {
181 .name = "pmem",
182 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
183 .cached = 1,
184 .memory_type = MEMTYPE_EBI1,
185};
186
187static struct platform_device android_pmem_device = {
188 .name = "android_pmem",
189 .id = 0,
190 .dev = {.platform_data = &android_pmem_pdata},
191};
192
193static struct android_pmem_platform_data android_pmem_adsp_pdata = {
194 .name = "pmem_adsp",
195 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
196 .cached = 0,
197 .memory_type = MEMTYPE_EBI1,
198};
199static struct platform_device android_pmem_adsp_device = {
200 .name = "android_pmem",
201 .id = 2,
202 .dev = { .platform_data = &android_pmem_adsp_pdata },
203};
204#endif
205
206static struct android_pmem_platform_data android_pmem_audio_pdata = {
207 .name = "pmem_audio",
208 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
209 .cached = 0,
210 .memory_type = MEMTYPE_EBI1,
211};
212
213static struct platform_device android_pmem_audio_device = {
214 .name = "android_pmem",
215 .id = 4,
216 .dev = { .platform_data = &android_pmem_audio_pdata },
217};
218#endif
219
220#define DSP_RAM_BASE_8960 0x8da00000
221#define DSP_RAM_SIZE_8960 0x1800000
222static int dspcrashd_pdata_8960 = 0xDEADDEAD;
223
224static struct resource resources_dspcrashd_8960[] = {
225 {
226 .name = "msm_dspcrashd",
227 .start = DSP_RAM_BASE_8960,
228 .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
229 .flags = IORESOURCE_DMA,
230 },
231};
232
233static struct platform_device msm_device_dspcrashd_8960 = {
234 .name = "msm_dspcrashd",
235 .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
236 .resource = resources_dspcrashd_8960,
237 .dev = { .platform_data = &dspcrashd_pdata_8960 },
238};
239
240static struct memtype_reserve msm8930_reserve_table[] __initdata = {
241 [MEMTYPE_SMI] = {
242 },
243 [MEMTYPE_EBI0] = {
244 .flags = MEMTYPE_FLAGS_1M_ALIGN,
245 },
246 [MEMTYPE_EBI1] = {
247 .flags = MEMTYPE_FLAGS_1M_ALIGN,
248 },
249};
250
251static void __init size_pmem_devices(void)
252{
253#ifdef CONFIG_ANDROID_PMEM
254#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
255 android_pmem_adsp_pdata.size = pmem_adsp_size;
256 android_pmem_pdata.size = pmem_size;
257#endif
258 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
259#endif
260}
261
262static void __init reserve_memory_for(struct android_pmem_platform_data *p)
263{
264 msm8930_reserve_table[p->memory_type].size += p->size;
265}
266
267static void __init reserve_pmem_memory(void)
268{
269#ifdef CONFIG_ANDROID_PMEM
270#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
271 reserve_memory_for(&android_pmem_adsp_pdata);
272 reserve_memory_for(&android_pmem_pdata);
273#endif
274 reserve_memory_for(&android_pmem_audio_pdata);
275 msm8930_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
276#endif
277}
278
279static int msm8930_paddr_to_memtype(unsigned int paddr)
280{
281 return MEMTYPE_EBI1;
282}
283
284#ifdef CONFIG_ION_MSM
285static struct ion_platform_data ion_pdata = {
286 .nr = MSM_ION_HEAP_NUM,
287 .heaps = {
288 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800289 .id = ION_SYSTEM_HEAP_ID,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800290 .type = ION_HEAP_TYPE_SYSTEM,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800291 .name = ION_VMALLOC_HEAP_NAME,
292 },
293#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
294 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800295 .id = ION_SF_HEAP_ID,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800296 .type = ION_HEAP_TYPE_CARVEOUT,
Olav Hauganb5be7992011-11-18 14:29:02 -0800297 .name = ION_SF_HEAP_NAME,
298 .size = MSM_ION_SF_SIZE,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800299 .memory_type = ION_EBI_TYPE,
300 },
301 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800302 .id = ION_CP_MM_HEAP_ID,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800303 .type = ION_HEAP_TYPE_CARVEOUT,
Olav Hauganb5be7992011-11-18 14:29:02 -0800304 .name = ION_MM_HEAP_NAME,
305 .size = MSM_ION_MM_SIZE,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800306 .memory_type = ION_EBI_TYPE,
307 },
Olav Hauganb5be7992011-11-18 14:29:02 -0800308 {
309 .id = ION_CP_MFC_HEAP_ID,
310 .type = ION_HEAP_TYPE_CARVEOUT,
311 .name = ION_MFC_HEAP_NAME,
312 .size = MSM_ION_MFC_SIZE,
313 .memory_type = ION_EBI_TYPE,
314 },
315 {
316 .id = ION_IOMMU_HEAP_ID,
317 .type = ION_HEAP_TYPE_IOMMU,
318 .name = ION_IOMMU_HEAP_NAME,
319 },
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800320#endif
321 }
322};
323
324static struct platform_device ion_dev = {
325 .name = "ion-msm",
326 .id = 1,
327 .dev = { .platform_data = &ion_pdata },
328};
329#endif
330
331static void reserve_ion_memory(void)
332{
333#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Olav Hauganb5be7992011-11-18 14:29:02 -0800334 msm8930_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
335 msm8930_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
336 msm8930_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800337#endif
338}
Huaibin Yanga5419422011-12-08 23:52:10 -0800339
340static void __init reserve_mdp_memory(void)
341{
342 msm8930_mdp_writeback(msm8930_reserve_table);
343}
344
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800345static void __init msm8930_calculate_reserve_sizes(void)
346{
347 size_pmem_devices();
348 reserve_pmem_memory();
349 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800350 reserve_mdp_memory();
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800351}
352
353static struct reserve_info msm8930_reserve_info __initdata = {
354 .memtype_reserve_table = msm8930_reserve_table,
355 .calculate_reserve_sizes = msm8930_calculate_reserve_sizes,
356 .paddr_to_memtype = msm8930_paddr_to_memtype,
357};
358
359static int msm8930_memory_bank_size(void)
360{
361 return 1<<29;
362}
363
364static void __init locate_unstable_memory(void)
365{
366 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
367 unsigned long bank_size;
368 unsigned long low, high;
369
370 bank_size = msm8930_memory_bank_size();
371 low = meminfo.bank[0].start;
372 high = mb->start + mb->size;
373
374 /* Check if 32 bit overflow occured */
375 if (high < mb->start)
376 high = ~0UL;
377
378 low &= ~(bank_size - 1);
379
380 if (high - low <= bank_size)
381 return;
382 msm8930_reserve_info.low_unstable_address = low + bank_size;
383 /* To avoid overflow of u32 compute max_unstable_size
384 * by first subtracting low from mb->start)
385 * */
386 msm8930_reserve_info.max_unstable_size = (mb->start - low) +
387 mb->size - bank_size;
388
389 msm8930_reserve_info.bank_size = bank_size;
390 pr_info("low unstable address %lx max size %lx bank size %lx\n",
391 msm8930_reserve_info.low_unstable_address,
392 msm8930_reserve_info.max_unstable_size,
393 msm8930_reserve_info.bank_size);
394}
395
396static void __init place_movable_zone(void)
397{
398 movable_reserved_start = msm8930_reserve_info.low_unstable_address;
399 movable_reserved_size = msm8930_reserve_info.max_unstable_size;
400 pr_info("movable zone start %lx size %lx\n",
401 movable_reserved_start, movable_reserved_size);
402}
403
404static void __init msm8930_early_memory(void)
405{
406 reserve_info = &msm8930_reserve_info;
407 locate_unstable_memory();
408 place_movable_zone();
409}
410
411static void __init msm8930_reserve(void)
412{
413 msm_reserve();
414}
415
416static int msm8930_change_memory_power(u64 start, u64 size,
417 int change_type)
418{
419 return soc_change_memory_power(start, size, change_type);
420}
421
422static void __init msm8930_allocate_memory_regions(void)
423{
424 msm8930_allocate_fb_region();
425}
426
427#ifdef CONFIG_WCD9310_CODEC
428
429#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
430
431/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
432 * 4 micbiases are used to power various analog and digital
433 * microphones operating at 1800 mV. Technically, all micbiases
434 * can source from single cfilter since all microphones operate
435 * at the same voltage level. The arrangement below is to make
436 * sure all cfilters are exercised. LDO_H regulator ouput level
437 * does not need to be as high as 2.85V. It is choosen for
438 * microphone sensitivity purpose.
439 */
440static struct tabla_pdata tabla_platform_data = {
441 .slimbus_slave_device = {
442 .name = "tabla-slave",
443 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
444 },
445 .irq = MSM_GPIO_TO_INT(62),
446 .irq_base = TABLA_INTERRUPT_BASE,
447 .num_irqs = NR_TABLA_IRQS,
Jay Chokshi06fa7542011-12-07 13:09:17 -0800448
449/*TODO: Replace this with right PM8038 gpio */
450#ifndef MSM8930_PHASE_2
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800451 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Jay Chokshi06fa7542011-12-07 13:09:17 -0800452#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800453 .micbias = {
454 .ldoh_v = TABLA_LDOH_2P85_V,
455 .cfilt1_mv = 1800,
456 .cfilt2_mv = 1800,
457 .cfilt3_mv = 1800,
458 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
459 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
460 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
461 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
462 }
463};
464
465static struct slim_device msm_slim_tabla = {
466 .name = "tabla-slim",
467 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
468 .dev = {
469 .platform_data = &tabla_platform_data,
470 },
471};
472
473static struct tabla_pdata tabla20_platform_data = {
474 .slimbus_slave_device = {
475 .name = "tabla-slave",
476 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
477 },
478 .irq = MSM_GPIO_TO_INT(62),
479 .irq_base = TABLA_INTERRUPT_BASE,
480 .num_irqs = NR_TABLA_IRQS,
Jay Chokshi06fa7542011-12-07 13:09:17 -0800481
482/*TODO: Replace this with right PM8038 gpio */
483#ifndef MSM8930_PHASE_2
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800484 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Jay Chokshi06fa7542011-12-07 13:09:17 -0800485#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800486 .micbias = {
487 .ldoh_v = TABLA_LDOH_2P85_V,
488 .cfilt1_mv = 1800,
489 .cfilt2_mv = 1800,
490 .cfilt3_mv = 1800,
491 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
492 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
493 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
494 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
495 }
496};
497
498static struct slim_device msm_slim_tabla20 = {
499 .name = "tabla2x-slim",
500 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
501 .dev = {
502 .platform_data = &tabla20_platform_data,
503 },
504};
505#endif
506
507static struct slim_boardinfo msm_slim_devices[] = {
508#ifdef CONFIG_WCD9310_CODEC
509 {
510 .bus_num = 1,
511 .slim_slave = &msm_slim_tabla,
512 },
513 {
514 .bus_num = 1,
515 .slim_slave = &msm_slim_tabla20,
516 },
517#endif
518 /* add more slimbus slaves as needed */
519};
520
521#define MSM_WCNSS_PHYS 0x03000000
522#define MSM_WCNSS_SIZE 0x280000
523
524static struct resource resources_wcnss_wlan[] = {
525 {
526 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
527 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
528 .name = "wcnss_wlanrx_irq",
529 .flags = IORESOURCE_IRQ,
530 },
531 {
532 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
533 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
534 .name = "wcnss_wlantx_irq",
535 .flags = IORESOURCE_IRQ,
536 },
537 {
538 .start = MSM_WCNSS_PHYS,
539 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
540 .name = "wcnss_mmio",
541 .flags = IORESOURCE_MEM,
542 },
543 {
544 .start = 84,
545 .end = 88,
546 .name = "wcnss_gpios_5wire",
547 .flags = IORESOURCE_IO,
548 },
549};
550
551static struct qcom_wcnss_opts qcom_wcnss_pdata = {
552 .has_48mhz_xo = 1,
553};
554
555static struct platform_device msm_device_wcnss_wlan = {
556 .name = "wcnss_wlan",
557 .id = 0,
558 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
559 .resource = resources_wcnss_wlan,
560 .dev = {.platform_data = &qcom_wcnss_pdata},
561};
562
563#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
564 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
565 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
566 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
567
568#define QCE_SIZE 0x10000
569#define QCE_0_BASE 0x18500000
570
571#define QCE_HW_KEY_SUPPORT 0
572#define QCE_SHA_HMAC_SUPPORT 1
573#define QCE_SHARE_CE_RESOURCE 1
574#define QCE_CE_SHARED 0
575
576static struct resource qcrypto_resources[] = {
577 [0] = {
578 .start = QCE_0_BASE,
579 .end = QCE_0_BASE + QCE_SIZE - 1,
580 .flags = IORESOURCE_MEM,
581 },
582 [1] = {
583 .name = "crypto_channels",
584 .start = DMOV_CE_IN_CHAN,
585 .end = DMOV_CE_OUT_CHAN,
586 .flags = IORESOURCE_DMA,
587 },
588 [2] = {
589 .name = "crypto_crci_in",
590 .start = DMOV_CE_IN_CRCI,
591 .end = DMOV_CE_IN_CRCI,
592 .flags = IORESOURCE_DMA,
593 },
594 [3] = {
595 .name = "crypto_crci_out",
596 .start = DMOV_CE_OUT_CRCI,
597 .end = DMOV_CE_OUT_CRCI,
598 .flags = IORESOURCE_DMA,
599 },
600};
601
602static struct resource qcedev_resources[] = {
603 [0] = {
604 .start = QCE_0_BASE,
605 .end = QCE_0_BASE + QCE_SIZE - 1,
606 .flags = IORESOURCE_MEM,
607 },
608 [1] = {
609 .name = "crypto_channels",
610 .start = DMOV_CE_IN_CHAN,
611 .end = DMOV_CE_OUT_CHAN,
612 .flags = IORESOURCE_DMA,
613 },
614 [2] = {
615 .name = "crypto_crci_in",
616 .start = DMOV_CE_IN_CRCI,
617 .end = DMOV_CE_IN_CRCI,
618 .flags = IORESOURCE_DMA,
619 },
620 [3] = {
621 .name = "crypto_crci_out",
622 .start = DMOV_CE_OUT_CRCI,
623 .end = DMOV_CE_OUT_CRCI,
624 .flags = IORESOURCE_DMA,
625 },
626};
627
628#endif
629
630#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
631 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
632
633static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
634 .ce_shared = QCE_CE_SHARED,
635 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
636 .hw_key_support = QCE_HW_KEY_SUPPORT,
637 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
638};
639
640static struct platform_device qcrypto_device = {
641 .name = "qcrypto",
642 .id = 0,
643 .num_resources = ARRAY_SIZE(qcrypto_resources),
644 .resource = qcrypto_resources,
645 .dev = {
646 .coherent_dma_mask = DMA_BIT_MASK(32),
647 .platform_data = &qcrypto_ce_hw_suppport,
648 },
649};
650#endif
651
652#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
653 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
654
655static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
656 .ce_shared = QCE_CE_SHARED,
657 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
658 .hw_key_support = QCE_HW_KEY_SUPPORT,
659 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
660};
661
662static struct platform_device qcedev_device = {
663 .name = "qce",
664 .id = 0,
665 .num_resources = ARRAY_SIZE(qcedev_resources),
666 .resource = qcedev_resources,
667 .dev = {
668 .coherent_dma_mask = DMA_BIT_MASK(32),
669 .platform_data = &qcedev_ce_hw_suppport,
670 },
671};
672#endif
673
674#define MDM2AP_ERRFATAL 70
675#define AP2MDM_ERRFATAL 95
676#define MDM2AP_STATUS 69
677#define AP2MDM_STATUS 94
678#define AP2MDM_PMIC_RESET_N 80
679#define AP2MDM_KPDPWR_N 81
680
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800681static struct resource mdm_resources[] = {
682 {
683 .start = MDM2AP_ERRFATAL,
684 .end = MDM2AP_ERRFATAL,
685 .name = "MDM2AP_ERRFATAL",
686 .flags = IORESOURCE_IO,
687 },
688 {
689 .start = AP2MDM_ERRFATAL,
690 .end = AP2MDM_ERRFATAL,
691 .name = "AP2MDM_ERRFATAL",
692 .flags = IORESOURCE_IO,
693 },
694 {
695 .start = MDM2AP_STATUS,
696 .end = MDM2AP_STATUS,
697 .name = "MDM2AP_STATUS",
698 .flags = IORESOURCE_IO,
699 },
700 {
701 .start = AP2MDM_STATUS,
702 .end = AP2MDM_STATUS,
703 .name = "AP2MDM_STATUS",
704 .flags = IORESOURCE_IO,
705 },
706 {
707 .start = AP2MDM_PMIC_RESET_N,
708 .end = AP2MDM_PMIC_RESET_N,
709 .name = "AP2MDM_PMIC_RESET_N",
710 .flags = IORESOURCE_IO,
711 },
712 {
713 .start = AP2MDM_KPDPWR_N,
714 .end = AP2MDM_KPDPWR_N,
715 .name = "AP2MDM_KPDPWR_N",
716 .flags = IORESOURCE_IO,
717 },
718};
719
720static struct mdm_platform_data mdm_platform_data = {
721 .mdm_version = "2.5",
722};
723
724static struct platform_device mdm_device = {
725 .name = "mdm2_modem",
726 .id = -1,
727 .num_resources = ARRAY_SIZE(mdm_resources),
728 .resource = mdm_resources,
729 .dev = {
730 .platform_data = &mdm_platform_data,
731 },
732};
733
734static struct platform_device *mdm_devices[] __initdata = {
735 &mdm_device,
736};
737
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800738#define MSM_SHARED_RAM_PHYS 0x80000000
739
740static void __init msm8930_map_io(void)
741{
742 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
743 msm_map_msm8930_io();
744
745 if (socinfo_init() < 0)
746 pr_err("socinfo_init() failed!\n");
747}
748
749static void __init msm8930_init_irq(void)
750{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800751 msm_mpm_irq_extn_init();
752 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
753 (void *)MSM_QGIC_CPU_BASE);
754
755 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
756 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
757
758 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
759 mb();
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800760}
761
762static void __init msm8930_init_buses(void)
763{
764#ifdef CONFIG_MSM_BUS_SCALING
765 msm_bus_rpm_set_mt_mask();
766 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
767 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
768 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
769 msm_bus_apps_fabric.dev.platform_data =
770 &msm_bus_8960_apps_fabric_pdata;
771 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
772 msm_bus_mm_fabric.dev.platform_data = &msm_bus_8960_mm_fabric_pdata;
773 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
774 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
775#endif
776}
777
778static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
779 .max_clock_speed = 15060000,
780};
781
782#ifdef CONFIG_USB_MSM_OTG_72K
783static struct msm_otg_platform_data msm_otg_pdata;
784#else
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800785static struct msm_otg_platform_data msm_otg_pdata = {
786 .mode = USB_OTG,
787 .otg_control = OTG_PMIC_CONTROL,
788 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Jay Chokshi06fa7542011-12-07 13:09:17 -0800789 .pmic_id_irq = PM8038_USB_ID_IN_IRQ(PM8038_IRQ_BASE),
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800790 .power_budget = 750,
791};
792#endif
793
794#ifdef CONFIG_USB_EHCI_MSM_HSIC
795#define HSIC_HUB_RESET_GPIO 91
796static struct msm_hsic_host_platform_data msm_hsic_pdata = {
797 .strobe = 150,
798 .data = 151,
799};
800#else
801static struct msm_hsic_host_platform_data msm_hsic_pdata;
802#endif
803
804#define PID_MAGIC_ID 0x71432909
805#define SERIAL_NUM_MAGIC_ID 0x61945374
806#define SERIAL_NUMBER_LENGTH 127
807#define DLOAD_USB_BASE_ADD 0x2A03F0C8
808
809struct magic_num_struct {
810 uint32_t pid;
811 uint32_t serial_num;
812};
813
814struct dload_struct {
815 uint32_t reserved1;
816 uint32_t reserved2;
817 uint32_t reserved3;
818 uint16_t reserved4;
819 uint16_t pid;
820 char serial_number[SERIAL_NUMBER_LENGTH];
821 uint16_t reserved5;
822 struct magic_num_struct magic_struct;
823};
824
825static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
826{
827 struct dload_struct __iomem *dload = 0;
828
829 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
830 if (!dload) {
831 pr_err("%s: cannot remap I/O memory region: %08x\n",
832 __func__, DLOAD_USB_BASE_ADD);
833 return -ENXIO;
834 }
835
836 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
837 __func__, dload, pid, snum);
838 /* update pid */
839 dload->magic_struct.pid = PID_MAGIC_ID;
840 dload->pid = pid;
841
842 /* update serial number */
843 dload->magic_struct.serial_num = 0;
844 if (!snum) {
845 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
846 goto out;
847 }
848
849 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
850 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
851out:
852 iounmap(dload);
853 return 0;
854}
855
856static struct android_usb_platform_data android_usb_pdata = {
857 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
858};
859
860static struct platform_device android_usb_device = {
861 .name = "android_usb",
862 .id = -1,
863 .dev = {
864 .platform_data = &android_usb_pdata,
865 },
866};
867
868static uint8_t spm_wfi_cmd_sequence[] __initdata = {
869 0x03, 0x0f,
870};
871
872static uint8_t spm_power_collapse_without_rpm[] __initdata = {
873 0x00, 0x24, 0x54, 0x10,
874 0x09, 0x03, 0x01,
875 0x10, 0x54, 0x30, 0x0C,
876 0x24, 0x30, 0x0f,
877};
878
879static uint8_t spm_power_collapse_with_rpm[] __initdata = {
880 0x00, 0x24, 0x54, 0x10,
881 0x09, 0x07, 0x01, 0x0B,
882 0x10, 0x54, 0x30, 0x0C,
883 0x24, 0x30, 0x0f,
884};
885
886static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
887 [0] = {
888 .mode = MSM_SPM_MODE_CLOCK_GATING,
889 .notify_rpm = false,
890 .cmd = spm_wfi_cmd_sequence,
891 },
892 [1] = {
893 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
894 .notify_rpm = false,
895 .cmd = spm_power_collapse_without_rpm,
896 },
897 [2] = {
898 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
899 .notify_rpm = true,
900 .cmd = spm_power_collapse_with_rpm,
901 },
902};
903
904static struct msm_spm_platform_data msm_spm_data[] __initdata = {
905 [0] = {
906 .reg_base_addr = MSM_SAW0_BASE,
907 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
908 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
909 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
910#if defined(CONFIG_MSM_AVS_HW)
911 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
912 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
913#endif
914 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
915 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
916 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
917 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
918 .vctl_timeout_us = 50,
919 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
920 .modes = msm_spm_seq_list,
921 },
922 [1] = {
923 .reg_base_addr = MSM_SAW1_BASE,
924 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
925 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
926 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
927#if defined(CONFIG_MSM_AVS_HW)
928 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
929 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
930#endif
931 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
932 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
933 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
934 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
935 .vctl_timeout_us = 50,
936 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
937 .modes = msm_spm_seq_list,
938 },
939};
940
941static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
942 0x00, 0x20, 0x03, 0x20,
943 0x00, 0x0f,
944};
945
946static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
947 0x00, 0x20, 0x34, 0x64,
948 0x48, 0x07, 0x48, 0x20,
949 0x50, 0x64, 0x04, 0x34,
950 0x50, 0x0f,
951};
952static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
953 0x00, 0x10, 0x34, 0x64,
954 0x48, 0x07, 0x48, 0x10,
955 0x50, 0x64, 0x04, 0x34,
956 0x50, 0x0F,
957};
958
959static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
960 [0] = {
961 .mode = MSM_SPM_L2_MODE_RETENTION,
962 .notify_rpm = false,
963 .cmd = l2_spm_wfi_cmd_sequence,
964 },
965 [1] = {
966 .mode = MSM_SPM_L2_MODE_GDHS,
967 .notify_rpm = true,
968 .cmd = l2_spm_gdhs_cmd_sequence,
969 },
970 [2] = {
971 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
972 .notify_rpm = true,
973 .cmd = l2_spm_power_off_cmd_sequence,
974 },
975};
976
977static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
978 [0] = {
979 .reg_base_addr = MSM_SAW_L2_BASE,
980 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
981 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
982 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
983 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
984 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
985 .modes = msm_spm_l2_seq_list,
986 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
987 },
988};
989
Jay Chokshi06fa7542011-12-07 13:09:17 -0800990#/* TODO: Remove this once PM8038 physically becomes
991 * available.
992 */
993#ifndef MSM8930_PHASE_2
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800994#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
995#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
Jay Chokshi06fa7542011-12-07 13:09:17 -0800996#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800997
998static struct msm_xo_voter *xo_handle_d1;
999
1000static int isa1200_power(int on)
1001{
1002 int rc = 0;
1003
1004 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, !!on);
1005
1006 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1007 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1008 if (rc < 0) {
1009 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1010 __func__, on ? "" : "de-", rc);
1011 goto err_xo_vote;
1012 }
1013
1014 return 0;
1015
1016err_xo_vote:
1017 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, !on);
1018 return rc;
1019}
1020
1021static int isa1200_dev_setup(bool enable)
1022{
1023 int rc = 0;
1024
1025 struct pm_gpio hap_gpio_config = {
1026 .direction = PM_GPIO_DIR_OUT,
1027 .pull = PM_GPIO_PULL_NO,
1028 .out_strength = PM_GPIO_STRENGTH_HIGH,
1029 .function = PM_GPIO_FUNC_NORMAL,
1030 .inv_int_pol = 0,
1031 .vin_sel = 2,
1032 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1033 .output_value = 0,
1034 };
1035
1036 if (enable == true) {
1037 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1038 if (rc) {
1039 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1040 __func__, PM_HAP_EN_GPIO, rc);
1041 return rc;
1042 }
1043
1044 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1045 if (rc) {
1046 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1047 __func__, PM_HAP_LEN_GPIO, rc);
1048 return rc;
1049 }
1050
1051 rc = gpio_request(HAP_SHIFT_LVL_OE_GPIO, "hap_shft_lvl_oe");
1052 if (rc) {
1053 pr_err("%s: unable to request gpio %d (%d)\n",
1054 __func__, HAP_SHIFT_LVL_OE_GPIO, rc);
1055 return rc;
1056 }
1057
1058 rc = gpio_direction_output(HAP_SHIFT_LVL_OE_GPIO, 0);
1059 if (rc) {
1060 pr_err("%s: Unable to set direction\n", __func__);
1061 goto free_gpio;
1062 }
1063
1064 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1065 if (IS_ERR(xo_handle_d1)) {
1066 rc = PTR_ERR(xo_handle_d1);
1067 pr_err("%s: failed to get the handle for D1(%d)\n",
1068 __func__, rc);
1069 goto gpio_set_dir;
1070 }
1071 } else {
1072 gpio_free(HAP_SHIFT_LVL_OE_GPIO);
1073
1074 msm_xo_put(xo_handle_d1);
1075 }
1076
1077 return 0;
1078
1079gpio_set_dir:
1080 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, 0);
1081free_gpio:
1082 gpio_free(HAP_SHIFT_LVL_OE_GPIO);
1083 return rc;
1084}
1085
1086static struct isa1200_regulator isa1200_reg_data[] = {
1087 {
1088 .name = "vcc_i2c",
1089 .min_uV = ISA_I2C_VTG_MIN_UV,
1090 .max_uV = ISA_I2C_VTG_MAX_UV,
1091 .load_uA = ISA_I2C_CURR_UA,
1092 },
1093};
1094
1095static struct isa1200_platform_data isa1200_1_pdata = {
1096 .name = "vibrator",
1097 .dev_setup = isa1200_dev_setup,
1098 .power_on = isa1200_power,
1099 .hap_en_gpio = PM_HAP_EN_GPIO,
1100 .hap_len_gpio = PM_HAP_LEN_GPIO,
1101 .max_timeout = 15000,
1102 .mode_ctrl = PWM_GEN_MODE,
1103 .pwm_fd = {
1104 .pwm_div = 256,
1105 },
1106 .is_erm = false,
1107 .smart_en = true,
1108 .ext_clk_en = true,
1109 .chip_en = 1,
1110 .regulator_info = isa1200_reg_data,
1111 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1112};
1113
1114static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1115 {
1116 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1117 .platform_data = &isa1200_1_pdata,
1118 },
1119};
1120
1121#define CYTTSP_TS_GPIO_IRQ 11
1122#define CYTTSP_TS_SLEEP_GPIO 50
1123#define CYTTSP_TS_RESOUT_N_GPIO 52
1124
1125/*virtual key support */
1126static ssize_t tma340_vkeys_show(struct kobject *kobj,
1127 struct kobj_attribute *attr, char *buf)
1128{
1129 return snprintf(buf, 200,
1130 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1131 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1132 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1133 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1134 "\n");
1135}
1136
1137static struct kobj_attribute tma340_vkeys_attr = {
1138 .attr = {
1139 .mode = S_IRUGO,
1140 },
1141 .show = &tma340_vkeys_show,
1142};
1143
1144static struct attribute *tma340_properties_attrs[] = {
1145 &tma340_vkeys_attr.attr,
1146 NULL
1147};
1148
1149static struct attribute_group tma340_properties_attr_group = {
1150 .attrs = tma340_properties_attrs,
1151};
1152
1153
1154static int cyttsp_platform_init(struct i2c_client *client)
1155{
1156 int rc = 0;
1157 static struct kobject *tma340_properties_kobj;
1158
1159 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1160 tma340_properties_kobj = kobject_create_and_add("board_properties",
1161 NULL);
1162 if (tma340_properties_kobj)
1163 rc = sysfs_create_group(tma340_properties_kobj,
1164 &tma340_properties_attr_group);
1165 if (!tma340_properties_kobj || rc)
1166 pr_err("%s: failed to create board_properties\n",
1167 __func__);
1168
1169 return 0;
1170}
1171
1172static struct cyttsp_regulator regulator_data[] = {
1173 {
1174 .name = "vdd",
1175 .min_uV = CY_TMA300_VTG_MIN_UV,
1176 .max_uV = CY_TMA300_VTG_MAX_UV,
1177 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1178 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
1179 },
1180 /* TODO: Remove after runtime PM is enabled in I2C driver */
1181 {
1182 .name = "vcc_i2c",
1183 .min_uV = CY_I2C_VTG_MIN_UV,
1184 .max_uV = CY_I2C_VTG_MAX_UV,
1185 .hpm_load_uA = CY_I2C_CURR_UA,
1186 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
1187 },
1188};
1189
1190static struct cyttsp_platform_data cyttsp_pdata = {
1191 .panel_maxx = 634,
1192 .panel_maxy = 1166,
1193 .disp_maxx = 616,
1194 .disp_maxy = 1023,
1195 .disp_minx = 0,
1196 .disp_miny = 16,
1197 .flags = 0x01,
1198 .gen = CY_GEN3, /* or */
1199 .use_st = CY_USE_ST,
1200 .use_mt = CY_USE_MT,
1201 .use_hndshk = CY_SEND_HNDSHK,
1202 .use_trk_id = CY_USE_TRACKING_ID,
1203 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
1204 .use_gestures = CY_USE_GESTURES,
1205 .fw_fname = "cyttsp_8960_cdp.hex",
1206 /* activate up to 4 groups
1207 * and set active distance
1208 */
1209 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
1210 CY_GEST_GRP3 | CY_GEST_GRP4 |
1211 CY_ACT_DIST,
1212 /* change act_intrvl to customize the Active power state
1213 * scanning/processing refresh interval for Operating mode
1214 */
1215 .act_intrvl = CY_ACT_INTRVL_DFLT,
1216 /* change tch_tmout to customize the touch timeout for the
1217 * Active power state for Operating mode
1218 */
1219 .tch_tmout = CY_TCH_TMOUT_DFLT,
1220 /* change lp_intrvl to customize the Low Power power state
1221 * scanning/processing refresh interval for Operating mode
1222 */
1223 .lp_intrvl = CY_LP_INTRVL_DFLT,
1224 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
1225 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
1226 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1227 .regulator_info = regulator_data,
1228 .num_regulators = ARRAY_SIZE(regulator_data),
1229 .init = cyttsp_platform_init,
1230 .correct_fw_ver = 9,
1231};
1232
1233static struct i2c_board_info cyttsp_info[] __initdata = {
1234 {
1235 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1236 .platform_data = &cyttsp_pdata,
1237#ifndef CY_USE_TIMER
1238 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1239#endif /* CY_USE_TIMER */
1240 },
1241};
1242
Amy Malochef3c9db42011-12-08 15:17:35 -08001243#define MXT_TS_GPIO_IRQ 11
1244#define MXT_TS_RESET_GPIO 52
1245
1246static const u8 mxt_config_data_8930[] = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001247 /* T6 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001248 0, 0, 0, 0, 0, 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001249 /* T38 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001250 15, 1, 0, 15, 12, 11, 0, 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001251 /* T7 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001252 48, 255, 25,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001253 /* T8 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001254 27, 0, 5, 1, 0, 0, 8, 8, 0, 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001255 /* T9 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001256 131, 0, 0, 19, 11, 0, 16, 35, 1, 3,
1257 10, 15, 1, 11, 4, 5, 40, 10, 54, 2,
1258 43, 4, 0, 0, 0, 0, 143, 40, 143, 80,
1259 18, 15, 50, 50, 2,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001260 /* T15 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1262 0,
1263 /* T18 Object */
1264 0, 0,
1265 /* T19 Object */
1266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1267 0, 0, 0, 0, 0, 0,
1268 /* T23 Object */
1269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1270 0, 0, 0, 0, 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001271 /* T25 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001272 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1273 0, 0, 0, 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001274 /* T40 Object */
Amy Malochef3c9db42011-12-08 15:17:35 -08001275 0, 0, 0, 0, 0,
1276 /* T42 Object */
1277 0, 0, 0, 0, 0, 0, 0, 0,
1278 /* T46 Object */
1279 0, 3, 16, 48, 0, 0, 1, 0, 0,
1280 /* T47 Object */
1281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1282 /* T48 Object */
1283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1287 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1288 0, 0, 0, 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001289};
1290
Amy Malochef3c9db42011-12-08 15:17:35 -08001291static ssize_t mxt224e_vkeys_show(struct kobject *kobj,
1292 struct kobj_attribute *attr, char *buf)
1293{
1294 return snprintf(buf, 200,
1295 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":65:938:90:90"
1296 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":208:938:90:90"
1297 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":348:938:90:90"
1298 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":490:938:90:90"
1299 "\n");
1300}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001301
Amy Malochef3c9db42011-12-08 15:17:35 -08001302static struct kobj_attribute mxt224e_vkeys_attr = {
1303 .attr = {
1304 .mode = S_IRUGO,
1305 },
1306 .show = &mxt224e_vkeys_show,
1307};
1308
1309static struct attribute *mxt224e_properties_attrs[] = {
1310 &mxt224e_vkeys_attr.attr,
1311 NULL
1312};
1313
1314static struct attribute_group mxt224e_properties_attr_group = {
1315 .attrs = mxt224e_properties_attrs,
1316};
1317
1318static void mxt_init_vkeys_8930(void)
1319{
1320 int rc;
1321 static struct kobject *mxt224e_properties_kobj;
1322
1323 mxt224e_vkeys_attr.attr.name = "virtualkeys.atmel_mxt_ts";
1324 mxt224e_properties_kobj = kobject_create_and_add("board_properties",
1325 NULL);
1326 if (mxt224e_properties_kobj)
1327 rc = sysfs_create_group(mxt224e_properties_kobj,
1328 &mxt224e_properties_attr_group);
1329 if (!mxt224e_properties_kobj || rc)
1330 pr_err("%s: failed to create board_properties\n",
1331 __func__);
1332
1333 return;
1334}
1335
1336static struct mxt_platform_data mxt_platform_data_8930 = {
1337 .config = mxt_config_data_8930,
1338 .config_length = ARRAY_SIZE(mxt_config_data_8930),
1339 .x_size = 1067,
1340 .y_size = 566,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001341 .irqflags = IRQF_TRIGGER_FALLING,
Anirudh Ghayald7ad84c2012-01-09 09:17:53 +05301342#ifdef MSM8930_PHASE_2
1343 .digital_pwr_regulator = true,
1344#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001345 .i2c_pull_up = true,
Amy Malochef3c9db42011-12-08 15:17:35 -08001346 .reset_gpio = MXT_TS_RESET_GPIO,
1347 .irq_gpio = MXT_TS_GPIO_IRQ,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001348};
1349
Amy Malochef3c9db42011-12-08 15:17:35 -08001350static struct i2c_board_info mxt_device_info_8930[] __initdata = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001351 {
Amy Malochef3c9db42011-12-08 15:17:35 -08001352 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
1353 .platform_data = &mxt_platform_data_8930,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001354 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1355 },
1356};
1357
Anirudh Ghayaleb3af972011-12-13 17:29:06 +05301358#ifdef MSM8930_PHASE_2
1359
1360#define GPIO_VOLUME_UP PM8038_GPIO_PM_TO_SYS(3)
1361#define GPIO_VOLUME_DOWN PM8038_GPIO_PM_TO_SYS(8)
1362#define GPIO_CAMERA_SNAPSHOT PM8038_GPIO_PM_TO_SYS(10)
1363#define GPIO_CAMERA_FOCUS PM8038_GPIO_PM_TO_SYS(11)
1364
1365static struct gpio_keys_button keys_8930[] = {
1366 {
1367 .code = KEY_VOLUMEUP,
1368 .type = EV_KEY,
1369 .desc = "volume_up",
1370 .gpio = GPIO_VOLUME_UP,
1371 .wakeup = 1,
1372 .active_low = 1,
1373 },
1374 {
1375 .code = KEY_VOLUMEDOWN,
1376 .type = EV_KEY,
1377 .desc = "volume_down",
1378 .gpio = GPIO_VOLUME_DOWN,
1379 .wakeup = 1,
1380 .active_low = 1,
1381 },
1382 {
1383 .code = KEY_CAMERA_FOCUS,
1384 .type = EV_KEY,
1385 .desc = "camera_focus",
1386 .gpio = GPIO_CAMERA_FOCUS,
1387 .wakeup = 1,
1388 .active_low = 1,
1389 },
1390 {
1391 .code = KEY_CAMERA_SNAPSHOT,
1392 .type = EV_KEY,
1393 .desc = "camera_snapshot",
1394 .gpio = GPIO_CAMERA_SNAPSHOT,
1395 .wakeup = 1,
1396 .active_low = 1,
1397 },
1398};
1399
1400/* Add GPIO keys for 8930 */
1401static struct gpio_keys_platform_data gpio_keys_8930_pdata = {
1402 .buttons = keys_8930,
1403 .nbuttons = 4,
1404};
1405
1406static struct platform_device gpio_keys_8930 = {
1407 .name = "gpio-keys",
1408 .id = -1,
1409 .dev = {
1410 .platform_data = &gpio_keys_8930_pdata,
1411 },
1412};
1413#endif /* MSM8930_PHASE_2 */
1414
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001415static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
1416 .clk_freq = 100000,
1417 .src_clk_rate = 24000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001418};
1419
1420static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
1421 .clk_freq = 100000,
1422 .src_clk_rate = 24000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001423};
1424
1425static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
1426 .clk_freq = 100000,
1427 .src_clk_rate = 24000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001428};
1429
1430static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
1431 .clk_freq = 100000,
1432 .src_clk_rate = 24000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001433};
1434
1435static struct msm_rpm_platform_data msm_rpm_data = {
1436 .reg_base_addrs = {
1437 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
1438 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
1439 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
1440 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
1441 },
1442
1443 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
1444 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
1445 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
1446 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
1447 .msm_apps_ipc_rpm_val = 4,
1448};
1449
1450static struct ks8851_pdata spi_eth_pdata = {
1451 .irq_gpio = KS8851_IRQ_GPIO,
1452 .rst_gpio = KS8851_RST_GPIO,
1453};
1454
1455static struct spi_board_info spi_board_info[] __initdata = {
1456 {
1457 .modalias = "ks8851",
1458 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
1459 .max_speed_hz = 19200000,
1460 .bus_num = 0,
1461 .chip_select = 0,
1462 .mode = SPI_MODE_0,
1463 .platform_data = &spi_eth_pdata
1464 },
1465 {
1466 .modalias = "dsi_novatek_3d_panel_spi",
1467 .max_speed_hz = 10800000,
1468 .bus_num = 0,
1469 .chip_select = 1,
1470 .mode = SPI_MODE_0,
1471 },
1472};
1473
1474static struct platform_device msm_device_saw_core0 = {
Jay Chokshi06fa7542011-12-07 13:09:17 -08001475 .name = "saw-regulator",
1476 .id = 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001477 .dev = {
David Collinsb4558422012-01-05 10:50:49 -08001478 .platform_data = &msm8930_saw_regulator_core0_pdata,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001479 },
1480};
1481
1482static struct platform_device msm_device_saw_core1 = {
Jay Chokshi06fa7542011-12-07 13:09:17 -08001483 .name = "saw-regulator",
1484 .id = 1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001485 .dev = {
David Collinsb4558422012-01-05 10:50:49 -08001486 .platform_data = &msm8930_saw_regulator_core1_pdata,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001487 },
1488};
1489
1490static struct tsens_platform_data msm_tsens_pdata = {
Jay Chokshi06fa7542011-12-07 13:09:17 -08001491 .slope = 910,
1492 .tsens_factor = 1000,
1493 .hw_type = MSM_8960,
1494 .tsens_num_sensor = 5,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001495};
1496
1497static struct platform_device msm_tsens_device = {
1498 .name = "tsens8960-tm",
1499 .id = -1,
1500 .dev = {
1501 .platform_data = &msm_tsens_pdata,
1502 },
1503};
1504
1505#ifdef CONFIG_MSM_FAKE_BATTERY
1506static struct platform_device fish_battery_device = {
1507 .name = "fish_battery",
1508};
1509#endif
1510
David Collins1d4061b2011-12-06 15:36:40 -08001511#ifndef MSM8930_PHASE_2
1512
1513/* 8930 Phase 1 */
Jay Chokshi06fa7542011-12-07 13:09:17 -08001514static struct platform_device msm8930_device_ext_5v_vreg __devinitdata = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001515 .name = GPIO_REGULATOR_DEV_NAME,
1516 .id = PM8921_MPP_PM_TO_SYS(7),
1517 .dev = {
1518 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
1519 },
1520};
1521
Jay Chokshi06fa7542011-12-07 13:09:17 -08001522static struct platform_device msm8930_device_ext_l2_vreg __devinitdata = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001523 .name = GPIO_REGULATOR_DEV_NAME,
1524 .id = 91,
1525 .dev = {
1526 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
1527 },
1528};
1529
David Collins1d4061b2011-12-06 15:36:40 -08001530#else
1531
1532/* 8930 Phase 2 */
1533static struct platform_device msm8930_device_ext_5v_vreg __devinitdata = {
1534 .name = GPIO_REGULATOR_DEV_NAME,
1535 .id = 63,
1536 .dev = {
1537 .platform_data =
1538 &msm8930_gpio_regulator_pdata[MSM8930_GPIO_VREG_ID_EXT_5V],
1539 },
1540};
1541
1542static struct platform_device msm8930_device_ext_otg_sw_vreg __devinitdata = {
1543 .name = GPIO_REGULATOR_DEV_NAME,
1544 .id = 97,
1545 .dev = {
1546 .platform_data =
1547 &msm8930_gpio_regulator_pdata[MSM8930_GPIO_VREG_ID_EXT_OTG_SW],
1548 },
1549};
1550
1551#endif
1552
Jay Chokshi06fa7542011-12-07 13:09:17 -08001553static struct platform_device msm8930_device_rpm_regulator __devinitdata = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001554 .name = "rpm-regulator",
1555 .id = -1,
1556 .dev = {
Jay Chokshi06fa7542011-12-07 13:09:17 -08001557 /*
1558 * TODO: When physical 8930/PM8038 hardware becomes
1559 * available, replace msm_rpm_regulator_pdata
1560 * with 8930 rpm regulator object.
1561 */
1562#if !defined(MSM8930_PHASE_2)
1563
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001564 .platform_data = &msm_rpm_regulator_pdata,
Jay Chokshi06fa7542011-12-07 13:09:17 -08001565#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001566 },
1567};
1568
1569static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
1570 .phys_addr_base = 0x0010C000,
1571 .reg_offsets = {
1572 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000080,
1573 [MSM_RPM_LOG_PAGE_BUFFER] = 0x000000A0,
1574 },
1575 .phys_size = SZ_8K,
1576 .log_len = 4096, /* log's buffer length in bytes */
1577 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
1578};
1579
1580static struct platform_device msm_rpm_log_device = {
1581 .name = "msm_rpm_log",
1582 .id = -1,
1583 .dev = {
1584 .platform_data = &msm_rpm_log_pdata,
1585 },
1586};
1587
1588static struct platform_device *common_devices[] __initdata = {
1589 &msm8960_device_dmov,
1590 &msm_device_smd,
1591 &msm8960_device_uart_gsbi5,
1592 &msm_device_uart_dm6,
1593 &msm_device_saw_core0,
1594 &msm_device_saw_core1,
Jay Chokshi06fa7542011-12-07 13:09:17 -08001595 &msm8930_device_ext_5v_vreg,
David Collins1d4061b2011-12-06 15:36:40 -08001596#ifndef MSM8930_PHASE_2
Jay Chokshi06fa7542011-12-07 13:09:17 -08001597 &msm8930_device_ext_l2_vreg,
David Collins1d4061b2011-12-06 15:36:40 -08001598#endif
Jay Chokshi33c044a2011-12-07 13:05:40 -08001599 &msm8960_device_ssbi_pmic,
David Collins1d4061b2011-12-06 15:36:40 -08001600#ifdef MSM8930_PHASE_2
1601 &msm8930_device_ext_otg_sw_vreg,
1602#endif
Stephen Boyd28d54952011-12-16 13:19:51 -08001603 &msm_8960_q6_lpass,
1604 &msm_8960_q6_mss_fw,
1605 &msm_8960_q6_mss_sw,
Stephen Boyd322a9922011-09-20 01:05:54 -07001606 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07001607 &msm_pil_tzapps,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001608 &msm8960_device_qup_spi_gsbi1,
1609 &msm8960_device_qup_i2c_gsbi3,
1610 &msm8960_device_qup_i2c_gsbi4,
1611 &msm8960_device_qup_i2c_gsbi10,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001612 &msm8960_device_qup_i2c_gsbi12,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001613 &msm_slim_ctrl,
1614 &msm_device_wcnss_wlan,
1615#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1616 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1617 &qcrypto_device,
1618#endif
1619
1620#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1621 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1622 &qcedev_device,
1623#endif
1624#ifdef CONFIG_MSM_ROTATOR
1625 &msm_rotator_device,
1626#endif
1627 &msm_device_sps,
1628#ifdef CONFIG_MSM_FAKE_BATTERY
1629 &fish_battery_device,
1630#endif
1631#ifdef CONFIG_ANDROID_PMEM
1632#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
1633 &android_pmem_device,
1634 &android_pmem_adsp_device,
1635#endif
1636 &android_pmem_audio_device,
1637#endif
1638 &msm_device_vidc,
1639 &msm_device_bam_dmux,
1640 &msm_fm_platform_init,
1641
1642#ifdef CONFIG_HW_RANDOM_MSM
1643 &msm_device_rng,
1644#endif
1645 &msm_rpm_device,
1646#ifdef CONFIG_ION_MSM
1647 &ion_dev,
1648#endif
1649 &msm_rpm_log_device,
1650 &msm_rpm_stat_device,
1651 &msm_device_tz_log,
1652
1653#ifdef CONFIG_MSM_QDSS
1654 &msm_etb_device,
1655 &msm_tpiu_device,
1656 &msm_funnel_device,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001657 &msm_ptm_device,
1658#endif
1659 &msm_device_dspcrashd_8960,
1660 &msm8960_device_watchdog,
Anirudh Ghayaleb3af972011-12-13 17:29:06 +05301661#ifdef MSM8930_PHASE_2
1662 &gpio_keys_8930,
1663#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001664};
1665
1666static struct platform_device *cdp_devices[] __initdata = {
1667 &msm8960_device_otg,
1668 &msm8960_device_gadget_peripheral,
1669 &msm_device_hsusb_host,
1670 &android_usb_device,
1671 &msm_pcm,
1672 &msm_pcm_routing,
1673 &msm_cpudai0,
1674 &msm_cpudai1,
1675 &msm_cpudai_hdmi_rx,
1676 &msm_cpudai_bt_rx,
1677 &msm_cpudai_bt_tx,
1678 &msm_cpudai_fm_rx,
1679 &msm_cpudai_fm_tx,
1680 &msm_cpudai_auxpcm_rx,
1681 &msm_cpudai_auxpcm_tx,
1682 &msm_cpu_fe,
1683 &msm_stub_codec,
1684 &msm_kgsl_3d0,
1685#ifdef CONFIG_MSM_KGSL_2D
1686 &msm_kgsl_2d0,
1687 &msm_kgsl_2d1,
1688#endif
1689#ifdef CONFIG_MSM_GEMINI
1690 &msm8960_gemini_device,
1691#endif
1692 &msm_voice,
1693 &msm_voip,
1694 &msm_lpa_pcm,
1695 &msm_cpudai_afe_01_rx,
1696 &msm_cpudai_afe_01_tx,
1697 &msm_cpudai_afe_02_rx,
1698 &msm_cpudai_afe_02_tx,
1699 &msm_pcm_afe,
Ajay Dudani79e268c2011-12-28 13:14:44 -08001700 &msm_compr_dsp,
1701 &msm_cpudai_incall_music_rx,
1702 &msm_cpudai_incall_record_rx,
1703 &msm_cpudai_incall_record_tx,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001704 &msm_pcm_hostless,
1705 &msm_bus_apps_fabric,
1706 &msm_bus_sys_fabric,
1707 &msm_bus_mm_fabric,
1708 &msm_bus_sys_fpb,
1709 &msm_bus_cpss_fpb,
1710 &msm_tsens_device,
1711};
1712
1713static void __init msm8930_i2c_init(void)
1714{
1715 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
1716 &msm8960_i2c_qup_gsbi4_pdata;
1717
1718 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
1719 &msm8960_i2c_qup_gsbi3_pdata;
1720
1721 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
1722 &msm8960_i2c_qup_gsbi10_pdata;
1723
1724 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
1725 &msm8960_i2c_qup_gsbi12_pdata;
1726}
1727
1728static void __init msm8930_gfx_init(void)
1729{
1730 uint32_t soc_platform_version = socinfo_get_version();
1731 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
1732 struct kgsl_device_platform_data *kgsl_3d0_pdata =
1733 msm_kgsl_3d0.dev.platform_data;
1734 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
1735 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
1736 }
1737}
1738
1739static struct msm_cpuidle_state msm_cstates[] __initdata = {
1740 {0, 0, "C0", "WFI",
1741 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
1742
1743 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
1744 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
1745
1746 {0, 2, "C2", "POWER_COLLAPSE",
1747 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
1748
1749 {1, 0, "C0", "WFI",
1750 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
1751
1752 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
1753 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
1754};
1755
1756static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
1757 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
1758 .idle_supported = 1,
1759 .suspend_supported = 1,
1760 .idle_enabled = 0,
1761 .suspend_enabled = 0,
1762 },
1763
1764 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
1765 .idle_supported = 1,
1766 .suspend_supported = 1,
1767 .idle_enabled = 0,
1768 .suspend_enabled = 0,
1769 },
1770
1771 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
1772 .idle_supported = 1,
1773 .suspend_supported = 1,
1774 .idle_enabled = 1,
1775 .suspend_enabled = 1,
1776 },
1777
1778 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
1779 .idle_supported = 0,
1780 .suspend_supported = 1,
1781 .idle_enabled = 0,
1782 .suspend_enabled = 0,
1783 },
1784
1785 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
1786 .idle_supported = 1,
1787 .suspend_supported = 1,
1788 .idle_enabled = 0,
1789 .suspend_enabled = 0,
1790 },
1791
1792 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
1793 .idle_supported = 1,
1794 .suspend_supported = 0,
1795 .idle_enabled = 1,
1796 .suspend_enabled = 0,
1797 },
1798};
1799
1800static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
1801 {
1802 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1803 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1804 true,
1805 100, 8000, 100000, 1,
1806 },
1807
1808 {
1809 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1810 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1811 true,
1812 2000, 6000, 60100000, 3000,
1813 },
1814
1815 {
1816 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1817 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
1818 false,
1819 4200, 5000, 60350000, 3500,
1820 },
1821
1822 {
1823 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1824 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
1825 false,
1826 6300, 4500, 65350000, 4800,
1827 },
1828 {
1829 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1830 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
1831 false,
1832 7000, 3500, 66600000, 5150,
1833 },
1834
1835 {
1836 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1837 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
1838 false,
1839 11700, 2500, 67850000, 5500,
1840 },
1841
1842 {
1843 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1844 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
1845 false,
1846 13800, 2000, 71850000, 6800,
1847 },
1848
1849 {
1850 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1851 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
1852 false,
1853 29700, 500, 75850000, 8800,
1854 },
1855
1856 {
1857 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1858 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
1859 false,
1860 29700, 0, 76350000, 9800,
1861 },
1862};
1863
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001864static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1865 .mode = MSM_PM_BOOT_CONFIG_TZ,
1866};
1867
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001868#ifdef CONFIG_I2C
1869#define I2C_SURF 1
1870#define I2C_FFA (1 << 1)
1871#define I2C_RUMI (1 << 2)
1872#define I2C_SIM (1 << 3)
1873#define I2C_FLUID (1 << 4)
1874#define I2C_LIQUID (1 << 5)
1875
1876struct i2c_registry {
1877 u8 machs;
1878 int bus;
1879 struct i2c_board_info *info;
1880 int len;
1881};
1882
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001883static void __init msm8930_init_hsic(void)
1884{
1885#ifdef CONFIG_USB_EHCI_MSM_HSIC
1886 uint32_t version = socinfo_get_version();
1887
1888 pr_info("%s: version:%d mtp:%d\n", __func__,
1889 SOCINFO_VERSION_MAJOR(version),
1890 machine_is_msm8930_mtp());
1891
1892 if ((SOCINFO_VERSION_MAJOR(version) == 1) ||
1893 machine_is_msm8930_mtp() ||
1894 machine_is_msm8930_fluid())
1895 return;
1896
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001897 platform_device_register(&msm_device_hsic_host);
1898#endif
1899}
1900
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001901#ifdef CONFIG_ISL9519_CHARGER
1902static struct isl_platform_data isl_data __initdata = {
1903 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
1904 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
1905 .max_system_voltage = 4200,
1906 .min_system_voltage = 3200,
1907 .chgcurrent = 1000, /* 1900, */
1908 .term_current = 400, /* Need fine tuning */
1909 .input_current = 2048,
1910};
1911
1912static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
1913 {
1914 I2C_BOARD_INFO("isl9519q", 0x9),
1915 .irq = 0, /* Not required when notify-by-pmic */
1916 .platform_data = &isl_data,
1917 },
1918};
1919#endif /* CONFIG_ISL9519_CHARGER */
1920
1921static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001922#ifdef CONFIG_ISL9519_CHARGER
1923 {
1924 I2C_LIQUID,
1925 MSM_8930_GSBI10_QUP_I2C_BUS_ID,
1926 isl_charger_i2c_info,
1927 ARRAY_SIZE(isl_charger_i2c_info),
1928 },
1929#endif /* CONFIG_ISL9519_CHARGER */
1930 {
1931 I2C_SURF | I2C_FFA | I2C_FLUID,
1932 MSM_8930_GSBI3_QUP_I2C_BUS_ID,
1933 cyttsp_info,
1934 ARRAY_SIZE(cyttsp_info),
1935 },
1936 {
1937 I2C_LIQUID,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001938 MSM_8930_GSBI10_QUP_I2C_BUS_ID,
1939 msm_isa1200_board_info,
1940 ARRAY_SIZE(msm_isa1200_board_info),
1941 },
Amy Malochef3c9db42011-12-08 15:17:35 -08001942 {
1943 I2C_SURF,
1944 MSM_8930_GSBI3_QUP_I2C_BUS_ID,
1945 mxt_device_info_8930,
1946 ARRAY_SIZE(mxt_device_info_8930),
1947 },
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001948};
1949#endif /* CONFIG_I2C */
1950
1951static void __init register_i2c_devices(void)
1952{
1953#ifdef CONFIG_I2C
1954 u8 mach_mask = 0;
1955 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08001956#ifdef CONFIG_MSM_CAMERA
1957 struct i2c_registry msm8930_camera_i2c_devices = {
1958 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
1959 MSM_8930_GSBI4_QUP_I2C_BUS_ID,
1960 msm8930_camera_board_info.board_info,
1961 msm8930_camera_board_info.num_i2c_board_info,
1962 };
1963#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001964
1965 /* Build the matching 'supported_machs' bitmask */
Stepan Moskovchenko8768eff2011-12-01 18:55:07 -08001966 if (machine_is_msm8930_cdp() || machine_is_msm8627_cdp())
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001967 mach_mask = I2C_SURF;
1968 else if (machine_is_msm8930_fluid())
1969 mach_mask = I2C_FLUID;
Stepan Moskovchenko8768eff2011-12-01 18:55:07 -08001970 else if (machine_is_msm8930_mtp() || machine_is_msm8627_mtp())
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001971 mach_mask = I2C_FFA;
1972 else
1973 pr_err("unmatched machine ID in register_i2c_devices\n");
1974
1975 /* Run the array and install devices as appropriate */
1976 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
1977 if (msm8960_i2c_devices[i].machs & mach_mask)
1978 i2c_register_board_info(msm8960_i2c_devices[i].bus,
1979 msm8960_i2c_devices[i].info,
1980 msm8960_i2c_devices[i].len);
1981 }
Kevin Chan09f4e662011-12-16 08:17:02 -08001982#ifdef CONFIG_MSM_CAMERA
1983 if (msm8930_camera_i2c_devices.machs & mach_mask)
1984 i2c_register_board_info(msm8930_camera_i2c_devices.bus,
1985 msm8930_camera_i2c_devices.info,
1986 msm8930_camera_i2c_devices.len);
1987#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001988#endif
1989}
1990
1991static void __init msm8930_cdp_init(void)
1992{
1993 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
1994 pr_err("meminfo_init() failed!\n");
1995
1996 BUG_ON(msm_rpm_init(&msm_rpm_data));
1997 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
1998 ARRAY_SIZE(msm_rpmrs_levels)));
1999
2000 regulator_suppress_info_printing();
2001 if (msm_xo_init())
2002 pr_err("Failed to initialize XO votes\n");
Jay Chokshi06fa7542011-12-07 13:09:17 -08002003 platform_device_register(&msm8930_device_rpm_regulator);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002004 msm_clock_init(&msm8960_clock_init_data);
2005 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
2006 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08002007 msm8930_init_gpiomux();
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002008 msm8960_device_qup_spi_gsbi1.dev.platform_data =
2009 &msm8960_qup_spi_gsbi1_pdata;
2010 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
2011
Jay Chokshi06fa7542011-12-07 13:09:17 -08002012 /*
2013 * TODO: When physical 8930/PM8038 hardware becomes
2014 * available, remove this block or add the config
2015 * option.
2016 */
2017#ifndef MSM8930_PHASE_2
2018 msm8960_init_pmic();
2019#else
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002020 msm8930_init_pmic();
Jay Chokshi06fa7542011-12-07 13:09:17 -08002021#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002022 msm8930_i2c_init();
2023 msm8930_gfx_init();
2024 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
2025 msm_spm_l2_init(msm_spm_l2_data);
2026 msm8930_init_buses();
2027 platform_add_devices(msm_footswitch_devices,
2028 msm_num_footswitch_devices);
2029 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Jay Chokshi06fa7542011-12-07 13:09:17 -08002030 /*
2031 * TODO: When physical 8930/PM8038 hardware becomes
2032 * available, remove this block or add the config
2033 * option.
2034 */
2035#ifndef MSM8930_PHASE_2
2036 msm8960_pm8921_gpio_mpp_init();
2037#else
2038 msm8930_pm8038_gpio_mpp_init();
2039#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002040 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
2041 msm8930_init_hsic();
2042 msm8930_init_cam();
2043 msm8930_init_mmc();
Tianyi Gou7c6b81f2011-12-07 23:09:08 -08002044 acpuclk_init(&acpuclk_8930_soc_data);
Amy Malochef3c9db42011-12-08 15:17:35 -08002045 if (machine_is_msm8930_cdp() || machine_is_msm8627_cdp())
2046 mxt_init_vkeys_8930();
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002047 register_i2c_devices();
2048 msm8930_init_fb();
2049 slim_register_board_info(msm_slim_devices,
2050 ARRAY_SIZE(msm_slim_devices));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002051 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
2052 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
2053 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
2054 msm_pm_data);
2055 change_memory_power = &msm8930_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002056 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002057
2058 if (PLATFORM_IS_CHARM25())
2059 platform_add_devices(mdm_devices, ARRAY_SIZE(mdm_devices));
2060}
2061
2062MACHINE_START(MSM8930_CDP, "QCT MSM8930 CDP")
2063 .map_io = msm8930_map_io,
2064 .reserve = msm8930_reserve,
2065 .init_irq = msm8930_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302066 .handle_irq = gic_handle_irq,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002067 .timer = &msm_timer,
2068 .init_machine = msm8930_cdp_init,
2069 .init_early = msm8930_allocate_memory_regions,
2070 .init_very_early = msm8930_early_memory,
2071MACHINE_END
2072
2073MACHINE_START(MSM8930_MTP, "QCT MSM8930 MTP")
2074 .map_io = msm8930_map_io,
2075 .reserve = msm8930_reserve,
2076 .init_irq = msm8930_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302077 .handle_irq = gic_handle_irq,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002078 .timer = &msm_timer,
2079 .init_machine = msm8930_cdp_init,
2080 .init_early = msm8930_allocate_memory_regions,
2081 .init_very_early = msm8930_early_memory,
2082MACHINE_END
2083
2084MACHINE_START(MSM8930_FLUID, "QCT MSM8930 FLUID")
2085 .map_io = msm8930_map_io,
2086 .reserve = msm8930_reserve,
2087 .init_irq = msm8930_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302088 .handle_irq = gic_handle_irq,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002089 .timer = &msm_timer,
2090 .init_machine = msm8930_cdp_init,
2091 .init_early = msm8930_allocate_memory_regions,
2092 .init_very_early = msm8930_early_memory,
2093MACHINE_END
Stepan Moskovchenko8768eff2011-12-01 18:55:07 -08002094
2095MACHINE_START(MSM8627_CDP, "QCT MSM8627 CDP")
2096 .map_io = msm8930_map_io,
2097 .reserve = msm8930_reserve,
2098 .init_irq = msm8930_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302099 .handle_irq = gic_handle_irq,
Stepan Moskovchenko8768eff2011-12-01 18:55:07 -08002100 .timer = &msm_timer,
2101 .init_machine = msm8930_cdp_init,
2102 .init_early = msm8930_allocate_memory_regions,
2103 .init_very_early = msm8930_early_memory,
2104MACHINE_END
2105
2106MACHINE_START(MSM8627_MTP, "QCT MSM8627 MTP")
2107 .map_io = msm8930_map_io,
2108 .reserve = msm8930_reserve,
2109 .init_irq = msm8930_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302110 .handle_irq = gic_handle_irq,
Stepan Moskovchenko8768eff2011-12-01 18:55:07 -08002111 .timer = &msm_timer,
2112 .init_machine = msm8930_cdp_init,
2113 .init_early = msm8930_allocate_memory_regions,
2114 .init_very_early = msm8930_early_memory,
2115MACHINE_END