blob: f4e788006004912bfa788121f315a0f2eaf6b78a [file] [log] [blame]
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080012 */
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080013#include <linux/err.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080014#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/io.h>
17#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/i2c.h>
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -070019#include <linux/i2c/sx150x.h>
Amir Samuelov5137e392011-09-21 17:31:25 +030020#include <linux/i2c/isl9519.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#include <linux/gpio.h>
22#include <linux/msm_ssbi.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070023#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024#include <linux/mfd/pm8xxx/pm8921.h>
Siddartha Mohanadossaf91d902011-10-20 10:23:34 -070025#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/regulator/consumer.h>
27#include <linux/spi/spi.h>
28#include <linux/slimbus/slimbus.h>
29#include <linux/bootmem.h>
30#ifdef CONFIG_ANDROID_PMEM
31#include <linux/android_pmem.h>
32#endif
Steve Mucklef132c6c2012-06-06 18:30:57 -070033#include <linux/cyttsp-qc.h>
Laura Abbottc0e64032012-08-03 17:32:09 -070034#include <linux/dma-contiguous.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035#include <linux/dma-mapping.h>
36#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070037#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038#include <linux/leds.h>
39#include <linux/leds-pm8xxx.h>
Mohan Pallaka50837382011-09-07 11:00:57 +053040#include <linux/i2c/atmel_mxt_ts.h>
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -070041#include <linux/msm_tsens.h>
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -070042#include <linux/ks8851.h>
Mohan Pallaka5e490392011-09-09 15:18:41 +053043#include <linux/i2c/isa1200.h>
Jack Cheung0b1987e2011-11-18 13:36:29 -080044#include <linux/memory.h>
Larry Bassel2d8b42d2012-03-12 10:41:26 -070045#include <linux/memblock.h>
Praveen Chidambaram877d7a42012-06-05 14:33:20 -060046#include <linux/msm_thermal.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080047
48#include <asm/mach-types.h>
49#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070050#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080051#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080053
54#include <mach/board.h>
Joel Nider266a2642011-10-16 10:58:05 +020055#include <mach/msm_tspp.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080056#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#include <mach/msm_spi.h>
Mayank Ranae009c922012-03-22 03:02:06 +053058#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059#ifdef CONFIG_USB_MSM_OTG_72K
60#include <mach/msm_hsusb.h>
61#else
62#include <linux/usb/msm_hsusb.h>
63#endif
64#include <linux/usb/android.h>
65#include <mach/usbdiag.h>
66#include <mach/socinfo.h>
67#include <mach/rpm.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070068#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#include <mach/msm_bus_board.h>
70#include <mach/msm_memtypes.h>
71#include <mach/dma.h>
72#include <mach/msm_dsps.h>
73#include <mach/msm_xo.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070074#include <mach/restart.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080075
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#ifdef CONFIG_WCD9310_CODEC
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053077#include <linux/mfd/wcd9xxx/core.h>
78#include <linux/mfd/wcd9xxx/pdata.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079#endif
80
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +053081#include <linux/smsc3503.h>
Mitchel Humpheryscfa31af2012-09-06 11:34:03 -070082#include <linux/msm_ion.h>
Laura Abbottd6183792011-08-19 13:42:24 -070083#include <mach/ion.h>
Joel Kingb8352a12011-11-15 18:46:24 -080084#include <mach/mdm2.h>
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -080085#include <mach/mdm-peripheral.h>
Laura Abbottf8c03b92012-02-16 14:57:58 -080086#include <mach/msm_rtb.h>
Laura Abbott306bcc22012-03-08 11:24:53 -080087#include <mach/msm_cache_dump.h>
88#include <mach/scm.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070089#include <mach/iommu_domains.h>
Laura Abbottd6183792011-08-19 13:42:24 -070090
Jordan Crouse914de9b2012-07-09 13:49:46 -060091#include <mach/kgsl.h>
Larry Bassel41a055b2011-12-06 16:15:14 -080092#include <linux/fmem.h>
93
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080095#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097#include "spm.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080098#include "board-8960.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080099#include "pm.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -0800100#include <mach/cpuidle.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101#include "rpm_resources.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +0530102#include <mach/mpm.h>
Matt Wagantall33d01f52012-02-23 23:27:44 -0800103#include "clock.h"
Naveen Ramaraj76483ad2011-09-06 14:25:44 -0700104#include "smd_private.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600105#include "pm-boot.h"
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700106#include "msm_watchdog.h"
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -0800107#include "platsmp.h"
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800108
Ming-yi Lin9baad172012-10-17 11:50:15 +0800109#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
110#include <linux/wlan_plat.h>
111#include <linux/mutex.h>
112#endif
113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114static struct platform_device msm_fm_platform_init = {
115 .name = "iris_fm",
116 .id = -1,
117};
118
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700119#define KS8851_RST_GPIO 89
120#define KS8851_IRQ_GPIO 90
Mohan Pallaka5e490392011-09-09 15:18:41 +0530121
Manoj Rao14648742012-03-30 19:42:12 -0700122#define MHL_GPIO_INT 4
123#define MHL_GPIO_RESET 15
124
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700125#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700126
Stepan Moskovchenkoc6ada422011-11-28 19:31:16 -0800127struct sx150x_platform_data msm8960_sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700128 [SX150X_CAM] = {
129 .gpio_base = GPIO_CAM_EXPANDER_BASE,
130 .oscio_is_gpo = false,
131 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530132 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700133 .io_open_drain_ena = 0x0,
134 .irq_summary = -1,
135 },
Amir Samuelov755616d2011-12-13 16:34:46 +0200136 [SX150X_LIQUID] = {
137 .gpio_base = GPIO_LIQUID_EXPANDER_BASE,
138 .oscio_is_gpo = false,
139 .io_pullup_ena = 0x0c08,
140 .io_pulldn_ena = 0x4060,
141 .io_open_drain_ena = 0x000c,
142 .io_polarity = 0,
143 .irq_summary = -1,
144 },
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700145};
Nishant Pandit474f2252011-07-23 23:17:56 +0530146
147#endif
148
Olav Haugana21169d2012-01-04 09:17:06 -0800149#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -0700150#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Mathew Karimpanal15fa5c42011-12-14 21:28:10 -0800151#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800152#define MSM_LIQUID_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800153#define MSM_HDMI_PRIM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Laura Abbott2d1760b2011-09-29 21:31:24 -0700154
155#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Deepak Kotur35825522012-06-06 15:49:14 -0700156#define HOLE_SIZE 0x20000
Rajeshwar Kurapatyc3e190a2012-12-04 19:28:05 +0530157#define MSM_ION_MFC_META_SIZE 0x40000 /* 256 Kbytes */
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700158#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan32594552012-03-13 11:40:05 -0700159#ifdef CONFIG_MSM_IOMMU
Olav Haugan8726caf2012-05-10 15:11:35 -0700160#define MSM_ION_MM_SIZE 0x3800000 /* Need to be multiple of 64K */
Olav Haugan32594552012-03-13 11:40:05 -0700161#define MSM_ION_SF_SIZE 0x0
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700162#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700163#define MSM_ION_HEAP_NUM 7
164#else
165#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
166#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Hauganfbbf05b2012-04-05 14:33:41 -0700167#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan32594552012-03-13 11:40:05 -0700168#define MSM_ION_HEAP_NUM 8
169#endif
Deepak Kotur35825522012-06-06 15:49:14 -0700170#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 128kb */
Rajeshwar Kurapatyc3e190a2012-12-04 19:28:05 +0530171#define MSM_ION_MFC_SIZE (SZ_8K + MSM_ION_MFC_META_SIZE)
Olav Haugan7355db02012-01-13 16:59:13 -0800172#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan32594552012-03-13 11:40:05 -0700173
Olav Hauganb5be7992011-11-18 14:29:02 -0800174#define MSM_LIQUID_ION_MM_SIZE (MSM_ION_MM_SIZE + 0x600000)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800175#define MSM_LIQUID_ION_SF_SIZE MSM_LIQUID_PMEM_SIZE
176#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SIZE
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700177
Deepak Kotur35825522012-06-06 15:49:14 -0700178#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 2mb -128kb*/
179#define MSM8960_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
180 HOLE_SIZE))
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700181#define MAX_FIXED_AREA_SIZE 0x10000000
Deepak Kotur35825522012-06-06 15:49:14 -0700182#define MSM8960_FW_START MSM8960_FIXED_AREA_START
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700183
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800184static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott2d1760b2011-09-29 21:31:24 -0700185#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700186#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Hauganb5be7992011-11-18 14:29:02 -0800187#define MSM_ION_HEAP_NUM 1
Laura Abbott2d1760b2011-09-29 21:31:24 -0700188#endif
Laura Abbottd6183792011-08-19 13:42:24 -0700189
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700190#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
191static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
192static int __init msm_contig_mem_size_setup(char *p)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700193{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700194 msm_contig_mem_size = memparse(p, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700195 return 0;
196}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700197early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700198#endif
199
200#ifdef CONFIG_ANDROID_PMEM
201static unsigned pmem_size = MSM_PMEM_SIZE;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800202static unsigned pmem_param_set;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700203static int __init pmem_size_setup(char *p)
204{
205 pmem_size = memparse(p, NULL);
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800206 pmem_param_set = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700207 return 0;
208}
209early_param("pmem_size", pmem_size_setup);
210
211static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
212
213static int __init pmem_adsp_size_setup(char *p)
214{
215 pmem_adsp_size = memparse(p, NULL);
216 return 0;
217}
218early_param("pmem_adsp_size", pmem_adsp_size_setup);
219
220static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
221
222static int __init pmem_audio_size_setup(char *p)
223{
224 pmem_audio_size = memparse(p, NULL);
225 return 0;
226}
227early_param("pmem_audio_size", pmem_audio_size_setup);
228#endif
229
230#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700231#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700232static struct android_pmem_platform_data android_pmem_pdata = {
233 .name = "pmem",
234 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
235 .cached = 1,
236 .memory_type = MEMTYPE_EBI1,
237};
238
Laura Abbottb93525f2012-04-12 09:57:19 -0700239static struct platform_device msm8960_android_pmem_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700240 .name = "android_pmem",
241 .id = 0,
242 .dev = {.platform_data = &android_pmem_pdata},
243};
244
245static struct android_pmem_platform_data android_pmem_adsp_pdata = {
246 .name = "pmem_adsp",
247 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
248 .cached = 0,
249 .memory_type = MEMTYPE_EBI1,
250};
Laura Abbottb93525f2012-04-12 09:57:19 -0700251static struct platform_device msm8960_android_pmem_adsp_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700252 .name = "android_pmem",
253 .id = 2,
254 .dev = { .platform_data = &android_pmem_adsp_pdata },
255};
256
257static struct android_pmem_platform_data android_pmem_audio_pdata = {
258 .name = "pmem_audio",
259 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
260 .cached = 0,
261 .memory_type = MEMTYPE_EBI1,
262};
263
Laura Abbottb93525f2012-04-12 09:57:19 -0700264static struct platform_device msm8960_android_pmem_audio_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265 .name = "android_pmem",
266 .id = 4,
267 .dev = { .platform_data = &android_pmem_audio_pdata },
268};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700269#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
270#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700271
Laura Abbottb93525f2012-04-12 09:57:19 -0700272struct fmem_platform_data msm8960_fmem_pdata = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800273};
274
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700275#define DSP_RAM_BASE_8960 0x8da00000
276#define DSP_RAM_SIZE_8960 0x1800000
277static int dspcrashd_pdata_8960 = 0xDEADDEAD;
278
279static struct resource resources_dspcrashd_8960[] = {
280 {
281 .name = "msm_dspcrashd",
282 .start = DSP_RAM_BASE_8960,
283 .end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
284 .flags = IORESOURCE_DMA,
285 },
286};
287
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800288static struct platform_device msm_device_dspcrashd_8960 = {
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -0700289 .name = "msm_dspcrashd",
290 .num_resources = ARRAY_SIZE(resources_dspcrashd_8960),
291 .resource = resources_dspcrashd_8960,
292 .dev = { .platform_data = &dspcrashd_pdata_8960 },
293};
294
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700295static struct memtype_reserve msm8960_reserve_table[] __initdata = {
296 [MEMTYPE_SMI] = {
297 },
298 [MEMTYPE_EBI0] = {
299 .flags = MEMTYPE_FLAGS_1M_ALIGN,
300 },
301 [MEMTYPE_EBI1] = {
302 .flags = MEMTYPE_FLAGS_1M_ALIGN,
303 },
304};
305
Laura Abbottf8c03b92012-02-16 14:57:58 -0800306static void __init reserve_rtb_memory(void)
307{
308#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700309 msm8960_reserve_table[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
Laura Abbottf8c03b92012-02-16 14:57:58 -0800310#endif
311}
312
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700313static void __init size_pmem_devices(void)
314{
315#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700316#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317 android_pmem_adsp_pdata.size = pmem_adsp_size;
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800318
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800319 if (!pmem_param_set) {
320 if (machine_is_msm8960_liquid())
321 pmem_size = MSM_LIQUID_PMEM_SIZE;
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700322 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800323 pmem_size = MSM_HDMI_PRIM_PMEM_SIZE;
324 }
325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326 android_pmem_pdata.size = pmem_size;
327 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700328#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
329#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330}
331
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700332#ifdef CONFIG_ANDROID_PMEM
333#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334static void __init reserve_memory_for(struct android_pmem_platform_data *p)
335{
336 msm8960_reserve_table[p->memory_type].size += p->size;
337}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700338#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
339#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340
341static void __init reserve_pmem_memory(void)
342{
343#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -0700344#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345 reserve_memory_for(&android_pmem_adsp_pdata);
346 reserve_memory_for(&android_pmem_pdata);
347 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700348#endif
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700349 msm8960_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700350#endif
351}
352
Larry Basselb4126da2011-07-18 14:31:33 -0700353static int msm8960_paddr_to_memtype(unsigned int paddr)
354{
355 return MEMTYPE_EBI1;
356}
357
Steve Mucklef132c6c2012-06-06 18:30:57 -0700358#define FMEM_ENABLED 0
Olav Hauganf6dc7742012-02-15 09:11:55 -0800359
Laura Abbottd6183792011-08-19 13:42:24 -0700360#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -0800361#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700362static struct ion_cp_heap_pdata cp_mm_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800363 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -0700364 .align = SZ_64K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800365 .reusable = FMEM_ENABLED,
366 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700367 .fixed_position = FIXED_MIDDLE,
Olav Haugan8726caf2012-05-10 15:11:35 -0700368 .iommu_map_all = 1,
369 .iommu_2x_map_domain = VIDEO_DOMAIN,
Laura Abbottac963312012-12-11 15:09:03 -0800370 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800371};
372
Laura Abbottb93525f2012-04-12 09:57:19 -0700373static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800374 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800375 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800376 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800377 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700378 .fixed_position = FIXED_HIGH,
Laura Abbottac963312012-12-11 15:09:03 -0800379 .no_nonsecure_alloc = 1,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800380};
381
Laura Abbottb93525f2012-04-12 09:57:19 -0700382static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800383 .adjacent_mem_id = INVALID_HEAP_ID,
384 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800385 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800386};
387
Laura Abbottb93525f2012-04-12 09:57:19 -0700388static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800389 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
390 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800391 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700392 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800393};
394#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800395
Laura Abbottc0e64032012-08-03 17:32:09 -0700396static u64 msm_dmamask = DMA_BIT_MASK(32);
397
398static struct platform_device ion_mm_heap_device = {
399 .name = "ion-mm-heap-device",
400 .id = -1,
401 .dev = {
402 .dma_mask = &msm_dmamask,
403 .coherent_dma_mask = DMA_BIT_MASK(32),
404 }
405};
406
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800407/**
408 * These heaps are listed in the order they will be allocated. Due to
409 * video hardware restrictions and content protection the FW heap has to
410 * be allocated adjacent (below) the MM heap and the MFC heap has to be
411 * allocated after the MM heap to ensure MFC heap is not more than 256MB
412 * away from the base address of the FW heap.
413 * However, the order of FW heap and MM heap doesn't matter since these
414 * two heaps are taken care of by separate code to ensure they are adjacent
415 * to each other.
416 * Don't swap the order unless you know what you are doing!
417 */
Benjamin Gaignard63d81032012-06-25 15:27:30 -0700418struct ion_platform_heap msm8960_heaps[] = {
Laura Abbottd6183792011-08-19 13:42:24 -0700419 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800420 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700421 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700422 .name = ION_VMALLOC_HEAP_NAME,
423 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700424#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700425 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800426 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800427 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800428 .name = ION_MM_HEAP_NAME,
429 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700430 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700431 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbottc0e64032012-08-03 17:32:09 -0700432 .priv = &ion_mm_heap_device.dev,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700433 },
Laura Abbott8c017362011-09-22 20:59:12 -0700434 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800435 .id = ION_MM_FIRMWARE_HEAP_ID,
436 .type = ION_HEAP_TYPE_CARVEOUT,
437 .name = ION_MM_FIRMWARE_HEAP_NAME,
438 .size = MSM_ION_MM_FW_SIZE,
439 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700440 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800441 },
442 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800443 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800444 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800445 .name = ION_MFC_HEAP_NAME,
446 .size = MSM_ION_MFC_SIZE,
447 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700448 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800449 },
Olav Haugan32594552012-03-13 11:40:05 -0700450#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800451 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800452 .id = ION_SF_HEAP_ID,
453 .type = ION_HEAP_TYPE_CARVEOUT,
454 .name = ION_SF_HEAP_NAME,
455 .size = MSM_ION_SF_SIZE,
456 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700457 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800458 },
Olav Haugan32594552012-03-13 11:40:05 -0700459#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800460 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800461 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700462 .type = ION_HEAP_TYPE_IOMMU,
463 .name = ION_IOMMU_HEAP_NAME,
464 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800465 {
466 .id = ION_QSECOM_HEAP_ID,
467 .type = ION_HEAP_TYPE_CARVEOUT,
468 .name = ION_QSECOM_HEAP_NAME,
469 .size = MSM_ION_QSECOM_SIZE,
470 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700471 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800472 },
Olav Haugan7355db02012-01-13 16:59:13 -0800473 {
474 .id = ION_AUDIO_HEAP_ID,
475 .type = ION_HEAP_TYPE_CARVEOUT,
476 .name = ION_AUDIO_HEAP_NAME,
477 .size = MSM_ION_AUDIO_SIZE,
478 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700479 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800480 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700481#endif
Benjamin Gaignard63d81032012-06-25 15:27:30 -0700482};
483
484static struct ion_platform_data msm8960_ion_pdata = {
485 .nr = MSM_ION_HEAP_NUM,
486 .heaps = msm8960_heaps,
Laura Abbottd6183792011-08-19 13:42:24 -0700487};
488
Laura Abbottb93525f2012-04-12 09:57:19 -0700489static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700490 .name = "ion-msm",
491 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700492 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700493};
494#endif
495
Laura Abbottb93525f2012-04-12 09:57:19 -0700496struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800497 .name = "fmem",
498 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700499 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800500};
501
Olav Haugan65f4bd82011-12-13 11:50:08 -0800502static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700503{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800504 unsigned int i;
505
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800506 if (!pmem_param_set) {
507 if (machine_is_msm8960_liquid())
508 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
509
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700510 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800511 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
512
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700513 if (machine_is_msm8960_liquid() ||
514 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700515 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
516 if (msm8960_ion_pdata.heaps[i].id ==
517 ION_SF_HEAP_ID) {
518 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800519 msm_ion_sf_size;
520 pr_debug("msm_ion_sf_size 0x%x\n",
521 msm_ion_sf_size);
522 break;
523 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800524 }
525 }
526 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800527}
528
529static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
530 unsigned long size)
531{
532 msm8960_reserve_table[mem_type].size += size;
533}
534
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700535static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
536{
537#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
538 int ret;
539
540 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
541 panic("fixed area size is larger than %dM\n",
542 MAX_FIXED_AREA_SIZE >> 20);
543
544 reserve_info->fixed_area_size = fixed_area_size;
545 reserve_info->fixed_area_start = MSM8960_FW_START;
546
547 ret = memblock_remove(reserve_info->fixed_area_start,
548 reserve_info->fixed_area_size);
549 BUG_ON(ret);
550#endif
551}
552
Olav Haugan65f4bd82011-12-13 11:50:08 -0800553/**
554 * Reserve memory for ION and calculate amount of reusable memory for fmem.
555 * We only reserve memory for heaps that are not reusable. However, we only
556 * support one reusable heap at the moment so we ignore the reusable flag for
557 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800558 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
559 * at a higher address than FW in addition to not more than 256MB away from the
560 * base address of the firmware. This means that if MM is reusable the other
561 * two heaps must be allocated in the same region as FW. This is handled by the
562 * mem_is_fmem flag in the platform data. In addition the MM heap must be
563 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800564 */
565static void __init reserve_ion_memory(void)
566{
567#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
568 unsigned int i;
Laura Abbottc0e64032012-08-03 17:32:09 -0700569 int ret;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700570 unsigned int fixed_size = 0;
571 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
572 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbottc0e64032012-08-03 17:32:09 -0700573 unsigned long cma_alignment;
574 unsigned int low_use_cma = 0;
575 unsigned int middle_use_cma = 0;
576 unsigned int high_use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800577
578 adjust_mem_for_liquid();
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700579 fixed_low_size = 0;
580 fixed_middle_size = 0;
581 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800582
Laura Abbottc0e64032012-08-03 17:32:09 -0700583 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
584
Laura Abbottb93525f2012-04-12 09:57:19 -0700585 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
Olav Haugan8726caf2012-05-10 15:11:35 -0700586 struct ion_platform_heap *heap =
Laura Abbottb93525f2012-04-12 09:57:19 -0700587 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan8726caf2012-05-10 15:11:35 -0700588 int align = SZ_4K;
589 int iommu_map_all = 0;
590 int adjacent_mem_id = INVALID_HEAP_ID;
Laura Abbottc0e64032012-08-03 17:32:09 -0700591 int use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800592
593 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700594 int fixed_position = NOT_FIXED;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700595
Mitchel Humpherys362b52b2012-09-13 10:53:22 -0700596 switch ((int) heap->type) {
Olav Haugan65f4bd82011-12-13 11:50:08 -0800597 case ION_HEAP_TYPE_CP:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700598 fixed_position = ((struct ion_cp_heap_pdata *)
599 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700600 align = ((struct ion_cp_heap_pdata *)
601 heap->extra_data)->align;
602 iommu_map_all =
603 ((struct ion_cp_heap_pdata *)
604 heap->extra_data)->iommu_map_all;
Laura Abbottc0e64032012-08-03 17:32:09 -0700605 if (((struct ion_cp_heap_pdata *)
606 heap->extra_data)->is_cma) {
607 heap->size = ALIGN(heap->size,
608 cma_alignment);
609 use_cma = 1;
610 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800611 break;
Laura Abbottc0e64032012-08-03 17:32:09 -0700612 case ION_HEAP_TYPE_DMA:
613 use_cma = 1;
614 /* Purposely fall through here */
Olav Haugan65f4bd82011-12-13 11:50:08 -0800615 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700616 fixed_position = ((struct ion_co_heap_pdata *)
617 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700618 adjacent_mem_id = ((struct ion_co_heap_pdata *)
619 heap->extra_data)->adjacent_mem_id;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700620 break;
621 default:
622 break;
623 }
624
Olav Haugan8726caf2012-05-10 15:11:35 -0700625 if (iommu_map_all) {
626 if (heap->size & (SZ_64K-1)) {
627 heap->size = ALIGN(heap->size, SZ_64K);
628 pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
629 heap->name, heap->size);
630 }
631 }
632
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700633 if (fixed_position != NOT_FIXED)
634 fixed_size += heap->size;
635 else
636 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
637
Laura Abbottc0e64032012-08-03 17:32:09 -0700638 if (fixed_position == FIXED_LOW) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700639 fixed_low_size += heap->size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700640 low_use_cma = use_cma;
641 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700642 fixed_middle_size += heap->size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700643 middle_use_cma = use_cma;
644 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700645 fixed_high_size += heap->size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700646 high_use_cma = use_cma;
647 } else if (use_cma) {
648 /*
649 * Heaps that use CMA but are not part of the
650 * fixed set. Create wherever.
651 */
652 dma_declare_contiguous(
653 heap->priv,
654 heap->size,
655 0,
656 0xb0000000);
657 }
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700658 }
659 }
660
661 if (!fixed_size)
662 return;
663
Laura Abbottc0e64032012-08-03 17:32:09 -0700664 /*
665 * Given the setup for the fixed area, we can't round up all sizes.
666 * Some sizes must be set up exactly and aligned correctly. Incorrect
667 * alignments are considered a configuration issue
Larry Bassel4d4f4482012-04-04 11:26:09 -0700668 */
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700669
670 fixed_low_start = MSM8960_FIXED_AREA_START;
Laura Abbottc0e64032012-08-03 17:32:09 -0700671 if (low_use_cma) {
672 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
673 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
674 } else {
675 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
676 ret = memblock_remove(fixed_low_start,
677 fixed_low_size + HOLE_SIZE);
678 BUG_ON(ret);
679 }
680
Deepak Kotur35825522012-06-06 15:49:14 -0700681 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbottc0e64032012-08-03 17:32:09 -0700682 if (middle_use_cma) {
683 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
684 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
685 } else {
686 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
687 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
688 BUG_ON(ret);
689 }
690
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700691 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700692 if (high_use_cma) {
693 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
694 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
695 } else {
696 /* This is the end of the fixed area so it's okay to round up */
697 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
698 ret = memblock_remove(fixed_high_start, fixed_high_size);
699 BUG_ON(ret);
700 }
701
702
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700703
Laura Abbottb93525f2012-04-12 09:57:19 -0700704 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
705 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700706
707 if (heap->extra_data) {
708 int fixed_position = NOT_FIXED;
Steve Muckle75c34ca2012-06-12 14:27:40 -0700709 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700710
Mitchel Humpherys362b52b2012-09-13 10:53:22 -0700711 switch ((int) heap->type) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700712 case ION_HEAP_TYPE_CP:
Deepak Kotur35825522012-06-06 15:49:14 -0700713 pdata =
714 (struct ion_cp_heap_pdata *)heap->extra_data;
715 fixed_position = pdata->fixed_position;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700716 break;
717 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbottc0e64032012-08-03 17:32:09 -0700718 case ION_HEAP_TYPE_DMA:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700719 fixed_position = ((struct ion_co_heap_pdata *)
720 heap->extra_data)->fixed_position;
721 break;
722 default:
723 break;
724 }
725
726 switch (fixed_position) {
727 case FIXED_LOW:
728 heap->base = fixed_low_start;
729 break;
730 case FIXED_MIDDLE:
731 heap->base = fixed_middle_start;
Laura Abbottc0e64032012-08-03 17:32:09 -0700732 if (middle_use_cma) {
733 ret = dma_declare_contiguous(
734 &ion_mm_heap_device.dev,
735 heap->size,
736 fixed_middle_start,
737 0xa0000000);
738 WARN_ON(ret);
739 }
Deepak Kotur35825522012-06-06 15:49:14 -0700740 pdata->secure_base = fixed_middle_start
741 - HOLE_SIZE;
742 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700743 break;
744 case FIXED_HIGH:
745 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800746 break;
747 default:
748 break;
749 }
750 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800751 }
Laura Abbottd6183792011-08-19 13:42:24 -0700752#endif
753}
Huaibin Yanga5419422011-12-08 23:52:10 -0800754
Laura Abbottac963312012-12-11 15:09:03 -0800755static void ion_adjust_secure_allocation(void)
756{
757 int i;
758
759 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
760 struct ion_platform_heap *heap =
761 &(msm8960_ion_pdata.heaps[i]);
762
763
764 if (heap->extra_data) {
765 switch ((int) heap->type) {
766 case ION_HEAP_TYPE_CP:
767 if (cpu_is_msm8960()) {
768 ((struct ion_cp_heap_pdata *)
769 heap->extra_data)->no_nonsecure_alloc =
770 0;
771 }
772
773 }
774 }
775 }
776}
777
Huaibin Yanga5419422011-12-08 23:52:10 -0800778static void __init reserve_mdp_memory(void)
779{
780 msm8960_mdp_writeback(msm8960_reserve_table);
781}
782
Stephen Boyd668d7652012-04-25 11:31:01 -0700783static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800784{
785#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbott306bcc22012-03-08 11:24:53 -0800786 unsigned int total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800787
Laura Abbott155ab6f2012-05-25 08:52:18 -0700788 total = msm8960_cache_dump_pdata.l1_size +
789 msm8960_cache_dump_pdata.l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800790 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800791#endif
792}
793
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794static void __init msm8960_calculate_reserve_sizes(void)
795{
796 size_pmem_devices();
797 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700798 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800799 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800800 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800801 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802}
803
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804static struct reserve_info msm8960_reserve_info __initdata = {
805 .memtype_reserve_table = msm8960_reserve_table,
806 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700807 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700808 .paddr_to_memtype = msm8960_paddr_to_memtype,
809};
810
Larry Basselb4126da2011-07-18 14:31:33 -0700811static int msm8960_memory_bank_size(void)
812{
813 return 1<<29;
814}
815
816static void __init locate_unstable_memory(void)
817{
818 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
819 unsigned long bank_size;
820 unsigned long low, high;
821
822 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700823 msm8960_reserve_info.bank_size = bank_size;
824
Larry Basselb4126da2011-07-18 14:31:33 -0700825 low = meminfo.bank[0].start;
826 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700827
828 /* Check if 32 bit overflow occured */
829 if (high < mb->start)
830 high = ~0UL;
831
Larry Bassel4d4f4482012-04-04 11:26:09 -0700832 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
833 panic("fixed area extends beyond end of memory\n");
834
Larry Basselb4126da2011-07-18 14:31:33 -0700835 low &= ~(bank_size - 1);
836
837 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700838 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800839
Larry Basselb8d61022012-02-24 10:49:45 -0800840#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800841 msm8960_reserve_info.low_unstable_address = mb->start -
842 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800843 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700844 pr_info("low unstable address %lx max size %lx bank size %lx\n",
845 msm8960_reserve_info.low_unstable_address,
846 msm8960_reserve_info.max_unstable_size,
847 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700848 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800849#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700850no_dmm:
851 msm8960_reserve_info.low_unstable_address = high;
852 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700853}
854
Larry Basselb830e182011-10-14 10:46:55 -0700855static void __init place_movable_zone(void)
856{
Larry Basselb8d61022012-02-24 10:49:45 -0800857#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700858 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
859 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
860 pr_info("movable zone start %lx size %lx\n",
861 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800862#endif
Larry Basselb830e182011-10-14 10:46:55 -0700863}
864
865static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700866{
867 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700868 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700869 place_movable_zone();
870}
871
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800872static char prim_panel_name[PANEL_NAME_MAX_LEN];
873static char ext_panel_name[PANEL_NAME_MAX_LEN];
874static int __init prim_display_setup(char *param)
875{
876 if (strnlen(param, PANEL_NAME_MAX_LEN))
877 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
878 return 0;
879}
880early_param("prim_display", prim_display_setup);
881
882static int __init ext_display_setup(char *param)
883{
884 if (strnlen(param, PANEL_NAME_MAX_LEN))
885 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
886 return 0;
887}
888early_param("ext_display", ext_display_setup);
889
Larry Basselb830e182011-10-14 10:46:55 -0700890static void __init msm8960_reserve(void)
891{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800892 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700893 msm_reserve();
894}
895
Larry Bassela4414b12011-08-04 11:11:02 -0700896static int msm8960_change_memory_power(u64 start, u64 size,
897 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700898{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700899 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700900}
901
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700902static void __init msm8960_allocate_memory_regions(void)
903{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800904 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700905}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800906
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907#ifdef CONFIG_WCD9310_CODEC
908
909#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
910
Patrick Lai3043fba2011-08-01 14:15:57 -0700911/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
912 * 4 micbiases are used to power various analog and digital
913 * microphones operating at 1800 mV. Technically, all micbiases
914 * can source from single cfilter since all microphones operate
915 * at the same voltage level. The arrangement below is to make
916 * sure all cfilters are exercised. LDO_H regulator ouput level
917 * does not need to be as high as 2.85V. It is choosen for
918 * microphone sensitivity purpose.
919 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530920static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700921 .slimbus_slave_device = {
922 .name = "tabla-slave",
923 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
924 },
925 .irq = MSM_GPIO_TO_INT(62),
926 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530927 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700928 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700929 .micbias = {
930 .ldoh_v = TABLA_LDOH_2P85_V,
931 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700932 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700933 .cfilt3_mv = 1800,
934 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
935 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
936 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
937 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530938 },
939 .regulator = {
940 {
941 .name = "CDC_VDD_CP",
942 .min_uV = 1800000,
943 .max_uV = 1800000,
944 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
945 },
946 {
947 .name = "CDC_VDDA_RX",
948 .min_uV = 1800000,
949 .max_uV = 1800000,
950 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
951 },
952 {
953 .name = "CDC_VDDA_TX",
954 .min_uV = 1800000,
955 .max_uV = 1800000,
956 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
957 },
958 {
959 .name = "VDDIO_CDC",
960 .min_uV = 1800000,
961 .max_uV = 1800000,
962 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
963 },
964 {
965 .name = "VDDD_CDC_D",
966 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700967 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530968 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
969 },
970 {
971 .name = "CDC_VDDA_A_1P2V",
972 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700973 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530974 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
975 },
976 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700977};
978
979static struct slim_device msm_slim_tabla = {
980 .name = "tabla-slim",
981 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
982 .dev = {
983 .platform_data = &tabla_platform_data,
984 },
985};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530986
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530987static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530988 .slimbus_slave_device = {
989 .name = "tabla-slave",
990 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
991 },
992 .irq = MSM_GPIO_TO_INT(62),
993 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530994 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530995 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
996 .micbias = {
997 .ldoh_v = TABLA_LDOH_2P85_V,
998 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700999 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +05301000 .cfilt3_mv = 1800,
1001 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1002 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1003 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1004 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301005 },
1006 .regulator = {
1007 {
1008 .name = "CDC_VDD_CP",
1009 .min_uV = 1800000,
1010 .max_uV = 1800000,
1011 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1012 },
1013 {
1014 .name = "CDC_VDDA_RX",
1015 .min_uV = 1800000,
1016 .max_uV = 1800000,
1017 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1018 },
1019 {
1020 .name = "CDC_VDDA_TX",
1021 .min_uV = 1800000,
1022 .max_uV = 1800000,
1023 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1024 },
1025 {
1026 .name = "VDDIO_CDC",
1027 .min_uV = 1800000,
1028 .max_uV = 1800000,
1029 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1030 },
1031 {
1032 .name = "VDDD_CDC_D",
1033 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001034 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301035 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1036 },
1037 {
1038 .name = "CDC_VDDA_A_1P2V",
1039 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001040 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301041 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1042 },
1043 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301044};
1045
1046static struct slim_device msm_slim_tabla20 = {
1047 .name = "tabla2x-slim",
1048 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1049 .dev = {
1050 .platform_data = &tabla20_platform_data,
1051 },
1052};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001053#endif
1054
1055static struct slim_boardinfo msm_slim_devices[] = {
1056#ifdef CONFIG_WCD9310_CODEC
1057 {
1058 .bus_num = 1,
1059 .slim_slave = &msm_slim_tabla,
1060 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301061 {
1062 .bus_num = 1,
1063 .slim_slave = &msm_slim_tabla20,
1064 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001065#endif
1066 /* add more slimbus slaves as needed */
1067};
1068
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001069#define MSM_WCNSS_PHYS 0x03000000
1070#define MSM_WCNSS_SIZE 0x280000
1071
1072static struct resource resources_wcnss_wlan[] = {
1073 {
1074 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1075 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1076 .name = "wcnss_wlanrx_irq",
1077 .flags = IORESOURCE_IRQ,
1078 },
1079 {
1080 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1081 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1082 .name = "wcnss_wlantx_irq",
1083 .flags = IORESOURCE_IRQ,
1084 },
1085 {
1086 .start = MSM_WCNSS_PHYS,
1087 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1088 .name = "wcnss_mmio",
1089 .flags = IORESOURCE_MEM,
1090 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001091 {
1092 .start = 84,
1093 .end = 88,
1094 .name = "wcnss_gpios_5wire",
1095 .flags = IORESOURCE_IO,
1096 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001097};
1098
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001099static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1100 .has_48mhz_xo = 1,
1101};
1102
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001103static struct platform_device msm_device_wcnss_wlan = {
1104 .name = "wcnss_wlan",
1105 .id = 0,
1106 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1107 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001108 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001109};
1110
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001111#ifdef CONFIG_QSEECOM
1112/* qseecom bus scaling */
1113static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1114 {
1115 .src = MSM_BUS_MASTER_SPS,
1116 .dst = MSM_BUS_SLAVE_EBI_CH0,
1117 .ib = 0,
1118 .ab = 0,
1119 },
1120 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001121 .src = MSM_BUS_MASTER_SPS,
1122 .dst = MSM_BUS_SLAVE_SPS,
1123 .ib = 0,
1124 .ab = 0,
1125 },
1126 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001127 .src = MSM_BUS_MASTER_SPDM,
1128 .dst = MSM_BUS_SLAVE_SPDM,
1129 .ib = 0,
1130 .ab = 0,
1131 },
1132};
1133
1134static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1135 {
1136 .src = MSM_BUS_MASTER_SPS,
1137 .dst = MSM_BUS_SLAVE_EBI_CH0,
1138 .ib = (492 * 8) * 1000000UL,
1139 .ab = (492 * 8) * 100000UL,
1140 },
1141 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001142 .src = MSM_BUS_MASTER_SPS,
1143 .dst = MSM_BUS_SLAVE_SPS,
1144 .ib = (492 * 8) * 1000000UL,
1145 .ab = (492 * 8) * 100000UL,
1146 },
1147 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001148 .src = MSM_BUS_MASTER_SPDM,
1149 .dst = MSM_BUS_SLAVE_SPDM,
1150 .ib = 0,
1151 .ab = 0,
1152 },
1153};
1154
1155static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1156 {
1157 .src = MSM_BUS_MASTER_SPS,
1158 .dst = MSM_BUS_SLAVE_EBI_CH0,
1159 .ib = 0,
1160 .ab = 0,
1161 },
1162 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001163 .src = MSM_BUS_MASTER_SPS,
1164 .dst = MSM_BUS_SLAVE_SPS,
1165 .ib = 0,
1166 .ab = 0,
1167 },
1168 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001169 .src = MSM_BUS_MASTER_SPDM,
1170 .dst = MSM_BUS_SLAVE_SPDM,
1171 .ib = (64 * 8) * 1000000UL,
1172 .ab = (64 * 8) * 100000UL,
1173 },
1174};
1175
Ramesh Masavarapu8d756582012-10-03 10:18:06 -07001176static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1177 {
1178 .src = MSM_BUS_MASTER_SPS,
1179 .dst = MSM_BUS_SLAVE_EBI_CH0,
1180 .ib = (492 * 8) * 1000000UL,
1181 .ab = (492 * 8) * 100000UL,
1182 },
1183 {
1184 .src = MSM_BUS_MASTER_SPS,
1185 .dst = MSM_BUS_SLAVE_SPS,
1186 .ib = (492 * 8) * 1000000UL,
1187 .ab = (492 * 8) * 100000UL,
1188 },
1189 {
1190 .src = MSM_BUS_MASTER_SPDM,
1191 .dst = MSM_BUS_SLAVE_SPDM,
1192 .ib = (64 * 8) * 1000000UL,
1193 .ab = (64 * 8) * 100000UL,
1194 },
1195};
1196
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001197static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1198 {
1199 ARRAY_SIZE(qseecom_clks_init_vectors),
1200 qseecom_clks_init_vectors,
1201 },
1202 {
1203 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001204 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001205 },
1206 {
1207 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1208 qseecom_enable_sfpb_vectors,
1209 },
Ramesh Masavarapu8d756582012-10-03 10:18:06 -07001210 {
1211 ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1212 qseecom_enable_dfab_sfpb_vectors,
1213 },
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001214};
1215
1216static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1217 qseecom_hw_bus_scale_usecases,
1218 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1219 .name = "qsee",
1220};
1221
1222static struct platform_device qseecom_device = {
1223 .name = "qseecom",
1224 .id = 0,
1225 .dev = {
1226 .platform_data = &qseecom_bus_pdata,
1227 },
1228};
1229#endif
1230
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001231#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1232 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1233 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1234 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1235
1236#define QCE_SIZE 0x10000
1237#define QCE_0_BASE 0x18500000
1238
1239#define QCE_HW_KEY_SUPPORT 0
1240#define QCE_SHA_HMAC_SUPPORT 1
1241#define QCE_SHARE_CE_RESOURCE 1
1242#define QCE_CE_SHARED 0
1243
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001244/* Begin Bus scaling definitions */
1245static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1246 {
1247 .src = MSM_BUS_MASTER_ADM_PORT0,
1248 .dst = MSM_BUS_SLAVE_EBI_CH0,
1249 .ab = 0,
1250 .ib = 0,
1251 },
1252 {
1253 .src = MSM_BUS_MASTER_ADM_PORT1,
1254 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1255 .ab = 0,
1256 .ib = 0,
1257 },
1258};
1259
1260static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1261 {
1262 .src = MSM_BUS_MASTER_ADM_PORT0,
1263 .dst = MSM_BUS_SLAVE_EBI_CH0,
1264 .ab = 70000000UL,
1265 .ib = 70000000UL,
1266 },
1267 {
1268 .src = MSM_BUS_MASTER_ADM_PORT1,
1269 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1270 .ab = 2480000000UL,
1271 .ib = 2480000000UL,
1272 },
1273};
1274
1275static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1276 {
1277 ARRAY_SIZE(crypto_hw_init_vectors),
1278 crypto_hw_init_vectors,
1279 },
1280 {
1281 ARRAY_SIZE(crypto_hw_active_vectors),
1282 crypto_hw_active_vectors,
1283 },
1284};
1285
1286static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1287 crypto_hw_bus_scale_usecases,
1288 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1289 .name = "cryptohw",
1290};
1291/* End Bus Scaling Definitions*/
1292
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001293static struct resource qcrypto_resources[] = {
1294 [0] = {
1295 .start = QCE_0_BASE,
1296 .end = QCE_0_BASE + QCE_SIZE - 1,
1297 .flags = IORESOURCE_MEM,
1298 },
1299 [1] = {
1300 .name = "crypto_channels",
1301 .start = DMOV_CE_IN_CHAN,
1302 .end = DMOV_CE_OUT_CHAN,
1303 .flags = IORESOURCE_DMA,
1304 },
1305 [2] = {
1306 .name = "crypto_crci_in",
1307 .start = DMOV_CE_IN_CRCI,
1308 .end = DMOV_CE_IN_CRCI,
1309 .flags = IORESOURCE_DMA,
1310 },
1311 [3] = {
1312 .name = "crypto_crci_out",
1313 .start = DMOV_CE_OUT_CRCI,
1314 .end = DMOV_CE_OUT_CRCI,
1315 .flags = IORESOURCE_DMA,
1316 },
1317};
1318
1319static struct resource qcedev_resources[] = {
1320 [0] = {
1321 .start = QCE_0_BASE,
1322 .end = QCE_0_BASE + QCE_SIZE - 1,
1323 .flags = IORESOURCE_MEM,
1324 },
1325 [1] = {
1326 .name = "crypto_channels",
1327 .start = DMOV_CE_IN_CHAN,
1328 .end = DMOV_CE_OUT_CHAN,
1329 .flags = IORESOURCE_DMA,
1330 },
1331 [2] = {
1332 .name = "crypto_crci_in",
1333 .start = DMOV_CE_IN_CRCI,
1334 .end = DMOV_CE_IN_CRCI,
1335 .flags = IORESOURCE_DMA,
1336 },
1337 [3] = {
1338 .name = "crypto_crci_out",
1339 .start = DMOV_CE_OUT_CRCI,
1340 .end = DMOV_CE_OUT_CRCI,
1341 .flags = IORESOURCE_DMA,
1342 },
1343};
1344
1345#endif
1346
1347#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1348 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1349
1350static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1351 .ce_shared = QCE_CE_SHARED,
1352 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1353 .hw_key_support = QCE_HW_KEY_SUPPORT,
1354 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001355 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001356};
1357
1358static struct platform_device qcrypto_device = {
1359 .name = "qcrypto",
1360 .id = 0,
1361 .num_resources = ARRAY_SIZE(qcrypto_resources),
1362 .resource = qcrypto_resources,
1363 .dev = {
1364 .coherent_dma_mask = DMA_BIT_MASK(32),
1365 .platform_data = &qcrypto_ce_hw_suppport,
1366 },
1367};
1368#endif
1369
1370#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1371 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1372
1373static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1374 .ce_shared = QCE_CE_SHARED,
1375 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1376 .hw_key_support = QCE_HW_KEY_SUPPORT,
1377 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001378 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001379};
1380
1381static struct platform_device qcedev_device = {
1382 .name = "qce",
1383 .id = 0,
1384 .num_resources = ARRAY_SIZE(qcedev_resources),
1385 .resource = qcedev_resources,
1386 .dev = {
1387 .coherent_dma_mask = DMA_BIT_MASK(32),
1388 .platform_data = &qcedev_ce_hw_suppport,
1389 },
1390};
1391#endif
1392
Joel King0cbf5d82012-05-24 15:21:38 -07001393static struct mdm_platform_data sglte_platform_data = {
1394 .mdm_version = "4.0",
1395 .ramdump_delay_ms = 1000,
Joel King63ce8332012-06-01 09:59:26 -07001396 .soft_reset_inverted = 1,
Joel King0cbf5d82012-05-24 15:21:38 -07001397 .peripheral_platform_device = NULL,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001398 .ramdump_timeout_ms = 600000,
Ameya Thakura98bde52012-06-28 18:55:19 -07001399 .no_powerdown_after_ramdumps = 1,
Ameya Thakur43248fd2012-07-10 18:50:52 -07001400 .image_upgrade_supported = 1,
Joel Kingb8352a12011-11-15 18:46:24 -08001401};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001402
Joel Nider266a2642011-10-16 10:58:05 +02001403#define MSM_TSIF0_PHYS (0x18200000)
1404#define MSM_TSIF1_PHYS (0x18201000)
1405#define MSM_TSIF_SIZE (0x200)
1406#define MSM_TSPP_PHYS (0x18202000)
1407#define MSM_TSPP_SIZE (0x1000)
1408#define MSM_TSPP_BAM_PHYS (0x18204000)
1409#define MSM_TSPP_BAM_SIZE (0x2000)
1410
1411#define TSIF_0_CLK GPIO_CFG(75, 1, GPIO_CFG_INPUT, \
1412 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1413#define TSIF_0_EN GPIO_CFG(76, 1, GPIO_CFG_INPUT, \
1414 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1415#define TSIF_0_DATA GPIO_CFG(77, 1, GPIO_CFG_INPUT, \
1416 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1417#define TSIF_0_SYNC GPIO_CFG(82, 1, GPIO_CFG_INPUT, \
1418 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1419#define TSIF_1_CLK GPIO_CFG(79, 1, GPIO_CFG_INPUT, \
1420 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1421#define TSIF_1_EN GPIO_CFG(80, 1, GPIO_CFG_INPUT, \
1422 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1423#define TSIF_1_DATA GPIO_CFG(81, 1, GPIO_CFG_INPUT, \
1424 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1425#define TSIF_1_SYNC GPIO_CFG(78, 1, GPIO_CFG_INPUT, \
1426 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1427
1428static const struct msm_gpio tsif_gpios[] = {
1429 { .gpio_cfg = TSIF_0_CLK, .label = "tsif0_clk", },
1430 { .gpio_cfg = TSIF_0_EN, .label = "tsif0_en", },
1431 { .gpio_cfg = TSIF_0_DATA, .label = "tsif0_data", },
1432 { .gpio_cfg = TSIF_0_SYNC, .label = "tsif0_sync", },
1433 { .gpio_cfg = TSIF_1_CLK, .label = "tsif1_clk", },
1434 { .gpio_cfg = TSIF_1_EN, .label = "tsif1_en", },
1435 { .gpio_cfg = TSIF_1_DATA, .label = "tsif1_data", },
1436 { .gpio_cfg = TSIF_1_SYNC, .label = "tsif1_sync", },
1437};
1438
1439static struct resource tspp_resources[] = {
1440 [0] = {
1441 .flags = IORESOURCE_IRQ,
1442 .start = TSIF_TSPP_IRQ,
1443 .end = TSIF1_IRQ,
1444 },
1445 [1] = {
1446 .flags = IORESOURCE_MEM,
1447 .start = MSM_TSIF0_PHYS,
1448 .end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
1449 },
1450 [2] = {
1451 .flags = IORESOURCE_MEM,
1452 .start = MSM_TSIF1_PHYS,
1453 .end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
1454 },
1455 [3] = {
1456 .flags = IORESOURCE_MEM,
1457 .start = MSM_TSPP_PHYS,
1458 .end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
1459 },
1460 [4] = {
1461 .flags = IORESOURCE_MEM,
1462 .start = MSM_TSPP_BAM_PHYS,
1463 .end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
1464 },
1465};
1466
1467static struct msm_tspp_platform_data tspp_platform_data = {
1468 .num_gpios = ARRAY_SIZE(tsif_gpios),
1469 .gpios = tsif_gpios,
1470 .tsif_pclk = "tsif_pclk",
1471 .tsif_ref_clk = "tsif_ref_clk",
1472};
1473
1474static struct platform_device msm_device_tspp = {
1475 .name = "msm_tspp",
1476 .id = 0,
1477 .num_resources = ARRAY_SIZE(tspp_resources),
1478 .resource = tspp_resources,
1479 .dev = {
1480 .platform_data = &tspp_platform_data
1481 },
1482};
1483
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001484#define MSM_SHARED_RAM_PHYS 0x80000000
1485
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001486static void __init msm8960_map_io(void)
1487{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001488 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001489 msm_map_msm8960_io();
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001490 if (IS_ERR_OR_NULL(socinfo_init()))
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001491 pr_err("socinfo_init() failed!\n");
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001492
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001493}
1494
1495static void __init msm8960_init_irq(void)
1496{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001497 struct msm_mpm_device_data *data = NULL;
1498
1499#ifdef CONFIG_MSM_MPM
1500 data = &msm8960_mpm_dev_data;
1501#endif
1502
1503 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001504 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001505 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001506}
1507
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001508static void __init msm8960_init_buses(void)
1509{
1510#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001511 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001512 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1513 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
Gagan Macae154c4b2011-10-05 19:24:43 -06001514 msm_bus_apps_fabric.dev.platform_data =
1515 &msm_bus_8960_apps_fabric_pdata;
1516 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
Gagan Mac680bfc02012-07-19 19:11:00 -06001517 if (cpu_is_msm8960ab()) {
1518 msm_bus_8960_sg_mm_fabric_pdata.rpm_enabled = 1;
1519 msm_bus_mm_fabric.dev.platform_data =
1520 &msm_bus_8960_sg_mm_fabric_pdata;
1521 } else {
1522 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1523 msm_bus_mm_fabric.dev.platform_data =
1524 &msm_bus_8960_mm_fabric_pdata;
1525 }
Gagan Macae154c4b2011-10-05 19:24:43 -06001526 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1527 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001528#endif
1529}
1530
1531static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1532 .max_clock_speed = 15060000,
Kiran Gundac5fbd7f2012-07-30 13:22:39 +05301533 .infinite_mode = 0xFFC0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001534};
1535
1536#ifdef CONFIG_USB_MSM_OTG_72K
1537static struct msm_otg_platform_data msm_otg_pdata;
1538#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301539static int wr_phy_init_seq[] = {
1540 0x44, 0x80, /* set VBUS valid threshold
1541 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301542 0x68, 0x81, /* update DC voltage level */
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301543 0x14, 0x82, /* set preemphasis and rise/fall time */
1544 0x13, 0x83, /* set source impedance adjusment */
1545 -1};
1546
1547static int liquid_v1_phy_init_seq[] = {
1548 0x44, 0x80,/* set VBUS valid threshold
1549 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301550 0x6C, 0x81,/* update DC voltage level */
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301551 0x18, 0x82,/* set preemphasis and rise/fall time */
1552 0x23, 0x83,/* set source impedance sdjusment */
1553 -1};
1554
Mayank Ranaa61da7a2012-08-14 10:57:00 +05301555static int sglte_phy_init_seq[] = {
1556 0x44, 0x80, /* set VBUS valid threshold
1557 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301558 0x6A, 0x81, /* update DC voltage level */
Mayank Ranaa61da7a2012-08-14 10:57:00 +05301559 0x24, 0x82, /* set preemphasis and rise/fall time */
1560 0x13, 0x83, /* set source impedance adjusment */
1561 -1};
1562
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301563#ifdef CONFIG_MSM_BUS_SCALING
1564/* Bandwidth requests (zero) if no vote placed */
1565static struct msm_bus_vectors usb_init_vectors[] = {
1566 {
1567 .src = MSM_BUS_MASTER_SPS,
1568 .dst = MSM_BUS_SLAVE_EBI_CH0,
1569 .ab = 0,
1570 .ib = 0,
1571 },
1572};
1573
1574/* Bus bandwidth requests in Bytes/sec */
1575static struct msm_bus_vectors usb_max_vectors[] = {
1576 {
1577 .src = MSM_BUS_MASTER_SPS,
1578 .dst = MSM_BUS_SLAVE_EBI_CH0,
1579 .ab = 60000000, /* At least 480Mbps on bus. */
1580 .ib = 960000000, /* MAX bursts rate */
1581 },
1582};
1583
1584static struct msm_bus_paths usb_bus_scale_usecases[] = {
1585 {
1586 ARRAY_SIZE(usb_init_vectors),
1587 usb_init_vectors,
1588 },
1589 {
1590 ARRAY_SIZE(usb_max_vectors),
1591 usb_max_vectors,
1592 },
1593};
1594
1595static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1596 usb_bus_scale_usecases,
1597 ARRAY_SIZE(usb_bus_scale_usecases),
1598 .name = "usb",
1599};
1600#endif
1601
Jack Pham87f202f2012-08-06 00:24:22 -07001602#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
1603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001604static struct msm_otg_platform_data msm_otg_pdata = {
1605 .mode = USB_OTG,
1606 .otg_control = OTG_PMIC_CONTROL,
1607 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001608 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301609 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301610#ifdef CONFIG_MSM_BUS_SCALING
1611 .bus_scale_table = &usb_bus_scale_pdata,
Jack Pham87f202f2012-08-06 00:24:22 -07001612 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301613#endif
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +05301614#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
1615 .mhl_dev_name = "sii8334",
1616#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001617};
1618#endif
1619
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301620#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301621#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301622static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1623 .strobe = 150,
1624 .data = 151,
1625};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301626
1627static struct smsc_hub_platform_data hsic_hub_pdata = {
1628 .hub_reset = HSIC_HUB_RESET_GPIO,
1629};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301630#else
1631static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301632static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301633#endif
1634
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301635static struct platform_device smsc_hub_device = {
1636 .name = "msm_smsc_hub",
1637 .id = -1,
1638 .dev = {
1639 .platform_data = &hsic_hub_pdata,
1640 },
1641};
1642
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001643#define PID_MAGIC_ID 0x71432909
1644#define SERIAL_NUM_MAGIC_ID 0x61945374
1645#define SERIAL_NUMBER_LENGTH 127
1646#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1647
1648struct magic_num_struct {
1649 uint32_t pid;
1650 uint32_t serial_num;
1651};
1652
1653struct dload_struct {
1654 uint32_t reserved1;
1655 uint32_t reserved2;
1656 uint32_t reserved3;
1657 uint16_t reserved4;
1658 uint16_t pid;
1659 char serial_number[SERIAL_NUMBER_LENGTH];
1660 uint16_t reserved5;
1661 struct magic_num_struct magic_struct;
1662};
1663
1664static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1665{
1666 struct dload_struct __iomem *dload = 0;
1667
1668 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1669 if (!dload) {
1670 pr_err("%s: cannot remap I/O memory region: %08x\n",
1671 __func__, DLOAD_USB_BASE_ADD);
1672 return -ENXIO;
1673 }
1674
1675 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1676 __func__, dload, pid, snum);
1677 /* update pid */
1678 dload->magic_struct.pid = PID_MAGIC_ID;
1679 dload->pid = pid;
1680
1681 /* update serial number */
1682 dload->magic_struct.serial_num = 0;
1683 if (!snum) {
1684 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1685 goto out;
1686 }
1687
1688 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001689 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001690out:
1691 iounmap(dload);
1692 return 0;
1693}
1694
1695static struct android_usb_platform_data android_usb_pdata = {
1696 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1697};
1698
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001699static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001700 .name = "android_usb",
1701 .id = -1,
1702 .dev = {
1703 .platform_data = &android_usb_pdata,
1704 },
1705};
1706
1707static uint8_t spm_wfi_cmd_sequence[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001708 0x03, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001709};
1710
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001711static uint8_t spm_retention_cmd_sequence[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001712 0x00, 0x05, 0x03, 0x0D,
1713 0x0B, 0x00, 0x0f,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001714};
1715
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001716static uint8_t spm_power_collapse_without_rpm[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001717 0x00, 0x24, 0x54, 0x10,
1718 0x09, 0x03, 0x01,
1719 0x10, 0x54, 0x30, 0x0C,
1720 0x24, 0x30, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001721};
1722
1723static uint8_t spm_power_collapse_with_rpm[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001724 0x00, 0x24, 0x54, 0x10,
1725 0x09, 0x07, 0x01, 0x0B,
1726 0x10, 0x54, 0x30, 0x0C,
1727 0x24, 0x30, 0x0f,
1728};
1729
1730/* 8960AB has a different command to assert apc_pdn */
1731static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
1732 0x00, 0x24, 0x84, 0x10,
1733 0x09, 0x03, 0x01,
1734 0x10, 0x84, 0x30, 0x0C,
1735 0x24, 0x30, 0x0f,
1736};
1737
1738static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
1739 0x00, 0x24, 0x84, 0x10,
1740 0x09, 0x07, 0x01, 0x0B,
1741 0x10, 0x84, 0x30, 0x0C,
1742 0x24, 0x30, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001743};
1744
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001745static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1746 [0] = {
1747 .mode = MSM_SPM_MODE_CLOCK_GATING,
1748 .notify_rpm = false,
1749 .cmd = spm_wfi_cmd_sequence,
1750 },
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001751 [1] = {
1752 .mode = MSM_SPM_MODE_POWER_RETENTION,
1753 .notify_rpm = false,
1754 .cmd = spm_retention_cmd_sequence,
1755 },
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001756 [2] = {
1757 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1758 .notify_rpm = false,
1759 .cmd = spm_power_collapse_without_rpm,
1760 },
1761 [3] = {
1762 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1763 .notify_rpm = true,
1764 .cmd = spm_power_collapse_with_rpm,
1765 },
1766};
1767
1768static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001769 [0] = {
1770 .mode = MSM_SPM_MODE_CLOCK_GATING,
1771 .notify_rpm = false,
1772 .cmd = spm_wfi_cmd_sequence,
1773 },
1774 [1] = {
1775 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1776 .notify_rpm = false,
1777 .cmd = spm_power_collapse_without_rpm,
1778 },
1779 [2] = {
1780 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1781 .notify_rpm = true,
1782 .cmd = spm_power_collapse_with_rpm,
1783 },
1784};
1785
1786static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1787 [0] = {
1788 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001789 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001790#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnala39dd7252012-11-26 15:56:26 +05301791 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaram631f2822012-03-16 12:08:42 -06001792 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001793#endif
1794 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001795 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1796 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1797 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001799 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1800 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001801 },
1802 [1] = {
1803 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001804 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnala39dd7252012-11-26 15:56:26 +05301806 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaram631f2822012-03-16 12:08:42 -06001807 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001808#endif
1809 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001810 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001811 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1812 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1813 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001814 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1815 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001816 },
1817};
1818
1819static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1820 0x00, 0x20, 0x03, 0x20,
1821 0x00, 0x0f,
1822};
1823
1824static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1825 0x00, 0x20, 0x34, 0x64,
1826 0x48, 0x07, 0x48, 0x20,
1827 0x50, 0x64, 0x04, 0x34,
1828 0x50, 0x0f,
1829};
1830static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1831 0x00, 0x10, 0x34, 0x64,
1832 0x48, 0x07, 0x48, 0x10,
1833 0x50, 0x64, 0x04, 0x34,
1834 0x50, 0x0F,
1835};
1836
1837static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1838 [0] = {
1839 .mode = MSM_SPM_L2_MODE_RETENTION,
1840 .notify_rpm = false,
1841 .cmd = l2_spm_wfi_cmd_sequence,
1842 },
1843 [1] = {
1844 .mode = MSM_SPM_L2_MODE_GDHS,
1845 .notify_rpm = true,
1846 .cmd = l2_spm_gdhs_cmd_sequence,
1847 },
1848 [2] = {
1849 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1850 .notify_rpm = true,
1851 .cmd = l2_spm_power_off_cmd_sequence,
1852 },
1853};
1854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001855static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1856 [0] = {
1857 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001858 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001859 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001860 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1861 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1862 .modes = msm_spm_l2_seq_list,
1863 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1864 },
1865};
1866
Anirudh Ghayal15698162012-07-31 11:51:32 +05301867#define HAP_SHIFT_LVL_OE_GPIO 47
1868#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301869#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1870#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1871
1872static struct msm_xo_voter *xo_handle_d1;
1873
1874static int isa1200_power(int on)
1875{
1876 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301877 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301878
Anirudh Ghayal15698162012-07-31 11:51:32 +05301879 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1880 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1881
1882
1883 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301884
1885 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1886 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1887 if (rc < 0) {
1888 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1889 __func__, on ? "" : "de-", rc);
1890 goto err_xo_vote;
1891 }
1892
1893 return 0;
1894
1895err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301896 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301897 return rc;
1898}
1899
1900static int isa1200_dev_setup(bool enable)
1901{
1902 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301903 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301904
1905 struct pm_gpio hap_gpio_config = {
1906 .direction = PM_GPIO_DIR_OUT,
1907 .pull = PM_GPIO_PULL_NO,
1908 .out_strength = PM_GPIO_STRENGTH_HIGH,
1909 .function = PM_GPIO_FUNC_NORMAL,
1910 .inv_int_pol = 0,
1911 .vin_sel = 2,
1912 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1913 .output_value = 0,
1914 };
1915
Anirudh Ghayal15698162012-07-31 11:51:32 +05301916 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1917 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1918
Mohan Pallaka5e490392011-09-09 15:18:41 +05301919 if (enable == true) {
1920 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1921 if (rc) {
1922 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1923 __func__, PM_HAP_EN_GPIO, rc);
1924 return rc;
1925 }
1926
1927 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1928 if (rc) {
1929 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1930 __func__, PM_HAP_LEN_GPIO, rc);
1931 return rc;
1932 }
1933
Anirudh Ghayal15698162012-07-31 11:51:32 +05301934 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301935 if (rc) {
1936 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301937 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301938 return rc;
1939 }
1940
Anirudh Ghayal15698162012-07-31 11:51:32 +05301941 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301942 if (rc) {
1943 pr_err("%s: Unable to set direction\n", __func__);
1944 goto free_gpio;
1945 }
1946
1947 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1948 if (IS_ERR(xo_handle_d1)) {
1949 rc = PTR_ERR(xo_handle_d1);
1950 pr_err("%s: failed to get the handle for D1(%d)\n",
1951 __func__, rc);
1952 goto gpio_set_dir;
1953 }
1954 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05301955 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301956
1957 msm_xo_put(xo_handle_d1);
1958 }
1959
1960 return 0;
1961
1962gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301963 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301964free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301965 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301966 return rc;
1967}
1968
1969static struct isa1200_regulator isa1200_reg_data[] = {
1970 {
1971 .name = "vcc_i2c",
1972 .min_uV = ISA_I2C_VTG_MIN_UV,
1973 .max_uV = ISA_I2C_VTG_MAX_UV,
1974 .load_uA = ISA_I2C_CURR_UA,
1975 },
1976};
1977
1978static struct isa1200_platform_data isa1200_1_pdata = {
1979 .name = "vibrator",
1980 .dev_setup = isa1200_dev_setup,
1981 .power_on = isa1200_power,
1982 .hap_en_gpio = PM_HAP_EN_GPIO,
1983 .hap_len_gpio = PM_HAP_LEN_GPIO,
1984 .max_timeout = 15000,
1985 .mode_ctrl = PWM_GEN_MODE,
1986 .pwm_fd = {
1987 .pwm_div = 256,
1988 },
1989 .is_erm = false,
1990 .smart_en = true,
1991 .ext_clk_en = true,
1992 .chip_en = 1,
1993 .regulator_info = isa1200_reg_data,
1994 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1995};
1996
1997static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
1998 {
1999 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05302000 },
2001};
2002
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002003#define CYTTSP_TS_GPIO_IRQ 11
2004#define CYTTSP_TS_SLEEP_GPIO 50
2005#define CYTTSP_TS_RESOUT_N_GPIO 52
2006
2007/*virtual key support */
2008static ssize_t tma340_vkeys_show(struct kobject *kobj,
2009 struct kobj_attribute *attr, char *buf)
2010{
2011 return snprintf(buf, 200,
2012 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2013 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2014 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2015 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2016 "\n");
2017}
2018
2019static struct kobj_attribute tma340_vkeys_attr = {
2020 .attr = {
2021 .mode = S_IRUGO,
2022 },
2023 .show = &tma340_vkeys_show,
2024};
2025
2026static struct attribute *tma340_properties_attrs[] = {
2027 &tma340_vkeys_attr.attr,
2028 NULL
2029};
2030
2031static struct attribute_group tma340_properties_attr_group = {
2032 .attrs = tma340_properties_attrs,
2033};
2034
2035
2036static int cyttsp_platform_init(struct i2c_client *client)
2037{
2038 int rc = 0;
2039 static struct kobject *tma340_properties_kobj;
2040
2041 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2042 tma340_properties_kobj = kobject_create_and_add("board_properties",
2043 NULL);
2044 if (tma340_properties_kobj)
2045 rc = sysfs_create_group(tma340_properties_kobj,
2046 &tma340_properties_attr_group);
2047 if (!tma340_properties_kobj || rc)
2048 pr_err("%s: failed to create board_properties\n",
2049 __func__);
2050
2051 return 0;
2052}
2053
2054static struct cyttsp_regulator regulator_data[] = {
2055 {
2056 .name = "vdd",
2057 .min_uV = CY_TMA300_VTG_MIN_UV,
2058 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302059 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
2060 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002061 },
2062 /* TODO: Remove after runtime PM is enabled in I2C driver */
2063 {
2064 .name = "vcc_i2c",
2065 .min_uV = CY_I2C_VTG_MIN_UV,
2066 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302067 .hpm_load_uA = CY_I2C_CURR_UA,
2068 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002069 },
2070};
2071
2072static struct cyttsp_platform_data cyttsp_pdata = {
2073 .panel_maxx = 634,
2074 .panel_maxy = 1166,
2075 .disp_maxx = 616,
2076 .disp_maxy = 1023,
2077 .disp_minx = 0,
2078 .disp_miny = 16,
2079 .flags = 0x01,
2080 .gen = CY_GEN3, /* or */
2081 .use_st = CY_USE_ST,
2082 .use_mt = CY_USE_MT,
2083 .use_hndshk = CY_SEND_HNDSHK,
2084 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302085 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002086 .use_gestures = CY_USE_GESTURES,
2087 .fw_fname = "cyttsp_8960_cdp.hex",
2088 /* activate up to 4 groups
2089 * and set active distance
2090 */
2091 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2092 CY_GEST_GRP3 | CY_GEST_GRP4 |
2093 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07002094 .act_intrvl = 10,
2095 .tch_tmout = 200,
2096 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002097 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2098 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2099 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2100 .regulator_info = regulator_data,
2101 .num_regulators = ARRAY_SIZE(regulator_data),
2102 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302103 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002104};
2105
2106static struct i2c_board_info cyttsp_info[] __initdata = {
2107 {
2108 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2109 .platform_data = &cyttsp_pdata,
2110#ifndef CY_USE_TIMER
2111 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2112#endif /* CY_USE_TIMER */
2113 },
2114};
2115
Jing Lindc4413c2012-01-16 15:22:52 -08002116/* configuration data for mxt1386 */
2117static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302118 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002119 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302120 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002121 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002122 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2123 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2126 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2127 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302128 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002129 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302130 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002131 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302132 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002133 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2134 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2135 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2136 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302137 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2139 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302140 /* T18 Object */
2141 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302142 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002143 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2144 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302145 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2147 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302148 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002149 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2150 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302151 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002152 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302153 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002154 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302155 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002156 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302157 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002158 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302159 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002160 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302161};
2162
Jing Lin33b007d2011-12-21 17:40:23 -08002163/* configuration data for mxt1386e using V1.0 firmware */
2164static const u8 mxt1386e_config_data_v1_0[] = {
2165 /* T6 Object */
2166 0, 0, 0, 0, 0, 0,
2167 /* T38 Object */
2168 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2174 0, 0, 0, 0,
2175 /* T7 Object */
2176 100, 16, 50,
2177 /* T8 Object */
2178 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2179 /* T9 Object */
2180 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2181 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2182 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2183 10, 5, 0, 0, 0,
2184 /* T18 Object */
2185 0, 0,
2186 /* T24 Object */
2187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2188 0, 0, 0, 0, 0, 0, 0, 0, 0,
2189 /* T25 Object */
2190 3, 0, 60, 115, 156, 99,
2191 /* T27 Object */
2192 0, 0, 0, 0, 0, 0, 0,
2193 /* T40 Object */
2194 0, 0, 0, 0, 0,
2195 /* T42 Object */
2196 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2197 /* T43 Object */
2198 0, 0, 0, 0, 0, 0, 0,
2199 /* T46 Object */
2200 64, 0, 20, 20, 0, 0, 0, 0, 0,
2201 /* T47 Object */
2202 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2203 /* T48 Object */
2204 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2205 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2206 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2207 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2209 0, 0, 0, 0,
2210 /* T56 Object */
2211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2215 2, 99, 33,
2216};
2217
2218/* configuration data for mxt1386e using V2.1 firmware */
2219static const u8 mxt1386e_config_data_v2_1[] = {
2220 /* T6 Object */
2221 0, 0, 0, 0, 0, 0,
2222 /* T38 Object */
Jing Lin4a8a3e42012-09-12 10:08:22 -07002223 12, 5, 0, 28, 8, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2229 0, 0, 0, 0,
2230 /* T7 Object */
Jing Lin4a8a3e42012-09-12 10:08:22 -07002231 32, 16, 50,
Jing Lin33b007d2011-12-21 17:40:23 -08002232 /* T8 Object */
2233 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2234 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002235 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002236 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002237 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2238 10, 5, 0, 0, 0,
2239 /* T18 Object */
2240 0, 0,
2241 /* T24 Object */
2242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2243 0, 0, 0, 0, 0, 0, 0, 0, 0,
2244 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002245 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002246 /* T27 Object */
2247 0, 0, 0, 0, 0, 0, 0,
2248 /* T40 Object */
2249 0, 0, 0, 0, 0,
2250 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002251 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002252 /* T43 Object */
2253 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2254 16,
2255 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002256 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002257 /* T47 Object */
2258 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2259 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002260 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002261 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2262 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2263 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2265 0, 0, 0, 0,
2266 /* T56 Object */
2267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2271 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2272 255,
2273};
2274
Jing Lineec88ca2012-02-08 11:18:30 -08002275/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2276static const u8 mxt1386e_config_data_3d[] = {
2277 /* T6 Object */
2278 0, 0, 0, 0, 0, 0,
2279 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002280 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2286 0, 0, 0, 0,
2287 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002288 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002289 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002290 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002291 /* T9 Object */
2292 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2293 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002294 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2295 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002296 /* T18 Object */
2297 0, 0,
2298 /* T24 Object */
2299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2300 0, 0, 0, 0, 0, 0, 0, 0, 0,
2301 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002302 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002303 /* T27 Object */
2304 0, 0, 0, 0, 0, 0, 0,
2305 /* T40 Object */
2306 0, 0, 0, 0, 0,
2307 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002308 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002309 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002310 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2311 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002312 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002313 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002314 /* T47 Object */
2315 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2316 /* T48 Object */
2317 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002318 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2319 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2320 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2322 0, 0, 0, 0,
2323 /* T56 Object */
2324 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2325 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2326 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2327 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002328 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2329 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002330};
2331
Amy Maloche08266db2011-11-04 11:07:16 -07002332#define MXT_TS_GPIO_IRQ 11
2333#define MXT_TS_LDO_EN_GPIO 50
2334#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302335
2336static void mxt_init_hw_liquid(void)
2337{
2338 int rc;
2339
Mohan Pallaka50837382011-09-07 11:00:57 +05302340 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2341 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002342 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2343 __func__, MXT_TS_LDO_EN_GPIO);
2344 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302345 }
2346
2347 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2348 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002349 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2350 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302351 goto err_ldo_gpio_req;
2352 }
2353
Mohan Pallaka50837382011-09-07 11:00:57 +05302354 return;
2355
Mohan Pallaka50837382011-09-07 11:00:57 +05302356err_ldo_gpio_req:
2357 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302358}
2359
Jing Lineec88ca2012-02-08 11:18:30 -08002360static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002361 {
2362 .config = mxt1386_config_data,
2363 .config_length = ARRAY_SIZE(mxt1386_config_data),
2364 .family_id = 0xA0,
2365 .variant_id = 0x0,
2366 .version = 0x10,
2367 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002368 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002369 },
Jing Lin33b007d2011-12-21 17:40:23 -08002370 {
2371 .config = mxt1386e_config_data_v1_0,
2372 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2373 .family_id = 0xA0,
2374 .variant_id = 0x2,
2375 .version = 0x10,
2376 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002377 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002378 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002379 },
2380 {
2381 .config = mxt1386e_config_data_v2_1,
2382 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2383 .family_id = 0xA0,
2384 .variant_id = 0x7,
2385 .version = 0x21,
2386 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002387 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002388 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2389 },
2390 {
2391 /* The config data for V2.2.AA is the same as for V2.1.AA */
2392 .config = mxt1386e_config_data_v2_1,
2393 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2394 .family_id = 0xA0,
2395 .variant_id = 0x7,
2396 .version = 0x22,
2397 .build = 0xAA,
2398 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002399 },
Jing Lindc4413c2012-01-16 15:22:52 -08002400};
2401
Jing Lineec88ca2012-02-08 11:18:30 -08002402static struct mxt_platform_data mxt_platform_data_2d = {
2403 .config_array = mxt_config_array_2d,
2404 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002405 .panel_minx = 0,
2406 .panel_maxx = 1365,
2407 .panel_miny = 0,
2408 .panel_maxy = 767,
2409 .disp_minx = 0,
2410 .disp_maxx = 1365,
2411 .disp_miny = 0,
2412 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302413 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002414 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002415 .reset_gpio = MXT_TS_RESET_GPIO,
2416 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302417};
2418
Jing Lineec88ca2012-02-08 11:18:30 -08002419static struct mxt_config_info mxt_config_array_3d[] = {
2420 {
2421 .config = mxt1386e_config_data_3d,
2422 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2423 .family_id = 0xA0,
2424 .variant_id = 0x7,
2425 .version = 0x21,
2426 .build = 0xAA,
2427 },
2428};
2429
2430static struct mxt_platform_data mxt_platform_data_3d = {
2431 .config_array = mxt_config_array_3d,
2432 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002433 .panel_minx = 0,
2434 .panel_maxx = 1919,
2435 .panel_miny = 0,
2436 .panel_maxy = 1199,
2437 .disp_minx = 0,
2438 .disp_maxx = 1919,
2439 .disp_miny = 0,
2440 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002441 .irqflags = IRQF_TRIGGER_FALLING,
2442 .i2c_pull_up = true,
2443 .reset_gpio = MXT_TS_RESET_GPIO,
2444 .irq_gpio = MXT_TS_GPIO_IRQ,
2445};
2446
Mohan Pallaka50837382011-09-07 11:00:57 +05302447static struct i2c_board_info mxt_device_info[] __initdata = {
2448 {
2449 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302450 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2451 },
2452};
2453
Manoj Rao14648742012-03-30 19:42:12 -07002454static struct msm_mhl_platform_data mhl_platform_data = {
2455 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002456 .gpio_mhl_int = MHL_GPIO_INT,
2457 .gpio_mhl_reset = MHL_GPIO_RESET,
2458 .gpio_mhl_power = 0,
2459 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002460};
Manoj Rao14648742012-03-30 19:42:12 -07002461
Eugene Yasmand2316b82011-12-07 18:23:48 +02002462static struct i2c_board_info sii_device_info[] __initdata = {
2463 {
Manoj Rao14648742012-03-30 19:42:12 -07002464#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2465 /*
2466 * keeps SI 8334 as the default
2467 * MHL TX
2468 */
2469 I2C_BOARD_INFO("sii8334", 0x39),
2470 .platform_data = &mhl_platform_data,
2471#endif
2472#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002473 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002474 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002475#endif /* CONFIG_MSM_HDMI_MHL */
2476 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002477 },
2478};
2479
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002480static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2481 .clk_freq = 100000,
2482 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002483};
2484
2485static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2486 .clk_freq = 100000,
2487 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002488};
2489
2490static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2491 .clk_freq = 100000,
2492 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002493};
2494
2495static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2496 .clk_freq = 100000,
2497 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002498};
2499
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002500static struct ks8851_pdata spi_eth_pdata = {
2501 .irq_gpio = KS8851_IRQ_GPIO,
2502 .rst_gpio = KS8851_RST_GPIO,
2503};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002504
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302505static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506 {
2507 .modalias = "ks8851",
2508 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2509 .max_speed_hz = 19200000,
2510 .bus_num = 0,
2511 .chip_select = 0,
2512 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002513 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002514 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302515};
2516static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002517 {
2518 .modalias = "dsi_novatek_3d_panel_spi",
2519 .max_speed_hz = 10800000,
2520 .bus_num = 0,
2521 .chip_select = 1,
2522 .mode = SPI_MODE_0,
2523 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002524};
2525
2526static struct platform_device msm_device_saw_core0 = {
2527 .name = "saw-regulator",
2528 .id = 0,
2529 .dev = {
2530 .platform_data = &msm_saw_regulator_pdata_s5,
2531 },
2532};
2533
2534static struct platform_device msm_device_saw_core1 = {
2535 .name = "saw-regulator",
2536 .id = 1,
2537 .dev = {
2538 .platform_data = &msm_saw_regulator_pdata_s6,
2539 },
2540};
2541
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002542static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002543 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002544 .tsens_factor = 1000,
2545 .hw_type = MSM_8960,
2546 .tsens_num_sensor = 5,
2547};
2548
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002549static struct platform_device msm_tsens_device = {
2550 .name = "tsens8960-tm",
2551 .id = -1,
2552};
2553
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002554static struct msm_thermal_data msm_thermal_pdata = {
2555 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002556 .poll_ms = 250,
2557 .limit_temp_degC = 60,
2558 .temp_hysteresis_degC = 10,
2559 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002560};
2561
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002562#ifdef CONFIG_MSM_FAKE_BATTERY
2563static struct platform_device fish_battery_device = {
2564 .name = "fish_battery",
2565};
2566#endif
2567
Binqiang Qiuf165c922012-08-15 18:00:18 -07002568#ifdef CONFIG_BATTERY_BCL
2569static struct platform_device battery_bcl_device = {
2570 .name = "battery_current_limit",
2571 .id = -1,
2572};
2573#endif
2574
David Collins26f05562011-06-20 09:56:28 -07002575static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002576 .name = GPIO_REGULATOR_DEV_NAME,
2577 .id = PM8921_MPP_PM_TO_SYS(7),
2578 .dev = {
2579 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2580 },
2581};
2582
David Collins26f05562011-06-20 09:56:28 -07002583static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002584 .name = GPIO_REGULATOR_DEV_NAME,
2585 .id = 91,
2586 .dev = {
2587 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2588 },
2589};
2590
David Collinsb10be1d2011-09-02 10:29:31 -07002591static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2592 .name = GPIO_REGULATOR_DEV_NAME,
2593 .id = PM8921_GPIO_PM_TO_SYS(17),
2594 .dev = {
2595 .platform_data =
2596 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2597 },
2598};
2599
David Collins35a78f52011-12-14 15:54:25 -08002600static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2601 .name = GPIO_REGULATOR_DEV_NAME,
2602 .id = PM8921_GPIO_PM_TO_SYS(42),
2603 .dev = {
2604 .platform_data =
2605 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2606 },
2607};
2608
David Collins26f05562011-06-20 09:56:28 -07002609static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2610 .name = "rpm-regulator",
2611 .id = -1,
2612 .dev = {
2613 .platform_data = &msm_rpm_regulator_pdata,
2614 },
2615};
Mayank Ranae009c922012-03-22 03:02:06 +05302616#ifdef CONFIG_SERIAL_MSM_HS
2617static int configure_uart_gpios(int on)
2618{
2619 int ret = 0, i;
2620 int uart_gpios[] = {93, 94, 95, 96};
2621
2622 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2623 if (on) {
2624 ret = gpio_request(uart_gpios[i], NULL);
2625 if (ret) {
2626 pr_err("%s: unable to request uart gpio[%d]\n",
2627 __func__, uart_gpios[i]);
2628 break;
2629 }
2630 } else {
2631 gpio_free(uart_gpios[i]);
2632 }
2633 }
2634
2635 if (ret && on && i)
2636 for (; i >= 0; i--)
2637 gpio_free(uart_gpios[i]);
2638 return ret;
2639}
2640
2641static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002642 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302643};
Mayank Rana1f02d952012-07-04 19:11:20 +05302644
2645static int configure_gsbi8_uart_gpios(int on)
2646{
2647 int ret = 0, i;
2648 int uart_gpios[] = {34, 35, 36, 37};
2649
2650 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2651 if (on) {
2652 ret = gpio_request(uart_gpios[i], NULL);
2653 if (ret) {
2654 pr_err("%s: unable to request uart gpio[%d]\n",
2655 __func__, uart_gpios[i]);
2656 break;
2657 }
2658 } else {
2659 gpio_free(uart_gpios[i]);
2660 }
2661 }
2662
2663 if (ret && on && i)
2664 for (; i >= 0; i--)
2665 gpio_free(uart_gpios[i]);
2666 return ret;
2667}
2668
2669static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
2670 .gpio_config = configure_gsbi8_uart_gpios,
2671};
Mayank Ranae009c922012-03-22 03:02:06 +05302672#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302673static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302674static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2675#endif
David Collins26f05562011-06-20 09:56:28 -07002676
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302677#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin9baad172012-10-17 11:50:15 +08002678enum WLANBT_STATUS {
2679 WLANOFF_BTOFF = 1,
2680 WLANOFF_BTON,
2681 WLANON_BTOFF,
2682 WLANON_BTON
2683};
2684
2685static DEFINE_MUTEX(ath_wlanbt_mutex);
2686static int gpio_wlan_sys_rest_en = 26;
2687static int ath_wlanbt_status = WLANOFF_BTOFF;
2688
2689static int ath6kl_power_control(int on)
2690{
2691 int rc;
2692
2693 if (on) {
2694 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2695 if (rc) {
2696 pr_err("%s: unable to request gpio %d (%d)\n",
2697 __func__, gpio_wlan_sys_rest_en, rc);
2698 return rc;
2699 }
2700 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2701 msleep(200);
2702 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2703 msleep(100);
2704 } else {
2705 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2706 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2707 msleep(100);
2708 gpio_free(gpio_wlan_sys_rest_en);
2709 }
2710 return 0;
2711};
2712
2713static int ath6kl_wlan_power(int on)
2714{
2715 int ret = 0;
2716
2717 mutex_lock(&ath_wlanbt_mutex);
2718 if (on) {
2719 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2720 ret = ath6kl_power_control(1);
2721 ath_wlanbt_status = WLANON_BTOFF;
2722 } else if (ath_wlanbt_status == WLANOFF_BTON)
2723 ath_wlanbt_status = WLANON_BTON;
2724 } else {
2725 if (ath_wlanbt_status == WLANON_BTOFF) {
2726 ret = ath6kl_power_control(0);
2727 ath_wlanbt_status = WLANOFF_BTOFF;
2728 } else if (ath_wlanbt_status == WLANON_BTON)
2729 ath_wlanbt_status = WLANOFF_BTON;
2730 }
2731 mutex_unlock(&ath_wlanbt_mutex);
2732 pr_debug("%s on= %d, wlan_status= %d\n",
2733 __func__, on, ath_wlanbt_status);
2734 return ret;
2735};
2736
2737static struct wifi_platform_data ath6kl_wifi_control = {
2738 .set_power = ath6kl_wlan_power,
2739};
2740
2741static struct platform_device msm_wlan_power_device = {
2742 .name = "ath6kl_power",
2743 .dev = {
2744 .platform_data = &ath6kl_wifi_control,
2745 },
2746};
2747
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302748static struct resource bluesleep_resources[] = {
2749 {
2750 .name = "gpio_host_wake",
2751 .start = 27,
2752 .end = 27,
2753 .flags = IORESOURCE_IO,
2754 },
2755 {
2756 .name = "gpio_ext_wake",
2757 .start = 29,
2758 .end = 29,
2759 .flags = IORESOURCE_IO,
2760 },
2761 {
2762 .name = "host_wake",
2763 .start = MSM_GPIO_TO_INT(27),
2764 .end = MSM_GPIO_TO_INT(27),
2765 .flags = IORESOURCE_IRQ,
2766 },
2767};
2768
2769static struct platform_device msm_bluesleep_device = {
2770 .name = "bluesleep",
2771 .id = -1,
2772 .num_resources = ARRAY_SIZE(bluesleep_resources),
2773 .resource = bluesleep_resources,
2774};
2775
2776static struct platform_device msm_bt_power_device = {
2777 .name = "bt_power",
2778};
2779
Ming-yi Lin9baad172012-10-17 11:50:15 +08002780static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302781
2782static int bluetooth_power(int on)
2783{
2784 int rc;
2785
Ming-yi Lin9baad172012-10-17 11:50:15 +08002786 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302787 if (on) {
Ming-yi Lin9baad172012-10-17 11:50:15 +08002788 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2789 ath6kl_power_control(1);
2790 ath_wlanbt_status = WLANOFF_BTON;
2791 } else if (ath_wlanbt_status == WLANON_BTOFF)
2792 ath_wlanbt_status = WLANON_BTON;
2793
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302794 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2795 if (rc) {
2796 pr_err("%s: unable to request gpio %d (%d)\n",
2797 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002798 mutex_unlock(&ath_wlanbt_mutex);
2799 return rc;
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302800 }
2801 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002802 msleep(20);
2803 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302804 msleep(100);
2805 } else {
2806 gpio_set_value(gpio_bt_sys_rest_en, 0);
2807 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2808 msleep(100);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002809 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302810
Ming-yi Lin9baad172012-10-17 11:50:15 +08002811 if (ath_wlanbt_status == WLANOFF_BTON) {
2812 ath6kl_power_control(0);
2813 ath_wlanbt_status = WLANOFF_BTOFF;
2814 } else if (ath_wlanbt_status == WLANON_BTON)
2815 ath_wlanbt_status = WLANON_BTOFF;
2816 }
2817 mutex_unlock(&ath_wlanbt_mutex);
2818 pr_debug("%s on= %d, wlan_status= %d\n",
2819 __func__, on, ath_wlanbt_status);
2820 return 0;
2821};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302822
2823static void __init bt_power_init(void)
2824{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302825 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302826 return;
Ming-yi Lin9baad172012-10-17 11:50:15 +08002827};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302828#else
2829#define bt_power_init(x) do {} while (0)
2830#endif
2831
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002832static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002833 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002834 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302835 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002836 &msm_device_saw_core0,
2837 &msm_device_saw_core1,
2838 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002839 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002840 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002841 &msm8960_device_qup_spi_gsbi1,
2842 &msm8960_device_qup_i2c_gsbi3,
2843 &msm8960_device_qup_i2c_gsbi4,
2844 &msm8960_device_qup_i2c_gsbi10,
2845#ifndef CONFIG_MSM_DSPS
2846 &msm8960_device_qup_i2c_gsbi12,
2847#endif
2848 &msm_slim_ctrl,
2849 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302850#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2851 &msm_bluesleep_device,
2852 &msm_bt_power_device,
Ming-yi Lin9baad172012-10-17 11:50:15 +08002853 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302854#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002855#if defined(CONFIG_QSEECOM)
2856 &qseecom_device,
2857#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002858#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2859 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2860 &qcrypto_device,
2861#endif
2862
2863#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2864 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2865 &qcedev_device,
2866#endif
2867#ifdef CONFIG_MSM_ROTATOR
2868 &msm_rotator_device,
2869#endif
2870 &msm_device_sps,
2871#ifdef CONFIG_MSM_FAKE_BATTERY
2872 &fish_battery_device,
2873#endif
Binqiang Qiuf165c922012-08-15 18:00:18 -07002874#ifdef CONFIG_BATTERY_BCL
2875 &battery_bcl_device,
2876#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002877 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002878#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002879#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002880 &msm8960_android_pmem_device,
2881 &msm8960_android_pmem_adsp_device,
2882 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002883#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002884#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002885 &msm_device_bam_dmux,
2886 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002887#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2888#ifdef CONFIG_MSM_USE_TSIF1
2889 &msm_device_tsif[1],
2890#else
2891 &msm_device_tsif[0],
2892#endif
2893#endif
Joel Nider266a2642011-10-16 10:58:05 +02002894 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002895#ifdef CONFIG_HW_RANDOM_MSM
2896 &msm_device_rng,
2897#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002898#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002899 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002900#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002901 &msm8960_rpm_device,
2902 &msm8960_rpm_log_device,
2903 &msm8960_rpm_stat_device,
Anji Jonnala93129922012-10-09 20:57:53 +05302904 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002905 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002906 &coresight_tpiu_device,
2907 &coresight_etb_device,
2908 &coresight_funnel_device,
2909 &coresight_etm0_device,
2910 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002911 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002912 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002913 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002914 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002915 &msm8960_device_ebi1_ch0_erp,
2916 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002917 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002918 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002919 &msm_tsens_device,
Anji Jonnala6c2b6852012-09-21 13:34:44 +05302920 &msm8960_pc_cntr,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002921};
2922
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002923static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002924 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002925 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002926 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002927 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002928 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002929 &msm8960_device_otg,
2930 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931 &msm_device_hsusb_host,
2932 &android_usb_device,
2933 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002934 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002935 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002936 &msm_pcm_routing,
2937 &msm_cpudai0,
2938 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002939 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002940 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002941 &msm_cpudai_hdmi_rx,
2942 &msm_cpudai_bt_rx,
2943 &msm_cpudai_bt_tx,
2944 &msm_cpudai_fm_rx,
2945 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002946 &msm_cpudai_auxpcm_rx,
2947 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002948 &msm_cpu_fe,
2949 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002950#ifdef CONFIG_MSM_GEMINI
2951 &msm8960_gemini_device,
2952#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07002953#ifdef CONFIG_MSM_MERCURY
2954 &msm8960_mercury_device,
2955#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002956 &msm_voice,
2957 &msm_voip,
2958 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302959 &msm_cpudai_afe_01_rx,
2960 &msm_cpudai_afe_01_tx,
2961 &msm_cpudai_afe_02_rx,
2962 &msm_cpudai_afe_02_tx,
2963 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05302964 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07002965 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07002966 &msm_cpudai_incall_record_rx,
2967 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002968 &msm_pcm_hostless,
2969 &msm_bus_apps_fabric,
2970 &msm_bus_sys_fabric,
2971 &msm_bus_mm_fabric,
2972 &msm_bus_sys_fpb,
2973 &msm_bus_cpss_fpb,
2974};
2975
2976static void __init msm8960_i2c_init(void)
2977{
Kiran Gundaaf3b3562012-08-31 14:00:05 +05302978 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
2979 msm8960_i2c_qup_gsbi4_pdata.keep_ahb_clk_on = 1;
2980
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002981 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2982 &msm8960_i2c_qup_gsbi4_pdata;
2983
2984 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2985 &msm8960_i2c_qup_gsbi3_pdata;
2986
2987 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2988 &msm8960_i2c_qup_gsbi10_pdata;
2989
2990 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2991 &msm8960_i2c_qup_gsbi12_pdata;
2992}
2993
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002994static void __init msm8960_gfx_init(void)
2995{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002996 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2997 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06002998 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06002999
Carter Coopera4a7ed22012-08-20 22:11:42 -06003000 /* Fixup data that needs to change based on GPU ID */
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003001 if (cpu_is_msm8960ab()) {
3002 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
Suman Tatiraju03a95db2012-10-29 18:24:53 -07003003 /* 8960PRO nominal clock rate is 320Mhz */
3004 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Lucille Sylvester0a82ff22012-12-06 14:10:19 -07003005#ifdef CONFIG_MSM_BUS_SCALING
3006 kgsl_3d0_pdata->bus_scale_table = &grp3d_bus_scale_pdata_ab;
3007#endif
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -06003008
3009 /*
3010 * If this an A320 GPU device (MSM8960AB), then
3011 * switch the resource table to 8960AB, to reflect the
3012 * separate register and shader memory mapping used in A320.
3013 */
3014
3015 msm_kgsl_3d0.num_resources = kgsl_num_resources_8960ab;
3016 msm_kgsl_3d0.resource = kgsl_3d0_resources_8960ab;
Carter Coopera4a7ed22012-08-20 22:11:42 -06003017 } else {
3018 kgsl_3d0_pdata->iommu_count = 1;
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -06003019
Carter Coopera4a7ed22012-08-20 22:11:42 -06003020 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3021 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
3022 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
3023 }
3024 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
3025 /* 8960v3 GPU registers returns 5 for patch release
3026 * but it should be 6, so dummy up the chipid here
3027 * based the platform type
3028 */
3029 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
3030 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003031 }
Carter Cooper83e9dab2012-08-20 15:17:23 -06003032
3033 /* Register the 3D core */
3034 platform_device_register(&msm_kgsl_3d0);
3035
3036 /* Register the 2D cores if we are not 8960PRO */
3037 if (!cpu_is_msm8960ab()) {
3038 platform_device_register(&msm_kgsl_2d0);
3039 platform_device_register(&msm_kgsl_2d1);
3040 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003041}
3042
Subhash Jadavani933e6a62011-12-26 18:05:04 +05303043static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003044 {
3045 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3046 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3047 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003048 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003049 },
3050
3051 {
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003052 MSM_PM_SLEEP_MODE_RETENTION,
3053 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3054 true,
3055 415, 715, 340827, 475,
3056 },
3057
3058 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003059 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3060 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3061 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003062 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003063 },
3064
3065 {
3066 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3067 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3068 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003069 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003070 },
3071
3072 {
3073 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003074 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
3075 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003076 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003077 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003078
3079 {
3080 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3081 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3082 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003083 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003084 },
3085
3086 {
3087 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3088 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3089 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003090 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003091 },
3092
3093 {
3094 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3095 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3096 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003097 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003098 },
3099
3100 {
3101 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3102 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3103 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003104 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105 },
3106};
3107
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003108
Praveen Chidambaram78499012011-11-01 17:15:17 -06003109static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
3110 .levels = &msm_rpmrs_levels[0],
3111 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
3112 .vdd_mem_levels = {
3113 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3114 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3115 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3116 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3117 },
3118 .vdd_dig_levels = {
3119 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3120 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3121 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3122 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3123 },
3124 .vdd_mask = 0x7FFFFF,
3125 .rpmrs_target_id = {
3126 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3127 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3128 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3129 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3130 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3131 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3132 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3133 },
3134};
3135
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003136static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3137 .mode = MSM_PM_BOOT_CONFIG_TZ,
3138};
3139
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003140#ifdef CONFIG_I2C
3141#define I2C_SURF 1
3142#define I2C_FFA (1 << 1)
3143#define I2C_RUMI (1 << 2)
3144#define I2C_SIM (1 << 3)
3145#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003146#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003147
3148struct i2c_registry {
3149 u8 machs;
3150 int bus;
3151 struct i2c_board_info *info;
3152 int len;
3153};
3154
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003155/* Sensors DSPS platform data */
3156#ifdef CONFIG_MSM_DSPS
3157#define DSPS_PIL_GENERIC_NAME "dsps"
3158#endif /* CONFIG_MSM_DSPS */
3159
3160static void __init msm8960_init_dsps(void)
3161{
3162#ifdef CONFIG_MSM_DSPS
3163 struct msm_dsps_platform_data *pdata =
3164 msm_dsps_device.dev.platform_data;
3165 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3166 pdata->gpios = NULL;
3167 pdata->gpios_num = 0;
3168
3169 platform_device_register(&msm_dsps_device);
3170#endif /* CONFIG_MSM_DSPS */
3171}
3172
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003173static int hsic_peripheral_status = 1;
3174static DEFINE_MUTEX(hsic_status_lock);
3175
3176void peripheral_connect()
3177{
3178 mutex_lock(&hsic_status_lock);
3179 if (hsic_peripheral_status)
3180 goto out;
3181 platform_device_add(&msm_device_hsic_host);
3182 hsic_peripheral_status = 1;
3183out:
3184 mutex_unlock(&hsic_status_lock);
3185}
3186EXPORT_SYMBOL(peripheral_connect);
3187
3188void peripheral_disconnect()
3189{
3190 mutex_lock(&hsic_status_lock);
3191 if (!hsic_peripheral_status)
3192 goto out;
3193 platform_device_del(&msm_device_hsic_host);
3194 hsic_peripheral_status = 0;
3195out:
3196 mutex_unlock(&hsic_status_lock);
3197}
3198EXPORT_SYMBOL(peripheral_disconnect);
3199
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303200static void __init msm8960_init_smsc_hub(void)
3201{
3202 uint32_t version = socinfo_get_version();
3203
3204 if (SOCINFO_VERSION_MAJOR(version) == 1)
3205 return;
3206
3207 if (machine_is_msm8960_liquid())
3208 platform_device_register(&smsc_hub_device);
3209}
3210
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003211static void __init msm8960_init_hsic(void)
3212{
3213#ifdef CONFIG_USB_EHCI_MSM_HSIC
3214 uint32_t version = socinfo_get_version();
3215
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003216 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003217 return;
3218
Joel King0cbf5d82012-05-24 15:21:38 -07003219 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003220 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003221#endif
3222}
3223
Amir Samuelov5137e392011-09-21 17:31:25 +03003224#ifdef CONFIG_ISL9519_CHARGER
3225static struct isl_platform_data isl_data __initdata = {
3226 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3227 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3228 .max_system_voltage = 4200,
3229 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003230 .chgcurrent = 1900,
3231 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003232 .input_current = 2048,
3233};
3234
3235static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3236 {
3237 I2C_BOARD_INFO("isl9519q", 0x9),
3238 .irq = 0, /* Not required when notify-by-pmic */
3239 .platform_data = &isl_data,
3240 },
3241};
3242#endif /* CONFIG_ISL9519_CHARGER */
3243
Amir Samuelov755616d2011-12-13 16:34:46 +02003244static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3245 {
3246 I2C_BOARD_INFO("sx1508q", 0x20),
3247 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3248 },
3249};
3250
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003251static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003252#ifdef CONFIG_ISL9519_CHARGER
3253 {
3254 I2C_LIQUID,
3255 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3256 isl_charger_i2c_info,
3257 ARRAY_SIZE(isl_charger_i2c_info),
3258 },
3259#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003260 {
3261 I2C_SURF | I2C_FFA | I2C_FLUID,
3262 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3263 cyttsp_info,
3264 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003265 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303266 {
3267 I2C_LIQUID,
3268 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3269 mxt_device_info,
3270 ARRAY_SIZE(mxt_device_info),
3271 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303272 {
Manoj Rao14648742012-03-30 19:42:12 -07003273 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303274 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003275 sii_device_info,
3276 ARRAY_SIZE(sii_device_info),
3277 },
3278 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303279 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003280 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303281 msm_isa1200_board_info,
3282 ARRAY_SIZE(msm_isa1200_board_info),
3283 },
Amir Samuelov755616d2011-12-13 16:34:46 +02003284 {
3285 I2C_LIQUID,
3286 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3287 liquid_io_expander_i2c_info,
3288 ARRAY_SIZE(liquid_io_expander_i2c_info),
3289 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003290};
3291#endif /* CONFIG_I2C */
3292
3293static void __init register_i2c_devices(void)
3294{
3295#ifdef CONFIG_I2C
3296 u8 mach_mask = 0;
3297 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003298#ifdef CONFIG_MSM_CAMERA
3299 struct i2c_registry msm8960_camera_i2c_devices = {
3300 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3301 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3302 msm8960_camera_board_info.board_info,
3303 msm8960_camera_board_info.num_i2c_board_info,
3304 };
3305#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003306
3307 /* Build the matching 'supported_machs' bitmask */
3308 if (machine_is_msm8960_cdp())
3309 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003310 else if (machine_is_msm8960_fluid())
3311 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003312 else if (machine_is_msm8960_liquid())
3313 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003314 else if (machine_is_msm8960_mtp())
3315 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003316 else
3317 pr_err("unmatched machine ID in register_i2c_devices\n");
3318
Jing Lineec88ca2012-02-08 11:18:30 -08003319 if (machine_is_msm8960_liquid()) {
3320 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3321 mxt_device_info[0].platform_data =
3322 &mxt_platform_data_3d;
3323 else
3324 mxt_device_info[0].platform_data =
3325 &mxt_platform_data_2d;
3326 }
3327
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003328 /* Run the array and install devices as appropriate */
3329 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3330 if (msm8960_i2c_devices[i].machs & mach_mask)
3331 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3332 msm8960_i2c_devices[i].info,
3333 msm8960_i2c_devices[i].len);
3334 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003335
3336 if (!mhl_platform_data.gpio_mhl_power)
3337 pr_debug("mhl device configured for ext debug board\n");
3338
Kevin Chan09f4e662011-12-16 08:17:02 -08003339#ifdef CONFIG_MSM_CAMERA
3340 if (msm8960_camera_i2c_devices.machs & mach_mask)
3341 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3342 msm8960_camera_i2c_devices.info,
3343 msm8960_camera_i2c_devices.len);
3344#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003345#endif
3346}
3347
Siddartha Mohanadoss30447fe2012-09-26 09:42:32 -07003348static void __init msm8960_tsens_init(void)
3349{
3350 if (cpu_is_msm8960())
3351 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3352 return;
3353
3354 msm_tsens_early_init(&msm_tsens_pdata);
3355}
3356
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003357static void __init msm8960ab_update_krait_spm(void)
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003358{
3359 int i;
3360
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003361 /* Update the SPM sequences for SPC and PC */
3362 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3363 int j;
3364 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3365 for (j = 0; j < pdata->num_modes; j++) {
3366 if (pdata->modes[j].cmd ==
3367 spm_power_collapse_without_rpm)
3368 pdata->modes[j].cmd =
3369 spm_power_collapse_without_rpm_krait_v3;
3370 else if (pdata->modes[j].cmd ==
3371 spm_power_collapse_with_rpm)
3372 pdata->modes[j].cmd =
3373 spm_power_collapse_with_rpm_krait_v3;
3374 }
3375 }
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003376}
3377
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003378static void __init msm8960_cdp_init(void)
3379{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003380 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3381 pr_err("meminfo_init() failed!\n");
3382
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003383 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss30447fe2012-09-26 09:42:32 -07003384 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003385 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003386 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3387 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003388
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003389 regulator_suppress_info_printing();
3390 if (msm_xo_init())
3391 pr_err("Failed to initialize XO votes\n");
David Collinse68647e2012-09-04 15:44:19 -07003392 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003393 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003394 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303395 if (machine_is_msm8960_liquid())
3396 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003397 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303398 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3399 machine_is_msm8960_cdp()) {
Mayank Ranaa61da7a2012-08-14 10:57:00 +05303400 /* Due to availability of USB Switch in SGLTE Platform
3401 * it requires different HSUSB PHY settings compare to
3402 * 8960 MTP/CDP platform.
3403 */
3404 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3405 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3406 else
3407 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303408 } else if (machine_is_msm8960_liquid()) {
3409 msm_otg_pdata.phy_init_seq =
3410 liquid_v1_phy_init_seq;
3411 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003412 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303413 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303414 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303415 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3416 machine_is_msm8960_liquid())
3417 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003418 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003419 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3420 &msm8960_qup_spi_gsbi1_pdata;
3421 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303422 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3423 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003424
3425 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303426 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jainae54a622012-12-03 15:09:39 +05303427 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3428 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303429 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003430 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003431 msm8960_gfx_init();
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003432
3433 if (cpu_is_msm8960ab())
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003434 msm8960ab_update_krait_spm();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003435 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3436 msm_spm_l2_init(msm_spm_l2_data);
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003437
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003438 msm8960_init_buses();
Stephen Boyd913c29d2012-10-25 11:46:04 -07003439 if (cpu_is_msm8960ab()) {
3440 platform_add_devices(msm8960ab_footswitch,
3441 msm8960ab_num_footswitch);
3442 } else {
3443 platform_add_devices(msm8960_footswitch,
3444 msm8960_num_footswitch);
3445 }
David Collinsb10be1d2011-09-02 10:29:31 -07003446 if (machine_is_msm8960_liquid())
3447 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003448 if (machine_is_msm8960_cdp())
3449 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003450
3451 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3452 platform_device_register(&msm8960_device_uart_gsbi8);
3453 else
3454 platform_device_register(&msm8960_device_uart_gsbi5);
3455
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003456 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003457 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3458 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003459 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303460 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003461 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003462
Mayank Rana1f02d952012-07-04 19:11:20 +05303463 /* For 8960 Standalone External Bluetooth Interface */
3464 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3465 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3466 platform_device_register(&msm_device_uart_dm8);
3467 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003468 if (cpu_is_msm8960ab())
3469 platform_device_register(&msm8960ab_device_acpuclk);
3470 else
3471 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003472 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menon697e91b2012-08-20 15:25:50 -07003473 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003474
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003475 msm8960_pm8921_gpio_mpp_init();
Stephen Boyded035682012-09-13 12:41:31 -07003476 /* Don't add modem devices on APQ targets */
Stephen Boydbdb53f32012-06-05 18:39:47 -07003477 if (socinfo_get_id() != 124)
3478 platform_device_register(&msm_8960_q6_mss);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003479 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303480 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003481 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003482#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003483 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003484#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003485 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303486 if (machine_is_msm8960_liquid())
3487 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003488 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003489 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003490 slim_register_board_info(msm_slim_devices,
3491 ARRAY_SIZE(msm_slim_devices));
3492 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003493 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003494 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303495 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003496 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3497 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3498 platform_device_register(&mdm_sglte_device);
3499 }
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003500 msm_pm_set_tz_retention_flag(1);
Laura Abbottac963312012-12-11 15:09:03 -08003501 ion_adjust_secure_allocation();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003502}
3503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003504MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3505 .map_io = msm8960_map_io,
3506 .reserve = msm8960_reserve,
3507 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303508 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003509 .timer = &msm_timer,
3510 .init_machine = msm8960_cdp_init,
3511 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003512 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003513 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003514 .smp = &msm8960_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003515MACHINE_END
3516
3517MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3518 .map_io = msm8960_map_io,
3519 .reserve = msm8960_reserve,
3520 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303521 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003522 .timer = &msm_timer,
3523 .init_machine = msm8960_cdp_init,
3524 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003525 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003526 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003527 .smp = &msm8960_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003528MACHINE_END
3529
3530MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3531 .map_io = msm8960_map_io,
3532 .reserve = msm8960_reserve,
3533 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303534 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003535 .timer = &msm_timer,
3536 .init_machine = msm8960_cdp_init,
3537 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003538 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003539 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003540 .smp = &msm8960_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003541MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003542
3543MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3544 .map_io = msm8960_map_io,
3545 .reserve = msm8960_reserve,
3546 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303547 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003548 .timer = &msm_timer,
3549 .init_machine = msm8960_cdp_init,
3550 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003551 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003552 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003553 .smp = &msm8960_smp_ops,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003554MACHINE_END