blob: 9dce07fd8ebf28116fad5d44299ba687f5c60424 [file] [log] [blame]
Laura Abbott03e3cd72013-02-09 09:35:30 -08001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -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 *
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080012 */
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/i2c.h>
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -070018#include <linux/i2c/sx150x.h>
Amir Samuelov5137e392011-09-21 17:31:25 +030019#include <linux/i2c/isl9519.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/gpio.h>
21#include <linux/msm_ssbi.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070022#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <linux/mfd/pm8xxx/pm8921.h>
Siddartha Mohanadossaf91d902011-10-20 10:23:34 -070024#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025#include <linux/regulator/consumer.h>
26#include <linux/spi/spi.h>
27#include <linux/slimbus/slimbus.h>
28#include <linux/bootmem.h>
29#ifdef CONFIG_ANDROID_PMEM
30#include <linux/android_pmem.h>
31#endif
Steve Mucklef132c6c2012-06-06 18:30:57 -070032#include <linux/cyttsp-qc.h>
Laura Abbott354d40f2012-08-03 17:32:09 -070033#include <linux/dma-contiguous.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include <linux/dma-mapping.h>
35#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070036#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037#include <linux/leds.h>
38#include <linux/leds-pm8xxx.h>
Mohan Pallaka50837382011-09-07 11:00:57 +053039#include <linux/i2c/atmel_mxt_ts.h>
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -070040#include <linux/msm_tsens.h>
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -070041#include <linux/ks8851.h>
Mohan Pallaka5e490392011-09-09 15:18:41 +053042#include <linux/i2c/isa1200.h>
Jack Cheung0b1987e2011-11-18 13:36:29 -080043#include <linux/memory.h>
Larry Bassel2d8b42d2012-03-12 10:41:26 -070044#include <linux/memblock.h>
Praveen Chidambaram877d7a42012-06-05 14:33:20 -060045#include <linux/msm_thermal.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080046
47#include <asm/mach-types.h>
48#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070049#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080050#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080052
53#include <mach/board.h>
Joel Nider266a2642011-10-16 10:58:05 +020054#include <mach/msm_tspp.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080055#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <mach/msm_spi.h>
Mayank Ranae009c922012-03-22 03:02:06 +053057#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#ifdef CONFIG_USB_MSM_OTG_72K
59#include <mach/msm_hsusb.h>
60#else
61#include <linux/usb/msm_hsusb.h>
62#endif
63#include <linux/usb/android.h>
64#include <mach/usbdiag.h>
65#include <mach/socinfo.h>
66#include <mach/rpm.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070067#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068#include <mach/msm_bus_board.h>
69#include <mach/msm_memtypes.h>
70#include <mach/dma.h>
71#include <mach/msm_dsps.h>
72#include <mach/msm_xo.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070073#include <mach/restart.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080074
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075#ifdef CONFIG_WCD9310_CODEC
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053076#include <linux/mfd/wcd9xxx/core.h>
77#include <linux/mfd/wcd9xxx/pdata.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078#endif
79
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +053080#include <linux/smsc3503.h>
Mitchel Humpherys9dc32cf2012-09-06 11:34:03 -070081#include <linux/msm_ion.h>
Laura Abbottd6183792011-08-19 13:42:24 -070082#include <mach/ion.h>
Joel Kingb8352a12011-11-15 18:46:24 -080083#include <mach/mdm2.h>
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -080084#include <mach/mdm-peripheral.h>
Laura Abbottf8c03b92012-02-16 14:57:58 -080085#include <mach/msm_rtb.h>
Laura Abbott306bcc22012-03-08 11:24:53 -080086#include <mach/msm_cache_dump.h>
87#include <mach/scm.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070088#include <mach/iommu_domains.h>
Laura Abbottd6183792011-08-19 13:42:24 -070089
Jordan Crouse914de9b2012-07-09 13:49:46 -060090#include <mach/kgsl.h>
Larry Bassel41a055b2011-12-06 16:15:14 -080091#include <linux/fmem.h>
92
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080094#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#include "spm.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080097#include "board-8960.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080098#include "pm.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080099#include <mach/cpuidle.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100#include "rpm_resources.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +0530101#include <mach/mpm.h>
Matt Wagantalld55b90f2012-02-23 23:27:44 -0800102#include "clock.h"
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700103#include "smd_private.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600104#include "pm-boot.h"
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700105#include "msm_watchdog.h"
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800106
Ming-yi Lin2d43cd52012-10-17 11:50:15 +0800107#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
108#include <linux/wlan_plat.h>
109#include <linux/mutex.h>
110#endif
111
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112static struct platform_device msm_fm_platform_init = {
113 .name = "iris_fm",
114 .id = -1,
115};
116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117#define KS8851_RST_GPIO 89
118#define KS8851_IRQ_GPIO 90
Mohan Pallaka5e490392011-09-09 15:18:41 +0530119
Manoj Rao14648742012-03-30 19:42:12 -0700120#define MHL_GPIO_INT 4
121#define MHL_GPIO_RESET 15
122
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700123#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700124
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800125struct sx150x_platform_data msm8960_sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700126 [SX150X_CAM] = {
127 .gpio_base = GPIO_CAM_EXPANDER_BASE,
128 .oscio_is_gpo = false,
129 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530130 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700131 .io_open_drain_ena = 0x0,
132 .irq_summary = -1,
133 },
Amir Samuelov755616d2011-12-13 16:34:46 +0200134 [SX150X_LIQUID] = {
135 .gpio_base = GPIO_LIQUID_EXPANDER_BASE,
136 .oscio_is_gpo = false,
137 .io_pullup_ena = 0x0c08,
138 .io_pulldn_ena = 0x4060,
139 .io_open_drain_ena = 0x000c,
140 .io_polarity = 0,
141 .irq_summary = -1,
142 },
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700143};
Nishant Pandit474f2252011-07-23 23:17:56 +0530144
145#endif
146
Olav Haugana21169d2012-01-04 09:17:06 -0800147#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -0700148#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Mathew Karimpanal15fa5c42011-12-14 21:28:10 -0800149#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800150#define MSM_LIQUID_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800151#define MSM_HDMI_PRIM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Laura Abbott2d1760b2011-09-29 21:31:24 -0700152
153#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Deepak Kotur35825522012-06-06 15:49:14 -0700154#define HOLE_SIZE 0x20000
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700155#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan32594552012-03-13 11:40:05 -0700156#ifdef CONFIG_MSM_IOMMU
Olav Haugan8726caf2012-05-10 15:11:35 -0700157#define MSM_ION_MM_SIZE 0x3800000 /* Need to be multiple of 64K */
Olav Haugan32594552012-03-13 11:40:05 -0700158#define MSM_ION_SF_SIZE 0x0
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700159#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Laura Abbott03e3cd72013-02-09 09:35:30 -0800160#define MSM_ION_HEAP_NUM 8
Olav Haugan32594552012-03-13 11:40:05 -0700161#else
162#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
163#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700164#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700165#define MSM_ION_HEAP_NUM 8
166#endif
Deepak Kotur35825522012-06-06 15:49:14 -0700167#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 128kb */
Praveen Chavand0857552013-01-31 20:06:07 -0800168#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan7355db02012-01-13 16:59:13 -0800169#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan32594552012-03-13 11:40:05 -0700170
Olav Hauganb5be7992011-11-18 14:29:02 -0800171#define MSM_LIQUID_ION_MM_SIZE (MSM_ION_MM_SIZE + 0x600000)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800172#define MSM_LIQUID_ION_SF_SIZE MSM_LIQUID_PMEM_SIZE
173#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SIZE
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700174
Deepak Kotur35825522012-06-06 15:49:14 -0700175#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 2mb -128kb*/
176#define MSM8960_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
177 HOLE_SIZE))
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700178#define MAX_FIXED_AREA_SIZE 0x10000000
Deepak Kotur35825522012-06-06 15:49:14 -0700179#define MSM8960_FW_START MSM8960_FIXED_AREA_START
Laura Abbott03e3cd72013-02-09 09:35:30 -0800180#define MSM_ION_ADSP_SIZE SZ_8M
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700181
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800182static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott2d1760b2011-09-29 21:31:24 -0700183#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700184#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800185#define MSM_ION_HEAP_NUM 1
Laura Abbott2d1760b2011-09-29 21:31:24 -0700186#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700187
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700188#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
189static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
190static int __init msm_contig_mem_size_setup(char *p)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700191{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700192 msm_contig_mem_size = memparse(p, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700193 return 0;
194}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700195early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700196#endif
197
198#ifdef CONFIG_ANDROID_PMEM
199static unsigned pmem_size = MSM_PMEM_SIZE;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800200static unsigned pmem_param_set;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700201static int __init pmem_size_setup(char *p)
202{
203 pmem_size = memparse(p, NULL);
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800204 pmem_param_set = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700205 return 0;
206}
207early_param("pmem_size", pmem_size_setup);
208
209static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
210
211static int __init pmem_adsp_size_setup(char *p)
212{
213 pmem_adsp_size = memparse(p, NULL);
214 return 0;
215}
216early_param("pmem_adsp_size", pmem_adsp_size_setup);
217
218static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
219
220static int __init pmem_audio_size_setup(char *p)
221{
222 pmem_audio_size = memparse(p, NULL);
223 return 0;
224}
225early_param("pmem_audio_size", pmem_audio_size_setup);
226#endif
227
228#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700229#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230static struct android_pmem_platform_data android_pmem_pdata = {
231 .name = "pmem",
232 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
233 .cached = 1,
234 .memory_type = MEMTYPE_EBI1,
235};
236
Laura Abbottb93525f2012-04-12 09:57:19 -0700237static struct platform_device msm8960_android_pmem_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238 .name = "android_pmem",
239 .id = 0,
240 .dev = {.platform_data = &android_pmem_pdata},
241};
242
243static struct android_pmem_platform_data android_pmem_adsp_pdata = {
244 .name = "pmem_adsp",
245 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
246 .cached = 0,
247 .memory_type = MEMTYPE_EBI1,
248};
Laura Abbottb93525f2012-04-12 09:57:19 -0700249static struct platform_device msm8960_android_pmem_adsp_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250 .name = "android_pmem",
251 .id = 2,
252 .dev = { .platform_data = &android_pmem_adsp_pdata },
253};
254
255static struct android_pmem_platform_data android_pmem_audio_pdata = {
256 .name = "pmem_audio",
257 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
258 .cached = 0,
259 .memory_type = MEMTYPE_EBI1,
260};
261
Laura Abbottb93525f2012-04-12 09:57:19 -0700262static struct platform_device msm8960_android_pmem_audio_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263 .name = "android_pmem",
264 .id = 4,
265 .dev = { .platform_data = &android_pmem_audio_pdata },
266};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700267#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
268#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700269
Laura Abbottb93525f2012-04-12 09:57:19 -0700270struct fmem_platform_data msm8960_fmem_pdata = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800271};
272
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700273#define DSP_RAM_BASE_8960 0x8da00000
274#define DSP_RAM_SIZE_8960 0x1800000
275static int dspcrashd_pdata_8960 = 0xDEADDEAD;
276
277static struct resource resources_dspcrashd_8960[] = {
278 {
279 .name = "msm_dspcrashd",
280 .start = DSP_RAM_BASE_8960,
281 .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
282 .flags = IORESOURCE_DMA,
283 },
284};
285
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800286static struct platform_device msm_device_dspcrashd_8960 = {
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700287 .name = "msm_dspcrashd",
288 .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
289 .resource = resources_dspcrashd_8960,
290 .dev = { .platform_data = &dspcrashd_pdata_8960 },
291};
292
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700293static struct memtype_reserve msm8960_reserve_table[] __initdata = {
294 [MEMTYPE_SMI] = {
295 },
296 [MEMTYPE_EBI0] = {
297 .flags = MEMTYPE_FLAGS_1M_ALIGN,
298 },
299 [MEMTYPE_EBI1] = {
300 .flags = MEMTYPE_FLAGS_1M_ALIGN,
301 },
302};
303
Laura Abbottf8c03b92012-02-16 14:57:58 -0800304static void __init reserve_rtb_memory(void)
305{
306#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700307 msm8960_reserve_table[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530308 pr_info("mem_map: rtb reserved with size 0x%x in pool\n",
309 msm8960_rtb_pdata.size);
Laura Abbottf8c03b92012-02-16 14:57:58 -0800310#endif
311}
312
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700313static void __init size_pmem_devices(void)
314{
315#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700316#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800318
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800319 if (!pmem_param_set) {
320 if (machine_is_msm8960_liquid())
321 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700322 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800323 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
324 }
325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326 android_pmem_pdata.size = pmem_size;
327 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700328#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
329#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330}
331
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700332#ifdef CONFIG_ANDROID_PMEM
333#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334static void __init reserve_memory_for(struct android_pmem_platform_data *p)
335{
336 msm8960_reserve_table[p->memory_type].size += p->size;
337}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700338#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
339#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340
341static void __init reserve_pmem_memory(void)
342{
343#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700344#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345 reserve_memory_for(&android_pmem_adsp_pdata);
346 reserve_memory_for(&android_pmem_pdata);
347 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700348#endif
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700349 msm8960_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530350 pr_info("mem_map: contig_mem reserved with size 0x%x in pool\n",
351 msm_contig_mem_size);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700352#endif
353}
354
Larry Basselb4126da2011-07-18 14:31:33 -0700355static int msm8960_paddr_to_memtype(unsigned int paddr)
356{
357 return MEMTYPE_EBI1;
358}
359
Steve Mucklef132c6c2012-06-06 18:30:57 -0700360#define FMEM_ENABLED 0
Olav Hauganf6dc7742012-02-15 09:11:55 -0800361
Laura Abbottd6183792011-08-19 13:42:24 -0700362#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800363#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700364static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800365 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -0700366 .align = SZ_64K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800367 .reusable = FMEM_ENABLED,
368 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700369 .fixed_position = FIXED_MIDDLE,
Olav Haugan8726caf2012-05-10 15:11:35 -0700370 .iommu_map_all = 1,
371 .iommu_2x_map_domain = VIDEO_DOMAIN,
Laura Abbottadec9c72012-12-05 11:49:59 -0800372 .is_cma = 1,
Laura Abbott5249a052012-12-11 15:09:03 -0800373 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800374};
375
Laura Abbottb93525f2012-04-12 09:57:19 -0700376static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800377 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800378 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800379 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800380 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700381 .fixed_position = FIXED_HIGH,
Laura Abbott5249a052012-12-11 15:09:03 -0800382 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800383};
384
Laura Abbottb93525f2012-04-12 09:57:19 -0700385static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800386 .adjacent_mem_id = INVALID_HEAP_ID,
387 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800388 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800389};
390
Laura Abbottb93525f2012-04-12 09:57:19 -0700391static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800392 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
393 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800394 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700395 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800396};
397#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800398
Laura Abbott354d40f2012-08-03 17:32:09 -0700399static u64 msm_dmamask = DMA_BIT_MASK(32);
400
401static struct platform_device ion_mm_heap_device = {
402 .name = "ion-mm-heap-device",
403 .id = -1,
404 .dev = {
405 .dma_mask = &msm_dmamask,
406 .coherent_dma_mask = DMA_BIT_MASK(32),
407 }
408};
409
Laura Abbott03e3cd72013-02-09 09:35:30 -0800410static struct platform_device ion_adsp_heap_device = {
411 .name = "ion-adsp-heap-device",
412 .id = -1,
413 .dev = {
414 .dma_mask = &msm_dmamask,
415 .coherent_dma_mask = DMA_BIT_MASK(32),
416 }
417};
418
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800419/**
420 * These heaps are listed in the order they will be allocated. Due to
421 * video hardware restrictions and content protection the FW heap has to
422 * be allocated adjacent (below) the MM heap and the MFC heap has to be
423 * allocated after the MM heap to ensure MFC heap is not more than 256MB
424 * away from the base address of the FW heap.
425 * However, the order of FW heap and MM heap doesn't matter since these
426 * two heaps are taken care of by separate code to ensure they are adjacent
427 * to each other.
428 * Don't swap the order unless you know what you are doing!
429 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700430struct ion_platform_heap msm8960_heaps[] = {
Laura Abbottd6183792011-08-19 13:42:24 -0700431 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800432 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700433 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700434 .name = ION_VMALLOC_HEAP_NAME,
435 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700436#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700437 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800438 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800439 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800440 .name = ION_MM_HEAP_NAME,
441 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700442 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700443 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbott354d40f2012-08-03 17:32:09 -0700444 .priv = &ion_mm_heap_device.dev,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700445 },
Laura Abbott8c017362011-09-22 20:59:12 -0700446 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800447 .id = ION_MM_FIRMWARE_HEAP_ID,
448 .type = ION_HEAP_TYPE_CARVEOUT,
449 .name = ION_MM_FIRMWARE_HEAP_NAME,
450 .size = MSM_ION_MM_FW_SIZE,
451 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700452 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800453 },
454 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800455 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800456 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800457 .name = ION_MFC_HEAP_NAME,
458 .size = MSM_ION_MFC_SIZE,
459 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700460 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800461 },
Olav Haugan32594552012-03-13 11:40:05 -0700462#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800463 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800464 .id = ION_SF_HEAP_ID,
465 .type = ION_HEAP_TYPE_CARVEOUT,
466 .name = ION_SF_HEAP_NAME,
467 .size = MSM_ION_SF_SIZE,
468 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700469 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800470 },
Olav Haugan32594552012-03-13 11:40:05 -0700471#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800472 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800473 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700474 .type = ION_HEAP_TYPE_IOMMU,
475 .name = ION_IOMMU_HEAP_NAME,
476 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800477 {
478 .id = ION_QSECOM_HEAP_ID,
479 .type = ION_HEAP_TYPE_CARVEOUT,
480 .name = ION_QSECOM_HEAP_NAME,
481 .size = MSM_ION_QSECOM_SIZE,
482 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700483 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800484 },
Olav Haugan7355db02012-01-13 16:59:13 -0800485 {
486 .id = ION_AUDIO_HEAP_ID,
487 .type = ION_HEAP_TYPE_CARVEOUT,
488 .name = ION_AUDIO_HEAP_NAME,
489 .size = MSM_ION_AUDIO_SIZE,
490 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700491 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800492 },
Laura Abbott03e3cd72013-02-09 09:35:30 -0800493 {
494 .id = ION_ADSP_HEAP_ID,
495 .type = ION_HEAP_TYPE_DMA,
496 .name = ION_ADSP_HEAP_NAME,
497 .size = MSM_ION_ADSP_SIZE,
498 .memory_type = ION_EBI_TYPE,
499 .extra_data = (void *) &co_msm8960_ion_pdata,
500 .priv = &ion_adsp_heap_device.dev,
501 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700502#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700503};
504
505static struct ion_platform_data msm8960_ion_pdata = {
506 .nr = MSM_ION_HEAP_NUM,
507 .heaps = msm8960_heaps,
Laura Abbottd6183792011-08-19 13:42:24 -0700508};
509
Laura Abbottb93525f2012-04-12 09:57:19 -0700510static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700511 .name = "ion-msm",
512 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700513 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700514};
515#endif
516
Laura Abbottb93525f2012-04-12 09:57:19 -0700517struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800518 .name = "fmem",
519 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700520 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800521};
522
Olav Haugan65f4bd82011-12-13 11:50:08 -0800523static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700524{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800525 unsigned int i;
526
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800527 if (!pmem_param_set) {
528 if (machine_is_msm8960_liquid())
529 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
530
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700531 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800532 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
533
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700534 if (machine_is_msm8960_liquid() ||
535 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700536 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
537 if (msm8960_ion_pdata.heaps[i].id ==
538 ION_SF_HEAP_ID) {
539 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800540 msm_ion_sf_size;
541 pr_debug("msm_ion_sf_size 0x%x\n",
542 msm_ion_sf_size);
543 break;
544 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800545 }
546 }
547 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800548}
549
550static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
551 unsigned long size)
552{
553 msm8960_reserve_table[mem_type].size += size;
554}
555
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700556static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
557{
558#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
559 int ret;
560
561 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
562 panic("fixed area size is larger than %dM\n",
563 MAX_FIXED_AREA_SIZE >> 20);
564
565 reserve_info->fixed_area_size = fixed_area_size;
566 reserve_info->fixed_area_start = MSM8960_FW_START;
567
568 ret = memblock_remove(reserve_info->fixed_area_start,
569 reserve_info->fixed_area_size);
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530570 pr_info("mem_map: fixed_area reserved at 0x%lx with size 0x%lx\n",
571 reserve_info->fixed_area_start,
572 reserve_info->fixed_area_size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700573 BUG_ON(ret);
574#endif
575}
576
Olav Haugan65f4bd82011-12-13 11:50:08 -0800577/**
578 * Reserve memory for ION and calculate amount of reusable memory for fmem.
579 * We only reserve memory for heaps that are not reusable. However, we only
580 * support one reusable heap at the moment so we ignore the reusable flag for
581 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800582 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
583 * at a higher address than FW in addition to not more than 256MB away from the
584 * base address of the firmware. This means that if MM is reusable the other
585 * two heaps must be allocated in the same region as FW. This is handled by the
586 * mem_is_fmem flag in the platform data. In addition the MM heap must be
587 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800588 */
589static void __init reserve_ion_memory(void)
590{
591#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
592 unsigned int i;
Laura Abbott354d40f2012-08-03 17:32:09 -0700593 int ret;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700594 unsigned int fixed_size = 0;
595 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
596 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbott354d40f2012-08-03 17:32:09 -0700597 unsigned long cma_alignment;
598 unsigned int low_use_cma = 0;
599 unsigned int middle_use_cma = 0;
600 unsigned int high_use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800601
602 adjust_mem_for_liquid();
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700603 fixed_low_size = 0;
604 fixed_middle_size = 0;
605 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800606
Laura Abbott354d40f2012-08-03 17:32:09 -0700607 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
608
Laura Abbottb93525f2012-04-12 09:57:19 -0700609 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
Olav Haugan8726caf2012-05-10 15:11:35 -0700610 struct ion_platform_heap *heap =
Laura Abbottb93525f2012-04-12 09:57:19 -0700611 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan8726caf2012-05-10 15:11:35 -0700612 int align = SZ_4K;
613 int iommu_map_all = 0;
614 int adjacent_mem_id = INVALID_HEAP_ID;
Laura Abbott354d40f2012-08-03 17:32:09 -0700615 int use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800616
617 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700618 int fixed_position = NOT_FIXED;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700619
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700620 switch ((int) heap->type) {
Olav Haugan65f4bd82011-12-13 11:50:08 -0800621 case ION_HEAP_TYPE_CP:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700622 fixed_position = ((struct ion_cp_heap_pdata *)
623 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700624 align = ((struct ion_cp_heap_pdata *)
625 heap->extra_data)->align;
626 iommu_map_all =
627 ((struct ion_cp_heap_pdata *)
628 heap->extra_data)->iommu_map_all;
Laura Abbott354d40f2012-08-03 17:32:09 -0700629 if (((struct ion_cp_heap_pdata *)
630 heap->extra_data)->is_cma) {
631 heap->size = ALIGN(heap->size,
632 cma_alignment);
633 use_cma = 1;
634 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800635 break;
Laura Abbott354d40f2012-08-03 17:32:09 -0700636 case ION_HEAP_TYPE_DMA:
637 use_cma = 1;
638 /* Purposely fall through here */
Olav Haugan65f4bd82011-12-13 11:50:08 -0800639 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700640 fixed_position = ((struct ion_co_heap_pdata *)
641 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700642 adjacent_mem_id = ((struct ion_co_heap_pdata *)
643 heap->extra_data)->adjacent_mem_id;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700644 break;
645 default:
646 break;
647 }
648
Olav Haugan8726caf2012-05-10 15:11:35 -0700649 if (iommu_map_all) {
650 if (heap->size & (SZ_64K-1)) {
651 heap->size = ALIGN(heap->size, SZ_64K);
652 pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
653 heap->name, heap->size);
654 }
655 }
656
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700657 if (fixed_position != NOT_FIXED)
658 fixed_size += heap->size;
Chintan Pandya2eab21d2013-04-12 14:50:29 +0530659 else if (!use_cma)
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700660 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
661
Laura Abbott354d40f2012-08-03 17:32:09 -0700662 if (fixed_position == FIXED_LOW) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700663 fixed_low_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700664 low_use_cma = use_cma;
665 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700666 fixed_middle_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700667 middle_use_cma = use_cma;
668 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700669 fixed_high_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700670 high_use_cma = use_cma;
671 } else if (use_cma) {
672 /*
673 * Heaps that use CMA but are not part of the
674 * fixed set. Create wherever.
675 */
676 dma_declare_contiguous(
677 heap->priv,
678 heap->size,
679 0,
680 0xb0000000);
681 }
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700682 }
683 }
684
685 if (!fixed_size)
686 return;
687
Laura Abbott354d40f2012-08-03 17:32:09 -0700688 /*
689 * Given the setup for the fixed area, we can't round up all sizes.
690 * Some sizes must be set up exactly and aligned correctly. Incorrect
691 * alignments are considered a configuration issue
Larry Bassel4d4f4482012-04-04 11:26:09 -0700692 */
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700693
694 fixed_low_start = MSM8960_FIXED_AREA_START;
Laura Abbott354d40f2012-08-03 17:32:09 -0700695 if (low_use_cma) {
696 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
697 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
698 } else {
699 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
700 ret = memblock_remove(fixed_low_start,
701 fixed_low_size + HOLE_SIZE);
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530702 pr_info("mem_map: fixed_low_area reserved at 0x%lx with size \
703 0x%x\n", fixed_low_start,
704 fixed_low_size + HOLE_SIZE);
Laura Abbott354d40f2012-08-03 17:32:09 -0700705 BUG_ON(ret);
706 }
707
Deepak Kotur35825522012-06-06 15:49:14 -0700708 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbott354d40f2012-08-03 17:32:09 -0700709 if (middle_use_cma) {
710 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
711 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
712 } else {
713 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
714 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530715 pr_info("mem_map: fixed_middle_area reserved at 0x%lx with \
716 size 0x%x\n", fixed_middle_start,
717 fixed_middle_size);
Laura Abbott354d40f2012-08-03 17:32:09 -0700718 BUG_ON(ret);
719 }
720
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700721 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700722 if (high_use_cma) {
723 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
724 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
725 } else {
726 /* This is the end of the fixed area so it's okay to round up */
727 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
728 ret = memblock_remove(fixed_high_start, fixed_high_size);
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530729 pr_info("mem_map: fixed_high_area reserved at 0x%lx with size \
730 0x%x\n", fixed_high_start,
731 fixed_high_size);
Laura Abbott354d40f2012-08-03 17:32:09 -0700732 BUG_ON(ret);
733 }
734
735
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700736
Laura Abbottb93525f2012-04-12 09:57:19 -0700737 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
738 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700739
740 if (heap->extra_data) {
741 int fixed_position = NOT_FIXED;
Steve Muckle75c34ca2012-06-12 14:27:40 -0700742 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700743
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700744 switch ((int) heap->type) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700745 case ION_HEAP_TYPE_CP:
Deepak Kotur35825522012-06-06 15:49:14 -0700746 pdata =
747 (struct ion_cp_heap_pdata *)heap->extra_data;
748 fixed_position = pdata->fixed_position;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700749 break;
750 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbott354d40f2012-08-03 17:32:09 -0700751 case ION_HEAP_TYPE_DMA:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700752 fixed_position = ((struct ion_co_heap_pdata *)
753 heap->extra_data)->fixed_position;
754 break;
755 default:
756 break;
757 }
758
759 switch (fixed_position) {
760 case FIXED_LOW:
761 heap->base = fixed_low_start;
762 break;
763 case FIXED_MIDDLE:
764 heap->base = fixed_middle_start;
Laura Abbott354d40f2012-08-03 17:32:09 -0700765 if (middle_use_cma) {
766 ret = dma_declare_contiguous(
767 &ion_mm_heap_device.dev,
768 heap->size,
769 fixed_middle_start,
770 0xa0000000);
771 WARN_ON(ret);
772 }
Deepak Kotur35825522012-06-06 15:49:14 -0700773 pdata->secure_base = fixed_middle_start
774 - HOLE_SIZE;
775 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700776 break;
777 case FIXED_HIGH:
778 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800779 break;
780 default:
781 break;
782 }
783 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800784 }
Laura Abbottd6183792011-08-19 13:42:24 -0700785#endif
786}
Huaibin Yanga5419422011-12-08 23:52:10 -0800787
788static void __init reserve_mdp_memory(void)
789{
790 msm8960_mdp_writeback(msm8960_reserve_table);
791}
792
Stephen Boyd668d7652012-04-25 11:31:01 -0700793static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800794{
795#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbott306bcc22012-03-08 11:24:53 -0800796 unsigned int total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800797
Laura Abbott155ab6f2012-05-25 08:52:18 -0700798 total = msm8960_cache_dump_pdata.l1_size +
799 msm8960_cache_dump_pdata.l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800800 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Chitti Babu Theegalaa7458c12013-05-06 21:03:20 +0530801 pr_info("mem_map: cache_dump reserved with size 0x%x in pool\n",
802 total);
Laura Abbott306bcc22012-03-08 11:24:53 -0800803#endif
804}
805
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700806static void __init msm8960_calculate_reserve_sizes(void)
807{
808 size_pmem_devices();
809 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700810 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800811 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800812 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800813 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700814}
815
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816static struct reserve_info msm8960_reserve_info __initdata = {
817 .memtype_reserve_table = msm8960_reserve_table,
818 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700819 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820 .paddr_to_memtype = msm8960_paddr_to_memtype,
821};
822
Larry Basselb830e182011-10-14 10:46:55 -0700823static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700824{
825 reserve_info = &msm8960_reserve_info;
Larry Basselb830e182011-10-14 10:46:55 -0700826}
827
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800828static char prim_panel_name[PANEL_NAME_MAX_LEN];
829static char ext_panel_name[PANEL_NAME_MAX_LEN];
830static int __init prim_display_setup(char *param)
831{
832 if (strnlen(param, PANEL_NAME_MAX_LEN))
833 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
834 return 0;
835}
836early_param("prim_display", prim_display_setup);
837
838static int __init ext_display_setup(char *param)
839{
840 if (strnlen(param, PANEL_NAME_MAX_LEN))
841 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
842 return 0;
843}
844early_param("ext_display", ext_display_setup);
845
Larry Basselb830e182011-10-14 10:46:55 -0700846static void __init msm8960_reserve(void)
847{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800848 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700849 msm_reserve();
850}
851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700852static void __init msm8960_allocate_memory_regions(void)
853{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800854 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700855}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800856
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700857#ifdef CONFIG_WCD9310_CODEC
858
859#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
860
Patrick Lai3043fba2011-08-01 14:15:57 -0700861/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
862 * 4 micbiases are used to power various analog and digital
863 * microphones operating at 1800 mV. Technically, all micbiases
864 * can source from single cfilter since all microphones operate
865 * at the same voltage level. The arrangement below is to make
866 * sure all cfilters are exercised. LDO_H regulator ouput level
867 * does not need to be as high as 2.85V. It is choosen for
868 * microphone sensitivity purpose.
869 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530870static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700871 .slimbus_slave_device = {
872 .name = "tabla-slave",
873 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
874 },
875 .irq = MSM_GPIO_TO_INT(62),
876 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530877 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700878 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700879 .micbias = {
880 .ldoh_v = TABLA_LDOH_2P85_V,
881 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700882 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700883 .cfilt3_mv = 1800,
884 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
885 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
886 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
887 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530888 },
889 .regulator = {
890 {
891 .name = "CDC_VDD_CP",
892 .min_uV = 1800000,
893 .max_uV = 1800000,
894 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
895 },
896 {
897 .name = "CDC_VDDA_RX",
898 .min_uV = 1800000,
899 .max_uV = 1800000,
900 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
901 },
902 {
903 .name = "CDC_VDDA_TX",
904 .min_uV = 1800000,
905 .max_uV = 1800000,
906 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
907 },
908 {
909 .name = "VDDIO_CDC",
910 .min_uV = 1800000,
911 .max_uV = 1800000,
912 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
913 },
914 {
915 .name = "VDDD_CDC_D",
916 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700917 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530918 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
919 },
920 {
921 .name = "CDC_VDDA_A_1P2V",
922 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700923 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530924 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
925 },
926 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700927};
928
929static struct slim_device msm_slim_tabla = {
930 .name = "tabla-slim",
931 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
932 .dev = {
933 .platform_data = &tabla_platform_data,
934 },
935};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530936
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530937static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530938 .slimbus_slave_device = {
939 .name = "tabla-slave",
940 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
941 },
942 .irq = MSM_GPIO_TO_INT(62),
943 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530944 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530945 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
946 .micbias = {
947 .ldoh_v = TABLA_LDOH_2P85_V,
948 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700949 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530950 .cfilt3_mv = 1800,
951 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
952 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
953 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
954 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530955 },
956 .regulator = {
957 {
958 .name = "CDC_VDD_CP",
959 .min_uV = 1800000,
960 .max_uV = 1800000,
961 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
962 },
963 {
964 .name = "CDC_VDDA_RX",
965 .min_uV = 1800000,
966 .max_uV = 1800000,
967 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
968 },
969 {
970 .name = "CDC_VDDA_TX",
971 .min_uV = 1800000,
972 .max_uV = 1800000,
973 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
974 },
975 {
976 .name = "VDDIO_CDC",
977 .min_uV = 1800000,
978 .max_uV = 1800000,
979 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
980 },
981 {
982 .name = "VDDD_CDC_D",
983 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700984 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530985 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
986 },
987 {
988 .name = "CDC_VDDA_A_1P2V",
989 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700990 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530991 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
992 },
993 },
Santosh Mardi60e19d92011-10-28 01:15:14 +0530994};
995
996static struct slim_device msm_slim_tabla20 = {
997 .name = "tabla2x-slim",
998 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
999 .dev = {
1000 .platform_data = &tabla20_platform_data,
1001 },
1002};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001003#endif
1004
1005static struct slim_boardinfo msm_slim_devices[] = {
1006#ifdef CONFIG_WCD9310_CODEC
1007 {
1008 .bus_num = 1,
1009 .slim_slave = &msm_slim_tabla,
1010 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301011 {
1012 .bus_num = 1,
1013 .slim_slave = &msm_slim_tabla20,
1014 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001015#endif
1016 /* add more slimbus slaves as needed */
1017};
1018
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001019#define MSM_WCNSS_PHYS 0x03000000
1020#define MSM_WCNSS_SIZE 0x280000
1021
1022static struct resource resources_wcnss_wlan[] = {
1023 {
1024 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1025 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1026 .name = "wcnss_wlanrx_irq",
1027 .flags = IORESOURCE_IRQ,
1028 },
1029 {
1030 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1031 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1032 .name = "wcnss_wlantx_irq",
1033 .flags = IORESOURCE_IRQ,
1034 },
1035 {
1036 .start = MSM_WCNSS_PHYS,
1037 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1038 .name = "wcnss_mmio",
1039 .flags = IORESOURCE_MEM,
1040 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001041 {
1042 .start = 84,
1043 .end = 88,
1044 .name = "wcnss_gpios_5wire",
1045 .flags = IORESOURCE_IO,
1046 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001047};
1048
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001049static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1050 .has_48mhz_xo = 1,
1051};
1052
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001053static struct platform_device msm_device_wcnss_wlan = {
1054 .name = "wcnss_wlan",
1055 .id = 0,
1056 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1057 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001058 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001059};
1060
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001061#ifdef CONFIG_QSEECOM
1062/* qseecom bus scaling */
1063static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1064 {
1065 .src = MSM_BUS_MASTER_SPS,
1066 .dst = MSM_BUS_SLAVE_EBI_CH0,
1067 .ib = 0,
1068 .ab = 0,
1069 },
1070 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001071 .src = MSM_BUS_MASTER_SPS,
1072 .dst = MSM_BUS_SLAVE_SPS,
1073 .ib = 0,
1074 .ab = 0,
1075 },
1076 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001077 .src = MSM_BUS_MASTER_SPDM,
1078 .dst = MSM_BUS_SLAVE_SPDM,
1079 .ib = 0,
1080 .ab = 0,
1081 },
1082};
1083
1084static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1085 {
1086 .src = MSM_BUS_MASTER_SPS,
1087 .dst = MSM_BUS_SLAVE_EBI_CH0,
1088 .ib = (492 * 8) * 1000000UL,
1089 .ab = (492 * 8) * 100000UL,
1090 },
1091 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001092 .src = MSM_BUS_MASTER_SPS,
1093 .dst = MSM_BUS_SLAVE_SPS,
1094 .ib = (492 * 8) * 1000000UL,
1095 .ab = (492 * 8) * 100000UL,
1096 },
1097 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001098 .src = MSM_BUS_MASTER_SPDM,
1099 .dst = MSM_BUS_SLAVE_SPDM,
1100 .ib = 0,
1101 .ab = 0,
1102 },
1103};
1104
1105static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1106 {
1107 .src = MSM_BUS_MASTER_SPS,
1108 .dst = MSM_BUS_SLAVE_EBI_CH0,
1109 .ib = 0,
1110 .ab = 0,
1111 },
1112 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001113 .src = MSM_BUS_MASTER_SPS,
1114 .dst = MSM_BUS_SLAVE_SPS,
1115 .ib = 0,
1116 .ab = 0,
1117 },
1118 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001119 .src = MSM_BUS_MASTER_SPDM,
1120 .dst = MSM_BUS_SLAVE_SPDM,
1121 .ib = (64 * 8) * 1000000UL,
1122 .ab = (64 * 8) * 100000UL,
1123 },
1124};
1125
Ramesh Masavarapu4f091cb2012-10-03 10:18:06 -07001126static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1127 {
1128 .src = MSM_BUS_MASTER_SPS,
1129 .dst = MSM_BUS_SLAVE_EBI_CH0,
1130 .ib = (492 * 8) * 1000000UL,
1131 .ab = (492 * 8) * 100000UL,
1132 },
1133 {
1134 .src = MSM_BUS_MASTER_SPS,
1135 .dst = MSM_BUS_SLAVE_SPS,
1136 .ib = (492 * 8) * 1000000UL,
1137 .ab = (492 * 8) * 100000UL,
1138 },
1139 {
1140 .src = MSM_BUS_MASTER_SPDM,
1141 .dst = MSM_BUS_SLAVE_SPDM,
1142 .ib = (64 * 8) * 1000000UL,
1143 .ab = (64 * 8) * 100000UL,
1144 },
1145};
1146
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001147static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1148 {
1149 ARRAY_SIZE(qseecom_clks_init_vectors),
1150 qseecom_clks_init_vectors,
1151 },
1152 {
1153 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001154 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001155 },
1156 {
1157 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1158 qseecom_enable_sfpb_vectors,
1159 },
Ramesh Masavarapu4f091cb2012-10-03 10:18:06 -07001160 {
1161 ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1162 qseecom_enable_dfab_sfpb_vectors,
1163 },
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001164};
1165
1166static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1167 qseecom_hw_bus_scale_usecases,
1168 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1169 .name = "qsee",
1170};
1171
1172static struct platform_device qseecom_device = {
1173 .name = "qseecom",
1174 .id = 0,
1175 .dev = {
1176 .platform_data = &qseecom_bus_pdata,
1177 },
1178};
1179#endif
1180
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001181#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1182 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1183 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1184 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1185
1186#define QCE_SIZE 0x10000
1187#define QCE_0_BASE 0x18500000
1188
1189#define QCE_HW_KEY_SUPPORT 0
1190#define QCE_SHA_HMAC_SUPPORT 1
1191#define QCE_SHARE_CE_RESOURCE 1
1192#define QCE_CE_SHARED 0
1193
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001194/* Begin Bus scaling definitions */
1195static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1196 {
1197 .src = MSM_BUS_MASTER_ADM_PORT0,
1198 .dst = MSM_BUS_SLAVE_EBI_CH0,
1199 .ab = 0,
1200 .ib = 0,
1201 },
1202 {
1203 .src = MSM_BUS_MASTER_ADM_PORT1,
1204 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1205 .ab = 0,
1206 .ib = 0,
1207 },
1208};
1209
1210static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1211 {
1212 .src = MSM_BUS_MASTER_ADM_PORT0,
1213 .dst = MSM_BUS_SLAVE_EBI_CH0,
1214 .ab = 70000000UL,
1215 .ib = 70000000UL,
1216 },
1217 {
1218 .src = MSM_BUS_MASTER_ADM_PORT1,
1219 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1220 .ab = 2480000000UL,
1221 .ib = 2480000000UL,
1222 },
1223};
1224
1225static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1226 {
1227 ARRAY_SIZE(crypto_hw_init_vectors),
1228 crypto_hw_init_vectors,
1229 },
1230 {
1231 ARRAY_SIZE(crypto_hw_active_vectors),
1232 crypto_hw_active_vectors,
1233 },
1234};
1235
1236static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1237 crypto_hw_bus_scale_usecases,
1238 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1239 .name = "cryptohw",
1240};
1241/* End Bus Scaling Definitions*/
1242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001243static struct resource qcrypto_resources[] = {
1244 [0] = {
1245 .start = QCE_0_BASE,
1246 .end = QCE_0_BASE + QCE_SIZE - 1,
1247 .flags = IORESOURCE_MEM,
1248 },
1249 [1] = {
1250 .name = "crypto_channels",
1251 .start = DMOV_CE_IN_CHAN,
1252 .end = DMOV_CE_OUT_CHAN,
1253 .flags = IORESOURCE_DMA,
1254 },
1255 [2] = {
1256 .name = "crypto_crci_in",
1257 .start = DMOV_CE_IN_CRCI,
1258 .end = DMOV_CE_IN_CRCI,
1259 .flags = IORESOURCE_DMA,
1260 },
1261 [3] = {
1262 .name = "crypto_crci_out",
1263 .start = DMOV_CE_OUT_CRCI,
1264 .end = DMOV_CE_OUT_CRCI,
1265 .flags = IORESOURCE_DMA,
1266 },
1267};
1268
1269static struct resource qcedev_resources[] = {
1270 [0] = {
1271 .start = QCE_0_BASE,
1272 .end = QCE_0_BASE + QCE_SIZE - 1,
1273 .flags = IORESOURCE_MEM,
1274 },
1275 [1] = {
1276 .name = "crypto_channels",
1277 .start = DMOV_CE_IN_CHAN,
1278 .end = DMOV_CE_OUT_CHAN,
1279 .flags = IORESOURCE_DMA,
1280 },
1281 [2] = {
1282 .name = "crypto_crci_in",
1283 .start = DMOV_CE_IN_CRCI,
1284 .end = DMOV_CE_IN_CRCI,
1285 .flags = IORESOURCE_DMA,
1286 },
1287 [3] = {
1288 .name = "crypto_crci_out",
1289 .start = DMOV_CE_OUT_CRCI,
1290 .end = DMOV_CE_OUT_CRCI,
1291 .flags = IORESOURCE_DMA,
1292 },
1293};
1294
1295#endif
1296
1297#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1298 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1299
1300static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1301 .ce_shared = QCE_CE_SHARED,
1302 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1303 .hw_key_support = QCE_HW_KEY_SUPPORT,
1304 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001305 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001306};
1307
1308static struct platform_device qcrypto_device = {
1309 .name = "qcrypto",
1310 .id = 0,
1311 .num_resources = ARRAY_SIZE(qcrypto_resources),
1312 .resource = qcrypto_resources,
1313 .dev = {
1314 .coherent_dma_mask = DMA_BIT_MASK(32),
1315 .platform_data = &qcrypto_ce_hw_suppport,
1316 },
1317};
1318#endif
1319
1320#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1321 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1322
1323static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1324 .ce_shared = QCE_CE_SHARED,
1325 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1326 .hw_key_support = QCE_HW_KEY_SUPPORT,
1327 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001328 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001329};
1330
1331static struct platform_device qcedev_device = {
1332 .name = "qce",
1333 .id = 0,
1334 .num_resources = ARRAY_SIZE(qcedev_resources),
1335 .resource = qcedev_resources,
1336 .dev = {
1337 .coherent_dma_mask = DMA_BIT_MASK(32),
1338 .platform_data = &qcedev_ce_hw_suppport,
1339 },
1340};
1341#endif
1342
Joel King0cbf5d82012-05-24 15:21:38 -07001343static struct mdm_platform_data sglte_platform_data = {
1344 .mdm_version = "4.0",
1345 .ramdump_delay_ms = 1000,
Taniya Das21274cf2013-01-15 11:28:14 +05301346 /* delay between two PS_HOLDs */
1347 .ps_hold_delay_ms = 500,
Joel King63ce8332012-06-01 09:59:26 -07001348 .soft_reset_inverted = 1,
Joel King0cbf5d82012-05-24 15:21:38 -07001349 .peripheral_platform_device = NULL,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001350 .ramdump_timeout_ms = 600000,
Ameya Thakura98bde52012-06-28 18:55:19 -07001351 .no_powerdown_after_ramdumps = 1,
Ameya Thakur43248fd2012-07-10 18:50:52 -07001352 .image_upgrade_supported = 1,
Joel Kingb8352a12011-11-15 18:46:24 -08001353};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001354
Joel Nider266a2642011-10-16 10:58:05 +02001355#define MSM_TSIF0_PHYS (0x18200000)
1356#define MSM_TSIF1_PHYS (0x18201000)
1357#define MSM_TSIF_SIZE (0x200)
1358#define MSM_TSPP_PHYS (0x18202000)
1359#define MSM_TSPP_SIZE (0x1000)
1360#define MSM_TSPP_BAM_PHYS (0x18204000)
1361#define MSM_TSPP_BAM_SIZE (0x2000)
1362
1363#define TSIF_0_CLK GPIO_CFG(75, 1, GPIO_CFG_INPUT, \
1364 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1365#define TSIF_0_EN GPIO_CFG(76, 1, GPIO_CFG_INPUT, \
1366 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1367#define TSIF_0_DATA GPIO_CFG(77, 1, GPIO_CFG_INPUT, \
1368 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1369#define TSIF_0_SYNC GPIO_CFG(82, 1, GPIO_CFG_INPUT, \
1370 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1371#define TSIF_1_CLK GPIO_CFG(79, 1, GPIO_CFG_INPUT, \
1372 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1373#define TSIF_1_EN GPIO_CFG(80, 1, GPIO_CFG_INPUT, \
1374 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1375#define TSIF_1_DATA GPIO_CFG(81, 1, GPIO_CFG_INPUT, \
1376 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1377#define TSIF_1_SYNC GPIO_CFG(78, 1, GPIO_CFG_INPUT, \
1378 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1379
1380static const struct msm_gpio tsif_gpios[] = {
1381 { .gpio_cfg = TSIF_0_CLK, .label = "tsif0_clk", },
1382 { .gpio_cfg = TSIF_0_EN, .label = "tsif0_en", },
1383 { .gpio_cfg = TSIF_0_DATA, .label = "tsif0_data", },
1384 { .gpio_cfg = TSIF_0_SYNC, .label = "tsif0_sync", },
1385 { .gpio_cfg = TSIF_1_CLK, .label = "tsif1_clk", },
1386 { .gpio_cfg = TSIF_1_EN, .label = "tsif1_en", },
1387 { .gpio_cfg = TSIF_1_DATA, .label = "tsif1_data", },
1388 { .gpio_cfg = TSIF_1_SYNC, .label = "tsif1_sync", },
1389};
1390
1391static struct resource tspp_resources[] = {
1392 [0] = {
Liron Kuch8fa85b02013-01-01 18:29:47 +02001393 .name = "TSIF_TSPP_IRQ",
Joel Nider266a2642011-10-16 10:58:05 +02001394 .flags = IORESOURCE_IRQ,
1395 .start = TSIF_TSPP_IRQ,
Liron Kuch8fa85b02013-01-01 18:29:47 +02001396 .end = TSIF_TSPP_IRQ,
Joel Nider266a2642011-10-16 10:58:05 +02001397 },
1398 [1] = {
Liron Kuch8fa85b02013-01-01 18:29:47 +02001399 .name = "TSIF0_IRQ",
1400 .flags = IORESOURCE_IRQ,
1401 .start = TSIF1_IRQ,
1402 .end = TSIF1_IRQ,
1403 },
1404 [2] = {
1405 .name = "TSIF1_IRQ",
1406 .flags = IORESOURCE_IRQ,
1407 .start = TSIF2_IRQ,
1408 .end = TSIF2_IRQ,
1409 },
1410 [3] = {
1411 .name = "TSIF_BAM_IRQ",
1412 .flags = IORESOURCE_IRQ,
1413 .start = TSIF_BAM_IRQ,
1414 .end = TSIF_BAM_IRQ,
1415 },
1416 [4] = {
1417 .name = "MSM_TSIF0_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001418 .flags = IORESOURCE_MEM,
1419 .start = MSM_TSIF0_PHYS,
1420 .end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
1421 },
Liron Kuch8fa85b02013-01-01 18:29:47 +02001422 [5] = {
1423 .name = "MSM_TSIF1_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001424 .flags = IORESOURCE_MEM,
1425 .start = MSM_TSIF1_PHYS,
1426 .end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
1427 },
Liron Kuch8fa85b02013-01-01 18:29:47 +02001428 [6] = {
1429 .name = "MSM_TSPP_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001430 .flags = IORESOURCE_MEM,
1431 .start = MSM_TSPP_PHYS,
1432 .end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
1433 },
Liron Kuch8fa85b02013-01-01 18:29:47 +02001434 [7] = {
1435 .name = "MSM_TSPP_BAM_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001436 .flags = IORESOURCE_MEM,
1437 .start = MSM_TSPP_BAM_PHYS,
1438 .end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
1439 },
1440};
1441
1442static struct msm_tspp_platform_data tspp_platform_data = {
1443 .num_gpios = ARRAY_SIZE(tsif_gpios),
1444 .gpios = tsif_gpios,
1445 .tsif_pclk = "tsif_pclk",
1446 .tsif_ref_clk = "tsif_ref_clk",
1447};
1448
1449static struct platform_device msm_device_tspp = {
1450 .name = "msm_tspp",
1451 .id = 0,
1452 .num_resources = ARRAY_SIZE(tspp_resources),
1453 .resource = tspp_resources,
1454 .dev = {
1455 .platform_data = &tspp_platform_data
1456 },
1457};
1458
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001459#define MSM_SHARED_RAM_PHYS 0x80000000
1460
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001461static void __init msm8960_map_io(void)
1462{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001463 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001464 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001465
1466 if (socinfo_init() < 0)
1467 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001468}
1469
1470static void __init msm8960_init_irq(void)
1471{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001472 struct msm_mpm_device_data *data = NULL;
1473
1474#ifdef CONFIG_MSM_MPM
1475 data = &msm8960_mpm_dev_data;
1476#endif
1477
1478 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001479 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001480 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001481}
1482
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001483static void __init msm8960_init_buses(void)
1484{
1485#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001486 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001487 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1488 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
Gagan Macae154c4b2011-10-05 19:24:43 -06001489 msm_bus_apps_fabric.dev.platform_data =
1490 &msm_bus_8960_apps_fabric_pdata;
1491 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
Gagan Mac680bfc02012-07-19 19:11:00 -06001492 if (cpu_is_msm8960ab()) {
1493 msm_bus_8960_sg_mm_fabric_pdata.rpm_enabled = 1;
1494 msm_bus_mm_fabric.dev.platform_data =
1495 &msm_bus_8960_sg_mm_fabric_pdata;
1496 } else {
1497 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1498 msm_bus_mm_fabric.dev.platform_data =
1499 &msm_bus_8960_mm_fabric_pdata;
1500 }
Gagan Macae154c4b2011-10-05 19:24:43 -06001501 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1502 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001503#endif
1504}
1505
1506static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1507 .max_clock_speed = 15060000,
Kiran Gunda2b285652012-07-30 13:22:39 +05301508 .infinite_mode = 0xFFC0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001509};
1510
1511#ifdef CONFIG_USB_MSM_OTG_72K
1512static struct msm_otg_platform_data msm_otg_pdata;
1513#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301514static int wr_phy_init_seq[] = {
1515 0x44, 0x80, /* set VBUS valid threshold
1516 and disconnect valid threshold */
1517 0x38, 0x81, /* update DC voltage level */
1518 0x14, 0x82, /* set preemphasis and rise/fall time */
1519 0x13, 0x83, /* set source impedance adjusment */
1520 -1};
1521
1522static int liquid_v1_phy_init_seq[] = {
1523 0x44, 0x80,/* set VBUS valid threshold
1524 and disconnect valid threshold */
1525 0x3C, 0x81,/* update DC voltage level */
1526 0x18, 0x82,/* set preemphasis and rise/fall time */
1527 0x23, 0x83,/* set source impedance sdjusment */
1528 -1};
1529
Mayank Ranaa1f507b2012-08-14 10:57:00 +05301530static int sglte_phy_init_seq[] = {
1531 0x44, 0x80, /* set VBUS valid threshold
1532 and disconnect valid threshold */
1533 0x3A, 0x81, /* update DC voltage level */
1534 0x24, 0x82, /* set preemphasis and rise/fall time */
1535 0x13, 0x83, /* set source impedance adjusment */
1536 -1};
1537
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301538#ifdef CONFIG_MSM_BUS_SCALING
1539/* Bandwidth requests (zero) if no vote placed */
1540static struct msm_bus_vectors usb_init_vectors[] = {
1541 {
1542 .src = MSM_BUS_MASTER_SPS,
1543 .dst = MSM_BUS_SLAVE_EBI_CH0,
1544 .ab = 0,
1545 .ib = 0,
1546 },
1547};
1548
1549/* Bus bandwidth requests in Bytes/sec */
1550static struct msm_bus_vectors usb_max_vectors[] = {
1551 {
1552 .src = MSM_BUS_MASTER_SPS,
1553 .dst = MSM_BUS_SLAVE_EBI_CH0,
1554 .ab = 60000000, /* At least 480Mbps on bus. */
1555 .ib = 960000000, /* MAX bursts rate */
1556 },
1557};
1558
1559static struct msm_bus_paths usb_bus_scale_usecases[] = {
1560 {
1561 ARRAY_SIZE(usb_init_vectors),
1562 usb_init_vectors,
1563 },
1564 {
1565 ARRAY_SIZE(usb_max_vectors),
1566 usb_max_vectors,
1567 },
1568};
1569
1570static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1571 usb_bus_scale_usecases,
1572 ARRAY_SIZE(usb_bus_scale_usecases),
1573 .name = "usb",
1574};
1575#endif
1576
Jack Pham87f202f2012-08-06 00:24:22 -07001577#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
1578
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001579static struct msm_otg_platform_data msm_otg_pdata = {
1580 .mode = USB_OTG,
1581 .otg_control = OTG_PMIC_CONTROL,
1582 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001583 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301584 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301585#ifdef CONFIG_MSM_BUS_SCALING
1586 .bus_scale_table = &usb_bus_scale_pdata,
Jack Pham87f202f2012-08-06 00:24:22 -07001587 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301588#endif
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +05301589#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
1590 .mhl_dev_name = "sii8334",
1591#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001592};
1593#endif
1594
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301595#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301596#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301597static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1598 .strobe = 150,
1599 .data = 151,
1600};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301601
1602static struct smsc_hub_platform_data hsic_hub_pdata = {
1603 .hub_reset = HSIC_HUB_RESET_GPIO,
1604};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301605#else
1606static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301607static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301608#endif
1609
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301610static struct platform_device smsc_hub_device = {
1611 .name = "msm_smsc_hub",
1612 .id = -1,
1613 .dev = {
1614 .platform_data = &hsic_hub_pdata,
1615 },
1616};
1617
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001618#define PID_MAGIC_ID 0x71432909
1619#define SERIAL_NUM_MAGIC_ID 0x61945374
1620#define SERIAL_NUMBER_LENGTH 127
1621#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1622
1623struct magic_num_struct {
1624 uint32_t pid;
1625 uint32_t serial_num;
1626};
1627
1628struct dload_struct {
1629 uint32_t reserved1;
1630 uint32_t reserved2;
1631 uint32_t reserved3;
1632 uint16_t reserved4;
1633 uint16_t pid;
1634 char serial_number[SERIAL_NUMBER_LENGTH];
1635 uint16_t reserved5;
1636 struct magic_num_struct magic_struct;
1637};
1638
1639static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1640{
1641 struct dload_struct __iomem *dload = 0;
1642
1643 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1644 if (!dload) {
1645 pr_err("%s: cannot remap I/O memory region: %08x\n",
1646 __func__, DLOAD_USB_BASE_ADD);
1647 return -ENXIO;
1648 }
1649
1650 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1651 __func__, dload, pid, snum);
1652 /* update pid */
1653 dload->magic_struct.pid = PID_MAGIC_ID;
1654 dload->pid = pid;
1655
1656 /* update serial number */
1657 dload->magic_struct.serial_num = 0;
1658 if (!snum) {
1659 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1660 goto out;
1661 }
1662
1663 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001664 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001665out:
1666 iounmap(dload);
1667 return 0;
1668}
1669
1670static struct android_usb_platform_data android_usb_pdata = {
1671 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1672};
1673
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001674static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675 .name = "android_usb",
1676 .id = -1,
1677 .dev = {
1678 .platform_data = &android_usb_pdata,
1679 },
1680};
1681
1682static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1683 0x03, 0x0f,
1684};
1685
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301686static uint8_t spm_retention_cmd_sequence[] __initdata = {
1687 0x00, 0x05, 0x03, 0x0D,
1688 0x0B, 0x00, 0x0f,
1689};
1690
Anji Jonnala786b39e2013-01-29 13:34:10 +05301691static uint8_t spm_retention_with_krait_v3_cmd_sequence[] __initdata = {
1692 0x42, 0x1B, 0x00,
1693 0x05, 0x03, 0x0D, 0x0B,
1694 0x00, 0x42, 0x1B,
1695 0x0f,
1696};
1697
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001698static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1699 0x00, 0x24, 0x54, 0x10,
1700 0x09, 0x03, 0x01,
1701 0x10, 0x54, 0x30, 0x0C,
1702 0x24, 0x30, 0x0f,
1703};
1704
1705static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1706 0x00, 0x24, 0x54, 0x10,
1707 0x09, 0x07, 0x01, 0x0B,
1708 0x10, 0x54, 0x30, 0x0C,
1709 0x24, 0x30, 0x0f,
1710};
1711
Anji Jonnala0f297a92013-01-19 11:22:25 +05301712/* 8960AB has a different command to assert apc_pdn */
1713static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
Venkat Devarasettycf839c72013-07-26 10:08:37 +05301714 0x00, 0x30, 0x24, 0x30,
1715 0x84, 0x10, 0x09, 0x03,
1716 0x01, 0x10, 0x84, 0x30,
1717 0x0C, 0x24, 0x30, 0x0f,
Anji Jonnala0f297a92013-01-19 11:22:25 +05301718};
1719
1720static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
Venkat Devarasettycf839c72013-07-26 10:08:37 +05301721 0x00, 0x30, 0x24, 0x30,
1722 0x84, 0x10, 0x09, 0x07,
1723 0x01, 0x0B, 0x10, 0x84,
1724 0x30, 0x0C, 0x24, 0x30,
1725 0x0f,
Anji Jonnala0f297a92013-01-19 11:22:25 +05301726};
1727
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301728static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1729 [0] = {
1730 .mode = MSM_SPM_MODE_CLOCK_GATING,
1731 .notify_rpm = false,
1732 .cmd = spm_wfi_cmd_sequence,
1733 },
1734
1735 [1] = {
1736 .mode = MSM_SPM_MODE_POWER_RETENTION,
1737 .notify_rpm = false,
1738 .cmd = spm_retention_cmd_sequence,
1739 },
1740
1741 [2] = {
1742 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1743 .notify_rpm = false,
1744 .cmd = spm_power_collapse_without_rpm,
1745 },
1746 [3] = {
1747 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1748 .notify_rpm = true,
1749 .cmd = spm_power_collapse_with_rpm,
1750 },
1751};
1752
1753static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001754 [0] = {
1755 .mode = MSM_SPM_MODE_CLOCK_GATING,
1756 .notify_rpm = false,
1757 .cmd = spm_wfi_cmd_sequence,
1758 },
Anji Jonnala786b39e2013-01-29 13:34:10 +05301759
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001760 [1] = {
Anji Jonnala786b39e2013-01-29 13:34:10 +05301761 .mode = MSM_SPM_MODE_POWER_RETENTION,
1762 .notify_rpm = false,
1763 .cmd = spm_retention_cmd_sequence,
1764 },
1765
1766 [2] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001767 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1768 .notify_rpm = false,
1769 .cmd = spm_power_collapse_without_rpm,
1770 },
Anji Jonnala786b39e2013-01-29 13:34:10 +05301771
1772 [3] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001773 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1774 .notify_rpm = true,
1775 .cmd = spm_power_collapse_with_rpm,
1776 },
1777};
1778
1779static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1780 [0] = {
1781 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001782 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001783#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301784 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001785 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001786#endif
1787 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301788 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1789 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1790 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001791 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301792 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1793 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001794 },
1795 [1] = {
1796 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001797 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301799 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001800 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001801#endif
1802 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala786b39e2013-01-29 13:34:10 +05301803 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1804 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1805 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001806 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301807 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1808 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001809 },
1810};
1811
1812static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1813 0x00, 0x20, 0x03, 0x20,
1814 0x00, 0x0f,
1815};
1816
1817static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1818 0x00, 0x20, 0x34, 0x64,
1819 0x48, 0x07, 0x48, 0x20,
1820 0x50, 0x64, 0x04, 0x34,
1821 0x50, 0x0f,
1822};
1823static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1824 0x00, 0x10, 0x34, 0x64,
1825 0x48, 0x07, 0x48, 0x10,
1826 0x50, 0x64, 0x04, 0x34,
1827 0x50, 0x0F,
1828};
1829
1830static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1831 [0] = {
1832 .mode = MSM_SPM_L2_MODE_RETENTION,
1833 .notify_rpm = false,
1834 .cmd = l2_spm_wfi_cmd_sequence,
1835 },
1836 [1] = {
1837 .mode = MSM_SPM_L2_MODE_GDHS,
1838 .notify_rpm = true,
1839 .cmd = l2_spm_gdhs_cmd_sequence,
1840 },
1841 [2] = {
1842 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1843 .notify_rpm = true,
1844 .cmd = l2_spm_power_off_cmd_sequence,
1845 },
1846};
1847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001848static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1849 [0] = {
1850 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001851 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001852 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001853 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1854 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1855 .modes = msm_spm_l2_seq_list,
1856 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1857 },
1858};
1859
Anirudh Ghayal15698162012-07-31 11:51:32 +05301860#define HAP_SHIFT_LVL_OE_GPIO 47
1861#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301862#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1863#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1864
1865static struct msm_xo_voter *xo_handle_d1;
1866
1867static int isa1200_power(int on)
1868{
1869 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301870 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301871
Anirudh Ghayal15698162012-07-31 11:51:32 +05301872 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1873 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1874
1875
1876 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301877
1878 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1879 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1880 if (rc < 0) {
1881 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1882 __func__, on ? "" : "de-", rc);
1883 goto err_xo_vote;
1884 }
1885
1886 return 0;
1887
1888err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301889 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301890 return rc;
1891}
1892
1893static int isa1200_dev_setup(bool enable)
1894{
1895 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301896 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301897
1898 struct pm_gpio hap_gpio_config = {
1899 .direction = PM_GPIO_DIR_OUT,
1900 .pull = PM_GPIO_PULL_NO,
1901 .out_strength = PM_GPIO_STRENGTH_HIGH,
1902 .function = PM_GPIO_FUNC_NORMAL,
1903 .inv_int_pol = 0,
1904 .vin_sel = 2,
1905 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1906 .output_value = 0,
1907 };
1908
Anirudh Ghayal15698162012-07-31 11:51:32 +05301909 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1910 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1911
Mohan Pallaka5e490392011-09-09 15:18:41 +05301912 if (enable == true) {
1913 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1914 if (rc) {
1915 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1916 __func__, PM_HAP_EN_GPIO, rc);
1917 return rc;
1918 }
1919
1920 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1921 if (rc) {
1922 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1923 __func__, PM_HAP_LEN_GPIO, rc);
1924 return rc;
1925 }
1926
Anirudh Ghayal15698162012-07-31 11:51:32 +05301927 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301928 if (rc) {
1929 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301930 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301931 return rc;
1932 }
1933
Anirudh Ghayal15698162012-07-31 11:51:32 +05301934 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301935 if (rc) {
1936 pr_err("%s: Unable to set direction\n", __func__);
1937 goto free_gpio;
1938 }
1939
1940 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1941 if (IS_ERR(xo_handle_d1)) {
1942 rc = PTR_ERR(xo_handle_d1);
1943 pr_err("%s: failed to get the handle for D1(%d)\n",
1944 __func__, rc);
1945 goto gpio_set_dir;
1946 }
1947 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05301948 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301949
1950 msm_xo_put(xo_handle_d1);
1951 }
1952
1953 return 0;
1954
1955gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301956 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301957free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301958 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301959 return rc;
1960}
1961
1962static struct isa1200_regulator isa1200_reg_data[] = {
1963 {
1964 .name = "vcc_i2c",
1965 .min_uV = ISA_I2C_VTG_MIN_UV,
1966 .max_uV = ISA_I2C_VTG_MAX_UV,
1967 .load_uA = ISA_I2C_CURR_UA,
1968 },
1969};
1970
1971static struct isa1200_platform_data isa1200_1_pdata = {
1972 .name = "vibrator",
1973 .dev_setup = isa1200_dev_setup,
1974 .power_on = isa1200_power,
1975 .hap_en_gpio = PM_HAP_EN_GPIO,
1976 .hap_len_gpio = PM_HAP_LEN_GPIO,
1977 .max_timeout = 15000,
1978 .mode_ctrl = PWM_GEN_MODE,
1979 .pwm_fd = {
1980 .pwm_div = 256,
1981 },
1982 .is_erm = false,
1983 .smart_en = true,
1984 .ext_clk_en = true,
1985 .chip_en = 1,
1986 .regulator_info = isa1200_reg_data,
1987 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1988};
1989
1990static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1991 {
1992 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05301993 },
1994};
1995
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001996#define CYTTSP_TS_GPIO_IRQ 11
1997#define CYTTSP_TS_SLEEP_GPIO 50
1998#define CYTTSP_TS_RESOUT_N_GPIO 52
1999
2000/*virtual key support */
2001static ssize_t tma340_vkeys_show(struct kobject *kobj,
2002 struct kobj_attribute *attr, char *buf)
2003{
2004 return snprintf(buf, 200,
2005 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2006 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2007 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2008 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2009 "\n");
2010}
2011
2012static struct kobj_attribute tma340_vkeys_attr = {
2013 .attr = {
2014 .mode = S_IRUGO,
2015 },
2016 .show = &tma340_vkeys_show,
2017};
2018
2019static struct attribute *tma340_properties_attrs[] = {
2020 &tma340_vkeys_attr.attr,
2021 NULL
2022};
2023
2024static struct attribute_group tma340_properties_attr_group = {
2025 .attrs = tma340_properties_attrs,
2026};
2027
2028
2029static int cyttsp_platform_init(struct i2c_client *client)
2030{
2031 int rc = 0;
2032 static struct kobject *tma340_properties_kobj;
2033
2034 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2035 tma340_properties_kobj = kobject_create_and_add("board_properties",
2036 NULL);
2037 if (tma340_properties_kobj)
2038 rc = sysfs_create_group(tma340_properties_kobj,
2039 &tma340_properties_attr_group);
2040 if (!tma340_properties_kobj || rc)
2041 pr_err("%s: failed to create board_properties\n",
2042 __func__);
2043
2044 return 0;
2045}
2046
2047static struct cyttsp_regulator regulator_data[] = {
2048 {
2049 .name = "vdd",
2050 .min_uV = CY_TMA300_VTG_MIN_UV,
2051 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302052 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
2053 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002054 },
2055 /* TODO: Remove after runtime PM is enabled in I2C driver */
2056 {
2057 .name = "vcc_i2c",
2058 .min_uV = CY_I2C_VTG_MIN_UV,
2059 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302060 .hpm_load_uA = CY_I2C_CURR_UA,
2061 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002062 },
2063};
2064
2065static struct cyttsp_platform_data cyttsp_pdata = {
2066 .panel_maxx = 634,
2067 .panel_maxy = 1166,
2068 .disp_maxx = 616,
2069 .disp_maxy = 1023,
2070 .disp_minx = 0,
2071 .disp_miny = 16,
2072 .flags = 0x01,
2073 .gen = CY_GEN3, /* or */
2074 .use_st = CY_USE_ST,
2075 .use_mt = CY_USE_MT,
2076 .use_hndshk = CY_SEND_HNDSHK,
2077 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302078 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002079 .use_gestures = CY_USE_GESTURES,
2080 .fw_fname = "cyttsp_8960_cdp.hex",
2081 /* activate up to 4 groups
2082 * and set active distance
2083 */
2084 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2085 CY_GEST_GRP3 | CY_GEST_GRP4 |
2086 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07002087 .act_intrvl = 10,
2088 .tch_tmout = 200,
2089 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002090 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2091 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2092 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2093 .regulator_info = regulator_data,
2094 .num_regulators = ARRAY_SIZE(regulator_data),
2095 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302096 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002097};
2098
2099static struct i2c_board_info cyttsp_info[] __initdata = {
2100 {
2101 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2102 .platform_data = &cyttsp_pdata,
2103#ifndef CY_USE_TIMER
2104 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2105#endif /* CY_USE_TIMER */
2106 },
2107};
2108
Jing Lindc4413c2012-01-16 15:22:52 -08002109/* configuration data for mxt1386 */
2110static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302111 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002112 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302113 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002114 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2120 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302121 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002122 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302123 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002124 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302125 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002126 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2127 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2128 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2129 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302130 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2132 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302133 /* T18 Object */
2134 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302135 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002136 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2137 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302138 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002139 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2140 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302141 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002142 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2143 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302144 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002145 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302146 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002147 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302148 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002149 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302150 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002151 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302152 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002153 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302154};
2155
Jing Lin33b007d2011-12-21 17:40:23 -08002156/* configuration data for mxt1386e using V1.0 firmware */
2157static const u8 mxt1386e_config_data_v1_0[] = {
2158 /* T6 Object */
2159 0, 0, 0, 0, 0, 0,
2160 /* T38 Object */
2161 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2167 0, 0, 0, 0,
2168 /* T7 Object */
2169 100, 16, 50,
2170 /* T8 Object */
2171 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2172 /* T9 Object */
2173 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2174 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2175 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2176 10, 5, 0, 0, 0,
2177 /* T18 Object */
2178 0, 0,
2179 /* T24 Object */
2180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2181 0, 0, 0, 0, 0, 0, 0, 0, 0,
2182 /* T25 Object */
2183 3, 0, 60, 115, 156, 99,
2184 /* T27 Object */
2185 0, 0, 0, 0, 0, 0, 0,
2186 /* T40 Object */
2187 0, 0, 0, 0, 0,
2188 /* T42 Object */
2189 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2190 /* T43 Object */
2191 0, 0, 0, 0, 0, 0, 0,
2192 /* T46 Object */
2193 64, 0, 20, 20, 0, 0, 0, 0, 0,
2194 /* T47 Object */
2195 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2196 /* T48 Object */
2197 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2198 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2199 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2200 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2202 0, 0, 0, 0,
2203 /* T56 Object */
2204 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2205 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2206 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2208 2, 99, 33,
2209};
2210
2211/* configuration data for mxt1386e using V2.1 firmware */
2212static const u8 mxt1386e_config_data_v2_1[] = {
2213 /* T6 Object */
2214 0, 0, 0, 0, 0, 0,
2215 /* T38 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002216 12, 4, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2218 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2222 0, 0, 0, 0,
2223 /* T7 Object */
2224 100, 16, 50,
2225 /* T8 Object */
2226 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2227 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002228 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002229 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002230 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2231 10, 5, 0, 0, 0,
2232 /* T18 Object */
2233 0, 0,
2234 /* T24 Object */
2235 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2236 0, 0, 0, 0, 0, 0, 0, 0, 0,
2237 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002238 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002239 /* T27 Object */
2240 0, 0, 0, 0, 0, 0, 0,
2241 /* T40 Object */
2242 0, 0, 0, 0, 0,
2243 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002244 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002245 /* T43 Object */
2246 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2247 16,
2248 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002249 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002250 /* T47 Object */
2251 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2252 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002253 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002254 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2255 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2256 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2258 0, 0, 0, 0,
2259 /* T56 Object */
2260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2264 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2265 255,
2266};
2267
Jing Lineec88ca2012-02-08 11:18:30 -08002268/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2269static const u8 mxt1386e_config_data_3d[] = {
2270 /* T6 Object */
2271 0, 0, 0, 0, 0, 0,
2272 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002273 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002274 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2275 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2276 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2277 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2278 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2279 0, 0, 0, 0,
2280 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002281 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002282 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002283 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002284 /* T9 Object */
2285 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2286 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002287 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2288 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002289 /* T18 Object */
2290 0, 0,
2291 /* T24 Object */
2292 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2293 0, 0, 0, 0, 0, 0, 0, 0, 0,
2294 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002295 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002296 /* T27 Object */
2297 0, 0, 0, 0, 0, 0, 0,
2298 /* T40 Object */
2299 0, 0, 0, 0, 0,
2300 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002302 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002303 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2304 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002305 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002306 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002307 /* T47 Object */
2308 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2309 /* T48 Object */
2310 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002311 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2312 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2313 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2315 0, 0, 0, 0,
2316 /* T56 Object */
2317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2322 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002323};
2324
Amy Maloche08266db2011-11-04 11:07:16 -07002325#define MXT_TS_GPIO_IRQ 11
2326#define MXT_TS_LDO_EN_GPIO 50
2327#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302328
2329static void mxt_init_hw_liquid(void)
2330{
2331 int rc;
2332
Mohan Pallaka50837382011-09-07 11:00:57 +05302333 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2334 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002335 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2336 __func__, MXT_TS_LDO_EN_GPIO);
2337 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302338 }
2339
2340 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2341 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002342 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2343 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302344 goto err_ldo_gpio_req;
2345 }
2346
Mohan Pallaka50837382011-09-07 11:00:57 +05302347 return;
2348
Mohan Pallaka50837382011-09-07 11:00:57 +05302349err_ldo_gpio_req:
2350 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302351}
2352
Jing Lineec88ca2012-02-08 11:18:30 -08002353static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002354 {
2355 .config = mxt1386_config_data,
2356 .config_length = ARRAY_SIZE(mxt1386_config_data),
2357 .family_id = 0xA0,
2358 .variant_id = 0x0,
2359 .version = 0x10,
2360 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002361 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002362 },
Jing Lin33b007d2011-12-21 17:40:23 -08002363 {
2364 .config = mxt1386e_config_data_v1_0,
2365 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2366 .family_id = 0xA0,
2367 .variant_id = 0x2,
2368 .version = 0x10,
2369 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002370 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002371 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002372 },
2373 {
2374 .config = mxt1386e_config_data_v2_1,
2375 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2376 .family_id = 0xA0,
2377 .variant_id = 0x7,
2378 .version = 0x21,
2379 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002380 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002381 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2382 },
2383 {
2384 /* The config data for V2.2.AA is the same as for V2.1.AA */
2385 .config = mxt1386e_config_data_v2_1,
2386 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2387 .family_id = 0xA0,
2388 .variant_id = 0x7,
2389 .version = 0x22,
2390 .build = 0xAA,
2391 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002392 },
Jing Lindc4413c2012-01-16 15:22:52 -08002393};
2394
Jing Lineec88ca2012-02-08 11:18:30 -08002395static struct mxt_platform_data mxt_platform_data_2d = {
2396 .config_array = mxt_config_array_2d,
2397 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002398 .panel_minx = 0,
2399 .panel_maxx = 1365,
2400 .panel_miny = 0,
2401 .panel_maxy = 767,
2402 .disp_minx = 0,
2403 .disp_maxx = 1365,
2404 .disp_miny = 0,
2405 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302406 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002407 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002408 .reset_gpio = MXT_TS_RESET_GPIO,
2409 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302410};
2411
Jing Lineec88ca2012-02-08 11:18:30 -08002412static struct mxt_config_info mxt_config_array_3d[] = {
2413 {
2414 .config = mxt1386e_config_data_3d,
2415 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2416 .family_id = 0xA0,
2417 .variant_id = 0x7,
2418 .version = 0x21,
2419 .build = 0xAA,
2420 },
2421};
2422
2423static struct mxt_platform_data mxt_platform_data_3d = {
2424 .config_array = mxt_config_array_3d,
2425 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002426 .panel_minx = 0,
2427 .panel_maxx = 1919,
2428 .panel_miny = 0,
2429 .panel_maxy = 1199,
2430 .disp_minx = 0,
2431 .disp_maxx = 1919,
2432 .disp_miny = 0,
2433 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002434 .irqflags = IRQF_TRIGGER_FALLING,
2435 .i2c_pull_up = true,
2436 .reset_gpio = MXT_TS_RESET_GPIO,
2437 .irq_gpio = MXT_TS_GPIO_IRQ,
2438};
2439
Mohan Pallaka50837382011-09-07 11:00:57 +05302440static struct i2c_board_info mxt_device_info[] __initdata = {
2441 {
2442 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302443 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2444 },
2445};
2446
Manoj Rao14648742012-03-30 19:42:12 -07002447static struct msm_mhl_platform_data mhl_platform_data = {
2448 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002449 .gpio_mhl_int = MHL_GPIO_INT,
2450 .gpio_mhl_reset = MHL_GPIO_RESET,
2451 .gpio_mhl_power = 0,
2452 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002453};
Manoj Rao14648742012-03-30 19:42:12 -07002454
Eugene Yasmand2316b82011-12-07 18:23:48 +02002455static struct i2c_board_info sii_device_info[] __initdata = {
2456 {
Manoj Rao14648742012-03-30 19:42:12 -07002457#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2458 /*
2459 * keeps SI 8334 as the default
2460 * MHL TX
2461 */
2462 I2C_BOARD_INFO("sii8334", 0x39),
2463 .platform_data = &mhl_platform_data,
2464#endif
2465#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002466 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002467 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002468#endif /* CONFIG_MSM_HDMI_MHL */
2469 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002470 },
2471};
2472
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002473static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2474 .clk_freq = 100000,
2475 .src_clk_rate = 24000000,
Kiran Gundab4696c72012-08-16 18:37:46 +05302476 .keep_ahb_clk_on = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002477};
2478
2479static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2480 .clk_freq = 100000,
2481 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002482};
2483
2484static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2485 .clk_freq = 100000,
2486 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002487};
2488
2489static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2490 .clk_freq = 100000,
2491 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002492};
2493
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002494static struct ks8851_pdata spi_eth_pdata = {
2495 .irq_gpio = KS8851_IRQ_GPIO,
2496 .rst_gpio = KS8851_RST_GPIO,
2497};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002498
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302499static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002500 {
2501 .modalias = "ks8851",
2502 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2503 .max_speed_hz = 19200000,
2504 .bus_num = 0,
2505 .chip_select = 0,
2506 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002507 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002508 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302509};
2510static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002511 {
2512 .modalias = "dsi_novatek_3d_panel_spi",
2513 .max_speed_hz = 10800000,
2514 .bus_num = 0,
2515 .chip_select = 1,
2516 .mode = SPI_MODE_0,
2517 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002518};
2519
2520static struct platform_device msm_device_saw_core0 = {
2521 .name = "saw-regulator",
2522 .id = 0,
2523 .dev = {
2524 .platform_data = &msm_saw_regulator_pdata_s5,
2525 },
2526};
2527
2528static struct platform_device msm_device_saw_core1 = {
2529 .name = "saw-regulator",
2530 .id = 1,
2531 .dev = {
2532 .platform_data = &msm_saw_regulator_pdata_s6,
2533 },
2534};
2535
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002536static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002537 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002538 .tsens_factor = 1000,
2539 .hw_type = MSM_8960,
2540 .tsens_num_sensor = 5,
2541};
2542
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002543static struct platform_device msm_tsens_device = {
2544 .name = "tsens8960-tm",
2545 .id = -1,
2546};
2547
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002548static struct msm_thermal_data msm_thermal_pdata = {
2549 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002550 .poll_ms = 250,
2551 .limit_temp_degC = 60,
2552 .temp_hysteresis_degC = 10,
2553 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002554};
2555
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002556#ifdef CONFIG_MSM_FAKE_BATTERY
2557static struct platform_device fish_battery_device = {
2558 .name = "fish_battery",
2559};
2560#endif
2561
Anji Jonnalafde57a32013-03-20 17:22:39 +05302562#ifdef CONFIG_BATTERY_BCL
2563static struct platform_device battery_bcl_device = {
2564 .name = "battery_current_limit",
2565 .id = -1,
2566 };
2567#endif
2568
David Collins26f05562011-06-20 09:56:28 -07002569static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002570 .name = GPIO_REGULATOR_DEV_NAME,
2571 .id = PM8921_MPP_PM_TO_SYS(7),
2572 .dev = {
2573 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2574 },
2575};
2576
David Collins26f05562011-06-20 09:56:28 -07002577static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002578 .name = GPIO_REGULATOR_DEV_NAME,
2579 .id = 91,
2580 .dev = {
2581 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2582 },
2583};
2584
David Collinsb10be1d2011-09-02 10:29:31 -07002585static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2586 .name = GPIO_REGULATOR_DEV_NAME,
2587 .id = PM8921_GPIO_PM_TO_SYS(17),
2588 .dev = {
2589 .platform_data =
2590 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2591 },
2592};
2593
David Collins35a78f52011-12-14 15:54:25 -08002594static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2595 .name = GPIO_REGULATOR_DEV_NAME,
2596 .id = PM8921_GPIO_PM_TO_SYS(42),
2597 .dev = {
2598 .platform_data =
2599 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2600 },
2601};
2602
David Collins26f05562011-06-20 09:56:28 -07002603static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2604 .name = "rpm-regulator",
2605 .id = -1,
2606 .dev = {
2607 .platform_data = &msm_rpm_regulator_pdata,
2608 },
2609};
Mayank Ranae009c922012-03-22 03:02:06 +05302610#ifdef CONFIG_SERIAL_MSM_HS
Mayank Ranae009c922012-03-22 03:02:06 +05302611static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Rana60ae1af2013-03-08 14:09:51 +05302612 .config_gpio = 4,
2613 .uart_tx_gpio = 93,
2614 .uart_rx_gpio = 94,
2615 .uart_cts_gpio = 95,
2616 .uart_rfr_gpio = 96,
Mayank Ranae009c922012-03-22 03:02:06 +05302617};
Mayank Rana1f02d952012-07-04 19:11:20 +05302618
Mayank Rana1f02d952012-07-04 19:11:20 +05302619static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
Mayank Rana60ae1af2013-03-08 14:09:51 +05302620 .config_gpio = 4,
2621 .uart_tx_gpio = 34,
2622 .uart_rx_gpio = 35,
2623 .uart_cts_gpio = 36,
2624 .uart_rfr_gpio = 37,
Dilip Kotaae751902013-07-15 12:59:21 +05302625 .uartdm_rx_buf_size = 1024,
Mayank Rana1f02d952012-07-04 19:11:20 +05302626};
Mayank Ranae009c922012-03-22 03:02:06 +05302627#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302628static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302629static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2630#endif
David Collins26f05562011-06-20 09:56:28 -07002631
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302632#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002633enum WLANBT_STATUS {
2634 WLANOFF_BTOFF = 1,
2635 WLANOFF_BTON,
2636 WLANON_BTOFF,
2637 WLANON_BTON
2638};
2639
2640static DEFINE_MUTEX(ath_wlanbt_mutex);
2641static int gpio_wlan_sys_rest_en = 26;
2642static int ath_wlanbt_status = WLANOFF_BTOFF;
2643
2644static int ath6kl_power_control(int on)
2645{
2646 int rc;
2647
2648 if (on) {
2649 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2650 if (rc) {
2651 pr_err("%s: unable to request gpio %d (%d)\n",
2652 __func__, gpio_wlan_sys_rest_en, rc);
2653 return rc;
2654 }
2655 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2656 msleep(200);
2657 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2658 msleep(100);
2659 } else {
2660 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2661 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2662 msleep(100);
2663 gpio_free(gpio_wlan_sys_rest_en);
2664 }
2665 return 0;
2666};
2667
2668static int ath6kl_wlan_power(int on)
2669{
2670 int ret = 0;
2671
2672 mutex_lock(&ath_wlanbt_mutex);
2673 if (on) {
2674 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2675 ret = ath6kl_power_control(1);
2676 ath_wlanbt_status = WLANON_BTOFF;
2677 } else if (ath_wlanbt_status == WLANOFF_BTON)
2678 ath_wlanbt_status = WLANON_BTON;
2679 } else {
2680 if (ath_wlanbt_status == WLANON_BTOFF) {
2681 ret = ath6kl_power_control(0);
2682 ath_wlanbt_status = WLANOFF_BTOFF;
2683 } else if (ath_wlanbt_status == WLANON_BTON)
2684 ath_wlanbt_status = WLANOFF_BTON;
2685 }
2686 mutex_unlock(&ath_wlanbt_mutex);
2687 pr_debug("%s on= %d, wlan_status= %d\n",
2688 __func__, on, ath_wlanbt_status);
2689 return ret;
2690};
2691
2692static struct wifi_platform_data ath6kl_wifi_control = {
2693 .set_power = ath6kl_wlan_power,
2694};
2695
2696static struct platform_device msm_wlan_power_device = {
2697 .name = "ath6kl_power",
2698 .dev = {
2699 .platform_data = &ath6kl_wifi_control,
2700 },
2701};
2702
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302703static struct resource bluesleep_resources[] = {
2704 {
2705 .name = "gpio_host_wake",
2706 .start = 27,
2707 .end = 27,
2708 .flags = IORESOURCE_IO,
2709 },
2710 {
2711 .name = "gpio_ext_wake",
2712 .start = 29,
2713 .end = 29,
2714 .flags = IORESOURCE_IO,
2715 },
2716 {
2717 .name = "host_wake",
2718 .start = MSM_GPIO_TO_INT(27),
2719 .end = MSM_GPIO_TO_INT(27),
2720 .flags = IORESOURCE_IRQ,
2721 },
2722};
2723
2724static struct platform_device msm_bluesleep_device = {
2725 .name = "bluesleep",
2726 .id = -1,
2727 .num_resources = ARRAY_SIZE(bluesleep_resources),
2728 .resource = bluesleep_resources,
2729};
2730
2731static struct platform_device msm_bt_power_device = {
2732 .name = "bt_power",
2733};
2734
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002735static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302736
2737static int bluetooth_power(int on)
2738{
2739 int rc;
2740
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002741 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302742 if (on) {
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002743 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2744 ath6kl_power_control(1);
2745 ath_wlanbt_status = WLANOFF_BTON;
2746 } else if (ath_wlanbt_status == WLANON_BTOFF)
2747 ath_wlanbt_status = WLANON_BTON;
2748
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302749 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2750 if (rc) {
2751 pr_err("%s: unable to request gpio %d (%d)\n",
2752 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002753 mutex_unlock(&ath_wlanbt_mutex);
2754 return rc;
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302755 }
2756 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002757 msleep(20);
2758 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302759 msleep(100);
2760 } else {
2761 gpio_set_value(gpio_bt_sys_rest_en, 0);
2762 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2763 msleep(100);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002764 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302765
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002766 if (ath_wlanbt_status == WLANOFF_BTON) {
2767 ath6kl_power_control(0);
2768 ath_wlanbt_status = WLANOFF_BTOFF;
2769 } else if (ath_wlanbt_status == WLANON_BTON)
2770 ath_wlanbt_status = WLANON_BTOFF;
2771 }
2772 mutex_unlock(&ath_wlanbt_mutex);
2773 pr_debug("%s on= %d, wlan_status= %d\n",
2774 __func__, on, ath_wlanbt_status);
2775 return 0;
2776};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302777
2778static void __init bt_power_init(void)
2779{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302780 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302781 return;
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002782};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302783#else
2784#define bt_power_init(x) do {} while (0)
2785#endif
2786
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002787static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002788 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002789 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302790 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002791 &msm_device_saw_core0,
2792 &msm_device_saw_core1,
2793 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002794 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002795 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002796 &msm8960_device_qup_spi_gsbi1,
2797 &msm8960_device_qup_i2c_gsbi3,
2798 &msm8960_device_qup_i2c_gsbi4,
2799 &msm8960_device_qup_i2c_gsbi10,
2800#ifndef CONFIG_MSM_DSPS
2801 &msm8960_device_qup_i2c_gsbi12,
2802#endif
2803 &msm_slim_ctrl,
2804 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302805#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2806 &msm_bluesleep_device,
2807 &msm_bt_power_device,
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002808 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302809#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002810#if defined(CONFIG_QSEECOM)
2811 &qseecom_device,
2812#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2814 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2815 &qcrypto_device,
2816#endif
2817
2818#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2819 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2820 &qcedev_device,
2821#endif
2822#ifdef CONFIG_MSM_ROTATOR
2823 &msm_rotator_device,
2824#endif
2825 &msm_device_sps,
2826#ifdef CONFIG_MSM_FAKE_BATTERY
2827 &fish_battery_device,
2828#endif
Anji Jonnalafde57a32013-03-20 17:22:39 +05302829#ifdef CONFIG_BATTERY_BCL
2830 &battery_bcl_device,
2831#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002832 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002833#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002834#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002835 &msm8960_android_pmem_device,
2836 &msm8960_android_pmem_adsp_device,
2837 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002838#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002839#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002840 &msm_device_bam_dmux,
2841 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002842#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2843#ifdef CONFIG_MSM_USE_TSIF1
2844 &msm_device_tsif[1],
2845#else
2846 &msm_device_tsif[0],
2847#endif
2848#endif
Joel Nider266a2642011-10-16 10:58:05 +02002849 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002850#ifdef CONFIG_HW_RANDOM_MSM
2851 &msm_device_rng,
2852#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002853#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002854 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002855#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002856 &msm8960_rpm_device,
2857 &msm8960_rpm_log_device,
2858 &msm8960_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302859 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002860 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002861 &coresight_tpiu_device,
2862 &coresight_etb_device,
2863 &coresight_funnel_device,
2864 &coresight_etm0_device,
2865 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002866 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002867 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002868 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002869 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002870 &msm8960_device_ebi1_ch0_erp,
2871 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002872 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002873 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002874 &msm_tsens_device,
Anji Jonnalae84292b2012-09-21 13:34:44 +05302875 &msm8960_pc_cntr,
Anji Jonnala4bf6c0c2013-04-16 17:07:52 +05302876 &msm8960_cpu_slp_status,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002877};
2878
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002879static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002880 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002881 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002882 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002883 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002884 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002885 &msm8960_device_otg,
2886 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887 &msm_device_hsusb_host,
2888 &android_usb_device,
2889 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002890 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002891 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892 &msm_pcm_routing,
2893 &msm_cpudai0,
2894 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002895 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002896 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002897 &msm_cpudai_hdmi_rx,
2898 &msm_cpudai_bt_rx,
2899 &msm_cpudai_bt_tx,
2900 &msm_cpudai_fm_rx,
2901 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002902 &msm_cpudai_auxpcm_rx,
2903 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002904 &msm_cpu_fe,
2905 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002906#ifdef CONFIG_MSM_GEMINI
2907 &msm8960_gemini_device,
2908#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07002909#ifdef CONFIG_MSM_MERCURY
2910 &msm8960_mercury_device,
2911#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002912 &msm_voice,
2913 &msm_voip,
2914 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302915 &msm_cpudai_afe_01_rx,
2916 &msm_cpudai_afe_01_tx,
2917 &msm_cpudai_afe_02_rx,
2918 &msm_cpudai_afe_02_tx,
2919 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302920 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002921 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002922 &msm_cpudai_incall_record_rx,
2923 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002924 &msm_pcm_hostless,
2925 &msm_bus_apps_fabric,
2926 &msm_bus_sys_fabric,
2927 &msm_bus_mm_fabric,
2928 &msm_bus_sys_fpb,
2929 &msm_bus_cpss_fpb,
2930};
2931
2932static void __init msm8960_i2c_init(void)
2933{
2934 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2935 &msm8960_i2c_qup_gsbi4_pdata;
2936
2937 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2938 &msm8960_i2c_qup_gsbi3_pdata;
2939
2940 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2941 &msm8960_i2c_qup_gsbi10_pdata;
2942
2943 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2944 &msm8960_i2c_qup_gsbi12_pdata;
2945}
2946
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002947static void __init msm8960_gfx_init(void)
2948{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002949 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2950 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06002951 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002952
Carter Cooper3852cbb2012-08-20 22:11:42 -06002953 /* Fixup data that needs to change based on GPU ID */
Carter Cooperffe7ea12012-08-22 13:27:58 -06002954 if (cpu_is_msm8960ab()) {
Hareesh Gundu9686de22013-02-20 20:16:11 +05302955 if (SOCINFO_VERSION_MINOR(soc_platform_version) == 0)
2956 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
2957 else
2958 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 1);
Suman Tatiraju20372242012-10-29 18:24:53 -07002959 /* 8960PRO nominal clock rate is 320Mhz */
2960 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Carter Cooper3852cbb2012-08-20 22:11:42 -06002961 } else {
2962 kgsl_3d0_pdata->iommu_count = 1;
2963 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
2964 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
2965 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
2966 }
2967 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
2968 /* 8960v3 GPU registers returns 5 for patch release
2969 * but it should be 6, so dummy up the chipid here
2970 * based the platform type
2971 */
2972 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
2973 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002974 }
Carter Cooper6307eb992012-08-20 15:17:23 -06002975
2976 /* Register the 3D core */
2977 platform_device_register(&msm_kgsl_3d0);
2978
2979 /* Register the 2D cores if we are not 8960PRO */
2980 if (!cpu_is_msm8960ab()) {
2981 platform_device_register(&msm_kgsl_2d0);
2982 platform_device_register(&msm_kgsl_2d1);
2983 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002984}
2985
Subhash Jadavani933e6a62011-12-26 18:05:04 +05302986static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002987 {
2988 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
2989 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2990 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002991 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002992 },
2993
2994 {
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302995 MSM_PM_SLEEP_MODE_RETENTION,
2996 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2997 true,
2998 415, 715, 340827, 475,
2999 },
3000
3001 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003002 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3003 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3004 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003005 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003006 },
3007
3008 {
3009 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3010 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3011 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003012 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003013 },
3014
3015 {
3016 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003017 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
3018 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003019 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003020 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003021
3022 {
3023 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3024 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3025 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003026 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003027 },
3028
3029 {
3030 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3031 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3032 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003033 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003034 },
3035
3036 {
3037 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3038 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3039 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003040 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003041 },
3042
3043 {
3044 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3045 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3046 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003047 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003048 },
3049};
3050
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303051
Praveen Chidambaram78499012011-11-01 17:15:17 -06003052static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
3053 .levels = &msm_rpmrs_levels[0],
3054 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
3055 .vdd_mem_levels = {
3056 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3057 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3058 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3059 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3060 },
3061 .vdd_dig_levels = {
3062 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3063 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3064 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3065 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3066 },
3067 .vdd_mask = 0x7FFFFF,
3068 .rpmrs_target_id = {
3069 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3070 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3071 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3072 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3073 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3074 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3075 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3076 },
3077};
3078
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003079static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3080 .mode = MSM_PM_BOOT_CONFIG_TZ,
3081};
3082
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003083#ifdef CONFIG_I2C
3084#define I2C_SURF 1
3085#define I2C_FFA (1 << 1)
3086#define I2C_RUMI (1 << 2)
3087#define I2C_SIM (1 << 3)
3088#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003089#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003090
3091struct i2c_registry {
3092 u8 machs;
3093 int bus;
3094 struct i2c_board_info *info;
3095 int len;
3096};
3097
Srikanth Uyyala187ada82013-07-17 18:42:57 +05303098/* AVTimer */
3099static struct platform_device msm_dev_avtimer_device = {
3100 .name = "dev_avtimer",
3101 .dev = { .platform_data = &dev_avtimer_pdata },
3102};
3103
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003104/* Sensors DSPS platform data */
3105#ifdef CONFIG_MSM_DSPS
3106#define DSPS_PIL_GENERIC_NAME "dsps"
3107#endif /* CONFIG_MSM_DSPS */
3108
3109static void __init msm8960_init_dsps(void)
3110{
3111#ifdef CONFIG_MSM_DSPS
3112 struct msm_dsps_platform_data *pdata =
3113 msm_dsps_device.dev.platform_data;
3114 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3115 pdata->gpios = NULL;
3116 pdata->gpios_num = 0;
3117
3118 platform_device_register(&msm_dsps_device);
3119#endif /* CONFIG_MSM_DSPS */
3120}
3121
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003122static int hsic_peripheral_status = 1;
3123static DEFINE_MUTEX(hsic_status_lock);
3124
3125void peripheral_connect()
3126{
3127 mutex_lock(&hsic_status_lock);
3128 if (hsic_peripheral_status)
3129 goto out;
3130 platform_device_add(&msm_device_hsic_host);
3131 hsic_peripheral_status = 1;
3132out:
3133 mutex_unlock(&hsic_status_lock);
3134}
3135EXPORT_SYMBOL(peripheral_connect);
3136
3137void peripheral_disconnect()
3138{
3139 mutex_lock(&hsic_status_lock);
3140 if (!hsic_peripheral_status)
3141 goto out;
3142 platform_device_del(&msm_device_hsic_host);
3143 hsic_peripheral_status = 0;
3144out:
3145 mutex_unlock(&hsic_status_lock);
3146}
3147EXPORT_SYMBOL(peripheral_disconnect);
3148
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303149static void __init msm8960_init_smsc_hub(void)
3150{
3151 uint32_t version = socinfo_get_version();
3152
3153 if (SOCINFO_VERSION_MAJOR(version) == 1)
3154 return;
3155
3156 if (machine_is_msm8960_liquid())
3157 platform_device_register(&smsc_hub_device);
3158}
3159
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003160static void __init msm8960_init_hsic(void)
3161{
3162#ifdef CONFIG_USB_EHCI_MSM_HSIC
3163 uint32_t version = socinfo_get_version();
3164
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003165 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003166 return;
3167
Joel King0cbf5d82012-05-24 15:21:38 -07003168 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003169 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003170#endif
3171}
3172
Amir Samuelov5137e392011-09-21 17:31:25 +03003173#ifdef CONFIG_ISL9519_CHARGER
3174static struct isl_platform_data isl_data __initdata = {
3175 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3176 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3177 .max_system_voltage = 4200,
3178 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003179 .chgcurrent = 1900,
3180 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003181 .input_current = 2048,
3182};
3183
3184static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3185 {
3186 I2C_BOARD_INFO("isl9519q", 0x9),
3187 .irq = 0, /* Not required when notify-by-pmic */
3188 .platform_data = &isl_data,
3189 },
3190};
3191#endif /* CONFIG_ISL9519_CHARGER */
3192
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003193#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003194static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3195 {
3196 I2C_BOARD_INFO("sx1508q", 0x20),
3197 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3198 },
3199};
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003200#endif
Amir Samuelov755616d2011-12-13 16:34:46 +02003201
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003202static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003203#ifdef CONFIG_ISL9519_CHARGER
3204 {
3205 I2C_LIQUID,
3206 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3207 isl_charger_i2c_info,
3208 ARRAY_SIZE(isl_charger_i2c_info),
3209 },
3210#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003211 {
3212 I2C_SURF | I2C_FFA | I2C_FLUID,
3213 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3214 cyttsp_info,
3215 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003216 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303217 {
3218 I2C_LIQUID,
3219 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3220 mxt_device_info,
3221 ARRAY_SIZE(mxt_device_info),
3222 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303223 {
Manoj Rao14648742012-03-30 19:42:12 -07003224 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303225 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003226 sii_device_info,
3227 ARRAY_SIZE(sii_device_info),
3228 },
3229 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303230 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003231 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303232 msm_isa1200_board_info,
3233 ARRAY_SIZE(msm_isa1200_board_info),
3234 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003235#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003236 {
3237 I2C_LIQUID,
3238 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3239 liquid_io_expander_i2c_info,
3240 ARRAY_SIZE(liquid_io_expander_i2c_info),
3241 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003242#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003243};
3244#endif /* CONFIG_I2C */
3245
3246static void __init register_i2c_devices(void)
3247{
3248#ifdef CONFIG_I2C
3249 u8 mach_mask = 0;
3250 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003251#ifdef CONFIG_MSM_CAMERA
3252 struct i2c_registry msm8960_camera_i2c_devices = {
3253 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3254 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3255 msm8960_camera_board_info.board_info,
3256 msm8960_camera_board_info.num_i2c_board_info,
3257 };
3258#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003259
3260 /* Build the matching 'supported_machs' bitmask */
3261 if (machine_is_msm8960_cdp())
3262 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003263 else if (machine_is_msm8960_fluid())
3264 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003265 else if (machine_is_msm8960_liquid())
3266 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003267 else if (machine_is_msm8960_mtp())
3268 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003269 else
3270 pr_err("unmatched machine ID in register_i2c_devices\n");
3271
Jing Lineec88ca2012-02-08 11:18:30 -08003272 if (machine_is_msm8960_liquid()) {
3273 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3274 mxt_device_info[0].platform_data =
3275 &mxt_platform_data_3d;
3276 else
3277 mxt_device_info[0].platform_data =
3278 &mxt_platform_data_2d;
3279 }
3280
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003281 /* Run the array and install devices as appropriate */
3282 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3283 if (msm8960_i2c_devices[i].machs & mach_mask)
3284 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3285 msm8960_i2c_devices[i].info,
3286 msm8960_i2c_devices[i].len);
3287 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003288
3289 if (!mhl_platform_data.gpio_mhl_power)
3290 pr_debug("mhl device configured for ext debug board\n");
3291
Kevin Chan09f4e662011-12-16 08:17:02 -08003292#ifdef CONFIG_MSM_CAMERA
3293 if (msm8960_camera_i2c_devices.machs & mach_mask)
3294 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3295 msm8960_camera_i2c_devices.info,
3296 msm8960_camera_i2c_devices.len);
3297#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003298#endif
3299}
3300
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003301static void __init msm8960_tsens_init(void)
3302{
3303 if (cpu_is_msm8960())
3304 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3305 return;
3306
3307 msm_tsens_early_init(&msm_tsens_pdata);
3308}
3309
Anji Jonnala0f297a92013-01-19 11:22:25 +05303310static void __init msm8960ab_update_krait_spm(void)
3311 {
3312 int i;
3313
Anji Jonnala0f297a92013-01-19 11:22:25 +05303314
3315 /* Update the SPM sequences for SPC and PC */
3316 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3317 int j;
3318 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3319 for (j = 0; j < pdata->num_modes; j++) {
3320 if (pdata->modes[j].cmd ==
3321 spm_power_collapse_without_rpm)
3322 pdata->modes[j].cmd =
3323 spm_power_collapse_without_rpm_krait_v3;
3324 else if (pdata->modes[j].cmd ==
3325 spm_power_collapse_with_rpm)
3326 pdata->modes[j].cmd =
3327 spm_power_collapse_with_rpm_krait_v3;
3328 }
3329 }
3330}
3331
Anji Jonnala786b39e2013-01-29 13:34:10 +05303332static void __init msm8960ab_update_retention_spm(void)
3333{
3334 int i;
3335
3336 /* Update the SPM sequences for krait retention on all cores */
3337 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3338 int j;
3339 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3340 for (j = 0; j < pdata->num_modes; j++) {
3341 if (pdata->modes[j].cmd ==
3342 spm_retention_cmd_sequence)
3343 pdata->modes[j].cmd =
3344 spm_retention_with_krait_v3_cmd_sequence;
3345 }
3346 }
3347}
3348
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003349static void __init msm8960_cdp_init(void)
3350{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003351 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3352 pr_err("meminfo_init() failed!\n");
3353
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003354 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003355 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003356 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003357 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3358 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003359
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003360 regulator_suppress_info_printing();
3361 if (msm_xo_init())
3362 pr_err("Failed to initialize XO votes\n");
David Collins4c93ce92012-09-04 15:44:19 -07003363 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003364 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003365 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303366 if (machine_is_msm8960_liquid())
3367 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003368 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303369 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3370 machine_is_msm8960_cdp()) {
Mayank Ranaa1f507b2012-08-14 10:57:00 +05303371 /* Due to availability of USB Switch in SGLTE Platform
3372 * it requires different HSUSB PHY settings compare to
3373 * 8960 MTP/CDP platform.
3374 */
3375 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3376 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3377 else
3378 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303379 } else if (machine_is_msm8960_liquid()) {
3380 msm_otg_pdata.phy_init_seq =
3381 liquid_v1_phy_init_seq;
3382 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003383 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303384 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303385 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303386 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3387 machine_is_msm8960_liquid())
3388 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003389 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003390 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3391 &msm8960_qup_spi_gsbi1_pdata;
3392 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303393 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3394 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003395
3396 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303397 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jain4ffd8122012-12-03 15:09:39 +05303398 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3399 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303400 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003401 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003402 msm8960_gfx_init();
Anji Jonnala0f297a92013-01-19 11:22:25 +05303403 if (cpu_is_msm8960ab())
3404 msm8960ab_update_krait_spm();
Anji Jonnala786b39e2013-01-29 13:34:10 +05303405 if (cpu_is_krait_v3()) {
3406 msm_pm_set_tz_retention_flag(0);
3407 msm8960ab_update_retention_spm();
3408 } else {
3409 msm_pm_set_tz_retention_flag(1);
3410 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003411 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3412 msm_spm_l2_init(msm_spm_l2_data);
3413 msm8960_init_buses();
Stephen Boyd6716bd92012-10-25 11:46:04 -07003414 if (cpu_is_msm8960ab()) {
3415 platform_add_devices(msm8960ab_footswitch,
3416 msm8960ab_num_footswitch);
3417 } else {
3418 platform_add_devices(msm8960_footswitch,
3419 msm8960_num_footswitch);
3420 }
David Collinsb10be1d2011-09-02 10:29:31 -07003421 if (machine_is_msm8960_liquid())
3422 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003423 if (machine_is_msm8960_cdp())
3424 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003425
3426 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3427 platform_device_register(&msm8960_device_uart_gsbi8);
3428 else
3429 platform_device_register(&msm8960_device_uart_gsbi5);
3430
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003431 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003432 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3433 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003434 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303435 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003436 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003437
Mayank Rana1f02d952012-07-04 19:11:20 +05303438 /* For 8960 Standalone External Bluetooth Interface */
3439 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3440 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3441 platform_device_register(&msm_device_uart_dm8);
3442 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003443 if (cpu_is_msm8960ab())
3444 platform_device_register(&msm8960ab_device_acpuclk);
3445 else
3446 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003447 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menond4837f62012-08-20 15:25:50 -07003448 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003449
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003450 msm8960_pm8921_gpio_mpp_init();
Stephen Boyd0ea1b762012-09-13 12:41:31 -07003451 /* Don't add modem devices on APQ targets */
3452 if (socinfo_get_id() != 124) {
3453 platform_device_register(&msm_8960_q6_mss_fw);
3454 platform_device_register(&msm_8960_q6_mss_sw);
3455 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003456 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303457 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003458 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003459#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003460 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003461#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303463 if (machine_is_msm8960_liquid())
3464 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003465 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003466 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003467 slim_register_board_info(msm_slim_devices,
3468 ARRAY_SIZE(msm_slim_devices));
3469 msm8960_init_dsps();
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003470 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303471 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003472 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3473 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3474 platform_device_register(&mdm_sglte_device);
3475 }
Srikanth Uyyala187ada82013-07-17 18:42:57 +05303476 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3477 machine_is_msm8960_cdp()) {
3478 platform_device_register(&msm_dev_avtimer_device);
3479 }
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003480}
3481
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003482MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3483 .map_io = msm8960_map_io,
3484 .reserve = msm8960_reserve,
3485 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303486 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003487 .timer = &msm_timer,
3488 .init_machine = msm8960_cdp_init,
3489 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003490 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003491 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003492MACHINE_END
3493
3494MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3495 .map_io = msm8960_map_io,
3496 .reserve = msm8960_reserve,
3497 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303498 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003499 .timer = &msm_timer,
3500 .init_machine = msm8960_cdp_init,
3501 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003502 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003503 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003504MACHINE_END
3505
3506MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3507 .map_io = msm8960_map_io,
3508 .reserve = msm8960_reserve,
3509 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303510 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003511 .timer = &msm_timer,
3512 .init_machine = msm8960_cdp_init,
3513 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003514 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003515 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003516MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003517
3518MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3519 .map_io = msm8960_map_io,
3520 .reserve = msm8960_reserve,
3521 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303522 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003523 .timer = &msm_timer,
3524 .init_machine = msm8960_cdp_init,
3525 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003526 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003527 .restart = msm_restart,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003528MACHINE_END