blob: defa33bf756118282b6628f2f98bc7f1294d52c2 [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 -0800294#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700295static struct msm_rtb_platform_data msm8960_rtb_pdata = {
Laura Abbottf8c03b92012-02-16 14:57:58 -0800296 .size = SZ_1M,
297};
298
299static int __init msm_rtb_set_buffer_size(char *p)
300{
301 int s;
302
303 s = memparse(p, NULL);
Laura Abbottb93525f2012-04-12 09:57:19 -0700304 msm8960_rtb_pdata.size = ALIGN(s, SZ_4K);
Laura Abbottf8c03b92012-02-16 14:57:58 -0800305 return 0;
306}
307early_param("msm_rtb_size", msm_rtb_set_buffer_size);
308
309
Laura Abbottb93525f2012-04-12 09:57:19 -0700310static struct platform_device msm8960_rtb_device = {
Laura Abbottf8c03b92012-02-16 14:57:58 -0800311 .name = "msm_rtb",
312 .id = -1,
313 .dev = {
Laura Abbottb93525f2012-04-12 09:57:19 -0700314 .platform_data = &msm8960_rtb_pdata,
Laura Abbottf8c03b92012-02-16 14:57:58 -0800315 },
316};
317#endif
318
319static void __init reserve_rtb_memory(void)
320{
321#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700322 msm8960_reserve_table[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
Laura Abbottf8c03b92012-02-16 14:57:58 -0800323#endif
324}
325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326static void __init size_pmem_devices(void)
327{
328#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700329#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800331
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800332 if (!pmem_param_set) {
333 if (machine_is_msm8960_liquid())
334 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700335 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800336 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
337 }
338
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339 android_pmem_pdata.size = pmem_size;
340 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700341#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
342#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700343}
344
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700345#ifdef CONFIG_ANDROID_PMEM
346#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700347static void __init reserve_memory_for(struct android_pmem_platform_data *p)
348{
349 msm8960_reserve_table[p->memory_type].size += p->size;
350}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700351#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
352#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700353
354static void __init reserve_pmem_memory(void)
355{
356#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700357#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700358 reserve_memory_for(&android_pmem_adsp_pdata);
359 reserve_memory_for(&android_pmem_pdata);
360 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700361#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700362 msm8960_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
363#endif
364}
365
Larry Basselb4126da2011-07-18 14:31:33 -0700366static int msm8960_paddr_to_memtype(unsigned int paddr)
367{
368 return MEMTYPE_EBI1;
369}
370
Olav Hauganf6dc7742012-02-15 09:11:55 -0800371#define FMEM_ENABLED 1
372
Laura Abbottd6183792011-08-19 13:42:24 -0700373#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800374#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700375static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800376 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan42ebe712012-01-10 16:30:58 -0800377 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800378 .reusable = FMEM_ENABLED,
379 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700380 .fixed_position = FIXED_MIDDLE,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800381};
382
Laura Abbottb93525f2012-04-12 09:57:19 -0700383static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800384 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800385 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800386 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800387 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700388 .fixed_position = FIXED_HIGH,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800389};
390
Laura Abbottb93525f2012-04-12 09:57:19 -0700391static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800392 .adjacent_mem_id = INVALID_HEAP_ID,
393 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800394 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800395};
396
Laura Abbottb93525f2012-04-12 09:57:19 -0700397static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800398 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
399 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800400 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700401 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800402};
403#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800404
405/**
406 * These heaps are listed in the order they will be allocated. Due to
407 * video hardware restrictions and content protection the FW heap has to
408 * be allocated adjacent (below) the MM heap and the MFC heap has to be
409 * allocated after the MM heap to ensure MFC heap is not more than 256MB
410 * away from the base address of the FW heap.
411 * However, the order of FW heap and MM heap doesn't matter since these
412 * two heaps are taken care of by separate code to ensure they are adjacent
413 * to each other.
414 * Don't swap the order unless you know what you are doing!
415 */
Laura Abbottb93525f2012-04-12 09:57:19 -0700416static struct ion_platform_data msm8960_ion_pdata = {
Laura Abbott2d1760b2011-09-29 21:31:24 -0700417 .nr = MSM_ION_HEAP_NUM,
Laura Abbottd6183792011-08-19 13:42:24 -0700418 .heaps = {
419 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800420 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700421 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700422 .name = ION_VMALLOC_HEAP_NAME,
423 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700424#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700425 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800426 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800427 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800428 .name = ION_MM_HEAP_NAME,
429 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700430 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700431 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700432 },
Laura Abbott8c017362011-09-22 20:59:12 -0700433 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800434 .id = ION_MM_FIRMWARE_HEAP_ID,
435 .type = ION_HEAP_TYPE_CARVEOUT,
436 .name = ION_MM_FIRMWARE_HEAP_NAME,
437 .size = MSM_ION_MM_FW_SIZE,
438 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700439 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800440 },
441 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800442 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800443 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800444 .name = ION_MFC_HEAP_NAME,
445 .size = MSM_ION_MFC_SIZE,
446 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700447 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800448 },
Olav Haugan32594552012-03-13 11:40:05 -0700449#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800450 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800451 .id = ION_SF_HEAP_ID,
452 .type = ION_HEAP_TYPE_CARVEOUT,
453 .name = ION_SF_HEAP_NAME,
454 .size = MSM_ION_SF_SIZE,
455 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700456 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800457 },
Olav Haugan32594552012-03-13 11:40:05 -0700458#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800459 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800460 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700461 .type = ION_HEAP_TYPE_IOMMU,
462 .name = ION_IOMMU_HEAP_NAME,
463 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800464 {
465 .id = ION_QSECOM_HEAP_ID,
466 .type = ION_HEAP_TYPE_CARVEOUT,
467 .name = ION_QSECOM_HEAP_NAME,
468 .size = MSM_ION_QSECOM_SIZE,
469 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700470 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800471 },
Olav Haugan7355db02012-01-13 16:59:13 -0800472 {
473 .id = ION_AUDIO_HEAP_ID,
474 .type = ION_HEAP_TYPE_CARVEOUT,
475 .name = ION_AUDIO_HEAP_NAME,
476 .size = MSM_ION_AUDIO_SIZE,
477 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700478 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800479 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700480#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700481 }
482};
483
Laura Abbottb93525f2012-04-12 09:57:19 -0700484static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700485 .name = "ion-msm",
486 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700487 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700488};
489#endif
490
Laura Abbottb93525f2012-04-12 09:57:19 -0700491struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800492 .name = "fmem",
493 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700494 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800495};
496
Olav Haugan65f4bd82011-12-13 11:50:08 -0800497static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700498{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800499 unsigned int i;
500
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800501 if (!pmem_param_set) {
502 if (machine_is_msm8960_liquid())
503 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
504
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700505 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800506 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
507
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700508 if (machine_is_msm8960_liquid() ||
509 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700510 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
511 if (msm8960_ion_pdata.heaps[i].id ==
512 ION_SF_HEAP_ID) {
513 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800514 msm_ion_sf_size;
515 pr_debug("msm_ion_sf_size 0x%x\n",
516 msm_ion_sf_size);
517 break;
518 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800519 }
520 }
521 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800522}
523
524static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
525 unsigned long size)
526{
527 msm8960_reserve_table[mem_type].size += size;
528}
529
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700530static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
531{
532#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
533 int ret;
534
535 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
536 panic("fixed area size is larger than %dM\n",
537 MAX_FIXED_AREA_SIZE >> 20);
538
539 reserve_info->fixed_area_size = fixed_area_size;
540 reserve_info->fixed_area_start = MSM8960_FW_START;
541
542 ret = memblock_remove(reserve_info->fixed_area_start,
543 reserve_info->fixed_area_size);
544 BUG_ON(ret);
545#endif
546}
547
Olav Haugan65f4bd82011-12-13 11:50:08 -0800548/**
549 * Reserve memory for ION and calculate amount of reusable memory for fmem.
550 * We only reserve memory for heaps that are not reusable. However, we only
551 * support one reusable heap at the moment so we ignore the reusable flag for
552 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800553 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
554 * at a higher address than FW in addition to not more than 256MB away from the
555 * base address of the firmware. This means that if MM is reusable the other
556 * two heaps must be allocated in the same region as FW. This is handled by the
557 * mem_is_fmem flag in the platform data. In addition the MM heap must be
558 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800559 */
560static void __init reserve_ion_memory(void)
561{
562#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
563 unsigned int i;
564 unsigned int reusable_count = 0;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700565 unsigned int fixed_size = 0;
566 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
567 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800568
569 adjust_mem_for_liquid();
Laura Abbottb93525f2012-04-12 09:57:19 -0700570 msm8960_fmem_pdata.size = 0;
571 msm8960_fmem_pdata.reserved_size_low = 0;
572 msm8960_fmem_pdata.reserved_size_high = 0;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700573 fixed_low_size = 0;
574 fixed_middle_size = 0;
575 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800576
577 /* We only support 1 reusable heap. Check if more than one heap
578 * is specified as reusable and set as non-reusable if found.
579 */
Laura Abbottb93525f2012-04-12 09:57:19 -0700580 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
581 const struct ion_platform_heap *heap =
582 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan65f4bd82011-12-13 11:50:08 -0800583
584 if (heap->type == ION_HEAP_TYPE_CP && heap->extra_data) {
585 struct ion_cp_heap_pdata *data = heap->extra_data;
586
587 reusable_count += (data->reusable) ? 1 : 0;
588
589 if (data->reusable && reusable_count > 1) {
590 pr_err("%s: Too many heaps specified as "
591 "reusable. Heap %s was not configured "
592 "as reusable.\n", __func__, heap->name);
593 data->reusable = 0;
594 }
595 }
596 }
597
Laura Abbottb93525f2012-04-12 09:57:19 -0700598 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
599 const struct ion_platform_heap *heap =
600 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan65f4bd82011-12-13 11:50:08 -0800601
602 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700603 int fixed_position = NOT_FIXED;
604 int mem_is_fmem = 0;
605
Olav Haugan65f4bd82011-12-13 11:50:08 -0800606 switch (heap->type) {
607 case ION_HEAP_TYPE_CP:
Olav Hauganf6dc7742012-02-15 09:11:55 -0800608 mem_is_fmem = ((struct ion_cp_heap_pdata *)
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700609 heap->extra_data)->mem_is_fmem;
610 fixed_position = ((struct ion_cp_heap_pdata *)
611 heap->extra_data)->fixed_position;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800612 break;
613 case ION_HEAP_TYPE_CARVEOUT:
Olav Hauganf6dc7742012-02-15 09:11:55 -0800614 mem_is_fmem = ((struct ion_co_heap_pdata *)
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700615 heap->extra_data)->mem_is_fmem;
616 fixed_position = ((struct ion_co_heap_pdata *)
617 heap->extra_data)->fixed_position;
618 break;
619 default:
620 break;
621 }
622
623 if (fixed_position != NOT_FIXED)
624 fixed_size += heap->size;
625 else
626 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
627
628 if (fixed_position == FIXED_LOW)
629 fixed_low_size += heap->size;
630 else if (fixed_position == FIXED_MIDDLE)
631 fixed_middle_size += heap->size;
632 else if (fixed_position == FIXED_HIGH)
633 fixed_high_size += heap->size;
634
635 if (mem_is_fmem)
Laura Abbottb93525f2012-04-12 09:57:19 -0700636 msm8960_fmem_pdata.size += heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700637 }
638 }
639
640 if (!fixed_size)
641 return;
642
Laura Abbottb93525f2012-04-12 09:57:19 -0700643 if (msm8960_fmem_pdata.size) {
644 msm8960_fmem_pdata.reserved_size_low = fixed_low_size;
645 msm8960_fmem_pdata.reserved_size_high = fixed_high_size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700646 }
647
Larry Bassel4d4f4482012-04-04 11:26:09 -0700648 /* Since the fixed area may be carved out of lowmem,
649 * make sure the length is a multiple of 1M.
650 */
651 fixed_size = (fixed_size + MSM_MM_FW_SIZE + SECTION_SIZE - 1)
652 & SECTION_MASK;
653 msm8960_reserve_fixed_area(fixed_size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700654
655 fixed_low_start = MSM8960_FIXED_AREA_START;
656 fixed_middle_start = fixed_low_start + fixed_low_size;
657 fixed_high_start = fixed_middle_start + fixed_middle_size;
658
Laura Abbottb93525f2012-04-12 09:57:19 -0700659 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
660 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700661
662 if (heap->extra_data) {
663 int fixed_position = NOT_FIXED;
664
665 switch (heap->type) {
666 case ION_HEAP_TYPE_CP:
667 fixed_position = ((struct ion_cp_heap_pdata *)
668 heap->extra_data)->fixed_position;
669 break;
670 case ION_HEAP_TYPE_CARVEOUT:
671 fixed_position = ((struct ion_co_heap_pdata *)
672 heap->extra_data)->fixed_position;
673 break;
674 default:
675 break;
676 }
677
678 switch (fixed_position) {
679 case FIXED_LOW:
680 heap->base = fixed_low_start;
681 break;
682 case FIXED_MIDDLE:
683 heap->base = fixed_middle_start;
684 break;
685 case FIXED_HIGH:
686 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800687 break;
688 default:
689 break;
690 }
691 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800692 }
Laura Abbottd6183792011-08-19 13:42:24 -0700693#endif
694}
Huaibin Yanga5419422011-12-08 23:52:10 -0800695
696static void __init reserve_mdp_memory(void)
697{
698 msm8960_mdp_writeback(msm8960_reserve_table);
699}
700
Laura Abbott306bcc22012-03-08 11:24:53 -0800701#if defined(CONFIG_MSM_CACHE_DUMP)
Laura Abbottb93525f2012-04-12 09:57:19 -0700702static struct msm_cache_dump_platform_data msm8960_cache_dump_pdata = {
Laura Abbott306bcc22012-03-08 11:24:53 -0800703 .l2_size = L2_BUFFER_SIZE,
704};
705
Laura Abbottb93525f2012-04-12 09:57:19 -0700706static struct platform_device msm8960_cache_dump_device = {
Laura Abbott306bcc22012-03-08 11:24:53 -0800707 .name = "msm_cache_dump",
708 .id = -1,
709 .dev = {
Laura Abbottb93525f2012-04-12 09:57:19 -0700710 .platform_data = &msm8960_cache_dump_pdata,
Laura Abbott306bcc22012-03-08 11:24:53 -0800711 },
712};
713
714#endif
715
Stephen Boyd668d7652012-04-25 11:31:01 -0700716static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800717{
718#ifdef CONFIG_MSM_CACHE_DUMP
719 unsigned int spare;
720 unsigned int l1_size;
Laura Abbott7b637362012-03-29 16:43:49 -0700721 unsigned int l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800722 unsigned int total;
723 int ret;
724
725 ret = scm_call(L1C_SERVICE_ID, L1C_BUFFER_GET_SIZE_COMMAND_ID, &spare,
726 sizeof(spare), &l1_size, sizeof(l1_size));
727
728 if (ret)
729 /* Fall back to something reasonable here */
730 l1_size = L1_BUFFER_SIZE;
731
Laura Abbott7b637362012-03-29 16:43:49 -0700732 ret = scm_call(L1C_SERVICE_ID, L2C_BUFFER_GET_SIZE_COMMAND_ID, &spare,
733 sizeof(spare), &l2_size, sizeof(l2_size));
734
735 if (ret)
736 /* Fall back to something reasonable here */
737 l2_size = L2_BUFFER_SIZE;
738
739 total = l1_size + l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800740
741 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbottb93525f2012-04-12 09:57:19 -0700742 msm8960_cache_dump_pdata.l1_size = l1_size;
743 msm8960_cache_dump_pdata.l2_size = l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800744#endif
745}
746
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700747static void __init msm8960_calculate_reserve_sizes(void)
748{
749 size_pmem_devices();
750 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700751 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800752 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800753 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800754 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755}
756
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757static struct reserve_info msm8960_reserve_info __initdata = {
758 .memtype_reserve_table = msm8960_reserve_table,
759 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700760 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700761 .paddr_to_memtype = msm8960_paddr_to_memtype,
762};
763
Larry Basselb4126da2011-07-18 14:31:33 -0700764static int msm8960_memory_bank_size(void)
765{
766 return 1<<29;
767}
768
769static void __init locate_unstable_memory(void)
770{
771 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
772 unsigned long bank_size;
773 unsigned long low, high;
774
775 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700776 msm8960_reserve_info.bank_size = bank_size;
777
Larry Basselb4126da2011-07-18 14:31:33 -0700778 low = meminfo.bank[0].start;
779 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700780
781 /* Check if 32 bit overflow occured */
782 if (high < mb->start)
783 high = ~0UL;
784
Larry Bassel4d4f4482012-04-04 11:26:09 -0700785 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
786 panic("fixed area extends beyond end of memory\n");
787
Larry Basselb4126da2011-07-18 14:31:33 -0700788 low &= ~(bank_size - 1);
789
790 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700791 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800792
Larry Basselb8d61022012-02-24 10:49:45 -0800793#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800794 msm8960_reserve_info.low_unstable_address = mb->start -
795 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800796 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700797 pr_info("low unstable address %lx max size %lx bank size %lx\n",
798 msm8960_reserve_info.low_unstable_address,
799 msm8960_reserve_info.max_unstable_size,
800 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700801 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800802#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700803no_dmm:
804 msm8960_reserve_info.low_unstable_address = high;
805 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700806}
807
Larry Basselb830e182011-10-14 10:46:55 -0700808static void __init place_movable_zone(void)
809{
Larry Basselb8d61022012-02-24 10:49:45 -0800810#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700811 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
812 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
813 pr_info("movable zone start %lx size %lx\n",
814 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800815#endif
Larry Basselb830e182011-10-14 10:46:55 -0700816}
817
818static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700819{
820 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700821 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700822 place_movable_zone();
823}
824
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800825static char prim_panel_name[PANEL_NAME_MAX_LEN];
826static char ext_panel_name[PANEL_NAME_MAX_LEN];
827static int __init prim_display_setup(char *param)
828{
829 if (strnlen(param, PANEL_NAME_MAX_LEN))
830 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
831 return 0;
832}
833early_param("prim_display", prim_display_setup);
834
835static int __init ext_display_setup(char *param)
836{
837 if (strnlen(param, PANEL_NAME_MAX_LEN))
838 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
839 return 0;
840}
841early_param("ext_display", ext_display_setup);
842
Larry Basselb830e182011-10-14 10:46:55 -0700843static void __init msm8960_reserve(void)
844{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800845 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700846 msm_reserve();
Laura Abbottb93525f2012-04-12 09:57:19 -0700847 if (msm8960_fmem_pdata.size) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700848#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Laura Abbottb93525f2012-04-12 09:57:19 -0700849 msm8960_fmem_pdata.phys = reserve_info->fixed_area_start +
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700850 MSM_MM_FW_SIZE;
851 pr_info("mm fw at %lx (fixed) size %x\n",
852 reserve_info->fixed_area_start, MSM_MM_FW_SIZE);
853 pr_info("fmem start %lx (fixed) size %lx\n",
Laura Abbottb93525f2012-04-12 09:57:19 -0700854 msm8960_fmem_pdata.phys, msm8960_fmem_pdata.size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700855#else
Laura Abbottb93525f2012-04-12 09:57:19 -0700856 msm8960_fmem_pdata.phys =
857 reserve_memory_for_fmem(msm8960_fmem_pdata.size);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700858#endif
859 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700860}
861
Larry Bassela4414b12011-08-04 11:11:02 -0700862static int msm8960_change_memory_power(u64 start, u64 size,
863 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700864{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700865 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700866}
867
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868static void __init msm8960_allocate_memory_regions(void)
869{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800870 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700871}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800872
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873#ifdef CONFIG_WCD9310_CODEC
874
875#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
876
Patrick Lai3043fba2011-08-01 14:15:57 -0700877/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
878 * 4 micbiases are used to power various analog and digital
879 * microphones operating at 1800 mV. Technically, all micbiases
880 * can source from single cfilter since all microphones operate
881 * at the same voltage level. The arrangement below is to make
882 * sure all cfilters are exercised. LDO_H regulator ouput level
883 * does not need to be as high as 2.85V. It is choosen for
884 * microphone sensitivity purpose.
885 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530886static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700887 .slimbus_slave_device = {
888 .name = "tabla-slave",
889 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
890 },
891 .irq = MSM_GPIO_TO_INT(62),
892 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530893 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700894 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700895 .micbias = {
896 .ldoh_v = TABLA_LDOH_2P85_V,
897 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700898 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700899 .cfilt3_mv = 1800,
900 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
901 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
902 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
903 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530904 },
905 .regulator = {
906 {
907 .name = "CDC_VDD_CP",
908 .min_uV = 1800000,
909 .max_uV = 1800000,
910 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
911 },
912 {
913 .name = "CDC_VDDA_RX",
914 .min_uV = 1800000,
915 .max_uV = 1800000,
916 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
917 },
918 {
919 .name = "CDC_VDDA_TX",
920 .min_uV = 1800000,
921 .max_uV = 1800000,
922 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
923 },
924 {
925 .name = "VDDIO_CDC",
926 .min_uV = 1800000,
927 .max_uV = 1800000,
928 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
929 },
930 {
931 .name = "VDDD_CDC_D",
932 .min_uV = 1225000,
933 .max_uV = 1225000,
934 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
935 },
936 {
937 .name = "CDC_VDDA_A_1P2V",
938 .min_uV = 1225000,
939 .max_uV = 1225000,
940 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
941 },
942 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700943};
944
945static struct slim_device msm_slim_tabla = {
946 .name = "tabla-slim",
947 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
948 .dev = {
949 .platform_data = &tabla_platform_data,
950 },
951};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530952
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530953static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530954 .slimbus_slave_device = {
955 .name = "tabla-slave",
956 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
957 },
958 .irq = MSM_GPIO_TO_INT(62),
959 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530960 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530961 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
962 .micbias = {
963 .ldoh_v = TABLA_LDOH_2P85_V,
964 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700965 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530966 .cfilt3_mv = 1800,
967 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
968 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
969 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
970 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530971 },
972 .regulator = {
973 {
974 .name = "CDC_VDD_CP",
975 .min_uV = 1800000,
976 .max_uV = 1800000,
977 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
978 },
979 {
980 .name = "CDC_VDDA_RX",
981 .min_uV = 1800000,
982 .max_uV = 1800000,
983 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
984 },
985 {
986 .name = "CDC_VDDA_TX",
987 .min_uV = 1800000,
988 .max_uV = 1800000,
989 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
990 },
991 {
992 .name = "VDDIO_CDC",
993 .min_uV = 1800000,
994 .max_uV = 1800000,
995 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
996 },
997 {
998 .name = "VDDD_CDC_D",
999 .min_uV = 1225000,
1000 .max_uV = 1225000,
1001 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1002 },
1003 {
1004 .name = "CDC_VDDA_A_1P2V",
1005 .min_uV = 1225000,
1006 .max_uV = 1225000,
1007 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1008 },
1009 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301010};
1011
1012static struct slim_device msm_slim_tabla20 = {
1013 .name = "tabla2x-slim",
1014 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1015 .dev = {
1016 .platform_data = &tabla20_platform_data,
1017 },
1018};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001019#endif
1020
1021static struct slim_boardinfo msm_slim_devices[] = {
1022#ifdef CONFIG_WCD9310_CODEC
1023 {
1024 .bus_num = 1,
1025 .slim_slave = &msm_slim_tabla,
1026 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301027 {
1028 .bus_num = 1,
1029 .slim_slave = &msm_slim_tabla20,
1030 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001031#endif
1032 /* add more slimbus slaves as needed */
1033};
1034
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001035#define MSM_WCNSS_PHYS 0x03000000
1036#define MSM_WCNSS_SIZE 0x280000
1037
1038static struct resource resources_wcnss_wlan[] = {
1039 {
1040 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1041 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1042 .name = "wcnss_wlanrx_irq",
1043 .flags = IORESOURCE_IRQ,
1044 },
1045 {
1046 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1047 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1048 .name = "wcnss_wlantx_irq",
1049 .flags = IORESOURCE_IRQ,
1050 },
1051 {
1052 .start = MSM_WCNSS_PHYS,
1053 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1054 .name = "wcnss_mmio",
1055 .flags = IORESOURCE_MEM,
1056 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001057 {
1058 .start = 84,
1059 .end = 88,
1060 .name = "wcnss_gpios_5wire",
1061 .flags = IORESOURCE_IO,
1062 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001063};
1064
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001065static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1066 .has_48mhz_xo = 1,
1067};
1068
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001069static struct platform_device msm_device_wcnss_wlan = {
1070 .name = "wcnss_wlan",
1071 .id = 0,
1072 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1073 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001074 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001075};
1076
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001077#ifdef CONFIG_QSEECOM
1078/* qseecom bus scaling */
1079static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1080 {
1081 .src = MSM_BUS_MASTER_SPS,
1082 .dst = MSM_BUS_SLAVE_EBI_CH0,
1083 .ib = 0,
1084 .ab = 0,
1085 },
1086 {
1087 .src = MSM_BUS_MASTER_SPDM,
1088 .dst = MSM_BUS_SLAVE_SPDM,
1089 .ib = 0,
1090 .ab = 0,
1091 },
1092};
1093
1094static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1095 {
1096 .src = MSM_BUS_MASTER_SPS,
1097 .dst = MSM_BUS_SLAVE_EBI_CH0,
1098 .ib = (492 * 8) * 1000000UL,
1099 .ab = (492 * 8) * 100000UL,
1100 },
1101 {
1102 .src = MSM_BUS_MASTER_SPDM,
1103 .dst = MSM_BUS_SLAVE_SPDM,
1104 .ib = 0,
1105 .ab = 0,
1106 },
1107};
1108
1109static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1110 {
1111 .src = MSM_BUS_MASTER_SPS,
1112 .dst = MSM_BUS_SLAVE_EBI_CH0,
1113 .ib = 0,
1114 .ab = 0,
1115 },
1116 {
1117 .src = MSM_BUS_MASTER_SPDM,
1118 .dst = MSM_BUS_SLAVE_SPDM,
1119 .ib = (64 * 8) * 1000000UL,
1120 .ab = (64 * 8) * 100000UL,
1121 },
1122};
1123
1124static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1125 {
1126 ARRAY_SIZE(qseecom_clks_init_vectors),
1127 qseecom_clks_init_vectors,
1128 },
1129 {
1130 ARRAY_SIZE(qseecom_enable_dfab_vectors),
1131 qseecom_enable_sfpb_vectors,
1132 },
1133 {
1134 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1135 qseecom_enable_sfpb_vectors,
1136 },
1137};
1138
1139static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1140 qseecom_hw_bus_scale_usecases,
1141 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1142 .name = "qsee",
1143};
1144
1145static struct platform_device qseecom_device = {
1146 .name = "qseecom",
1147 .id = 0,
1148 .dev = {
1149 .platform_data = &qseecom_bus_pdata,
1150 },
1151};
1152#endif
1153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001154#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1155 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1156 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1157 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1158
1159#define QCE_SIZE 0x10000
1160#define QCE_0_BASE 0x18500000
1161
1162#define QCE_HW_KEY_SUPPORT 0
1163#define QCE_SHA_HMAC_SUPPORT 1
1164#define QCE_SHARE_CE_RESOURCE 1
1165#define QCE_CE_SHARED 0
1166
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001167/* Begin Bus scaling definitions */
1168static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1169 {
1170 .src = MSM_BUS_MASTER_ADM_PORT0,
1171 .dst = MSM_BUS_SLAVE_EBI_CH0,
1172 .ab = 0,
1173 .ib = 0,
1174 },
1175 {
1176 .src = MSM_BUS_MASTER_ADM_PORT1,
1177 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1178 .ab = 0,
1179 .ib = 0,
1180 },
1181};
1182
1183static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1184 {
1185 .src = MSM_BUS_MASTER_ADM_PORT0,
1186 .dst = MSM_BUS_SLAVE_EBI_CH0,
1187 .ab = 70000000UL,
1188 .ib = 70000000UL,
1189 },
1190 {
1191 .src = MSM_BUS_MASTER_ADM_PORT1,
1192 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1193 .ab = 2480000000UL,
1194 .ib = 2480000000UL,
1195 },
1196};
1197
1198static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1199 {
1200 ARRAY_SIZE(crypto_hw_init_vectors),
1201 crypto_hw_init_vectors,
1202 },
1203 {
1204 ARRAY_SIZE(crypto_hw_active_vectors),
1205 crypto_hw_active_vectors,
1206 },
1207};
1208
1209static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1210 crypto_hw_bus_scale_usecases,
1211 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1212 .name = "cryptohw",
1213};
1214/* End Bus Scaling Definitions*/
1215
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001216static struct resource qcrypto_resources[] = {
1217 [0] = {
1218 .start = QCE_0_BASE,
1219 .end = QCE_0_BASE + QCE_SIZE - 1,
1220 .flags = IORESOURCE_MEM,
1221 },
1222 [1] = {
1223 .name = "crypto_channels",
1224 .start = DMOV_CE_IN_CHAN,
1225 .end = DMOV_CE_OUT_CHAN,
1226 .flags = IORESOURCE_DMA,
1227 },
1228 [2] = {
1229 .name = "crypto_crci_in",
1230 .start = DMOV_CE_IN_CRCI,
1231 .end = DMOV_CE_IN_CRCI,
1232 .flags = IORESOURCE_DMA,
1233 },
1234 [3] = {
1235 .name = "crypto_crci_out",
1236 .start = DMOV_CE_OUT_CRCI,
1237 .end = DMOV_CE_OUT_CRCI,
1238 .flags = IORESOURCE_DMA,
1239 },
1240};
1241
1242static struct resource qcedev_resources[] = {
1243 [0] = {
1244 .start = QCE_0_BASE,
1245 .end = QCE_0_BASE + QCE_SIZE - 1,
1246 .flags = IORESOURCE_MEM,
1247 },
1248 [1] = {
1249 .name = "crypto_channels",
1250 .start = DMOV_CE_IN_CHAN,
1251 .end = DMOV_CE_OUT_CHAN,
1252 .flags = IORESOURCE_DMA,
1253 },
1254 [2] = {
1255 .name = "crypto_crci_in",
1256 .start = DMOV_CE_IN_CRCI,
1257 .end = DMOV_CE_IN_CRCI,
1258 .flags = IORESOURCE_DMA,
1259 },
1260 [3] = {
1261 .name = "crypto_crci_out",
1262 .start = DMOV_CE_OUT_CRCI,
1263 .end = DMOV_CE_OUT_CRCI,
1264 .flags = IORESOURCE_DMA,
1265 },
1266};
1267
1268#endif
1269
1270#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1271 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1272
1273static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1274 .ce_shared = QCE_CE_SHARED,
1275 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1276 .hw_key_support = QCE_HW_KEY_SUPPORT,
1277 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001278 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001279};
1280
1281static struct platform_device qcrypto_device = {
1282 .name = "qcrypto",
1283 .id = 0,
1284 .num_resources = ARRAY_SIZE(qcrypto_resources),
1285 .resource = qcrypto_resources,
1286 .dev = {
1287 .coherent_dma_mask = DMA_BIT_MASK(32),
1288 .platform_data = &qcrypto_ce_hw_suppport,
1289 },
1290};
1291#endif
1292
1293#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1294 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1295
1296static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1297 .ce_shared = QCE_CE_SHARED,
1298 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1299 .hw_key_support = QCE_HW_KEY_SUPPORT,
1300 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001301 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001302};
1303
1304static struct platform_device qcedev_device = {
1305 .name = "qce",
1306 .id = 0,
1307 .num_resources = ARRAY_SIZE(qcedev_resources),
1308 .resource = qcedev_resources,
1309 .dev = {
1310 .coherent_dma_mask = DMA_BIT_MASK(32),
1311 .platform_data = &qcedev_ce_hw_suppport,
1312 },
1313};
1314#endif
1315
Joel Kingb8352a12011-11-15 18:46:24 -08001316#define MDM2AP_ERRFATAL 70
1317#define AP2MDM_ERRFATAL 95
1318#define MDM2AP_STATUS 69
1319#define AP2MDM_STATUS 94
1320#define AP2MDM_PMIC_RESET_N 80
1321#define AP2MDM_KPDPWR_N 81
1322
Joel Kingb8352a12011-11-15 18:46:24 -08001323static struct resource mdm_resources[] = {
1324 {
1325 .start = MDM2AP_ERRFATAL,
1326 .end = MDM2AP_ERRFATAL,
1327 .name = "MDM2AP_ERRFATAL",
1328 .flags = IORESOURCE_IO,
1329 },
1330 {
1331 .start = AP2MDM_ERRFATAL,
1332 .end = AP2MDM_ERRFATAL,
1333 .name = "AP2MDM_ERRFATAL",
1334 .flags = IORESOURCE_IO,
1335 },
1336 {
1337 .start = MDM2AP_STATUS,
1338 .end = MDM2AP_STATUS,
1339 .name = "MDM2AP_STATUS",
1340 .flags = IORESOURCE_IO,
1341 },
1342 {
1343 .start = AP2MDM_STATUS,
1344 .end = AP2MDM_STATUS,
1345 .name = "AP2MDM_STATUS",
1346 .flags = IORESOURCE_IO,
1347 },
1348 {
1349 .start = AP2MDM_PMIC_RESET_N,
1350 .end = AP2MDM_PMIC_RESET_N,
1351 .name = "AP2MDM_PMIC_RESET_N",
1352 .flags = IORESOURCE_IO,
1353 },
1354 {
1355 .start = AP2MDM_KPDPWR_N,
1356 .end = AP2MDM_KPDPWR_N,
1357 .name = "AP2MDM_KPDPWR_N",
1358 .flags = IORESOURCE_IO,
1359 },
1360};
1361
1362static struct mdm_platform_data mdm_platform_data = {
1363 .mdm_version = "2.5",
1364};
1365
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001366static struct platform_device mdm_device = {
Joel Kingb8352a12011-11-15 18:46:24 -08001367 .name = "mdm2_modem",
1368 .id = -1,
1369 .num_resources = ARRAY_SIZE(mdm_resources),
1370 .resource = mdm_resources,
1371 .dev = {
1372 .platform_data = &mdm_platform_data,
1373 },
1374};
1375
1376static struct platform_device *mdm_devices[] __initdata = {
1377 &mdm_device,
1378};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001379
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001380#define MSM_SHARED_RAM_PHYS 0x80000000
1381
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001382static void __init msm8960_map_io(void)
1383{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001384 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001385 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001386
1387 if (socinfo_init() < 0)
1388 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001389}
1390
1391static void __init msm8960_init_irq(void)
1392{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001393 struct msm_mpm_device_data *data = NULL;
1394
1395#ifdef CONFIG_MSM_MPM
1396 data = &msm8960_mpm_dev_data;
1397#endif
1398
1399 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001400 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001401 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001402}
1403
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001404static void __init msm8960_init_buses(void)
1405{
1406#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001407 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001408 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1409 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
1410 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1411 msm_bus_apps_fabric.dev.platform_data =
1412 &msm_bus_8960_apps_fabric_pdata;
1413 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
1414 msm_bus_mm_fabric.dev.platform_data = &msm_bus_8960_mm_fabric_pdata;
1415 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1416 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001417#endif
1418}
1419
1420static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1421 .max_clock_speed = 15060000,
1422};
1423
1424#ifdef CONFIG_USB_MSM_OTG_72K
1425static struct msm_otg_platform_data msm_otg_pdata;
1426#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301427static int wr_phy_init_seq[] = {
1428 0x44, 0x80, /* set VBUS valid threshold
1429 and disconnect valid threshold */
1430 0x38, 0x81, /* update DC voltage level */
1431 0x14, 0x82, /* set preemphasis and rise/fall time */
1432 0x13, 0x83, /* set source impedance adjusment */
1433 -1};
1434
1435static int liquid_v1_phy_init_seq[] = {
1436 0x44, 0x80,/* set VBUS valid threshold
1437 and disconnect valid threshold */
1438 0x3C, 0x81,/* update DC voltage level */
1439 0x18, 0x82,/* set preemphasis and rise/fall time */
1440 0x23, 0x83,/* set source impedance sdjusment */
1441 -1};
1442
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301443#ifdef CONFIG_MSM_BUS_SCALING
1444/* Bandwidth requests (zero) if no vote placed */
1445static struct msm_bus_vectors usb_init_vectors[] = {
1446 {
1447 .src = MSM_BUS_MASTER_SPS,
1448 .dst = MSM_BUS_SLAVE_EBI_CH0,
1449 .ab = 0,
1450 .ib = 0,
1451 },
1452};
1453
1454/* Bus bandwidth requests in Bytes/sec */
1455static struct msm_bus_vectors usb_max_vectors[] = {
1456 {
1457 .src = MSM_BUS_MASTER_SPS,
1458 .dst = MSM_BUS_SLAVE_EBI_CH0,
1459 .ab = 60000000, /* At least 480Mbps on bus. */
1460 .ib = 960000000, /* MAX bursts rate */
1461 },
1462};
1463
1464static struct msm_bus_paths usb_bus_scale_usecases[] = {
1465 {
1466 ARRAY_SIZE(usb_init_vectors),
1467 usb_init_vectors,
1468 },
1469 {
1470 ARRAY_SIZE(usb_max_vectors),
1471 usb_max_vectors,
1472 },
1473};
1474
1475static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1476 usb_bus_scale_usecases,
1477 ARRAY_SIZE(usb_bus_scale_usecases),
1478 .name = "usb",
1479};
1480#endif
1481
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001482static struct msm_otg_platform_data msm_otg_pdata = {
1483 .mode = USB_OTG,
1484 .otg_control = OTG_PMIC_CONTROL,
1485 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001486 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301487 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301488#ifdef CONFIG_MSM_BUS_SCALING
1489 .bus_scale_table = &usb_bus_scale_pdata,
1490#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001491};
1492#endif
1493
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301494#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301495#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301496static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1497 .strobe = 150,
1498 .data = 151,
1499};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301500
1501static struct smsc_hub_platform_data hsic_hub_pdata = {
1502 .hub_reset = HSIC_HUB_RESET_GPIO,
1503};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301504#else
1505static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301506static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301507#endif
1508
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301509static struct platform_device smsc_hub_device = {
1510 .name = "msm_smsc_hub",
1511 .id = -1,
1512 .dev = {
1513 .platform_data = &hsic_hub_pdata,
1514 },
1515};
1516
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001517#define PID_MAGIC_ID 0x71432909
1518#define SERIAL_NUM_MAGIC_ID 0x61945374
1519#define SERIAL_NUMBER_LENGTH 127
1520#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1521
1522struct magic_num_struct {
1523 uint32_t pid;
1524 uint32_t serial_num;
1525};
1526
1527struct dload_struct {
1528 uint32_t reserved1;
1529 uint32_t reserved2;
1530 uint32_t reserved3;
1531 uint16_t reserved4;
1532 uint16_t pid;
1533 char serial_number[SERIAL_NUMBER_LENGTH];
1534 uint16_t reserved5;
1535 struct magic_num_struct magic_struct;
1536};
1537
1538static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1539{
1540 struct dload_struct __iomem *dload = 0;
1541
1542 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1543 if (!dload) {
1544 pr_err("%s: cannot remap I/O memory region: %08x\n",
1545 __func__, DLOAD_USB_BASE_ADD);
1546 return -ENXIO;
1547 }
1548
1549 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1550 __func__, dload, pid, snum);
1551 /* update pid */
1552 dload->magic_struct.pid = PID_MAGIC_ID;
1553 dload->pid = pid;
1554
1555 /* update serial number */
1556 dload->magic_struct.serial_num = 0;
1557 if (!snum) {
1558 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1559 goto out;
1560 }
1561
1562 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001563 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001564out:
1565 iounmap(dload);
1566 return 0;
1567}
1568
1569static struct android_usb_platform_data android_usb_pdata = {
1570 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1571};
1572
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001573static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001574 .name = "android_usb",
1575 .id = -1,
1576 .dev = {
1577 .platform_data = &android_usb_pdata,
1578 },
1579};
1580
1581static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1582 0x03, 0x0f,
1583};
1584
1585static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1586 0x00, 0x24, 0x54, 0x10,
1587 0x09, 0x03, 0x01,
1588 0x10, 0x54, 0x30, 0x0C,
1589 0x24, 0x30, 0x0f,
1590};
1591
1592static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1593 0x00, 0x24, 0x54, 0x10,
1594 0x09, 0x07, 0x01, 0x0B,
1595 0x10, 0x54, 0x30, 0x0C,
1596 0x24, 0x30, 0x0f,
1597};
1598
1599static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
1600 [0] = {
1601 .mode = MSM_SPM_MODE_CLOCK_GATING,
1602 .notify_rpm = false,
1603 .cmd = spm_wfi_cmd_sequence,
1604 },
1605 [1] = {
1606 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1607 .notify_rpm = false,
1608 .cmd = spm_power_collapse_without_rpm,
1609 },
1610 [2] = {
1611 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1612 .notify_rpm = true,
1613 .cmd = spm_power_collapse_with_rpm,
1614 },
1615};
1616
1617static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1618 [0] = {
1619 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001620 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001621#if defined(CONFIG_MSM_AVS_HW)
1622 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1623 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1624#endif
1625 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001626 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1628 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1629 .vctl_timeout_us = 50,
1630 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1631 .modes = msm_spm_seq_list,
1632 },
1633 [1] = {
1634 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001635 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001636#if defined(CONFIG_MSM_AVS_HW)
1637 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1638 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1639#endif
1640 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001641 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001642 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1643 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1644 .vctl_timeout_us = 50,
1645 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1646 .modes = msm_spm_seq_list,
1647 },
1648};
1649
1650static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1651 0x00, 0x20, 0x03, 0x20,
1652 0x00, 0x0f,
1653};
1654
1655static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1656 0x00, 0x20, 0x34, 0x64,
1657 0x48, 0x07, 0x48, 0x20,
1658 0x50, 0x64, 0x04, 0x34,
1659 0x50, 0x0f,
1660};
1661static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1662 0x00, 0x10, 0x34, 0x64,
1663 0x48, 0x07, 0x48, 0x10,
1664 0x50, 0x64, 0x04, 0x34,
1665 0x50, 0x0F,
1666};
1667
1668static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1669 [0] = {
1670 .mode = MSM_SPM_L2_MODE_RETENTION,
1671 .notify_rpm = false,
1672 .cmd = l2_spm_wfi_cmd_sequence,
1673 },
1674 [1] = {
1675 .mode = MSM_SPM_L2_MODE_GDHS,
1676 .notify_rpm = true,
1677 .cmd = l2_spm_gdhs_cmd_sequence,
1678 },
1679 [2] = {
1680 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1681 .notify_rpm = true,
1682 .cmd = l2_spm_power_off_cmd_sequence,
1683 },
1684};
1685
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001686static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1687 [0] = {
1688 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001689 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001690 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001691 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1692 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1693 .modes = msm_spm_l2_seq_list,
1694 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1695 },
1696};
1697
Mohan Pallaka5e490392011-09-09 15:18:41 +05301698#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1699#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1700
1701static struct msm_xo_voter *xo_handle_d1;
1702
1703static int isa1200_power(int on)
1704{
1705 int rc = 0;
1706
1707 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, !!on);
1708
1709 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1710 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1711 if (rc < 0) {
1712 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1713 __func__, on ? "" : "de-", rc);
1714 goto err_xo_vote;
1715 }
1716
1717 return 0;
1718
1719err_xo_vote:
1720 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, !on);
1721 return rc;
1722}
1723
1724static int isa1200_dev_setup(bool enable)
1725{
1726 int rc = 0;
1727
1728 struct pm_gpio hap_gpio_config = {
1729 .direction = PM_GPIO_DIR_OUT,
1730 .pull = PM_GPIO_PULL_NO,
1731 .out_strength = PM_GPIO_STRENGTH_HIGH,
1732 .function = PM_GPIO_FUNC_NORMAL,
1733 .inv_int_pol = 0,
1734 .vin_sel = 2,
1735 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1736 .output_value = 0,
1737 };
1738
1739 if (enable == true) {
1740 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1741 if (rc) {
1742 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1743 __func__, PM_HAP_EN_GPIO, rc);
1744 return rc;
1745 }
1746
1747 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1748 if (rc) {
1749 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1750 __func__, PM_HAP_LEN_GPIO, rc);
1751 return rc;
1752 }
1753
1754 rc = gpio_request(HAP_SHIFT_LVL_OE_GPIO, "hap_shft_lvl_oe");
1755 if (rc) {
1756 pr_err("%s: unable to request gpio %d (%d)\n",
1757 __func__, HAP_SHIFT_LVL_OE_GPIO, rc);
1758 return rc;
1759 }
1760
1761 rc = gpio_direction_output(HAP_SHIFT_LVL_OE_GPIO, 0);
1762 if (rc) {
1763 pr_err("%s: Unable to set direction\n", __func__);
1764 goto free_gpio;
1765 }
1766
1767 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1768 if (IS_ERR(xo_handle_d1)) {
1769 rc = PTR_ERR(xo_handle_d1);
1770 pr_err("%s: failed to get the handle for D1(%d)\n",
1771 __func__, rc);
1772 goto gpio_set_dir;
1773 }
1774 } else {
1775 gpio_free(HAP_SHIFT_LVL_OE_GPIO);
1776
1777 msm_xo_put(xo_handle_d1);
1778 }
1779
1780 return 0;
1781
1782gpio_set_dir:
1783 gpio_set_value(HAP_SHIFT_LVL_OE_GPIO, 0);
1784free_gpio:
1785 gpio_free(HAP_SHIFT_LVL_OE_GPIO);
1786 return rc;
1787}
1788
1789static struct isa1200_regulator isa1200_reg_data[] = {
1790 {
1791 .name = "vcc_i2c",
1792 .min_uV = ISA_I2C_VTG_MIN_UV,
1793 .max_uV = ISA_I2C_VTG_MAX_UV,
1794 .load_uA = ISA_I2C_CURR_UA,
1795 },
1796};
1797
1798static struct isa1200_platform_data isa1200_1_pdata = {
1799 .name = "vibrator",
1800 .dev_setup = isa1200_dev_setup,
1801 .power_on = isa1200_power,
1802 .hap_en_gpio = PM_HAP_EN_GPIO,
1803 .hap_len_gpio = PM_HAP_LEN_GPIO,
1804 .max_timeout = 15000,
1805 .mode_ctrl = PWM_GEN_MODE,
1806 .pwm_fd = {
1807 .pwm_div = 256,
1808 },
1809 .is_erm = false,
1810 .smart_en = true,
1811 .ext_clk_en = true,
1812 .chip_en = 1,
1813 .regulator_info = isa1200_reg_data,
1814 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1815};
1816
1817static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1818 {
1819 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05301820 },
1821};
1822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001823#define CYTTSP_TS_GPIO_IRQ 11
1824#define CYTTSP_TS_SLEEP_GPIO 50
1825#define CYTTSP_TS_RESOUT_N_GPIO 52
1826
1827/*virtual key support */
1828static ssize_t tma340_vkeys_show(struct kobject *kobj,
1829 struct kobj_attribute *attr, char *buf)
1830{
1831 return snprintf(buf, 200,
1832 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1833 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1834 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1835 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1836 "\n");
1837}
1838
1839static struct kobj_attribute tma340_vkeys_attr = {
1840 .attr = {
1841 .mode = S_IRUGO,
1842 },
1843 .show = &tma340_vkeys_show,
1844};
1845
1846static struct attribute *tma340_properties_attrs[] = {
1847 &tma340_vkeys_attr.attr,
1848 NULL
1849};
1850
1851static struct attribute_group tma340_properties_attr_group = {
1852 .attrs = tma340_properties_attrs,
1853};
1854
1855
1856static int cyttsp_platform_init(struct i2c_client *client)
1857{
1858 int rc = 0;
1859 static struct kobject *tma340_properties_kobj;
1860
1861 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1862 tma340_properties_kobj = kobject_create_and_add("board_properties",
1863 NULL);
1864 if (tma340_properties_kobj)
1865 rc = sysfs_create_group(tma340_properties_kobj,
1866 &tma340_properties_attr_group);
1867 if (!tma340_properties_kobj || rc)
1868 pr_err("%s: failed to create board_properties\n",
1869 __func__);
1870
1871 return 0;
1872}
1873
1874static struct cyttsp_regulator regulator_data[] = {
1875 {
1876 .name = "vdd",
1877 .min_uV = CY_TMA300_VTG_MIN_UV,
1878 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05301879 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1880 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001881 },
1882 /* TODO: Remove after runtime PM is enabled in I2C driver */
1883 {
1884 .name = "vcc_i2c",
1885 .min_uV = CY_I2C_VTG_MIN_UV,
1886 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05301887 .hpm_load_uA = CY_I2C_CURR_UA,
1888 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001889 },
1890};
1891
1892static struct cyttsp_platform_data cyttsp_pdata = {
1893 .panel_maxx = 634,
1894 .panel_maxy = 1166,
1895 .disp_maxx = 616,
1896 .disp_maxy = 1023,
1897 .disp_minx = 0,
1898 .disp_miny = 16,
1899 .flags = 0x01,
1900 .gen = CY_GEN3, /* or */
1901 .use_st = CY_USE_ST,
1902 .use_mt = CY_USE_MT,
1903 .use_hndshk = CY_SEND_HNDSHK,
1904 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05301905 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001906 .use_gestures = CY_USE_GESTURES,
1907 .fw_fname = "cyttsp_8960_cdp.hex",
1908 /* activate up to 4 groups
1909 * and set active distance
1910 */
1911 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
1912 CY_GEST_GRP3 | CY_GEST_GRP4 |
1913 CY_ACT_DIST,
1914 /* change act_intrvl to customize the Active power state
1915 * scanning/processing refresh interval for Operating mode
1916 */
1917 .act_intrvl = CY_ACT_INTRVL_DFLT,
1918 /* change tch_tmout to customize the touch timeout for the
1919 * Active power state for Operating mode
1920 */
1921 .tch_tmout = CY_TCH_TMOUT_DFLT,
1922 /* change lp_intrvl to customize the Low Power power state
1923 * scanning/processing refresh interval for Operating mode
1924 */
1925 .lp_intrvl = CY_LP_INTRVL_DFLT,
1926 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
1927 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
1928 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1929 .regulator_info = regulator_data,
1930 .num_regulators = ARRAY_SIZE(regulator_data),
1931 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05301932 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933};
1934
1935static struct i2c_board_info cyttsp_info[] __initdata = {
1936 {
1937 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1938 .platform_data = &cyttsp_pdata,
1939#ifndef CY_USE_TIMER
1940 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1941#endif /* CY_USE_TIMER */
1942 },
1943};
1944
Jing Lindc4413c2012-01-16 15:22:52 -08001945/* configuration data for mxt1386 */
1946static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05301947 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001948 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301949 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001950 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07001951 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1952 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1953 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1954 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1955 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1956 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301957 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001958 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05301959 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001960 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05301961 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001962 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
1963 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
1964 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
1965 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05301966 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001967 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1968 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05301969 /* T18 Object */
1970 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301971 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001972 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
1973 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301974 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001975 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1976 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301977 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001978 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
1979 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301980 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001981 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301982 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08001983 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05301984 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001985 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301986 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001987 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301988 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07001989 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05301990};
1991
Jing Lin33b007d2011-12-21 17:40:23 -08001992/* configuration data for mxt1386e using V1.0 firmware */
1993static const u8 mxt1386e_config_data_v1_0[] = {
1994 /* T6 Object */
1995 0, 0, 0, 0, 0, 0,
1996 /* T38 Object */
1997 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
1998 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1999 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2000 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2001 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2002 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2003 0, 0, 0, 0,
2004 /* T7 Object */
2005 100, 16, 50,
2006 /* T8 Object */
2007 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2008 /* T9 Object */
2009 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2010 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2011 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2012 10, 5, 0, 0, 0,
2013 /* T18 Object */
2014 0, 0,
2015 /* T24 Object */
2016 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2017 0, 0, 0, 0, 0, 0, 0, 0, 0,
2018 /* T25 Object */
2019 3, 0, 60, 115, 156, 99,
2020 /* T27 Object */
2021 0, 0, 0, 0, 0, 0, 0,
2022 /* T40 Object */
2023 0, 0, 0, 0, 0,
2024 /* T42 Object */
2025 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2026 /* T43 Object */
2027 0, 0, 0, 0, 0, 0, 0,
2028 /* T46 Object */
2029 64, 0, 20, 20, 0, 0, 0, 0, 0,
2030 /* T47 Object */
2031 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2032 /* T48 Object */
2033 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2034 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2035 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2036 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2037 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2038 0, 0, 0, 0,
2039 /* T56 Object */
2040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2041 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2042 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2043 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2044 2, 99, 33,
2045};
2046
2047/* configuration data for mxt1386e using V2.1 firmware */
2048static const u8 mxt1386e_config_data_v2_1[] = {
2049 /* T6 Object */
2050 0, 0, 0, 0, 0, 0,
2051 /* T38 Object */
2052 12, 2, 0, 17, 1, 12, 0, 0, 0, 0,
2053 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2054 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2055 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2056 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2057 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2058 0, 0, 0, 0,
2059 /* T7 Object */
2060 100, 16, 50,
2061 /* T8 Object */
2062 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2063 /* T9 Object */
2064 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2065 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2066 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2067 10, 5, 0, 0, 0,
2068 /* T18 Object */
2069 0, 0,
2070 /* T24 Object */
2071 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2072 0, 0, 0, 0, 0, 0, 0, 0, 0,
2073 /* T25 Object */
2074 3, 0, 60, 115, 156, 99,
2075 /* T27 Object */
2076 0, 0, 0, 0, 0, 0, 0,
2077 /* T40 Object */
2078 0, 0, 0, 0, 0,
2079 /* T42 Object */
2080 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2081 /* T43 Object */
2082 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2083 16,
2084 /* T46 Object */
2085 64, 0, 20, 20, 0, 0, 0, 0, 0,
2086 /* T47 Object */
2087 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2088 /* T48 Object */
2089 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2090 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2091 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2092 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2093 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2094 0, 0, 0, 0,
2095 /* T56 Object */
2096 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2098 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2099 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2100 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2101 255,
2102};
2103
Jing Lineec88ca2012-02-08 11:18:30 -08002104/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2105static const u8 mxt1386e_config_data_3d[] = {
2106 /* T6 Object */
2107 0, 0, 0, 0, 0, 0,
2108 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002109 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2115 0, 0, 0, 0,
2116 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002117 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002118 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002119 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002120 /* T9 Object */
2121 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2122 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002123 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2124 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002125 /* T18 Object */
2126 0, 0,
2127 /* T24 Object */
2128 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2129 0, 0, 0, 0, 0, 0, 0, 0, 0,
2130 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002131 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002132 /* T27 Object */
2133 0, 0, 0, 0, 0, 0, 0,
2134 /* T40 Object */
2135 0, 0, 0, 0, 0,
2136 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002138 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002139 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2140 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002141 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002142 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002143 /* T47 Object */
2144 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2145 /* T48 Object */
2146 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002147 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2148 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2149 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2151 0, 0, 0, 0,
2152 /* T56 Object */
2153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2158 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002159};
2160
Amy Maloche08266db2011-11-04 11:07:16 -07002161#define MXT_TS_GPIO_IRQ 11
2162#define MXT_TS_LDO_EN_GPIO 50
2163#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302164
2165static void mxt_init_hw_liquid(void)
2166{
2167 int rc;
2168
Mohan Pallaka50837382011-09-07 11:00:57 +05302169 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2170 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002171 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2172 __func__, MXT_TS_LDO_EN_GPIO);
2173 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302174 }
2175
2176 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2177 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002178 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2179 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302180 goto err_ldo_gpio_req;
2181 }
2182
Mohan Pallaka50837382011-09-07 11:00:57 +05302183 return;
2184
Mohan Pallaka50837382011-09-07 11:00:57 +05302185err_ldo_gpio_req:
2186 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302187}
2188
Jing Lineec88ca2012-02-08 11:18:30 -08002189static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002190 {
2191 .config = mxt1386_config_data,
2192 .config_length = ARRAY_SIZE(mxt1386_config_data),
2193 .family_id = 0xA0,
2194 .variant_id = 0x0,
2195 .version = 0x10,
2196 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002197 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002198 },
Jing Lin33b007d2011-12-21 17:40:23 -08002199 {
2200 .config = mxt1386e_config_data_v1_0,
2201 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2202 .family_id = 0xA0,
2203 .variant_id = 0x2,
2204 .version = 0x10,
2205 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002206 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002207 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002208 },
2209 {
2210 .config = mxt1386e_config_data_v2_1,
2211 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2212 .family_id = 0xA0,
2213 .variant_id = 0x7,
2214 .version = 0x21,
2215 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002216 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002217 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2218 },
2219 {
2220 /* The config data for V2.2.AA is the same as for V2.1.AA */
2221 .config = mxt1386e_config_data_v2_1,
2222 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2223 .family_id = 0xA0,
2224 .variant_id = 0x7,
2225 .version = 0x22,
2226 .build = 0xAA,
2227 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002228 },
Jing Lindc4413c2012-01-16 15:22:52 -08002229};
2230
Jing Lineec88ca2012-02-08 11:18:30 -08002231static struct mxt_platform_data mxt_platform_data_2d = {
2232 .config_array = mxt_config_array_2d,
2233 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002234 .panel_minx = 0,
2235 .panel_maxx = 1365,
2236 .panel_miny = 0,
2237 .panel_maxy = 767,
2238 .disp_minx = 0,
2239 .disp_maxx = 1365,
2240 .disp_miny = 0,
2241 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302242 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002243 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002244 .reset_gpio = MXT_TS_RESET_GPIO,
2245 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302246};
2247
Jing Lineec88ca2012-02-08 11:18:30 -08002248static struct mxt_config_info mxt_config_array_3d[] = {
2249 {
2250 .config = mxt1386e_config_data_3d,
2251 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2252 .family_id = 0xA0,
2253 .variant_id = 0x7,
2254 .version = 0x21,
2255 .build = 0xAA,
2256 },
2257};
2258
2259static struct mxt_platform_data mxt_platform_data_3d = {
2260 .config_array = mxt_config_array_3d,
2261 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002262 .panel_minx = 0,
2263 .panel_maxx = 1919,
2264 .panel_miny = 0,
2265 .panel_maxy = 1199,
2266 .disp_minx = 0,
2267 .disp_maxx = 1919,
2268 .disp_miny = 0,
2269 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002270 .irqflags = IRQF_TRIGGER_FALLING,
2271 .i2c_pull_up = true,
2272 .reset_gpio = MXT_TS_RESET_GPIO,
2273 .irq_gpio = MXT_TS_GPIO_IRQ,
2274};
2275
Mohan Pallaka50837382011-09-07 11:00:57 +05302276static struct i2c_board_info mxt_device_info[] __initdata = {
2277 {
2278 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302279 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2280 },
2281};
2282
Manoj Rao14648742012-03-30 19:42:12 -07002283#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2284static void mhl_sii_reset_gpio(int on)
2285{
2286 gpio_set_value(MHL_GPIO_RESET, on);
2287 return;
2288}
2289
2290/*
2291 * Request for GPIO allocations
2292 * Set appropriate GPIO directions
2293 */
2294static int mhl_sii_gpio_setup(int on)
2295{
2296 int ret;
2297
2298 if (on) {
2299 ret = gpio_request(MHL_GPIO_RESET, "W_RST#");
2300 if (ret < 0) {
2301 pr_err("GPIO RESET request failed: %d\n", ret);
2302 return -EBUSY;
2303 }
2304 ret = gpio_direction_output(MHL_GPIO_RESET, 1);
2305 if (ret < 0) {
2306 pr_err("SET GPIO RESET direction failed: %d\n", ret);
2307 gpio_free(MHL_GPIO_RESET);
2308 return -EBUSY;
2309 }
2310 ret = gpio_request(MHL_GPIO_INT, "W_INT");
2311 if (ret < 0) {
2312 pr_err("GPIO INT request failed: %d\n", ret);
2313 gpio_free(MHL_GPIO_RESET);
2314 return -EBUSY;
2315 }
2316 ret = gpio_direction_input(MHL_GPIO_INT);
2317 if (ret < 0) {
2318 pr_err("SET GPIO INTR direction failed: %d\n", ret);
2319 gpio_free(MHL_GPIO_RESET);
2320 gpio_free(MHL_GPIO_INT);
2321 return -EBUSY;
2322 }
2323 } else {
2324 gpio_free(MHL_GPIO_RESET);
2325 gpio_free(MHL_GPIO_INT);
2326 }
2327
2328 return 0;
2329}
2330
2331static struct msm_mhl_platform_data mhl_platform_data = {
2332 .irq = MSM_GPIO_TO_INT(4),
2333 .gpio_setup = mhl_sii_gpio_setup,
2334 .reset_pin = mhl_sii_reset_gpio,
2335};
2336#endif
2337
Eugene Yasmand2316b82011-12-07 18:23:48 +02002338static struct i2c_board_info sii_device_info[] __initdata = {
2339 {
Manoj Rao14648742012-03-30 19:42:12 -07002340#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2341 /*
2342 * keeps SI 8334 as the default
2343 * MHL TX
2344 */
2345 I2C_BOARD_INFO("sii8334", 0x39),
2346 .platform_data = &mhl_platform_data,
2347#endif
2348#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002349 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002350 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002351#endif /* CONFIG_MSM_HDMI_MHL */
2352 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002353 },
2354};
2355
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002356static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2357 .clk_freq = 100000,
2358 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002359};
2360
2361static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2362 .clk_freq = 100000,
2363 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002364};
2365
2366static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2367 .clk_freq = 100000,
2368 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002369};
2370
2371static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2372 .clk_freq = 100000,
2373 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002374};
2375
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06002376static struct msm_pm_sleep_status_data msm_pm_slp_sts_data = {
2377 .base_addr = MSM_ACC0_BASE + 0x08,
2378 .cpu_offset = MSM_ACC1_BASE - MSM_ACC0_BASE,
2379 .mask = 1UL << 13,
2380};
2381
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002382static struct ks8851_pdata spi_eth_pdata = {
2383 .irq_gpio = KS8851_IRQ_GPIO,
2384 .rst_gpio = KS8851_RST_GPIO,
2385};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002386
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002387static struct spi_board_info spi_board_info[] __initdata = {
2388 {
2389 .modalias = "ks8851",
2390 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2391 .max_speed_hz = 19200000,
2392 .bus_num = 0,
2393 .chip_select = 0,
2394 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002395 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002396 },
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002397 {
2398 .modalias = "dsi_novatek_3d_panel_spi",
2399 .max_speed_hz = 10800000,
2400 .bus_num = 0,
2401 .chip_select = 1,
2402 .mode = SPI_MODE_0,
2403 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002404};
2405
2406static struct platform_device msm_device_saw_core0 = {
2407 .name = "saw-regulator",
2408 .id = 0,
2409 .dev = {
2410 .platform_data = &msm_saw_regulator_pdata_s5,
2411 },
2412};
2413
2414static struct platform_device msm_device_saw_core1 = {
2415 .name = "saw-regulator",
2416 .id = 1,
2417 .dev = {
2418 .platform_data = &msm_saw_regulator_pdata_s6,
2419 },
2420};
2421
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002422static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002423 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002424 .tsens_factor = 1000,
2425 .hw_type = MSM_8960,
2426 .tsens_num_sensor = 5,
2427};
2428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002429#ifdef CONFIG_MSM_FAKE_BATTERY
2430static struct platform_device fish_battery_device = {
2431 .name = "fish_battery",
2432};
2433#endif
2434
David Collins26f05562011-06-20 09:56:28 -07002435static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002436 .name = GPIO_REGULATOR_DEV_NAME,
2437 .id = PM8921_MPP_PM_TO_SYS(7),
2438 .dev = {
2439 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2440 },
2441};
2442
David Collins26f05562011-06-20 09:56:28 -07002443static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002444 .name = GPIO_REGULATOR_DEV_NAME,
2445 .id = 91,
2446 .dev = {
2447 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2448 },
2449};
2450
David Collinsb10be1d2011-09-02 10:29:31 -07002451static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2452 .name = GPIO_REGULATOR_DEV_NAME,
2453 .id = PM8921_GPIO_PM_TO_SYS(17),
2454 .dev = {
2455 .platform_data =
2456 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2457 },
2458};
2459
David Collins35a78f52011-12-14 15:54:25 -08002460static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2461 .name = GPIO_REGULATOR_DEV_NAME,
2462 .id = PM8921_GPIO_PM_TO_SYS(42),
2463 .dev = {
2464 .platform_data =
2465 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2466 },
2467};
2468
David Collins26f05562011-06-20 09:56:28 -07002469static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2470 .name = "rpm-regulator",
2471 .id = -1,
2472 .dev = {
2473 .platform_data = &msm_rpm_regulator_pdata,
2474 },
2475};
Mayank Ranae009c922012-03-22 03:02:06 +05302476#ifdef CONFIG_SERIAL_MSM_HS
2477static int configure_uart_gpios(int on)
2478{
2479 int ret = 0, i;
2480 int uart_gpios[] = {93, 94, 95, 96};
2481
2482 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2483 if (on) {
2484 ret = gpio_request(uart_gpios[i], NULL);
2485 if (ret) {
2486 pr_err("%s: unable to request uart gpio[%d]\n",
2487 __func__, uart_gpios[i]);
2488 break;
2489 }
2490 } else {
2491 gpio_free(uart_gpios[i]);
2492 }
2493 }
2494
2495 if (ret && on && i)
2496 for (; i >= 0; i--)
2497 gpio_free(uart_gpios[i]);
2498 return ret;
2499}
2500
2501static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002502 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302503};
2504#else
2505static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2506#endif
David Collins26f05562011-06-20 09:56:28 -07002507
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002508static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002509 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002510 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302511 &msm_device_uart_dm6,
Mayank Ranae009c922012-03-22 03:02:06 +05302512 &msm_device_uart_dm9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002513 &msm_device_saw_core0,
2514 &msm_device_saw_core1,
2515 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002516 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002517 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002518 &msm8960_device_qup_spi_gsbi1,
2519 &msm8960_device_qup_i2c_gsbi3,
2520 &msm8960_device_qup_i2c_gsbi4,
2521 &msm8960_device_qup_i2c_gsbi10,
2522#ifndef CONFIG_MSM_DSPS
2523 &msm8960_device_qup_i2c_gsbi12,
2524#endif
2525 &msm_slim_ctrl,
2526 &msm_device_wcnss_wlan,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002527#if defined(CONFIG_QSEECOM)
2528 &qseecom_device,
2529#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002530#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2531 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2532 &qcrypto_device,
2533#endif
2534
2535#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2536 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2537 &qcedev_device,
2538#endif
2539#ifdef CONFIG_MSM_ROTATOR
2540 &msm_rotator_device,
2541#endif
2542 &msm_device_sps,
2543#ifdef CONFIG_MSM_FAKE_BATTERY
2544 &fish_battery_device,
2545#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002546 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002547#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002548#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002549 &msm8960_android_pmem_device,
2550 &msm8960_android_pmem_adsp_device,
2551 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002552#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002553#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002554 &msm_device_vidc,
2555 &msm_device_bam_dmux,
2556 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07002557
Joel Nidera1261942011-09-12 16:30:09 +03002558#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2559#ifdef CONFIG_MSM_USE_TSIF1
2560 &msm_device_tsif[1],
2561#else
2562 &msm_device_tsif[0],
2563#endif
2564#endif
2565
Mona Hossain9c430e32011-07-27 11:04:47 -07002566#ifdef CONFIG_HW_RANDOM_MSM
2567 &msm_device_rng,
2568#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002569#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002570 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002571#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002572 &msm8960_rpm_device,
2573 &msm8960_rpm_log_device,
2574 &msm8960_rpm_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002575 &msm_device_tz_log,
Pratik Patel7831c082011-06-08 21:44:37 -07002576#ifdef CONFIG_MSM_QDSS
Pratik Patel1403f2a2012-03-21 10:10:00 -07002577 &msm_qdss_device,
Pratik Patel7831c082011-06-08 21:44:37 -07002578 &msm_etb_device,
2579 &msm_tpiu_device,
2580 &msm_funnel_device,
Pratik Patel492b3012012-03-06 14:22:30 -08002581 &msm_etm_device,
Pratik Patel7831c082011-06-08 21:44:37 -07002582#endif
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002583 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002584 &msm8960_device_watchdog,
Laura Abbottf8c03b92012-02-16 14:57:58 -08002585#ifdef CONFIG_MSM_RTB
Laura Abbottb93525f2012-04-12 09:57:19 -07002586 &msm8960_rtb_device,
Laura Abbottf8c03b92012-02-16 14:57:58 -08002587#endif
Praveen Chidambaram8ea3dcd2011-12-07 14:46:31 -07002588 &msm8960_cpu_idle_device,
Praveen Chidambaram5c8adf22012-02-23 18:44:37 -07002589 &msm8960_msm_gov_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002590 &msm8960_device_cache_erp,
Laura Abbott306bcc22012-03-08 11:24:53 -08002591#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbottb93525f2012-04-12 09:57:19 -07002592 &msm8960_cache_dump_device,
Laura Abbott306bcc22012-03-08 11:24:53 -08002593#endif
Laura Abbott0577d7b2012-04-17 11:14:30 -07002594 &msm8960_iommu_domain_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002595};
2596
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002597static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07002598 &msm8960_device_uart_gsbi5,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002599 &msm8960_device_otg,
2600 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002601 &msm_device_hsusb_host,
Vijayavardhan Vennapusaeb566482011-09-18 07:48:37 +05302602 &msm_device_hsic_host,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002603 &android_usb_device,
2604 &msm_device_vidc,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002605 &msm_bus_apps_fabric,
2606 &msm_bus_sys_fabric,
2607 &msm_bus_mm_fabric,
2608 &msm_bus_sys_fpb,
2609 &msm_bus_cpss_fpb,
2610 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002611 &msm_multi_ch_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002612 &msm_pcm_routing,
2613 &msm_cpudai0,
2614 &msm_cpudai1,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002615 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002616 &msm_cpudai_hdmi_rx,
2617 &msm_cpudai_bt_rx,
2618 &msm_cpudai_bt_tx,
2619 &msm_cpudai_fm_rx,
2620 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002621 &msm_cpudai_auxpcm_rx,
2622 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002623 &msm_cpu_fe,
2624 &msm_stub_codec,
2625 &msm_voice,
2626 &msm_voip,
2627 &msm_lpa_pcm,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302628 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002629 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002630 &msm_cpudai_incall_record_rx,
2631 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002632
2633#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2634 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2635 &qcrypto_device,
2636#endif
2637
2638#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2639 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2640 &qcedev_device,
2641#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002642};
2643
2644static struct platform_device *rumi3_devices[] __initdata = {
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07002645 &msm8960_device_uart_gsbi5,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002646 &msm_kgsl_3d0,
2647 &msm_kgsl_2d0,
2648 &msm_kgsl_2d1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002649#ifdef CONFIG_MSM_GEMINI
2650 &msm8960_gemini_device,
2651#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002652};
2653
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002654static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002655 &msm_8960_q6_lpass,
2656 &msm_8960_q6_mss_fw,
2657 &msm_8960_q6_mss_sw,
Stephen Boyd322a9922011-09-20 01:05:54 -07002658 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002659 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002660 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002661 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002662 &msm8960_device_otg,
2663 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002664 &msm_device_hsusb_host,
2665 &android_usb_device,
2666 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002667 &msm_multi_ch_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002668 &msm_pcm_routing,
2669 &msm_cpudai0,
2670 &msm_cpudai1,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002671 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002672 &msm_cpudai_hdmi_rx,
2673 &msm_cpudai_bt_rx,
2674 &msm_cpudai_bt_tx,
2675 &msm_cpudai_fm_rx,
2676 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002677 &msm_cpudai_auxpcm_rx,
2678 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002679 &msm_cpu_fe,
2680 &msm_stub_codec,
2681 &msm_kgsl_3d0,
2682#ifdef CONFIG_MSM_KGSL_2D
2683 &msm_kgsl_2d0,
2684 &msm_kgsl_2d1,
2685#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002686#ifdef CONFIG_MSM_GEMINI
2687 &msm8960_gemini_device,
2688#endif
2689 &msm_voice,
2690 &msm_voip,
2691 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302692 &msm_cpudai_afe_01_rx,
2693 &msm_cpudai_afe_01_tx,
2694 &msm_cpudai_afe_02_rx,
2695 &msm_cpudai_afe_02_tx,
2696 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302697 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002698 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002699 &msm_cpudai_incall_record_rx,
2700 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002701 &msm_pcm_hostless,
2702 &msm_bus_apps_fabric,
2703 &msm_bus_sys_fabric,
2704 &msm_bus_mm_fabric,
2705 &msm_bus_sys_fpb,
2706 &msm_bus_cpss_fpb,
2707};
2708
2709static void __init msm8960_i2c_init(void)
2710{
2711 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2712 &msm8960_i2c_qup_gsbi4_pdata;
2713
2714 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2715 &msm8960_i2c_qup_gsbi3_pdata;
2716
2717 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2718 &msm8960_i2c_qup_gsbi10_pdata;
2719
2720 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2721 &msm8960_i2c_qup_gsbi12_pdata;
2722}
2723
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002724static void __init msm8960_gfx_init(void)
2725{
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06002726 uint32_t soc_platform_version = socinfo_get_version();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002727 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
2728 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2729 msm_kgsl_3d0.dev.platform_data;
Lucille Sylvesterdce84cd2011-10-12 14:15:37 -06002730 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
2731 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002732 }
2733}
2734
Subhash Jadavani933e6a62011-12-26 18:05:04 +05302735static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736 {
2737 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
2738 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2739 true,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002740 100, 650, 801, 200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002741 },
2742
2743 {
2744 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
2745 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2746 true,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002747 2000, 200, 576000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002748 },
2749
2750 {
2751 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2752 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
2753 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002754 8500, 51, 1122000, 8500,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002755 },
2756
2757 {
2758 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2759 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
2760 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002761 9000, 51, 1130300, 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002762 },
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06002763 {
2764 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2765 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
2766 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002767 10000, 51, 1130300, 10000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06002768 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002769
2770 {
2771 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2772 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
2773 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002774 12000, 14, 2205900, 12000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002775 },
2776
2777 {
2778 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2779 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
2780 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002781 18000, 12, 2364250, 18000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002782 },
2783
2784 {
2785 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2786 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
2787 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002788 23500, 10, 2667000, 23500,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002789 },
2790
2791 {
2792 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2793 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
2794 false,
Praveen Chidambaram8e499d42012-02-08 10:32:27 -07002795 29700, 5, 2867000, 30000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002796 },
2797};
2798
Praveen Chidambaram78499012011-11-01 17:15:17 -06002799static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
2800 .levels = &msm_rpmrs_levels[0],
2801 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
2802 .vdd_mem_levels = {
2803 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
2804 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
2805 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
2806 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
2807 },
2808 .vdd_dig_levels = {
2809 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
2810 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
2811 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
2812 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
2813 },
2814 .vdd_mask = 0x7FFFFF,
2815 .rpmrs_target_id = {
2816 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
2817 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
2818 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
2819 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
2820 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
2821 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
2822 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
2823 },
2824};
2825
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002826static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2827 .mode = MSM_PM_BOOT_CONFIG_TZ,
2828};
2829
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002830#ifdef CONFIG_I2C
2831#define I2C_SURF 1
2832#define I2C_FFA (1 << 1)
2833#define I2C_RUMI (1 << 2)
2834#define I2C_SIM (1 << 3)
2835#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03002836#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002837
2838struct i2c_registry {
2839 u8 machs;
2840 int bus;
2841 struct i2c_board_info *info;
2842 int len;
2843};
2844
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002845/* Sensors DSPS platform data */
2846#ifdef CONFIG_MSM_DSPS
2847#define DSPS_PIL_GENERIC_NAME "dsps"
2848#endif /* CONFIG_MSM_DSPS */
2849
2850static void __init msm8960_init_dsps(void)
2851{
2852#ifdef CONFIG_MSM_DSPS
2853 struct msm_dsps_platform_data *pdata =
2854 msm_dsps_device.dev.platform_data;
2855 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2856 pdata->gpios = NULL;
2857 pdata->gpios_num = 0;
2858
2859 platform_device_register(&msm_dsps_device);
2860#endif /* CONFIG_MSM_DSPS */
2861}
2862
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08002863static int hsic_peripheral_status = 1;
2864static DEFINE_MUTEX(hsic_status_lock);
2865
2866void peripheral_connect()
2867{
2868 mutex_lock(&hsic_status_lock);
2869 if (hsic_peripheral_status)
2870 goto out;
2871 platform_device_add(&msm_device_hsic_host);
2872 hsic_peripheral_status = 1;
2873out:
2874 mutex_unlock(&hsic_status_lock);
2875}
2876EXPORT_SYMBOL(peripheral_connect);
2877
2878void peripheral_disconnect()
2879{
2880 mutex_lock(&hsic_status_lock);
2881 if (!hsic_peripheral_status)
2882 goto out;
2883 platform_device_del(&msm_device_hsic_host);
2884 hsic_peripheral_status = 0;
2885out:
2886 mutex_unlock(&hsic_status_lock);
2887}
2888EXPORT_SYMBOL(peripheral_disconnect);
2889
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05302890static void __init msm8960_init_smsc_hub(void)
2891{
2892 uint32_t version = socinfo_get_version();
2893
2894 if (SOCINFO_VERSION_MAJOR(version) == 1)
2895 return;
2896
2897 if (machine_is_msm8960_liquid())
2898 platform_device_register(&smsc_hub_device);
2899}
2900
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07002901static void __init msm8960_init_hsic(void)
2902{
2903#ifdef CONFIG_USB_EHCI_MSM_HSIC
2904 uint32_t version = socinfo_get_version();
2905
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08002906 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07002907 return;
2908
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08002909 if (PLATFORM_IS_CHARM25() || machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08002910 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07002911#endif
2912}
2913
Amir Samuelov5137e392011-09-21 17:31:25 +03002914#ifdef CONFIG_ISL9519_CHARGER
2915static struct isl_platform_data isl_data __initdata = {
2916 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
2917 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
2918 .max_system_voltage = 4200,
2919 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02002920 .chgcurrent = 1900,
2921 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03002922 .input_current = 2048,
2923};
2924
2925static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
2926 {
2927 I2C_BOARD_INFO("isl9519q", 0x9),
2928 .irq = 0, /* Not required when notify-by-pmic */
2929 .platform_data = &isl_data,
2930 },
2931};
2932#endif /* CONFIG_ISL9519_CHARGER */
2933
Amir Samuelov755616d2011-12-13 16:34:46 +02002934static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
2935 {
2936 I2C_BOARD_INFO("sx1508q", 0x20),
2937 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
2938 },
2939};
2940
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002941static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03002942#ifdef CONFIG_ISL9519_CHARGER
2943 {
2944 I2C_LIQUID,
2945 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
2946 isl_charger_i2c_info,
2947 ARRAY_SIZE(isl_charger_i2c_info),
2948 },
2949#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002950 {
2951 I2C_SURF | I2C_FFA | I2C_FLUID,
2952 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
2953 cyttsp_info,
2954 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07002955 },
Mohan Pallaka50837382011-09-07 11:00:57 +05302956 {
2957 I2C_LIQUID,
2958 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
2959 mxt_device_info,
2960 ARRAY_SIZE(mxt_device_info),
2961 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05302962 {
Manoj Rao14648742012-03-30 19:42:12 -07002963 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05302964 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002965 sii_device_info,
2966 ARRAY_SIZE(sii_device_info),
2967 },
2968 {
2969 I2C_LIQUID,
2970 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05302971 msm_isa1200_board_info,
2972 ARRAY_SIZE(msm_isa1200_board_info),
2973 },
Amir Samuelov755616d2011-12-13 16:34:46 +02002974 {
2975 I2C_LIQUID,
2976 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
2977 liquid_io_expander_i2c_info,
2978 ARRAY_SIZE(liquid_io_expander_i2c_info),
2979 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002980};
2981#endif /* CONFIG_I2C */
2982
2983static void __init register_i2c_devices(void)
2984{
2985#ifdef CONFIG_I2C
2986 u8 mach_mask = 0;
2987 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08002988#ifdef CONFIG_MSM_CAMERA
2989 struct i2c_registry msm8960_camera_i2c_devices = {
2990 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
2991 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
2992 msm8960_camera_board_info.board_info,
2993 msm8960_camera_board_info.num_i2c_board_info,
2994 };
2995#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002996
2997 /* Build the matching 'supported_machs' bitmask */
2998 if (machine_is_msm8960_cdp())
2999 mach_mask = I2C_SURF;
3000 else if (machine_is_msm8960_rumi3())
3001 mach_mask = I2C_RUMI;
3002 else if (machine_is_msm8960_sim())
3003 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07003004 else if (machine_is_msm8960_fluid())
3005 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003006 else if (machine_is_msm8960_liquid())
3007 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003008 else if (machine_is_msm8960_mtp())
3009 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003010 else
3011 pr_err("unmatched machine ID in register_i2c_devices\n");
3012
Jing Lineec88ca2012-02-08 11:18:30 -08003013 if (machine_is_msm8960_liquid()) {
3014 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3015 mxt_device_info[0].platform_data =
3016 &mxt_platform_data_3d;
3017 else
3018 mxt_device_info[0].platform_data =
3019 &mxt_platform_data_2d;
3020 }
3021
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003022 /* Run the array and install devices as appropriate */
3023 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3024 if (msm8960_i2c_devices[i].machs & mach_mask)
3025 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3026 msm8960_i2c_devices[i].info,
3027 msm8960_i2c_devices[i].len);
3028 }
Kevin Chan09f4e662011-12-16 08:17:02 -08003029#ifdef CONFIG_MSM_CAMERA
3030 if (msm8960_camera_i2c_devices.machs & mach_mask)
3031 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3032 msm8960_camera_i2c_devices.info,
3033 msm8960_camera_i2c_devices.len);
3034#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003035#endif
3036}
3037
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003038static void __init msm8960_sim_init(void)
3039{
Jeff Ohlstein7e668552011-10-06 16:17:25 -07003040 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
3041 &msm8960_device_watchdog.dev.platform_data;
3042
3043 wdog_pdata->bark_time = 15000;
Siddartha Mohanadossfad0af12012-01-20 15:08:38 -08003044 msm_tsens_early_init(&msm_tsens_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003045 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3046 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003047 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003048 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003049 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003050 msm8960_init_pmic();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003051
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003052 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003053 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003054 msm8960_i2c_init();
3055 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3056 msm_spm_l2_init(msm_spm_l2_data);
3057 msm8960_init_buses();
3058 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003059 msm8960_pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003060 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Matt Wagantallec57f062011-08-16 23:54:46 -07003061 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003062
3063 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
3067 msm8960_init_mmc();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003068 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003069 slim_register_board_info(msm_slim_devices,
3070 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003071 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06003072 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003073}
3074
3075static void __init msm8960_rumi3_init(void)
3076{
Siddartha Mohanadossfad0af12012-01-20 15:08:38 -08003077 msm_tsens_early_init(&msm_tsens_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003078 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3079 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003080 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003081 platform_device_register(&msm8960_device_rpm_regulator);
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003082 msm8960_init_gpiomux();
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003083 msm8960_init_pmic();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003084 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3085 &msm8960_qup_spi_gsbi1_pdata;
3086 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3087 msm8960_i2c_init();
3088 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3089 msm_spm_l2_init(msm_spm_l2_data);
3090 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003091 msm8960_pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003092 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003093 msm8960_init_mmc();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003094 register_i2c_devices();
Mayank Ranae009c922012-03-22 03:02:06 +05303095
Mayank Ranae009c922012-03-22 03:02:06 +05303096
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003097 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003098 slim_register_board_info(msm_slim_devices,
3099 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003100 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06003101 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102}
3103
3104static void __init msm8960_cdp_init(void)
3105{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003106 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3107 pr_err("meminfo_init() failed!\n");
3108
Siddartha Mohanadossfad0af12012-01-20 15:08:38 -08003109 msm_tsens_early_init(&msm_tsens_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003110 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3111 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003112
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003113 regulator_suppress_info_printing();
3114 if (msm_xo_init())
3115 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07003116 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003117 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303118 if (machine_is_msm8960_liquid())
3119 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003120 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303121 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3122 machine_is_msm8960_cdp()) {
3123 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
3124 } else if (machine_is_msm8960_liquid()) {
3125 msm_otg_pdata.phy_init_seq =
3126 liquid_v1_phy_init_seq;
3127 }
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303128 msm_otg_pdata.swfi_latency =
3129 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303130 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303131 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3132 machine_is_msm8960_liquid())
3133 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003134 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003135 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3136 &msm8960_qup_spi_gsbi1_pdata;
3137 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003138
3139 msm8960_init_pmic();
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303140 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3141 (machine_is_msm8960_mtp())) || machine_is_msm8960_liquid())
3142 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003143 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003144 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003145 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3146 msm_spm_l2_init(msm_spm_l2_data);
3147 msm8960_init_buses();
3148 platform_add_devices(msm_footswitch_devices,
3149 msm_num_footswitch_devices);
David Collinsb10be1d2011-09-02 10:29:31 -07003150 if (machine_is_msm8960_liquid())
3151 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003152 if (machine_is_msm8960_cdp())
3153 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003154
3155 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3156 platform_device_register(&msm8960_device_uart_gsbi8);
3157 else
3158 platform_device_register(&msm8960_device_uart_gsbi5);
3159
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003160 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003161 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3162 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003163 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Ranad85a5082012-04-29 17:24:13 -07003164 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003165
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003166 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003167 msm8960_pm8921_gpio_mpp_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003168 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303169 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003170 msm8960_init_hsic();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003171 msm8960_init_cam();
3172 msm8960_init_mmc();
Matt Wagantallec57f062011-08-16 23:54:46 -07003173 acpuclk_init(&acpuclk_8960_soc_data);
Mohan Pallaka50837382011-09-07 11:00:57 +05303174 if (machine_is_msm8960_liquid())
3175 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003176 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003177 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003178 slim_register_board_info(msm_slim_devices,
3179 ARRAY_SIZE(msm_slim_devices));
3180 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003181 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003182 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Maheshkumar Sivasubramanian6866b1c2011-06-07 14:20:33 -06003183 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Joel Kingb8352a12011-11-15 18:46:24 -08003184 if (PLATFORM_IS_CHARM25())
3185 platform_add_devices(mdm_devices, ARRAY_SIZE(mdm_devices));
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003186}
3187
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003188MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
3189 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003190 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003191 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303192 .handle_irq = gic_handle_irq,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003193 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003194 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003195 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003196 .init_very_early = msm8960_early_memory,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003197MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003198
3199MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
3200 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003201 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003202 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303203 .handle_irq = gic_handle_irq,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003204 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003205 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003206 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003207 .init_very_early = msm8960_early_memory,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003208MACHINE_END
3209
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003210MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3211 .map_io = msm8960_map_io,
3212 .reserve = msm8960_reserve,
3213 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303214 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003215 .timer = &msm_timer,
3216 .init_machine = msm8960_cdp_init,
3217 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003218 .init_very_early = msm8960_early_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003219MACHINE_END
3220
3221MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3222 .map_io = msm8960_map_io,
3223 .reserve = msm8960_reserve,
3224 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303225 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003226 .timer = &msm_timer,
3227 .init_machine = msm8960_cdp_init,
3228 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003229 .init_very_early = msm8960_early_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003230MACHINE_END
3231
3232MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3233 .map_io = msm8960_map_io,
3234 .reserve = msm8960_reserve,
3235 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303236 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003237 .timer = &msm_timer,
3238 .init_machine = msm8960_cdp_init,
3239 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003240 .init_very_early = msm8960_early_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003241MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003242
3243MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3244 .map_io = msm8960_map_io,
3245 .reserve = msm8960_reserve,
3246 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303247 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003248 .timer = &msm_timer,
3249 .init_machine = msm8960_cdp_init,
3250 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003251 .init_very_early = msm8960_early_memory,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003252MACHINE_END