blob: 67cabcec865f260306b04ca05f2a9816a9e778be [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"
Praveen Chidambaram78499012011-11-01 17:15:17 -060081#include "spm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053082#include <mach/mpm.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060083#include "rpm_resources.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080084#include "pm.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060085#include "pm-boot.h"
Rajesh Sastrulaaee8af32012-01-20 11:46:31 -080086#include "devices-msm8x60.h"
Hanumant Singh50440d42012-04-23 19:27:16 -070087#include "smd_private.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070088
Olav Haugan7c6aa742012-01-16 16:47:37 -080089#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -070090#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Olav Haugan7c6aa742012-01-16 16:47:37 -080091#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
92#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
93#else
Chetan Kalyan72aac4f2012-02-23 14:56:54 -080094#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Olav Haugan7c6aa742012-01-16 16:47:37 -080095#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070096
Olav Haugan7c6aa742012-01-16 16:47:37 -080097#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Hanumant Singheadb7502012-05-15 18:14:04 -070098#define HOLE_SIZE 0x20000
Mitchel Humpherys05e58812012-08-13 14:24:13 -070099#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan129992c2012-03-22 09:54:01 -0700100#ifdef CONFIG_MSM_IOMMU
101#define MSM_ION_MM_SIZE 0x3800000
102#define MSM_ION_SF_SIZE 0
Olav Haugan39477bb2012-05-14 16:05:36 -0700103#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700104#define MSM_ION_HEAP_NUM 7
105#else
Olav Haugan7c6aa742012-01-16 16:47:37 -0800106#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan129992c2012-03-22 09:54:01 -0700107#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Haugan39477bb2012-05-14 16:05:36 -0700108#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700109#define MSM_ION_HEAP_NUM 8
110#endif
Hanumant Singheadb7502012-05-15 18:14:04 -0700111#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* (2MB - 128KB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800112#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan2c43fac2012-01-19 11:06:37 -0800113#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan7c6aa742012-01-16 16:47:37 -0800114#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700115#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Haugan7c6aa742012-01-16 16:47:37 -0800116#define MSM_ION_HEAP_NUM 1
117#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700118
Hanumant Singheadb7502012-05-15 18:14:04 -0700119#define APQ8064_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
120 HOLE_SIZE))
Larry Bassel67b921d2012-04-06 10:23:27 -0700121#define MAX_FIXED_AREA_SIZE 0x10000000
Hanumant Singheadb7502012-05-15 18:14:04 -0700122#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE)
123#define APQ8064_FW_START APQ8064_FIXED_AREA_START
Larry Bassel67b921d2012-04-06 10:23:27 -0700124
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -0600125#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB (MSM_QFPROM_BASE + 0x23c)
126#define QFPROM_RAW_OEM_CONFIG_ROW0_LSB (MSM_QFPROM_BASE + 0x220)
127
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -0600128/* PCIE AXI address space */
129#define PCIE_AXI_BAR_PHYS 0x08000000
130#define PCIE_AXI_BAR_SIZE SZ_128M
131
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -0600132/* PCIe pmic gpios */
133#define PCIE_WAKE_N_PMIC_GPIO 12
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600134#define PCIE_PWR_EN_PMIC_GPIO 13
135#define PCIE_RST_N_PMIC_MPP 1
136
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700137#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
138static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
139static int __init msm_contig_mem_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -0700140{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700141 msm_contig_mem_size = memparse(p, NULL);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800142 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700143}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700144early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800145#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700146
Olav Haugan7c6aa742012-01-16 16:47:37 -0800147#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -0700148static unsigned pmem_size = MSM_PMEM_SIZE;
149static int __init pmem_size_setup(char *p)
150{
151 pmem_size = memparse(p, NULL);
152 return 0;
153}
154early_param("pmem_size", pmem_size_setup);
155
156static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
157
158static int __init pmem_adsp_size_setup(char *p)
159{
160 pmem_adsp_size = memparse(p, NULL);
161 return 0;
162}
163early_param("pmem_adsp_size", pmem_adsp_size_setup);
164
165static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
166
167static int __init pmem_audio_size_setup(char *p)
168{
169 pmem_audio_size = memparse(p, NULL);
170 return 0;
171}
172early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800173#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700174
Olav Haugan7c6aa742012-01-16 16:47:37 -0800175#ifdef CONFIG_ANDROID_PMEM
176#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700177static struct android_pmem_platform_data android_pmem_pdata = {
178 .name = "pmem",
179 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
180 .cached = 1,
181 .memory_type = MEMTYPE_EBI1,
182};
183
Laura Abbottb93525f2012-04-12 09:57:19 -0700184static struct platform_device apq8064_android_pmem_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700185 .name = "android_pmem",
186 .id = 0,
187 .dev = {.platform_data = &android_pmem_pdata},
188};
189
190static struct android_pmem_platform_data android_pmem_adsp_pdata = {
191 .name = "pmem_adsp",
192 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
193 .cached = 0,
194 .memory_type = MEMTYPE_EBI1,
195};
Laura Abbottb93525f2012-04-12 09:57:19 -0700196static struct platform_device apq8064_android_pmem_adsp_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700197 .name = "android_pmem",
198 .id = 2,
199 .dev = { .platform_data = &android_pmem_adsp_pdata },
200};
201
202static struct android_pmem_platform_data android_pmem_audio_pdata = {
203 .name = "pmem_audio",
204 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
205 .cached = 0,
206 .memory_type = MEMTYPE_EBI1,
207};
208
Laura Abbottb93525f2012-04-12 09:57:19 -0700209static struct platform_device apq8064_android_pmem_audio_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700210 .name = "android_pmem",
211 .id = 4,
212 .dev = { .platform_data = &android_pmem_audio_pdata },
213};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700214#endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
215#endif /* CONFIG_ANDROID_PMEM */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800216
Larry Bassel67b921d2012-04-06 10:23:27 -0700217struct fmem_platform_data apq8064_fmem_pdata = {
218};
219
Olav Haugan7c6aa742012-01-16 16:47:37 -0800220static struct memtype_reserve apq8064_reserve_table[] __initdata = {
221 [MEMTYPE_SMI] = {
222 },
223 [MEMTYPE_EBI0] = {
224 .flags = MEMTYPE_FLAGS_1M_ALIGN,
225 },
226 [MEMTYPE_EBI1] = {
227 .flags = MEMTYPE_FLAGS_1M_ALIGN,
228 },
229};
Kevin Chan13be4e22011-10-20 11:30:32 -0700230
Laura Abbott350c8362012-02-28 14:46:52 -0800231static void __init reserve_rtb_memory(void)
232{
233#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700234 apq8064_reserve_table[MEMTYPE_EBI1].size += apq8064_rtb_pdata.size;
Laura Abbott350c8362012-02-28 14:46:52 -0800235#endif
236}
237
238
Kevin Chan13be4e22011-10-20 11:30:32 -0700239static void __init size_pmem_devices(void)
240{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800241#ifdef CONFIG_ANDROID_PMEM
242#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700243 android_pmem_adsp_pdata.size = pmem_adsp_size;
244 android_pmem_pdata.size = pmem_size;
245 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700246#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
247#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700248}
249
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700250#ifdef CONFIG_ANDROID_PMEM
251#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700252static void __init reserve_memory_for(struct android_pmem_platform_data *p)
253{
254 apq8064_reserve_table[p->memory_type].size += p->size;
255}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700256#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
257#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700258
Kevin Chan13be4e22011-10-20 11:30:32 -0700259static void __init reserve_pmem_memory(void)
260{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800261#ifdef CONFIG_ANDROID_PMEM
262#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700263 reserve_memory_for(&android_pmem_adsp_pdata);
264 reserve_memory_for(&android_pmem_pdata);
265 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700266#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700267 apq8064_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700268#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -0800269}
270
271static int apq8064_paddr_to_memtype(unsigned int paddr)
272{
273 return MEMTYPE_EBI1;
274}
275
Steve Mucklef132c6c2012-06-06 18:30:57 -0700276#define FMEM_ENABLED 0
Larry Bassel67b921d2012-04-06 10:23:27 -0700277
Olav Haugan7c6aa742012-01-16 16:47:37 -0800278#ifdef CONFIG_ION_MSM
279#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700280static struct ion_cp_heap_pdata cp_mm_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800281 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800282 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700283 .reusable = FMEM_ENABLED,
284 .mem_is_fmem = FMEM_ENABLED,
285 .fixed_position = FIXED_MIDDLE,
Laura Abbottadec9c72012-12-05 11:49:59 -0800286 .is_cma = 1,
Laura Abbott5249a052012-12-11 15:09:03 -0800287 .no_nonsecure_alloc = 1,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800288};
289
Laura Abbottb93525f2012-04-12 09:57:19 -0700290static struct ion_cp_heap_pdata cp_mfc_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800291 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800292 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700293 .reusable = 0,
294 .mem_is_fmem = FMEM_ENABLED,
295 .fixed_position = FIXED_HIGH,
Laura Abbott5249a052012-12-11 15:09:03 -0800296 .no_nonsecure_alloc = 1,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800297};
298
Laura Abbottb93525f2012-04-12 09:57:19 -0700299static struct ion_co_heap_pdata co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800300 .adjacent_mem_id = INVALID_HEAP_ID,
301 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700302 .mem_is_fmem = 0,
Olav Haugand3d29682012-01-19 10:57:07 -0800303};
304
Laura Abbottb93525f2012-04-12 09:57:19 -0700305static struct ion_co_heap_pdata fw_co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800306 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
307 .align = SZ_128K,
Larry Bassel67b921d2012-04-06 10:23:27 -0700308 .mem_is_fmem = FMEM_ENABLED,
309 .fixed_position = FIXED_LOW,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800310};
311#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800312
Laura Abbott0ae40a02012-08-10 10:49:33 -0700313static u64 msm_dmamask = DMA_BIT_MASK(32);
314
315static struct platform_device ion_mm_heap_device = {
316 .name = "ion-mm-heap-device",
317 .id = -1,
318 .dev = {
319 .dma_mask = &msm_dmamask,
320 .coherent_dma_mask = DMA_BIT_MASK(32),
321 }
322};
323
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800324/**
325 * These heaps are listed in the order they will be allocated. Due to
326 * video hardware restrictions and content protection the FW heap has to
327 * be allocated adjacent (below) the MM heap and the MFC heap has to be
328 * allocated after the MM heap to ensure MFC heap is not more than 256MB
329 * away from the base address of the FW heap.
330 * However, the order of FW heap and MM heap doesn't matter since these
331 * two heaps are taken care of by separate code to ensure they are adjacent
332 * to each other.
333 * Don't swap the order unless you know what you are doing!
334 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700335struct ion_platform_heap apq8064_heaps[] = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800336 {
337 .id = ION_SYSTEM_HEAP_ID,
338 .type = ION_HEAP_TYPE_SYSTEM,
339 .name = ION_VMALLOC_HEAP_NAME,
340 },
341#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
342 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800343 .id = ION_CP_MM_HEAP_ID,
344 .type = ION_HEAP_TYPE_CP,
345 .name = ION_MM_HEAP_NAME,
346 .size = MSM_ION_MM_SIZE,
347 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700348 .extra_data = (void *) &cp_mm_apq8064_ion_pdata,
Laura Abbott0ae40a02012-08-10 10:49:33 -0700349 .priv = &ion_mm_heap_device.dev
Olav Haugan7c6aa742012-01-16 16:47:37 -0800350 },
351 {
Olav Haugand3d29682012-01-19 10:57:07 -0800352 .id = ION_MM_FIRMWARE_HEAP_ID,
353 .type = ION_HEAP_TYPE_CARVEOUT,
354 .name = ION_MM_FIRMWARE_HEAP_NAME,
355 .size = MSM_ION_MM_FW_SIZE,
356 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700357 .extra_data = (void *) &fw_co_apq8064_ion_pdata,
Olav Haugand3d29682012-01-19 10:57:07 -0800358 },
359 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800360 .id = ION_CP_MFC_HEAP_ID,
361 .type = ION_HEAP_TYPE_CP,
362 .name = ION_MFC_HEAP_NAME,
363 .size = MSM_ION_MFC_SIZE,
364 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700365 .extra_data = (void *) &cp_mfc_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800366 },
Olav Haugan129992c2012-03-22 09:54:01 -0700367#ifndef CONFIG_MSM_IOMMU
Olav Haugan7c6aa742012-01-16 16:47:37 -0800368 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800369 .id = ION_SF_HEAP_ID,
370 .type = ION_HEAP_TYPE_CARVEOUT,
371 .name = ION_SF_HEAP_NAME,
372 .size = MSM_ION_SF_SIZE,
373 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700374 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800375 },
Olav Haugan129992c2012-03-22 09:54:01 -0700376#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800377 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800378 .id = ION_IOMMU_HEAP_ID,
379 .type = ION_HEAP_TYPE_IOMMU,
380 .name = ION_IOMMU_HEAP_NAME,
381 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800382 {
383 .id = ION_QSECOM_HEAP_ID,
384 .type = ION_HEAP_TYPE_CARVEOUT,
385 .name = ION_QSECOM_HEAP_NAME,
386 .size = MSM_ION_QSECOM_SIZE,
387 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700388 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Hauganf45e2142012-01-19 11:01:01 -0800389 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800390 {
391 .id = ION_AUDIO_HEAP_ID,
392 .type = ION_HEAP_TYPE_CARVEOUT,
393 .name = ION_AUDIO_HEAP_NAME,
394 .size = MSM_ION_AUDIO_SIZE,
395 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700396 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan2c43fac2012-01-19 11:06:37 -0800397 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800398#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -0700399};
400
401static struct ion_platform_data apq8064_ion_pdata = {
402 .nr = MSM_ION_HEAP_NUM,
403 .heaps = apq8064_heaps,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800404};
405
Laura Abbottb93525f2012-04-12 09:57:19 -0700406static struct platform_device apq8064_ion_dev = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800407 .name = "ion-msm",
408 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700409 .dev = { .platform_data = &apq8064_ion_pdata },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800410};
411#endif
412
Larry Bassel67b921d2012-04-06 10:23:27 -0700413static struct platform_device apq8064_fmem_device = {
414 .name = "fmem",
415 .id = 1,
416 .dev = { .platform_data = &apq8064_fmem_pdata },
417};
418
419static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
420 unsigned long size)
421{
422 apq8064_reserve_table[mem_type].size += size;
423}
424
425static void __init apq8064_reserve_fixed_area(unsigned long fixed_area_size)
426{
427#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
428 int ret;
429
430 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
431 panic("fixed area size is larger than %dM\n",
432 MAX_FIXED_AREA_SIZE >> 20);
433
434 reserve_info->fixed_area_size = fixed_area_size;
435 reserve_info->fixed_area_start = APQ8064_FW_START;
436
437 ret = memblock_remove(reserve_info->fixed_area_start,
438 reserve_info->fixed_area_size);
439 BUG_ON(ret);
440#endif
441}
442
443/**
444 * Reserve memory for ION and calculate amount of reusable memory for fmem.
445 * We only reserve memory for heaps that are not reusable. However, we only
446 * support one reusable heap at the moment so we ignore the reusable flag for
447 * other than the first heap with reusable flag set. Also handle special case
448 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
449 * at a higher address than FW in addition to not more than 256MB away from the
450 * base address of the firmware. This means that if MM is reusable the other
451 * two heaps must be allocated in the same region as FW. This is handled by the
452 * mem_is_fmem flag in the platform data. In addition the MM heap must be
453 * adjacent to the FW heap for content protection purposes.
454 */
Stephen Boyd668d7652012-04-25 11:31:01 -0700455static void __init reserve_ion_memory(void)
Olav Haugan7c6aa742012-01-16 16:47:37 -0800456{
457#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Larry Bassel67b921d2012-04-06 10:23:27 -0700458 unsigned int i;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700459 unsigned int ret;
Larry Bassel67b921d2012-04-06 10:23:27 -0700460 unsigned int fixed_size = 0;
461 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
462 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700463 unsigned long cma_alignment;
464 unsigned int low_use_cma = 0;
465 unsigned int middle_use_cma = 0;
466 unsigned int high_use_cma = 0;
467
Larry Bassel67b921d2012-04-06 10:23:27 -0700468
Larry Bassel67b921d2012-04-06 10:23:27 -0700469 fixed_low_size = 0;
470 fixed_middle_size = 0;
471 fixed_high_size = 0;
472
Laura Abbott0ae40a02012-08-10 10:49:33 -0700473 cma_alignment = PAGE_SIZE << max(MAX_ORDER, pageblock_order);
474
Larry Bassel67b921d2012-04-06 10:23:27 -0700475 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
Laura Abbott0ae40a02012-08-10 10:49:33 -0700476 struct ion_platform_heap *heap =
Larry Bassel67b921d2012-04-06 10:23:27 -0700477 &(apq8064_ion_pdata.heaps[i]);
Laura Abbott0ae40a02012-08-10 10:49:33 -0700478 int use_cma = 0;
479
Larry Bassel67b921d2012-04-06 10:23:27 -0700480
481 if (heap->extra_data) {
482 int fixed_position = NOT_FIXED;
Larry Bassel67b921d2012-04-06 10:23:27 -0700483
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700484 switch ((int)heap->type) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700485 case ION_HEAP_TYPE_CP:
Laura Abbott0ae40a02012-08-10 10:49:33 -0700486 if (((struct ion_cp_heap_pdata *)
487 heap->extra_data)->is_cma) {
488 heap->size = ALIGN(heap->size,
489 cma_alignment);
490 use_cma = 1;
491 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700492 fixed_position = ((struct ion_cp_heap_pdata *)
493 heap->extra_data)->fixed_position;
494 break;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700495 case ION_HEAP_TYPE_DMA:
496 use_cma = 1;
497 /* Purposely fall through here */
Larry Bassel67b921d2012-04-06 10:23:27 -0700498 case ION_HEAP_TYPE_CARVEOUT:
Larry Bassel67b921d2012-04-06 10:23:27 -0700499 fixed_position = ((struct ion_co_heap_pdata *)
500 heap->extra_data)->fixed_position;
501 break;
502 default:
503 break;
504 }
505
506 if (fixed_position != NOT_FIXED)
507 fixed_size += heap->size;
508 else
509 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
510
Laura Abbott0ae40a02012-08-10 10:49:33 -0700511 if (fixed_position == FIXED_LOW) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700512 fixed_low_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700513 low_use_cma = use_cma;
514 } else if (fixed_position == FIXED_MIDDLE) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700515 fixed_middle_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700516 middle_use_cma = use_cma;
517 } else if (fixed_position == FIXED_HIGH) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700518 fixed_high_size += heap->size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700519 high_use_cma = use_cma;
520 } else if (use_cma) {
521 /*
522 * Heaps that use CMA but are not part of the
523 * fixed set. Create wherever.
524 */
525 dma_declare_contiguous(
526 heap->priv,
527 heap->size,
528 0,
529 0xb0000000);
530
531 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700532 }
533 }
534
535 if (!fixed_size)
536 return;
537
Laura Abbott0ae40a02012-08-10 10:49:33 -0700538 /*
539 * Given the setup for the fixed area, we can't round up all sizes.
540 * Some sizes must be set up exactly and aligned correctly. Incorrect
541 * alignments are considered a configuration issue
Larry Bassel67b921d2012-04-06 10:23:27 -0700542 */
Larry Bassel67b921d2012-04-06 10:23:27 -0700543
544 fixed_low_start = APQ8064_FIXED_AREA_START;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700545 if (low_use_cma) {
546 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, cma_alignment));
547 BUG_ON(!IS_ALIGNED(fixed_low_start, cma_alignment));
548 } else {
549 BUG_ON(!IS_ALIGNED(fixed_low_size + HOLE_SIZE, SECTION_SIZE));
550 ret = memblock_remove(fixed_low_start,
551 fixed_low_size + HOLE_SIZE);
552 BUG_ON(ret);
553 }
554
Hanumant Singheadb7502012-05-15 18:14:04 -0700555 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700556 if (middle_use_cma) {
557 BUG_ON(!IS_ALIGNED(fixed_middle_start, cma_alignment));
558 BUG_ON(!IS_ALIGNED(fixed_middle_size, cma_alignment));
559 } else {
560 BUG_ON(!IS_ALIGNED(fixed_middle_size, SECTION_SIZE));
561 ret = memblock_remove(fixed_middle_start, fixed_middle_size);
562 BUG_ON(ret);
563 }
564
Larry Bassel67b921d2012-04-06 10:23:27 -0700565 fixed_high_start = fixed_middle_start + fixed_middle_size;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700566 if (high_use_cma) {
567 fixed_high_size = ALIGN(fixed_high_size, cma_alignment);
568 BUG_ON(!IS_ALIGNED(fixed_high_start, cma_alignment));
569 } else {
570 /* This is the end of the fixed area so it's okay to round up */
571 fixed_high_size = ALIGN(fixed_high_size, SECTION_SIZE);
572 ret = memblock_remove(fixed_high_start, fixed_high_size);
573 BUG_ON(ret);
574 }
Larry Bassel67b921d2012-04-06 10:23:27 -0700575
576 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
577 struct ion_platform_heap *heap = &(apq8064_ion_pdata.heaps[i]);
578
579 if (heap->extra_data) {
580 int fixed_position = NOT_FIXED;
Steve Mucklef132c6c2012-06-06 18:30:57 -0700581 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel67b921d2012-04-06 10:23:27 -0700582
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -0700583 switch ((int) heap->type) {
Larry Bassel67b921d2012-04-06 10:23:27 -0700584 case ION_HEAP_TYPE_CP:
Hanumant Singheadb7502012-05-15 18:14:04 -0700585 pdata =
586 (struct ion_cp_heap_pdata *)heap->extra_data;
587 fixed_position = pdata->fixed_position;
Larry Bassel67b921d2012-04-06 10:23:27 -0700588 break;
589 case ION_HEAP_TYPE_CARVEOUT:
Laura Abbott0ae40a02012-08-10 10:49:33 -0700590 case ION_HEAP_TYPE_DMA:
Larry Bassel67b921d2012-04-06 10:23:27 -0700591 fixed_position = ((struct ion_co_heap_pdata *)
592 heap->extra_data)->fixed_position;
593 break;
594 default:
595 break;
596 }
597
598 switch (fixed_position) {
599 case FIXED_LOW:
600 heap->base = fixed_low_start;
601 break;
602 case FIXED_MIDDLE:
603 heap->base = fixed_middle_start;
Laura Abbott0ae40a02012-08-10 10:49:33 -0700604 if (middle_use_cma) {
605 ret = dma_declare_contiguous(
606 heap->priv,
607 heap->size,
608 fixed_middle_start,
609 0xa0000000);
610 WARN_ON(ret);
611 }
Hanumant Singheadb7502012-05-15 18:14:04 -0700612 pdata->secure_base = fixed_middle_start
613 - HOLE_SIZE;
614 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel67b921d2012-04-06 10:23:27 -0700615 break;
616 case FIXED_HIGH:
617 heap->base = fixed_high_start;
618 break;
619 default:
620 break;
621 }
622 }
623 }
Olav Haugan7c6aa742012-01-16 16:47:37 -0800624#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700625}
626
Huaibin Yang4a084e32011-12-15 15:25:52 -0800627static void __init reserve_mdp_memory(void)
628{
629 apq8064_mdp_writeback(apq8064_reserve_table);
630}
631
Laura Abbott93a4a352012-05-25 09:26:35 -0700632static void __init reserve_cache_dump_memory(void)
633{
634#ifdef CONFIG_MSM_CACHE_DUMP
635 unsigned int total;
636
637 total = apq8064_cache_dump_pdata.l1_size +
638 apq8064_cache_dump_pdata.l2_size;
639 apq8064_reserve_table[MEMTYPE_EBI1].size += total;
640#endif
641}
642
Abhijeet Dharmapurikar3edb5de2012-09-13 11:02:03 -0700643static void __init reserve_mpdcvs_memory(void)
644{
645 apq8064_reserve_table[MEMTYPE_EBI1].size += SZ_32K;
646}
647
Kevin Chan13be4e22011-10-20 11:30:32 -0700648static void __init apq8064_calculate_reserve_sizes(void)
649{
650 size_pmem_devices();
651 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800652 reserve_ion_memory();
Huaibin Yang4a084e32011-12-15 15:25:52 -0800653 reserve_mdp_memory();
Laura Abbott350c8362012-02-28 14:46:52 -0800654 reserve_rtb_memory();
Laura Abbott93a4a352012-05-25 09:26:35 -0700655 reserve_cache_dump_memory();
Abhijeet Dharmapurikar3edb5de2012-09-13 11:02:03 -0700656 reserve_mpdcvs_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700657}
658
659static struct reserve_info apq8064_reserve_info __initdata = {
660 .memtype_reserve_table = apq8064_reserve_table,
661 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
Larry Bassel67b921d2012-04-06 10:23:27 -0700662 .reserve_fixed_area = apq8064_reserve_fixed_area,
Kevin Chan13be4e22011-10-20 11:30:32 -0700663 .paddr_to_memtype = apq8064_paddr_to_memtype,
664};
665
666static int apq8064_memory_bank_size(void)
667{
668 return 1<<29;
669}
670
671static void __init locate_unstable_memory(void)
672{
673 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
674 unsigned long bank_size;
675 unsigned long low, high;
676
677 bank_size = apq8064_memory_bank_size();
678 low = meminfo.bank[0].start;
679 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800680
681 /* Check if 32 bit overflow occured */
682 if (high < mb->start)
Larry Bassel67b921d2012-04-06 10:23:27 -0700683 high = -PAGE_SIZE;
Olav Haugand76e3a82012-01-16 16:55:07 -0800684
Kevin Chan13be4e22011-10-20 11:30:32 -0700685 low &= ~(bank_size - 1);
686
687 if (high - low <= bank_size)
Larry Bassel67b921d2012-04-06 10:23:27 -0700688 goto no_dmm;
689
690#ifdef CONFIG_ENABLE_DMM
Jack Cheung46bfffa2012-01-19 15:26:24 -0800691 apq8064_reserve_info.low_unstable_address = mb->start -
692 MIN_MEMORY_BLOCK_SIZE + mb->size;
693 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
694
Kevin Chan13be4e22011-10-20 11:30:32 -0700695 apq8064_reserve_info.bank_size = bank_size;
696 pr_info("low unstable address %lx max size %lx bank size %lx\n",
697 apq8064_reserve_info.low_unstable_address,
698 apq8064_reserve_info.max_unstable_size,
699 apq8064_reserve_info.bank_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700700 return;
701#endif
702no_dmm:
703 apq8064_reserve_info.low_unstable_address = high;
704 apq8064_reserve_info.max_unstable_size = 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700705}
706
Hanumant Singh50440d42012-04-23 19:27:16 -0700707static int apq8064_change_memory_power(u64 start, u64 size,
708 int change_type)
709{
710 return soc_change_memory_power(start, size, change_type);
711}
712
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700713static char prim_panel_name[PANEL_NAME_MAX_LEN];
714static char ext_panel_name[PANEL_NAME_MAX_LEN];
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530715
716static int ext_resolution;
717
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700718static int __init prim_display_setup(char *param)
719{
720 if (strnlen(param, PANEL_NAME_MAX_LEN))
721 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
722 return 0;
723}
724early_param("prim_display", prim_display_setup);
725
726static int __init ext_display_setup(char *param)
727{
728 if (strnlen(param, PANEL_NAME_MAX_LEN))
729 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
730 return 0;
731}
732early_param("ext_display", ext_display_setup);
733
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530734static int __init hdmi_resulution_setup(char *param)
735{
736 int ret;
737 ret = kstrtoint(param, 10, &ext_resolution);
738 return ret;
739}
740early_param("ext_resolution", hdmi_resulution_setup);
741
Kevin Chan13be4e22011-10-20 11:30:32 -0700742static void __init apq8064_reserve(void)
743{
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530744 apq8064_set_display_params(prim_panel_name, ext_panel_name,
745 ext_resolution);
Kevin Chan13be4e22011-10-20 11:30:32 -0700746 msm_reserve();
747}
748
Laura Abbott6988cef2012-03-15 14:27:13 -0700749static void __init place_movable_zone(void)
750{
Larry Bassel67b921d2012-04-06 10:23:27 -0700751#ifdef CONFIG_ENABLE_DMM
Laura Abbott6988cef2012-03-15 14:27:13 -0700752 movable_reserved_start = apq8064_reserve_info.low_unstable_address;
753 movable_reserved_size = apq8064_reserve_info.max_unstable_size;
754 pr_info("movable zone start %lx size %lx\n",
755 movable_reserved_start, movable_reserved_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700756#endif
Laura Abbott6988cef2012-03-15 14:27:13 -0700757}
758
759static void __init apq8064_early_reserve(void)
760{
761 reserve_info = &apq8064_reserve_info;
762 locate_unstable_memory();
763 place_movable_zone();
764
765}
Hemant Kumara945b472012-01-25 15:08:06 -0800766#ifdef CONFIG_USB_EHCI_MSM_HSIC
Hemant Kumare6275972012-02-29 20:06:21 -0800767/* Bandwidth requests (zero) if no vote placed */
768static struct msm_bus_vectors hsic_init_vectors[] = {
769 {
770 .src = MSM_BUS_MASTER_SPS,
771 .dst = MSM_BUS_SLAVE_EBI_CH0,
772 .ab = 0,
773 .ib = 0,
774 },
775 {
776 .src = MSM_BUS_MASTER_SPS,
777 .dst = MSM_BUS_SLAVE_SPS,
778 .ab = 0,
779 .ib = 0,
780 },
781};
782
783/* Bus bandwidth requests in Bytes/sec */
784static struct msm_bus_vectors hsic_max_vectors[] = {
785 {
786 .src = MSM_BUS_MASTER_SPS,
787 .dst = MSM_BUS_SLAVE_EBI_CH0,
788 .ab = 60000000, /* At least 480Mbps on bus. */
789 .ib = 960000000, /* MAX bursts rate */
790 },
791 {
792 .src = MSM_BUS_MASTER_SPS,
793 .dst = MSM_BUS_SLAVE_SPS,
794 .ab = 0,
795 .ib = 512000000, /*vote for 64Mhz dfab clk rate*/
796 },
797};
798
799static struct msm_bus_paths hsic_bus_scale_usecases[] = {
800 {
801 ARRAY_SIZE(hsic_init_vectors),
802 hsic_init_vectors,
803 },
804 {
805 ARRAY_SIZE(hsic_max_vectors),
806 hsic_max_vectors,
807 },
808};
809
810static struct msm_bus_scale_pdata hsic_bus_scale_pdata = {
811 hsic_bus_scale_usecases,
812 ARRAY_SIZE(hsic_bus_scale_usecases),
813 .name = "hsic",
814};
815
Hemant Kumara945b472012-01-25 15:08:06 -0800816static struct msm_hsic_host_platform_data msm_hsic_pdata = {
Hemant Kumare6275972012-02-29 20:06:21 -0800817 .strobe = 88,
818 .data = 89,
819 .bus_scale_table = &hsic_bus_scale_pdata,
Hemant Kumara945b472012-01-25 15:08:06 -0800820};
821#else
822static struct msm_hsic_host_platform_data msm_hsic_pdata;
823#endif
824
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800825#define PID_MAGIC_ID 0x71432909
826#define SERIAL_NUM_MAGIC_ID 0x61945374
827#define SERIAL_NUMBER_LENGTH 127
828#define DLOAD_USB_BASE_ADD 0x2A03F0C8
829
830struct magic_num_struct {
831 uint32_t pid;
832 uint32_t serial_num;
833};
834
835struct dload_struct {
836 uint32_t reserved1;
837 uint32_t reserved2;
838 uint32_t reserved3;
839 uint16_t reserved4;
840 uint16_t pid;
841 char serial_number[SERIAL_NUMBER_LENGTH];
842 uint16_t reserved5;
843 struct magic_num_struct magic_struct;
844};
845
846static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
847{
848 struct dload_struct __iomem *dload = 0;
849
850 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
851 if (!dload) {
852 pr_err("%s: cannot remap I/O memory region: %08x\n",
853 __func__, DLOAD_USB_BASE_ADD);
854 return -ENXIO;
855 }
856
857 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
858 __func__, dload, pid, snum);
859 /* update pid */
860 dload->magic_struct.pid = PID_MAGIC_ID;
861 dload->pid = pid;
862
863 /* update serial number */
864 dload->magic_struct.serial_num = 0;
865 if (!snum) {
866 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
867 goto out;
868 }
869
870 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
871 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
872out:
873 iounmap(dload);
874 return 0;
875}
876
877static struct android_usb_platform_data android_usb_pdata = {
878 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
879};
880
Hemant Kumar4933b072011-10-17 23:43:11 -0700881static struct platform_device android_usb_device = {
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800882 .name = "android_usb",
883 .id = -1,
884 .dev = {
885 .platform_data = &android_usb_pdata,
886 },
Hemant Kumar4933b072011-10-17 23:43:11 -0700887};
888
Hemant Kumar7620eed2012-02-26 09:08:43 -0800889/* Bandwidth requests (zero) if no vote placed */
890static struct msm_bus_vectors usb_init_vectors[] = {
891 {
892 .src = MSM_BUS_MASTER_SPS,
893 .dst = MSM_BUS_SLAVE_EBI_CH0,
894 .ab = 0,
895 .ib = 0,
896 },
897};
898
899/* Bus bandwidth requests in Bytes/sec */
900static struct msm_bus_vectors usb_max_vectors[] = {
901 {
902 .src = MSM_BUS_MASTER_SPS,
903 .dst = MSM_BUS_SLAVE_EBI_CH0,
904 .ab = 60000000, /* At least 480Mbps on bus. */
905 .ib = 960000000, /* MAX bursts rate */
906 },
907};
908
909static struct msm_bus_paths usb_bus_scale_usecases[] = {
910 {
911 ARRAY_SIZE(usb_init_vectors),
912 usb_init_vectors,
913 },
914 {
915 ARRAY_SIZE(usb_max_vectors),
916 usb_max_vectors,
917 },
918};
919
920static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
921 usb_bus_scale_usecases,
922 ARRAY_SIZE(usb_bus_scale_usecases),
923 .name = "usb",
924};
925
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700926static int phy_init_seq[] = {
927 0x38, 0x81, /* update DC voltage level */
928 0x24, 0x82, /* set pre-emphasis and rise/fall time */
929 -1
930};
931
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530932#define PMIC_GPIO_DP 27 /* PMIC GPIO for D+ change */
933#define PMIC_GPIO_DP_IRQ PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PMIC_GPIO_DP)
Jack Pham87f202f2012-08-06 00:24:22 -0700934#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
935
Hemant Kumar4933b072011-10-17 23:43:11 -0700936static struct msm_otg_platform_data msm_otg_pdata = {
Hemant Kumard86c4882012-01-24 19:39:37 -0800937 .mode = USB_OTG,
938 .otg_control = OTG_PMIC_CONTROL,
Hemant Kumar4933b072011-10-17 23:43:11 -0700939 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumard86c4882012-01-24 19:39:37 -0800940 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
941 .power_budget = 750,
Hemant Kumar7620eed2012-02-26 09:08:43 -0800942 .bus_scale_table = &usb_bus_scale_pdata,
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700943 .phy_init_seq = phy_init_seq,
Jack Pham87f202f2012-08-06 00:24:22 -0700944 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Hemant Kumar4933b072011-10-17 23:43:11 -0700945};
946
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800947static struct msm_usb_host_platform_data msm_ehci_host_pdata3 = {
Manu Gautam91223e02011-11-08 15:27:22 +0530948 .power_budget = 500,
949};
950
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800951#ifdef CONFIG_USB_EHCI_MSM_HOST4
952static struct msm_usb_host_platform_data msm_ehci_host_pdata4;
953#endif
954
Manu Gautam91223e02011-11-08 15:27:22 +0530955static void __init apq8064_ehci_host_init(void)
956{
Chiranjeevi Velempatib822fa32012-05-23 22:05:59 +0530957 if (machine_is_apq8064_liquid() || machine_is_mpq8064_cdp() ||
958 machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
959 if (machine_is_apq8064_liquid())
960 msm_ehci_host_pdata3.dock_connect_irq =
961 PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9);
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530962 else
963 msm_ehci_host_pdata3.pmic_gpio_dp_irq =
964 PMIC_GPIO_DP_IRQ;
Hemant Kumar56925352012-02-13 16:59:52 -0800965
Manu Gautam91223e02011-11-08 15:27:22 +0530966 apq8064_device_ehci_host3.dev.platform_data =
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800967 &msm_ehci_host_pdata3;
Manu Gautam91223e02011-11-08 15:27:22 +0530968 platform_device_register(&apq8064_device_ehci_host3);
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800969
970#ifdef CONFIG_USB_EHCI_MSM_HOST4
971 apq8064_device_ehci_host4.dev.platform_data =
972 &msm_ehci_host_pdata4;
973 platform_device_register(&apq8064_device_ehci_host4);
974#endif
Manu Gautam91223e02011-11-08 15:27:22 +0530975 }
976}
977
David Keitel2f613d92012-02-15 11:29:16 -0800978static struct smb349_platform_data smb349_data __initdata = {
979 .en_n_gpio = PM8921_GPIO_PM_TO_SYS(37),
980 .chg_susp_gpio = PM8921_GPIO_PM_TO_SYS(30),
981 .chg_current_ma = 2200,
982};
983
984static struct i2c_board_info smb349_charger_i2c_info[] __initdata = {
985 {
986 I2C_BOARD_INFO(SMB349_NAME, 0x1B),
987 .platform_data = &smb349_data,
988 },
989};
990
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -0800991struct sx150x_platform_data apq8064_sx150x_data[] = {
992 [SX150X_EPM] = {
993 .gpio_base = GPIO_EPM_EXPANDER_BASE,
994 .oscio_is_gpo = false,
995 .io_pullup_ena = 0x0,
996 .io_pulldn_ena = 0x0,
997 .io_open_drain_ena = 0x0,
998 .io_polarity = 0,
999 .irq_summary = -1,
1000 },
1001};
1002
1003static struct epm_chan_properties ads_adc_channel_data[] = {
Yan Hec942e402012-08-31 11:14:58 -07001004 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
1005 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
1006 {10, 100}, {20, 100}, {500, 100}, {5, 100},
1007 {1000, 1}, {200, 100}, {50, 100}, {10, 100},
1008 {510, 100}, {50, 100}, {20, 100}, {100, 100},
1009 {510, 100}, {20, 100}, {50, 100}, {200, 100},
1010 {10, 100}, {20, 100}, {1000, 1}, {10, 100},
1011 {200, 100}, {510, 100}, {1000, 100}, {200, 100},
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08001012};
1013
1014static struct epm_adc_platform_data epm_adc_pdata = {
1015 .channel = ads_adc_channel_data,
1016 .bus_id = 0x0,
1017 .epm_i2c_board_info = {
1018 .type = "sx1509q",
1019 .addr = 0x3e,
1020 .platform_data = &apq8064_sx150x_data[SX150X_EPM],
1021 },
1022 .gpio_expander_base_addr = GPIO_EPM_EXPANDER_BASE,
1023};
1024
1025static struct platform_device epm_adc_device = {
1026 .name = "epm_adc",
1027 .id = -1,
1028 .dev = {
1029 .platform_data = &epm_adc_pdata,
1030 },
1031};
1032
1033static void __init apq8064_epm_adc_init(void)
1034{
1035 epm_adc_pdata.num_channels = 32;
1036 epm_adc_pdata.num_adc = 2;
1037 epm_adc_pdata.chan_per_adc = 16;
1038 epm_adc_pdata.chan_per_mux = 8;
1039};
1040
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001041/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1042 * 4 micbiases are used to power various analog and digital
1043 * microphones operating at 1800 mV. Technically, all micbiases
1044 * can source from single cfilter since all microphones operate
1045 * at the same voltage level. The arrangement below is to make
1046 * sure all cfilters are exercised. LDO_H regulator ouput level
1047 * does not need to be as high as 2.85V. It is choosen for
1048 * microphone sensitivity purpose.
1049 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301050static struct wcd9xxx_pdata apq8064_tabla_platform_data = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001051 .slimbus_slave_device = {
1052 .name = "tabla-slave",
1053 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1054 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001055 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001056 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301057 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001058 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1059 .micbias = {
1060 .ldoh_v = TABLA_LDOH_2P85_V,
1061 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001062 .cfilt2_mv = 2700,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001063 .cfilt3_mv = 1800,
1064 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1065 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1066 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1067 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301068 },
1069 .regulator = {
1070 {
1071 .name = "CDC_VDD_CP",
1072 .min_uV = 1800000,
1073 .max_uV = 1800000,
1074 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1075 },
1076 {
1077 .name = "CDC_VDDA_RX",
1078 .min_uV = 1800000,
1079 .max_uV = 1800000,
1080 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1081 },
1082 {
1083 .name = "CDC_VDDA_TX",
1084 .min_uV = 1800000,
1085 .max_uV = 1800000,
1086 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1087 },
1088 {
1089 .name = "VDDIO_CDC",
1090 .min_uV = 1800000,
1091 .max_uV = 1800000,
1092 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1093 },
1094 {
1095 .name = "VDDD_CDC_D",
1096 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001097 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301098 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1099 },
1100 {
1101 .name = "CDC_VDDA_A_1P2V",
1102 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001103 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301104 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1105 },
1106 },
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001107};
1108
1109static struct slim_device apq8064_slim_tabla = {
1110 .name = "tabla-slim",
1111 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1112 .dev = {
1113 .platform_data = &apq8064_tabla_platform_data,
1114 },
1115};
1116
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301117static struct wcd9xxx_pdata apq8064_tabla20_platform_data = {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001118 .slimbus_slave_device = {
1119 .name = "tabla-slave",
1120 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
1121 },
1122 .irq = MSM_GPIO_TO_INT(42),
1123 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301124 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001125 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1126 .micbias = {
1127 .ldoh_v = TABLA_LDOH_2P85_V,
1128 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001129 .cfilt2_mv = 2700,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001130 .cfilt3_mv = 1800,
1131 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1132 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1133 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1134 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301135 },
1136 .regulator = {
1137 {
1138 .name = "CDC_VDD_CP",
1139 .min_uV = 1800000,
1140 .max_uV = 1800000,
1141 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1142 },
1143 {
1144 .name = "CDC_VDDA_RX",
1145 .min_uV = 1800000,
1146 .max_uV = 1800000,
1147 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1148 },
1149 {
1150 .name = "CDC_VDDA_TX",
1151 .min_uV = 1800000,
1152 .max_uV = 1800000,
1153 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1154 },
1155 {
1156 .name = "VDDIO_CDC",
1157 .min_uV = 1800000,
1158 .max_uV = 1800000,
1159 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1160 },
1161 {
1162 .name = "VDDD_CDC_D",
1163 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001164 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301165 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1166 },
1167 {
1168 .name = "CDC_VDDA_A_1P2V",
1169 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001170 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301171 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1172 },
1173 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001174};
1175
1176static struct slim_device apq8064_slim_tabla20 = {
1177 .name = "tabla2x-slim",
1178 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1179 .dev = {
1180 .platform_data = &apq8064_tabla20_platform_data,
1181 },
1182};
1183
Santosh Mardi695be0d2012-04-10 23:21:12 +05301184/* enable the level shifter for cs8427 to make sure the I2C
1185 * clock is running at 100KHz and voltage levels are at 3.3
1186 * and 5 volts
1187 */
1188static int enable_100KHz_ls(int enable)
1189{
1190 int ret = 0;
1191 if (enable) {
1192 ret = gpio_request(SX150X_GPIO(1, 10),
1193 "cs8427_100KHZ_ENABLE");
1194 if (ret) {
1195 pr_err("%s: Failed to request gpio %d\n", __func__,
1196 SX150X_GPIO(1, 10));
1197 return ret;
1198 }
1199 gpio_direction_output(SX150X_GPIO(1, 10), 1);
Santosh Mardid706fcf2012-08-31 19:26:54 +05301200 } else {
1201 gpio_direction_output(SX150X_GPIO(1, 10), 0);
Santosh Mardi695be0d2012-04-10 23:21:12 +05301202 gpio_free(SX150X_GPIO(1, 10));
Santosh Mardid706fcf2012-08-31 19:26:54 +05301203 }
Santosh Mardi695be0d2012-04-10 23:21:12 +05301204 return ret;
1205}
1206
Santosh Mardieff9a742012-04-09 23:23:39 +05301207static struct cs8427_platform_data cs8427_i2c_platform_data = {
1208 .irq = SX150X_GPIO(1, 4),
1209 .reset_gpio = SX150X_GPIO(1, 6),
Santosh Mardi695be0d2012-04-10 23:21:12 +05301210 .enable = enable_100KHz_ls,
Santosh Mardieff9a742012-04-09 23:23:39 +05301211};
1212
1213static struct i2c_board_info cs8427_device_info[] __initdata = {
1214 {
1215 I2C_BOARD_INFO("cs8427", CS8427_ADDR4),
1216 .platform_data = &cs8427_i2c_platform_data,
1217 },
1218};
1219
Amy Maloche70090f992012-02-16 16:35:26 -08001220#define HAP_SHIFT_LVL_OE_GPIO PM8921_MPP_PM_TO_SYS(8)
1221#define ISA1200_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1222#define ISA1200_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
David Collins6f7c3472012-08-22 13:18:06 -07001223#define ISA1200_HAP_CLK_PM8921 PM8921_GPIO_PM_TO_SYS(44)
1224#define ISA1200_HAP_CLK_PM8917 PM8921_GPIO_PM_TO_SYS(38)
Amy Maloche70090f992012-02-16 16:35:26 -08001225
Mohan Pallaka2d877602012-05-11 13:07:30 +05301226static int isa1200_clk_enable(bool on)
Amy Maloche70090f992012-02-16 16:35:26 -08001227{
David Collins6f7c3472012-08-22 13:18:06 -07001228 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche8f973892012-03-26 14:53:13 -07001229 int rc = 0;
1230
David Collins6f7c3472012-08-22 13:18:06 -07001231 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1232 gpio = ISA1200_HAP_CLK_PM8917;
1233
1234 gpio_set_value_cansleep(gpio, on);
Amy Maloche70090f992012-02-16 16:35:26 -08001235
Mohan Pallaka2d877602012-05-11 13:07:30 +05301236 if (on) {
Amy Maloche8f973892012-03-26 14:53:13 -07001237 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_1, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301238 if (rc) {
1239 pr_err("%s: unable to write aux clock register(%d)\n",
1240 __func__, rc);
1241 goto err_gpio_dis;
1242 }
1243 } else {
Amy Maloche8f973892012-03-26 14:53:13 -07001244 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_NONE, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301245 if (rc)
1246 pr_err("%s: unable to write aux clock register(%d)\n",
1247 __func__, rc);
Amy Maloche8f973892012-03-26 14:53:13 -07001248 }
1249
1250 return rc;
Mohan Pallaka2d877602012-05-11 13:07:30 +05301251
1252err_gpio_dis:
David Collins6f7c3472012-08-22 13:18:06 -07001253 gpio_set_value_cansleep(gpio, !on);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301254 return rc;
Amy Maloche70090f992012-02-16 16:35:26 -08001255}
1256
1257static int isa1200_dev_setup(bool enable)
1258{
David Collins6f7c3472012-08-22 13:18:06 -07001259 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche70090f992012-02-16 16:35:26 -08001260 int rc = 0;
1261
David Collins6f7c3472012-08-22 13:18:06 -07001262 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1263 gpio = ISA1200_HAP_CLK_PM8917;
1264
Amy Maloche70090f992012-02-16 16:35:26 -08001265 if (!enable)
1266 goto free_gpio;
1267
David Collins6f7c3472012-08-22 13:18:06 -07001268 rc = gpio_request(gpio, "haptics_clk");
Amy Maloche70090f992012-02-16 16:35:26 -08001269 if (rc) {
1270 pr_err("%s: unable to request gpio %d config(%d)\n",
David Collins6f7c3472012-08-22 13:18:06 -07001271 __func__, gpio, rc);
Amy Maloche70090f992012-02-16 16:35:26 -08001272 return rc;
1273 }
1274
David Collins6f7c3472012-08-22 13:18:06 -07001275 rc = gpio_direction_output(gpio, 0);
Amy Maloche70090f992012-02-16 16:35:26 -08001276 if (rc) {
1277 pr_err("%s: unable to set direction\n", __func__);
1278 goto free_gpio;
1279 }
1280
1281 return 0;
1282
1283free_gpio:
David Collins6f7c3472012-08-22 13:18:06 -07001284 gpio_free(gpio);
Amy Maloche70090f992012-02-16 16:35:26 -08001285 return rc;
1286}
1287
1288static struct isa1200_regulator isa1200_reg_data[] = {
1289 {
1290 .name = "vddp",
1291 .min_uV = ISA_I2C_VTG_MIN_UV,
1292 .max_uV = ISA_I2C_VTG_MAX_UV,
1293 .load_uA = ISA_I2C_CURR_UA,
1294 },
1295};
1296
1297static struct isa1200_platform_data isa1200_1_pdata = {
1298 .name = "vibrator",
1299 .dev_setup = isa1200_dev_setup,
Mohan Pallaka2d877602012-05-11 13:07:30 +05301300 .clk_enable = isa1200_clk_enable,
Mohan Pallaka32f20a72012-06-14 14:41:11 +05301301 .need_pwm_clk = true,
Amy Maloche70090f992012-02-16 16:35:26 -08001302 .hap_en_gpio = ISA1200_HAP_EN_GPIO,
1303 .hap_len_gpio = ISA1200_HAP_LEN_GPIO,
1304 .max_timeout = 15000,
1305 .mode_ctrl = PWM_GEN_MODE,
1306 .pwm_fd = {
1307 .pwm_div = 256,
1308 },
1309 .is_erm = false,
1310 .smart_en = true,
1311 .ext_clk_en = true,
1312 .chip_en = 1,
1313 .regulator_info = isa1200_reg_data,
1314 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1315};
1316
1317static struct i2c_board_info isa1200_board_info[] __initdata = {
1318 {
1319 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1320 .platform_data = &isa1200_1_pdata,
1321 },
1322};
Jing Lin21ed4de2012-02-05 15:53:28 -08001323/* configuration data for mxt1386e using V2.1 firmware */
1324static const u8 mxt1386e_config_data_v2_1[] = {
1325 /* T6 Object */
1326 0, 0, 0, 0, 0, 0,
1327 /* T38 Object */
Jing Line4c47042012-08-31 10:54:44 -07001328 14, 3, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001329 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1330 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,
1335 /* T7 Object */
Jing Line4c47042012-08-31 10:54:44 -07001336 32, 10, 50,
Jing Lin21ed4de2012-02-05 15:53:28 -08001337 /* T8 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001338 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001339 /* T9 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001340 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Line4c47042012-08-31 10:54:44 -07001341 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Linf1208fd2012-02-23 11:15:42 -08001342 85, 5, 0, 5, 9, 5, 12, 35, 70, 40,
1343 20, 5, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001344 /* T18 Object */
1345 0, 0,
1346 /* T24 Object */
1347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1348 0, 0, 0, 0, 0, 0, 0, 0, 0,
1349 /* T25 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001350 1, 0, 60, 115, 156, 99,
Jing Lin21ed4de2012-02-05 15:53:28 -08001351 /* T27 Object */
1352 0, 0, 0, 0, 0, 0, 0,
1353 /* T40 Object */
1354 0, 0, 0, 0, 0,
1355 /* T42 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001356 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001357 /* T43 Object */
1358 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
1359 16,
1360 /* T46 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001361 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001362 /* T47 Object */
1363 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
1364 /* T48 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001365 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001366 32, 40, 0, 10, 10, 0, 0, 100, 10, 90,
1367 0, 0, 0, 0, 0, 0, 0, 10, 1, 10,
1368 52, 10, 12, 0, 33, 0, 1, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001369 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1370 0, 0, 0, 0,
1371 /* T56 Object */
1372 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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,
Jing Linf1208fd2012-02-23 11:15:42 -08001376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1377 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001378};
1379
1380#define MXT_TS_GPIO_IRQ 6
1381#define MXT_TS_PWR_EN_GPIO PM8921_GPIO_PM_TO_SYS(23)
1382#define MXT_TS_RESET_GPIO 33
1383
1384static struct mxt_config_info mxt_config_array[] = {
1385 {
1386 .config = mxt1386e_config_data_v2_1,
1387 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1388 .family_id = 0xA0,
1389 .variant_id = 0x7,
1390 .version = 0x21,
1391 .build = 0xAA,
Jing Linef4aa9b2012-03-26 12:01:41 -07001392 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
1393 .fw_name = "atmel_8064_liquid_v2_2_AA.hex",
1394 },
1395 {
1396 /* The config data for V2.2.AA is the same as for V2.1.AA */
1397 .config = mxt1386e_config_data_v2_1,
1398 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1399 .family_id = 0xA0,
1400 .variant_id = 0x7,
1401 .version = 0x22,
1402 .build = 0xAA,
1403 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin21ed4de2012-02-05 15:53:28 -08001404 },
1405};
1406
1407static struct mxt_platform_data mxt_platform_data = {
1408 .config_array = mxt_config_array,
1409 .config_array_size = ARRAY_SIZE(mxt_config_array),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08001410 .panel_minx = 0,
1411 .panel_maxx = 1365,
1412 .panel_miny = 0,
1413 .panel_maxy = 767,
1414 .disp_minx = 0,
1415 .disp_maxx = 1365,
1416 .disp_miny = 0,
1417 .disp_maxy = 767,
Anirudh Ghayal39dbe3f2012-04-13 15:43:16 +05301418 .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Jing Lin21ed4de2012-02-05 15:53:28 -08001419 .i2c_pull_up = true,
1420 .reset_gpio = MXT_TS_RESET_GPIO,
1421 .irq_gpio = MXT_TS_GPIO_IRQ,
1422};
1423
1424static struct i2c_board_info mxt_device_info[] __initdata = {
1425 {
1426 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
1427 .platform_data = &mxt_platform_data,
1428 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1429 },
1430};
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001431#define CYTTSP_TS_GPIO_IRQ 6
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001432#define CYTTSP_TS_GPIO_SLEEP 33
Amy Maloche609bb5e2012-08-03 09:41:42 -07001433#define CYTTSP_TS_GPIO_SLEEP_ALT 12
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001434
1435static ssize_t tma340_vkeys_show(struct kobject *kobj,
1436 struct kobj_attribute *attr, char *buf)
1437{
1438 return snprintf(buf, 200,
1439 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1440 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1441 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1442 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1443 "\n");
1444}
1445
1446static struct kobj_attribute tma340_vkeys_attr = {
1447 .attr = {
1448 .mode = S_IRUGO,
1449 },
1450 .show = &tma340_vkeys_show,
1451};
1452
1453static struct attribute *tma340_properties_attrs[] = {
1454 &tma340_vkeys_attr.attr,
1455 NULL
1456};
1457
1458static struct attribute_group tma340_properties_attr_group = {
1459 .attrs = tma340_properties_attrs,
1460};
1461
1462static int cyttsp_platform_init(struct i2c_client *client)
1463{
1464 int rc = 0;
1465 static struct kobject *tma340_properties_kobj;
1466
1467 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1468 tma340_properties_kobj = kobject_create_and_add("board_properties",
1469 NULL);
1470 if (tma340_properties_kobj)
1471 rc = sysfs_create_group(tma340_properties_kobj,
1472 &tma340_properties_attr_group);
1473 if (!tma340_properties_kobj || rc)
1474 pr_err("%s: failed to create board_properties\n",
1475 __func__);
1476
1477 return 0;
1478}
1479
1480static struct cyttsp_regulator cyttsp_regulator_data[] = {
1481 {
1482 .name = "vdd",
1483 .min_uV = CY_TMA300_VTG_MIN_UV,
1484 .max_uV = CY_TMA300_VTG_MAX_UV,
1485 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1486 .lpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1487 },
1488 {
1489 .name = "vcc_i2c",
1490 .min_uV = CY_I2C_VTG_MIN_UV,
1491 .max_uV = CY_I2C_VTG_MAX_UV,
1492 .hpm_load_uA = CY_I2C_CURR_UA,
1493 .lpm_load_uA = CY_I2C_CURR_UA,
1494 },
1495};
1496
1497static struct cyttsp_platform_data cyttsp_pdata = {
1498 .panel_maxx = 634,
1499 .panel_maxy = 1166,
1500 .disp_maxx = 599,
1501 .disp_maxy = 1023,
1502 .disp_minx = 0,
1503 .disp_miny = 0,
1504 .flags = 0x01,
1505 .gen = CY_GEN3,
1506 .use_st = CY_USE_ST,
1507 .use_mt = CY_USE_MT,
1508 .use_hndshk = CY_SEND_HNDSHK,
1509 .use_trk_id = CY_USE_TRACKING_ID,
1510 .use_sleep = CY_USE_DEEP_SLEEP_SEL,
1511 .use_gestures = CY_USE_GESTURES,
1512 .fw_fname = "cyttsp_8064_mtp.hex",
1513 /* change act_intrvl to customize the Active power state
1514 * scanning/processing refresh interval for Operating mode
1515 */
1516 .act_intrvl = CY_ACT_INTRVL_DFLT,
1517 /* change tch_tmout to customize the touch timeout for the
1518 * Active power state for Operating mode
1519 */
1520 .tch_tmout = CY_TCH_TMOUT_DFLT,
1521 /* change lp_intrvl to customize the Low Power power state
1522 * scanning/processing refresh interval for Operating mode
1523 */
1524 .lp_intrvl = CY_LP_INTRVL_DFLT,
1525 .sleep_gpio = CYTTSP_TS_GPIO_SLEEP,
Amy Maloche9ba3ffe2012-04-26 10:31:20 -07001526 .resout_gpio = -1,
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001527 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1528 .regulator_info = cyttsp_regulator_data,
1529 .num_regulators = ARRAY_SIZE(cyttsp_regulator_data),
1530 .init = cyttsp_platform_init,
1531 .correct_fw_ver = 17,
1532};
1533
1534static struct i2c_board_info cyttsp_info[] __initdata = {
1535 {
1536 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1537 .platform_data = &cyttsp_pdata,
1538 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1539 },
1540};
Jing Lin21ed4de2012-02-05 15:53:28 -08001541
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08001542#define MSM_WCNSS_PHYS 0x03000000
1543#define MSM_WCNSS_SIZE 0x280000
1544
1545static struct resource resources_wcnss_wlan[] = {
1546 {
1547 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1548 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1549 .name = "wcnss_wlanrx_irq",
1550 .flags = IORESOURCE_IRQ,
1551 },
1552 {
1553 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1554 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1555 .name = "wcnss_wlantx_irq",
1556 .flags = IORESOURCE_IRQ,
1557 },
1558 {
1559 .start = MSM_WCNSS_PHYS,
1560 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1561 .name = "wcnss_mmio",
1562 .flags = IORESOURCE_MEM,
1563 },
1564 {
1565 .start = 64,
1566 .end = 68,
1567 .name = "wcnss_gpios_5wire",
1568 .flags = IORESOURCE_IO,
1569 },
1570};
1571
1572static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1573 .has_48mhz_xo = 1,
1574};
1575
1576static struct platform_device msm_device_wcnss_wlan = {
1577 .name = "wcnss_wlan",
1578 .id = 0,
1579 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1580 .resource = resources_wcnss_wlan,
1581 .dev = {.platform_data = &qcom_wcnss_pdata},
1582};
1583
Ankit Vermab7c26e62012-02-28 15:04:15 -08001584static struct platform_device msm_device_iris_fm __devinitdata = {
1585 .name = "iris_fm",
1586 .id = -1,
1587};
1588
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001589#ifdef CONFIG_QSEECOM
1590/* qseecom bus scaling */
1591static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1592 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001593 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001594 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001595 .ab = 0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001596 .ib = 0,
1597 },
1598 {
1599 .src = MSM_BUS_MASTER_ADM_PORT1,
1600 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1601 .ab = 0,
1602 .ib = 0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001603 },
1604 {
1605 .src = MSM_BUS_MASTER_SPDM,
1606 .dst = MSM_BUS_SLAVE_SPDM,
1607 .ib = 0,
1608 .ab = 0,
1609 },
1610};
1611
1612static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1613 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001614 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001615 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001616 .ab = 70000000UL,
1617 .ib = 70000000UL,
1618 },
1619 {
1620 .src = MSM_BUS_MASTER_ADM_PORT1,
1621 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1622 .ab = 2480000000UL,
1623 .ib = 2480000000UL,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001624 },
1625 {
1626 .src = MSM_BUS_MASTER_SPDM,
1627 .dst = MSM_BUS_SLAVE_SPDM,
1628 .ib = 0,
1629 .ab = 0,
1630 },
1631};
1632
1633static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1634 {
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001635 .src = MSM_BUS_MASTER_ADM_PORT0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001636 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001637 .ab = 0,
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001638 .ib = 0,
1639 },
1640 {
1641 .src = MSM_BUS_MASTER_ADM_PORT1,
1642 .dst = MSM_BUS_SLAVE_GSBI1_UART,
1643 .ab = 0,
1644 .ib = 0,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001645 },
1646 {
1647 .src = MSM_BUS_MASTER_SPDM,
1648 .dst = MSM_BUS_SLAVE_SPDM,
1649 .ib = (64 * 8) * 1000000UL,
1650 .ab = (64 * 8) * 100000UL,
1651 },
1652};
1653
1654static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1655 {
1656 ARRAY_SIZE(qseecom_clks_init_vectors),
1657 qseecom_clks_init_vectors,
1658 },
1659 {
1660 ARRAY_SIZE(qseecom_enable_dfab_vectors),
Ramesh Masavarapu037942d2012-09-04 11:52:57 -07001661 qseecom_enable_dfab_vectors,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001662 },
1663 {
1664 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1665 qseecom_enable_sfpb_vectors,
1666 },
1667};
1668
1669static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1670 qseecom_hw_bus_scale_usecases,
1671 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1672 .name = "qsee",
1673};
1674
1675static struct platform_device qseecom_device = {
1676 .name = "qseecom",
1677 .id = 0,
1678 .dev = {
1679 .platform_data = &qseecom_bus_pdata,
1680 },
1681};
1682#endif
1683
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001684#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1685 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1686 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1687 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1688
1689#define QCE_SIZE 0x10000
1690#define QCE_0_BASE 0x11000000
1691
1692#define QCE_HW_KEY_SUPPORT 0
1693#define QCE_SHA_HMAC_SUPPORT 1
1694#define QCE_SHARE_CE_RESOURCE 3
1695#define QCE_CE_SHARED 0
1696
1697static struct resource qcrypto_resources[] = {
1698 [0] = {
1699 .start = QCE_0_BASE,
1700 .end = QCE_0_BASE + QCE_SIZE - 1,
1701 .flags = IORESOURCE_MEM,
1702 },
1703 [1] = {
1704 .name = "crypto_channels",
1705 .start = DMOV8064_CE_IN_CHAN,
1706 .end = DMOV8064_CE_OUT_CHAN,
1707 .flags = IORESOURCE_DMA,
1708 },
1709 [2] = {
1710 .name = "crypto_crci_in",
1711 .start = DMOV8064_CE_IN_CRCI,
1712 .end = DMOV8064_CE_IN_CRCI,
1713 .flags = IORESOURCE_DMA,
1714 },
1715 [3] = {
1716 .name = "crypto_crci_out",
1717 .start = DMOV8064_CE_OUT_CRCI,
1718 .end = DMOV8064_CE_OUT_CRCI,
1719 .flags = IORESOURCE_DMA,
1720 },
1721};
1722
1723static struct resource qcedev_resources[] = {
1724 [0] = {
1725 .start = QCE_0_BASE,
1726 .end = QCE_0_BASE + QCE_SIZE - 1,
1727 .flags = IORESOURCE_MEM,
1728 },
1729 [1] = {
1730 .name = "crypto_channels",
1731 .start = DMOV8064_CE_IN_CHAN,
1732 .end = DMOV8064_CE_OUT_CHAN,
1733 .flags = IORESOURCE_DMA,
1734 },
1735 [2] = {
1736 .name = "crypto_crci_in",
1737 .start = DMOV8064_CE_IN_CRCI,
1738 .end = DMOV8064_CE_IN_CRCI,
1739 .flags = IORESOURCE_DMA,
1740 },
1741 [3] = {
1742 .name = "crypto_crci_out",
1743 .start = DMOV8064_CE_OUT_CRCI,
1744 .end = DMOV8064_CE_OUT_CRCI,
1745 .flags = IORESOURCE_DMA,
1746 },
1747};
1748
1749#endif
1750
1751#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1752 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1753
1754static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1755 .ce_shared = QCE_CE_SHARED,
1756 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1757 .hw_key_support = QCE_HW_KEY_SUPPORT,
1758 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001759 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001760};
1761
1762static struct platform_device qcrypto_device = {
1763 .name = "qcrypto",
1764 .id = 0,
1765 .num_resources = ARRAY_SIZE(qcrypto_resources),
1766 .resource = qcrypto_resources,
1767 .dev = {
1768 .coherent_dma_mask = DMA_BIT_MASK(32),
1769 .platform_data = &qcrypto_ce_hw_suppport,
1770 },
1771};
1772#endif
1773
1774#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1775 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1776
1777static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1778 .ce_shared = QCE_CE_SHARED,
1779 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1780 .hw_key_support = QCE_HW_KEY_SUPPORT,
1781 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001782 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001783};
1784
1785static struct platform_device qcedev_device = {
1786 .name = "qce",
1787 .id = 0,
1788 .num_resources = ARRAY_SIZE(qcedev_resources),
1789 .resource = qcedev_resources,
1790 .dev = {
1791 .coherent_dma_mask = DMA_BIT_MASK(32),
1792 .platform_data = &qcedev_ce_hw_suppport,
1793 },
1794};
1795#endif
1796
Joel Kingef390842012-05-23 16:42:48 -07001797static struct mdm_vddmin_resource mdm_vddmin_rscs = {
1798 .rpm_id = MSM_RPM_ID_VDDMIN_GPIO,
1799 .ap2mdm_vddmin_gpio = 30,
1800 .modes = 0x03,
1801 .drive_strength = 8,
1802 .mdm2ap_vddmin_gpio = 80,
1803};
1804
Joel King269aa602012-07-23 08:07:35 -07001805static struct gpiomux_setting mdm2ap_status_gpio_run_cfg = {
1806 .func = GPIOMUX_FUNC_GPIO,
1807 .drv = GPIOMUX_DRV_8MA,
1808 .pull = GPIOMUX_PULL_NONE,
1809};
1810
Joel Kingdacbc822012-01-25 13:30:57 -08001811static struct mdm_platform_data mdm_platform_data = {
1812 .mdm_version = "3.0",
1813 .ramdump_delay_ms = 2000,
Joel King14fe7fa2012-05-27 14:26:11 -07001814 .early_power_on = 1,
1815 .sfr_query = 1,
Joel Kingef390842012-05-23 16:42:48 -07001816 .vddmin_resource = &mdm_vddmin_rscs,
Hemant Kumara945b472012-01-25 15:08:06 -08001817 .peripheral_platform_device = &apq8064_device_hsic_host,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001818 .ramdump_timeout_ms = 120000,
Joel King269aa602012-07-23 08:07:35 -07001819 .mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
Joel Kingdacbc822012-01-25 13:30:57 -08001820};
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001821
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08001822static struct tsens_platform_data apq_tsens_pdata = {
1823 .tsens_factor = 1000,
1824 .hw_type = APQ_8064,
1825 .tsens_num_sensor = 11,
1826 .slope = {1176, 1176, 1154, 1176, 1111,
1827 1132, 1132, 1199, 1132, 1199, 1132},
1828};
1829
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07001830static struct platform_device msm_tsens_device = {
1831 .name = "tsens8960-tm",
1832 .id = -1,
1833};
1834
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001835static struct msm_thermal_data msm_thermal_pdata = {
1836 .sensor_id = 7,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06001837 .poll_ms = 250,
1838 .limit_temp_degC = 60,
1839 .temp_hysteresis_degC = 10,
1840 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001841};
1842
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001843#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001844static void __init apq8064_map_io(void)
1845{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001846 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001847 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001848 if (socinfo_init() < 0)
1849 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001850}
1851
1852static void __init apq8064_init_irq(void)
1853{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001854 struct msm_mpm_device_data *data = NULL;
1855
1856#ifdef CONFIG_MSM_MPM
1857 data = &apq8064_mpm_dev_data;
1858#endif
1859
1860 msm_mpm_irq_extn_init(data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001861 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
1862 (void *)MSM_QGIC_CPU_BASE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001863}
1864
Jay Chokshi7805b5a2011-11-07 15:55:30 -08001865static struct platform_device msm8064_device_saw_regulator_core0 = {
1866 .name = "saw-regulator",
1867 .id = 0,
1868 .dev = {
1869 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
1870 },
1871};
1872
1873static struct platform_device msm8064_device_saw_regulator_core1 = {
1874 .name = "saw-regulator",
1875 .id = 1,
1876 .dev = {
1877 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
1878 },
1879};
1880
1881static struct platform_device msm8064_device_saw_regulator_core2 = {
1882 .name = "saw-regulator",
1883 .id = 2,
1884 .dev = {
1885 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
1886 },
1887};
1888
1889static struct platform_device msm8064_device_saw_regulator_core3 = {
1890 .name = "saw-regulator",
1891 .id = 3,
1892 .dev = {
1893 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001894
1895 },
1896};
1897
Oluwafemi Adeyemif5a31422012-03-08 16:58:45 -08001898static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001899 {
1900 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1901 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1902 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001903 1, 784, 180000, 100,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001904 },
1905
1906 {
1907 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1908 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1909 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001910 1300, 228, 1200000, 2000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001911 },
1912
1913 {
1914 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1915 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
1916 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001917 2000, 138, 1208400, 3200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001918 },
1919
1920 {
1921 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Praveen Chidambarame3380672012-02-08 10:32:27 -07001922 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
1923 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001924 6000, 119, 1850300, 9000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001925 },
1926
1927 {
1928 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1929 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
1930 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001931 9200, 68, 2839200, 16400,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001932 },
1933
1934 {
1935 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1936 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
1937 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001938 10300, 63, 3128000, 18200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001939 },
1940
1941 {
1942 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1943 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
1944 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001945 18000, 10, 4602600, 27000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001946 },
1947
1948 {
1949 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1950 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
1951 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001952 20000, 2, 5752000, 32000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001953 },
1954};
1955
1956static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1957 .mode = MSM_PM_BOOT_CONFIG_TZ,
1958};
1959
1960static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
1961 .levels = &msm_rpmrs_levels[0],
1962 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
1963 .vdd_mem_levels = {
1964 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
1965 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
1966 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
1967 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
1968 },
1969 .vdd_dig_levels = {
1970 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
1971 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
1972 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
1973 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
1974 },
1975 .vdd_mask = 0x7FFFFF,
1976 .rpmrs_target_id = {
1977 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
1978 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
1979 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
1980 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
1981 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
1982 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
1983 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
1984 },
1985};
1986
Praveen Chidambaram78499012011-11-01 17:15:17 -06001987static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1988 0x03, 0x0f,
1989};
1990
1991static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1992 0x00, 0x24, 0x54, 0x10,
1993 0x09, 0x03, 0x01,
1994 0x10, 0x54, 0x30, 0x0C,
1995 0x24, 0x30, 0x0f,
1996};
1997
1998static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1999 0x00, 0x24, 0x54, 0x10,
2000 0x09, 0x07, 0x01, 0x0B,
2001 0x10, 0x54, 0x30, 0x0C,
2002 0x24, 0x30, 0x0f,
2003};
2004
2005static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
2006 [0] = {
2007 .mode = MSM_SPM_MODE_CLOCK_GATING,
2008 .notify_rpm = false,
2009 .cmd = spm_wfi_cmd_sequence,
2010 },
2011 [1] = {
2012 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2013 .notify_rpm = false,
2014 .cmd = spm_power_collapse_without_rpm,
2015 },
2016 [2] = {
2017 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2018 .notify_rpm = true,
2019 .cmd = spm_power_collapse_with_rpm,
2020 },
2021};
2022
2023static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2024 0x00, 0x20, 0x03, 0x20,
2025 0x00, 0x0f,
2026};
2027
2028static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2029 0x00, 0x20, 0x34, 0x64,
2030 0x48, 0x07, 0x48, 0x20,
2031 0x50, 0x64, 0x04, 0x34,
2032 0x50, 0x0f,
2033};
2034static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2035 0x00, 0x10, 0x34, 0x64,
2036 0x48, 0x07, 0x48, 0x10,
2037 0x50, 0x64, 0x04, 0x34,
2038 0x50, 0x0F,
2039};
2040
2041static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2042 [0] = {
2043 .mode = MSM_SPM_L2_MODE_RETENTION,
2044 .notify_rpm = false,
2045 .cmd = l2_spm_wfi_cmd_sequence,
2046 },
2047 [1] = {
2048 .mode = MSM_SPM_L2_MODE_GDHS,
2049 .notify_rpm = true,
2050 .cmd = l2_spm_gdhs_cmd_sequence,
2051 },
2052 [2] = {
2053 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2054 .notify_rpm = true,
2055 .cmd = l2_spm_power_off_cmd_sequence,
2056 },
2057};
2058
2059
2060static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2061 [0] = {
2062 .reg_base_addr = MSM_SAW_L2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002063 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002064 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002065 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2066 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2067 .modes = msm_spm_l2_seq_list,
2068 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2069 },
2070};
2071
2072static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2073 [0] = {
2074 .reg_base_addr = MSM_SAW0_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002075 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002076#if defined(CONFIG_MSM_AVS_HW)
2077 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2078 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2079#endif
2080 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002081 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002082 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2083 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2084 .vctl_timeout_us = 50,
2085 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2086 .modes = msm_spm_seq_list,
2087 },
2088 [1] = {
2089 .reg_base_addr = MSM_SAW1_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002090 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002091#if defined(CONFIG_MSM_AVS_HW)
2092 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2093 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2094#endif
2095 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002096 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002097 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2098 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2099 .vctl_timeout_us = 50,
2100 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2101 .modes = msm_spm_seq_list,
2102 },
2103 [2] = {
2104 .reg_base_addr = MSM_SAW2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002105 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002106#if defined(CONFIG_MSM_AVS_HW)
2107 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2108 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2109#endif
2110 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002111 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002112 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2113 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2114 .vctl_timeout_us = 50,
2115 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2116 .modes = msm_spm_seq_list,
2117 },
2118 [3] = {
2119 .reg_base_addr = MSM_SAW3_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002120 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002121#if defined(CONFIG_MSM_AVS_HW)
2122 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2123 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2124#endif
2125 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002126 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002127 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2128 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2129 .vctl_timeout_us = 50,
2130 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2131 .modes = msm_spm_seq_list,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002132 },
2133};
2134
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002135static void __init apq8064_init_buses(void)
2136{
2137 msm_bus_rpm_set_mt_mask();
2138 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
2139 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
2140 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
2141 msm_bus_8064_apps_fabric.dev.platform_data =
2142 &msm_bus_8064_apps_fabric_pdata;
2143 msm_bus_8064_sys_fabric.dev.platform_data =
2144 &msm_bus_8064_sys_fabric_pdata;
2145 msm_bus_8064_mm_fabric.dev.platform_data =
2146 &msm_bus_8064_mm_fabric_pdata;
2147 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
2148 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
2149}
2150
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002151/* PCIe gpios */
2152static struct msm_pcie_gpio_info_t msm_pcie_gpio_info[MSM_PCIE_MAX_GPIO] = {
2153 {"rst_n", PM8921_MPP_PM_TO_SYS(PCIE_RST_N_PMIC_MPP), 0},
2154 {"pwr_en", PM8921_GPIO_PM_TO_SYS(PCIE_PWR_EN_PMIC_GPIO), 1},
2155};
2156
2157static struct msm_pcie_platform msm_pcie_platform_data = {
2158 .gpio = msm_pcie_gpio_info,
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -06002159 .axi_addr = PCIE_AXI_BAR_PHYS,
2160 .axi_size = PCIE_AXI_BAR_SIZE,
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -06002161 .wake_n = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PCIE_WAKE_N_PMIC_GPIO),
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002162};
2163
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002164static int __init mpq8064_pcie_enabled(void)
2165{
2166 return !((readl_relaxed(QFPROM_RAW_FEAT_CONFIG_ROW0_MSB) & BIT(21)) ||
2167 (readl_relaxed(QFPROM_RAW_OEM_CONFIG_ROW0_LSB) & BIT(4)));
2168}
2169
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002170static void __init mpq8064_pcie_init(void)
2171{
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002172 if (mpq8064_pcie_enabled()) {
2173 msm_device_pcie.dev.platform_data = &msm_pcie_platform_data;
2174 platform_device_register(&msm_device_pcie);
2175 }
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002176}
2177
David Collinsf0d00732012-01-25 15:46:50 -08002178static struct platform_device apq8064_device_ext_5v_vreg __devinitdata = {
2179 .name = GPIO_REGULATOR_DEV_NAME,
2180 .id = PM8921_MPP_PM_TO_SYS(7),
2181 .dev = {
2182 .platform_data
2183 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2184 },
2185};
2186
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002187static struct platform_device apq8064_device_ext_mpp8_vreg __devinitdata = {
2188 .name = GPIO_REGULATOR_DEV_NAME,
2189 .id = PM8921_MPP_PM_TO_SYS(8),
2190 .dev = {
2191 .platform_data
2192 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_MPP8],
2193 },
2194};
2195
David Collinsf0d00732012-01-25 15:46:50 -08002196static struct platform_device apq8064_device_ext_3p3v_vreg __devinitdata = {
2197 .name = GPIO_REGULATOR_DEV_NAME,
2198 .id = APQ8064_EXT_3P3V_REG_EN_GPIO,
2199 .dev = {
2200 .platform_data =
2201 &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2202 },
2203};
2204
David Collins390fc332012-02-07 14:38:16 -08002205static struct platform_device apq8064_device_ext_ts_sw_vreg __devinitdata = {
2206 .name = GPIO_REGULATOR_DEV_NAME,
2207 .id = PM8921_GPIO_PM_TO_SYS(23),
2208 .dev = {
2209 .platform_data
2210 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_TS_SW],
2211 },
2212};
2213
David Collins2782b5c2012-02-06 10:02:42 -08002214static struct platform_device apq8064_device_rpm_regulator __devinitdata = {
2215 .name = "rpm-regulator",
David Collins36199252012-08-21 15:43:02 -07002216 .id = 0,
David Collins2782b5c2012-02-06 10:02:42 -08002217 .dev = {
2218 .platform_data = &apq8064_rpm_regulator_pdata,
2219 },
2220};
2221
David Collins36199252012-08-21 15:43:02 -07002222static struct platform_device
2223apq8064_pm8921_device_rpm_regulator __devinitdata = {
2224 .name = "rpm-regulator",
2225 .id = 1,
2226 .dev = {
2227 .platform_data = &apq8064_rpm_regulator_pm8921_pdata,
2228 },
2229};
2230
Ravi Kumar V05931a22012-04-04 17:09:37 +05302231static struct gpio_ir_recv_platform_data gpio_ir_recv_pdata = {
2232 .gpio_nr = 88,
2233 .active_low = 1,
2234};
2235
2236static struct platform_device gpio_ir_recv_pdev = {
2237 .name = "gpio-rc-recv",
2238 .dev = {
2239 .platform_data = &gpio_ir_recv_pdata,
2240 },
2241};
2242
Terence Hampson36b70722012-05-10 13:18:16 -04002243static struct platform_device *common_not_mpq_devices[] __initdata = {
David Keitel3c40fc52012-02-09 17:53:52 -08002244 &apq8064_device_qup_i2c_gsbi1,
Jing Lin04601f92012-02-05 15:36:07 -08002245 &apq8064_device_qup_i2c_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002246 &apq8064_device_qup_i2c_gsbi4,
Terence Hampson36b70722012-05-10 13:18:16 -04002247};
2248
David Collins36199252012-08-21 15:43:02 -07002249static struct platform_device *early_common_devices[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -07002250 &apq8064_device_acpuclk,
Terence Hampson36b70722012-05-10 13:18:16 -04002251 &apq8064_device_dmov,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002252 &apq8064_device_qup_spi_gsbi5,
David Collins36199252012-08-21 15:43:02 -07002253};
2254
2255static struct platform_device *pm8921_common_devices[] __initdata = {
David Collinsf0d00732012-01-25 15:46:50 -08002256 &apq8064_device_ext_5v_vreg,
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002257 &apq8064_device_ext_mpp8_vreg,
David Collinsf0d00732012-01-25 15:46:50 -08002258 &apq8064_device_ext_3p3v_vreg,
Jay Chokshi9c25f072011-09-23 18:19:15 -07002259 &apq8064_device_ssbi_pmic1,
2260 &apq8064_device_ssbi_pmic2,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002261 &apq8064_device_ext_ts_sw_vreg,
David Collins36199252012-08-21 15:43:02 -07002262};
2263
2264static struct platform_device *pm8917_common_devices[] __initdata = {
2265 &apq8064_device_ext_mpp8_vreg,
2266 &apq8064_device_ext_3p3v_vreg,
2267 &apq8064_device_ssbi_pmic1,
2268 &apq8064_device_ssbi_pmic2,
2269 &apq8064_device_ext_ts_sw_vreg,
2270};
2271
2272static struct platform_device *common_devices[] __initdata = {
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06002273 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -07002274 &apq8064_device_otg,
2275 &apq8064_device_gadget_peripheral,
Hemant Kumard86c4882012-01-24 19:39:37 -08002276 &apq8064_device_hsusb_host,
Hemant Kumar4933b072011-10-17 23:43:11 -07002277 &android_usb_device,
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08002278 &msm_device_wcnss_wlan,
Ankit Vermab7c26e62012-02-28 15:04:15 -08002279 &msm_device_iris_fm,
Larry Bassel67b921d2012-04-06 10:23:27 -07002280 &apq8064_fmem_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002281#ifdef CONFIG_ANDROID_PMEM
2282#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002283 &apq8064_android_pmem_device,
2284 &apq8064_android_pmem_adsp_device,
2285 &apq8064_android_pmem_audio_device,
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002286#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2287#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -08002288#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002289 &apq8064_ion_dev,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002290#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002291 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002292 &msm8064_device_saw_regulator_core0,
2293 &msm8064_device_saw_regulator_core1,
2294 &msm8064_device_saw_regulator_core2,
2295 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002296#if defined(CONFIG_QSEECOM)
2297 &qseecom_device,
2298#endif
2299
Joel Nider6b9a7bc2012-06-26 11:19:19 +03002300 &msm_8064_device_tsif[0],
2301 &msm_8064_device_tsif[1],
2302
Ramesh Masavarapu28311912011-10-27 11:04:12 -07002303#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2304 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2305 &qcrypto_device,
2306#endif
2307
2308#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2309 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2310 &qcedev_device,
2311#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07002312
2313#ifdef CONFIG_HW_RANDOM_MSM
2314 &apq8064_device_rng,
2315#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002316 &apq_pcm,
2317 &apq_pcm_routing,
2318 &apq_cpudai0,
2319 &apq_cpudai1,
Santosh Mardieff9a742012-04-09 23:23:39 +05302320 &mpq_cpudai_sec_i2s_rx,
Kuirong Wangf23f8c52012-03-31 12:34:51 -07002321 &mpq_cpudai_mi2s_tx,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002322 &apq_cpudai_hdmi_rx,
2323 &apq_cpudai_bt_rx,
2324 &apq_cpudai_bt_tx,
2325 &apq_cpudai_fm_rx,
2326 &apq_cpudai_fm_tx,
2327 &apq_cpu_fe,
2328 &apq_stub_codec,
2329 &apq_voice,
2330 &apq_voip,
2331 &apq_lpa_pcm,
Krishnankutty Kolathappilly4374e332012-03-18 22:27:30 -07002332 &apq_compr_dsp,
2333 &apq_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002334 &apq_lowlatency_pcm,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002335 &apq_pcm_hostless,
2336 &apq_cpudai_afe_01_rx,
2337 &apq_cpudai_afe_01_tx,
2338 &apq_cpudai_afe_02_rx,
2339 &apq_cpudai_afe_02_tx,
2340 &apq_pcm_afe,
2341 &apq_cpudai_auxpcm_rx,
2342 &apq_cpudai_auxpcm_tx,
Neema Shetty8427c262012-02-16 11:23:43 -08002343 &apq_cpudai_stub,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002344 &apq_cpudai_slimbus_1_rx,
2345 &apq_cpudai_slimbus_1_tx,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002346 &apq_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002347 &apq_cpudai_slimbus_2_tx,
Neema Shettyc9d86c32012-05-09 12:01:39 -07002348 &apq_cpudai_slimbus_3_rx,
Helen Zeng38c3c962012-05-17 14:56:20 -07002349 &apq_cpudai_slimbus_3_tx,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002350 &apq8064_rpm_device,
2351 &apq8064_rpm_log_device,
2352 &apq8064_rpm_stat_device,
Anji Jonnala2a8bd312012-11-01 13:11:42 +05302353 &apq8064_rpm_master_stat_device,
Ramesh Masavarapuf31ff242012-05-10 18:55:21 -07002354 &apq_device_tz_log,
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002355 &msm_bus_8064_apps_fabric,
2356 &msm_bus_8064_sys_fabric,
2357 &msm_bus_8064_mm_fabric,
2358 &msm_bus_8064_sys_fpb,
2359 &msm_bus_8064_cpss_fpb,
Mohan Kumar Gubbihalli Lachma Naik7f72edd2012-02-06 17:26:47 -08002360 &apq8064_msm_device_vidc,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002361 &msm_pil_dsps,
Matt Wagantallb94b9a52012-02-02 21:59:54 -08002362 &msm_8960_q6_lpass,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002363 &msm_pil_vidc,
Matt Wagantall292aace2012-01-26 19:12:34 -08002364 &msm_gss,
Laura Abbottb93525f2012-04-12 09:57:19 -07002365 &apq8064_rtb_device,
Steve Mucklea9aac292012-11-02 15:41:00 -07002366 &apq8064_dcvs_device,
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07002367 &apq8064_msm_gov_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002368 &apq8064_device_cache_erp,
Stepan Moskovchenko0f3de112012-06-08 18:11:46 -07002369 &msm8960_device_ebi1_ch0_erp,
2370 &msm8960_device_ebi1_ch1_erp,
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002371 &epm_adc_device,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002372 &coresight_tpiu_device,
2373 &coresight_etb_device,
2374 &apq8064_coresight_funnel_device,
2375 &coresight_etm0_device,
2376 &coresight_etm1_device,
2377 &coresight_etm2_device,
2378 &coresight_etm3_device,
Helen Zeng8f925502012-03-05 16:50:17 -08002379 &apq_cpudai_slim_4_rx,
2380 &apq_cpudai_slim_4_tx,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002381#ifdef CONFIG_MSM_GEMINI
Jignesh Mehta921649d2012-04-19 06:57:23 -07002382 &msm8960_gemini_device,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002383#endif
Laura Abbott0577d7b2012-04-17 11:14:30 -07002384 &apq8064_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002385 &msm_tsens_device,
Laura Abbott93a4a352012-05-25 09:26:35 -07002386 &apq8064_cache_dump_device,
Joel Nider0e4a16d2012-08-05 14:20:11 +03002387 &msm_8064_device_tspp,
Abhijeet Dharmapurikarde91d2c2012-08-23 14:36:59 -07002388#ifdef CONFIG_BATTERY_BCL
2389 &battery_bcl_device,
2390#endif
2391 &apq8064_msm_mpd_device,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002392};
2393
Joel King82b7e3f2012-01-05 10:03:27 -08002394static struct platform_device *cdp_devices[] __initdata = {
2395 &apq8064_device_uart_gsbi1,
Jin Hong4bbbfba2012-02-02 21:48:07 -08002396 &apq8064_device_uart_gsbi7,
Joel King82b7e3f2012-01-05 10:03:27 -08002397 &msm_device_sps_apq8064,
Aravind Venkateswaran4ca27532012-02-16 14:27:05 -08002398#ifdef CONFIG_MSM_ROTATOR
2399 &msm_rotator_device,
2400#endif
Joel King82b7e3f2012-01-05 10:03:27 -08002401};
2402
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002403static struct platform_device
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002404mpq8064_device_ext_1p2_buck_vreg __devinitdata = {
2405 .name = GPIO_REGULATOR_DEV_NAME,
2406 .id = SX150X_GPIO(4, 2),
2407 .dev = {
2408 .platform_data =
2409 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P2V],
2410 },
2411};
2412
2413static struct platform_device
2414mpq8064_device_ext_1p8_buck_vreg __devinitdata = {
2415 .name = GPIO_REGULATOR_DEV_NAME,
2416 .id = SX150X_GPIO(4, 4),
2417 .dev = {
2418 .platform_data =
2419 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P8V],
2420 },
2421};
2422
2423static struct platform_device
2424mpq8064_device_ext_2p2_buck_vreg __devinitdata = {
2425 .name = GPIO_REGULATOR_DEV_NAME,
2426 .id = SX150X_GPIO(4, 14),
2427 .dev = {
2428 .platform_data =
2429 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_2P2V],
2430 },
2431};
2432
2433static struct platform_device
2434mpq8064_device_ext_5v_buck_vreg __devinitdata = {
2435 .name = GPIO_REGULATOR_DEV_NAME,
2436 .id = SX150X_GPIO(4, 3),
2437 .dev = {
2438 .platform_data =
2439 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_5V],
2440 },
2441};
2442
2443static struct platform_device
2444mpq8064_device_ext_3p3v_ldo_vreg __devinitdata = {
2445 .name = GPIO_REGULATOR_DEV_NAME,
2446 .id = SX150X_GPIO(4, 15),
2447 .dev = {
2448 .platform_data =
2449 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_3P3V],
2450 },
2451};
2452
Ravi Kumar V1c903012012-05-15 16:11:35 +05302453static struct platform_device rc_input_loopback_pdev = {
2454 .name = "rc-user-input",
2455 .id = -1,
2456};
2457
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302458static int rf4ce_gpio_init(void)
2459{
Ravi Kumar V0143c582012-08-14 17:18:11 +05302460 if (!machine_is_mpq8064_cdp() &&
2461 !machine_is_mpq8064_hrd() &&
2462 !machine_is_mpq8064_dtv())
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302463 return -EINVAL;
2464
2465 /* CC2533 SRDY Input */
2466 if (!gpio_request(SX150X_GPIO(4, 6), "rf4ce_srdy")) {
2467 gpio_direction_input(SX150X_GPIO(4, 6));
2468 gpio_export(SX150X_GPIO(4, 6), true);
2469 }
2470
2471 /* CC2533 MRDY Output */
2472 if (!gpio_request(SX150X_GPIO(4, 5), "rf4ce_mrdy")) {
2473 gpio_direction_output(SX150X_GPIO(4, 5), 1);
2474 gpio_export(SX150X_GPIO(4, 5), true);
2475 }
2476
2477 /* CC2533 Reset Output */
2478 if (!gpio_request(SX150X_GPIO(4, 7), "rf4ce_reset")) {
2479 gpio_direction_output(SX150X_GPIO(4, 7), 0);
2480 gpio_export(SX150X_GPIO(4, 7), true);
2481 }
2482
2483 return 0;
2484}
2485late_initcall(rf4ce_gpio_init);
2486
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002487static struct platform_device *mpq_devices[] __initdata = {
2488 &msm_device_sps_apq8064,
2489 &mpq8064_device_qup_i2c_gsbi5,
2490#ifdef CONFIG_MSM_ROTATOR
2491 &msm_rotator_device,
2492#endif
Ravi Kumar V05931a22012-04-04 17:09:37 +05302493 &gpio_ir_recv_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002494 &mpq8064_device_ext_1p2_buck_vreg,
2495 &mpq8064_device_ext_1p8_buck_vreg,
2496 &mpq8064_device_ext_2p2_buck_vreg,
2497 &mpq8064_device_ext_5v_buck_vreg,
2498 &mpq8064_device_ext_3p3v_ldo_vreg,
Terence Hampson2e1705f2012-04-11 19:55:29 -04002499#ifdef CONFIG_MSM_VCAP
2500 &msm8064_device_vcap,
2501#endif
Ravi Kumar V1c903012012-05-15 16:11:35 +05302502 &rc_input_loopback_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002503};
2504
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002505static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002506 .max_clock_speed = 1100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002507};
2508
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002509#define KS8851_IRQ_GPIO 43
2510
2511static struct spi_board_info spi_board_info[] __initdata = {
2512 {
2513 .modalias = "ks8851",
2514 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2515 .max_speed_hz = 19200000,
2516 .bus_num = 0,
2517 .chip_select = 2,
2518 .mode = SPI_MODE_0,
2519 },
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002520 {
2521 .modalias = "epm_adc",
2522 .max_speed_hz = 1100000,
2523 .bus_num = 0,
2524 .chip_select = 3,
2525 .mode = SPI_MODE_0,
2526 },
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002527};
2528
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002529static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002530 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08002531 .bus_num = 1,
2532 .slim_slave = &apq8064_slim_tabla,
2533 },
2534 {
2535 .bus_num = 1,
2536 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002537 },
2538 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002539};
2540
David Keitel3c40fc52012-02-09 17:53:52 -08002541static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi1_pdata = {
2542 .clk_freq = 100000,
2543 .src_clk_rate = 24000000,
2544};
2545
Jing Lin04601f92012-02-05 15:36:07 -08002546static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi3_pdata = {
Anirudh Ghayalc2163472012-04-10 14:58:14 +05302547 .clk_freq = 384000,
Jing Lin04601f92012-02-05 15:36:07 -08002548 .src_clk_rate = 24000000,
2549};
2550
Kenneth Heitke748593a2011-07-15 15:45:11 -06002551static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
2552 .clk_freq = 100000,
2553 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002554};
2555
Joel King8f839b92012-04-01 14:37:46 -07002556static struct msm_i2c_platform_data mpq8064_i2c_qup_gsbi5_pdata = {
2557 .clk_freq = 100000,
2558 .src_clk_rate = 24000000,
2559};
2560
David Keitel3c40fc52012-02-09 17:53:52 -08002561#define GSBI_DUAL_MODE_CODE 0x60
2562#define MSM_GSBI1_PHYS 0x12440000
Kenneth Heitke748593a2011-07-15 15:45:11 -06002563static void __init apq8064_i2c_init(void)
2564{
David Keitel3c40fc52012-02-09 17:53:52 -08002565 void __iomem *gsbi_mem;
2566
2567 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2568 &apq8064_i2c_qup_gsbi1_pdata;
2569 gsbi_mem = ioremap_nocache(MSM_GSBI1_PHYS, 4);
2570 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
2571 /* Ensure protocol code is written before proceeding */
2572 wmb();
2573 iounmap(gsbi_mem);
2574 apq8064_i2c_qup_gsbi1_pdata.use_gsbi_shared_mode = 1;
Jing Lin04601f92012-02-05 15:36:07 -08002575 apq8064_device_qup_i2c_gsbi3.dev.platform_data =
2576 &apq8064_i2c_qup_gsbi3_pdata;
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002577 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2578 &apq8064_i2c_qup_gsbi1_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002579 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
2580 &apq8064_i2c_qup_gsbi4_pdata;
Joel King8f839b92012-04-01 14:37:46 -07002581 mpq8064_device_qup_i2c_gsbi5.dev.platform_data =
2582 &mpq8064_i2c_qup_gsbi5_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002583}
2584
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002585#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002586static int ethernet_init(void)
2587{
2588 int ret;
2589 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
2590 if (ret) {
2591 pr_err("ks8851 gpio_request failed: %d\n", ret);
2592 goto fail;
2593 }
2594
2595 return 0;
2596fail:
2597 return ret;
2598}
2599#else
2600static int ethernet_init(void)
2601{
2602 return 0;
2603}
2604#endif
2605
David Collins6f7c3472012-08-22 13:18:06 -07002606#define GPIO_KEY_HOME PM8921_GPIO_PM_TO_SYS(27)
2607#define GPIO_KEY_VOLUME_UP PM8921_GPIO_PM_TO_SYS(35)
2608#define GPIO_KEY_VOLUME_DOWN_PM8921 PM8921_GPIO_PM_TO_SYS(38)
2609#define GPIO_KEY_VOLUME_DOWN_PM8917 PM8921_GPIO_PM_TO_SYS(30)
2610#define GPIO_KEY_CAM_FOCUS PM8921_GPIO_PM_TO_SYS(3)
2611#define GPIO_KEY_CAM_SNAP PM8921_GPIO_PM_TO_SYS(4)
2612#define GPIO_KEY_ROTATION_PM8921 PM8921_GPIO_PM_TO_SYS(42)
2613#define GPIO_KEY_ROTATION_PM8917 PM8921_GPIO_PM_TO_SYS(8)
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302614
David Collins6f7c3472012-08-22 13:18:06 -07002615static struct gpio_keys_button cdp_keys_pm8921[] = {
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302616 {
2617 .code = KEY_HOME,
2618 .gpio = GPIO_KEY_HOME,
2619 .desc = "home_key",
2620 .active_low = 1,
2621 .type = EV_KEY,
2622 .wakeup = 1,
2623 .debounce_interval = 15,
2624 },
2625 {
2626 .code = KEY_VOLUMEUP,
2627 .gpio = GPIO_KEY_VOLUME_UP,
2628 .desc = "volume_up_key",
2629 .active_low = 1,
2630 .type = EV_KEY,
2631 .wakeup = 1,
2632 .debounce_interval = 15,
2633 },
2634 {
2635 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002636 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302637 .desc = "volume_down_key",
2638 .active_low = 1,
2639 .type = EV_KEY,
2640 .wakeup = 1,
2641 .debounce_interval = 15,
2642 },
2643 {
2644 .code = SW_ROTATE_LOCK,
David Collins6f7c3472012-08-22 13:18:06 -07002645 .gpio = GPIO_KEY_ROTATION_PM8921,
2646 .desc = "rotate_key",
2647 .active_low = 1,
2648 .type = EV_SW,
2649 .debounce_interval = 15,
2650 },
2651};
2652
2653static struct gpio_keys_button cdp_keys_pm8917[] = {
2654 {
2655 .code = KEY_HOME,
2656 .gpio = GPIO_KEY_HOME,
2657 .desc = "home_key",
2658 .active_low = 1,
2659 .type = EV_KEY,
2660 .wakeup = 1,
2661 .debounce_interval = 15,
2662 },
2663 {
2664 .code = KEY_VOLUMEUP,
2665 .gpio = GPIO_KEY_VOLUME_UP,
2666 .desc = "volume_up_key",
2667 .active_low = 1,
2668 .type = EV_KEY,
2669 .wakeup = 1,
2670 .debounce_interval = 15,
2671 },
2672 {
2673 .code = KEY_VOLUMEDOWN,
2674 .gpio = GPIO_KEY_VOLUME_DOWN_PM8917,
2675 .desc = "volume_down_key",
2676 .active_low = 1,
2677 .type = EV_KEY,
2678 .wakeup = 1,
2679 .debounce_interval = 15,
2680 },
2681 {
2682 .code = SW_ROTATE_LOCK,
2683 .gpio = GPIO_KEY_ROTATION_PM8917,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302684 .desc = "rotate_key",
2685 .active_low = 1,
2686 .type = EV_SW,
2687 .debounce_interval = 15,
2688 },
2689};
2690
2691static struct gpio_keys_platform_data cdp_keys_data = {
David Collins6f7c3472012-08-22 13:18:06 -07002692 .buttons = cdp_keys_pm8921,
2693 .nbuttons = ARRAY_SIZE(cdp_keys_pm8921),
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302694};
2695
2696static struct platform_device cdp_kp_pdev = {
2697 .name = "gpio-keys",
2698 .id = -1,
2699 .dev = {
2700 .platform_data = &cdp_keys_data,
2701 },
2702};
2703
2704static struct gpio_keys_button mtp_keys[] = {
2705 {
2706 .code = KEY_CAMERA_FOCUS,
2707 .gpio = GPIO_KEY_CAM_FOCUS,
2708 .desc = "cam_focus_key",
2709 .active_low = 1,
2710 .type = EV_KEY,
2711 .wakeup = 1,
2712 .debounce_interval = 15,
2713 },
2714 {
2715 .code = KEY_VOLUMEUP,
2716 .gpio = GPIO_KEY_VOLUME_UP,
2717 .desc = "volume_up_key",
2718 .active_low = 1,
2719 .type = EV_KEY,
2720 .wakeup = 1,
2721 .debounce_interval = 15,
2722 },
2723 {
2724 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002725 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302726 .desc = "volume_down_key",
2727 .active_low = 1,
2728 .type = EV_KEY,
2729 .wakeup = 1,
2730 .debounce_interval = 15,
2731 },
2732 {
2733 .code = KEY_CAMERA_SNAPSHOT,
2734 .gpio = GPIO_KEY_CAM_SNAP,
2735 .desc = "cam_snap_key",
2736 .active_low = 1,
2737 .type = EV_KEY,
2738 .debounce_interval = 15,
2739 },
2740};
2741
2742static struct gpio_keys_platform_data mtp_keys_data = {
2743 .buttons = mtp_keys,
2744 .nbuttons = ARRAY_SIZE(mtp_keys),
2745};
2746
2747static struct platform_device mtp_kp_pdev = {
2748 .name = "gpio-keys",
2749 .id = -1,
2750 .dev = {
2751 .platform_data = &mtp_keys_data,
2752 },
2753};
2754
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302755static struct gpio_keys_button mpq_keys[] = {
2756 {
2757 .code = KEY_VOLUMEDOWN,
David Collins6f7c3472012-08-22 13:18:06 -07002758 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302759 .desc = "volume_down_key",
2760 .active_low = 1,
2761 .type = EV_KEY,
2762 .wakeup = 1,
2763 .debounce_interval = 15,
2764 },
2765 {
2766 .code = KEY_VOLUMEUP,
2767 .gpio = GPIO_KEY_VOLUME_UP,
2768 .desc = "volume_up_key",
2769 .active_low = 1,
2770 .type = EV_KEY,
2771 .wakeup = 1,
2772 .debounce_interval = 15,
2773 },
2774};
2775
2776static struct gpio_keys_platform_data mpq_keys_data = {
2777 .buttons = mpq_keys,
2778 .nbuttons = ARRAY_SIZE(mpq_keys),
2779};
2780
2781static struct platform_device mpq_gpio_keys_pdev = {
2782 .name = "gpio-keys",
2783 .id = -1,
2784 .dev = {
2785 .platform_data = &mpq_keys_data,
2786 },
2787};
2788
2789#define MPQ_KP_ROW_BASE SX150X_EXP2_GPIO_BASE
2790#define MPQ_KP_COL_BASE (SX150X_EXP2_GPIO_BASE + 4)
2791
2792static unsigned int mpq_row_gpios[] = {MPQ_KP_ROW_BASE, MPQ_KP_ROW_BASE + 1,
2793 MPQ_KP_ROW_BASE + 2, MPQ_KP_ROW_BASE + 3};
2794static unsigned int mpq_col_gpios[] = {MPQ_KP_COL_BASE, MPQ_KP_COL_BASE + 1,
2795 MPQ_KP_COL_BASE + 2};
2796
2797static const unsigned int mpq_keymap[] = {
2798 KEY(0, 0, KEY_UP),
2799 KEY(0, 1, KEY_ENTER),
2800 KEY(0, 2, KEY_3),
2801
2802 KEY(1, 0, KEY_DOWN),
2803 KEY(1, 1, KEY_EXIT),
2804 KEY(1, 2, KEY_4),
2805
2806 KEY(2, 0, KEY_LEFT),
2807 KEY(2, 1, KEY_1),
2808 KEY(2, 2, KEY_5),
2809
2810 KEY(3, 0, KEY_RIGHT),
2811 KEY(3, 1, KEY_2),
2812 KEY(3, 2, KEY_6),
2813};
2814
2815static struct matrix_keymap_data mpq_keymap_data = {
2816 .keymap_size = ARRAY_SIZE(mpq_keymap),
2817 .keymap = mpq_keymap,
2818};
2819
2820static struct matrix_keypad_platform_data mpq_keypad_data = {
2821 .keymap_data = &mpq_keymap_data,
2822 .row_gpios = mpq_row_gpios,
2823 .col_gpios = mpq_col_gpios,
2824 .num_row_gpios = ARRAY_SIZE(mpq_row_gpios),
2825 .num_col_gpios = ARRAY_SIZE(mpq_col_gpios),
2826 .col_scan_delay_us = 32000,
2827 .debounce_ms = 20,
2828 .wakeup = 1,
2829 .active_low = 1,
2830 .no_autorepeat = 1,
2831};
2832
2833static struct platform_device mpq_keypad_device = {
2834 .name = "matrix-keypad",
2835 .id = -1,
2836 .dev = {
2837 .platform_data = &mpq_keypad_data,
2838 },
2839};
2840
Jin Hongd3024e62012-02-09 16:13:32 -08002841/* Sensors DSPS platform data */
2842#define DSPS_PIL_GENERIC_NAME "dsps"
2843static void __init apq8064_init_dsps(void)
2844{
2845 struct msm_dsps_platform_data *pdata =
2846 msm_dsps_device_8064.dev.platform_data;
2847 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2848 pdata->gpios = NULL;
2849 pdata->gpios_num = 0;
2850
2851 platform_device_register(&msm_dsps_device_8064);
2852}
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302853
Jing Lin417fa452012-02-05 14:31:06 -08002854#define I2C_SURF 1
2855#define I2C_FFA (1 << 1)
2856#define I2C_RUMI (1 << 2)
2857#define I2C_SIM (1 << 3)
2858#define I2C_LIQUID (1 << 4)
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002859#define I2C_MPQ_CDP BIT(5)
2860#define I2C_MPQ_HRD BIT(6)
2861#define I2C_MPQ_DTV BIT(7)
Jing Lin417fa452012-02-05 14:31:06 -08002862
2863struct i2c_registry {
2864 u8 machs;
2865 int bus;
2866 struct i2c_board_info *info;
2867 int len;
2868};
2869
2870static struct i2c_registry apq8064_i2c_devices[] __initdata = {
Jing Lin21ed4de2012-02-05 15:53:28 -08002871 {
David Keitel2f613d92012-02-15 11:29:16 -08002872 I2C_LIQUID,
2873 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2874 smb349_charger_i2c_info,
2875 ARRAY_SIZE(smb349_charger_i2c_info)
2876 },
2877 {
Jing Lin21ed4de2012-02-05 15:53:28 -08002878 I2C_SURF | I2C_LIQUID,
2879 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2880 mxt_device_info,
2881 ARRAY_SIZE(mxt_device_info),
2882 },
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08002883 {
2884 I2C_FFA,
2885 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2886 cyttsp_info,
2887 ARRAY_SIZE(cyttsp_info),
2888 },
Amy Maloche70090f992012-02-16 16:35:26 -08002889 {
2890 I2C_FFA | I2C_LIQUID,
2891 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2892 isa1200_board_info,
2893 ARRAY_SIZE(isa1200_board_info),
2894 },
Santosh Mardieff9a742012-04-09 23:23:39 +05302895 {
2896 I2C_MPQ_CDP,
2897 APQ_8064_GSBI5_QUP_I2C_BUS_ID,
2898 cs8427_device_info,
2899 ARRAY_SIZE(cs8427_device_info),
2900 },
Jing Lin417fa452012-02-05 14:31:06 -08002901};
2902
Jay Chokshi607f61b2012-04-25 18:21:21 -07002903#define SX150X_EXP1_INT_N PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9)
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302904#define SX150X_EXP2_INT_N MSM_GPIO_TO_INT(81)
Jay Chokshi607f61b2012-04-25 18:21:21 -07002905
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002906struct sx150x_platform_data mpq8064_sx150x_pdata[] = {
2907 [SX150X_EXP1] = {
2908 .gpio_base = SX150X_EXP1_GPIO_BASE,
2909 .oscio_is_gpo = false,
2910 .io_pullup_ena = 0x0,
2911 .io_pulldn_ena = 0x0,
2912 .io_open_drain_ena = 0x0,
2913 .io_polarity = 0,
Jay Chokshi607f61b2012-04-25 18:21:21 -07002914 .irq_summary = SX150X_EXP1_INT_N,
2915 .irq_base = SX150X_EXP1_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002916 },
2917 [SX150X_EXP2] = {
2918 .gpio_base = SX150X_EXP2_GPIO_BASE,
2919 .oscio_is_gpo = false,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302920 .io_pullup_ena = 0x0f,
2921 .io_pulldn_ena = 0x70,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002922 .io_open_drain_ena = 0x0,
2923 .io_polarity = 0,
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302924 .irq_summary = SX150X_EXP2_INT_N,
2925 .irq_base = SX150X_EXP2_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002926 },
2927 [SX150X_EXP3] = {
2928 .gpio_base = SX150X_EXP3_GPIO_BASE,
2929 .oscio_is_gpo = false,
2930 .io_pullup_ena = 0x0,
2931 .io_pulldn_ena = 0x0,
2932 .io_open_drain_ena = 0x0,
2933 .io_polarity = 0,
2934 .irq_summary = -1,
2935 },
2936 [SX150X_EXP4] = {
2937 .gpio_base = SX150X_EXP4_GPIO_BASE,
2938 .oscio_is_gpo = false,
2939 .io_pullup_ena = 0x0,
2940 .io_pulldn_ena = 0x0,
2941 .io_open_drain_ena = 0x0,
2942 .io_polarity = 0,
2943 .irq_summary = -1,
2944 },
2945};
2946
2947static struct i2c_board_info sx150x_gpio_exp_info[] = {
2948 {
2949 I2C_BOARD_INFO("sx1509q", 0x70),
2950 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP1],
2951 },
2952 {
2953 I2C_BOARD_INFO("sx1508q", 0x23),
2954 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP2],
2955 },
2956 {
2957 I2C_BOARD_INFO("sx1508q", 0x22),
2958 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP3],
2959 },
2960 {
2961 I2C_BOARD_INFO("sx1509q", 0x3E),
2962 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP4],
2963 },
2964};
2965
2966#define MPQ8064_I2C_GSBI5_BUS_ID 5
2967
2968static struct i2c_registry mpq8064_i2c_devices[] __initdata = {
2969 {
2970 I2C_MPQ_CDP,
2971 MPQ8064_I2C_GSBI5_BUS_ID,
2972 sx150x_gpio_exp_info,
2973 ARRAY_SIZE(sx150x_gpio_exp_info),
2974 },
2975};
2976
Jing Lin417fa452012-02-05 14:31:06 -08002977static void __init register_i2c_devices(void)
2978{
2979 u8 mach_mask = 0;
2980 int i;
2981
Kevin Chand07220e2012-02-13 15:52:22 -08002982#ifdef CONFIG_MSM_CAMERA
2983 struct i2c_registry apq8064_camera_i2c_devices = {
2984 I2C_SURF | I2C_FFA | I2C_LIQUID | I2C_RUMI,
2985 APQ_8064_GSBI4_QUP_I2C_BUS_ID,
2986 apq8064_camera_board_info.board_info,
2987 apq8064_camera_board_info.num_i2c_board_info,
2988 };
2989#endif
Jing Lin417fa452012-02-05 14:31:06 -08002990 /* Build the matching 'supported_machs' bitmask */
2991 if (machine_is_apq8064_cdp())
2992 mach_mask = I2C_SURF;
2993 else if (machine_is_apq8064_mtp())
2994 mach_mask = I2C_FFA;
2995 else if (machine_is_apq8064_liquid())
2996 mach_mask = I2C_LIQUID;
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002997 else if (PLATFORM_IS_MPQ8064())
2998 mach_mask = I2C_MPQ_CDP;
Jing Lin417fa452012-02-05 14:31:06 -08002999 else
3000 pr_err("unmatched machine ID in register_i2c_devices\n");
3001
3002 /* Run the array and install devices as appropriate */
3003 for (i = 0; i < ARRAY_SIZE(apq8064_i2c_devices); ++i) {
3004 if (apq8064_i2c_devices[i].machs & mach_mask)
3005 i2c_register_board_info(apq8064_i2c_devices[i].bus,
3006 apq8064_i2c_devices[i].info,
3007 apq8064_i2c_devices[i].len);
3008 }
Kevin Chand07220e2012-02-13 15:52:22 -08003009#ifdef CONFIG_MSM_CAMERA
3010 if (apq8064_camera_i2c_devices.machs & mach_mask)
3011 i2c_register_board_info(apq8064_camera_i2c_devices.bus,
3012 apq8064_camera_i2c_devices.info,
3013 apq8064_camera_i2c_devices.len);
3014#endif
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003015
3016 for (i = 0; i < ARRAY_SIZE(mpq8064_i2c_devices); ++i) {
3017 if (mpq8064_i2c_devices[i].machs & mach_mask)
3018 i2c_register_board_info(
3019 mpq8064_i2c_devices[i].bus,
3020 mpq8064_i2c_devices[i].info,
3021 mpq8064_i2c_devices[i].len);
3022 }
Jing Lin417fa452012-02-05 14:31:06 -08003023}
3024
Jay Chokshi994ff122012-03-27 15:43:48 -07003025static void enable_ddr3_regulator(void)
3026{
3027 static struct regulator *ext_ddr3;
3028
3029 /* Use MPP7 output state as a flag for PCDDR3 presence. */
3030 if (gpio_get_value_cansleep(PM8921_MPP_PM_TO_SYS(7)) > 0) {
3031 ext_ddr3 = regulator_get(NULL, "ext_ddr3");
3032 if (IS_ERR(ext_ddr3) || ext_ddr3 == NULL)
3033 pr_err("Could not get MPP7 regulator\n");
3034 else
3035 regulator_enable(ext_ddr3);
3036 }
3037}
3038
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003039static void enable_avc_i2c_bus(void)
3040{
3041 int avc_i2c_en_mpp = PM8921_MPP_PM_TO_SYS(8);
3042 int rc;
3043
3044 rc = gpio_request(avc_i2c_en_mpp, "avc_i2c_en");
3045 if (rc)
3046 pr_err("request for avc_i2c_en mpp failed,"
3047 "rc=%d\n", rc);
3048 else
3049 gpio_set_value_cansleep(avc_i2c_en_mpp, 1);
3050}
3051
David Collins6f7c3472012-08-22 13:18:06 -07003052/* Modify platform data values to match requirements for PM8917. */
3053static void __init apq8064_pm8917_pdata_fixup(void)
3054{
3055 cdp_keys_data.buttons = cdp_keys_pm8917;
3056 cdp_keys_data.nbuttons = ARRAY_SIZE(cdp_keys_pm8917);
3057}
3058
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003059static void __init apq8064_common_init(void)
3060{
Ameya Thakure155ece2012-07-09 12:08:37 -07003061 u32 platform_version;
David Collins6f7c3472012-08-22 13:18:06 -07003062
3063 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3064 apq8064_pm8917_pdata_fixup();
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003065 platform_device_register(&msm_gpio_device);
Joel King8f839b92012-04-01 14:37:46 -07003066 msm_tsens_early_init(&apq_tsens_pdata);
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003067 msm_thermal_init(&msm_thermal_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003068 if (socinfo_init() < 0)
3069 pr_err("socinfo_init() failed!\n");
Praveen Chidambaram78499012011-11-01 17:15:17 -06003070 BUG_ON(msm_rpm_init(&apq8064_rpm_data));
3071 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
David Collins2782b5c2012-02-06 10:02:42 -08003072 regulator_suppress_info_printing();
David Collins36199252012-08-21 15:43:02 -07003073 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3074 configure_apq8064_pm8917_power_grid();
David Collins2782b5c2012-02-06 10:02:42 -08003075 platform_device_register(&apq8064_device_rpm_regulator);
David Collins36199252012-08-21 15:43:02 -07003076 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3077 platform_device_register(&apq8064_pm8921_device_rpm_regulator);
Stephen Boyd4d0d2582012-02-10 14:49:40 -08003078 if (msm_xo_init())
3079 pr_err("Failed to initialize XO votes\n");
Matt Wagantallc51e5602012-02-27 17:25:25 -08003080 msm_clock_init(&apq8064_clock_init_data);
Stepan Moskovchenko2327a952011-12-14 16:31:28 -08003081 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -06003082 apq8064_i2c_init();
Jing Lin417fa452012-02-05 14:31:06 -08003083 register_i2c_devices();
Kenneth Heitke36920d32011-07-20 16:44:30 -06003084
Harini Jayaramanc4c58692011-07-19 14:50:10 -06003085 apq8064_device_qup_spi_gsbi5.dev.platform_data =
3086 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -08003087 apq8064_init_pmic();
Hemant Kumar94e7da22012-02-03 16:52:29 -08003088 if (machine_is_apq8064_liquid())
3089 msm_otg_pdata.mhl_enable = true;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003090
Ofir Cohen94213a72012-05-03 14:26:32 +03003091 android_usb_pdata.swfi_latency =
3092 msm_rpmrs_levels[0].latency_us;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003093
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003094 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Manu Gautam91223e02011-11-08 15:27:22 +05303095 apq8064_ehci_host_init();
Gagan Mac8a7a5d32011-11-11 16:43:06 -07003096 apq8064_init_buses();
David Collins36199252012-08-21 15:43:02 -07003097
3098 platform_add_devices(early_common_devices,
3099 ARRAY_SIZE(early_common_devices));
3100 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3101 platform_add_devices(pm8921_common_devices,
3102 ARRAY_SIZE(pm8921_common_devices));
3103 else
3104 platform_add_devices(pm8917_common_devices,
3105 ARRAY_SIZE(pm8917_common_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003106 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Terence Hampson36b70722012-05-10 13:18:16 -04003107 if (!(machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3108 machine_is_mpq8064_dtv()))
3109 platform_add_devices(common_not_mpq_devices,
3110 ARRAY_SIZE(common_not_mpq_devices));
Jay Chokshi994ff122012-03-27 15:43:48 -07003111 enable_ddr3_regulator();
Pavankumar Kondetife2d4d32012-09-07 15:33:09 +05303112 msm_hsic_pdata.swfi_latency =
3113 msm_rpmrs_levels[0].latency_us;
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003114 if (machine_is_apq8064_mtp()) {
Ajay Dudanic4e40db2012-08-20 14:44:40 -07003115 msm_hsic_pdata.log2_irq_thresh = 5,
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003116 apq8064_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
3117 device_initialize(&apq8064_device_hsic_host.dev);
3118 }
Jay Chokshie8741282012-01-25 15:22:55 -08003119 apq8064_pm8xxx_gpio_mpp_init();
Sahitya Tummala3586ed92011-08-03 09:13:23 +05303120 apq8064_init_mmc();
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003121
3122 if (machine_is_apq8064_mtp()) {
3123 mdm_8064_device.dev.platform_data = &mdm_platform_data;
Ameya Thakure155ece2012-07-09 12:08:37 -07003124 platform_version = socinfo_get_platform_version();
3125 if (SOCINFO_VERSION_MINOR(platform_version) == 1) {
3126 i2s_mdm_8064_device.dev.platform_data =
3127 &mdm_platform_data;
3128 platform_device_register(&i2s_mdm_8064_device);
3129 } else {
3130 mdm_8064_device.dev.platform_data = &mdm_platform_data;
3131 platform_device_register(&mdm_8064_device);
3132 }
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003133 }
3134 platform_device_register(&apq8064_slim_ctrl);
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06003135 slim_register_board_info(apq8064_slim_devices,
3136 ARRAY_SIZE(apq8064_slim_devices));
Taniya Dasbbf633d2012-07-31 16:07:47 +05303137 if (!PLATFORM_IS_MPQ8064()) {
Taniya Das30cae292012-07-31 15:56:12 +05303138 apq8064_init_dsps();
Taniya Dasbbf633d2012-07-31 16:07:47 +05303139 platform_device_register(&msm_8960_riva);
3140 }
Praveen Chidambaram78499012011-11-01 17:15:17 -06003141 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3142 msm_spm_l2_init(msm_spm_l2_data);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003143 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08003144 apq8064_epm_adc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003145}
3146
Huaibin Yang4a084e32011-12-15 15:25:52 -08003147static void __init apq8064_allocate_memory_regions(void)
3148{
3149 apq8064_allocate_fb_region();
3150}
3151
Joel King82b7e3f2012-01-05 10:03:27 -08003152static void __init apq8064_cdp_init(void)
3153{
Hanumant Singh50440d42012-04-23 19:27:16 -07003154 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3155 pr_err("meminfo_init() failed!\n");
Amy Maloche609bb5e2012-08-03 09:41:42 -07003156 if (machine_is_apq8064_mtp() &&
3157 SOCINFO_VERSION_MINOR(socinfo_get_platform_version()) == 1)
3158 cyttsp_pdata.sleep_gpio = CYTTSP_TS_GPIO_SLEEP_ALT;
Joel King82b7e3f2012-01-05 10:03:27 -08003159 apq8064_common_init();
Joel King8f839b92012-04-01 14:37:46 -07003160 if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3161 machine_is_mpq8064_dtv()) {
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003162 enable_avc_i2c_bus();
Olav Hauganef95ae32012-05-15 09:50:30 -07003163 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003164 platform_add_devices(mpq_devices, ARRAY_SIZE(mpq_devices));
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06003165 mpq8064_pcie_init();
Joel King8f839b92012-04-01 14:37:46 -07003166 } else {
3167 ethernet_init();
Olav Hauganef95ae32012-05-15 09:50:30 -07003168 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003169 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3170 spi_register_board_info(spi_board_info,
3171 ARRAY_SIZE(spi_board_info));
3172 }
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003173 apq8064_init_fb();
Jordan Crouseb3115fe2012-02-01 22:11:12 -07003174 apq8064_init_gpu();
Matt Wagantall1f65d9d2012-04-25 14:24:20 -07003175 platform_add_devices(apq8064_footswitch, apq8064_num_footswitch);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003176#ifdef CONFIG_MSM_CAMERA
Kevin Chand07220e2012-02-13 15:52:22 -08003177 apq8064_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003178#endif
Mohan Pallaka474b94b2012-01-25 12:59:58 +05303179
3180 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid())
3181 platform_device_register(&cdp_kp_pdev);
3182
3183 if (machine_is_apq8064_mtp())
3184 platform_device_register(&mtp_kp_pdev);
Hanumant Singh50440d42012-04-23 19:27:16 -07003185
3186 change_memory_power = &apq8064_change_memory_power;
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05303187
3188 if (machine_is_mpq8064_cdp()) {
3189 platform_device_register(&mpq_gpio_keys_pdev);
3190 platform_device_register(&mpq_keypad_device);
3191 }
Joel King82b7e3f2012-01-05 10:03:27 -08003192}
3193
Joel King82b7e3f2012-01-05 10:03:27 -08003194MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
3195 .map_io = apq8064_map_io,
3196 .reserve = apq8064_reserve,
3197 .init_irq = apq8064_init_irq,
3198 .handle_irq = gic_handle_irq,
3199 .timer = &msm_timer,
3200 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003201 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003202 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003203 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003204MACHINE_END
3205
3206MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
3207 .map_io = apq8064_map_io,
3208 .reserve = apq8064_reserve,
3209 .init_irq = apq8064_init_irq,
3210 .handle_irq = gic_handle_irq,
3211 .timer = &msm_timer,
3212 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003213 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003214 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003215 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003216MACHINE_END
3217
3218MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
3219 .map_io = apq8064_map_io,
3220 .reserve = apq8064_reserve,
3221 .init_irq = apq8064_init_irq,
3222 .handle_irq = gic_handle_irq,
3223 .timer = &msm_timer,
3224 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003225 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003226 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003227 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003228MACHINE_END
3229
Joel King064bbf82012-04-01 13:23:39 -07003230MACHINE_START(MPQ8064_CDP, "QCT MPQ8064 CDP")
3231 .map_io = apq8064_map_io,
3232 .reserve = apq8064_reserve,
3233 .init_irq = apq8064_init_irq,
3234 .handle_irq = gic_handle_irq,
3235 .timer = &msm_timer,
3236 .init_machine = apq8064_cdp_init,
3237 .init_early = apq8064_allocate_memory_regions,
3238 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003239 .restart = msm_restart,
Joel King064bbf82012-04-01 13:23:39 -07003240MACHINE_END
3241
Joel King11ca8202012-02-13 16:19:03 -08003242MACHINE_START(MPQ8064_HRD, "QCT MPQ8064 HRD")
3243 .map_io = apq8064_map_io,
3244 .reserve = apq8064_reserve,
3245 .init_irq = apq8064_init_irq,
3246 .handle_irq = gic_handle_irq,
3247 .timer = &msm_timer,
3248 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003249 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003250 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003251 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003252MACHINE_END
3253
3254MACHINE_START(MPQ8064_DTV, "QCT MPQ8064 DTV")
3255 .map_io = apq8064_map_io,
3256 .reserve = apq8064_reserve,
3257 .init_irq = apq8064_init_irq,
3258 .handle_irq = gic_handle_irq,
3259 .timer = &msm_timer,
3260 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003261 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003262 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003263 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003264MACHINE_END
3265