blob: 42dbbee82b9a59bd9f089cc1b29ad87b5ba5a575 [file] [log] [blame]
Harini Jayaramana9873ab2011-12-20 17:29:48 -07001/* Copyright (c) 2011-2012, Code Aurora Forum. 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>
22#include <linux/regulator/gpio-regulator.h>
23#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>
Lucille Sylvester34ec3692011-08-16 16:28:04 -060029#include <linux/msm_kgsl.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030#ifdef CONFIG_ANDROID_PMEM
31#include <linux/android_pmem.h>
32#endif
33#include <linux/cyttsp.h>
34#include <linux/dma-mapping.h>
35#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070036#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037#include <linux/leds.h>
38#include <linux/leds-pm8xxx.h>
Mohan Pallaka50837382011-09-07 11:00:57 +053039#include <linux/i2c/atmel_mxt_ts.h>
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -070040#include <linux/msm_tsens.h>
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -070041#include <linux/ks8851.h>
Mohan Pallaka5e490392011-09-09 15:18:41 +053042#include <linux/i2c/isa1200.h>
Jack Cheung0b1987e2011-11-18 13:36:29 -080043#include <linux/memory.h>
Larry Bassel2d8b42d2012-03-12 10:41:26 -070044#include <linux/memblock.h>
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>
53#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#include <mach/msm_spi.h>
Mayank Ranae009c922012-03-22 03:02:06 +053055#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#ifdef CONFIG_USB_MSM_OTG_72K
57#include <mach/msm_hsusb.h>
58#else
59#include <linux/usb/msm_hsusb.h>
60#endif
61#include <linux/usb/android.h>
62#include <mach/usbdiag.h>
63#include <mach/socinfo.h>
64#include <mach/rpm.h>
65#include <mach/gpio.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>
Laura Abbottd6183792011-08-19 13:42:24 -070080#include <linux/ion.h>
81#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>
Laura Abbottd6183792011-08-19 13:42:24 -070087
Larry Bassel41a055b2011-12-06 16:15:14 -080088#include <linux/fmem.h>
89
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080091#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093#include "spm.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080094#include "board-8960.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080095#include "pm.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080096#include <mach/cpuidle.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097#include "rpm_resources.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053098#include <mach/mpm.h>
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070099#include "acpuclock.h"
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700100#include "smd_private.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600101#include "pm-boot.h"
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700102#include "msm_watchdog.h"
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800103
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104static struct platform_device msm_fm_platform_init = {
105 .name = "iris_fm",
106 .id = -1,
107};
108
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109#define KS8851_RST_GPIO 89
110#define KS8851_IRQ_GPIO 90
Mohan Pallaka5e490392011-09-09 15:18:41 +0530111#define HAP_SHIFT_LVL_OE_GPIO 47
112
Manoj Rao14648742012-03-30 19:42:12 -0700113#define MHL_GPIO_INT 4
114#define MHL_GPIO_RESET 15
115
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700116#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700117
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800118struct sx150x_platform_data msm8960_sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700119 [SX150X_CAM] = {
120 .gpio_base = GPIO_CAM_EXPANDER_BASE,
121 .oscio_is_gpo = false,
122 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530123 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700124 .io_open_drain_ena = 0x0,
125 .irq_summary = -1,
126 },
Amir Samuelov755616d2011-12-13 16:34:46 +0200127 [SX150X_LIQUID] = {
128 .gpio_base = GPIO_LIQUID_EXPANDER_BASE,
129 .oscio_is_gpo = false,
130 .io_pullup_ena = 0x0c08,
131 .io_pulldn_ena = 0x4060,
132 .io_open_drain_ena = 0x000c,
133 .io_polarity = 0,
134 .irq_summary = -1,
135 },
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700136};
Nishant Pandit474f2252011-07-23 23:17:56 +0530137
138#endif
139
Olav Haugana21169d2012-01-04 09:17:06 -0800140#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -0700141#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Mathew Karimpanal15fa5c42011-12-14 21:28:10 -0800142#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800143#define MSM_LIQUID_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800144#define MSM_HDMI_PRIM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Laura Abbott2d1760b2011-09-29 21:31:24 -0700145
146#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -0700147#define MSM_PMEM_KERNEL_EBI1_SIZE 0x65000
Olav Haugan32594552012-03-13 11:40:05 -0700148#ifdef CONFIG_MSM_IOMMU
149#define MSM_ION_MM_SIZE 0x3800000
150#define MSM_ION_SF_SIZE 0x0
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700151#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700152#define MSM_ION_HEAP_NUM 7
153#else
154#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
155#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700156#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700157#define MSM_ION_HEAP_NUM 8
158#endif
Olav Haugan42ebe712012-01-10 16:30:58 -0800159#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Olav Hauganb5be7992011-11-18 14:29:02 -0800160#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan7355db02012-01-13 16:59:13 -0800161#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan32594552012-03-13 11:40:05 -0700162
Olav Hauganb5be7992011-11-18 14:29:02 -0800163#define MSM_LIQUID_ION_MM_SIZE (MSM_ION_MM_SIZE + 0x600000)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800164#define MSM_LIQUID_ION_SF_SIZE MSM_LIQUID_PMEM_SIZE
165#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SIZE
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700166
Larry Bassel4d4f4482012-04-04 11:26:09 -0700167#define MSM8960_FIXED_AREA_START 0xa0000000
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700168#define MAX_FIXED_AREA_SIZE 0x10000000
Larry Bassel4d4f4482012-04-04 11:26:09 -0700169#define MSM_MM_FW_SIZE 0x200000
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700170#define MSM8960_FW_START (MSM8960_FIXED_AREA_START - MSM_MM_FW_SIZE)
171
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800172static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott2d1760b2011-09-29 21:31:24 -0700173#else
Laura Abbott6db11c92011-11-04 10:31:43 -0700174#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800175#define MSM_ION_HEAP_NUM 1
Laura Abbott2d1760b2011-09-29 21:31:24 -0700176#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700177
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
179static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
180static int __init pmem_kernel_ebi1_size_setup(char *p)
181{
182 pmem_kernel_ebi1_size = memparse(p, NULL);
183 return 0;
184}
185early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
186#endif
187
188#ifdef CONFIG_ANDROID_PMEM
189static unsigned pmem_size = MSM_PMEM_SIZE;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800190static unsigned pmem_param_set;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700191static int __init pmem_size_setup(char *p)
192{
193 pmem_size = memparse(p, NULL);
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800194 pmem_param_set = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700195 return 0;
196}
197early_param("pmem_size", pmem_size_setup);
198
199static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
200
201static int __init pmem_adsp_size_setup(char *p)
202{
203 pmem_adsp_size = memparse(p, NULL);
204 return 0;
205}
206early_param("pmem_adsp_size", pmem_adsp_size_setup);
207
208static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
209
210static int __init pmem_audio_size_setup(char *p)
211{
212 pmem_audio_size = memparse(p, NULL);
213 return 0;
214}
215early_param("pmem_audio_size", pmem_audio_size_setup);
216#endif
217
218#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700219#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220static struct android_pmem_platform_data android_pmem_pdata = {
221 .name = "pmem",
222 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
223 .cached = 1,
224 .memory_type = MEMTYPE_EBI1,
225};
226
Laura Abbottb93525f2012-04-12 09:57:19 -0700227static struct platform_device msm8960_android_pmem_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700228 .name = "android_pmem",
229 .id = 0,
230 .dev = {.platform_data = &android_pmem_pdata},
231};
232
233static struct android_pmem_platform_data android_pmem_adsp_pdata = {
234 .name = "pmem_adsp",
235 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
236 .cached = 0,
237 .memory_type = MEMTYPE_EBI1,
238};
Laura Abbottb93525f2012-04-12 09:57:19 -0700239static struct platform_device msm8960_android_pmem_adsp_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700240 .name = "android_pmem",
241 .id = 2,
242 .dev = { .platform_data = &android_pmem_adsp_pdata },
243};
244
245static struct android_pmem_platform_data android_pmem_audio_pdata = {
246 .name = "pmem_audio",
247 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
248 .cached = 0,
249 .memory_type = MEMTYPE_EBI1,
250};
251
Laura Abbottb93525f2012-04-12 09:57:19 -0700252static struct platform_device msm8960_android_pmem_audio_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253 .name = "android_pmem",
254 .id = 4,
255 .dev = { .platform_data = &android_pmem_audio_pdata },
256};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700257#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
258#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700259
Laura Abbottb93525f2012-04-12 09:57:19 -0700260struct fmem_platform_data msm8960_fmem_pdata = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800261};
262
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700263#define DSP_RAM_BASE_8960 0x8da00000
264#define DSP_RAM_SIZE_8960 0x1800000
265static int dspcrashd_pdata_8960 = 0xDEADDEAD;
266
267static struct resource resources_dspcrashd_8960[] = {
268 {
269 .name = "msm_dspcrashd",
270 .start = DSP_RAM_BASE_8960,
271 .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
272 .flags = IORESOURCE_DMA,
273 },
274};
275
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800276static struct platform_device msm_device_dspcrashd_8960 = {
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700277 .name = "msm_dspcrashd",
278 .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
279 .resource = resources_dspcrashd_8960,
280 .dev = { .platform_data = &dspcrashd_pdata_8960 },
281};
282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283static struct memtype_reserve msm8960_reserve_table[] __initdata = {
284 [MEMTYPE_SMI] = {
285 },
286 [MEMTYPE_EBI0] = {
287 .flags = MEMTYPE_FLAGS_1M_ALIGN,
288 },
289 [MEMTYPE_EBI1] = {
290 .flags = MEMTYPE_FLAGS_1M_ALIGN,
291 },
292};
293
Laura Abbottf8c03b92012-02-16 14:57:58 -0800294static void __init reserve_rtb_memory(void)
295{
296#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700297 msm8960_reserve_table[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
Laura Abbottf8c03b92012-02-16 14:57:58 -0800298#endif
299}
300
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700301static void __init size_pmem_devices(void)
302{
303#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700304#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800306
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800307 if (!pmem_param_set) {
308 if (machine_is_msm8960_liquid())
309 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700310 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800311 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
312 }
313
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700314 android_pmem_pdata.size = pmem_size;
315 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700316#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
317#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700318}
319
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700320#ifdef CONFIG_ANDROID_PMEM
321#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322static void __init reserve_memory_for(struct android_pmem_platform_data *p)
323{
324 msm8960_reserve_table[p->memory_type].size += p->size;
325}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700326#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
327#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328
329static void __init reserve_pmem_memory(void)
330{
331#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700332#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700333 reserve_memory_for(&android_pmem_adsp_pdata);
334 reserve_memory_for(&android_pmem_pdata);
335 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700336#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700337 msm8960_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
338#endif
339}
340
Larry Basselb4126da2011-07-18 14:31:33 -0700341static int msm8960_paddr_to_memtype(unsigned int paddr)
342{
343 return MEMTYPE_EBI1;
344}
345
Olav Hauganf6dc7742012-02-15 09:11:55 -0800346#define FMEM_ENABLED 1
347
Laura Abbottd6183792011-08-19 13:42:24 -0700348#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800349#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700350static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800351 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan42ebe712012-01-10 16:30:58 -0800352 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800353 .reusable = FMEM_ENABLED,
354 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700355 .fixed_position = FIXED_MIDDLE,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800356};
357
Laura Abbottb93525f2012-04-12 09:57:19 -0700358static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800359 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800360 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800361 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800362 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700363 .fixed_position = FIXED_HIGH,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800364};
365
Laura Abbottb93525f2012-04-12 09:57:19 -0700366static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800367 .adjacent_mem_id = INVALID_HEAP_ID,
368 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800369 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800370};
371
Laura Abbottb93525f2012-04-12 09:57:19 -0700372static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800373 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
374 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800375 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700376 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800377};
378#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800379
380/**
381 * These heaps are listed in the order they will be allocated. Due to
382 * video hardware restrictions and content protection the FW heap has to
383 * be allocated adjacent (below) the MM heap and the MFC heap has to be
384 * allocated after the MM heap to ensure MFC heap is not more than 256MB
385 * away from the base address of the FW heap.
386 * However, the order of FW heap and MM heap doesn't matter since these
387 * two heaps are taken care of by separate code to ensure they are adjacent
388 * to each other.
389 * Don't swap the order unless you know what you are doing!
390 */
Laura Abbottb93525f2012-04-12 09:57:19 -0700391static struct ion_platform_data msm8960_ion_pdata = {
Laura Abbott2d1760b2011-09-29 21:31:24 -0700392 .nr = MSM_ION_HEAP_NUM,
Laura Abbottd6183792011-08-19 13:42:24 -0700393 .heaps = {
394 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800395 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700396 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700397 .name = ION_VMALLOC_HEAP_NAME,
398 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700399#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700400 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800401 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800402 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800403 .name = ION_MM_HEAP_NAME,
404 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700405 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700406 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700407 },
Laura Abbott8c017362011-09-22 20:59:12 -0700408 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800409 .id = ION_MM_FIRMWARE_HEAP_ID,
410 .type = ION_HEAP_TYPE_CARVEOUT,
411 .name = ION_MM_FIRMWARE_HEAP_NAME,
412 .size = MSM_ION_MM_FW_SIZE,
413 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700414 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800415 },
416 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800417 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800418 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800419 .name = ION_MFC_HEAP_NAME,
420 .size = MSM_ION_MFC_SIZE,
421 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700422 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800423 },
Olav Haugan32594552012-03-13 11:40:05 -0700424#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800425 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800426 .id = ION_SF_HEAP_ID,
427 .type = ION_HEAP_TYPE_CARVEOUT,
428 .name = ION_SF_HEAP_NAME,
429 .size = MSM_ION_SF_SIZE,
430 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700431 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800432 },
Olav Haugan32594552012-03-13 11:40:05 -0700433#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800434 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800435 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700436 .type = ION_HEAP_TYPE_IOMMU,
437 .name = ION_IOMMU_HEAP_NAME,
438 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800439 {
440 .id = ION_QSECOM_HEAP_ID,
441 .type = ION_HEAP_TYPE_CARVEOUT,
442 .name = ION_QSECOM_HEAP_NAME,
443 .size = MSM_ION_QSECOM_SIZE,
444 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700445 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800446 },
Olav Haugan7355db02012-01-13 16:59:13 -0800447 {
448 .id = ION_AUDIO_HEAP_ID,
449 .type = ION_HEAP_TYPE_CARVEOUT,
450 .name = ION_AUDIO_HEAP_NAME,
451 .size = MSM_ION_AUDIO_SIZE,
452 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700453 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800454 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700455#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700456 }
457};
458
Laura Abbottb93525f2012-04-12 09:57:19 -0700459static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700460 .name = "ion-msm",
461 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700462 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700463};
464#endif
465
Laura Abbottb93525f2012-04-12 09:57:19 -0700466struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800467 .name = "fmem",
468 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700469 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800470};
471
Olav Haugan65f4bd82011-12-13 11:50:08 -0800472static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700473{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800474 unsigned int i;
475
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800476 if (!pmem_param_set) {
477 if (machine_is_msm8960_liquid())
478 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
479
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700480 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800481 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
482
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700483 if (machine_is_msm8960_liquid() ||
484 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700485 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
486 if (msm8960_ion_pdata.heaps[i].id ==
487 ION_SF_HEAP_ID) {
488 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800489 msm_ion_sf_size;
490 pr_debug("msm_ion_sf_size 0x%x\n",
491 msm_ion_sf_size);
492 break;
493 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800494 }
495 }
496 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800497}
498
499static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
500 unsigned long size)
501{
502 msm8960_reserve_table[mem_type].size += size;
503}
504
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700505static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
506{
507#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
508 int ret;
509
510 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
511 panic("fixed area size is larger than %dM\n",
512 MAX_FIXED_AREA_SIZE >> 20);
513
514 reserve_info->fixed_area_size = fixed_area_size;
515 reserve_info->fixed_area_start = MSM8960_FW_START;
516
517 ret = memblock_remove(reserve_info->fixed_area_start,
518 reserve_info->fixed_area_size);
519 BUG_ON(ret);
520#endif
521}
522
Olav Haugan65f4bd82011-12-13 11:50:08 -0800523/**
524 * Reserve memory for ION and calculate amount of reusable memory for fmem.
525 * We only reserve memory for heaps that are not reusable. However, we only
526 * support one reusable heap at the moment so we ignore the reusable flag for
527 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800528 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
529 * at a higher address than FW in addition to not more than 256MB away from the
530 * base address of the firmware. This means that if MM is reusable the other
531 * two heaps must be allocated in the same region as FW. This is handled by the
532 * mem_is_fmem flag in the platform data. In addition the MM heap must be
533 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800534 */
535static void __init reserve_ion_memory(void)
536{
537#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
538 unsigned int i;
539 unsigned int reusable_count = 0;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700540 unsigned int fixed_size = 0;
541 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
542 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800543
544 adjust_mem_for_liquid();
Laura Abbottb93525f2012-04-12 09:57:19 -0700545 msm8960_fmem_pdata.size = 0;
546 msm8960_fmem_pdata.reserved_size_low = 0;
547 msm8960_fmem_pdata.reserved_size_high = 0;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700548 fixed_low_size = 0;
549 fixed_middle_size = 0;
550 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800551
552 /* We only support 1 reusable heap. Check if more than one heap
553 * is specified as reusable and set as non-reusable if found.
554 */
Laura Abbottb93525f2012-04-12 09:57:19 -0700555 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
556 const struct ion_platform_heap *heap =
557 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan65f4bd82011-12-13 11:50:08 -0800558
559 if (heap->type == ION_HEAP_TYPE_CP && heap->extra_data) {
560 struct ion_cp_heap_pdata *data = heap->extra_data;
561
562 reusable_count += (data->reusable) ? 1 : 0;
563
564 if (data->reusable && reusable_count > 1) {
565 pr_err("%s: Too many heaps specified as "
566 "reusable. Heap %s was not configured "
567 "as reusable.\n", __func__, heap->name);
568 data->reusable = 0;
569 }
570 }
571 }
572
Laura Abbottb93525f2012-04-12 09:57:19 -0700573 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
574 const struct ion_platform_heap *heap =
575 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan65f4bd82011-12-13 11:50:08 -0800576
577 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700578 int fixed_position = NOT_FIXED;
579 int mem_is_fmem = 0;
580
Olav Haugan65f4bd82011-12-13 11:50:08 -0800581 switch (heap->type) {
582 case ION_HEAP_TYPE_CP:
Olav Hauganf6dc7742012-02-15 09:11:55 -0800583 mem_is_fmem = ((struct ion_cp_heap_pdata *)
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700584 heap->extra_data)->mem_is_fmem;
585 fixed_position = ((struct ion_cp_heap_pdata *)
586 heap->extra_data)->fixed_position;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800587 break;
588 case ION_HEAP_TYPE_CARVEOUT:
Olav Hauganf6dc7742012-02-15 09:11:55 -0800589 mem_is_fmem = ((struct ion_co_heap_pdata *)
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700590 heap->extra_data)->mem_is_fmem;
591 fixed_position = ((struct ion_co_heap_pdata *)
592 heap->extra_data)->fixed_position;
593 break;
594 default:
595 break;
596 }
597
598 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;
609
610 if (mem_is_fmem)
Laura Abbottb93525f2012-04-12 09:57:19 -0700611 msm8960_fmem_pdata.size += heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700612 }
613 }
614
615 if (!fixed_size)
616 return;
617
Laura Abbottb93525f2012-04-12 09:57:19 -0700618 if (msm8960_fmem_pdata.size) {
619 msm8960_fmem_pdata.reserved_size_low = fixed_low_size;
620 msm8960_fmem_pdata.reserved_size_high = fixed_high_size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700621 }
622
Larry Bassel4d4f4482012-04-04 11:26:09 -0700623 /* Since the fixed area may be carved out of lowmem,
624 * make sure the length is a multiple of 1M.
625 */
626 fixed_size = (fixed_size + MSM_MM_FW_SIZE + SECTION_SIZE - 1)
627 & SECTION_MASK;
628 msm8960_reserve_fixed_area(fixed_size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700629
630 fixed_low_start = MSM8960_FIXED_AREA_START;
631 fixed_middle_start = fixed_low_start + fixed_low_size;
632 fixed_high_start = fixed_middle_start + fixed_middle_size;
633
Laura Abbottb93525f2012-04-12 09:57:19 -0700634 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
635 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700636
637 if (heap->extra_data) {
638 int fixed_position = NOT_FIXED;
639
640 switch (heap->type) {
641 case ION_HEAP_TYPE_CP:
642 fixed_position = ((struct ion_cp_heap_pdata *)
643 heap->extra_data)->fixed_position;
644 break;
645 case ION_HEAP_TYPE_CARVEOUT:
646 fixed_position = ((struct ion_co_heap_pdata *)
647 heap->extra_data)->fixed_position;
648 break;
649 default:
650 break;
651 }
652
653 switch (fixed_position) {
654 case FIXED_LOW:
655 heap->base = fixed_low_start;
656 break;
657 case FIXED_MIDDLE:
658 heap->base = fixed_middle_start;
659 break;
660 case FIXED_HIGH:
661 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800662 break;
663 default:
664 break;
665 }
666 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800667 }
Laura Abbottd6183792011-08-19 13:42:24 -0700668#endif
669}
Huaibin Yanga5419422011-12-08 23:52:10 -0800670
671static void __init reserve_mdp_memory(void)
672{
673 msm8960_mdp_writeback(msm8960_reserve_table);
674}
675
Laura Abbott306bcc22012-03-08 11:24:53 -0800676#if defined(CONFIG_MSM_CACHE_DUMP)
Laura Abbottb93525f2012-04-12 09:57:19 -0700677static struct msm_cache_dump_platform_data msm8960_cache_dump_pdata = {
Laura Abbott306bcc22012-03-08 11:24:53 -0800678 .l2_size = L2_BUFFER_SIZE,
679};
680
Laura Abbottb93525f2012-04-12 09:57:19 -0700681static struct platform_device msm8960_cache_dump_device = {
Laura Abbott306bcc22012-03-08 11:24:53 -0800682 .name = "msm_cache_dump",
683 .id = -1,
684 .dev = {
Laura Abbottb93525f2012-04-12 09:57:19 -0700685 .platform_data = &msm8960_cache_dump_pdata,
Laura Abbott306bcc22012-03-08 11:24:53 -0800686 },
687};
688
689#endif
690
Stephen Boyd668d7652012-04-25 11:31:01 -0700691static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800692{
693#ifdef CONFIG_MSM_CACHE_DUMP
694 unsigned int spare;
695 unsigned int l1_size;
Laura Abbott7b637362012-03-29 16:43:49 -0700696 unsigned int l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800697 unsigned int total;
698 int ret;
699
700 ret = scm_call(L1C_SERVICE_ID, L1C_BUFFER_GET_SIZE_COMMAND_ID, &spare,
701 sizeof(spare), &l1_size, sizeof(l1_size));
702
703 if (ret)
704 /* Fall back to something reasonable here */
705 l1_size = L1_BUFFER_SIZE;
706
Laura Abbott7b637362012-03-29 16:43:49 -0700707 ret = scm_call(L1C_SERVICE_ID, L2C_BUFFER_GET_SIZE_COMMAND_ID, &spare,
708 sizeof(spare), &l2_size, sizeof(l2_size));
709
710 if (ret)
711 /* Fall back to something reasonable here */
712 l2_size = L2_BUFFER_SIZE;
713
714 total = l1_size + l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800715
716 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbottb93525f2012-04-12 09:57:19 -0700717 msm8960_cache_dump_pdata.l1_size = l1_size;
718 msm8960_cache_dump_pdata.l2_size = l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800719#endif
720}
721
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700722static void __init msm8960_calculate_reserve_sizes(void)
723{
724 size_pmem_devices();
725 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700726 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800727 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800728 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800729 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700730}
731
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700732static struct reserve_info msm8960_reserve_info __initdata = {
733 .memtype_reserve_table = msm8960_reserve_table,
734 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700735 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700736 .paddr_to_memtype = msm8960_paddr_to_memtype,
737};
738
Larry Basselb4126da2011-07-18 14:31:33 -0700739static int msm8960_memory_bank_size(void)
740{
741 return 1<<29;
742}
743
744static void __init locate_unstable_memory(void)
745{
746 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
747 unsigned long bank_size;
748 unsigned long low, high;
749
750 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700751 msm8960_reserve_info.bank_size = bank_size;
752
Larry Basselb4126da2011-07-18 14:31:33 -0700753 low = meminfo.bank[0].start;
754 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700755
756 /* Check if 32 bit overflow occured */
757 if (high < mb->start)
758 high = ~0UL;
759
Larry Bassel4d4f4482012-04-04 11:26:09 -0700760 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
761 panic("fixed area extends beyond end of memory\n");
762
Larry Basselb4126da2011-07-18 14:31:33 -0700763 low &= ~(bank_size - 1);
764
765 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700766 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800767
Larry Basselb8d61022012-02-24 10:49:45 -0800768#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800769 msm8960_reserve_info.low_unstable_address = mb->start -
770 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800771 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700772 pr_info("low unstable address %lx max size %lx bank size %lx\n",
773 msm8960_reserve_info.low_unstable_address,
774 msm8960_reserve_info.max_unstable_size,
775 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700776 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800777#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700778no_dmm:
779 msm8960_reserve_info.low_unstable_address = high;
780 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700781}
782
Larry Basselb830e182011-10-14 10:46:55 -0700783static void __init place_movable_zone(void)
784{
Larry Basselb8d61022012-02-24 10:49:45 -0800785#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700786 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
787 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
788 pr_info("movable zone start %lx size %lx\n",
789 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800790#endif
Larry Basselb830e182011-10-14 10:46:55 -0700791}
792
793static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794{
795 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700796 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700797 place_movable_zone();
798}
799
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800800static char prim_panel_name[PANEL_NAME_MAX_LEN];
801static char ext_panel_name[PANEL_NAME_MAX_LEN];
802static int __init prim_display_setup(char *param)
803{
804 if (strnlen(param, PANEL_NAME_MAX_LEN))
805 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
806 return 0;
807}
808early_param("prim_display", prim_display_setup);
809
810static int __init ext_display_setup(char *param)
811{
812 if (strnlen(param, PANEL_NAME_MAX_LEN))
813 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
814 return 0;
815}
816early_param("ext_display", ext_display_setup);
817
Larry Basselb830e182011-10-14 10:46:55 -0700818static void __init msm8960_reserve(void)
819{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800820 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700821 msm_reserve();
Laura Abbottb93525f2012-04-12 09:57:19 -0700822 if (msm8960_fmem_pdata.size) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700823#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Laura Abbottb93525f2012-04-12 09:57:19 -0700824 msm8960_fmem_pdata.phys = reserve_info->fixed_area_start +
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700825 MSM_MM_FW_SIZE;
826 pr_info("mm fw at %lx (fixed) size %x\n",
827 reserve_info->fixed_area_start, MSM_MM_FW_SIZE);
828 pr_info("fmem start %lx (fixed) size %lx\n",
Laura Abbottb93525f2012-04-12 09:57:19 -0700829 msm8960_fmem_pdata.phys, msm8960_fmem_pdata.size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700830#else
Laura Abbottb93525f2012-04-12 09:57:19 -0700831 msm8960_fmem_pdata.phys =
832 reserve_memory_for_fmem(msm8960_fmem_pdata.size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700833#endif
834 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700835}
836
Larry Bassela4414b12011-08-04 11:11:02 -0700837static int msm8960_change_memory_power(u64 start, u64 size,
838 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700839{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700840 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700841}
842
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700843static void __init msm8960_allocate_memory_regions(void)
844{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800845 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700846}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700848#ifdef CONFIG_WCD9310_CODEC
849
850#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
851
Patrick Lai3043fba2011-08-01 14:15:57 -0700852/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
853 * 4 micbiases are used to power various analog and digital
854 * microphones operating at 1800 mV. Technically, all micbiases
855 * can source from single cfilter since all microphones operate
856 * at the same voltage level. The arrangement below is to make
857 * sure all cfilters are exercised. LDO_H regulator ouput level
858 * does not need to be as high as 2.85V. It is choosen for
859 * microphone sensitivity purpose.
860 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530861static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700862 .slimbus_slave_device = {
863 .name = "tabla-slave",
864 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
865 },
866 .irq = MSM_GPIO_TO_INT(62),
867 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530868 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700870 .micbias = {
871 .ldoh_v = TABLA_LDOH_2P85_V,
872 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700873 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700874 .cfilt3_mv = 1800,
875 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
876 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
877 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
878 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530879 },
880 .regulator = {
881 {
882 .name = "CDC_VDD_CP",
883 .min_uV = 1800000,
884 .max_uV = 1800000,
885 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
886 },
887 {
888 .name = "CDC_VDDA_RX",
889 .min_uV = 1800000,
890 .max_uV = 1800000,
891 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
892 },
893 {
894 .name = "CDC_VDDA_TX",
895 .min_uV = 1800000,
896 .max_uV = 1800000,
897 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
898 },
899 {
900 .name = "VDDIO_CDC",
901 .min_uV = 1800000,
902 .max_uV = 1800000,
903 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
904 },
905 {
906 .name = "VDDD_CDC_D",
907 .min_uV = 1225000,
908 .max_uV = 1225000,
909 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
910 },
911 {
912 .name = "CDC_VDDA_A_1P2V",
913 .min_uV = 1225000,
914 .max_uV = 1225000,
915 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
916 },
917 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700918};
919
920static struct slim_device msm_slim_tabla = {
921 .name = "tabla-slim",
922 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
923 .dev = {
924 .platform_data = &tabla_platform_data,
925 },
926};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530927
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530928static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530929 .slimbus_slave_device = {
930 .name = "tabla-slave",
931 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
932 },
933 .irq = MSM_GPIO_TO_INT(62),
934 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530935 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530936 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
937 .micbias = {
938 .ldoh_v = TABLA_LDOH_2P85_V,
939 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700940 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530941 .cfilt3_mv = 1800,
942 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
943 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
944 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
945 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530946 },
947 .regulator = {
948 {
949 .name = "CDC_VDD_CP",
950 .min_uV = 1800000,
951 .max_uV = 1800000,
952 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
953 },
954 {
955 .name = "CDC_VDDA_RX",
956 .min_uV = 1800000,
957 .max_uV = 1800000,
958 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
959 },
960 {
961 .name = "CDC_VDDA_TX",
962 .min_uV = 1800000,
963 .max_uV = 1800000,
964 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
965 },
966 {
967 .name = "VDDIO_CDC",
968 .min_uV = 1800000,
969 .max_uV = 1800000,
970 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
971 },
972 {
973 .name = "VDDD_CDC_D",
974 .min_uV = 1225000,
975 .max_uV = 1225000,
976 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
977 },
978 {
979 .name = "CDC_VDDA_A_1P2V",
980 .min_uV = 1225000,
981 .max_uV = 1225000,
982 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
983 },
984 },
Santosh Mardi60e19d92011-10-28 01:15:14 +0530985};
986
987static struct slim_device msm_slim_tabla20 = {
988 .name = "tabla2x-slim",
989 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
990 .dev = {
991 .platform_data = &tabla20_platform_data,
992 },
993};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700994#endif
995
996static struct slim_boardinfo msm_slim_devices[] = {
997#ifdef CONFIG_WCD9310_CODEC
998 {
999 .bus_num = 1,
1000 .slim_slave = &msm_slim_tabla,
1001 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301002 {
1003 .bus_num = 1,
1004 .slim_slave = &msm_slim_tabla20,
1005 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001006#endif
1007 /* add more slimbus slaves as needed */
1008};
1009
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001010#define MSM_WCNSS_PHYS 0x03000000
1011#define MSM_WCNSS_SIZE 0x280000
1012
1013static struct resource resources_wcnss_wlan[] = {
1014 {
1015 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1016 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1017 .name = "wcnss_wlanrx_irq",
1018 .flags = IORESOURCE_IRQ,
1019 },
1020 {
1021 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1022 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1023 .name = "wcnss_wlantx_irq",
1024 .flags = IORESOURCE_IRQ,
1025 },
1026 {
1027 .start = MSM_WCNSS_PHYS,
1028 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1029 .name = "wcnss_mmio",
1030 .flags = IORESOURCE_MEM,
1031 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001032 {
1033 .start = 84,
1034 .end = 88,
1035 .name = "wcnss_gpios_5wire",
1036 .flags = IORESOURCE_IO,
1037 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001038};
1039
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001040static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1041 .has_48mhz_xo = 1,
1042};
1043
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001044static struct platform_device msm_device_wcnss_wlan = {
1045 .name = "wcnss_wlan",
1046 .id = 0,
1047 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1048 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001049 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001050};
1051
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001052#ifdef CONFIG_QSEECOM
1053/* qseecom bus scaling */
1054static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1055 {
1056 .src = MSM_BUS_MASTER_SPS,
1057 .dst = MSM_BUS_SLAVE_EBI_CH0,
1058 .ib = 0,
1059 .ab = 0,
1060 },
1061 {
1062 .src = MSM_BUS_MASTER_SPDM,
1063 .dst = MSM_BUS_SLAVE_SPDM,
1064 .ib = 0,
1065 .ab = 0,
1066 },
1067};
1068
1069static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1070 {
1071 .src = MSM_BUS_MASTER_SPS,
1072 .dst = MSM_BUS_SLAVE_EBI_CH0,
1073 .ib = (492 * 8) * 1000000UL,
1074 .ab = (492 * 8) * 100000UL,
1075 },
1076 {
1077 .src = MSM_BUS_MASTER_SPDM,
1078 .dst = MSM_BUS_SLAVE_SPDM,
1079 .ib = 0,
1080 .ab = 0,
1081 },
1082};
1083
1084static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1085 {
1086 .src = MSM_BUS_MASTER_SPS,
1087 .dst = MSM_BUS_SLAVE_EBI_CH0,
1088 .ib = 0,
1089 .ab = 0,
1090 },
1091 {
1092 .src = MSM_BUS_MASTER_SPDM,
1093 .dst = MSM_BUS_SLAVE_SPDM,
1094 .ib = (64 * 8) * 1000000UL,
1095 .ab = (64 * 8) * 100000UL,
1096 },
1097};
1098
1099static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1100 {
1101 ARRAY_SIZE(qseecom_clks_init_vectors),
1102 qseecom_clks_init_vectors,
1103 },
1104 {
1105 ARRAY_SIZE(qseecom_enable_dfab_vectors),
1106 qseecom_enable_sfpb_vectors,
1107 },
1108 {
1109 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1110 qseecom_enable_sfpb_vectors,
1111 },
1112};
1113
1114static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1115 qseecom_hw_bus_scale_usecases,
1116 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1117 .name = "qsee",
1118};
1119
1120static struct platform_device qseecom_device = {
1121 .name = "qseecom",
1122 .id = 0,
1123 .dev = {
1124 .platform_data = &qseecom_bus_pdata,
1125 },
1126};
1127#endif
1128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001129#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1130 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1131 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1132 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1133
1134#define QCE_SIZE 0x10000
1135#define QCE_0_BASE 0x18500000
1136
1137#define QCE_HW_KEY_SUPPORT 0
1138#define QCE_SHA_HMAC_SUPPORT 1
1139#define QCE_SHARE_CE_RESOURCE 1
1140#define QCE_CE_SHARED 0
1141
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001142/* Begin Bus scaling definitions */
1143static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1144 {
1145 .src = MSM_BUS_MASTER_ADM_PORT0,
1146 .dst = MSM_BUS_SLAVE_EBI_CH0,
1147 .ab = 0,
1148 .ib = 0,
1149 },
1150 {
1151 .src = MSM_BUS_MASTER_ADM_PORT1,
1152 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1153 .ab = 0,
1154 .ib = 0,
1155 },
1156};
1157
1158static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1159 {
1160 .src = MSM_BUS_MASTER_ADM_PORT0,
1161 .dst = MSM_BUS_SLAVE_EBI_CH0,
1162 .ab = 70000000UL,
1163 .ib = 70000000UL,
1164 },
1165 {
1166 .src = MSM_BUS_MASTER_ADM_PORT1,
1167 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1168 .ab = 2480000000UL,
1169 .ib = 2480000000UL,
1170 },
1171};
1172
1173static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1174 {
1175 ARRAY_SIZE(crypto_hw_init_vectors),
1176 crypto_hw_init_vectors,
1177 },
1178 {
1179 ARRAY_SIZE(crypto_hw_active_vectors),
1180 crypto_hw_active_vectors,
1181 },
1182};
1183
1184static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1185 crypto_hw_bus_scale_usecases,
1186 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1187 .name = "cryptohw",
1188};
1189/* End Bus Scaling Definitions*/
1190
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001191static struct resource qcrypto_resources[] = {
1192 [0] = {
1193 .start = QCE_0_BASE,
1194 .end = QCE_0_BASE + QCE_SIZE - 1,
1195 .flags = IORESOURCE_MEM,
1196 },
1197 [1] = {
1198 .name = "crypto_channels",
1199 .start = DMOV_CE_IN_CHAN,
1200 .end = DMOV_CE_OUT_CHAN,
1201 .flags = IORESOURCE_DMA,
1202 },
1203 [2] = {
1204 .name = "crypto_crci_in",
1205 .start = DMOV_CE_IN_CRCI,
1206 .end = DMOV_CE_IN_CRCI,
1207 .flags = IORESOURCE_DMA,
1208 },
1209 [3] = {
1210 .name = "crypto_crci_out",
1211 .start = DMOV_CE_OUT_CRCI,
1212 .end = DMOV_CE_OUT_CRCI,
1213 .flags = IORESOURCE_DMA,
1214 },
1215};
1216
1217static struct resource qcedev_resources[] = {
1218 [0] = {
1219 .start = QCE_0_BASE,
1220 .end = QCE_0_BASE + QCE_SIZE - 1,
1221 .flags = IORESOURCE_MEM,
1222 },
1223 [1] = {
1224 .name = "crypto_channels",
1225 .start = DMOV_CE_IN_CHAN,
1226 .end = DMOV_CE_OUT_CHAN,
1227 .flags = IORESOURCE_DMA,
1228 },
1229 [2] = {
1230 .name = "crypto_crci_in",
1231 .start = DMOV_CE_IN_CRCI,
1232 .end = DMOV_CE_IN_CRCI,
1233 .flags = IORESOURCE_DMA,
1234 },
1235 [3] = {
1236 .name = "crypto_crci_out",
1237 .start = DMOV_CE_OUT_CRCI,
1238 .end = DMOV_CE_OUT_CRCI,
1239 .flags = IORESOURCE_DMA,
1240 },
1241};
1242
1243#endif
1244
1245#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1246 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1247
1248static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1249 .ce_shared = QCE_CE_SHARED,
1250 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1251 .hw_key_support = QCE_HW_KEY_SUPPORT,
1252 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001253 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001254};
1255
1256static struct platform_device qcrypto_device = {
1257 .name = "qcrypto",
1258 .id = 0,
1259 .num_resources = ARRAY_SIZE(qcrypto_resources),
1260 .resource = qcrypto_resources,
1261 .dev = {
1262 .coherent_dma_mask = DMA_BIT_MASK(32),
1263 .platform_data = &qcrypto_ce_hw_suppport,
1264 },
1265};
1266#endif
1267
1268#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1269 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1270
1271static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1272 .ce_shared = QCE_CE_SHARED,
1273 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1274 .hw_key_support = QCE_HW_KEY_SUPPORT,
1275 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001276 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001277};
1278
1279static struct platform_device qcedev_device = {
1280 .name = "qce",
1281 .id = 0,
1282 .num_resources = ARRAY_SIZE(qcedev_resources),
1283 .resource = qcedev_resources,
1284 .dev = {
1285 .coherent_dma_mask = DMA_BIT_MASK(32),
1286 .platform_data = &qcedev_ce_hw_suppport,
1287 },
1288};
1289#endif
1290
Joel Kingb8352a12011-11-15 18:46:24 -08001291#define MDM2AP_ERRFATAL 70
1292#define AP2MDM_ERRFATAL 95
1293#define MDM2AP_STATUS 69
1294#define AP2MDM_STATUS 94
1295#define AP2MDM_PMIC_RESET_N 80
1296#define AP2MDM_KPDPWR_N 81
1297
Joel Kingb8352a12011-11-15 18:46:24 -08001298static struct resource mdm_resources[] = {
1299 {
1300 .start = MDM2AP_ERRFATAL,
1301 .end = MDM2AP_ERRFATAL,
1302 .name = "MDM2AP_ERRFATAL",
1303 .flags = IORESOURCE_IO,
1304 },
1305 {
1306 .start = AP2MDM_ERRFATAL,
1307 .end = AP2MDM_ERRFATAL,
1308 .name = "AP2MDM_ERRFATAL",
1309 .flags = IORESOURCE_IO,
1310 },
1311 {
1312 .start = MDM2AP_STATUS,
1313 .end = MDM2AP_STATUS,
1314 .name = "MDM2AP_STATUS",
1315 .flags = IORESOURCE_IO,
1316 },
1317 {
1318 .start = AP2MDM_STATUS,
1319 .end = AP2MDM_STATUS,
1320 .name = "AP2MDM_STATUS",
1321 .flags = IORESOURCE_IO,
1322 },
1323 {
1324 .start = AP2MDM_PMIC_RESET_N,
1325 .end = AP2MDM_PMIC_RESET_N,
1326 .name = "AP2MDM_PMIC_RESET_N",
1327 .flags = IORESOURCE_IO,
1328 },
1329 {
1330 .start = AP2MDM_KPDPWR_N,
1331 .end = AP2MDM_KPDPWR_N,
1332 .name = "AP2MDM_KPDPWR_N",
1333 .flags = IORESOURCE_IO,
1334 },
1335};
1336
1337static struct mdm_platform_data mdm_platform_data = {
1338 .mdm_version = "2.5",
1339};
1340
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001341static struct platform_device mdm_device = {
Joel Kingb8352a12011-11-15 18:46:24 -08001342 .name = "mdm2_modem",
1343 .id = -1,
1344 .num_resources = ARRAY_SIZE(mdm_resources),
1345 .resource = mdm_resources,
1346 .dev = {
1347 .platform_data = &mdm_platform_data,
1348 },
1349};
1350
1351static struct platform_device *mdm_devices[] __initdata = {
1352 &mdm_device,
1353};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001354
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001355#define MSM_SHARED_RAM_PHYS 0x80000000
1356
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001357static void __init msm8960_map_io(void)
1358{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001359 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001360 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001361
1362 if (socinfo_init() < 0)
1363 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001364}
1365
1366static void __init msm8960_init_irq(void)
1367{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001368 struct msm_mpm_device_data *data = NULL;
1369
1370#ifdef CONFIG_MSM_MPM
1371 data = &msm8960_mpm_dev_data;
1372#endif
1373
1374 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001375 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001376 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001377}
1378
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001379static void __init msm8960_init_buses(void)
1380{
1381#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001382 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001383 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1384 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
1385 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1386 msm_bus_apps_fabric.dev.platform_data =
1387 &msm_bus_8960_apps_fabric_pdata;
1388 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
1389 msm_bus_mm_fabric.dev.platform_data = &msm_bus_8960_mm_fabric_pdata;
1390 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1391 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001392#endif
1393}
1394
1395static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1396 .max_clock_speed = 15060000,
1397};
1398
1399#ifdef CONFIG_USB_MSM_OTG_72K
1400static struct msm_otg_platform_data msm_otg_pdata;
1401#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301402static int wr_phy_init_seq[] = {
1403 0x44, 0x80, /* set VBUS valid threshold
1404 and disconnect valid threshold */
1405 0x38, 0x81, /* update DC voltage level */
1406 0x14, 0x82, /* set preemphasis and rise/fall time */
1407 0x13, 0x83, /* set source impedance adjusment */
1408 -1};
1409
1410static int liquid_v1_phy_init_seq[] = {
1411 0x44, 0x80,/* set VBUS valid threshold
1412 and disconnect valid threshold */
1413 0x3C, 0x81,/* update DC voltage level */
1414 0x18, 0x82,/* set preemphasis and rise/fall time */
1415 0x23, 0x83,/* set source impedance sdjusment */
1416 -1};
1417
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301418#ifdef CONFIG_MSM_BUS_SCALING
1419/* Bandwidth requests (zero) if no vote placed */
1420static struct msm_bus_vectors usb_init_vectors[] = {
1421 {
1422 .src = MSM_BUS_MASTER_SPS,
1423 .dst = MSM_BUS_SLAVE_EBI_CH0,
1424 .ab = 0,
1425 .ib = 0,
1426 },
1427};
1428
1429/* Bus bandwidth requests in Bytes/sec */
1430static struct msm_bus_vectors usb_max_vectors[] = {
1431 {
1432 .src = MSM_BUS_MASTER_SPS,
1433 .dst = MSM_BUS_SLAVE_EBI_CH0,
1434 .ab = 60000000, /* At least 480Mbps on bus. */
1435 .ib = 960000000, /* MAX bursts rate */
1436 },
1437};
1438
1439static struct msm_bus_paths usb_bus_scale_usecases[] = {
1440 {
1441 ARRAY_SIZE(usb_init_vectors),
1442 usb_init_vectors,
1443 },
1444 {
1445 ARRAY_SIZE(usb_max_vectors),
1446 usb_max_vectors,
1447 },
1448};
1449
1450static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1451 usb_bus_scale_usecases,
1452 ARRAY_SIZE(usb_bus_scale_usecases),
1453 .name = "usb",
1454};
1455#endif
1456
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001457static struct msm_otg_platform_data msm_otg_pdata = {
1458 .mode = USB_OTG,
1459 .otg_control = OTG_PMIC_CONTROL,
1460 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001461 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301462 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301463#ifdef CONFIG_MSM_BUS_SCALING
1464 .bus_scale_table = &usb_bus_scale_pdata,
1465#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001466};
1467#endif
1468
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301469#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301470#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301471static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1472 .strobe = 150,
1473 .data = 151,
1474};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301475
1476static struct smsc_hub_platform_data hsic_hub_pdata = {
1477 .hub_reset = HSIC_HUB_RESET_GPIO,
1478};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301479#else
1480static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301481static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301482#endif
1483
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301484static struct platform_device smsc_hub_device = {
1485 .name = "msm_smsc_hub",
1486 .id = -1,
1487 .dev = {
1488 .platform_data = &hsic_hub_pdata,
1489 },
1490};
1491
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001492#define PID_MAGIC_ID 0x71432909
1493#define SERIAL_NUM_MAGIC_ID 0x61945374
1494#define SERIAL_NUMBER_LENGTH 127
1495#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1496
1497struct magic_num_struct {
1498 uint32_t pid;
1499 uint32_t serial_num;
1500};
1501
1502struct dload_struct {
1503 uint32_t reserved1;
1504 uint32_t reserved2;
1505 uint32_t reserved3;
1506 uint16_t reserved4;
1507 uint16_t pid;
1508 char serial_number[SERIAL_NUMBER_LENGTH];
1509 uint16_t reserved5;
1510 struct magic_num_struct magic_struct;
1511};
1512
1513static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1514{
1515 struct dload_struct __iomem *dload = 0;
1516
1517 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1518 if (!dload) {
1519 pr_err("%s: cannot remap I/O memory region: %08x\n",
1520 __func__, DLOAD_USB_BASE_ADD);
1521 return -ENXIO;
1522 }
1523
1524 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1525 __func__, dload, pid, snum);
1526 /* update pid */
1527 dload->magic_struct.pid = PID_MAGIC_ID;
1528 dload->pid = pid;
1529
1530 /* update serial number */
1531 dload->magic_struct.serial_num = 0;
1532 if (!snum) {
1533 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1534 goto out;
1535 }
1536
1537 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001538 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001539out:
1540 iounmap(dload);
1541 return 0;
1542}
1543
1544static struct android_usb_platform_data android_usb_pdata = {
1545 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1546};
1547
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001548static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001549 .name = "android_usb",
1550 .id = -1,
1551 .dev = {
1552 .platform_data = &android_usb_pdata,
1553 },
1554};
1555
1556static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1557 0x03, 0x0f,
1558};
1559
1560static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1561 0x00, 0x24, 0x54, 0x10,
1562 0x09, 0x03, 0x01,
1563 0x10, 0x54, 0x30, 0x0C,
1564 0x24, 0x30, 0x0f,
1565};
1566
1567static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1568 0x00, 0x24, 0x54, 0x10,
1569 0x09, 0x07, 0x01, 0x0B,
1570 0x10, 0x54, 0x30, 0x0C,
1571 0x24, 0x30, 0x0f,
1572};
1573
1574static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
1575 [0] = {
1576 .mode = MSM_SPM_MODE_CLOCK_GATING,
1577 .notify_rpm = false,
1578 .cmd = spm_wfi_cmd_sequence,
1579 },
1580 [1] = {
1581 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1582 .notify_rpm = false,
1583 .cmd = spm_power_collapse_without_rpm,
1584 },
1585 [2] = {
1586 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1587 .notify_rpm = true,
1588 .cmd = spm_power_collapse_with_rpm,
1589 },
1590};
1591
1592static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1593 [0] = {
1594 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001595 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001596#if defined(CONFIG_MSM_AVS_HW)
1597 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1598 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1599#endif
1600 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001601 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001602 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1603 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1604 .vctl_timeout_us = 50,
1605 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1606 .modes = msm_spm_seq_list,
1607 },
1608 [1] = {
1609 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001610 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001611#if defined(CONFIG_MSM_AVS_HW)
1612 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1613 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1614#endif
1615 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001616 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001617 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1618 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1619 .vctl_timeout_us = 50,
1620 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1621 .modes = msm_spm_seq_list,
1622 },
1623};
1624
1625static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1626 0x00, 0x20, 0x03, 0x20,
1627 0x00, 0x0f,
1628};
1629
1630static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1631 0x00, 0x20, 0x34, 0x64,
1632 0x48, 0x07, 0x48, 0x20,
1633 0x50, 0x64, 0x04, 0x34,
1634 0x50, 0x0f,
1635};
1636static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1637 0x00, 0x10, 0x34, 0x64,
1638 0x48, 0x07, 0x48, 0x10,
1639 0x50, 0x64, 0x04, 0x34,
1640 0x50, 0x0F,
1641};
1642
1643static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1644 [0] = {
1645 .mode = MSM_SPM_L2_MODE_RETENTION,
1646 .notify_rpm = false,
1647 .cmd = l2_spm_wfi_cmd_sequence,
1648 },
1649 [1] = {
1650 .mode = MSM_SPM_L2_MODE_GDHS,
1651 .notify_rpm = true,
1652 .cmd = l2_spm_gdhs_cmd_sequence,
1653 },
1654 [2] = {
1655 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1656 .notify_rpm = true,
1657 .cmd = l2_spm_power_off_cmd_sequence,
1658 },
1659};
1660
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001661static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1662 [0] = {
1663 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001664 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001665 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001666 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1667 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1668 .modes = msm_spm_l2_seq_list,
1669 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1670 },
1671};
1672
Mohan Pallaka5e490392011-09-09 15:18:41 +05301673#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1674#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1675
1676static struct msm_xo_voter *xo_handle_d1;
1677
1678static int isa1200_power(int on)
1679{
1680 int rc = 0;
1681
1682 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, !!on);
1683
1684 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1685 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1686 if (rc < 0) {
1687 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1688 __func__, on ? "" : "de-", rc);
1689 goto err_xo_vote;
1690 }
1691
1692 return 0;
1693
1694err_xo_vote:
1695 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, !on);
1696 return rc;
1697}
1698
1699static int isa1200_dev_setup(bool enable)
1700{
1701 int rc = 0;
1702
1703 struct pm_gpio hap_gpio_config = {
1704 .direction = PM_GPIO_DIR_OUT,
1705 .pull = PM_GPIO_PULL_NO,
1706 .out_strength = PM_GPIO_STRENGTH_HIGH,
1707 .function = PM_GPIO_FUNC_NORMAL,
1708 .inv_int_pol = 0,
1709 .vin_sel = 2,
1710 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1711 .output_value = 0,
1712 };
1713
1714 if (enable == true) {
1715 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1716 if (rc) {
1717 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1718 __func__, PM_HAP_EN_GPIO, rc);
1719 return rc;
1720 }
1721
1722 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1723 if (rc) {
1724 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1725 __func__, PM_HAP_LEN_GPIO, rc);
1726 return rc;
1727 }
1728
1729 rc = gpio_request(HAP_SHIFT_LVL_OE_GPIO, "hap_shft_lvl_oe");
1730 if (rc) {
1731 pr_err("%s: unable to request gpio %d (%d)\n",
1732 __func__, HAP_SHIFT_LVL_OE_GPIO, rc);
1733 return rc;
1734 }
1735
1736 rc = gpio_direction_output(HAP_SHIFT_LVL_OE_GPIO, 0);
1737 if (rc) {
1738 pr_err("%s: Unable to set direction\n", __func__);
1739 goto free_gpio;
1740 }
1741
1742 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1743 if (IS_ERR(xo_handle_d1)) {
1744 rc = PTR_ERR(xo_handle_d1);
1745 pr_err("%s: failed to get the handle for D1(%d)\n",
1746 __func__, rc);
1747 goto gpio_set_dir;
1748 }
1749 } else {
1750 gpio_free(HAP_SHIFT_LVL_OE_GPIO);
1751
1752 msm_xo_put(xo_handle_d1);
1753 }
1754
1755 return 0;
1756
1757gpio_set_dir:
1758 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, 0);
1759free_gpio:
1760 gpio_free(HAP_SHIFT_LVL_OE_GPIO);
1761 return rc;
1762}
1763
1764static struct isa1200_regulator isa1200_reg_data[] = {
1765 {
1766 .name = "vcc_i2c",
1767 .min_uV = ISA_I2C_VTG_MIN_UV,
1768 .max_uV = ISA_I2C_VTG_MAX_UV,
1769 .load_uA = ISA_I2C_CURR_UA,
1770 },
1771};
1772
1773static struct isa1200_platform_data isa1200_1_pdata = {
1774 .name = "vibrator",
1775 .dev_setup = isa1200_dev_setup,
1776 .power_on = isa1200_power,
1777 .hap_en_gpio = PM_HAP_EN_GPIO,
1778 .hap_len_gpio = PM_HAP_LEN_GPIO,
1779 .max_timeout = 15000,
1780 .mode_ctrl = PWM_GEN_MODE,
1781 .pwm_fd = {
1782 .pwm_div = 256,
1783 },
1784 .is_erm = false,
1785 .smart_en = true,
1786 .ext_clk_en = true,
1787 .chip_en = 1,
1788 .regulator_info = isa1200_reg_data,
1789 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1790};
1791
1792static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1793 {
1794 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05301795 },
1796};
1797
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798#define CYTTSP_TS_GPIO_IRQ 11
1799#define CYTTSP_TS_SLEEP_GPIO 50
1800#define CYTTSP_TS_RESOUT_N_GPIO 52
1801
1802/*virtual key support */
1803static ssize_t tma340_vkeys_show(struct kobject *kobj,
1804 struct kobj_attribute *attr, char *buf)
1805{
1806 return snprintf(buf, 200,
1807 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1808 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1809 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1810 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1811 "\n");
1812}
1813
1814static struct kobj_attribute tma340_vkeys_attr = {
1815 .attr = {
1816 .mode = S_IRUGO,
1817 },
1818 .show = &tma340_vkeys_show,
1819};
1820
1821static struct attribute *tma340_properties_attrs[] = {
1822 &tma340_vkeys_attr.attr,
1823 NULL
1824};
1825
1826static struct attribute_group tma340_properties_attr_group = {
1827 .attrs = tma340_properties_attrs,
1828};
1829
1830
1831static int cyttsp_platform_init(struct i2c_client *client)
1832{
1833 int rc = 0;
1834 static struct kobject *tma340_properties_kobj;
1835
1836 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1837 tma340_properties_kobj = kobject_create_and_add("board_properties",
1838 NULL);
1839 if (tma340_properties_kobj)
1840 rc = sysfs_create_group(tma340_properties_kobj,
1841 &tma340_properties_attr_group);
1842 if (!tma340_properties_kobj || rc)
1843 pr_err("%s: failed to create board_properties\n",
1844 __func__);
1845
1846 return 0;
1847}
1848
1849static struct cyttsp_regulator regulator_data[] = {
1850 {
1851 .name = "vdd",
1852 .min_uV = CY_TMA300_VTG_MIN_UV,
1853 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05301854 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1855 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001856 },
1857 /* TODO: Remove after runtime PM is enabled in I2C driver */
1858 {
1859 .name = "vcc_i2c",
1860 .min_uV = CY_I2C_VTG_MIN_UV,
1861 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05301862 .hpm_load_uA = CY_I2C_CURR_UA,
1863 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001864 },
1865};
1866
1867static struct cyttsp_platform_data cyttsp_pdata = {
1868 .panel_maxx = 634,
1869 .panel_maxy = 1166,
1870 .disp_maxx = 616,
1871 .disp_maxy = 1023,
1872 .disp_minx = 0,
1873 .disp_miny = 16,
1874 .flags = 0x01,
1875 .gen = CY_GEN3, /* or */
1876 .use_st = CY_USE_ST,
1877 .use_mt = CY_USE_MT,
1878 .use_hndshk = CY_SEND_HNDSHK,
1879 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05301880 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001881 .use_gestures = CY_USE_GESTURES,
1882 .fw_fname = "cyttsp_8960_cdp.hex",
1883 /* activate up to 4 groups
1884 * and set active distance
1885 */
1886 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
1887 CY_GEST_GRP3 | CY_GEST_GRP4 |
1888 CY_ACT_DIST,
1889 /* change act_intrvl to customize the Active power state
1890 * scanning/processing refresh interval for Operating mode
1891 */
1892 .act_intrvl = CY_ACT_INTRVL_DFLT,
1893 /* change tch_tmout to customize the touch timeout for the
1894 * Active power state for Operating mode
1895 */
1896 .tch_tmout = CY_TCH_TMOUT_DFLT,
1897 /* change lp_intrvl to customize the Low Power power state
1898 * scanning/processing refresh interval for Operating mode
1899 */
1900 .lp_intrvl = CY_LP_INTRVL_DFLT,
1901 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
1902 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
1903 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1904 .regulator_info = regulator_data,
1905 .num_regulators = ARRAY_SIZE(regulator_data),
1906 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05301907 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908};
1909
1910static struct i2c_board_info cyttsp_info[] __initdata = {
1911 {
1912 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1913 .platform_data = &cyttsp_pdata,
1914#ifndef CY_USE_TIMER
1915 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1916#endif /* CY_USE_TIMER */
1917 },
1918};
1919
Jing Lindc4413c2012-01-16 15:22:52 -08001920/* configuration data for mxt1386 */
1921static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05301922 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001923 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301924 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001925 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07001926 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1927 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1928 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1929 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1930 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1931 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301932 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001933 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05301934 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001935 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05301936 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001937 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
1938 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
1939 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
1940 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05301941 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001942 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1943 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05301944 /* T18 Object */
1945 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301946 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001947 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
1948 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301949 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001950 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1951 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301952 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001953 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
1954 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301955 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001956 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301957 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001958 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05301959 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001960 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301961 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001962 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301963 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001964 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301965};
1966
Jing Lin33b007d2011-12-21 17:40:23 -08001967/* configuration data for mxt1386e using V1.0 firmware */
1968static const u8 mxt1386e_config_data_v1_0[] = {
1969 /* T6 Object */
1970 0, 0, 0, 0, 0, 0,
1971 /* T38 Object */
1972 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
1973 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1974 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1975 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1976 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1977 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1978 0, 0, 0, 0,
1979 /* T7 Object */
1980 100, 16, 50,
1981 /* T8 Object */
1982 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
1983 /* T9 Object */
1984 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
1985 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
1986 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
1987 10, 5, 0, 0, 0,
1988 /* T18 Object */
1989 0, 0,
1990 /* T24 Object */
1991 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1992 0, 0, 0, 0, 0, 0, 0, 0, 0,
1993 /* T25 Object */
1994 3, 0, 60, 115, 156, 99,
1995 /* T27 Object */
1996 0, 0, 0, 0, 0, 0, 0,
1997 /* T40 Object */
1998 0, 0, 0, 0, 0,
1999 /* T42 Object */
2000 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2001 /* T43 Object */
2002 0, 0, 0, 0, 0, 0, 0,
2003 /* T46 Object */
2004 64, 0, 20, 20, 0, 0, 0, 0, 0,
2005 /* T47 Object */
2006 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2007 /* T48 Object */
2008 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2009 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2010 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2011 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2012 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2013 0, 0, 0, 0,
2014 /* T56 Object */
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, 0, 0, 0, 0, 0, 0,
2018 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2019 2, 99, 33,
2020};
2021
2022/* configuration data for mxt1386e using V2.1 firmware */
2023static const u8 mxt1386e_config_data_v2_1[] = {
2024 /* T6 Object */
2025 0, 0, 0, 0, 0, 0,
2026 /* T38 Object */
2027 12, 2, 0, 17, 1, 12, 0, 0, 0, 0,
2028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2029 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2030 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2031 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2032 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2033 0, 0, 0, 0,
2034 /* T7 Object */
2035 100, 16, 50,
2036 /* T8 Object */
2037 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2038 /* T9 Object */
2039 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2040 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2041 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2042 10, 5, 0, 0, 0,
2043 /* T18 Object */
2044 0, 0,
2045 /* T24 Object */
2046 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2047 0, 0, 0, 0, 0, 0, 0, 0, 0,
2048 /* T25 Object */
2049 3, 0, 60, 115, 156, 99,
2050 /* T27 Object */
2051 0, 0, 0, 0, 0, 0, 0,
2052 /* T40 Object */
2053 0, 0, 0, 0, 0,
2054 /* T42 Object */
2055 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2056 /* T43 Object */
2057 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2058 16,
2059 /* T46 Object */
2060 64, 0, 20, 20, 0, 0, 0, 0, 0,
2061 /* T47 Object */
2062 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2063 /* T48 Object */
2064 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2065 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2066 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2067 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2068 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2069 0, 0, 0, 0,
2070 /* T56 Object */
2071 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2072 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2073 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2074 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2075 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2076 255,
2077};
2078
Jing Lineec88ca2012-02-08 11:18:30 -08002079/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2080static const u8 mxt1386e_config_data_3d[] = {
2081 /* T6 Object */
2082 0, 0, 0, 0, 0, 0,
2083 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002084 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002085 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2086 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2087 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2088 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2089 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2090 0, 0, 0, 0,
2091 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002092 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002093 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002094 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002095 /* T9 Object */
2096 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2097 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002098 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2099 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002100 /* T18 Object */
2101 0, 0,
2102 /* T24 Object */
2103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2104 0, 0, 0, 0, 0, 0, 0, 0, 0,
2105 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002106 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002107 /* T27 Object */
2108 0, 0, 0, 0, 0, 0, 0,
2109 /* T40 Object */
2110 0, 0, 0, 0, 0,
2111 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002113 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2115 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002116 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002117 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002118 /* T47 Object */
2119 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2120 /* T48 Object */
2121 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002122 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2123 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2124 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2126 0, 0, 0, 0,
2127 /* T56 Object */
2128 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2133 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002134};
2135
Amy Maloche08266db2011-11-04 11:07:16 -07002136#define MXT_TS_GPIO_IRQ 11
2137#define MXT_TS_LDO_EN_GPIO 50
2138#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302139
2140static void mxt_init_hw_liquid(void)
2141{
2142 int rc;
2143
Mohan Pallaka50837382011-09-07 11:00:57 +05302144 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2145 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002146 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2147 __func__, MXT_TS_LDO_EN_GPIO);
2148 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302149 }
2150
2151 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2152 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002153 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2154 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302155 goto err_ldo_gpio_req;
2156 }
2157
Mohan Pallaka50837382011-09-07 11:00:57 +05302158 return;
2159
Mohan Pallaka50837382011-09-07 11:00:57 +05302160err_ldo_gpio_req:
2161 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302162}
2163
Jing Lineec88ca2012-02-08 11:18:30 -08002164static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002165 {
2166 .config = mxt1386_config_data,
2167 .config_length = ARRAY_SIZE(mxt1386_config_data),
2168 .family_id = 0xA0,
2169 .variant_id = 0x0,
2170 .version = 0x10,
2171 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002172 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002173 },
Jing Lin33b007d2011-12-21 17:40:23 -08002174 {
2175 .config = mxt1386e_config_data_v1_0,
2176 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2177 .family_id = 0xA0,
2178 .variant_id = 0x2,
2179 .version = 0x10,
2180 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002181 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002182 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002183 },
2184 {
2185 .config = mxt1386e_config_data_v2_1,
2186 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2187 .family_id = 0xA0,
2188 .variant_id = 0x7,
2189 .version = 0x21,
2190 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002191 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002192 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2193 },
2194 {
2195 /* The config data for V2.2.AA is the same as for V2.1.AA */
2196 .config = mxt1386e_config_data_v2_1,
2197 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2198 .family_id = 0xA0,
2199 .variant_id = 0x7,
2200 .version = 0x22,
2201 .build = 0xAA,
2202 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002203 },
Jing Lindc4413c2012-01-16 15:22:52 -08002204};
2205
Jing Lineec88ca2012-02-08 11:18:30 -08002206static struct mxt_platform_data mxt_platform_data_2d = {
2207 .config_array = mxt_config_array_2d,
2208 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002209 .panel_minx = 0,
2210 .panel_maxx = 1365,
2211 .panel_miny = 0,
2212 .panel_maxy = 767,
2213 .disp_minx = 0,
2214 .disp_maxx = 1365,
2215 .disp_miny = 0,
2216 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302217 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002218 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002219 .reset_gpio = MXT_TS_RESET_GPIO,
2220 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302221};
2222
Jing Lineec88ca2012-02-08 11:18:30 -08002223static struct mxt_config_info mxt_config_array_3d[] = {
2224 {
2225 .config = mxt1386e_config_data_3d,
2226 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2227 .family_id = 0xA0,
2228 .variant_id = 0x7,
2229 .version = 0x21,
2230 .build = 0xAA,
2231 },
2232};
2233
2234static struct mxt_platform_data mxt_platform_data_3d = {
2235 .config_array = mxt_config_array_3d,
2236 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002237 .panel_minx = 0,
2238 .panel_maxx = 1919,
2239 .panel_miny = 0,
2240 .panel_maxy = 1199,
2241 .disp_minx = 0,
2242 .disp_maxx = 1919,
2243 .disp_miny = 0,
2244 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002245 .irqflags = IRQF_TRIGGER_FALLING,
2246 .i2c_pull_up = true,
2247 .reset_gpio = MXT_TS_RESET_GPIO,
2248 .irq_gpio = MXT_TS_GPIO_IRQ,
2249};
2250
Mohan Pallaka50837382011-09-07 11:00:57 +05302251static struct i2c_board_info mxt_device_info[] __initdata = {
2252 {
2253 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302254 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2255 },
2256};
2257
Manoj Rao14648742012-03-30 19:42:12 -07002258#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2259static void mhl_sii_reset_gpio(int on)
2260{
2261 gpio_set_value(MHL_GPIO_RESET, on);
2262 return;
2263}
2264
2265/*
2266 * Request for GPIO allocations
2267 * Set appropriate GPIO directions
2268 */
2269static int mhl_sii_gpio_setup(int on)
2270{
2271 int ret;
2272
2273 if (on) {
2274 ret = gpio_request(MHL_GPIO_RESET, "W_RST#");
2275 if (ret < 0) {
2276 pr_err("GPIO RESET request failed: %d\n", ret);
2277 return -EBUSY;
2278 }
2279 ret = gpio_direction_output(MHL_GPIO_RESET, 1);
2280 if (ret < 0) {
2281 pr_err("SET GPIO RESET direction failed: %d\n", ret);
2282 gpio_free(MHL_GPIO_RESET);
2283 return -EBUSY;
2284 }
2285 ret = gpio_request(MHL_GPIO_INT, "W_INT");
2286 if (ret < 0) {
2287 pr_err("GPIO INT request failed: %d\n", ret);
2288 gpio_free(MHL_GPIO_RESET);
2289 return -EBUSY;
2290 }
2291 ret = gpio_direction_input(MHL_GPIO_INT);
2292 if (ret < 0) {
2293 pr_err("SET GPIO INTR direction failed: %d\n", ret);
2294 gpio_free(MHL_GPIO_RESET);
2295 gpio_free(MHL_GPIO_INT);
2296 return -EBUSY;
2297 }
2298 } else {
2299 gpio_free(MHL_GPIO_RESET);
2300 gpio_free(MHL_GPIO_INT);
2301 }
2302
2303 return 0;
2304}
2305
2306static struct msm_mhl_platform_data mhl_platform_data = {
2307 .irq = MSM_GPIO_TO_INT(4),
2308 .gpio_setup = mhl_sii_gpio_setup,
2309 .reset_pin = mhl_sii_reset_gpio,
2310};
2311#endif
2312
Eugene Yasmand2316b82011-12-07 18:23:48 +02002313static struct i2c_board_info sii_device_info[] __initdata = {
2314 {
Manoj Rao14648742012-03-30 19:42:12 -07002315#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2316 /*
2317 * keeps SI 8334 as the default
2318 * MHL TX
2319 */
2320 I2C_BOARD_INFO("sii8334", 0x39),
2321 .platform_data = &mhl_platform_data,
2322#endif
2323#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002324 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002325 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002326#endif /* CONFIG_MSM_HDMI_MHL */
2327 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002328 },
2329};
2330
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002331static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2332 .clk_freq = 100000,
2333 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002334};
2335
2336static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2337 .clk_freq = 100000,
2338 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002339};
2340
2341static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2342 .clk_freq = 100000,
2343 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002344};
2345
2346static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2347 .clk_freq = 100000,
2348 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002349};
2350
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06002351static struct msm_pm_sleep_status_data msm_pm_slp_sts_data = {
2352 .base_addr = MSM_ACC0_BASE + 0x08,
2353 .cpu_offset = MSM_ACC1_BASE - MSM_ACC0_BASE,
2354 .mask = 1UL << 13,
2355};
2356
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002357static struct ks8851_pdata spi_eth_pdata = {
2358 .irq_gpio = KS8851_IRQ_GPIO,
2359 .rst_gpio = KS8851_RST_GPIO,
2360};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002361
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002362static struct spi_board_info spi_board_info[] __initdata = {
2363 {
2364 .modalias = "ks8851",
2365 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2366 .max_speed_hz = 19200000,
2367 .bus_num = 0,
2368 .chip_select = 0,
2369 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002370 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002371 },
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002372 {
2373 .modalias = "dsi_novatek_3d_panel_spi",
2374 .max_speed_hz = 10800000,
2375 .bus_num = 0,
2376 .chip_select = 1,
2377 .mode = SPI_MODE_0,
2378 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002379};
2380
2381static struct platform_device msm_device_saw_core0 = {
2382 .name = "saw-regulator",
2383 .id = 0,
2384 .dev = {
2385 .platform_data = &msm_saw_regulator_pdata_s5,
2386 },
2387};
2388
2389static struct platform_device msm_device_saw_core1 = {
2390 .name = "saw-regulator",
2391 .id = 1,
2392 .dev = {
2393 .platform_data = &msm_saw_regulator_pdata_s6,
2394 },
2395};
2396
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002397static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002398 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002399 .tsens_factor = 1000,
2400 .hw_type = MSM_8960,
2401 .tsens_num_sensor = 5,
2402};
2403
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002404static struct platform_device msm_tsens_device = {
2405 .name = "tsens8960-tm",
2406 .id = -1,
2407};
2408
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002409#ifdef CONFIG_MSM_FAKE_BATTERY
2410static struct platform_device fish_battery_device = {
2411 .name = "fish_battery",
2412};
2413#endif
2414
David Collins26f05562011-06-20 09:56:28 -07002415static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002416 .name = GPIO_REGULATOR_DEV_NAME,
2417 .id = PM8921_MPP_PM_TO_SYS(7),
2418 .dev = {
2419 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2420 },
2421};
2422
David Collins26f05562011-06-20 09:56:28 -07002423static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002424 .name = GPIO_REGULATOR_DEV_NAME,
2425 .id = 91,
2426 .dev = {
2427 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2428 },
2429};
2430
David Collinsb10be1d2011-09-02 10:29:31 -07002431static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2432 .name = GPIO_REGULATOR_DEV_NAME,
2433 .id = PM8921_GPIO_PM_TO_SYS(17),
2434 .dev = {
2435 .platform_data =
2436 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2437 },
2438};
2439
David Collins35a78f52011-12-14 15:54:25 -08002440static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2441 .name = GPIO_REGULATOR_DEV_NAME,
2442 .id = PM8921_GPIO_PM_TO_SYS(42),
2443 .dev = {
2444 .platform_data =
2445 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2446 },
2447};
2448
David Collins26f05562011-06-20 09:56:28 -07002449static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2450 .name = "rpm-regulator",
2451 .id = -1,
2452 .dev = {
2453 .platform_data = &msm_rpm_regulator_pdata,
2454 },
2455};
Mayank Ranae009c922012-03-22 03:02:06 +05302456#ifdef CONFIG_SERIAL_MSM_HS
2457static int configure_uart_gpios(int on)
2458{
2459 int ret = 0, i;
2460 int uart_gpios[] = {93, 94, 95, 96};
2461
2462 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2463 if (on) {
2464 ret = gpio_request(uart_gpios[i], NULL);
2465 if (ret) {
2466 pr_err("%s: unable to request uart gpio[%d]\n",
2467 __func__, uart_gpios[i]);
2468 break;
2469 }
2470 } else {
2471 gpio_free(uart_gpios[i]);
2472 }
2473 }
2474
2475 if (ret && on && i)
2476 for (; i >= 0; i--)
2477 gpio_free(uart_gpios[i]);
2478 return ret;
2479}
2480
2481static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002482 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302483};
2484#else
2485static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2486#endif
David Collins26f05562011-06-20 09:56:28 -07002487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002488static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002489 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002490 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302491 &msm_device_uart_dm6,
Mayank Ranae009c922012-03-22 03:02:06 +05302492 &msm_device_uart_dm9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002493 &msm_device_saw_core0,
2494 &msm_device_saw_core1,
2495 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002496 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002497 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002498 &msm8960_device_qup_spi_gsbi1,
2499 &msm8960_device_qup_i2c_gsbi3,
2500 &msm8960_device_qup_i2c_gsbi4,
2501 &msm8960_device_qup_i2c_gsbi10,
2502#ifndef CONFIG_MSM_DSPS
2503 &msm8960_device_qup_i2c_gsbi12,
2504#endif
2505 &msm_slim_ctrl,
2506 &msm_device_wcnss_wlan,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002507#if defined(CONFIG_QSEECOM)
2508 &qseecom_device,
2509#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002510#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2511 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2512 &qcrypto_device,
2513#endif
2514
2515#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2516 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2517 &qcedev_device,
2518#endif
2519#ifdef CONFIG_MSM_ROTATOR
2520 &msm_rotator_device,
2521#endif
2522 &msm_device_sps,
2523#ifdef CONFIG_MSM_FAKE_BATTERY
2524 &fish_battery_device,
2525#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002526 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002527#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002528#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002529 &msm8960_android_pmem_device,
2530 &msm8960_android_pmem_adsp_device,
2531 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002532#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002533#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002534 &msm_device_vidc,
2535 &msm_device_bam_dmux,
2536 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07002537
Joel Nidera1261942011-09-12 16:30:09 +03002538#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2539#ifdef CONFIG_MSM_USE_TSIF1
2540 &msm_device_tsif[1],
2541#else
2542 &msm_device_tsif[0],
2543#endif
2544#endif
2545
Mona Hossain9c430e32011-07-27 11:04:47 -07002546#ifdef CONFIG_HW_RANDOM_MSM
2547 &msm_device_rng,
2548#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002549#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002550 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002551#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002552 &msm8960_rpm_device,
2553 &msm8960_rpm_log_device,
2554 &msm8960_rpm_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002555 &msm_device_tz_log,
Pratik Patel7831c082011-06-08 21:44:37 -07002556#ifdef CONFIG_MSM_QDSS
Pratik Patel1403f2a2012-03-21 10:10:00 -07002557 &msm_qdss_device,
Pratik Patel7831c082011-06-08 21:44:37 -07002558 &msm_etb_device,
2559 &msm_tpiu_device,
2560 &msm_funnel_device,
Pratik Patel492b3012012-03-06 14:22:30 -08002561 &msm_etm_device,
Pratik Patel7831c082011-06-08 21:44:37 -07002562#endif
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002563 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002564 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002565 &msm8960_rtb_device,
Praveen Chidambaram8ea3dcd2011-12-07 14:46:31 -07002566 &msm8960_cpu_idle_device,
Praveen Chidambaram5c8adf22012-02-23 18:44:37 -07002567 &msm8960_msm_gov_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002568 &msm8960_device_cache_erp,
Laura Abbott306bcc22012-03-08 11:24:53 -08002569#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbottb93525f2012-04-12 09:57:19 -07002570 &msm8960_cache_dump_device,
Laura Abbott306bcc22012-03-08 11:24:53 -08002571#endif
Laura Abbott0577d7b2012-04-17 11:14:30 -07002572 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002573 &msm_tsens_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002574};
2575
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002576static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07002577 &msm8960_device_uart_gsbi5,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002578 &msm8960_device_otg,
2579 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002580 &msm_device_hsusb_host,
Vijayavardhan Vennapusaeb566482011-09-18 07:48:37 +05302581 &msm_device_hsic_host,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002582 &android_usb_device,
2583 &msm_device_vidc,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002584 &msm_bus_apps_fabric,
2585 &msm_bus_sys_fabric,
2586 &msm_bus_mm_fabric,
2587 &msm_bus_sys_fpb,
2588 &msm_bus_cpss_fpb,
2589 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002590 &msm_multi_ch_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002591 &msm_pcm_routing,
2592 &msm_cpudai0,
2593 &msm_cpudai1,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002594 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002595 &msm_cpudai_hdmi_rx,
2596 &msm_cpudai_bt_rx,
2597 &msm_cpudai_bt_tx,
2598 &msm_cpudai_fm_rx,
2599 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002600 &msm_cpudai_auxpcm_rx,
2601 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002602 &msm_cpu_fe,
2603 &msm_stub_codec,
2604 &msm_voice,
2605 &msm_voip,
2606 &msm_lpa_pcm,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302607 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002608 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002609 &msm_cpudai_incall_record_rx,
2610 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002611
2612#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2613 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2614 &qcrypto_device,
2615#endif
2616
2617#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2618 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2619 &qcedev_device,
2620#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002621};
2622
2623static struct platform_device *rumi3_devices[] __initdata = {
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07002624 &msm8960_device_uart_gsbi5,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002625 &msm_kgsl_3d0,
2626 &msm_kgsl_2d0,
2627 &msm_kgsl_2d1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002628#ifdef CONFIG_MSM_GEMINI
2629 &msm8960_gemini_device,
2630#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002631};
2632
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002633static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002634 &msm_8960_q6_lpass,
2635 &msm_8960_q6_mss_fw,
2636 &msm_8960_q6_mss_sw,
Stephen Boyd322a9922011-09-20 01:05:54 -07002637 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002638 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002639 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002640 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002641 &msm8960_device_otg,
2642 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002643 &msm_device_hsusb_host,
2644 &android_usb_device,
2645 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002646 &msm_multi_ch_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002647 &msm_pcm_routing,
2648 &msm_cpudai0,
2649 &msm_cpudai1,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002650 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002651 &msm_cpudai_hdmi_rx,
2652 &msm_cpudai_bt_rx,
2653 &msm_cpudai_bt_tx,
2654 &msm_cpudai_fm_rx,
2655 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002656 &msm_cpudai_auxpcm_rx,
2657 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002658 &msm_cpu_fe,
2659 &msm_stub_codec,
2660 &msm_kgsl_3d0,
2661#ifdef CONFIG_MSM_KGSL_2D
2662 &msm_kgsl_2d0,
2663 &msm_kgsl_2d1,
2664#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002665#ifdef CONFIG_MSM_GEMINI
2666 &msm8960_gemini_device,
2667#endif
2668 &msm_voice,
2669 &msm_voip,
2670 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302671 &msm_cpudai_afe_01_rx,
2672 &msm_cpudai_afe_01_tx,
2673 &msm_cpudai_afe_02_rx,
2674 &msm_cpudai_afe_02_tx,
2675 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302676 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002677 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002678 &msm_cpudai_incall_record_rx,
2679 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002680 &msm_pcm_hostless,
2681 &msm_bus_apps_fabric,
2682 &msm_bus_sys_fabric,
2683 &msm_bus_mm_fabric,
2684 &msm_bus_sys_fpb,
2685 &msm_bus_cpss_fpb,
2686};
2687
2688static void __init msm8960_i2c_init(void)
2689{
2690 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2691 &msm8960_i2c_qup_gsbi4_pdata;
2692
2693 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2694 &msm8960_i2c_qup_gsbi3_pdata;
2695
2696 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2697 &msm8960_i2c_qup_gsbi10_pdata;
2698
2699 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2700 &msm8960_i2c_qup_gsbi12_pdata;
2701}
2702
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002703static void __init msm8960_gfx_init(void)
2704{
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06002705 uint32_t soc_platform_version = socinfo_get_version();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002706 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
2707 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2708 msm_kgsl_3d0.dev.platform_data;
Lucille Sylvesterdce84cd2011-10-12 14:15:37 -06002709 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
2710 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002711 }
2712}
2713
Subhash Jadavani933e6a62011-12-26 18:05:04 +05302714static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002715 {
2716 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
2717 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2718 true,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002719 100, 650, 801, 200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002720 },
2721
2722 {
2723 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
2724 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2725 true,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002726 2000, 200, 576000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002727 },
2728
2729 {
2730 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2731 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
2732 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002733 8500, 51, 1122000, 8500,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002734 },
2735
2736 {
2737 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2738 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
2739 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002740 9000, 51, 1130300, 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002741 },
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06002742 {
2743 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2744 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
2745 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002746 10000, 51, 1130300, 10000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06002747 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002748
2749 {
2750 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2751 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
2752 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002753 12000, 14, 2205900, 12000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002754 },
2755
2756 {
2757 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2758 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
2759 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002760 18000, 12, 2364250, 18000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002761 },
2762
2763 {
2764 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2765 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
2766 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002767 23500, 10, 2667000, 23500,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002768 },
2769
2770 {
2771 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2772 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
2773 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002774 29700, 5, 2867000, 30000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002775 },
2776};
2777
Praveen Chidambaram78499012011-11-01 17:15:17 -06002778static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
2779 .levels = &msm_rpmrs_levels[0],
2780 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
2781 .vdd_mem_levels = {
2782 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
2783 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
2784 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
2785 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
2786 },
2787 .vdd_dig_levels = {
2788 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
2789 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
2790 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
2791 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
2792 },
2793 .vdd_mask = 0x7FFFFF,
2794 .rpmrs_target_id = {
2795 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
2796 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
2797 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
2798 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
2799 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
2800 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
2801 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
2802 },
2803};
2804
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002805static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2806 .mode = MSM_PM_BOOT_CONFIG_TZ,
2807};
2808
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002809#ifdef CONFIG_I2C
2810#define I2C_SURF 1
2811#define I2C_FFA (1 << 1)
2812#define I2C_RUMI (1 << 2)
2813#define I2C_SIM (1 << 3)
2814#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03002815#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002816
2817struct i2c_registry {
2818 u8 machs;
2819 int bus;
2820 struct i2c_board_info *info;
2821 int len;
2822};
2823
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002824/* Sensors DSPS platform data */
2825#ifdef CONFIG_MSM_DSPS
2826#define DSPS_PIL_GENERIC_NAME "dsps"
2827#endif /* CONFIG_MSM_DSPS */
2828
2829static void __init msm8960_init_dsps(void)
2830{
2831#ifdef CONFIG_MSM_DSPS
2832 struct msm_dsps_platform_data *pdata =
2833 msm_dsps_device.dev.platform_data;
2834 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2835 pdata->gpios = NULL;
2836 pdata->gpios_num = 0;
2837
2838 platform_device_register(&msm_dsps_device);
2839#endif /* CONFIG_MSM_DSPS */
2840}
2841
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08002842static int hsic_peripheral_status = 1;
2843static DEFINE_MUTEX(hsic_status_lock);
2844
2845void peripheral_connect()
2846{
2847 mutex_lock(&hsic_status_lock);
2848 if (hsic_peripheral_status)
2849 goto out;
2850 platform_device_add(&msm_device_hsic_host);
2851 hsic_peripheral_status = 1;
2852out:
2853 mutex_unlock(&hsic_status_lock);
2854}
2855EXPORT_SYMBOL(peripheral_connect);
2856
2857void peripheral_disconnect()
2858{
2859 mutex_lock(&hsic_status_lock);
2860 if (!hsic_peripheral_status)
2861 goto out;
2862 platform_device_del(&msm_device_hsic_host);
2863 hsic_peripheral_status = 0;
2864out:
2865 mutex_unlock(&hsic_status_lock);
2866}
2867EXPORT_SYMBOL(peripheral_disconnect);
2868
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05302869static void __init msm8960_init_smsc_hub(void)
2870{
2871 uint32_t version = socinfo_get_version();
2872
2873 if (SOCINFO_VERSION_MAJOR(version) == 1)
2874 return;
2875
2876 if (machine_is_msm8960_liquid())
2877 platform_device_register(&smsc_hub_device);
2878}
2879
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07002880static void __init msm8960_init_hsic(void)
2881{
2882#ifdef CONFIG_USB_EHCI_MSM_HSIC
2883 uint32_t version = socinfo_get_version();
2884
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08002885 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07002886 return;
2887
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08002888 if (PLATFORM_IS_CHARM25() || machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08002889 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07002890#endif
2891}
2892
Amir Samuelov5137e392011-09-21 17:31:25 +03002893#ifdef CONFIG_ISL9519_CHARGER
2894static struct isl_platform_data isl_data __initdata = {
2895 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
2896 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
2897 .max_system_voltage = 4200,
2898 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02002899 .chgcurrent = 1900,
2900 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03002901 .input_current = 2048,
2902};
2903
2904static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
2905 {
2906 I2C_BOARD_INFO("isl9519q", 0x9),
2907 .irq = 0, /* Not required when notify-by-pmic */
2908 .platform_data = &isl_data,
2909 },
2910};
2911#endif /* CONFIG_ISL9519_CHARGER */
2912
Amir Samuelov755616d2011-12-13 16:34:46 +02002913static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
2914 {
2915 I2C_BOARD_INFO("sx1508q", 0x20),
2916 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
2917 },
2918};
2919
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002920static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03002921#ifdef CONFIG_ISL9519_CHARGER
2922 {
2923 I2C_LIQUID,
2924 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
2925 isl_charger_i2c_info,
2926 ARRAY_SIZE(isl_charger_i2c_info),
2927 },
2928#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002929 {
2930 I2C_SURF | I2C_FFA | I2C_FLUID,
2931 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
2932 cyttsp_info,
2933 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07002934 },
Mohan Pallaka50837382011-09-07 11:00:57 +05302935 {
2936 I2C_LIQUID,
2937 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
2938 mxt_device_info,
2939 ARRAY_SIZE(mxt_device_info),
2940 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05302941 {
Manoj Rao14648742012-03-30 19:42:12 -07002942 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05302943 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002944 sii_device_info,
2945 ARRAY_SIZE(sii_device_info),
2946 },
2947 {
2948 I2C_LIQUID,
2949 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05302950 msm_isa1200_board_info,
2951 ARRAY_SIZE(msm_isa1200_board_info),
2952 },
Amir Samuelov755616d2011-12-13 16:34:46 +02002953 {
2954 I2C_LIQUID,
2955 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
2956 liquid_io_expander_i2c_info,
2957 ARRAY_SIZE(liquid_io_expander_i2c_info),
2958 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002959};
2960#endif /* CONFIG_I2C */
2961
2962static void __init register_i2c_devices(void)
2963{
2964#ifdef CONFIG_I2C
2965 u8 mach_mask = 0;
2966 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08002967#ifdef CONFIG_MSM_CAMERA
2968 struct i2c_registry msm8960_camera_i2c_devices = {
2969 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
2970 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
2971 msm8960_camera_board_info.board_info,
2972 msm8960_camera_board_info.num_i2c_board_info,
2973 };
2974#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002975
2976 /* Build the matching 'supported_machs' bitmask */
2977 if (machine_is_msm8960_cdp())
2978 mach_mask = I2C_SURF;
2979 else if (machine_is_msm8960_rumi3())
2980 mach_mask = I2C_RUMI;
2981 else if (machine_is_msm8960_sim())
2982 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07002983 else if (machine_is_msm8960_fluid())
2984 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03002985 else if (machine_is_msm8960_liquid())
2986 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07002987 else if (machine_is_msm8960_mtp())
2988 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002989 else
2990 pr_err("unmatched machine ID in register_i2c_devices\n");
2991
Jing Lineec88ca2012-02-08 11:18:30 -08002992 if (machine_is_msm8960_liquid()) {
2993 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
2994 mxt_device_info[0].platform_data =
2995 &mxt_platform_data_3d;
2996 else
2997 mxt_device_info[0].platform_data =
2998 &mxt_platform_data_2d;
2999 }
3000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003001 /* Run the array and install devices as appropriate */
3002 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3003 if (msm8960_i2c_devices[i].machs & mach_mask)
3004 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3005 msm8960_i2c_devices[i].info,
3006 msm8960_i2c_devices[i].len);
3007 }
Kevin Chan09f4e662011-12-16 08:17:02 -08003008#ifdef CONFIG_MSM_CAMERA
3009 if (msm8960_camera_i2c_devices.machs & mach_mask)
3010 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3011 msm8960_camera_i2c_devices.info,
3012 msm8960_camera_i2c_devices.len);
3013#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003014#endif
3015}
3016
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003017static void __init msm8960_sim_init(void)
3018{
Jeff Ohlstein7e668552011-10-06 16:17:25 -07003019 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
3020 &msm8960_device_watchdog.dev.platform_data;
3021
3022 wdog_pdata->bark_time = 15000;
Siddartha Mohanadossfad0af12012-01-20 15:08:38 -08003023 msm_tsens_early_init(&msm_tsens_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003024 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3025 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003026 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003027 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003028 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003029 msm8960_init_pmic();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003030
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003031 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003032 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003033 msm8960_i2c_init();
3034 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3035 msm_spm_l2_init(msm_spm_l2_data);
3036 msm8960_init_buses();
3037 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003038 msm8960_pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003039 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Matt Wagantallec57f062011-08-16 23:54:46 -07003040 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003041
3042 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3043 &msm8960_qup_spi_gsbi1_pdata;
3044 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3045
3046 msm8960_init_mmc();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003047 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003048 slim_register_board_info(msm_slim_devices,
3049 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003050 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06003051 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003052}
3053
3054static void __init msm8960_rumi3_init(void)
3055{
Siddartha Mohanadossfad0af12012-01-20 15:08:38 -08003056 msm_tsens_early_init(&msm_tsens_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003057 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3058 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003059 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003060 platform_device_register(&msm8960_device_rpm_regulator);
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003061 msm8960_init_gpiomux();
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003062 msm8960_init_pmic();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003063 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3064 &msm8960_qup_spi_gsbi1_pdata;
3065 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3066 msm8960_i2c_init();
3067 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3068 msm_spm_l2_init(msm_spm_l2_data);
3069 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003070 msm8960_pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003071 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003072 msm8960_init_mmc();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003073 register_i2c_devices();
Mayank Ranae009c922012-03-22 03:02:06 +05303074
Mayank Ranae009c922012-03-22 03:02:06 +05303075
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003076 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003077 slim_register_board_info(msm_slim_devices,
3078 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003079 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06003080 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003081}
3082
3083static void __init msm8960_cdp_init(void)
3084{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003085 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3086 pr_err("meminfo_init() failed!\n");
3087
Siddartha Mohanadossfad0af12012-01-20 15:08:38 -08003088 msm_tsens_early_init(&msm_tsens_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003089 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3090 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003091
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003092 regulator_suppress_info_printing();
3093 if (msm_xo_init())
3094 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07003095 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003096 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303097 if (machine_is_msm8960_liquid())
3098 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003099 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303100 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3101 machine_is_msm8960_cdp()) {
3102 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
3103 } else if (machine_is_msm8960_liquid()) {
3104 msm_otg_pdata.phy_init_seq =
3105 liquid_v1_phy_init_seq;
3106 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003107 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303108 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303109 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303110 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3111 machine_is_msm8960_liquid())
3112 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003113 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003114 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3115 &msm8960_qup_spi_gsbi1_pdata;
3116 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003117
3118 msm8960_init_pmic();
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303119 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3120 (machine_is_msm8960_mtp())) || machine_is_msm8960_liquid())
3121 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003122 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003123 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003124 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3125 msm_spm_l2_init(msm_spm_l2_data);
3126 msm8960_init_buses();
3127 platform_add_devices(msm_footswitch_devices,
3128 msm_num_footswitch_devices);
David Collinsb10be1d2011-09-02 10:29:31 -07003129 if (machine_is_msm8960_liquid())
3130 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003131 if (machine_is_msm8960_cdp())
3132 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003133
3134 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3135 platform_device_register(&msm8960_device_uart_gsbi8);
3136 else
3137 platform_device_register(&msm8960_device_uart_gsbi5);
3138
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003139 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003140 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3141 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003142 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Ranad85a5082012-04-29 17:24:13 -07003143 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003144
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003145 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003146 msm8960_pm8921_gpio_mpp_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003147 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303148 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003149 msm8960_init_hsic();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003150 msm8960_init_cam();
3151 msm8960_init_mmc();
Matt Wagantallec57f062011-08-16 23:54:46 -07003152 acpuclk_init(&acpuclk_8960_soc_data);
Mohan Pallaka50837382011-09-07 11:00:57 +05303153 if (machine_is_msm8960_liquid())
3154 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003155 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003156 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003157 slim_register_board_info(msm_slim_devices,
3158 ARRAY_SIZE(msm_slim_devices));
3159 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003160 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003161 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06003162 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Joel Kingb8352a12011-11-15 18:46:24 -08003163 if (PLATFORM_IS_CHARM25())
3164 platform_add_devices(mdm_devices, ARRAY_SIZE(mdm_devices));
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003165}
3166
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003167MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
3168 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003169 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003170 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303171 .handle_irq = gic_handle_irq,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003172 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003173 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003174 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003175 .init_very_early = msm8960_early_memory,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003176MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003177
3178MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
3179 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003180 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003181 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303182 .handle_irq = gic_handle_irq,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003183 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003184 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003185 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003186 .init_very_early = msm8960_early_memory,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003187MACHINE_END
3188
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003189MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3190 .map_io = msm8960_map_io,
3191 .reserve = msm8960_reserve,
3192 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303193 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003194 .timer = &msm_timer,
3195 .init_machine = msm8960_cdp_init,
3196 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003197 .init_very_early = msm8960_early_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003198MACHINE_END
3199
3200MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3201 .map_io = msm8960_map_io,
3202 .reserve = msm8960_reserve,
3203 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303204 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003205 .timer = &msm_timer,
3206 .init_machine = msm8960_cdp_init,
3207 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003208 .init_very_early = msm8960_early_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003209MACHINE_END
3210
3211MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3212 .map_io = msm8960_map_io,
3213 .reserve = msm8960_reserve,
3214 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303215 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003216 .timer = &msm_timer,
3217 .init_machine = msm8960_cdp_init,
3218 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003219 .init_very_early = msm8960_early_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003220MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003221
3222MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3223 .map_io = msm8960_map_io,
3224 .reserve = msm8960_reserve,
3225 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303226 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003227 .timer = &msm_timer,
3228 .init_machine = msm8960_cdp_init,
3229 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003230 .init_very_early = msm8960_early_memory,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003231MACHINE_END