blob: 819ccc53254dd43c597673d9b8398c16b6a93ac5 [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,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800370};
371
Laura Abbottb93525f2012-04-12 09:57:19 -0700372static struct ion_cp_heap_pdata cp_mfc_msm8960_ion_pdata = {
Olav Haugan0703dbf2011-12-19 17:53:38 -0800373 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -0800374 .align = PAGE_SIZE,
Olav Haugan65f4bd82011-12-13 11:50:08 -0800375 .reusable = 0,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800376 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700377 .fixed_position = FIXED_HIGH,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800378};
379
Laura Abbottb93525f2012-04-12 09:57:19 -0700380static struct ion_co_heap_pdata co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800381 .adjacent_mem_id = INVALID_HEAP_ID,
382 .align = PAGE_SIZE,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800383 .mem_is_fmem = 0,
Olav Haugan42ebe712012-01-10 16:30:58 -0800384};
385
Laura Abbottb93525f2012-04-12 09:57:19 -0700386static struct ion_co_heap_pdata fw_co_msm8960_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -0800387 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
388 .align = SZ_128K,
Olav Hauganf6dc7742012-02-15 09:11:55 -0800389 .mem_is_fmem = FMEM_ENABLED,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700390 .fixed_position = FIXED_LOW,
Olav Haugan0703dbf2011-12-19 17:53:38 -0800391};
392#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800393
Laura Abbottc0e64032012-08-03 17:32:09 -0700394static u64 msm_dmamask = DMA_BIT_MASK(32);
395
396static struct platform_device ion_mm_heap_device = {
397 .name = "ion-mm-heap-device",
398 .id = -1,
399 .dev = {
400 .dma_mask = &msm_dmamask,
401 .coherent_dma_mask = DMA_BIT_MASK(32),
402 }
403};
404
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800405/**
406 * These heaps are listed in the order they will be allocated. Due to
407 * video hardware restrictions and content protection the FW heap has to
408 * be allocated adjacent (below) the MM heap and the MFC heap has to be
409 * allocated after the MM heap to ensure MFC heap is not more than 256MB
410 * away from the base address of the FW heap.
411 * However, the order of FW heap and MM heap doesn't matter since these
412 * two heaps are taken care of by separate code to ensure they are adjacent
413 * to each other.
414 * Don't swap the order unless you know what you are doing!
415 */
Benjamin Gaignard63d81032012-06-25 15:27:30 -0700416struct ion_platform_heap msm8960_heaps[] = {
Laura Abbottd6183792011-08-19 13:42:24 -0700417 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800418 .id = ION_SYSTEM_HEAP_ID,
Laura Abbottd6183792011-08-19 13:42:24 -0700419 .type = ION_HEAP_TYPE_SYSTEM,
Laura Abbottd6183792011-08-19 13:42:24 -0700420 .name = ION_VMALLOC_HEAP_NAME,
421 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700422#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottd6183792011-08-19 13:42:24 -0700423 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800424 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800425 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800426 .name = ION_MM_HEAP_NAME,
427 .size = MSM_ION_MM_SIZE,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700428 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700429 .extra_data = (void *) &cp_mm_msm8960_ion_pdata,
Laura Abbottc0e64032012-08-03 17:32:09 -0700430 .priv = &ion_mm_heap_device.dev,
Laura Abbott2d1760b2011-09-29 21:31:24 -0700431 },
Laura Abbott8c017362011-09-22 20:59:12 -0700432 {
Olav Haugan42ebe712012-01-10 16:30:58 -0800433 .id = ION_MM_FIRMWARE_HEAP_ID,
434 .type = ION_HEAP_TYPE_CARVEOUT,
435 .name = ION_MM_FIRMWARE_HEAP_NAME,
436 .size = MSM_ION_MM_FW_SIZE,
437 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700438 .extra_data = (void *) &fw_co_msm8960_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -0800439 },
440 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800441 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -0800442 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -0800443 .name = ION_MFC_HEAP_NAME,
444 .size = MSM_ION_MFC_SIZE,
445 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700446 .extra_data = (void *) &cp_mfc_msm8960_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -0800447 },
Olav Haugan32594552012-03-13 11:40:05 -0700448#ifndef CONFIG_MSM_IOMMU
Olav Hauganb5be7992011-11-18 14:29:02 -0800449 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800450 .id = ION_SF_HEAP_ID,
451 .type = ION_HEAP_TYPE_CARVEOUT,
452 .name = ION_SF_HEAP_NAME,
453 .size = MSM_ION_SF_SIZE,
454 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700455 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800456 },
Olav Haugan32594552012-03-13 11:40:05 -0700457#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800458 {
Olav Hauganb5be7992011-11-18 14:29:02 -0800459 .id = ION_IOMMU_HEAP_ID,
Laura Abbott8c017362011-09-22 20:59:12 -0700460 .type = ION_HEAP_TYPE_IOMMU,
461 .name = ION_IOMMU_HEAP_NAME,
462 },
Olav Haugan80854eb2012-01-12 12:00:23 -0800463 {
464 .id = ION_QSECOM_HEAP_ID,
465 .type = ION_HEAP_TYPE_CARVEOUT,
466 .name = ION_QSECOM_HEAP_NAME,
467 .size = MSM_ION_QSECOM_SIZE,
468 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700469 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan80854eb2012-01-12 12:00:23 -0800470 },
Olav Haugan7355db02012-01-13 16:59:13 -0800471 {
472 .id = ION_AUDIO_HEAP_ID,
473 .type = ION_HEAP_TYPE_CARVEOUT,
474 .name = ION_AUDIO_HEAP_NAME,
475 .size = MSM_ION_AUDIO_SIZE,
476 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700477 .extra_data = (void *) &co_msm8960_ion_pdata,
Olav Haugan7355db02012-01-13 16:59:13 -0800478 },
Laura Abbott2d1760b2011-09-29 21:31:24 -0700479#endif
Benjamin Gaignard63d81032012-06-25 15:27:30 -0700480};
481
482static struct ion_platform_data msm8960_ion_pdata = {
483 .nr = MSM_ION_HEAP_NUM,
484 .heaps = msm8960_heaps,
Laura Abbottd6183792011-08-19 13:42:24 -0700485};
486
Laura Abbottb93525f2012-04-12 09:57:19 -0700487static struct platform_device msm8960_ion_dev = {
Laura Abbottd6183792011-08-19 13:42:24 -0700488 .name = "ion-msm",
489 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700490 .dev = { .platform_data = &msm8960_ion_pdata },
Laura Abbottd6183792011-08-19 13:42:24 -0700491};
492#endif
493
Laura Abbottb93525f2012-04-12 09:57:19 -0700494struct platform_device msm8960_fmem_device = {
Larry Bassel41a055b2011-12-06 16:15:14 -0800495 .name = "fmem",
496 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700497 .dev = { .platform_data = &msm8960_fmem_pdata },
Larry Bassel41a055b2011-12-06 16:15:14 -0800498};
499
Olav Haugan65f4bd82011-12-13 11:50:08 -0800500static void __init adjust_mem_for_liquid(void)
Laura Abbottd6183792011-08-19 13:42:24 -0700501{
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800502 unsigned int i;
503
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800504 if (!pmem_param_set) {
505 if (machine_is_msm8960_liquid())
506 msm_ion_sf_size = MSM_LIQUID_ION_SF_SIZE;
507
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700508 if (msm8960_hdmi_as_primary_selected())
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800509 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
510
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -0700511 if (machine_is_msm8960_liquid() ||
512 msm8960_hdmi_as_primary_selected()) {
Laura Abbottb93525f2012-04-12 09:57:19 -0700513 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
514 if (msm8960_ion_pdata.heaps[i].id ==
515 ION_SF_HEAP_ID) {
516 msm8960_ion_pdata.heaps[i].size =
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800517 msm_ion_sf_size;
518 pr_debug("msm_ion_sf_size 0x%x\n",
519 msm_ion_sf_size);
520 break;
521 }
Ravishangar Kalyanam671f5ce2011-12-06 20:25:29 -0800522 }
523 }
524 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800525}
526
527static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
528 unsigned long size)
529{
530 msm8960_reserve_table[mem_type].size += size;
531}
532
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700533static void __init msm8960_reserve_fixed_area(unsigned long fixed_area_size)
534{
535#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
536 int ret;
537
538 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
539 panic("fixed area size is larger than %dM\n",
540 MAX_FIXED_AREA_SIZE >> 20);
541
542 reserve_info->fixed_area_size = fixed_area_size;
543 reserve_info->fixed_area_start = MSM8960_FW_START;
544
545 ret = memblock_remove(reserve_info->fixed_area_start,
546 reserve_info->fixed_area_size);
547 BUG_ON(ret);
548#endif
549}
550
Olav Haugan65f4bd82011-12-13 11:50:08 -0800551/**
552 * Reserve memory for ION and calculate amount of reusable memory for fmem.
553 * We only reserve memory for heaps that are not reusable. However, we only
554 * support one reusable heap at the moment so we ignore the reusable flag for
555 * other than the first heap with reusable flag set. Also handle special case
Olav Hauganf6dc7742012-02-15 09:11:55 -0800556 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
557 * at a higher address than FW in addition to not more than 256MB away from the
558 * base address of the firmware. This means that if MM is reusable the other
559 * two heaps must be allocated in the same region as FW. This is handled by the
560 * mem_is_fmem flag in the platform data. In addition the MM heap must be
561 * adjacent to the FW heap for content protection purposes.
Olav Haugan65f4bd82011-12-13 11:50:08 -0800562 */
563static void __init reserve_ion_memory(void)
564{
565#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
566 unsigned int i;
Laura Abbottc0e64032012-08-03 17:32:09 -0700567 int ret;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700568 unsigned int fixed_size = 0;
569 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
570 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbottc0e64032012-08-03 17:32:09 -0700571 unsigned long cma_alignment;
572 unsigned int low_use_cma = 0;
573 unsigned int middle_use_cma = 0;
574 unsigned int high_use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800575
576 adjust_mem_for_liquid();
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700577 fixed_low_size = 0;
578 fixed_middle_size = 0;
579 fixed_high_size = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800580
Laura Abbottc0e64032012-08-03 17:32:09 -0700581 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
582
Laura Abbottb93525f2012-04-12 09:57:19 -0700583 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
Olav Haugan8726caf2012-05-10 15:11:35 -0700584 struct ion_platform_heap *heap =
Laura Abbottb93525f2012-04-12 09:57:19 -0700585 &(msm8960_ion_pdata.heaps[i]);
Olav Haugan8726caf2012-05-10 15:11:35 -0700586 int align = SZ_4K;
587 int iommu_map_all = 0;
588 int adjacent_mem_id = INVALID_HEAP_ID;
Laura Abbottc0e64032012-08-03 17:32:09 -0700589 int use_cma = 0;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800590
591 if (heap->extra_data) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700592 int fixed_position = NOT_FIXED;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700593
Mitchel Humpherys362b52b2012-09-13 10:53:22 -0700594 switch ((int) heap->type) {
Olav Haugan65f4bd82011-12-13 11:50:08 -0800595 case ION_HEAP_TYPE_CP:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700596 fixed_position = ((struct ion_cp_heap_pdata *)
597 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700598 align = ((struct ion_cp_heap_pdata *)
599 heap->extra_data)->align;
600 iommu_map_all =
601 ((struct ion_cp_heap_pdata *)
602 heap->extra_data)->iommu_map_all;
Laura Abbottc0e64032012-08-03 17:32:09 -0700603 if (((struct ion_cp_heap_pdata *)
604 heap->extra_data)->is_cma) {
605 heap->size = ALIGN(heap->size,
606 cma_alignment);
607 use_cma = 1;
608 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800609 break;
Laura Abbottc0e64032012-08-03 17:32:09 -0700610 case ION_HEAP_TYPE_DMA:
611 use_cma = 1;
612 /* Purposely fall through here */
Olav Haugan65f4bd82011-12-13 11:50:08 -0800613 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700614 fixed_position = ((struct ion_co_heap_pdata *)
615 heap->extra_data)->fixed_position;
Olav Haugan8726caf2012-05-10 15:11:35 -0700616 adjacent_mem_id = ((struct ion_co_heap_pdata *)
617 heap->extra_data)->adjacent_mem_id;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700618 break;
619 default:
620 break;
621 }
622
Olav Haugan8726caf2012-05-10 15:11:35 -0700623 if (iommu_map_all) {
624 if (heap->size & (SZ_64K-1)) {
625 heap->size = ALIGN(heap->size, SZ_64K);
626 pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
627 heap->name, heap->size);
628 }
629 }
630
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700631 if (fixed_position != NOT_FIXED)
632 fixed_size += heap->size;
633 else
634 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
635
Laura Abbottc0e64032012-08-03 17:32:09 -0700636 if (fixed_position == FIXED_LOW) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700637 fixed_low_size += heap->size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700638 low_use_cma = use_cma;
639 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700640 fixed_middle_size += heap->size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700641 middle_use_cma = use_cma;
642 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700643 fixed_high_size += heap->size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700644 high_use_cma = use_cma;
645 } else if (use_cma) {
646 /*
647 * Heaps that use CMA but are not part of the
648 * fixed set. Create wherever.
649 */
650 dma_declare_contiguous(
651 heap->priv,
652 heap->size,
653 0,
654 0xb0000000);
655 }
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700656 }
657 }
658
659 if (!fixed_size)
660 return;
661
Laura Abbottc0e64032012-08-03 17:32:09 -0700662 /*
663 * Given the setup for the fixed area, we can't round up all sizes.
664 * Some sizes must be set up exactly and aligned correctly. Incorrect
665 * alignments are considered a configuration issue
Larry Bassel4d4f4482012-04-04 11:26:09 -0700666 */
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700667
668 fixed_low_start = MSM8960_FIXED_AREA_START;
Laura Abbottc0e64032012-08-03 17:32:09 -0700669 if (low_use_cma) {
670 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
671 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
672 } else {
673 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
674 ret = memblock_remove(fixed_low_start,
675 fixed_low_size + HOLE_SIZE);
676 BUG_ON(ret);
677 }
678
Deepak Kotur35825522012-06-06 15:49:14 -0700679 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbottc0e64032012-08-03 17:32:09 -0700680 if (middle_use_cma) {
681 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
682 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
683 } else {
684 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
685 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
686 BUG_ON(ret);
687 }
688
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700689 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbottc0e64032012-08-03 17:32:09 -0700690 if (high_use_cma) {
691 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
692 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
693 } else {
694 /* This is the end of the fixed area so it's okay to round up */
695 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
696 ret = memblock_remove(fixed_high_start, fixed_high_size);
697 BUG_ON(ret);
698 }
699
700
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700701
Laura Abbottb93525f2012-04-12 09:57:19 -0700702 for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
703 struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700704
705 if (heap->extra_data) {
706 int fixed_position = NOT_FIXED;
Steve Muckle75c34ca2012-06-12 14:27:40 -0700707 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700708
Mitchel Humpherys362b52b2012-09-13 10:53:22 -0700709 switch ((int) heap->type) {
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700710 case ION_HEAP_TYPE_CP:
Deepak Kotur35825522012-06-06 15:49:14 -0700711 pdata =
712 (struct ion_cp_heap_pdata *)heap->extra_data;
713 fixed_position = pdata->fixed_position;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700714 break;
715 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbottc0e64032012-08-03 17:32:09 -0700716 case ION_HEAP_TYPE_DMA:
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700717 fixed_position = ((struct ion_co_heap_pdata *)
718 heap->extra_data)->fixed_position;
719 break;
720 default:
721 break;
722 }
723
724 switch (fixed_position) {
725 case FIXED_LOW:
726 heap->base = fixed_low_start;
727 break;
728 case FIXED_MIDDLE:
729 heap->base = fixed_middle_start;
Laura Abbottc0e64032012-08-03 17:32:09 -0700730 if (middle_use_cma) {
731 ret = dma_declare_contiguous(
732 &ion_mm_heap_device.dev,
733 heap->size,
734 fixed_middle_start,
735 0xa0000000);
736 WARN_ON(ret);
737 }
Deepak Kotur35825522012-06-06 15:49:14 -0700738 pdata->secure_base = fixed_middle_start
739 - HOLE_SIZE;
740 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700741 break;
742 case FIXED_HIGH:
743 heap->base = fixed_high_start;
Olav Haugan65f4bd82011-12-13 11:50:08 -0800744 break;
745 default:
746 break;
747 }
748 }
Olav Haugan65f4bd82011-12-13 11:50:08 -0800749 }
Laura Abbottd6183792011-08-19 13:42:24 -0700750#endif
751}
Huaibin Yanga5419422011-12-08 23:52:10 -0800752
Laura Abbottac963312012-12-11 15:09:03 -0800753static void ion_adjust_secure_allocation(void)
754{
755 int i;
756
757 for (i = 0; i < msm8960_ion_pdata.nr; i++) {
758 struct ion_platform_heap *heap =
759 &(msm8960_ion_pdata.heaps[i]);
760
761
762 if (heap->extra_data) {
763 switch ((int) heap->type) {
764 case ION_HEAP_TYPE_CP:
765 if (cpu_is_msm8960()) {
766 ((struct ion_cp_heap_pdata *)
Mitchel Humpherys345f0232013-01-11 10:55:25 -0800767 heap->extra_data)->allow_nonsecure_alloc
768 = 1;
Laura Abbottac963312012-12-11 15:09:03 -0800769 }
770
771 }
772 }
773 }
774}
775
Huaibin Yanga5419422011-12-08 23:52:10 -0800776static void __init reserve_mdp_memory(void)
777{
778 msm8960_mdp_writeback(msm8960_reserve_table);
779}
780
Stephen Boyd668d7652012-04-25 11:31:01 -0700781static void __init reserve_cache_dump_memory(void)
Laura Abbott306bcc22012-03-08 11:24:53 -0800782{
783#ifdef CONFIG_MSM_CACHE_DUMP
Laura Abbott306bcc22012-03-08 11:24:53 -0800784 unsigned int total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800785
Laura Abbott155ab6f2012-05-25 08:52:18 -0700786 total = msm8960_cache_dump_pdata.l1_size +
787 msm8960_cache_dump_pdata.l2_size;
Laura Abbott306bcc22012-03-08 11:24:53 -0800788 msm8960_reserve_table[MEMTYPE_EBI1].size += total;
Laura Abbott306bcc22012-03-08 11:24:53 -0800789#endif
790}
791
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700792static void __init msm8960_calculate_reserve_sizes(void)
793{
794 size_pmem_devices();
795 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700796 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -0800797 reserve_mdp_memory();
Laura Abbottf8c03b92012-02-16 14:57:58 -0800798 reserve_rtb_memory();
Laura Abbott306bcc22012-03-08 11:24:53 -0800799 reserve_cache_dump_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800}
801
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802static struct reserve_info msm8960_reserve_info __initdata = {
803 .memtype_reserve_table = msm8960_reserve_table,
804 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
Larry Bassel2d8b42d2012-03-12 10:41:26 -0700805 .reserve_fixed_area = msm8960_reserve_fixed_area,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700806 .paddr_to_memtype = msm8960_paddr_to_memtype,
807};
808
Larry Basselb4126da2011-07-18 14:31:33 -0700809static int msm8960_memory_bank_size(void)
810{
811 return 1<<29;
812}
813
814static void __init locate_unstable_memory(void)
815{
816 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
817 unsigned long bank_size;
818 unsigned long low, high;
819
820 bank_size = msm8960_memory_bank_size();
Larry Bassel4d4f4482012-04-04 11:26:09 -0700821 msm8960_reserve_info.bank_size = bank_size;
822
Larry Basselb4126da2011-07-18 14:31:33 -0700823 low = meminfo.bank[0].start;
824 high = mb->start + mb->size;
Olav Haugan62052e42011-10-28 14:28:32 -0700825
826 /* Check if 32 bit overflow occured */
827 if (high < mb->start)
828 high = ~0UL;
829
Larry Bassel4d4f4482012-04-04 11:26:09 -0700830 if (high < MAX_FIXED_AREA_SIZE + MSM8960_FIXED_AREA_START)
831 panic("fixed area extends beyond end of memory\n");
832
Larry Basselb4126da2011-07-18 14:31:33 -0700833 low &= ~(bank_size - 1);
834
835 if (high - low <= bank_size)
Larry Bassel4d4f4482012-04-04 11:26:09 -0700836 goto no_dmm;
Larry Basselb8d61022012-02-24 10:49:45 -0800837
Larry Basselb8d61022012-02-24 10:49:45 -0800838#ifdef CONFIG_ENABLE_DMM
Jack Cheung60eaeab2012-01-09 16:40:26 -0800839 msm8960_reserve_info.low_unstable_address = mb->start -
840 MIN_MEMORY_BLOCK_SIZE + mb->size;
Jack Cheung0b1987e2011-11-18 13:36:29 -0800841 msm8960_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
Larry Basselb4126da2011-07-18 14:31:33 -0700842 pr_info("low unstable address %lx max size %lx bank size %lx\n",
843 msm8960_reserve_info.low_unstable_address,
844 msm8960_reserve_info.max_unstable_size,
845 msm8960_reserve_info.bank_size);
Larry Bassel4d4f4482012-04-04 11:26:09 -0700846 return;
Larry Basselb8d61022012-02-24 10:49:45 -0800847#endif
Larry Bassel4d4f4482012-04-04 11:26:09 -0700848no_dmm:
849 msm8960_reserve_info.low_unstable_address = high;
850 msm8960_reserve_info.max_unstable_size = 0;
Larry Basselb4126da2011-07-18 14:31:33 -0700851}
852
Larry Basselb830e182011-10-14 10:46:55 -0700853static void __init place_movable_zone(void)
854{
Larry Basselb8d61022012-02-24 10:49:45 -0800855#ifdef CONFIG_ENABLE_DMM
Larry Basselb830e182011-10-14 10:46:55 -0700856 movable_reserved_start = msm8960_reserve_info.low_unstable_address;
857 movable_reserved_size = msm8960_reserve_info.max_unstable_size;
858 pr_info("movable zone start %lx size %lx\n",
859 movable_reserved_start, movable_reserved_size);
Larry Basselb8d61022012-02-24 10:49:45 -0800860#endif
Larry Basselb830e182011-10-14 10:46:55 -0700861}
862
863static void __init msm8960_early_memory(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700864{
865 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700866 locate_unstable_memory();
Larry Basselb830e182011-10-14 10:46:55 -0700867 place_movable_zone();
868}
869
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800870static char prim_panel_name[PANEL_NAME_MAX_LEN];
871static char ext_panel_name[PANEL_NAME_MAX_LEN];
872static int __init prim_display_setup(char *param)
873{
874 if (strnlen(param, PANEL_NAME_MAX_LEN))
875 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
876 return 0;
877}
878early_param("prim_display", prim_display_setup);
879
880static int __init ext_display_setup(char *param)
881{
882 if (strnlen(param, PANEL_NAME_MAX_LEN))
883 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
884 return 0;
885}
886early_param("ext_display", ext_display_setup);
887
Larry Basselb830e182011-10-14 10:46:55 -0700888static void __init msm8960_reserve(void)
889{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -0800890 msm8960_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700891 msm_reserve();
892}
893
Larry Bassela4414b12011-08-04 11:11:02 -0700894static int msm8960_change_memory_power(u64 start, u64 size,
895 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700896{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700897 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700898}
899
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700900static void __init msm8960_allocate_memory_regions(void)
901{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800902 msm8960_allocate_fb_region();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700903}
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800904
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700905#ifdef CONFIG_WCD9310_CODEC
906
907#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
908
Patrick Lai3043fba2011-08-01 14:15:57 -0700909/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
910 * 4 micbiases are used to power various analog and digital
911 * microphones operating at 1800 mV. Technically, all micbiases
912 * can source from single cfilter since all microphones operate
913 * at the same voltage level. The arrangement below is to make
914 * sure all cfilters are exercised. LDO_H regulator ouput level
915 * does not need to be as high as 2.85V. It is choosen for
916 * microphone sensitivity purpose.
917 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530918static struct wcd9xxx_pdata tabla_platform_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700919 .slimbus_slave_device = {
920 .name = "tabla-slave",
921 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
922 },
923 .irq = MSM_GPIO_TO_INT(62),
924 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530925 .num_irqs = NR_WCD9XXX_IRQS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700926 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -0700927 .micbias = {
928 .ldoh_v = TABLA_LDOH_2P85_V,
929 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700930 .cfilt2_mv = 2700,
Patrick Lai3043fba2011-08-01 14:15:57 -0700931 .cfilt3_mv = 1800,
932 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
933 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
934 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
935 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530936 },
937 .regulator = {
938 {
939 .name = "CDC_VDD_CP",
940 .min_uV = 1800000,
941 .max_uV = 1800000,
942 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
943 },
944 {
945 .name = "CDC_VDDA_RX",
946 .min_uV = 1800000,
947 .max_uV = 1800000,
948 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
949 },
950 {
951 .name = "CDC_VDDA_TX",
952 .min_uV = 1800000,
953 .max_uV = 1800000,
954 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
955 },
956 {
957 .name = "VDDIO_CDC",
958 .min_uV = 1800000,
959 .max_uV = 1800000,
960 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
961 },
962 {
963 .name = "VDDD_CDC_D",
964 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700965 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530966 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
967 },
968 {
969 .name = "CDC_VDDA_A_1P2V",
970 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -0700971 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530972 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
973 },
974 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700975};
976
977static struct slim_device msm_slim_tabla = {
978 .name = "tabla-slim",
979 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
980 .dev = {
981 .platform_data = &tabla_platform_data,
982 },
983};
Santosh Mardi60e19d92011-10-28 01:15:14 +0530984
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530985static struct wcd9xxx_pdata tabla20_platform_data = {
Santosh Mardi60e19d92011-10-28 01:15:14 +0530986 .slimbus_slave_device = {
987 .name = "tabla-slave",
988 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
989 },
990 .irq = MSM_GPIO_TO_INT(62),
991 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530992 .num_irqs = NR_WCD9XXX_IRQS,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530993 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
994 .micbias = {
995 .ldoh_v = TABLA_LDOH_2P85_V,
996 .cfilt1_mv = 1800,
Joonwoo Parkcf473b42012-03-29 19:48:16 -0700997 .cfilt2_mv = 2700,
Santosh Mardi60e19d92011-10-28 01:15:14 +0530998 .cfilt3_mv = 1800,
999 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1000 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1001 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1002 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301003 },
1004 .regulator = {
1005 {
1006 .name = "CDC_VDD_CP",
1007 .min_uV = 1800000,
1008 .max_uV = 1800000,
1009 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1010 },
1011 {
1012 .name = "CDC_VDDA_RX",
1013 .min_uV = 1800000,
1014 .max_uV = 1800000,
1015 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1016 },
1017 {
1018 .name = "CDC_VDDA_TX",
1019 .min_uV = 1800000,
1020 .max_uV = 1800000,
1021 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1022 },
1023 {
1024 .name = "VDDIO_CDC",
1025 .min_uV = 1800000,
1026 .max_uV = 1800000,
1027 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1028 },
1029 {
1030 .name = "VDDD_CDC_D",
1031 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001032 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301033 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1034 },
1035 {
1036 .name = "CDC_VDDA_A_1P2V",
1037 .min_uV = 1225000,
David Collins8f2a1962012-05-18 09:47:59 -07001038 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301039 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1040 },
1041 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301042};
1043
1044static struct slim_device msm_slim_tabla20 = {
1045 .name = "tabla2x-slim",
1046 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1047 .dev = {
1048 .platform_data = &tabla20_platform_data,
1049 },
1050};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001051#endif
1052
1053static struct slim_boardinfo msm_slim_devices[] = {
1054#ifdef CONFIG_WCD9310_CODEC
1055 {
1056 .bus_num = 1,
1057 .slim_slave = &msm_slim_tabla,
1058 },
Santosh Mardi60e19d92011-10-28 01:15:14 +05301059 {
1060 .bus_num = 1,
1061 .slim_slave = &msm_slim_tabla20,
1062 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001063#endif
1064 /* add more slimbus slaves as needed */
1065};
1066
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001067#define MSM_WCNSS_PHYS 0x03000000
1068#define MSM_WCNSS_SIZE 0x280000
1069
1070static struct resource resources_wcnss_wlan[] = {
1071 {
1072 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1073 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1074 .name = "wcnss_wlanrx_irq",
1075 .flags = IORESOURCE_IRQ,
1076 },
1077 {
1078 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1079 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1080 .name = "wcnss_wlantx_irq",
1081 .flags = IORESOURCE_IRQ,
1082 },
1083 {
1084 .start = MSM_WCNSS_PHYS,
1085 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1086 .name = "wcnss_mmio",
1087 .flags = IORESOURCE_MEM,
1088 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07001089 {
1090 .start = 84,
1091 .end = 88,
1092 .name = "wcnss_gpios_5wire",
1093 .flags = IORESOURCE_IO,
1094 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001095};
1096
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001097static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1098 .has_48mhz_xo = 1,
1099};
1100
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001101static struct platform_device msm_device_wcnss_wlan = {
1102 .name = "wcnss_wlan",
1103 .id = 0,
1104 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1105 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001106 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001107};
1108
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001109#ifdef CONFIG_QSEECOM
1110/* qseecom bus scaling */
1111static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1112 {
1113 .src = MSM_BUS_MASTER_SPS,
1114 .dst = MSM_BUS_SLAVE_EBI_CH0,
1115 .ib = 0,
1116 .ab = 0,
1117 },
1118 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001119 .src = MSM_BUS_MASTER_SPS,
1120 .dst = MSM_BUS_SLAVE_SPS,
1121 .ib = 0,
1122 .ab = 0,
1123 },
1124 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001125 .src = MSM_BUS_MASTER_SPDM,
1126 .dst = MSM_BUS_SLAVE_SPDM,
1127 .ib = 0,
1128 .ab = 0,
1129 },
1130};
1131
1132static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1133 {
1134 .src = MSM_BUS_MASTER_SPS,
1135 .dst = MSM_BUS_SLAVE_EBI_CH0,
1136 .ib = (492 * 8) * 1000000UL,
1137 .ab = (492 * 8) * 100000UL,
1138 },
1139 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001140 .src = MSM_BUS_MASTER_SPS,
1141 .dst = MSM_BUS_SLAVE_SPS,
1142 .ib = (492 * 8) * 1000000UL,
1143 .ab = (492 * 8) * 100000UL,
1144 },
1145 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001146 .src = MSM_BUS_MASTER_SPDM,
1147 .dst = MSM_BUS_SLAVE_SPDM,
1148 .ib = 0,
1149 .ab = 0,
1150 },
1151};
1152
1153static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1154 {
1155 .src = MSM_BUS_MASTER_SPS,
1156 .dst = MSM_BUS_SLAVE_EBI_CH0,
1157 .ib = 0,
1158 .ab = 0,
1159 },
1160 {
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001161 .src = MSM_BUS_MASTER_SPS,
1162 .dst = MSM_BUS_SLAVE_SPS,
1163 .ib = 0,
1164 .ab = 0,
1165 },
1166 {
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001167 .src = MSM_BUS_MASTER_SPDM,
1168 .dst = MSM_BUS_SLAVE_SPDM,
1169 .ib = (64 * 8) * 1000000UL,
1170 .ab = (64 * 8) * 100000UL,
1171 },
1172};
1173
Ramesh Masavarapu8d756582012-10-03 10:18:06 -07001174static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1175 {
1176 .src = MSM_BUS_MASTER_SPS,
1177 .dst = MSM_BUS_SLAVE_EBI_CH0,
1178 .ib = (492 * 8) * 1000000UL,
1179 .ab = (492 * 8) * 100000UL,
1180 },
1181 {
1182 .src = MSM_BUS_MASTER_SPS,
1183 .dst = MSM_BUS_SLAVE_SPS,
1184 .ib = (492 * 8) * 1000000UL,
1185 .ab = (492 * 8) * 100000UL,
1186 },
1187 {
1188 .src = MSM_BUS_MASTER_SPDM,
1189 .dst = MSM_BUS_SLAVE_SPDM,
1190 .ib = (64 * 8) * 1000000UL,
1191 .ab = (64 * 8) * 100000UL,
1192 },
1193};
1194
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001195static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1196 {
1197 ARRAY_SIZE(qseecom_clks_init_vectors),
1198 qseecom_clks_init_vectors,
1199 },
1200 {
1201 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu1e8c7242012-09-04 11:52:57 -07001202 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001203 },
1204 {
1205 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1206 qseecom_enable_sfpb_vectors,
1207 },
Ramesh Masavarapu8d756582012-10-03 10:18:06 -07001208 {
1209 ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1210 qseecom_enable_dfab_sfpb_vectors,
1211 },
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001212};
1213
1214static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1215 qseecom_hw_bus_scale_usecases,
1216 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1217 .name = "qsee",
1218};
1219
1220static struct platform_device qseecom_device = {
1221 .name = "qseecom",
1222 .id = 0,
1223 .dev = {
1224 .platform_data = &qseecom_bus_pdata,
1225 },
1226};
1227#endif
1228
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001229#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1230 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1231 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1232 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1233
1234#define QCE_SIZE 0x10000
1235#define QCE_0_BASE 0x18500000
1236
1237#define QCE_HW_KEY_SUPPORT 0
1238#define QCE_SHA_HMAC_SUPPORT 1
1239#define QCE_SHARE_CE_RESOURCE 1
1240#define QCE_CE_SHARED 0
1241
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001242/* Begin Bus scaling definitions */
1243static struct msm_bus_vectors crypto_hw_init_vectors[] = {
1244 {
1245 .src = MSM_BUS_MASTER_ADM_PORT0,
1246 .dst = MSM_BUS_SLAVE_EBI_CH0,
1247 .ab = 0,
1248 .ib = 0,
1249 },
1250 {
1251 .src = MSM_BUS_MASTER_ADM_PORT1,
1252 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1253 .ab = 0,
1254 .ib = 0,
1255 },
1256};
1257
1258static struct msm_bus_vectors crypto_hw_active_vectors[] = {
1259 {
1260 .src = MSM_BUS_MASTER_ADM_PORT0,
1261 .dst = MSM_BUS_SLAVE_EBI_CH0,
1262 .ab = 70000000UL,
1263 .ib = 70000000UL,
1264 },
1265 {
1266 .src = MSM_BUS_MASTER_ADM_PORT1,
1267 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1268 .ab = 2480000000UL,
1269 .ib = 2480000000UL,
1270 },
1271};
1272
1273static struct msm_bus_paths crypto_hw_bus_scale_usecases[] = {
1274 {
1275 ARRAY_SIZE(crypto_hw_init_vectors),
1276 crypto_hw_init_vectors,
1277 },
1278 {
1279 ARRAY_SIZE(crypto_hw_active_vectors),
1280 crypto_hw_active_vectors,
1281 },
1282};
1283
1284static struct msm_bus_scale_pdata crypto_hw_bus_scale_pdata = {
1285 crypto_hw_bus_scale_usecases,
1286 ARRAY_SIZE(crypto_hw_bus_scale_usecases),
1287 .name = "cryptohw",
1288};
1289/* End Bus Scaling Definitions*/
1290
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001291static struct resource qcrypto_resources[] = {
1292 [0] = {
1293 .start = QCE_0_BASE,
1294 .end = QCE_0_BASE + QCE_SIZE - 1,
1295 .flags = IORESOURCE_MEM,
1296 },
1297 [1] = {
1298 .name = "crypto_channels",
1299 .start = DMOV_CE_IN_CHAN,
1300 .end = DMOV_CE_OUT_CHAN,
1301 .flags = IORESOURCE_DMA,
1302 },
1303 [2] = {
1304 .name = "crypto_crci_in",
1305 .start = DMOV_CE_IN_CRCI,
1306 .end = DMOV_CE_IN_CRCI,
1307 .flags = IORESOURCE_DMA,
1308 },
1309 [3] = {
1310 .name = "crypto_crci_out",
1311 .start = DMOV_CE_OUT_CRCI,
1312 .end = DMOV_CE_OUT_CRCI,
1313 .flags = IORESOURCE_DMA,
1314 },
1315};
1316
1317static struct resource qcedev_resources[] = {
1318 [0] = {
1319 .start = QCE_0_BASE,
1320 .end = QCE_0_BASE + QCE_SIZE - 1,
1321 .flags = IORESOURCE_MEM,
1322 },
1323 [1] = {
1324 .name = "crypto_channels",
1325 .start = DMOV_CE_IN_CHAN,
1326 .end = DMOV_CE_OUT_CHAN,
1327 .flags = IORESOURCE_DMA,
1328 },
1329 [2] = {
1330 .name = "crypto_crci_in",
1331 .start = DMOV_CE_IN_CRCI,
1332 .end = DMOV_CE_IN_CRCI,
1333 .flags = IORESOURCE_DMA,
1334 },
1335 [3] = {
1336 .name = "crypto_crci_out",
1337 .start = DMOV_CE_OUT_CRCI,
1338 .end = DMOV_CE_OUT_CRCI,
1339 .flags = IORESOURCE_DMA,
1340 },
1341};
1342
1343#endif
1344
1345#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1346 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1347
1348static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1349 .ce_shared = QCE_CE_SHARED,
1350 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1351 .hw_key_support = QCE_HW_KEY_SUPPORT,
1352 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001353 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001354};
1355
1356static struct platform_device qcrypto_device = {
1357 .name = "qcrypto",
1358 .id = 0,
1359 .num_resources = ARRAY_SIZE(qcrypto_resources),
1360 .resource = qcrypto_resources,
1361 .dev = {
1362 .coherent_dma_mask = DMA_BIT_MASK(32),
1363 .platform_data = &qcrypto_ce_hw_suppport,
1364 },
1365};
1366#endif
1367
1368#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1369 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1370
1371static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1372 .ce_shared = QCE_CE_SHARED,
1373 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1374 .hw_key_support = QCE_HW_KEY_SUPPORT,
1375 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001376 .bus_scale_table = &crypto_hw_bus_scale_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377};
1378
1379static struct platform_device qcedev_device = {
1380 .name = "qce",
1381 .id = 0,
1382 .num_resources = ARRAY_SIZE(qcedev_resources),
1383 .resource = qcedev_resources,
1384 .dev = {
1385 .coherent_dma_mask = DMA_BIT_MASK(32),
1386 .platform_data = &qcedev_ce_hw_suppport,
1387 },
1388};
1389#endif
1390
Joel King0cbf5d82012-05-24 15:21:38 -07001391static struct mdm_platform_data sglte_platform_data = {
1392 .mdm_version = "4.0",
1393 .ramdump_delay_ms = 1000,
Taniya Das2b7646b2013-01-15 11:28:14 +05301394 /* delay between two PS_HOLDs */
1395 .ps_hold_delay_ms = 500,
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] = {
Liron Kuch59339922013-01-01 18:29:47 +02001441 .name = "TSIF_TSPP_IRQ",
Joel Nider266a2642011-10-16 10:58:05 +02001442 .flags = IORESOURCE_IRQ,
1443 .start = TSIF_TSPP_IRQ,
Liron Kuch59339922013-01-01 18:29:47 +02001444 .end = TSIF_TSPP_IRQ,
Joel Nider266a2642011-10-16 10:58:05 +02001445 },
1446 [1] = {
Liron Kuch59339922013-01-01 18:29:47 +02001447 .name = "TSIF0_IRQ",
1448 .flags = IORESOURCE_IRQ,
1449 .start = TSIF1_IRQ,
1450 .end = TSIF1_IRQ,
1451 },
1452 [2] = {
1453 .name = "TSIF1_IRQ",
1454 .flags = IORESOURCE_IRQ,
1455 .start = TSIF2_IRQ,
1456 .end = TSIF2_IRQ,
1457 },
1458 [3] = {
1459 .name = "TSIF_BAM_IRQ",
1460 .flags = IORESOURCE_IRQ,
1461 .start = TSIF_BAM_IRQ,
1462 .end = TSIF_BAM_IRQ,
1463 },
1464 [4] = {
1465 .name = "MSM_TSIF0_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001466 .flags = IORESOURCE_MEM,
1467 .start = MSM_TSIF0_PHYS,
1468 .end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
1469 },
Liron Kuch59339922013-01-01 18:29:47 +02001470 [5] = {
1471 .name = "MSM_TSIF1_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001472 .flags = IORESOURCE_MEM,
1473 .start = MSM_TSIF1_PHYS,
1474 .end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
1475 },
Liron Kuch59339922013-01-01 18:29:47 +02001476 [6] = {
1477 .name = "MSM_TSPP_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001478 .flags = IORESOURCE_MEM,
1479 .start = MSM_TSPP_PHYS,
1480 .end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
1481 },
Liron Kuch59339922013-01-01 18:29:47 +02001482 [7] = {
1483 .name = "MSM_TSPP_BAM_PHYS",
Joel Nider266a2642011-10-16 10:58:05 +02001484 .flags = IORESOURCE_MEM,
1485 .start = MSM_TSPP_BAM_PHYS,
1486 .end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
1487 },
1488};
1489
1490static struct msm_tspp_platform_data tspp_platform_data = {
1491 .num_gpios = ARRAY_SIZE(tsif_gpios),
1492 .gpios = tsif_gpios,
1493 .tsif_pclk = "tsif_pclk",
1494 .tsif_ref_clk = "tsif_ref_clk",
1495};
1496
1497static struct platform_device msm_device_tspp = {
1498 .name = "msm_tspp",
1499 .id = 0,
1500 .num_resources = ARRAY_SIZE(tspp_resources),
1501 .resource = tspp_resources,
1502 .dev = {
1503 .platform_data = &tspp_platform_data
1504 },
1505};
1506
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001507#define MSM_SHARED_RAM_PHYS 0x80000000
1508
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001509static void __init msm8960_map_io(void)
1510{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001511 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001512 msm_map_msm8960_io();
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -08001513 if (socinfo_init() < 0)
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001514 pr_err("socinfo_init() failed!\n");
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001515
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001516}
1517
1518static void __init msm8960_init_irq(void)
1519{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001520 struct msm_mpm_device_data *data = NULL;
1521
1522#ifdef CONFIG_MSM_MPM
1523 data = &msm8960_mpm_dev_data;
1524#endif
1525
1526 msm_mpm_irq_extn_init(data);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001527 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001528 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001529}
1530
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001531static void __init msm8960_init_buses(void)
1532{
1533#ifdef CONFIG_MSM_BUS_SCALING
Gagan Macdc1dc142011-09-16 15:13:35 -06001534 msm_bus_rpm_set_mt_mask();
Gagan Macae154c4b2011-10-05 19:24:43 -06001535 msm_bus_8960_apps_fabric_pdata.rpm_enabled = 1;
1536 msm_bus_8960_sys_fabric_pdata.rpm_enabled = 1;
Gagan Macae154c4b2011-10-05 19:24:43 -06001537 msm_bus_apps_fabric.dev.platform_data =
1538 &msm_bus_8960_apps_fabric_pdata;
1539 msm_bus_sys_fabric.dev.platform_data = &msm_bus_8960_sys_fabric_pdata;
Gagan Mac680bfc02012-07-19 19:11:00 -06001540 if (cpu_is_msm8960ab()) {
1541 msm_bus_8960_sg_mm_fabric_pdata.rpm_enabled = 1;
1542 msm_bus_mm_fabric.dev.platform_data =
1543 &msm_bus_8960_sg_mm_fabric_pdata;
1544 } else {
1545 msm_bus_8960_mm_fabric_pdata.rpm_enabled = 1;
1546 msm_bus_mm_fabric.dev.platform_data =
1547 &msm_bus_8960_mm_fabric_pdata;
1548 }
Gagan Macae154c4b2011-10-05 19:24:43 -06001549 msm_bus_sys_fpb.dev.platform_data = &msm_bus_8960_sys_fpb_pdata;
1550 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_8960_cpss_fpb_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001551#endif
1552}
1553
1554static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
1555 .max_clock_speed = 15060000,
Kiran Gundac5fbd7f2012-07-30 13:22:39 +05301556 .infinite_mode = 0xFFC0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001557};
1558
1559#ifdef CONFIG_USB_MSM_OTG_72K
1560static struct msm_otg_platform_data msm_otg_pdata;
1561#else
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301562static int wr_phy_init_seq[] = {
1563 0x44, 0x80, /* set VBUS valid threshold
1564 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301565 0x68, 0x81, /* update DC voltage level */
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301566 0x14, 0x82, /* set preemphasis and rise/fall time */
1567 0x13, 0x83, /* set source impedance adjusment */
1568 -1};
1569
1570static int liquid_v1_phy_init_seq[] = {
1571 0x44, 0x80,/* set VBUS valid threshold
1572 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301573 0x6C, 0x81,/* update DC voltage level */
Anji jonnalaa8b8d732011-12-06 10:03:24 +05301574 0x18, 0x82,/* set preemphasis and rise/fall time */
1575 0x23, 0x83,/* set source impedance sdjusment */
1576 -1};
1577
Mayank Ranaa61da7a2012-08-14 10:57:00 +05301578static int sglte_phy_init_seq[] = {
1579 0x44, 0x80, /* set VBUS valid threshold
1580 and disconnect valid threshold */
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +05301581 0x6A, 0x81, /* update DC voltage level */
Mayank Ranaa61da7a2012-08-14 10:57:00 +05301582 0x24, 0x82, /* set preemphasis and rise/fall time */
1583 0x13, 0x83, /* set source impedance adjusment */
1584 -1};
1585
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301586#ifdef CONFIG_MSM_BUS_SCALING
1587/* Bandwidth requests (zero) if no vote placed */
1588static struct msm_bus_vectors usb_init_vectors[] = {
1589 {
1590 .src = MSM_BUS_MASTER_SPS,
1591 .dst = MSM_BUS_SLAVE_EBI_CH0,
1592 .ab = 0,
1593 .ib = 0,
1594 },
1595};
1596
1597/* Bus bandwidth requests in Bytes/sec */
1598static struct msm_bus_vectors usb_max_vectors[] = {
1599 {
1600 .src = MSM_BUS_MASTER_SPS,
1601 .dst = MSM_BUS_SLAVE_EBI_CH0,
1602 .ab = 60000000, /* At least 480Mbps on bus. */
1603 .ib = 960000000, /* MAX bursts rate */
1604 },
1605};
1606
1607static struct msm_bus_paths usb_bus_scale_usecases[] = {
1608 {
1609 ARRAY_SIZE(usb_init_vectors),
1610 usb_init_vectors,
1611 },
1612 {
1613 ARRAY_SIZE(usb_max_vectors),
1614 usb_max_vectors,
1615 },
1616};
1617
1618static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
1619 usb_bus_scale_usecases,
1620 ARRAY_SIZE(usb_bus_scale_usecases),
1621 .name = "usb",
1622};
1623#endif
1624
Jack Pham87f202f2012-08-06 00:24:22 -07001625#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
1626
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627static struct msm_otg_platform_data msm_otg_pdata = {
1628 .mode = USB_OTG,
1629 .otg_control = OTG_PMIC_CONTROL,
1630 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
Anji jonnala4e3e6772011-09-15 18:53:42 +05301632 .power_budget = 750,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301633#ifdef CONFIG_MSM_BUS_SCALING
1634 .bus_scale_table = &usb_bus_scale_pdata,
Jack Pham87f202f2012-08-06 00:24:22 -07001635 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Manu Gautamcd82e9d2011-12-20 14:17:28 +05301636#endif
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +05301637#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
1638 .mhl_dev_name = "sii8334",
1639#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001640};
1641#endif
1642
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301643#ifdef CONFIG_USB_EHCI_MSM_HSIC
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +05301644#define HSIC_HUB_RESET_GPIO 91
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301645static struct msm_hsic_host_platform_data msm_hsic_pdata = {
1646 .strobe = 150,
1647 .data = 151,
1648};
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301649
1650static struct smsc_hub_platform_data hsic_hub_pdata = {
1651 .hub_reset = HSIC_HUB_RESET_GPIO,
1652};
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301653#else
1654static struct msm_hsic_host_platform_data msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301655static struct smsc_hub_platform_data hsic_hub_pdata;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05301656#endif
1657
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05301658static struct platform_device smsc_hub_device = {
1659 .name = "msm_smsc_hub",
1660 .id = -1,
1661 .dev = {
1662 .platform_data = &hsic_hub_pdata,
1663 },
1664};
1665
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001666#define PID_MAGIC_ID 0x71432909
1667#define SERIAL_NUM_MAGIC_ID 0x61945374
1668#define SERIAL_NUMBER_LENGTH 127
1669#define DLOAD_USB_BASE_ADD 0x2A03F0C8
1670
1671struct magic_num_struct {
1672 uint32_t pid;
1673 uint32_t serial_num;
1674};
1675
1676struct dload_struct {
1677 uint32_t reserved1;
1678 uint32_t reserved2;
1679 uint32_t reserved3;
1680 uint16_t reserved4;
1681 uint16_t pid;
1682 char serial_number[SERIAL_NUMBER_LENGTH];
1683 uint16_t reserved5;
1684 struct magic_num_struct magic_struct;
1685};
1686
1687static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1688{
1689 struct dload_struct __iomem *dload = 0;
1690
1691 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1692 if (!dload) {
1693 pr_err("%s: cannot remap I/O memory region: %08x\n",
1694 __func__, DLOAD_USB_BASE_ADD);
1695 return -ENXIO;
1696 }
1697
1698 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1699 __func__, dload, pid, snum);
1700 /* update pid */
1701 dload->magic_struct.pid = PID_MAGIC_ID;
1702 dload->pid = pid;
1703
1704 /* update serial number */
1705 dload->magic_struct.serial_num = 0;
1706 if (!snum) {
1707 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
1708 goto out;
1709 }
1710
1711 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
Jin Honge49b1482011-10-03 11:15:50 -07001712 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001713out:
1714 iounmap(dload);
1715 return 0;
1716}
1717
1718static struct android_usb_platform_data android_usb_pdata = {
1719 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1720};
1721
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07001722static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001723 .name = "android_usb",
1724 .id = -1,
1725 .dev = {
1726 .platform_data = &android_usb_pdata,
1727 },
1728};
1729
1730static uint8_t spm_wfi_cmd_sequence[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001731 0x03, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001732};
1733
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001734static uint8_t spm_retention_cmd_sequence[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001735 0x00, 0x05, 0x03, 0x0D,
1736 0x0B, 0x00, 0x0f,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001737};
1738
Anji Jonnala1a1711a2013-01-29 13:34:10 +05301739static uint8_t spm_retention_with_krait_v3_cmd_sequence[] __initdata = {
1740 0x42, 0x1B, 0x00,
1741 0x05, 0x03, 0x01, 0x0B,
1742 0x00, 0x42, 0x1B,
1743 0x0f,
1744};
1745
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001746static uint8_t spm_power_collapse_without_rpm[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001747 0x00, 0x24, 0x54, 0x10,
1748 0x09, 0x03, 0x01,
1749 0x10, 0x54, 0x30, 0x0C,
1750 0x24, 0x30, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001751};
1752
1753static uint8_t spm_power_collapse_with_rpm[] __initdata = {
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07001754 0x00, 0x24, 0x54, 0x10,
1755 0x09, 0x07, 0x01, 0x0B,
1756 0x10, 0x54, 0x30, 0x0C,
1757 0x24, 0x30, 0x0f,
1758};
1759
1760/* 8960AB has a different command to assert apc_pdn */
1761static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
1762 0x00, 0x24, 0x84, 0x10,
1763 0x09, 0x03, 0x01,
1764 0x10, 0x84, 0x30, 0x0C,
1765 0x24, 0x30, 0x0f,
1766};
1767
1768static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
1769 0x00, 0x24, 0x84, 0x10,
1770 0x09, 0x07, 0x01, 0x0B,
1771 0x10, 0x84, 0x30, 0x0C,
1772 0x24, 0x30, 0x0f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001773};
1774
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001775static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
1776 [0] = {
1777 .mode = MSM_SPM_MODE_CLOCK_GATING,
1778 .notify_rpm = false,
1779 .cmd = spm_wfi_cmd_sequence,
1780 },
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001781 [1] = {
1782 .mode = MSM_SPM_MODE_POWER_RETENTION,
1783 .notify_rpm = false,
1784 .cmd = spm_retention_cmd_sequence,
1785 },
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001786 [2] = {
1787 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1788 .notify_rpm = false,
1789 .cmd = spm_power_collapse_without_rpm,
1790 },
1791 [3] = {
1792 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1793 .notify_rpm = true,
1794 .cmd = spm_power_collapse_with_rpm,
1795 },
1796};
1797
1798static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001799 [0] = {
1800 .mode = MSM_SPM_MODE_CLOCK_GATING,
1801 .notify_rpm = false,
1802 .cmd = spm_wfi_cmd_sequence,
1803 },
Anji Jonnala1a1711a2013-01-29 13:34:10 +05301804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805 [1] = {
Anji Jonnala1a1711a2013-01-29 13:34:10 +05301806 .mode = MSM_SPM_MODE_POWER_RETENTION,
1807 .notify_rpm = false,
1808 .cmd = spm_retention_cmd_sequence,
1809 },
1810
1811 [2] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001812 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1813 .notify_rpm = false,
1814 .cmd = spm_power_collapse_without_rpm,
1815 },
Anji Jonnala1a1711a2013-01-29 13:34:10 +05301816
1817 [3] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001818 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1819 .notify_rpm = true,
1820 .cmd = spm_power_collapse_with_rpm,
1821 },
1822};
1823
1824static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1825 [0] = {
1826 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001827 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001828#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnala39dd7252012-11-26 15:56:26 +05301829 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaram631f2822012-03-16 12:08:42 -06001830 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001831#endif
1832 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001833 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
1834 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
1835 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001836 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001837 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
1838 .modes = msm_spm_boot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001839 },
1840 [1] = {
1841 .reg_base_addr = MSM_SAW1_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001842 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001843#if defined(CONFIG_MSM_AVS_HW)
Anji Jonnala39dd7252012-11-26 15:56:26 +05301844 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x58589464,
Praveen Chidambaram631f2822012-03-16 12:08:42 -06001845 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00020000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001846#endif
1847 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001848 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001849 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1850 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1851 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001852 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
1853 .modes = msm_spm_nonboot_cpu_seq_list,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001854 },
1855};
1856
1857static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1858 0x00, 0x20, 0x03, 0x20,
1859 0x00, 0x0f,
1860};
1861
1862static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1863 0x00, 0x20, 0x34, 0x64,
1864 0x48, 0x07, 0x48, 0x20,
1865 0x50, 0x64, 0x04, 0x34,
1866 0x50, 0x0f,
1867};
1868static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1869 0x00, 0x10, 0x34, 0x64,
1870 0x48, 0x07, 0x48, 0x10,
1871 0x50, 0x64, 0x04, 0x34,
1872 0x50, 0x0F,
1873};
1874
1875static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1876 [0] = {
1877 .mode = MSM_SPM_L2_MODE_RETENTION,
1878 .notify_rpm = false,
1879 .cmd = l2_spm_wfi_cmd_sequence,
1880 },
1881 [1] = {
1882 .mode = MSM_SPM_L2_MODE_GDHS,
1883 .notify_rpm = true,
1884 .cmd = l2_spm_gdhs_cmd_sequence,
1885 },
1886 [2] = {
1887 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1888 .notify_rpm = true,
1889 .cmd = l2_spm_power_off_cmd_sequence,
1890 },
1891};
1892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1894 [0] = {
1895 .reg_base_addr = MSM_SAW_L2_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001896 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001897 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001898 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1899 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1900 .modes = msm_spm_l2_seq_list,
1901 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1902 },
1903};
1904
Anirudh Ghayal15698162012-07-31 11:51:32 +05301905#define HAP_SHIFT_LVL_OE_GPIO 47
1906#define HAP_SHIFT_LVL_OE_GPIO_SGLTE 89
Mohan Pallaka5e490392011-09-09 15:18:41 +05301907#define PM_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1908#define PM_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1909
1910static struct msm_xo_voter *xo_handle_d1;
1911
1912static int isa1200_power(int on)
1913{
1914 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301915 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301916
Anirudh Ghayal15698162012-07-31 11:51:32 +05301917 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1918 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1919
1920
1921 gpio_set_value(hap_oe_gpio, !!on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301922
1923 rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
1924 msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
1925 if (rc < 0) {
1926 pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
1927 __func__, on ? "" : "de-", rc);
1928 goto err_xo_vote;
1929 }
1930
1931 return 0;
1932
1933err_xo_vote:
Anirudh Ghayal15698162012-07-31 11:51:32 +05301934 gpio_set_value(hap_oe_gpio, !on);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301935 return rc;
1936}
1937
1938static int isa1200_dev_setup(bool enable)
1939{
1940 int rc = 0;
Anirudh Ghayal15698162012-07-31 11:51:32 +05301941 int hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO;
Mohan Pallaka5e490392011-09-09 15:18:41 +05301942
1943 struct pm_gpio hap_gpio_config = {
1944 .direction = PM_GPIO_DIR_OUT,
1945 .pull = PM_GPIO_PULL_NO,
1946 .out_strength = PM_GPIO_STRENGTH_HIGH,
1947 .function = PM_GPIO_FUNC_NORMAL,
1948 .inv_int_pol = 0,
1949 .vin_sel = 2,
1950 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1951 .output_value = 0,
1952 };
1953
Anirudh Ghayal15698162012-07-31 11:51:32 +05301954 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
1955 hap_oe_gpio = HAP_SHIFT_LVL_OE_GPIO_SGLTE;
1956
Mohan Pallaka5e490392011-09-09 15:18:41 +05301957 if (enable == true) {
1958 rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
1959 if (rc) {
1960 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1961 __func__, PM_HAP_EN_GPIO, rc);
1962 return rc;
1963 }
1964
1965 rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
1966 if (rc) {
1967 pr_err("%s: pm8921 gpio %d config failed(%d)\n",
1968 __func__, PM_HAP_LEN_GPIO, rc);
1969 return rc;
1970 }
1971
Anirudh Ghayal15698162012-07-31 11:51:32 +05301972 rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
Mohan Pallaka5e490392011-09-09 15:18:41 +05301973 if (rc) {
1974 pr_err("%s: unable to request gpio %d (%d)\n",
Anirudh Ghayal15698162012-07-31 11:51:32 +05301975 __func__, hap_oe_gpio, rc);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301976 return rc;
1977 }
1978
Anirudh Ghayal15698162012-07-31 11:51:32 +05301979 rc = gpio_direction_output(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301980 if (rc) {
1981 pr_err("%s: Unable to set direction\n", __func__);
1982 goto free_gpio;
1983 }
1984
1985 xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
1986 if (IS_ERR(xo_handle_d1)) {
1987 rc = PTR_ERR(xo_handle_d1);
1988 pr_err("%s: failed to get the handle for D1(%d)\n",
1989 __func__, rc);
1990 goto gpio_set_dir;
1991 }
1992 } else {
Anirudh Ghayal15698162012-07-31 11:51:32 +05301993 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05301994
1995 msm_xo_put(xo_handle_d1);
1996 }
1997
1998 return 0;
1999
2000gpio_set_dir:
Anirudh Ghayal15698162012-07-31 11:51:32 +05302001 gpio_set_value(hap_oe_gpio, 0);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302002free_gpio:
Anirudh Ghayal15698162012-07-31 11:51:32 +05302003 gpio_free(hap_oe_gpio);
Mohan Pallaka5e490392011-09-09 15:18:41 +05302004 return rc;
2005}
2006
2007static struct isa1200_regulator isa1200_reg_data[] = {
2008 {
2009 .name = "vcc_i2c",
2010 .min_uV = ISA_I2C_VTG_MIN_UV,
2011 .max_uV = ISA_I2C_VTG_MAX_UV,
2012 .load_uA = ISA_I2C_CURR_UA,
2013 },
2014};
2015
2016static struct isa1200_platform_data isa1200_1_pdata = {
2017 .name = "vibrator",
2018 .dev_setup = isa1200_dev_setup,
2019 .power_on = isa1200_power,
2020 .hap_en_gpio = PM_HAP_EN_GPIO,
2021 .hap_len_gpio = PM_HAP_LEN_GPIO,
2022 .max_timeout = 15000,
2023 .mode_ctrl = PWM_GEN_MODE,
2024 .pwm_fd = {
2025 .pwm_div = 256,
2026 },
2027 .is_erm = false,
2028 .smart_en = true,
2029 .ext_clk_en = true,
2030 .chip_en = 1,
2031 .regulator_info = isa1200_reg_data,
2032 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
2033};
2034
2035static struct i2c_board_info msm_isa1200_board_info[] __initdata = {
2036 {
2037 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
Mohan Pallaka5e490392011-09-09 15:18:41 +05302038 },
2039};
2040
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002041#define CYTTSP_TS_GPIO_IRQ 11
2042#define CYTTSP_TS_SLEEP_GPIO 50
2043#define CYTTSP_TS_RESOUT_N_GPIO 52
2044
2045/*virtual key support */
2046static ssize_t tma340_vkeys_show(struct kobject *kobj,
2047 struct kobj_attribute *attr, char *buf)
2048{
2049 return snprintf(buf, 200,
2050 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2051 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2052 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2053 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2054 "\n");
2055}
2056
2057static struct kobj_attribute tma340_vkeys_attr = {
2058 .attr = {
2059 .mode = S_IRUGO,
2060 },
2061 .show = &tma340_vkeys_show,
2062};
2063
2064static struct attribute *tma340_properties_attrs[] = {
2065 &tma340_vkeys_attr.attr,
2066 NULL
2067};
2068
2069static struct attribute_group tma340_properties_attr_group = {
2070 .attrs = tma340_properties_attrs,
2071};
2072
2073
2074static int cyttsp_platform_init(struct i2c_client *client)
2075{
2076 int rc = 0;
2077 static struct kobject *tma340_properties_kobj;
2078
2079 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2080 tma340_properties_kobj = kobject_create_and_add("board_properties",
2081 NULL);
2082 if (tma340_properties_kobj)
2083 rc = sysfs_create_group(tma340_properties_kobj,
2084 &tma340_properties_attr_group);
2085 if (!tma340_properties_kobj || rc)
2086 pr_err("%s: failed to create board_properties\n",
2087 __func__);
2088
2089 return 0;
2090}
2091
2092static struct cyttsp_regulator regulator_data[] = {
2093 {
2094 .name = "vdd",
2095 .min_uV = CY_TMA300_VTG_MIN_UV,
2096 .max_uV = CY_TMA300_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302097 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
2098 .lpm_load_uA = CY_TMA300_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002099 },
2100 /* TODO: Remove after runtime PM is enabled in I2C driver */
2101 {
2102 .name = "vcc_i2c",
2103 .min_uV = CY_I2C_VTG_MIN_UV,
2104 .max_uV = CY_I2C_VTG_MAX_UV,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05302105 .hpm_load_uA = CY_I2C_CURR_UA,
2106 .lpm_load_uA = CY_I2C_SLEEP_CURR_UA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002107 },
2108};
2109
2110static struct cyttsp_platform_data cyttsp_pdata = {
2111 .panel_maxx = 634,
2112 .panel_maxy = 1166,
2113 .disp_maxx = 616,
2114 .disp_maxy = 1023,
2115 .disp_minx = 0,
2116 .disp_miny = 16,
2117 .flags = 0x01,
2118 .gen = CY_GEN3, /* or */
2119 .use_st = CY_USE_ST,
2120 .use_mt = CY_USE_MT,
2121 .use_hndshk = CY_SEND_HNDSHK,
2122 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302123 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002124 .use_gestures = CY_USE_GESTURES,
2125 .fw_fname = "cyttsp_8960_cdp.hex",
2126 /* activate up to 4 groups
2127 * and set active distance
2128 */
2129 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2130 CY_GEST_GRP3 | CY_GEST_GRP4 |
2131 CY_ACT_DIST,
Amy Maloche7b741b22012-06-14 14:37:22 -07002132 .act_intrvl = 10,
2133 .tch_tmout = 200,
2134 .lp_intrvl = 30,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002135 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2136 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2137 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2138 .regulator_info = regulator_data,
2139 .num_regulators = ARRAY_SIZE(regulator_data),
2140 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302141 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002142};
2143
2144static struct i2c_board_info cyttsp_info[] __initdata = {
2145 {
2146 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2147 .platform_data = &cyttsp_pdata,
2148#ifndef CY_USE_TIMER
2149 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2150#endif /* CY_USE_TIMER */
2151 },
2152};
2153
Jing Lindc4413c2012-01-16 15:22:52 -08002154/* configuration data for mxt1386 */
2155static const u8 mxt1386_config_data[] = {
Mohan Pallaka50837382011-09-07 11:00:57 +05302156 /* T6 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002157 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302158 /* T38 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002159 11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
Jing Lin2f863172011-10-17 10:56:58 -07002160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2165 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302166 /* T7 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002167 100, 16, 50,
Mohan Pallaka50837382011-09-07 11:00:57 +05302168 /* T8 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002169 8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
Mohan Pallaka50837382011-09-07 11:00:57 +05302170 /* T9 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002171 131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
2172 0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
2173 85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
2174 10, 10, 45, 46,
Mohan Pallaka50837382011-09-07 11:00:57 +05302175 /* T15 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2177 0,
Anirudh Ghayaldab4e0d2012-01-09 14:59:27 +05302178 /* T18 Object */
2179 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302180 /* T22 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002181 5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
2182 0, 0, 5, 8, 10, 13, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302183 /* T24 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2185 0, 0, 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302186 /* T25 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002187 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
2188 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302189 /* T27 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002190 0, 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302191 /* T28 Object */
Jing Lin93f07082011-11-11 15:53:54 -08002192 0, 0, 0, 8, 12, 60,
Mohan Pallaka50837382011-09-07 11:00:57 +05302193 /* T40 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002194 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302195 /* T41 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002196 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302197 /* T43 Object */
Jing Lin2f863172011-10-17 10:56:58 -07002198 0, 0, 0, 0, 0, 0,
Mohan Pallaka50837382011-09-07 11:00:57 +05302199};
2200
Jing Lin33b007d2011-12-21 17:40:23 -08002201/* configuration data for mxt1386e using V1.0 firmware */
2202static const u8 mxt1386e_config_data_v1_0[] = {
2203 /* T6 Object */
2204 0, 0, 0, 0, 0, 0,
2205 /* T38 Object */
2206 12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
2207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2209 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2210 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2212 0, 0, 0, 0,
2213 /* T7 Object */
2214 100, 16, 50,
2215 /* T8 Object */
2216 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2217 /* T9 Object */
2218 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2219 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
2220 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2221 10, 5, 0, 0, 0,
2222 /* T18 Object */
2223 0, 0,
2224 /* T24 Object */
2225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2226 0, 0, 0, 0, 0, 0, 0, 0, 0,
2227 /* T25 Object */
2228 3, 0, 60, 115, 156, 99,
2229 /* T27 Object */
2230 0, 0, 0, 0, 0, 0, 0,
2231 /* T40 Object */
2232 0, 0, 0, 0, 0,
2233 /* T42 Object */
2234 2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
2235 /* T43 Object */
2236 0, 0, 0, 0, 0, 0, 0,
2237 /* T46 Object */
2238 64, 0, 20, 20, 0, 0, 0, 0, 0,
2239 /* T47 Object */
2240 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2241 /* T48 Object */
2242 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
2243 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2244 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2245 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2247 0, 0, 0, 0,
2248 /* T56 Object */
2249 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2253 2, 99, 33,
2254};
2255
2256/* configuration data for mxt1386e using V2.1 firmware */
2257static const u8 mxt1386e_config_data_v2_1[] = {
2258 /* T6 Object */
2259 0, 0, 0, 0, 0, 0,
2260 /* T38 Object */
Jing Lin4a8a3e42012-09-12 10:08:22 -07002261 12, 5, 0, 28, 8, 12, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2267 0, 0, 0, 0,
2268 /* T7 Object */
Jing Lin4a8a3e42012-09-12 10:08:22 -07002269 32, 16, 50,
Jing Lin33b007d2011-12-21 17:40:23 -08002270 /* T8 Object */
2271 25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
2272 /* T9 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002273 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lina0bc4102012-07-06 17:03:45 -07002274 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Lin33b007d2011-12-21 17:40:23 -08002275 85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
2276 10, 5, 0, 0, 0,
2277 /* T18 Object */
2278 0, 0,
2279 /* T24 Object */
2280 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2281 0, 0, 0, 0, 0, 0, 0, 0, 0,
2282 /* T25 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002283 1, 0, 60, 115, 156, 99,
Jing Lin33b007d2011-12-21 17:40:23 -08002284 /* T27 Object */
2285 0, 0, 0, 0, 0, 0, 0,
2286 /* T40 Object */
2287 0, 0, 0, 0, 0,
2288 /* T42 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002289 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002290 /* T43 Object */
2291 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
2292 16,
2293 /* T46 Object */
Jing Lina0bc4102012-07-06 17:03:45 -07002294 64, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002295 /* T47 Object */
2296 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2297 /* T48 Object */
Jing Lin763f4772012-05-25 13:39:40 -07002298 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin33b007d2011-12-21 17:40:23 -08002299 48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
2300 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
2301 52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
2302 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2303 0, 0, 0, 0,
2304 /* T56 Object */
2305 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2306 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2307 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2308 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2309 2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
2310 255,
2311};
2312
Jing Lineec88ca2012-02-08 11:18:30 -08002313/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
2314static const u8 mxt1386e_config_data_3d[] = {
2315 /* T6 Object */
2316 0, 0, 0, 0, 0, 0,
2317 /* T38 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002318 13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2323 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2324 0, 0, 0, 0,
2325 /* T7 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002326 100, 10, 50,
Jing Lineec88ca2012-02-08 11:18:30 -08002327 /* T8 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002328 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002329 /* T9 Object */
2330 131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
2331 0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
Jing Lin66ba78b2012-02-24 21:25:12 -08002332 127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
2333 20, 5, 54, 49, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002334 /* T18 Object */
2335 0, 0,
2336 /* T24 Object */
2337 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2338 0, 0, 0, 0, 0, 0, 0, 0, 0,
2339 /* T25 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002340 0, 0, 72, 113, 168, 97,
Jing Lineec88ca2012-02-08 11:18:30 -08002341 /* T27 Object */
2342 0, 0, 0, 0, 0, 0, 0,
2343 /* T40 Object */
2344 0, 0, 0, 0, 0,
2345 /* T42 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002347 /* T43 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2349 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002350 /* T46 Object */
Jing Lin66ba78b2012-02-24 21:25:12 -08002351 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002352 /* T47 Object */
2353 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
2354 /* T48 Object */
2355 31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002356 32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
2357 0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
2358 52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002359 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2360 0, 0, 0, 0,
2361 /* T56 Object */
2362 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2364 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2365 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Lin66ba78b2012-02-24 21:25:12 -08002366 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2367 0,
Jing Lineec88ca2012-02-08 11:18:30 -08002368};
2369
Amy Maloche08266db2011-11-04 11:07:16 -07002370#define MXT_TS_GPIO_IRQ 11
2371#define MXT_TS_LDO_EN_GPIO 50
2372#define MXT_TS_RESET_GPIO 52
Mohan Pallaka50837382011-09-07 11:00:57 +05302373
2374static void mxt_init_hw_liquid(void)
2375{
2376 int rc;
2377
Mohan Pallaka50837382011-09-07 11:00:57 +05302378 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
2379 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002380 pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
2381 __func__, MXT_TS_LDO_EN_GPIO);
2382 return;
Mohan Pallaka50837382011-09-07 11:00:57 +05302383 }
2384
2385 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
2386 if (rc) {
Amy Maloche08266db2011-11-04 11:07:16 -07002387 pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
2388 __func__, MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302389 goto err_ldo_gpio_req;
2390 }
2391
Mohan Pallaka50837382011-09-07 11:00:57 +05302392 return;
2393
Mohan Pallaka50837382011-09-07 11:00:57 +05302394err_ldo_gpio_req:
2395 gpio_free(MXT_TS_LDO_EN_GPIO);
Mohan Pallaka50837382011-09-07 11:00:57 +05302396}
2397
Jing Lineec88ca2012-02-08 11:18:30 -08002398static struct mxt_config_info mxt_config_array_2d[] = {
Jing Lindc4413c2012-01-16 15:22:52 -08002399 {
2400 .config = mxt1386_config_data,
2401 .config_length = ARRAY_SIZE(mxt1386_config_data),
2402 .family_id = 0xA0,
2403 .variant_id = 0x0,
2404 .version = 0x10,
2405 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002406 .bootldr_id = MXT_BOOTLOADER_ID_1386,
Jing Lindc4413c2012-01-16 15:22:52 -08002407 },
Jing Lin33b007d2011-12-21 17:40:23 -08002408 {
2409 .config = mxt1386e_config_data_v1_0,
2410 .config_length = ARRAY_SIZE(mxt1386e_config_data_v1_0),
2411 .family_id = 0xA0,
2412 .variant_id = 0x2,
2413 .version = 0x10,
2414 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002415 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002416 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
Jing Lin33b007d2011-12-21 17:40:23 -08002417 },
2418 {
2419 .config = mxt1386e_config_data_v2_1,
2420 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2421 .family_id = 0xA0,
2422 .variant_id = 0x7,
2423 .version = 0x21,
2424 .build = 0xAA,
Anirudh Ghayala77941e2012-02-23 19:12:26 -08002425 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Linaeaeed52012-03-26 14:57:15 -07002426 .fw_name = "atmel_8960_liquid_v2_2_AA.hex",
2427 },
2428 {
2429 /* The config data for V2.2.AA is the same as for V2.1.AA */
2430 .config = mxt1386e_config_data_v2_1,
2431 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
2432 .family_id = 0xA0,
2433 .variant_id = 0x7,
2434 .version = 0x22,
2435 .build = 0xAA,
2436 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin33b007d2011-12-21 17:40:23 -08002437 },
Jing Lindc4413c2012-01-16 15:22:52 -08002438};
2439
Jing Lineec88ca2012-02-08 11:18:30 -08002440static struct mxt_platform_data mxt_platform_data_2d = {
2441 .config_array = mxt_config_array_2d,
2442 .config_array_size = ARRAY_SIZE(mxt_config_array_2d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002443 .panel_minx = 0,
2444 .panel_maxx = 1365,
2445 .panel_miny = 0,
2446 .panel_maxy = 767,
2447 .disp_minx = 0,
2448 .disp_maxx = 1365,
2449 .disp_miny = 0,
2450 .disp_maxy = 767,
Mohan Pallaka50837382011-09-07 11:00:57 +05302451 .irqflags = IRQF_TRIGGER_FALLING,
Jing Lin2f863172011-10-17 10:56:58 -07002452 .i2c_pull_up = true,
Amy Maloche08266db2011-11-04 11:07:16 -07002453 .reset_gpio = MXT_TS_RESET_GPIO,
2454 .irq_gpio = MXT_TS_GPIO_IRQ,
Mohan Pallaka50837382011-09-07 11:00:57 +05302455};
2456
Jing Lineec88ca2012-02-08 11:18:30 -08002457static struct mxt_config_info mxt_config_array_3d[] = {
2458 {
2459 .config = mxt1386e_config_data_3d,
2460 .config_length = ARRAY_SIZE(mxt1386e_config_data_3d),
2461 .family_id = 0xA0,
2462 .variant_id = 0x7,
2463 .version = 0x21,
2464 .build = 0xAA,
2465 },
2466};
2467
2468static struct mxt_platform_data mxt_platform_data_3d = {
2469 .config_array = mxt_config_array_3d,
2470 .config_array_size = ARRAY_SIZE(mxt_config_array_3d),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08002471 .panel_minx = 0,
2472 .panel_maxx = 1919,
2473 .panel_miny = 0,
2474 .panel_maxy = 1199,
2475 .disp_minx = 0,
2476 .disp_maxx = 1919,
2477 .disp_miny = 0,
2478 .disp_maxy = 1199,
Jing Lineec88ca2012-02-08 11:18:30 -08002479 .irqflags = IRQF_TRIGGER_FALLING,
2480 .i2c_pull_up = true,
2481 .reset_gpio = MXT_TS_RESET_GPIO,
2482 .irq_gpio = MXT_TS_GPIO_IRQ,
2483};
2484
Mohan Pallaka50837382011-09-07 11:00:57 +05302485static struct i2c_board_info mxt_device_info[] __initdata = {
2486 {
2487 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
Mohan Pallaka50837382011-09-07 11:00:57 +05302488 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
2489 },
2490};
2491
Manoj Rao14648742012-03-30 19:42:12 -07002492static struct msm_mhl_platform_data mhl_platform_data = {
2493 .irq = MSM_GPIO_TO_INT(4),
Manoj Raoc6d904c2012-06-22 00:32:14 -07002494 .gpio_mhl_int = MHL_GPIO_INT,
2495 .gpio_mhl_reset = MHL_GPIO_RESET,
2496 .gpio_mhl_power = 0,
2497 .gpio_hdmi_mhl_mux = 0,
Manoj Rao14648742012-03-30 19:42:12 -07002498};
Manoj Rao14648742012-03-30 19:42:12 -07002499
Eugene Yasmand2316b82011-12-07 18:23:48 +02002500static struct i2c_board_info sii_device_info[] __initdata = {
2501 {
Manoj Rao14648742012-03-30 19:42:12 -07002502#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
2503 /*
2504 * keeps SI 8334 as the default
2505 * MHL TX
2506 */
2507 I2C_BOARD_INFO("sii8334", 0x39),
2508 .platform_data = &mhl_platform_data,
2509#endif
2510#ifdef CONFIG_FB_MSM_HDMI_MHL_9244
Eugene Yasmand2316b82011-12-07 18:23:48 +02002511 I2C_BOARD_INFO("Sil-9244", 0x39),
Eugene Yasmand2316b82011-12-07 18:23:48 +02002512 .irq = MSM_GPIO_TO_INT(15),
Manoj Rao14648742012-03-30 19:42:12 -07002513#endif /* CONFIG_MSM_HDMI_MHL */
2514 .flags = I2C_CLIENT_WAKE,
Eugene Yasmand2316b82011-12-07 18:23:48 +02002515 },
2516};
2517
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002518static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2519 .clk_freq = 100000,
2520 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002521};
2522
2523static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2524 .clk_freq = 100000,
2525 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002526};
2527
2528static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2529 .clk_freq = 100000,
2530 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002531};
2532
2533static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2534 .clk_freq = 100000,
2535 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002536};
2537
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002538static struct ks8851_pdata spi_eth_pdata = {
2539 .irq_gpio = KS8851_IRQ_GPIO,
2540 .rst_gpio = KS8851_RST_GPIO,
2541};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002542
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302543static struct spi_board_info spi_eth_info[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002544 {
2545 .modalias = "ks8851",
2546 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2547 .max_speed_hz = 19200000,
2548 .bus_num = 0,
2549 .chip_select = 0,
2550 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07002551 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002552 },
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05302553};
2554static struct spi_board_info spi_board_info[] __initdata = {
Chandan Uddaraju15e54b92011-09-12 10:52:36 -07002555 {
2556 .modalias = "dsi_novatek_3d_panel_spi",
2557 .max_speed_hz = 10800000,
2558 .bus_num = 0,
2559 .chip_select = 1,
2560 .mode = SPI_MODE_0,
2561 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002562};
2563
2564static struct platform_device msm_device_saw_core0 = {
2565 .name = "saw-regulator",
2566 .id = 0,
2567 .dev = {
2568 .platform_data = &msm_saw_regulator_pdata_s5,
2569 },
2570};
2571
2572static struct platform_device msm_device_saw_core1 = {
2573 .name = "saw-regulator",
2574 .id = 1,
2575 .dev = {
2576 .platform_data = &msm_saw_regulator_pdata_s6,
2577 },
2578};
2579
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002580static struct tsens_platform_data msm_tsens_pdata = {
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08002581 .slope = {910, 910, 910, 910, 910},
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07002582 .tsens_factor = 1000,
2583 .hw_type = MSM_8960,
2584 .tsens_num_sensor = 5,
2585};
2586
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002587static struct platform_device msm_tsens_device = {
2588 .name = "tsens8960-tm",
2589 .id = -1,
2590};
2591
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002592static struct msm_thermal_data msm_thermal_pdata = {
2593 .sensor_id = 0,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06002594 .poll_ms = 250,
2595 .limit_temp_degC = 60,
2596 .temp_hysteresis_degC = 10,
2597 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06002598};
2599
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002600#ifdef CONFIG_MSM_FAKE_BATTERY
2601static struct platform_device fish_battery_device = {
2602 .name = "fish_battery",
2603};
2604#endif
2605
Binqiang Qiuf165c922012-08-15 18:00:18 -07002606#ifdef CONFIG_BATTERY_BCL
2607static struct platform_device battery_bcl_device = {
2608 .name = "battery_current_limit",
2609 .id = -1,
2610};
2611#endif
2612
David Collins26f05562011-06-20 09:56:28 -07002613static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002614 .name = GPIO_REGULATOR_DEV_NAME,
2615 .id = PM8921_MPP_PM_TO_SYS(7),
2616 .dev = {
2617 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2618 },
2619};
2620
David Collins26f05562011-06-20 09:56:28 -07002621static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002622 .name = GPIO_REGULATOR_DEV_NAME,
2623 .id = 91,
2624 .dev = {
2625 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2626 },
2627};
2628
David Collinsb10be1d2011-09-02 10:29:31 -07002629static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2630 .name = GPIO_REGULATOR_DEV_NAME,
2631 .id = PM8921_GPIO_PM_TO_SYS(17),
2632 .dev = {
2633 .platform_data =
2634 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2635 },
2636};
2637
David Collins35a78f52011-12-14 15:54:25 -08002638static struct platform_device msm8960_device_ext_otg_sw_vreg __devinitdata = {
2639 .name = GPIO_REGULATOR_DEV_NAME,
2640 .id = PM8921_GPIO_PM_TO_SYS(42),
2641 .dev = {
2642 .platform_data =
2643 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_OTG_SW],
2644 },
2645};
2646
David Collins26f05562011-06-20 09:56:28 -07002647static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2648 .name = "rpm-regulator",
2649 .id = -1,
2650 .dev = {
2651 .platform_data = &msm_rpm_regulator_pdata,
2652 },
2653};
Mayank Ranae009c922012-03-22 03:02:06 +05302654#ifdef CONFIG_SERIAL_MSM_HS
2655static int configure_uart_gpios(int on)
2656{
2657 int ret = 0, i;
2658 int uart_gpios[] = {93, 94, 95, 96};
2659
2660 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2661 if (on) {
2662 ret = gpio_request(uart_gpios[i], NULL);
2663 if (ret) {
2664 pr_err("%s: unable to request uart gpio[%d]\n",
2665 __func__, uart_gpios[i]);
2666 break;
2667 }
2668 } else {
2669 gpio_free(uart_gpios[i]);
2670 }
2671 }
2672
2673 if (ret && on && i)
2674 for (; i >= 0; i--)
2675 gpio_free(uart_gpios[i]);
2676 return ret;
2677}
2678
2679static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
Mayank Ranad85a5082012-04-29 17:24:13 -07002680 .gpio_config = configure_uart_gpios,
Mayank Ranae009c922012-03-22 03:02:06 +05302681};
Mayank Rana1f02d952012-07-04 19:11:20 +05302682
2683static int configure_gsbi8_uart_gpios(int on)
2684{
2685 int ret = 0, i;
2686 int uart_gpios[] = {34, 35, 36, 37};
2687
2688 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2689 if (on) {
2690 ret = gpio_request(uart_gpios[i], NULL);
2691 if (ret) {
2692 pr_err("%s: unable to request uart gpio[%d]\n",
2693 __func__, uart_gpios[i]);
2694 break;
2695 }
2696 } else {
2697 gpio_free(uart_gpios[i]);
2698 }
2699 }
2700
2701 if (ret && on && i)
2702 for (; i >= 0; i--)
2703 gpio_free(uart_gpios[i]);
2704 return ret;
2705}
2706
2707static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
2708 .gpio_config = configure_gsbi8_uart_gpios,
2709};
Mayank Ranae009c922012-03-22 03:02:06 +05302710#else
Mayank Rana1f02d952012-07-04 19:11:20 +05302711static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
Mayank Ranae009c922012-03-22 03:02:06 +05302712static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2713#endif
David Collins26f05562011-06-20 09:56:28 -07002714
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302715#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
Ming-yi Lin9baad172012-10-17 11:50:15 +08002716enum WLANBT_STATUS {
2717 WLANOFF_BTOFF = 1,
2718 WLANOFF_BTON,
2719 WLANON_BTOFF,
2720 WLANON_BTON
2721};
2722
2723static DEFINE_MUTEX(ath_wlanbt_mutex);
2724static int gpio_wlan_sys_rest_en = 26;
2725static int ath_wlanbt_status = WLANOFF_BTOFF;
2726
2727static int ath6kl_power_control(int on)
2728{
2729 int rc;
2730
2731 if (on) {
2732 rc = gpio_request(gpio_wlan_sys_rest_en, "wlan sys_rst_n");
2733 if (rc) {
2734 pr_err("%s: unable to request gpio %d (%d)\n",
2735 __func__, gpio_wlan_sys_rest_en, rc);
2736 return rc;
2737 }
2738 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 0);
2739 msleep(200);
2740 rc = gpio_direction_output(gpio_wlan_sys_rest_en, 1);
2741 msleep(100);
2742 } else {
2743 gpio_set_value(gpio_wlan_sys_rest_en, 0);
2744 rc = gpio_direction_input(gpio_wlan_sys_rest_en);
2745 msleep(100);
2746 gpio_free(gpio_wlan_sys_rest_en);
2747 }
2748 return 0;
2749};
2750
2751static int ath6kl_wlan_power(int on)
2752{
2753 int ret = 0;
2754
2755 mutex_lock(&ath_wlanbt_mutex);
2756 if (on) {
2757 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2758 ret = ath6kl_power_control(1);
2759 ath_wlanbt_status = WLANON_BTOFF;
2760 } else if (ath_wlanbt_status == WLANOFF_BTON)
2761 ath_wlanbt_status = WLANON_BTON;
2762 } else {
2763 if (ath_wlanbt_status == WLANON_BTOFF) {
2764 ret = ath6kl_power_control(0);
2765 ath_wlanbt_status = WLANOFF_BTOFF;
2766 } else if (ath_wlanbt_status == WLANON_BTON)
2767 ath_wlanbt_status = WLANOFF_BTON;
2768 }
2769 mutex_unlock(&ath_wlanbt_mutex);
2770 pr_debug("%s on= %d, wlan_status= %d\n",
2771 __func__, on, ath_wlanbt_status);
2772 return ret;
2773};
2774
2775static struct wifi_platform_data ath6kl_wifi_control = {
2776 .set_power = ath6kl_wlan_power,
2777};
2778
2779static struct platform_device msm_wlan_power_device = {
2780 .name = "ath6kl_power",
2781 .dev = {
2782 .platform_data = &ath6kl_wifi_control,
2783 },
2784};
2785
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302786static struct resource bluesleep_resources[] = {
2787 {
2788 .name = "gpio_host_wake",
2789 .start = 27,
2790 .end = 27,
2791 .flags = IORESOURCE_IO,
2792 },
2793 {
2794 .name = "gpio_ext_wake",
2795 .start = 29,
2796 .end = 29,
2797 .flags = IORESOURCE_IO,
2798 },
2799 {
2800 .name = "host_wake",
2801 .start = MSM_GPIO_TO_INT(27),
2802 .end = MSM_GPIO_TO_INT(27),
2803 .flags = IORESOURCE_IRQ,
2804 },
2805};
2806
2807static struct platform_device msm_bluesleep_device = {
2808 .name = "bluesleep",
2809 .id = -1,
2810 .num_resources = ARRAY_SIZE(bluesleep_resources),
2811 .resource = bluesleep_resources,
2812};
2813
2814static struct platform_device msm_bt_power_device = {
2815 .name = "bt_power",
2816};
2817
Ming-yi Lin9baad172012-10-17 11:50:15 +08002818static int gpio_bt_sys_rest_en = 28;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302819
2820static int bluetooth_power(int on)
2821{
2822 int rc;
2823
Ming-yi Lin9baad172012-10-17 11:50:15 +08002824 mutex_lock(&ath_wlanbt_mutex);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302825 if (on) {
Ming-yi Lin9baad172012-10-17 11:50:15 +08002826 if (ath_wlanbt_status == WLANOFF_BTOFF) {
2827 ath6kl_power_control(1);
2828 ath_wlanbt_status = WLANOFF_BTON;
2829 } else if (ath_wlanbt_status == WLANON_BTOFF)
2830 ath_wlanbt_status = WLANON_BTON;
2831
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302832 rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
2833 if (rc) {
2834 pr_err("%s: unable to request gpio %d (%d)\n",
2835 __func__, gpio_bt_sys_rest_en, rc);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002836 mutex_unlock(&ath_wlanbt_mutex);
2837 return rc;
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302838 }
2839 rc = gpio_direction_output(gpio_bt_sys_rest_en, 0);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002840 msleep(20);
2841 rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302842 msleep(100);
2843 } else {
2844 gpio_set_value(gpio_bt_sys_rest_en, 0);
2845 rc = gpio_direction_input(gpio_bt_sys_rest_en);
2846 msleep(100);
Ming-yi Lin9baad172012-10-17 11:50:15 +08002847 gpio_free(gpio_bt_sys_rest_en);
Ram Mohan Korukondac4cfb692012-08-18 22:24:03 +05302848
Ming-yi Lin9baad172012-10-17 11:50:15 +08002849 if (ath_wlanbt_status == WLANOFF_BTON) {
2850 ath6kl_power_control(0);
2851 ath_wlanbt_status = WLANOFF_BTOFF;
2852 } else if (ath_wlanbt_status == WLANON_BTON)
2853 ath_wlanbt_status = WLANON_BTOFF;
2854 }
2855 mutex_unlock(&ath_wlanbt_mutex);
2856 pr_debug("%s on= %d, wlan_status= %d\n",
2857 __func__, on, ath_wlanbt_status);
2858 return 0;
2859};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302860
2861static void __init bt_power_init(void)
2862{
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302863 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302864 return;
Ming-yi Lin9baad172012-10-17 11:50:15 +08002865};
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302866#else
2867#define bt_power_init(x) do {} while (0)
2868#endif
2869
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002870static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002871 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002872 &msm_device_smd,
Mayank Rana9f51f582011-08-04 18:35:59 +05302873 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002874 &msm_device_saw_core0,
2875 &msm_device_saw_core1,
2876 &msm8960_device_ext_5v_vreg,
David Collins87579612012-01-30 16:00:15 -08002877 &msm8960_device_ssbi_pmic,
David Collins96aa3e12012-02-29 10:31:34 -08002878 &msm8960_device_ext_otg_sw_vreg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002879 &msm8960_device_qup_spi_gsbi1,
2880 &msm8960_device_qup_i2c_gsbi3,
2881 &msm8960_device_qup_i2c_gsbi4,
2882 &msm8960_device_qup_i2c_gsbi10,
2883#ifndef CONFIG_MSM_DSPS
2884 &msm8960_device_qup_i2c_gsbi12,
2885#endif
2886 &msm_slim_ctrl,
2887 &msm_device_wcnss_wlan,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302888#if defined(CONFIG_BT) && defined(CONFIG_BT_HCIUART_ATH3K)
2889 &msm_bluesleep_device,
2890 &msm_bt_power_device,
Ming-yi Lin9baad172012-10-17 11:50:15 +08002891 &msm_wlan_power_device,
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05302892#endif
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002893#if defined(CONFIG_QSEECOM)
2894 &qseecom_device,
2895#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002896#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2897 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2898 &qcrypto_device,
2899#endif
2900
2901#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2902 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2903 &qcedev_device,
2904#endif
2905#ifdef CONFIG_MSM_ROTATOR
2906 &msm_rotator_device,
2907#endif
2908 &msm_device_sps,
2909#ifdef CONFIG_MSM_FAKE_BATTERY
2910 &fish_battery_device,
2911#endif
Binqiang Qiuf165c922012-08-15 18:00:18 -07002912#ifdef CONFIG_BATTERY_BCL
2913 &battery_bcl_device,
2914#endif
Laura Abbottb93525f2012-04-12 09:57:19 -07002915 &msm8960_fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916#ifdef CONFIG_ANDROID_PMEM
Laura Abbott2d1760b2011-09-29 21:31:24 -07002917#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002918 &msm8960_android_pmem_device,
2919 &msm8960_android_pmem_adsp_device,
2920 &msm8960_android_pmem_audio_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002921#endif
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002922#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002923 &msm_device_bam_dmux,
2924 &msm_fm_platform_init,
Joel Nidera1261942011-09-12 16:30:09 +03002925#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2926#ifdef CONFIG_MSM_USE_TSIF1
2927 &msm_device_tsif[1],
2928#else
2929 &msm_device_tsif[0],
2930#endif
2931#endif
Joel Nider266a2642011-10-16 10:58:05 +02002932 &msm_device_tspp,
Mona Hossain9c430e32011-07-27 11:04:47 -07002933#ifdef CONFIG_HW_RANDOM_MSM
2934 &msm_device_rng,
2935#endif
Laura Abbottd6183792011-08-19 13:42:24 -07002936#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002937 &msm8960_ion_dev,
Laura Abbottd6183792011-08-19 13:42:24 -07002938#endif
Praveen Chidambaram78499012011-11-01 17:15:17 -06002939 &msm8960_rpm_device,
2940 &msm8960_rpm_log_device,
2941 &msm8960_rpm_stat_device,
Anji Jonnala93129922012-10-09 20:57:53 +05302942 &msm8960_rpm_master_stat_device,
Mona Hossain11c03ac2011-10-26 12:42:10 -07002943 &msm_device_tz_log,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002944 &coresight_tpiu_device,
2945 &coresight_etb_device,
2946 &coresight_funnel_device,
2947 &coresight_etm0_device,
2948 &coresight_etm1_device,
Swaminathan Sathappanb77c65e92011-09-30 18:36:09 -07002949 &msm_device_dspcrashd_8960,
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002950 &msm8960_device_watchdog,
Laura Abbottb93525f2012-04-12 09:57:19 -07002951 &msm8960_rtb_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002952 &msm8960_device_cache_erp,
Stepan Moskovchenkoc0557252012-06-07 17:39:14 -07002953 &msm8960_device_ebi1_ch0_erp,
2954 &msm8960_device_ebi1_ch1_erp,
Laura Abbottb93525f2012-04-12 09:57:19 -07002955 &msm8960_cache_dump_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002956 &msm8960_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002957 &msm_tsens_device,
Anji Jonnalaf91d8972013-02-26 17:55:50 +05302958 &msm8960_cpu_slp_status,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002959};
2960
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002961static struct platform_device *cdp_devices[] __initdata = {
Stephen Boydeb819882011-08-29 14:46:30 -07002962 &msm_8960_q6_lpass,
Stephen Boyd322a9922011-09-20 01:05:54 -07002963 &msm_8960_riva,
Stephen Boydd89eebe2011-09-28 23:28:11 -07002964 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002965 &msm_pil_dsps,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002966 &msm_pil_vidc,
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002967 &msm8960_device_otg,
2968 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 &msm_device_hsusb_host,
2970 &android_usb_device,
2971 &msm_pcm,
Kiran Kandi5e809b02012-01-31 00:24:33 -08002972 &msm_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002973 &msm_lowlatency_pcm,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002974 &msm_pcm_routing,
2975 &msm_cpudai0,
2976 &msm_cpudai1,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002977 &msm8960_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002978 &msm8960_cpudai_slimbus_2_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979 &msm_cpudai_hdmi_rx,
2980 &msm_cpudai_bt_rx,
2981 &msm_cpudai_bt_tx,
2982 &msm_cpudai_fm_rx,
2983 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002984 &msm_cpudai_auxpcm_rx,
2985 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002986 &msm_cpu_fe,
2987 &msm_stub_codec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002988#ifdef CONFIG_MSM_GEMINI
2989 &msm8960_gemini_device,
2990#endif
Kalyani Oruganti465d1e12012-05-15 10:23:05 -07002991#ifdef CONFIG_MSM_MERCURY
2992 &msm8960_mercury_device,
2993#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002994 &msm_voice,
2995 &msm_voip,
2996 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05302997 &msm_cpudai_afe_01_rx,
2998 &msm_cpudai_afe_01_tx,
2999 &msm_cpudai_afe_02_rx,
3000 &msm_cpudai_afe_02_tx,
3001 &msm_pcm_afe,
Asish Bhattacharya96bb6f42011-11-01 20:36:09 +05303002 &msm_compr_dsp,
Helen Zeng0705a5f2011-10-14 15:29:52 -07003003 &msm_cpudai_incall_music_rx,
Helen Zenge3d716a2011-10-14 16:32:16 -07003004 &msm_cpudai_incall_record_rx,
3005 &msm_cpudai_incall_record_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003006 &msm_pcm_hostless,
3007 &msm_bus_apps_fabric,
3008 &msm_bus_sys_fabric,
3009 &msm_bus_mm_fabric,
3010 &msm_bus_sys_fpb,
3011 &msm_bus_cpss_fpb,
3012};
3013
3014static void __init msm8960_i2c_init(void)
3015{
Kiran Gundaaf3b3562012-08-31 14:00:05 +05303016 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3017 msm8960_i2c_qup_gsbi4_pdata.keep_ahb_clk_on = 1;
3018
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003019 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3020 &msm8960_i2c_qup_gsbi4_pdata;
3021
3022 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3023 &msm8960_i2c_qup_gsbi3_pdata;
3024
3025 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3026 &msm8960_i2c_qup_gsbi10_pdata;
3027
3028 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3029 &msm8960_i2c_qup_gsbi12_pdata;
3030}
3031
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003032static void __init msm8960_gfx_init(void)
3033{
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003034 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3035 msm_kgsl_3d0.dev.platform_data;
Jeremy Gebben58b2dce2011-10-13 11:14:19 -06003036 uint32_t soc_platform_version = socinfo_get_version();
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003037
Carter Coopera4a7ed22012-08-20 22:11:42 -06003038 /* Fixup data that needs to change based on GPU ID */
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003039 if (cpu_is_msm8960ab()) {
3040 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
Suman Tatiraju03a95db2012-10-29 18:24:53 -07003041 /* 8960PRO nominal clock rate is 320Mhz */
3042 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 320000000;
Lucille Sylvester0a82ff22012-12-06 14:10:19 -07003043#ifdef CONFIG_MSM_BUS_SCALING
3044 kgsl_3d0_pdata->bus_scale_table = &grp3d_bus_scale_pdata_ab;
3045#endif
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -06003046
3047 /*
3048 * If this an A320 GPU device (MSM8960AB), then
3049 * switch the resource table to 8960AB, to reflect the
3050 * separate register and shader memory mapping used in A320.
3051 */
3052
3053 msm_kgsl_3d0.num_resources = kgsl_num_resources_8960ab;
3054 msm_kgsl_3d0.resource = kgsl_3d0_resources_8960ab;
Carter Coopera4a7ed22012-08-20 22:11:42 -06003055 } else {
3056 kgsl_3d0_pdata->iommu_count = 1;
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -06003057
Carter Coopera4a7ed22012-08-20 22:11:42 -06003058 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3059 kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
3060 kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
3061 }
3062 if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3) {
3063 /* 8960v3 GPU registers returns 5 for patch release
3064 * but it should be 6, so dummy up the chipid here
3065 * based the platform type
3066 */
3067 kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
3068 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -06003069 }
Carter Cooper83e9dab2012-08-20 15:17:23 -06003070
3071 /* Register the 3D core */
3072 platform_device_register(&msm_kgsl_3d0);
3073
3074 /* Register the 2D cores if we are not 8960PRO */
3075 if (!cpu_is_msm8960ab()) {
3076 platform_device_register(&msm_kgsl_2d0);
3077 platform_device_register(&msm_kgsl_2d1);
3078 }
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003079}
3080
Subhash Jadavani933e6a62011-12-26 18:05:04 +05303081static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003082 {
3083 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3084 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3085 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003086 1, 784, 180000, 100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003087 },
3088
3089 {
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003090 MSM_PM_SLEEP_MODE_RETENTION,
3091 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3092 true,
3093 415, 715, 340827, 475,
3094 },
3095
3096 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003097 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3098 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3099 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003100 1300, 228, 1200000, 2000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003101 },
3102
3103 {
3104 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3105 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3106 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003107 2000, 138, 1208400, 3200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003108 },
3109
3110 {
3111 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003112 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
3113 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003114 6000, 119, 1850300, 9000,
Maheshkumar Sivasubramanian7df12362011-11-02 08:25:49 -06003115 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003116
3117 {
3118 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3119 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3120 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003121 9200, 68, 2839200, 16400,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003122 },
3123
3124 {
3125 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3126 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3127 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003128 10300, 63, 3128000, 18200,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003129 },
3130
3131 {
3132 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3133 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3134 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003135 18000, 10, 4602600, 27000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003136 },
3137
3138 {
3139 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3140 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3141 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06003142 20000, 2, 5752000, 32000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003143 },
3144};
3145
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003146
Praveen Chidambaram78499012011-11-01 17:15:17 -06003147static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
3148 .levels = &msm_rpmrs_levels[0],
3149 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
3150 .vdd_mem_levels = {
3151 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
3152 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
3153 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
3154 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
3155 },
3156 .vdd_dig_levels = {
3157 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
3158 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
3159 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
3160 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
3161 },
3162 .vdd_mask = 0x7FFFFF,
3163 .rpmrs_target_id = {
3164 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
3165 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
3166 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
3167 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
3168 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
3169 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
3170 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
3171 },
3172};
3173
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003174static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3175 .mode = MSM_PM_BOOT_CONFIG_TZ,
3176};
3177
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003178#ifdef CONFIG_I2C
3179#define I2C_SURF 1
3180#define I2C_FFA (1 << 1)
3181#define I2C_RUMI (1 << 2)
3182#define I2C_SIM (1 << 3)
3183#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003184#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003185
3186struct i2c_registry {
3187 u8 machs;
3188 int bus;
3189 struct i2c_board_info *info;
3190 int len;
3191};
3192
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003193/* Sensors DSPS platform data */
3194#ifdef CONFIG_MSM_DSPS
3195#define DSPS_PIL_GENERIC_NAME "dsps"
3196#endif /* CONFIG_MSM_DSPS */
3197
3198static void __init msm8960_init_dsps(void)
3199{
3200#ifdef CONFIG_MSM_DSPS
3201 struct msm_dsps_platform_data *pdata =
3202 msm_dsps_device.dev.platform_data;
3203 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3204 pdata->gpios = NULL;
3205 pdata->gpios_num = 0;
3206
3207 platform_device_register(&msm_dsps_device);
3208#endif /* CONFIG_MSM_DSPS */
3209}
3210
Vamsi Krishna6aa6b1f2011-12-14 22:55:20 -08003211static int hsic_peripheral_status = 1;
3212static DEFINE_MUTEX(hsic_status_lock);
3213
3214void peripheral_connect()
3215{
3216 mutex_lock(&hsic_status_lock);
3217 if (hsic_peripheral_status)
3218 goto out;
3219 platform_device_add(&msm_device_hsic_host);
3220 hsic_peripheral_status = 1;
3221out:
3222 mutex_unlock(&hsic_status_lock);
3223}
3224EXPORT_SYMBOL(peripheral_connect);
3225
3226void peripheral_disconnect()
3227{
3228 mutex_lock(&hsic_status_lock);
3229 if (!hsic_peripheral_status)
3230 goto out;
3231 platform_device_del(&msm_device_hsic_host);
3232 hsic_peripheral_status = 0;
3233out:
3234 mutex_unlock(&hsic_status_lock);
3235}
3236EXPORT_SYMBOL(peripheral_disconnect);
3237
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303238static void __init msm8960_init_smsc_hub(void)
3239{
3240 uint32_t version = socinfo_get_version();
3241
3242 if (SOCINFO_VERSION_MAJOR(version) == 1)
3243 return;
3244
3245 if (machine_is_msm8960_liquid())
3246 platform_device_register(&smsc_hub_device);
3247}
3248
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003249static void __init msm8960_init_hsic(void)
3250{
3251#ifdef CONFIG_USB_EHCI_MSM_HSIC
3252 uint32_t version = socinfo_get_version();
3253
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003254 if (SOCINFO_VERSION_MAJOR(version) == 1)
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003255 return;
3256
Joel King0cbf5d82012-05-24 15:21:38 -07003257 if (machine_is_msm8960_liquid())
Vamsi Krishnaf74d2edb2011-12-02 10:41:11 -08003258 platform_device_register(&msm_device_hsic_host);
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003259#endif
3260}
3261
Amir Samuelov5137e392011-09-21 17:31:25 +03003262#ifdef CONFIG_ISL9519_CHARGER
3263static struct isl_platform_data isl_data __initdata = {
3264 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
3265 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
3266 .max_system_voltage = 4200,
3267 .min_system_voltage = 3200,
Amir Samuelov95f49ff2012-01-29 09:14:08 +02003268 .chgcurrent = 1900,
3269 .term_current = 0,
Amir Samuelov5137e392011-09-21 17:31:25 +03003270 .input_current = 2048,
3271};
3272
3273static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
3274 {
3275 I2C_BOARD_INFO("isl9519q", 0x9),
3276 .irq = 0, /* Not required when notify-by-pmic */
3277 .platform_data = &isl_data,
3278 },
3279};
3280#endif /* CONFIG_ISL9519_CHARGER */
3281
Amir Samuelov755616d2011-12-13 16:34:46 +02003282static struct i2c_board_info liquid_io_expander_i2c_info[] __initdata = {
3283 {
3284 I2C_BOARD_INFO("sx1508q", 0x20),
3285 .platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
3286 },
3287};
3288
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003289static struct i2c_registry msm8960_i2c_devices[] __initdata = {
Amir Samuelov5137e392011-09-21 17:31:25 +03003290#ifdef CONFIG_ISL9519_CHARGER
3291 {
3292 I2C_LIQUID,
3293 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3294 isl_charger_i2c_info,
3295 ARRAY_SIZE(isl_charger_i2c_info),
3296 },
3297#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003298 {
3299 I2C_SURF | I2C_FFA | I2C_FLUID,
3300 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3301 cyttsp_info,
3302 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003303 },
Mohan Pallaka50837382011-09-07 11:00:57 +05303304 {
3305 I2C_LIQUID,
3306 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3307 mxt_device_info,
3308 ARRAY_SIZE(mxt_device_info),
3309 },
Mohan Pallaka5e490392011-09-09 15:18:41 +05303310 {
Manoj Rao14648742012-03-30 19:42:12 -07003311 I2C_SURF | I2C_FFA | I2C_LIQUID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303312 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003313 sii_device_info,
3314 ARRAY_SIZE(sii_device_info),
3315 },
3316 {
Anirudh Ghayal15698162012-07-31 11:51:32 +05303317 I2C_LIQUID | I2C_FFA,
Eugene Yasmand2316b82011-12-07 18:23:48 +02003318 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
Mohan Pallaka5e490392011-09-09 15:18:41 +05303319 msm_isa1200_board_info,
3320 ARRAY_SIZE(msm_isa1200_board_info),
3321 },
Amir Samuelov755616d2011-12-13 16:34:46 +02003322 {
3323 I2C_LIQUID,
3324 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
3325 liquid_io_expander_i2c_info,
3326 ARRAY_SIZE(liquid_io_expander_i2c_info),
3327 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003328};
3329#endif /* CONFIG_I2C */
3330
3331static void __init register_i2c_devices(void)
3332{
3333#ifdef CONFIG_I2C
3334 u8 mach_mask = 0;
3335 int i;
Kevin Chan09f4e662011-12-16 08:17:02 -08003336#ifdef CONFIG_MSM_CAMERA
3337 struct i2c_registry msm8960_camera_i2c_devices = {
3338 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
3339 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3340 msm8960_camera_board_info.board_info,
3341 msm8960_camera_board_info.num_i2c_board_info,
3342 };
3343#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003344
3345 /* Build the matching 'supported_machs' bitmask */
3346 if (machine_is_msm8960_cdp())
3347 mach_mask = I2C_SURF;
Amy Maloche2d028032011-07-20 14:08:06 -07003348 else if (machine_is_msm8960_fluid())
3349 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003350 else if (machine_is_msm8960_liquid())
3351 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003352 else if (machine_is_msm8960_mtp())
3353 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003354 else
3355 pr_err("unmatched machine ID in register_i2c_devices\n");
3356
Jing Lineec88ca2012-02-08 11:18:30 -08003357 if (machine_is_msm8960_liquid()) {
3358 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) == 3)
3359 mxt_device_info[0].platform_data =
3360 &mxt_platform_data_3d;
3361 else
3362 mxt_device_info[0].platform_data =
3363 &mxt_platform_data_2d;
3364 }
3365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003366 /* Run the array and install devices as appropriate */
3367 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3368 if (msm8960_i2c_devices[i].machs & mach_mask)
3369 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3370 msm8960_i2c_devices[i].info,
3371 msm8960_i2c_devices[i].len);
3372 }
Manoj Raoc6d904c2012-06-22 00:32:14 -07003373
3374 if (!mhl_platform_data.gpio_mhl_power)
3375 pr_debug("mhl device configured for ext debug board\n");
3376
Kevin Chan09f4e662011-12-16 08:17:02 -08003377#ifdef CONFIG_MSM_CAMERA
3378 if (msm8960_camera_i2c_devices.machs & mach_mask)
3379 i2c_register_board_info(msm8960_camera_i2c_devices.bus,
3380 msm8960_camera_i2c_devices.info,
3381 msm8960_camera_i2c_devices.len);
3382#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003383#endif
3384}
3385
Siddartha Mohanadoss30447fe2012-09-26 09:42:32 -07003386static void __init msm8960_tsens_init(void)
3387{
3388 if (cpu_is_msm8960())
3389 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1)
3390 return;
3391
3392 msm_tsens_early_init(&msm_tsens_pdata);
3393}
3394
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003395static void __init msm8960ab_update_krait_spm(void)
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003396{
3397 int i;
3398
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003399 /* Update the SPM sequences for SPC and PC */
3400 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3401 int j;
3402 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3403 for (j = 0; j < pdata->num_modes; j++) {
3404 if (pdata->modes[j].cmd ==
3405 spm_power_collapse_without_rpm)
3406 pdata->modes[j].cmd =
3407 spm_power_collapse_without_rpm_krait_v3;
3408 else if (pdata->modes[j].cmd ==
3409 spm_power_collapse_with_rpm)
3410 pdata->modes[j].cmd =
3411 spm_power_collapse_with_rpm_krait_v3;
3412 }
3413 }
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003414}
3415
Anji Jonnala1a1711a2013-01-29 13:34:10 +05303416static void __init msm8960ab_update_retention_spm(void)
3417{
3418 int i;
3419
3420 /* Update the SPM sequences for krait retention on all cores */
3421 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
3422 int j;
3423 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
3424 for (j = 0; j < pdata->num_modes; j++) {
3425 if (pdata->modes[j].cmd ==
3426 spm_retention_cmd_sequence)
3427 pdata->modes[j].cmd =
3428 spm_retention_with_krait_v3_cmd_sequence;
3429 }
3430 }
3431}
3432
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003433static void __init msm8960_cdp_init(void)
3434{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07003435 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3436 pr_err("meminfo_init() failed!\n");
3437
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003438 platform_device_register(&msm_gpio_device);
Siddartha Mohanadoss30447fe2012-09-26 09:42:32 -07003439 msm8960_tsens_init();
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003440 msm_thermal_init(&msm_thermal_pdata);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003441 BUG_ON(msm_rpm_init(&msm8960_rpm_data));
3442 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07003443
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003444 regulator_suppress_info_printing();
3445 if (msm_xo_init())
3446 pr_err("Failed to initialize XO votes\n");
David Collinse68647e2012-09-04 15:44:19 -07003447 configure_msm8960_power_grid();
David Collins26f05562011-06-20 09:56:28 -07003448 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003449 msm_clock_init(&msm8960_clock_init_data);
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +05303450 if (machine_is_msm8960_liquid())
3451 msm_otg_pdata.mhl_enable = true;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003452 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303453 if (machine_is_msm8960_mtp() || machine_is_msm8960_fluid() ||
3454 machine_is_msm8960_cdp()) {
Mayank Ranaa61da7a2012-08-14 10:57:00 +05303455 /* Due to availability of USB Switch in SGLTE Platform
3456 * it requires different HSUSB PHY settings compare to
3457 * 8960 MTP/CDP platform.
3458 */
3459 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3460 msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
3461 else
3462 msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
Anji jonnalaa8b8d732011-12-06 10:03:24 +05303463 } else if (machine_is_msm8960_liquid()) {
3464 msm_otg_pdata.phy_init_seq =
3465 liquid_v1_phy_init_seq;
3466 }
Ofir Cohen94213a72012-05-03 14:26:32 +03003467 android_usb_pdata.swfi_latency =
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +05303468 msm_rpmrs_levels[0].latency_us;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +05303469 msm_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303470 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2 &&
3471 machine_is_msm8960_liquid())
3472 msm_device_hsic_host.dev.parent = &smsc_hub_device.dev;
Stepan Moskovchenko3b09bf52011-12-06 20:40:53 -08003473 msm8960_init_gpiomux();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003474 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3475 &msm8960_qup_spi_gsbi1_pdata;
3476 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Anirudh Ghayal50137fb2012-07-31 16:58:53 +05303477 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE)
3478 spi_register_board_info(spi_eth_info, ARRAY_SIZE(spi_eth_info));
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003479
3480 msm8960_init_pmic();
Anirudh Ghayal15698162012-07-31 11:51:32 +05303481 if (machine_is_msm8960_liquid() || (machine_is_msm8960_mtp() &&
Shantanu Jainae54a622012-12-03 15:09:39 +05303482 (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE ||
3483 cpu_is_msm8960ab())))
Mohan Pallakaf69f0492011-11-21 13:08:33 +05303484 msm_isa1200_board_info[0].platform_data = &isa1200_1_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003485 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003486 msm8960_gfx_init();
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003487
3488 if (cpu_is_msm8960ab())
Praveen Chidambaramc3c90822012-11-07 15:43:49 -07003489 msm8960ab_update_krait_spm();
Anji Jonnala1a1711a2013-01-29 13:34:10 +05303490 if (cpu_is_krait_v3()) {
Praveen Chidambaramf27a5152013-02-01 11:44:53 -07003491 struct msm_pm_init_data_type *pdata =
3492 msm8960_pm_8x60.dev.platform_data;
3493 pdata->retention_calls_tz = false;
Anji Jonnala1a1711a2013-01-29 13:34:10 +05303494 msm8960ab_update_retention_spm();
Anji Jonnala1a1711a2013-01-29 13:34:10 +05303495 }
Praveen Chidambaramf27a5152013-02-01 11:44:53 -07003496 platform_device_register(&msm8960_pm_8x60);
3497
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003498 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3499 msm_spm_l2_init(msm_spm_l2_data);
Mahesh Sivasubramanianc5c82f42012-10-22 13:33:59 -06003500
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003501 msm8960_init_buses();
Stephen Boyd913c29d2012-10-25 11:46:04 -07003502 if (cpu_is_msm8960ab()) {
3503 platform_add_devices(msm8960ab_footswitch,
3504 msm8960ab_num_footswitch);
3505 } else {
3506 platform_add_devices(msm8960_footswitch,
3507 msm8960_num_footswitch);
3508 }
David Collinsb10be1d2011-09-02 10:29:31 -07003509 if (machine_is_msm8960_liquid())
3510 platform_device_register(&msm8960_device_ext_3p3v_vreg);
David Collinsd5a40732011-11-29 15:53:56 -08003511 if (machine_is_msm8960_cdp())
3512 platform_device_register(&msm8960_device_ext_l2_vreg);
Stepan Moskovchenko2b4b1cd2012-03-29 18:21:04 -07003513
3514 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE)
3515 platform_device_register(&msm8960_device_uart_gsbi8);
3516 else
3517 platform_device_register(&msm8960_device_uart_gsbi5);
3518
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003519 /* For 8960 Fusion 2.2 Primary IPC */
Mayank Ranad85a5082012-04-29 17:24:13 -07003520 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3521 msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003522 msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
Mayank Rana77f83c22012-07-10 09:31:02 +05303523 platform_device_register(&msm_device_uart_dm9);
Mayank Ranad85a5082012-04-29 17:24:13 -07003524 }
Mayank Ranaa7f75a62012-04-21 10:09:42 -07003525
Mayank Rana1f02d952012-07-04 19:11:20 +05303526 /* For 8960 Standalone External Bluetooth Interface */
3527 if (socinfo_get_platform_subtype() != PLATFORM_SUBTYPE_SGLTE) {
3528 msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
3529 platform_device_register(&msm_device_uart_dm8);
3530 }
Patrick Daly6578e0c2012-07-19 18:50:02 -07003531 if (cpu_is_msm8960ab())
3532 platform_device_register(&msm8960ab_device_acpuclk);
3533 else
3534 platform_device_register(&msm8960_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003535 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Arun Menon697e91b2012-08-20 15:25:50 -07003536 msm8960_add_vidc_device();
Patrick Daly6578e0c2012-07-19 18:50:02 -07003537
Stepan Moskovchenkoef1e0b62011-12-01 12:10:16 -08003538 msm8960_pm8921_gpio_mpp_init();
Stephen Boyded035682012-09-13 12:41:31 -07003539 /* Don't add modem devices on APQ targets */
Stephen Boydbdb53f32012-06-05 18:39:47 -07003540 if (socinfo_get_id() != 124)
3541 platform_device_register(&msm_8960_q6_mss);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003542 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
Vijayavardhan Vennapusaafbbb8f2012-04-13 16:28:45 +05303543 msm8960_init_smsc_hub();
Vamsi Krishna98f54fb2011-11-02 14:55:41 -07003544 msm8960_init_hsic();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003545#ifdef CONFIG_MSM_CAMERA
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003546 msm8960_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003547#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003548 msm8960_init_mmc();
Mohan Pallaka50837382011-09-07 11:00:57 +05303549 if (machine_is_msm8960_liquid())
3550 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003551 register_i2c_devices();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08003552 msm8960_init_fb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003553 slim_register_board_info(msm_slim_devices,
3554 ARRAY_SIZE(msm_slim_devices));
3555 msm8960_init_dsps();
Larry Bassela7eadea2011-07-14 10:46:00 -07003556 change_memory_power = &msm8960_change_memory_power;
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003557 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Ram Mohan Korukondace14bd82012-07-11 13:55:52 +05303558 bt_power_init();
Joel King0cbf5d82012-05-24 15:21:38 -07003559 if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
3560 mdm_sglte_device.dev.platform_data = &sglte_platform_data;
3561 platform_device_register(&mdm_sglte_device);
3562 }
Laura Abbottac963312012-12-11 15:09:03 -08003563 ion_adjust_secure_allocation();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003564}
3565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003566MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3567 .map_io = msm8960_map_io,
3568 .reserve = msm8960_reserve,
3569 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303570 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003571 .timer = &msm_timer,
3572 .init_machine = msm8960_cdp_init,
3573 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003574 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003575 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003576 .smp = &msm8960_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003577MACHINE_END
3578
3579MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3580 .map_io = msm8960_map_io,
3581 .reserve = msm8960_reserve,
3582 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303583 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003584 .timer = &msm_timer,
3585 .init_machine = msm8960_cdp_init,
3586 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003587 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003588 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003589 .smp = &msm8960_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003590MACHINE_END
3591
3592MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3593 .map_io = msm8960_map_io,
3594 .reserve = msm8960_reserve,
3595 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303596 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003597 .timer = &msm_timer,
3598 .init_machine = msm8960_cdp_init,
3599 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003600 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003601 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003602 .smp = &msm8960_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003603MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003604
3605MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3606 .map_io = msm8960_map_io,
3607 .reserve = msm8960_reserve,
3608 .init_irq = msm8960_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05303609 .handle_irq = gic_handle_irq,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003610 .timer = &msm_timer,
3611 .init_machine = msm8960_cdp_init,
3612 .init_early = msm8960_allocate_memory_regions,
Larry Basselb830e182011-10-14 10:46:55 -07003613 .init_very_early = msm8960_early_memory,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003614 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -08003615 .smp = &msm8960_smp_ops,
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003616MACHINE_END