blob: aa12ce09925eda241444193b6a79339611a517e9 [file] [log] [blame]
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07001/* Copyright (c) 2011-2012, 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"
Jay Chokshiea67c622011-07-29 17:12:26 -070089
Olav Haugan7c6aa742012-01-16 16:47:37 -080090#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -070091#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Olav Haugan7c6aa742012-01-16 16:47:37 -080092#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
93#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
94#else
Chetan Kalyan72aac4f2012-02-23 14:56:54 -080095#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Olav Haugan7c6aa742012-01-16 16:47:37 -080096#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070097
Olav Haugan7c6aa742012-01-16 16:47:37 -080098#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Hanumant Singheadb7502012-05-15 18:14:04 -070099#define HOLE_SIZE 0x20000
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700100#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan129992c2012-03-22 09:54:01 -0700101#ifdef CONFIG_MSM_IOMMU
102#define MSM_ION_MM_SIZE 0x3800000
103#define MSM_ION_SF_SIZE 0
Olav Haugan39477bb2012-05-14 16:05:36 -0700104#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700105#define MSM_ION_HEAP_NUM 7
106#else
Olav Haugan7c6aa742012-01-16 16:47:37 -0800107#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan129992c2012-03-22 09:54:01 -0700108#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Haugan39477bb2012-05-14 16:05:36 -0700109#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700110#define MSM_ION_HEAP_NUM 8
111#endif
Hanumant Singheadb7502012-05-15 18:14:04 -0700112#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* (2MB - 128KB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800113#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan2c43fac2012-01-19 11:06:37 -0800114#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan7c6aa742012-01-16 16:47:37 -0800115#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700116#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Haugan7c6aa742012-01-16 16:47:37 -0800117#define MSM_ION_HEAP_NUM 1
118#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700119
Hanumant Singheadb7502012-05-15 18:14:04 -0700120#define APQ8064_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
121 HOLE_SIZE))
Larry Bassel67b921d2012-04-06 10:23:27 -0700122#define MAX_FIXED_AREA_SIZE 0x10000000
Hanumant Singheadb7502012-05-15 18:14:04 -0700123#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE)
124#define APQ8064_FW_START APQ8064_FIXED_AREA_START
Larry Bassel67b921d2012-04-06 10:23:27 -0700125
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -0600126#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB (MSM_QFPROM_BASE + 0x23c)
127#define QFPROM_RAW_OEM_CONFIG_ROW0_LSB (MSM_QFPROM_BASE + 0x220)
128
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -0600129/* PCIE AXI address space */
130#define PCIE_AXI_BAR_PHYS 0x08000000
131#define PCIE_AXI_BAR_SIZE SZ_128M
132
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -0600133/* PCIe pmic gpios */
134#define PCIE_WAKE_N_PMIC_GPIO 12
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600135#define PCIE_PWR_EN_PMIC_GPIO 13
136#define PCIE_RST_N_PMIC_MPP 1
137
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700138#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
139static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
140static int __init msm_contig_mem_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -0700141{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700142 msm_contig_mem_size = memparse(p, NULL);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800143 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700144}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700145early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800146#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700147
Olav Haugan7c6aa742012-01-16 16:47:37 -0800148#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -0700149static unsigned pmem_size = MSM_PMEM_SIZE;
150static int __init pmem_size_setup(char *p)
151{
152 pmem_size = memparse(p, NULL);
153 return 0;
154}
155early_param("pmem_size", pmem_size_setup);
156
157static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
158
159static int __init pmem_adsp_size_setup(char *p)
160{
161 pmem_adsp_size = memparse(p, NULL);
162 return 0;
163}
164early_param("pmem_adsp_size", pmem_adsp_size_setup);
165
166static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
167
168static int __init pmem_audio_size_setup(char *p)
169{
170 pmem_audio_size = memparse(p, NULL);
171 return 0;
172}
173early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800174#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700175
Olav Haugan7c6aa742012-01-16 16:47:37 -0800176#ifdef CONFIG_ANDROID_PMEM
177#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700178static struct android_pmem_platform_data android_pmem_pdata = {
179 .name = "pmem",
180 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
181 .cached = 1,
182 .memory_type = MEMTYPE_EBI1,
183};
184
Laura Abbottb93525f2012-04-12 09:57:19 -0700185static struct platform_device apq8064_android_pmem_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700186 .name = "android_pmem",
187 .id = 0,
188 .dev = {.platform_data = &android_pmem_pdata},
189};
190
191static struct android_pmem_platform_data android_pmem_adsp_pdata = {
192 .name = "pmem_adsp",
193 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
194 .cached = 0,
195 .memory_type = MEMTYPE_EBI1,
196};
Laura Abbottb93525f2012-04-12 09:57:19 -0700197static struct platform_device apq8064_android_pmem_adsp_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700198 .name = "android_pmem",
199 .id = 2,
200 .dev = { .platform_data = &android_pmem_adsp_pdata },
201};
202
203static struct android_pmem_platform_data android_pmem_audio_pdata = {
204 .name = "pmem_audio",
205 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
206 .cached = 0,
207 .memory_type = MEMTYPE_EBI1,
208};
209
Laura Abbottb93525f2012-04-12 09:57:19 -0700210static struct platform_device apq8064_android_pmem_audio_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700211 .name = "android_pmem",
212 .id = 4,
213 .dev = { .platform_data = &android_pmem_audio_pdata },
214};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700215#endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
216#endif /* CONFIG_ANDROID_PMEM */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800217
Larry Bassel67b921d2012-04-06 10:23:27 -0700218struct fmem_platform_data apq8064_fmem_pdata = {
219};
220
Olav Haugan7c6aa742012-01-16 16:47:37 -0800221static struct memtype_reserve apq8064_reserve_table[] __initdata = {
222 [MEMTYPE_SMI] = {
223 },
224 [MEMTYPE_EBI0] = {
225 .flags = MEMTYPE_FLAGS_1M_ALIGN,
226 },
227 [MEMTYPE_EBI1] = {
228 .flags = MEMTYPE_FLAGS_1M_ALIGN,
229 },
230};
Kevin Chan13be4e22011-10-20 11:30:32 -0700231
Laura Abbott350c8362012-02-28 14:46:52 -0800232static void __init reserve_rtb_memory(void)
233{
234#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700235 apq8064_reserve_table[MEMTYPE_EBI1].size += apq8064_rtb_pdata.size;
Laura Abbott350c8362012-02-28 14:46:52 -0800236#endif
237}
238
239
Kevin Chan13be4e22011-10-20 11:30:32 -0700240static void __init size_pmem_devices(void)
241{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800242#ifdef CONFIG_ANDROID_PMEM
243#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700244 android_pmem_adsp_pdata.size = pmem_adsp_size;
245 android_pmem_pdata.size = pmem_size;
246 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700247#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
248#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700249}
250
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700251#ifdef CONFIG_ANDROID_PMEM
252#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700253static void __init reserve_memory_for(struct android_pmem_platform_data *p)
254{
255 apq8064_reserve_table[p->memory_type].size += p->size;
256}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700257#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
258#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700259
Kevin Chan13be4e22011-10-20 11:30:32 -0700260static void __init reserve_pmem_memory(void)
261{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800262#ifdef CONFIG_ANDROID_PMEM
263#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700264 reserve_memory_for(&android_pmem_adsp_pdata);
265 reserve_memory_for(&android_pmem_pdata);
266 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700267#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700268 apq8064_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700269#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -0800270}
271
272static int apq8064_paddr_to_memtype(unsigned int paddr)
273{
274 return MEMTYPE_EBI1;
275}
276
Steve Mucklef132c6c2012-06-06 18:30:57 -0700277#define FMEM_ENABLED 0
Larry Bassel67b921d2012-04-06 10:23:27 -0700278
Olav Haugan7c6aa742012-01-16 16:47:37 -0800279#ifdef CONFIG_ION_MSM
280#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700281static struct ion_cp_heap_pdata cp_mm_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800282 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800283 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700284 .reusable = FMEM_ENABLED,
285 .mem_is_fmem = FMEM_ENABLED,
286 .fixed_position = FIXED_MIDDLE,
Laura Abbottadec9c72012-12-05 11:49:59 -0800287 .is_cma = 1,
Laura Abbott5249a052012-12-11 15:09:03 -0800288 .no_nonsecure_alloc = 1,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800289};
290
Laura Abbottb93525f2012-04-12 09:57:19 -0700291static struct ion_cp_heap_pdata cp_mfc_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800292 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800293 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700294 .reusable = 0,
295 .mem_is_fmem = FMEM_ENABLED,
296 .fixed_position = FIXED_HIGH,
Laura Abbott5249a052012-12-11 15:09:03 -0800297 .no_nonsecure_alloc = 1,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800298};
299
Laura Abbottb93525f2012-04-12 09:57:19 -0700300static struct ion_co_heap_pdata co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800301 .adjacent_mem_id = INVALID_HEAP_ID,
302 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700303 .mem_is_fmem = 0,
Olav Haugand3d29682012-01-19 10:57:07 -0800304};
305
Laura Abbottb93525f2012-04-12 09:57:19 -0700306static struct ion_co_heap_pdata fw_co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800307 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
308 .align = SZ_128K,
Larry Bassel67b921d2012-04-06 10:23:27 -0700309 .mem_is_fmem = FMEM_ENABLED,
310 .fixed_position = FIXED_LOW,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800311};
312#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800313
Laura Abbott0ae40a02012-08-10 10:49:33 -0700314static u64 msm_dmamask = DMA_BIT_MASK(32);
315
316static struct platform_device ion_mm_heap_device = {
317 .name = "ion-mm-heap-device",
318 .id = -1,
319 .dev = {
320 .dma_mask = &msm_dmamask,
321 .coherent_dma_mask = DMA_BIT_MASK(32),
322 }
323};
324
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800325/**
326 * These heaps are listed in the order they will be allocated. Due to
327 * video hardware restrictions and content protection the FW heap has to
328 * be allocated adjacent (below) the MM heap and the MFC heap has to be
329 * allocated after the MM heap to ensure MFC heap is not more than 256MB
330 * away from the base address of the FW heap.
331 * However, the order of FW heap and MM heap doesn't matter since these
332 * two heaps are taken care of by separate code to ensure they are adjacent
333 * to each other.
334 * Don't swap the order unless you know what you are doing!
335 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700336struct ion_platform_heap apq8064_heaps[] = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800337 {
338 .id = ION_SYSTEM_HEAP_ID,
339 .type = ION_HEAP_TYPE_SYSTEM,
340 .name = ION_VMALLOC_HEAP_NAME,
341 },
342#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
343 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800344 .id = ION_CP_MM_HEAP_ID,
345 .type = ION_HEAP_TYPE_CP,
346 .name = ION_MM_HEAP_NAME,
347 .size = MSM_ION_MM_SIZE,
348 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700349 .extra_data = (void *) &cp_mm_apq8064_ion_pdata,
Laura Abbott0ae40a02012-08-10 10:49:33 -0700350 .priv = &ion_mm_heap_device.dev
Olav Haugan7c6aa742012-01-16 16:47:37 -0800351 },
352 {
Olav Haugand3d29682012-01-19 10:57:07 -0800353 .id = ION_MM_FIRMWARE_HEAP_ID,
354 .type = ION_HEAP_TYPE_CARVEOUT,
355 .name = ION_MM_FIRMWARE_HEAP_NAME,
356 .size = MSM_ION_MM_FW_SIZE,
357 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700358 .extra_data = (void *) &fw_co_apq8064_ion_pdata,
Olav Haugand3d29682012-01-19 10:57:07 -0800359 },
360 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800361 .id = ION_CP_MFC_HEAP_ID,
362 .type = ION_HEAP_TYPE_CP,
363 .name = ION_MFC_HEAP_NAME,
364 .size = MSM_ION_MFC_SIZE,
365 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700366 .extra_data = (void *) &cp_mfc_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800367 },
Olav Haugan129992c2012-03-22 09:54:01 -0700368#ifndef CONFIG_MSM_IOMMU
Olav Haugan7c6aa742012-01-16 16:47:37 -0800369 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800370 .id = ION_SF_HEAP_ID,
371 .type = ION_HEAP_TYPE_CARVEOUT,
372 .name = ION_SF_HEAP_NAME,
373 .size = MSM_ION_SF_SIZE,
374 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700375 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800376 },
Olav Haugan129992c2012-03-22 09:54:01 -0700377#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800378 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800379 .id = ION_IOMMU_HEAP_ID,
380 .type = ION_HEAP_TYPE_IOMMU,
381 .name = ION_IOMMU_HEAP_NAME,
382 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800383 {
384 .id = ION_QSECOM_HEAP_ID,
385 .type = ION_HEAP_TYPE_CARVEOUT,
386 .name = ION_QSECOM_HEAP_NAME,
387 .size = MSM_ION_QSECOM_SIZE,
388 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700389 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Hauganf45e2142012-01-19 11:01:01 -0800390 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800391 {
392 .id = ION_AUDIO_HEAP_ID,
393 .type = ION_HEAP_TYPE_CARVEOUT,
394 .name = ION_AUDIO_HEAP_NAME,
395 .size = MSM_ION_AUDIO_SIZE,
396 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700397 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan2c43fac2012-01-19 11:06:37 -0800398 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800399#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700400};
401
402static struct ion_platform_data apq8064_ion_pdata = {
403 .nr = MSM_ION_HEAP_NUM,
404 .heaps = apq8064_heaps,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800405};
406
Laura Abbottb93525f2012-04-12 09:57:19 -0700407static struct platform_device apq8064_ion_dev = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800408 .name = "ion-msm",
409 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700410 .dev = { .platform_data = &apq8064_ion_pdata },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800411};
412#endif
413
Larry Bassel67b921d2012-04-06 10:23:27 -0700414static struct platform_device apq8064_fmem_device = {
415 .name = "fmem",
416 .id = 1,
417 .dev = { .platform_data = &apq8064_fmem_pdata },
418};
419
420static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
421 unsigned long size)
422{
423 apq8064_reserve_table[mem_type].size += size;
424}
425
426static void __init apq8064_reserve_fixed_area(unsigned long fixed_area_size)
427{
428#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
429 int ret;
430
431 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
432 panic("fixed area size is larger than %dM\n",
433 MAX_FIXED_AREA_SIZE >> 20);
434
435 reserve_info->fixed_area_size = fixed_area_size;
436 reserve_info->fixed_area_start = APQ8064_FW_START;
437
438 ret = memblock_remove(reserve_info->fixed_area_start,
439 reserve_info->fixed_area_size);
440 BUG_ON(ret);
441#endif
442}
443
444/**
445 * Reserve memory for ION and calculate amount of reusable memory for fmem.
446 * We only reserve memory for heaps that are not reusable. However, we only
447 * support one reusable heap at the moment so we ignore the reusable flag for
448 * other than the first heap with reusable flag set. Also handle special case
449 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
450 * at a higher address than FW in addition to not more than 256MB away from the
451 * base address of the firmware. This means that if MM is reusable the other
452 * two heaps must be allocated in the same region as FW. This is handled by the
453 * mem_is_fmem flag in the platform data. In addition the MM heap must be
454 * adjacent to the FW heap for content protection purposes.
455 */
Stephen Boyd668d7652012-04-25 11:31:01 -0700456static void __init reserve_ion_memory(void)
Olav Haugan7c6aa742012-01-16 16:47:37 -0800457{
458#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Larry Bassel67b921d2012-04-06 10:23:27 -0700459 unsigned int i;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700460 unsigned int ret;
Larry Bassel67b921d2012-04-06 10:23:27 -0700461 unsigned int fixed_size = 0;
462 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
463 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700464 unsigned long cma_alignment;
465 unsigned int low_use_cma = 0;
466 unsigned int middle_use_cma = 0;
467 unsigned int high_use_cma = 0;
468
Larry Bassel67b921d2012-04-06 10:23:27 -0700469
Larry Bassel67b921d2012-04-06 10:23:27 -0700470 fixed_low_size = 0;
471 fixed_middle_size = 0;
472 fixed_high_size = 0;
473
Laura Abbott0ae40a02012-08-10 10:49:33 -0700474 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
475
Larry Bassel67b921d2012-04-06 10:23:27 -0700476 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
Laura Abbott0ae40a02012-08-10 10:49:33 -0700477 struct ion_platform_heap *heap =
Larry Bassel67b921d2012-04-06 10:23:27 -0700478 &(apq8064_ion_pdata.heaps[i]);
Laura Abbott0ae40a02012-08-10 10:49:33 -0700479 int use_cma = 0;
480
Larry Bassel67b921d2012-04-06 10:23:27 -0700481
482 if (heap->extra_data) {
483 int fixed_position = NOT_FIXED;
Larry Bassel67b921d2012-04-06 10:23:27 -0700484
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700485 switch ((int)heap->type) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700486 case ION_HEAP_TYPE_CP:
Laura Abbott0ae40a02012-08-10 10:49:33 -0700487 if (((struct ion_cp_heap_pdata *)
488 heap->extra_data)->is_cma) {
489 heap->size = ALIGN(heap->size,
490 cma_alignment);
491 use_cma = 1;
492 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700493 fixed_position = ((struct ion_cp_heap_pdata *)
494 heap->extra_data)->fixed_position;
495 break;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700496 case ION_HEAP_TYPE_DMA:
497 use_cma = 1;
498 /* Purposely fall through here */
Larry Bassel67b921d2012-04-06 10:23:27 -0700499 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel67b921d2012-04-06 10:23:27 -0700500 fixed_position = ((struct ion_co_heap_pdata *)
501 heap->extra_data)->fixed_position;
502 break;
503 default:
504 break;
505 }
506
507 if (fixed_position != NOT_FIXED)
508 fixed_size += heap->size;
509 else
510 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
511
Laura Abbott0ae40a02012-08-10 10:49:33 -0700512 if (fixed_position == FIXED_LOW) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700513 fixed_low_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700514 low_use_cma = use_cma;
515 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700516 fixed_middle_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700517 middle_use_cma = use_cma;
518 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700519 fixed_high_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700520 high_use_cma = use_cma;
521 } else if (use_cma) {
522 /*
523 * Heaps that use CMA but are not part of the
524 * fixed set. Create wherever.
525 */
526 dma_declare_contiguous(
527 heap->priv,
528 heap->size,
529 0,
530 0xb0000000);
531
532 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700533 }
534 }
535
536 if (!fixed_size)
537 return;
538
Laura Abbott0ae40a02012-08-10 10:49:33 -0700539 /*
540 * Given the setup for the fixed area, we can't round up all sizes.
541 * Some sizes must be set up exactly and aligned correctly. Incorrect
542 * alignments are considered a configuration issue
Larry Bassel67b921d2012-04-06 10:23:27 -0700543 */
Larry Bassel67b921d2012-04-06 10:23:27 -0700544
545 fixed_low_start = APQ8064_FIXED_AREA_START;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700546 if (low_use_cma) {
547 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
548 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
549 } else {
550 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
551 ret = memblock_remove(fixed_low_start,
552 fixed_low_size + HOLE_SIZE);
553 BUG_ON(ret);
554 }
555
Hanumant Singheadb7502012-05-15 18:14:04 -0700556 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700557 if (middle_use_cma) {
558 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
559 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
560 } else {
561 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
562 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
563 BUG_ON(ret);
564 }
565
Larry Bassel67b921d2012-04-06 10:23:27 -0700566 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700567 if (high_use_cma) {
568 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
569 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
570 } else {
571 /* This is the end of the fixed area so it's okay to round up */
572 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
573 ret = memblock_remove(fixed_high_start, fixed_high_size);
574 BUG_ON(ret);
575 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700576
577 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
578 struct ion_platform_heap *heap = &(apq8064_ion_pdata.heaps[i]);
579
580 if (heap->extra_data) {
581 int fixed_position = NOT_FIXED;
Steve Mucklef132c6c2012-06-06 18:30:57 -0700582 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel67b921d2012-04-06 10:23:27 -0700583
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700584 switch ((int) heap->type) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700585 case ION_HEAP_TYPE_CP:
Hanumant Singheadb7502012-05-15 18:14:04 -0700586 pdata =
587 (struct ion_cp_heap_pdata *)heap->extra_data;
588 fixed_position = pdata->fixed_position;
Larry Bassel67b921d2012-04-06 10:23:27 -0700589 break;
590 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbott0ae40a02012-08-10 10:49:33 -0700591 case ION_HEAP_TYPE_DMA:
Larry Bassel67b921d2012-04-06 10:23:27 -0700592 fixed_position = ((struct ion_co_heap_pdata *)
593 heap->extra_data)->fixed_position;
594 break;
595 default:
596 break;
597 }
598
599 switch (fixed_position) {
600 case FIXED_LOW:
601 heap->base = fixed_low_start;
602 break;
603 case FIXED_MIDDLE:
604 heap->base = fixed_middle_start;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700605 if (middle_use_cma) {
606 ret = dma_declare_contiguous(
607 heap->priv,
608 heap->size,
609 fixed_middle_start,
610 0xa0000000);
611 WARN_ON(ret);
612 }
Hanumant Singheadb7502012-05-15 18:14:04 -0700613 pdata->secure_base = fixed_middle_start
614 - HOLE_SIZE;
615 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel67b921d2012-04-06 10:23:27 -0700616 break;
617 case FIXED_HIGH:
618 heap->base = fixed_high_start;
619 break;
620 default:
621 break;
622 }
623 }
624 }
Olav Haugan7c6aa742012-01-16 16:47:37 -0800625#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700626}
627
Huaibin Yang4a084e32011-12-15 15:25:52 -0800628static void __init reserve_mdp_memory(void)
629{
630 apq8064_mdp_writeback(apq8064_reserve_table);
631}
632
Laura Abbott93a4a352012-05-25 09:26:35 -0700633static void __init reserve_cache_dump_memory(void)
634{
635#ifdef CONFIG_MSM_CACHE_DUMP
636 unsigned int total;
637
638 total = apq8064_cache_dump_pdata.l1_size +
639 apq8064_cache_dump_pdata.l2_size;
640 apq8064_reserve_table[MEMTYPE_EBI1].size += total;
641#endif
642}
643
Abhijeet Dharmapurikar3edb5de2012-09-13 11:02:03 -0700644static void __init reserve_mpdcvs_memory(void)
645{
646 apq8064_reserve_table[MEMTYPE_EBI1].size += SZ_32K;
647}
648
Kevin Chan13be4e22011-10-20 11:30:32 -0700649static void __init apq8064_calculate_reserve_sizes(void)
650{
651 size_pmem_devices();
652 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800653 reserve_ion_memory();
Huaibin Yang4a084e32011-12-15 15:25:52 -0800654 reserve_mdp_memory();
Laura Abbott350c8362012-02-28 14:46:52 -0800655 reserve_rtb_memory();
Laura Abbott93a4a352012-05-25 09:26:35 -0700656 reserve_cache_dump_memory();
Abhijeet Dharmapurikar3edb5de2012-09-13 11:02:03 -0700657 reserve_mpdcvs_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700658}
659
660static struct reserve_info apq8064_reserve_info __initdata = {
661 .memtype_reserve_table = apq8064_reserve_table,
662 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
Larry Bassel67b921d2012-04-06 10:23:27 -0700663 .reserve_fixed_area = apq8064_reserve_fixed_area,
Kevin Chan13be4e22011-10-20 11:30:32 -0700664 .paddr_to_memtype = apq8064_paddr_to_memtype,
665};
666
667static int apq8064_memory_bank_size(void)
668{
669 return 1<<29;
670}
671
672static void __init locate_unstable_memory(void)
673{
674 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
675 unsigned long bank_size;
676 unsigned long low, high;
677
678 bank_size = apq8064_memory_bank_size();
679 low = meminfo.bank[0].start;
680 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800681
682 /* Check if 32 bit overflow occured */
683 if (high < mb->start)
Larry Bassel67b921d2012-04-06 10:23:27 -0700684 high = -PAGE_SIZE;
Olav Haugand76e3a82012-01-16 16:55:07 -0800685
Kevin Chan13be4e22011-10-20 11:30:32 -0700686 low &= ~(bank_size - 1);
687
688 if (high - low <= bank_size)
Larry Bassel67b921d2012-04-06 10:23:27 -0700689 goto no_dmm;
690
691#ifdef CONFIG_ENABLE_DMM
Jack Cheung46bfffa2012-01-19 15:26:24 -0800692 apq8064_reserve_info.low_unstable_address = mb->start -
693 MIN_MEMORY_BLOCK_SIZE + mb->size;
694 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
695
Kevin Chan13be4e22011-10-20 11:30:32 -0700696 apq8064_reserve_info.bank_size = bank_size;
697 pr_info("low unstable address %lx max size %lx bank size %lx\n",
698 apq8064_reserve_info.low_unstable_address,
699 apq8064_reserve_info.max_unstable_size,
700 apq8064_reserve_info.bank_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700701 return;
702#endif
703no_dmm:
704 apq8064_reserve_info.low_unstable_address = high;
705 apq8064_reserve_info.max_unstable_size = 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700706}
707
Hanumant Singh50440d42012-04-23 19:27:16 -0700708static int apq8064_change_memory_power(u64 start, u64 size,
709 int change_type)
710{
711 return soc_change_memory_power(start, size, change_type);
712}
713
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700714static char prim_panel_name[PANEL_NAME_MAX_LEN];
715static char ext_panel_name[PANEL_NAME_MAX_LEN];
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530716
717static int ext_resolution;
718
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700719static int __init prim_display_setup(char *param)
720{
721 if (strnlen(param, PANEL_NAME_MAX_LEN))
722 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
723 return 0;
724}
725early_param("prim_display", prim_display_setup);
726
727static int __init ext_display_setup(char *param)
728{
729 if (strnlen(param, PANEL_NAME_MAX_LEN))
730 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
731 return 0;
732}
733early_param("ext_display", ext_display_setup);
734
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530735static int __init hdmi_resulution_setup(char *param)
736{
737 int ret;
738 ret = kstrtoint(param, 10, &ext_resolution);
739 return ret;
740}
741early_param("ext_resolution", hdmi_resulution_setup);
742
Kevin Chan13be4e22011-10-20 11:30:32 -0700743static void __init apq8064_reserve(void)
744{
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530745 apq8064_set_display_params(prim_panel_name, ext_panel_name,
746 ext_resolution);
Kevin Chan13be4e22011-10-20 11:30:32 -0700747 msm_reserve();
748}
749
Laura Abbott6988cef2012-03-15 14:27:13 -0700750static void __init place_movable_zone(void)
751{
Larry Bassel67b921d2012-04-06 10:23:27 -0700752#ifdef CONFIG_ENABLE_DMM
Laura Abbott6988cef2012-03-15 14:27:13 -0700753 movable_reserved_start = apq8064_reserve_info.low_unstable_address;
754 movable_reserved_size = apq8064_reserve_info.max_unstable_size;
755 pr_info("movable zone start %lx size %lx\n",
756 movable_reserved_start, movable_reserved_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700757#endif
Laura Abbott6988cef2012-03-15 14:27:13 -0700758}
759
760static void __init apq8064_early_reserve(void)
761{
762 reserve_info = &apq8064_reserve_info;
763 locate_unstable_memory();
764 place_movable_zone();
765
766}
Hemant Kumara945b472012-01-25 15:08:06 -0800767#ifdef CONFIG_USB_EHCI_MSM_HSIC
Hemant Kumare6275972012-02-29 20:06:21 -0800768/* Bandwidth requests (zero) if no vote placed */
769static struct msm_bus_vectors hsic_init_vectors[] = {
770 {
771 .src = MSM_BUS_MASTER_SPS,
772 .dst = MSM_BUS_SLAVE_EBI_CH0,
773 .ab = 0,
774 .ib = 0,
775 },
776 {
777 .src = MSM_BUS_MASTER_SPS,
778 .dst = MSM_BUS_SLAVE_SPS,
779 .ab = 0,
780 .ib = 0,
781 },
782};
783
784/* Bus bandwidth requests in Bytes/sec */
785static struct msm_bus_vectors hsic_max_vectors[] = {
786 {
787 .src = MSM_BUS_MASTER_SPS,
788 .dst = MSM_BUS_SLAVE_EBI_CH0,
789 .ab = 60000000, /* At least 480Mbps on bus. */
790 .ib = 960000000, /* MAX bursts rate */
791 },
792 {
793 .src = MSM_BUS_MASTER_SPS,
794 .dst = MSM_BUS_SLAVE_SPS,
795 .ab = 0,
796 .ib = 512000000, /*vote for 64Mhz dfab clk rate*/
797 },
798};
799
800static struct msm_bus_paths hsic_bus_scale_usecases[] = {
801 {
802 ARRAY_SIZE(hsic_init_vectors),
803 hsic_init_vectors,
804 },
805 {
806 ARRAY_SIZE(hsic_max_vectors),
807 hsic_max_vectors,
808 },
809};
810
811static struct msm_bus_scale_pdata hsic_bus_scale_pdata = {
812 hsic_bus_scale_usecases,
813 ARRAY_SIZE(hsic_bus_scale_usecases),
814 .name = "hsic",
815};
816
Hemant Kumara945b472012-01-25 15:08:06 -0800817static struct msm_hsic_host_platform_data msm_hsic_pdata = {
Hemant Kumare6275972012-02-29 20:06:21 -0800818 .strobe = 88,
819 .data = 89,
820 .bus_scale_table = &hsic_bus_scale_pdata,
Hemant Kumara945b472012-01-25 15:08:06 -0800821};
822#else
823static struct msm_hsic_host_platform_data msm_hsic_pdata;
824#endif
825
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800826#define PID_MAGIC_ID 0x71432909
827#define SERIAL_NUM_MAGIC_ID 0x61945374
828#define SERIAL_NUMBER_LENGTH 127
829#define DLOAD_USB_BASE_ADD 0x2A03F0C8
830
831struct magic_num_struct {
832 uint32_t pid;
833 uint32_t serial_num;
834};
835
836struct dload_struct {
837 uint32_t reserved1;
838 uint32_t reserved2;
839 uint32_t reserved3;
840 uint16_t reserved4;
841 uint16_t pid;
842 char serial_number[SERIAL_NUMBER_LENGTH];
843 uint16_t reserved5;
844 struct magic_num_struct magic_struct;
845};
846
847static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
848{
849 struct dload_struct __iomem *dload = 0;
850
851 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
852 if (!dload) {
853 pr_err("%s: cannot remap I/O memory region: %08x\n",
854 __func__, DLOAD_USB_BASE_ADD);
855 return -ENXIO;
856 }
857
858 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
859 __func__, dload, pid, snum);
860 /* update pid */
861 dload->magic_struct.pid = PID_MAGIC_ID;
862 dload->pid = pid;
863
864 /* update serial number */
865 dload->magic_struct.serial_num = 0;
866 if (!snum) {
867 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
868 goto out;
869 }
870
871 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
872 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
873out:
874 iounmap(dload);
875 return 0;
876}
877
878static struct android_usb_platform_data android_usb_pdata = {
879 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
880};
881
Hemant Kumar4933b072011-10-17 23:43:11 -0700882static struct platform_device android_usb_device = {
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800883 .name = "android_usb",
884 .id = -1,
885 .dev = {
886 .platform_data = &android_usb_pdata,
887 },
Hemant Kumar4933b072011-10-17 23:43:11 -0700888};
889
Hemant Kumar7620eed2012-02-26 09:08:43 -0800890/* Bandwidth requests (zero) if no vote placed */
891static struct msm_bus_vectors usb_init_vectors[] = {
892 {
893 .src = MSM_BUS_MASTER_SPS,
894 .dst = MSM_BUS_SLAVE_EBI_CH0,
895 .ab = 0,
896 .ib = 0,
897 },
898};
899
900/* Bus bandwidth requests in Bytes/sec */
901static struct msm_bus_vectors usb_max_vectors[] = {
902 {
903 .src = MSM_BUS_MASTER_SPS,
904 .dst = MSM_BUS_SLAVE_EBI_CH0,
905 .ab = 60000000, /* At least 480Mbps on bus. */
906 .ib = 960000000, /* MAX bursts rate */
907 },
908};
909
910static struct msm_bus_paths usb_bus_scale_usecases[] = {
911 {
912 ARRAY_SIZE(usb_init_vectors),
913 usb_init_vectors,
914 },
915 {
916 ARRAY_SIZE(usb_max_vectors),
917 usb_max_vectors,
918 },
919};
920
921static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
922 usb_bus_scale_usecases,
923 ARRAY_SIZE(usb_bus_scale_usecases),
924 .name = "usb",
925};
926
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700927static int phy_init_seq[] = {
928 0x38, 0x81, /* update DC voltage level */
929 0x24, 0x82, /* set pre-emphasis and rise/fall time */
930 -1
931};
932
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530933#define PMIC_GPIO_DP 27 /* PMIC GPIO for D+ change */
934#define PMIC_GPIO_DP_IRQ PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PMIC_GPIO_DP)
Jack Pham87f202f2012-08-06 00:24:22 -0700935#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
936
Hemant Kumar4933b072011-10-17 23:43:11 -0700937static struct msm_otg_platform_data msm_otg_pdata = {
Hemant Kumard86c4882012-01-24 19:39:37 -0800938 .mode = USB_OTG,
939 .otg_control = OTG_PMIC_CONTROL,
Hemant Kumar4933b072011-10-17 23:43:11 -0700940 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumard86c4882012-01-24 19:39:37 -0800941 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
942 .power_budget = 750,
Hemant Kumar7620eed2012-02-26 09:08:43 -0800943 .bus_scale_table = &usb_bus_scale_pdata,
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700944 .phy_init_seq = phy_init_seq,
Jack Pham87f202f2012-08-06 00:24:22 -0700945 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Hemant Kumar4933b072011-10-17 23:43:11 -0700946};
947
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800948static struct msm_usb_host_platform_data msm_ehci_host_pdata3 = {
Manu Gautam91223e02011-11-08 15:27:22 +0530949 .power_budget = 500,
950};
951
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800952#ifdef CONFIG_USB_EHCI_MSM_HOST4
953static struct msm_usb_host_platform_data msm_ehci_host_pdata4;
954#endif
955
Manu Gautam91223e02011-11-08 15:27:22 +0530956static void __init apq8064_ehci_host_init(void)
957{
Chiranjeevi Velempatib822fa32012-05-23 22:05:59 +0530958 if (machine_is_apq8064_liquid() || machine_is_mpq8064_cdp() ||
959 machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
960 if (machine_is_apq8064_liquid())
961 msm_ehci_host_pdata3.dock_connect_irq =
962 PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9);
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530963 else
964 msm_ehci_host_pdata3.pmic_gpio_dp_irq =
965 PMIC_GPIO_DP_IRQ;
Hemant Kumar56925352012-02-13 16:59:52 -0800966
Manu Gautam91223e02011-11-08 15:27:22 +0530967 apq8064_device_ehci_host3.dev.platform_data =
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800968 &msm_ehci_host_pdata3;
Manu Gautam91223e02011-11-08 15:27:22 +0530969 platform_device_register(&apq8064_device_ehci_host3);
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800970
971#ifdef CONFIG_USB_EHCI_MSM_HOST4
972 apq8064_device_ehci_host4.dev.platform_data =
973 &msm_ehci_host_pdata4;
974 platform_device_register(&apq8064_device_ehci_host4);
975#endif
Manu Gautam91223e02011-11-08 15:27:22 +0530976 }
977}
978
David Keitel2f613d92012-02-15 11:29:16 -0800979static struct smb349_platform_data smb349_data __initdata = {
980 .en_n_gpio = PM8921_GPIO_PM_TO_SYS(37),
981 .chg_susp_gpio = PM8921_GPIO_PM_TO_SYS(30),
982 .chg_current_ma = 2200,
983};
984
985static struct i2c_board_info smb349_charger_i2c_info[] __initdata = {
986 {
987 I2C_BOARD_INFO(SMB349_NAME, 0x1B),
988 .platform_data = &smb349_data,
989 },
990};
991
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -0800992struct sx150x_platform_data apq8064_sx150x_data[] = {
993 [SX150X_EPM] = {
994 .gpio_base = GPIO_EPM_EXPANDER_BASE,
995 .oscio_is_gpo = false,
996 .io_pullup_ena = 0x0,
997 .io_pulldn_ena = 0x0,
998 .io_open_drain_ena = 0x0,
999 .io_polarity = 0,
1000 .irq_summary = -1,
1001 },
1002};
1003
1004static struct epm_chan_properties ads_adc_channel_data[] = {
Yan Hec942e402012-08-31 11:14:58 -07001005 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
1006 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
1007 {10, 100}, {20, 100}, {500, 100}, {5, 100},
1008 {1000, 1}, {200, 100}, {50, 100}, {10, 100},
1009 {510, 100}, {50, 100}, {20, 100}, {100, 100},
1010 {510, 100}, {20, 100}, {50, 100}, {200, 100},
1011 {10, 100}, {20, 100}, {1000, 1}, {10, 100},
1012 {200, 100}, {510, 100}, {1000, 100}, {200, 100},
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08001013};
1014
1015static struct epm_adc_platform_data epm_adc_pdata = {
1016 .channel = ads_adc_channel_data,
1017 .bus_id = 0x0,
1018 .epm_i2c_board_info = {
1019 .type = "sx1509q",
1020 .addr = 0x3e,
1021 .platform_data = &apq8064_sx150x_data[SX150X_EPM],
1022 },
1023 .gpio_expander_base_addr = GPIO_EPM_EXPANDER_BASE,
1024};
1025
1026static struct platform_device epm_adc_device = {
1027 .name = "epm_adc",
1028 .id = -1,
1029 .dev = {
1030 .platform_data = &epm_adc_pdata,
1031 },
1032};
1033
1034static void __init apq8064_epm_adc_init(void)
1035{
1036 epm_adc_pdata.num_channels = 32;
1037 epm_adc_pdata.num_adc = 2;
1038 epm_adc_pdata.chan_per_adc = 16;
1039 epm_adc_pdata.chan_per_mux = 8;
1040};
1041
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001042/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1043 * 4 micbiases are used to power various analog and digital
1044 * microphones operating at 1800 mV. Technically, all micbiases
1045 * can source from single cfilter since all microphones operate
1046 * at the same voltage level. The arrangement below is to make
1047 * sure all cfilters are exercised. LDO_H regulator ouput level
1048 * does not need to be as high as 2.85V. It is choosen for
1049 * microphone sensitivity purpose.
1050 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301051static struct wcd9xxx_pdata apq8064_tabla_platform_data = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001052 .slimbus_slave_device = {
1053 .name = "tabla-slave",
1054 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1055 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001056 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001057 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301058 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001059 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1060 .micbias = {
1061 .ldoh_v = TABLA_LDOH_2P85_V,
1062 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001063 .cfilt2_mv = 2700,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001064 .cfilt3_mv = 1800,
1065 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1066 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1067 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1068 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301069 },
1070 .regulator = {
1071 {
1072 .name = "CDC_VDD_CP",
1073 .min_uV = 1800000,
1074 .max_uV = 1800000,
1075 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1076 },
1077 {
1078 .name = "CDC_VDDA_RX",
1079 .min_uV = 1800000,
1080 .max_uV = 1800000,
1081 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1082 },
1083 {
1084 .name = "CDC_VDDA_TX",
1085 .min_uV = 1800000,
1086 .max_uV = 1800000,
1087 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1088 },
1089 {
1090 .name = "VDDIO_CDC",
1091 .min_uV = 1800000,
1092 .max_uV = 1800000,
1093 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1094 },
1095 {
1096 .name = "VDDD_CDC_D",
1097 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001098 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301099 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1100 },
1101 {
1102 .name = "CDC_VDDA_A_1P2V",
1103 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001104 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301105 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1106 },
1107 },
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001108};
1109
1110static struct slim_device apq8064_slim_tabla = {
1111 .name = "tabla-slim",
1112 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1113 .dev = {
1114 .platform_data = &apq8064_tabla_platform_data,
1115 },
1116};
1117
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301118static struct wcd9xxx_pdata apq8064_tabla20_platform_data = {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001119 .slimbus_slave_device = {
1120 .name = "tabla-slave",
1121 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
1122 },
1123 .irq = MSM_GPIO_TO_INT(42),
1124 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301125 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001126 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1127 .micbias = {
1128 .ldoh_v = TABLA_LDOH_2P85_V,
1129 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001130 .cfilt2_mv = 2700,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001131 .cfilt3_mv = 1800,
1132 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1133 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1134 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1135 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301136 },
1137 .regulator = {
1138 {
1139 .name = "CDC_VDD_CP",
1140 .min_uV = 1800000,
1141 .max_uV = 1800000,
1142 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1143 },
1144 {
1145 .name = "CDC_VDDA_RX",
1146 .min_uV = 1800000,
1147 .max_uV = 1800000,
1148 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1149 },
1150 {
1151 .name = "CDC_VDDA_TX",
1152 .min_uV = 1800000,
1153 .max_uV = 1800000,
1154 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1155 },
1156 {
1157 .name = "VDDIO_CDC",
1158 .min_uV = 1800000,
1159 .max_uV = 1800000,
1160 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1161 },
1162 {
1163 .name = "VDDD_CDC_D",
1164 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001165 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301166 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1167 },
1168 {
1169 .name = "CDC_VDDA_A_1P2V",
1170 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001171 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301172 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1173 },
1174 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001175};
1176
1177static struct slim_device apq8064_slim_tabla20 = {
1178 .name = "tabla2x-slim",
1179 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1180 .dev = {
1181 .platform_data = &apq8064_tabla20_platform_data,
1182 },
1183};
1184
Santosh Mardi695be0d2012-04-10 23:21:12 +05301185/* enable the level shifter for cs8427 to make sure the I2C
1186 * clock is running at 100KHz and voltage levels are at 3.3
1187 * and 5 volts
1188 */
1189static int enable_100KHz_ls(int enable)
1190{
1191 int ret = 0;
1192 if (enable) {
1193 ret = gpio_request(SX150X_GPIO(1, 10),
1194 "cs8427_100KHZ_ENABLE");
1195 if (ret) {
1196 pr_err("%s: Failed to request gpio %d\n", __func__,
1197 SX150X_GPIO(1, 10));
1198 return ret;
1199 }
1200 gpio_direction_output(SX150X_GPIO(1, 10), 1);
Santosh Mardid706fcf2012-08-31 19:26:54 +05301201 } else {
1202 gpio_direction_output(SX150X_GPIO(1, 10), 0);
Santosh Mardi695be0d2012-04-10 23:21:12 +05301203 gpio_free(SX150X_GPIO(1, 10));
Santosh Mardid706fcf2012-08-31 19:26:54 +05301204 }
Santosh Mardi695be0d2012-04-10 23:21:12 +05301205 return ret;
1206}
1207
Santosh Mardieff9a742012-04-09 23:23:39 +05301208static struct cs8427_platform_data cs8427_i2c_platform_data = {
1209 .irq = SX150X_GPIO(1, 4),
1210 .reset_gpio = SX150X_GPIO(1, 6),
Santosh Mardi695be0d2012-04-10 23:21:12 +05301211 .enable = enable_100KHz_ls,
Santosh Mardieff9a742012-04-09 23:23:39 +05301212};
1213
1214static struct i2c_board_info cs8427_device_info[] __initdata = {
1215 {
1216 I2C_BOARD_INFO("cs8427", CS8427_ADDR4),
1217 .platform_data = &cs8427_i2c_platform_data,
1218 },
1219};
1220
Amy Maloche70090f992012-02-16 16:35:26 -08001221#define HAP_SHIFT_LVL_OE_GPIO PM8921_MPP_PM_TO_SYS(8)
1222#define ISA1200_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1223#define ISA1200_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
David Collins6f7c3472012-08-22 13:18:06 -07001224#define ISA1200_HAP_CLK_PM8921 PM8921_GPIO_PM_TO_SYS(44)
1225#define ISA1200_HAP_CLK_PM8917 PM8921_GPIO_PM_TO_SYS(38)
Amy Maloche70090f992012-02-16 16:35:26 -08001226
Mohan Pallaka2d877602012-05-11 13:07:30 +05301227static int isa1200_clk_enable(bool on)
Amy Maloche70090f992012-02-16 16:35:26 -08001228{
David Collins6f7c3472012-08-22 13:18:06 -07001229 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche8f973892012-03-26 14:53:13 -07001230 int rc = 0;
1231
David Collins6f7c3472012-08-22 13:18:06 -07001232 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1233 gpio = ISA1200_HAP_CLK_PM8917;
1234
1235 gpio_set_value_cansleep(gpio, on);
Amy Maloche70090f992012-02-16 16:35:26 -08001236
Mohan Pallaka2d877602012-05-11 13:07:30 +05301237 if (on) {
Amy Maloche8f973892012-03-26 14:53:13 -07001238 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_1, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301239 if (rc) {
1240 pr_err("%s: unable to write aux clock register(%d)\n",
1241 __func__, rc);
1242 goto err_gpio_dis;
1243 }
1244 } else {
Amy Maloche8f973892012-03-26 14:53:13 -07001245 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_NONE, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301246 if (rc)
1247 pr_err("%s: unable to write aux clock register(%d)\n",
1248 __func__, rc);
Amy Maloche8f973892012-03-26 14:53:13 -07001249 }
1250
1251 return rc;
Mohan Pallaka2d877602012-05-11 13:07:30 +05301252
1253err_gpio_dis:
David Collins6f7c3472012-08-22 13:18:06 -07001254 gpio_set_value_cansleep(gpio, !on);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301255 return rc;
Amy Maloche70090f992012-02-16 16:35:26 -08001256}
1257
1258static int isa1200_dev_setup(bool enable)
1259{
David Collins6f7c3472012-08-22 13:18:06 -07001260 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche70090f992012-02-16 16:35:26 -08001261 int rc = 0;
1262
David Collins6f7c3472012-08-22 13:18:06 -07001263 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1264 gpio = ISA1200_HAP_CLK_PM8917;
1265
Amy Maloche70090f992012-02-16 16:35:26 -08001266 if (!enable)
1267 goto free_gpio;
1268
David Collins6f7c3472012-08-22 13:18:06 -07001269 rc = gpio_request(gpio, "haptics_clk");
Amy Maloche70090f992012-02-16 16:35:26 -08001270 if (rc) {
1271 pr_err("%s: unable to request gpio %d config(%d)\n",
David Collins6f7c3472012-08-22 13:18:06 -07001272 __func__, gpio, rc);
Amy Maloche70090f992012-02-16 16:35:26 -08001273 return rc;
1274 }
1275
David Collins6f7c3472012-08-22 13:18:06 -07001276 rc = gpio_direction_output(gpio, 0);
Amy Maloche70090f992012-02-16 16:35:26 -08001277 if (rc) {
1278 pr_err("%s: unable to set direction\n", __func__);
1279 goto free_gpio;
1280 }
1281
1282 return 0;
1283
1284free_gpio:
David Collins6f7c3472012-08-22 13:18:06 -07001285 gpio_free(gpio);
Amy Maloche70090f992012-02-16 16:35:26 -08001286 return rc;
1287}
1288
1289static struct isa1200_regulator isa1200_reg_data[] = {
1290 {
1291 .name = "vddp",
1292 .min_uV = ISA_I2C_VTG_MIN_UV,
1293 .max_uV = ISA_I2C_VTG_MAX_UV,
1294 .load_uA = ISA_I2C_CURR_UA,
1295 },
1296};
1297
1298static struct isa1200_platform_data isa1200_1_pdata = {
1299 .name = "vibrator",
1300 .dev_setup = isa1200_dev_setup,
Mohan Pallaka2d877602012-05-11 13:07:30 +05301301 .clk_enable = isa1200_clk_enable,
Mohan Pallaka32f20a72012-06-14 14:41:11 +05301302 .need_pwm_clk = true,
Amy Maloche70090f992012-02-16 16:35:26 -08001303 .hap_en_gpio = ISA1200_HAP_EN_GPIO,
1304 .hap_len_gpio = ISA1200_HAP_LEN_GPIO,
1305 .max_timeout = 15000,
1306 .mode_ctrl = PWM_GEN_MODE,
1307 .pwm_fd = {
1308 .pwm_div = 256,
1309 },
1310 .is_erm = false,
1311 .smart_en = true,
1312 .ext_clk_en = true,
1313 .chip_en = 1,
1314 .regulator_info = isa1200_reg_data,
1315 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1316};
1317
1318static struct i2c_board_info isa1200_board_info[] __initdata = {
1319 {
1320 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1321 .platform_data = &isa1200_1_pdata,
1322 },
1323};
Jing Lin21ed4de2012-02-05 15:53:28 -08001324/* configuration data for mxt1386e using V2.1 firmware */
1325static const u8 mxt1386e_config_data_v2_1[] = {
1326 /* T6 Object */
1327 0, 0, 0, 0, 0, 0,
1328 /* T38 Object */
Jing Line4c47042012-08-31 10:54:44 -07001329 14, 3, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001330 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1331 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1332 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1333 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1334 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1335 0, 0, 0, 0,
1336 /* T7 Object */
Jing Line4c47042012-08-31 10:54:44 -07001337 32, 10, 50,
Jing Lin21ed4de2012-02-05 15:53:28 -08001338 /* T8 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001339 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001340 /* T9 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001341 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Line4c47042012-08-31 10:54:44 -07001342 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Linf1208fd2012-02-23 11:15:42 -08001343 85, 5, 0, 5, 9, 5, 12, 35, 70, 40,
1344 20, 5, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001345 /* T18 Object */
1346 0, 0,
1347 /* T24 Object */
1348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1349 0, 0, 0, 0, 0, 0, 0, 0, 0,
1350 /* T25 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001351 1, 0, 60, 115, 156, 99,
Jing Lin21ed4de2012-02-05 15:53:28 -08001352 /* T27 Object */
1353 0, 0, 0, 0, 0, 0, 0,
1354 /* T40 Object */
1355 0, 0, 0, 0, 0,
1356 /* T42 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001357 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001358 /* T43 Object */
1359 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
1360 16,
1361 /* T46 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001362 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001363 /* T47 Object */
1364 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
1365 /* T48 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001366 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001367 32, 40, 0, 10, 10, 0, 0, 100, 10, 90,
1368 0, 0, 0, 0, 0, 0, 0, 10, 1, 10,
1369 52, 10, 12, 0, 33, 0, 1, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1371 0, 0, 0, 0,
1372 /* T56 Object */
1373 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1374 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1378 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001379};
1380
1381#define MXT_TS_GPIO_IRQ 6
1382#define MXT_TS_PWR_EN_GPIO PM8921_GPIO_PM_TO_SYS(23)
1383#define MXT_TS_RESET_GPIO 33
1384
1385static struct mxt_config_info mxt_config_array[] = {
1386 {
1387 .config = mxt1386e_config_data_v2_1,
1388 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1389 .family_id = 0xA0,
1390 .variant_id = 0x7,
1391 .version = 0x21,
1392 .build = 0xAA,
Jing Linef4aa9b2012-03-26 12:01:41 -07001393 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
1394 .fw_name = "atmel_8064_liquid_v2_2_AA.hex",
1395 },
1396 {
1397 /* The config data for V2.2.AA is the same as for V2.1.AA */
1398 .config = mxt1386e_config_data_v2_1,
1399 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1400 .family_id = 0xA0,
1401 .variant_id = 0x7,
1402 .version = 0x22,
1403 .build = 0xAA,
1404 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin21ed4de2012-02-05 15:53:28 -08001405 },
1406};
1407
1408static struct mxt_platform_data mxt_platform_data = {
1409 .config_array = mxt_config_array,
1410 .config_array_size = ARRAY_SIZE(mxt_config_array),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08001411 .panel_minx = 0,
1412 .panel_maxx = 1365,
1413 .panel_miny = 0,
1414 .panel_maxy = 767,
1415 .disp_minx = 0,
1416 .disp_maxx = 1365,
1417 .disp_miny = 0,
1418 .disp_maxy = 767,
Anirudh Ghayal39dbe3f2012-04-13 15:43:16 +05301419 .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Jing Lin21ed4de2012-02-05 15:53:28 -08001420 .i2c_pull_up = true,
1421 .reset_gpio = MXT_TS_RESET_GPIO,
1422 .irq_gpio = MXT_TS_GPIO_IRQ,
1423};
1424
1425static struct i2c_board_info mxt_device_info[] __initdata = {
1426 {
1427 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
1428 .platform_data = &mxt_platform_data,
1429 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1430 },
1431};
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001432#define CYTTSP_TS_GPIO_IRQ 6
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001433#define CYTTSP_TS_GPIO_SLEEP 33
Amy Maloche609bb5e2012-08-03 09:41:42 -07001434#define CYTTSP_TS_GPIO_SLEEP_ALT 12
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001435
1436static ssize_t tma340_vkeys_show(struct kobject *kobj,
1437 struct kobj_attribute *attr, char *buf)
1438{
1439 return snprintf(buf, 200,
1440 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1441 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1442 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1443 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1444 "\n");
1445}
1446
1447static struct kobj_attribute tma340_vkeys_attr = {
1448 .attr = {
1449 .mode = S_IRUGO,
1450 },
1451 .show = &tma340_vkeys_show,
1452};
1453
1454static struct attribute *tma340_properties_attrs[] = {
1455 &tma340_vkeys_attr.attr,
1456 NULL
1457};
1458
1459static struct attribute_group tma340_properties_attr_group = {
1460 .attrs = tma340_properties_attrs,
1461};
1462
1463static int cyttsp_platform_init(struct i2c_client *client)
1464{
1465 int rc = 0;
1466 static struct kobject *tma340_properties_kobj;
1467
1468 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1469 tma340_properties_kobj = kobject_create_and_add("board_properties",
1470 NULL);
1471 if (tma340_properties_kobj)
1472 rc = sysfs_create_group(tma340_properties_kobj,
1473 &tma340_properties_attr_group);
1474 if (!tma340_properties_kobj || rc)
1475 pr_err("%s: failed to create board_properties\n",
1476 __func__);
1477
1478 return 0;
1479}
1480
1481static struct cyttsp_regulator cyttsp_regulator_data[] = {
1482 {
1483 .name = "vdd",
1484 .min_uV = CY_TMA300_VTG_MIN_UV,
1485 .max_uV = CY_TMA300_VTG_MAX_UV,
1486 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1487 .lpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1488 },
1489 {
1490 .name = "vcc_i2c",
1491 .min_uV = CY_I2C_VTG_MIN_UV,
1492 .max_uV = CY_I2C_VTG_MAX_UV,
1493 .hpm_load_uA = CY_I2C_CURR_UA,
1494 .lpm_load_uA = CY_I2C_CURR_UA,
1495 },
1496};
1497
1498static struct cyttsp_platform_data cyttsp_pdata = {
1499 .panel_maxx = 634,
1500 .panel_maxy = 1166,
1501 .disp_maxx = 599,
1502 .disp_maxy = 1023,
1503 .disp_minx = 0,
1504 .disp_miny = 0,
1505 .flags = 0x01,
1506 .gen = CY_GEN3,
1507 .use_st = CY_USE_ST,
1508 .use_mt = CY_USE_MT,
1509 .use_hndshk = CY_SEND_HNDSHK,
1510 .use_trk_id = CY_USE_TRACKING_ID,
1511 .use_sleep = CY_USE_DEEP_SLEEP_SEL,
1512 .use_gestures = CY_USE_GESTURES,
1513 .fw_fname = "cyttsp_8064_mtp.hex",
1514 /* change act_intrvl to customize the Active power state
1515 * scanning/processing refresh interval for Operating mode
1516 */
1517 .act_intrvl = CY_ACT_INTRVL_DFLT,
1518 /* change tch_tmout to customize the touch timeout for the
1519 * Active power state for Operating mode
1520 */
1521 .tch_tmout = CY_TCH_TMOUT_DFLT,
1522 /* change lp_intrvl to customize the Low Power power state
1523 * scanning/processing refresh interval for Operating mode
1524 */
1525 .lp_intrvl = CY_LP_INTRVL_DFLT,
1526 .sleep_gpio = CYTTSP_TS_GPIO_SLEEP,
Amy Maloche9ba3ffe2012-04-26 10:31:20 -07001527 .resout_gpio = -1,
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001528 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1529 .regulator_info = cyttsp_regulator_data,
1530 .num_regulators = ARRAY_SIZE(cyttsp_regulator_data),
1531 .init = cyttsp_platform_init,
1532 .correct_fw_ver = 17,
1533};
1534
1535static struct i2c_board_info cyttsp_info[] __initdata = {
1536 {
1537 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1538 .platform_data = &cyttsp_pdata,
1539 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1540 },
1541};
Jing Lin21ed4de2012-02-05 15:53:28 -08001542
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08001543#define MSM_WCNSS_PHYS 0x03000000
1544#define MSM_WCNSS_SIZE 0x280000
1545
1546static struct resource resources_wcnss_wlan[] = {
1547 {
1548 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1549 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1550 .name = "wcnss_wlanrx_irq",
1551 .flags = IORESOURCE_IRQ,
1552 },
1553 {
1554 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1555 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1556 .name = "wcnss_wlantx_irq",
1557 .flags = IORESOURCE_IRQ,
1558 },
1559 {
1560 .start = MSM_WCNSS_PHYS,
1561 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1562 .name = "wcnss_mmio",
1563 .flags = IORESOURCE_MEM,
1564 },
1565 {
1566 .start = 64,
1567 .end = 68,
1568 .name = "wcnss_gpios_5wire",
1569 .flags = IORESOURCE_IO,
1570 },
1571};
1572
1573static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1574 .has_48mhz_xo = 1,
1575};
1576
1577static struct platform_device msm_device_wcnss_wlan = {
1578 .name = "wcnss_wlan",
1579 .id = 0,
1580 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1581 .resource = resources_wcnss_wlan,
1582 .dev = {.platform_data = &qcom_wcnss_pdata},
1583};
1584
Ankit Vermab7c26e62012-02-28 15:04:15 -08001585static struct platform_device msm_device_iris_fm __devinitdata = {
1586 .name = "iris_fm",
1587 .id = -1,
1588};
1589
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001590#ifdef CONFIG_QSEECOM
1591/* qseecom bus scaling */
1592static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1593 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001594 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001595 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001596 .ab = 0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001597 .ib = 0,
1598 },
1599 {
1600 .src = MSM_BUS_MASTER_ADM_PORT1,
1601 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1602 .ab = 0,
1603 .ib = 0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001604 },
1605 {
1606 .src = MSM_BUS_MASTER_SPDM,
1607 .dst = MSM_BUS_SLAVE_SPDM,
1608 .ib = 0,
1609 .ab = 0,
1610 },
1611};
1612
1613static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1614 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001615 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001616 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001617 .ab = 70000000UL,
1618 .ib = 70000000UL,
1619 },
1620 {
1621 .src = MSM_BUS_MASTER_ADM_PORT1,
1622 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1623 .ab = 2480000000UL,
1624 .ib = 2480000000UL,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001625 },
1626 {
1627 .src = MSM_BUS_MASTER_SPDM,
1628 .dst = MSM_BUS_SLAVE_SPDM,
1629 .ib = 0,
1630 .ab = 0,
1631 },
1632};
1633
1634static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1635 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001636 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001637 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001638 .ab = 0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001639 .ib = 0,
1640 },
1641 {
1642 .src = MSM_BUS_MASTER_ADM_PORT1,
1643 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1644 .ab = 0,
1645 .ib = 0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001646 },
1647 {
1648 .src = MSM_BUS_MASTER_SPDM,
1649 .dst = MSM_BUS_SLAVE_SPDM,
1650 .ib = (64 * 8) * 1000000UL,
1651 .ab = (64 * 8) * 100000UL,
1652 },
1653};
1654
1655static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1656 {
1657 ARRAY_SIZE(qseecom_clks_init_vectors),
1658 qseecom_clks_init_vectors,
1659 },
1660 {
1661 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001662 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001663 },
1664 {
1665 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1666 qseecom_enable_sfpb_vectors,
1667 },
1668};
1669
1670static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1671 qseecom_hw_bus_scale_usecases,
1672 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1673 .name = "qsee",
1674};
1675
1676static struct platform_device qseecom_device = {
1677 .name = "qseecom",
1678 .id = 0,
1679 .dev = {
1680 .platform_data = &qseecom_bus_pdata,
1681 },
1682};
1683#endif
1684
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001685#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1686 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1687 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1688 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1689
1690#define QCE_SIZE 0x10000
1691#define QCE_0_BASE 0x11000000
1692
1693#define QCE_HW_KEY_SUPPORT 0
1694#define QCE_SHA_HMAC_SUPPORT 1
1695#define QCE_SHARE_CE_RESOURCE 3
1696#define QCE_CE_SHARED 0
1697
1698static struct resource qcrypto_resources[] = {
1699 [0] = {
1700 .start = QCE_0_BASE,
1701 .end = QCE_0_BASE + QCE_SIZE - 1,
1702 .flags = IORESOURCE_MEM,
1703 },
1704 [1] = {
1705 .name = "crypto_channels",
1706 .start = DMOV8064_CE_IN_CHAN,
1707 .end = DMOV8064_CE_OUT_CHAN,
1708 .flags = IORESOURCE_DMA,
1709 },
1710 [2] = {
1711 .name = "crypto_crci_in",
1712 .start = DMOV8064_CE_IN_CRCI,
1713 .end = DMOV8064_CE_IN_CRCI,
1714 .flags = IORESOURCE_DMA,
1715 },
1716 [3] = {
1717 .name = "crypto_crci_out",
1718 .start = DMOV8064_CE_OUT_CRCI,
1719 .end = DMOV8064_CE_OUT_CRCI,
1720 .flags = IORESOURCE_DMA,
1721 },
1722};
1723
1724static struct resource qcedev_resources[] = {
1725 [0] = {
1726 .start = QCE_0_BASE,
1727 .end = QCE_0_BASE + QCE_SIZE - 1,
1728 .flags = IORESOURCE_MEM,
1729 },
1730 [1] = {
1731 .name = "crypto_channels",
1732 .start = DMOV8064_CE_IN_CHAN,
1733 .end = DMOV8064_CE_OUT_CHAN,
1734 .flags = IORESOURCE_DMA,
1735 },
1736 [2] = {
1737 .name = "crypto_crci_in",
1738 .start = DMOV8064_CE_IN_CRCI,
1739 .end = DMOV8064_CE_IN_CRCI,
1740 .flags = IORESOURCE_DMA,
1741 },
1742 [3] = {
1743 .name = "crypto_crci_out",
1744 .start = DMOV8064_CE_OUT_CRCI,
1745 .end = DMOV8064_CE_OUT_CRCI,
1746 .flags = IORESOURCE_DMA,
1747 },
1748};
1749
1750#endif
1751
1752#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1753 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1754
1755static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1756 .ce_shared = QCE_CE_SHARED,
1757 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1758 .hw_key_support = QCE_HW_KEY_SUPPORT,
1759 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001760 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001761};
1762
1763static struct platform_device qcrypto_device = {
1764 .name = "qcrypto",
1765 .id = 0,
1766 .num_resources = ARRAY_SIZE(qcrypto_resources),
1767 .resource = qcrypto_resources,
1768 .dev = {
1769 .coherent_dma_mask = DMA_BIT_MASK(32),
1770 .platform_data = &qcrypto_ce_hw_suppport,
1771 },
1772};
1773#endif
1774
1775#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1776 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1777
1778static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1779 .ce_shared = QCE_CE_SHARED,
1780 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1781 .hw_key_support = QCE_HW_KEY_SUPPORT,
1782 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001783 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001784};
1785
1786static struct platform_device qcedev_device = {
1787 .name = "qce",
1788 .id = 0,
1789 .num_resources = ARRAY_SIZE(qcedev_resources),
1790 .resource = qcedev_resources,
1791 .dev = {
1792 .coherent_dma_mask = DMA_BIT_MASK(32),
1793 .platform_data = &qcedev_ce_hw_suppport,
1794 },
1795};
1796#endif
1797
Joel Kingef390842012-05-23 16:42:48 -07001798static struct mdm_vddmin_resource mdm_vddmin_rscs = {
1799 .rpm_id = MSM_RPM_ID_VDDMIN_GPIO,
1800 .ap2mdm_vddmin_gpio = 30,
1801 .modes = 0x03,
1802 .drive_strength = 8,
1803 .mdm2ap_vddmin_gpio = 80,
1804};
1805
Joel King269aa602012-07-23 08:07:35 -07001806static struct gpiomux_setting mdm2ap_status_gpio_run_cfg = {
1807 .func = GPIOMUX_FUNC_GPIO,
1808 .drv = GPIOMUX_DRV_8MA,
1809 .pull = GPIOMUX_PULL_NONE,
1810};
1811
Joel Kingdacbc822012-01-25 13:30:57 -08001812static struct mdm_platform_data mdm_platform_data = {
1813 .mdm_version = "3.0",
1814 .ramdump_delay_ms = 2000,
Joel King14fe7fa2012-05-27 14:26:11 -07001815 .early_power_on = 1,
1816 .sfr_query = 1,
Joel Kingef390842012-05-23 16:42:48 -07001817 .vddmin_resource = &mdm_vddmin_rscs,
Hemant Kumara945b472012-01-25 15:08:06 -08001818 .peripheral_platform_device = &apq8064_device_hsic_host,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001819 .ramdump_timeout_ms = 120000,
Joel King269aa602012-07-23 08:07:35 -07001820 .mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
Joel Kingdacbc822012-01-25 13:30:57 -08001821};
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001822
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08001823static struct tsens_platform_data apq_tsens_pdata = {
1824 .tsens_factor = 1000,
1825 .hw_type = APQ_8064,
1826 .tsens_num_sensor = 11,
1827 .slope = {1176, 1176, 1154, 1176, 1111,
1828 1132, 1132, 1199, 1132, 1199, 1132},
1829};
1830
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07001831static struct platform_device msm_tsens_device = {
1832 .name = "tsens8960-tm",
1833 .id = -1,
1834};
1835
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001836static struct msm_thermal_data msm_thermal_pdata = {
1837 .sensor_id = 7,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06001838 .poll_ms = 250,
1839 .limit_temp_degC = 60,
1840 .temp_hysteresis_degC = 10,
1841 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001842};
1843
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001844#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001845static void __init apq8064_map_io(void)
1846{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001847 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001848 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001849 if (socinfo_init() < 0)
1850 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001851}
1852
1853static void __init apq8064_init_irq(void)
1854{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001855 struct msm_mpm_device_data *data = NULL;
1856
1857#ifdef CONFIG_MSM_MPM
1858 data = &apq8064_mpm_dev_data;
1859#endif
1860
1861 msm_mpm_irq_extn_init(data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
1863 (void *)MSM_QGIC_CPU_BASE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001864}
1865
Jay Chokshi7805b5a2011-11-07 15:55:30 -08001866static struct platform_device msm8064_device_saw_regulator_core0 = {
1867 .name = "saw-regulator",
1868 .id = 0,
1869 .dev = {
1870 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
1871 },
1872};
1873
1874static struct platform_device msm8064_device_saw_regulator_core1 = {
1875 .name = "saw-regulator",
1876 .id = 1,
1877 .dev = {
1878 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
1879 },
1880};
1881
1882static struct platform_device msm8064_device_saw_regulator_core2 = {
1883 .name = "saw-regulator",
1884 .id = 2,
1885 .dev = {
1886 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
1887 },
1888};
1889
1890static struct platform_device msm8064_device_saw_regulator_core3 = {
1891 .name = "saw-regulator",
1892 .id = 3,
1893 .dev = {
1894 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001895
1896 },
1897};
1898
Oluwafemi Adeyemif5a31422012-03-08 16:58:45 -08001899static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001900 {
1901 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1902 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1903 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001904 1, 784, 180000, 100,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001905 },
1906
1907 {
Anji Jonnala85b29ff2013-01-15 14:12:45 +05301908 MSM_PM_SLEEP_MODE_RETENTION,
1909 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1910 true,
1911 415, 715, 340827, 475,
1912 },
1913
1914 {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001915 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1916 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1917 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001918 1300, 228, 1200000, 2000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001919 },
1920
1921 {
1922 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1923 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
1924 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001925 2000, 138, 1208400, 3200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001926 },
1927
1928 {
1929 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Praveen Chidambarame3380672012-02-08 10:32:27 -07001930 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
1931 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001932 6000, 119, 1850300, 9000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001933 },
1934
1935 {
1936 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1937 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
1938 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001939 9200, 68, 2839200, 16400,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001940 },
1941
1942 {
1943 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1944 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
1945 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001946 10300, 63, 3128000, 18200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001947 },
1948
1949 {
1950 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1951 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
1952 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001953 18000, 10, 4602600, 27000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001954 },
1955
1956 {
1957 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1958 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
1959 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001960 20000, 2, 5752000, 32000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001961 },
1962};
1963
1964static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1965 .mode = MSM_PM_BOOT_CONFIG_TZ,
1966};
1967
1968static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
1969 .levels = &msm_rpmrs_levels[0],
1970 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
1971 .vdd_mem_levels = {
1972 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
1973 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
1974 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
1975 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
1976 },
1977 .vdd_dig_levels = {
1978 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
1979 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
1980 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
1981 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
1982 },
1983 .vdd_mask = 0x7FFFFF,
1984 .rpmrs_target_id = {
1985 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
1986 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
1987 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
1988 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
1989 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
1990 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
1991 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
1992 },
1993};
1994
Praveen Chidambaram78499012011-11-01 17:15:17 -06001995static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1996 0x03, 0x0f,
1997};
1998
1999static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2000 0x00, 0x24, 0x54, 0x10,
2001 0x09, 0x03, 0x01,
2002 0x10, 0x54, 0x30, 0x0C,
2003 0x24, 0x30, 0x0f,
2004};
2005
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302006static uint8_t spm_retention_cmd_sequence[] __initdata = {
2007 0x00, 0x05, 0x03, 0x0D,
2008 0x0B, 0x00, 0x0f,
2009};
2010
Praveen Chidambaram78499012011-11-01 17:15:17 -06002011static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2012 0x00, 0x24, 0x54, 0x10,
2013 0x09, 0x07, 0x01, 0x0B,
2014 0x10, 0x54, 0x30, 0x0C,
2015 0x24, 0x30, 0x0f,
2016};
2017
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302018static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
2019 [0] = {
2020 .mode = MSM_SPM_MODE_CLOCK_GATING,
2021 .notify_rpm = false,
2022 .cmd = spm_wfi_cmd_sequence,
2023 },
2024 [1] = {
2025 .mode = MSM_SPM_MODE_POWER_RETENTION,
2026 .notify_rpm = false,
2027 .cmd = spm_retention_cmd_sequence,
2028 },
2029 [2] = {
2030 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2031 .notify_rpm = false,
2032 .cmd = spm_power_collapse_without_rpm,
2033 },
2034 [3] = {
2035 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2036 .notify_rpm = true,
2037 .cmd = spm_power_collapse_with_rpm,
2038 },
2039};
2040static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06002041 [0] = {
2042 .mode = MSM_SPM_MODE_CLOCK_GATING,
2043 .notify_rpm = false,
2044 .cmd = spm_wfi_cmd_sequence,
2045 },
2046 [1] = {
2047 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2048 .notify_rpm = false,
2049 .cmd = spm_power_collapse_without_rpm,
2050 },
2051 [2] = {
2052 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2053 .notify_rpm = true,
2054 .cmd = spm_power_collapse_with_rpm,
2055 },
2056};
2057
2058static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2059 0x00, 0x20, 0x03, 0x20,
2060 0x00, 0x0f,
2061};
2062
2063static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2064 0x00, 0x20, 0x34, 0x64,
2065 0x48, 0x07, 0x48, 0x20,
2066 0x50, 0x64, 0x04, 0x34,
2067 0x50, 0x0f,
2068};
2069static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2070 0x00, 0x10, 0x34, 0x64,
2071 0x48, 0x07, 0x48, 0x10,
2072 0x50, 0x64, 0x04, 0x34,
2073 0x50, 0x0F,
2074};
2075
2076static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2077 [0] = {
2078 .mode = MSM_SPM_L2_MODE_RETENTION,
2079 .notify_rpm = false,
2080 .cmd = l2_spm_wfi_cmd_sequence,
2081 },
2082 [1] = {
2083 .mode = MSM_SPM_L2_MODE_GDHS,
2084 .notify_rpm = true,
2085 .cmd = l2_spm_gdhs_cmd_sequence,
2086 },
2087 [2] = {
2088 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2089 .notify_rpm = true,
2090 .cmd = l2_spm_power_off_cmd_sequence,
2091 },
2092};
2093
2094
2095static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2096 [0] = {
2097 .reg_base_addr = MSM_SAW_L2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002098 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002099 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002100 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2101 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2102 .modes = msm_spm_l2_seq_list,
2103 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2104 },
2105};
2106
2107static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2108 [0] = {
2109 .reg_base_addr = MSM_SAW0_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002110 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002111#if defined(CONFIG_MSM_AVS_HW)
2112 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2113 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2114#endif
2115 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302116 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
2117 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
2118 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002119 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302120 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
2121 .modes = msm_spm_boot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002122 },
2123 [1] = {
2124 .reg_base_addr = MSM_SAW1_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002125 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002126#if defined(CONFIG_MSM_AVS_HW)
2127 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2128 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2129#endif
2130 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
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] = 0x0060009C,
2133 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2134 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302135 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2136 .modes = msm_spm_nonboot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002137 },
2138 [2] = {
2139 .reg_base_addr = MSM_SAW2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002140 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002141#if defined(CONFIG_MSM_AVS_HW)
2142 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2143 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2144#endif
2145 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002146 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002147 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2148 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2149 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302150 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2151 .modes = msm_spm_nonboot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002152 },
2153 [3] = {
2154 .reg_base_addr = MSM_SAW3_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002155 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002156#if defined(CONFIG_MSM_AVS_HW)
2157 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2158 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2159#endif
2160 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002161 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002162 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2163 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2164 .vctl_timeout_us = 50,
Anji Jonnala85b29ff2013-01-15 14:12:45 +05302165 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2166 .modes = msm_spm_nonboot_cpu_seq_list,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002167 },
2168};
2169
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002170static void __init apq8064_init_buses(void)
2171{
2172 msm_bus_rpm_set_mt_mask();
2173 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
2174 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
2175 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
2176 msm_bus_8064_apps_fabric.dev.platform_data =
2177 &msm_bus_8064_apps_fabric_pdata;
2178 msm_bus_8064_sys_fabric.dev.platform_data =
2179 &msm_bus_8064_sys_fabric_pdata;
2180 msm_bus_8064_mm_fabric.dev.platform_data =
2181 &msm_bus_8064_mm_fabric_pdata;
2182 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
2183 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
2184}
2185
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002186/* PCIe gpios */
2187static struct msm_pcie_gpio_info_t msm_pcie_gpio_info[MSM_PCIE_MAX_GPIO] = {
2188 {"rst_n", PM8921_MPP_PM_TO_SYS(PCIE_RST_N_PMIC_MPP), 0},
2189 {"pwr_en", PM8921_GPIO_PM_TO_SYS(PCIE_PWR_EN_PMIC_GPIO), 1},
2190};
2191
2192static struct msm_pcie_platform msm_pcie_platform_data = {
2193 .gpio = msm_pcie_gpio_info,
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -06002194 .axi_addr = PCIE_AXI_BAR_PHYS,
2195 .axi_size = PCIE_AXI_BAR_SIZE,
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -06002196 .wake_n = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PCIE_WAKE_N_PMIC_GPIO),
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002197};
2198
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002199static int __init mpq8064_pcie_enabled(void)
2200{
2201 return !((readl_relaxed(QFPROM_RAW_FEAT_CONFIG_ROW0_MSB) & BIT(21)) ||
2202 (readl_relaxed(QFPROM_RAW_OEM_CONFIG_ROW0_LSB) & BIT(4)));
2203}
2204
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002205static void __init mpq8064_pcie_init(void)
2206{
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002207 if (mpq8064_pcie_enabled()) {
2208 msm_device_pcie.dev.platform_data = &msm_pcie_platform_data;
2209 platform_device_register(&msm_device_pcie);
2210 }
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002211}
2212
David Collinsf0d00732012-01-25 15:46:50 -08002213static struct platform_device apq8064_device_ext_5v_vreg __devinitdata = {
2214 .name = GPIO_REGULATOR_DEV_NAME,
2215 .id = PM8921_MPP_PM_TO_SYS(7),
2216 .dev = {
2217 .platform_data
2218 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2219 },
2220};
2221
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002222static struct platform_device apq8064_device_ext_mpp8_vreg __devinitdata = {
2223 .name = GPIO_REGULATOR_DEV_NAME,
2224 .id = PM8921_MPP_PM_TO_SYS(8),
2225 .dev = {
2226 .platform_data
2227 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_MPP8],
2228 },
2229};
2230
David Collinsf0d00732012-01-25 15:46:50 -08002231static struct platform_device apq8064_device_ext_3p3v_vreg __devinitdata = {
2232 .name = GPIO_REGULATOR_DEV_NAME,
2233 .id = APQ8064_EXT_3P3V_REG_EN_GPIO,
2234 .dev = {
2235 .platform_data =
2236 &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2237 },
2238};
2239
David Collins390fc332012-02-07 14:38:16 -08002240static struct platform_device apq8064_device_ext_ts_sw_vreg __devinitdata = {
2241 .name = GPIO_REGULATOR_DEV_NAME,
2242 .id = PM8921_GPIO_PM_TO_SYS(23),
2243 .dev = {
2244 .platform_data
2245 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_TS_SW],
2246 },
2247};
2248
David Collins2782b5c2012-02-06 10:02:42 -08002249static struct platform_device apq8064_device_rpm_regulator __devinitdata = {
2250 .name = "rpm-regulator",
David Collins36199252012-08-21 15:43:02 -07002251 .id = 0,
David Collins2782b5c2012-02-06 10:02:42 -08002252 .dev = {
2253 .platform_data = &apq8064_rpm_regulator_pdata,
2254 },
2255};
2256
David Collins36199252012-08-21 15:43:02 -07002257static struct platform_device
2258apq8064_pm8921_device_rpm_regulator __devinitdata = {
2259 .name = "rpm-regulator",
2260 .id = 1,
2261 .dev = {
2262 .platform_data = &apq8064_rpm_regulator_pm8921_pdata,
2263 },
2264};
2265
Ravi Kumar V05931a22012-04-04 17:09:37 +05302266static struct gpio_ir_recv_platform_data gpio_ir_recv_pdata = {
2267 .gpio_nr = 88,
2268 .active_low = 1,
2269};
2270
2271static struct platform_device gpio_ir_recv_pdev = {
2272 .name = "gpio-rc-recv",
2273 .dev = {
2274 .platform_data = &gpio_ir_recv_pdata,
2275 },
2276};
2277
Terence Hampson36b70722012-05-10 13:18:16 -04002278static struct platform_device *common_not_mpq_devices[] __initdata = {
David Keitel3c40fc52012-02-09 17:53:52 -08002279 &apq8064_device_qup_i2c_gsbi1,
Jing Lin04601f92012-02-05 15:36:07 -08002280 &apq8064_device_qup_i2c_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002281 &apq8064_device_qup_i2c_gsbi4,
Terence Hampson36b70722012-05-10 13:18:16 -04002282};
2283
David Collins36199252012-08-21 15:43:02 -07002284static struct platform_device *early_common_devices[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -07002285 &apq8064_device_acpuclk,
Terence Hampson36b70722012-05-10 13:18:16 -04002286 &apq8064_device_dmov,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002287 &apq8064_device_qup_spi_gsbi5,
David Collins36199252012-08-21 15:43:02 -07002288};
2289
2290static struct platform_device *pm8921_common_devices[] __initdata = {
David Collinsf0d00732012-01-25 15:46:50 -08002291 &apq8064_device_ext_5v_vreg,
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002292 &apq8064_device_ext_mpp8_vreg,
David Collinsf0d00732012-01-25 15:46:50 -08002293 &apq8064_device_ext_3p3v_vreg,
Jay Chokshi9c25f072011-09-23 18:19:15 -07002294 &apq8064_device_ssbi_pmic1,
2295 &apq8064_device_ssbi_pmic2,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002296 &apq8064_device_ext_ts_sw_vreg,
David Collins36199252012-08-21 15:43:02 -07002297};
2298
2299static struct platform_device *pm8917_common_devices[] __initdata = {
2300 &apq8064_device_ext_mpp8_vreg,
2301 &apq8064_device_ext_3p3v_vreg,
2302 &apq8064_device_ssbi_pmic1,
2303 &apq8064_device_ssbi_pmic2,
2304 &apq8064_device_ext_ts_sw_vreg,
2305};
2306
2307static struct platform_device *common_devices[] __initdata = {
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06002308 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -07002309 &apq8064_device_otg,
2310 &apq8064_device_gadget_peripheral,
Hemant Kumard86c4882012-01-24 19:39:37 -08002311 &apq8064_device_hsusb_host,
Hemant Kumar4933b072011-10-17 23:43:11 -07002312 &android_usb_device,
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08002313 &msm_device_wcnss_wlan,
Ankit Vermab7c26e62012-02-28 15:04:15 -08002314 &msm_device_iris_fm,
Larry Bassel67b921d2012-04-06 10:23:27 -07002315 &apq8064_fmem_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002316#ifdef CONFIG_ANDROID_PMEM
2317#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002318 &apq8064_android_pmem_device,
2319 &apq8064_android_pmem_adsp_device,
2320 &apq8064_android_pmem_audio_device,
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002321#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2322#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -08002323#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002324 &apq8064_ion_dev,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002325#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002326 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002327 &msm8064_device_saw_regulator_core0,
2328 &msm8064_device_saw_regulator_core1,
2329 &msm8064_device_saw_regulator_core2,
2330 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002331#if defined(CONFIG_QSEECOM)
2332 &qseecom_device,
2333#endif
2334
Joel Nider6b9a7bc2012-06-26 11:19:19 +03002335 &msm_8064_device_tsif[0],
2336 &msm_8064_device_tsif[1],
2337
Ramesh Masavarapu28311912011-10-27 11:04:12 -07002338#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2339 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2340 &qcrypto_device,
2341#endif
2342
2343#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2344 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2345 &qcedev_device,
2346#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07002347
2348#ifdef CONFIG_HW_RANDOM_MSM
2349 &apq8064_device_rng,
2350#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002351 &apq_pcm,
2352 &apq_pcm_routing,
2353 &apq_cpudai0,
2354 &apq_cpudai1,
Santosh Mardieff9a742012-04-09 23:23:39 +05302355 &mpq_cpudai_sec_i2s_rx,
Kuirong Wangf23f8c52012-03-31 12:34:51 -07002356 &mpq_cpudai_mi2s_tx,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002357 &apq_cpudai_hdmi_rx,
2358 &apq_cpudai_bt_rx,
2359 &apq_cpudai_bt_tx,
2360 &apq_cpudai_fm_rx,
2361 &apq_cpudai_fm_tx,
2362 &apq_cpu_fe,
2363 &apq_stub_codec,
2364 &apq_voice,
2365 &apq_voip,
2366 &apq_lpa_pcm,
Krishnankutty Kolathappilly4374e332012-03-18 22:27:30 -07002367 &apq_compr_dsp,
2368 &apq_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002369 &apq_lowlatency_pcm,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002370 &apq_pcm_hostless,
2371 &apq_cpudai_afe_01_rx,
2372 &apq_cpudai_afe_01_tx,
2373 &apq_cpudai_afe_02_rx,
2374 &apq_cpudai_afe_02_tx,
2375 &apq_pcm_afe,
2376 &apq_cpudai_auxpcm_rx,
2377 &apq_cpudai_auxpcm_tx,
Neema Shetty8427c262012-02-16 11:23:43 -08002378 &apq_cpudai_stub,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002379 &apq_cpudai_slimbus_1_rx,
2380 &apq_cpudai_slimbus_1_tx,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002381 &apq_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002382 &apq_cpudai_slimbus_2_tx,
Neema Shettyc9d86c32012-05-09 12:01:39 -07002383 &apq_cpudai_slimbus_3_rx,
Helen Zeng38c3c962012-05-17 14:56:20 -07002384 &apq_cpudai_slimbus_3_tx,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002385 &apq8064_rpm_device,
2386 &apq8064_rpm_log_device,
2387 &apq8064_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302388 &apq8064_rpm_master_stat_device,
Ramesh Masavarapuf31ff242012-05-10 18:55:21 -07002389 &apq_device_tz_log,
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002390 &msm_bus_8064_apps_fabric,
2391 &msm_bus_8064_sys_fabric,
2392 &msm_bus_8064_mm_fabric,
2393 &msm_bus_8064_sys_fpb,
2394 &msm_bus_8064_cpss_fpb,
Mohan Kumar Gubbihalli Lachma Naik7f72edd2012-02-06 17:26:47 -08002395 &apq8064_msm_device_vidc,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002396 &msm_pil_dsps,
Matt Wagantallb94b9a52012-02-02 21:59:54 -08002397 &msm_8960_q6_lpass,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002398 &msm_pil_vidc,
Matt Wagantall292aace2012-01-26 19:12:34 -08002399 &msm_gss,
Laura Abbottb93525f2012-04-12 09:57:19 -07002400 &apq8064_rtb_device,
Steve Mucklea9aac292012-11-02 15:41:00 -07002401 &apq8064_dcvs_device,
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07002402 &apq8064_msm_gov_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002403 &apq8064_device_cache_erp,
Stepan Moskovchenko0f3de112012-06-08 18:11:46 -07002404 &msm8960_device_ebi1_ch0_erp,
2405 &msm8960_device_ebi1_ch1_erp,
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002406 &epm_adc_device,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002407 &coresight_tpiu_device,
2408 &coresight_etb_device,
2409 &apq8064_coresight_funnel_device,
2410 &coresight_etm0_device,
2411 &coresight_etm1_device,
2412 &coresight_etm2_device,
2413 &coresight_etm3_device,
Helen Zeng8f925502012-03-05 16:50:17 -08002414 &apq_cpudai_slim_4_rx,
2415 &apq_cpudai_slim_4_tx,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002416#ifdef CONFIG_MSM_GEMINI
Jignesh Mehta921649d2012-04-19 06:57:23 -07002417 &msm8960_gemini_device,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002418#endif
Laura Abbott0577d7b2012-04-17 11:14:30 -07002419 &apq8064_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002420 &msm_tsens_device,
Laura Abbott93a4a352012-05-25 09:26:35 -07002421 &apq8064_cache_dump_device,
Joel Nider0e4a16d2012-08-05 14:20:11 +03002422 &msm_8064_device_tspp,
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07002423#ifdef CONFIG_BATTERY_BCL
2424 &battery_bcl_device,
2425#endif
2426 &apq8064_msm_mpd_device,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002427};
2428
Joel King82b7e3f2012-01-05 10:03:27 -08002429static struct platform_device *cdp_devices[] __initdata = {
2430 &apq8064_device_uart_gsbi1,
Jin Hong4bbbfba2012-02-02 21:48:07 -08002431 &apq8064_device_uart_gsbi7,
Joel King82b7e3f2012-01-05 10:03:27 -08002432 &msm_device_sps_apq8064,
Aravind Venkateswaran4ca27532012-02-16 14:27:05 -08002433#ifdef CONFIG_MSM_ROTATOR
2434 &msm_rotator_device,
2435#endif
Anji Jonnalae84292b2012-09-21 13:34:44 +05302436 &msm8064_pc_cntr,
Joel King82b7e3f2012-01-05 10:03:27 -08002437};
2438
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002439static struct platform_device
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002440mpq8064_device_ext_1p2_buck_vreg __devinitdata = {
2441 .name = GPIO_REGULATOR_DEV_NAME,
2442 .id = SX150X_GPIO(4, 2),
2443 .dev = {
2444 .platform_data =
2445 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P2V],
2446 },
2447};
2448
2449static struct platform_device
2450mpq8064_device_ext_1p8_buck_vreg __devinitdata = {
2451 .name = GPIO_REGULATOR_DEV_NAME,
2452 .id = SX150X_GPIO(4, 4),
2453 .dev = {
2454 .platform_data =
2455 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P8V],
2456 },
2457};
2458
2459static struct platform_device
2460mpq8064_device_ext_2p2_buck_vreg __devinitdata = {
2461 .name = GPIO_REGULATOR_DEV_NAME,
2462 .id = SX150X_GPIO(4, 14),
2463 .dev = {
2464 .platform_data =
2465 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_2P2V],
2466 },
2467};
2468
2469static struct platform_device
2470mpq8064_device_ext_5v_buck_vreg __devinitdata = {
2471 .name = GPIO_REGULATOR_DEV_NAME,
2472 .id = SX150X_GPIO(4, 3),
2473 .dev = {
2474 .platform_data =
2475 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_5V],
2476 },
2477};
2478
2479static struct platform_device
2480mpq8064_device_ext_3p3v_ldo_vreg __devinitdata = {
2481 .name = GPIO_REGULATOR_DEV_NAME,
2482 .id = SX150X_GPIO(4, 15),
2483 .dev = {
2484 .platform_data =
2485 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_3P3V],
2486 },
2487};
2488
Ravi Kumar V1c903012012-05-15 16:11:35 +05302489static struct platform_device rc_input_loopback_pdev = {
2490 .name = "rc-user-input",
2491 .id = -1,
2492};
2493
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302494static int rf4ce_gpio_init(void)
2495{
Ravi Kumar V0143c582012-08-14 17:18:11 +05302496 if (!machine_is_mpq8064_cdp() &&
2497 !machine_is_mpq8064_hrd() &&
2498 !machine_is_mpq8064_dtv())
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302499 return -EINVAL;
2500
2501 /* CC2533 SRDY Input */
2502 if (!gpio_request(SX150X_GPIO(4, 6), "rf4ce_srdy")) {
2503 gpio_direction_input(SX150X_GPIO(4, 6));
2504 gpio_export(SX150X_GPIO(4, 6), true);
2505 }
2506
2507 /* CC2533 MRDY Output */
2508 if (!gpio_request(SX150X_GPIO(4, 5), "rf4ce_mrdy")) {
2509 gpio_direction_output(SX150X_GPIO(4, 5), 1);
2510 gpio_export(SX150X_GPIO(4, 5), true);
2511 }
2512
2513 /* CC2533 Reset Output */
2514 if (!gpio_request(SX150X_GPIO(4, 7), "rf4ce_reset")) {
2515 gpio_direction_output(SX150X_GPIO(4, 7), 0);
2516 gpio_export(SX150X_GPIO(4, 7), true);
2517 }
2518
2519 return 0;
2520}
2521late_initcall(rf4ce_gpio_init);
2522
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002523static struct platform_device *mpq_devices[] __initdata = {
2524 &msm_device_sps_apq8064,
2525 &mpq8064_device_qup_i2c_gsbi5,
2526#ifdef CONFIG_MSM_ROTATOR
2527 &msm_rotator_device,
2528#endif
Ravi Kumar V05931a22012-04-04 17:09:37 +05302529 &gpio_ir_recv_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002530 &mpq8064_device_ext_1p2_buck_vreg,
2531 &mpq8064_device_ext_1p8_buck_vreg,
2532 &mpq8064_device_ext_2p2_buck_vreg,
2533 &mpq8064_device_ext_5v_buck_vreg,
2534 &mpq8064_device_ext_3p3v_ldo_vreg,
Terence Hampson2e1705f2012-04-11 19:55:29 -04002535#ifdef CONFIG_MSM_VCAP
2536 &msm8064_device_vcap,
2537#endif
Ravi Kumar V1c903012012-05-15 16:11:35 +05302538 &rc_input_loopback_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002539};
2540
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002541static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002542 .max_clock_speed = 1100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002543};
2544
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002545#define KS8851_IRQ_GPIO 43
2546
2547static struct spi_board_info spi_board_info[] __initdata = {
2548 {
2549 .modalias = "ks8851",
2550 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2551 .max_speed_hz = 19200000,
2552 .bus_num = 0,
2553 .chip_select = 2,
2554 .mode = SPI_MODE_0,
2555 },
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002556 {
2557 .modalias = "epm_adc",
2558 .max_speed_hz = 1100000,
2559 .bus_num = 0,
2560 .chip_select = 3,
2561 .mode = SPI_MODE_0,
2562 },
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002563};
2564
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002565static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002566 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08002567 .bus_num = 1,
2568 .slim_slave = &apq8064_slim_tabla,
2569 },
2570 {
2571 .bus_num = 1,
2572 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002573 },
2574 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002575};
2576
David Keitel3c40fc52012-02-09 17:53:52 -08002577static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi1_pdata = {
2578 .clk_freq = 100000,
2579 .src_clk_rate = 24000000,
2580};
2581
Jing Lin04601f92012-02-05 15:36:07 -08002582static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi3_pdata = {
Anirudh Ghayalc2163472012-04-10 14:58:14 +05302583 .clk_freq = 384000,
Jing Lin04601f92012-02-05 15:36:07 -08002584 .src_clk_rate = 24000000,
2585};
2586
Kenneth Heitke748593a2011-07-15 15:45:11 -06002587static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
2588 .clk_freq = 100000,
2589 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002590};
2591
Joel King8f839b92012-04-01 14:37:46 -07002592static struct msm_i2c_platform_data mpq8064_i2c_qup_gsbi5_pdata = {
2593 .clk_freq = 100000,
2594 .src_clk_rate = 24000000,
2595};
2596
David Keitel3c40fc52012-02-09 17:53:52 -08002597#define GSBI_DUAL_MODE_CODE 0x60
2598#define MSM_GSBI1_PHYS 0x12440000
Kenneth Heitke748593a2011-07-15 15:45:11 -06002599static void __init apq8064_i2c_init(void)
2600{
David Keitel3c40fc52012-02-09 17:53:52 -08002601 void __iomem *gsbi_mem;
2602
2603 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2604 &apq8064_i2c_qup_gsbi1_pdata;
2605 gsbi_mem = ioremap_nocache(MSM_GSBI1_PHYS, 4);
2606 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
2607 /* Ensure protocol code is written before proceeding */
2608 wmb();
2609 iounmap(gsbi_mem);
2610 apq8064_i2c_qup_gsbi1_pdata.use_gsbi_shared_mode = 1;
Jing Lin04601f92012-02-05 15:36:07 -08002611 apq8064_device_qup_i2c_gsbi3.dev.platform_data =
2612 &apq8064_i2c_qup_gsbi3_pdata;
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002613 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2614 &apq8064_i2c_qup_gsbi1_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002615 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
2616 &apq8064_i2c_qup_gsbi4_pdata;
Joel King8f839b92012-04-01 14:37:46 -07002617 mpq8064_device_qup_i2c_gsbi5.dev.platform_data =
2618 &mpq8064_i2c_qup_gsbi5_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002619}
2620
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002621#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002622static int ethernet_init(void)
2623{
2624 int ret;
2625 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
2626 if (ret) {
2627 pr_err("ks8851 gpio_request failed: %d\n", ret);
2628 goto fail;
2629 }
2630
2631 return 0;
2632fail:
2633 return ret;
2634}
2635#else
2636static int ethernet_init(void)
2637{
2638 return 0;
2639}
2640#endif
2641
David Collins6f7c3472012-08-22 13:18:06 -07002642#define GPIO_KEY_HOME PM8921_GPIO_PM_TO_SYS(27)
2643#define GPIO_KEY_VOLUME_UP PM8921_GPIO_PM_TO_SYS(35)
2644#define GPIO_KEY_VOLUME_DOWN_PM8921 PM8921_GPIO_PM_TO_SYS(38)
2645#define GPIO_KEY_VOLUME_DOWN_PM8917 PM8921_GPIO_PM_TO_SYS(30)
2646#define GPIO_KEY_CAM_FOCUS PM8921_GPIO_PM_TO_SYS(3)
2647#define GPIO_KEY_CAM_SNAP PM8921_GPIO_PM_TO_SYS(4)
2648#define GPIO_KEY_ROTATION_PM8921 PM8921_GPIO_PM_TO_SYS(42)
2649#define GPIO_KEY_ROTATION_PM8917 PM8921_GPIO_PM_TO_SYS(8)
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302650
David Collins6f7c3472012-08-22 13:18:06 -07002651static struct gpio_keys_button cdp_keys_pm8921[] = {
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302652 {
2653 .code = KEY_HOME,
2654 .gpio = GPIO_KEY_HOME,
2655 .desc = "home_key",
2656 .active_low = 1,
2657 .type = EV_KEY,
2658 .wakeup = 1,
2659 .debounce_interval = 15,
2660 },
2661 {
2662 .code = KEY_VOLUMEUP,
2663 .gpio = GPIO_KEY_VOLUME_UP,
2664 .desc = "volume_up_key",
2665 .active_low = 1,
2666 .type = EV_KEY,
2667 .wakeup = 1,
2668 .debounce_interval = 15,
2669 },
2670 {
2671 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002672 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302673 .desc = "volume_down_key",
2674 .active_low = 1,
2675 .type = EV_KEY,
2676 .wakeup = 1,
2677 .debounce_interval = 15,
2678 },
2679 {
2680 .code = SW_ROTATE_LOCK,
David Collins6f7c3472012-08-22 13:18:06 -07002681 .gpio = GPIO_KEY_ROTATION_PM8921,
2682 .desc = "rotate_key",
2683 .active_low = 1,
2684 .type = EV_SW,
2685 .debounce_interval = 15,
2686 },
2687};
2688
2689static struct gpio_keys_button cdp_keys_pm8917[] = {
2690 {
2691 .code = KEY_HOME,
2692 .gpio = GPIO_KEY_HOME,
2693 .desc = "home_key",
2694 .active_low = 1,
2695 .type = EV_KEY,
2696 .wakeup = 1,
2697 .debounce_interval = 15,
2698 },
2699 {
2700 .code = KEY_VOLUMEUP,
2701 .gpio = GPIO_KEY_VOLUME_UP,
2702 .desc = "volume_up_key",
2703 .active_low = 1,
2704 .type = EV_KEY,
2705 .wakeup = 1,
2706 .debounce_interval = 15,
2707 },
2708 {
2709 .code = KEY_VOLUMEDOWN,
2710 .gpio = GPIO_KEY_VOLUME_DOWN_PM8917,
2711 .desc = "volume_down_key",
2712 .active_low = 1,
2713 .type = EV_KEY,
2714 .wakeup = 1,
2715 .debounce_interval = 15,
2716 },
2717 {
2718 .code = SW_ROTATE_LOCK,
2719 .gpio = GPIO_KEY_ROTATION_PM8917,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302720 .desc = "rotate_key",
2721 .active_low = 1,
2722 .type = EV_SW,
2723 .debounce_interval = 15,
2724 },
2725};
2726
2727static struct gpio_keys_platform_data cdp_keys_data = {
David Collins6f7c3472012-08-22 13:18:06 -07002728 .buttons = cdp_keys_pm8921,
2729 .nbuttons = ARRAY_SIZE(cdp_keys_pm8921),
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302730};
2731
2732static struct platform_device cdp_kp_pdev = {
2733 .name = "gpio-keys",
2734 .id = -1,
2735 .dev = {
2736 .platform_data = &cdp_keys_data,
2737 },
2738};
2739
2740static struct gpio_keys_button mtp_keys[] = {
2741 {
2742 .code = KEY_CAMERA_FOCUS,
2743 .gpio = GPIO_KEY_CAM_FOCUS,
2744 .desc = "cam_focus_key",
2745 .active_low = 1,
2746 .type = EV_KEY,
2747 .wakeup = 1,
2748 .debounce_interval = 15,
2749 },
2750 {
2751 .code = KEY_VOLUMEUP,
2752 .gpio = GPIO_KEY_VOLUME_UP,
2753 .desc = "volume_up_key",
2754 .active_low = 1,
2755 .type = EV_KEY,
2756 .wakeup = 1,
2757 .debounce_interval = 15,
2758 },
2759 {
2760 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002761 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302762 .desc = "volume_down_key",
2763 .active_low = 1,
2764 .type = EV_KEY,
2765 .wakeup = 1,
2766 .debounce_interval = 15,
2767 },
2768 {
2769 .code = KEY_CAMERA_SNAPSHOT,
2770 .gpio = GPIO_KEY_CAM_SNAP,
2771 .desc = "cam_snap_key",
2772 .active_low = 1,
2773 .type = EV_KEY,
2774 .debounce_interval = 15,
2775 },
2776};
2777
2778static struct gpio_keys_platform_data mtp_keys_data = {
2779 .buttons = mtp_keys,
2780 .nbuttons = ARRAY_SIZE(mtp_keys),
2781};
2782
2783static struct platform_device mtp_kp_pdev = {
2784 .name = "gpio-keys",
2785 .id = -1,
2786 .dev = {
2787 .platform_data = &mtp_keys_data,
2788 },
2789};
2790
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302791static struct gpio_keys_button mpq_keys[] = {
2792 {
2793 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002794 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302795 .desc = "volume_down_key",
2796 .active_low = 1,
2797 .type = EV_KEY,
2798 .wakeup = 1,
2799 .debounce_interval = 15,
2800 },
2801 {
2802 .code = KEY_VOLUMEUP,
2803 .gpio = GPIO_KEY_VOLUME_UP,
2804 .desc = "volume_up_key",
2805 .active_low = 1,
2806 .type = EV_KEY,
2807 .wakeup = 1,
2808 .debounce_interval = 15,
2809 },
2810};
2811
2812static struct gpio_keys_platform_data mpq_keys_data = {
2813 .buttons = mpq_keys,
2814 .nbuttons = ARRAY_SIZE(mpq_keys),
2815};
2816
2817static struct platform_device mpq_gpio_keys_pdev = {
2818 .name = "gpio-keys",
2819 .id = -1,
2820 .dev = {
2821 .platform_data = &mpq_keys_data,
2822 },
2823};
2824
2825#define MPQ_KP_ROW_BASE SX150X_EXP2_GPIO_BASE
2826#define MPQ_KP_COL_BASE (SX150X_EXP2_GPIO_BASE + 4)
2827
2828static unsigned int mpq_row_gpios[] = {MPQ_KP_ROW_BASE, MPQ_KP_ROW_BASE + 1,
2829 MPQ_KP_ROW_BASE + 2, MPQ_KP_ROW_BASE + 3};
2830static unsigned int mpq_col_gpios[] = {MPQ_KP_COL_BASE, MPQ_KP_COL_BASE + 1,
2831 MPQ_KP_COL_BASE + 2};
2832
2833static const unsigned int mpq_keymap[] = {
2834 KEY(0, 0, KEY_UP),
2835 KEY(0, 1, KEY_ENTER),
2836 KEY(0, 2, KEY_3),
2837
2838 KEY(1, 0, KEY_DOWN),
2839 KEY(1, 1, KEY_EXIT),
2840 KEY(1, 2, KEY_4),
2841
2842 KEY(2, 0, KEY_LEFT),
2843 KEY(2, 1, KEY_1),
2844 KEY(2, 2, KEY_5),
2845
2846 KEY(3, 0, KEY_RIGHT),
2847 KEY(3, 1, KEY_2),
2848 KEY(3, 2, KEY_6),
2849};
2850
2851static struct matrix_keymap_data mpq_keymap_data = {
2852 .keymap_size = ARRAY_SIZE(mpq_keymap),
2853 .keymap = mpq_keymap,
2854};
2855
2856static struct matrix_keypad_platform_data mpq_keypad_data = {
2857 .keymap_data = &mpq_keymap_data,
2858 .row_gpios = mpq_row_gpios,
2859 .col_gpios = mpq_col_gpios,
2860 .num_row_gpios = ARRAY_SIZE(mpq_row_gpios),
2861 .num_col_gpios = ARRAY_SIZE(mpq_col_gpios),
2862 .col_scan_delay_us = 32000,
2863 .debounce_ms = 20,
2864 .wakeup = 1,
2865 .active_low = 1,
2866 .no_autorepeat = 1,
2867};
2868
2869static struct platform_device mpq_keypad_device = {
2870 .name = "matrix-keypad",
2871 .id = -1,
2872 .dev = {
2873 .platform_data = &mpq_keypad_data,
2874 },
2875};
2876
Jin Hongd3024e62012-02-09 16:13:32 -08002877/* Sensors DSPS platform data */
2878#define DSPS_PIL_GENERIC_NAME "dsps"
2879static void __init apq8064_init_dsps(void)
2880{
2881 struct msm_dsps_platform_data *pdata =
2882 msm_dsps_device_8064.dev.platform_data;
2883 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2884 pdata->gpios = NULL;
2885 pdata->gpios_num = 0;
2886
2887 platform_device_register(&msm_dsps_device_8064);
2888}
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302889
Jing Lin417fa452012-02-05 14:31:06 -08002890#define I2C_SURF 1
2891#define I2C_FFA (1 << 1)
2892#define I2C_RUMI (1 << 2)
2893#define I2C_SIM (1 << 3)
2894#define I2C_LIQUID (1 << 4)
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002895#define I2C_MPQ_CDP BIT(5)
2896#define I2C_MPQ_HRD BIT(6)
2897#define I2C_MPQ_DTV BIT(7)
Jing Lin417fa452012-02-05 14:31:06 -08002898
2899struct i2c_registry {
2900 u8 machs;
2901 int bus;
2902 struct i2c_board_info *info;
2903 int len;
2904};
2905
2906static struct i2c_registry apq8064_i2c_devices[] __initdata = {
Jing Lin21ed4de2012-02-05 15:53:28 -08002907 {
David Keitel2f613d92012-02-15 11:29:16 -08002908 I2C_LIQUID,
2909 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2910 smb349_charger_i2c_info,
2911 ARRAY_SIZE(smb349_charger_i2c_info)
2912 },
2913 {
Jing Lin21ed4de2012-02-05 15:53:28 -08002914 I2C_SURF | I2C_LIQUID,
2915 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2916 mxt_device_info,
2917 ARRAY_SIZE(mxt_device_info),
2918 },
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08002919 {
2920 I2C_FFA,
2921 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2922 cyttsp_info,
2923 ARRAY_SIZE(cyttsp_info),
2924 },
Amy Maloche70090f992012-02-16 16:35:26 -08002925 {
2926 I2C_FFA | I2C_LIQUID,
2927 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2928 isa1200_board_info,
2929 ARRAY_SIZE(isa1200_board_info),
2930 },
Santosh Mardieff9a742012-04-09 23:23:39 +05302931 {
2932 I2C_MPQ_CDP,
2933 APQ_8064_GSBI5_QUP_I2C_BUS_ID,
2934 cs8427_device_info,
2935 ARRAY_SIZE(cs8427_device_info),
2936 },
Jing Lin417fa452012-02-05 14:31:06 -08002937};
2938
Jay Chokshi607f61b2012-04-25 18:21:21 -07002939#define SX150X_EXP1_INT_N PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9)
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302940#define SX150X_EXP2_INT_N MSM_GPIO_TO_INT(81)
Jay Chokshi607f61b2012-04-25 18:21:21 -07002941
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002942struct sx150x_platform_data mpq8064_sx150x_pdata[] = {
2943 [SX150X_EXP1] = {
2944 .gpio_base = SX150X_EXP1_GPIO_BASE,
2945 .oscio_is_gpo = false,
2946 .io_pullup_ena = 0x0,
2947 .io_pulldn_ena = 0x0,
2948 .io_open_drain_ena = 0x0,
2949 .io_polarity = 0,
Jay Chokshi607f61b2012-04-25 18:21:21 -07002950 .irq_summary = SX150X_EXP1_INT_N,
2951 .irq_base = SX150X_EXP1_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002952 },
2953 [SX150X_EXP2] = {
2954 .gpio_base = SX150X_EXP2_GPIO_BASE,
2955 .oscio_is_gpo = false,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302956 .io_pullup_ena = 0x0f,
2957 .io_pulldn_ena = 0x70,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002958 .io_open_drain_ena = 0x0,
2959 .io_polarity = 0,
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302960 .irq_summary = SX150X_EXP2_INT_N,
2961 .irq_base = SX150X_EXP2_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002962 },
2963 [SX150X_EXP3] = {
2964 .gpio_base = SX150X_EXP3_GPIO_BASE,
2965 .oscio_is_gpo = false,
2966 .io_pullup_ena = 0x0,
2967 .io_pulldn_ena = 0x0,
2968 .io_open_drain_ena = 0x0,
2969 .io_polarity = 0,
2970 .irq_summary = -1,
2971 },
2972 [SX150X_EXP4] = {
2973 .gpio_base = SX150X_EXP4_GPIO_BASE,
2974 .oscio_is_gpo = false,
2975 .io_pullup_ena = 0x0,
2976 .io_pulldn_ena = 0x0,
2977 .io_open_drain_ena = 0x0,
2978 .io_polarity = 0,
2979 .irq_summary = -1,
2980 },
2981};
2982
2983static struct i2c_board_info sx150x_gpio_exp_info[] = {
2984 {
2985 I2C_BOARD_INFO("sx1509q", 0x70),
2986 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP1],
2987 },
2988 {
2989 I2C_BOARD_INFO("sx1508q", 0x23),
2990 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP2],
2991 },
2992 {
2993 I2C_BOARD_INFO("sx1508q", 0x22),
2994 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP3],
2995 },
2996 {
2997 I2C_BOARD_INFO("sx1509q", 0x3E),
2998 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP4],
2999 },
3000};
3001
3002#define MPQ8064_I2C_GSBI5_BUS_ID 5
3003
3004static struct i2c_registry mpq8064_i2c_devices[] __initdata = {
3005 {
3006 I2C_MPQ_CDP,
3007 MPQ8064_I2C_GSBI5_BUS_ID,
3008 sx150x_gpio_exp_info,
3009 ARRAY_SIZE(sx150x_gpio_exp_info),
3010 },
3011};
3012
Jing Lin417fa452012-02-05 14:31:06 -08003013static void __init register_i2c_devices(void)
3014{
3015 u8 mach_mask = 0;
3016 int i;
3017
Kevin Chand07220e2012-02-13 15:52:22 -08003018#ifdef CONFIG_MSM_CAMERA
3019 struct i2c_registry apq8064_camera_i2c_devices = {
3020 I2C_SURF | I2C_FFA | I2C_LIQUID | I2C_RUMI,
3021 APQ_8064_GSBI4_QUP_I2C_BUS_ID,
3022 apq8064_camera_board_info.board_info,
3023 apq8064_camera_board_info.num_i2c_board_info,
3024 };
3025#endif
Jing Lin417fa452012-02-05 14:31:06 -08003026 /* Build the matching 'supported_machs' bitmask */
3027 if (machine_is_apq8064_cdp())
3028 mach_mask = I2C_SURF;
3029 else if (machine_is_apq8064_mtp())
3030 mach_mask = I2C_FFA;
3031 else if (machine_is_apq8064_liquid())
3032 mach_mask = I2C_LIQUID;
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003033 else if (PLATFORM_IS_MPQ8064())
3034 mach_mask = I2C_MPQ_CDP;
Jing Lin417fa452012-02-05 14:31:06 -08003035 else
3036 pr_err("unmatched machine ID in register_i2c_devices\n");
3037
3038 /* Run the array and install devices as appropriate */
3039 for (i = 0; i < ARRAY_SIZE(apq8064_i2c_devices); ++i) {
3040 if (apq8064_i2c_devices[i].machs & mach_mask)
3041 i2c_register_board_info(apq8064_i2c_devices[i].bus,
3042 apq8064_i2c_devices[i].info,
3043 apq8064_i2c_devices[i].len);
3044 }
Kevin Chand07220e2012-02-13 15:52:22 -08003045#ifdef CONFIG_MSM_CAMERA
3046 if (apq8064_camera_i2c_devices.machs & mach_mask)
3047 i2c_register_board_info(apq8064_camera_i2c_devices.bus,
3048 apq8064_camera_i2c_devices.info,
3049 apq8064_camera_i2c_devices.len);
3050#endif
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003051
3052 for (i = 0; i < ARRAY_SIZE(mpq8064_i2c_devices); ++i) {
3053 if (mpq8064_i2c_devices[i].machs & mach_mask)
3054 i2c_register_board_info(
3055 mpq8064_i2c_devices[i].bus,
3056 mpq8064_i2c_devices[i].info,
3057 mpq8064_i2c_devices[i].len);
3058 }
Jing Lin417fa452012-02-05 14:31:06 -08003059}
3060
Jay Chokshi994ff122012-03-27 15:43:48 -07003061static void enable_ddr3_regulator(void)
3062{
3063 static struct regulator *ext_ddr3;
3064
3065 /* Use MPP7 output state as a flag for PCDDR3 presence. */
3066 if (gpio_get_value_cansleep(PM8921_MPP_PM_TO_SYS(7)) > 0) {
3067 ext_ddr3 = regulator_get(NULL, "ext_ddr3");
3068 if (IS_ERR(ext_ddr3) || ext_ddr3 == NULL)
3069 pr_err("Could not get MPP7 regulator\n");
3070 else
3071 regulator_enable(ext_ddr3);
3072 }
3073}
3074
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003075static void enable_avc_i2c_bus(void)
3076{
3077 int avc_i2c_en_mpp = PM8921_MPP_PM_TO_SYS(8);
3078 int rc;
3079
3080 rc = gpio_request(avc_i2c_en_mpp, "avc_i2c_en");
3081 if (rc)
3082 pr_err("request for avc_i2c_en mpp failed,"
3083 "rc=%d\n", rc);
3084 else
3085 gpio_set_value_cansleep(avc_i2c_en_mpp, 1);
3086}
3087
David Collins6f7c3472012-08-22 13:18:06 -07003088/* Modify platform data values to match requirements for PM8917. */
3089static void __init apq8064_pm8917_pdata_fixup(void)
3090{
3091 cdp_keys_data.buttons = cdp_keys_pm8917;
3092 cdp_keys_data.nbuttons = ARRAY_SIZE(cdp_keys_pm8917);
3093}
3094
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003095static void __init apq8064_common_init(void)
3096{
Ameya Thakure155ece2012-07-09 12:08:37 -07003097 u32 platform_version;
David Collins6f7c3472012-08-22 13:18:06 -07003098
3099 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3100 apq8064_pm8917_pdata_fixup();
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003101 platform_device_register(&msm_gpio_device);
Joel King8f839b92012-04-01 14:37:46 -07003102 msm_tsens_early_init(&apq_tsens_pdata);
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003103 msm_thermal_init(&msm_thermal_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003104 if (socinfo_init() < 0)
3105 pr_err("socinfo_init() failed!\n");
Praveen Chidambaram78499012011-11-01 17:15:17 -06003106 BUG_ON(msm_rpm_init(&apq8064_rpm_data));
3107 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
David Collins2782b5c2012-02-06 10:02:42 -08003108 regulator_suppress_info_printing();
David Collins36199252012-08-21 15:43:02 -07003109 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3110 configure_apq8064_pm8917_power_grid();
David Collins2782b5c2012-02-06 10:02:42 -08003111 platform_device_register(&apq8064_device_rpm_regulator);
David Collins36199252012-08-21 15:43:02 -07003112 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3113 platform_device_register(&apq8064_pm8921_device_rpm_regulator);
Stephen Boyd4d0d2582012-02-10 14:49:40 -08003114 if (msm_xo_init())
3115 pr_err("Failed to initialize XO votes\n");
Matt Wagantallc51e5602012-02-27 17:25:25 -08003116 msm_clock_init(&apq8064_clock_init_data);
Stepan Moskovchenko2327a952011-12-14 16:31:28 -08003117 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -06003118 apq8064_i2c_init();
Jing Lin417fa452012-02-05 14:31:06 -08003119 register_i2c_devices();
Kenneth Heitke36920d32011-07-20 16:44:30 -06003120
Harini Jayaramanc4c58692011-07-19 14:50:10 -06003121 apq8064_device_qup_spi_gsbi5.dev.platform_data =
3122 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -08003123 apq8064_init_pmic();
Hemant Kumar94e7da22012-02-03 16:52:29 -08003124 if (machine_is_apq8064_liquid())
3125 msm_otg_pdata.mhl_enable = true;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003126
Ofir Cohen94213a72012-05-03 14:26:32 +03003127 android_usb_pdata.swfi_latency =
3128 msm_rpmrs_levels[0].latency_us;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003129
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003130 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Manu Gautam91223e02011-11-08 15:27:22 +05303131 apq8064_ehci_host_init();
Gagan Mac8a7a5d32011-11-11 16:43:06 -07003132 apq8064_init_buses();
David Collins36199252012-08-21 15:43:02 -07003133
3134 platform_add_devices(early_common_devices,
3135 ARRAY_SIZE(early_common_devices));
3136 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3137 platform_add_devices(pm8921_common_devices,
3138 ARRAY_SIZE(pm8921_common_devices));
3139 else
3140 platform_add_devices(pm8917_common_devices,
3141 ARRAY_SIZE(pm8917_common_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003142 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Terence Hampson36b70722012-05-10 13:18:16 -04003143 if (!(machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3144 machine_is_mpq8064_dtv()))
3145 platform_add_devices(common_not_mpq_devices,
3146 ARRAY_SIZE(common_not_mpq_devices));
Jay Chokshi994ff122012-03-27 15:43:48 -07003147 enable_ddr3_regulator();
Pavankumar Kondetife2d4d32012-09-07 15:33:09 +05303148 msm_hsic_pdata.swfi_latency =
3149 msm_rpmrs_levels[0].latency_us;
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003150 if (machine_is_apq8064_mtp()) {
Ajay Dudanic4e40db2012-08-20 14:44:40 -07003151 msm_hsic_pdata.log2_irq_thresh = 5,
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003152 apq8064_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
3153 device_initialize(&apq8064_device_hsic_host.dev);
3154 }
Jay Chokshie8741282012-01-25 15:22:55 -08003155 apq8064_pm8xxx_gpio_mpp_init();
Sahitya Tummala3586ed92011-08-03 09:13:23 +05303156 apq8064_init_mmc();
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003157
3158 if (machine_is_apq8064_mtp()) {
3159 mdm_8064_device.dev.platform_data = &mdm_platform_data;
Ameya Thakure155ece2012-07-09 12:08:37 -07003160 platform_version = socinfo_get_platform_version();
3161 if (SOCINFO_VERSION_MINOR(platform_version) == 1) {
3162 i2s_mdm_8064_device.dev.platform_data =
3163 &mdm_platform_data;
3164 platform_device_register(&i2s_mdm_8064_device);
3165 } else {
3166 mdm_8064_device.dev.platform_data = &mdm_platform_data;
3167 platform_device_register(&mdm_8064_device);
3168 }
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003169 }
3170 platform_device_register(&apq8064_slim_ctrl);
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06003171 slim_register_board_info(apq8064_slim_devices,
3172 ARRAY_SIZE(apq8064_slim_devices));
Taniya Dasbbf633d2012-07-31 16:07:47 +05303173 if (!PLATFORM_IS_MPQ8064()) {
Taniya Das30cae292012-07-31 15:56:12 +05303174 apq8064_init_dsps();
Taniya Dasbbf633d2012-07-31 16:07:47 +05303175 platform_device_register(&msm_8960_riva);
3176 }
Praveen Chidambaram78499012011-11-01 17:15:17 -06003177 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3178 msm_spm_l2_init(msm_spm_l2_data);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003179 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08003180 apq8064_epm_adc_init();
Anji Jonnala85b29ff2013-01-15 14:12:45 +05303181 msm_pm_set_tz_retention_flag(1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003182}
3183
Huaibin Yang4a084e32011-12-15 15:25:52 -08003184static void __init apq8064_allocate_memory_regions(void)
3185{
3186 apq8064_allocate_fb_region();
3187}
3188
Joel King82b7e3f2012-01-05 10:03:27 -08003189static void __init apq8064_cdp_init(void)
3190{
Hanumant Singh50440d42012-04-23 19:27:16 -07003191 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3192 pr_err("meminfo_init() failed!\n");
Amy Maloche609bb5e2012-08-03 09:41:42 -07003193 if (machine_is_apq8064_mtp() &&
3194 SOCINFO_VERSION_MINOR(socinfo_get_platform_version()) == 1)
3195 cyttsp_pdata.sleep_gpio = CYTTSP_TS_GPIO_SLEEP_ALT;
Joel King82b7e3f2012-01-05 10:03:27 -08003196 apq8064_common_init();
Joel King8f839b92012-04-01 14:37:46 -07003197 if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3198 machine_is_mpq8064_dtv()) {
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003199 enable_avc_i2c_bus();
Olav Hauganef95ae32012-05-15 09:50:30 -07003200 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003201 platform_add_devices(mpq_devices, ARRAY_SIZE(mpq_devices));
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06003202 mpq8064_pcie_init();
Joel King8f839b92012-04-01 14:37:46 -07003203 } else {
3204 ethernet_init();
Olav Hauganef95ae32012-05-15 09:50:30 -07003205 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003206 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3207 spi_register_board_info(spi_board_info,
3208 ARRAY_SIZE(spi_board_info));
3209 }
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003210 apq8064_init_fb();
Jordan Crouseb3115fe2012-02-01 22:11:12 -07003211 apq8064_init_gpu();
Matt Wagantall1f65d9d2012-04-25 14:24:20 -07003212 platform_add_devices(apq8064_footswitch, apq8064_num_footswitch);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003213#ifdef CONFIG_MSM_CAMERA
Kevin Chand07220e2012-02-13 15:52:22 -08003214 apq8064_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003215#endif
Mohan Pallaka474b94b2012-01-25 12:59:58 +05303216
3217 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid())
3218 platform_device_register(&cdp_kp_pdev);
3219
3220 if (machine_is_apq8064_mtp())
3221 platform_device_register(&mtp_kp_pdev);
Hanumant Singh50440d42012-04-23 19:27:16 -07003222
3223 change_memory_power = &apq8064_change_memory_power;
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05303224
3225 if (machine_is_mpq8064_cdp()) {
3226 platform_device_register(&mpq_gpio_keys_pdev);
3227 platform_device_register(&mpq_keypad_device);
3228 }
Joel King82b7e3f2012-01-05 10:03:27 -08003229}
3230
Joel King82b7e3f2012-01-05 10:03:27 -08003231MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
3232 .map_io = apq8064_map_io,
3233 .reserve = apq8064_reserve,
3234 .init_irq = apq8064_init_irq,
3235 .handle_irq = gic_handle_irq,
3236 .timer = &msm_timer,
3237 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003238 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003239 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003240 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003241MACHINE_END
3242
3243MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
3244 .map_io = apq8064_map_io,
3245 .reserve = apq8064_reserve,
3246 .init_irq = apq8064_init_irq,
3247 .handle_irq = gic_handle_irq,
3248 .timer = &msm_timer,
3249 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003250 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003251 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003252 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003253MACHINE_END
3254
3255MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
3256 .map_io = apq8064_map_io,
3257 .reserve = apq8064_reserve,
3258 .init_irq = apq8064_init_irq,
3259 .handle_irq = gic_handle_irq,
3260 .timer = &msm_timer,
3261 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003262 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003263 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003264 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003265MACHINE_END
3266
Joel King064bbf82012-04-01 13:23:39 -07003267MACHINE_START(MPQ8064_CDP, "QCT MPQ8064 CDP")
3268 .map_io = apq8064_map_io,
3269 .reserve = apq8064_reserve,
3270 .init_irq = apq8064_init_irq,
3271 .handle_irq = gic_handle_irq,
3272 .timer = &msm_timer,
3273 .init_machine = apq8064_cdp_init,
3274 .init_early = apq8064_allocate_memory_regions,
3275 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003276 .restart = msm_restart,
Joel King064bbf82012-04-01 13:23:39 -07003277MACHINE_END
3278
Joel King11ca8202012-02-13 16:19:03 -08003279MACHINE_START(MPQ8064_HRD, "QCT MPQ8064 HRD")
3280 .map_io = apq8064_map_io,
3281 .reserve = apq8064_reserve,
3282 .init_irq = apq8064_init_irq,
3283 .handle_irq = gic_handle_irq,
3284 .timer = &msm_timer,
3285 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003286 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003287 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003288 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003289MACHINE_END
3290
3291MACHINE_START(MPQ8064_DTV, "QCT MPQ8064 DTV")
3292 .map_io = apq8064_map_io,
3293 .reserve = apq8064_reserve,
3294 .init_irq = apq8064_init_irq,
3295 .handle_irq = gic_handle_irq,
3296 .timer = &msm_timer,
3297 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003298 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003299 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003300 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003301MACHINE_END
3302