blob: 4b4d653d23bded4528b77f719c26665b19a0b8c0 [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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001756static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1757 0x00, 0x24, 0x54, 0x10,
1758 0x09, 0x03, 0x01,
1759 0x10, 0x54, 0x30, 0x0C,
1760 0x24, 0x30, 0x0f,
1761};
1762
1763static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1764 0x00, 0x24, 0x54, 0x10,
1765 0x09, 0x07, 0x01, 0x0B,
1766 0x10, 0x54, 0x30, 0x0C,
1767 0x24, 0x30, 0x0f,
1768};
1769
Anji Jonnala0f297a92013-01-19 11:22:25 +05301770/* 8960AB has a different command to assert apc_pdn */
1771static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
1772 0x00, 0x24, 0x84, 0x10,
1773 0x09, 0x03, 0x01,
1774 0x10, 0x84, 0x30, 0x0C,
1775 0x24, 0x30, 0x0f,
1776};
1777
1778static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
1779 0x00, 0x24, 0x84, 0x10,
1780 0x09, 0x07, 0x01, 0x0B,
1781 0x10, 0x84, 0x30, 0x0C,
1782 0x24, 0x30, 0x0f,
1783};
1784
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301785static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1786 [0] = {
1787 .mode = MSM_SPM_MODE_CLOCK_GATING,
1788 .notify_rpm = false,
1789 .cmd = spm_wfi_cmd_sequence,
1790 },
1791
1792 [1] = {
1793 .mode = MSM_SPM_MODE_POWER_RETENTION,
1794 .notify_rpm = false,
1795 .cmd = spm_retention_cmd_sequence,
1796 },
1797
1798 [2] = {
1799 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1800 .notify_rpm = false,
1801 .cmd = spm_power_collapse_without_rpm,
1802 },
1803 [3] = {
1804 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1805 .notify_rpm = true,
1806 .cmd = spm_power_collapse_with_rpm,
1807 },
1808};
1809
1810static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001811 [0] = {
1812 .mode = MSM_SPM_MODE_CLOCK_GATING,
1813 .notify_rpm = false,
1814 .cmd = spm_wfi_cmd_sequence,
1815 },
1816 [1] = {
1817 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1818 .notify_rpm = false,
1819 .cmd = spm_power_collapse_without_rpm,
1820 },
1821 [2] = {
1822 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1823 .notify_rpm = true,
1824 .cmd = spm_power_collapse_with_rpm,
1825 },
1826};
1827
1828static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1829 [0] = {
1830 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001831 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001832#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301833 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001834 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001835#endif
1836 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301837 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1838 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1839 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001840 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301841 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1842 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001843 },
1844 [1] = {
1845 .reg_base_addr = MSM_SAW1_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,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001852 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001853 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1854 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1855 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301856 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1857 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001858 },
1859};
1860
1861static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1862 0x00, 0x20, 0x03, 0x20,
1863 0x00, 0x0f,
1864};
1865
1866static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1867 0x00, 0x20, 0x34, 0x64,
1868 0x48, 0x07, 0x48, 0x20,
1869 0x50, 0x64, 0x04, 0x34,
1870 0x50, 0x0f,
1871};
1872static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1873 0x00, 0x10, 0x34, 0x64,
1874 0x48, 0x07, 0x48, 0x10,
1875 0x50, 0x64, 0x04, 0x34,
1876 0x50, 0x0F,
1877};
1878
1879static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1880 [0] = {
1881 .mode = MSM_SPM_L2_MODE_RETENTION,
1882 .notify_rpm = false,
1883 .cmd = l2_spm_wfi_cmd_sequence,
1884 },
1885 [1] = {
1886 .mode = MSM_SPM_L2_MODE_GDHS,
1887 .notify_rpm = true,
1888 .cmd = l2_spm_gdhs_cmd_sequence,
1889 },
1890 [2] = {
1891 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1892 .notify_rpm = true,
1893 .cmd = l2_spm_power_off_cmd_sequence,
1894 },
1895};
1896
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001897static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1898 [0] = {
1899 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001901 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001902 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1903 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1904 .modes = msm_spm_l2_seq_list,
1905 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1906 },
1907};
1908
Anirudh Ghayal15698162012-07-31 11:51:32 +05301909#define HAP_SHIFT_LVL_OE_GPIO 47
1910#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301911#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1912#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1913
1914static struct msm_xo_voter *xo_handle_d1;
1915
1916static int isa1200_power(int on)
1917{
1918 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301919 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301920
Anirudh Ghayal15698162012-07-31 11:51:32 +05301921 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1922 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1923
1924
1925 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301926
1927 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1928 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1929 if (rc < 0) {
1930 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1931 __func__, on ? "" : "de-", rc);
1932 goto err_xo_vote;
1933 }
1934
1935 return 0;
1936
1937err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301938 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301939 return rc;
1940}
1941
1942static int isa1200_dev_setup(bool enable)
1943{
1944 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301945 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301946
1947 struct pm_gpio hap_gpio_config = {
1948 .direction = PM_GPIO_DIR_OUT,
1949 .pull = PM_GPIO_PULL_NO,
1950 .out_strength = PM_GPIO_STRENGTH_HIGH,
1951 .function = PM_GPIO_FUNC_NORMAL,
1952 .inv_int_pol = 0,
1953 .vin_sel = 2,
1954 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1955 .output_value = 0,
1956 };
1957
Anirudh Ghayal15698162012-07-31 11:51:32 +05301958 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1959 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1960
Mohan Pallaka5e490392011-09-09 15:18:41 +05301961 if (enable == true) {
1962 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1963 if (rc) {
1964 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1965 __func__, PM_HAP_EN_GPIO, rc);
1966 return rc;
1967 }
1968
1969 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1970 if (rc) {
1971 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1972 __func__, PM_HAP_LEN_GPIO, rc);
1973 return rc;
1974 }
1975
Anirudh Ghayal15698162012-07-31 11:51:32 +05301976 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301977 if (rc) {
1978 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301979 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301980 return rc;
1981 }
1982
Anirudh Ghayal15698162012-07-31 11:51:32 +05301983 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301984 if (rc) {
1985 pr_err("%s: Unable to set direction\n", __func__);
1986 goto free_gpio;
1987 }
1988
1989 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1990 if (IS_ERR(xo_handle_d1)) {
1991 rc = PTR_ERR(xo_handle_d1);
1992 pr_err("%s: failed to get the handle for D1(%d)\n",
1993 __func__, rc);
1994 goto gpio_set_dir;
1995 }
1996 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05301997 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301998
1999 msm_xo_put(xo_handle_d1);
2000 }
2001
2002 return 0;
2003
2004gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05302005 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302006free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05302007 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302008 return rc;
2009}
2010
2011static struct isa1200_regulator isa1200_reg_data[] = {
2012 {
2013 .name = "vcc_i2c",
2014 .min_uV = ISA_I2C_VTG_MIN_UV,
2015 .max_uV = ISA_I2C_VTG_MAX_UV,
2016 .load_uA = ISA_I2C_CURR_UA,
2017 },
2018};
2019
2020static struct isa1200_platform_data isa1200_1_pdata = {
2021 .name = "vibrator",
2022 .dev_setup = isa1200_dev_setup,
2023 .power_on = isa1200_power,
2024 .hap_en_gpio = PM_HAP_EN_GPIO,
2025 .hap_len_gpio = PM_HAP_LEN_GPIO,
2026 .max_timeout = 15000,
2027 .mode_ctrl = PWM_GEN_MODE,
2028 .pwm_fd = {
2029 .pwm_div = 256,
2030 },
2031 .is_erm = false,
2032 .smart_en = true,
2033 .ext_clk_en = true,
2034 .chip_en = 1,
2035 .regulator_info = isa1200_reg_data,
2036 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
2037};
2038
2039static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
2040 {
2041 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05302042 },
2043};
2044
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002045#define CYTTSP_TS_GPIO_IRQ 11
2046#define CYTTSP_TS_SLEEP_GPIO 50
2047#define CYTTSP_TS_RESOUT_N_GPIO 52
2048
2049/*virtual key support */
2050static ssize_t tma340_vkeys_show(struct kobject *kobj,
2051 struct kobj_attribute *attr, char *buf)
2052{
2053 return snprintf(buf, 200,
2054 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2055 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2056 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2057 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2058 "\n");
2059}
2060
2061static struct kobj_attribute tma340_vkeys_attr = {
2062 .attr = {
2063 .mode = S_IRUGO,
2064 },
2065 .show = &tma340_vkeys_show,
2066};
2067
2068static struct attribute *tma340_properties_attrs[] = {
2069 &tma340_vkeys_attr.attr,
2070 NULL
2071};
2072
2073static struct attribute_group tma340_properties_attr_group = {
2074 .attrs = tma340_properties_attrs,
2075};
2076
2077
2078static int cyttsp_platform_init(struct i2c_client *client)
2079{
2080 int rc = 0;
2081 static struct kobject *tma340_properties_kobj;
2082
2083 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2084 tma340_properties_kobj = kobject_create_and_add("board_properties",
2085 NULL);
2086 if (tma340_properties_kobj)
2087 rc = sysfs_create_group(tma340_properties_kobj,
2088 &tma340_properties_attr_group);
2089 if (!tma340_properties_kobj || rc)
2090 pr_err("%s: failed to create board_properties\n",
2091 __func__);
2092
2093 return 0;
2094}
2095
2096static struct cyttsp_regulator regulator_data[] = {
2097 {
2098 .name = "vdd",
2099 .min_uV = CY_TMA300_VTG_MIN_UV,
2100 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302101 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
2102 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002103 },
2104 /* TODO: Remove after runtime PM is enabled in I2C driver */
2105 {
2106 .name = "vcc_i2c",
2107 .min_uV = CY_I2C_VTG_MIN_UV,
2108 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302109 .hpm_load_uA = CY_I2C_CURR_UA,
2110 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002111 },
2112};
2113
2114static struct cyttsp_platform_data cyttsp_pdata = {
2115 .panel_maxx = 634,
2116 .panel_maxy = 1166,
2117 .disp_maxx = 616,
2118 .disp_maxy = 1023,
2119 .disp_minx = 0,
2120 .disp_miny = 16,
2121 .flags = 0x01,
2122 .gen = CY_GEN3, /* or */
2123 .use_st = CY_USE_ST,
2124 .use_mt = CY_USE_MT,
2125 .use_hndshk = CY_SEND_HNDSHK,
2126 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302127 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002128 .use_gestures = CY_USE_GESTURES,
2129 .fw_fname = "cyttsp_8960_cdp.hex",
2130 /* activate up to 4 groups
2131 * and set active distance
2132 */
2133 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2134 CY_GEST_GRP3 | CY_GEST_GRP4 |
2135 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07002136 .act_intrvl = 10,
2137 .tch_tmout = 200,
2138 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002139 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2140 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2141 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2142 .regulator_info = regulator_data,
2143 .num_regulators = ARRAY_SIZE(regulator_data),
2144 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302145 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002146};
2147
2148static struct i2c_board_info cyttsp_info[] __initdata = {
2149 {
2150 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2151 .platform_data = &cyttsp_pdata,
2152#ifndef CY_USE_TIMER
2153 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2154#endif /* CY_USE_TIMER */
2155 },
2156};
2157
Jing Lindc4413c2012-01-16 15:22:52 -08002158/* configuration data for mxt1386 */
2159static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302160 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002161 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302162 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002163 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2168 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2169 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302170 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002171 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302172 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002173 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302174 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002175 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2176 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2177 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2178 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302179 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2181 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302182 /* T18 Object */
2183 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302184 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002185 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2186 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302187 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2189 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302190 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002191 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2192 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302193 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002194 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302195 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002196 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302197 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002198 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302199 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002200 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302201 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002202 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302203};
2204
Jing Lin33b007d2011-12-21 17:40:23 -08002205/* configuration data for mxt1386e using V1.0 firmware */
2206static const u8 mxt1386e_config_data_v1_0[] = {
2207 /* T6 Object */
2208 0, 0, 0, 0, 0, 0,
2209 /* T38 Object */
2210 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2216 0, 0, 0, 0,
2217 /* T7 Object */
2218 100, 16, 50,
2219 /* T8 Object */
2220 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2221 /* T9 Object */
2222 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2223 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2224 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2225 10, 5, 0, 0, 0,
2226 /* T18 Object */
2227 0, 0,
2228 /* T24 Object */
2229 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2230 0, 0, 0, 0, 0, 0, 0, 0, 0,
2231 /* T25 Object */
2232 3, 0, 60, 115, 156, 99,
2233 /* T27 Object */
2234 0, 0, 0, 0, 0, 0, 0,
2235 /* T40 Object */
2236 0, 0, 0, 0, 0,
2237 /* T42 Object */
2238 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2239 /* T43 Object */
2240 0, 0, 0, 0, 0, 0, 0,
2241 /* T46 Object */
2242 64, 0, 20, 20, 0, 0, 0, 0, 0,
2243 /* T47 Object */
2244 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2245 /* T48 Object */
2246 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2247 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2248 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2249 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2251 0, 0, 0, 0,
2252 /* T56 Object */
2253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2257 2, 99, 33,
2258};
2259
2260/* configuration data for mxt1386e using V2.1 firmware */
2261static const u8 mxt1386e_config_data_v2_1[] = {
2262 /* T6 Object */
2263 0, 0, 0, 0, 0, 0,
2264 /* T38 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002265 12, 4, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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,
2272 /* T7 Object */
2273 100, 16, 50,
2274 /* T8 Object */
2275 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2276 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002277 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002278 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002279 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2280 10, 5, 0, 0, 0,
2281 /* T18 Object */
2282 0, 0,
2283 /* T24 Object */
2284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2285 0, 0, 0, 0, 0, 0, 0, 0, 0,
2286 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002287 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002288 /* T27 Object */
2289 0, 0, 0, 0, 0, 0, 0,
2290 /* T40 Object */
2291 0, 0, 0, 0, 0,
2292 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002293 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002294 /* T43 Object */
2295 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2296 16,
2297 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002298 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002299 /* T47 Object */
2300 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2301 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002302 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002303 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2304 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2305 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2306 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2307 0, 0, 0, 0,
2308 /* T56 Object */
2309 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2310 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2311 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2313 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2314 255,
2315};
2316
Jing Lineec88ca2012-02-08 11:18:30 -08002317/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2318static const u8 mxt1386e_config_data_3d[] = {
2319 /* T6 Object */
2320 0, 0, 0, 0, 0, 0,
2321 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002322 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002323 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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 0, 0, 0, 0,
2329 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002330 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002331 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002332 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002333 /* T9 Object */
2334 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2335 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002336 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2337 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002338 /* T18 Object */
2339 0, 0,
2340 /* T24 Object */
2341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2342 0, 0, 0, 0, 0, 0, 0, 0, 0,
2343 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002344 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002345 /* T27 Object */
2346 0, 0, 0, 0, 0, 0, 0,
2347 /* T40 Object */
2348 0, 0, 0, 0, 0,
2349 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002350 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002351 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002352 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2353 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002354 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002355 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002356 /* T47 Object */
2357 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2358 /* T48 Object */
2359 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002360 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2361 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2362 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2364 0, 0, 0, 0,
2365 /* T56 Object */
2366 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2367 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2368 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2369 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2371 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002372};
2373
Amy Maloche08266db2011-11-04 11:07:16 -07002374#define MXT_TS_GPIO_IRQ 11
2375#define MXT_TS_LDO_EN_GPIO 50
2376#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302377
2378static void mxt_init_hw_liquid(void)
2379{
2380 int rc;
2381
Mohan Pallaka50837382011-09-07 11:00:57 +05302382 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2383 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002384 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2385 __func__, MXT_TS_LDO_EN_GPIO);
2386 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302387 }
2388
2389 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2390 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002391 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2392 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302393 goto err_ldo_gpio_req;
2394 }
2395
Mohan Pallaka50837382011-09-07 11:00:57 +05302396 return;
2397
Mohan Pallaka50837382011-09-07 11:00:57 +05302398err_ldo_gpio_req:
2399 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302400}
2401
Jing Lineec88ca2012-02-08 11:18:30 -08002402static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002403 {
2404 .config = mxt1386_config_data,
2405 .config_length = ARRAY_SIZE(mxt1386_config_data),
2406 .family_id = 0xA0,
2407 .variant_id = 0x0,
2408 .version = 0x10,
2409 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002410 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002411 },
Jing Lin33b007d2011-12-21 17:40:23 -08002412 {
2413 .config = mxt1386e_config_data_v1_0,
2414 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2415 .family_id = 0xA0,
2416 .variant_id = 0x2,
2417 .version = 0x10,
2418 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002419 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002420 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002421 },
2422 {
2423 .config = mxt1386e_config_data_v2_1,
2424 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2425 .family_id = 0xA0,
2426 .variant_id = 0x7,
2427 .version = 0x21,
2428 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002429 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002430 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2431 },
2432 {
2433 /* The config data for V2.2.AA is the same as for V2.1.AA */
2434 .config = mxt1386e_config_data_v2_1,
2435 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2436 .family_id = 0xA0,
2437 .variant_id = 0x7,
2438 .version = 0x22,
2439 .build = 0xAA,
2440 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002441 },
Jing Lindc4413c2012-01-16 15:22:52 -08002442};
2443
Jing Lineec88ca2012-02-08 11:18:30 -08002444static struct mxt_platform_data mxt_platform_data_2d = {
2445 .config_array = mxt_config_array_2d,
2446 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002447 .panel_minx = 0,
2448 .panel_maxx = 1365,
2449 .panel_miny = 0,
2450 .panel_maxy = 767,
2451 .disp_minx = 0,
2452 .disp_maxx = 1365,
2453 .disp_miny = 0,
2454 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302455 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002456 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002457 .reset_gpio = MXT_TS_RESET_GPIO,
2458 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302459};
2460
Jing Lineec88ca2012-02-08 11:18:30 -08002461static struct mxt_config_info mxt_config_array_3d[] = {
2462 {
2463 .config = mxt1386e_config_data_3d,
2464 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2465 .family_id = 0xA0,
2466 .variant_id = 0x7,
2467 .version = 0x21,
2468 .build = 0xAA,
2469 },
2470};
2471
2472static struct mxt_platform_data mxt_platform_data_3d = {
2473 .config_array = mxt_config_array_3d,
2474 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002475 .panel_minx = 0,
2476 .panel_maxx = 1919,
2477 .panel_miny = 0,
2478 .panel_maxy = 1199,
2479 .disp_minx = 0,
2480 .disp_maxx = 1919,
2481 .disp_miny = 0,
2482 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002483 .irqflags = IRQF_TRIGGER_FALLING,
2484 .i2c_pull_up = true,
2485 .reset_gpio = MXT_TS_RESET_GPIO,
2486 .irq_gpio = MXT_TS_GPIO_IRQ,
2487};
2488
Mohan Pallaka50837382011-09-07 11:00:57 +05302489static struct i2c_board_info mxt_device_info[] __initdata = {
2490 {
2491 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302492 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2493 },
2494};
2495
Manoj Rao14648742012-03-30 19:42:12 -07002496static struct msm_mhl_platform_data mhl_platform_data = {
2497 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002498 .gpio_mhl_int = MHL_GPIO_INT,
2499 .gpio_mhl_reset = MHL_GPIO_RESET,
2500 .gpio_mhl_power = 0,
2501 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002502};
Manoj Rao14648742012-03-30 19:42:12 -07002503
Eugene Yasmand2316b82011-12-07 18:23:48 +02002504static struct i2c_board_info sii_device_info[] __initdata = {
2505 {
Manoj Rao14648742012-03-30 19:42:12 -07002506#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2507 /*
2508 * keeps SI 8334 as the default
2509 * MHL TX
2510 */
2511 I2C_BOARD_INFO("sii8334", 0x39),
2512 .platform_data = &mhl_platform_data,
2513#endif
2514#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002515 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002516 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002517#endif /* CONFIG_MSM_HDMI_MHL */
2518 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002519 },
2520};
2521
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002522static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2523 .clk_freq = 100000,
2524 .src_clk_rate = 24000000,
Kiran Gundab4696c72012-08-16 18:37:46 +05302525 .keep_ahb_clk_on = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002526};
2527
2528static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2529 .clk_freq = 100000,
2530 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002531};
2532
2533static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2534 .clk_freq = 100000,
2535 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002536};
2537
2538static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2539 .clk_freq = 100000,
2540 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002541};
2542
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002543static struct ks8851_pdata spi_eth_pdata = {
2544 .irq_gpio = KS8851_IRQ_GPIO,
2545 .rst_gpio = KS8851_RST_GPIO,
2546};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002547
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302548static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002549 {
2550 .modalias = "ks8851",
2551 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2552 .max_speed_hz = 19200000,
2553 .bus_num = 0,
2554 .chip_select = 0,
2555 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002556 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002557 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302558};
2559static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002560 {
2561 .modalias = "dsi_novatek_3d_panel_spi",
2562 .max_speed_hz = 10800000,
2563 .bus_num = 0,
2564 .chip_select = 1,
2565 .mode = SPI_MODE_0,
2566 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002567};
2568
2569static struct platform_device msm_device_saw_core0 = {
2570 .name = "saw-regulator",
2571 .id = 0,
2572 .dev = {
2573 .platform_data = &msm_saw_regulator_pdata_s5,
2574 },
2575};
2576
2577static struct platform_device msm_device_saw_core1 = {
2578 .name = "saw-regulator",
2579 .id = 1,
2580 .dev = {
2581 .platform_data = &msm_saw_regulator_pdata_s6,
2582 },
2583};
2584
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002585static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002586 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002587 .tsens_factor = 1000,
2588 .hw_type = MSM_8960,
2589 .tsens_num_sensor = 5,
2590};
2591
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002592static struct platform_device msm_tsens_device = {
2593 .name = "tsens8960-tm",
2594 .id = -1,
2595};
2596
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002597static struct msm_thermal_data msm_thermal_pdata = {
2598 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002599 .poll_ms = 250,
2600 .limit_temp_degC = 60,
2601 .temp_hysteresis_degC = 10,
2602 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002603};
2604
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002605#ifdef CONFIG_MSM_FAKE_BATTERY
2606static struct platform_device fish_battery_device = {
2607 .name = "fish_battery",
2608};
2609#endif
2610
David Collins26f05562011-06-20 09:56:28 -07002611static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002612 .name = GPIO_REGULATOR_DEV_NAME,
2613 .id = PM8921_MPP_PM_TO_SYS(7),
2614 .dev = {
2615 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2616 },
2617};
2618
David Collins26f05562011-06-20 09:56:28 -07002619static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002620 .name = GPIO_REGULATOR_DEV_NAME,
2621 .id = 91,
2622 .dev = {
2623 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2624 },
2625};
2626
David Collinsb10be1d2011-09-02 10:29:31 -07002627static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2628 .name = GPIO_REGULATOR_DEV_NAME,
2629 .id = PM8921_GPIO_PM_TO_SYS(17),
2630 .dev = {
2631 .platform_data =
2632 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2633 },
2634};
2635
David Collins35a78f52011-12-14 15:54:25 -08002636static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2637 .name = GPIO_REGULATOR_DEV_NAME,
2638 .id = PM8921_GPIO_PM_TO_SYS(42),
2639 .dev = {
2640 .platform_data =
2641 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2642 },
2643};
2644
David Collins26f05562011-06-20 09:56:28 -07002645static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2646 .name = "rpm-regulator",
2647 .id = -1,
2648 .dev = {
2649 .platform_data = &msm_rpm_regulator_pdata,
2650 },
2651};
Mayank Ranae009c922012-03-22 03:02:06 +05302652#ifdef CONFIG_SERIAL_MSM_HS
2653static int configure_uart_gpios(int on)
2654{
2655 int ret = 0, i;
2656 int uart_gpios[] = {93, 94, 95, 96};
2657
2658 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2659 if (on) {
2660 ret = gpio_request(uart_gpios[i], NULL);
2661 if (ret) {
2662 pr_err("%s: unable to request uart gpio[%d]\n",
2663 __func__, uart_gpios[i]);
2664 break;
2665 }
2666 } else {
2667 gpio_free(uart_gpios[i]);
2668 }
2669 }
2670
2671 if (ret && on && i)
2672 for (; i >= 0; i--)
2673 gpio_free(uart_gpios[i]);
2674 return ret;
2675}
2676
2677static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002678 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302679};
Mayank Rana1f02d952012-07-04 19:11:20 +05302680
2681static int configure_gsbi8_uart_gpios(int on)
2682{
2683 int ret = 0, i;
2684 int uart_gpios[] = {34, 35, 36, 37};
2685
2686 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2687 if (on) {
2688 ret = gpio_request(uart_gpios[i], NULL);
2689 if (ret) {
2690 pr_err("%s: unable to request uart gpio[%d]\n",
2691 __func__, uart_gpios[i]);
2692 break;
2693 }
2694 } else {
2695 gpio_free(uart_gpios[i]);
2696 }
2697 }
2698
2699 if (ret && on && i)
2700 for (; i >= 0; i--)
2701 gpio_free(uart_gpios[i]);
2702 return ret;
2703}
2704
2705static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
2706 .gpio_config = configure_gsbi8_uart_gpios,
2707};
Mayank Ranae009c922012-03-22 03:02:06 +05302708#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302709static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302710static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2711#endif
David Collins26f05562011-06-20 09:56:28 -07002712
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302713#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002714enum WLANBT_STATUS {
2715 WLANOFF_BTOFF = 1,
2716 WLANOFF_BTON,
2717 WLANON_BTOFF,
2718 WLANON_BTON
2719};
2720
2721static DEFINE_MUTEX(ath_wlanbt_mutex);
2722static int gpio_wlan_sys_rest_en = 26;
2723static int ath_wlanbt_status = WLANOFF_BTOFF;
2724
2725static int ath6kl_power_control(int on)
2726{
2727 int rc;
2728
2729 if (on) {
2730 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2731 if (rc) {
2732 pr_err("%s: unable to request gpio %d (%d)\n",
2733 __func__, gpio_wlan_sys_rest_en, rc);
2734 return rc;
2735 }
2736 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2737 msleep(200);
2738 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2739 msleep(100);
2740 } else {
2741 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2742 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2743 msleep(100);
2744 gpio_free(gpio_wlan_sys_rest_en);
2745 }
2746 return 0;
2747};
2748
2749static int ath6kl_wlan_power(int on)
2750{
2751 int ret = 0;
2752
2753 mutex_lock(&ath_wlanbt_mutex);
2754 if (on) {
2755 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2756 ret = ath6kl_power_control(1);
2757 ath_wlanbt_status = WLANON_BTOFF;
2758 } else if (ath_wlanbt_status == WLANOFF_BTON)
2759 ath_wlanbt_status = WLANON_BTON;
2760 } else {
2761 if (ath_wlanbt_status == WLANON_BTOFF) {
2762 ret = ath6kl_power_control(0);
2763 ath_wlanbt_status = WLANOFF_BTOFF;
2764 } else if (ath_wlanbt_status == WLANON_BTON)
2765 ath_wlanbt_status = WLANOFF_BTON;
2766 }
2767 mutex_unlock(&ath_wlanbt_mutex);
2768 pr_debug("%s on= %d, wlan_status= %d\n",
2769 __func__, on, ath_wlanbt_status);
2770 return ret;
2771};
2772
2773static struct wifi_platform_data ath6kl_wifi_control = {
2774 .set_power = ath6kl_wlan_power,
2775};
2776
2777static struct platform_device msm_wlan_power_device = {
2778 .name = "ath6kl_power",
2779 .dev = {
2780 .platform_data = &ath6kl_wifi_control,
2781 },
2782};
2783
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302784static struct resource bluesleep_resources[] = {
2785 {
2786 .name = "gpio_host_wake",
2787 .start = 27,
2788 .end = 27,
2789 .flags = IORESOURCE_IO,
2790 },
2791 {
2792 .name = "gpio_ext_wake",
2793 .start = 29,
2794 .end = 29,
2795 .flags = IORESOURCE_IO,
2796 },
2797 {
2798 .name = "host_wake",
2799 .start = MSM_GPIO_TO_INT(27),
2800 .end = MSM_GPIO_TO_INT(27),
2801 .flags = IORESOURCE_IRQ,
2802 },
2803};
2804
2805static struct platform_device msm_bluesleep_device = {
2806 .name = "bluesleep",
2807 .id = -1,
2808 .num_resources = ARRAY_SIZE(bluesleep_resources),
2809 .resource = bluesleep_resources,
2810};
2811
2812static struct platform_device msm_bt_power_device = {
2813 .name = "bt_power",
2814};
2815
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002816static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302817
2818static int bluetooth_power(int on)
2819{
2820 int rc;
2821
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002822 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302823 if (on) {
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002824 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2825 ath6kl_power_control(1);
2826 ath_wlanbt_status = WLANOFF_BTON;
2827 } else if (ath_wlanbt_status == WLANON_BTOFF)
2828 ath_wlanbt_status = WLANON_BTON;
2829
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302830 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2831 if (rc) {
2832 pr_err("%s: unable to request gpio %d (%d)\n",
2833 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002834 mutex_unlock(&ath_wlanbt_mutex);
2835 return rc;
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302836 }
2837 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002838 msleep(20);
2839 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302840 msleep(100);
2841 } else {
2842 gpio_set_value(gpio_bt_sys_rest_en, 0);
2843 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2844 msleep(100);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002845 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302846
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002847 if (ath_wlanbt_status == WLANOFF_BTON) {
2848 ath6kl_power_control(0);
2849 ath_wlanbt_status = WLANOFF_BTOFF;
2850 } else if (ath_wlanbt_status == WLANON_BTON)
2851 ath_wlanbt_status = WLANON_BTOFF;
2852 }
2853 mutex_unlock(&ath_wlanbt_mutex);
2854 pr_debug("%s on= %d, wlan_status= %d\n",
2855 __func__, on, ath_wlanbt_status);
2856 return 0;
2857};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302858
2859static void __init bt_power_init(void)
2860{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302861 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302862 return;
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002863};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302864#else
2865#define bt_power_init(x) do {} while (0)
2866#endif
2867
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002868static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002869 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002870 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302871 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002872 &msm_device_saw_core0,
2873 &msm_device_saw_core1,
2874 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002875 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002876 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002877 &msm8960_device_qup_spi_gsbi1,
2878 &msm8960_device_qup_i2c_gsbi3,
2879 &msm8960_device_qup_i2c_gsbi4,
2880 &msm8960_device_qup_i2c_gsbi10,
2881#ifndef CONFIG_MSM_DSPS
2882 &msm8960_device_qup_i2c_gsbi12,
2883#endif
2884 &msm_slim_ctrl,
2885 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302886#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2887 &msm_bluesleep_device,
2888 &msm_bt_power_device,
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002889 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302890#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002891#if defined(CONFIG_QSEECOM)
2892 &qseecom_device,
2893#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002894#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2895 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2896 &qcrypto_device,
2897#endif
2898
2899#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2900 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2901 &qcedev_device,
2902#endif
2903#ifdef CONFIG_MSM_ROTATOR
2904 &msm_rotator_device,
2905#endif
2906 &msm_device_sps,
2907#ifdef CONFIG_MSM_FAKE_BATTERY
2908 &fish_battery_device,
2909#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002910 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002911#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002912#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002913 &msm8960_android_pmem_device,
2914 &msm8960_android_pmem_adsp_device,
2915 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002917#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002918 &msm_device_bam_dmux,
2919 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002920#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2921#ifdef CONFIG_MSM_USE_TSIF1
2922 &msm_device_tsif[1],
2923#else
2924 &msm_device_tsif[0],
2925#endif
2926#endif
Joel Nider266a2642011-10-16 10:58:05 +02002927 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002928#ifdef CONFIG_HW_RANDOM_MSM
2929 &msm_device_rng,
2930#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002931#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002932 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002933#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002934 &msm8960_rpm_device,
2935 &msm8960_rpm_log_device,
2936 &msm8960_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302937 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002938 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002939 &coresight_tpiu_device,
2940 &coresight_etb_device,
2941 &coresight_funnel_device,
2942 &coresight_etm0_device,
2943 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002944 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002945 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002946 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002947 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002948 &msm8960_device_ebi1_ch0_erp,
2949 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002950 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002951 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002952 &msm_tsens_device,
Anji Jonnalae84292b2012-09-21 13:34:44 +05302953 &msm8960_pc_cntr,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002954};
2955
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002956static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002957 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002958 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002959 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002960 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002961 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002962 &msm8960_device_otg,
2963 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002964 &msm_device_hsusb_host,
2965 &android_usb_device,
2966 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002967 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002968 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 &msm_pcm_routing,
2970 &msm_cpudai0,
2971 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002972 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002973 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002974 &msm_cpudai_hdmi_rx,
2975 &msm_cpudai_bt_rx,
2976 &msm_cpudai_bt_tx,
2977 &msm_cpudai_fm_rx,
2978 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002979 &msm_cpudai_auxpcm_rx,
2980 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002981 &msm_cpu_fe,
2982 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002983#ifdef CONFIG_MSM_GEMINI
2984 &msm8960_gemini_device,
2985#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07002986#ifdef CONFIG_MSM_MERCURY
2987 &msm8960_mercury_device,
2988#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002989 &msm_voice,
2990 &msm_voip,
2991 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302992 &msm_cpudai_afe_01_rx,
2993 &msm_cpudai_afe_01_tx,
2994 &msm_cpudai_afe_02_rx,
2995 &msm_cpudai_afe_02_tx,
2996 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302997 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002998 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002999 &msm_cpudai_incall_record_rx,
3000 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003001 &msm_pcm_hostless,
3002 &msm_bus_apps_fabric,
3003 &msm_bus_sys_fabric,
3004 &msm_bus_mm_fabric,
3005 &msm_bus_sys_fpb,
3006 &msm_bus_cpss_fpb,
3007};
3008
3009static void __init msm8960_i2c_init(void)
3010{
3011 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3012 &msm8960_i2c_qup_gsbi4_pdata;
3013
3014 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3015 &msm8960_i2c_qup_gsbi3_pdata;
3016
3017 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3018 &msm8960_i2c_qup_gsbi10_pdata;
3019
3020 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3021 &msm8960_i2c_qup_gsbi12_pdata;
3022}
3023
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003024static void __init msm8960_gfx_init(void)
3025{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003026 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3027 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06003028 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003029
Carter Cooper3852cbb2012-08-20 22:11:42 -06003030 /* Fixup data that needs to change based on GPU ID */
Carter Cooperffe7ea12012-08-22 13:27:58 -06003031 if (cpu_is_msm8960ab()) {
3032 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
Suman Tatiraju20372242012-10-29 18:24:53 -07003033 /* 8960PRO nominal clock rate is 320Mhz */
3034 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Carter Cooper3852cbb2012-08-20 22:11:42 -06003035 } else {
3036 kgsl_3d0_pdata->iommu_count = 1;
3037 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3038 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
3039 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
3040 }
3041 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
3042 /* 8960v3 GPU registers returns 5 for patch release
3043 * but it should be 6, so dummy up the chipid here
3044 * based the platform type
3045 */
3046 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
3047 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003048 }
Carter Cooper6307eb992012-08-20 15:17:23 -06003049
3050 /* Register the 3D core */
3051 platform_device_register(&msm_kgsl_3d0);
3052
3053 /* Register the 2D cores if we are not 8960PRO */
3054 if (!cpu_is_msm8960ab()) {
3055 platform_device_register(&msm_kgsl_2d0);
3056 platform_device_register(&msm_kgsl_2d1);
3057 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003058}
3059
Subhash Jadavani933e6a62011-12-26 18:05:04 +05303060static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003061 {
3062 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3063 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3064 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003065 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003066 },
3067
3068 {
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303069 MSM_PM_SLEEP_MODE_RETENTION,
3070 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3071 true,
3072 415, 715, 340827, 475,
3073 },
3074
3075 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003076 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3077 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3078 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003079 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003080 },
3081
3082 {
3083 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3084 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3085 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003086 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003087 },
3088
3089 {
3090 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003091 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
3092 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003093 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003094 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003095
3096 {
3097 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3098 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3099 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003100 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003101 },
3102
3103 {
3104 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3105 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3106 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003107 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003108 },
3109
3110 {
3111 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3112 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3113 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003114 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003115 },
3116
3117 {
3118 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3119 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3120 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003121 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003122 },
3123};
3124
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303125
Praveen Chidambaram78499012011-11-01 17:15:17 -06003126static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
3127 .levels = &msm_rpmrs_levels[0],
3128 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
3129 .vdd_mem_levels = {
3130 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3131 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3132 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3133 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3134 },
3135 .vdd_dig_levels = {
3136 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3137 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3138 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3139 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3140 },
3141 .vdd_mask = 0x7FFFFF,
3142 .rpmrs_target_id = {
3143 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3144 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3145 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3146 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3147 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3148 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3149 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3150 },
3151};
3152
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003153static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3154 .mode = MSM_PM_BOOT_CONFIG_TZ,
3155};
3156
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003157#ifdef CONFIG_I2C
3158#define I2C_SURF 1
3159#define I2C_FFA (1 << 1)
3160#define I2C_RUMI (1 << 2)
3161#define I2C_SIM (1 << 3)
3162#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003163#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003164
3165struct i2c_registry {
3166 u8 machs;
3167 int bus;
3168 struct i2c_board_info *info;
3169 int len;
3170};
3171
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003172/* Sensors DSPS platform data */
3173#ifdef CONFIG_MSM_DSPS
3174#define DSPS_PIL_GENERIC_NAME "dsps"
3175#endif /* CONFIG_MSM_DSPS */
3176
3177static void __init msm8960_init_dsps(void)
3178{
3179#ifdef CONFIG_MSM_DSPS
3180 struct msm_dsps_platform_data *pdata =
3181 msm_dsps_device.dev.platform_data;
3182 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3183 pdata->gpios = NULL;
3184 pdata->gpios_num = 0;
3185
3186 platform_device_register(&msm_dsps_device);
3187#endif /* CONFIG_MSM_DSPS */
3188}
3189
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003190static int hsic_peripheral_status = 1;
3191static DEFINE_MUTEX(hsic_status_lock);
3192
3193void peripheral_connect()
3194{
3195 mutex_lock(&hsic_status_lock);
3196 if (hsic_peripheral_status)
3197 goto out;
3198 platform_device_add(&msm_device_hsic_host);
3199 hsic_peripheral_status = 1;
3200out:
3201 mutex_unlock(&hsic_status_lock);
3202}
3203EXPORT_SYMBOL(peripheral_connect);
3204
3205void peripheral_disconnect()
3206{
3207 mutex_lock(&hsic_status_lock);
3208 if (!hsic_peripheral_status)
3209 goto out;
3210 platform_device_del(&msm_device_hsic_host);
3211 hsic_peripheral_status = 0;
3212out:
3213 mutex_unlock(&hsic_status_lock);
3214}
3215EXPORT_SYMBOL(peripheral_disconnect);
3216
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303217static void __init msm8960_init_smsc_hub(void)
3218{
3219 uint32_t version = socinfo_get_version();
3220
3221 if (SOCINFO_VERSION_MAJOR(version) == 1)
3222 return;
3223
3224 if (machine_is_msm8960_liquid())
3225 platform_device_register(&smsc_hub_device);
3226}
3227
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003228static void __init msm8960_init_hsic(void)
3229{
3230#ifdef CONFIG_USB_EHCI_MSM_HSIC
3231 uint32_t version = socinfo_get_version();
3232
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003233 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003234 return;
3235
Joel King0cbf5d82012-05-24 15:21:38 -07003236 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003237 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003238#endif
3239}
3240
Amir Samuelov5137e392011-09-21 17:31:25 +03003241#ifdef CONFIG_ISL9519_CHARGER
3242static struct isl_platform_data isl_data __initdata = {
3243 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3244 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3245 .max_system_voltage = 4200,
3246 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003247 .chgcurrent = 1900,
3248 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003249 .input_current = 2048,
3250};
3251
3252static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3253 {
3254 I2C_BOARD_INFO("isl9519q", 0x9),
3255 .irq = 0, /* Not required when notify-by-pmic */
3256 .platform_data = &isl_data,
3257 },
3258};
3259#endif /* CONFIG_ISL9519_CHARGER */
3260
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003261#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003262static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3263 {
3264 I2C_BOARD_INFO("sx1508q", 0x20),
3265 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3266 },
3267};
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003268#endif
Amir Samuelov755616d2011-12-13 16:34:46 +02003269
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003270static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003271#ifdef CONFIG_ISL9519_CHARGER
3272 {
3273 I2C_LIQUID,
3274 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3275 isl_charger_i2c_info,
3276 ARRAY_SIZE(isl_charger_i2c_info),
3277 },
3278#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003279 {
3280 I2C_SURF | I2C_FFA | I2C_FLUID,
3281 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3282 cyttsp_info,
3283 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003284 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303285 {
3286 I2C_LIQUID,
3287 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3288 mxt_device_info,
3289 ARRAY_SIZE(mxt_device_info),
3290 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303291 {
Manoj Rao14648742012-03-30 19:42:12 -07003292 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303293 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003294 sii_device_info,
3295 ARRAY_SIZE(sii_device_info),
3296 },
3297 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303298 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003299 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303300 msm_isa1200_board_info,
3301 ARRAY_SIZE(msm_isa1200_board_info),
3302 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003303#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003304 {
3305 I2C_LIQUID,
3306 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3307 liquid_io_expander_i2c_info,
3308 ARRAY_SIZE(liquid_io_expander_i2c_info),
3309 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003310#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003311};
3312#endif /* CONFIG_I2C */
3313
3314static void __init register_i2c_devices(void)
3315{
3316#ifdef CONFIG_I2C
3317 u8 mach_mask = 0;
3318 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003319#ifdef CONFIG_MSM_CAMERA
3320 struct i2c_registry msm8960_camera_i2c_devices = {
3321 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3322 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3323 msm8960_camera_board_info.board_info,
3324 msm8960_camera_board_info.num_i2c_board_info,
3325 };
3326#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003327
3328 /* Build the matching 'supported_machs' bitmask */
3329 if (machine_is_msm8960_cdp())
3330 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003331 else if (machine_is_msm8960_fluid())
3332 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003333 else if (machine_is_msm8960_liquid())
3334 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003335 else if (machine_is_msm8960_mtp())
3336 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003337 else
3338 pr_err("unmatched machine ID in register_i2c_devices\n");
3339
Jing Lineec88ca2012-02-08 11:18:30 -08003340 if (machine_is_msm8960_liquid()) {
3341 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3342 mxt_device_info[0].platform_data =
3343 &mxt_platform_data_3d;
3344 else
3345 mxt_device_info[0].platform_data =
3346 &mxt_platform_data_2d;
3347 }
3348
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003349 /* Run the array and install devices as appropriate */
3350 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3351 if (msm8960_i2c_devices[i].machs & mach_mask)
3352 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3353 msm8960_i2c_devices[i].info,
3354 msm8960_i2c_devices[i].len);
3355 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003356
3357 if (!mhl_platform_data.gpio_mhl_power)
3358 pr_debug("mhl device configured for ext debug board\n");
3359
Kevin Chan09f4e662011-12-16 08:17:02 -08003360#ifdef CONFIG_MSM_CAMERA
3361 if (msm8960_camera_i2c_devices.machs & mach_mask)
3362 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3363 msm8960_camera_i2c_devices.info,
3364 msm8960_camera_i2c_devices.len);
3365#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003366#endif
3367}
3368
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003369static void __init msm8960_tsens_init(void)
3370{
3371 if (cpu_is_msm8960())
3372 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3373 return;
3374
3375 msm_tsens_early_init(&msm_tsens_pdata);
3376}
3377
Anji Jonnala0f297a92013-01-19 11:22:25 +05303378static void __init msm8960ab_update_krait_spm(void)
3379 {
3380 int i;
3381
Anji Jonnala0f297a92013-01-19 11:22:25 +05303382
3383 /* Update the SPM sequences for SPC and PC */
3384 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3385 int j;
3386 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3387 for (j = 0; j < pdata->num_modes; j++) {
3388 if (pdata->modes[j].cmd ==
3389 spm_power_collapse_without_rpm)
3390 pdata->modes[j].cmd =
3391 spm_power_collapse_without_rpm_krait_v3;
3392 else if (pdata->modes[j].cmd ==
3393 spm_power_collapse_with_rpm)
3394 pdata->modes[j].cmd =
3395 spm_power_collapse_with_rpm_krait_v3;
3396 }
3397 }
3398}
3399
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003400static void __init msm8960_cdp_init(void)
3401{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003402 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3403 pr_err("meminfo_init() failed!\n");
3404
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003405 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003406 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003407 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003408 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3409 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003411 regulator_suppress_info_printing();
3412 if (msm_xo_init())
3413 pr_err("Failed to initialize XO votes\n");
David Collins4c93ce92012-09-04 15:44:19 -07003414 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003415 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003416 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303417 if (machine_is_msm8960_liquid())
3418 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003419 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303420 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3421 machine_is_msm8960_cdp()) {
Mayank Ranaa1f507b2012-08-14 10:57:00 +05303422 /* Due to availability of USB Switch in SGLTE Platform
3423 * it requires different HSUSB PHY settings compare to
3424 * 8960 MTP/CDP platform.
3425 */
3426 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3427 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3428 else
3429 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303430 } else if (machine_is_msm8960_liquid()) {
3431 msm_otg_pdata.phy_init_seq =
3432 liquid_v1_phy_init_seq;
3433 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003434 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303435 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303436 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303437 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3438 machine_is_msm8960_liquid())
3439 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003440 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003441 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3442 &msm8960_qup_spi_gsbi1_pdata;
3443 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303444 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3445 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003446
3447 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303448 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jain4ffd8122012-12-03 15:09:39 +05303449 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3450 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303451 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003452 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003453 msm8960_gfx_init();
Anji Jonnala0f297a92013-01-19 11:22:25 +05303454 if (cpu_is_msm8960ab())
3455 msm8960ab_update_krait_spm();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003456 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3457 msm_spm_l2_init(msm_spm_l2_data);
3458 msm8960_init_buses();
Stephen Boyd6716bd92012-10-25 11:46:04 -07003459 if (cpu_is_msm8960ab()) {
3460 platform_add_devices(msm8960ab_footswitch,
3461 msm8960ab_num_footswitch);
3462 } else {
3463 platform_add_devices(msm8960_footswitch,
3464 msm8960_num_footswitch);
3465 }
David Collinsb10be1d2011-09-02 10:29:31 -07003466 if (machine_is_msm8960_liquid())
3467 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003468 if (machine_is_msm8960_cdp())
3469 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003470
3471 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3472 platform_device_register(&msm8960_device_uart_gsbi8);
3473 else
3474 platform_device_register(&msm8960_device_uart_gsbi5);
3475
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003476 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003477 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3478 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003479 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303480 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003481 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003482
Mayank Rana1f02d952012-07-04 19:11:20 +05303483 /* For 8960 Standalone External Bluetooth Interface */
3484 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3485 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3486 platform_device_register(&msm_device_uart_dm8);
3487 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003488 if (cpu_is_msm8960ab())
3489 platform_device_register(&msm8960ab_device_acpuclk);
3490 else
3491 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003492 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menond4837f62012-08-20 15:25:50 -07003493 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003494
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003495 msm8960_pm8921_gpio_mpp_init();
Stephen Boyd0ea1b762012-09-13 12:41:31 -07003496 /* Don't add modem devices on APQ targets */
3497 if (socinfo_get_id() != 124) {
3498 platform_device_register(&msm_8960_q6_mss_fw);
3499 platform_device_register(&msm_8960_q6_mss_sw);
3500 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003501 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303502 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003503 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003504#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003505 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003506#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003507 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303508 if (machine_is_msm8960_liquid())
3509 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003510 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003511 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003512 slim_register_board_info(msm_slim_devices,
3513 ARRAY_SIZE(msm_slim_devices));
3514 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003515 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003516 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303517 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003518 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3519 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3520 platform_device_register(&mdm_sglte_device);
3521 }
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303522 msm_pm_set_tz_retention_flag(1);
Laura Abbott5249a052012-12-11 15:09:03 -08003523 ion_adjust_secure_allocation();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003524}
3525
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003526MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3527 .map_io = msm8960_map_io,
3528 .reserve = msm8960_reserve,
3529 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303530 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003531 .timer = &msm_timer,
3532 .init_machine = msm8960_cdp_init,
3533 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003534 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003535 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003536MACHINE_END
3537
3538MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3539 .map_io = msm8960_map_io,
3540 .reserve = msm8960_reserve,
3541 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303542 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003543 .timer = &msm_timer,
3544 .init_machine = msm8960_cdp_init,
3545 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003546 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003547 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003548MACHINE_END
3549
3550MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3551 .map_io = msm8960_map_io,
3552 .reserve = msm8960_reserve,
3553 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303554 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003555 .timer = &msm_timer,
3556 .init_machine = msm8960_cdp_init,
3557 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003558 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003559 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003560MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003561
3562MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3563 .map_io = msm8960_map_io,
3564 .reserve = msm8960_reserve,
3565 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303566 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003567 .timer = &msm_timer,
3568 .init_machine = msm8960_cdp_init,
3569 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003570 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003571 .restart = msm_restart,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003572MACHINE_END