blob: a482c9a9c14a40a6ca6e0b7871bb2c52a184bbcb [file] [log] [blame]
Abhijeet Dharmapurikar7e37e6e2012-08-23 18:58:44 -07001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080012 */
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/i2c.h>
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -070018#include <linux/i2c/sx150x.h>
Amir Samuelov5137e392011-09-21 17:31:25 +030019#include <linux/i2c/isl9519.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/gpio.h>
21#include <linux/msm_ssbi.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070022#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <linux/mfd/pm8xxx/pm8921.h>
Siddartha Mohanadossaf91d902011-10-20 10:23:34 -070024#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025#include <linux/regulator/consumer.h>
26#include <linux/spi/spi.h>
27#include <linux/slimbus/slimbus.h>
28#include <linux/bootmem.h>
29#ifdef CONFIG_ANDROID_PMEM
30#include <linux/android_pmem.h>
31#endif
Steve Mucklef132c6c2012-06-06 18:30:57 -070032#include <linux/cyttsp-qc.h>
Laura Abbott354d40f2012-08-03 17:32:09 -070033#include <linux/dma-contiguous.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include <linux/dma-mapping.h>
35#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070036#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037#include <linux/leds.h>
38#include <linux/leds-pm8xxx.h>
Mohan Pallaka50837382011-09-07 11:00:57 +053039#include <linux/i2c/atmel_mxt_ts.h>
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -070040#include <linux/msm_tsens.h>
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -070041#include <linux/ks8851.h>
Mohan Pallaka5e490392011-09-09 15:18:41 +053042#include <linux/i2c/isa1200.h>
Jack Cheung0b1987e2011-11-18 13:36:29 -080043#include <linux/memory.h>
Larry Bassel2d8b42d2012-03-12 10:41:26 -070044#include <linux/memblock.h>
Praveen Chidambaram877d7a42012-06-05 14:33:20 -060045#include <linux/msm_thermal.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080046
47#include <asm/mach-types.h>
48#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070049#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080050#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080052
53#include <mach/board.h>
Joel Nider266a2642011-10-16 10:58:05 +020054#include <mach/msm_tspp.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080055#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <mach/msm_spi.h>
Mayank Ranae009c922012-03-22 03:02:06 +053057#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#ifdef CONFIG_USB_MSM_OTG_72K
59#include <mach/msm_hsusb.h>
60#else
61#include <linux/usb/msm_hsusb.h>
62#endif
63#include <linux/usb/android.h>
64#include <mach/usbdiag.h>
65#include <mach/socinfo.h>
66#include <mach/rpm.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070067#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068#include <mach/msm_bus_board.h>
69#include <mach/msm_memtypes.h>
70#include <mach/dma.h>
71#include <mach/msm_dsps.h>
72#include <mach/msm_xo.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070073#include <mach/restart.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080074
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075#ifdef CONFIG_WCD9310_CODEC
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053076#include <linux/mfd/wcd9xxx/core.h>
77#include <linux/mfd/wcd9xxx/pdata.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078#endif
79
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +053080#include <linux/smsc3503.h>
Mitchel Humpherys9dc32cf2012-09-06 11:34:03 -070081#include <linux/msm_ion.h>
Laura Abbottd6183792011-08-19 13:42:24 -070082#include <mach/ion.h>
Joel Kingb8352a12011-11-15 18:46:24 -080083#include <mach/mdm2.h>
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -080084#include <mach/mdm-peripheral.h>
Laura Abbottf8c03b92012-02-16 14:57:58 -080085#include <mach/msm_rtb.h>
Laura Abbott306bcc22012-03-08 11:24:53 -080086#include <mach/msm_cache_dump.h>
87#include <mach/scm.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070088#include <mach/iommu_domains.h>
Laura Abbottd6183792011-08-19 13:42:24 -070089
Jordan Crouse914de9b2012-07-09 13:49:46 -060090#include <mach/kgsl.h>
Larry Bassel41a055b2011-12-06 16:15:14 -080091#include <linux/fmem.h>
92
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080094#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#include "spm.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080097#include "board-8960.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080098#include "pm.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080099#include <mach/cpuidle.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100#include "rpm_resources.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +0530101#include <mach/mpm.h>
Matt Wagantalld55b90f2012-02-23 23:27:44 -0800102#include "clock.h"
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700103#include "smd_private.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600104#include "pm-boot.h"
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700105#include "msm_watchdog.h"
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800106
Ming-yi Lin2d43cd52012-10-17 11:50:15 +0800107#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
108#include <linux/wlan_plat.h>
109#include <linux/mutex.h>
110#endif
111
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112static struct platform_device msm_fm_platform_init = {
113 .name = "iris_fm",
114 .id = -1,
115};
116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117#define KS8851_RST_GPIO 89
118#define KS8851_IRQ_GPIO 90
Mohan Pallaka5e490392011-09-09 15:18:41 +0530119
Manoj Rao14648742012-03-30 19:42:12 -0700120#define MHL_GPIO_INT 4
121#define MHL_GPIO_RESET 15
122
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700123#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700124
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800125struct sx150x_platform_data msm8960_sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700126 [SX150X_CAM] = {
127 .gpio_base = GPIO_CAM_EXPANDER_BASE,
128 .oscio_is_gpo = false,
129 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530130 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700131 .io_open_drain_ena = 0x0,
132 .irq_summary = -1,
133 },
Amir Samuelov755616d2011-12-13 16:34:46 +0200134 [SX150X_LIQUID] = {
135 .gpio_base = GPIO_LIQUID_EXPANDER_BASE,
136 .oscio_is_gpo = false,
137 .io_pullup_ena = 0x0c08,
138 .io_pulldn_ena = 0x4060,
139 .io_open_drain_ena = 0x000c,
140 .io_polarity = 0,
141 .irq_summary = -1,
142 },
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700143};
Nishant Pandit474f2252011-07-23 23:17:56 +0530144
145#endif
146
Olav Haugana21169d2012-01-04 09:17:06 -0800147#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -0700148#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Mathew Karimpanal15fa5c42011-12-14 21:28:10 -0800149#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800150#define MSM_LIQUID_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800151#define MSM_HDMI_PRIM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Laura Abbott2d1760b2011-09-29 21:31:24 -0700152
153#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Deepak Kotur35825522012-06-06 15:49:14 -0700154#define HOLE_SIZE 0x20000
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700155#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan32594552012-03-13 11:40:05 -0700156#ifdef CONFIG_MSM_IOMMU
Olav Haugan8726caf2012-05-10 15:11:35 -0700157#define MSM_ION_MM_SIZE 0x3800000 /* Need to be multiple of 64K */
Olav Haugan32594552012-03-13 11:40:05 -0700158#define MSM_ION_SF_SIZE 0x0
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700159#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700160#define MSM_ION_HEAP_NUM 7
161#else
162#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
163#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700164#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700165#define MSM_ION_HEAP_NUM 8
166#endif
Deepak Kotur35825522012-06-06 15:49:14 -0700167#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 128kb */
Olav Hauganb5be7992011-11-18 14:29:02 -0800168#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan7355db02012-01-13 16:59:13 -0800169#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan32594552012-03-13 11:40:05 -0700170
Olav Hauganb5be7992011-11-18 14:29:02 -0800171#define MSM_LIQUID_ION_MM_SIZE (MSM_ION_MM_SIZE + 0x600000)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800172#define MSM_LIQUID_ION_SF_SIZE MSM_LIQUID_PMEM_SIZE
173#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SIZE
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700174
Deepak Kotur35825522012-06-06 15:49:14 -0700175#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 2mb -128kb*/
176#define MSM8960_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
177 HOLE_SIZE))
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700178#define MAX_FIXED_AREA_SIZE 0x10000000
Deepak Kotur35825522012-06-06 15:49:14 -0700179#define MSM8960_FW_START MSM8960_FIXED_AREA_START
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700180
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800181static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott2d1760b2011-09-29 21:31:24 -0700182#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700183#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800184#define MSM_ION_HEAP_NUM 1
Laura Abbott2d1760b2011-09-29 21:31:24 -0700185#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700186
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700187#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
188static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
189static int __init msm_contig_mem_size_setup(char *p)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700190{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700191 msm_contig_mem_size = memparse(p, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700192 return 0;
193}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700194early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700195#endif
196
197#ifdef CONFIG_ANDROID_PMEM
198static unsigned pmem_size = MSM_PMEM_SIZE;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800199static unsigned pmem_param_set;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700200static int __init pmem_size_setup(char *p)
201{
202 pmem_size = memparse(p, NULL);
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800203 pmem_param_set = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700204 return 0;
205}
206early_param("pmem_size", pmem_size_setup);
207
208static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
209
210static int __init pmem_adsp_size_setup(char *p)
211{
212 pmem_adsp_size = memparse(p, NULL);
213 return 0;
214}
215early_param("pmem_adsp_size", pmem_adsp_size_setup);
216
217static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
218
219static int __init pmem_audio_size_setup(char *p)
220{
221 pmem_audio_size = memparse(p, NULL);
222 return 0;
223}
224early_param("pmem_audio_size", pmem_audio_size_setup);
225#endif
226
227#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700228#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700229static struct android_pmem_platform_data android_pmem_pdata = {
230 .name = "pmem",
231 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
232 .cached = 1,
233 .memory_type = MEMTYPE_EBI1,
234};
235
Laura Abbottb93525f2012-04-12 09:57:19 -0700236static struct platform_device msm8960_android_pmem_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237 .name = "android_pmem",
238 .id = 0,
239 .dev = {.platform_data = &android_pmem_pdata},
240};
241
242static struct android_pmem_platform_data android_pmem_adsp_pdata = {
243 .name = "pmem_adsp",
244 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
245 .cached = 0,
246 .memory_type = MEMTYPE_EBI1,
247};
Laura Abbottb93525f2012-04-12 09:57:19 -0700248static struct platform_device msm8960_android_pmem_adsp_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700249 .name = "android_pmem",
250 .id = 2,
251 .dev = { .platform_data = &android_pmem_adsp_pdata },
252};
253
254static struct android_pmem_platform_data android_pmem_audio_pdata = {
255 .name = "pmem_audio",
256 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
257 .cached = 0,
258 .memory_type = MEMTYPE_EBI1,
259};
260
Laura Abbottb93525f2012-04-12 09:57:19 -0700261static struct platform_device msm8960_android_pmem_audio_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700262 .name = "android_pmem",
263 .id = 4,
264 .dev = { .platform_data = &android_pmem_audio_pdata },
265};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700266#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
267#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700268
Laura Abbottb93525f2012-04-12 09:57:19 -0700269struct fmem_platform_data msm8960_fmem_pdata = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800270};
271
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700272#define DSP_RAM_BASE_8960 0x8da00000
273#define DSP_RAM_SIZE_8960 0x1800000
274static int dspcrashd_pdata_8960 = 0xDEADDEAD;
275
276static struct resource resources_dspcrashd_8960[] = {
277 {
278 .name = "msm_dspcrashd",
279 .start = DSP_RAM_BASE_8960,
280 .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
281 .flags = IORESOURCE_DMA,
282 },
283};
284
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800285static struct platform_device msm_device_dspcrashd_8960 = {
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700286 .name = "msm_dspcrashd",
287 .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
288 .resource = resources_dspcrashd_8960,
289 .dev = { .platform_data = &dspcrashd_pdata_8960 },
290};
291
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700292static struct memtype_reserve msm8960_reserve_table[] __initdata = {
293 [MEMTYPE_SMI] = {
294 },
295 [MEMTYPE_EBI0] = {
296 .flags = MEMTYPE_FLAGS_1M_ALIGN,
297 },
298 [MEMTYPE_EBI1] = {
299 .flags = MEMTYPE_FLAGS_1M_ALIGN,
300 },
301};
302
Laura Abbottf8c03b92012-02-16 14:57:58 -0800303static void __init reserve_rtb_memory(void)
304{
305#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700306 msm8960_reserve_table[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
Laura Abbottf8c03b92012-02-16 14:57:58 -0800307#endif
308}
309
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310static void __init size_pmem_devices(void)
311{
312#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700313#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700314 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800315
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800316 if (!pmem_param_set) {
317 if (machine_is_msm8960_liquid())
318 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700319 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800320 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
321 }
322
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700323 android_pmem_pdata.size = pmem_size;
324 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700325#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
326#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700327}
328
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700329#ifdef CONFIG_ANDROID_PMEM
330#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700331static void __init reserve_memory_for(struct android_pmem_platform_data *p)
332{
333 msm8960_reserve_table[p->memory_type].size += p->size;
334}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700335#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
336#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700337
338static void __init reserve_pmem_memory(void)
339{
340#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700341#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700342 reserve_memory_for(&android_pmem_adsp_pdata);
343 reserve_memory_for(&android_pmem_pdata);
344 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700345#endif
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700346 msm8960_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700347#endif
348}
349
Larry Basselb4126da2011-07-18 14:31:33 -0700350static int msm8960_paddr_to_memtype(unsigned int paddr)
351{
352 return MEMTYPE_EBI1;
353}
354
Steve Mucklef132c6c2012-06-06 18:30:57 -0700355#define FMEM_ENABLED 0
Olav Hauganf6dc7742012-02-15 09:11:55 -0800356
Laura Abbottd6183792011-08-19 13:42:24 -0700357#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800358#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700359static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800360 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -0700361 .align = SZ_64K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800362 .reusable = FMEM_ENABLED,
363 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700364 .fixed_position = FIXED_MIDDLE,
Olav Haugan8726caf2012-05-10 15:11:35 -0700365 .iommu_map_all = 1,
366 .iommu_2x_map_domain = VIDEO_DOMAIN,
Laura Abbottadec9c72012-12-05 11:49:59 -0800367 .is_cma = 1,
Laura Abbott5249a052012-12-11 15:09:03 -0800368 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800369};
370
Laura Abbottb93525f2012-04-12 09:57:19 -0700371static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800372 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800373 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800374 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800375 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700376 .fixed_position = FIXED_HIGH,
Laura Abbott5249a052012-12-11 15:09:03 -0800377 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800378};
379
Laura Abbottb93525f2012-04-12 09:57:19 -0700380static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800381 .adjacent_mem_id = INVALID_HEAP_ID,
382 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800383 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800384};
385
Laura Abbottb93525f2012-04-12 09:57:19 -0700386static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800387 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
388 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800389 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700390 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800391};
392#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800393
Laura Abbott354d40f2012-08-03 17:32:09 -0700394static u64 msm_dmamask = DMA_BIT_MASK(32);
395
396static struct platform_device ion_mm_heap_device = {
397 .name = "ion-mm-heap-device",
398 .id = -1,
399 .dev = {
400 .dma_mask = &msm_dmamask,
401 .coherent_dma_mask = DMA_BIT_MASK(32),
402 }
403};
404
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800405/**
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 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700416struct ion_platform_heap msm8960_heaps[] = {
Laura Abbottd6183792011-08-19 13:42:24 -0700417 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800418 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700419 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700420 .name = ION_VMALLOC_HEAP_NAME,
421 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700422#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700423 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800424 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800425 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800426 .name = ION_MM_HEAP_NAME,
427 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700428 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700429 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbott354d40f2012-08-03 17:32:09 -0700430 .priv = &ion_mm_heap_device.dev,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700431 },
Laura Abbott8c017362011-09-22 20:59:12 -0700432 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800433 .id = ION_MM_FIRMWARE_HEAP_ID,
434 .type = ION_HEAP_TYPE_CARVEOUT,
435 .name = ION_MM_FIRMWARE_HEAP_NAME,
436 .size = MSM_ION_MM_FW_SIZE,
437 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700438 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800439 },
440 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800441 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800442 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800443 .name = ION_MFC_HEAP_NAME,
444 .size = MSM_ION_MFC_SIZE,
445 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700446 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800447 },
Olav Haugan32594552012-03-13 11:40:05 -0700448#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800449 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800450 .id = ION_SF_HEAP_ID,
451 .type = ION_HEAP_TYPE_CARVEOUT,
452 .name = ION_SF_HEAP_NAME,
453 .size = MSM_ION_SF_SIZE,
454 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700455 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800456 },
Olav Haugan32594552012-03-13 11:40:05 -0700457#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800458 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800459 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700460 .type = ION_HEAP_TYPE_IOMMU,
461 .name = ION_IOMMU_HEAP_NAME,
462 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800463 {
464 .id = ION_QSECOM_HEAP_ID,
465 .type = ION_HEAP_TYPE_CARVEOUT,
466 .name = ION_QSECOM_HEAP_NAME,
467 .size = MSM_ION_QSECOM_SIZE,
468 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700469 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800470 },
Olav Haugan7355db02012-01-13 16:59:13 -0800471 {
472 .id = ION_AUDIO_HEAP_ID,
473 .type = ION_HEAP_TYPE_CARVEOUT,
474 .name = ION_AUDIO_HEAP_NAME,
475 .size = MSM_ION_AUDIO_SIZE,
476 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700477 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800478 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700479#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700480};
481
482static struct ion_platform_data msm8960_ion_pdata = {
483 .nr = MSM_ION_HEAP_NUM,
484 .heaps = msm8960_heaps,
Laura Abbottd6183792011-08-19 13:42:24 -0700485};
486
Laura Abbottb93525f2012-04-12 09:57:19 -0700487static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700488 .name = "ion-msm",
489 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700490 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700491};
492#endif
493
Laura Abbottb93525f2012-04-12 09:57:19 -0700494struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800495 .name = "fmem",
496 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700497 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800498};
499
Olav Haugan65f4bd82011-12-13 11:50:08 -0800500static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700501{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800502 unsigned int i;
503
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800504 if (!pmem_param_set) {
505 if (machine_is_msm8960_liquid())
506 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
507
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700508 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800509 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
510
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700511 if (machine_is_msm8960_liquid() ||
512 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700513 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
514 if (msm8960_ion_pdata.heaps[i].id ==
515 ION_SF_HEAP_ID) {
516 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800517 msm_ion_sf_size;
518 pr_debug("msm_ion_sf_size 0x%x\n",
519 msm_ion_sf_size);
520 break;
521 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800522 }
523 }
524 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800525}
526
527static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
528 unsigned long size)
529{
530 msm8960_reserve_table[mem_type].size += size;
531}
532
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700533static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
534{
535#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
536 int ret;
537
538 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
539 panic("fixed area size is larger than %dM\n",
540 MAX_FIXED_AREA_SIZE >> 20);
541
542 reserve_info->fixed_area_size = fixed_area_size;
543 reserve_info->fixed_area_start = MSM8960_FW_START;
544
545 ret = memblock_remove(reserve_info->fixed_area_start,
546 reserve_info->fixed_area_size);
547 BUG_ON(ret);
548#endif
549}
550
Olav Haugan65f4bd82011-12-13 11:50:08 -0800551/**
552 * Reserve memory for ION and calculate amount of reusable memory for fmem.
553 * We only reserve memory for heaps that are not reusable. However, we only
554 * support one reusable heap at the moment so we ignore the reusable flag for
555 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800556 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
557 * at a higher address than FW in addition to not more than 256MB away from the
558 * base address of the firmware. This means that if MM is reusable the other
559 * two heaps must be allocated in the same region as FW. This is handled by the
560 * mem_is_fmem flag in the platform data. In addition the MM heap must be
561 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800562 */
563static void __init reserve_ion_memory(void)
564{
565#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
566 unsigned int i;
Laura Abbott354d40f2012-08-03 17:32:09 -0700567 int ret;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700568 unsigned int fixed_size = 0;
569 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
570 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbott354d40f2012-08-03 17:32:09 -0700571 unsigned long cma_alignment;
572 unsigned int low_use_cma = 0;
573 unsigned int middle_use_cma = 0;
574 unsigned int high_use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800575
576 adjust_mem_for_liquid();
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700577 fixed_low_size = 0;
578 fixed_middle_size = 0;
579 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800580
Laura Abbott354d40f2012-08-03 17:32:09 -0700581 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
582
Laura Abbottb93525f2012-04-12 09:57:19 -0700583 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
Olav Haugan8726caf2012-05-10 15:11:35 -0700584 struct ion_platform_heap *heap =
Laura Abbottb93525f2012-04-12 09:57:19 -0700585 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan8726caf2012-05-10 15:11:35 -0700586 int align = SZ_4K;
587 int iommu_map_all = 0;
588 int adjacent_mem_id = INVALID_HEAP_ID;
Laura Abbott354d40f2012-08-03 17:32:09 -0700589 int use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800590
591 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700592 int fixed_position = NOT_FIXED;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700593
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700594 switch ((int) heap->type) {
Olav Haugan65f4bd82011-12-13 11:50:08 -0800595 case ION_HEAP_TYPE_CP:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700596 fixed_position = ((struct ion_cp_heap_pdata *)
597 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700598 align = ((struct ion_cp_heap_pdata *)
599 heap->extra_data)->align;
600 iommu_map_all =
601 ((struct ion_cp_heap_pdata *)
602 heap->extra_data)->iommu_map_all;
Laura Abbott354d40f2012-08-03 17:32:09 -0700603 if (((struct ion_cp_heap_pdata *)
604 heap->extra_data)->is_cma) {
605 heap->size = ALIGN(heap->size,
606 cma_alignment);
607 use_cma = 1;
608 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800609 break;
Laura Abbott354d40f2012-08-03 17:32:09 -0700610 case ION_HEAP_TYPE_DMA:
611 use_cma = 1;
612 /* Purposely fall through here */
Olav Haugan65f4bd82011-12-13 11:50:08 -0800613 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700614 fixed_position = ((struct ion_co_heap_pdata *)
615 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700616 adjacent_mem_id = ((struct ion_co_heap_pdata *)
617 heap->extra_data)->adjacent_mem_id;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700618 break;
619 default:
620 break;
621 }
622
Olav Haugan8726caf2012-05-10 15:11:35 -0700623 if (iommu_map_all) {
624 if (heap->size & (SZ_64K-1)) {
625 heap->size = ALIGN(heap->size, SZ_64K);
626 pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
627 heap->name, heap->size);
628 }
629 }
630
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700631 if (fixed_position != NOT_FIXED)
632 fixed_size += heap->size;
633 else
634 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
635
Laura Abbott354d40f2012-08-03 17:32:09 -0700636 if (fixed_position == FIXED_LOW) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700637 fixed_low_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700638 low_use_cma = use_cma;
639 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700640 fixed_middle_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700641 middle_use_cma = use_cma;
642 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700643 fixed_high_size += heap->size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700644 high_use_cma = use_cma;
645 } else if (use_cma) {
646 /*
647 * Heaps that use CMA but are not part of the
648 * fixed set. Create wherever.
649 */
650 dma_declare_contiguous(
651 heap->priv,
652 heap->size,
653 0,
654 0xb0000000);
655 }
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700656 }
657 }
658
659 if (!fixed_size)
660 return;
661
Laura Abbott354d40f2012-08-03 17:32:09 -0700662 /*
663 * Given the setup for the fixed area, we can't round up all sizes.
664 * Some sizes must be set up exactly and aligned correctly. Incorrect
665 * alignments are considered a configuration issue
Larry Bassel4d4f4482012-04-04 11:26:09 -0700666 */
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700667
668 fixed_low_start = MSM8960_FIXED_AREA_START;
Laura Abbott354d40f2012-08-03 17:32:09 -0700669 if (low_use_cma) {
670 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
671 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
672 } else {
673 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
674 ret = memblock_remove(fixed_low_start,
675 fixed_low_size + HOLE_SIZE);
676 BUG_ON(ret);
677 }
678
Deepak Kotur35825522012-06-06 15:49:14 -0700679 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbott354d40f2012-08-03 17:32:09 -0700680 if (middle_use_cma) {
681 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
682 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
683 } else {
684 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
685 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
686 BUG_ON(ret);
687 }
688
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700689 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbott354d40f2012-08-03 17:32:09 -0700690 if (high_use_cma) {
691 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
692 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
693 } else {
694 /* This is the end of the fixed area so it's okay to round up */
695 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
696 ret = memblock_remove(fixed_high_start, fixed_high_size);
697 BUG_ON(ret);
698 }
699
700
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700701
Laura Abbottb93525f2012-04-12 09:57:19 -0700702 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
703 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700704
705 if (heap->extra_data) {
706 int fixed_position = NOT_FIXED;
Steve Muckle75c34ca2012-06-12 14:27:40 -0700707 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700708
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700709 switch ((int) heap->type) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700710 case ION_HEAP_TYPE_CP:
Deepak Kotur35825522012-06-06 15:49:14 -0700711 pdata =
712 (struct ion_cp_heap_pdata *)heap->extra_data;
713 fixed_position = pdata->fixed_position;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700714 break;
715 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbott354d40f2012-08-03 17:32:09 -0700716 case ION_HEAP_TYPE_DMA:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700717 fixed_position = ((struct ion_co_heap_pdata *)
718 heap->extra_data)->fixed_position;
719 break;
720 default:
721 break;
722 }
723
724 switch (fixed_position) {
725 case FIXED_LOW:
726 heap->base = fixed_low_start;
727 break;
728 case FIXED_MIDDLE:
729 heap->base = fixed_middle_start;
Laura Abbott354d40f2012-08-03 17:32:09 -0700730 if (middle_use_cma) {
731 ret = dma_declare_contiguous(
732 &ion_mm_heap_device.dev,
733 heap->size,
734 fixed_middle_start,
735 0xa0000000);
736 WARN_ON(ret);
737 }
Deepak Kotur35825522012-06-06 15:49:14 -0700738 pdata->secure_base = fixed_middle_start
739 - HOLE_SIZE;
740 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700741 break;
742 case FIXED_HIGH:
743 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800744 break;
745 default:
746 break;
747 }
748 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800749 }
Laura Abbottd6183792011-08-19 13:42:24 -0700750#endif
751}
Huaibin Yanga5419422011-12-08 23:52:10 -0800752
Laura Abbott5249a052012-12-11 15:09:03 -0800753static void ion_adjust_secure_allocation(void)
754{
755 int i;
756
757 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
758 struct ion_platform_heap *heap =
759 &(msm8960_ion_pdata.heaps[i]);
760
761
762 if (heap->extra_data) {
763 switch ((int) heap->type) {
764 case ION_HEAP_TYPE_CP:
765 if (cpu_is_msm8960()) {
766 ((struct ion_cp_heap_pdata *)
767 heap->extra_data)->no_nonsecure_alloc =
768 0;
769 }
770
771 }
772 }
773 }
774}
775
Huaibin Yanga5419422011-12-08 23:52:10 -0800776static void __init reserve_mdp_memory(void)
777{
778 msm8960_mdp_writeback(msm8960_reserve_table);
779}
780
Stephen Boyd668d7652012-04-25 11:31:01 -0700781static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800782{
783#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbott306bcc22012-03-08 11:24:53 -0800784 unsigned int total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800785
Laura Abbott155ab6f2012-05-25 08:52:18 -0700786 total = msm8960_cache_dump_pdata.l1_size +
787 msm8960_cache_dump_pdata.l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800788 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800789#endif
790}
791
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700792static void __init msm8960_calculate_reserve_sizes(void)
793{
794 size_pmem_devices();
795 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700796 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800797 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800798 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800799 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800}
801
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802static struct reserve_info msm8960_reserve_info __initdata = {
803 .memtype_reserve_table = msm8960_reserve_table,
804 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700805 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700806 .paddr_to_memtype = msm8960_paddr_to_memtype,
807};
808
Larry Basselb4126da2011-07-18 14:31:33 -0700809static int msm8960_memory_bank_size(void)
810{
811 return 1<<29;
812}
813
814static void __init locate_unstable_memory(void)
815{
816 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
817 unsigned long bank_size;
818 unsigned long low, high;
819
820 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700821 msm8960_reserve_info.bank_size = bank_size;
822
Larry Basselb4126da2011-07-18 14:31:33 -0700823 low = meminfo.bank[0].start;
824 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700825
826 /* Check if 32 bit overflow occured */
827 if (high < mb->start)
828 high = ~0UL;
829
Larry Bassel4d4f4482012-04-04 11:26:09 -0700830 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
831 panic("fixed area extends beyond end of memory\n");
832
Larry Basselb4126da2011-07-18 14:31:33 -0700833 low &= ~(bank_size - 1);
834
835 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700836 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800837
Larry Basselb8d61022012-02-24 10:49:45 -0800838#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800839 msm8960_reserve_info.low_unstable_address = mb->start -
840 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800841 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700842 pr_info("low unstable address %lx max size %lx bank size %lx\n",
843 msm8960_reserve_info.low_unstable_address,
844 msm8960_reserve_info.max_unstable_size,
845 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700846 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800847#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700848no_dmm:
849 msm8960_reserve_info.low_unstable_address = high;
850 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700851}
852
Larry Basselb830e182011-10-14 10:46:55 -0700853static void __init place_movable_zone(void)
854{
Larry Basselb8d61022012-02-24 10:49:45 -0800855#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700856 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
857 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
858 pr_info("movable zone start %lx size %lx\n",
859 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800860#endif
Larry Basselb830e182011-10-14 10:46:55 -0700861}
862
863static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700864{
865 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700866 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700867 place_movable_zone();
868}
869
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800870static char prim_panel_name[PANEL_NAME_MAX_LEN];
871static char ext_panel_name[PANEL_NAME_MAX_LEN];
872static int __init prim_display_setup(char *param)
873{
874 if (strnlen(param, PANEL_NAME_MAX_LEN))
875 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
876 return 0;
877}
878early_param("prim_display", prim_display_setup);
879
880static int __init ext_display_setup(char *param)
881{
882 if (strnlen(param, PANEL_NAME_MAX_LEN))
883 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
884 return 0;
885}
886early_param("ext_display", ext_display_setup);
887
Larry Basselb830e182011-10-14 10:46:55 -0700888static void __init msm8960_reserve(void)
889{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800890 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700891 msm_reserve();
892}
893
Larry Bassela4414b12011-08-04 11:11:02 -0700894static int msm8960_change_memory_power(u64 start, u64 size,
895 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700896{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700897 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700898}
899
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700900static void __init msm8960_allocate_memory_regions(void)
901{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800902 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700903}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800904
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700905#ifdef CONFIG_WCD9310_CODEC
906
907#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
908
Patrick Lai3043fba2011-08-01 14:15:57 -0700909/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
910 * 4 micbiases are used to power various analog and digital
911 * microphones operating at 1800 mV. Technically, all micbiases
912 * can source from single cfilter since all microphones operate
913 * at the same voltage level. The arrangement below is to make
914 * sure all cfilters are exercised. LDO_H regulator ouput level
915 * does not need to be as high as 2.85V. It is choosen for
916 * microphone sensitivity purpose.
917 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530918static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700919 .slimbus_slave_device = {
920 .name = "tabla-slave",
921 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
922 },
923 .irq = MSM_GPIO_TO_INT(62),
924 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530925 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700926 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700927 .micbias = {
928 .ldoh_v = TABLA_LDOH_2P85_V,
929 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700930 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700931 .cfilt3_mv = 1800,
932 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
933 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
934 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
935 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530936 },
937 .regulator = {
938 {
939 .name = "CDC_VDD_CP",
940 .min_uV = 1800000,
941 .max_uV = 1800000,
942 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
943 },
944 {
945 .name = "CDC_VDDA_RX",
946 .min_uV = 1800000,
947 .max_uV = 1800000,
948 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
949 },
950 {
951 .name = "CDC_VDDA_TX",
952 .min_uV = 1800000,
953 .max_uV = 1800000,
954 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
955 },
956 {
957 .name = "VDDIO_CDC",
958 .min_uV = 1800000,
959 .max_uV = 1800000,
960 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
961 },
962 {
963 .name = "VDDD_CDC_D",
964 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700965 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530966 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
967 },
968 {
969 .name = "CDC_VDDA_A_1P2V",
970 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700971 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530972 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
973 },
974 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700975};
976
977static struct slim_device msm_slim_tabla = {
978 .name = "tabla-slim",
979 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
980 .dev = {
981 .platform_data = &tabla_platform_data,
982 },
983};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530984
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530985static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530986 .slimbus_slave_device = {
987 .name = "tabla-slave",
988 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
989 },
990 .irq = MSM_GPIO_TO_INT(62),
991 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530992 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530993 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
994 .micbias = {
995 .ldoh_v = TABLA_LDOH_2P85_V,
996 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700997 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530998 .cfilt3_mv = 1800,
999 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1000 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1001 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1002 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301003 },
1004 .regulator = {
1005 {
1006 .name = "CDC_VDD_CP",
1007 .min_uV = 1800000,
1008 .max_uV = 1800000,
1009 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1010 },
1011 {
1012 .name = "CDC_VDDA_RX",
1013 .min_uV = 1800000,
1014 .max_uV = 1800000,
1015 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1016 },
1017 {
1018 .name = "CDC_VDDA_TX",
1019 .min_uV = 1800000,
1020 .max_uV = 1800000,
1021 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1022 },
1023 {
1024 .name = "VDDIO_CDC",
1025 .min_uV = 1800000,
1026 .max_uV = 1800000,
1027 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1028 },
1029 {
1030 .name = "VDDD_CDC_D",
1031 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001032 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301033 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1034 },
1035 {
1036 .name = "CDC_VDDA_A_1P2V",
1037 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001038 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301039 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1040 },
1041 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301042};
1043
1044static struct slim_device msm_slim_tabla20 = {
1045 .name = "tabla2x-slim",
1046 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1047 .dev = {
1048 .platform_data = &tabla20_platform_data,
1049 },
1050};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001051#endif
1052
1053static struct slim_boardinfo msm_slim_devices[] = {
1054#ifdef CONFIG_WCD9310_CODEC
1055 {
1056 .bus_num = 1,
1057 .slim_slave = &msm_slim_tabla,
1058 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301059 {
1060 .bus_num = 1,
1061 .slim_slave = &msm_slim_tabla20,
1062 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001063#endif
1064 /* add more slimbus slaves as needed */
1065};
1066
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001067#define MSM_WCNSS_PHYS 0x03000000
1068#define MSM_WCNSS_SIZE 0x280000
1069
1070static struct resource resources_wcnss_wlan[] = {
1071 {
1072 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1073 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1074 .name = "wcnss_wlanrx_irq",
1075 .flags = IORESOURCE_IRQ,
1076 },
1077 {
1078 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1079 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1080 .name = "wcnss_wlantx_irq",
1081 .flags = IORESOURCE_IRQ,
1082 },
1083 {
1084 .start = MSM_WCNSS_PHYS,
1085 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1086 .name = "wcnss_mmio",
1087 .flags = IORESOURCE_MEM,
1088 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001089 {
1090 .start = 84,
1091 .end = 88,
1092 .name = "wcnss_gpios_5wire",
1093 .flags = IORESOURCE_IO,
1094 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001095};
1096
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001097static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1098 .has_48mhz_xo = 1,
1099};
1100
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001101static struct platform_device msm_device_wcnss_wlan = {
1102 .name = "wcnss_wlan",
1103 .id = 0,
1104 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1105 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001106 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001107};
1108
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001109#ifdef CONFIG_QSEECOM
1110/* qseecom bus scaling */
1111static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1112 {
1113 .src = MSM_BUS_MASTER_SPS,
1114 .dst = MSM_BUS_SLAVE_EBI_CH0,
1115 .ib = 0,
1116 .ab = 0,
1117 },
1118 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001119 .src = MSM_BUS_MASTER_SPS,
1120 .dst = MSM_BUS_SLAVE_SPS,
1121 .ib = 0,
1122 .ab = 0,
1123 },
1124 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001125 .src = MSM_BUS_MASTER_SPDM,
1126 .dst = MSM_BUS_SLAVE_SPDM,
1127 .ib = 0,
1128 .ab = 0,
1129 },
1130};
1131
1132static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1133 {
1134 .src = MSM_BUS_MASTER_SPS,
1135 .dst = MSM_BUS_SLAVE_EBI_CH0,
1136 .ib = (492 * 8) * 1000000UL,
1137 .ab = (492 * 8) * 100000UL,
1138 },
1139 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001140 .src = MSM_BUS_MASTER_SPS,
1141 .dst = MSM_BUS_SLAVE_SPS,
1142 .ib = (492 * 8) * 1000000UL,
1143 .ab = (492 * 8) * 100000UL,
1144 },
1145 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001146 .src = MSM_BUS_MASTER_SPDM,
1147 .dst = MSM_BUS_SLAVE_SPDM,
1148 .ib = 0,
1149 .ab = 0,
1150 },
1151};
1152
1153static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1154 {
1155 .src = MSM_BUS_MASTER_SPS,
1156 .dst = MSM_BUS_SLAVE_EBI_CH0,
1157 .ib = 0,
1158 .ab = 0,
1159 },
1160 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001161 .src = MSM_BUS_MASTER_SPS,
1162 .dst = MSM_BUS_SLAVE_SPS,
1163 .ib = 0,
1164 .ab = 0,
1165 },
1166 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001167 .src = MSM_BUS_MASTER_SPDM,
1168 .dst = MSM_BUS_SLAVE_SPDM,
1169 .ib = (64 * 8) * 1000000UL,
1170 .ab = (64 * 8) * 100000UL,
1171 },
1172};
1173
1174static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1175 {
1176 ARRAY_SIZE(qseecom_clks_init_vectors),
1177 qseecom_clks_init_vectors,
1178 },
1179 {
1180 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001181 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001182 },
1183 {
1184 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1185 qseecom_enable_sfpb_vectors,
1186 },
1187};
1188
1189static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1190 qseecom_hw_bus_scale_usecases,
1191 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1192 .name = "qsee",
1193};
1194
1195static struct platform_device qseecom_device = {
1196 .name = "qseecom",
1197 .id = 0,
1198 .dev = {
1199 .platform_data = &qseecom_bus_pdata,
1200 },
1201};
1202#endif
1203
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1205 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1206 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1207 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1208
1209#define QCE_SIZE 0x10000
1210#define QCE_0_BASE 0x18500000
1211
1212#define QCE_HW_KEY_SUPPORT 0
1213#define QCE_SHA_HMAC_SUPPORT 1
1214#define QCE_SHARE_CE_RESOURCE 1
1215#define QCE_CE_SHARED 0
1216
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001217/* Begin Bus scaling definitions */
1218static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1219 {
1220 .src = MSM_BUS_MASTER_ADM_PORT0,
1221 .dst = MSM_BUS_SLAVE_EBI_CH0,
1222 .ab = 0,
1223 .ib = 0,
1224 },
1225 {
1226 .src = MSM_BUS_MASTER_ADM_PORT1,
1227 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1228 .ab = 0,
1229 .ib = 0,
1230 },
1231};
1232
1233static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1234 {
1235 .src = MSM_BUS_MASTER_ADM_PORT0,
1236 .dst = MSM_BUS_SLAVE_EBI_CH0,
1237 .ab = 70000000UL,
1238 .ib = 70000000UL,
1239 },
1240 {
1241 .src = MSM_BUS_MASTER_ADM_PORT1,
1242 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1243 .ab = 2480000000UL,
1244 .ib = 2480000000UL,
1245 },
1246};
1247
1248static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1249 {
1250 ARRAY_SIZE(crypto_hw_init_vectors),
1251 crypto_hw_init_vectors,
1252 },
1253 {
1254 ARRAY_SIZE(crypto_hw_active_vectors),
1255 crypto_hw_active_vectors,
1256 },
1257};
1258
1259static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1260 crypto_hw_bus_scale_usecases,
1261 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1262 .name = "cryptohw",
1263};
1264/* End Bus Scaling Definitions*/
1265
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001266static struct resource qcrypto_resources[] = {
1267 [0] = {
1268 .start = QCE_0_BASE,
1269 .end = QCE_0_BASE + QCE_SIZE - 1,
1270 .flags = IORESOURCE_MEM,
1271 },
1272 [1] = {
1273 .name = "crypto_channels",
1274 .start = DMOV_CE_IN_CHAN,
1275 .end = DMOV_CE_OUT_CHAN,
1276 .flags = IORESOURCE_DMA,
1277 },
1278 [2] = {
1279 .name = "crypto_crci_in",
1280 .start = DMOV_CE_IN_CRCI,
1281 .end = DMOV_CE_IN_CRCI,
1282 .flags = IORESOURCE_DMA,
1283 },
1284 [3] = {
1285 .name = "crypto_crci_out",
1286 .start = DMOV_CE_OUT_CRCI,
1287 .end = DMOV_CE_OUT_CRCI,
1288 .flags = IORESOURCE_DMA,
1289 },
1290};
1291
1292static struct resource qcedev_resources[] = {
1293 [0] = {
1294 .start = QCE_0_BASE,
1295 .end = QCE_0_BASE + QCE_SIZE - 1,
1296 .flags = IORESOURCE_MEM,
1297 },
1298 [1] = {
1299 .name = "crypto_channels",
1300 .start = DMOV_CE_IN_CHAN,
1301 .end = DMOV_CE_OUT_CHAN,
1302 .flags = IORESOURCE_DMA,
1303 },
1304 [2] = {
1305 .name = "crypto_crci_in",
1306 .start = DMOV_CE_IN_CRCI,
1307 .end = DMOV_CE_IN_CRCI,
1308 .flags = IORESOURCE_DMA,
1309 },
1310 [3] = {
1311 .name = "crypto_crci_out",
1312 .start = DMOV_CE_OUT_CRCI,
1313 .end = DMOV_CE_OUT_CRCI,
1314 .flags = IORESOURCE_DMA,
1315 },
1316};
1317
1318#endif
1319
1320#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1321 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1322
1323static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1324 .ce_shared = QCE_CE_SHARED,
1325 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1326 .hw_key_support = QCE_HW_KEY_SUPPORT,
1327 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001328 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001329};
1330
1331static struct platform_device qcrypto_device = {
1332 .name = "qcrypto",
1333 .id = 0,
1334 .num_resources = ARRAY_SIZE(qcrypto_resources),
1335 .resource = qcrypto_resources,
1336 .dev = {
1337 .coherent_dma_mask = DMA_BIT_MASK(32),
1338 .platform_data = &qcrypto_ce_hw_suppport,
1339 },
1340};
1341#endif
1342
1343#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1344 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1345
1346static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1347 .ce_shared = QCE_CE_SHARED,
1348 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1349 .hw_key_support = QCE_HW_KEY_SUPPORT,
1350 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001351 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001352};
1353
1354static struct platform_device qcedev_device = {
1355 .name = "qce",
1356 .id = 0,
1357 .num_resources = ARRAY_SIZE(qcedev_resources),
1358 .resource = qcedev_resources,
1359 .dev = {
1360 .coherent_dma_mask = DMA_BIT_MASK(32),
1361 .platform_data = &qcedev_ce_hw_suppport,
1362 },
1363};
1364#endif
1365
Joel King0cbf5d82012-05-24 15:21:38 -07001366static struct mdm_platform_data sglte_platform_data = {
1367 .mdm_version = "4.0",
1368 .ramdump_delay_ms = 1000,
Joel King63ce8332012-06-01 09:59:26 -07001369 .soft_reset_inverted = 1,
Joel King0cbf5d82012-05-24 15:21:38 -07001370 .peripheral_platform_device = NULL,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001371 .ramdump_timeout_ms = 600000,
Ameya Thakura98bde52012-06-28 18:55:19 -07001372 .no_powerdown_after_ramdumps = 1,
Ameya Thakur43248fd2012-07-10 18:50:52 -07001373 .image_upgrade_supported = 1,
Joel Kingb8352a12011-11-15 18:46:24 -08001374};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001375
Joel Nider266a2642011-10-16 10:58:05 +02001376#define MSM_TSIF0_PHYS (0x18200000)
1377#define MSM_TSIF1_PHYS (0x18201000)
1378#define MSM_TSIF_SIZE (0x200)
1379#define MSM_TSPP_PHYS (0x18202000)
1380#define MSM_TSPP_SIZE (0x1000)
1381#define MSM_TSPP_BAM_PHYS (0x18204000)
1382#define MSM_TSPP_BAM_SIZE (0x2000)
1383
1384#define TSIF_0_CLK GPIO_CFG(75, 1, GPIO_CFG_INPUT, \
1385 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1386#define TSIF_0_EN GPIO_CFG(76, 1, GPIO_CFG_INPUT, \
1387 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1388#define TSIF_0_DATA GPIO_CFG(77, 1, GPIO_CFG_INPUT, \
1389 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1390#define TSIF_0_SYNC GPIO_CFG(82, 1, GPIO_CFG_INPUT, \
1391 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1392#define TSIF_1_CLK GPIO_CFG(79, 1, GPIO_CFG_INPUT, \
1393 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1394#define TSIF_1_EN GPIO_CFG(80, 1, GPIO_CFG_INPUT, \
1395 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1396#define TSIF_1_DATA GPIO_CFG(81, 1, GPIO_CFG_INPUT, \
1397 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1398#define TSIF_1_SYNC GPIO_CFG(78, 1, GPIO_CFG_INPUT, \
1399 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1400
1401static const struct msm_gpio tsif_gpios[] = {
1402 { .gpio_cfg = TSIF_0_CLK, .label = "tsif0_clk", },
1403 { .gpio_cfg = TSIF_0_EN, .label = "tsif0_en", },
1404 { .gpio_cfg = TSIF_0_DATA, .label = "tsif0_data", },
1405 { .gpio_cfg = TSIF_0_SYNC, .label = "tsif0_sync", },
1406 { .gpio_cfg = TSIF_1_CLK, .label = "tsif1_clk", },
1407 { .gpio_cfg = TSIF_1_EN, .label = "tsif1_en", },
1408 { .gpio_cfg = TSIF_1_DATA, .label = "tsif1_data", },
1409 { .gpio_cfg = TSIF_1_SYNC, .label = "tsif1_sync", },
1410};
1411
1412static struct resource tspp_resources[] = {
1413 [0] = {
1414 .flags = IORESOURCE_IRQ,
1415 .start = TSIF_TSPP_IRQ,
1416 .end = TSIF1_IRQ,
1417 },
1418 [1] = {
1419 .flags = IORESOURCE_MEM,
1420 .start = MSM_TSIF0_PHYS,
1421 .end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
1422 },
1423 [2] = {
1424 .flags = IORESOURCE_MEM,
1425 .start = MSM_TSIF1_PHYS,
1426 .end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
1427 },
1428 [3] = {
1429 .flags = IORESOURCE_MEM,
1430 .start = MSM_TSPP_PHYS,
1431 .end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
1432 },
1433 [4] = {
1434 .flags = IORESOURCE_MEM,
1435 .start = MSM_TSPP_BAM_PHYS,
1436 .end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
1437 },
1438};
1439
1440static struct msm_tspp_platform_data tspp_platform_data = {
1441 .num_gpios = ARRAY_SIZE(tsif_gpios),
1442 .gpios = tsif_gpios,
1443 .tsif_pclk = "tsif_pclk",
1444 .tsif_ref_clk = "tsif_ref_clk",
1445};
1446
1447static struct platform_device msm_device_tspp = {
1448 .name = "msm_tspp",
1449 .id = 0,
1450 .num_resources = ARRAY_SIZE(tspp_resources),
1451 .resource = tspp_resources,
1452 .dev = {
1453 .platform_data = &tspp_platform_data
1454 },
1455};
1456
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001457#define MSM_SHARED_RAM_PHYS 0x80000000
1458
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001459static void __init msm8960_map_io(void)
1460{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001461 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001462 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001463
1464 if (socinfo_init() < 0)
1465 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001466}
1467
1468static void __init msm8960_init_irq(void)
1469{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001470 struct msm_mpm_device_data *data = NULL;
1471
1472#ifdef CONFIG_MSM_MPM
1473 data = &msm8960_mpm_dev_data;
1474#endif
1475
1476 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001477 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001478 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001479}
1480
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001481static void __init msm8960_init_buses(void)
1482{
1483#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001484 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001485 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1486 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
Gagan Macae154c4b2011-10-05 19:24:43 -06001487 msm_bus_apps_fabric.dev.platform_data =
1488 &msm_bus_8960_apps_fabric_pdata;
1489 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
Gagan Mac680bfc02012-07-19 19:11:00 -06001490 if (cpu_is_msm8960ab()) {
1491 msm_bus_8960_sg_mm_fabric_pdata.rpm_enabled = 1;
1492 msm_bus_mm_fabric.dev.platform_data =
1493 &msm_bus_8960_sg_mm_fabric_pdata;
1494 } else {
1495 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1496 msm_bus_mm_fabric.dev.platform_data =
1497 &msm_bus_8960_mm_fabric_pdata;
1498 }
Gagan Macae154c4b2011-10-05 19:24:43 -06001499 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1500 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001501#endif
1502}
1503
1504static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1505 .max_clock_speed = 15060000,
Kiran Gunda2b285652012-07-30 13:22:39 +05301506 .infinite_mode = 0xFFC0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001507};
1508
1509#ifdef CONFIG_USB_MSM_OTG_72K
1510static struct msm_otg_platform_data msm_otg_pdata;
1511#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301512static int wr_phy_init_seq[] = {
1513 0x44, 0x80, /* set VBUS valid threshold
1514 and disconnect valid threshold */
1515 0x38, 0x81, /* update DC voltage level */
1516 0x14, 0x82, /* set preemphasis and rise/fall time */
1517 0x13, 0x83, /* set source impedance adjusment */
1518 -1};
1519
1520static int liquid_v1_phy_init_seq[] = {
1521 0x44, 0x80,/* set VBUS valid threshold
1522 and disconnect valid threshold */
1523 0x3C, 0x81,/* update DC voltage level */
1524 0x18, 0x82,/* set preemphasis and rise/fall time */
1525 0x23, 0x83,/* set source impedance sdjusment */
1526 -1};
1527
Mayank Ranaa1f507b2012-08-14 10:57:00 +05301528static int sglte_phy_init_seq[] = {
1529 0x44, 0x80, /* set VBUS valid threshold
1530 and disconnect valid threshold */
1531 0x3A, 0x81, /* update DC voltage level */
1532 0x24, 0x82, /* set preemphasis and rise/fall time */
1533 0x13, 0x83, /* set source impedance adjusment */
1534 -1};
1535
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301536#ifdef CONFIG_MSM_BUS_SCALING
1537/* Bandwidth requests (zero) if no vote placed */
1538static struct msm_bus_vectors usb_init_vectors[] = {
1539 {
1540 .src = MSM_BUS_MASTER_SPS,
1541 .dst = MSM_BUS_SLAVE_EBI_CH0,
1542 .ab = 0,
1543 .ib = 0,
1544 },
1545};
1546
1547/* Bus bandwidth requests in Bytes/sec */
1548static struct msm_bus_vectors usb_max_vectors[] = {
1549 {
1550 .src = MSM_BUS_MASTER_SPS,
1551 .dst = MSM_BUS_SLAVE_EBI_CH0,
1552 .ab = 60000000, /* At least 480Mbps on bus. */
1553 .ib = 960000000, /* MAX bursts rate */
1554 },
1555};
1556
1557static struct msm_bus_paths usb_bus_scale_usecases[] = {
1558 {
1559 ARRAY_SIZE(usb_init_vectors),
1560 usb_init_vectors,
1561 },
1562 {
1563 ARRAY_SIZE(usb_max_vectors),
1564 usb_max_vectors,
1565 },
1566};
1567
1568static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1569 usb_bus_scale_usecases,
1570 ARRAY_SIZE(usb_bus_scale_usecases),
1571 .name = "usb",
1572};
1573#endif
1574
Jack Pham87f202f2012-08-06 00:24:22 -07001575#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
1576
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001577static struct msm_otg_platform_data msm_otg_pdata = {
1578 .mode = USB_OTG,
1579 .otg_control = OTG_PMIC_CONTROL,
1580 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001581 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301582 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301583#ifdef CONFIG_MSM_BUS_SCALING
1584 .bus_scale_table = &usb_bus_scale_pdata,
Jack Pham87f202f2012-08-06 00:24:22 -07001585 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301586#endif
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +05301587#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
1588 .mhl_dev_name = "sii8334",
1589#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001590};
1591#endif
1592
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301593#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301594#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301595static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1596 .strobe = 150,
1597 .data = 151,
1598};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301599
1600static struct smsc_hub_platform_data hsic_hub_pdata = {
1601 .hub_reset = HSIC_HUB_RESET_GPIO,
1602};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301603#else
1604static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301605static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301606#endif
1607
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301608static struct platform_device smsc_hub_device = {
1609 .name = "msm_smsc_hub",
1610 .id = -1,
1611 .dev = {
1612 .platform_data = &hsic_hub_pdata,
1613 },
1614};
1615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001616#define PID_MAGIC_ID 0x71432909
1617#define SERIAL_NUM_MAGIC_ID 0x61945374
1618#define SERIAL_NUMBER_LENGTH 127
1619#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1620
1621struct magic_num_struct {
1622 uint32_t pid;
1623 uint32_t serial_num;
1624};
1625
1626struct dload_struct {
1627 uint32_t reserved1;
1628 uint32_t reserved2;
1629 uint32_t reserved3;
1630 uint16_t reserved4;
1631 uint16_t pid;
1632 char serial_number[SERIAL_NUMBER_LENGTH];
1633 uint16_t reserved5;
1634 struct magic_num_struct magic_struct;
1635};
1636
1637static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1638{
1639 struct dload_struct __iomem *dload = 0;
1640
1641 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1642 if (!dload) {
1643 pr_err("%s: cannot remap I/O memory region: %08x\n",
1644 __func__, DLOAD_USB_BASE_ADD);
1645 return -ENXIO;
1646 }
1647
1648 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1649 __func__, dload, pid, snum);
1650 /* update pid */
1651 dload->magic_struct.pid = PID_MAGIC_ID;
1652 dload->pid = pid;
1653
1654 /* update serial number */
1655 dload->magic_struct.serial_num = 0;
1656 if (!snum) {
1657 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1658 goto out;
1659 }
1660
1661 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001662 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001663out:
1664 iounmap(dload);
1665 return 0;
1666}
1667
1668static struct android_usb_platform_data android_usb_pdata = {
1669 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1670};
1671
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001672static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001673 .name = "android_usb",
1674 .id = -1,
1675 .dev = {
1676 .platform_data = &android_usb_pdata,
1677 },
1678};
1679
1680static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1681 0x03, 0x0f,
1682};
1683
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301684static uint8_t spm_retention_cmd_sequence[] __initdata = {
1685 0x00, 0x05, 0x03, 0x0D,
1686 0x0B, 0x00, 0x0f,
1687};
1688
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001689static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1690 0x00, 0x24, 0x54, 0x10,
1691 0x09, 0x03, 0x01,
1692 0x10, 0x54, 0x30, 0x0C,
1693 0x24, 0x30, 0x0f,
1694};
1695
1696static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1697 0x00, 0x24, 0x54, 0x10,
1698 0x09, 0x07, 0x01, 0x0B,
1699 0x10, 0x54, 0x30, 0x0C,
1700 0x24, 0x30, 0x0f,
1701};
1702
Anji Jonnala0f297a92013-01-19 11:22:25 +05301703/* 8960AB has a different command to assert apc_pdn */
1704static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
1705 0x00, 0x24, 0x84, 0x10,
1706 0x09, 0x03, 0x01,
1707 0x10, 0x84, 0x30, 0x0C,
1708 0x24, 0x30, 0x0f,
1709};
1710
1711static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
1712 0x00, 0x24, 0x84, 0x10,
1713 0x09, 0x07, 0x01, 0x0B,
1714 0x10, 0x84, 0x30, 0x0C,
1715 0x24, 0x30, 0x0f,
1716};
1717
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301718static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1719 [0] = {
1720 .mode = MSM_SPM_MODE_CLOCK_GATING,
1721 .notify_rpm = false,
1722 .cmd = spm_wfi_cmd_sequence,
1723 },
1724
1725 [1] = {
1726 .mode = MSM_SPM_MODE_POWER_RETENTION,
1727 .notify_rpm = false,
1728 .cmd = spm_retention_cmd_sequence,
1729 },
1730
1731 [2] = {
1732 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1733 .notify_rpm = false,
1734 .cmd = spm_power_collapse_without_rpm,
1735 },
1736 [3] = {
1737 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1738 .notify_rpm = true,
1739 .cmd = spm_power_collapse_with_rpm,
1740 },
1741};
1742
1743static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001744 [0] = {
1745 .mode = MSM_SPM_MODE_CLOCK_GATING,
1746 .notify_rpm = false,
1747 .cmd = spm_wfi_cmd_sequence,
1748 },
1749 [1] = {
1750 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1751 .notify_rpm = false,
1752 .cmd = spm_power_collapse_without_rpm,
1753 },
1754 [2] = {
1755 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1756 .notify_rpm = true,
1757 .cmd = spm_power_collapse_with_rpm,
1758 },
1759};
1760
1761static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1762 [0] = {
1763 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001764 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001765#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301766 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001767 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001768#endif
1769 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301770 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1771 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1772 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001773 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301774 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1775 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001776 },
1777 [1] = {
1778 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001779 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001780#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnalafb119af2012-11-26 15:56:26 +05301781 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaramd3c5eaf2012-03-16 12:08:42 -06001782 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001783#endif
1784 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001785 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001786 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1787 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1788 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301789 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1790 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001791 },
1792};
1793
1794static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1795 0x00, 0x20, 0x03, 0x20,
1796 0x00, 0x0f,
1797};
1798
1799static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1800 0x00, 0x20, 0x34, 0x64,
1801 0x48, 0x07, 0x48, 0x20,
1802 0x50, 0x64, 0x04, 0x34,
1803 0x50, 0x0f,
1804};
1805static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1806 0x00, 0x10, 0x34, 0x64,
1807 0x48, 0x07, 0x48, 0x10,
1808 0x50, 0x64, 0x04, 0x34,
1809 0x50, 0x0F,
1810};
1811
1812static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1813 [0] = {
1814 .mode = MSM_SPM_L2_MODE_RETENTION,
1815 .notify_rpm = false,
1816 .cmd = l2_spm_wfi_cmd_sequence,
1817 },
1818 [1] = {
1819 .mode = MSM_SPM_L2_MODE_GDHS,
1820 .notify_rpm = true,
1821 .cmd = l2_spm_gdhs_cmd_sequence,
1822 },
1823 [2] = {
1824 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1825 .notify_rpm = true,
1826 .cmd = l2_spm_power_off_cmd_sequence,
1827 },
1828};
1829
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001830static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1831 [0] = {
1832 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001833 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001834 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001835 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1836 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1837 .modes = msm_spm_l2_seq_list,
1838 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1839 },
1840};
1841
Anirudh Ghayal15698162012-07-31 11:51:32 +05301842#define HAP_SHIFT_LVL_OE_GPIO 47
1843#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301844#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1845#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1846
1847static struct msm_xo_voter *xo_handle_d1;
1848
1849static int isa1200_power(int on)
1850{
1851 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301852 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301853
Anirudh Ghayal15698162012-07-31 11:51:32 +05301854 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1855 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1856
1857
1858 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301859
1860 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1861 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1862 if (rc < 0) {
1863 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1864 __func__, on ? "" : "de-", rc);
1865 goto err_xo_vote;
1866 }
1867
1868 return 0;
1869
1870err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301871 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301872 return rc;
1873}
1874
1875static int isa1200_dev_setup(bool enable)
1876{
1877 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301878 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301879
1880 struct pm_gpio hap_gpio_config = {
1881 .direction = PM_GPIO_DIR_OUT,
1882 .pull = PM_GPIO_PULL_NO,
1883 .out_strength = PM_GPIO_STRENGTH_HIGH,
1884 .function = PM_GPIO_FUNC_NORMAL,
1885 .inv_int_pol = 0,
1886 .vin_sel = 2,
1887 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1888 .output_value = 0,
1889 };
1890
Anirudh Ghayal15698162012-07-31 11:51:32 +05301891 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1892 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1893
Mohan Pallaka5e490392011-09-09 15:18:41 +05301894 if (enable == true) {
1895 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1896 if (rc) {
1897 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1898 __func__, PM_HAP_EN_GPIO, rc);
1899 return rc;
1900 }
1901
1902 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1903 if (rc) {
1904 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1905 __func__, PM_HAP_LEN_GPIO, rc);
1906 return rc;
1907 }
1908
Anirudh Ghayal15698162012-07-31 11:51:32 +05301909 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301910 if (rc) {
1911 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301912 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301913 return rc;
1914 }
1915
Anirudh Ghayal15698162012-07-31 11:51:32 +05301916 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301917 if (rc) {
1918 pr_err("%s: Unable to set direction\n", __func__);
1919 goto free_gpio;
1920 }
1921
1922 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1923 if (IS_ERR(xo_handle_d1)) {
1924 rc = PTR_ERR(xo_handle_d1);
1925 pr_err("%s: failed to get the handle for D1(%d)\n",
1926 __func__, rc);
1927 goto gpio_set_dir;
1928 }
1929 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05301930 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301931
1932 msm_xo_put(xo_handle_d1);
1933 }
1934
1935 return 0;
1936
1937gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301938 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301939free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301940 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301941 return rc;
1942}
1943
1944static struct isa1200_regulator isa1200_reg_data[] = {
1945 {
1946 .name = "vcc_i2c",
1947 .min_uV = ISA_I2C_VTG_MIN_UV,
1948 .max_uV = ISA_I2C_VTG_MAX_UV,
1949 .load_uA = ISA_I2C_CURR_UA,
1950 },
1951};
1952
1953static struct isa1200_platform_data isa1200_1_pdata = {
1954 .name = "vibrator",
1955 .dev_setup = isa1200_dev_setup,
1956 .power_on = isa1200_power,
1957 .hap_en_gpio = PM_HAP_EN_GPIO,
1958 .hap_len_gpio = PM_HAP_LEN_GPIO,
1959 .max_timeout = 15000,
1960 .mode_ctrl = PWM_GEN_MODE,
1961 .pwm_fd = {
1962 .pwm_div = 256,
1963 },
1964 .is_erm = false,
1965 .smart_en = true,
1966 .ext_clk_en = true,
1967 .chip_en = 1,
1968 .regulator_info = isa1200_reg_data,
1969 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1970};
1971
1972static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1973 {
1974 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05301975 },
1976};
1977
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001978#define CYTTSP_TS_GPIO_IRQ 11
1979#define CYTTSP_TS_SLEEP_GPIO 50
1980#define CYTTSP_TS_RESOUT_N_GPIO 52
1981
1982/*virtual key support */
1983static ssize_t tma340_vkeys_show(struct kobject *kobj,
1984 struct kobj_attribute *attr, char *buf)
1985{
1986 return snprintf(buf, 200,
1987 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1988 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1989 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1990 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1991 "\n");
1992}
1993
1994static struct kobj_attribute tma340_vkeys_attr = {
1995 .attr = {
1996 .mode = S_IRUGO,
1997 },
1998 .show = &tma340_vkeys_show,
1999};
2000
2001static struct attribute *tma340_properties_attrs[] = {
2002 &tma340_vkeys_attr.attr,
2003 NULL
2004};
2005
2006static struct attribute_group tma340_properties_attr_group = {
2007 .attrs = tma340_properties_attrs,
2008};
2009
2010
2011static int cyttsp_platform_init(struct i2c_client *client)
2012{
2013 int rc = 0;
2014 static struct kobject *tma340_properties_kobj;
2015
2016 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2017 tma340_properties_kobj = kobject_create_and_add("board_properties",
2018 NULL);
2019 if (tma340_properties_kobj)
2020 rc = sysfs_create_group(tma340_properties_kobj,
2021 &tma340_properties_attr_group);
2022 if (!tma340_properties_kobj || rc)
2023 pr_err("%s: failed to create board_properties\n",
2024 __func__);
2025
2026 return 0;
2027}
2028
2029static struct cyttsp_regulator regulator_data[] = {
2030 {
2031 .name = "vdd",
2032 .min_uV = CY_TMA300_VTG_MIN_UV,
2033 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302034 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
2035 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002036 },
2037 /* TODO: Remove after runtime PM is enabled in I2C driver */
2038 {
2039 .name = "vcc_i2c",
2040 .min_uV = CY_I2C_VTG_MIN_UV,
2041 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302042 .hpm_load_uA = CY_I2C_CURR_UA,
2043 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002044 },
2045};
2046
2047static struct cyttsp_platform_data cyttsp_pdata = {
2048 .panel_maxx = 634,
2049 .panel_maxy = 1166,
2050 .disp_maxx = 616,
2051 .disp_maxy = 1023,
2052 .disp_minx = 0,
2053 .disp_miny = 16,
2054 .flags = 0x01,
2055 .gen = CY_GEN3, /* or */
2056 .use_st = CY_USE_ST,
2057 .use_mt = CY_USE_MT,
2058 .use_hndshk = CY_SEND_HNDSHK,
2059 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302060 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002061 .use_gestures = CY_USE_GESTURES,
2062 .fw_fname = "cyttsp_8960_cdp.hex",
2063 /* activate up to 4 groups
2064 * and set active distance
2065 */
2066 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2067 CY_GEST_GRP3 | CY_GEST_GRP4 |
2068 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07002069 .act_intrvl = 10,
2070 .tch_tmout = 200,
2071 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002072 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2073 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2074 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2075 .regulator_info = regulator_data,
2076 .num_regulators = ARRAY_SIZE(regulator_data),
2077 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302078 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002079};
2080
2081static struct i2c_board_info cyttsp_info[] __initdata = {
2082 {
2083 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2084 .platform_data = &cyttsp_pdata,
2085#ifndef CY_USE_TIMER
2086 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2087#endif /* CY_USE_TIMER */
2088 },
2089};
2090
Jing Lindc4413c2012-01-16 15:22:52 -08002091/* configuration data for mxt1386 */
2092static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302093 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002094 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302095 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002096 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002097 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2102 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302103 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002104 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302105 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002106 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302107 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002108 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2109 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2110 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2111 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302112 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2114 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302115 /* T18 Object */
2116 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302117 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002118 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2119 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302120 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2122 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302123 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002124 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2125 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302126 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002127 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302128 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002129 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302130 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002131 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302132 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002133 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302134 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002135 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302136};
2137
Jing Lin33b007d2011-12-21 17:40:23 -08002138/* configuration data for mxt1386e using V1.0 firmware */
2139static const u8 mxt1386e_config_data_v1_0[] = {
2140 /* T6 Object */
2141 0, 0, 0, 0, 0, 0,
2142 /* T38 Object */
2143 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2149 0, 0, 0, 0,
2150 /* T7 Object */
2151 100, 16, 50,
2152 /* T8 Object */
2153 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2154 /* T9 Object */
2155 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2156 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2157 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2158 10, 5, 0, 0, 0,
2159 /* T18 Object */
2160 0, 0,
2161 /* T24 Object */
2162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2163 0, 0, 0, 0, 0, 0, 0, 0, 0,
2164 /* T25 Object */
2165 3, 0, 60, 115, 156, 99,
2166 /* T27 Object */
2167 0, 0, 0, 0, 0, 0, 0,
2168 /* T40 Object */
2169 0, 0, 0, 0, 0,
2170 /* T42 Object */
2171 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2172 /* T43 Object */
2173 0, 0, 0, 0, 0, 0, 0,
2174 /* T46 Object */
2175 64, 0, 20, 20, 0, 0, 0, 0, 0,
2176 /* T47 Object */
2177 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2178 /* T48 Object */
2179 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2180 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2181 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2182 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2184 0, 0, 0, 0,
2185 /* T56 Object */
2186 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2190 2, 99, 33,
2191};
2192
2193/* configuration data for mxt1386e using V2.1 firmware */
2194static const u8 mxt1386e_config_data_v2_1[] = {
2195 /* T6 Object */
2196 0, 0, 0, 0, 0, 0,
2197 /* T38 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002198 12, 4, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002199 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2200 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2202 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2203 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2204 0, 0, 0, 0,
2205 /* T7 Object */
2206 100, 16, 50,
2207 /* T8 Object */
2208 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2209 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002210 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002211 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002212 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2213 10, 5, 0, 0, 0,
2214 /* T18 Object */
2215 0, 0,
2216 /* T24 Object */
2217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2218 0, 0, 0, 0, 0, 0, 0, 0, 0,
2219 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002220 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002221 /* T27 Object */
2222 0, 0, 0, 0, 0, 0, 0,
2223 /* T40 Object */
2224 0, 0, 0, 0, 0,
2225 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002226 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002227 /* T43 Object */
2228 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2229 16,
2230 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002231 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002232 /* T47 Object */
2233 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2234 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002235 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002236 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2237 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2238 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2239 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2240 0, 0, 0, 0,
2241 /* T56 Object */
2242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2246 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2247 255,
2248};
2249
Jing Lineec88ca2012-02-08 11:18:30 -08002250/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2251static const u8 mxt1386e_config_data_3d[] = {
2252 /* T6 Object */
2253 0, 0, 0, 0, 0, 0,
2254 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002255 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2261 0, 0, 0, 0,
2262 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002263 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002264 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002265 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002266 /* T9 Object */
2267 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2268 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002269 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2270 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002271 /* T18 Object */
2272 0, 0,
2273 /* T24 Object */
2274 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2275 0, 0, 0, 0, 0, 0, 0, 0, 0,
2276 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002277 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002278 /* T27 Object */
2279 0, 0, 0, 0, 0, 0, 0,
2280 /* T40 Object */
2281 0, 0, 0, 0, 0,
2282 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002284 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2286 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002287 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002288 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002289 /* T47 Object */
2290 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2291 /* T48 Object */
2292 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002293 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2294 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2295 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002296 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2297 0, 0, 0, 0,
2298 /* T56 Object */
2299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2302 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002303 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2304 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002305};
2306
Amy Maloche08266db2011-11-04 11:07:16 -07002307#define MXT_TS_GPIO_IRQ 11
2308#define MXT_TS_LDO_EN_GPIO 50
2309#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302310
2311static void mxt_init_hw_liquid(void)
2312{
2313 int rc;
2314
Mohan Pallaka50837382011-09-07 11:00:57 +05302315 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2316 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002317 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2318 __func__, MXT_TS_LDO_EN_GPIO);
2319 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302320 }
2321
2322 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2323 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002324 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2325 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302326 goto err_ldo_gpio_req;
2327 }
2328
Mohan Pallaka50837382011-09-07 11:00:57 +05302329 return;
2330
Mohan Pallaka50837382011-09-07 11:00:57 +05302331err_ldo_gpio_req:
2332 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302333}
2334
Jing Lineec88ca2012-02-08 11:18:30 -08002335static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002336 {
2337 .config = mxt1386_config_data,
2338 .config_length = ARRAY_SIZE(mxt1386_config_data),
2339 .family_id = 0xA0,
2340 .variant_id = 0x0,
2341 .version = 0x10,
2342 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002343 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002344 },
Jing Lin33b007d2011-12-21 17:40:23 -08002345 {
2346 .config = mxt1386e_config_data_v1_0,
2347 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2348 .family_id = 0xA0,
2349 .variant_id = 0x2,
2350 .version = 0x10,
2351 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002352 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002353 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002354 },
2355 {
2356 .config = mxt1386e_config_data_v2_1,
2357 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2358 .family_id = 0xA0,
2359 .variant_id = 0x7,
2360 .version = 0x21,
2361 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002362 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002363 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2364 },
2365 {
2366 /* The config data for V2.2.AA is the same as for V2.1.AA */
2367 .config = mxt1386e_config_data_v2_1,
2368 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2369 .family_id = 0xA0,
2370 .variant_id = 0x7,
2371 .version = 0x22,
2372 .build = 0xAA,
2373 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002374 },
Jing Lindc4413c2012-01-16 15:22:52 -08002375};
2376
Jing Lineec88ca2012-02-08 11:18:30 -08002377static struct mxt_platform_data mxt_platform_data_2d = {
2378 .config_array = mxt_config_array_2d,
2379 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002380 .panel_minx = 0,
2381 .panel_maxx = 1365,
2382 .panel_miny = 0,
2383 .panel_maxy = 767,
2384 .disp_minx = 0,
2385 .disp_maxx = 1365,
2386 .disp_miny = 0,
2387 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302388 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002389 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002390 .reset_gpio = MXT_TS_RESET_GPIO,
2391 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302392};
2393
Jing Lineec88ca2012-02-08 11:18:30 -08002394static struct mxt_config_info mxt_config_array_3d[] = {
2395 {
2396 .config = mxt1386e_config_data_3d,
2397 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2398 .family_id = 0xA0,
2399 .variant_id = 0x7,
2400 .version = 0x21,
2401 .build = 0xAA,
2402 },
2403};
2404
2405static struct mxt_platform_data mxt_platform_data_3d = {
2406 .config_array = mxt_config_array_3d,
2407 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002408 .panel_minx = 0,
2409 .panel_maxx = 1919,
2410 .panel_miny = 0,
2411 .panel_maxy = 1199,
2412 .disp_minx = 0,
2413 .disp_maxx = 1919,
2414 .disp_miny = 0,
2415 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002416 .irqflags = IRQF_TRIGGER_FALLING,
2417 .i2c_pull_up = true,
2418 .reset_gpio = MXT_TS_RESET_GPIO,
2419 .irq_gpio = MXT_TS_GPIO_IRQ,
2420};
2421
Mohan Pallaka50837382011-09-07 11:00:57 +05302422static struct i2c_board_info mxt_device_info[] __initdata = {
2423 {
2424 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302425 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2426 },
2427};
2428
Manoj Rao14648742012-03-30 19:42:12 -07002429static struct msm_mhl_platform_data mhl_platform_data = {
2430 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002431 .gpio_mhl_int = MHL_GPIO_INT,
2432 .gpio_mhl_reset = MHL_GPIO_RESET,
2433 .gpio_mhl_power = 0,
2434 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002435};
Manoj Rao14648742012-03-30 19:42:12 -07002436
Eugene Yasmand2316b82011-12-07 18:23:48 +02002437static struct i2c_board_info sii_device_info[] __initdata = {
2438 {
Manoj Rao14648742012-03-30 19:42:12 -07002439#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2440 /*
2441 * keeps SI 8334 as the default
2442 * MHL TX
2443 */
2444 I2C_BOARD_INFO("sii8334", 0x39),
2445 .platform_data = &mhl_platform_data,
2446#endif
2447#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002448 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002449 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002450#endif /* CONFIG_MSM_HDMI_MHL */
2451 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002452 },
2453};
2454
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002455static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2456 .clk_freq = 100000,
2457 .src_clk_rate = 24000000,
Kiran Gundab4696c72012-08-16 18:37:46 +05302458 .keep_ahb_clk_on = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002459};
2460
2461static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2462 .clk_freq = 100000,
2463 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002464};
2465
2466static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2467 .clk_freq = 100000,
2468 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002469};
2470
2471static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2472 .clk_freq = 100000,
2473 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002474};
2475
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002476static struct ks8851_pdata spi_eth_pdata = {
2477 .irq_gpio = KS8851_IRQ_GPIO,
2478 .rst_gpio = KS8851_RST_GPIO,
2479};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002480
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302481static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002482 {
2483 .modalias = "ks8851",
2484 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2485 .max_speed_hz = 19200000,
2486 .bus_num = 0,
2487 .chip_select = 0,
2488 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002489 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002490 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302491};
2492static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002493 {
2494 .modalias = "dsi_novatek_3d_panel_spi",
2495 .max_speed_hz = 10800000,
2496 .bus_num = 0,
2497 .chip_select = 1,
2498 .mode = SPI_MODE_0,
2499 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002500};
2501
2502static struct platform_device msm_device_saw_core0 = {
2503 .name = "saw-regulator",
2504 .id = 0,
2505 .dev = {
2506 .platform_data = &msm_saw_regulator_pdata_s5,
2507 },
2508};
2509
2510static struct platform_device msm_device_saw_core1 = {
2511 .name = "saw-regulator",
2512 .id = 1,
2513 .dev = {
2514 .platform_data = &msm_saw_regulator_pdata_s6,
2515 },
2516};
2517
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002518static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002519 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002520 .tsens_factor = 1000,
2521 .hw_type = MSM_8960,
2522 .tsens_num_sensor = 5,
2523};
2524
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002525static struct platform_device msm_tsens_device = {
2526 .name = "tsens8960-tm",
2527 .id = -1,
2528};
2529
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002530static struct msm_thermal_data msm_thermal_pdata = {
2531 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002532 .poll_ms = 250,
2533 .limit_temp_degC = 60,
2534 .temp_hysteresis_degC = 10,
2535 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002536};
2537
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002538#ifdef CONFIG_MSM_FAKE_BATTERY
2539static struct platform_device fish_battery_device = {
2540 .name = "fish_battery",
2541};
2542#endif
2543
David Collins26f05562011-06-20 09:56:28 -07002544static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002545 .name = GPIO_REGULATOR_DEV_NAME,
2546 .id = PM8921_MPP_PM_TO_SYS(7),
2547 .dev = {
2548 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2549 },
2550};
2551
David Collins26f05562011-06-20 09:56:28 -07002552static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002553 .name = GPIO_REGULATOR_DEV_NAME,
2554 .id = 91,
2555 .dev = {
2556 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2557 },
2558};
2559
David Collinsb10be1d2011-09-02 10:29:31 -07002560static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2561 .name = GPIO_REGULATOR_DEV_NAME,
2562 .id = PM8921_GPIO_PM_TO_SYS(17),
2563 .dev = {
2564 .platform_data =
2565 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2566 },
2567};
2568
David Collins35a78f52011-12-14 15:54:25 -08002569static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2570 .name = GPIO_REGULATOR_DEV_NAME,
2571 .id = PM8921_GPIO_PM_TO_SYS(42),
2572 .dev = {
2573 .platform_data =
2574 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2575 },
2576};
2577
David Collins26f05562011-06-20 09:56:28 -07002578static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2579 .name = "rpm-regulator",
2580 .id = -1,
2581 .dev = {
2582 .platform_data = &msm_rpm_regulator_pdata,
2583 },
2584};
Mayank Ranae009c922012-03-22 03:02:06 +05302585#ifdef CONFIG_SERIAL_MSM_HS
2586static int configure_uart_gpios(int on)
2587{
2588 int ret = 0, i;
2589 int uart_gpios[] = {93, 94, 95, 96};
2590
2591 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2592 if (on) {
2593 ret = gpio_request(uart_gpios[i], NULL);
2594 if (ret) {
2595 pr_err("%s: unable to request uart gpio[%d]\n",
2596 __func__, uart_gpios[i]);
2597 break;
2598 }
2599 } else {
2600 gpio_free(uart_gpios[i]);
2601 }
2602 }
2603
2604 if (ret && on && i)
2605 for (; i >= 0; i--)
2606 gpio_free(uart_gpios[i]);
2607 return ret;
2608}
2609
2610static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002611 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302612};
Mayank Rana1f02d952012-07-04 19:11:20 +05302613
2614static int configure_gsbi8_uart_gpios(int on)
2615{
2616 int ret = 0, i;
2617 int uart_gpios[] = {34, 35, 36, 37};
2618
2619 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2620 if (on) {
2621 ret = gpio_request(uart_gpios[i], NULL);
2622 if (ret) {
2623 pr_err("%s: unable to request uart gpio[%d]\n",
2624 __func__, uart_gpios[i]);
2625 break;
2626 }
2627 } else {
2628 gpio_free(uart_gpios[i]);
2629 }
2630 }
2631
2632 if (ret && on && i)
2633 for (; i >= 0; i--)
2634 gpio_free(uart_gpios[i]);
2635 return ret;
2636}
2637
2638static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
2639 .gpio_config = configure_gsbi8_uart_gpios,
2640};
Mayank Ranae009c922012-03-22 03:02:06 +05302641#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302642static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302643static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2644#endif
David Collins26f05562011-06-20 09:56:28 -07002645
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302646#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002647enum WLANBT_STATUS {
2648 WLANOFF_BTOFF = 1,
2649 WLANOFF_BTON,
2650 WLANON_BTOFF,
2651 WLANON_BTON
2652};
2653
2654static DEFINE_MUTEX(ath_wlanbt_mutex);
2655static int gpio_wlan_sys_rest_en = 26;
2656static int ath_wlanbt_status = WLANOFF_BTOFF;
2657
2658static int ath6kl_power_control(int on)
2659{
2660 int rc;
2661
2662 if (on) {
2663 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2664 if (rc) {
2665 pr_err("%s: unable to request gpio %d (%d)\n",
2666 __func__, gpio_wlan_sys_rest_en, rc);
2667 return rc;
2668 }
2669 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2670 msleep(200);
2671 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2672 msleep(100);
2673 } else {
2674 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2675 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2676 msleep(100);
2677 gpio_free(gpio_wlan_sys_rest_en);
2678 }
2679 return 0;
2680};
2681
2682static int ath6kl_wlan_power(int on)
2683{
2684 int ret = 0;
2685
2686 mutex_lock(&ath_wlanbt_mutex);
2687 if (on) {
2688 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2689 ret = ath6kl_power_control(1);
2690 ath_wlanbt_status = WLANON_BTOFF;
2691 } else if (ath_wlanbt_status == WLANOFF_BTON)
2692 ath_wlanbt_status = WLANON_BTON;
2693 } else {
2694 if (ath_wlanbt_status == WLANON_BTOFF) {
2695 ret = ath6kl_power_control(0);
2696 ath_wlanbt_status = WLANOFF_BTOFF;
2697 } else if (ath_wlanbt_status == WLANON_BTON)
2698 ath_wlanbt_status = WLANOFF_BTON;
2699 }
2700 mutex_unlock(&ath_wlanbt_mutex);
2701 pr_debug("%s on= %d, wlan_status= %d\n",
2702 __func__, on, ath_wlanbt_status);
2703 return ret;
2704};
2705
2706static struct wifi_platform_data ath6kl_wifi_control = {
2707 .set_power = ath6kl_wlan_power,
2708};
2709
2710static struct platform_device msm_wlan_power_device = {
2711 .name = "ath6kl_power",
2712 .dev = {
2713 .platform_data = &ath6kl_wifi_control,
2714 },
2715};
2716
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302717static struct resource bluesleep_resources[] = {
2718 {
2719 .name = "gpio_host_wake",
2720 .start = 27,
2721 .end = 27,
2722 .flags = IORESOURCE_IO,
2723 },
2724 {
2725 .name = "gpio_ext_wake",
2726 .start = 29,
2727 .end = 29,
2728 .flags = IORESOURCE_IO,
2729 },
2730 {
2731 .name = "host_wake",
2732 .start = MSM_GPIO_TO_INT(27),
2733 .end = MSM_GPIO_TO_INT(27),
2734 .flags = IORESOURCE_IRQ,
2735 },
2736};
2737
2738static struct platform_device msm_bluesleep_device = {
2739 .name = "bluesleep",
2740 .id = -1,
2741 .num_resources = ARRAY_SIZE(bluesleep_resources),
2742 .resource = bluesleep_resources,
2743};
2744
2745static struct platform_device msm_bt_power_device = {
2746 .name = "bt_power",
2747};
2748
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002749static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302750
2751static int bluetooth_power(int on)
2752{
2753 int rc;
2754
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002755 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302756 if (on) {
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002757 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2758 ath6kl_power_control(1);
2759 ath_wlanbt_status = WLANOFF_BTON;
2760 } else if (ath_wlanbt_status == WLANON_BTOFF)
2761 ath_wlanbt_status = WLANON_BTON;
2762
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302763 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2764 if (rc) {
2765 pr_err("%s: unable to request gpio %d (%d)\n",
2766 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002767 mutex_unlock(&ath_wlanbt_mutex);
2768 return rc;
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302769 }
2770 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002771 msleep(20);
2772 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302773 msleep(100);
2774 } else {
2775 gpio_set_value(gpio_bt_sys_rest_en, 0);
2776 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2777 msleep(100);
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002778 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondab07c2632012-08-18 22:24:03 +05302779
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002780 if (ath_wlanbt_status == WLANOFF_BTON) {
2781 ath6kl_power_control(0);
2782 ath_wlanbt_status = WLANOFF_BTOFF;
2783 } else if (ath_wlanbt_status == WLANON_BTON)
2784 ath_wlanbt_status = WLANON_BTOFF;
2785 }
2786 mutex_unlock(&ath_wlanbt_mutex);
2787 pr_debug("%s on= %d, wlan_status= %d\n",
2788 __func__, on, ath_wlanbt_status);
2789 return 0;
2790};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302791
2792static void __init bt_power_init(void)
2793{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302794 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302795 return;
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002796};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302797#else
2798#define bt_power_init(x) do {} while (0)
2799#endif
2800
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002801static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002802 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002803 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302804 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805 &msm_device_saw_core0,
2806 &msm_device_saw_core1,
2807 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002808 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002809 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810 &msm8960_device_qup_spi_gsbi1,
2811 &msm8960_device_qup_i2c_gsbi3,
2812 &msm8960_device_qup_i2c_gsbi4,
2813 &msm8960_device_qup_i2c_gsbi10,
2814#ifndef CONFIG_MSM_DSPS
2815 &msm8960_device_qup_i2c_gsbi12,
2816#endif
2817 &msm_slim_ctrl,
2818 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302819#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2820 &msm_bluesleep_device,
2821 &msm_bt_power_device,
Ming-yi Lin2d43cd52012-10-17 11:50:15 +08002822 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302823#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002824#if defined(CONFIG_QSEECOM)
2825 &qseecom_device,
2826#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002827#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2828 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2829 &qcrypto_device,
2830#endif
2831
2832#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2833 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2834 &qcedev_device,
2835#endif
2836#ifdef CONFIG_MSM_ROTATOR
2837 &msm_rotator_device,
2838#endif
2839 &msm_device_sps,
2840#ifdef CONFIG_MSM_FAKE_BATTERY
2841 &fish_battery_device,
2842#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002843 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002845#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002846 &msm8960_android_pmem_device,
2847 &msm8960_android_pmem_adsp_device,
2848 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002849#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002850#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002851 &msm_device_bam_dmux,
2852 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002853#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2854#ifdef CONFIG_MSM_USE_TSIF1
2855 &msm_device_tsif[1],
2856#else
2857 &msm_device_tsif[0],
2858#endif
2859#endif
Joel Nider266a2642011-10-16 10:58:05 +02002860 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002861#ifdef CONFIG_HW_RANDOM_MSM
2862 &msm_device_rng,
2863#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002864#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002865 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002866#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002867 &msm8960_rpm_device,
2868 &msm8960_rpm_log_device,
2869 &msm8960_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302870 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002871 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002872 &coresight_tpiu_device,
2873 &coresight_etb_device,
2874 &coresight_funnel_device,
2875 &coresight_etm0_device,
2876 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002877 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002878 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002879 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002880 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002881 &msm8960_device_ebi1_ch0_erp,
2882 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002883 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002884 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002885 &msm_tsens_device,
Anji Jonnalae84292b2012-09-21 13:34:44 +05302886 &msm8960_pc_cntr,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887};
2888
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002889static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002890 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002891 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002892 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002893 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002894 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002895 &msm8960_device_otg,
2896 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002897 &msm_device_hsusb_host,
2898 &android_usb_device,
2899 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002900 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002901 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002902 &msm_pcm_routing,
2903 &msm_cpudai0,
2904 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002905 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002906 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002907 &msm_cpudai_hdmi_rx,
2908 &msm_cpudai_bt_rx,
2909 &msm_cpudai_bt_tx,
2910 &msm_cpudai_fm_rx,
2911 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002912 &msm_cpudai_auxpcm_rx,
2913 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002914 &msm_cpu_fe,
2915 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916#ifdef CONFIG_MSM_GEMINI
2917 &msm8960_gemini_device,
2918#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07002919#ifdef CONFIG_MSM_MERCURY
2920 &msm8960_mercury_device,
2921#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002922 &msm_voice,
2923 &msm_voip,
2924 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302925 &msm_cpudai_afe_01_rx,
2926 &msm_cpudai_afe_01_tx,
2927 &msm_cpudai_afe_02_rx,
2928 &msm_cpudai_afe_02_tx,
2929 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302930 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002931 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002932 &msm_cpudai_incall_record_rx,
2933 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002934 &msm_pcm_hostless,
2935 &msm_bus_apps_fabric,
2936 &msm_bus_sys_fabric,
2937 &msm_bus_mm_fabric,
2938 &msm_bus_sys_fpb,
2939 &msm_bus_cpss_fpb,
2940};
2941
2942static void __init msm8960_i2c_init(void)
2943{
2944 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2945 &msm8960_i2c_qup_gsbi4_pdata;
2946
2947 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2948 &msm8960_i2c_qup_gsbi3_pdata;
2949
2950 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2951 &msm8960_i2c_qup_gsbi10_pdata;
2952
2953 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2954 &msm8960_i2c_qup_gsbi12_pdata;
2955}
2956
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002957static void __init msm8960_gfx_init(void)
2958{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002959 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2960 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06002961 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002962
Carter Cooper3852cbb2012-08-20 22:11:42 -06002963 /* Fixup data that needs to change based on GPU ID */
Carter Cooperffe7ea12012-08-22 13:27:58 -06002964 if (cpu_is_msm8960ab()) {
2965 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
Suman Tatiraju20372242012-10-29 18:24:53 -07002966 /* 8960PRO nominal clock rate is 320Mhz */
2967 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Carter Cooper3852cbb2012-08-20 22:11:42 -06002968 } else {
2969 kgsl_3d0_pdata->iommu_count = 1;
2970 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
2971 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
2972 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
2973 }
2974 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
2975 /* 8960v3 GPU registers returns 5 for patch release
2976 * but it should be 6, so dummy up the chipid here
2977 * based the platform type
2978 */
2979 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
2980 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002981 }
Carter Cooper6307eb992012-08-20 15:17:23 -06002982
2983 /* Register the 3D core */
2984 platform_device_register(&msm_kgsl_3d0);
2985
2986 /* Register the 2D cores if we are not 8960PRO */
2987 if (!cpu_is_msm8960ab()) {
2988 platform_device_register(&msm_kgsl_2d0);
2989 platform_device_register(&msm_kgsl_2d1);
2990 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002991}
2992
Subhash Jadavani933e6a62011-12-26 18:05:04 +05302993static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002994 {
2995 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
2996 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
2997 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002998 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002999 },
3000
3001 {
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303002 MSM_PM_SLEEP_MODE_RETENTION,
3003 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3004 true,
3005 415, 715, 340827, 475,
3006 },
3007
3008 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003009 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3010 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3011 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003012 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003013 },
3014
3015 {
3016 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3017 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3018 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003019 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003020 },
3021
3022 {
3023 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003024 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
3025 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003026 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003027 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003028
3029 {
3030 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3031 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3032 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003033 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003034 },
3035
3036 {
3037 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3038 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3039 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003040 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003041 },
3042
3043 {
3044 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3045 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3046 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003047 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003048 },
3049
3050 {
3051 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3052 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3053 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003054 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003055 },
3056};
3057
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303058
Praveen Chidambaram78499012011-11-01 17:15:17 -06003059static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
3060 .levels = &msm_rpmrs_levels[0],
3061 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
3062 .vdd_mem_levels = {
3063 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3064 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3065 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3066 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3067 },
3068 .vdd_dig_levels = {
3069 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3070 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3071 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3072 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3073 },
3074 .vdd_mask = 0x7FFFFF,
3075 .rpmrs_target_id = {
3076 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3077 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3078 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3079 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3080 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3081 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3082 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3083 },
3084};
3085
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003086static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3087 .mode = MSM_PM_BOOT_CONFIG_TZ,
3088};
3089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003090#ifdef CONFIG_I2C
3091#define I2C_SURF 1
3092#define I2C_FFA (1 << 1)
3093#define I2C_RUMI (1 << 2)
3094#define I2C_SIM (1 << 3)
3095#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003096#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003097
3098struct i2c_registry {
3099 u8 machs;
3100 int bus;
3101 struct i2c_board_info *info;
3102 int len;
3103};
3104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105/* Sensors DSPS platform data */
3106#ifdef CONFIG_MSM_DSPS
3107#define DSPS_PIL_GENERIC_NAME "dsps"
3108#endif /* CONFIG_MSM_DSPS */
3109
3110static void __init msm8960_init_dsps(void)
3111{
3112#ifdef CONFIG_MSM_DSPS
3113 struct msm_dsps_platform_data *pdata =
3114 msm_dsps_device.dev.platform_data;
3115 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3116 pdata->gpios = NULL;
3117 pdata->gpios_num = 0;
3118
3119 platform_device_register(&msm_dsps_device);
3120#endif /* CONFIG_MSM_DSPS */
3121}
3122
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003123static int hsic_peripheral_status = 1;
3124static DEFINE_MUTEX(hsic_status_lock);
3125
3126void peripheral_connect()
3127{
3128 mutex_lock(&hsic_status_lock);
3129 if (hsic_peripheral_status)
3130 goto out;
3131 platform_device_add(&msm_device_hsic_host);
3132 hsic_peripheral_status = 1;
3133out:
3134 mutex_unlock(&hsic_status_lock);
3135}
3136EXPORT_SYMBOL(peripheral_connect);
3137
3138void peripheral_disconnect()
3139{
3140 mutex_lock(&hsic_status_lock);
3141 if (!hsic_peripheral_status)
3142 goto out;
3143 platform_device_del(&msm_device_hsic_host);
3144 hsic_peripheral_status = 0;
3145out:
3146 mutex_unlock(&hsic_status_lock);
3147}
3148EXPORT_SYMBOL(peripheral_disconnect);
3149
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303150static void __init msm8960_init_smsc_hub(void)
3151{
3152 uint32_t version = socinfo_get_version();
3153
3154 if (SOCINFO_VERSION_MAJOR(version) == 1)
3155 return;
3156
3157 if (machine_is_msm8960_liquid())
3158 platform_device_register(&smsc_hub_device);
3159}
3160
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003161static void __init msm8960_init_hsic(void)
3162{
3163#ifdef CONFIG_USB_EHCI_MSM_HSIC
3164 uint32_t version = socinfo_get_version();
3165
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003166 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003167 return;
3168
Joel King0cbf5d82012-05-24 15:21:38 -07003169 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003170 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003171#endif
3172}
3173
Amir Samuelov5137e392011-09-21 17:31:25 +03003174#ifdef CONFIG_ISL9519_CHARGER
3175static struct isl_platform_data isl_data __initdata = {
3176 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3177 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3178 .max_system_voltage = 4200,
3179 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003180 .chgcurrent = 1900,
3181 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003182 .input_current = 2048,
3183};
3184
3185static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3186 {
3187 I2C_BOARD_INFO("isl9519q", 0x9),
3188 .irq = 0, /* Not required when notify-by-pmic */
3189 .platform_data = &isl_data,
3190 },
3191};
3192#endif /* CONFIG_ISL9519_CHARGER */
3193
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003194#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003195static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3196 {
3197 I2C_BOARD_INFO("sx1508q", 0x20),
3198 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3199 },
3200};
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003201#endif
Amir Samuelov755616d2011-12-13 16:34:46 +02003202
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003203static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003204#ifdef CONFIG_ISL9519_CHARGER
3205 {
3206 I2C_LIQUID,
3207 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3208 isl_charger_i2c_info,
3209 ARRAY_SIZE(isl_charger_i2c_info),
3210 },
3211#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003212 {
3213 I2C_SURF | I2C_FFA | I2C_FLUID,
3214 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3215 cyttsp_info,
3216 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003217 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303218 {
3219 I2C_LIQUID,
3220 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3221 mxt_device_info,
3222 ARRAY_SIZE(mxt_device_info),
3223 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303224 {
Manoj Rao14648742012-03-30 19:42:12 -07003225 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303226 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003227 sii_device_info,
3228 ARRAY_SIZE(sii_device_info),
3229 },
3230 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303231 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003232 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303233 msm_isa1200_board_info,
3234 ARRAY_SIZE(msm_isa1200_board_info),
3235 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003236#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Amir Samuelov755616d2011-12-13 16:34:46 +02003237 {
3238 I2C_LIQUID,
3239 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3240 liquid_io_expander_i2c_info,
3241 ARRAY_SIZE(liquid_io_expander_i2c_info),
3242 },
Hanumant Singhbcd8ae72013-01-03 15:13:52 -08003243#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003244};
3245#endif /* CONFIG_I2C */
3246
3247static void __init register_i2c_devices(void)
3248{
3249#ifdef CONFIG_I2C
3250 u8 mach_mask = 0;
3251 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003252#ifdef CONFIG_MSM_CAMERA
3253 struct i2c_registry msm8960_camera_i2c_devices = {
3254 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3255 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3256 msm8960_camera_board_info.board_info,
3257 msm8960_camera_board_info.num_i2c_board_info,
3258 };
3259#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003260
3261 /* Build the matching 'supported_machs' bitmask */
3262 if (machine_is_msm8960_cdp())
3263 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003264 else if (machine_is_msm8960_fluid())
3265 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003266 else if (machine_is_msm8960_liquid())
3267 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003268 else if (machine_is_msm8960_mtp())
3269 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003270 else
3271 pr_err("unmatched machine ID in register_i2c_devices\n");
3272
Jing Lineec88ca2012-02-08 11:18:30 -08003273 if (machine_is_msm8960_liquid()) {
3274 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3275 mxt_device_info[0].platform_data =
3276 &mxt_platform_data_3d;
3277 else
3278 mxt_device_info[0].platform_data =
3279 &mxt_platform_data_2d;
3280 }
3281
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003282 /* Run the array and install devices as appropriate */
3283 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3284 if (msm8960_i2c_devices[i].machs & mach_mask)
3285 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3286 msm8960_i2c_devices[i].info,
3287 msm8960_i2c_devices[i].len);
3288 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003289
3290 if (!mhl_platform_data.gpio_mhl_power)
3291 pr_debug("mhl device configured for ext debug board\n");
3292
Kevin Chan09f4e662011-12-16 08:17:02 -08003293#ifdef CONFIG_MSM_CAMERA
3294 if (msm8960_camera_i2c_devices.machs & mach_mask)
3295 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3296 msm8960_camera_i2c_devices.info,
3297 msm8960_camera_i2c_devices.len);
3298#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003299#endif
3300}
3301
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003302static void __init msm8960_tsens_init(void)
3303{
3304 if (cpu_is_msm8960())
3305 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3306 return;
3307
3308 msm_tsens_early_init(&msm_tsens_pdata);
3309}
3310
Anji Jonnala0f297a92013-01-19 11:22:25 +05303311static void __init msm8960ab_update_krait_spm(void)
3312 {
3313 int i;
3314
3315 /* Reset the AVS registers until we have support for AVS */
3316 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3317 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3318 pdata->reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0;
3319 pdata->reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0;
3320 }
3321
3322 /* Update the SPM sequences for SPC and PC */
3323 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3324 int j;
3325 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3326 for (j = 0; j < pdata->num_modes; j++) {
3327 if (pdata->modes[j].cmd ==
3328 spm_power_collapse_without_rpm)
3329 pdata->modes[j].cmd =
3330 spm_power_collapse_without_rpm_krait_v3;
3331 else if (pdata->modes[j].cmd ==
3332 spm_power_collapse_with_rpm)
3333 pdata->modes[j].cmd =
3334 spm_power_collapse_with_rpm_krait_v3;
3335 }
3336 }
3337}
3338
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003339static void __init msm8960_cdp_init(void)
3340{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003341 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3342 pr_err("meminfo_init() failed!\n");
3343
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003344 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss9e1417c2012-09-26 09:42:32 -07003345 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003346 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003347 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3348 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003349
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003350 regulator_suppress_info_printing();
3351 if (msm_xo_init())
3352 pr_err("Failed to initialize XO votes\n");
David Collins4c93ce92012-09-04 15:44:19 -07003353 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003354 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003355 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303356 if (machine_is_msm8960_liquid())
3357 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003358 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303359 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3360 machine_is_msm8960_cdp()) {
Mayank Ranaa1f507b2012-08-14 10:57:00 +05303361 /* Due to availability of USB Switch in SGLTE Platform
3362 * it requires different HSUSB PHY settings compare to
3363 * 8960 MTP/CDP platform.
3364 */
3365 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3366 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3367 else
3368 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303369 } else if (machine_is_msm8960_liquid()) {
3370 msm_otg_pdata.phy_init_seq =
3371 liquid_v1_phy_init_seq;
3372 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003373 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303374 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303375 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303376 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3377 machine_is_msm8960_liquid())
3378 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003379 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003380 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3381 &msm8960_qup_spi_gsbi1_pdata;
3382 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303383 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3384 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003385
3386 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303387 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jain4ffd8122012-12-03 15:09:39 +05303388 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3389 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303390 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003391 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003392 msm8960_gfx_init();
Anji Jonnala0f297a92013-01-19 11:22:25 +05303393 if (cpu_is_msm8960ab())
3394 msm8960ab_update_krait_spm();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003395 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3396 msm_spm_l2_init(msm_spm_l2_data);
3397 msm8960_init_buses();
Stephen Boyd6716bd92012-10-25 11:46:04 -07003398 if (cpu_is_msm8960ab()) {
3399 platform_add_devices(msm8960ab_footswitch,
3400 msm8960ab_num_footswitch);
3401 } else {
3402 platform_add_devices(msm8960_footswitch,
3403 msm8960_num_footswitch);
3404 }
David Collinsb10be1d2011-09-02 10:29:31 -07003405 if (machine_is_msm8960_liquid())
3406 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003407 if (machine_is_msm8960_cdp())
3408 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003409
3410 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3411 platform_device_register(&msm8960_device_uart_gsbi8);
3412 else
3413 platform_device_register(&msm8960_device_uart_gsbi5);
3414
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003415 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003416 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3417 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003418 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303419 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003420 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003421
Mayank Rana1f02d952012-07-04 19:11:20 +05303422 /* For 8960 Standalone External Bluetooth Interface */
3423 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3424 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3425 platform_device_register(&msm_device_uart_dm8);
3426 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003427 if (cpu_is_msm8960ab())
3428 platform_device_register(&msm8960ab_device_acpuclk);
3429 else
3430 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menond4837f62012-08-20 15:25:50 -07003432 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003433
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003434 msm8960_pm8921_gpio_mpp_init();
Stephen Boyd0ea1b762012-09-13 12:41:31 -07003435 /* Don't add modem devices on APQ targets */
3436 if (socinfo_get_id() != 124) {
3437 platform_device_register(&msm_8960_q6_mss_fw);
3438 platform_device_register(&msm_8960_q6_mss_sw);
3439 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003440 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303441 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003442 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003443#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003444 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003445#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003446 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303447 if (machine_is_msm8960_liquid())
3448 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003449 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003450 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003451 slim_register_board_info(msm_slim_devices,
3452 ARRAY_SIZE(msm_slim_devices));
3453 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003454 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003455 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303456 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003457 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3458 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3459 platform_device_register(&mdm_sglte_device);
3460 }
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303461 msm_pm_set_tz_retention_flag(1);
Laura Abbott5249a052012-12-11 15:09:03 -08003462 ion_adjust_secure_allocation();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003463}
3464
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003465MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3466 .map_io = msm8960_map_io,
3467 .reserve = msm8960_reserve,
3468 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303469 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003470 .timer = &msm_timer,
3471 .init_machine = msm8960_cdp_init,
3472 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003473 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003474 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003475MACHINE_END
3476
3477MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3478 .map_io = msm8960_map_io,
3479 .reserve = msm8960_reserve,
3480 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303481 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003482 .timer = &msm_timer,
3483 .init_machine = msm8960_cdp_init,
3484 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003485 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003486 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003487MACHINE_END
3488
3489MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3490 .map_io = msm8960_map_io,
3491 .reserve = msm8960_reserve,
3492 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303493 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003494 .timer = &msm_timer,
3495 .init_machine = msm8960_cdp_init,
3496 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003497 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003498 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003499MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003500
3501MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3502 .map_io = msm8960_map_io,
3503 .reserve = msm8960_reserve,
3504 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303505 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003506 .timer = &msm_timer,
3507 .init_machine = msm8960_cdp_init,
3508 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003509 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003510 .restart = msm_restart,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003511MACHINE_END