blob: 32ab870aed50d0bafe857c3880dcf5029ea44fa9 [file] [log] [blame]
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -07001/* Copyright (c) 2011-2012, 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>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070033#include <linux/dma-mapping.h>
34#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070035#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070036#include <linux/leds.h>
37#include <linux/leds-pm8xxx.h>
Mohan Pallaka50837382011-09-07 11:00:57 +053038#include <linux/i2c/atmel_mxt_ts.h>
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -070039#include <linux/msm_tsens.h>
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -070040#include <linux/ks8851.h>
Mohan Pallaka5e490392011-09-09 15:18:41 +053041#include <linux/i2c/isa1200.h>
Jack Cheung0b1987e2011-11-18 13:36:29 -080042#include <linux/memory.h>
Larry Bassel2d8b42d2012-03-12 10:41:26 -070043#include <linux/memblock.h>
Praveen Chidambaram877d7a42012-06-05 14:33:20 -060044#include <linux/msm_thermal.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080045
46#include <asm/mach-types.h>
47#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070048#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080049#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080051
52#include <mach/board.h>
Joel Nider266a2642011-10-16 10:58:05 +020053#include <mach/msm_tspp.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080054#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include <mach/msm_spi.h>
Mayank Ranae009c922012-03-22 03:02:06 +053056#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#ifdef CONFIG_USB_MSM_OTG_72K
58#include <mach/msm_hsusb.h>
59#else
60#include <linux/usb/msm_hsusb.h>
61#endif
62#include <linux/usb/android.h>
63#include <mach/usbdiag.h>
64#include <mach/socinfo.h>
65#include <mach/rpm.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070066#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067#include <mach/msm_bus_board.h>
68#include <mach/msm_memtypes.h>
69#include <mach/dma.h>
70#include <mach/msm_dsps.h>
71#include <mach/msm_xo.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070072#include <mach/restart.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074#ifdef CONFIG_WCD9310_CODEC
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053075#include <linux/mfd/wcd9xxx/core.h>
76#include <linux/mfd/wcd9xxx/pdata.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077#endif
78
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +053079#include <linux/smsc3503.h>
Mitchel Humpheryscfa31af2012-09-06 11:34:03 -070080#include <linux/msm_ion.h>
Laura Abbottd6183792011-08-19 13:42:24 -070081#include <mach/ion.h>
Joel Kingb8352a12011-11-15 18:46:24 -080082#include <mach/mdm2.h>
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -080083#include <mach/mdm-peripheral.h>
Laura Abbottf8c03b92012-02-16 14:57:58 -080084#include <mach/msm_rtb.h>
Laura Abbott306bcc22012-03-08 11:24:53 -080085#include <mach/msm_cache_dump.h>
86#include <mach/scm.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070087#include <mach/iommu_domains.h>
Laura Abbottd6183792011-08-19 13:42:24 -070088
Jordan Crouse914de9b2012-07-09 13:49:46 -060089#include <mach/kgsl.h>
Larry Bassel41a055b2011-12-06 16:15:14 -080090#include <linux/fmem.h>
91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080093#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#include "spm.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080096#include "board-8960.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080097#include "pm.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080098#include <mach/cpuidle.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099#include "rpm_resources.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +0530100#include <mach/mpm.h>
Matt Wagantall33d01f52012-02-23 23:27:44 -0800101#include "clock.h"
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700102#include "smd_private.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600103#include "pm-boot.h"
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700104#include "msm_watchdog.h"
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800105
Ming-yi Lin9baad172012-10-17 11:50:15 +0800106#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
107#include <linux/wlan_plat.h>
108#include <linux/mutex.h>
109#endif
110
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111static struct platform_device msm_fm_platform_init = {
112 .name = "iris_fm",
113 .id = -1,
114};
115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116#define KS8851_RST_GPIO 89
117#define KS8851_IRQ_GPIO 90
Mohan Pallaka5e490392011-09-09 15:18:41 +0530118
Manoj Rao14648742012-03-30 19:42:12 -0700119#define MHL_GPIO_INT 4
120#define MHL_GPIO_RESET 15
121
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700122#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700123
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800124struct sx150x_platform_data msm8960_sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700125 [SX150X_CAM] = {
126 .gpio_base = GPIO_CAM_EXPANDER_BASE,
127 .oscio_is_gpo = false,
128 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530129 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700130 .io_open_drain_ena = 0x0,
131 .irq_summary = -1,
132 },
Amir Samuelov755616d2011-12-13 16:34:46 +0200133 [SX150X_LIQUID] = {
134 .gpio_base = GPIO_LIQUID_EXPANDER_BASE,
135 .oscio_is_gpo = false,
136 .io_pullup_ena = 0x0c08,
137 .io_pulldn_ena = 0x4060,
138 .io_open_drain_ena = 0x000c,
139 .io_polarity = 0,
140 .irq_summary = -1,
141 },
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700142};
Nishant Pandit474f2252011-07-23 23:17:56 +0530143
144#endif
145
Olav Haugana21169d2012-01-04 09:17:06 -0800146#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -0700147#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Mathew Karimpanal15fa5c42011-12-14 21:28:10 -0800148#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800149#define MSM_LIQUID_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800150#define MSM_HDMI_PRIM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Laura Abbott2d1760b2011-09-29 21:31:24 -0700151
152#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Deepak Kotur35825522012-06-06 15:49:14 -0700153#define HOLE_SIZE 0x20000
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700154#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan32594552012-03-13 11:40:05 -0700155#ifdef CONFIG_MSM_IOMMU
Olav Haugan8726caf2012-05-10 15:11:35 -0700156#define MSM_ION_MM_SIZE 0x3800000 /* Need to be multiple of 64K */
Olav Haugan32594552012-03-13 11:40:05 -0700157#define MSM_ION_SF_SIZE 0x0
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700158#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700159#define MSM_ION_HEAP_NUM 7
160#else
161#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
162#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700163#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700164#define MSM_ION_HEAP_NUM 8
165#endif
Deepak Kotur35825522012-06-06 15:49:14 -0700166#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 128kb */
Olav Hauganb5be7992011-11-18 14:29:02 -0800167#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan7355db02012-01-13 16:59:13 -0800168#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan32594552012-03-13 11:40:05 -0700169
Olav Hauganb5be7992011-11-18 14:29:02 -0800170#define MSM_LIQUID_ION_MM_SIZE (MSM_ION_MM_SIZE + 0x600000)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800171#define MSM_LIQUID_ION_SF_SIZE MSM_LIQUID_PMEM_SIZE
172#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SIZE
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700173
Deepak Kotur35825522012-06-06 15:49:14 -0700174#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 2mb -128kb*/
175#define MSM8960_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
176 HOLE_SIZE))
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700177#define MAX_FIXED_AREA_SIZE 0x10000000
Deepak Kotur35825522012-06-06 15:49:14 -0700178#define MSM8960_FW_START MSM8960_FIXED_AREA_START
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700179
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800180static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott2d1760b2011-09-29 21:31:24 -0700181#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700182#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800183#define MSM_ION_HEAP_NUM 1
Laura Abbott2d1760b2011-09-29 21:31:24 -0700184#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700185
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700186#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
187static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
188static int __init msm_contig_mem_size_setup(char *p)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700189{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700190 msm_contig_mem_size = memparse(p, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700191 return 0;
192}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700193early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700194#endif
195
196#ifdef CONFIG_ANDROID_PMEM
197static unsigned pmem_size = MSM_PMEM_SIZE;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800198static unsigned pmem_param_set;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700199static int __init pmem_size_setup(char *p)
200{
201 pmem_size = memparse(p, NULL);
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800202 pmem_param_set = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700203 return 0;
204}
205early_param("pmem_size", pmem_size_setup);
206
207static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
208
209static int __init pmem_adsp_size_setup(char *p)
210{
211 pmem_adsp_size = memparse(p, NULL);
212 return 0;
213}
214early_param("pmem_adsp_size", pmem_adsp_size_setup);
215
216static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
217
218static int __init pmem_audio_size_setup(char *p)
219{
220 pmem_audio_size = memparse(p, NULL);
221 return 0;
222}
223early_param("pmem_audio_size", pmem_audio_size_setup);
224#endif
225
226#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700227#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700228static struct android_pmem_platform_data android_pmem_pdata = {
229 .name = "pmem",
230 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
231 .cached = 1,
232 .memory_type = MEMTYPE_EBI1,
233};
234
Laura Abbottb93525f2012-04-12 09:57:19 -0700235static struct platform_device msm8960_android_pmem_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700236 .name = "android_pmem",
237 .id = 0,
238 .dev = {.platform_data = &android_pmem_pdata},
239};
240
241static struct android_pmem_platform_data android_pmem_adsp_pdata = {
242 .name = "pmem_adsp",
243 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
244 .cached = 0,
245 .memory_type = MEMTYPE_EBI1,
246};
Laura Abbottb93525f2012-04-12 09:57:19 -0700247static struct platform_device msm8960_android_pmem_adsp_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248 .name = "android_pmem",
249 .id = 2,
250 .dev = { .platform_data = &android_pmem_adsp_pdata },
251};
252
253static struct android_pmem_platform_data android_pmem_audio_pdata = {
254 .name = "pmem_audio",
255 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
256 .cached = 0,
257 .memory_type = MEMTYPE_EBI1,
258};
259
Laura Abbottb93525f2012-04-12 09:57:19 -0700260static struct platform_device msm8960_android_pmem_audio_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700261 .name = "android_pmem",
262 .id = 4,
263 .dev = { .platform_data = &android_pmem_audio_pdata },
264};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700265#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
266#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267
Laura Abbottb93525f2012-04-12 09:57:19 -0700268struct fmem_platform_data msm8960_fmem_pdata = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800269};
270
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700271#define DSP_RAM_BASE_8960 0x8da00000
272#define DSP_RAM_SIZE_8960 0x1800000
273static int dspcrashd_pdata_8960 = 0xDEADDEAD;
274
275static struct resource resources_dspcrashd_8960[] = {
276 {
277 .name = "msm_dspcrashd",
278 .start = DSP_RAM_BASE_8960,
279 .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
280 .flags = IORESOURCE_DMA,
281 },
282};
283
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800284static struct platform_device msm_device_dspcrashd_8960 = {
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700285 .name = "msm_dspcrashd",
286 .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
287 .resource = resources_dspcrashd_8960,
288 .dev = { .platform_data = &dspcrashd_pdata_8960 },
289};
290
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700291static struct memtype_reserve msm8960_reserve_table[] __initdata = {
292 [MEMTYPE_SMI] = {
293 },
294 [MEMTYPE_EBI0] = {
295 .flags = MEMTYPE_FLAGS_1M_ALIGN,
296 },
297 [MEMTYPE_EBI1] = {
298 .flags = MEMTYPE_FLAGS_1M_ALIGN,
299 },
300};
301
Laura Abbottf8c03b92012-02-16 14:57:58 -0800302static void __init reserve_rtb_memory(void)
303{
304#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700305 msm8960_reserve_table[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
Laura Abbottf8c03b92012-02-16 14:57:58 -0800306#endif
307}
308
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309static void __init size_pmem_devices(void)
310{
311#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700312#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700313 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800314
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800315 if (!pmem_param_set) {
316 if (machine_is_msm8960_liquid())
317 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700318 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800319 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
320 }
321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322 android_pmem_pdata.size = pmem_size;
323 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700324#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
325#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326}
327
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700328#ifdef CONFIG_ANDROID_PMEM
329#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330static void __init reserve_memory_for(struct android_pmem_platform_data *p)
331{
332 msm8960_reserve_table[p->memory_type].size += p->size;
333}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700334#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
335#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336
337static void __init reserve_pmem_memory(void)
338{
339#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700340#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700341 reserve_memory_for(&android_pmem_adsp_pdata);
342 reserve_memory_for(&android_pmem_pdata);
343 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700344#endif
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700345 msm8960_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346#endif
347}
348
Larry Basselb4126da2011-07-18 14:31:33 -0700349static int msm8960_paddr_to_memtype(unsigned int paddr)
350{
351 return MEMTYPE_EBI1;
352}
353
Steve Mucklef132c6c2012-06-06 18:30:57 -0700354#define FMEM_ENABLED 0
Olav Hauganf6dc7742012-02-15 09:11:55 -0800355
Laura Abbottd6183792011-08-19 13:42:24 -0700356#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800357#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700358static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800359 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -0700360 .align = SZ_64K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800361 .reusable = FMEM_ENABLED,
362 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700363 .fixed_position = FIXED_MIDDLE,
Olav Haugan8726caf2012-05-10 15:11:35 -0700364 .iommu_map_all = 1,
365 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800366};
367
Laura Abbottb93525f2012-04-12 09:57:19 -0700368static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800369 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800370 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800371 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800372 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700373 .fixed_position = FIXED_HIGH,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800374};
375
Laura Abbottb93525f2012-04-12 09:57:19 -0700376static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800377 .adjacent_mem_id = INVALID_HEAP_ID,
378 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800379 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800380};
381
Laura Abbottb93525f2012-04-12 09:57:19 -0700382static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800383 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
384 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800385 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700386 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800387};
388#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800389
390/**
391 * These heaps are listed in the order they will be allocated. Due to
392 * video hardware restrictions and content protection the FW heap has to
393 * be allocated adjacent (below) the MM heap and the MFC heap has to be
394 * allocated after the MM heap to ensure MFC heap is not more than 256MB
395 * away from the base address of the FW heap.
396 * However, the order of FW heap and MM heap doesn't matter since these
397 * two heaps are taken care of by separate code to ensure they are adjacent
398 * to each other.
399 * Don't swap the order unless you know what you are doing!
400 */
Benjamin Gaignard63d81032012-06-25 15:27:30 -0700401struct ion_platform_heap msm8960_heaps[] = {
Laura Abbottd6183792011-08-19 13:42:24 -0700402 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800403 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700404 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700405 .name = ION_VMALLOC_HEAP_NAME,
406 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700407#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700408 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800409 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800410 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800411 .name = ION_MM_HEAP_NAME,
412 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700413 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700414 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700415 },
Laura Abbott8c017362011-09-22 20:59:12 -0700416 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800417 .id = ION_MM_FIRMWARE_HEAP_ID,
418 .type = ION_HEAP_TYPE_CARVEOUT,
419 .name = ION_MM_FIRMWARE_HEAP_NAME,
420 .size = MSM_ION_MM_FW_SIZE,
421 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700422 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800423 },
424 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800425 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800426 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800427 .name = ION_MFC_HEAP_NAME,
428 .size = MSM_ION_MFC_SIZE,
429 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700430 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800431 },
Olav Haugan32594552012-03-13 11:40:05 -0700432#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800433 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800434 .id = ION_SF_HEAP_ID,
435 .type = ION_HEAP_TYPE_CARVEOUT,
436 .name = ION_SF_HEAP_NAME,
437 .size = MSM_ION_SF_SIZE,
438 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700439 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800440 },
Olav Haugan32594552012-03-13 11:40:05 -0700441#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800442 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800443 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700444 .type = ION_HEAP_TYPE_IOMMU,
445 .name = ION_IOMMU_HEAP_NAME,
446 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800447 {
448 .id = ION_QSECOM_HEAP_ID,
449 .type = ION_HEAP_TYPE_CARVEOUT,
450 .name = ION_QSECOM_HEAP_NAME,
451 .size = MSM_ION_QSECOM_SIZE,
452 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700453 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800454 },
Olav Haugan7355db02012-01-13 16:59:13 -0800455 {
456 .id = ION_AUDIO_HEAP_ID,
457 .type = ION_HEAP_TYPE_CARVEOUT,
458 .name = ION_AUDIO_HEAP_NAME,
459 .size = MSM_ION_AUDIO_SIZE,
460 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700461 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800462 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700463#endif
Benjamin Gaignard63d81032012-06-25 15:27:30 -0700464};
465
466static struct ion_platform_data msm8960_ion_pdata = {
467 .nr = MSM_ION_HEAP_NUM,
468 .heaps = msm8960_heaps,
Laura Abbottd6183792011-08-19 13:42:24 -0700469};
470
Laura Abbottb93525f2012-04-12 09:57:19 -0700471static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700472 .name = "ion-msm",
473 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700474 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700475};
476#endif
477
Laura Abbottb93525f2012-04-12 09:57:19 -0700478struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800479 .name = "fmem",
480 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700481 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800482};
483
Olav Haugan65f4bd82011-12-13 11:50:08 -0800484static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700485{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800486 unsigned int i;
487
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800488 if (!pmem_param_set) {
489 if (machine_is_msm8960_liquid())
490 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
491
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700492 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800493 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
494
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700495 if (machine_is_msm8960_liquid() ||
496 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700497 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
498 if (msm8960_ion_pdata.heaps[i].id ==
499 ION_SF_HEAP_ID) {
500 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800501 msm_ion_sf_size;
502 pr_debug("msm_ion_sf_size 0x%x\n",
503 msm_ion_sf_size);
504 break;
505 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800506 }
507 }
508 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800509}
510
511static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
512 unsigned long size)
513{
514 msm8960_reserve_table[mem_type].size += size;
515}
516
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700517static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
518{
519#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
520 int ret;
521
522 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
523 panic("fixed area size is larger than %dM\n",
524 MAX_FIXED_AREA_SIZE >> 20);
525
526 reserve_info->fixed_area_size = fixed_area_size;
527 reserve_info->fixed_area_start = MSM8960_FW_START;
528
529 ret = memblock_remove(reserve_info->fixed_area_start,
530 reserve_info->fixed_area_size);
531 BUG_ON(ret);
532#endif
533}
534
Olav Haugan65f4bd82011-12-13 11:50:08 -0800535/**
536 * Reserve memory for ION and calculate amount of reusable memory for fmem.
537 * We only reserve memory for heaps that are not reusable. However, we only
538 * support one reusable heap at the moment so we ignore the reusable flag for
539 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800540 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
541 * at a higher address than FW in addition to not more than 256MB away from the
542 * base address of the firmware. This means that if MM is reusable the other
543 * two heaps must be allocated in the same region as FW. This is handled by the
544 * mem_is_fmem flag in the platform data. In addition the MM heap must be
545 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800546 */
547static void __init reserve_ion_memory(void)
548{
549#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
550 unsigned int i;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700551 unsigned int fixed_size = 0;
552 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
553 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800554
555 adjust_mem_for_liquid();
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700556 fixed_low_size = 0;
557 fixed_middle_size = 0;
558 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800559
Laura Abbottb93525f2012-04-12 09:57:19 -0700560 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
Olav Haugan8726caf2012-05-10 15:11:35 -0700561 struct ion_platform_heap *heap =
Laura Abbottb93525f2012-04-12 09:57:19 -0700562 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan8726caf2012-05-10 15:11:35 -0700563 int align = SZ_4K;
564 int iommu_map_all = 0;
565 int adjacent_mem_id = INVALID_HEAP_ID;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800566
567 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700568 int fixed_position = NOT_FIXED;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700569
Mitchel Humpherys362b52b2012-09-13 10:53:22 -0700570 switch ((int) heap->type) {
Olav Haugan65f4bd82011-12-13 11:50:08 -0800571 case ION_HEAP_TYPE_CP:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700572 fixed_position = ((struct ion_cp_heap_pdata *)
573 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700574 align = ((struct ion_cp_heap_pdata *)
575 heap->extra_data)->align;
576 iommu_map_all =
577 ((struct ion_cp_heap_pdata *)
578 heap->extra_data)->iommu_map_all;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800579 break;
580 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700581 fixed_position = ((struct ion_co_heap_pdata *)
582 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700583 adjacent_mem_id = ((struct ion_co_heap_pdata *)
584 heap->extra_data)->adjacent_mem_id;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700585 break;
586 default:
587 break;
588 }
589
Olav Haugan8726caf2012-05-10 15:11:35 -0700590 if (iommu_map_all) {
591 if (heap->size & (SZ_64K-1)) {
592 heap->size = ALIGN(heap->size, SZ_64K);
593 pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
594 heap->name, heap->size);
595 }
596 }
597
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700598 if (fixed_position != NOT_FIXED)
599 fixed_size += heap->size;
600 else
601 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
602
603 if (fixed_position == FIXED_LOW)
604 fixed_low_size += heap->size;
605 else if (fixed_position == FIXED_MIDDLE)
606 fixed_middle_size += heap->size;
607 else if (fixed_position == FIXED_HIGH)
608 fixed_high_size += heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700609 }
610 }
611
612 if (!fixed_size)
613 return;
614
Larry Bassel4d4f4482012-04-04 11:26:09 -0700615 /* Since the fixed area may be carved out of lowmem,
616 * make sure the length is a multiple of 1M.
617 */
618 fixed_size = (fixed_size + MSM_MM_FW_SIZE + SECTION_SIZE - 1)
619 & SECTION_MASK;
620 msm8960_reserve_fixed_area(fixed_size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700621
622 fixed_low_start = MSM8960_FIXED_AREA_START;
Deepak Kotur35825522012-06-06 15:49:14 -0700623 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700624 fixed_high_start = fixed_middle_start + fixed_middle_size;
625
Laura Abbottb93525f2012-04-12 09:57:19 -0700626 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
627 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700628
629 if (heap->extra_data) {
630 int fixed_position = NOT_FIXED;
Steve Muckle75c34ca2012-06-12 14:27:40 -0700631 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700632
Mitchel Humpherys362b52b2012-09-13 10:53:22 -0700633 switch ((int) heap->type) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700634 case ION_HEAP_TYPE_CP:
Deepak Kotur35825522012-06-06 15:49:14 -0700635 pdata =
636 (struct ion_cp_heap_pdata *)heap->extra_data;
637 fixed_position = pdata->fixed_position;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700638 break;
639 case ION_HEAP_TYPE_CARVEOUT:
640 fixed_position = ((struct ion_co_heap_pdata *)
641 heap->extra_data)->fixed_position;
642 break;
643 default:
644 break;
645 }
646
647 switch (fixed_position) {
648 case FIXED_LOW:
649 heap->base = fixed_low_start;
650 break;
651 case FIXED_MIDDLE:
652 heap->base = fixed_middle_start;
Deepak Kotur35825522012-06-06 15:49:14 -0700653 pdata->secure_base = fixed_middle_start
654 - HOLE_SIZE;
655 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700656 break;
657 case FIXED_HIGH:
658 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800659 break;
660 default:
661 break;
662 }
663 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800664 }
Laura Abbottd6183792011-08-19 13:42:24 -0700665#endif
666}
Huaibin Yanga5419422011-12-08 23:52:10 -0800667
668static void __init reserve_mdp_memory(void)
669{
670 msm8960_mdp_writeback(msm8960_reserve_table);
671}
672
Stephen Boyd668d7652012-04-25 11:31:01 -0700673static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800674{
675#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbott306bcc22012-03-08 11:24:53 -0800676 unsigned int total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800677
Laura Abbott155ab6f2012-05-25 08:52:18 -0700678 total = msm8960_cache_dump_pdata.l1_size +
679 msm8960_cache_dump_pdata.l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800680 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800681#endif
682}
683
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700684static void __init msm8960_calculate_reserve_sizes(void)
685{
686 size_pmem_devices();
687 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700688 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800689 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800690 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800691 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692}
693
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700694static struct reserve_info msm8960_reserve_info __initdata = {
695 .memtype_reserve_table = msm8960_reserve_table,
696 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700697 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700698 .paddr_to_memtype = msm8960_paddr_to_memtype,
699};
700
Larry Basselb4126da2011-07-18 14:31:33 -0700701static int msm8960_memory_bank_size(void)
702{
703 return 1<<29;
704}
705
706static void __init locate_unstable_memory(void)
707{
708 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
709 unsigned long bank_size;
710 unsigned long low, high;
711
712 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700713 msm8960_reserve_info.bank_size = bank_size;
714
Larry Basselb4126da2011-07-18 14:31:33 -0700715 low = meminfo.bank[0].start;
716 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700717
718 /* Check if 32 bit overflow occured */
719 if (high < mb->start)
720 high = ~0UL;
721
Larry Bassel4d4f4482012-04-04 11:26:09 -0700722 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
723 panic("fixed area extends beyond end of memory\n");
724
Larry Basselb4126da2011-07-18 14:31:33 -0700725 low &= ~(bank_size - 1);
726
727 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700728 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800729
Larry Basselb8d61022012-02-24 10:49:45 -0800730#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800731 msm8960_reserve_info.low_unstable_address = mb->start -
732 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800733 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700734 pr_info("low unstable address %lx max size %lx bank size %lx\n",
735 msm8960_reserve_info.low_unstable_address,
736 msm8960_reserve_info.max_unstable_size,
737 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700738 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800739#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700740no_dmm:
741 msm8960_reserve_info.low_unstable_address = high;
742 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700743}
744
Larry Basselb830e182011-10-14 10:46:55 -0700745static void __init place_movable_zone(void)
746{
Larry Basselb8d61022012-02-24 10:49:45 -0800747#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700748 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
749 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
750 pr_info("movable zone start %lx size %lx\n",
751 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800752#endif
Larry Basselb830e182011-10-14 10:46:55 -0700753}
754
755static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700756{
757 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700758 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700759 place_movable_zone();
760}
761
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800762static char prim_panel_name[PANEL_NAME_MAX_LEN];
763static char ext_panel_name[PANEL_NAME_MAX_LEN];
764static int __init prim_display_setup(char *param)
765{
766 if (strnlen(param, PANEL_NAME_MAX_LEN))
767 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
768 return 0;
769}
770early_param("prim_display", prim_display_setup);
771
772static int __init ext_display_setup(char *param)
773{
774 if (strnlen(param, PANEL_NAME_MAX_LEN))
775 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
776 return 0;
777}
778early_param("ext_display", ext_display_setup);
779
Larry Basselb830e182011-10-14 10:46:55 -0700780static void __init msm8960_reserve(void)
781{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800782 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700783 msm_reserve();
784}
785
Larry Bassela4414b12011-08-04 11:11:02 -0700786static int msm8960_change_memory_power(u64 start, u64 size,
787 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700788{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700789 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700790}
791
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700792static void __init msm8960_allocate_memory_regions(void)
793{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800794 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700795}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800796
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700797#ifdef CONFIG_WCD9310_CODEC
798
799#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
800
Patrick Lai3043fba2011-08-01 14:15:57 -0700801/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
802 * 4 micbiases are used to power various analog and digital
803 * microphones operating at 1800 mV. Technically, all micbiases
804 * can source from single cfilter since all microphones operate
805 * at the same voltage level. The arrangement below is to make
806 * sure all cfilters are exercised. LDO_H regulator ouput level
807 * does not need to be as high as 2.85V. It is choosen for
808 * microphone sensitivity purpose.
809 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530810static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700811 .slimbus_slave_device = {
812 .name = "tabla-slave",
813 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
814 },
815 .irq = MSM_GPIO_TO_INT(62),
816 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530817 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700818 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700819 .micbias = {
820 .ldoh_v = TABLA_LDOH_2P85_V,
821 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700822 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700823 .cfilt3_mv = 1800,
824 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
825 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
826 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
827 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530828 },
829 .regulator = {
830 {
831 .name = "CDC_VDD_CP",
832 .min_uV = 1800000,
833 .max_uV = 1800000,
834 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
835 },
836 {
837 .name = "CDC_VDDA_RX",
838 .min_uV = 1800000,
839 .max_uV = 1800000,
840 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
841 },
842 {
843 .name = "CDC_VDDA_TX",
844 .min_uV = 1800000,
845 .max_uV = 1800000,
846 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
847 },
848 {
849 .name = "VDDIO_CDC",
850 .min_uV = 1800000,
851 .max_uV = 1800000,
852 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
853 },
854 {
855 .name = "VDDD_CDC_D",
856 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700857 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530858 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
859 },
860 {
861 .name = "CDC_VDDA_A_1P2V",
862 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700863 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530864 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
865 },
866 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700867};
868
869static struct slim_device msm_slim_tabla = {
870 .name = "tabla-slim",
871 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
872 .dev = {
873 .platform_data = &tabla_platform_data,
874 },
875};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530876
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530877static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530878 .slimbus_slave_device = {
879 .name = "tabla-slave",
880 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
881 },
882 .irq = MSM_GPIO_TO_INT(62),
883 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530884 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530885 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
886 .micbias = {
887 .ldoh_v = TABLA_LDOH_2P85_V,
888 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700889 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530890 .cfilt3_mv = 1800,
891 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
892 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
893 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
894 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530895 },
896 .regulator = {
897 {
898 .name = "CDC_VDD_CP",
899 .min_uV = 1800000,
900 .max_uV = 1800000,
901 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
902 },
903 {
904 .name = "CDC_VDDA_RX",
905 .min_uV = 1800000,
906 .max_uV = 1800000,
907 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
908 },
909 {
910 .name = "CDC_VDDA_TX",
911 .min_uV = 1800000,
912 .max_uV = 1800000,
913 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
914 },
915 {
916 .name = "VDDIO_CDC",
917 .min_uV = 1800000,
918 .max_uV = 1800000,
919 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
920 },
921 {
922 .name = "VDDD_CDC_D",
923 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700924 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530925 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
926 },
927 {
928 .name = "CDC_VDDA_A_1P2V",
929 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700930 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530931 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
932 },
933 },
Santosh Mardi60e19d92011-10-28 01:15:14 +0530934};
935
936static struct slim_device msm_slim_tabla20 = {
937 .name = "tabla2x-slim",
938 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
939 .dev = {
940 .platform_data = &tabla20_platform_data,
941 },
942};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700943#endif
944
945static struct slim_boardinfo msm_slim_devices[] = {
946#ifdef CONFIG_WCD9310_CODEC
947 {
948 .bus_num = 1,
949 .slim_slave = &msm_slim_tabla,
950 },
Santosh Mardi60e19d92011-10-28 01:15:14 +0530951 {
952 .bus_num = 1,
953 .slim_slave = &msm_slim_tabla20,
954 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700955#endif
956 /* add more slimbus slaves as needed */
957};
958
Yunsen Wang5c1a7392011-07-09 19:10:16 -0700959#define MSM_WCNSS_PHYS 0x03000000
960#define MSM_WCNSS_SIZE 0x280000
961
962static struct resource resources_wcnss_wlan[] = {
963 {
964 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
965 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
966 .name = "wcnss_wlanrx_irq",
967 .flags = IORESOURCE_IRQ,
968 },
969 {
970 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
971 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
972 .name = "wcnss_wlantx_irq",
973 .flags = IORESOURCE_IRQ,
974 },
975 {
976 .start = MSM_WCNSS_PHYS,
977 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
978 .name = "wcnss_mmio",
979 .flags = IORESOURCE_MEM,
980 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -0700981 {
982 .start = 84,
983 .end = 88,
984 .name = "wcnss_gpios_5wire",
985 .flags = IORESOURCE_IO,
986 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -0700987};
988
Ankur Nandwanib0039b02011-08-09 14:00:45 -0700989static struct qcom_wcnss_opts qcom_wcnss_pdata = {
990 .has_48mhz_xo = 1,
991};
992
Yunsen Wang5c1a7392011-07-09 19:10:16 -0700993static struct platform_device msm_device_wcnss_wlan = {
994 .name = "wcnss_wlan",
995 .id = 0,
996 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
997 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -0700998 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -0700999};
1000
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001001#ifdef CONFIG_QSEECOM
1002/* qseecom bus scaling */
1003static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1004 {
1005 .src = MSM_BUS_MASTER_SPS,
1006 .dst = MSM_BUS_SLAVE_EBI_CH0,
1007 .ib = 0,
1008 .ab = 0,
1009 },
1010 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001011 .src = MSM_BUS_MASTER_SPS,
1012 .dst = MSM_BUS_SLAVE_SPS,
1013 .ib = 0,
1014 .ab = 0,
1015 },
1016 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001017 .src = MSM_BUS_MASTER_SPDM,
1018 .dst = MSM_BUS_SLAVE_SPDM,
1019 .ib = 0,
1020 .ab = 0,
1021 },
1022};
1023
1024static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1025 {
1026 .src = MSM_BUS_MASTER_SPS,
1027 .dst = MSM_BUS_SLAVE_EBI_CH0,
1028 .ib = (492 * 8) * 1000000UL,
1029 .ab = (492 * 8) * 100000UL,
1030 },
1031 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001032 .src = MSM_BUS_MASTER_SPS,
1033 .dst = MSM_BUS_SLAVE_SPS,
1034 .ib = (492 * 8) * 1000000UL,
1035 .ab = (492 * 8) * 100000UL,
1036 },
1037 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001038 .src = MSM_BUS_MASTER_SPDM,
1039 .dst = MSM_BUS_SLAVE_SPDM,
1040 .ib = 0,
1041 .ab = 0,
1042 },
1043};
1044
1045static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1046 {
1047 .src = MSM_BUS_MASTER_SPS,
1048 .dst = MSM_BUS_SLAVE_EBI_CH0,
1049 .ib = 0,
1050 .ab = 0,
1051 },
1052 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001053 .src = MSM_BUS_MASTER_SPS,
1054 .dst = MSM_BUS_SLAVE_SPS,
1055 .ib = 0,
1056 .ab = 0,
1057 },
1058 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001059 .src = MSM_BUS_MASTER_SPDM,
1060 .dst = MSM_BUS_SLAVE_SPDM,
1061 .ib = (64 * 8) * 1000000UL,
1062 .ab = (64 * 8) * 100000UL,
1063 },
1064};
1065
Ramesh Masavarapu8d756582012-10-03 10:18:06 -07001066static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1067 {
1068 .src = MSM_BUS_MASTER_SPS,
1069 .dst = MSM_BUS_SLAVE_EBI_CH0,
1070 .ib = (492 * 8) * 1000000UL,
1071 .ab = (492 * 8) * 100000UL,
1072 },
1073 {
1074 .src = MSM_BUS_MASTER_SPS,
1075 .dst = MSM_BUS_SLAVE_SPS,
1076 .ib = (492 * 8) * 1000000UL,
1077 .ab = (492 * 8) * 100000UL,
1078 },
1079 {
1080 .src = MSM_BUS_MASTER_SPDM,
1081 .dst = MSM_BUS_SLAVE_SPDM,
1082 .ib = (64 * 8) * 1000000UL,
1083 .ab = (64 * 8) * 100000UL,
1084 },
1085};
1086
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001087static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1088 {
1089 ARRAY_SIZE(qseecom_clks_init_vectors),
1090 qseecom_clks_init_vectors,
1091 },
1092 {
1093 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001094 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001095 },
1096 {
1097 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1098 qseecom_enable_sfpb_vectors,
1099 },
Ramesh Masavarapu8d756582012-10-03 10:18:06 -07001100 {
1101 ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1102 qseecom_enable_dfab_sfpb_vectors,
1103 },
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001104};
1105
1106static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1107 qseecom_hw_bus_scale_usecases,
1108 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1109 .name = "qsee",
1110};
1111
1112static struct platform_device qseecom_device = {
1113 .name = "qseecom",
1114 .id = 0,
1115 .dev = {
1116 .platform_data = &qseecom_bus_pdata,
1117 },
1118};
1119#endif
1120
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001121#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1122 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1123 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1124 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1125
1126#define QCE_SIZE 0x10000
1127#define QCE_0_BASE 0x18500000
1128
1129#define QCE_HW_KEY_SUPPORT 0
1130#define QCE_SHA_HMAC_SUPPORT 1
1131#define QCE_SHARE_CE_RESOURCE 1
1132#define QCE_CE_SHARED 0
1133
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001134/* Begin Bus scaling definitions */
1135static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1136 {
1137 .src = MSM_BUS_MASTER_ADM_PORT0,
1138 .dst = MSM_BUS_SLAVE_EBI_CH0,
1139 .ab = 0,
1140 .ib = 0,
1141 },
1142 {
1143 .src = MSM_BUS_MASTER_ADM_PORT1,
1144 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1145 .ab = 0,
1146 .ib = 0,
1147 },
1148};
1149
1150static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1151 {
1152 .src = MSM_BUS_MASTER_ADM_PORT0,
1153 .dst = MSM_BUS_SLAVE_EBI_CH0,
1154 .ab = 70000000UL,
1155 .ib = 70000000UL,
1156 },
1157 {
1158 .src = MSM_BUS_MASTER_ADM_PORT1,
1159 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1160 .ab = 2480000000UL,
1161 .ib = 2480000000UL,
1162 },
1163};
1164
1165static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1166 {
1167 ARRAY_SIZE(crypto_hw_init_vectors),
1168 crypto_hw_init_vectors,
1169 },
1170 {
1171 ARRAY_SIZE(crypto_hw_active_vectors),
1172 crypto_hw_active_vectors,
1173 },
1174};
1175
1176static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1177 crypto_hw_bus_scale_usecases,
1178 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1179 .name = "cryptohw",
1180};
1181/* End Bus Scaling Definitions*/
1182
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001183static struct resource qcrypto_resources[] = {
1184 [0] = {
1185 .start = QCE_0_BASE,
1186 .end = QCE_0_BASE + QCE_SIZE - 1,
1187 .flags = IORESOURCE_MEM,
1188 },
1189 [1] = {
1190 .name = "crypto_channels",
1191 .start = DMOV_CE_IN_CHAN,
1192 .end = DMOV_CE_OUT_CHAN,
1193 .flags = IORESOURCE_DMA,
1194 },
1195 [2] = {
1196 .name = "crypto_crci_in",
1197 .start = DMOV_CE_IN_CRCI,
1198 .end = DMOV_CE_IN_CRCI,
1199 .flags = IORESOURCE_DMA,
1200 },
1201 [3] = {
1202 .name = "crypto_crci_out",
1203 .start = DMOV_CE_OUT_CRCI,
1204 .end = DMOV_CE_OUT_CRCI,
1205 .flags = IORESOURCE_DMA,
1206 },
1207};
1208
1209static struct resource qcedev_resources[] = {
1210 [0] = {
1211 .start = QCE_0_BASE,
1212 .end = QCE_0_BASE + QCE_SIZE - 1,
1213 .flags = IORESOURCE_MEM,
1214 },
1215 [1] = {
1216 .name = "crypto_channels",
1217 .start = DMOV_CE_IN_CHAN,
1218 .end = DMOV_CE_OUT_CHAN,
1219 .flags = IORESOURCE_DMA,
1220 },
1221 [2] = {
1222 .name = "crypto_crci_in",
1223 .start = DMOV_CE_IN_CRCI,
1224 .end = DMOV_CE_IN_CRCI,
1225 .flags = IORESOURCE_DMA,
1226 },
1227 [3] = {
1228 .name = "crypto_crci_out",
1229 .start = DMOV_CE_OUT_CRCI,
1230 .end = DMOV_CE_OUT_CRCI,
1231 .flags = IORESOURCE_DMA,
1232 },
1233};
1234
1235#endif
1236
1237#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1238 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1239
1240static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1241 .ce_shared = QCE_CE_SHARED,
1242 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1243 .hw_key_support = QCE_HW_KEY_SUPPORT,
1244 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001245 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001246};
1247
1248static struct platform_device qcrypto_device = {
1249 .name = "qcrypto",
1250 .id = 0,
1251 .num_resources = ARRAY_SIZE(qcrypto_resources),
1252 .resource = qcrypto_resources,
1253 .dev = {
1254 .coherent_dma_mask = DMA_BIT_MASK(32),
1255 .platform_data = &qcrypto_ce_hw_suppport,
1256 },
1257};
1258#endif
1259
1260#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1261 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1262
1263static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1264 .ce_shared = QCE_CE_SHARED,
1265 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1266 .hw_key_support = QCE_HW_KEY_SUPPORT,
1267 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001268 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001269};
1270
1271static struct platform_device qcedev_device = {
1272 .name = "qce",
1273 .id = 0,
1274 .num_resources = ARRAY_SIZE(qcedev_resources),
1275 .resource = qcedev_resources,
1276 .dev = {
1277 .coherent_dma_mask = DMA_BIT_MASK(32),
1278 .platform_data = &qcedev_ce_hw_suppport,
1279 },
1280};
1281#endif
1282
Joel King0cbf5d82012-05-24 15:21:38 -07001283static struct mdm_platform_data sglte_platform_data = {
1284 .mdm_version = "4.0",
1285 .ramdump_delay_ms = 1000,
Joel King63ce8332012-06-01 09:59:26 -07001286 .soft_reset_inverted = 1,
Joel King0cbf5d82012-05-24 15:21:38 -07001287 .peripheral_platform_device = NULL,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001288 .ramdump_timeout_ms = 600000,
Ameya Thakura98bde52012-06-28 18:55:19 -07001289 .no_powerdown_after_ramdumps = 1,
Ameya Thakur43248fd2012-07-10 18:50:52 -07001290 .image_upgrade_supported = 1,
Joel Kingb8352a12011-11-15 18:46:24 -08001291};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001292
Joel Nider266a2642011-10-16 10:58:05 +02001293#define MSM_TSIF0_PHYS (0x18200000)
1294#define MSM_TSIF1_PHYS (0x18201000)
1295#define MSM_TSIF_SIZE (0x200)
1296#define MSM_TSPP_PHYS (0x18202000)
1297#define MSM_TSPP_SIZE (0x1000)
1298#define MSM_TSPP_BAM_PHYS (0x18204000)
1299#define MSM_TSPP_BAM_SIZE (0x2000)
1300
1301#define TSIF_0_CLK GPIO_CFG(75, 1, GPIO_CFG_INPUT, \
1302 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1303#define TSIF_0_EN GPIO_CFG(76, 1, GPIO_CFG_INPUT, \
1304 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1305#define TSIF_0_DATA GPIO_CFG(77, 1, GPIO_CFG_INPUT, \
1306 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1307#define TSIF_0_SYNC GPIO_CFG(82, 1, GPIO_CFG_INPUT, \
1308 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1309#define TSIF_1_CLK GPIO_CFG(79, 1, GPIO_CFG_INPUT, \
1310 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1311#define TSIF_1_EN GPIO_CFG(80, 1, GPIO_CFG_INPUT, \
1312 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1313#define TSIF_1_DATA GPIO_CFG(81, 1, GPIO_CFG_INPUT, \
1314 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1315#define TSIF_1_SYNC GPIO_CFG(78, 1, GPIO_CFG_INPUT, \
1316 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1317
1318static const struct msm_gpio tsif_gpios[] = {
1319 { .gpio_cfg = TSIF_0_CLK, .label = "tsif0_clk", },
1320 { .gpio_cfg = TSIF_0_EN, .label = "tsif0_en", },
1321 { .gpio_cfg = TSIF_0_DATA, .label = "tsif0_data", },
1322 { .gpio_cfg = TSIF_0_SYNC, .label = "tsif0_sync", },
1323 { .gpio_cfg = TSIF_1_CLK, .label = "tsif1_clk", },
1324 { .gpio_cfg = TSIF_1_EN, .label = "tsif1_en", },
1325 { .gpio_cfg = TSIF_1_DATA, .label = "tsif1_data", },
1326 { .gpio_cfg = TSIF_1_SYNC, .label = "tsif1_sync", },
1327};
1328
1329static struct resource tspp_resources[] = {
1330 [0] = {
1331 .flags = IORESOURCE_IRQ,
1332 .start = TSIF_TSPP_IRQ,
1333 .end = TSIF1_IRQ,
1334 },
1335 [1] = {
1336 .flags = IORESOURCE_MEM,
1337 .start = MSM_TSIF0_PHYS,
1338 .end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
1339 },
1340 [2] = {
1341 .flags = IORESOURCE_MEM,
1342 .start = MSM_TSIF1_PHYS,
1343 .end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
1344 },
1345 [3] = {
1346 .flags = IORESOURCE_MEM,
1347 .start = MSM_TSPP_PHYS,
1348 .end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
1349 },
1350 [4] = {
1351 .flags = IORESOURCE_MEM,
1352 .start = MSM_TSPP_BAM_PHYS,
1353 .end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
1354 },
1355};
1356
1357static struct msm_tspp_platform_data tspp_platform_data = {
1358 .num_gpios = ARRAY_SIZE(tsif_gpios),
1359 .gpios = tsif_gpios,
1360 .tsif_pclk = "tsif_pclk",
1361 .tsif_ref_clk = "tsif_ref_clk",
1362};
1363
1364static struct platform_device msm_device_tspp = {
1365 .name = "msm_tspp",
1366 .id = 0,
1367 .num_resources = ARRAY_SIZE(tspp_resources),
1368 .resource = tspp_resources,
1369 .dev = {
1370 .platform_data = &tspp_platform_data
1371 },
1372};
1373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001374#define MSM_SHARED_RAM_PHYS 0x80000000
1375
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001376static void __init msm8960_map_io(void)
1377{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001378 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001379 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001380
1381 if (socinfo_init() < 0)
1382 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001383}
1384
1385static void __init msm8960_init_irq(void)
1386{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001387 struct msm_mpm_device_data *data = NULL;
1388
1389#ifdef CONFIG_MSM_MPM
1390 data = &msm8960_mpm_dev_data;
1391#endif
1392
1393 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001394 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001395 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001396}
1397
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001398static void __init msm8960_init_buses(void)
1399{
1400#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001401 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001402 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1403 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
Gagan Macae154c4b2011-10-05 19:24:43 -06001404 msm_bus_apps_fabric.dev.platform_data =
1405 &msm_bus_8960_apps_fabric_pdata;
1406 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
Gagan Mac680bfc02012-07-19 19:11:00 -06001407 if (cpu_is_msm8960ab()) {
1408 msm_bus_8960_sg_mm_fabric_pdata.rpm_enabled = 1;
1409 msm_bus_mm_fabric.dev.platform_data =
1410 &msm_bus_8960_sg_mm_fabric_pdata;
1411 } else {
1412 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1413 msm_bus_mm_fabric.dev.platform_data =
1414 &msm_bus_8960_mm_fabric_pdata;
1415 }
Gagan Macae154c4b2011-10-05 19:24:43 -06001416 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1417 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001418#endif
1419}
1420
1421static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1422 .max_clock_speed = 15060000,
Kiran Gundac5fbd7f2012-07-30 13:22:39 +05301423 .infinite_mode = 0xFFC0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001424};
1425
1426#ifdef CONFIG_USB_MSM_OTG_72K
1427static struct msm_otg_platform_data msm_otg_pdata;
1428#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301429static int wr_phy_init_seq[] = {
1430 0x44, 0x80, /* set VBUS valid threshold
1431 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301432 0x68, 0x81, /* update DC voltage level */
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301433 0x14, 0x82, /* set preemphasis and rise/fall time */
1434 0x13, 0x83, /* set source impedance adjusment */
1435 -1};
1436
1437static int liquid_v1_phy_init_seq[] = {
1438 0x44, 0x80,/* set VBUS valid threshold
1439 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301440 0x6C, 0x81,/* update DC voltage level */
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301441 0x18, 0x82,/* set preemphasis and rise/fall time */
1442 0x23, 0x83,/* set source impedance sdjusment */
1443 -1};
1444
Mayank Ranaa61da7a2012-08-14 10:57:00 +05301445static int sglte_phy_init_seq[] = {
1446 0x44, 0x80, /* set VBUS valid threshold
1447 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301448 0x6A, 0x81, /* update DC voltage level */
Mayank Ranaa61da7a2012-08-14 10:57:00 +05301449 0x24, 0x82, /* set preemphasis and rise/fall time */
1450 0x13, 0x83, /* set source impedance adjusment */
1451 -1};
1452
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301453#ifdef CONFIG_MSM_BUS_SCALING
1454/* Bandwidth requests (zero) if no vote placed */
1455static struct msm_bus_vectors usb_init_vectors[] = {
1456 {
1457 .src = MSM_BUS_MASTER_SPS,
1458 .dst = MSM_BUS_SLAVE_EBI_CH0,
1459 .ab = 0,
1460 .ib = 0,
1461 },
1462};
1463
1464/* Bus bandwidth requests in Bytes/sec */
1465static struct msm_bus_vectors usb_max_vectors[] = {
1466 {
1467 .src = MSM_BUS_MASTER_SPS,
1468 .dst = MSM_BUS_SLAVE_EBI_CH0,
1469 .ab = 60000000, /* At least 480Mbps on bus. */
1470 .ib = 960000000, /* MAX bursts rate */
1471 },
1472};
1473
1474static struct msm_bus_paths usb_bus_scale_usecases[] = {
1475 {
1476 ARRAY_SIZE(usb_init_vectors),
1477 usb_init_vectors,
1478 },
1479 {
1480 ARRAY_SIZE(usb_max_vectors),
1481 usb_max_vectors,
1482 },
1483};
1484
1485static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1486 usb_bus_scale_usecases,
1487 ARRAY_SIZE(usb_bus_scale_usecases),
1488 .name = "usb",
1489};
1490#endif
1491
Jack Pham87f202f2012-08-06 00:24:22 -07001492#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
1493
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001494static struct msm_otg_platform_data msm_otg_pdata = {
1495 .mode = USB_OTG,
1496 .otg_control = OTG_PMIC_CONTROL,
1497 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001498 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301499 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301500#ifdef CONFIG_MSM_BUS_SCALING
1501 .bus_scale_table = &usb_bus_scale_pdata,
Jack Pham87f202f2012-08-06 00:24:22 -07001502 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301503#endif
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +05301504#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
1505 .mhl_dev_name = "sii8334",
1506#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001507};
1508#endif
1509
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301510#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301511#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301512static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1513 .strobe = 150,
1514 .data = 151,
1515};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301516
1517static struct smsc_hub_platform_data hsic_hub_pdata = {
1518 .hub_reset = HSIC_HUB_RESET_GPIO,
1519};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301520#else
1521static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301522static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301523#endif
1524
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301525static struct platform_device smsc_hub_device = {
1526 .name = "msm_smsc_hub",
1527 .id = -1,
1528 .dev = {
1529 .platform_data = &hsic_hub_pdata,
1530 },
1531};
1532
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001533#define PID_MAGIC_ID 0x71432909
1534#define SERIAL_NUM_MAGIC_ID 0x61945374
1535#define SERIAL_NUMBER_LENGTH 127
1536#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1537
1538struct magic_num_struct {
1539 uint32_t pid;
1540 uint32_t serial_num;
1541};
1542
1543struct dload_struct {
1544 uint32_t reserved1;
1545 uint32_t reserved2;
1546 uint32_t reserved3;
1547 uint16_t reserved4;
1548 uint16_t pid;
1549 char serial_number[SERIAL_NUMBER_LENGTH];
1550 uint16_t reserved5;
1551 struct magic_num_struct magic_struct;
1552};
1553
1554static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1555{
1556 struct dload_struct __iomem *dload = 0;
1557
1558 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1559 if (!dload) {
1560 pr_err("%s: cannot remap I/O memory region: %08x\n",
1561 __func__, DLOAD_USB_BASE_ADD);
1562 return -ENXIO;
1563 }
1564
1565 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1566 __func__, dload, pid, snum);
1567 /* update pid */
1568 dload->magic_struct.pid = PID_MAGIC_ID;
1569 dload->pid = pid;
1570
1571 /* update serial number */
1572 dload->magic_struct.serial_num = 0;
1573 if (!snum) {
1574 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1575 goto out;
1576 }
1577
1578 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001579 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001580out:
1581 iounmap(dload);
1582 return 0;
1583}
1584
1585static struct android_usb_platform_data android_usb_pdata = {
1586 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1587};
1588
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001589static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001590 .name = "android_usb",
1591 .id = -1,
1592 .dev = {
1593 .platform_data = &android_usb_pdata,
1594 },
1595};
1596
1597static uint8_t spm_wfi_cmd_sequence[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001598 0x03, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001599};
1600
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001601static uint8_t spm_retention_cmd_sequence[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001602 0x00, 0x05, 0x03, 0x0D,
1603 0x0B, 0x00, 0x0f,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001604};
1605
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001606static uint8_t spm_power_collapse_without_rpm[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001607 0x00, 0x24, 0x54, 0x10,
1608 0x09, 0x03, 0x01,
1609 0x10, 0x54, 0x30, 0x0C,
1610 0x24, 0x30, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001611};
1612
1613static uint8_t spm_power_collapse_with_rpm[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001614 0x00, 0x24, 0x54, 0x10,
1615 0x09, 0x07, 0x01, 0x0B,
1616 0x10, 0x54, 0x30, 0x0C,
1617 0x24, 0x30, 0x0f,
1618};
1619
1620/* 8960AB has a different command to assert apc_pdn */
1621static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
1622 0x00, 0x24, 0x84, 0x10,
1623 0x09, 0x03, 0x01,
1624 0x10, 0x84, 0x30, 0x0C,
1625 0x24, 0x30, 0x0f,
1626};
1627
1628static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
1629 0x00, 0x24, 0x84, 0x10,
1630 0x09, 0x07, 0x01, 0x0B,
1631 0x10, 0x84, 0x30, 0x0C,
1632 0x24, 0x30, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001633};
1634
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001635static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1636 [0] = {
1637 .mode = MSM_SPM_MODE_CLOCK_GATING,
1638 .notify_rpm = false,
1639 .cmd = spm_wfi_cmd_sequence,
1640 },
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001641 [1] = {
1642 .mode = MSM_SPM_MODE_POWER_RETENTION,
1643 .notify_rpm = false,
1644 .cmd = spm_retention_cmd_sequence,
1645 },
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001646 [2] = {
1647 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1648 .notify_rpm = false,
1649 .cmd = spm_power_collapse_without_rpm,
1650 },
1651 [3] = {
1652 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1653 .notify_rpm = true,
1654 .cmd = spm_power_collapse_with_rpm,
1655 },
1656};
1657
1658static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001659 [0] = {
1660 .mode = MSM_SPM_MODE_CLOCK_GATING,
1661 .notify_rpm = false,
1662 .cmd = spm_wfi_cmd_sequence,
1663 },
1664 [1] = {
1665 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1666 .notify_rpm = false,
1667 .cmd = spm_power_collapse_without_rpm,
1668 },
1669 [2] = {
1670 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1671 .notify_rpm = true,
1672 .cmd = spm_power_collapse_with_rpm,
1673 },
1674};
1675
1676static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1677 [0] = {
1678 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001679 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001680#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnala39dd7252012-11-26 15:56:26 +05301681 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaram631f2822012-03-16 12:08:42 -06001682 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001683#endif
1684 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001685 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1686 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1687 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001688 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001689 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1690 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001691 },
1692 [1] = {
1693 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001694 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001695#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnala39dd7252012-11-26 15:56:26 +05301696 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaram631f2822012-03-16 12:08:42 -06001697 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001698#endif
1699 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001700 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001701 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1702 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1703 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001704 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1705 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001706 },
1707};
1708
1709static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1710 0x00, 0x20, 0x03, 0x20,
1711 0x00, 0x0f,
1712};
1713
1714static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1715 0x00, 0x20, 0x34, 0x64,
1716 0x48, 0x07, 0x48, 0x20,
1717 0x50, 0x64, 0x04, 0x34,
1718 0x50, 0x0f,
1719};
1720static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1721 0x00, 0x10, 0x34, 0x64,
1722 0x48, 0x07, 0x48, 0x10,
1723 0x50, 0x64, 0x04, 0x34,
1724 0x50, 0x0F,
1725};
1726
1727static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1728 [0] = {
1729 .mode = MSM_SPM_L2_MODE_RETENTION,
1730 .notify_rpm = false,
1731 .cmd = l2_spm_wfi_cmd_sequence,
1732 },
1733 [1] = {
1734 .mode = MSM_SPM_L2_MODE_GDHS,
1735 .notify_rpm = true,
1736 .cmd = l2_spm_gdhs_cmd_sequence,
1737 },
1738 [2] = {
1739 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1740 .notify_rpm = true,
1741 .cmd = l2_spm_power_off_cmd_sequence,
1742 },
1743};
1744
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001745static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1746 [0] = {
1747 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001748 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001749 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001750 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1751 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1752 .modes = msm_spm_l2_seq_list,
1753 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1754 },
1755};
1756
Anirudh Ghayal15698162012-07-31 11:51:32 +05301757#define HAP_SHIFT_LVL_OE_GPIO 47
1758#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301759#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1760#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1761
1762static struct msm_xo_voter *xo_handle_d1;
1763
1764static int isa1200_power(int on)
1765{
1766 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301767 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301768
Anirudh Ghayal15698162012-07-31 11:51:32 +05301769 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1770 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1771
1772
1773 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301774
1775 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1776 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1777 if (rc < 0) {
1778 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1779 __func__, on ? "" : "de-", rc);
1780 goto err_xo_vote;
1781 }
1782
1783 return 0;
1784
1785err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301786 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301787 return rc;
1788}
1789
1790static int isa1200_dev_setup(bool enable)
1791{
1792 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301793 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301794
1795 struct pm_gpio hap_gpio_config = {
1796 .direction = PM_GPIO_DIR_OUT,
1797 .pull = PM_GPIO_PULL_NO,
1798 .out_strength = PM_GPIO_STRENGTH_HIGH,
1799 .function = PM_GPIO_FUNC_NORMAL,
1800 .inv_int_pol = 0,
1801 .vin_sel = 2,
1802 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1803 .output_value = 0,
1804 };
1805
Anirudh Ghayal15698162012-07-31 11:51:32 +05301806 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1807 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1808
Mohan Pallaka5e490392011-09-09 15:18:41 +05301809 if (enable == true) {
1810 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1811 if (rc) {
1812 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1813 __func__, PM_HAP_EN_GPIO, rc);
1814 return rc;
1815 }
1816
1817 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1818 if (rc) {
1819 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1820 __func__, PM_HAP_LEN_GPIO, rc);
1821 return rc;
1822 }
1823
Anirudh Ghayal15698162012-07-31 11:51:32 +05301824 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301825 if (rc) {
1826 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301827 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301828 return rc;
1829 }
1830
Anirudh Ghayal15698162012-07-31 11:51:32 +05301831 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301832 if (rc) {
1833 pr_err("%s: Unable to set direction\n", __func__);
1834 goto free_gpio;
1835 }
1836
1837 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1838 if (IS_ERR(xo_handle_d1)) {
1839 rc = PTR_ERR(xo_handle_d1);
1840 pr_err("%s: failed to get the handle for D1(%d)\n",
1841 __func__, rc);
1842 goto gpio_set_dir;
1843 }
1844 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05301845 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301846
1847 msm_xo_put(xo_handle_d1);
1848 }
1849
1850 return 0;
1851
1852gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301853 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301854free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301855 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301856 return rc;
1857}
1858
1859static struct isa1200_regulator isa1200_reg_data[] = {
1860 {
1861 .name = "vcc_i2c",
1862 .min_uV = ISA_I2C_VTG_MIN_UV,
1863 .max_uV = ISA_I2C_VTG_MAX_UV,
1864 .load_uA = ISA_I2C_CURR_UA,
1865 },
1866};
1867
1868static struct isa1200_platform_data isa1200_1_pdata = {
1869 .name = "vibrator",
1870 .dev_setup = isa1200_dev_setup,
1871 .power_on = isa1200_power,
1872 .hap_en_gpio = PM_HAP_EN_GPIO,
1873 .hap_len_gpio = PM_HAP_LEN_GPIO,
1874 .max_timeout = 15000,
1875 .mode_ctrl = PWM_GEN_MODE,
1876 .pwm_fd = {
1877 .pwm_div = 256,
1878 },
1879 .is_erm = false,
1880 .smart_en = true,
1881 .ext_clk_en = true,
1882 .chip_en = 1,
1883 .regulator_info = isa1200_reg_data,
1884 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1885};
1886
1887static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1888 {
1889 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05301890 },
1891};
1892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893#define CYTTSP_TS_GPIO_IRQ 11
1894#define CYTTSP_TS_SLEEP_GPIO 50
1895#define CYTTSP_TS_RESOUT_N_GPIO 52
1896
1897/*virtual key support */
1898static ssize_t tma340_vkeys_show(struct kobject *kobj,
1899 struct kobj_attribute *attr, char *buf)
1900{
1901 return snprintf(buf, 200,
1902 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1903 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1904 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1905 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1906 "\n");
1907}
1908
1909static struct kobj_attribute tma340_vkeys_attr = {
1910 .attr = {
1911 .mode = S_IRUGO,
1912 },
1913 .show = &tma340_vkeys_show,
1914};
1915
1916static struct attribute *tma340_properties_attrs[] = {
1917 &tma340_vkeys_attr.attr,
1918 NULL
1919};
1920
1921static struct attribute_group tma340_properties_attr_group = {
1922 .attrs = tma340_properties_attrs,
1923};
1924
1925
1926static int cyttsp_platform_init(struct i2c_client *client)
1927{
1928 int rc = 0;
1929 static struct kobject *tma340_properties_kobj;
1930
1931 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1932 tma340_properties_kobj = kobject_create_and_add("board_properties",
1933 NULL);
1934 if (tma340_properties_kobj)
1935 rc = sysfs_create_group(tma340_properties_kobj,
1936 &tma340_properties_attr_group);
1937 if (!tma340_properties_kobj || rc)
1938 pr_err("%s: failed to create board_properties\n",
1939 __func__);
1940
1941 return 0;
1942}
1943
1944static struct cyttsp_regulator regulator_data[] = {
1945 {
1946 .name = "vdd",
1947 .min_uV = CY_TMA300_VTG_MIN_UV,
1948 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05301949 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1950 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001951 },
1952 /* TODO: Remove after runtime PM is enabled in I2C driver */
1953 {
1954 .name = "vcc_i2c",
1955 .min_uV = CY_I2C_VTG_MIN_UV,
1956 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05301957 .hpm_load_uA = CY_I2C_CURR_UA,
1958 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001959 },
1960};
1961
1962static struct cyttsp_platform_data cyttsp_pdata = {
1963 .panel_maxx = 634,
1964 .panel_maxy = 1166,
1965 .disp_maxx = 616,
1966 .disp_maxy = 1023,
1967 .disp_minx = 0,
1968 .disp_miny = 16,
1969 .flags = 0x01,
1970 .gen = CY_GEN3, /* or */
1971 .use_st = CY_USE_ST,
1972 .use_mt = CY_USE_MT,
1973 .use_hndshk = CY_SEND_HNDSHK,
1974 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05301975 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001976 .use_gestures = CY_USE_GESTURES,
1977 .fw_fname = "cyttsp_8960_cdp.hex",
1978 /* activate up to 4 groups
1979 * and set active distance
1980 */
1981 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
1982 CY_GEST_GRP3 | CY_GEST_GRP4 |
1983 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07001984 .act_intrvl = 10,
1985 .tch_tmout = 200,
1986 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001987 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
1988 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
1989 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1990 .regulator_info = regulator_data,
1991 .num_regulators = ARRAY_SIZE(regulator_data),
1992 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05301993 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001994};
1995
1996static struct i2c_board_info cyttsp_info[] __initdata = {
1997 {
1998 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1999 .platform_data = &cyttsp_pdata,
2000#ifndef CY_USE_TIMER
2001 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2002#endif /* CY_USE_TIMER */
2003 },
2004};
2005
Jing Lindc4413c2012-01-16 15:22:52 -08002006/* configuration data for mxt1386 */
2007static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302008 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002009 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302010 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002011 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002012 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2013 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2014 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2015 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2016 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2017 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302018 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002019 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302020 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002021 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302022 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002023 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2024 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2025 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2026 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302027 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2029 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302030 /* T18 Object */
2031 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302032 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002033 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2034 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302035 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002036 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2037 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302038 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002039 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2040 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302041 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002042 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302043 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002044 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302045 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002046 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302047 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002048 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302049 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002050 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302051};
2052
Jing Lin33b007d2011-12-21 17:40:23 -08002053/* configuration data for mxt1386e using V1.0 firmware */
2054static const u8 mxt1386e_config_data_v1_0[] = {
2055 /* T6 Object */
2056 0, 0, 0, 0, 0, 0,
2057 /* T38 Object */
2058 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2059 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2060 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2061 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2062 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2063 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2064 0, 0, 0, 0,
2065 /* T7 Object */
2066 100, 16, 50,
2067 /* T8 Object */
2068 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2069 /* T9 Object */
2070 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2071 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2072 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2073 10, 5, 0, 0, 0,
2074 /* T18 Object */
2075 0, 0,
2076 /* T24 Object */
2077 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2078 0, 0, 0, 0, 0, 0, 0, 0, 0,
2079 /* T25 Object */
2080 3, 0, 60, 115, 156, 99,
2081 /* T27 Object */
2082 0, 0, 0, 0, 0, 0, 0,
2083 /* T40 Object */
2084 0, 0, 0, 0, 0,
2085 /* T42 Object */
2086 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2087 /* T43 Object */
2088 0, 0, 0, 0, 0, 0, 0,
2089 /* T46 Object */
2090 64, 0, 20, 20, 0, 0, 0, 0, 0,
2091 /* T47 Object */
2092 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2093 /* T48 Object */
2094 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2095 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2096 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2097 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2098 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2099 0, 0, 0, 0,
2100 /* T56 Object */
2101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2105 2, 99, 33,
2106};
2107
2108/* configuration data for mxt1386e using V2.1 firmware */
2109static const u8 mxt1386e_config_data_v2_1[] = {
2110 /* T6 Object */
2111 0, 0, 0, 0, 0, 0,
2112 /* T38 Object */
Jing Lin4a8a3e42012-09-12 10:08:22 -07002113 12, 5, 0, 28, 8, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2119 0, 0, 0, 0,
2120 /* T7 Object */
Jing Lin4a8a3e42012-09-12 10:08:22 -07002121 32, 16, 50,
Jing Lin33b007d2011-12-21 17:40:23 -08002122 /* T8 Object */
2123 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2124 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002125 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002126 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002127 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2128 10, 5, 0, 0, 0,
2129 /* T18 Object */
2130 0, 0,
2131 /* T24 Object */
2132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2133 0, 0, 0, 0, 0, 0, 0, 0, 0,
2134 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002135 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002136 /* T27 Object */
2137 0, 0, 0, 0, 0, 0, 0,
2138 /* T40 Object */
2139 0, 0, 0, 0, 0,
2140 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002141 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002142 /* T43 Object */
2143 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2144 16,
2145 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002146 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002147 /* T47 Object */
2148 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2149 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002150 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002151 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2152 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2153 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2155 0, 0, 0, 0,
2156 /* T56 Object */
2157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2158 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2161 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2162 255,
2163};
2164
Jing Lineec88ca2012-02-08 11:18:30 -08002165/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2166static const u8 mxt1386e_config_data_3d[] = {
2167 /* T6 Object */
2168 0, 0, 0, 0, 0, 0,
2169 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002170 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2176 0, 0, 0, 0,
2177 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002178 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002179 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002180 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002181 /* T9 Object */
2182 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2183 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002184 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2185 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002186 /* T18 Object */
2187 0, 0,
2188 /* T24 Object */
2189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2190 0, 0, 0, 0, 0, 0, 0, 0, 0,
2191 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002192 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002193 /* T27 Object */
2194 0, 0, 0, 0, 0, 0, 0,
2195 /* T40 Object */
2196 0, 0, 0, 0, 0,
2197 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002198 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002199 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002200 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2201 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002202 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002203 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002204 /* T47 Object */
2205 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2206 /* T48 Object */
2207 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002208 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2209 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2210 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2212 0, 0, 0, 0,
2213 /* T56 Object */
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, 0, 0, 0, 0, 0, 0,
2217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002218 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2219 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002220};
2221
Amy Maloche08266db2011-11-04 11:07:16 -07002222#define MXT_TS_GPIO_IRQ 11
2223#define MXT_TS_LDO_EN_GPIO 50
2224#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302225
2226static void mxt_init_hw_liquid(void)
2227{
2228 int rc;
2229
Mohan Pallaka50837382011-09-07 11:00:57 +05302230 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2231 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002232 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2233 __func__, MXT_TS_LDO_EN_GPIO);
2234 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302235 }
2236
2237 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2238 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002239 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2240 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302241 goto err_ldo_gpio_req;
2242 }
2243
Mohan Pallaka50837382011-09-07 11:00:57 +05302244 return;
2245
Mohan Pallaka50837382011-09-07 11:00:57 +05302246err_ldo_gpio_req:
2247 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302248}
2249
Jing Lineec88ca2012-02-08 11:18:30 -08002250static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002251 {
2252 .config = mxt1386_config_data,
2253 .config_length = ARRAY_SIZE(mxt1386_config_data),
2254 .family_id = 0xA0,
2255 .variant_id = 0x0,
2256 .version = 0x10,
2257 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002258 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002259 },
Jing Lin33b007d2011-12-21 17:40:23 -08002260 {
2261 .config = mxt1386e_config_data_v1_0,
2262 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2263 .family_id = 0xA0,
2264 .variant_id = 0x2,
2265 .version = 0x10,
2266 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002267 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002268 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002269 },
2270 {
2271 .config = mxt1386e_config_data_v2_1,
2272 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2273 .family_id = 0xA0,
2274 .variant_id = 0x7,
2275 .version = 0x21,
2276 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002277 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002278 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2279 },
2280 {
2281 /* The config data for V2.2.AA is the same as for V2.1.AA */
2282 .config = mxt1386e_config_data_v2_1,
2283 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2284 .family_id = 0xA0,
2285 .variant_id = 0x7,
2286 .version = 0x22,
2287 .build = 0xAA,
2288 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002289 },
Jing Lindc4413c2012-01-16 15:22:52 -08002290};
2291
Jing Lineec88ca2012-02-08 11:18:30 -08002292static struct mxt_platform_data mxt_platform_data_2d = {
2293 .config_array = mxt_config_array_2d,
2294 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002295 .panel_minx = 0,
2296 .panel_maxx = 1365,
2297 .panel_miny = 0,
2298 .panel_maxy = 767,
2299 .disp_minx = 0,
2300 .disp_maxx = 1365,
2301 .disp_miny = 0,
2302 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302303 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002304 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002305 .reset_gpio = MXT_TS_RESET_GPIO,
2306 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302307};
2308
Jing Lineec88ca2012-02-08 11:18:30 -08002309static struct mxt_config_info mxt_config_array_3d[] = {
2310 {
2311 .config = mxt1386e_config_data_3d,
2312 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2313 .family_id = 0xA0,
2314 .variant_id = 0x7,
2315 .version = 0x21,
2316 .build = 0xAA,
2317 },
2318};
2319
2320static struct mxt_platform_data mxt_platform_data_3d = {
2321 .config_array = mxt_config_array_3d,
2322 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002323 .panel_minx = 0,
2324 .panel_maxx = 1919,
2325 .panel_miny = 0,
2326 .panel_maxy = 1199,
2327 .disp_minx = 0,
2328 .disp_maxx = 1919,
2329 .disp_miny = 0,
2330 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002331 .irqflags = IRQF_TRIGGER_FALLING,
2332 .i2c_pull_up = true,
2333 .reset_gpio = MXT_TS_RESET_GPIO,
2334 .irq_gpio = MXT_TS_GPIO_IRQ,
2335};
2336
Mohan Pallaka50837382011-09-07 11:00:57 +05302337static struct i2c_board_info mxt_device_info[] __initdata = {
2338 {
2339 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302340 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2341 },
2342};
2343
Manoj Rao14648742012-03-30 19:42:12 -07002344static struct msm_mhl_platform_data mhl_platform_data = {
2345 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002346 .gpio_mhl_int = MHL_GPIO_INT,
2347 .gpio_mhl_reset = MHL_GPIO_RESET,
2348 .gpio_mhl_power = 0,
2349 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002350};
Manoj Rao14648742012-03-30 19:42:12 -07002351
Eugene Yasmand2316b82011-12-07 18:23:48 +02002352static struct i2c_board_info sii_device_info[] __initdata = {
2353 {
Manoj Rao14648742012-03-30 19:42:12 -07002354#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2355 /*
2356 * keeps SI 8334 as the default
2357 * MHL TX
2358 */
2359 I2C_BOARD_INFO("sii8334", 0x39),
2360 .platform_data = &mhl_platform_data,
2361#endif
2362#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002363 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002364 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002365#endif /* CONFIG_MSM_HDMI_MHL */
2366 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002367 },
2368};
2369
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002370static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2371 .clk_freq = 100000,
2372 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002373};
2374
2375static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2376 .clk_freq = 100000,
2377 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002378};
2379
2380static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2381 .clk_freq = 100000,
2382 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002383};
2384
2385static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2386 .clk_freq = 100000,
2387 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002388};
2389
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002390static struct ks8851_pdata spi_eth_pdata = {
2391 .irq_gpio = KS8851_IRQ_GPIO,
2392 .rst_gpio = KS8851_RST_GPIO,
2393};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002394
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302395static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002396 {
2397 .modalias = "ks8851",
2398 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2399 .max_speed_hz = 19200000,
2400 .bus_num = 0,
2401 .chip_select = 0,
2402 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002403 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002404 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302405};
2406static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002407 {
2408 .modalias = "dsi_novatek_3d_panel_spi",
2409 .max_speed_hz = 10800000,
2410 .bus_num = 0,
2411 .chip_select = 1,
2412 .mode = SPI_MODE_0,
2413 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002414};
2415
2416static struct platform_device msm_device_saw_core0 = {
2417 .name = "saw-regulator",
2418 .id = 0,
2419 .dev = {
2420 .platform_data = &msm_saw_regulator_pdata_s5,
2421 },
2422};
2423
2424static struct platform_device msm_device_saw_core1 = {
2425 .name = "saw-regulator",
2426 .id = 1,
2427 .dev = {
2428 .platform_data = &msm_saw_regulator_pdata_s6,
2429 },
2430};
2431
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002432static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002433 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002434 .tsens_factor = 1000,
2435 .hw_type = MSM_8960,
2436 .tsens_num_sensor = 5,
2437};
2438
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002439static struct platform_device msm_tsens_device = {
2440 .name = "tsens8960-tm",
2441 .id = -1,
2442};
2443
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002444static struct msm_thermal_data msm_thermal_pdata = {
2445 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002446 .poll_ms = 250,
2447 .limit_temp_degC = 60,
2448 .temp_hysteresis_degC = 10,
2449 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002450};
2451
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002452#ifdef CONFIG_MSM_FAKE_BATTERY
2453static struct platform_device fish_battery_device = {
2454 .name = "fish_battery",
2455};
2456#endif
2457
Binqiang Qiuf165c922012-08-15 18:00:18 -07002458#ifdef CONFIG_BATTERY_BCL
2459static struct platform_device battery_bcl_device = {
2460 .name = "battery_current_limit",
2461 .id = -1,
2462};
2463#endif
2464
David Collins26f05562011-06-20 09:56:28 -07002465static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002466 .name = GPIO_REGULATOR_DEV_NAME,
2467 .id = PM8921_MPP_PM_TO_SYS(7),
2468 .dev = {
2469 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2470 },
2471};
2472
David Collins26f05562011-06-20 09:56:28 -07002473static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002474 .name = GPIO_REGULATOR_DEV_NAME,
2475 .id = 91,
2476 .dev = {
2477 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2478 },
2479};
2480
David Collinsb10be1d2011-09-02 10:29:31 -07002481static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2482 .name = GPIO_REGULATOR_DEV_NAME,
2483 .id = PM8921_GPIO_PM_TO_SYS(17),
2484 .dev = {
2485 .platform_data =
2486 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2487 },
2488};
2489
David Collins35a78f52011-12-14 15:54:25 -08002490static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2491 .name = GPIO_REGULATOR_DEV_NAME,
2492 .id = PM8921_GPIO_PM_TO_SYS(42),
2493 .dev = {
2494 .platform_data =
2495 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2496 },
2497};
2498
David Collins26f05562011-06-20 09:56:28 -07002499static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2500 .name = "rpm-regulator",
2501 .id = -1,
2502 .dev = {
2503 .platform_data = &msm_rpm_regulator_pdata,
2504 },
2505};
Mayank Ranae009c922012-03-22 03:02:06 +05302506#ifdef CONFIG_SERIAL_MSM_HS
2507static int configure_uart_gpios(int on)
2508{
2509 int ret = 0, i;
2510 int uart_gpios[] = {93, 94, 95, 96};
2511
2512 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2513 if (on) {
2514 ret = gpio_request(uart_gpios[i], NULL);
2515 if (ret) {
2516 pr_err("%s: unable to request uart gpio[%d]\n",
2517 __func__, uart_gpios[i]);
2518 break;
2519 }
2520 } else {
2521 gpio_free(uart_gpios[i]);
2522 }
2523 }
2524
2525 if (ret && on && i)
2526 for (; i >= 0; i--)
2527 gpio_free(uart_gpios[i]);
2528 return ret;
2529}
2530
2531static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002532 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302533};
Mayank Rana1f02d952012-07-04 19:11:20 +05302534
2535static int configure_gsbi8_uart_gpios(int on)
2536{
2537 int ret = 0, i;
2538 int uart_gpios[] = {34, 35, 36, 37};
2539
2540 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2541 if (on) {
2542 ret = gpio_request(uart_gpios[i], NULL);
2543 if (ret) {
2544 pr_err("%s: unable to request uart gpio[%d]\n",
2545 __func__, uart_gpios[i]);
2546 break;
2547 }
2548 } else {
2549 gpio_free(uart_gpios[i]);
2550 }
2551 }
2552
2553 if (ret && on && i)
2554 for (; i >= 0; i--)
2555 gpio_free(uart_gpios[i]);
2556 return ret;
2557}
2558
2559static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
2560 .gpio_config = configure_gsbi8_uart_gpios,
2561};
Mayank Ranae009c922012-03-22 03:02:06 +05302562#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302563static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302564static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2565#endif
David Collins26f05562011-06-20 09:56:28 -07002566
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302567#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin9baad172012-10-17 11:50:15 +08002568enum WLANBT_STATUS {
2569 WLANOFF_BTOFF = 1,
2570 WLANOFF_BTON,
2571 WLANON_BTOFF,
2572 WLANON_BTON
2573};
2574
2575static DEFINE_MUTEX(ath_wlanbt_mutex);
2576static int gpio_wlan_sys_rest_en = 26;
2577static int ath_wlanbt_status = WLANOFF_BTOFF;
2578
2579static int ath6kl_power_control(int on)
2580{
2581 int rc;
2582
2583 if (on) {
2584 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2585 if (rc) {
2586 pr_err("%s: unable to request gpio %d (%d)\n",
2587 __func__, gpio_wlan_sys_rest_en, rc);
2588 return rc;
2589 }
2590 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2591 msleep(200);
2592 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2593 msleep(100);
2594 } else {
2595 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2596 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2597 msleep(100);
2598 gpio_free(gpio_wlan_sys_rest_en);
2599 }
2600 return 0;
2601};
2602
2603static int ath6kl_wlan_power(int on)
2604{
2605 int ret = 0;
2606
2607 mutex_lock(&ath_wlanbt_mutex);
2608 if (on) {
2609 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2610 ret = ath6kl_power_control(1);
2611 ath_wlanbt_status = WLANON_BTOFF;
2612 } else if (ath_wlanbt_status == WLANOFF_BTON)
2613 ath_wlanbt_status = WLANON_BTON;
2614 } else {
2615 if (ath_wlanbt_status == WLANON_BTOFF) {
2616 ret = ath6kl_power_control(0);
2617 ath_wlanbt_status = WLANOFF_BTOFF;
2618 } else if (ath_wlanbt_status == WLANON_BTON)
2619 ath_wlanbt_status = WLANOFF_BTON;
2620 }
2621 mutex_unlock(&ath_wlanbt_mutex);
2622 pr_debug("%s on= %d, wlan_status= %d\n",
2623 __func__, on, ath_wlanbt_status);
2624 return ret;
2625};
2626
2627static struct wifi_platform_data ath6kl_wifi_control = {
2628 .set_power = ath6kl_wlan_power,
2629};
2630
2631static struct platform_device msm_wlan_power_device = {
2632 .name = "ath6kl_power",
2633 .dev = {
2634 .platform_data = &ath6kl_wifi_control,
2635 },
2636};
2637
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302638static struct resource bluesleep_resources[] = {
2639 {
2640 .name = "gpio_host_wake",
2641 .start = 27,
2642 .end = 27,
2643 .flags = IORESOURCE_IO,
2644 },
2645 {
2646 .name = "gpio_ext_wake",
2647 .start = 29,
2648 .end = 29,
2649 .flags = IORESOURCE_IO,
2650 },
2651 {
2652 .name = "host_wake",
2653 .start = MSM_GPIO_TO_INT(27),
2654 .end = MSM_GPIO_TO_INT(27),
2655 .flags = IORESOURCE_IRQ,
2656 },
2657};
2658
2659static struct platform_device msm_bluesleep_device = {
2660 .name = "bluesleep",
2661 .id = -1,
2662 .num_resources = ARRAY_SIZE(bluesleep_resources),
2663 .resource = bluesleep_resources,
2664};
2665
2666static struct platform_device msm_bt_power_device = {
2667 .name = "bt_power",
2668};
2669
Ming-yi Lin9baad172012-10-17 11:50:15 +08002670static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302671
2672static int bluetooth_power(int on)
2673{
2674 int rc;
2675
Ming-yi Lin9baad172012-10-17 11:50:15 +08002676 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302677 if (on) {
Ming-yi Lin9baad172012-10-17 11:50:15 +08002678 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2679 ath6kl_power_control(1);
2680 ath_wlanbt_status = WLANOFF_BTON;
2681 } else if (ath_wlanbt_status == WLANON_BTOFF)
2682 ath_wlanbt_status = WLANON_BTON;
2683
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302684 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2685 if (rc) {
2686 pr_err("%s: unable to request gpio %d (%d)\n",
2687 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002688 mutex_unlock(&ath_wlanbt_mutex);
2689 return rc;
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302690 }
2691 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002692 msleep(20);
2693 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302694 msleep(100);
2695 } else {
2696 gpio_set_value(gpio_bt_sys_rest_en, 0);
2697 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2698 msleep(100);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002699 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302700
Ming-yi Lin9baad172012-10-17 11:50:15 +08002701 if (ath_wlanbt_status == WLANOFF_BTON) {
2702 ath6kl_power_control(0);
2703 ath_wlanbt_status = WLANOFF_BTOFF;
2704 } else if (ath_wlanbt_status == WLANON_BTON)
2705 ath_wlanbt_status = WLANON_BTOFF;
2706 }
2707 mutex_unlock(&ath_wlanbt_mutex);
2708 pr_debug("%s on= %d, wlan_status= %d\n",
2709 __func__, on, ath_wlanbt_status);
2710 return 0;
2711};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302712
2713static void __init bt_power_init(void)
2714{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302715 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302716 return;
Ming-yi Lin9baad172012-10-17 11:50:15 +08002717};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302718#else
2719#define bt_power_init(x) do {} while (0)
2720#endif
2721
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002722static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002723 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002724 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302725 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002726 &msm_device_saw_core0,
2727 &msm_device_saw_core1,
2728 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002729 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002730 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002731 &msm8960_device_qup_spi_gsbi1,
2732 &msm8960_device_qup_i2c_gsbi3,
2733 &msm8960_device_qup_i2c_gsbi4,
2734 &msm8960_device_qup_i2c_gsbi10,
2735#ifndef CONFIG_MSM_DSPS
2736 &msm8960_device_qup_i2c_gsbi12,
2737#endif
2738 &msm_slim_ctrl,
2739 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302740#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2741 &msm_bluesleep_device,
2742 &msm_bt_power_device,
Ming-yi Lin9baad172012-10-17 11:50:15 +08002743 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302744#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002745#if defined(CONFIG_QSEECOM)
2746 &qseecom_device,
2747#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002748#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2749 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2750 &qcrypto_device,
2751#endif
2752
2753#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2754 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2755 &qcedev_device,
2756#endif
2757#ifdef CONFIG_MSM_ROTATOR
2758 &msm_rotator_device,
2759#endif
2760 &msm_device_sps,
2761#ifdef CONFIG_MSM_FAKE_BATTERY
2762 &fish_battery_device,
2763#endif
Binqiang Qiuf165c922012-08-15 18:00:18 -07002764#ifdef CONFIG_BATTERY_BCL
2765 &battery_bcl_device,
2766#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002767 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002768#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002769#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002770 &msm8960_android_pmem_device,
2771 &msm8960_android_pmem_adsp_device,
2772 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002773#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002774#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002775 &msm_device_bam_dmux,
2776 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002777#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2778#ifdef CONFIG_MSM_USE_TSIF1
2779 &msm_device_tsif[1],
2780#else
2781 &msm_device_tsif[0],
2782#endif
2783#endif
Joel Nider266a2642011-10-16 10:58:05 +02002784 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002785#ifdef CONFIG_HW_RANDOM_MSM
2786 &msm_device_rng,
2787#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002788#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002789 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002790#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002791 &msm8960_rpm_device,
2792 &msm8960_rpm_log_device,
2793 &msm8960_rpm_stat_device,
Anji Jonnala93129922012-10-09 20:57:53 +05302794 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002795 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002796 &coresight_tpiu_device,
2797 &coresight_etb_device,
2798 &coresight_funnel_device,
2799 &coresight_etm0_device,
2800 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002801 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002802 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002803 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002804 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002805 &msm8960_device_ebi1_ch0_erp,
2806 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002807 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002808 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002809 &msm_tsens_device,
Anji Jonnala6c2b6852012-09-21 13:34:44 +05302810 &msm8960_pc_cntr,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002811};
2812
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002814 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002815 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002816 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002817 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002818 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002819 &msm8960_device_otg,
2820 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002821 &msm_device_hsusb_host,
2822 &android_usb_device,
2823 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002824 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002825 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002826 &msm_pcm_routing,
2827 &msm_cpudai0,
2828 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002829 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002830 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002831 &msm_cpudai_hdmi_rx,
2832 &msm_cpudai_bt_rx,
2833 &msm_cpudai_bt_tx,
2834 &msm_cpudai_fm_rx,
2835 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002836 &msm_cpudai_auxpcm_rx,
2837 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002838 &msm_cpu_fe,
2839 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002840#ifdef CONFIG_MSM_GEMINI
2841 &msm8960_gemini_device,
2842#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07002843#ifdef CONFIG_MSM_MERCURY
2844 &msm8960_mercury_device,
2845#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002846 &msm_voice,
2847 &msm_voip,
2848 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302849 &msm_cpudai_afe_01_rx,
2850 &msm_cpudai_afe_01_tx,
2851 &msm_cpudai_afe_02_rx,
2852 &msm_cpudai_afe_02_tx,
2853 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302854 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002855 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002856 &msm_cpudai_incall_record_rx,
2857 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002858 &msm_pcm_hostless,
2859 &msm_bus_apps_fabric,
2860 &msm_bus_sys_fabric,
2861 &msm_bus_mm_fabric,
2862 &msm_bus_sys_fpb,
2863 &msm_bus_cpss_fpb,
2864};
2865
2866static void __init msm8960_i2c_init(void)
2867{
Kiran Gundaaf3b3562012-08-31 14:00:05 +05302868 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
2869 msm8960_i2c_qup_gsbi4_pdata.keep_ahb_clk_on = 1;
2870
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002871 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2872 &msm8960_i2c_qup_gsbi4_pdata;
2873
2874 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2875 &msm8960_i2c_qup_gsbi3_pdata;
2876
2877 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2878 &msm8960_i2c_qup_gsbi10_pdata;
2879
2880 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2881 &msm8960_i2c_qup_gsbi12_pdata;
2882}
2883
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002884static void __init msm8960_gfx_init(void)
2885{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002886 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2887 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06002888 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002889
Carter Coopera4a7ed22012-08-20 22:11:42 -06002890 /* Fixup data that needs to change based on GPU ID */
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002891 if (cpu_is_msm8960ab()) {
2892 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
Suman Tatiraju03a95db2012-10-29 18:24:53 -07002893 /* 8960PRO nominal clock rate is 320Mhz */
2894 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -06002895
2896 /*
2897 * If this an A320 GPU device (MSM8960AB), then
2898 * switch the resource table to 8960AB, to reflect the
2899 * separate register and shader memory mapping used in A320.
2900 */
2901
2902 msm_kgsl_3d0.num_resources = kgsl_num_resources_8960ab;
2903 msm_kgsl_3d0.resource = kgsl_3d0_resources_8960ab;
Carter Coopera4a7ed22012-08-20 22:11:42 -06002904 } else {
2905 kgsl_3d0_pdata->iommu_count = 1;
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -06002906
Carter Coopera4a7ed22012-08-20 22:11:42 -06002907 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
2908 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
2909 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
2910 }
2911 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
2912 /* 8960v3 GPU registers returns 5 for patch release
2913 * but it should be 6, so dummy up the chipid here
2914 * based the platform type
2915 */
2916 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
2917 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002918 }
Carter Cooper83e9dab2012-08-20 15:17:23 -06002919
2920 /* Register the 3D core */
2921 platform_device_register(&msm_kgsl_3d0);
2922
2923 /* Register the 2D cores if we are not 8960PRO */
2924 if (!cpu_is_msm8960ab()) {
2925 platform_device_register(&msm_kgsl_2d0);
2926 platform_device_register(&msm_kgsl_2d1);
2927 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002928}
2929
Subhash Jadavani933e6a62011-12-26 18:05:04 +05302930static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931 {
2932 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
2933 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2934 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002935 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002936 },
2937
2938 {
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002939 MSM_PM_SLEEP_MODE_RETENTION,
2940 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2941 true,
2942 415, 715, 340827, 475,
2943 },
2944
2945 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002946 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
2947 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2948 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002949 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002950 },
2951
2952 {
2953 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2954 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
2955 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002956 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002957 },
2958
2959 {
2960 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06002961 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
2962 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002963 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06002964 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002965
2966 {
2967 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2968 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
2969 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002970 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002971 },
2972
2973 {
2974 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2975 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
2976 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002977 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002978 },
2979
2980 {
2981 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2982 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
2983 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002984 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002985 },
2986
2987 {
2988 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2989 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
2990 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002991 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002992 },
2993};
2994
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002995
Praveen Chidambaram78499012011-11-01 17:15:17 -06002996static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
2997 .levels = &msm_rpmrs_levels[0],
2998 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
2999 .vdd_mem_levels = {
3000 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3001 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3002 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3003 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3004 },
3005 .vdd_dig_levels = {
3006 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3007 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3008 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3009 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3010 },
3011 .vdd_mask = 0x7FFFFF,
3012 .rpmrs_target_id = {
3013 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3014 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3015 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3016 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3017 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3018 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3019 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3020 },
3021};
3022
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003023static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3024 .mode = MSM_PM_BOOT_CONFIG_TZ,
3025};
3026
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003027#ifdef CONFIG_I2C
3028#define I2C_SURF 1
3029#define I2C_FFA (1 << 1)
3030#define I2C_RUMI (1 << 2)
3031#define I2C_SIM (1 << 3)
3032#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003033#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003034
3035struct i2c_registry {
3036 u8 machs;
3037 int bus;
3038 struct i2c_board_info *info;
3039 int len;
3040};
3041
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003042/* Sensors DSPS platform data */
3043#ifdef CONFIG_MSM_DSPS
3044#define DSPS_PIL_GENERIC_NAME "dsps"
3045#endif /* CONFIG_MSM_DSPS */
3046
3047static void __init msm8960_init_dsps(void)
3048{
3049#ifdef CONFIG_MSM_DSPS
3050 struct msm_dsps_platform_data *pdata =
3051 msm_dsps_device.dev.platform_data;
3052 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3053 pdata->gpios = NULL;
3054 pdata->gpios_num = 0;
3055
3056 platform_device_register(&msm_dsps_device);
3057#endif /* CONFIG_MSM_DSPS */
3058}
3059
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003060static int hsic_peripheral_status = 1;
3061static DEFINE_MUTEX(hsic_status_lock);
3062
3063void peripheral_connect()
3064{
3065 mutex_lock(&hsic_status_lock);
3066 if (hsic_peripheral_status)
3067 goto out;
3068 platform_device_add(&msm_device_hsic_host);
3069 hsic_peripheral_status = 1;
3070out:
3071 mutex_unlock(&hsic_status_lock);
3072}
3073EXPORT_SYMBOL(peripheral_connect);
3074
3075void peripheral_disconnect()
3076{
3077 mutex_lock(&hsic_status_lock);
3078 if (!hsic_peripheral_status)
3079 goto out;
3080 platform_device_del(&msm_device_hsic_host);
3081 hsic_peripheral_status = 0;
3082out:
3083 mutex_unlock(&hsic_status_lock);
3084}
3085EXPORT_SYMBOL(peripheral_disconnect);
3086
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303087static void __init msm8960_init_smsc_hub(void)
3088{
3089 uint32_t version = socinfo_get_version();
3090
3091 if (SOCINFO_VERSION_MAJOR(version) == 1)
3092 return;
3093
3094 if (machine_is_msm8960_liquid())
3095 platform_device_register(&smsc_hub_device);
3096}
3097
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003098static void __init msm8960_init_hsic(void)
3099{
3100#ifdef CONFIG_USB_EHCI_MSM_HSIC
3101 uint32_t version = socinfo_get_version();
3102
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003103 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003104 return;
3105
Joel King0cbf5d82012-05-24 15:21:38 -07003106 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003107 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003108#endif
3109}
3110
Amir Samuelov5137e392011-09-21 17:31:25 +03003111#ifdef CONFIG_ISL9519_CHARGER
3112static struct isl_platform_data isl_data __initdata = {
3113 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3114 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3115 .max_system_voltage = 4200,
3116 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003117 .chgcurrent = 1900,
3118 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003119 .input_current = 2048,
3120};
3121
3122static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3123 {
3124 I2C_BOARD_INFO("isl9519q", 0x9),
3125 .irq = 0, /* Not required when notify-by-pmic */
3126 .platform_data = &isl_data,
3127 },
3128};
3129#endif /* CONFIG_ISL9519_CHARGER */
3130
Amir Samuelov755616d2011-12-13 16:34:46 +02003131static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3132 {
3133 I2C_BOARD_INFO("sx1508q", 0x20),
3134 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3135 },
3136};
3137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003138static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003139#ifdef CONFIG_ISL9519_CHARGER
3140 {
3141 I2C_LIQUID,
3142 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3143 isl_charger_i2c_info,
3144 ARRAY_SIZE(isl_charger_i2c_info),
3145 },
3146#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003147 {
3148 I2C_SURF | I2C_FFA | I2C_FLUID,
3149 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3150 cyttsp_info,
3151 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003152 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303153 {
3154 I2C_LIQUID,
3155 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3156 mxt_device_info,
3157 ARRAY_SIZE(mxt_device_info),
3158 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303159 {
Manoj Rao14648742012-03-30 19:42:12 -07003160 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303161 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003162 sii_device_info,
3163 ARRAY_SIZE(sii_device_info),
3164 },
3165 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303166 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003167 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303168 msm_isa1200_board_info,
3169 ARRAY_SIZE(msm_isa1200_board_info),
3170 },
Amir Samuelov755616d2011-12-13 16:34:46 +02003171 {
3172 I2C_LIQUID,
3173 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3174 liquid_io_expander_i2c_info,
3175 ARRAY_SIZE(liquid_io_expander_i2c_info),
3176 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003177};
3178#endif /* CONFIG_I2C */
3179
3180static void __init register_i2c_devices(void)
3181{
3182#ifdef CONFIG_I2C
3183 u8 mach_mask = 0;
3184 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003185#ifdef CONFIG_MSM_CAMERA
3186 struct i2c_registry msm8960_camera_i2c_devices = {
3187 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3188 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3189 msm8960_camera_board_info.board_info,
3190 msm8960_camera_board_info.num_i2c_board_info,
3191 };
3192#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003193
3194 /* Build the matching 'supported_machs' bitmask */
3195 if (machine_is_msm8960_cdp())
3196 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003197 else if (machine_is_msm8960_fluid())
3198 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003199 else if (machine_is_msm8960_liquid())
3200 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003201 else if (machine_is_msm8960_mtp())
3202 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003203 else
3204 pr_err("unmatched machine ID in register_i2c_devices\n");
3205
Jing Lineec88ca2012-02-08 11:18:30 -08003206 if (machine_is_msm8960_liquid()) {
3207 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3208 mxt_device_info[0].platform_data =
3209 &mxt_platform_data_3d;
3210 else
3211 mxt_device_info[0].platform_data =
3212 &mxt_platform_data_2d;
3213 }
3214
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003215 /* Run the array and install devices as appropriate */
3216 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3217 if (msm8960_i2c_devices[i].machs & mach_mask)
3218 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3219 msm8960_i2c_devices[i].info,
3220 msm8960_i2c_devices[i].len);
3221 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003222
3223 if (!mhl_platform_data.gpio_mhl_power)
3224 pr_debug("mhl device configured for ext debug board\n");
3225
Kevin Chan09f4e662011-12-16 08:17:02 -08003226#ifdef CONFIG_MSM_CAMERA
3227 if (msm8960_camera_i2c_devices.machs & mach_mask)
3228 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3229 msm8960_camera_i2c_devices.info,
3230 msm8960_camera_i2c_devices.len);
3231#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003232#endif
3233}
3234
Siddartha Mohanadoss30447fe2012-09-26 09:42:32 -07003235static void __init msm8960_tsens_init(void)
3236{
3237 if (cpu_is_msm8960())
3238 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3239 return;
3240
3241 msm_tsens_early_init(&msm_tsens_pdata);
3242}
3243
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003244static void __init msm8960ab_update_krait_spm(void)
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003245{
3246 int i;
3247
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003248 /* Reset the AVS registers until we have support for AVS */
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003249 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3250 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3251 pdata->reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0;
3252 pdata->reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0;
3253 }
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003254
3255 /* Update the SPM sequences for SPC and PC */
3256 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3257 int j;
3258 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3259 for (j = 0; j < pdata->num_modes; j++) {
3260 if (pdata->modes[j].cmd ==
3261 spm_power_collapse_without_rpm)
3262 pdata->modes[j].cmd =
3263 spm_power_collapse_without_rpm_krait_v3;
3264 else if (pdata->modes[j].cmd ==
3265 spm_power_collapse_with_rpm)
3266 pdata->modes[j].cmd =
3267 spm_power_collapse_with_rpm_krait_v3;
3268 }
3269 }
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003270}
3271
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003272static void __init msm8960_cdp_init(void)
3273{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003274 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3275 pr_err("meminfo_init() failed!\n");
3276
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003277 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss30447fe2012-09-26 09:42:32 -07003278 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003279 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003280 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3281 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003283 regulator_suppress_info_printing();
3284 if (msm_xo_init())
3285 pr_err("Failed to initialize XO votes\n");
David Collinse68647e2012-09-04 15:44:19 -07003286 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003287 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003288 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303289 if (machine_is_msm8960_liquid())
3290 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003291 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303292 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3293 machine_is_msm8960_cdp()) {
Mayank Ranaa61da7a2012-08-14 10:57:00 +05303294 /* Due to availability of USB Switch in SGLTE Platform
3295 * it requires different HSUSB PHY settings compare to
3296 * 8960 MTP/CDP platform.
3297 */
3298 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3299 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3300 else
3301 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303302 } else if (machine_is_msm8960_liquid()) {
3303 msm_otg_pdata.phy_init_seq =
3304 liquid_v1_phy_init_seq;
3305 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003306 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303307 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303308 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303309 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3310 machine_is_msm8960_liquid())
3311 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003312 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003313 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3314 &msm8960_qup_spi_gsbi1_pdata;
3315 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303316 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3317 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003318
3319 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303320 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jainae54a622012-12-03 15:09:39 +05303321 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3322 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303323 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003324 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003325 msm8960_gfx_init();
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003326
3327 if (cpu_is_msm8960ab())
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003328 msm8960ab_update_krait_spm();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003329 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3330 msm_spm_l2_init(msm_spm_l2_data);
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003331
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003332 msm8960_init_buses();
Stephen Boyd913c29d2012-10-25 11:46:04 -07003333 if (cpu_is_msm8960ab()) {
3334 platform_add_devices(msm8960ab_footswitch,
3335 msm8960ab_num_footswitch);
3336 } else {
3337 platform_add_devices(msm8960_footswitch,
3338 msm8960_num_footswitch);
3339 }
David Collinsb10be1d2011-09-02 10:29:31 -07003340 if (machine_is_msm8960_liquid())
3341 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003342 if (machine_is_msm8960_cdp())
3343 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003344
3345 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3346 platform_device_register(&msm8960_device_uart_gsbi8);
3347 else
3348 platform_device_register(&msm8960_device_uart_gsbi5);
3349
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003350 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003351 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3352 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003353 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303354 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003355 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003356
Mayank Rana1f02d952012-07-04 19:11:20 +05303357 /* For 8960 Standalone External Bluetooth Interface */
3358 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3359 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3360 platform_device_register(&msm_device_uart_dm8);
3361 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003362 if (cpu_is_msm8960ab())
3363 platform_device_register(&msm8960ab_device_acpuclk);
3364 else
3365 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003366 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menon697e91b2012-08-20 15:25:50 -07003367 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003368
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003369 msm8960_pm8921_gpio_mpp_init();
Stephen Boyded035682012-09-13 12:41:31 -07003370 /* Don't add modem devices on APQ targets */
Stephen Boydbdb53f32012-06-05 18:39:47 -07003371 if (socinfo_get_id() != 124)
3372 platform_device_register(&msm_8960_q6_mss);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003373 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303374 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003375 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003376#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003377 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003378#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003379 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303380 if (machine_is_msm8960_liquid())
3381 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003382 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003383 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384 slim_register_board_info(msm_slim_devices,
3385 ARRAY_SIZE(msm_slim_devices));
3386 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003387 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003388 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303389 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003390 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3391 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3392 platform_device_register(&mdm_sglte_device);
3393 }
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003394 msm_pm_set_tz_retention_flag(1);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003395}
3396
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003397MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3398 .map_io = msm8960_map_io,
3399 .reserve = msm8960_reserve,
3400 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303401 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402 .timer = &msm_timer,
3403 .init_machine = msm8960_cdp_init,
3404 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003405 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003406 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003407MACHINE_END
3408
3409MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3410 .map_io = msm8960_map_io,
3411 .reserve = msm8960_reserve,
3412 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303413 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003414 .timer = &msm_timer,
3415 .init_machine = msm8960_cdp_init,
3416 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003417 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003418 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003419MACHINE_END
3420
3421MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3422 .map_io = msm8960_map_io,
3423 .reserve = msm8960_reserve,
3424 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303425 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003426 .timer = &msm_timer,
3427 .init_machine = msm8960_cdp_init,
3428 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003429 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003430 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003432
3433MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3434 .map_io = msm8960_map_io,
3435 .reserve = msm8960_reserve,
3436 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303437 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003438 .timer = &msm_timer,
3439 .init_machine = msm8960_cdp_init,
3440 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003441 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003442 .restart = msm_restart,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003443MACHINE_END