blob: 3b7fc1494c526809000591ab933157467e1b2888 [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;
Laura Abbottf8c03b92012-02-16 14:57:58 -0800308#endif
309}
310
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700311static void __init size_pmem_devices(void)
312{
313#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700314#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700315 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800316
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800317 if (!pmem_param_set) {
318 if (machine_is_msm8960_liquid())
319 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700320 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800321 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
322 }
323
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324 android_pmem_pdata.size = pmem_size;
325 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700326#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
327#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328}
329
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700330#ifdef CONFIG_ANDROID_PMEM
331#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332static void __init reserve_memory_for(struct android_pmem_platform_data *p)
333{
334 msm8960_reserve_table[p->memory_type].size += p->size;
335}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700336#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
337#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338
339static void __init reserve_pmem_memory(void)
340{
341#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700342#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700343 reserve_memory_for(&android_pmem_adsp_pdata);
344 reserve_memory_for(&android_pmem_pdata);
345 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700346#endif
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700347 msm8960_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700348#endif
349}
350
Larry Basselb4126da2011-07-18 14:31:33 -0700351static int msm8960_paddr_to_memtype(unsigned int paddr)
352{
353 return MEMTYPE_EBI1;
354}
355
Steve Mucklef132c6c2012-06-06 18:30:57 -0700356#define FMEM_ENABLED 0
Olav Hauganf6dc7742012-02-15 09:11:55 -0800357
Laura Abbottd6183792011-08-19 13:42:24 -0700358#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800359#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700360static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800361 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -0700362 .align = SZ_64K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800363 .reusable = FMEM_ENABLED,
364 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700365 .fixed_position = FIXED_MIDDLE,
Olav Haugan8726caf2012-05-10 15:11:35 -0700366 .iommu_map_all = 1,
367 .iommu_2x_map_domain = VIDEO_DOMAIN,
Laura Abbottadec9c72012-12-05 11:49:59 -0800368 .is_cma = 1,
Laura Abbott5249a052012-12-11 15:09:03 -0800369 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800370};
371
Laura Abbottb93525f2012-04-12 09:57:19 -0700372static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800373 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800374 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800375 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800376 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700377 .fixed_position = FIXED_HIGH,
Laura Abbott5249a052012-12-11 15:09:03 -0800378 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800379};
380
Laura Abbottb93525f2012-04-12 09:57:19 -0700381static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800382 .adjacent_mem_id = INVALID_HEAP_ID,
383 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800384 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800385};
386
Laura Abbottb93525f2012-04-12 09:57:19 -0700387static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800388 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
389 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800390 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700391 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800392};
393#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800394
Laura Abbott354d40f2012-08-03 17:32:09 -0700395static u64 msm_dmamask = DMA_BIT_MASK(32);
396
397static struct platform_device ion_mm_heap_device = {
398 .name = "ion-mm-heap-device",
399 .id = -1,
400 .dev = {
401 .dma_mask = &msm_dmamask,
402 .coherent_dma_mask = DMA_BIT_MASK(32),
403 }
404};
405
Laura Abbott03e3cd72013-02-09 09:35:30 -0800406static struct platform_device ion_adsp_heap_device = {
407 .name = "ion-adsp-heap-device",
408 .id = -1,
409 .dev = {
410 .dma_mask = &msm_dmamask,
411 .coherent_dma_mask = DMA_BIT_MASK(32),
412 }
413};
414
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800415/**
416 * These heaps are listed in the order they will be allocated. Due to
417 * video hardware restrictions and content protection the FW heap has to
418 * be allocated adjacent (below) the MM heap and the MFC heap has to be
419 * allocated after the MM heap to ensure MFC heap is not more than 256MB
420 * away from the base address of the FW heap.
421 * However, the order of FW heap and MM heap doesn't matter since these
422 * two heaps are taken care of by separate code to ensure they are adjacent
423 * to each other.
424 * Don't swap the order unless you know what you are doing!
425 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700426struct ion_platform_heap msm8960_heaps[] = {
Laura Abbottd6183792011-08-19 13:42:24 -0700427 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800428 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700429 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700430 .name = ION_VMALLOC_HEAP_NAME,
431 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700432#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700433 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800434 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800435 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800436 .name = ION_MM_HEAP_NAME,
437 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700438 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700439 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbott354d40f2012-08-03 17:32:09 -0700440 .priv = &ion_mm_heap_device.dev,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700441 },
Laura Abbott8c017362011-09-22 20:59:12 -0700442 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800443 .id = ION_MM_FIRMWARE_HEAP_ID,
444 .type = ION_HEAP_TYPE_CARVEOUT,
445 .name = ION_MM_FIRMWARE_HEAP_NAME,
446 .size = MSM_ION_MM_FW_SIZE,
447 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700448 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800449 },
450 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800451 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800452 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800453 .name = ION_MFC_HEAP_NAME,
454 .size = MSM_ION_MFC_SIZE,
455 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700456 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800457 },
Olav Haugan32594552012-03-13 11:40:05 -0700458#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800459 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800460 .id = ION_SF_HEAP_ID,
461 .type = ION_HEAP_TYPE_CARVEOUT,
462 .name = ION_SF_HEAP_NAME,
463 .size = MSM_ION_SF_SIZE,
464 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700465 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800466 },
Olav Haugan32594552012-03-13 11:40:05 -0700467#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800468 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800469 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700470 .type = ION_HEAP_TYPE_IOMMU,
471 .name = ION_IOMMU_HEAP_NAME,
472 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800473 {
474 .id = ION_QSECOM_HEAP_ID,
475 .type = ION_HEAP_TYPE_CARVEOUT,
476 .name = ION_QSECOM_HEAP_NAME,
477 .size = MSM_ION_QSECOM_SIZE,
478 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700479 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800480 },
Olav Haugan7355db02012-01-13 16:59:13 -0800481 {
482 .id = ION_AUDIO_HEAP_ID,
483 .type = ION_HEAP_TYPE_CARVEOUT,
484 .name = ION_AUDIO_HEAP_NAME,
485 .size = MSM_ION_AUDIO_SIZE,
486 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700487 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800488 },
Laura Abbott03e3cd72013-02-09 09:35:30 -0800489 {
490 .id = ION_ADSP_HEAP_ID,
491 .type = ION_HEAP_TYPE_DMA,
492 .name = ION_ADSP_HEAP_NAME,
493 .size = MSM_ION_ADSP_SIZE,
494 .memory_type = ION_EBI_TYPE,
495 .extra_data = (void *) &co_msm8960_ion_pdata,
496 .priv = &ion_adsp_heap_device.dev,
497 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700498#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700499};
500
501static struct ion_platform_data msm8960_ion_pdata = {
502 .nr = MSM_ION_HEAP_NUM,
503 .heaps = msm8960_heaps,
Laura Abbottd6183792011-08-19 13:42:24 -0700504};
505
Laura Abbottb93525f2012-04-12 09:57:19 -0700506static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700507 .name = "ion-msm",
508 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700509 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700510};
511#endif
512
Laura Abbottb93525f2012-04-12 09:57:19 -0700513struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800514 .name = "fmem",
515 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700516 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800517};
518
Olav Haugan65f4bd82011-12-13 11:50:08 -0800519static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700520{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800521 unsigned int i;
522
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800523 if (!pmem_param_set) {
524 if (machine_is_msm8960_liquid())
525 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
526
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700527 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800528 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
529
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700530 if (machine_is_msm8960_liquid() ||
531 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700532 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
533 if (msm8960_ion_pdata.heaps[i].id ==
534 ION_SF_HEAP_ID) {
535 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800536 msm_ion_sf_size;
537 pr_debug("msm_ion_sf_size 0x%x\n",
538 msm_ion_sf_size);
539 break;
540 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800541 }
542 }
543 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800544}
545
546static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
547 unsigned long size)
548{
549 msm8960_reserve_table[mem_type].size += size;
550}
551
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700552static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
553{
554#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
555 int ret;
556
557 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
558 panic("fixed area size is larger than %dM\n",
559 MAX_FIXED_AREA_SIZE >> 20);
560
561 reserve_info->fixed_area_size = fixed_area_size;
562 reserve_info->fixed_area_start = MSM8960_FW_START;
563
564 ret = memblock_remove(reserve_info->fixed_area_start,
565 reserve_info->fixed_area_size);
566 BUG_ON(ret);
567#endif
568}
569
Olav Haugan65f4bd82011-12-13 11:50:08 -0800570/**
571 * Reserve memory for ION and calculate amount of reusable memory for fmem.
572 * We only reserve memory for heaps that are not reusable. However, we only
573 * support one reusable heap at the moment so we ignore the reusable flag for
574 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800575 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
576 * at a higher address than FW in addition to not more than 256MB away from the
577 * base address of the firmware. This means that if MM is reusable the other
578 * two heaps must be allocated in the same region as FW. This is handled by the
579 * mem_is_fmem flag in the platform data. In addition the MM heap must be
580 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800581 */
582static void __init reserve_ion_memory(void)
583{
584#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
585 unsigned int i;
Laura Abbott354d40f2012-08-03 17:32:09 -0700586 int ret;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700587 unsigned int fixed_size = 0;
588 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
589 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbott354d40f2012-08-03 17:32:09 -0700590 unsigned long cma_alignment;
591 unsigned int low_use_cma = 0;
592 unsigned int middle_use_cma = 0;
593 unsigned int high_use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800594
595 adjust_mem_for_liquid();
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700596 fixed_low_size = 0;
597 fixed_middle_size = 0;
598 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800599
Laura Abbott354d40f2012-08-03 17:32:09 -0700600 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
601
Laura Abbottb93525f2012-04-12 09:57:19 -0700602 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
Olav Haugan8726caf2012-05-10 15:11:35 -0700603 struct ion_platform_heap *heap =
Laura Abbottb93525f2012-04-12 09:57:19 -0700604 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan8726caf2012-05-10 15:11:35 -0700605 int align = SZ_4K;
606 int iommu_map_all = 0;
607 int adjacent_mem_id = INVALID_HEAP_ID;
Laura Abbott354d40f2012-08-03 17:32:09 -0700608 int use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800609
610 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700611 int fixed_position = NOT_FIXED;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700612
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700613 switch ((int) heap->type) {
Olav Haugan65f4bd82011-12-13 11:50:08 -0800614 case ION_HEAP_TYPE_CP:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700615 fixed_position = ((struct ion_cp_heap_pdata *)
616 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700617 align = ((struct ion_cp_heap_pdata *)
618 heap->extra_data)->align;
619 iommu_map_all =
620 ((struct ion_cp_heap_pdata *)
621 heap->extra_data)->iommu_map_all;
Laura Abbott354d40f2012-08-03 17:32:09 -0700622 if (((struct ion_cp_heap_pdata *)
623 heap->extra_data)->is_cma) {
624 heap->size = ALIGN(heap->size,
625 cma_alignment);
626 use_cma = 1;
627 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800628 break;
Laura Abbott354d40f2012-08-03 17:32:09 -0700629 case ION_HEAP_TYPE_DMA:
630 use_cma = 1;
631 /* Purposely fall through here */
Olav Haugan65f4bd82011-12-13 11:50:08 -0800632 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700633 fixed_position = ((struct ion_co_heap_pdata *)
634 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700635 adjacent_mem_id = ((struct ion_co_heap_pdata *)
636 heap->extra_data)->adjacent_mem_id;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700637 break;
638 default:
639 break;
640 }
641
Olav Haugan8726caf2012-05-10 15:11:35 -0700642 if (iommu_map_all) {
643 if (heap->size & (SZ_64K-1)) {
644 heap->size = ALIGN(heap->size, SZ_64K);
645 pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
646 heap->name, heap->size);
647 }
648 }
649
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700650 if (fixed_position != NOT_FIXED)
651 fixed_size += heap->size;
652 else
653 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
654
Laura Abbott354d40f2012-08-03 17:32:09 -0700655 if (fixed_position == FIXED_LOW) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700656 fixed_low_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700657 low_use_cma = use_cma;
658 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700659 fixed_middle_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700660 middle_use_cma = use_cma;
661 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700662 fixed_high_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700663 high_use_cma = use_cma;
664 } else if (use_cma) {
665 /*
666 * Heaps that use CMA but are not part of the
667 * fixed set. Create wherever.
668 */
669 dma_declare_contiguous(
670 heap->priv,
671 heap->size,
672 0,
673 0xb0000000);
674 }
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700675 }
676 }
677
678 if (!fixed_size)
679 return;
680
Laura Abbott354d40f2012-08-03 17:32:09 -0700681 /*
682 * Given the setup for the fixed area, we can't round up all sizes.
683 * Some sizes must be set up exactly and aligned correctly. Incorrect
684 * alignments are considered a configuration issue
Larry Bassel4d4f4482012-04-04 11:26:09 -0700685 */
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700686
687 fixed_low_start = MSM8960_FIXED_AREA_START;
Laura Abbott354d40f2012-08-03 17:32:09 -0700688 if (low_use_cma) {
689 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
690 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
691 } else {
692 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
693 ret = memblock_remove(fixed_low_start,
694 fixed_low_size + HOLE_SIZE);
695 BUG_ON(ret);
696 }
697
Deepak Kotur35825522012-06-06 15:49:14 -0700698 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbott354d40f2012-08-03 17:32:09 -0700699 if (middle_use_cma) {
700 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
701 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
702 } else {
703 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
704 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
705 BUG_ON(ret);
706 }
707
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700708 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700709 if (high_use_cma) {
710 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
711 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
712 } else {
713 /* This is the end of the fixed area so it's okay to round up */
714 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
715 ret = memblock_remove(fixed_high_start, fixed_high_size);
716 BUG_ON(ret);
717 }
718
719
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700720
Laura Abbottb93525f2012-04-12 09:57:19 -0700721 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
722 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700723
724 if (heap->extra_data) {
725 int fixed_position = NOT_FIXED;
Steve Muckle75c34ca2012-06-12 14:27:40 -0700726 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700727
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700728 switch ((int) heap->type) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700729 case ION_HEAP_TYPE_CP:
Deepak Kotur35825522012-06-06 15:49:14 -0700730 pdata =
731 (struct ion_cp_heap_pdata *)heap->extra_data;
732 fixed_position = pdata->fixed_position;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700733 break;
734 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbott354d40f2012-08-03 17:32:09 -0700735 case ION_HEAP_TYPE_DMA:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700736 fixed_position = ((struct ion_co_heap_pdata *)
737 heap->extra_data)->fixed_position;
738 break;
739 default:
740 break;
741 }
742
743 switch (fixed_position) {
744 case FIXED_LOW:
745 heap->base = fixed_low_start;
746 break;
747 case FIXED_MIDDLE:
748 heap->base = fixed_middle_start;
Laura Abbott354d40f2012-08-03 17:32:09 -0700749 if (middle_use_cma) {
750 ret = dma_declare_contiguous(
751 &ion_mm_heap_device.dev,
752 heap->size,
753 fixed_middle_start,
754 0xa0000000);
755 WARN_ON(ret);
756 }
Deepak Kotur35825522012-06-06 15:49:14 -0700757 pdata->secure_base = fixed_middle_start
758 - HOLE_SIZE;
759 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700760 break;
761 case FIXED_HIGH:
762 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800763 break;
764 default:
765 break;
766 }
767 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800768 }
Laura Abbottd6183792011-08-19 13:42:24 -0700769#endif
770}
Huaibin Yanga5419422011-12-08 23:52:10 -0800771
Laura Abbott5249a052012-12-11 15:09:03 -0800772static void ion_adjust_secure_allocation(void)
773{
774 int i;
775
776 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
777 struct ion_platform_heap *heap =
778 &(msm8960_ion_pdata.heaps[i]);
779
780
781 if (heap->extra_data) {
782 switch ((int) heap->type) {
783 case ION_HEAP_TYPE_CP:
784 if (cpu_is_msm8960()) {
785 ((struct ion_cp_heap_pdata *)
786 heap->extra_data)->no_nonsecure_alloc =
787 0;
788 }
789
790 }
791 }
792 }
793}
794
Huaibin Yanga5419422011-12-08 23:52:10 -0800795static void __init reserve_mdp_memory(void)
796{
797 msm8960_mdp_writeback(msm8960_reserve_table);
798}
799
Stephen Boyd668d7652012-04-25 11:31:01 -0700800static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800801{
802#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbott306bcc22012-03-08 11:24:53 -0800803 unsigned int total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800804
Laura Abbott155ab6f2012-05-25 08:52:18 -0700805 total = msm8960_cache_dump_pdata.l1_size +
806 msm8960_cache_dump_pdata.l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800807 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800808#endif
809}
810
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700811static void __init msm8960_calculate_reserve_sizes(void)
812{
813 size_pmem_devices();
814 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700815 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800816 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800817 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800818 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700819}
820
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700821static struct reserve_info msm8960_reserve_info __initdata = {
822 .memtype_reserve_table = msm8960_reserve_table,
823 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700824 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825 .paddr_to_memtype = msm8960_paddr_to_memtype,
826};
827
Larry Basselb4126da2011-07-18 14:31:33 -0700828static int msm8960_memory_bank_size(void)
829{
830 return 1<<29;
831}
832
833static void __init locate_unstable_memory(void)
834{
835 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
836 unsigned long bank_size;
837 unsigned long low, high;
838
839 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700840 msm8960_reserve_info.bank_size = bank_size;
841
Larry Basselb4126da2011-07-18 14:31:33 -0700842 low = meminfo.bank[0].start;
843 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700844
845 /* Check if 32 bit overflow occured */
846 if (high < mb->start)
847 high = ~0UL;
848
Larry Bassel4d4f4482012-04-04 11:26:09 -0700849 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
850 panic("fixed area extends beyond end of memory\n");
851
Larry Basselb4126da2011-07-18 14:31:33 -0700852 low &= ~(bank_size - 1);
853
854 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700855 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800856
Larry Basselb8d61022012-02-24 10:49:45 -0800857#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800858 msm8960_reserve_info.low_unstable_address = mb->start -
859 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800860 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700861 pr_info("low unstable address %lx max size %lx bank size %lx\n",
862 msm8960_reserve_info.low_unstable_address,
863 msm8960_reserve_info.max_unstable_size,
864 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700865 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800866#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700867no_dmm:
868 msm8960_reserve_info.low_unstable_address = high;
869 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700870}
871
Larry Basselb830e182011-10-14 10:46:55 -0700872static void __init place_movable_zone(void)
873{
Larry Basselb8d61022012-02-24 10:49:45 -0800874#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700875 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
876 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
877 pr_info("movable zone start %lx size %lx\n",
878 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800879#endif
Larry Basselb830e182011-10-14 10:46:55 -0700880}
881
882static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700883{
884 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700885 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700886 place_movable_zone();
887}
888
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800889static char prim_panel_name[PANEL_NAME_MAX_LEN];
890static char ext_panel_name[PANEL_NAME_MAX_LEN];
891static int __init prim_display_setup(char *param)
892{
893 if (strnlen(param, PANEL_NAME_MAX_LEN))
894 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
895 return 0;
896}
897early_param("prim_display", prim_display_setup);
898
899static int __init ext_display_setup(char *param)
900{
901 if (strnlen(param, PANEL_NAME_MAX_LEN))
902 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
903 return 0;
904}
905early_param("ext_display", ext_display_setup);
906
Larry Basselb830e182011-10-14 10:46:55 -0700907static void __init msm8960_reserve(void)
908{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800909 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910 msm_reserve();
911}
912
Larry Bassela4414b12011-08-04 11:11:02 -0700913static int msm8960_change_memory_power(u64 start, u64 size,
914 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700915{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700916 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700917}
918
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700919static void __init msm8960_allocate_memory_regions(void)
920{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800921 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700922}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800923
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700924#ifdef CONFIG_WCD9310_CODEC
925
926#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
927
Patrick Lai3043fba2011-08-01 14:15:57 -0700928/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
929 * 4 micbiases are used to power various analog and digital
930 * microphones operating at 1800 mV. Technically, all micbiases
931 * can source from single cfilter since all microphones operate
932 * at the same voltage level. The arrangement below is to make
933 * sure all cfilters are exercised. LDO_H regulator ouput level
934 * does not need to be as high as 2.85V. It is choosen for
935 * microphone sensitivity purpose.
936 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530937static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700938 .slimbus_slave_device = {
939 .name = "tabla-slave",
940 .e_addr = {0, 0, 0x10, 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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700945 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700946 .micbias = {
947 .ldoh_v = TABLA_LDOH_2P85_V,
948 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700949 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700950 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700994};
995
996static struct slim_device msm_slim_tabla = {
997 .name = "tabla-slim",
998 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
999 .dev = {
1000 .platform_data = &tabla_platform_data,
1001 },
1002};
Santosh Mardi60e19d92011-10-28 01:15:14 +05301003
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301004static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +05301005 .slimbus_slave_device = {
1006 .name = "tabla-slave",
1007 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
1008 },
1009 .irq = MSM_GPIO_TO_INT(62),
1010 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301011 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +05301012 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1013 .micbias = {
1014 .ldoh_v = TABLA_LDOH_2P85_V,
1015 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -07001016 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +05301017 .cfilt3_mv = 1800,
1018 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1019 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1020 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1021 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301022 },
1023 .regulator = {
1024 {
1025 .name = "CDC_VDD_CP",
1026 .min_uV = 1800000,
1027 .max_uV = 1800000,
1028 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1029 },
1030 {
1031 .name = "CDC_VDDA_RX",
1032 .min_uV = 1800000,
1033 .max_uV = 1800000,
1034 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1035 },
1036 {
1037 .name = "CDC_VDDA_TX",
1038 .min_uV = 1800000,
1039 .max_uV = 1800000,
1040 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1041 },
1042 {
1043 .name = "VDDIO_CDC",
1044 .min_uV = 1800000,
1045 .max_uV = 1800000,
1046 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1047 },
1048 {
1049 .name = "VDDD_CDC_D",
1050 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001051 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301052 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1053 },
1054 {
1055 .name = "CDC_VDDA_A_1P2V",
1056 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001057 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301058 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1059 },
1060 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301061};
1062
1063static struct slim_device msm_slim_tabla20 = {
1064 .name = "tabla2x-slim",
1065 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1066 .dev = {
1067 .platform_data = &tabla20_platform_data,
1068 },
1069};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070#endif
1071
1072static struct slim_boardinfo msm_slim_devices[] = {
1073#ifdef CONFIG_WCD9310_CODEC
1074 {
1075 .bus_num = 1,
1076 .slim_slave = &msm_slim_tabla,
1077 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301078 {
1079 .bus_num = 1,
1080 .slim_slave = &msm_slim_tabla20,
1081 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001082#endif
1083 /* add more slimbus slaves as needed */
1084};
1085
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001086#define MSM_WCNSS_PHYS 0x03000000
1087#define MSM_WCNSS_SIZE 0x280000
1088
1089static struct resource resources_wcnss_wlan[] = {
1090 {
1091 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1092 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1093 .name = "wcnss_wlanrx_irq",
1094 .flags = IORESOURCE_IRQ,
1095 },
1096 {
1097 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1098 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1099 .name = "wcnss_wlantx_irq",
1100 .flags = IORESOURCE_IRQ,
1101 },
1102 {
1103 .start = MSM_WCNSS_PHYS,
1104 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1105 .name = "wcnss_mmio",
1106 .flags = IORESOURCE_MEM,
1107 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001108 {
1109 .start = 84,
1110 .end = 88,
1111 .name = "wcnss_gpios_5wire",
1112 .flags = IORESOURCE_IO,
1113 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001114};
1115
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001116static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1117 .has_48mhz_xo = 1,
1118};
1119
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001120static struct platform_device msm_device_wcnss_wlan = {
1121 .name = "wcnss_wlan",
1122 .id = 0,
1123 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1124 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001125 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001126};
1127
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001128#ifdef CONFIG_QSEECOM
1129/* qseecom bus scaling */
1130static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1131 {
1132 .src = MSM_BUS_MASTER_SPS,
1133 .dst = MSM_BUS_SLAVE_EBI_CH0,
1134 .ib = 0,
1135 .ab = 0,
1136 },
1137 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001138 .src = MSM_BUS_MASTER_SPS,
1139 .dst = MSM_BUS_SLAVE_SPS,
1140 .ib = 0,
1141 .ab = 0,
1142 },
1143 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001144 .src = MSM_BUS_MASTER_SPDM,
1145 .dst = MSM_BUS_SLAVE_SPDM,
1146 .ib = 0,
1147 .ab = 0,
1148 },
1149};
1150
1151static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1152 {
1153 .src = MSM_BUS_MASTER_SPS,
1154 .dst = MSM_BUS_SLAVE_EBI_CH0,
1155 .ib = (492 * 8) * 1000000UL,
1156 .ab = (492 * 8) * 100000UL,
1157 },
1158 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001159 .src = MSM_BUS_MASTER_SPS,
1160 .dst = MSM_BUS_SLAVE_SPS,
1161 .ib = (492 * 8) * 1000000UL,
1162 .ab = (492 * 8) * 100000UL,
1163 },
1164 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001165 .src = MSM_BUS_MASTER_SPDM,
1166 .dst = MSM_BUS_SLAVE_SPDM,
1167 .ib = 0,
1168 .ab = 0,
1169 },
1170};
1171
1172static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1173 {
1174 .src = MSM_BUS_MASTER_SPS,
1175 .dst = MSM_BUS_SLAVE_EBI_CH0,
1176 .ib = 0,
1177 .ab = 0,
1178 },
1179 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001180 .src = MSM_BUS_MASTER_SPS,
1181 .dst = MSM_BUS_SLAVE_SPS,
1182 .ib = 0,
1183 .ab = 0,
1184 },
1185 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001186 .src = MSM_BUS_MASTER_SPDM,
1187 .dst = MSM_BUS_SLAVE_SPDM,
1188 .ib = (64 * 8) * 1000000UL,
1189 .ab = (64 * 8) * 100000UL,
1190 },
1191};
1192
Ramesh Masavarapu4f091cb2012-10-03 10:18:06 -07001193static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1194 {
1195 .src = MSM_BUS_MASTER_SPS,
1196 .dst = MSM_BUS_SLAVE_EBI_CH0,
1197 .ib = (492 * 8) * 1000000UL,
1198 .ab = (492 * 8) * 100000UL,
1199 },
1200 {
1201 .src = MSM_BUS_MASTER_SPS,
1202 .dst = MSM_BUS_SLAVE_SPS,
1203 .ib = (492 * 8) * 1000000UL,
1204 .ab = (492 * 8) * 100000UL,
1205 },
1206 {
1207 .src = MSM_BUS_MASTER_SPDM,
1208 .dst = MSM_BUS_SLAVE_SPDM,
1209 .ib = (64 * 8) * 1000000UL,
1210 .ab = (64 * 8) * 100000UL,
1211 },
1212};
1213
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001214static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1215 {
1216 ARRAY_SIZE(qseecom_clks_init_vectors),
1217 qseecom_clks_init_vectors,
1218 },
1219 {
1220 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001221 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001222 },
1223 {
1224 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1225 qseecom_enable_sfpb_vectors,
1226 },
Ramesh Masavarapu4f091cb2012-10-03 10:18:06 -07001227 {
1228 ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1229 qseecom_enable_dfab_sfpb_vectors,
1230 },
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001231};
1232
1233static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1234 qseecom_hw_bus_scale_usecases,
1235 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1236 .name = "qsee",
1237};
1238
1239static struct platform_device qseecom_device = {
1240 .name = "qseecom",
1241 .id = 0,
1242 .dev = {
1243 .platform_data = &qseecom_bus_pdata,
1244 },
1245};
1246#endif
1247
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001248#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1249 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1250 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1251 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1252
1253#define QCE_SIZE 0x10000
1254#define QCE_0_BASE 0x18500000
1255
1256#define QCE_HW_KEY_SUPPORT 0
1257#define QCE_SHA_HMAC_SUPPORT 1
1258#define QCE_SHARE_CE_RESOURCE 1
1259#define QCE_CE_SHARED 0
1260
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001261/* Begin Bus scaling definitions */
1262static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1263 {
1264 .src = MSM_BUS_MASTER_ADM_PORT0,
1265 .dst = MSM_BUS_SLAVE_EBI_CH0,
1266 .ab = 0,
1267 .ib = 0,
1268 },
1269 {
1270 .src = MSM_BUS_MASTER_ADM_PORT1,
1271 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1272 .ab = 0,
1273 .ib = 0,
1274 },
1275};
1276
1277static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1278 {
1279 .src = MSM_BUS_MASTER_ADM_PORT0,
1280 .dst = MSM_BUS_SLAVE_EBI_CH0,
1281 .ab = 70000000UL,
1282 .ib = 70000000UL,
1283 },
1284 {
1285 .src = MSM_BUS_MASTER_ADM_PORT1,
1286 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1287 .ab = 2480000000UL,
1288 .ib = 2480000000UL,
1289 },
1290};
1291
1292static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1293 {
1294 ARRAY_SIZE(crypto_hw_init_vectors),
1295 crypto_hw_init_vectors,
1296 },
1297 {
1298 ARRAY_SIZE(crypto_hw_active_vectors),
1299 crypto_hw_active_vectors,
1300 },
1301};
1302
1303static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1304 crypto_hw_bus_scale_usecases,
1305 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1306 .name = "cryptohw",
1307};
1308/* End Bus Scaling Definitions*/
1309
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001310static struct resource qcrypto_resources[] = {
1311 [0] = {
1312 .start = QCE_0_BASE,
1313 .end = QCE_0_BASE + QCE_SIZE - 1,
1314 .flags = IORESOURCE_MEM,
1315 },
1316 [1] = {
1317 .name = "crypto_channels",
1318 .start = DMOV_CE_IN_CHAN,
1319 .end = DMOV_CE_OUT_CHAN,
1320 .flags = IORESOURCE_DMA,
1321 },
1322 [2] = {
1323 .name = "crypto_crci_in",
1324 .start = DMOV_CE_IN_CRCI,
1325 .end = DMOV_CE_IN_CRCI,
1326 .flags = IORESOURCE_DMA,
1327 },
1328 [3] = {
1329 .name = "crypto_crci_out",
1330 .start = DMOV_CE_OUT_CRCI,
1331 .end = DMOV_CE_OUT_CRCI,
1332 .flags = IORESOURCE_DMA,
1333 },
1334};
1335
1336static struct resource qcedev_resources[] = {
1337 [0] = {
1338 .start = QCE_0_BASE,
1339 .end = QCE_0_BASE + QCE_SIZE - 1,
1340 .flags = IORESOURCE_MEM,
1341 },
1342 [1] = {
1343 .name = "crypto_channels",
1344 .start = DMOV_CE_IN_CHAN,
1345 .end = DMOV_CE_OUT_CHAN,
1346 .flags = IORESOURCE_DMA,
1347 },
1348 [2] = {
1349 .name = "crypto_crci_in",
1350 .start = DMOV_CE_IN_CRCI,
1351 .end = DMOV_CE_IN_CRCI,
1352 .flags = IORESOURCE_DMA,
1353 },
1354 [3] = {
1355 .name = "crypto_crci_out",
1356 .start = DMOV_CE_OUT_CRCI,
1357 .end = DMOV_CE_OUT_CRCI,
1358 .flags = IORESOURCE_DMA,
1359 },
1360};
1361
1362#endif
1363
1364#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1365 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1366
1367static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1368 .ce_shared = QCE_CE_SHARED,
1369 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1370 .hw_key_support = QCE_HW_KEY_SUPPORT,
1371 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001372 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001373};
1374
1375static struct platform_device qcrypto_device = {
1376 .name = "qcrypto",
1377 .id = 0,
1378 .num_resources = ARRAY_SIZE(qcrypto_resources),
1379 .resource = qcrypto_resources,
1380 .dev = {
1381 .coherent_dma_mask = DMA_BIT_MASK(32),
1382 .platform_data = &qcrypto_ce_hw_suppport,
1383 },
1384};
1385#endif
1386
1387#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1388 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1389
1390static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1391 .ce_shared = QCE_CE_SHARED,
1392 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1393 .hw_key_support = QCE_HW_KEY_SUPPORT,
1394 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001395 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001396};
1397
1398static struct platform_device qcedev_device = {
1399 .name = "qce",
1400 .id = 0,
1401 .num_resources = ARRAY_SIZE(qcedev_resources),
1402 .resource = qcedev_resources,
1403 .dev = {
1404 .coherent_dma_mask = DMA_BIT_MASK(32),
1405 .platform_data = &qcedev_ce_hw_suppport,
1406 },
1407};
1408#endif
1409
Joel King0cbf5d82012-05-24 15:21:38 -07001410static struct mdm_platform_data sglte_platform_data = {
1411 .mdm_version = "4.0",
1412 .ramdump_delay_ms = 1000,
Joel King63ce8332012-06-01 09:59:26 -07001413 .soft_reset_inverted = 1,
Joel King0cbf5d82012-05-24 15:21:38 -07001414 .peripheral_platform_device = NULL,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001415 .ramdump_timeout_ms = 600000,
Ameya Thakura98bde52012-06-28 18:55:19 -07001416 .no_powerdown_after_ramdumps = 1,
Ameya Thakur43248fd2012-07-10 18:50:52 -07001417 .image_upgrade_supported = 1,
Joel Kingb8352a12011-11-15 18:46:24 -08001418};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001419
Joel Nider266a2642011-10-16 10:58:05 +02001420#define MSM_TSIF0_PHYS (0x18200000)
1421#define MSM_TSIF1_PHYS (0x18201000)
1422#define MSM_TSIF_SIZE (0x200)
1423#define MSM_TSPP_PHYS (0x18202000)
1424#define MSM_TSPP_SIZE (0x1000)
1425#define MSM_TSPP_BAM_PHYS (0x18204000)
1426#define MSM_TSPP_BAM_SIZE (0x2000)
1427
1428#define TSIF_0_CLK GPIO_CFG(75, 1, GPIO_CFG_INPUT, \
1429 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1430#define TSIF_0_EN GPIO_CFG(76, 1, GPIO_CFG_INPUT, \
1431 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1432#define TSIF_0_DATA GPIO_CFG(77, 1, GPIO_CFG_INPUT, \
1433 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1434#define TSIF_0_SYNC GPIO_CFG(82, 1, GPIO_CFG_INPUT, \
1435 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1436#define TSIF_1_CLK GPIO_CFG(79, 1, GPIO_CFG_INPUT, \
1437 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1438#define TSIF_1_EN GPIO_CFG(80, 1, GPIO_CFG_INPUT, \
1439 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1440#define TSIF_1_DATA GPIO_CFG(81, 1, GPIO_CFG_INPUT, \
1441 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1442#define TSIF_1_SYNC GPIO_CFG(78, 1, GPIO_CFG_INPUT, \
1443 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1444
1445static const struct msm_gpio tsif_gpios[] = {
1446 { .gpio_cfg = TSIF_0_CLK, .label = "tsif0_clk", },
1447 { .gpio_cfg = TSIF_0_EN, .label = "tsif0_en", },
1448 { .gpio_cfg = TSIF_0_DATA, .label = "tsif0_data", },
1449 { .gpio_cfg = TSIF_0_SYNC, .label = "tsif0_sync", },
1450 { .gpio_cfg = TSIF_1_CLK, .label = "tsif1_clk", },
1451 { .gpio_cfg = TSIF_1_EN, .label = "tsif1_en", },
1452 { .gpio_cfg = TSIF_1_DATA, .label = "tsif1_data", },
1453 { .gpio_cfg = TSIF_1_SYNC, .label = "tsif1_sync", },
1454};
1455
1456static struct resource tspp_resources[] = {
1457 [0] = {
Liron Kuch8fa85b02013-01-01 18:29:47 +02001458 .name = "TSIF_TSPP_IRQ",
Joel Nider266a2642011-10-16 10:58:05 +02001459 .flags = IORESOURCE_IRQ,
1460 .start = TSIF_TSPP_IRQ,
Liron Kuch8fa85b02013-01-01 18:29:47 +02001461 .end = TSIF_TSPP_IRQ,
Joel Nider266a2642011-10-16 10:58:05 +02001462 },
1463 [1] = {
Liron Kuch8fa85b02013-01-01 18:29:47 +02001464 .name = "TSIF0_IRQ",
1465 .flags = IORESOURCE_IRQ,
1466 .start = TSIF1_IRQ,
1467 .end = TSIF1_IRQ,
1468 },
1469 [2] = {
1470 .name = "TSIF1_IRQ",
1471 .flags = IORESOURCE_IRQ,
1472 .start = TSIF2_IRQ,
1473 .end = TSIF2_IRQ,
1474 },
1475 [3] = {
1476 .name = "TSIF_BAM_IRQ",
1477 .flags = IORESOURCE_IRQ,
1478 .start = TSIF_BAM_IRQ,
1479 .end = TSIF_BAM_IRQ,
1480 },
1481 [4] = {
1482 .name = "MSM_TSIF0_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001483 .flags = IORESOURCE_MEM,
1484 .start = MSM_TSIF0_PHYS,
1485 .end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
1486 },
Liron Kuch8fa85b02013-01-01 18:29:47 +02001487 [5] = {
1488 .name = "MSM_TSIF1_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001489 .flags = IORESOURCE_MEM,
1490 .start = MSM_TSIF1_PHYS,
1491 .end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
1492 },
Liron Kuch8fa85b02013-01-01 18:29:47 +02001493 [6] = {
1494 .name = "MSM_TSPP_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001495 .flags = IORESOURCE_MEM,
1496 .start = MSM_TSPP_PHYS,
1497 .end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
1498 },
Liron Kuch8fa85b02013-01-01 18:29:47 +02001499 [7] = {
1500 .name = "MSM_TSPP_BAM_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001501 .flags = IORESOURCE_MEM,
1502 .start = MSM_TSPP_BAM_PHYS,
1503 .end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
1504 },
1505};
1506
1507static struct msm_tspp_platform_data tspp_platform_data = {
1508 .num_gpios = ARRAY_SIZE(tsif_gpios),
1509 .gpios = tsif_gpios,
1510 .tsif_pclk = "tsif_pclk",
1511 .tsif_ref_clk = "tsif_ref_clk",
1512};
1513
1514static struct platform_device msm_device_tspp = {
1515 .name = "msm_tspp",
1516 .id = 0,
1517 .num_resources = ARRAY_SIZE(tspp_resources),
1518 .resource = tspp_resources,
1519 .dev = {
1520 .platform_data = &tspp_platform_data
1521 },
1522};
1523
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001524#define MSM_SHARED_RAM_PHYS 0x80000000
1525
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001526static void __init msm8960_map_io(void)
1527{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001528 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001529 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001530
1531 if (socinfo_init() < 0)
1532 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001533}
1534
1535static void __init msm8960_init_irq(void)
1536{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001537 struct msm_mpm_device_data *data = NULL;
1538
1539#ifdef CONFIG_MSM_MPM
1540 data = &msm8960_mpm_dev_data;
1541#endif
1542
1543 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001544 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001545 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001546}
1547
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001548static void __init msm8960_init_buses(void)
1549{
1550#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001551 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001552 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1553 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
Gagan Macae154c4b2011-10-05 19:24:43 -06001554 msm_bus_apps_fabric.dev.platform_data =
1555 &msm_bus_8960_apps_fabric_pdata;
1556 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
Gagan Mac680bfc02012-07-19 19:11:00 -06001557 if (cpu_is_msm8960ab()) {
1558 msm_bus_8960_sg_mm_fabric_pdata.rpm_enabled = 1;
1559 msm_bus_mm_fabric.dev.platform_data =
1560 &msm_bus_8960_sg_mm_fabric_pdata;
1561 } else {
1562 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1563 msm_bus_mm_fabric.dev.platform_data =
1564 &msm_bus_8960_mm_fabric_pdata;
1565 }
Gagan Macae154c4b2011-10-05 19:24:43 -06001566 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1567 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001568#endif
1569}
1570
1571static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1572 .max_clock_speed = 15060000,
Kiran Gunda2b285652012-07-30 13:22:39 +05301573 .infinite_mode = 0xFFC0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001574};
1575
1576#ifdef CONFIG_USB_MSM_OTG_72K
1577static struct msm_otg_platform_data msm_otg_pdata;
1578#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301579static int wr_phy_init_seq[] = {
1580 0x44, 0x80, /* set VBUS valid threshold
1581 and disconnect valid threshold */
1582 0x38, 0x81, /* update DC voltage level */
1583 0x14, 0x82, /* set preemphasis and rise/fall time */
1584 0x13, 0x83, /* set source impedance adjusment */
1585 -1};
1586
1587static int liquid_v1_phy_init_seq[] = {
1588 0x44, 0x80,/* set VBUS valid threshold
1589 and disconnect valid threshold */
1590 0x3C, 0x81,/* update DC voltage level */
1591 0x18, 0x82,/* set preemphasis and rise/fall time */
1592 0x23, 0x83,/* set source impedance sdjusment */
1593 -1};
1594
Mayank Ranaa1f507b2012-08-14 10:57:00 +05301595static int sglte_phy_init_seq[] = {
1596 0x44, 0x80, /* set VBUS valid threshold
1597 and disconnect valid threshold */
1598 0x3A, 0x81, /* update DC voltage level */
1599 0x24, 0x82, /* set preemphasis and rise/fall time */
1600 0x13, 0x83, /* set source impedance adjusment */
1601 -1};
1602
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301603#ifdef CONFIG_MSM_BUS_SCALING
1604/* Bandwidth requests (zero) if no vote placed */
1605static struct msm_bus_vectors usb_init_vectors[] = {
1606 {
1607 .src = MSM_BUS_MASTER_SPS,
1608 .dst = MSM_BUS_SLAVE_EBI_CH0,
1609 .ab = 0,
1610 .ib = 0,
1611 },
1612};
1613
1614/* Bus bandwidth requests in Bytes/sec */
1615static struct msm_bus_vectors usb_max_vectors[] = {
1616 {
1617 .src = MSM_BUS_MASTER_SPS,
1618 .dst = MSM_BUS_SLAVE_EBI_CH0,
1619 .ab = 60000000, /* At least 480Mbps on bus. */
1620 .ib = 960000000, /* MAX bursts rate */
1621 },
1622};
1623
1624static struct msm_bus_paths usb_bus_scale_usecases[] = {
1625 {
1626 ARRAY_SIZE(usb_init_vectors),
1627 usb_init_vectors,
1628 },
1629 {
1630 ARRAY_SIZE(usb_max_vectors),
1631 usb_max_vectors,
1632 },
1633};
1634
1635static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1636 usb_bus_scale_usecases,
1637 ARRAY_SIZE(usb_bus_scale_usecases),
1638 .name = "usb",
1639};
1640#endif
1641
Jack Pham87f202f2012-08-06 00:24:22 -07001642#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
1643
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001644static struct msm_otg_platform_data msm_otg_pdata = {
1645 .mode = USB_OTG,
1646 .otg_control = OTG_PMIC_CONTROL,
1647 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001648 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301649 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301650#ifdef CONFIG_MSM_BUS_SCALING
1651 .bus_scale_table = &usb_bus_scale_pdata,
Jack Pham87f202f2012-08-06 00:24:22 -07001652 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301653#endif
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +05301654#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
1655 .mhl_dev_name = "sii8334",
1656#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001657};
1658#endif
1659
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301660#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301661#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301662static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1663 .strobe = 150,
1664 .data = 151,
1665};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301666
1667static struct smsc_hub_platform_data hsic_hub_pdata = {
1668 .hub_reset = HSIC_HUB_RESET_GPIO,
1669};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301670#else
1671static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301672static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301673#endif
1674
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301675static struct platform_device smsc_hub_device = {
1676 .name = "msm_smsc_hub",
1677 .id = -1,
1678 .dev = {
1679 .platform_data = &hsic_hub_pdata,
1680 },
1681};
1682
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001683#define PID_MAGIC_ID 0x71432909
1684#define SERIAL_NUM_MAGIC_ID 0x61945374
1685#define SERIAL_NUMBER_LENGTH 127
1686#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1687
1688struct magic_num_struct {
1689 uint32_t pid;
1690 uint32_t serial_num;
1691};
1692
1693struct dload_struct {
1694 uint32_t reserved1;
1695 uint32_t reserved2;
1696 uint32_t reserved3;
1697 uint16_t reserved4;
1698 uint16_t pid;
1699 char serial_number[SERIAL_NUMBER_LENGTH];
1700 uint16_t reserved5;
1701 struct magic_num_struct magic_struct;
1702};
1703
1704static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1705{
1706 struct dload_struct __iomem *dload = 0;
1707
1708 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1709 if (!dload) {
1710 pr_err("%s: cannot remap I/O memory region: %08x\n",
1711 __func__, DLOAD_USB_BASE_ADD);
1712 return -ENXIO;
1713 }
1714
1715 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1716 __func__, dload, pid, snum);
1717 /* update pid */
1718 dload->magic_struct.pid = PID_MAGIC_ID;
1719 dload->pid = pid;
1720
1721 /* update serial number */
1722 dload->magic_struct.serial_num = 0;
1723 if (!snum) {
1724 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1725 goto out;
1726 }
1727
1728 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001729 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001730out:
1731 iounmap(dload);
1732 return 0;
1733}
1734
1735static struct android_usb_platform_data android_usb_pdata = {
1736 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1737};
1738
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001739static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001740 .name = "android_usb",
1741 .id = -1,
1742 .dev = {
1743 .platform_data = &android_usb_pdata,
1744 },
1745};
1746
1747static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1748 0x03, 0x0f,
1749};
1750
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301751static uint8_t spm_retention_cmd_sequence[] __initdata = {
1752 0x00, 0x05, 0x03, 0x0D,
1753 0x0B, 0x00, 0x0f,
1754};
1755
Anji Jonnala786b39e2013-01-29 13:34:10 +05301756static uint8_t spm_retention_with_krait_v3_cmd_sequence[] __initdata = {
1757 0x42, 0x1B, 0x00,
1758 0x05, 0x03, 0x0D, 0x0B,
1759 0x00, 0x42, 0x1B,
1760 0x0f,
1761};
1762
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001763static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1764 0x00, 0x24, 0x54, 0x10,
1765 0x09, 0x03, 0x01,
1766 0x10, 0x54, 0x30, 0x0C,
1767 0x24, 0x30, 0x0f,
1768};
1769
1770static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1771 0x00, 0x24, 0x54, 0x10,
1772 0x09, 0x07, 0x01, 0x0B,
1773 0x10, 0x54, 0x30, 0x0C,
1774 0x24, 0x30, 0x0f,
1775};
1776
Anji Jonnala0f297a92013-01-19 11:22:25 +05301777/* 8960AB has a different command to assert apc_pdn */
1778static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
1779 0x00, 0x24, 0x84, 0x10,
1780 0x09, 0x03, 0x01,
1781 0x10, 0x84, 0x30, 0x0C,
1782 0x24, 0x30, 0x0f,
1783};
1784
1785static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
1786 0x00, 0x24, 0x84, 0x10,
1787 0x09, 0x07, 0x01, 0x0B,
1788 0x10, 0x84, 0x30, 0x0C,
1789 0x24, 0x30, 0x0f,
1790};
1791
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301792static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1793 [0] = {
1794 .mode = MSM_SPM_MODE_CLOCK_GATING,
1795 .notify_rpm = false,
1796 .cmd = spm_wfi_cmd_sequence,
1797 },
1798
1799 [1] = {
1800 .mode = MSM_SPM_MODE_POWER_RETENTION,
1801 .notify_rpm = false,
1802 .cmd = spm_retention_cmd_sequence,
1803 },
1804
1805 [2] = {
1806 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1807 .notify_rpm = false,
1808 .cmd = spm_power_collapse_without_rpm,
1809 },
1810 [3] = {
1811 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1812 .notify_rpm = true,
1813 .cmd = spm_power_collapse_with_rpm,
1814 },
1815};
1816
1817static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001818 [0] = {
1819 .mode = MSM_SPM_MODE_CLOCK_GATING,
1820 .notify_rpm = false,
1821 .cmd = spm_wfi_cmd_sequence,
1822 },
Anji Jonnala786b39e2013-01-29 13:34:10 +05301823
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001824 [1] = {
Anji Jonnala786b39e2013-01-29 13:34:10 +05301825 .mode = MSM_SPM_MODE_POWER_RETENTION,
1826 .notify_rpm = false,
1827 .cmd = spm_retention_cmd_sequence,
1828 },
1829
1830 [2] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001831 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1832 .notify_rpm = false,
1833 .cmd = spm_power_collapse_without_rpm,
1834 },
Anji Jonnala786b39e2013-01-29 13:34:10 +05301835
1836 [3] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001837 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1838 .notify_rpm = true,
1839 .cmd = spm_power_collapse_with_rpm,
1840 },
1841};
1842
1843static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1844 [0] = {
1845 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001846 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001847#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301848 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001849 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001850#endif
1851 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301852 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1853 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1854 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001855 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301856 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1857 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001858 },
1859 [1] = {
1860 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001861 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301863 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001864 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001865#endif
1866 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala786b39e2013-01-29 13:34:10 +05301867 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1868 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1869 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001870 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301871 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1872 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001873 },
1874};
1875
1876static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1877 0x00, 0x20, 0x03, 0x20,
1878 0x00, 0x0f,
1879};
1880
1881static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1882 0x00, 0x20, 0x34, 0x64,
1883 0x48, 0x07, 0x48, 0x20,
1884 0x50, 0x64, 0x04, 0x34,
1885 0x50, 0x0f,
1886};
1887static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1888 0x00, 0x10, 0x34, 0x64,
1889 0x48, 0x07, 0x48, 0x10,
1890 0x50, 0x64, 0x04, 0x34,
1891 0x50, 0x0F,
1892};
1893
1894static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1895 [0] = {
1896 .mode = MSM_SPM_L2_MODE_RETENTION,
1897 .notify_rpm = false,
1898 .cmd = l2_spm_wfi_cmd_sequence,
1899 },
1900 [1] = {
1901 .mode = MSM_SPM_L2_MODE_GDHS,
1902 .notify_rpm = true,
1903 .cmd = l2_spm_gdhs_cmd_sequence,
1904 },
1905 [2] = {
1906 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1907 .notify_rpm = true,
1908 .cmd = l2_spm_power_off_cmd_sequence,
1909 },
1910};
1911
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001912static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1913 [0] = {
1914 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001915 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001916 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001917 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1918 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1919 .modes = msm_spm_l2_seq_list,
1920 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1921 },
1922};
1923
Anirudh Ghayal15698162012-07-31 11:51:32 +05301924#define HAP_SHIFT_LVL_OE_GPIO 47
1925#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301926#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1927#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1928
1929static struct msm_xo_voter *xo_handle_d1;
1930
1931static int isa1200_power(int on)
1932{
1933 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301934 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301935
Anirudh Ghayal15698162012-07-31 11:51:32 +05301936 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1937 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1938
1939
1940 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301941
1942 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1943 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1944 if (rc < 0) {
1945 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1946 __func__, on ? "" : "de-", rc);
1947 goto err_xo_vote;
1948 }
1949
1950 return 0;
1951
1952err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301953 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301954 return rc;
1955}
1956
1957static int isa1200_dev_setup(bool enable)
1958{
1959 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301960 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301961
1962 struct pm_gpio hap_gpio_config = {
1963 .direction = PM_GPIO_DIR_OUT,
1964 .pull = PM_GPIO_PULL_NO,
1965 .out_strength = PM_GPIO_STRENGTH_HIGH,
1966 .function = PM_GPIO_FUNC_NORMAL,
1967 .inv_int_pol = 0,
1968 .vin_sel = 2,
1969 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1970 .output_value = 0,
1971 };
1972
Anirudh Ghayal15698162012-07-31 11:51:32 +05301973 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1974 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1975
Mohan Pallaka5e490392011-09-09 15:18:41 +05301976 if (enable == true) {
1977 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1978 if (rc) {
1979 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1980 __func__, PM_HAP_EN_GPIO, rc);
1981 return rc;
1982 }
1983
1984 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1985 if (rc) {
1986 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1987 __func__, PM_HAP_LEN_GPIO, rc);
1988 return rc;
1989 }
1990
Anirudh Ghayal15698162012-07-31 11:51:32 +05301991 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301992 if (rc) {
1993 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301994 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301995 return rc;
1996 }
1997
Anirudh Ghayal15698162012-07-31 11:51:32 +05301998 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301999 if (rc) {
2000 pr_err("%s: Unable to set direction\n", __func__);
2001 goto free_gpio;
2002 }
2003
2004 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
2005 if (IS_ERR(xo_handle_d1)) {
2006 rc = PTR_ERR(xo_handle_d1);
2007 pr_err("%s: failed to get the handle for D1(%d)\n",
2008 __func__, rc);
2009 goto gpio_set_dir;
2010 }
2011 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05302012 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302013
2014 msm_xo_put(xo_handle_d1);
2015 }
2016
2017 return 0;
2018
2019gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05302020 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302021free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05302022 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302023 return rc;
2024}
2025
2026static struct isa1200_regulator isa1200_reg_data[] = {
2027 {
2028 .name = "vcc_i2c",
2029 .min_uV = ISA_I2C_VTG_MIN_UV,
2030 .max_uV = ISA_I2C_VTG_MAX_UV,
2031 .load_uA = ISA_I2C_CURR_UA,
2032 },
2033};
2034
2035static struct isa1200_platform_data isa1200_1_pdata = {
2036 .name = "vibrator",
2037 .dev_setup = isa1200_dev_setup,
2038 .power_on = isa1200_power,
2039 .hap_en_gpio = PM_HAP_EN_GPIO,
2040 .hap_len_gpio = PM_HAP_LEN_GPIO,
2041 .max_timeout = 15000,
2042 .mode_ctrl = PWM_GEN_MODE,
2043 .pwm_fd = {
2044 .pwm_div = 256,
2045 },
2046 .is_erm = false,
2047 .smart_en = true,
2048 .ext_clk_en = true,
2049 .chip_en = 1,
2050 .regulator_info = isa1200_reg_data,
2051 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
2052};
2053
2054static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
2055 {
2056 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05302057 },
2058};
2059
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002060#define CYTTSP_TS_GPIO_IRQ 11
2061#define CYTTSP_TS_SLEEP_GPIO 50
2062#define CYTTSP_TS_RESOUT_N_GPIO 52
2063
2064/*virtual key support */
2065static ssize_t tma340_vkeys_show(struct kobject *kobj,
2066 struct kobj_attribute *attr, char *buf)
2067{
2068 return snprintf(buf, 200,
2069 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2070 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2071 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2072 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2073 "\n");
2074}
2075
2076static struct kobj_attribute tma340_vkeys_attr = {
2077 .attr = {
2078 .mode = S_IRUGO,
2079 },
2080 .show = &tma340_vkeys_show,
2081};
2082
2083static struct attribute *tma340_properties_attrs[] = {
2084 &tma340_vkeys_attr.attr,
2085 NULL
2086};
2087
2088static struct attribute_group tma340_properties_attr_group = {
2089 .attrs = tma340_properties_attrs,
2090};
2091
2092
2093static int cyttsp_platform_init(struct i2c_client *client)
2094{
2095 int rc = 0;
2096 static struct kobject *tma340_properties_kobj;
2097
2098 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2099 tma340_properties_kobj = kobject_create_and_add("board_properties",
2100 NULL);
2101 if (tma340_properties_kobj)
2102 rc = sysfs_create_group(tma340_properties_kobj,
2103 &tma340_properties_attr_group);
2104 if (!tma340_properties_kobj || rc)
2105 pr_err("%s: failed to create board_properties\n",
2106 __func__);
2107
2108 return 0;
2109}
2110
2111static struct cyttsp_regulator regulator_data[] = {
2112 {
2113 .name = "vdd",
2114 .min_uV = CY_TMA300_VTG_MIN_UV,
2115 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302116 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
2117 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002118 },
2119 /* TODO: Remove after runtime PM is enabled in I2C driver */
2120 {
2121 .name = "vcc_i2c",
2122 .min_uV = CY_I2C_VTG_MIN_UV,
2123 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302124 .hpm_load_uA = CY_I2C_CURR_UA,
2125 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002126 },
2127};
2128
2129static struct cyttsp_platform_data cyttsp_pdata = {
2130 .panel_maxx = 634,
2131 .panel_maxy = 1166,
2132 .disp_maxx = 616,
2133 .disp_maxy = 1023,
2134 .disp_minx = 0,
2135 .disp_miny = 16,
2136 .flags = 0x01,
2137 .gen = CY_GEN3, /* or */
2138 .use_st = CY_USE_ST,
2139 .use_mt = CY_USE_MT,
2140 .use_hndshk = CY_SEND_HNDSHK,
2141 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302142 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143 .use_gestures = CY_USE_GESTURES,
2144 .fw_fname = "cyttsp_8960_cdp.hex",
2145 /* activate up to 4 groups
2146 * and set active distance
2147 */
2148 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2149 CY_GEST_GRP3 | CY_GEST_GRP4 |
2150 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07002151 .act_intrvl = 10,
2152 .tch_tmout = 200,
2153 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002154 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2155 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2156 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2157 .regulator_info = regulator_data,
2158 .num_regulators = ARRAY_SIZE(regulator_data),
2159 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302160 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002161};
2162
2163static struct i2c_board_info cyttsp_info[] __initdata = {
2164 {
2165 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2166 .platform_data = &cyttsp_pdata,
2167#ifndef CY_USE_TIMER
2168 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2169#endif /* CY_USE_TIMER */
2170 },
2171};
2172
Jing Lindc4413c2012-01-16 15:22:52 -08002173/* configuration data for mxt1386 */
2174static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302175 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002176 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302177 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002178 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2182 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2184 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302185 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002186 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302187 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002188 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302189 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002190 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2191 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2192 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2193 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302194 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002195 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2196 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302197 /* T18 Object */
2198 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302199 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002200 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2201 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302202 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002203 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2204 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302205 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002206 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2207 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302208 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002209 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302210 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002211 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302212 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002213 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302214 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002215 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302216 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002217 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302218};
2219
Jing Lin33b007d2011-12-21 17:40:23 -08002220/* configuration data for mxt1386e using V1.0 firmware */
2221static const u8 mxt1386e_config_data_v1_0[] = {
2222 /* T6 Object */
2223 0, 0, 0, 0, 0, 0,
2224 /* T38 Object */
2225 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2229 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2231 0, 0, 0, 0,
2232 /* T7 Object */
2233 100, 16, 50,
2234 /* T8 Object */
2235 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2236 /* T9 Object */
2237 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2238 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2239 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2240 10, 5, 0, 0, 0,
2241 /* T18 Object */
2242 0, 0,
2243 /* T24 Object */
2244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2245 0, 0, 0, 0, 0, 0, 0, 0, 0,
2246 /* T25 Object */
2247 3, 0, 60, 115, 156, 99,
2248 /* T27 Object */
2249 0, 0, 0, 0, 0, 0, 0,
2250 /* T40 Object */
2251 0, 0, 0, 0, 0,
2252 /* T42 Object */
2253 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2254 /* T43 Object */
2255 0, 0, 0, 0, 0, 0, 0,
2256 /* T46 Object */
2257 64, 0, 20, 20, 0, 0, 0, 0, 0,
2258 /* T47 Object */
2259 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2260 /* T48 Object */
2261 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2262 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2263 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2264 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2266 0, 0, 0, 0,
2267 /* T56 Object */
2268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2271 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2272 2, 99, 33,
2273};
2274
2275/* configuration data for mxt1386e using V2.1 firmware */
2276static const u8 mxt1386e_config_data_v2_1[] = {
2277 /* T6 Object */
2278 0, 0, 0, 0, 0, 0,
2279 /* T38 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002280 12, 4, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2286 0, 0, 0, 0,
2287 /* T7 Object */
2288 100, 16, 50,
2289 /* T8 Object */
2290 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2291 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002292 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002293 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002294 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2295 10, 5, 0, 0, 0,
2296 /* T18 Object */
2297 0, 0,
2298 /* T24 Object */
2299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2300 0, 0, 0, 0, 0, 0, 0, 0, 0,
2301 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002302 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002303 /* T27 Object */
2304 0, 0, 0, 0, 0, 0, 0,
2305 /* T40 Object */
2306 0, 0, 0, 0, 0,
2307 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002308 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002309 /* T43 Object */
2310 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2311 16,
2312 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002313 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002314 /* T47 Object */
2315 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2316 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002317 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002318 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2319 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2320 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2322 0, 0, 0, 0,
2323 /* T56 Object */
2324 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2325 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2326 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2327 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2328 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2329 255,
2330};
2331
Jing Lineec88ca2012-02-08 11:18:30 -08002332/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2333static const u8 mxt1386e_config_data_3d[] = {
2334 /* T6 Object */
2335 0, 0, 0, 0, 0, 0,
2336 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002337 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002338 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2342 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2343 0, 0, 0, 0,
2344 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002345 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002346 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002347 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002348 /* T9 Object */
2349 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2350 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002351 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2352 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002353 /* T18 Object */
2354 0, 0,
2355 /* T24 Object */
2356 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2357 0, 0, 0, 0, 0, 0, 0, 0, 0,
2358 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002359 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002360 /* T27 Object */
2361 0, 0, 0, 0, 0, 0, 0,
2362 /* T40 Object */
2363 0, 0, 0, 0, 0,
2364 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002365 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002366 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002367 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2368 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002369 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002370 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002371 /* T47 Object */
2372 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2373 /* T48 Object */
2374 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002375 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2376 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2377 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002378 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2379 0, 0, 0, 0,
2380 /* T56 Object */
2381 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2382 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2383 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2384 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002385 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2386 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002387};
2388
Amy Maloche08266db2011-11-04 11:07:16 -07002389#define MXT_TS_GPIO_IRQ 11
2390#define MXT_TS_LDO_EN_GPIO 50
2391#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302392
2393static void mxt_init_hw_liquid(void)
2394{
2395 int rc;
2396
Mohan Pallaka50837382011-09-07 11:00:57 +05302397 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2398 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002399 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2400 __func__, MXT_TS_LDO_EN_GPIO);
2401 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302402 }
2403
2404 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2405 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002406 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2407 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302408 goto err_ldo_gpio_req;
2409 }
2410
Mohan Pallaka50837382011-09-07 11:00:57 +05302411 return;
2412
Mohan Pallaka50837382011-09-07 11:00:57 +05302413err_ldo_gpio_req:
2414 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302415}
2416
Jing Lineec88ca2012-02-08 11:18:30 -08002417static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002418 {
2419 .config = mxt1386_config_data,
2420 .config_length = ARRAY_SIZE(mxt1386_config_data),
2421 .family_id = 0xA0,
2422 .variant_id = 0x0,
2423 .version = 0x10,
2424 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002425 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002426 },
Jing Lin33b007d2011-12-21 17:40:23 -08002427 {
2428 .config = mxt1386e_config_data_v1_0,
2429 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2430 .family_id = 0xA0,
2431 .variant_id = 0x2,
2432 .version = 0x10,
2433 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002434 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002435 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002436 },
2437 {
2438 .config = mxt1386e_config_data_v2_1,
2439 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2440 .family_id = 0xA0,
2441 .variant_id = 0x7,
2442 .version = 0x21,
2443 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002444 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002445 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2446 },
2447 {
2448 /* The config data for V2.2.AA is the same as for V2.1.AA */
2449 .config = mxt1386e_config_data_v2_1,
2450 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2451 .family_id = 0xA0,
2452 .variant_id = 0x7,
2453 .version = 0x22,
2454 .build = 0xAA,
2455 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002456 },
Jing Lindc4413c2012-01-16 15:22:52 -08002457};
2458
Jing Lineec88ca2012-02-08 11:18:30 -08002459static struct mxt_platform_data mxt_platform_data_2d = {
2460 .config_array = mxt_config_array_2d,
2461 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002462 .panel_minx = 0,
2463 .panel_maxx = 1365,
2464 .panel_miny = 0,
2465 .panel_maxy = 767,
2466 .disp_minx = 0,
2467 .disp_maxx = 1365,
2468 .disp_miny = 0,
2469 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302470 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002471 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002472 .reset_gpio = MXT_TS_RESET_GPIO,
2473 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302474};
2475
Jing Lineec88ca2012-02-08 11:18:30 -08002476static struct mxt_config_info mxt_config_array_3d[] = {
2477 {
2478 .config = mxt1386e_config_data_3d,
2479 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2480 .family_id = 0xA0,
2481 .variant_id = 0x7,
2482 .version = 0x21,
2483 .build = 0xAA,
2484 },
2485};
2486
2487static struct mxt_platform_data mxt_platform_data_3d = {
2488 .config_array = mxt_config_array_3d,
2489 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002490 .panel_minx = 0,
2491 .panel_maxx = 1919,
2492 .panel_miny = 0,
2493 .panel_maxy = 1199,
2494 .disp_minx = 0,
2495 .disp_maxx = 1919,
2496 .disp_miny = 0,
2497 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002498 .irqflags = IRQF_TRIGGER_FALLING,
2499 .i2c_pull_up = true,
2500 .reset_gpio = MXT_TS_RESET_GPIO,
2501 .irq_gpio = MXT_TS_GPIO_IRQ,
2502};
2503
Mohan Pallaka50837382011-09-07 11:00:57 +05302504static struct i2c_board_info mxt_device_info[] __initdata = {
2505 {
2506 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302507 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2508 },
2509};
2510
Manoj Rao14648742012-03-30 19:42:12 -07002511static struct msm_mhl_platform_data mhl_platform_data = {
2512 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002513 .gpio_mhl_int = MHL_GPIO_INT,
2514 .gpio_mhl_reset = MHL_GPIO_RESET,
2515 .gpio_mhl_power = 0,
2516 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002517};
Manoj Rao14648742012-03-30 19:42:12 -07002518
Eugene Yasmand2316b82011-12-07 18:23:48 +02002519static struct i2c_board_info sii_device_info[] __initdata = {
2520 {
Manoj Rao14648742012-03-30 19:42:12 -07002521#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2522 /*
2523 * keeps SI 8334 as the default
2524 * MHL TX
2525 */
2526 I2C_BOARD_INFO("sii8334", 0x39),
2527 .platform_data = &mhl_platform_data,
2528#endif
2529#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002530 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002531 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002532#endif /* CONFIG_MSM_HDMI_MHL */
2533 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002534 },
2535};
2536
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002537static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2538 .clk_freq = 100000,
2539 .src_clk_rate = 24000000,
Kiran Gundab4696c72012-08-16 18:37:46 +05302540 .keep_ahb_clk_on = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002541};
2542
2543static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2544 .clk_freq = 100000,
2545 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002546};
2547
2548static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2549 .clk_freq = 100000,
2550 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002551};
2552
2553static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2554 .clk_freq = 100000,
2555 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002556};
2557
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002558static struct ks8851_pdata spi_eth_pdata = {
2559 .irq_gpio = KS8851_IRQ_GPIO,
2560 .rst_gpio = KS8851_RST_GPIO,
2561};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002562
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302563static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002564 {
2565 .modalias = "ks8851",
2566 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2567 .max_speed_hz = 19200000,
2568 .bus_num = 0,
2569 .chip_select = 0,
2570 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002571 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002572 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302573};
2574static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002575 {
2576 .modalias = "dsi_novatek_3d_panel_spi",
2577 .max_speed_hz = 10800000,
2578 .bus_num = 0,
2579 .chip_select = 1,
2580 .mode = SPI_MODE_0,
2581 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002582};
2583
2584static struct platform_device msm_device_saw_core0 = {
2585 .name = "saw-regulator",
2586 .id = 0,
2587 .dev = {
2588 .platform_data = &msm_saw_regulator_pdata_s5,
2589 },
2590};
2591
2592static struct platform_device msm_device_saw_core1 = {
2593 .name = "saw-regulator",
2594 .id = 1,
2595 .dev = {
2596 .platform_data = &msm_saw_regulator_pdata_s6,
2597 },
2598};
2599
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002600static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002601 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002602 .tsens_factor = 1000,
2603 .hw_type = MSM_8960,
2604 .tsens_num_sensor = 5,
2605};
2606
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002607static struct platform_device msm_tsens_device = {
2608 .name = "tsens8960-tm",
2609 .id = -1,
2610};
2611
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002612static struct msm_thermal_data msm_thermal_pdata = {
2613 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002614 .poll_ms = 250,
2615 .limit_temp_degC = 60,
2616 .temp_hysteresis_degC = 10,
2617 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002618};
2619
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002620#ifdef CONFIG_MSM_FAKE_BATTERY
2621static struct platform_device fish_battery_device = {
2622 .name = "fish_battery",
2623};
2624#endif
2625
David Collins26f05562011-06-20 09:56:28 -07002626static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002627 .name = GPIO_REGULATOR_DEV_NAME,
2628 .id = PM8921_MPP_PM_TO_SYS(7),
2629 .dev = {
2630 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2631 },
2632};
2633
David Collins26f05562011-06-20 09:56:28 -07002634static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002635 .name = GPIO_REGULATOR_DEV_NAME,
2636 .id = 91,
2637 .dev = {
2638 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2639 },
2640};
2641
David Collinsb10be1d2011-09-02 10:29:31 -07002642static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2643 .name = GPIO_REGULATOR_DEV_NAME,
2644 .id = PM8921_GPIO_PM_TO_SYS(17),
2645 .dev = {
2646 .platform_data =
2647 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2648 },
2649};
2650
David Collins35a78f52011-12-14 15:54:25 -08002651static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2652 .name = GPIO_REGULATOR_DEV_NAME,
2653 .id = PM8921_GPIO_PM_TO_SYS(42),
2654 .dev = {
2655 .platform_data =
2656 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2657 },
2658};
2659
David Collins26f05562011-06-20 09:56:28 -07002660static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2661 .name = "rpm-regulator",
2662 .id = -1,
2663 .dev = {
2664 .platform_data = &msm_rpm_regulator_pdata,
2665 },
2666};
Mayank Ranae009c922012-03-22 03:02:06 +05302667#ifdef CONFIG_SERIAL_MSM_HS
2668static int configure_uart_gpios(int on)
2669{
2670 int ret = 0, i;
2671 int uart_gpios[] = {93, 94, 95, 96};
2672
2673 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2674 if (on) {
2675 ret = gpio_request(uart_gpios[i], NULL);
2676 if (ret) {
2677 pr_err("%s: unable to request uart gpio[%d]\n",
2678 __func__, uart_gpios[i]);
2679 break;
2680 }
2681 } else {
2682 gpio_free(uart_gpios[i]);
2683 }
2684 }
2685
2686 if (ret && on && i)
2687 for (; i >= 0; i--)
2688 gpio_free(uart_gpios[i]);
2689 return ret;
2690}
2691
2692static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002693 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302694};
Mayank Rana1f02d952012-07-04 19:11:20 +05302695
2696static int configure_gsbi8_uart_gpios(int on)
2697{
2698 int ret = 0, i;
2699 int uart_gpios[] = {34, 35, 36, 37};
2700
2701 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2702 if (on) {
2703 ret = gpio_request(uart_gpios[i], NULL);
2704 if (ret) {
2705 pr_err("%s: unable to request uart gpio[%d]\n",
2706 __func__, uart_gpios[i]);
2707 break;
2708 }
2709 } else {
2710 gpio_free(uart_gpios[i]);
2711 }
2712 }
2713
2714 if (ret && on && i)
2715 for (; i >= 0; i--)
2716 gpio_free(uart_gpios[i]);
2717 return ret;
2718}
2719
2720static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
2721 .gpio_config = configure_gsbi8_uart_gpios,
2722};
Mayank Ranae009c922012-03-22 03:02:06 +05302723#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302724static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302725static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2726#endif
David Collins26f05562011-06-20 09:56:28 -07002727
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302728#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002729enum WLANBT_STATUS {
2730 WLANOFF_BTOFF = 1,
2731 WLANOFF_BTON,
2732 WLANON_BTOFF,
2733 WLANON_BTON
2734};
2735
2736static DEFINE_MUTEX(ath_wlanbt_mutex);
2737static int gpio_wlan_sys_rest_en = 26;
2738static int ath_wlanbt_status = WLANOFF_BTOFF;
2739
2740static int ath6kl_power_control(int on)
2741{
2742 int rc;
2743
2744 if (on) {
2745 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2746 if (rc) {
2747 pr_err("%s: unable to request gpio %d (%d)\n",
2748 __func__, gpio_wlan_sys_rest_en, rc);
2749 return rc;
2750 }
2751 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2752 msleep(200);
2753 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2754 msleep(100);
2755 } else {
2756 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2757 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2758 msleep(100);
2759 gpio_free(gpio_wlan_sys_rest_en);
2760 }
2761 return 0;
2762};
2763
2764static int ath6kl_wlan_power(int on)
2765{
2766 int ret = 0;
2767
2768 mutex_lock(&ath_wlanbt_mutex);
2769 if (on) {
2770 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2771 ret = ath6kl_power_control(1);
2772 ath_wlanbt_status = WLANON_BTOFF;
2773 } else if (ath_wlanbt_status == WLANOFF_BTON)
2774 ath_wlanbt_status = WLANON_BTON;
2775 } else {
2776 if (ath_wlanbt_status == WLANON_BTOFF) {
2777 ret = ath6kl_power_control(0);
2778 ath_wlanbt_status = WLANOFF_BTOFF;
2779 } else if (ath_wlanbt_status == WLANON_BTON)
2780 ath_wlanbt_status = WLANOFF_BTON;
2781 }
2782 mutex_unlock(&ath_wlanbt_mutex);
2783 pr_debug("%s on= %d, wlan_status= %d\n",
2784 __func__, on, ath_wlanbt_status);
2785 return ret;
2786};
2787
2788static struct wifi_platform_data ath6kl_wifi_control = {
2789 .set_power = ath6kl_wlan_power,
2790};
2791
2792static struct platform_device msm_wlan_power_device = {
2793 .name = "ath6kl_power",
2794 .dev = {
2795 .platform_data = &ath6kl_wifi_control,
2796 },
2797};
2798
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302799static struct resource bluesleep_resources[] = {
2800 {
2801 .name = "gpio_host_wake",
2802 .start = 27,
2803 .end = 27,
2804 .flags = IORESOURCE_IO,
2805 },
2806 {
2807 .name = "gpio_ext_wake",
2808 .start = 29,
2809 .end = 29,
2810 .flags = IORESOURCE_IO,
2811 },
2812 {
2813 .name = "host_wake",
2814 .start = MSM_GPIO_TO_INT(27),
2815 .end = MSM_GPIO_TO_INT(27),
2816 .flags = IORESOURCE_IRQ,
2817 },
2818};
2819
2820static struct platform_device msm_bluesleep_device = {
2821 .name = "bluesleep",
2822 .id = -1,
2823 .num_resources = ARRAY_SIZE(bluesleep_resources),
2824 .resource = bluesleep_resources,
2825};
2826
2827static struct platform_device msm_bt_power_device = {
2828 .name = "bt_power",
2829};
2830
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002831static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302832
2833static int bluetooth_power(int on)
2834{
2835 int rc;
2836
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002837 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302838 if (on) {
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002839 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2840 ath6kl_power_control(1);
2841 ath_wlanbt_status = WLANOFF_BTON;
2842 } else if (ath_wlanbt_status == WLANON_BTOFF)
2843 ath_wlanbt_status = WLANON_BTON;
2844
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302845 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2846 if (rc) {
2847 pr_err("%s: unable to request gpio %d (%d)\n",
2848 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002849 mutex_unlock(&ath_wlanbt_mutex);
2850 return rc;
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302851 }
2852 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002853 msleep(20);
2854 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302855 msleep(100);
2856 } else {
2857 gpio_set_value(gpio_bt_sys_rest_en, 0);
2858 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2859 msleep(100);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002860 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302861
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002862 if (ath_wlanbt_status == WLANOFF_BTON) {
2863 ath6kl_power_control(0);
2864 ath_wlanbt_status = WLANOFF_BTOFF;
2865 } else if (ath_wlanbt_status == WLANON_BTON)
2866 ath_wlanbt_status = WLANON_BTOFF;
2867 }
2868 mutex_unlock(&ath_wlanbt_mutex);
2869 pr_debug("%s on= %d, wlan_status= %d\n",
2870 __func__, on, ath_wlanbt_status);
2871 return 0;
2872};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302873
2874static void __init bt_power_init(void)
2875{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302876 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302877 return;
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002878};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302879#else
2880#define bt_power_init(x) do {} while (0)
2881#endif
2882
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002883static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002884 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002885 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302886 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887 &msm_device_saw_core0,
2888 &msm_device_saw_core1,
2889 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002890 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002891 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892 &msm8960_device_qup_spi_gsbi1,
2893 &msm8960_device_qup_i2c_gsbi3,
2894 &msm8960_device_qup_i2c_gsbi4,
2895 &msm8960_device_qup_i2c_gsbi10,
2896#ifndef CONFIG_MSM_DSPS
2897 &msm8960_device_qup_i2c_gsbi12,
2898#endif
2899 &msm_slim_ctrl,
2900 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302901#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2902 &msm_bluesleep_device,
2903 &msm_bt_power_device,
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002904 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302905#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002906#if defined(CONFIG_QSEECOM)
2907 &qseecom_device,
2908#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2910 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2911 &qcrypto_device,
2912#endif
2913
2914#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2915 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2916 &qcedev_device,
2917#endif
2918#ifdef CONFIG_MSM_ROTATOR
2919 &msm_rotator_device,
2920#endif
2921 &msm_device_sps,
2922#ifdef CONFIG_MSM_FAKE_BATTERY
2923 &fish_battery_device,
2924#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002925 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002926#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002927#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002928 &msm8960_android_pmem_device,
2929 &msm8960_android_pmem_adsp_device,
2930 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002932#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002933 &msm_device_bam_dmux,
2934 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002935#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2936#ifdef CONFIG_MSM_USE_TSIF1
2937 &msm_device_tsif[1],
2938#else
2939 &msm_device_tsif[0],
2940#endif
2941#endif
Joel Nider266a2642011-10-16 10:58:05 +02002942 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002943#ifdef CONFIG_HW_RANDOM_MSM
2944 &msm_device_rng,
2945#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002946#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002947 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002948#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002949 &msm8960_rpm_device,
2950 &msm8960_rpm_log_device,
2951 &msm8960_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302952 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002953 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002954 &coresight_tpiu_device,
2955 &coresight_etb_device,
2956 &coresight_funnel_device,
2957 &coresight_etm0_device,
2958 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002959 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002960 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002961 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002962 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002963 &msm8960_device_ebi1_ch0_erp,
2964 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002965 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002966 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002967 &msm_tsens_device,
Anji Jonnalae84292b2012-09-21 13:34:44 +05302968 &msm8960_pc_cntr,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969};
2970
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002971static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002972 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002973 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002974 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002975 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002976 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002977 &msm8960_device_otg,
2978 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979 &msm_device_hsusb_host,
2980 &android_usb_device,
2981 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002982 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002983 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002984 &msm_pcm_routing,
2985 &msm_cpudai0,
2986 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002987 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002988 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002989 &msm_cpudai_hdmi_rx,
2990 &msm_cpudai_bt_rx,
2991 &msm_cpudai_bt_tx,
2992 &msm_cpudai_fm_rx,
2993 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002994 &msm_cpudai_auxpcm_rx,
2995 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002996 &msm_cpu_fe,
2997 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002998#ifdef CONFIG_MSM_GEMINI
2999 &msm8960_gemini_device,
3000#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07003001#ifdef CONFIG_MSM_MERCURY
3002 &msm8960_mercury_device,
3003#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003004 &msm_voice,
3005 &msm_voip,
3006 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05303007 &msm_cpudai_afe_01_rx,
3008 &msm_cpudai_afe_01_tx,
3009 &msm_cpudai_afe_02_rx,
3010 &msm_cpudai_afe_02_tx,
3011 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05303012 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07003013 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07003014 &msm_cpudai_incall_record_rx,
3015 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003016 &msm_pcm_hostless,
3017 &msm_bus_apps_fabric,
3018 &msm_bus_sys_fabric,
3019 &msm_bus_mm_fabric,
3020 &msm_bus_sys_fpb,
3021 &msm_bus_cpss_fpb,
3022};
3023
3024static void __init msm8960_i2c_init(void)
3025{
3026 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3027 &msm8960_i2c_qup_gsbi4_pdata;
3028
3029 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3030 &msm8960_i2c_qup_gsbi3_pdata;
3031
3032 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3033 &msm8960_i2c_qup_gsbi10_pdata;
3034
3035 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3036 &msm8960_i2c_qup_gsbi12_pdata;
3037}
3038
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003039static void __init msm8960_gfx_init(void)
3040{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003041 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3042 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06003043 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003044
Carter Cooper3852cbb2012-08-20 22:11:42 -06003045 /* Fixup data that needs to change based on GPU ID */
Carter Cooperffe7ea12012-08-22 13:27:58 -06003046 if (cpu_is_msm8960ab()) {
3047 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
Suman Tatiraju20372242012-10-29 18:24:53 -07003048 /* 8960PRO nominal clock rate is 320Mhz */
3049 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Carter Cooper3852cbb2012-08-20 22:11:42 -06003050 } else {
3051 kgsl_3d0_pdata->iommu_count = 1;
3052 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3053 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
3054 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
3055 }
3056 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
3057 /* 8960v3 GPU registers returns 5 for patch release
3058 * but it should be 6, so dummy up the chipid here
3059 * based the platform type
3060 */
3061 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
3062 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003063 }
Carter Cooper6307eb992012-08-20 15:17:23 -06003064
3065 /* Register the 3D core */
3066 platform_device_register(&msm_kgsl_3d0);
3067
3068 /* Register the 2D cores if we are not 8960PRO */
3069 if (!cpu_is_msm8960ab()) {
3070 platform_device_register(&msm_kgsl_2d0);
3071 platform_device_register(&msm_kgsl_2d1);
3072 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003073}
3074
Subhash Jadavani933e6a62011-12-26 18:05:04 +05303075static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003076 {
3077 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3078 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3079 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003080 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003081 },
3082
3083 {
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303084 MSM_PM_SLEEP_MODE_RETENTION,
3085 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3086 true,
3087 415, 715, 340827, 475,
3088 },
3089
3090 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003091 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3092 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3093 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003094 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003095 },
3096
3097 {
3098 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3099 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3100 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003101 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102 },
3103
3104 {
3105 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003106 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
3107 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003108 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003109 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003110
3111 {
3112 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3113 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3114 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003115 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003116 },
3117
3118 {
3119 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3120 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3121 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003122 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003123 },
3124
3125 {
3126 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3127 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3128 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003129 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003130 },
3131
3132 {
3133 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3134 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3135 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003136 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003137 },
3138};
3139
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303140
Praveen Chidambaram78499012011-11-01 17:15:17 -06003141static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
3142 .levels = &msm_rpmrs_levels[0],
3143 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
3144 .vdd_mem_levels = {
3145 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3146 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3147 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3148 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3149 },
3150 .vdd_dig_levels = {
3151 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3152 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3153 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3154 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3155 },
3156 .vdd_mask = 0x7FFFFF,
3157 .rpmrs_target_id = {
3158 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3159 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3160 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3161 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3162 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3163 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3164 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3165 },
3166};
3167
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003168static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3169 .mode = MSM_PM_BOOT_CONFIG_TZ,
3170};
3171
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003172#ifdef CONFIG_I2C
3173#define I2C_SURF 1
3174#define I2C_FFA (1 << 1)
3175#define I2C_RUMI (1 << 2)
3176#define I2C_SIM (1 << 3)
3177#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003178#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003179
3180struct i2c_registry {
3181 u8 machs;
3182 int bus;
3183 struct i2c_board_info *info;
3184 int len;
3185};
3186
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003187/* Sensors DSPS platform data */
3188#ifdef CONFIG_MSM_DSPS
3189#define DSPS_PIL_GENERIC_NAME "dsps"
3190#endif /* CONFIG_MSM_DSPS */
3191
3192static void __init msm8960_init_dsps(void)
3193{
3194#ifdef CONFIG_MSM_DSPS
3195 struct msm_dsps_platform_data *pdata =
3196 msm_dsps_device.dev.platform_data;
3197 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3198 pdata->gpios = NULL;
3199 pdata->gpios_num = 0;
3200
3201 platform_device_register(&msm_dsps_device);
3202#endif /* CONFIG_MSM_DSPS */
3203}
3204
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003205static int hsic_peripheral_status = 1;
3206static DEFINE_MUTEX(hsic_status_lock);
3207
3208void peripheral_connect()
3209{
3210 mutex_lock(&hsic_status_lock);
3211 if (hsic_peripheral_status)
3212 goto out;
3213 platform_device_add(&msm_device_hsic_host);
3214 hsic_peripheral_status = 1;
3215out:
3216 mutex_unlock(&hsic_status_lock);
3217}
3218EXPORT_SYMBOL(peripheral_connect);
3219
3220void peripheral_disconnect()
3221{
3222 mutex_lock(&hsic_status_lock);
3223 if (!hsic_peripheral_status)
3224 goto out;
3225 platform_device_del(&msm_device_hsic_host);
3226 hsic_peripheral_status = 0;
3227out:
3228 mutex_unlock(&hsic_status_lock);
3229}
3230EXPORT_SYMBOL(peripheral_disconnect);
3231
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303232static void __init msm8960_init_smsc_hub(void)
3233{
3234 uint32_t version = socinfo_get_version();
3235
3236 if (SOCINFO_VERSION_MAJOR(version) == 1)
3237 return;
3238
3239 if (machine_is_msm8960_liquid())
3240 platform_device_register(&smsc_hub_device);
3241}
3242
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003243static void __init msm8960_init_hsic(void)
3244{
3245#ifdef CONFIG_USB_EHCI_MSM_HSIC
3246 uint32_t version = socinfo_get_version();
3247
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003248 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003249 return;
3250
Joel King0cbf5d82012-05-24 15:21:38 -07003251 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003252 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003253#endif
3254}
3255
Amir Samuelov5137e392011-09-21 17:31:25 +03003256#ifdef CONFIG_ISL9519_CHARGER
3257static struct isl_platform_data isl_data __initdata = {
3258 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3259 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3260 .max_system_voltage = 4200,
3261 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003262 .chgcurrent = 1900,
3263 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003264 .input_current = 2048,
3265};
3266
3267static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3268 {
3269 I2C_BOARD_INFO("isl9519q", 0x9),
3270 .irq = 0, /* Not required when notify-by-pmic */
3271 .platform_data = &isl_data,
3272 },
3273};
3274#endif /* CONFIG_ISL9519_CHARGER */
3275
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003276#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003277static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3278 {
3279 I2C_BOARD_INFO("sx1508q", 0x20),
3280 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3281 },
3282};
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003283#endif
Amir Samuelov755616d2011-12-13 16:34:46 +02003284
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003285static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003286#ifdef CONFIG_ISL9519_CHARGER
3287 {
3288 I2C_LIQUID,
3289 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3290 isl_charger_i2c_info,
3291 ARRAY_SIZE(isl_charger_i2c_info),
3292 },
3293#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003294 {
3295 I2C_SURF | I2C_FFA | I2C_FLUID,
3296 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3297 cyttsp_info,
3298 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003299 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303300 {
3301 I2C_LIQUID,
3302 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3303 mxt_device_info,
3304 ARRAY_SIZE(mxt_device_info),
3305 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303306 {
Manoj Rao14648742012-03-30 19:42:12 -07003307 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303308 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003309 sii_device_info,
3310 ARRAY_SIZE(sii_device_info),
3311 },
3312 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303313 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003314 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303315 msm_isa1200_board_info,
3316 ARRAY_SIZE(msm_isa1200_board_info),
3317 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003318#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003319 {
3320 I2C_LIQUID,
3321 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3322 liquid_io_expander_i2c_info,
3323 ARRAY_SIZE(liquid_io_expander_i2c_info),
3324 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003325#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003326};
3327#endif /* CONFIG_I2C */
3328
3329static void __init register_i2c_devices(void)
3330{
3331#ifdef CONFIG_I2C
3332 u8 mach_mask = 0;
3333 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003334#ifdef CONFIG_MSM_CAMERA
3335 struct i2c_registry msm8960_camera_i2c_devices = {
3336 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3337 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3338 msm8960_camera_board_info.board_info,
3339 msm8960_camera_board_info.num_i2c_board_info,
3340 };
3341#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003342
3343 /* Build the matching 'supported_machs' bitmask */
3344 if (machine_is_msm8960_cdp())
3345 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003346 else if (machine_is_msm8960_fluid())
3347 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003348 else if (machine_is_msm8960_liquid())
3349 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003350 else if (machine_is_msm8960_mtp())
3351 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003352 else
3353 pr_err("unmatched machine ID in register_i2c_devices\n");
3354
Jing Lineec88ca2012-02-08 11:18:30 -08003355 if (machine_is_msm8960_liquid()) {
3356 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3357 mxt_device_info[0].platform_data =
3358 &mxt_platform_data_3d;
3359 else
3360 mxt_device_info[0].platform_data =
3361 &mxt_platform_data_2d;
3362 }
3363
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364 /* Run the array and install devices as appropriate */
3365 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3366 if (msm8960_i2c_devices[i].machs & mach_mask)
3367 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3368 msm8960_i2c_devices[i].info,
3369 msm8960_i2c_devices[i].len);
3370 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003371
3372 if (!mhl_platform_data.gpio_mhl_power)
3373 pr_debug("mhl device configured for ext debug board\n");
3374
Kevin Chan09f4e662011-12-16 08:17:02 -08003375#ifdef CONFIG_MSM_CAMERA
3376 if (msm8960_camera_i2c_devices.machs & mach_mask)
3377 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3378 msm8960_camera_i2c_devices.info,
3379 msm8960_camera_i2c_devices.len);
3380#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003381#endif
3382}
3383
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003384static void __init msm8960_tsens_init(void)
3385{
3386 if (cpu_is_msm8960())
3387 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3388 return;
3389
3390 msm_tsens_early_init(&msm_tsens_pdata);
3391}
3392
Anji Jonnala0f297a92013-01-19 11:22:25 +05303393static void __init msm8960ab_update_krait_spm(void)
3394 {
3395 int i;
3396
Anji Jonnala0f297a92013-01-19 11:22:25 +05303397
3398 /* Update the SPM sequences for SPC and PC */
3399 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3400 int j;
3401 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3402 for (j = 0; j < pdata->num_modes; j++) {
3403 if (pdata->modes[j].cmd ==
3404 spm_power_collapse_without_rpm)
3405 pdata->modes[j].cmd =
3406 spm_power_collapse_without_rpm_krait_v3;
3407 else if (pdata->modes[j].cmd ==
3408 spm_power_collapse_with_rpm)
3409 pdata->modes[j].cmd =
3410 spm_power_collapse_with_rpm_krait_v3;
3411 }
3412 }
3413}
3414
Anji Jonnala786b39e2013-01-29 13:34:10 +05303415static void __init msm8960ab_update_retention_spm(void)
3416{
3417 int i;
3418
3419 /* Update the SPM sequences for krait retention on all cores */
3420 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3421 int j;
3422 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3423 for (j = 0; j < pdata->num_modes; j++) {
3424 if (pdata->modes[j].cmd ==
3425 spm_retention_cmd_sequence)
3426 pdata->modes[j].cmd =
3427 spm_retention_with_krait_v3_cmd_sequence;
3428 }
3429 }
3430}
3431
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003432static void __init msm8960_cdp_init(void)
3433{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003434 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3435 pr_err("meminfo_init() failed!\n");
3436
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003437 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003438 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003439 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003440 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3441 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003442
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003443 regulator_suppress_info_printing();
3444 if (msm_xo_init())
3445 pr_err("Failed to initialize XO votes\n");
David Collins4c93ce92012-09-04 15:44:19 -07003446 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003447 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003448 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303449 if (machine_is_msm8960_liquid())
3450 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003451 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303452 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3453 machine_is_msm8960_cdp()) {
Mayank Ranaa1f507b2012-08-14 10:57:00 +05303454 /* Due to availability of USB Switch in SGLTE Platform
3455 * it requires different HSUSB PHY settings compare to
3456 * 8960 MTP/CDP platform.
3457 */
3458 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3459 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3460 else
3461 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303462 } else if (machine_is_msm8960_liquid()) {
3463 msm_otg_pdata.phy_init_seq =
3464 liquid_v1_phy_init_seq;
3465 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003466 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303467 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303468 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303469 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3470 machine_is_msm8960_liquid())
3471 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003472 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003473 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3474 &msm8960_qup_spi_gsbi1_pdata;
3475 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303476 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3477 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003478
3479 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303480 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jain4ffd8122012-12-03 15:09:39 +05303481 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3482 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303483 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003484 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003485 msm8960_gfx_init();
Anji Jonnala0f297a92013-01-19 11:22:25 +05303486 if (cpu_is_msm8960ab())
3487 msm8960ab_update_krait_spm();
Anji Jonnala786b39e2013-01-29 13:34:10 +05303488 if (cpu_is_krait_v3()) {
3489 msm_pm_set_tz_retention_flag(0);
3490 msm8960ab_update_retention_spm();
3491 } else {
3492 msm_pm_set_tz_retention_flag(1);
3493 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003494 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3495 msm_spm_l2_init(msm_spm_l2_data);
3496 msm8960_init_buses();
Stephen Boyd6716bd92012-10-25 11:46:04 -07003497 if (cpu_is_msm8960ab()) {
3498 platform_add_devices(msm8960ab_footswitch,
3499 msm8960ab_num_footswitch);
3500 } else {
3501 platform_add_devices(msm8960_footswitch,
3502 msm8960_num_footswitch);
3503 }
David Collinsb10be1d2011-09-02 10:29:31 -07003504 if (machine_is_msm8960_liquid())
3505 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003506 if (machine_is_msm8960_cdp())
3507 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003508
3509 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3510 platform_device_register(&msm8960_device_uart_gsbi8);
3511 else
3512 platform_device_register(&msm8960_device_uart_gsbi5);
3513
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003514 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003515 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3516 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003517 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303518 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003519 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003520
Mayank Rana1f02d952012-07-04 19:11:20 +05303521 /* For 8960 Standalone External Bluetooth Interface */
3522 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3523 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3524 platform_device_register(&msm_device_uart_dm8);
3525 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003526 if (cpu_is_msm8960ab())
3527 platform_device_register(&msm8960ab_device_acpuclk);
3528 else
3529 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003530 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menond4837f62012-08-20 15:25:50 -07003531 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003532
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003533 msm8960_pm8921_gpio_mpp_init();
Stephen Boyd0ea1b762012-09-13 12:41:31 -07003534 /* Don't add modem devices on APQ targets */
3535 if (socinfo_get_id() != 124) {
3536 platform_device_register(&msm_8960_q6_mss_fw);
3537 platform_device_register(&msm_8960_q6_mss_sw);
3538 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003539 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303540 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003541 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003542#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003543 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003544#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003545 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303546 if (machine_is_msm8960_liquid())
3547 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003548 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003549 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003550 slim_register_board_info(msm_slim_devices,
3551 ARRAY_SIZE(msm_slim_devices));
3552 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003553 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003554 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303555 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003556 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3557 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3558 platform_device_register(&mdm_sglte_device);
3559 }
Laura Abbott5249a052012-12-11 15:09:03 -08003560 ion_adjust_secure_allocation();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003561}
3562
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003563MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3564 .map_io = msm8960_map_io,
3565 .reserve = msm8960_reserve,
3566 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303567 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003568 .timer = &msm_timer,
3569 .init_machine = msm8960_cdp_init,
3570 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003571 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003572 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003573MACHINE_END
3574
3575MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3576 .map_io = msm8960_map_io,
3577 .reserve = msm8960_reserve,
3578 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303579 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003580 .timer = &msm_timer,
3581 .init_machine = msm8960_cdp_init,
3582 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003583 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003584 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003585MACHINE_END
3586
3587MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3588 .map_io = msm8960_map_io,
3589 .reserve = msm8960_reserve,
3590 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303591 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003592 .timer = &msm_timer,
3593 .init_machine = msm8960_cdp_init,
3594 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003595 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003596 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003597MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003598
3599MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3600 .map_io = msm8960_map_io,
3601 .reserve = msm8960_reserve,
3602 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303603 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003604 .timer = &msm_timer,
3605 .init_machine = msm8960_cdp_init,
3606 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003607 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003608 .restart = msm_restart,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003609MACHINE_END