blob: 3839014c85db2adfec64d29248ce83a2901cbd47 [file] [log] [blame]
Deepak Verma888204f2013-01-25 11:43:09 +05301/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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 *
12 */
13#include <linux/kernel.h>
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -060014#include <linux/bitops.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/platform_device.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070016#include <linux/gpio.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/io.h>
18#include <linux/irq.h>
Kenneth Heitke748593a2011-07-15 15:45:11 -060019#include <linux/i2c.h>
David Keitel2f613d92012-02-15 11:29:16 -080020#include <linux/i2c/smb349.h>
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -080021#include <linux/i2c/sx150x.h>
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -060022#include <linux/slimbus/slimbus.h>
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053023#include <linux/mfd/wcd9xxx/core.h>
24#include <linux/mfd/wcd9xxx/pdata.h>
Amy Maloche70090f992012-02-16 16:35:26 -080025#include <linux/mfd/pm8xxx/misc.h>
Kenneth Heitke36920d32011-07-20 16:44:30 -060026#include <linux/msm_ssbi.h>
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -070027#include <linux/spi/spi.h>
Laura Abbott0ae40a02012-08-10 10:49:33 -070028#include <linux/dma-contiguous.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070029#include <linux/dma-mapping.h>
30#include <linux/platform_data/qcom_crypto_device.h>
Mitchel Humpherys6ff930c2012-09-06 11:32:54 -070031#include <linux/msm_ion.h>
Jack Cheung46bfffa2012-01-19 15:26:24 -080032#include <linux/memory.h>
Larry Bassel67b921d2012-04-06 10:23:27 -070033#include <linux/memblock.h>
Praveen Chidambaram877d7a42012-06-05 14:33:20 -060034#include <linux/msm_thermal.h>
Jing Lin21ed4de2012-02-05 15:53:28 -080035#include <linux/i2c/atmel_mxt_ts.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070036#include <linux/cyttsp-qc.h>
Amy Maloche70090f992012-02-16 16:35:26 -080037#include <linux/i2c/isa1200.h>
Mohan Pallaka474b94b2012-01-25 12:59:58 +053038#include <linux/gpio_keys.h>
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -080039#include <linux/epm_adc.h>
Jay Chokshie7d8d4f2012-04-04 14:47:57 -070040#include <linux/i2c/sx150x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041#include <asm/mach-types.h>
42#include <asm/mach/arch.h>
43#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053044#include <asm/mach/mmc.h>
Ankit Verma6b7e2ba2012-01-26 15:48:54 -080045#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046
47#include <mach/board.h>
48#include <mach/msm_iomap.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080049#include <mach/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#include <linux/usb/msm_hsusb.h>
51#include <linux/usb/android.h>
52#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060053#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#include "timer.h"
55#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070056#include <mach/gpiomux.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060057#include <mach/rpm.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080058#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070059#include <linux/android_pmem.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080060#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070061#include <mach/msm_memtypes.h>
62#include <linux/bootmem.h>
63#include <asm/setup.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070064#include <mach/dma.h>
Jin Hongd3024e62012-02-09 16:13:32 -080065#include <mach/msm_dsps.h>
Gagan Mac8a7a5d32011-11-11 16:43:06 -070066#include <mach/msm_bus_board.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060067#include <mach/cpuidle.h>
Joel Kingdacbc822012-01-25 13:30:57 -080068#include <mach/mdm2.h>
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -080069#include <linux/msm_tsens.h>
Stephen Boyd4d0d2582012-02-10 14:49:40 -080070#include <mach/msm_xo.h>
Laura Abbott350c8362012-02-28 14:46:52 -080071#include <mach/msm_rtb.h>
Santosh Mardieff9a742012-04-09 23:23:39 +053072#include <sound/cs8427.h>
Ravi Kumar V05931a22012-04-04 17:09:37 +053073#include <media/gpio-ir-recv.h>
Larry Bassel67b921d2012-04-06 10:23:27 -070074#include <linux/fmem.h>
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -060075#include <mach/msm_pcie.h>
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070076#include <mach/restart.h>
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -060077#include <mach/msm_iomap.h>
Joel King4ebccc62011-07-22 09:43:22 -070078
Jeff Ohlstein7e668552011-10-06 16:17:25 -070079#include "msm_watchdog.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080080#include "board-8064.h"
Matt Wagantalld55b90f2012-02-23 23:27:44 -080081#include "clock.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060082#include "spm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053083#include <mach/mpm.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060084#include "rpm_resources.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080085#include "pm.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060086#include "pm-boot.h"
Rajesh Sastrulaaee8af32012-01-20 11:46:31 -080087#include "devices-msm8x60.h"
Hanumant Singh50440d42012-04-23 19:27:16 -070088#include "smd_private.h"
Ameya Thakurffd21b02013-01-30 11:33:22 -080089#include "sysmon.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070090
Olav Haugan7c6aa742012-01-16 16:47:37 -080091#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -070092#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Olav Haugan7c6aa742012-01-16 16:47:37 -080093#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
94#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
95#else
Chetan Kalyan72aac4f2012-02-23 14:56:54 -080096#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Olav Haugan7c6aa742012-01-16 16:47:37 -080097#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070098
Olav Haugan7c6aa742012-01-16 16:47:37 -080099#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Hanumant Singheadb7502012-05-15 18:14:04 -0700100#define HOLE_SIZE 0x20000
Deepak Verma888204f2013-01-25 11:43:09 +0530101#define MSM_ION_MFC_META_SIZE 0x40000 /* 256 Kbytes */
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700102#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan129992c2012-03-22 09:54:01 -0700103#ifdef CONFIG_MSM_IOMMU
104#define MSM_ION_MM_SIZE 0x3800000
105#define MSM_ION_SF_SIZE 0
Olav Haugan39477bb2012-05-14 16:05:36 -0700106#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700107#define MSM_ION_HEAP_NUM 7
108#else
Olav Haugan7c6aa742012-01-16 16:47:37 -0800109#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan129992c2012-03-22 09:54:01 -0700110#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Haugan39477bb2012-05-14 16:05:36 -0700111#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700112#define MSM_ION_HEAP_NUM 8
113#endif
Hanumant Singheadb7502012-05-15 18:14:04 -0700114#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* (2MB - 128KB) */
Deepak Verma888204f2013-01-25 11:43:09 +0530115#define MSM_ION_MFC_SIZE (SZ_8K + MSM_ION_MFC_META_SIZE)
Olav Haugan2c43fac2012-01-19 11:06:37 -0800116#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan7c6aa742012-01-16 16:47:37 -0800117#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700118#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Haugan7c6aa742012-01-16 16:47:37 -0800119#define MSM_ION_HEAP_NUM 1
120#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700121
Hanumant Singheadb7502012-05-15 18:14:04 -0700122#define APQ8064_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
123 HOLE_SIZE))
Larry Bassel67b921d2012-04-06 10:23:27 -0700124#define MAX_FIXED_AREA_SIZE 0x10000000
Hanumant Singheadb7502012-05-15 18:14:04 -0700125#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE)
126#define APQ8064_FW_START APQ8064_FIXED_AREA_START
Larry Bassel67b921d2012-04-06 10:23:27 -0700127
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -0600128#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB (MSM_QFPROM_BASE + 0x23c)
129#define QFPROM_RAW_OEM_CONFIG_ROW0_LSB (MSM_QFPROM_BASE + 0x220)
130
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -0600131/* PCIE AXI address space */
132#define PCIE_AXI_BAR_PHYS 0x08000000
133#define PCIE_AXI_BAR_SIZE SZ_128M
134
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -0600135/* PCIe pmic gpios */
136#define PCIE_WAKE_N_PMIC_GPIO 12
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600137#define PCIE_PWR_EN_PMIC_GPIO 13
138#define PCIE_RST_N_PMIC_MPP 1
139
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700140#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
141static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
142static int __init msm_contig_mem_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -0700143{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700144 msm_contig_mem_size = memparse(p, NULL);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800145 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700146}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700147early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800148#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700149
Olav Haugan7c6aa742012-01-16 16:47:37 -0800150#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -0700151static unsigned pmem_size = MSM_PMEM_SIZE;
152static int __init pmem_size_setup(char *p)
153{
154 pmem_size = memparse(p, NULL);
155 return 0;
156}
157early_param("pmem_size", pmem_size_setup);
158
159static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
160
161static int __init pmem_adsp_size_setup(char *p)
162{
163 pmem_adsp_size = memparse(p, NULL);
164 return 0;
165}
166early_param("pmem_adsp_size", pmem_adsp_size_setup);
167
168static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
169
170static int __init pmem_audio_size_setup(char *p)
171{
172 pmem_audio_size = memparse(p, NULL);
173 return 0;
174}
175early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800176#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700177
Olav Haugan7c6aa742012-01-16 16:47:37 -0800178#ifdef CONFIG_ANDROID_PMEM
179#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700180static struct android_pmem_platform_data android_pmem_pdata = {
181 .name = "pmem",
182 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
183 .cached = 1,
184 .memory_type = MEMTYPE_EBI1,
185};
186
Laura Abbottb93525f2012-04-12 09:57:19 -0700187static struct platform_device apq8064_android_pmem_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700188 .name = "android_pmem",
189 .id = 0,
190 .dev = {.platform_data = &android_pmem_pdata},
191};
192
193static struct android_pmem_platform_data android_pmem_adsp_pdata = {
194 .name = "pmem_adsp",
195 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
196 .cached = 0,
197 .memory_type = MEMTYPE_EBI1,
198};
Laura Abbottb93525f2012-04-12 09:57:19 -0700199static struct platform_device apq8064_android_pmem_adsp_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700200 .name = "android_pmem",
201 .id = 2,
202 .dev = { .platform_data = &android_pmem_adsp_pdata },
203};
204
205static struct android_pmem_platform_data android_pmem_audio_pdata = {
206 .name = "pmem_audio",
207 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
208 .cached = 0,
209 .memory_type = MEMTYPE_EBI1,
210};
211
Laura Abbottb93525f2012-04-12 09:57:19 -0700212static struct platform_device apq8064_android_pmem_audio_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700213 .name = "android_pmem",
214 .id = 4,
215 .dev = { .platform_data = &android_pmem_audio_pdata },
216};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700217#endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
218#endif /* CONFIG_ANDROID_PMEM */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800219
Larry Bassel67b921d2012-04-06 10:23:27 -0700220struct fmem_platform_data apq8064_fmem_pdata = {
221};
222
Olav Haugan7c6aa742012-01-16 16:47:37 -0800223static struct memtype_reserve apq8064_reserve_table[] __initdata = {
224 [MEMTYPE_SMI] = {
225 },
226 [MEMTYPE_EBI0] = {
227 .flags = MEMTYPE_FLAGS_1M_ALIGN,
228 },
229 [MEMTYPE_EBI1] = {
230 .flags = MEMTYPE_FLAGS_1M_ALIGN,
231 },
232};
Kevin Chan13be4e22011-10-20 11:30:32 -0700233
Laura Abbott350c8362012-02-28 14:46:52 -0800234static void __init reserve_rtb_memory(void)
235{
236#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700237 apq8064_reserve_table[MEMTYPE_EBI1].size += apq8064_rtb_pdata.size;
Laura Abbott350c8362012-02-28 14:46:52 -0800238#endif
239}
240
241
Kevin Chan13be4e22011-10-20 11:30:32 -0700242static void __init size_pmem_devices(void)
243{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800244#ifdef CONFIG_ANDROID_PMEM
245#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700246 android_pmem_adsp_pdata.size = pmem_adsp_size;
247 android_pmem_pdata.size = pmem_size;
248 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700249#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
250#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700251}
252
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700253#ifdef CONFIG_ANDROID_PMEM
254#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700255static void __init reserve_memory_for(struct android_pmem_platform_data *p)
256{
257 apq8064_reserve_table[p->memory_type].size += p->size;
258}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700259#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
260#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700261
Kevin Chan13be4e22011-10-20 11:30:32 -0700262static void __init reserve_pmem_memory(void)
263{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800264#ifdef CONFIG_ANDROID_PMEM
265#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700266 reserve_memory_for(&android_pmem_adsp_pdata);
267 reserve_memory_for(&android_pmem_pdata);
268 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700269#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700270 apq8064_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700271#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -0800272}
273
274static int apq8064_paddr_to_memtype(unsigned int paddr)
275{
276 return MEMTYPE_EBI1;
277}
278
Steve Mucklef132c6c2012-06-06 18:30:57 -0700279#define FMEM_ENABLED 0
Larry Bassel67b921d2012-04-06 10:23:27 -0700280
Olav Haugan7c6aa742012-01-16 16:47:37 -0800281#ifdef CONFIG_ION_MSM
282#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700283static struct ion_cp_heap_pdata cp_mm_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800284 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800285 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700286 .reusable = FMEM_ENABLED,
287 .mem_is_fmem = FMEM_ENABLED,
288 .fixed_position = FIXED_MIDDLE,
Laura Abbottadec9c72012-12-05 11:49:59 -0800289 .is_cma = 1,
Laura Abbott5249a052012-12-11 15:09:03 -0800290 .no_nonsecure_alloc = 1,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800291};
292
Laura Abbottb93525f2012-04-12 09:57:19 -0700293static struct ion_cp_heap_pdata cp_mfc_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800294 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800295 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700296 .reusable = 0,
297 .mem_is_fmem = FMEM_ENABLED,
298 .fixed_position = FIXED_HIGH,
Laura Abbott5249a052012-12-11 15:09:03 -0800299 .no_nonsecure_alloc = 1,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800300};
301
Laura Abbottb93525f2012-04-12 09:57:19 -0700302static struct ion_co_heap_pdata co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800303 .adjacent_mem_id = INVALID_HEAP_ID,
304 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700305 .mem_is_fmem = 0,
Olav Haugand3d29682012-01-19 10:57:07 -0800306};
307
Laura Abbottb93525f2012-04-12 09:57:19 -0700308static struct ion_co_heap_pdata fw_co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800309 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
310 .align = SZ_128K,
Larry Bassel67b921d2012-04-06 10:23:27 -0700311 .mem_is_fmem = FMEM_ENABLED,
312 .fixed_position = FIXED_LOW,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800313};
314#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800315
Laura Abbott0ae40a02012-08-10 10:49:33 -0700316static u64 msm_dmamask = DMA_BIT_MASK(32);
317
318static struct platform_device ion_mm_heap_device = {
319 .name = "ion-mm-heap-device",
320 .id = -1,
321 .dev = {
322 .dma_mask = &msm_dmamask,
323 .coherent_dma_mask = DMA_BIT_MASK(32),
324 }
325};
326
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800327/**
328 * These heaps are listed in the order they will be allocated. Due to
329 * video hardware restrictions and content protection the FW heap has to
330 * be allocated adjacent (below) the MM heap and the MFC heap has to be
331 * allocated after the MM heap to ensure MFC heap is not more than 256MB
332 * away from the base address of the FW heap.
333 * However, the order of FW heap and MM heap doesn't matter since these
334 * two heaps are taken care of by separate code to ensure they are adjacent
335 * to each other.
336 * Don't swap the order unless you know what you are doing!
337 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700338struct ion_platform_heap apq8064_heaps[] = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800339 {
340 .id = ION_SYSTEM_HEAP_ID,
341 .type = ION_HEAP_TYPE_SYSTEM,
342 .name = ION_VMALLOC_HEAP_NAME,
343 },
344#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
345 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800346 .id = ION_CP_MM_HEAP_ID,
347 .type = ION_HEAP_TYPE_CP,
348 .name = ION_MM_HEAP_NAME,
349 .size = MSM_ION_MM_SIZE,
350 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700351 .extra_data = (void *) &cp_mm_apq8064_ion_pdata,
Laura Abbott0ae40a02012-08-10 10:49:33 -0700352 .priv = &ion_mm_heap_device.dev
Olav Haugan7c6aa742012-01-16 16:47:37 -0800353 },
354 {
Olav Haugand3d29682012-01-19 10:57:07 -0800355 .id = ION_MM_FIRMWARE_HEAP_ID,
356 .type = ION_HEAP_TYPE_CARVEOUT,
357 .name = ION_MM_FIRMWARE_HEAP_NAME,
358 .size = MSM_ION_MM_FW_SIZE,
359 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700360 .extra_data = (void *) &fw_co_apq8064_ion_pdata,
Olav Haugand3d29682012-01-19 10:57:07 -0800361 },
362 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800363 .id = ION_CP_MFC_HEAP_ID,
364 .type = ION_HEAP_TYPE_CP,
365 .name = ION_MFC_HEAP_NAME,
366 .size = MSM_ION_MFC_SIZE,
367 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700368 .extra_data = (void *) &cp_mfc_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800369 },
Olav Haugan129992c2012-03-22 09:54:01 -0700370#ifndef CONFIG_MSM_IOMMU
Olav Haugan7c6aa742012-01-16 16:47:37 -0800371 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800372 .id = ION_SF_HEAP_ID,
373 .type = ION_HEAP_TYPE_CARVEOUT,
374 .name = ION_SF_HEAP_NAME,
375 .size = MSM_ION_SF_SIZE,
376 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700377 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800378 },
Olav Haugan129992c2012-03-22 09:54:01 -0700379#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800380 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800381 .id = ION_IOMMU_HEAP_ID,
382 .type = ION_HEAP_TYPE_IOMMU,
383 .name = ION_IOMMU_HEAP_NAME,
384 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800385 {
386 .id = ION_QSECOM_HEAP_ID,
387 .type = ION_HEAP_TYPE_CARVEOUT,
388 .name = ION_QSECOM_HEAP_NAME,
389 .size = MSM_ION_QSECOM_SIZE,
390 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700391 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Hauganf45e2142012-01-19 11:01:01 -0800392 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800393 {
394 .id = ION_AUDIO_HEAP_ID,
395 .type = ION_HEAP_TYPE_CARVEOUT,
396 .name = ION_AUDIO_HEAP_NAME,
397 .size = MSM_ION_AUDIO_SIZE,
398 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700399 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan2c43fac2012-01-19 11:06:37 -0800400 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800401#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700402};
403
404static struct ion_platform_data apq8064_ion_pdata = {
405 .nr = MSM_ION_HEAP_NUM,
406 .heaps = apq8064_heaps,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800407};
408
Laura Abbottb93525f2012-04-12 09:57:19 -0700409static struct platform_device apq8064_ion_dev = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800410 .name = "ion-msm",
411 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700412 .dev = { .platform_data = &apq8064_ion_pdata },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800413};
414#endif
415
Larry Bassel67b921d2012-04-06 10:23:27 -0700416static struct platform_device apq8064_fmem_device = {
417 .name = "fmem",
418 .id = 1,
419 .dev = { .platform_data = &apq8064_fmem_pdata },
420};
421
422static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
423 unsigned long size)
424{
425 apq8064_reserve_table[mem_type].size += size;
426}
427
428static void __init apq8064_reserve_fixed_area(unsigned long fixed_area_size)
429{
430#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
431 int ret;
432
433 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
434 panic("fixed area size is larger than %dM\n",
435 MAX_FIXED_AREA_SIZE >> 20);
436
437 reserve_info->fixed_area_size = fixed_area_size;
438 reserve_info->fixed_area_start = APQ8064_FW_START;
439
440 ret = memblock_remove(reserve_info->fixed_area_start,
441 reserve_info->fixed_area_size);
442 BUG_ON(ret);
443#endif
444}
445
446/**
447 * Reserve memory for ION and calculate amount of reusable memory for fmem.
448 * We only reserve memory for heaps that are not reusable. However, we only
449 * support one reusable heap at the moment so we ignore the reusable flag for
450 * other than the first heap with reusable flag set. Also handle special case
451 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
452 * at a higher address than FW in addition to not more than 256MB away from the
453 * base address of the firmware. This means that if MM is reusable the other
454 * two heaps must be allocated in the same region as FW. This is handled by the
455 * mem_is_fmem flag in the platform data. In addition the MM heap must be
456 * adjacent to the FW heap for content protection purposes.
457 */
Stephen Boyd668d7652012-04-25 11:31:01 -0700458static void __init reserve_ion_memory(void)
Olav Haugan7c6aa742012-01-16 16:47:37 -0800459{
460#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Larry Bassel67b921d2012-04-06 10:23:27 -0700461 unsigned int i;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700462 unsigned int ret;
Larry Bassel67b921d2012-04-06 10:23:27 -0700463 unsigned int fixed_size = 0;
464 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
465 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700466 unsigned long cma_alignment;
467 unsigned int low_use_cma = 0;
468 unsigned int middle_use_cma = 0;
469 unsigned int high_use_cma = 0;
470
Larry Bassel67b921d2012-04-06 10:23:27 -0700471
Larry Bassel67b921d2012-04-06 10:23:27 -0700472 fixed_low_size = 0;
473 fixed_middle_size = 0;
474 fixed_high_size = 0;
475
Laura Abbott0ae40a02012-08-10 10:49:33 -0700476 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
477
Larry Bassel67b921d2012-04-06 10:23:27 -0700478 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
Laura Abbott0ae40a02012-08-10 10:49:33 -0700479 struct ion_platform_heap *heap =
Larry Bassel67b921d2012-04-06 10:23:27 -0700480 &(apq8064_ion_pdata.heaps[i]);
Laura Abbott0ae40a02012-08-10 10:49:33 -0700481 int use_cma = 0;
482
Larry Bassel67b921d2012-04-06 10:23:27 -0700483
484 if (heap->extra_data) {
485 int fixed_position = NOT_FIXED;
Larry Bassel67b921d2012-04-06 10:23:27 -0700486
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700487 switch ((int)heap->type) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700488 case ION_HEAP_TYPE_CP:
Laura Abbott0ae40a02012-08-10 10:49:33 -0700489 if (((struct ion_cp_heap_pdata *)
490 heap->extra_data)->is_cma) {
491 heap->size = ALIGN(heap->size,
492 cma_alignment);
493 use_cma = 1;
494 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700495 fixed_position = ((struct ion_cp_heap_pdata *)
496 heap->extra_data)->fixed_position;
497 break;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700498 case ION_HEAP_TYPE_DMA:
499 use_cma = 1;
500 /* Purposely fall through here */
Larry Bassel67b921d2012-04-06 10:23:27 -0700501 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel67b921d2012-04-06 10:23:27 -0700502 fixed_position = ((struct ion_co_heap_pdata *)
503 heap->extra_data)->fixed_position;
504 break;
505 default:
506 break;
507 }
508
509 if (fixed_position != NOT_FIXED)
510 fixed_size += heap->size;
511 else
512 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
513
Laura Abbott0ae40a02012-08-10 10:49:33 -0700514 if (fixed_position == FIXED_LOW) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700515 fixed_low_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700516 low_use_cma = use_cma;
517 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700518 fixed_middle_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700519 middle_use_cma = use_cma;
520 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700521 fixed_high_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700522 high_use_cma = use_cma;
523 } else if (use_cma) {
524 /*
525 * Heaps that use CMA but are not part of the
526 * fixed set. Create wherever.
527 */
528 dma_declare_contiguous(
529 heap->priv,
530 heap->size,
531 0,
532 0xb0000000);
533
534 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700535 }
536 }
537
538 if (!fixed_size)
539 return;
540
Laura Abbott0ae40a02012-08-10 10:49:33 -0700541 /*
542 * Given the setup for the fixed area, we can't round up all sizes.
543 * Some sizes must be set up exactly and aligned correctly. Incorrect
544 * alignments are considered a configuration issue
Larry Bassel67b921d2012-04-06 10:23:27 -0700545 */
Larry Bassel67b921d2012-04-06 10:23:27 -0700546
547 fixed_low_start = APQ8064_FIXED_AREA_START;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700548 if (low_use_cma) {
549 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
550 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
551 } else {
552 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
553 ret = memblock_remove(fixed_low_start,
554 fixed_low_size + HOLE_SIZE);
555 BUG_ON(ret);
556 }
557
Hanumant Singheadb7502012-05-15 18:14:04 -0700558 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700559 if (middle_use_cma) {
560 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
561 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
562 } else {
563 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
564 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
565 BUG_ON(ret);
566 }
567
Larry Bassel67b921d2012-04-06 10:23:27 -0700568 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700569 if (high_use_cma) {
570 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
571 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
572 } else {
573 /* This is the end of the fixed area so it's okay to round up */
574 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
575 ret = memblock_remove(fixed_high_start, fixed_high_size);
576 BUG_ON(ret);
577 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700578
579 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
580 struct ion_platform_heap *heap = &(apq8064_ion_pdata.heaps[i]);
581
582 if (heap->extra_data) {
583 int fixed_position = NOT_FIXED;
Steve Mucklef132c6c2012-06-06 18:30:57 -0700584 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel67b921d2012-04-06 10:23:27 -0700585
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700586 switch ((int) heap->type) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700587 case ION_HEAP_TYPE_CP:
Hanumant Singheadb7502012-05-15 18:14:04 -0700588 pdata =
589 (struct ion_cp_heap_pdata *)heap->extra_data;
590 fixed_position = pdata->fixed_position;
Larry Bassel67b921d2012-04-06 10:23:27 -0700591 break;
592 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbott0ae40a02012-08-10 10:49:33 -0700593 case ION_HEAP_TYPE_DMA:
Larry Bassel67b921d2012-04-06 10:23:27 -0700594 fixed_position = ((struct ion_co_heap_pdata *)
595 heap->extra_data)->fixed_position;
596 break;
597 default:
598 break;
599 }
600
601 switch (fixed_position) {
602 case FIXED_LOW:
603 heap->base = fixed_low_start;
604 break;
605 case FIXED_MIDDLE:
606 heap->base = fixed_middle_start;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700607 if (middle_use_cma) {
608 ret = dma_declare_contiguous(
609 heap->priv,
610 heap->size,
611 fixed_middle_start,
612 0xa0000000);
613 WARN_ON(ret);
614 }
Hanumant Singheadb7502012-05-15 18:14:04 -0700615 pdata->secure_base = fixed_middle_start
616 - HOLE_SIZE;
617 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel67b921d2012-04-06 10:23:27 -0700618 break;
619 case FIXED_HIGH:
620 heap->base = fixed_high_start;
621 break;
622 default:
623 break;
624 }
625 }
626 }
Olav Haugan7c6aa742012-01-16 16:47:37 -0800627#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700628}
629
Huaibin Yang4a084e32011-12-15 15:25:52 -0800630static void __init reserve_mdp_memory(void)
631{
632 apq8064_mdp_writeback(apq8064_reserve_table);
633}
634
Laura Abbott93a4a352012-05-25 09:26:35 -0700635static void __init reserve_cache_dump_memory(void)
636{
637#ifdef CONFIG_MSM_CACHE_DUMP
638 unsigned int total;
639
640 total = apq8064_cache_dump_pdata.l1_size +
641 apq8064_cache_dump_pdata.l2_size;
642 apq8064_reserve_table[MEMTYPE_EBI1].size += total;
643#endif
644}
645
Abhijeet Dharmapurikar3edb5de2012-09-13 11:02:03 -0700646static void __init reserve_mpdcvs_memory(void)
647{
648 apq8064_reserve_table[MEMTYPE_EBI1].size += SZ_32K;
649}
650
Kevin Chan13be4e22011-10-20 11:30:32 -0700651static void __init apq8064_calculate_reserve_sizes(void)
652{
653 size_pmem_devices();
654 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800655 reserve_ion_memory();
Huaibin Yang4a084e32011-12-15 15:25:52 -0800656 reserve_mdp_memory();
Laura Abbott350c8362012-02-28 14:46:52 -0800657 reserve_rtb_memory();
Laura Abbott93a4a352012-05-25 09:26:35 -0700658 reserve_cache_dump_memory();
Abhijeet Dharmapurikar3edb5de2012-09-13 11:02:03 -0700659 reserve_mpdcvs_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700660}
661
662static struct reserve_info apq8064_reserve_info __initdata = {
663 .memtype_reserve_table = apq8064_reserve_table,
664 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
Larry Bassel67b921d2012-04-06 10:23:27 -0700665 .reserve_fixed_area = apq8064_reserve_fixed_area,
Kevin Chan13be4e22011-10-20 11:30:32 -0700666 .paddr_to_memtype = apq8064_paddr_to_memtype,
667};
668
669static int apq8064_memory_bank_size(void)
670{
671 return 1<<29;
672}
673
674static void __init locate_unstable_memory(void)
675{
676 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
677 unsigned long bank_size;
678 unsigned long low, high;
679
680 bank_size = apq8064_memory_bank_size();
681 low = meminfo.bank[0].start;
682 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800683
684 /* Check if 32 bit overflow occured */
685 if (high < mb->start)
Larry Bassel67b921d2012-04-06 10:23:27 -0700686 high = -PAGE_SIZE;
Olav Haugand76e3a82012-01-16 16:55:07 -0800687
Kevin Chan13be4e22011-10-20 11:30:32 -0700688 low &= ~(bank_size - 1);
689
690 if (high - low <= bank_size)
Larry Bassel67b921d2012-04-06 10:23:27 -0700691 goto no_dmm;
692
693#ifdef CONFIG_ENABLE_DMM
Jack Cheung46bfffa2012-01-19 15:26:24 -0800694 apq8064_reserve_info.low_unstable_address = mb->start -
695 MIN_MEMORY_BLOCK_SIZE + mb->size;
696 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
697
Kevin Chan13be4e22011-10-20 11:30:32 -0700698 apq8064_reserve_info.bank_size = bank_size;
699 pr_info("low unstable address %lx max size %lx bank size %lx\n",
700 apq8064_reserve_info.low_unstable_address,
701 apq8064_reserve_info.max_unstable_size,
702 apq8064_reserve_info.bank_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700703 return;
704#endif
705no_dmm:
706 apq8064_reserve_info.low_unstable_address = high;
707 apq8064_reserve_info.max_unstable_size = 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700708}
709
Hanumant Singh50440d42012-04-23 19:27:16 -0700710static int apq8064_change_memory_power(u64 start, u64 size,
711 int change_type)
712{
713 return soc_change_memory_power(start, size, change_type);
714}
715
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700716static char prim_panel_name[PANEL_NAME_MAX_LEN];
717static char ext_panel_name[PANEL_NAME_MAX_LEN];
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530718
719static int ext_resolution;
720
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700721static int __init prim_display_setup(char *param)
722{
723 if (strnlen(param, PANEL_NAME_MAX_LEN))
724 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
725 return 0;
726}
727early_param("prim_display", prim_display_setup);
728
729static int __init ext_display_setup(char *param)
730{
731 if (strnlen(param, PANEL_NAME_MAX_LEN))
732 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
733 return 0;
734}
735early_param("ext_display", ext_display_setup);
736
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530737static int __init hdmi_resulution_setup(char *param)
738{
739 int ret;
740 ret = kstrtoint(param, 10, &ext_resolution);
741 return ret;
742}
743early_param("ext_resolution", hdmi_resulution_setup);
744
Kevin Chan13be4e22011-10-20 11:30:32 -0700745static void __init apq8064_reserve(void)
746{
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530747 apq8064_set_display_params(prim_panel_name, ext_panel_name,
748 ext_resolution);
Kevin Chan13be4e22011-10-20 11:30:32 -0700749 msm_reserve();
750}
751
Laura Abbott6988cef2012-03-15 14:27:13 -0700752static void __init place_movable_zone(void)
753{
Larry Bassel67b921d2012-04-06 10:23:27 -0700754#ifdef CONFIG_ENABLE_DMM
Laura Abbott6988cef2012-03-15 14:27:13 -0700755 movable_reserved_start = apq8064_reserve_info.low_unstable_address;
756 movable_reserved_size = apq8064_reserve_info.max_unstable_size;
757 pr_info("movable zone start %lx size %lx\n",
758 movable_reserved_start, movable_reserved_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700759#endif
Laura Abbott6988cef2012-03-15 14:27:13 -0700760}
761
762static void __init apq8064_early_reserve(void)
763{
764 reserve_info = &apq8064_reserve_info;
765 locate_unstable_memory();
766 place_movable_zone();
767
768}
Hemant Kumara945b472012-01-25 15:08:06 -0800769#ifdef CONFIG_USB_EHCI_MSM_HSIC
Hemant Kumare6275972012-02-29 20:06:21 -0800770/* Bandwidth requests (zero) if no vote placed */
771static struct msm_bus_vectors hsic_init_vectors[] = {
772 {
773 .src = MSM_BUS_MASTER_SPS,
Hemant Kumare6275972012-02-29 20:06:21 -0800774 .dst = MSM_BUS_SLAVE_SPS,
775 .ab = 0,
776 .ib = 0,
777 },
778};
779
780/* Bus bandwidth requests in Bytes/sec */
781static struct msm_bus_vectors hsic_max_vectors[] = {
782 {
783 .src = MSM_BUS_MASTER_SPS,
Hemant Kumare6275972012-02-29 20:06:21 -0800784 .dst = MSM_BUS_SLAVE_SPS,
785 .ab = 0,
Hemant Kumar266d9d52012-10-17 13:48:10 -0700786 .ib = 256000000, /*vote for 32Mhz dfab clk rate*/
Hemant Kumare6275972012-02-29 20:06:21 -0800787 },
788};
789
790static struct msm_bus_paths hsic_bus_scale_usecases[] = {
791 {
792 ARRAY_SIZE(hsic_init_vectors),
793 hsic_init_vectors,
794 },
795 {
796 ARRAY_SIZE(hsic_max_vectors),
797 hsic_max_vectors,
798 },
799};
800
801static struct msm_bus_scale_pdata hsic_bus_scale_pdata = {
802 hsic_bus_scale_usecases,
803 ARRAY_SIZE(hsic_bus_scale_usecases),
804 .name = "hsic",
805};
806
Hemant Kumara945b472012-01-25 15:08:06 -0800807static struct msm_hsic_host_platform_data msm_hsic_pdata = {
Hemant Kumare6275972012-02-29 20:06:21 -0800808 .strobe = 88,
809 .data = 89,
810 .bus_scale_table = &hsic_bus_scale_pdata,
Hemant Kumara945b472012-01-25 15:08:06 -0800811};
812#else
813static struct msm_hsic_host_platform_data msm_hsic_pdata;
814#endif
815
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800816#define PID_MAGIC_ID 0x71432909
817#define SERIAL_NUM_MAGIC_ID 0x61945374
818#define SERIAL_NUMBER_LENGTH 127
819#define DLOAD_USB_BASE_ADD 0x2A03F0C8
820
821struct magic_num_struct {
822 uint32_t pid;
823 uint32_t serial_num;
824};
825
826struct dload_struct {
827 uint32_t reserved1;
828 uint32_t reserved2;
829 uint32_t reserved3;
830 uint16_t reserved4;
831 uint16_t pid;
832 char serial_number[SERIAL_NUMBER_LENGTH];
833 uint16_t reserved5;
834 struct magic_num_struct magic_struct;
835};
836
837static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
838{
839 struct dload_struct __iomem *dload = 0;
840
841 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
842 if (!dload) {
843 pr_err("%s: cannot remap I/O memory region: %08x\n",
844 __func__, DLOAD_USB_BASE_ADD);
845 return -ENXIO;
846 }
847
848 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
849 __func__, dload, pid, snum);
850 /* update pid */
851 dload->magic_struct.pid = PID_MAGIC_ID;
852 dload->pid = pid;
853
854 /* update serial number */
855 dload->magic_struct.serial_num = 0;
856 if (!snum) {
857 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
858 goto out;
859 }
860
861 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
862 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
863out:
864 iounmap(dload);
865 return 0;
866}
867
868static struct android_usb_platform_data android_usb_pdata = {
869 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
870};
871
Hemant Kumar4933b072011-10-17 23:43:11 -0700872static struct platform_device android_usb_device = {
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800873 .name = "android_usb",
874 .id = -1,
875 .dev = {
876 .platform_data = &android_usb_pdata,
877 },
Hemant Kumar4933b072011-10-17 23:43:11 -0700878};
879
Hemant Kumar7620eed2012-02-26 09:08:43 -0800880/* Bandwidth requests (zero) if no vote placed */
881static struct msm_bus_vectors usb_init_vectors[] = {
882 {
883 .src = MSM_BUS_MASTER_SPS,
884 .dst = MSM_BUS_SLAVE_EBI_CH0,
885 .ab = 0,
886 .ib = 0,
887 },
888};
889
890/* Bus bandwidth requests in Bytes/sec */
891static struct msm_bus_vectors usb_max_vectors[] = {
892 {
893 .src = MSM_BUS_MASTER_SPS,
894 .dst = MSM_BUS_SLAVE_EBI_CH0,
895 .ab = 60000000, /* At least 480Mbps on bus. */
896 .ib = 960000000, /* MAX bursts rate */
897 },
898};
899
900static struct msm_bus_paths usb_bus_scale_usecases[] = {
901 {
902 ARRAY_SIZE(usb_init_vectors),
903 usb_init_vectors,
904 },
905 {
906 ARRAY_SIZE(usb_max_vectors),
907 usb_max_vectors,
908 },
909};
910
911static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
912 usb_bus_scale_usecases,
913 ARRAY_SIZE(usb_bus_scale_usecases),
914 .name = "usb",
915};
916
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700917static int phy_init_seq[] = {
918 0x38, 0x81, /* update DC voltage level */
919 0x24, 0x82, /* set pre-emphasis and rise/fall time */
920 -1
921};
922
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530923#define PMIC_GPIO_DP 27 /* PMIC GPIO for D+ change */
924#define PMIC_GPIO_DP_IRQ PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PMIC_GPIO_DP)
Jack Pham87f202f2012-08-06 00:24:22 -0700925#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
926
Hemant Kumar4933b072011-10-17 23:43:11 -0700927static struct msm_otg_platform_data msm_otg_pdata = {
Hemant Kumard86c4882012-01-24 19:39:37 -0800928 .mode = USB_OTG,
929 .otg_control = OTG_PMIC_CONTROL,
Hemant Kumar4933b072011-10-17 23:43:11 -0700930 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumard86c4882012-01-24 19:39:37 -0800931 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
932 .power_budget = 750,
Hemant Kumar7620eed2012-02-26 09:08:43 -0800933 .bus_scale_table = &usb_bus_scale_pdata,
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700934 .phy_init_seq = phy_init_seq,
Jack Pham87f202f2012-08-06 00:24:22 -0700935 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Hemant Kumar4933b072011-10-17 23:43:11 -0700936};
937
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800938static struct msm_usb_host_platform_data msm_ehci_host_pdata3 = {
Manu Gautam91223e02011-11-08 15:27:22 +0530939 .power_budget = 500,
940};
941
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800942#ifdef CONFIG_USB_EHCI_MSM_HOST4
943static struct msm_usb_host_platform_data msm_ehci_host_pdata4;
944#endif
945
Manu Gautam91223e02011-11-08 15:27:22 +0530946static void __init apq8064_ehci_host_init(void)
947{
Chiranjeevi Velempatib822fa32012-05-23 22:05:59 +0530948 if (machine_is_apq8064_liquid() || machine_is_mpq8064_cdp() ||
949 machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
950 if (machine_is_apq8064_liquid())
951 msm_ehci_host_pdata3.dock_connect_irq =
952 PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9);
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530953 else
954 msm_ehci_host_pdata3.pmic_gpio_dp_irq =
955 PMIC_GPIO_DP_IRQ;
Hemant Kumar56925352012-02-13 16:59:52 -0800956
Manu Gautam91223e02011-11-08 15:27:22 +0530957 apq8064_device_ehci_host3.dev.platform_data =
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800958 &msm_ehci_host_pdata3;
Manu Gautam91223e02011-11-08 15:27:22 +0530959 platform_device_register(&apq8064_device_ehci_host3);
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800960
961#ifdef CONFIG_USB_EHCI_MSM_HOST4
962 apq8064_device_ehci_host4.dev.platform_data =
963 &msm_ehci_host_pdata4;
964 platform_device_register(&apq8064_device_ehci_host4);
965#endif
Manu Gautam91223e02011-11-08 15:27:22 +0530966 }
967}
968
David Keitel2f613d92012-02-15 11:29:16 -0800969static struct smb349_platform_data smb349_data __initdata = {
970 .en_n_gpio = PM8921_GPIO_PM_TO_SYS(37),
971 .chg_susp_gpio = PM8921_GPIO_PM_TO_SYS(30),
972 .chg_current_ma = 2200,
973};
974
975static struct i2c_board_info smb349_charger_i2c_info[] __initdata = {
976 {
977 I2C_BOARD_INFO(SMB349_NAME, 0x1B),
978 .platform_data = &smb349_data,
979 },
980};
981
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -0800982struct sx150x_platform_data apq8064_sx150x_data[] = {
983 [SX150X_EPM] = {
984 .gpio_base = GPIO_EPM_EXPANDER_BASE,
985 .oscio_is_gpo = false,
986 .io_pullup_ena = 0x0,
987 .io_pulldn_ena = 0x0,
988 .io_open_drain_ena = 0x0,
989 .io_polarity = 0,
990 .irq_summary = -1,
991 },
992};
993
994static struct epm_chan_properties ads_adc_channel_data[] = {
Yan Hec942e402012-08-31 11:14:58 -0700995 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
996 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
997 {10, 100}, {20, 100}, {500, 100}, {5, 100},
998 {1000, 1}, {200, 100}, {50, 100}, {10, 100},
999 {510, 100}, {50, 100}, {20, 100}, {100, 100},
1000 {510, 100}, {20, 100}, {50, 100}, {200, 100},
1001 {10, 100}, {20, 100}, {1000, 1}, {10, 100},
1002 {200, 100}, {510, 100}, {1000, 100}, {200, 100},
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08001003};
1004
1005static struct epm_adc_platform_data epm_adc_pdata = {
1006 .channel = ads_adc_channel_data,
1007 .bus_id = 0x0,
1008 .epm_i2c_board_info = {
1009 .type = "sx1509q",
1010 .addr = 0x3e,
1011 .platform_data = &apq8064_sx150x_data[SX150X_EPM],
1012 },
1013 .gpio_expander_base_addr = GPIO_EPM_EXPANDER_BASE,
1014};
1015
1016static struct platform_device epm_adc_device = {
1017 .name = "epm_adc",
1018 .id = -1,
1019 .dev = {
1020 .platform_data = &epm_adc_pdata,
1021 },
1022};
1023
1024static void __init apq8064_epm_adc_init(void)
1025{
1026 epm_adc_pdata.num_channels = 32;
1027 epm_adc_pdata.num_adc = 2;
1028 epm_adc_pdata.chan_per_adc = 16;
1029 epm_adc_pdata.chan_per_mux = 8;
1030};
1031
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001032/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1033 * 4 micbiases are used to power various analog and digital
1034 * microphones operating at 1800 mV. Technically, all micbiases
1035 * can source from single cfilter since all microphones operate
1036 * at the same voltage level. The arrangement below is to make
1037 * sure all cfilters are exercised. LDO_H regulator ouput level
1038 * does not need to be as high as 2.85V. It is choosen for
1039 * microphone sensitivity purpose.
1040 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301041static struct wcd9xxx_pdata apq8064_tabla_platform_data = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001042 .slimbus_slave_device = {
1043 .name = "tabla-slave",
1044 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1045 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001046 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001047 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301048 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001049 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1050 .micbias = {
1051 .ldoh_v = TABLA_LDOH_2P85_V,
1052 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001053 .cfilt2_mv = 2700,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001054 .cfilt3_mv = 1800,
1055 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1056 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1057 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1058 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301059 },
1060 .regulator = {
1061 {
1062 .name = "CDC_VDD_CP",
1063 .min_uV = 1800000,
1064 .max_uV = 1800000,
1065 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1066 },
1067 {
1068 .name = "CDC_VDDA_RX",
1069 .min_uV = 1800000,
1070 .max_uV = 1800000,
1071 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1072 },
1073 {
1074 .name = "CDC_VDDA_TX",
1075 .min_uV = 1800000,
1076 .max_uV = 1800000,
1077 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1078 },
1079 {
1080 .name = "VDDIO_CDC",
1081 .min_uV = 1800000,
1082 .max_uV = 1800000,
1083 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1084 },
1085 {
1086 .name = "VDDD_CDC_D",
1087 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001088 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301089 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1090 },
1091 {
1092 .name = "CDC_VDDA_A_1P2V",
1093 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001094 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301095 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1096 },
1097 },
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001098};
1099
1100static struct slim_device apq8064_slim_tabla = {
1101 .name = "tabla-slim",
1102 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1103 .dev = {
1104 .platform_data = &apq8064_tabla_platform_data,
1105 },
1106};
1107
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301108static struct wcd9xxx_pdata apq8064_tabla20_platform_data = {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001109 .slimbus_slave_device = {
1110 .name = "tabla-slave",
1111 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
1112 },
1113 .irq = MSM_GPIO_TO_INT(42),
1114 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301115 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001116 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1117 .micbias = {
1118 .ldoh_v = TABLA_LDOH_2P85_V,
1119 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001120 .cfilt2_mv = 2700,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001121 .cfilt3_mv = 1800,
1122 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1123 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1124 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1125 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301126 },
1127 .regulator = {
1128 {
1129 .name = "CDC_VDD_CP",
1130 .min_uV = 1800000,
1131 .max_uV = 1800000,
1132 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1133 },
1134 {
1135 .name = "CDC_VDDA_RX",
1136 .min_uV = 1800000,
1137 .max_uV = 1800000,
1138 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1139 },
1140 {
1141 .name = "CDC_VDDA_TX",
1142 .min_uV = 1800000,
1143 .max_uV = 1800000,
1144 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1145 },
1146 {
1147 .name = "VDDIO_CDC",
1148 .min_uV = 1800000,
1149 .max_uV = 1800000,
1150 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1151 },
1152 {
1153 .name = "VDDD_CDC_D",
1154 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001155 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301156 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1157 },
1158 {
1159 .name = "CDC_VDDA_A_1P2V",
1160 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001161 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301162 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1163 },
1164 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001165};
1166
1167static struct slim_device apq8064_slim_tabla20 = {
1168 .name = "tabla2x-slim",
1169 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1170 .dev = {
1171 .platform_data = &apq8064_tabla20_platform_data,
1172 },
1173};
1174
Santosh Mardi695be0d2012-04-10 23:21:12 +05301175/* enable the level shifter for cs8427 to make sure the I2C
1176 * clock is running at 100KHz and voltage levels are at 3.3
1177 * and 5 volts
1178 */
1179static int enable_100KHz_ls(int enable)
1180{
1181 int ret = 0;
1182 if (enable) {
1183 ret = gpio_request(SX150X_GPIO(1, 10),
1184 "cs8427_100KHZ_ENABLE");
1185 if (ret) {
1186 pr_err("%s: Failed to request gpio %d\n", __func__,
1187 SX150X_GPIO(1, 10));
1188 return ret;
1189 }
1190 gpio_direction_output(SX150X_GPIO(1, 10), 1);
Santosh Mardid706fcf2012-08-31 19:26:54 +05301191 } else {
1192 gpio_direction_output(SX150X_GPIO(1, 10), 0);
Santosh Mardi695be0d2012-04-10 23:21:12 +05301193 gpio_free(SX150X_GPIO(1, 10));
Santosh Mardid706fcf2012-08-31 19:26:54 +05301194 }
Santosh Mardi695be0d2012-04-10 23:21:12 +05301195 return ret;
1196}
1197
Santosh Mardieff9a742012-04-09 23:23:39 +05301198static struct cs8427_platform_data cs8427_i2c_platform_data = {
1199 .irq = SX150X_GPIO(1, 4),
1200 .reset_gpio = SX150X_GPIO(1, 6),
Santosh Mardi695be0d2012-04-10 23:21:12 +05301201 .enable = enable_100KHz_ls,
Santosh Mardieff9a742012-04-09 23:23:39 +05301202};
1203
1204static struct i2c_board_info cs8427_device_info[] __initdata = {
1205 {
1206 I2C_BOARD_INFO("cs8427", CS8427_ADDR4),
1207 .platform_data = &cs8427_i2c_platform_data,
1208 },
1209};
1210
Amy Maloche70090f992012-02-16 16:35:26 -08001211#define HAP_SHIFT_LVL_OE_GPIO PM8921_MPP_PM_TO_SYS(8)
1212#define ISA1200_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1213#define ISA1200_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
David Collins6f7c3472012-08-22 13:18:06 -07001214#define ISA1200_HAP_CLK_PM8921 PM8921_GPIO_PM_TO_SYS(44)
1215#define ISA1200_HAP_CLK_PM8917 PM8921_GPIO_PM_TO_SYS(38)
Amy Maloche70090f992012-02-16 16:35:26 -08001216
Mohan Pallaka2d877602012-05-11 13:07:30 +05301217static int isa1200_clk_enable(bool on)
Amy Maloche70090f992012-02-16 16:35:26 -08001218{
David Collins6f7c3472012-08-22 13:18:06 -07001219 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche8f973892012-03-26 14:53:13 -07001220 int rc = 0;
1221
David Collins6f7c3472012-08-22 13:18:06 -07001222 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1223 gpio = ISA1200_HAP_CLK_PM8917;
1224
1225 gpio_set_value_cansleep(gpio, on);
Amy Maloche70090f992012-02-16 16:35:26 -08001226
Mohan Pallaka2d877602012-05-11 13:07:30 +05301227 if (on) {
Amy Maloche8f973892012-03-26 14:53:13 -07001228 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_1, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301229 if (rc) {
1230 pr_err("%s: unable to write aux clock register(%d)\n",
1231 __func__, rc);
1232 goto err_gpio_dis;
1233 }
1234 } else {
Amy Maloche8f973892012-03-26 14:53:13 -07001235 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_NONE, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301236 if (rc)
1237 pr_err("%s: unable to write aux clock register(%d)\n",
1238 __func__, rc);
Amy Maloche8f973892012-03-26 14:53:13 -07001239 }
1240
1241 return rc;
Mohan Pallaka2d877602012-05-11 13:07:30 +05301242
1243err_gpio_dis:
David Collins6f7c3472012-08-22 13:18:06 -07001244 gpio_set_value_cansleep(gpio, !on);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301245 return rc;
Amy Maloche70090f992012-02-16 16:35:26 -08001246}
1247
1248static int isa1200_dev_setup(bool enable)
1249{
David Collins6f7c3472012-08-22 13:18:06 -07001250 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche70090f992012-02-16 16:35:26 -08001251 int rc = 0;
1252
David Collins6f7c3472012-08-22 13:18:06 -07001253 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1254 gpio = ISA1200_HAP_CLK_PM8917;
1255
Amy Maloche70090f992012-02-16 16:35:26 -08001256 if (!enable)
1257 goto free_gpio;
1258
David Collins6f7c3472012-08-22 13:18:06 -07001259 rc = gpio_request(gpio, "haptics_clk");
Amy Maloche70090f992012-02-16 16:35:26 -08001260 if (rc) {
1261 pr_err("%s: unable to request gpio %d config(%d)\n",
David Collins6f7c3472012-08-22 13:18:06 -07001262 __func__, gpio, rc);
Amy Maloche70090f992012-02-16 16:35:26 -08001263 return rc;
1264 }
1265
David Collins6f7c3472012-08-22 13:18:06 -07001266 rc = gpio_direction_output(gpio, 0);
Amy Maloche70090f992012-02-16 16:35:26 -08001267 if (rc) {
1268 pr_err("%s: unable to set direction\n", __func__);
1269 goto free_gpio;
1270 }
1271
1272 return 0;
1273
1274free_gpio:
David Collins6f7c3472012-08-22 13:18:06 -07001275 gpio_free(gpio);
Amy Maloche70090f992012-02-16 16:35:26 -08001276 return rc;
1277}
1278
1279static struct isa1200_regulator isa1200_reg_data[] = {
1280 {
1281 .name = "vddp",
1282 .min_uV = ISA_I2C_VTG_MIN_UV,
1283 .max_uV = ISA_I2C_VTG_MAX_UV,
1284 .load_uA = ISA_I2C_CURR_UA,
1285 },
1286};
1287
1288static struct isa1200_platform_data isa1200_1_pdata = {
1289 .name = "vibrator",
1290 .dev_setup = isa1200_dev_setup,
Mohan Pallaka2d877602012-05-11 13:07:30 +05301291 .clk_enable = isa1200_clk_enable,
Mohan Pallaka32f20a72012-06-14 14:41:11 +05301292 .need_pwm_clk = true,
Amy Maloche70090f992012-02-16 16:35:26 -08001293 .hap_en_gpio = ISA1200_HAP_EN_GPIO,
1294 .hap_len_gpio = ISA1200_HAP_LEN_GPIO,
1295 .max_timeout = 15000,
1296 .mode_ctrl = PWM_GEN_MODE,
1297 .pwm_fd = {
1298 .pwm_div = 256,
1299 },
1300 .is_erm = false,
1301 .smart_en = true,
1302 .ext_clk_en = true,
1303 .chip_en = 1,
1304 .regulator_info = isa1200_reg_data,
1305 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1306};
1307
1308static struct i2c_board_info isa1200_board_info[] __initdata = {
1309 {
1310 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1311 .platform_data = &isa1200_1_pdata,
1312 },
1313};
Jing Lin21ed4de2012-02-05 15:53:28 -08001314/* configuration data for mxt1386e using V2.1 firmware */
1315static const u8 mxt1386e_config_data_v2_1[] = {
1316 /* T6 Object */
1317 0, 0, 0, 0, 0, 0,
1318 /* T38 Object */
Jing Line4c47042012-08-31 10:54:44 -07001319 14, 3, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1323 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1324 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1325 0, 0, 0, 0,
1326 /* T7 Object */
Jing Line4c47042012-08-31 10:54:44 -07001327 32, 10, 50,
Jing Lin21ed4de2012-02-05 15:53:28 -08001328 /* T8 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001329 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001330 /* T9 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001331 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Line4c47042012-08-31 10:54:44 -07001332 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Linf1208fd2012-02-23 11:15:42 -08001333 85, 5, 0, 5, 9, 5, 12, 35, 70, 40,
1334 20, 5, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001335 /* T18 Object */
1336 0, 0,
1337 /* T24 Object */
1338 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1339 0, 0, 0, 0, 0, 0, 0, 0, 0,
1340 /* T25 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001341 1, 0, 60, 115, 156, 99,
Jing Lin21ed4de2012-02-05 15:53:28 -08001342 /* T27 Object */
1343 0, 0, 0, 0, 0, 0, 0,
1344 /* T40 Object */
1345 0, 0, 0, 0, 0,
1346 /* T42 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001347 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001348 /* T43 Object */
1349 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
1350 16,
1351 /* T46 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001352 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001353 /* T47 Object */
1354 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
1355 /* T48 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001356 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001357 32, 40, 0, 10, 10, 0, 0, 100, 10, 90,
1358 0, 0, 0, 0, 0, 0, 0, 10, 1, 10,
1359 52, 10, 12, 0, 33, 0, 1, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1361 0, 0, 0, 0,
1362 /* T56 Object */
1363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1364 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1365 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1366 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001367 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1368 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001369};
1370
1371#define MXT_TS_GPIO_IRQ 6
1372#define MXT_TS_PWR_EN_GPIO PM8921_GPIO_PM_TO_SYS(23)
1373#define MXT_TS_RESET_GPIO 33
1374
1375static struct mxt_config_info mxt_config_array[] = {
1376 {
1377 .config = mxt1386e_config_data_v2_1,
1378 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1379 .family_id = 0xA0,
1380 .variant_id = 0x7,
1381 .version = 0x21,
1382 .build = 0xAA,
Jing Linef4aa9b2012-03-26 12:01:41 -07001383 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
1384 .fw_name = "atmel_8064_liquid_v2_2_AA.hex",
1385 },
1386 {
1387 /* The config data for V2.2.AA is the same as for V2.1.AA */
1388 .config = mxt1386e_config_data_v2_1,
1389 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1390 .family_id = 0xA0,
1391 .variant_id = 0x7,
1392 .version = 0x22,
1393 .build = 0xAA,
1394 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin21ed4de2012-02-05 15:53:28 -08001395 },
1396};
1397
1398static struct mxt_platform_data mxt_platform_data = {
1399 .config_array = mxt_config_array,
1400 .config_array_size = ARRAY_SIZE(mxt_config_array),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08001401 .panel_minx = 0,
1402 .panel_maxx = 1365,
1403 .panel_miny = 0,
1404 .panel_maxy = 767,
1405 .disp_minx = 0,
1406 .disp_maxx = 1365,
1407 .disp_miny = 0,
1408 .disp_maxy = 767,
Anirudh Ghayal39dbe3f2012-04-13 15:43:16 +05301409 .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Jing Lin21ed4de2012-02-05 15:53:28 -08001410 .i2c_pull_up = true,
1411 .reset_gpio = MXT_TS_RESET_GPIO,
1412 .irq_gpio = MXT_TS_GPIO_IRQ,
1413};
1414
1415static struct i2c_board_info mxt_device_info[] __initdata = {
1416 {
1417 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
1418 .platform_data = &mxt_platform_data,
1419 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1420 },
1421};
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001422#define CYTTSP_TS_GPIO_IRQ 6
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001423#define CYTTSP_TS_GPIO_SLEEP 33
Amy Maloche609bb5e2012-08-03 09:41:42 -07001424#define CYTTSP_TS_GPIO_SLEEP_ALT 12
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001425
1426static ssize_t tma340_vkeys_show(struct kobject *kobj,
1427 struct kobj_attribute *attr, char *buf)
1428{
1429 return snprintf(buf, 200,
1430 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1431 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1432 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1433 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1434 "\n");
1435}
1436
1437static struct kobj_attribute tma340_vkeys_attr = {
1438 .attr = {
1439 .mode = S_IRUGO,
1440 },
1441 .show = &tma340_vkeys_show,
1442};
1443
1444static struct attribute *tma340_properties_attrs[] = {
1445 &tma340_vkeys_attr.attr,
1446 NULL
1447};
1448
1449static struct attribute_group tma340_properties_attr_group = {
1450 .attrs = tma340_properties_attrs,
1451};
1452
1453static int cyttsp_platform_init(struct i2c_client *client)
1454{
1455 int rc = 0;
1456 static struct kobject *tma340_properties_kobj;
1457
1458 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1459 tma340_properties_kobj = kobject_create_and_add("board_properties",
1460 NULL);
1461 if (tma340_properties_kobj)
1462 rc = sysfs_create_group(tma340_properties_kobj,
1463 &tma340_properties_attr_group);
1464 if (!tma340_properties_kobj || rc)
1465 pr_err("%s: failed to create board_properties\n",
1466 __func__);
1467
1468 return 0;
1469}
1470
1471static struct cyttsp_regulator cyttsp_regulator_data[] = {
1472 {
1473 .name = "vdd",
1474 .min_uV = CY_TMA300_VTG_MIN_UV,
1475 .max_uV = CY_TMA300_VTG_MAX_UV,
1476 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1477 .lpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1478 },
1479 {
1480 .name = "vcc_i2c",
1481 .min_uV = CY_I2C_VTG_MIN_UV,
1482 .max_uV = CY_I2C_VTG_MAX_UV,
1483 .hpm_load_uA = CY_I2C_CURR_UA,
1484 .lpm_load_uA = CY_I2C_CURR_UA,
1485 },
1486};
1487
1488static struct cyttsp_platform_data cyttsp_pdata = {
1489 .panel_maxx = 634,
1490 .panel_maxy = 1166,
Amy Maloche684fcda2012-12-05 14:28:53 -08001491 .disp_minx = 18,
1492 .disp_maxx = 617,
1493 .disp_miny = 18,
1494 .disp_maxy = 1041,
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001495 .flags = 0x01,
1496 .gen = CY_GEN3,
1497 .use_st = CY_USE_ST,
1498 .use_mt = CY_USE_MT,
1499 .use_hndshk = CY_SEND_HNDSHK,
1500 .use_trk_id = CY_USE_TRACKING_ID,
1501 .use_sleep = CY_USE_DEEP_SLEEP_SEL,
1502 .use_gestures = CY_USE_GESTURES,
1503 .fw_fname = "cyttsp_8064_mtp.hex",
1504 /* change act_intrvl to customize the Active power state
1505 * scanning/processing refresh interval for Operating mode
1506 */
1507 .act_intrvl = CY_ACT_INTRVL_DFLT,
1508 /* change tch_tmout to customize the touch timeout for the
1509 * Active power state for Operating mode
1510 */
1511 .tch_tmout = CY_TCH_TMOUT_DFLT,
1512 /* change lp_intrvl to customize the Low Power power state
1513 * scanning/processing refresh interval for Operating mode
1514 */
1515 .lp_intrvl = CY_LP_INTRVL_DFLT,
1516 .sleep_gpio = CYTTSP_TS_GPIO_SLEEP,
Amy Maloche9ba3ffe2012-04-26 10:31:20 -07001517 .resout_gpio = -1,
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001518 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1519 .regulator_info = cyttsp_regulator_data,
1520 .num_regulators = ARRAY_SIZE(cyttsp_regulator_data),
1521 .init = cyttsp_platform_init,
1522 .correct_fw_ver = 17,
1523};
1524
1525static struct i2c_board_info cyttsp_info[] __initdata = {
1526 {
1527 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1528 .platform_data = &cyttsp_pdata,
1529 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1530 },
1531};
Jing Lin21ed4de2012-02-05 15:53:28 -08001532
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08001533#define MSM_WCNSS_PHYS 0x03000000
1534#define MSM_WCNSS_SIZE 0x280000
1535
1536static struct resource resources_wcnss_wlan[] = {
1537 {
1538 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1539 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1540 .name = "wcnss_wlanrx_irq",
1541 .flags = IORESOURCE_IRQ,
1542 },
1543 {
1544 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1545 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1546 .name = "wcnss_wlantx_irq",
1547 .flags = IORESOURCE_IRQ,
1548 },
1549 {
1550 .start = MSM_WCNSS_PHYS,
1551 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1552 .name = "wcnss_mmio",
1553 .flags = IORESOURCE_MEM,
1554 },
1555 {
1556 .start = 64,
1557 .end = 68,
1558 .name = "wcnss_gpios_5wire",
1559 .flags = IORESOURCE_IO,
1560 },
1561};
1562
1563static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1564 .has_48mhz_xo = 1,
1565};
1566
1567static struct platform_device msm_device_wcnss_wlan = {
1568 .name = "wcnss_wlan",
1569 .id = 0,
1570 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1571 .resource = resources_wcnss_wlan,
1572 .dev = {.platform_data = &qcom_wcnss_pdata},
1573};
1574
Ankit Vermab7c26e62012-02-28 15:04:15 -08001575static struct platform_device msm_device_iris_fm __devinitdata = {
1576 .name = "iris_fm",
1577 .id = -1,
1578};
1579
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001580#ifdef CONFIG_QSEECOM
1581/* qseecom bus scaling */
1582static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1583 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001584 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001585 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001586 .ab = 0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001587 .ib = 0,
1588 },
1589 {
1590 .src = MSM_BUS_MASTER_ADM_PORT1,
1591 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1592 .ab = 0,
1593 .ib = 0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001594 },
1595 {
1596 .src = MSM_BUS_MASTER_SPDM,
1597 .dst = MSM_BUS_SLAVE_SPDM,
1598 .ib = 0,
1599 .ab = 0,
1600 },
1601};
1602
1603static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1604 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001605 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001606 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001607 .ab = 70000000UL,
1608 .ib = 70000000UL,
1609 },
1610 {
1611 .src = MSM_BUS_MASTER_ADM_PORT1,
1612 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1613 .ab = 2480000000UL,
1614 .ib = 2480000000UL,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001615 },
1616 {
1617 .src = MSM_BUS_MASTER_SPDM,
1618 .dst = MSM_BUS_SLAVE_SPDM,
1619 .ib = 0,
1620 .ab = 0,
1621 },
1622};
1623
1624static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1625 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001626 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001627 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001628 .ab = 0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001629 .ib = 0,
1630 },
1631 {
1632 .src = MSM_BUS_MASTER_ADM_PORT1,
1633 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1634 .ab = 0,
1635 .ib = 0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001636 },
1637 {
1638 .src = MSM_BUS_MASTER_SPDM,
1639 .dst = MSM_BUS_SLAVE_SPDM,
1640 .ib = (64 * 8) * 1000000UL,
1641 .ab = (64 * 8) * 100000UL,
1642 },
1643};
1644
Ramesh Masavarapu4f091cb2012-10-03 10:18:06 -07001645static struct msm_bus_vectors qseecom_enable_dfab_sfpb_vectors[] = {
1646 {
1647 .src = MSM_BUS_MASTER_ADM_PORT0,
1648 .dst = MSM_BUS_SLAVE_EBI_CH0,
1649 .ab = 70000000UL,
1650 .ib = 70000000UL,
1651 },
1652 {
1653 .src = MSM_BUS_MASTER_ADM_PORT1,
1654 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1655 .ab = 2480000000UL,
1656 .ib = 2480000000UL,
1657 },
1658 {
1659 .src = MSM_BUS_MASTER_SPDM,
1660 .dst = MSM_BUS_SLAVE_SPDM,
1661 .ib = (64 * 8) * 1000000UL,
1662 .ab = (64 * 8) * 100000UL,
1663 },
1664};
1665
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001666static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1667 {
1668 ARRAY_SIZE(qseecom_clks_init_vectors),
1669 qseecom_clks_init_vectors,
1670 },
1671 {
1672 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001673 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001674 },
1675 {
1676 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1677 qseecom_enable_sfpb_vectors,
1678 },
Ramesh Masavarapu4f091cb2012-10-03 10:18:06 -07001679 {
1680 ARRAY_SIZE(qseecom_enable_dfab_sfpb_vectors),
1681 qseecom_enable_dfab_sfpb_vectors,
1682 },
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001683};
1684
1685static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1686 qseecom_hw_bus_scale_usecases,
1687 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1688 .name = "qsee",
1689};
1690
1691static struct platform_device qseecom_device = {
1692 .name = "qseecom",
1693 .id = 0,
1694 .dev = {
1695 .platform_data = &qseecom_bus_pdata,
1696 },
1697};
1698#endif
1699
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001700#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1701 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1702 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1703 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1704
1705#define QCE_SIZE 0x10000
1706#define QCE_0_BASE 0x11000000
1707
1708#define QCE_HW_KEY_SUPPORT 0
1709#define QCE_SHA_HMAC_SUPPORT 1
1710#define QCE_SHARE_CE_RESOURCE 3
1711#define QCE_CE_SHARED 0
1712
1713static struct resource qcrypto_resources[] = {
1714 [0] = {
1715 .start = QCE_0_BASE,
1716 .end = QCE_0_BASE + QCE_SIZE - 1,
1717 .flags = IORESOURCE_MEM,
1718 },
1719 [1] = {
1720 .name = "crypto_channels",
1721 .start = DMOV8064_CE_IN_CHAN,
1722 .end = DMOV8064_CE_OUT_CHAN,
1723 .flags = IORESOURCE_DMA,
1724 },
1725 [2] = {
1726 .name = "crypto_crci_in",
1727 .start = DMOV8064_CE_IN_CRCI,
1728 .end = DMOV8064_CE_IN_CRCI,
1729 .flags = IORESOURCE_DMA,
1730 },
1731 [3] = {
1732 .name = "crypto_crci_out",
1733 .start = DMOV8064_CE_OUT_CRCI,
1734 .end = DMOV8064_CE_OUT_CRCI,
1735 .flags = IORESOURCE_DMA,
1736 },
1737};
1738
1739static struct resource qcedev_resources[] = {
1740 [0] = {
1741 .start = QCE_0_BASE,
1742 .end = QCE_0_BASE + QCE_SIZE - 1,
1743 .flags = IORESOURCE_MEM,
1744 },
1745 [1] = {
1746 .name = "crypto_channels",
1747 .start = DMOV8064_CE_IN_CHAN,
1748 .end = DMOV8064_CE_OUT_CHAN,
1749 .flags = IORESOURCE_DMA,
1750 },
1751 [2] = {
1752 .name = "crypto_crci_in",
1753 .start = DMOV8064_CE_IN_CRCI,
1754 .end = DMOV8064_CE_IN_CRCI,
1755 .flags = IORESOURCE_DMA,
1756 },
1757 [3] = {
1758 .name = "crypto_crci_out",
1759 .start = DMOV8064_CE_OUT_CRCI,
1760 .end = DMOV8064_CE_OUT_CRCI,
1761 .flags = IORESOURCE_DMA,
1762 },
1763};
1764
1765#endif
1766
1767#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1768 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1769
1770static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1771 .ce_shared = QCE_CE_SHARED,
1772 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1773 .hw_key_support = QCE_HW_KEY_SUPPORT,
1774 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001775 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001776};
1777
1778static struct platform_device qcrypto_device = {
1779 .name = "qcrypto",
1780 .id = 0,
1781 .num_resources = ARRAY_SIZE(qcrypto_resources),
1782 .resource = qcrypto_resources,
1783 .dev = {
1784 .coherent_dma_mask = DMA_BIT_MASK(32),
1785 .platform_data = &qcrypto_ce_hw_suppport,
1786 },
1787};
1788#endif
1789
1790#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1791 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1792
1793static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1794 .ce_shared = QCE_CE_SHARED,
1795 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1796 .hw_key_support = QCE_HW_KEY_SUPPORT,
1797 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001798 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001799};
1800
1801static struct platform_device qcedev_device = {
1802 .name = "qce",
1803 .id = 0,
1804 .num_resources = ARRAY_SIZE(qcedev_resources),
1805 .resource = qcedev_resources,
1806 .dev = {
1807 .coherent_dma_mask = DMA_BIT_MASK(32),
1808 .platform_data = &qcedev_ce_hw_suppport,
1809 },
1810};
1811#endif
1812
Joel Kingef390842012-05-23 16:42:48 -07001813static struct mdm_vddmin_resource mdm_vddmin_rscs = {
1814 .rpm_id = MSM_RPM_ID_VDDMIN_GPIO,
1815 .ap2mdm_vddmin_gpio = 30,
1816 .modes = 0x03,
1817 .drive_strength = 8,
1818 .mdm2ap_vddmin_gpio = 80,
1819};
1820
Joel King269aa602012-07-23 08:07:35 -07001821static struct gpiomux_setting mdm2ap_status_gpio_run_cfg = {
1822 .func = GPIOMUX_FUNC_GPIO,
1823 .drv = GPIOMUX_DRV_8MA,
1824 .pull = GPIOMUX_PULL_NONE,
1825};
1826
Joel Kingdacbc822012-01-25 13:30:57 -08001827static struct mdm_platform_data mdm_platform_data = {
1828 .mdm_version = "3.0",
1829 .ramdump_delay_ms = 2000,
Joel King14fe7fa2012-05-27 14:26:11 -07001830 .early_power_on = 1,
1831 .sfr_query = 1,
Joel Kingef390842012-05-23 16:42:48 -07001832 .vddmin_resource = &mdm_vddmin_rscs,
Hemant Kumara945b472012-01-25 15:08:06 -08001833 .peripheral_platform_device = &apq8064_device_hsic_host,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001834 .ramdump_timeout_ms = 120000,
Joel King269aa602012-07-23 08:07:35 -07001835 .mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
Ameya Thakurffd21b02013-01-30 11:33:22 -08001836 .sysmon_subsys_id_valid = 1,
1837 .sysmon_subsys_id = SYSMON_SS_EXT_MODEM,
Joel Kingdacbc822012-01-25 13:30:57 -08001838};
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001839
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08001840static struct tsens_platform_data apq_tsens_pdata = {
1841 .tsens_factor = 1000,
1842 .hw_type = APQ_8064,
1843 .tsens_num_sensor = 11,
1844 .slope = {1176, 1176, 1154, 1176, 1111,
1845 1132, 1132, 1199, 1132, 1199, 1132},
1846};
1847
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07001848static struct platform_device msm_tsens_device = {
1849 .name = "tsens8960-tm",
1850 .id = -1,
1851};
1852
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001853static struct msm_thermal_data msm_thermal_pdata = {
1854 .sensor_id = 7,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06001855 .poll_ms = 250,
1856 .limit_temp_degC = 60,
1857 .temp_hysteresis_degC = 10,
1858 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001859};
1860
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001861#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862static void __init apq8064_map_io(void)
1863{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001864 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001865 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001866 if (socinfo_init() < 0)
1867 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001868}
1869
1870static void __init apq8064_init_irq(void)
1871{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001872 struct msm_mpm_device_data *data = NULL;
1873
1874#ifdef CONFIG_MSM_MPM
1875 data = &apq8064_mpm_dev_data;
1876#endif
1877
1878 msm_mpm_irq_extn_init(data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001879 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
1880 (void *)MSM_QGIC_CPU_BASE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001881}
1882
Jay Chokshi7805b5a2011-11-07 15:55:30 -08001883static struct platform_device msm8064_device_saw_regulator_core0 = {
1884 .name = "saw-regulator",
1885 .id = 0,
1886 .dev = {
1887 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
1888 },
1889};
1890
1891static struct platform_device msm8064_device_saw_regulator_core1 = {
1892 .name = "saw-regulator",
1893 .id = 1,
1894 .dev = {
1895 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
1896 },
1897};
1898
1899static struct platform_device msm8064_device_saw_regulator_core2 = {
1900 .name = "saw-regulator",
1901 .id = 2,
1902 .dev = {
1903 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
1904 },
1905};
1906
1907static struct platform_device msm8064_device_saw_regulator_core3 = {
1908 .name = "saw-regulator",
1909 .id = 3,
1910 .dev = {
1911 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001912
1913 },
1914};
1915
Oluwafemi Adeyemif5a31422012-03-08 16:58:45 -08001916static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001917 {
1918 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1919 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1920 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001921 1, 784, 180000, 100,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001922 },
1923
1924 {
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301925 MSM_PM_SLEEP_MODE_RETENTION,
1926 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1927 true,
1928 415, 715, 340827, 475,
1929 },
1930
1931 {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001932 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1933 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1934 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001935 1300, 228, 1200000, 2000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001936 },
1937
1938 {
1939 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1940 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
1941 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001942 2000, 138, 1208400, 3200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001943 },
1944
1945 {
1946 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Praveen Chidambarame3380672012-02-08 10:32:27 -07001947 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
1948 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001949 6000, 119, 1850300, 9000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001950 },
1951
1952 {
1953 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1954 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
1955 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001956 9200, 68, 2839200, 16400,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001957 },
1958
1959 {
1960 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1961 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
1962 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001963 10300, 63, 3128000, 18200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001964 },
1965
1966 {
1967 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1968 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
1969 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001970 18000, 10, 4602600, 27000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001971 },
1972
1973 {
1974 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1975 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
1976 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001977 20000, 2, 5752000, 32000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001978 },
1979};
1980
1981static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1982 .mode = MSM_PM_BOOT_CONFIG_TZ,
1983};
1984
1985static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
1986 .levels = &msm_rpmrs_levels[0],
1987 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
1988 .vdd_mem_levels = {
1989 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
1990 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
1991 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
1992 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
1993 },
1994 .vdd_dig_levels = {
1995 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
1996 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
1997 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
1998 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
1999 },
2000 .vdd_mask = 0x7FFFFF,
2001 .rpmrs_target_id = {
2002 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
2003 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
2004 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
2005 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
2006 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
2007 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
2008 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
2009 },
2010};
2011
Praveen Chidambaram78499012011-11-01 17:15:17 -06002012static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2013 0x03, 0x0f,
2014};
2015
2016static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2017 0x00, 0x24, 0x54, 0x10,
2018 0x09, 0x03, 0x01,
2019 0x10, 0x54, 0x30, 0x0C,
2020 0x24, 0x30, 0x0f,
2021};
2022
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302023static uint8_t spm_retention_cmd_sequence[] __initdata = {
2024 0x00, 0x05, 0x03, 0x0D,
2025 0x0B, 0x00, 0x0f,
2026};
2027
Praveen Chidambaram78499012011-11-01 17:15:17 -06002028static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2029 0x00, 0x24, 0x54, 0x10,
2030 0x09, 0x07, 0x01, 0x0B,
2031 0x10, 0x54, 0x30, 0x0C,
2032 0x24, 0x30, 0x0f,
2033};
2034
Anji Jonnala0f297a92013-01-19 11:22:25 +05302035/* 8064AB has a different command to assert apc_pdn */
2036static uint8_t spm_power_collapse_without_rpm_krait_v3[] __initdata = {
2037 0x00, 0x24, 0x84, 0x10,
2038 0x09, 0x03, 0x01,
2039 0x10, 0x84, 0x30, 0x0C,
2040 0x24, 0x30, 0x0f,
2041};
2042
2043static uint8_t spm_power_collapse_with_rpm_krait_v3[] __initdata = {
2044 0x00, 0x24, 0x84, 0x10,
2045 0x09, 0x07, 0x01, 0x0B,
2046 0x10, 0x84, 0x30, 0x0C,
2047 0x24, 0x30, 0x0f,
2048};
2049
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302050static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
2051 [0] = {
2052 .mode = MSM_SPM_MODE_CLOCK_GATING,
2053 .notify_rpm = false,
2054 .cmd = spm_wfi_cmd_sequence,
2055 },
2056 [1] = {
2057 .mode = MSM_SPM_MODE_POWER_RETENTION,
2058 .notify_rpm = false,
2059 .cmd = spm_retention_cmd_sequence,
2060 },
2061 [2] = {
2062 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2063 .notify_rpm = false,
2064 .cmd = spm_power_collapse_without_rpm,
2065 },
2066 [3] = {
2067 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2068 .notify_rpm = true,
2069 .cmd = spm_power_collapse_with_rpm,
2070 },
2071};
2072static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06002073 [0] = {
2074 .mode = MSM_SPM_MODE_CLOCK_GATING,
2075 .notify_rpm = false,
2076 .cmd = spm_wfi_cmd_sequence,
2077 },
2078 [1] = {
2079 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2080 .notify_rpm = false,
2081 .cmd = spm_power_collapse_without_rpm,
2082 },
2083 [2] = {
2084 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2085 .notify_rpm = true,
2086 .cmd = spm_power_collapse_with_rpm,
2087 },
2088};
2089
2090static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2091 0x00, 0x20, 0x03, 0x20,
2092 0x00, 0x0f,
2093};
2094
2095static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2096 0x00, 0x20, 0x34, 0x64,
2097 0x48, 0x07, 0x48, 0x20,
2098 0x50, 0x64, 0x04, 0x34,
2099 0x50, 0x0f,
2100};
2101static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2102 0x00, 0x10, 0x34, 0x64,
2103 0x48, 0x07, 0x48, 0x10,
2104 0x50, 0x64, 0x04, 0x34,
2105 0x50, 0x0F,
2106};
2107
2108static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2109 [0] = {
2110 .mode = MSM_SPM_L2_MODE_RETENTION,
2111 .notify_rpm = false,
2112 .cmd = l2_spm_wfi_cmd_sequence,
2113 },
2114 [1] = {
2115 .mode = MSM_SPM_L2_MODE_GDHS,
2116 .notify_rpm = true,
2117 .cmd = l2_spm_gdhs_cmd_sequence,
2118 },
2119 [2] = {
2120 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2121 .notify_rpm = true,
2122 .cmd = l2_spm_power_off_cmd_sequence,
2123 },
2124};
2125
2126
2127static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2128 [0] = {
2129 .reg_base_addr = MSM_SAW_L2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002130 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002131 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002132 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2133 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2134 .modes = msm_spm_l2_seq_list,
2135 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2136 },
2137};
2138
2139static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2140 [0] = {
2141 .reg_base_addr = MSM_SAW0_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002142 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002143#if defined(CONFIG_MSM_AVS_HW)
2144 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2145 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2146#endif
2147 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302148 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
2149 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
2150 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002151 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302152 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
2153 .modes = msm_spm_boot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002154 },
2155 [1] = {
2156 .reg_base_addr = MSM_SAW1_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002157 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002158#if defined(CONFIG_MSM_AVS_HW)
2159 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2160 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2161#endif
2162 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002163 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002164 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2165 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2166 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302167 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2168 .modes = msm_spm_nonboot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002169 },
2170 [2] = {
2171 .reg_base_addr = MSM_SAW2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002172 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002173#if defined(CONFIG_MSM_AVS_HW)
2174 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2175 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2176#endif
2177 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002178 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002179 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2180 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2181 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302182 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2183 .modes = msm_spm_nonboot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002184 },
2185 [3] = {
2186 .reg_base_addr = MSM_SAW3_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002187 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002188#if defined(CONFIG_MSM_AVS_HW)
2189 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2190 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2191#endif
2192 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002193 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002194 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2195 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2196 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302197 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2198 .modes = msm_spm_nonboot_cpu_seq_list,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002199 },
2200};
2201
Anji Jonnala0f297a92013-01-19 11:22:25 +05302202static void __init apq8064ab_update_krait_spm(void)
2203{
2204 int i;
2205
2206 /* Update the SPM sequences for SPC and PC */
2207 for (i = 0; i < ARRAY_SIZE(msm_spm_data); i++) {
2208 int j;
2209 struct msm_spm_platform_data *pdata = &msm_spm_data[i];
2210 for (j = 0; j < pdata->num_modes; j++) {
2211 if (pdata->modes[j].cmd ==
2212 spm_power_collapse_without_rpm)
2213 pdata->modes[j].cmd =
2214 spm_power_collapse_without_rpm_krait_v3;
2215 else if (pdata->modes[j].cmd ==
2216 spm_power_collapse_with_rpm)
2217 pdata->modes[j].cmd =
2218 spm_power_collapse_with_rpm_krait_v3;
2219 }
2220 }
2221}
2222
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002223static void __init apq8064_init_buses(void)
2224{
2225 msm_bus_rpm_set_mt_mask();
2226 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
2227 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
2228 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
2229 msm_bus_8064_apps_fabric.dev.platform_data =
2230 &msm_bus_8064_apps_fabric_pdata;
2231 msm_bus_8064_sys_fabric.dev.platform_data =
2232 &msm_bus_8064_sys_fabric_pdata;
2233 msm_bus_8064_mm_fabric.dev.platform_data =
2234 &msm_bus_8064_mm_fabric_pdata;
2235 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
2236 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
2237}
2238
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002239/* PCIe gpios */
2240static struct msm_pcie_gpio_info_t msm_pcie_gpio_info[MSM_PCIE_MAX_GPIO] = {
2241 {"rst_n", PM8921_MPP_PM_TO_SYS(PCIE_RST_N_PMIC_MPP), 0},
2242 {"pwr_en", PM8921_GPIO_PM_TO_SYS(PCIE_PWR_EN_PMIC_GPIO), 1},
2243};
2244
2245static struct msm_pcie_platform msm_pcie_platform_data = {
2246 .gpio = msm_pcie_gpio_info,
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -06002247 .axi_addr = PCIE_AXI_BAR_PHYS,
2248 .axi_size = PCIE_AXI_BAR_SIZE,
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -06002249 .wake_n = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PCIE_WAKE_N_PMIC_GPIO),
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002250};
2251
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002252static int __init mpq8064_pcie_enabled(void)
2253{
2254 return !((readl_relaxed(QFPROM_RAW_FEAT_CONFIG_ROW0_MSB) & BIT(21)) ||
2255 (readl_relaxed(QFPROM_RAW_OEM_CONFIG_ROW0_LSB) & BIT(4)));
2256}
2257
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002258static void __init mpq8064_pcie_init(void)
2259{
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002260 if (mpq8064_pcie_enabled()) {
2261 msm_device_pcie.dev.platform_data = &msm_pcie_platform_data;
2262 platform_device_register(&msm_device_pcie);
2263 }
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002264}
2265
David Collinsf0d00732012-01-25 15:46:50 -08002266static struct platform_device apq8064_device_ext_5v_vreg __devinitdata = {
2267 .name = GPIO_REGULATOR_DEV_NAME,
2268 .id = PM8921_MPP_PM_TO_SYS(7),
2269 .dev = {
2270 .platform_data
2271 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2272 },
2273};
2274
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002275static struct platform_device apq8064_device_ext_mpp8_vreg __devinitdata = {
2276 .name = GPIO_REGULATOR_DEV_NAME,
2277 .id = PM8921_MPP_PM_TO_SYS(8),
2278 .dev = {
2279 .platform_data
2280 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_MPP8],
2281 },
2282};
2283
David Collinsf0d00732012-01-25 15:46:50 -08002284static struct platform_device apq8064_device_ext_3p3v_vreg __devinitdata = {
2285 .name = GPIO_REGULATOR_DEV_NAME,
2286 .id = APQ8064_EXT_3P3V_REG_EN_GPIO,
2287 .dev = {
2288 .platform_data =
2289 &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2290 },
2291};
2292
David Collins390fc332012-02-07 14:38:16 -08002293static struct platform_device apq8064_device_ext_ts_sw_vreg __devinitdata = {
2294 .name = GPIO_REGULATOR_DEV_NAME,
2295 .id = PM8921_GPIO_PM_TO_SYS(23),
2296 .dev = {
2297 .platform_data
2298 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_TS_SW],
2299 },
2300};
2301
David Collins2782b5c2012-02-06 10:02:42 -08002302static struct platform_device apq8064_device_rpm_regulator __devinitdata = {
2303 .name = "rpm-regulator",
David Collins36199252012-08-21 15:43:02 -07002304 .id = 0,
David Collins2782b5c2012-02-06 10:02:42 -08002305 .dev = {
2306 .platform_data = &apq8064_rpm_regulator_pdata,
2307 },
2308};
2309
David Collins36199252012-08-21 15:43:02 -07002310static struct platform_device
2311apq8064_pm8921_device_rpm_regulator __devinitdata = {
2312 .name = "rpm-regulator",
2313 .id = 1,
2314 .dev = {
2315 .platform_data = &apq8064_rpm_regulator_pm8921_pdata,
2316 },
2317};
2318
Ravi Kumar V05931a22012-04-04 17:09:37 +05302319static struct gpio_ir_recv_platform_data gpio_ir_recv_pdata = {
2320 .gpio_nr = 88,
2321 .active_low = 1,
2322};
2323
2324static struct platform_device gpio_ir_recv_pdev = {
2325 .name = "gpio-rc-recv",
2326 .dev = {
2327 .platform_data = &gpio_ir_recv_pdata,
2328 },
2329};
2330
Terence Hampson36b70722012-05-10 13:18:16 -04002331static struct platform_device *common_not_mpq_devices[] __initdata = {
David Keitel3c40fc52012-02-09 17:53:52 -08002332 &apq8064_device_qup_i2c_gsbi1,
Jing Lin04601f92012-02-05 15:36:07 -08002333 &apq8064_device_qup_i2c_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002334 &apq8064_device_qup_i2c_gsbi4,
Terence Hampson36b70722012-05-10 13:18:16 -04002335};
2336
David Collins36199252012-08-21 15:43:02 -07002337static struct platform_device *early_common_devices[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -07002338 &apq8064_device_acpuclk,
Terence Hampson36b70722012-05-10 13:18:16 -04002339 &apq8064_device_dmov,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002340 &apq8064_device_qup_spi_gsbi5,
David Collins36199252012-08-21 15:43:02 -07002341};
2342
2343static struct platform_device *pm8921_common_devices[] __initdata = {
David Collinsf0d00732012-01-25 15:46:50 -08002344 &apq8064_device_ext_5v_vreg,
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002345 &apq8064_device_ext_mpp8_vreg,
David Collinsf0d00732012-01-25 15:46:50 -08002346 &apq8064_device_ext_3p3v_vreg,
Jay Chokshi9c25f072011-09-23 18:19:15 -07002347 &apq8064_device_ssbi_pmic1,
2348 &apq8064_device_ssbi_pmic2,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002349 &apq8064_device_ext_ts_sw_vreg,
David Collins36199252012-08-21 15:43:02 -07002350};
2351
2352static struct platform_device *pm8917_common_devices[] __initdata = {
2353 &apq8064_device_ext_mpp8_vreg,
2354 &apq8064_device_ext_3p3v_vreg,
2355 &apq8064_device_ssbi_pmic1,
2356 &apq8064_device_ssbi_pmic2,
2357 &apq8064_device_ext_ts_sw_vreg,
2358};
2359
2360static struct platform_device *common_devices[] __initdata = {
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06002361 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -07002362 &apq8064_device_otg,
2363 &apq8064_device_gadget_peripheral,
Hemant Kumard86c4882012-01-24 19:39:37 -08002364 &apq8064_device_hsusb_host,
Hemant Kumar4933b072011-10-17 23:43:11 -07002365 &android_usb_device,
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08002366 &msm_device_wcnss_wlan,
Ankit Vermab7c26e62012-02-28 15:04:15 -08002367 &msm_device_iris_fm,
Larry Bassel67b921d2012-04-06 10:23:27 -07002368 &apq8064_fmem_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002369#ifdef CONFIG_ANDROID_PMEM
2370#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002371 &apq8064_android_pmem_device,
2372 &apq8064_android_pmem_adsp_device,
2373 &apq8064_android_pmem_audio_device,
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002374#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2375#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -08002376#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002377 &apq8064_ion_dev,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002378#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002379 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002380 &msm8064_device_saw_regulator_core0,
2381 &msm8064_device_saw_regulator_core1,
2382 &msm8064_device_saw_regulator_core2,
2383 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002384#if defined(CONFIG_QSEECOM)
2385 &qseecom_device,
2386#endif
2387
Joel Nider6b9a7bc2012-06-26 11:19:19 +03002388 &msm_8064_device_tsif[0],
2389 &msm_8064_device_tsif[1],
2390
Ramesh Masavarapu28311912011-10-27 11:04:12 -07002391#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2392 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2393 &qcrypto_device,
2394#endif
2395
2396#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2397 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2398 &qcedev_device,
2399#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07002400
2401#ifdef CONFIG_HW_RANDOM_MSM
2402 &apq8064_device_rng,
2403#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002404 &apq_pcm,
2405 &apq_pcm_routing,
2406 &apq_cpudai0,
2407 &apq_cpudai1,
Santosh Mardieff9a742012-04-09 23:23:39 +05302408 &mpq_cpudai_sec_i2s_rx,
Kuirong Wangf23f8c52012-03-31 12:34:51 -07002409 &mpq_cpudai_mi2s_tx,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002410 &apq_cpudai_hdmi_rx,
2411 &apq_cpudai_bt_rx,
2412 &apq_cpudai_bt_tx,
2413 &apq_cpudai_fm_rx,
2414 &apq_cpudai_fm_tx,
2415 &apq_cpu_fe,
2416 &apq_stub_codec,
2417 &apq_voice,
2418 &apq_voip,
2419 &apq_lpa_pcm,
Krishnankutty Kolathappilly4374e332012-03-18 22:27:30 -07002420 &apq_compr_dsp,
2421 &apq_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002422 &apq_lowlatency_pcm,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002423 &apq_pcm_hostless,
2424 &apq_cpudai_afe_01_rx,
2425 &apq_cpudai_afe_01_tx,
2426 &apq_cpudai_afe_02_rx,
2427 &apq_cpudai_afe_02_tx,
2428 &apq_pcm_afe,
2429 &apq_cpudai_auxpcm_rx,
2430 &apq_cpudai_auxpcm_tx,
Neema Shetty8427c262012-02-16 11:23:43 -08002431 &apq_cpudai_stub,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002432 &apq_cpudai_slimbus_1_rx,
2433 &apq_cpudai_slimbus_1_tx,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002434 &apq_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002435 &apq_cpudai_slimbus_2_tx,
Neema Shettyc9d86c32012-05-09 12:01:39 -07002436 &apq_cpudai_slimbus_3_rx,
Helen Zeng38c3c962012-05-17 14:56:20 -07002437 &apq_cpudai_slimbus_3_tx,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002438 &apq8064_rpm_device,
2439 &apq8064_rpm_log_device,
2440 &apq8064_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302441 &apq8064_rpm_master_stat_device,
Ramesh Masavarapuf31ff242012-05-10 18:55:21 -07002442 &apq_device_tz_log,
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002443 &msm_bus_8064_apps_fabric,
2444 &msm_bus_8064_sys_fabric,
2445 &msm_bus_8064_mm_fabric,
2446 &msm_bus_8064_sys_fpb,
2447 &msm_bus_8064_cpss_fpb,
Mohan Kumar Gubbihalli Lachma Naik7f72edd2012-02-06 17:26:47 -08002448 &apq8064_msm_device_vidc,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002449 &msm_pil_dsps,
Matt Wagantallb94b9a52012-02-02 21:59:54 -08002450 &msm_8960_q6_lpass,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002451 &msm_pil_vidc,
Matt Wagantall292aace2012-01-26 19:12:34 -08002452 &msm_gss,
Laura Abbottb93525f2012-04-12 09:57:19 -07002453 &apq8064_rtb_device,
Steve Mucklea9aac292012-11-02 15:41:00 -07002454 &apq8064_dcvs_device,
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07002455 &apq8064_msm_gov_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002456 &apq8064_device_cache_erp,
Stepan Moskovchenko0f3de112012-06-08 18:11:46 -07002457 &msm8960_device_ebi1_ch0_erp,
2458 &msm8960_device_ebi1_ch1_erp,
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002459 &epm_adc_device,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002460 &coresight_tpiu_device,
2461 &coresight_etb_device,
2462 &apq8064_coresight_funnel_device,
2463 &coresight_etm0_device,
2464 &coresight_etm1_device,
2465 &coresight_etm2_device,
2466 &coresight_etm3_device,
Helen Zeng8f925502012-03-05 16:50:17 -08002467 &apq_cpudai_slim_4_rx,
2468 &apq_cpudai_slim_4_tx,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002469#ifdef CONFIG_MSM_GEMINI
Jignesh Mehta921649d2012-04-19 06:57:23 -07002470 &msm8960_gemini_device,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002471#endif
Laura Abbott0577d7b2012-04-17 11:14:30 -07002472 &apq8064_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002473 &msm_tsens_device,
Laura Abbott93a4a352012-05-25 09:26:35 -07002474 &apq8064_cache_dump_device,
Joel Nider0e4a16d2012-08-05 14:20:11 +03002475 &msm_8064_device_tspp,
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07002476#ifdef CONFIG_BATTERY_BCL
2477 &battery_bcl_device,
2478#endif
2479 &apq8064_msm_mpd_device,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002480};
2481
Joel King82b7e3f2012-01-05 10:03:27 -08002482static struct platform_device *cdp_devices[] __initdata = {
2483 &apq8064_device_uart_gsbi1,
Jin Hong4bbbfba2012-02-02 21:48:07 -08002484 &apq8064_device_uart_gsbi7,
Joel King82b7e3f2012-01-05 10:03:27 -08002485 &msm_device_sps_apq8064,
Aravind Venkateswaran4ca27532012-02-16 14:27:05 -08002486#ifdef CONFIG_MSM_ROTATOR
2487 &msm_rotator_device,
2488#endif
Anji Jonnalae84292b2012-09-21 13:34:44 +05302489 &msm8064_pc_cntr,
Joel King82b7e3f2012-01-05 10:03:27 -08002490};
2491
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002492static struct platform_device
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002493mpq8064_device_ext_1p2_buck_vreg __devinitdata = {
2494 .name = GPIO_REGULATOR_DEV_NAME,
2495 .id = SX150X_GPIO(4, 2),
2496 .dev = {
2497 .platform_data =
2498 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P2V],
2499 },
2500};
2501
2502static struct platform_device
2503mpq8064_device_ext_1p8_buck_vreg __devinitdata = {
2504 .name = GPIO_REGULATOR_DEV_NAME,
2505 .id = SX150X_GPIO(4, 4),
2506 .dev = {
2507 .platform_data =
2508 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P8V],
2509 },
2510};
2511
2512static struct platform_device
2513mpq8064_device_ext_2p2_buck_vreg __devinitdata = {
2514 .name = GPIO_REGULATOR_DEV_NAME,
2515 .id = SX150X_GPIO(4, 14),
2516 .dev = {
2517 .platform_data =
2518 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_2P2V],
2519 },
2520};
2521
2522static struct platform_device
2523mpq8064_device_ext_5v_buck_vreg __devinitdata = {
2524 .name = GPIO_REGULATOR_DEV_NAME,
2525 .id = SX150X_GPIO(4, 3),
2526 .dev = {
2527 .platform_data =
2528 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_5V],
2529 },
2530};
2531
2532static struct platform_device
2533mpq8064_device_ext_3p3v_ldo_vreg __devinitdata = {
2534 .name = GPIO_REGULATOR_DEV_NAME,
2535 .id = SX150X_GPIO(4, 15),
2536 .dev = {
2537 .platform_data =
2538 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_3P3V],
2539 },
2540};
2541
Ravi Kumar V1c903012012-05-15 16:11:35 +05302542static struct platform_device rc_input_loopback_pdev = {
2543 .name = "rc-user-input",
2544 .id = -1,
2545};
2546
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302547static int rf4ce_gpio_init(void)
2548{
Ravi Kumar V0143c582012-08-14 17:18:11 +05302549 if (!machine_is_mpq8064_cdp() &&
2550 !machine_is_mpq8064_hrd() &&
2551 !machine_is_mpq8064_dtv())
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302552 return -EINVAL;
2553
2554 /* CC2533 SRDY Input */
2555 if (!gpio_request(SX150X_GPIO(4, 6), "rf4ce_srdy")) {
2556 gpio_direction_input(SX150X_GPIO(4, 6));
2557 gpio_export(SX150X_GPIO(4, 6), true);
2558 }
2559
2560 /* CC2533 MRDY Output */
2561 if (!gpio_request(SX150X_GPIO(4, 5), "rf4ce_mrdy")) {
2562 gpio_direction_output(SX150X_GPIO(4, 5), 1);
2563 gpio_export(SX150X_GPIO(4, 5), true);
2564 }
2565
2566 /* CC2533 Reset Output */
2567 if (!gpio_request(SX150X_GPIO(4, 7), "rf4ce_reset")) {
2568 gpio_direction_output(SX150X_GPIO(4, 7), 0);
2569 gpio_export(SX150X_GPIO(4, 7), true);
2570 }
2571
2572 return 0;
2573}
2574late_initcall(rf4ce_gpio_init);
2575
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002576static struct platform_device *mpq_devices[] __initdata = {
2577 &msm_device_sps_apq8064,
2578 &mpq8064_device_qup_i2c_gsbi5,
2579#ifdef CONFIG_MSM_ROTATOR
2580 &msm_rotator_device,
2581#endif
Ravi Kumar V05931a22012-04-04 17:09:37 +05302582 &gpio_ir_recv_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002583 &mpq8064_device_ext_1p2_buck_vreg,
2584 &mpq8064_device_ext_1p8_buck_vreg,
2585 &mpq8064_device_ext_2p2_buck_vreg,
2586 &mpq8064_device_ext_5v_buck_vreg,
2587 &mpq8064_device_ext_3p3v_ldo_vreg,
Terence Hampson2e1705f2012-04-11 19:55:29 -04002588#ifdef CONFIG_MSM_VCAP
2589 &msm8064_device_vcap,
2590#endif
Ravi Kumar V1c903012012-05-15 16:11:35 +05302591 &rc_input_loopback_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002592};
2593
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002594static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002595 .max_clock_speed = 1100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002596};
2597
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002598#define KS8851_IRQ_GPIO 43
2599
2600static struct spi_board_info spi_board_info[] __initdata = {
2601 {
2602 .modalias = "ks8851",
2603 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2604 .max_speed_hz = 19200000,
2605 .bus_num = 0,
2606 .chip_select = 2,
2607 .mode = SPI_MODE_0,
2608 },
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002609 {
2610 .modalias = "epm_adc",
2611 .max_speed_hz = 1100000,
2612 .bus_num = 0,
2613 .chip_select = 3,
2614 .mode = SPI_MODE_0,
2615 },
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002616};
2617
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002618static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002619 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08002620 .bus_num = 1,
2621 .slim_slave = &apq8064_slim_tabla,
2622 },
2623 {
2624 .bus_num = 1,
2625 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002626 },
2627 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002628};
2629
David Keitel3c40fc52012-02-09 17:53:52 -08002630static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi1_pdata = {
2631 .clk_freq = 100000,
2632 .src_clk_rate = 24000000,
2633};
2634
Jing Lin04601f92012-02-05 15:36:07 -08002635static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi3_pdata = {
Anirudh Ghayalc2163472012-04-10 14:58:14 +05302636 .clk_freq = 384000,
Jing Lin04601f92012-02-05 15:36:07 -08002637 .src_clk_rate = 24000000,
2638};
2639
Kenneth Heitke748593a2011-07-15 15:45:11 -06002640static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
2641 .clk_freq = 100000,
2642 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002643};
2644
Joel King8f839b92012-04-01 14:37:46 -07002645static struct msm_i2c_platform_data mpq8064_i2c_qup_gsbi5_pdata = {
2646 .clk_freq = 100000,
2647 .src_clk_rate = 24000000,
2648};
2649
David Keitel3c40fc52012-02-09 17:53:52 -08002650#define GSBI_DUAL_MODE_CODE 0x60
2651#define MSM_GSBI1_PHYS 0x12440000
Kenneth Heitke748593a2011-07-15 15:45:11 -06002652static void __init apq8064_i2c_init(void)
2653{
David Keitel3c40fc52012-02-09 17:53:52 -08002654 void __iomem *gsbi_mem;
2655
2656 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2657 &apq8064_i2c_qup_gsbi1_pdata;
2658 gsbi_mem = ioremap_nocache(MSM_GSBI1_PHYS, 4);
2659 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
2660 /* Ensure protocol code is written before proceeding */
2661 wmb();
2662 iounmap(gsbi_mem);
2663 apq8064_i2c_qup_gsbi1_pdata.use_gsbi_shared_mode = 1;
Jing Lin04601f92012-02-05 15:36:07 -08002664 apq8064_device_qup_i2c_gsbi3.dev.platform_data =
2665 &apq8064_i2c_qup_gsbi3_pdata;
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002666 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2667 &apq8064_i2c_qup_gsbi1_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002668 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
2669 &apq8064_i2c_qup_gsbi4_pdata;
Joel King8f839b92012-04-01 14:37:46 -07002670 mpq8064_device_qup_i2c_gsbi5.dev.platform_data =
2671 &mpq8064_i2c_qup_gsbi5_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002672}
2673
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002674#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002675static int ethernet_init(void)
2676{
2677 int ret;
2678 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
2679 if (ret) {
2680 pr_err("ks8851 gpio_request failed: %d\n", ret);
2681 goto fail;
2682 }
2683
2684 return 0;
2685fail:
2686 return ret;
2687}
2688#else
2689static int ethernet_init(void)
2690{
2691 return 0;
2692}
2693#endif
2694
David Collins6f7c3472012-08-22 13:18:06 -07002695#define GPIO_KEY_HOME PM8921_GPIO_PM_TO_SYS(27)
2696#define GPIO_KEY_VOLUME_UP PM8921_GPIO_PM_TO_SYS(35)
2697#define GPIO_KEY_VOLUME_DOWN_PM8921 PM8921_GPIO_PM_TO_SYS(38)
2698#define GPIO_KEY_VOLUME_DOWN_PM8917 PM8921_GPIO_PM_TO_SYS(30)
2699#define GPIO_KEY_CAM_FOCUS PM8921_GPIO_PM_TO_SYS(3)
2700#define GPIO_KEY_CAM_SNAP PM8921_GPIO_PM_TO_SYS(4)
2701#define GPIO_KEY_ROTATION_PM8921 PM8921_GPIO_PM_TO_SYS(42)
2702#define GPIO_KEY_ROTATION_PM8917 PM8921_GPIO_PM_TO_SYS(8)
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302703
David Collins6f7c3472012-08-22 13:18:06 -07002704static struct gpio_keys_button cdp_keys_pm8921[] = {
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302705 {
2706 .code = KEY_HOME,
2707 .gpio = GPIO_KEY_HOME,
2708 .desc = "home_key",
2709 .active_low = 1,
2710 .type = EV_KEY,
2711 .wakeup = 1,
2712 .debounce_interval = 15,
2713 },
2714 {
2715 .code = KEY_VOLUMEUP,
2716 .gpio = GPIO_KEY_VOLUME_UP,
2717 .desc = "volume_up_key",
2718 .active_low = 1,
2719 .type = EV_KEY,
2720 .wakeup = 1,
2721 .debounce_interval = 15,
2722 },
2723 {
2724 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002725 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302726 .desc = "volume_down_key",
2727 .active_low = 1,
2728 .type = EV_KEY,
2729 .wakeup = 1,
2730 .debounce_interval = 15,
2731 },
2732 {
2733 .code = SW_ROTATE_LOCK,
David Collins6f7c3472012-08-22 13:18:06 -07002734 .gpio = GPIO_KEY_ROTATION_PM8921,
2735 .desc = "rotate_key",
2736 .active_low = 1,
2737 .type = EV_SW,
2738 .debounce_interval = 15,
2739 },
2740};
2741
2742static struct gpio_keys_button cdp_keys_pm8917[] = {
2743 {
2744 .code = KEY_HOME,
2745 .gpio = GPIO_KEY_HOME,
2746 .desc = "home_key",
2747 .active_low = 1,
2748 .type = EV_KEY,
2749 .wakeup = 1,
2750 .debounce_interval = 15,
2751 },
2752 {
2753 .code = KEY_VOLUMEUP,
2754 .gpio = GPIO_KEY_VOLUME_UP,
2755 .desc = "volume_up_key",
2756 .active_low = 1,
2757 .type = EV_KEY,
2758 .wakeup = 1,
2759 .debounce_interval = 15,
2760 },
2761 {
2762 .code = KEY_VOLUMEDOWN,
2763 .gpio = GPIO_KEY_VOLUME_DOWN_PM8917,
2764 .desc = "volume_down_key",
2765 .active_low = 1,
2766 .type = EV_KEY,
2767 .wakeup = 1,
2768 .debounce_interval = 15,
2769 },
2770 {
2771 .code = SW_ROTATE_LOCK,
2772 .gpio = GPIO_KEY_ROTATION_PM8917,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302773 .desc = "rotate_key",
2774 .active_low = 1,
2775 .type = EV_SW,
2776 .debounce_interval = 15,
2777 },
2778};
2779
2780static struct gpio_keys_platform_data cdp_keys_data = {
David Collins6f7c3472012-08-22 13:18:06 -07002781 .buttons = cdp_keys_pm8921,
2782 .nbuttons = ARRAY_SIZE(cdp_keys_pm8921),
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302783};
2784
2785static struct platform_device cdp_kp_pdev = {
2786 .name = "gpio-keys",
2787 .id = -1,
2788 .dev = {
2789 .platform_data = &cdp_keys_data,
2790 },
2791};
2792
2793static struct gpio_keys_button mtp_keys[] = {
2794 {
2795 .code = KEY_CAMERA_FOCUS,
2796 .gpio = GPIO_KEY_CAM_FOCUS,
2797 .desc = "cam_focus_key",
2798 .active_low = 1,
2799 .type = EV_KEY,
2800 .wakeup = 1,
2801 .debounce_interval = 15,
2802 },
2803 {
2804 .code = KEY_VOLUMEUP,
2805 .gpio = GPIO_KEY_VOLUME_UP,
2806 .desc = "volume_up_key",
2807 .active_low = 1,
2808 .type = EV_KEY,
2809 .wakeup = 1,
2810 .debounce_interval = 15,
2811 },
2812 {
2813 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002814 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302815 .desc = "volume_down_key",
2816 .active_low = 1,
2817 .type = EV_KEY,
2818 .wakeup = 1,
2819 .debounce_interval = 15,
2820 },
2821 {
2822 .code = KEY_CAMERA_SNAPSHOT,
2823 .gpio = GPIO_KEY_CAM_SNAP,
2824 .desc = "cam_snap_key",
2825 .active_low = 1,
2826 .type = EV_KEY,
2827 .debounce_interval = 15,
2828 },
2829};
2830
2831static struct gpio_keys_platform_data mtp_keys_data = {
2832 .buttons = mtp_keys,
2833 .nbuttons = ARRAY_SIZE(mtp_keys),
2834};
2835
2836static struct platform_device mtp_kp_pdev = {
2837 .name = "gpio-keys",
2838 .id = -1,
2839 .dev = {
2840 .platform_data = &mtp_keys_data,
2841 },
2842};
2843
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302844static struct gpio_keys_button mpq_keys[] = {
2845 {
2846 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002847 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302848 .desc = "volume_down_key",
2849 .active_low = 1,
2850 .type = EV_KEY,
2851 .wakeup = 1,
2852 .debounce_interval = 15,
2853 },
2854 {
2855 .code = KEY_VOLUMEUP,
2856 .gpio = GPIO_KEY_VOLUME_UP,
2857 .desc = "volume_up_key",
2858 .active_low = 1,
2859 .type = EV_KEY,
2860 .wakeup = 1,
2861 .debounce_interval = 15,
2862 },
2863};
2864
2865static struct gpio_keys_platform_data mpq_keys_data = {
2866 .buttons = mpq_keys,
2867 .nbuttons = ARRAY_SIZE(mpq_keys),
2868};
2869
2870static struct platform_device mpq_gpio_keys_pdev = {
2871 .name = "gpio-keys",
2872 .id = -1,
2873 .dev = {
2874 .platform_data = &mpq_keys_data,
2875 },
2876};
2877
2878#define MPQ_KP_ROW_BASE SX150X_EXP2_GPIO_BASE
2879#define MPQ_KP_COL_BASE (SX150X_EXP2_GPIO_BASE + 4)
2880
2881static unsigned int mpq_row_gpios[] = {MPQ_KP_ROW_BASE, MPQ_KP_ROW_BASE + 1,
2882 MPQ_KP_ROW_BASE + 2, MPQ_KP_ROW_BASE + 3};
2883static unsigned int mpq_col_gpios[] = {MPQ_KP_COL_BASE, MPQ_KP_COL_BASE + 1,
2884 MPQ_KP_COL_BASE + 2};
2885
2886static const unsigned int mpq_keymap[] = {
2887 KEY(0, 0, KEY_UP),
2888 KEY(0, 1, KEY_ENTER),
2889 KEY(0, 2, KEY_3),
2890
2891 KEY(1, 0, KEY_DOWN),
2892 KEY(1, 1, KEY_EXIT),
2893 KEY(1, 2, KEY_4),
2894
2895 KEY(2, 0, KEY_LEFT),
2896 KEY(2, 1, KEY_1),
2897 KEY(2, 2, KEY_5),
2898
2899 KEY(3, 0, KEY_RIGHT),
2900 KEY(3, 1, KEY_2),
2901 KEY(3, 2, KEY_6),
2902};
2903
2904static struct matrix_keymap_data mpq_keymap_data = {
2905 .keymap_size = ARRAY_SIZE(mpq_keymap),
2906 .keymap = mpq_keymap,
2907};
2908
2909static struct matrix_keypad_platform_data mpq_keypad_data = {
2910 .keymap_data = &mpq_keymap_data,
2911 .row_gpios = mpq_row_gpios,
2912 .col_gpios = mpq_col_gpios,
2913 .num_row_gpios = ARRAY_SIZE(mpq_row_gpios),
2914 .num_col_gpios = ARRAY_SIZE(mpq_col_gpios),
2915 .col_scan_delay_us = 32000,
2916 .debounce_ms = 20,
2917 .wakeup = 1,
2918 .active_low = 1,
2919 .no_autorepeat = 1,
2920};
2921
2922static struct platform_device mpq_keypad_device = {
2923 .name = "matrix-keypad",
2924 .id = -1,
2925 .dev = {
2926 .platform_data = &mpq_keypad_data,
2927 },
2928};
2929
Jin Hongd3024e62012-02-09 16:13:32 -08002930/* Sensors DSPS platform data */
2931#define DSPS_PIL_GENERIC_NAME "dsps"
2932static void __init apq8064_init_dsps(void)
2933{
2934 struct msm_dsps_platform_data *pdata =
2935 msm_dsps_device_8064.dev.platform_data;
2936 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2937 pdata->gpios = NULL;
2938 pdata->gpios_num = 0;
2939
2940 platform_device_register(&msm_dsps_device_8064);
2941}
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302942
Jing Lin417fa452012-02-05 14:31:06 -08002943#define I2C_SURF 1
2944#define I2C_FFA (1 << 1)
2945#define I2C_RUMI (1 << 2)
2946#define I2C_SIM (1 << 3)
2947#define I2C_LIQUID (1 << 4)
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002948#define I2C_MPQ_CDP BIT(5)
2949#define I2C_MPQ_HRD BIT(6)
2950#define I2C_MPQ_DTV BIT(7)
Jing Lin417fa452012-02-05 14:31:06 -08002951
2952struct i2c_registry {
2953 u8 machs;
2954 int bus;
2955 struct i2c_board_info *info;
2956 int len;
2957};
2958
2959static struct i2c_registry apq8064_i2c_devices[] __initdata = {
Jing Lin21ed4de2012-02-05 15:53:28 -08002960 {
David Keitel2f613d92012-02-15 11:29:16 -08002961 I2C_LIQUID,
2962 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2963 smb349_charger_i2c_info,
2964 ARRAY_SIZE(smb349_charger_i2c_info)
2965 },
2966 {
Jing Lin21ed4de2012-02-05 15:53:28 -08002967 I2C_SURF | I2C_LIQUID,
2968 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2969 mxt_device_info,
2970 ARRAY_SIZE(mxt_device_info),
2971 },
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08002972 {
2973 I2C_FFA,
2974 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2975 cyttsp_info,
2976 ARRAY_SIZE(cyttsp_info),
2977 },
Amy Maloche70090f992012-02-16 16:35:26 -08002978 {
2979 I2C_FFA | I2C_LIQUID,
2980 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2981 isa1200_board_info,
2982 ARRAY_SIZE(isa1200_board_info),
2983 },
Santosh Mardieff9a742012-04-09 23:23:39 +05302984 {
2985 I2C_MPQ_CDP,
2986 APQ_8064_GSBI5_QUP_I2C_BUS_ID,
2987 cs8427_device_info,
2988 ARRAY_SIZE(cs8427_device_info),
2989 },
Jing Lin417fa452012-02-05 14:31:06 -08002990};
2991
Jay Chokshi607f61b2012-04-25 18:21:21 -07002992#define SX150X_EXP1_INT_N PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9)
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302993#define SX150X_EXP2_INT_N MSM_GPIO_TO_INT(81)
Jay Chokshi607f61b2012-04-25 18:21:21 -07002994
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002995struct sx150x_platform_data mpq8064_sx150x_pdata[] = {
2996 [SX150X_EXP1] = {
2997 .gpio_base = SX150X_EXP1_GPIO_BASE,
2998 .oscio_is_gpo = false,
2999 .io_pullup_ena = 0x0,
3000 .io_pulldn_ena = 0x0,
3001 .io_open_drain_ena = 0x0,
3002 .io_polarity = 0,
Jay Chokshi607f61b2012-04-25 18:21:21 -07003003 .irq_summary = SX150X_EXP1_INT_N,
3004 .irq_base = SX150X_EXP1_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003005 },
3006 [SX150X_EXP2] = {
3007 .gpio_base = SX150X_EXP2_GPIO_BASE,
3008 .oscio_is_gpo = false,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05303009 .io_pullup_ena = 0x0f,
3010 .io_pulldn_ena = 0x70,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003011 .io_open_drain_ena = 0x0,
3012 .io_polarity = 0,
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05303013 .irq_summary = SX150X_EXP2_INT_N,
3014 .irq_base = SX150X_EXP2_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003015 },
3016 [SX150X_EXP3] = {
3017 .gpio_base = SX150X_EXP3_GPIO_BASE,
3018 .oscio_is_gpo = false,
3019 .io_pullup_ena = 0x0,
3020 .io_pulldn_ena = 0x0,
3021 .io_open_drain_ena = 0x0,
3022 .io_polarity = 0,
3023 .irq_summary = -1,
3024 },
3025 [SX150X_EXP4] = {
3026 .gpio_base = SX150X_EXP4_GPIO_BASE,
3027 .oscio_is_gpo = false,
3028 .io_pullup_ena = 0x0,
3029 .io_pulldn_ena = 0x0,
3030 .io_open_drain_ena = 0x0,
3031 .io_polarity = 0,
3032 .irq_summary = -1,
3033 },
3034};
3035
3036static struct i2c_board_info sx150x_gpio_exp_info[] = {
3037 {
3038 I2C_BOARD_INFO("sx1509q", 0x70),
3039 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP1],
3040 },
3041 {
3042 I2C_BOARD_INFO("sx1508q", 0x23),
3043 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP2],
3044 },
3045 {
3046 I2C_BOARD_INFO("sx1508q", 0x22),
3047 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP3],
3048 },
3049 {
3050 I2C_BOARD_INFO("sx1509q", 0x3E),
3051 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP4],
3052 },
3053};
3054
3055#define MPQ8064_I2C_GSBI5_BUS_ID 5
3056
3057static struct i2c_registry mpq8064_i2c_devices[] __initdata = {
3058 {
3059 I2C_MPQ_CDP,
3060 MPQ8064_I2C_GSBI5_BUS_ID,
3061 sx150x_gpio_exp_info,
3062 ARRAY_SIZE(sx150x_gpio_exp_info),
3063 },
3064};
3065
Jing Lin417fa452012-02-05 14:31:06 -08003066static void __init register_i2c_devices(void)
3067{
3068 u8 mach_mask = 0;
3069 int i;
3070
Kevin Chand07220e2012-02-13 15:52:22 -08003071#ifdef CONFIG_MSM_CAMERA
3072 struct i2c_registry apq8064_camera_i2c_devices = {
3073 I2C_SURF | I2C_FFA | I2C_LIQUID | I2C_RUMI,
3074 APQ_8064_GSBI4_QUP_I2C_BUS_ID,
3075 apq8064_camera_board_info.board_info,
3076 apq8064_camera_board_info.num_i2c_board_info,
3077 };
3078#endif
Jing Lin417fa452012-02-05 14:31:06 -08003079 /* Build the matching 'supported_machs' bitmask */
3080 if (machine_is_apq8064_cdp())
3081 mach_mask = I2C_SURF;
3082 else if (machine_is_apq8064_mtp())
3083 mach_mask = I2C_FFA;
3084 else if (machine_is_apq8064_liquid())
3085 mach_mask = I2C_LIQUID;
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003086 else if (PLATFORM_IS_MPQ8064())
3087 mach_mask = I2C_MPQ_CDP;
Jing Lin417fa452012-02-05 14:31:06 -08003088 else
3089 pr_err("unmatched machine ID in register_i2c_devices\n");
3090
3091 /* Run the array and install devices as appropriate */
3092 for (i = 0; i < ARRAY_SIZE(apq8064_i2c_devices); ++i) {
3093 if (apq8064_i2c_devices[i].machs & mach_mask)
3094 i2c_register_board_info(apq8064_i2c_devices[i].bus,
3095 apq8064_i2c_devices[i].info,
3096 apq8064_i2c_devices[i].len);
3097 }
Kevin Chand07220e2012-02-13 15:52:22 -08003098#ifdef CONFIG_MSM_CAMERA
3099 if (apq8064_camera_i2c_devices.machs & mach_mask)
3100 i2c_register_board_info(apq8064_camera_i2c_devices.bus,
3101 apq8064_camera_i2c_devices.info,
3102 apq8064_camera_i2c_devices.len);
3103#endif
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003104
3105 for (i = 0; i < ARRAY_SIZE(mpq8064_i2c_devices); ++i) {
3106 if (mpq8064_i2c_devices[i].machs & mach_mask)
3107 i2c_register_board_info(
3108 mpq8064_i2c_devices[i].bus,
3109 mpq8064_i2c_devices[i].info,
3110 mpq8064_i2c_devices[i].len);
3111 }
Jing Lin417fa452012-02-05 14:31:06 -08003112}
3113
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003114static void enable_avc_i2c_bus(void)
3115{
3116 int avc_i2c_en_mpp = PM8921_MPP_PM_TO_SYS(8);
3117 int rc;
3118
3119 rc = gpio_request(avc_i2c_en_mpp, "avc_i2c_en");
3120 if (rc)
3121 pr_err("request for avc_i2c_en mpp failed,"
3122 "rc=%d\n", rc);
3123 else
3124 gpio_set_value_cansleep(avc_i2c_en_mpp, 1);
3125}
3126
David Collins6f7c3472012-08-22 13:18:06 -07003127/* Modify platform data values to match requirements for PM8917. */
3128static void __init apq8064_pm8917_pdata_fixup(void)
3129{
3130 cdp_keys_data.buttons = cdp_keys_pm8917;
3131 cdp_keys_data.nbuttons = ARRAY_SIZE(cdp_keys_pm8917);
3132}
3133
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003134static void __init apq8064_common_init(void)
3135{
Ameya Thakure155ece2012-07-09 12:08:37 -07003136 u32 platform_version;
David Collins6f7c3472012-08-22 13:18:06 -07003137
3138 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3139 apq8064_pm8917_pdata_fixup();
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003140 platform_device_register(&msm_gpio_device);
Joel King8f839b92012-04-01 14:37:46 -07003141 msm_tsens_early_init(&apq_tsens_pdata);
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003142 msm_thermal_init(&msm_thermal_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003143 if (socinfo_init() < 0)
3144 pr_err("socinfo_init() failed!\n");
Praveen Chidambaram78499012011-11-01 17:15:17 -06003145 BUG_ON(msm_rpm_init(&apq8064_rpm_data));
3146 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
David Collins2782b5c2012-02-06 10:02:42 -08003147 regulator_suppress_info_printing();
David Collins36199252012-08-21 15:43:02 -07003148 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3149 configure_apq8064_pm8917_power_grid();
David Collins2782b5c2012-02-06 10:02:42 -08003150 platform_device_register(&apq8064_device_rpm_regulator);
David Collins36199252012-08-21 15:43:02 -07003151 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3152 platform_device_register(&apq8064_pm8921_device_rpm_regulator);
Stephen Boyd4d0d2582012-02-10 14:49:40 -08003153 if (msm_xo_init())
3154 pr_err("Failed to initialize XO votes\n");
Matt Wagantallc51e5602012-02-27 17:25:25 -08003155 msm_clock_init(&apq8064_clock_init_data);
Stepan Moskovchenko2327a952011-12-14 16:31:28 -08003156 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -06003157 apq8064_i2c_init();
Jing Lin417fa452012-02-05 14:31:06 -08003158 register_i2c_devices();
Kenneth Heitke36920d32011-07-20 16:44:30 -06003159
Harini Jayaramanc4c58692011-07-19 14:50:10 -06003160 apq8064_device_qup_spi_gsbi5.dev.platform_data =
3161 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -08003162 apq8064_init_pmic();
Hemant Kumar94e7da22012-02-03 16:52:29 -08003163 if (machine_is_apq8064_liquid())
3164 msm_otg_pdata.mhl_enable = true;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003165
Ofir Cohen94213a72012-05-03 14:26:32 +03003166 android_usb_pdata.swfi_latency =
3167 msm_rpmrs_levels[0].latency_us;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003168
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003169 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Manu Gautam91223e02011-11-08 15:27:22 +05303170 apq8064_ehci_host_init();
Gagan Mac8a7a5d32011-11-11 16:43:06 -07003171 apq8064_init_buses();
David Collins36199252012-08-21 15:43:02 -07003172
3173 platform_add_devices(early_common_devices,
3174 ARRAY_SIZE(early_common_devices));
3175 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3176 platform_add_devices(pm8921_common_devices,
3177 ARRAY_SIZE(pm8921_common_devices));
3178 else
3179 platform_add_devices(pm8917_common_devices,
3180 ARRAY_SIZE(pm8917_common_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003181 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Terence Hampson36b70722012-05-10 13:18:16 -04003182 if (!(machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3183 machine_is_mpq8064_dtv()))
3184 platform_add_devices(common_not_mpq_devices,
3185 ARRAY_SIZE(common_not_mpq_devices));
Pavankumar Kondetife2d4d32012-09-07 15:33:09 +05303186 msm_hsic_pdata.swfi_latency =
3187 msm_rpmrs_levels[0].latency_us;
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003188 if (machine_is_apq8064_mtp()) {
Ajay Dudanic4e40db2012-08-20 14:44:40 -07003189 msm_hsic_pdata.log2_irq_thresh = 5,
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003190 apq8064_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
3191 device_initialize(&apq8064_device_hsic_host.dev);
3192 }
Jay Chokshie8741282012-01-25 15:22:55 -08003193 apq8064_pm8xxx_gpio_mpp_init();
Sahitya Tummala3586ed92011-08-03 09:13:23 +05303194 apq8064_init_mmc();
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003195
3196 if (machine_is_apq8064_mtp()) {
3197 mdm_8064_device.dev.platform_data = &mdm_platform_data;
Ameya Thakure155ece2012-07-09 12:08:37 -07003198 platform_version = socinfo_get_platform_version();
3199 if (SOCINFO_VERSION_MINOR(platform_version) == 1) {
3200 i2s_mdm_8064_device.dev.platform_data =
3201 &mdm_platform_data;
3202 platform_device_register(&i2s_mdm_8064_device);
3203 } else {
3204 mdm_8064_device.dev.platform_data = &mdm_platform_data;
3205 platform_device_register(&mdm_8064_device);
3206 }
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003207 }
3208 platform_device_register(&apq8064_slim_ctrl);
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06003209 slim_register_board_info(apq8064_slim_devices,
3210 ARRAY_SIZE(apq8064_slim_devices));
Taniya Dasbbf633d2012-07-31 16:07:47 +05303211 if (!PLATFORM_IS_MPQ8064()) {
Taniya Das30cae292012-07-31 15:56:12 +05303212 apq8064_init_dsps();
Taniya Dasbbf633d2012-07-31 16:07:47 +05303213 platform_device_register(&msm_8960_riva);
3214 }
Anji Jonnala0f297a92013-01-19 11:22:25 +05303215 if (cpu_is_apq8064ab())
3216 apq8064ab_update_krait_spm();
Praveen Chidambaram78499012011-11-01 17:15:17 -06003217 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3218 msm_spm_l2_init(msm_spm_l2_data);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003219 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08003220 apq8064_epm_adc_init();
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303221 msm_pm_set_tz_retention_flag(1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003222}
3223
Huaibin Yang4a084e32011-12-15 15:25:52 -08003224static void __init apq8064_allocate_memory_regions(void)
3225{
3226 apq8064_allocate_fb_region();
3227}
3228
Joel King82b7e3f2012-01-05 10:03:27 -08003229static void __init apq8064_cdp_init(void)
3230{
Hanumant Singh50440d42012-04-23 19:27:16 -07003231 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3232 pr_err("meminfo_init() failed!\n");
Amy Maloche609bb5e2012-08-03 09:41:42 -07003233 if (machine_is_apq8064_mtp() &&
3234 SOCINFO_VERSION_MINOR(socinfo_get_platform_version()) == 1)
3235 cyttsp_pdata.sleep_gpio = CYTTSP_TS_GPIO_SLEEP_ALT;
Joel King82b7e3f2012-01-05 10:03:27 -08003236 apq8064_common_init();
Joel King8f839b92012-04-01 14:37:46 -07003237 if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3238 machine_is_mpq8064_dtv()) {
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003239 enable_avc_i2c_bus();
Olav Hauganef95ae32012-05-15 09:50:30 -07003240 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003241 platform_add_devices(mpq_devices, ARRAY_SIZE(mpq_devices));
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06003242 mpq8064_pcie_init();
Joel King8f839b92012-04-01 14:37:46 -07003243 } else {
3244 ethernet_init();
Olav Hauganef95ae32012-05-15 09:50:30 -07003245 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003246 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3247 spi_register_board_info(spi_board_info,
3248 ARRAY_SIZE(spi_board_info));
3249 }
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003250 apq8064_init_fb();
Jordan Crouseb3115fe2012-02-01 22:11:12 -07003251 apq8064_init_gpu();
Matt Wagantall1f65d9d2012-04-25 14:24:20 -07003252 platform_add_devices(apq8064_footswitch, apq8064_num_footswitch);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003253#ifdef CONFIG_MSM_CAMERA
Kevin Chand07220e2012-02-13 15:52:22 -08003254 apq8064_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003255#endif
Mohan Pallaka474b94b2012-01-25 12:59:58 +05303256
3257 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid())
3258 platform_device_register(&cdp_kp_pdev);
3259
3260 if (machine_is_apq8064_mtp())
3261 platform_device_register(&mtp_kp_pdev);
Hanumant Singh50440d42012-04-23 19:27:16 -07003262
3263 change_memory_power = &apq8064_change_memory_power;
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05303264
3265 if (machine_is_mpq8064_cdp()) {
3266 platform_device_register(&mpq_gpio_keys_pdev);
3267 platform_device_register(&mpq_keypad_device);
3268 }
Joel King82b7e3f2012-01-05 10:03:27 -08003269}
3270
Joel King82b7e3f2012-01-05 10:03:27 -08003271MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
3272 .map_io = apq8064_map_io,
3273 .reserve = apq8064_reserve,
3274 .init_irq = apq8064_init_irq,
3275 .handle_irq = gic_handle_irq,
3276 .timer = &msm_timer,
3277 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003278 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003279 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003280 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003281MACHINE_END
3282
3283MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
3284 .map_io = apq8064_map_io,
3285 .reserve = apq8064_reserve,
3286 .init_irq = apq8064_init_irq,
3287 .handle_irq = gic_handle_irq,
3288 .timer = &msm_timer,
3289 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003290 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003291 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003292 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003293MACHINE_END
3294
3295MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
3296 .map_io = apq8064_map_io,
3297 .reserve = apq8064_reserve,
3298 .init_irq = apq8064_init_irq,
3299 .handle_irq = gic_handle_irq,
3300 .timer = &msm_timer,
3301 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003302 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003303 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003304 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003305MACHINE_END
3306
Joel King064bbf82012-04-01 13:23:39 -07003307MACHINE_START(MPQ8064_CDP, "QCT MPQ8064 CDP")
3308 .map_io = apq8064_map_io,
3309 .reserve = apq8064_reserve,
3310 .init_irq = apq8064_init_irq,
3311 .handle_irq = gic_handle_irq,
3312 .timer = &msm_timer,
3313 .init_machine = apq8064_cdp_init,
3314 .init_early = apq8064_allocate_memory_regions,
3315 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003316 .restart = msm_restart,
Joel King064bbf82012-04-01 13:23:39 -07003317MACHINE_END
3318
Joel King11ca8202012-02-13 16:19:03 -08003319MACHINE_START(MPQ8064_HRD, "QCT MPQ8064 HRD")
3320 .map_io = apq8064_map_io,
3321 .reserve = apq8064_reserve,
3322 .init_irq = apq8064_init_irq,
3323 .handle_irq = gic_handle_irq,
3324 .timer = &msm_timer,
3325 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003326 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003327 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003328 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003329MACHINE_END
3330
3331MACHINE_START(MPQ8064_DTV, "QCT MPQ8064 DTV")
3332 .map_io = apq8064_map_io,
3333 .reserve = apq8064_reserve,
3334 .init_irq = apq8064_init_irq,
3335 .handle_irq = gic_handle_irq,
3336 .timer = &msm_timer,
3337 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003338 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003339 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003340 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003341MACHINE_END
3342