blob: 835b8b924c297eef658c20ca4b230f1ab5864b94 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. 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>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
Kenneth Heitke748593a2011-07-15 15:45:11 -060017#include <linux/i2c.h>
David Keitel2f613d92012-02-15 11:29:16 -080018#include <linux/i2c/smb349.h>
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -080019#include <linux/i2c/sx150x.h>
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -060020#include <linux/slimbus/slimbus.h>
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053021#include <linux/mfd/wcd9xxx/core.h>
22#include <linux/mfd/wcd9xxx/pdata.h>
Amy Maloche70090f992012-02-16 16:35:26 -080023#include <linux/mfd/pm8xxx/misc.h>
Kenneth Heitke36920d32011-07-20 16:44:30 -060024#include <linux/msm_ssbi.h>
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -070025#include <linux/spi/spi.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070026#include <linux/dma-mapping.h>
27#include <linux/platform_data/qcom_crypto_device.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080028#include <linux/ion.h>
Jack Cheung46bfffa2012-01-19 15:26:24 -080029#include <linux/memory.h>
Larry Bassel67b921d2012-04-06 10:23:27 -070030#include <linux/memblock.h>
Jing Lin21ed4de2012-02-05 15:53:28 -080031#include <linux/i2c/atmel_mxt_ts.h>
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -080032#include <linux/cyttsp.h>
Amy Maloche70090f992012-02-16 16:35:26 -080033#include <linux/i2c/isa1200.h>
Mohan Pallaka474b94b2012-01-25 12:59:58 +053034#include <linux/gpio_keys.h>
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -080035#include <linux/epm_adc.h>
Jay Chokshie7d8d4f2012-04-04 14:47:57 -070036#include <linux/i2c/sx150x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
39#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053040#include <asm/mach/mmc.h>
Ankit Verma6b7e2ba2012-01-26 15:48:54 -080041#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
43#include <mach/board.h>
44#include <mach/msm_iomap.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080045#include <mach/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <linux/usb/msm_hsusb.h>
47#include <linux/usb/android.h>
48#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060049#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#include "timer.h"
51#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070052#include <mach/gpio.h>
53#include <mach/gpiomux.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060054#include <mach/rpm.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080055#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070056#include <linux/android_pmem.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080057#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070058#include <mach/msm_memtypes.h>
59#include <linux/bootmem.h>
60#include <asm/setup.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070061#include <mach/dma.h>
Jin Hongd3024e62012-02-09 16:13:32 -080062#include <mach/msm_dsps.h>
Gagan Mac8a7a5d32011-11-11 16:43:06 -070063#include <mach/msm_bus_board.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060064#include <mach/cpuidle.h>
Joel Kingdacbc822012-01-25 13:30:57 -080065#include <mach/mdm2.h>
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -080066#include <linux/msm_tsens.h>
Stephen Boyd4d0d2582012-02-10 14:49:40 -080067#include <mach/msm_xo.h>
Laura Abbott350c8362012-02-28 14:46:52 -080068#include <mach/msm_rtb.h>
Santosh Mardieff9a742012-04-09 23:23:39 +053069#include <sound/cs8427.h>
Ravi Kumar V05931a22012-04-04 17:09:37 +053070#include <media/gpio-ir-recv.h>
Larry Bassel67b921d2012-04-06 10:23:27 -070071#include <linux/fmem.h>
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -060072#include <mach/msm_pcie.h>
Joel King4ebccc62011-07-22 09:43:22 -070073
Jeff Ohlstein7e668552011-10-06 16:17:25 -070074#include "msm_watchdog.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080075#include "board-8064.h"
Vikram Mulukutlabc2e9572011-11-04 03:41:38 -070076#include "acpuclock.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060077#include "spm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053078#include <mach/mpm.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060079#include "rpm_resources.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080080#include "pm.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060081#include "pm-boot.h"
Rajesh Sastrulaaee8af32012-01-20 11:46:31 -080082#include "devices-msm8x60.h"
Hanumant Singh50440d42012-04-23 19:27:16 -070083#include "smd_private.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070084
Olav Haugan7c6aa742012-01-16 16:47:37 -080085#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -070086#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Olav Haugan7c6aa742012-01-16 16:47:37 -080087#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
88#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
89#else
Chetan Kalyan72aac4f2012-02-23 14:56:54 -080090#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Olav Haugan7c6aa742012-01-16 16:47:37 -080091#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070092
Olav Haugan7c6aa742012-01-16 16:47:37 -080093#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -070094#define MSM_PMEM_KERNEL_EBI1_SIZE 0x65000
Olav Haugan129992c2012-03-22 09:54:01 -070095#ifdef CONFIG_MSM_IOMMU
96#define MSM_ION_MM_SIZE 0x3800000
97#define MSM_ION_SF_SIZE 0
Olav Haugan39477bb2012-05-14 16:05:36 -070098#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan129992c2012-03-22 09:54:01 -070099#define MSM_ION_HEAP_NUM 7
100#else
Olav Haugan7c6aa742012-01-16 16:47:37 -0800101#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan129992c2012-03-22 09:54:01 -0700102#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Haugan39477bb2012-05-14 16:05:36 -0700103#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700104#define MSM_ION_HEAP_NUM 8
105#endif
106#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800107#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan2c43fac2012-01-19 11:06:37 -0800108#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan7c6aa742012-01-16 16:47:37 -0800109#else
110#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
111#define MSM_ION_HEAP_NUM 1
112#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700113
Larry Bassel67b921d2012-04-06 10:23:27 -0700114#define APQ8064_FIXED_AREA_START 0xa0000000
115#define MAX_FIXED_AREA_SIZE 0x10000000
116#define MSM_MM_FW_SIZE 0x200000
117#define APQ8064_FW_START (APQ8064_FIXED_AREA_START - MSM_MM_FW_SIZE)
118
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600119/* PCIe power enable pmic gpio */
120#define PCIE_PWR_EN_PMIC_GPIO 13
121#define PCIE_RST_N_PMIC_MPP 1
122
Olav Haugan7c6aa742012-01-16 16:47:37 -0800123#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
124static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
125static int __init pmem_kernel_ebi1_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -0700126{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800127 pmem_kernel_ebi1_size = memparse(p, NULL);
128 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700129}
Olav Haugan7c6aa742012-01-16 16:47:37 -0800130early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
131#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700132
Olav Haugan7c6aa742012-01-16 16:47:37 -0800133#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -0700134static unsigned pmem_size = MSM_PMEM_SIZE;
135static int __init pmem_size_setup(char *p)
136{
137 pmem_size = memparse(p, NULL);
138 return 0;
139}
140early_param("pmem_size", pmem_size_setup);
141
142static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
143
144static int __init pmem_adsp_size_setup(char *p)
145{
146 pmem_adsp_size = memparse(p, NULL);
147 return 0;
148}
149early_param("pmem_adsp_size", pmem_adsp_size_setup);
150
151static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
152
153static int __init pmem_audio_size_setup(char *p)
154{
155 pmem_audio_size = memparse(p, NULL);
156 return 0;
157}
158early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800159#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700160
Olav Haugan7c6aa742012-01-16 16:47:37 -0800161#ifdef CONFIG_ANDROID_PMEM
162#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700163static struct android_pmem_platform_data android_pmem_pdata = {
164 .name = "pmem",
165 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
166 .cached = 1,
167 .memory_type = MEMTYPE_EBI1,
168};
169
Laura Abbottb93525f2012-04-12 09:57:19 -0700170static struct platform_device apq8064_android_pmem_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700171 .name = "android_pmem",
172 .id = 0,
173 .dev = {.platform_data = &android_pmem_pdata},
174};
175
176static struct android_pmem_platform_data android_pmem_adsp_pdata = {
177 .name = "pmem_adsp",
178 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
179 .cached = 0,
180 .memory_type = MEMTYPE_EBI1,
181};
Laura Abbottb93525f2012-04-12 09:57:19 -0700182static struct platform_device apq8064_android_pmem_adsp_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700183 .name = "android_pmem",
184 .id = 2,
185 .dev = { .platform_data = &android_pmem_adsp_pdata },
186};
187
188static struct android_pmem_platform_data android_pmem_audio_pdata = {
189 .name = "pmem_audio",
190 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
191 .cached = 0,
192 .memory_type = MEMTYPE_EBI1,
193};
194
Laura Abbottb93525f2012-04-12 09:57:19 -0700195static struct platform_device apq8064_android_pmem_audio_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700196 .name = "android_pmem",
197 .id = 4,
198 .dev = { .platform_data = &android_pmem_audio_pdata },
199};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700200#endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
201#endif /* CONFIG_ANDROID_PMEM */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800202
Larry Bassel67b921d2012-04-06 10:23:27 -0700203struct fmem_platform_data apq8064_fmem_pdata = {
204};
205
Olav Haugan7c6aa742012-01-16 16:47:37 -0800206static struct memtype_reserve apq8064_reserve_table[] __initdata = {
207 [MEMTYPE_SMI] = {
208 },
209 [MEMTYPE_EBI0] = {
210 .flags = MEMTYPE_FLAGS_1M_ALIGN,
211 },
212 [MEMTYPE_EBI1] = {
213 .flags = MEMTYPE_FLAGS_1M_ALIGN,
214 },
215};
Kevin Chan13be4e22011-10-20 11:30:32 -0700216
Laura Abbott350c8362012-02-28 14:46:52 -0800217static void __init reserve_rtb_memory(void)
218{
219#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700220 apq8064_reserve_table[MEMTYPE_EBI1].size += apq8064_rtb_pdata.size;
Laura Abbott350c8362012-02-28 14:46:52 -0800221#endif
222}
223
224
Kevin Chan13be4e22011-10-20 11:30:32 -0700225static void __init size_pmem_devices(void)
226{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800227#ifdef CONFIG_ANDROID_PMEM
228#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700229 android_pmem_adsp_pdata.size = pmem_adsp_size;
230 android_pmem_pdata.size = pmem_size;
231 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700232#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
233#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700234}
235
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700236#ifdef CONFIG_ANDROID_PMEM
237#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700238static void __init reserve_memory_for(struct android_pmem_platform_data *p)
239{
240 apq8064_reserve_table[p->memory_type].size += p->size;
241}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700242#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
243#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700244
Kevin Chan13be4e22011-10-20 11:30:32 -0700245static void __init reserve_pmem_memory(void)
246{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800247#ifdef CONFIG_ANDROID_PMEM
248#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700249 reserve_memory_for(&android_pmem_adsp_pdata);
250 reserve_memory_for(&android_pmem_pdata);
251 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700252#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700253 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700254#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -0800255}
256
257static int apq8064_paddr_to_memtype(unsigned int paddr)
258{
259 return MEMTYPE_EBI1;
260}
261
Larry Bassel67b921d2012-04-06 10:23:27 -0700262#define FMEM_ENABLED 1
263
Olav Haugan7c6aa742012-01-16 16:47:37 -0800264#ifdef CONFIG_ION_MSM
265#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700266static struct ion_cp_heap_pdata cp_mm_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800267 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800268 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700269 .reusable = FMEM_ENABLED,
270 .mem_is_fmem = FMEM_ENABLED,
271 .fixed_position = FIXED_MIDDLE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800272};
273
Laura Abbottb93525f2012-04-12 09:57:19 -0700274static struct ion_cp_heap_pdata cp_mfc_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800275 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800276 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700277 .reusable = 0,
278 .mem_is_fmem = FMEM_ENABLED,
279 .fixed_position = FIXED_HIGH,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800280};
281
Laura Abbottb93525f2012-04-12 09:57:19 -0700282static struct ion_co_heap_pdata co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800283 .adjacent_mem_id = INVALID_HEAP_ID,
284 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700285 .mem_is_fmem = 0,
Olav Haugand3d29682012-01-19 10:57:07 -0800286};
287
Laura Abbottb93525f2012-04-12 09:57:19 -0700288static struct ion_co_heap_pdata fw_co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800289 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
290 .align = SZ_128K,
Larry Bassel67b921d2012-04-06 10:23:27 -0700291 .mem_is_fmem = FMEM_ENABLED,
292 .fixed_position = FIXED_LOW,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800293};
294#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800295
296/**
297 * These heaps are listed in the order they will be allocated. Due to
298 * video hardware restrictions and content protection the FW heap has to
299 * be allocated adjacent (below) the MM heap and the MFC heap has to be
300 * allocated after the MM heap to ensure MFC heap is not more than 256MB
301 * away from the base address of the FW heap.
302 * However, the order of FW heap and MM heap doesn't matter since these
303 * two heaps are taken care of by separate code to ensure they are adjacent
304 * to each other.
305 * Don't swap the order unless you know what you are doing!
306 */
Laura Abbottb93525f2012-04-12 09:57:19 -0700307static struct ion_platform_data apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800308 .nr = MSM_ION_HEAP_NUM,
309 .heaps = {
310 {
311 .id = ION_SYSTEM_HEAP_ID,
312 .type = ION_HEAP_TYPE_SYSTEM,
313 .name = ION_VMALLOC_HEAP_NAME,
314 },
315#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
316 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800317 .id = ION_CP_MM_HEAP_ID,
318 .type = ION_HEAP_TYPE_CP,
319 .name = ION_MM_HEAP_NAME,
320 .size = MSM_ION_MM_SIZE,
321 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700322 .extra_data = (void *) &cp_mm_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800323 },
324 {
Olav Haugand3d29682012-01-19 10:57:07 -0800325 .id = ION_MM_FIRMWARE_HEAP_ID,
326 .type = ION_HEAP_TYPE_CARVEOUT,
327 .name = ION_MM_FIRMWARE_HEAP_NAME,
328 .size = MSM_ION_MM_FW_SIZE,
329 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700330 .extra_data = (void *) &fw_co_apq8064_ion_pdata,
Olav Haugand3d29682012-01-19 10:57:07 -0800331 },
332 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800333 .id = ION_CP_MFC_HEAP_ID,
334 .type = ION_HEAP_TYPE_CP,
335 .name = ION_MFC_HEAP_NAME,
336 .size = MSM_ION_MFC_SIZE,
337 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700338 .extra_data = (void *) &cp_mfc_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800339 },
Olav Haugan129992c2012-03-22 09:54:01 -0700340#ifndef CONFIG_MSM_IOMMU
Olav Haugan7c6aa742012-01-16 16:47:37 -0800341 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800342 .id = ION_SF_HEAP_ID,
343 .type = ION_HEAP_TYPE_CARVEOUT,
344 .name = ION_SF_HEAP_NAME,
345 .size = MSM_ION_SF_SIZE,
346 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700347 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800348 },
Olav Haugan129992c2012-03-22 09:54:01 -0700349#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800350 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800351 .id = ION_IOMMU_HEAP_ID,
352 .type = ION_HEAP_TYPE_IOMMU,
353 .name = ION_IOMMU_HEAP_NAME,
354 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800355 {
356 .id = ION_QSECOM_HEAP_ID,
357 .type = ION_HEAP_TYPE_CARVEOUT,
358 .name = ION_QSECOM_HEAP_NAME,
359 .size = MSM_ION_QSECOM_SIZE,
360 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700361 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Hauganf45e2142012-01-19 11:01:01 -0800362 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800363 {
364 .id = ION_AUDIO_HEAP_ID,
365 .type = ION_HEAP_TYPE_CARVEOUT,
366 .name = ION_AUDIO_HEAP_NAME,
367 .size = MSM_ION_AUDIO_SIZE,
368 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700369 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan2c43fac2012-01-19 11:06:37 -0800370 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800371#endif
372 }
373};
374
Laura Abbottb93525f2012-04-12 09:57:19 -0700375static struct platform_device apq8064_ion_dev = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800376 .name = "ion-msm",
377 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700378 .dev = { .platform_data = &apq8064_ion_pdata },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800379};
380#endif
381
Larry Bassel67b921d2012-04-06 10:23:27 -0700382static struct platform_device apq8064_fmem_device = {
383 .name = "fmem",
384 .id = 1,
385 .dev = { .platform_data = &apq8064_fmem_pdata },
386};
387
388static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
389 unsigned long size)
390{
391 apq8064_reserve_table[mem_type].size += size;
392}
393
394static void __init apq8064_reserve_fixed_area(unsigned long fixed_area_size)
395{
396#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
397 int ret;
398
399 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
400 panic("fixed area size is larger than %dM\n",
401 MAX_FIXED_AREA_SIZE >> 20);
402
403 reserve_info->fixed_area_size = fixed_area_size;
404 reserve_info->fixed_area_start = APQ8064_FW_START;
405
406 ret = memblock_remove(reserve_info->fixed_area_start,
407 reserve_info->fixed_area_size);
408 BUG_ON(ret);
409#endif
410}
411
412/**
413 * Reserve memory for ION and calculate amount of reusable memory for fmem.
414 * We only reserve memory for heaps that are not reusable. However, we only
415 * support one reusable heap at the moment so we ignore the reusable flag for
416 * other than the first heap with reusable flag set. Also handle special case
417 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
418 * at a higher address than FW in addition to not more than 256MB away from the
419 * base address of the firmware. This means that if MM is reusable the other
420 * two heaps must be allocated in the same region as FW. This is handled by the
421 * mem_is_fmem flag in the platform data. In addition the MM heap must be
422 * adjacent to the FW heap for content protection purposes.
423 */
Stephen Boyd668d7652012-04-25 11:31:01 -0700424static void __init reserve_ion_memory(void)
Olav Haugan7c6aa742012-01-16 16:47:37 -0800425{
426#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Larry Bassel67b921d2012-04-06 10:23:27 -0700427 unsigned int i;
428 unsigned int reusable_count = 0;
429 unsigned int fixed_size = 0;
430 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
431 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
432
433 apq8064_fmem_pdata.size = 0;
434 apq8064_fmem_pdata.reserved_size_low = 0;
435 apq8064_fmem_pdata.reserved_size_high = 0;
Olav Haugan62436252012-05-16 09:09:43 -0700436 apq8064_fmem_pdata.align = PAGE_SIZE;
Larry Bassel67b921d2012-04-06 10:23:27 -0700437 fixed_low_size = 0;
438 fixed_middle_size = 0;
439 fixed_high_size = 0;
440
441 /* We only support 1 reusable heap. Check if more than one heap
442 * is specified as reusable and set as non-reusable if found.
443 */
444 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
445 const struct ion_platform_heap *heap =
446 &(apq8064_ion_pdata.heaps[i]);
447
448 if (heap->type == ION_HEAP_TYPE_CP && heap->extra_data) {
449 struct ion_cp_heap_pdata *data = heap->extra_data;
450
451 reusable_count += (data->reusable) ? 1 : 0;
452
453 if (data->reusable && reusable_count > 1) {
454 pr_err("%s: Too many heaps specified as "
455 "reusable. Heap %s was not configured "
456 "as reusable.\n", __func__, heap->name);
457 data->reusable = 0;
458 }
459 }
460 }
461
462 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
463 const struct ion_platform_heap *heap =
464 &(apq8064_ion_pdata.heaps[i]);
465
466 if (heap->extra_data) {
467 int fixed_position = NOT_FIXED;
468 int mem_is_fmem = 0;
469
470 switch (heap->type) {
471 case ION_HEAP_TYPE_CP:
472 mem_is_fmem = ((struct ion_cp_heap_pdata *)
473 heap->extra_data)->mem_is_fmem;
474 fixed_position = ((struct ion_cp_heap_pdata *)
475 heap->extra_data)->fixed_position;
476 break;
477 case ION_HEAP_TYPE_CARVEOUT:
478 mem_is_fmem = ((struct ion_co_heap_pdata *)
479 heap->extra_data)->mem_is_fmem;
480 fixed_position = ((struct ion_co_heap_pdata *)
481 heap->extra_data)->fixed_position;
482 break;
483 default:
484 break;
485 }
486
487 if (fixed_position != NOT_FIXED)
488 fixed_size += heap->size;
489 else
490 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
491
492 if (fixed_position == FIXED_LOW)
493 fixed_low_size += heap->size;
494 else if (fixed_position == FIXED_MIDDLE)
495 fixed_middle_size += heap->size;
496 else if (fixed_position == FIXED_HIGH)
497 fixed_high_size += heap->size;
498
499 if (mem_is_fmem)
500 apq8064_fmem_pdata.size += heap->size;
501 }
502 }
503
504 if (!fixed_size)
505 return;
506
507 if (apq8064_fmem_pdata.size) {
508 apq8064_fmem_pdata.reserved_size_low = fixed_low_size;
509 apq8064_fmem_pdata.reserved_size_high = fixed_high_size;
510 }
511
512 /* Since the fixed area may be carved out of lowmem,
513 * make sure the length is a multiple of 1M.
514 */
515 fixed_size = (fixed_size + MSM_MM_FW_SIZE + SECTION_SIZE - 1)
516 & SECTION_MASK;
517 apq8064_reserve_fixed_area(fixed_size);
518
519 fixed_low_start = APQ8064_FIXED_AREA_START;
520 fixed_middle_start = fixed_low_start + fixed_low_size;
521 fixed_high_start = fixed_middle_start + fixed_middle_size;
522
523 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
524 struct ion_platform_heap *heap = &(apq8064_ion_pdata.heaps[i]);
525
526 if (heap->extra_data) {
527 int fixed_position = NOT_FIXED;
528
529 switch (heap->type) {
530 case ION_HEAP_TYPE_CP:
531 fixed_position = ((struct ion_cp_heap_pdata *)
532 heap->extra_data)->fixed_position;
533 break;
534 case ION_HEAP_TYPE_CARVEOUT:
535 fixed_position = ((struct ion_co_heap_pdata *)
536 heap->extra_data)->fixed_position;
537 break;
538 default:
539 break;
540 }
541
542 switch (fixed_position) {
543 case FIXED_LOW:
544 heap->base = fixed_low_start;
545 break;
546 case FIXED_MIDDLE:
547 heap->base = fixed_middle_start;
548 break;
549 case FIXED_HIGH:
550 heap->base = fixed_high_start;
551 break;
552 default:
553 break;
554 }
555 }
556 }
Olav Haugan7c6aa742012-01-16 16:47:37 -0800557#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700558}
559
Huaibin Yang4a084e32011-12-15 15:25:52 -0800560static void __init reserve_mdp_memory(void)
561{
562 apq8064_mdp_writeback(apq8064_reserve_table);
563}
564
Laura Abbott93a4a352012-05-25 09:26:35 -0700565static void __init reserve_cache_dump_memory(void)
566{
567#ifdef CONFIG_MSM_CACHE_DUMP
568 unsigned int total;
569
570 total = apq8064_cache_dump_pdata.l1_size +
571 apq8064_cache_dump_pdata.l2_size;
572 apq8064_reserve_table[MEMTYPE_EBI1].size += total;
573#endif
574}
575
Kevin Chan13be4e22011-10-20 11:30:32 -0700576static void __init apq8064_calculate_reserve_sizes(void)
577{
578 size_pmem_devices();
579 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800580 reserve_ion_memory();
Huaibin Yang4a084e32011-12-15 15:25:52 -0800581 reserve_mdp_memory();
Laura Abbott350c8362012-02-28 14:46:52 -0800582 reserve_rtb_memory();
Laura Abbott93a4a352012-05-25 09:26:35 -0700583 reserve_cache_dump_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700584}
585
586static struct reserve_info apq8064_reserve_info __initdata = {
587 .memtype_reserve_table = apq8064_reserve_table,
588 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
Larry Bassel67b921d2012-04-06 10:23:27 -0700589 .reserve_fixed_area = apq8064_reserve_fixed_area,
Kevin Chan13be4e22011-10-20 11:30:32 -0700590 .paddr_to_memtype = apq8064_paddr_to_memtype,
591};
592
593static int apq8064_memory_bank_size(void)
594{
595 return 1<<29;
596}
597
598static void __init locate_unstable_memory(void)
599{
600 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
601 unsigned long bank_size;
602 unsigned long low, high;
603
604 bank_size = apq8064_memory_bank_size();
605 low = meminfo.bank[0].start;
606 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800607
608 /* Check if 32 bit overflow occured */
609 if (high < mb->start)
Larry Bassel67b921d2012-04-06 10:23:27 -0700610 high = -PAGE_SIZE;
Olav Haugand76e3a82012-01-16 16:55:07 -0800611
Kevin Chan13be4e22011-10-20 11:30:32 -0700612 low &= ~(bank_size - 1);
613
614 if (high - low <= bank_size)
Larry Bassel67b921d2012-04-06 10:23:27 -0700615 goto no_dmm;
616
617#ifdef CONFIG_ENABLE_DMM
Jack Cheung46bfffa2012-01-19 15:26:24 -0800618 apq8064_reserve_info.low_unstable_address = mb->start -
619 MIN_MEMORY_BLOCK_SIZE + mb->size;
620 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
621
Kevin Chan13be4e22011-10-20 11:30:32 -0700622 apq8064_reserve_info.bank_size = bank_size;
623 pr_info("low unstable address %lx max size %lx bank size %lx\n",
624 apq8064_reserve_info.low_unstable_address,
625 apq8064_reserve_info.max_unstable_size,
626 apq8064_reserve_info.bank_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700627 return;
628#endif
629no_dmm:
630 apq8064_reserve_info.low_unstable_address = high;
631 apq8064_reserve_info.max_unstable_size = 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700632}
633
Hanumant Singh50440d42012-04-23 19:27:16 -0700634static int apq8064_change_memory_power(u64 start, u64 size,
635 int change_type)
636{
637 return soc_change_memory_power(start, size, change_type);
638}
639
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700640static char prim_panel_name[PANEL_NAME_MAX_LEN];
641static char ext_panel_name[PANEL_NAME_MAX_LEN];
642static int __init prim_display_setup(char *param)
643{
644 if (strnlen(param, PANEL_NAME_MAX_LEN))
645 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
646 return 0;
647}
648early_param("prim_display", prim_display_setup);
649
650static int __init ext_display_setup(char *param)
651{
652 if (strnlen(param, PANEL_NAME_MAX_LEN))
653 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
654 return 0;
655}
656early_param("ext_display", ext_display_setup);
657
Kevin Chan13be4e22011-10-20 11:30:32 -0700658static void __init apq8064_reserve(void)
659{
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700660 apq8064_set_display_params(prim_panel_name, ext_panel_name);
Kevin Chan13be4e22011-10-20 11:30:32 -0700661 msm_reserve();
Larry Bassel67b921d2012-04-06 10:23:27 -0700662 if (apq8064_fmem_pdata.size) {
663#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
664 if (reserve_info->fixed_area_size) {
665 apq8064_fmem_pdata.phys =
666 reserve_info->fixed_area_start + MSM_MM_FW_SIZE;
667 pr_info("mm fw at %lx (fixed) size %x\n",
668 reserve_info->fixed_area_start, MSM_MM_FW_SIZE);
669 pr_info("fmem start %lx (fixed) size %lx\n",
670 apq8064_fmem_pdata.phys,
671 apq8064_fmem_pdata.size);
672 }
673#endif
674 }
Kevin Chan13be4e22011-10-20 11:30:32 -0700675}
676
Laura Abbott6988cef2012-03-15 14:27:13 -0700677static void __init place_movable_zone(void)
678{
Larry Bassel67b921d2012-04-06 10:23:27 -0700679#ifdef CONFIG_ENABLE_DMM
Laura Abbott6988cef2012-03-15 14:27:13 -0700680 movable_reserved_start = apq8064_reserve_info.low_unstable_address;
681 movable_reserved_size = apq8064_reserve_info.max_unstable_size;
682 pr_info("movable zone start %lx size %lx\n",
683 movable_reserved_start, movable_reserved_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700684#endif
Laura Abbott6988cef2012-03-15 14:27:13 -0700685}
686
687static void __init apq8064_early_reserve(void)
688{
689 reserve_info = &apq8064_reserve_info;
690 locate_unstable_memory();
691 place_movable_zone();
692
693}
Hemant Kumara945b472012-01-25 15:08:06 -0800694#ifdef CONFIG_USB_EHCI_MSM_HSIC
Hemant Kumare6275972012-02-29 20:06:21 -0800695/* Bandwidth requests (zero) if no vote placed */
696static struct msm_bus_vectors hsic_init_vectors[] = {
697 {
698 .src = MSM_BUS_MASTER_SPS,
699 .dst = MSM_BUS_SLAVE_EBI_CH0,
700 .ab = 0,
701 .ib = 0,
702 },
703 {
704 .src = MSM_BUS_MASTER_SPS,
705 .dst = MSM_BUS_SLAVE_SPS,
706 .ab = 0,
707 .ib = 0,
708 },
709};
710
711/* Bus bandwidth requests in Bytes/sec */
712static struct msm_bus_vectors hsic_max_vectors[] = {
713 {
714 .src = MSM_BUS_MASTER_SPS,
715 .dst = MSM_BUS_SLAVE_EBI_CH0,
716 .ab = 60000000, /* At least 480Mbps on bus. */
717 .ib = 960000000, /* MAX bursts rate */
718 },
719 {
720 .src = MSM_BUS_MASTER_SPS,
721 .dst = MSM_BUS_SLAVE_SPS,
722 .ab = 0,
723 .ib = 512000000, /*vote for 64Mhz dfab clk rate*/
724 },
725};
726
727static struct msm_bus_paths hsic_bus_scale_usecases[] = {
728 {
729 ARRAY_SIZE(hsic_init_vectors),
730 hsic_init_vectors,
731 },
732 {
733 ARRAY_SIZE(hsic_max_vectors),
734 hsic_max_vectors,
735 },
736};
737
738static struct msm_bus_scale_pdata hsic_bus_scale_pdata = {
739 hsic_bus_scale_usecases,
740 ARRAY_SIZE(hsic_bus_scale_usecases),
741 .name = "hsic",
742};
743
Hemant Kumara945b472012-01-25 15:08:06 -0800744static struct msm_hsic_host_platform_data msm_hsic_pdata = {
Hemant Kumare6275972012-02-29 20:06:21 -0800745 .strobe = 88,
746 .data = 89,
747 .bus_scale_table = &hsic_bus_scale_pdata,
Hemant Kumara945b472012-01-25 15:08:06 -0800748};
749#else
750static struct msm_hsic_host_platform_data msm_hsic_pdata;
751#endif
752
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800753#define PID_MAGIC_ID 0x71432909
754#define SERIAL_NUM_MAGIC_ID 0x61945374
755#define SERIAL_NUMBER_LENGTH 127
756#define DLOAD_USB_BASE_ADD 0x2A03F0C8
757
758struct magic_num_struct {
759 uint32_t pid;
760 uint32_t serial_num;
761};
762
763struct dload_struct {
764 uint32_t reserved1;
765 uint32_t reserved2;
766 uint32_t reserved3;
767 uint16_t reserved4;
768 uint16_t pid;
769 char serial_number[SERIAL_NUMBER_LENGTH];
770 uint16_t reserved5;
771 struct magic_num_struct magic_struct;
772};
773
774static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
775{
776 struct dload_struct __iomem *dload = 0;
777
778 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
779 if (!dload) {
780 pr_err("%s: cannot remap I/O memory region: %08x\n",
781 __func__, DLOAD_USB_BASE_ADD);
782 return -ENXIO;
783 }
784
785 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
786 __func__, dload, pid, snum);
787 /* update pid */
788 dload->magic_struct.pid = PID_MAGIC_ID;
789 dload->pid = pid;
790
791 /* update serial number */
792 dload->magic_struct.serial_num = 0;
793 if (!snum) {
794 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
795 goto out;
796 }
797
798 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
799 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
800out:
801 iounmap(dload);
802 return 0;
803}
804
805static struct android_usb_platform_data android_usb_pdata = {
806 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
807};
808
Hemant Kumar4933b072011-10-17 23:43:11 -0700809static struct platform_device android_usb_device = {
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800810 .name = "android_usb",
811 .id = -1,
812 .dev = {
813 .platform_data = &android_usb_pdata,
814 },
Hemant Kumar4933b072011-10-17 23:43:11 -0700815};
816
Hemant Kumar7620eed2012-02-26 09:08:43 -0800817/* Bandwidth requests (zero) if no vote placed */
818static struct msm_bus_vectors usb_init_vectors[] = {
819 {
820 .src = MSM_BUS_MASTER_SPS,
821 .dst = MSM_BUS_SLAVE_EBI_CH0,
822 .ab = 0,
823 .ib = 0,
824 },
825};
826
827/* Bus bandwidth requests in Bytes/sec */
828static struct msm_bus_vectors usb_max_vectors[] = {
829 {
830 .src = MSM_BUS_MASTER_SPS,
831 .dst = MSM_BUS_SLAVE_EBI_CH0,
832 .ab = 60000000, /* At least 480Mbps on bus. */
833 .ib = 960000000, /* MAX bursts rate */
834 },
835};
836
837static struct msm_bus_paths usb_bus_scale_usecases[] = {
838 {
839 ARRAY_SIZE(usb_init_vectors),
840 usb_init_vectors,
841 },
842 {
843 ARRAY_SIZE(usb_max_vectors),
844 usb_max_vectors,
845 },
846};
847
848static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
849 usb_bus_scale_usecases,
850 ARRAY_SIZE(usb_bus_scale_usecases),
851 .name = "usb",
852};
853
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700854static int phy_init_seq[] = {
855 0x38, 0x81, /* update DC voltage level */
856 0x24, 0x82, /* set pre-emphasis and rise/fall time */
857 -1
858};
859
Hemant Kumar4933b072011-10-17 23:43:11 -0700860static struct msm_otg_platform_data msm_otg_pdata = {
Hemant Kumard86c4882012-01-24 19:39:37 -0800861 .mode = USB_OTG,
862 .otg_control = OTG_PMIC_CONTROL,
Hemant Kumar4933b072011-10-17 23:43:11 -0700863 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumard86c4882012-01-24 19:39:37 -0800864 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
865 .power_budget = 750,
Hemant Kumar7620eed2012-02-26 09:08:43 -0800866 .bus_scale_table = &usb_bus_scale_pdata,
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700867 .phy_init_seq = phy_init_seq,
Hemant Kumar4933b072011-10-17 23:43:11 -0700868};
869
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800870static struct msm_usb_host_platform_data msm_ehci_host_pdata3 = {
Manu Gautam91223e02011-11-08 15:27:22 +0530871 .power_budget = 500,
872};
873
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800874#ifdef CONFIG_USB_EHCI_MSM_HOST4
875static struct msm_usb_host_platform_data msm_ehci_host_pdata4;
876#endif
877
Manu Gautam91223e02011-11-08 15:27:22 +0530878static void __init apq8064_ehci_host_init(void)
879{
Chiranjeevi Velempatib822fa32012-05-23 22:05:59 +0530880 if (machine_is_apq8064_liquid() || machine_is_mpq8064_cdp() ||
881 machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
882 if (machine_is_apq8064_liquid())
883 msm_ehci_host_pdata3.dock_connect_irq =
884 PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9);
Hemant Kumar56925352012-02-13 16:59:52 -0800885
Manu Gautam91223e02011-11-08 15:27:22 +0530886 apq8064_device_ehci_host3.dev.platform_data =
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800887 &msm_ehci_host_pdata3;
Manu Gautam91223e02011-11-08 15:27:22 +0530888 platform_device_register(&apq8064_device_ehci_host3);
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800889
890#ifdef CONFIG_USB_EHCI_MSM_HOST4
891 apq8064_device_ehci_host4.dev.platform_data =
892 &msm_ehci_host_pdata4;
893 platform_device_register(&apq8064_device_ehci_host4);
894#endif
Manu Gautam91223e02011-11-08 15:27:22 +0530895 }
896}
897
David Keitel2f613d92012-02-15 11:29:16 -0800898static struct smb349_platform_data smb349_data __initdata = {
899 .en_n_gpio = PM8921_GPIO_PM_TO_SYS(37),
900 .chg_susp_gpio = PM8921_GPIO_PM_TO_SYS(30),
901 .chg_current_ma = 2200,
902};
903
904static struct i2c_board_info smb349_charger_i2c_info[] __initdata = {
905 {
906 I2C_BOARD_INFO(SMB349_NAME, 0x1B),
907 .platform_data = &smb349_data,
908 },
909};
910
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -0800911struct sx150x_platform_data apq8064_sx150x_data[] = {
912 [SX150X_EPM] = {
913 .gpio_base = GPIO_EPM_EXPANDER_BASE,
914 .oscio_is_gpo = false,
915 .io_pullup_ena = 0x0,
916 .io_pulldn_ena = 0x0,
917 .io_open_drain_ena = 0x0,
918 .io_polarity = 0,
919 .irq_summary = -1,
920 },
921};
922
923static struct epm_chan_properties ads_adc_channel_data[] = {
924 {10, 100}, {500, 50}, {1, 1}, {1, 1},
925 {20, 50}, {10, 100}, {1, 1}, {1, 1},
926 {10, 100}, {10, 100}, {100, 100}, {200, 100},
927 {100, 50}, {2000, 50}, {1000, 50}, {200, 50},
928 {200, 100}, {1, 1}, {20, 50}, {500, 50},
929 {50, 50}, {200, 100}, {500, 100}, {20, 50},
930 {200, 50}, {2000, 100}, {1000, 50}, {100, 50},
931 {200, 100}, {500, 50}, {1000, 100}, {200, 50},
932 {1000, 50}, {50, 50}, {100, 50}, {100, 50},
933 {1, 1}, {1, 1}, {20, 100}, {20, 50},
934 {500, 100}, {1000, 100}, {100, 50}, {1000, 50},
935 {100, 50}, {1000, 100}, {100, 50}, {100, 50},
936};
937
938static struct epm_adc_platform_data epm_adc_pdata = {
939 .channel = ads_adc_channel_data,
940 .bus_id = 0x0,
941 .epm_i2c_board_info = {
942 .type = "sx1509q",
943 .addr = 0x3e,
944 .platform_data = &apq8064_sx150x_data[SX150X_EPM],
945 },
946 .gpio_expander_base_addr = GPIO_EPM_EXPANDER_BASE,
947};
948
949static struct platform_device epm_adc_device = {
950 .name = "epm_adc",
951 .id = -1,
952 .dev = {
953 .platform_data = &epm_adc_pdata,
954 },
955};
956
957static void __init apq8064_epm_adc_init(void)
958{
959 epm_adc_pdata.num_channels = 32;
960 epm_adc_pdata.num_adc = 2;
961 epm_adc_pdata.chan_per_adc = 16;
962 epm_adc_pdata.chan_per_mux = 8;
963};
964
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800965/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
966 * 4 micbiases are used to power various analog and digital
967 * microphones operating at 1800 mV. Technically, all micbiases
968 * can source from single cfilter since all microphones operate
969 * at the same voltage level. The arrangement below is to make
970 * sure all cfilters are exercised. LDO_H regulator ouput level
971 * does not need to be as high as 2.85V. It is choosen for
972 * microphone sensitivity purpose.
973 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530974static struct wcd9xxx_pdata apq8064_tabla_platform_data = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800975 .slimbus_slave_device = {
976 .name = "tabla-slave",
977 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
978 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800979 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800980 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530981 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -0800982 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
983 .micbias = {
984 .ldoh_v = TABLA_LDOH_2P85_V,
985 .cfilt1_mv = 1800,
986 .cfilt2_mv = 1800,
987 .cfilt3_mv = 1800,
988 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
989 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
990 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
991 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530992 },
993 .regulator = {
994 {
995 .name = "CDC_VDD_CP",
996 .min_uV = 1800000,
997 .max_uV = 1800000,
998 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
999 },
1000 {
1001 .name = "CDC_VDDA_RX",
1002 .min_uV = 1800000,
1003 .max_uV = 1800000,
1004 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1005 },
1006 {
1007 .name = "CDC_VDDA_TX",
1008 .min_uV = 1800000,
1009 .max_uV = 1800000,
1010 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1011 },
1012 {
1013 .name = "VDDIO_CDC",
1014 .min_uV = 1800000,
1015 .max_uV = 1800000,
1016 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1017 },
1018 {
1019 .name = "VDDD_CDC_D",
1020 .min_uV = 1225000,
1021 .max_uV = 1225000,
1022 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1023 },
1024 {
1025 .name = "CDC_VDDA_A_1P2V",
1026 .min_uV = 1225000,
1027 .max_uV = 1225000,
1028 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1029 },
1030 },
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001031};
1032
1033static struct slim_device apq8064_slim_tabla = {
1034 .name = "tabla-slim",
1035 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1036 .dev = {
1037 .platform_data = &apq8064_tabla_platform_data,
1038 },
1039};
1040
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301041static struct wcd9xxx_pdata apq8064_tabla20_platform_data = {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001042 .slimbus_slave_device = {
1043 .name = "tabla-slave",
1044 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
1045 },
1046 .irq = MSM_GPIO_TO_INT(42),
1047 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301048 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001049 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1050 .micbias = {
1051 .ldoh_v = TABLA_LDOH_2P85_V,
1052 .cfilt1_mv = 1800,
1053 .cfilt2_mv = 1800,
1054 .cfilt3_mv = 1800,
1055 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1056 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1057 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1058 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301059 },
1060 .regulator = {
1061 {
1062 .name = "CDC_VDD_CP",
1063 .min_uV = 1800000,
1064 .max_uV = 1800000,
1065 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1066 },
1067 {
1068 .name = "CDC_VDDA_RX",
1069 .min_uV = 1800000,
1070 .max_uV = 1800000,
1071 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1072 },
1073 {
1074 .name = "CDC_VDDA_TX",
1075 .min_uV = 1800000,
1076 .max_uV = 1800000,
1077 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1078 },
1079 {
1080 .name = "VDDIO_CDC",
1081 .min_uV = 1800000,
1082 .max_uV = 1800000,
1083 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1084 },
1085 {
1086 .name = "VDDD_CDC_D",
1087 .min_uV = 1225000,
1088 .max_uV = 1225000,
1089 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1090 },
1091 {
1092 .name = "CDC_VDDA_A_1P2V",
1093 .min_uV = 1225000,
1094 .max_uV = 1225000,
1095 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1096 },
1097 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001098};
1099
1100static struct slim_device apq8064_slim_tabla20 = {
1101 .name = "tabla2x-slim",
1102 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1103 .dev = {
1104 .platform_data = &apq8064_tabla20_platform_data,
1105 },
1106};
1107
Santosh Mardi695be0d2012-04-10 23:21:12 +05301108/* enable the level shifter for cs8427 to make sure the I2C
1109 * clock is running at 100KHz and voltage levels are at 3.3
1110 * and 5 volts
1111 */
1112static int enable_100KHz_ls(int enable)
1113{
1114 int ret = 0;
1115 if (enable) {
1116 ret = gpio_request(SX150X_GPIO(1, 10),
1117 "cs8427_100KHZ_ENABLE");
1118 if (ret) {
1119 pr_err("%s: Failed to request gpio %d\n", __func__,
1120 SX150X_GPIO(1, 10));
1121 return ret;
1122 }
1123 gpio_direction_output(SX150X_GPIO(1, 10), 1);
1124 } else
1125 gpio_free(SX150X_GPIO(1, 10));
1126 return ret;
1127}
1128
Santosh Mardieff9a742012-04-09 23:23:39 +05301129static struct cs8427_platform_data cs8427_i2c_platform_data = {
1130 .irq = SX150X_GPIO(1, 4),
1131 .reset_gpio = SX150X_GPIO(1, 6),
Santosh Mardi695be0d2012-04-10 23:21:12 +05301132 .enable = enable_100KHz_ls,
Santosh Mardieff9a742012-04-09 23:23:39 +05301133};
1134
1135static struct i2c_board_info cs8427_device_info[] __initdata = {
1136 {
1137 I2C_BOARD_INFO("cs8427", CS8427_ADDR4),
1138 .platform_data = &cs8427_i2c_platform_data,
1139 },
1140};
1141
Amy Maloche70090f992012-02-16 16:35:26 -08001142#define HAP_SHIFT_LVL_OE_GPIO PM8921_MPP_PM_TO_SYS(8)
1143#define ISA1200_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1144#define ISA1200_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
1145#define ISA1200_HAP_CLK PM8921_GPIO_PM_TO_SYS(44)
1146
Mohan Pallaka2d877602012-05-11 13:07:30 +05301147static int isa1200_clk_enable(bool on)
Amy Maloche70090f992012-02-16 16:35:26 -08001148{
Amy Maloche8f973892012-03-26 14:53:13 -07001149 int rc = 0;
1150
Mohan Pallaka2d877602012-05-11 13:07:30 +05301151 gpio_set_value_cansleep(ISA1200_HAP_CLK, on);
Amy Maloche70090f992012-02-16 16:35:26 -08001152
Mohan Pallaka2d877602012-05-11 13:07:30 +05301153 if (on) {
Amy Maloche8f973892012-03-26 14:53:13 -07001154 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_1, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301155 if (rc) {
1156 pr_err("%s: unable to write aux clock register(%d)\n",
1157 __func__, rc);
1158 goto err_gpio_dis;
1159 }
1160 } else {
Amy Maloche8f973892012-03-26 14:53:13 -07001161 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_NONE, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301162 if (rc)
1163 pr_err("%s: unable to write aux clock register(%d)\n",
1164 __func__, rc);
Amy Maloche8f973892012-03-26 14:53:13 -07001165 }
1166
1167 return rc;
Mohan Pallaka2d877602012-05-11 13:07:30 +05301168
1169err_gpio_dis:
1170 gpio_set_value_cansleep(ISA1200_HAP_CLK, !on);
1171 return rc;
Amy Maloche70090f992012-02-16 16:35:26 -08001172}
1173
1174static int isa1200_dev_setup(bool enable)
1175{
1176 int rc = 0;
1177
Amy Maloche70090f992012-02-16 16:35:26 -08001178 if (!enable)
1179 goto free_gpio;
1180
1181 rc = gpio_request(ISA1200_HAP_CLK, "haptics_clk");
1182 if (rc) {
1183 pr_err("%s: unable to request gpio %d config(%d)\n",
1184 __func__, ISA1200_HAP_CLK, rc);
1185 return rc;
1186 }
1187
1188 rc = gpio_direction_output(ISA1200_HAP_CLK, 0);
1189 if (rc) {
1190 pr_err("%s: unable to set direction\n", __func__);
1191 goto free_gpio;
1192 }
1193
1194 return 0;
1195
1196free_gpio:
1197 gpio_free(ISA1200_HAP_CLK);
1198 return rc;
1199}
1200
1201static struct isa1200_regulator isa1200_reg_data[] = {
1202 {
1203 .name = "vddp",
1204 .min_uV = ISA_I2C_VTG_MIN_UV,
1205 .max_uV = ISA_I2C_VTG_MAX_UV,
1206 .load_uA = ISA_I2C_CURR_UA,
1207 },
1208};
1209
1210static struct isa1200_platform_data isa1200_1_pdata = {
1211 .name = "vibrator",
1212 .dev_setup = isa1200_dev_setup,
Mohan Pallaka2d877602012-05-11 13:07:30 +05301213 .clk_enable = isa1200_clk_enable,
Amy Maloche70090f992012-02-16 16:35:26 -08001214 .hap_en_gpio = ISA1200_HAP_EN_GPIO,
1215 .hap_len_gpio = ISA1200_HAP_LEN_GPIO,
1216 .max_timeout = 15000,
1217 .mode_ctrl = PWM_GEN_MODE,
1218 .pwm_fd = {
1219 .pwm_div = 256,
1220 },
1221 .is_erm = false,
1222 .smart_en = true,
1223 .ext_clk_en = true,
1224 .chip_en = 1,
1225 .regulator_info = isa1200_reg_data,
1226 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1227};
1228
1229static struct i2c_board_info isa1200_board_info[] __initdata = {
1230 {
1231 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1232 .platform_data = &isa1200_1_pdata,
1233 },
1234};
Jing Lin21ed4de2012-02-05 15:53:28 -08001235/* configuration data for mxt1386e using V2.1 firmware */
1236static const u8 mxt1386e_config_data_v2_1[] = {
1237 /* T6 Object */
1238 0, 0, 0, 0, 0, 0,
1239 /* T38 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001240 14, 2, 0, 24, 5, 12, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1246 0, 0, 0, 0,
1247 /* T7 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001248 100, 10, 50,
Jing Lin21ed4de2012-02-05 15:53:28 -08001249 /* T8 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001250 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001251 /* T9 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001252 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Lin21ed4de2012-02-05 15:53:28 -08001253 0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
Jing Linf1208fd2012-02-23 11:15:42 -08001254 85, 5, 0, 5, 9, 5, 12, 35, 70, 40,
1255 20, 5, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001256 /* T18 Object */
1257 0, 0,
1258 /* T24 Object */
1259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1260 0, 0, 0, 0, 0, 0, 0, 0, 0,
1261 /* T25 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001262 1, 0, 60, 115, 156, 99,
Jing Lin21ed4de2012-02-05 15:53:28 -08001263 /* T27 Object */
1264 0, 0, 0, 0, 0, 0, 0,
1265 /* T40 Object */
1266 0, 0, 0, 0, 0,
1267 /* T42 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001268 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001269 /* T43 Object */
1270 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
1271 16,
1272 /* T46 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001273 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001274 /* T47 Object */
1275 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
1276 /* T48 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001277 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001278 32, 40, 0, 10, 10, 0, 0, 100, 10, 90,
1279 0, 0, 0, 0, 0, 0, 0, 10, 1, 10,
1280 52, 10, 12, 0, 33, 0, 1, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1282 0, 0, 0, 0,
1283 /* T56 Object */
1284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1287 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001288 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1289 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001290};
1291
1292#define MXT_TS_GPIO_IRQ 6
1293#define MXT_TS_PWR_EN_GPIO PM8921_GPIO_PM_TO_SYS(23)
1294#define MXT_TS_RESET_GPIO 33
1295
1296static struct mxt_config_info mxt_config_array[] = {
1297 {
1298 .config = mxt1386e_config_data_v2_1,
1299 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1300 .family_id = 0xA0,
1301 .variant_id = 0x7,
1302 .version = 0x21,
1303 .build = 0xAA,
Jing Linef4aa9b2012-03-26 12:01:41 -07001304 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
1305 .fw_name = "atmel_8064_liquid_v2_2_AA.hex",
1306 },
1307 {
1308 /* The config data for V2.2.AA is the same as for V2.1.AA */
1309 .config = mxt1386e_config_data_v2_1,
1310 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1311 .family_id = 0xA0,
1312 .variant_id = 0x7,
1313 .version = 0x22,
1314 .build = 0xAA,
1315 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin21ed4de2012-02-05 15:53:28 -08001316 },
1317};
1318
1319static struct mxt_platform_data mxt_platform_data = {
1320 .config_array = mxt_config_array,
1321 .config_array_size = ARRAY_SIZE(mxt_config_array),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08001322 .panel_minx = 0,
1323 .panel_maxx = 1365,
1324 .panel_miny = 0,
1325 .panel_maxy = 767,
1326 .disp_minx = 0,
1327 .disp_maxx = 1365,
1328 .disp_miny = 0,
1329 .disp_maxy = 767,
Anirudh Ghayal39dbe3f2012-04-13 15:43:16 +05301330 .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Jing Lin21ed4de2012-02-05 15:53:28 -08001331 .i2c_pull_up = true,
1332 .reset_gpio = MXT_TS_RESET_GPIO,
1333 .irq_gpio = MXT_TS_GPIO_IRQ,
1334};
1335
1336static struct i2c_board_info mxt_device_info[] __initdata = {
1337 {
1338 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
1339 .platform_data = &mxt_platform_data,
1340 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1341 },
1342};
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001343#define CYTTSP_TS_GPIO_IRQ 6
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001344#define CYTTSP_TS_GPIO_SLEEP 33
1345
1346static ssize_t tma340_vkeys_show(struct kobject *kobj,
1347 struct kobj_attribute *attr, char *buf)
1348{
1349 return snprintf(buf, 200,
1350 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1351 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1352 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1353 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1354 "\n");
1355}
1356
1357static struct kobj_attribute tma340_vkeys_attr = {
1358 .attr = {
1359 .mode = S_IRUGO,
1360 },
1361 .show = &tma340_vkeys_show,
1362};
1363
1364static struct attribute *tma340_properties_attrs[] = {
1365 &tma340_vkeys_attr.attr,
1366 NULL
1367};
1368
1369static struct attribute_group tma340_properties_attr_group = {
1370 .attrs = tma340_properties_attrs,
1371};
1372
1373static int cyttsp_platform_init(struct i2c_client *client)
1374{
1375 int rc = 0;
1376 static struct kobject *tma340_properties_kobj;
1377
1378 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1379 tma340_properties_kobj = kobject_create_and_add("board_properties",
1380 NULL);
1381 if (tma340_properties_kobj)
1382 rc = sysfs_create_group(tma340_properties_kobj,
1383 &tma340_properties_attr_group);
1384 if (!tma340_properties_kobj || rc)
1385 pr_err("%s: failed to create board_properties\n",
1386 __func__);
1387
1388 return 0;
1389}
1390
1391static struct cyttsp_regulator cyttsp_regulator_data[] = {
1392 {
1393 .name = "vdd",
1394 .min_uV = CY_TMA300_VTG_MIN_UV,
1395 .max_uV = CY_TMA300_VTG_MAX_UV,
1396 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1397 .lpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1398 },
1399 {
1400 .name = "vcc_i2c",
1401 .min_uV = CY_I2C_VTG_MIN_UV,
1402 .max_uV = CY_I2C_VTG_MAX_UV,
1403 .hpm_load_uA = CY_I2C_CURR_UA,
1404 .lpm_load_uA = CY_I2C_CURR_UA,
1405 },
1406};
1407
1408static struct cyttsp_platform_data cyttsp_pdata = {
1409 .panel_maxx = 634,
1410 .panel_maxy = 1166,
1411 .disp_maxx = 599,
1412 .disp_maxy = 1023,
1413 .disp_minx = 0,
1414 .disp_miny = 0,
1415 .flags = 0x01,
1416 .gen = CY_GEN3,
1417 .use_st = CY_USE_ST,
1418 .use_mt = CY_USE_MT,
1419 .use_hndshk = CY_SEND_HNDSHK,
1420 .use_trk_id = CY_USE_TRACKING_ID,
1421 .use_sleep = CY_USE_DEEP_SLEEP_SEL,
1422 .use_gestures = CY_USE_GESTURES,
1423 .fw_fname = "cyttsp_8064_mtp.hex",
1424 /* change act_intrvl to customize the Active power state
1425 * scanning/processing refresh interval for Operating mode
1426 */
1427 .act_intrvl = CY_ACT_INTRVL_DFLT,
1428 /* change tch_tmout to customize the touch timeout for the
1429 * Active power state for Operating mode
1430 */
1431 .tch_tmout = CY_TCH_TMOUT_DFLT,
1432 /* change lp_intrvl to customize the Low Power power state
1433 * scanning/processing refresh interval for Operating mode
1434 */
1435 .lp_intrvl = CY_LP_INTRVL_DFLT,
1436 .sleep_gpio = CYTTSP_TS_GPIO_SLEEP,
Amy Maloche9ba3ffe2012-04-26 10:31:20 -07001437 .resout_gpio = -1,
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001438 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1439 .regulator_info = cyttsp_regulator_data,
1440 .num_regulators = ARRAY_SIZE(cyttsp_regulator_data),
1441 .init = cyttsp_platform_init,
1442 .correct_fw_ver = 17,
1443};
1444
1445static struct i2c_board_info cyttsp_info[] __initdata = {
1446 {
1447 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1448 .platform_data = &cyttsp_pdata,
1449 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1450 },
1451};
Jing Lin21ed4de2012-02-05 15:53:28 -08001452
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08001453#define MSM_WCNSS_PHYS 0x03000000
1454#define MSM_WCNSS_SIZE 0x280000
1455
1456static struct resource resources_wcnss_wlan[] = {
1457 {
1458 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1459 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1460 .name = "wcnss_wlanrx_irq",
1461 .flags = IORESOURCE_IRQ,
1462 },
1463 {
1464 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1465 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1466 .name = "wcnss_wlantx_irq",
1467 .flags = IORESOURCE_IRQ,
1468 },
1469 {
1470 .start = MSM_WCNSS_PHYS,
1471 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1472 .name = "wcnss_mmio",
1473 .flags = IORESOURCE_MEM,
1474 },
1475 {
1476 .start = 64,
1477 .end = 68,
1478 .name = "wcnss_gpios_5wire",
1479 .flags = IORESOURCE_IO,
1480 },
1481};
1482
1483static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1484 .has_48mhz_xo = 1,
1485};
1486
1487static struct platform_device msm_device_wcnss_wlan = {
1488 .name = "wcnss_wlan",
1489 .id = 0,
1490 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1491 .resource = resources_wcnss_wlan,
1492 .dev = {.platform_data = &qcom_wcnss_pdata},
1493};
1494
Ankit Vermab7c26e62012-02-28 15:04:15 -08001495static struct platform_device msm_device_iris_fm __devinitdata = {
1496 .name = "iris_fm",
1497 .id = -1,
1498};
1499
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001500#ifdef CONFIG_QSEECOM
1501/* qseecom bus scaling */
1502static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1503 {
1504 .src = MSM_BUS_MASTER_SPS,
1505 .dst = MSM_BUS_SLAVE_EBI_CH0,
1506 .ib = 0,
1507 .ab = 0,
1508 },
1509 {
1510 .src = MSM_BUS_MASTER_SPDM,
1511 .dst = MSM_BUS_SLAVE_SPDM,
1512 .ib = 0,
1513 .ab = 0,
1514 },
1515};
1516
1517static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1518 {
1519 .src = MSM_BUS_MASTER_SPS,
1520 .dst = MSM_BUS_SLAVE_EBI_CH0,
1521 .ib = (492 * 8) * 1000000UL,
1522 .ab = (492 * 8) * 100000UL,
1523 },
1524 {
1525 .src = MSM_BUS_MASTER_SPDM,
1526 .dst = MSM_BUS_SLAVE_SPDM,
1527 .ib = 0,
1528 .ab = 0,
1529 },
1530};
1531
1532static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1533 {
1534 .src = MSM_BUS_MASTER_SPS,
1535 .dst = MSM_BUS_SLAVE_EBI_CH0,
1536 .ib = 0,
1537 .ab = 0,
1538 },
1539 {
1540 .src = MSM_BUS_MASTER_SPDM,
1541 .dst = MSM_BUS_SLAVE_SPDM,
1542 .ib = (64 * 8) * 1000000UL,
1543 .ab = (64 * 8) * 100000UL,
1544 },
1545};
1546
1547static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1548 {
1549 ARRAY_SIZE(qseecom_clks_init_vectors),
1550 qseecom_clks_init_vectors,
1551 },
1552 {
1553 ARRAY_SIZE(qseecom_enable_dfab_vectors),
1554 qseecom_enable_sfpb_vectors,
1555 },
1556 {
1557 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1558 qseecom_enable_sfpb_vectors,
1559 },
1560};
1561
1562static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1563 qseecom_hw_bus_scale_usecases,
1564 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1565 .name = "qsee",
1566};
1567
1568static struct platform_device qseecom_device = {
1569 .name = "qseecom",
1570 .id = 0,
1571 .dev = {
1572 .platform_data = &qseecom_bus_pdata,
1573 },
1574};
1575#endif
1576
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001577#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1578 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1579 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1580 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1581
1582#define QCE_SIZE 0x10000
1583#define QCE_0_BASE 0x11000000
1584
1585#define QCE_HW_KEY_SUPPORT 0
1586#define QCE_SHA_HMAC_SUPPORT 1
1587#define QCE_SHARE_CE_RESOURCE 3
1588#define QCE_CE_SHARED 0
1589
1590static struct resource qcrypto_resources[] = {
1591 [0] = {
1592 .start = QCE_0_BASE,
1593 .end = QCE_0_BASE + QCE_SIZE - 1,
1594 .flags = IORESOURCE_MEM,
1595 },
1596 [1] = {
1597 .name = "crypto_channels",
1598 .start = DMOV8064_CE_IN_CHAN,
1599 .end = DMOV8064_CE_OUT_CHAN,
1600 .flags = IORESOURCE_DMA,
1601 },
1602 [2] = {
1603 .name = "crypto_crci_in",
1604 .start = DMOV8064_CE_IN_CRCI,
1605 .end = DMOV8064_CE_IN_CRCI,
1606 .flags = IORESOURCE_DMA,
1607 },
1608 [3] = {
1609 .name = "crypto_crci_out",
1610 .start = DMOV8064_CE_OUT_CRCI,
1611 .end = DMOV8064_CE_OUT_CRCI,
1612 .flags = IORESOURCE_DMA,
1613 },
1614};
1615
1616static struct resource qcedev_resources[] = {
1617 [0] = {
1618 .start = QCE_0_BASE,
1619 .end = QCE_0_BASE + QCE_SIZE - 1,
1620 .flags = IORESOURCE_MEM,
1621 },
1622 [1] = {
1623 .name = "crypto_channels",
1624 .start = DMOV8064_CE_IN_CHAN,
1625 .end = DMOV8064_CE_OUT_CHAN,
1626 .flags = IORESOURCE_DMA,
1627 },
1628 [2] = {
1629 .name = "crypto_crci_in",
1630 .start = DMOV8064_CE_IN_CRCI,
1631 .end = DMOV8064_CE_IN_CRCI,
1632 .flags = IORESOURCE_DMA,
1633 },
1634 [3] = {
1635 .name = "crypto_crci_out",
1636 .start = DMOV8064_CE_OUT_CRCI,
1637 .end = DMOV8064_CE_OUT_CRCI,
1638 .flags = IORESOURCE_DMA,
1639 },
1640};
1641
1642#endif
1643
1644#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1645 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1646
1647static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1648 .ce_shared = QCE_CE_SHARED,
1649 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1650 .hw_key_support = QCE_HW_KEY_SUPPORT,
1651 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001652 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001653};
1654
1655static struct platform_device qcrypto_device = {
1656 .name = "qcrypto",
1657 .id = 0,
1658 .num_resources = ARRAY_SIZE(qcrypto_resources),
1659 .resource = qcrypto_resources,
1660 .dev = {
1661 .coherent_dma_mask = DMA_BIT_MASK(32),
1662 .platform_data = &qcrypto_ce_hw_suppport,
1663 },
1664};
1665#endif
1666
1667#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1668 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1669
1670static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1671 .ce_shared = QCE_CE_SHARED,
1672 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1673 .hw_key_support = QCE_HW_KEY_SUPPORT,
1674 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001675 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001676};
1677
1678static struct platform_device qcedev_device = {
1679 .name = "qce",
1680 .id = 0,
1681 .num_resources = ARRAY_SIZE(qcedev_resources),
1682 .resource = qcedev_resources,
1683 .dev = {
1684 .coherent_dma_mask = DMA_BIT_MASK(32),
1685 .platform_data = &qcedev_ce_hw_suppport,
1686 },
1687};
1688#endif
1689
Joel Kingdacbc822012-01-25 13:30:57 -08001690static struct mdm_platform_data mdm_platform_data = {
1691 .mdm_version = "3.0",
1692 .ramdump_delay_ms = 2000,
Joel King14fe7fa2012-05-27 14:26:11 -07001693 .early_power_on = 1,
1694 .sfr_query = 1,
Hemant Kumara945b472012-01-25 15:08:06 -08001695 .peripheral_platform_device = &apq8064_device_hsic_host,
Joel Kingdacbc822012-01-25 13:30:57 -08001696};
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001697
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08001698static struct tsens_platform_data apq_tsens_pdata = {
1699 .tsens_factor = 1000,
1700 .hw_type = APQ_8064,
1701 .tsens_num_sensor = 11,
1702 .slope = {1176, 1176, 1154, 1176, 1111,
1703 1132, 1132, 1199, 1132, 1199, 1132},
1704};
1705
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07001706static struct platform_device msm_tsens_device = {
1707 .name = "tsens8960-tm",
1708 .id = -1,
1709};
1710
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001711#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001712static void __init apq8064_map_io(void)
1713{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001714 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001715 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001716 if (socinfo_init() < 0)
1717 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001718}
1719
1720static void __init apq8064_init_irq(void)
1721{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001722 struct msm_mpm_device_data *data = NULL;
1723
1724#ifdef CONFIG_MSM_MPM
1725 data = &apq8064_mpm_dev_data;
1726#endif
1727
1728 msm_mpm_irq_extn_init(data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001729 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
1730 (void *)MSM_QGIC_CPU_BASE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001731}
1732
Jay Chokshi7805b5a2011-11-07 15:55:30 -08001733static struct platform_device msm8064_device_saw_regulator_core0 = {
1734 .name = "saw-regulator",
1735 .id = 0,
1736 .dev = {
1737 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
1738 },
1739};
1740
1741static struct platform_device msm8064_device_saw_regulator_core1 = {
1742 .name = "saw-regulator",
1743 .id = 1,
1744 .dev = {
1745 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
1746 },
1747};
1748
1749static struct platform_device msm8064_device_saw_regulator_core2 = {
1750 .name = "saw-regulator",
1751 .id = 2,
1752 .dev = {
1753 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
1754 },
1755};
1756
1757static struct platform_device msm8064_device_saw_regulator_core3 = {
1758 .name = "saw-regulator",
1759 .id = 3,
1760 .dev = {
1761 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001762
1763 },
1764};
1765
Oluwafemi Adeyemif5a31422012-03-08 16:58:45 -08001766static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001767 {
1768 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1769 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1770 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001771 1, 784, 180000, 100,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001772 },
1773
1774 {
1775 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1776 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1777 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001778 1300, 228, 1200000, 2000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001779 },
1780
1781 {
1782 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1783 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
1784 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001785 2000, 138, 1208400, 3200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001786 },
1787
1788 {
1789 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Praveen Chidambarame3380672012-02-08 10:32:27 -07001790 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
1791 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001792 6000, 119, 1850300, 9000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001793 },
1794
1795 {
1796 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1797 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
1798 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001799 9200, 68, 2839200, 16400,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001800 },
1801
1802 {
1803 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1804 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
1805 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001806 10300, 63, 3128000, 18200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001807 },
1808
1809 {
1810 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1811 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
1812 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001813 18000, 10, 4602600, 27000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001814 },
1815
1816 {
1817 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1818 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
1819 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001820 20000, 2, 5752000, 32000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001821 },
1822};
1823
1824static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1825 .mode = MSM_PM_BOOT_CONFIG_TZ,
1826};
1827
1828static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
1829 .levels = &msm_rpmrs_levels[0],
1830 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
1831 .vdd_mem_levels = {
1832 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
1833 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
1834 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
1835 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
1836 },
1837 .vdd_dig_levels = {
1838 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
1839 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
1840 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
1841 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
1842 },
1843 .vdd_mask = 0x7FFFFF,
1844 .rpmrs_target_id = {
1845 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
1846 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
1847 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
1848 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
1849 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
1850 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
1851 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
1852 },
1853};
1854
Praveen Chidambaram78499012011-11-01 17:15:17 -06001855static uint8_t spm_wfi_cmd_sequence[] __initdata = {
1856 0x03, 0x0f,
1857};
1858
1859static uint8_t spm_power_collapse_without_rpm[] __initdata = {
1860 0x00, 0x24, 0x54, 0x10,
1861 0x09, 0x03, 0x01,
1862 0x10, 0x54, 0x30, 0x0C,
1863 0x24, 0x30, 0x0f,
1864};
1865
1866static uint8_t spm_power_collapse_with_rpm[] __initdata = {
1867 0x00, 0x24, 0x54, 0x10,
1868 0x09, 0x07, 0x01, 0x0B,
1869 0x10, 0x54, 0x30, 0x0C,
1870 0x24, 0x30, 0x0f,
1871};
1872
1873static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
1874 [0] = {
1875 .mode = MSM_SPM_MODE_CLOCK_GATING,
1876 .notify_rpm = false,
1877 .cmd = spm_wfi_cmd_sequence,
1878 },
1879 [1] = {
1880 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1881 .notify_rpm = false,
1882 .cmd = spm_power_collapse_without_rpm,
1883 },
1884 [2] = {
1885 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
1886 .notify_rpm = true,
1887 .cmd = spm_power_collapse_with_rpm,
1888 },
1889};
1890
1891static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
1892 0x00, 0x20, 0x03, 0x20,
1893 0x00, 0x0f,
1894};
1895
1896static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
1897 0x00, 0x20, 0x34, 0x64,
1898 0x48, 0x07, 0x48, 0x20,
1899 0x50, 0x64, 0x04, 0x34,
1900 0x50, 0x0f,
1901};
1902static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
1903 0x00, 0x10, 0x34, 0x64,
1904 0x48, 0x07, 0x48, 0x10,
1905 0x50, 0x64, 0x04, 0x34,
1906 0x50, 0x0F,
1907};
1908
1909static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
1910 [0] = {
1911 .mode = MSM_SPM_L2_MODE_RETENTION,
1912 .notify_rpm = false,
1913 .cmd = l2_spm_wfi_cmd_sequence,
1914 },
1915 [1] = {
1916 .mode = MSM_SPM_L2_MODE_GDHS,
1917 .notify_rpm = true,
1918 .cmd = l2_spm_gdhs_cmd_sequence,
1919 },
1920 [2] = {
1921 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
1922 .notify_rpm = true,
1923 .cmd = l2_spm_power_off_cmd_sequence,
1924 },
1925};
1926
1927
1928static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
1929 [0] = {
1930 .reg_base_addr = MSM_SAW_L2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001931 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001932 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001933 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
1934 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
1935 .modes = msm_spm_l2_seq_list,
1936 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
1937 },
1938};
1939
1940static struct msm_spm_platform_data msm_spm_data[] __initdata = {
1941 [0] = {
1942 .reg_base_addr = MSM_SAW0_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001943 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001944#if defined(CONFIG_MSM_AVS_HW)
1945 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1946 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1947#endif
1948 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001949 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001950 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1951 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1952 .vctl_timeout_us = 50,
1953 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1954 .modes = msm_spm_seq_list,
1955 },
1956 [1] = {
1957 .reg_base_addr = MSM_SAW1_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001958 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001959#if defined(CONFIG_MSM_AVS_HW)
1960 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1961 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1962#endif
1963 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001964 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001965 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1966 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1967 .vctl_timeout_us = 50,
1968 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1969 .modes = msm_spm_seq_list,
1970 },
1971 [2] = {
1972 .reg_base_addr = MSM_SAW2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001973 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001974#if defined(CONFIG_MSM_AVS_HW)
1975 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1976 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1977#endif
1978 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001979 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001980 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1981 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1982 .vctl_timeout_us = 50,
1983 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1984 .modes = msm_spm_seq_list,
1985 },
1986 [3] = {
1987 .reg_base_addr = MSM_SAW3_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001988 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001989#if defined(CONFIG_MSM_AVS_HW)
1990 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
1991 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
1992#endif
1993 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07001994 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001995 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
1996 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
1997 .vctl_timeout_us = 50,
1998 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
1999 .modes = msm_spm_seq_list,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002000 },
2001};
2002
Praveen Chidambaram4d19be42012-04-03 18:05:52 -06002003static struct msm_pm_sleep_status_data msm_pm_slp_sts_data = {
2004 .base_addr = MSM_ACC0_BASE + 0x08,
2005 .cpu_offset = MSM_ACC1_BASE - MSM_ACC0_BASE,
2006 .mask = 1UL << 13,
2007};
2008
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002009static void __init apq8064_init_buses(void)
2010{
2011 msm_bus_rpm_set_mt_mask();
2012 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
2013 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
2014 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
2015 msm_bus_8064_apps_fabric.dev.platform_data =
2016 &msm_bus_8064_apps_fabric_pdata;
2017 msm_bus_8064_sys_fabric.dev.platform_data =
2018 &msm_bus_8064_sys_fabric_pdata;
2019 msm_bus_8064_mm_fabric.dev.platform_data =
2020 &msm_bus_8064_mm_fabric_pdata;
2021 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
2022 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
2023}
2024
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002025/* PCIe gpios */
2026static struct msm_pcie_gpio_info_t msm_pcie_gpio_info[MSM_PCIE_MAX_GPIO] = {
2027 {"rst_n", PM8921_MPP_PM_TO_SYS(PCIE_RST_N_PMIC_MPP), 0},
2028 {"pwr_en", PM8921_GPIO_PM_TO_SYS(PCIE_PWR_EN_PMIC_GPIO), 1},
2029};
2030
2031static struct msm_pcie_platform msm_pcie_platform_data = {
2032 .gpio = msm_pcie_gpio_info,
2033};
2034
2035static void __init mpq8064_pcie_init(void)
2036{
2037 msm_device_pcie.dev.platform_data = &msm_pcie_platform_data;
2038 platform_device_register(&msm_device_pcie);
2039}
2040
David Collinsf0d00732012-01-25 15:46:50 -08002041static struct platform_device apq8064_device_ext_5v_vreg __devinitdata = {
2042 .name = GPIO_REGULATOR_DEV_NAME,
2043 .id = PM8921_MPP_PM_TO_SYS(7),
2044 .dev = {
2045 .platform_data
2046 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2047 },
2048};
2049
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002050static struct platform_device apq8064_device_ext_mpp8_vreg __devinitdata = {
2051 .name = GPIO_REGULATOR_DEV_NAME,
2052 .id = PM8921_MPP_PM_TO_SYS(8),
2053 .dev = {
2054 .platform_data
2055 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_MPP8],
2056 },
2057};
2058
David Collinsf0d00732012-01-25 15:46:50 -08002059static struct platform_device apq8064_device_ext_3p3v_vreg __devinitdata = {
2060 .name = GPIO_REGULATOR_DEV_NAME,
2061 .id = APQ8064_EXT_3P3V_REG_EN_GPIO,
2062 .dev = {
2063 .platform_data =
2064 &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2065 },
2066};
2067
David Collins390fc332012-02-07 14:38:16 -08002068static struct platform_device apq8064_device_ext_ts_sw_vreg __devinitdata = {
2069 .name = GPIO_REGULATOR_DEV_NAME,
2070 .id = PM8921_GPIO_PM_TO_SYS(23),
2071 .dev = {
2072 .platform_data
2073 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_TS_SW],
2074 },
2075};
2076
David Collins2782b5c2012-02-06 10:02:42 -08002077static struct platform_device apq8064_device_rpm_regulator __devinitdata = {
2078 .name = "rpm-regulator",
2079 .id = -1,
2080 .dev = {
2081 .platform_data = &apq8064_rpm_regulator_pdata,
2082 },
2083};
2084
Ravi Kumar V05931a22012-04-04 17:09:37 +05302085static struct gpio_ir_recv_platform_data gpio_ir_recv_pdata = {
2086 .gpio_nr = 88,
2087 .active_low = 1,
2088};
2089
2090static struct platform_device gpio_ir_recv_pdev = {
2091 .name = "gpio-rc-recv",
2092 .dev = {
2093 .platform_data = &gpio_ir_recv_pdata,
2094 },
2095};
2096
Terence Hampson36b70722012-05-10 13:18:16 -04002097static struct platform_device *common_not_mpq_devices[] __initdata = {
David Keitel3c40fc52012-02-09 17:53:52 -08002098 &apq8064_device_qup_i2c_gsbi1,
Jing Lin04601f92012-02-05 15:36:07 -08002099 &apq8064_device_qup_i2c_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002100 &apq8064_device_qup_i2c_gsbi4,
Terence Hampson36b70722012-05-10 13:18:16 -04002101};
2102
2103static struct platform_device *common_devices[] __initdata = {
2104 &apq8064_device_dmov,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002105 &apq8064_device_qup_spi_gsbi5,
David Collinsf0d00732012-01-25 15:46:50 -08002106 &apq8064_device_ext_5v_vreg,
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002107 &apq8064_device_ext_mpp8_vreg,
David Collinsf0d00732012-01-25 15:46:50 -08002108 &apq8064_device_ext_3p3v_vreg,
David Collins390fc332012-02-07 14:38:16 -08002109 &apq8064_device_ext_ts_sw_vreg,
Jay Chokshi9c25f072011-09-23 18:19:15 -07002110 &apq8064_device_ssbi_pmic1,
2111 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06002112 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -07002113 &apq8064_device_otg,
2114 &apq8064_device_gadget_peripheral,
Hemant Kumard86c4882012-01-24 19:39:37 -08002115 &apq8064_device_hsusb_host,
Hemant Kumar4933b072011-10-17 23:43:11 -07002116 &android_usb_device,
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08002117 &msm_device_wcnss_wlan,
Ankit Vermab7c26e62012-02-28 15:04:15 -08002118 &msm_device_iris_fm,
Larry Bassel67b921d2012-04-06 10:23:27 -07002119 &apq8064_fmem_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002120#ifdef CONFIG_ANDROID_PMEM
2121#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002122 &apq8064_android_pmem_device,
2123 &apq8064_android_pmem_adsp_device,
2124 &apq8064_android_pmem_audio_device,
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002125#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2126#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -08002127#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002128 &apq8064_ion_dev,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002129#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002130 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002131 &msm8064_device_saw_regulator_core0,
2132 &msm8064_device_saw_regulator_core1,
2133 &msm8064_device_saw_regulator_core2,
2134 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002135#if defined(CONFIG_QSEECOM)
2136 &qseecom_device,
2137#endif
2138
Ramesh Masavarapu28311912011-10-27 11:04:12 -07002139#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2140 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2141 &qcrypto_device,
2142#endif
2143
2144#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2145 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2146 &qcedev_device,
2147#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07002148
2149#ifdef CONFIG_HW_RANDOM_MSM
2150 &apq8064_device_rng,
2151#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002152 &apq_pcm,
2153 &apq_pcm_routing,
2154 &apq_cpudai0,
2155 &apq_cpudai1,
Santosh Mardieff9a742012-04-09 23:23:39 +05302156 &mpq_cpudai_sec_i2s_rx,
Kuirong Wangf23f8c52012-03-31 12:34:51 -07002157 &mpq_cpudai_mi2s_tx,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002158 &apq_cpudai_hdmi_rx,
2159 &apq_cpudai_bt_rx,
2160 &apq_cpudai_bt_tx,
2161 &apq_cpudai_fm_rx,
2162 &apq_cpudai_fm_tx,
2163 &apq_cpu_fe,
2164 &apq_stub_codec,
2165 &apq_voice,
2166 &apq_voip,
2167 &apq_lpa_pcm,
Krishnankutty Kolathappilly4374e332012-03-18 22:27:30 -07002168 &apq_compr_dsp,
2169 &apq_multi_ch_pcm,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002170 &apq_pcm_hostless,
2171 &apq_cpudai_afe_01_rx,
2172 &apq_cpudai_afe_01_tx,
2173 &apq_cpudai_afe_02_rx,
2174 &apq_cpudai_afe_02_tx,
2175 &apq_pcm_afe,
2176 &apq_cpudai_auxpcm_rx,
2177 &apq_cpudai_auxpcm_tx,
Neema Shetty8427c262012-02-16 11:23:43 -08002178 &apq_cpudai_stub,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002179 &apq_cpudai_slimbus_1_rx,
2180 &apq_cpudai_slimbus_1_tx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002181 &apq_cpudai_slimbus_2_tx,
Neema Shettyc9d86c32012-05-09 12:01:39 -07002182 &apq_cpudai_slimbus_3_rx,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002183 &apq8064_rpm_device,
2184 &apq8064_rpm_log_device,
2185 &apq8064_rpm_stat_device,
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002186 &msm_bus_8064_apps_fabric,
2187 &msm_bus_8064_sys_fabric,
2188 &msm_bus_8064_mm_fabric,
2189 &msm_bus_8064_sys_fpb,
2190 &msm_bus_8064_cpss_fpb,
Mohan Kumar Gubbihalli Lachma Naik7f72edd2012-02-06 17:26:47 -08002191 &apq8064_msm_device_vidc,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002192 &msm_pil_dsps,
Matt Wagantalled832652012-02-02 19:23:17 -08002193 &msm_8960_riva,
Matt Wagantallb94b9a52012-02-02 21:59:54 -08002194 &msm_8960_q6_lpass,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002195 &msm_pil_vidc,
Matt Wagantall292aace2012-01-26 19:12:34 -08002196 &msm_gss,
Laura Abbottb93525f2012-04-12 09:57:19 -07002197 &apq8064_rtb_device,
Praveen Chidambaram8ea3dcd2011-12-07 14:46:31 -07002198 &apq8064_cpu_idle_device,
Praveen Chidambaram5c8adf22012-02-23 18:44:37 -07002199 &apq8064_msm_gov_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002200 &apq8064_device_cache_erp,
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002201 &epm_adc_device,
Pratik Patel212ab362012-03-16 12:30:07 -07002202 &apq8064_qdss_device,
2203 &msm_etb_device,
2204 &msm_tpiu_device,
2205 &msm_funnel_device,
2206 &apq8064_etm_device,
Helen Zeng8f925502012-03-05 16:50:17 -08002207 &apq_cpudai_slim_4_rx,
2208 &apq_cpudai_slim_4_tx,
Jignesh Mehta921649d2012-04-19 06:57:23 -07002209 &msm8960_gemini_device,
Laura Abbott0577d7b2012-04-17 11:14:30 -07002210 &apq8064_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002211 &msm_tsens_device,
Laura Abbott93a4a352012-05-25 09:26:35 -07002212 &apq8064_cache_dump_device,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002213};
2214
Joel King4e7ad222011-08-17 15:47:38 -07002215static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -07002216 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -07002217 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -07002218};
2219
2220static struct platform_device *rumi3_devices[] __initdata = {
2221 &apq8064_device_uart_gsbi1,
Yan He435ed612011-11-23 17:34:59 -08002222 &msm_device_sps_apq8064,
Huaibin Yang4a084e32011-12-15 15:25:52 -08002223#ifdef CONFIG_MSM_ROTATOR
2224 &msm_rotator_device,
2225#endif
Joel King4e7ad222011-08-17 15:47:38 -07002226};
2227
Joel King82b7e3f2012-01-05 10:03:27 -08002228static struct platform_device *cdp_devices[] __initdata = {
2229 &apq8064_device_uart_gsbi1,
Jin Hong4bbbfba2012-02-02 21:48:07 -08002230 &apq8064_device_uart_gsbi7,
Joel King82b7e3f2012-01-05 10:03:27 -08002231 &msm_device_sps_apq8064,
Aravind Venkateswaran4ca27532012-02-16 14:27:05 -08002232#ifdef CONFIG_MSM_ROTATOR
2233 &msm_rotator_device,
2234#endif
Joel King82b7e3f2012-01-05 10:03:27 -08002235};
2236
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002237static struct platform_device
2238mpq8064_device_ext_5v_frc_vreg __devinitdata = {
2239 .name = GPIO_REGULATOR_DEV_NAME,
2240 .id = SX150X_GPIO(4, 10),
2241 .dev = {
2242 .platform_data =
2243 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_FRC_5V],
2244 },
2245};
2246
2247static struct platform_device
2248mpq8064_device_ext_1p2_buck_vreg __devinitdata = {
2249 .name = GPIO_REGULATOR_DEV_NAME,
2250 .id = SX150X_GPIO(4, 2),
2251 .dev = {
2252 .platform_data =
2253 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P2V],
2254 },
2255};
2256
2257static struct platform_device
2258mpq8064_device_ext_1p8_buck_vreg __devinitdata = {
2259 .name = GPIO_REGULATOR_DEV_NAME,
2260 .id = SX150X_GPIO(4, 4),
2261 .dev = {
2262 .platform_data =
2263 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P8V],
2264 },
2265};
2266
2267static struct platform_device
2268mpq8064_device_ext_2p2_buck_vreg __devinitdata = {
2269 .name = GPIO_REGULATOR_DEV_NAME,
2270 .id = SX150X_GPIO(4, 14),
2271 .dev = {
2272 .platform_data =
2273 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_2P2V],
2274 },
2275};
2276
2277static struct platform_device
2278mpq8064_device_ext_5v_buck_vreg __devinitdata = {
2279 .name = GPIO_REGULATOR_DEV_NAME,
2280 .id = SX150X_GPIO(4, 3),
2281 .dev = {
2282 .platform_data =
2283 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_5V],
2284 },
2285};
2286
2287static struct platform_device
2288mpq8064_device_ext_3p3v_ldo_vreg __devinitdata = {
2289 .name = GPIO_REGULATOR_DEV_NAME,
2290 .id = SX150X_GPIO(4, 15),
2291 .dev = {
2292 .platform_data =
2293 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_3P3V],
2294 },
2295};
2296
Ravi Kumar V1c903012012-05-15 16:11:35 +05302297static struct platform_device rc_input_loopback_pdev = {
2298 .name = "rc-user-input",
2299 .id = -1,
2300};
2301
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302302static int rf4ce_gpio_init(void)
2303{
2304 if (!machine_is_mpq8064_cdp())
2305 return -EINVAL;
2306
2307 /* CC2533 SRDY Input */
2308 if (!gpio_request(SX150X_GPIO(4, 6), "rf4ce_srdy")) {
2309 gpio_direction_input(SX150X_GPIO(4, 6));
2310 gpio_export(SX150X_GPIO(4, 6), true);
2311 }
2312
2313 /* CC2533 MRDY Output */
2314 if (!gpio_request(SX150X_GPIO(4, 5), "rf4ce_mrdy")) {
2315 gpio_direction_output(SX150X_GPIO(4, 5), 1);
2316 gpio_export(SX150X_GPIO(4, 5), true);
2317 }
2318
2319 /* CC2533 Reset Output */
2320 if (!gpio_request(SX150X_GPIO(4, 7), "rf4ce_reset")) {
2321 gpio_direction_output(SX150X_GPIO(4, 7), 0);
2322 gpio_export(SX150X_GPIO(4, 7), true);
2323 }
2324
2325 return 0;
2326}
2327late_initcall(rf4ce_gpio_init);
2328
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002329static struct platform_device *mpq_devices[] __initdata = {
2330 &msm_device_sps_apq8064,
2331 &mpq8064_device_qup_i2c_gsbi5,
2332#ifdef CONFIG_MSM_ROTATOR
2333 &msm_rotator_device,
2334#endif
Ravi Kumar V05931a22012-04-04 17:09:37 +05302335 &gpio_ir_recv_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002336 &mpq8064_device_ext_5v_frc_vreg,
2337 &mpq8064_device_ext_1p2_buck_vreg,
2338 &mpq8064_device_ext_1p8_buck_vreg,
2339 &mpq8064_device_ext_2p2_buck_vreg,
2340 &mpq8064_device_ext_5v_buck_vreg,
2341 &mpq8064_device_ext_3p3v_ldo_vreg,
Terence Hampson2e1705f2012-04-11 19:55:29 -04002342#ifdef CONFIG_MSM_VCAP
2343 &msm8064_device_vcap,
2344#endif
Ravi Kumar V1c903012012-05-15 16:11:35 +05302345 &rc_input_loopback_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002346};
2347
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002348static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002349 .max_clock_speed = 1100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002350};
2351
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002352#define KS8851_IRQ_GPIO 43
2353
2354static struct spi_board_info spi_board_info[] __initdata = {
2355 {
2356 .modalias = "ks8851",
2357 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2358 .max_speed_hz = 19200000,
2359 .bus_num = 0,
2360 .chip_select = 2,
2361 .mode = SPI_MODE_0,
2362 },
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002363 {
2364 .modalias = "epm_adc",
2365 .max_speed_hz = 1100000,
2366 .bus_num = 0,
2367 .chip_select = 3,
2368 .mode = SPI_MODE_0,
2369 },
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002370};
2371
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002372static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002373 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08002374 .bus_num = 1,
2375 .slim_slave = &apq8064_slim_tabla,
2376 },
2377 {
2378 .bus_num = 1,
2379 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002380 },
2381 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002382};
2383
David Keitel3c40fc52012-02-09 17:53:52 -08002384static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi1_pdata = {
2385 .clk_freq = 100000,
2386 .src_clk_rate = 24000000,
2387};
2388
Jing Lin04601f92012-02-05 15:36:07 -08002389static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi3_pdata = {
Anirudh Ghayalc2163472012-04-10 14:58:14 +05302390 .clk_freq = 384000,
Jing Lin04601f92012-02-05 15:36:07 -08002391 .src_clk_rate = 24000000,
2392};
2393
Kenneth Heitke748593a2011-07-15 15:45:11 -06002394static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
2395 .clk_freq = 100000,
2396 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002397};
2398
Joel King8f839b92012-04-01 14:37:46 -07002399static struct msm_i2c_platform_data mpq8064_i2c_qup_gsbi5_pdata = {
2400 .clk_freq = 100000,
2401 .src_clk_rate = 24000000,
2402};
2403
David Keitel3c40fc52012-02-09 17:53:52 -08002404#define GSBI_DUAL_MODE_CODE 0x60
2405#define MSM_GSBI1_PHYS 0x12440000
Kenneth Heitke748593a2011-07-15 15:45:11 -06002406static void __init apq8064_i2c_init(void)
2407{
David Keitel3c40fc52012-02-09 17:53:52 -08002408 void __iomem *gsbi_mem;
2409
2410 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2411 &apq8064_i2c_qup_gsbi1_pdata;
2412 gsbi_mem = ioremap_nocache(MSM_GSBI1_PHYS, 4);
2413 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
2414 /* Ensure protocol code is written before proceeding */
2415 wmb();
2416 iounmap(gsbi_mem);
2417 apq8064_i2c_qup_gsbi1_pdata.use_gsbi_shared_mode = 1;
Jing Lin04601f92012-02-05 15:36:07 -08002418 apq8064_device_qup_i2c_gsbi3.dev.platform_data =
2419 &apq8064_i2c_qup_gsbi3_pdata;
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002420 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2421 &apq8064_i2c_qup_gsbi1_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002422 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
2423 &apq8064_i2c_qup_gsbi4_pdata;
Joel King8f839b92012-04-01 14:37:46 -07002424 mpq8064_device_qup_i2c_gsbi5.dev.platform_data =
2425 &mpq8064_i2c_qup_gsbi5_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002426}
2427
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002428#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002429static int ethernet_init(void)
2430{
2431 int ret;
2432 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
2433 if (ret) {
2434 pr_err("ks8851 gpio_request failed: %d\n", ret);
2435 goto fail;
2436 }
2437
2438 return 0;
2439fail:
2440 return ret;
2441}
2442#else
2443static int ethernet_init(void)
2444{
2445 return 0;
2446}
2447#endif
2448
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302449#define GPIO_KEY_HOME PM8921_GPIO_PM_TO_SYS(27)
2450#define GPIO_KEY_VOLUME_UP PM8921_GPIO_PM_TO_SYS(35)
2451#define GPIO_KEY_VOLUME_DOWN PM8921_GPIO_PM_TO_SYS(38)
2452#define GPIO_KEY_CAM_FOCUS PM8921_GPIO_PM_TO_SYS(3)
2453#define GPIO_KEY_CAM_SNAP PM8921_GPIO_PM_TO_SYS(4)
Jing Lin3f8f8422012-03-05 09:32:11 -08002454#define GPIO_KEY_ROTATION PM8921_GPIO_PM_TO_SYS(42)
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302455
2456static struct gpio_keys_button cdp_keys[] = {
2457 {
2458 .code = KEY_HOME,
2459 .gpio = GPIO_KEY_HOME,
2460 .desc = "home_key",
2461 .active_low = 1,
2462 .type = EV_KEY,
2463 .wakeup = 1,
2464 .debounce_interval = 15,
2465 },
2466 {
2467 .code = KEY_VOLUMEUP,
2468 .gpio = GPIO_KEY_VOLUME_UP,
2469 .desc = "volume_up_key",
2470 .active_low = 1,
2471 .type = EV_KEY,
2472 .wakeup = 1,
2473 .debounce_interval = 15,
2474 },
2475 {
2476 .code = KEY_VOLUMEDOWN,
2477 .gpio = GPIO_KEY_VOLUME_DOWN,
2478 .desc = "volume_down_key",
2479 .active_low = 1,
2480 .type = EV_KEY,
2481 .wakeup = 1,
2482 .debounce_interval = 15,
2483 },
2484 {
2485 .code = SW_ROTATE_LOCK,
2486 .gpio = GPIO_KEY_ROTATION,
2487 .desc = "rotate_key",
2488 .active_low = 1,
2489 .type = EV_SW,
2490 .debounce_interval = 15,
2491 },
2492};
2493
2494static struct gpio_keys_platform_data cdp_keys_data = {
2495 .buttons = cdp_keys,
2496 .nbuttons = ARRAY_SIZE(cdp_keys),
2497};
2498
2499static struct platform_device cdp_kp_pdev = {
2500 .name = "gpio-keys",
2501 .id = -1,
2502 .dev = {
2503 .platform_data = &cdp_keys_data,
2504 },
2505};
2506
2507static struct gpio_keys_button mtp_keys[] = {
2508 {
2509 .code = KEY_CAMERA_FOCUS,
2510 .gpio = GPIO_KEY_CAM_FOCUS,
2511 .desc = "cam_focus_key",
2512 .active_low = 1,
2513 .type = EV_KEY,
2514 .wakeup = 1,
2515 .debounce_interval = 15,
2516 },
2517 {
2518 .code = KEY_VOLUMEUP,
2519 .gpio = GPIO_KEY_VOLUME_UP,
2520 .desc = "volume_up_key",
2521 .active_low = 1,
2522 .type = EV_KEY,
2523 .wakeup = 1,
2524 .debounce_interval = 15,
2525 },
2526 {
2527 .code = KEY_VOLUMEDOWN,
2528 .gpio = GPIO_KEY_VOLUME_DOWN,
2529 .desc = "volume_down_key",
2530 .active_low = 1,
2531 .type = EV_KEY,
2532 .wakeup = 1,
2533 .debounce_interval = 15,
2534 },
2535 {
2536 .code = KEY_CAMERA_SNAPSHOT,
2537 .gpio = GPIO_KEY_CAM_SNAP,
2538 .desc = "cam_snap_key",
2539 .active_low = 1,
2540 .type = EV_KEY,
2541 .debounce_interval = 15,
2542 },
2543};
2544
2545static struct gpio_keys_platform_data mtp_keys_data = {
2546 .buttons = mtp_keys,
2547 .nbuttons = ARRAY_SIZE(mtp_keys),
2548};
2549
2550static struct platform_device mtp_kp_pdev = {
2551 .name = "gpio-keys",
2552 .id = -1,
2553 .dev = {
2554 .platform_data = &mtp_keys_data,
2555 },
2556};
2557
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302558static struct gpio_keys_button mpq_keys[] = {
2559 {
2560 .code = KEY_VOLUMEDOWN,
2561 .gpio = GPIO_KEY_VOLUME_DOWN,
2562 .desc = "volume_down_key",
2563 .active_low = 1,
2564 .type = EV_KEY,
2565 .wakeup = 1,
2566 .debounce_interval = 15,
2567 },
2568 {
2569 .code = KEY_VOLUMEUP,
2570 .gpio = GPIO_KEY_VOLUME_UP,
2571 .desc = "volume_up_key",
2572 .active_low = 1,
2573 .type = EV_KEY,
2574 .wakeup = 1,
2575 .debounce_interval = 15,
2576 },
2577};
2578
2579static struct gpio_keys_platform_data mpq_keys_data = {
2580 .buttons = mpq_keys,
2581 .nbuttons = ARRAY_SIZE(mpq_keys),
2582};
2583
2584static struct platform_device mpq_gpio_keys_pdev = {
2585 .name = "gpio-keys",
2586 .id = -1,
2587 .dev = {
2588 .platform_data = &mpq_keys_data,
2589 },
2590};
2591
2592#define MPQ_KP_ROW_BASE SX150X_EXP2_GPIO_BASE
2593#define MPQ_KP_COL_BASE (SX150X_EXP2_GPIO_BASE + 4)
2594
2595static unsigned int mpq_row_gpios[] = {MPQ_KP_ROW_BASE, MPQ_KP_ROW_BASE + 1,
2596 MPQ_KP_ROW_BASE + 2, MPQ_KP_ROW_BASE + 3};
2597static unsigned int mpq_col_gpios[] = {MPQ_KP_COL_BASE, MPQ_KP_COL_BASE + 1,
2598 MPQ_KP_COL_BASE + 2};
2599
2600static const unsigned int mpq_keymap[] = {
2601 KEY(0, 0, KEY_UP),
2602 KEY(0, 1, KEY_ENTER),
2603 KEY(0, 2, KEY_3),
2604
2605 KEY(1, 0, KEY_DOWN),
2606 KEY(1, 1, KEY_EXIT),
2607 KEY(1, 2, KEY_4),
2608
2609 KEY(2, 0, KEY_LEFT),
2610 KEY(2, 1, KEY_1),
2611 KEY(2, 2, KEY_5),
2612
2613 KEY(3, 0, KEY_RIGHT),
2614 KEY(3, 1, KEY_2),
2615 KEY(3, 2, KEY_6),
2616};
2617
2618static struct matrix_keymap_data mpq_keymap_data = {
2619 .keymap_size = ARRAY_SIZE(mpq_keymap),
2620 .keymap = mpq_keymap,
2621};
2622
2623static struct matrix_keypad_platform_data mpq_keypad_data = {
2624 .keymap_data = &mpq_keymap_data,
2625 .row_gpios = mpq_row_gpios,
2626 .col_gpios = mpq_col_gpios,
2627 .num_row_gpios = ARRAY_SIZE(mpq_row_gpios),
2628 .num_col_gpios = ARRAY_SIZE(mpq_col_gpios),
2629 .col_scan_delay_us = 32000,
2630 .debounce_ms = 20,
2631 .wakeup = 1,
2632 .active_low = 1,
2633 .no_autorepeat = 1,
2634};
2635
2636static struct platform_device mpq_keypad_device = {
2637 .name = "matrix-keypad",
2638 .id = -1,
2639 .dev = {
2640 .platform_data = &mpq_keypad_data,
2641 },
2642};
2643
Jin Hongd3024e62012-02-09 16:13:32 -08002644/* Sensors DSPS platform data */
2645#define DSPS_PIL_GENERIC_NAME "dsps"
2646static void __init apq8064_init_dsps(void)
2647{
2648 struct msm_dsps_platform_data *pdata =
2649 msm_dsps_device_8064.dev.platform_data;
2650 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2651 pdata->gpios = NULL;
2652 pdata->gpios_num = 0;
2653
2654 platform_device_register(&msm_dsps_device_8064);
2655}
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302656
Jing Lin417fa452012-02-05 14:31:06 -08002657#define I2C_SURF 1
2658#define I2C_FFA (1 << 1)
2659#define I2C_RUMI (1 << 2)
2660#define I2C_SIM (1 << 3)
2661#define I2C_LIQUID (1 << 4)
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002662#define I2C_MPQ_CDP BIT(5)
2663#define I2C_MPQ_HRD BIT(6)
2664#define I2C_MPQ_DTV BIT(7)
Jing Lin417fa452012-02-05 14:31:06 -08002665
2666struct i2c_registry {
2667 u8 machs;
2668 int bus;
2669 struct i2c_board_info *info;
2670 int len;
2671};
2672
2673static struct i2c_registry apq8064_i2c_devices[] __initdata = {
Jing Lin21ed4de2012-02-05 15:53:28 -08002674 {
David Keitel2f613d92012-02-15 11:29:16 -08002675 I2C_LIQUID,
2676 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2677 smb349_charger_i2c_info,
2678 ARRAY_SIZE(smb349_charger_i2c_info)
2679 },
2680 {
Jing Lin21ed4de2012-02-05 15:53:28 -08002681 I2C_SURF | I2C_LIQUID,
2682 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2683 mxt_device_info,
2684 ARRAY_SIZE(mxt_device_info),
2685 },
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08002686 {
2687 I2C_FFA,
2688 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
2689 cyttsp_info,
2690 ARRAY_SIZE(cyttsp_info),
2691 },
Amy Maloche70090f992012-02-16 16:35:26 -08002692 {
2693 I2C_FFA | I2C_LIQUID,
2694 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2695 isa1200_board_info,
2696 ARRAY_SIZE(isa1200_board_info),
2697 },
Santosh Mardieff9a742012-04-09 23:23:39 +05302698 {
2699 I2C_MPQ_CDP,
2700 APQ_8064_GSBI5_QUP_I2C_BUS_ID,
2701 cs8427_device_info,
2702 ARRAY_SIZE(cs8427_device_info),
2703 },
Jing Lin417fa452012-02-05 14:31:06 -08002704};
2705
Jay Chokshi607f61b2012-04-25 18:21:21 -07002706#define SX150X_EXP1_INT_N PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9)
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302707#define SX150X_EXP2_INT_N MSM_GPIO_TO_INT(81)
Jay Chokshi607f61b2012-04-25 18:21:21 -07002708
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002709struct sx150x_platform_data mpq8064_sx150x_pdata[] = {
2710 [SX150X_EXP1] = {
2711 .gpio_base = SX150X_EXP1_GPIO_BASE,
2712 .oscio_is_gpo = false,
2713 .io_pullup_ena = 0x0,
2714 .io_pulldn_ena = 0x0,
2715 .io_open_drain_ena = 0x0,
2716 .io_polarity = 0,
Jay Chokshi607f61b2012-04-25 18:21:21 -07002717 .irq_summary = SX150X_EXP1_INT_N,
2718 .irq_base = SX150X_EXP1_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002719 },
2720 [SX150X_EXP2] = {
2721 .gpio_base = SX150X_EXP2_GPIO_BASE,
2722 .oscio_is_gpo = false,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302723 .io_pullup_ena = 0x0f,
2724 .io_pulldn_ena = 0x70,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002725 .io_open_drain_ena = 0x0,
2726 .io_polarity = 0,
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05302727 .irq_summary = SX150X_EXP2_INT_N,
2728 .irq_base = SX150X_EXP2_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002729 },
2730 [SX150X_EXP3] = {
2731 .gpio_base = SX150X_EXP3_GPIO_BASE,
2732 .oscio_is_gpo = false,
2733 .io_pullup_ena = 0x0,
2734 .io_pulldn_ena = 0x0,
2735 .io_open_drain_ena = 0x0,
2736 .io_polarity = 0,
2737 .irq_summary = -1,
2738 },
2739 [SX150X_EXP4] = {
2740 .gpio_base = SX150X_EXP4_GPIO_BASE,
2741 .oscio_is_gpo = false,
2742 .io_pullup_ena = 0x0,
2743 .io_pulldn_ena = 0x0,
2744 .io_open_drain_ena = 0x0,
2745 .io_polarity = 0,
2746 .irq_summary = -1,
2747 },
2748};
2749
2750static struct i2c_board_info sx150x_gpio_exp_info[] = {
2751 {
2752 I2C_BOARD_INFO("sx1509q", 0x70),
2753 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP1],
2754 },
2755 {
2756 I2C_BOARD_INFO("sx1508q", 0x23),
2757 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP2],
2758 },
2759 {
2760 I2C_BOARD_INFO("sx1508q", 0x22),
2761 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP3],
2762 },
2763 {
2764 I2C_BOARD_INFO("sx1509q", 0x3E),
2765 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP4],
2766 },
2767};
2768
2769#define MPQ8064_I2C_GSBI5_BUS_ID 5
2770
2771static struct i2c_registry mpq8064_i2c_devices[] __initdata = {
2772 {
2773 I2C_MPQ_CDP,
2774 MPQ8064_I2C_GSBI5_BUS_ID,
2775 sx150x_gpio_exp_info,
2776 ARRAY_SIZE(sx150x_gpio_exp_info),
2777 },
2778};
2779
Jing Lin417fa452012-02-05 14:31:06 -08002780static void __init register_i2c_devices(void)
2781{
2782 u8 mach_mask = 0;
2783 int i;
2784
Kevin Chand07220e2012-02-13 15:52:22 -08002785#ifdef CONFIG_MSM_CAMERA
2786 struct i2c_registry apq8064_camera_i2c_devices = {
2787 I2C_SURF | I2C_FFA | I2C_LIQUID | I2C_RUMI,
2788 APQ_8064_GSBI4_QUP_I2C_BUS_ID,
2789 apq8064_camera_board_info.board_info,
2790 apq8064_camera_board_info.num_i2c_board_info,
2791 };
2792#endif
Jing Lin417fa452012-02-05 14:31:06 -08002793 /* Build the matching 'supported_machs' bitmask */
2794 if (machine_is_apq8064_cdp())
2795 mach_mask = I2C_SURF;
2796 else if (machine_is_apq8064_mtp())
2797 mach_mask = I2C_FFA;
2798 else if (machine_is_apq8064_liquid())
2799 mach_mask = I2C_LIQUID;
2800 else if (machine_is_apq8064_rumi3())
2801 mach_mask = I2C_RUMI;
2802 else if (machine_is_apq8064_sim())
2803 mach_mask = I2C_SIM;
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002804 else if (PLATFORM_IS_MPQ8064())
2805 mach_mask = I2C_MPQ_CDP;
Jing Lin417fa452012-02-05 14:31:06 -08002806 else
2807 pr_err("unmatched machine ID in register_i2c_devices\n");
2808
2809 /* Run the array and install devices as appropriate */
2810 for (i = 0; i < ARRAY_SIZE(apq8064_i2c_devices); ++i) {
2811 if (apq8064_i2c_devices[i].machs & mach_mask)
2812 i2c_register_board_info(apq8064_i2c_devices[i].bus,
2813 apq8064_i2c_devices[i].info,
2814 apq8064_i2c_devices[i].len);
2815 }
Kevin Chand07220e2012-02-13 15:52:22 -08002816#ifdef CONFIG_MSM_CAMERA
2817 if (apq8064_camera_i2c_devices.machs & mach_mask)
2818 i2c_register_board_info(apq8064_camera_i2c_devices.bus,
2819 apq8064_camera_i2c_devices.info,
2820 apq8064_camera_i2c_devices.len);
2821#endif
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002822
2823 for (i = 0; i < ARRAY_SIZE(mpq8064_i2c_devices); ++i) {
2824 if (mpq8064_i2c_devices[i].machs & mach_mask)
2825 i2c_register_board_info(
2826 mpq8064_i2c_devices[i].bus,
2827 mpq8064_i2c_devices[i].info,
2828 mpq8064_i2c_devices[i].len);
2829 }
Jing Lin417fa452012-02-05 14:31:06 -08002830}
2831
Jay Chokshi994ff122012-03-27 15:43:48 -07002832static void enable_ddr3_regulator(void)
2833{
2834 static struct regulator *ext_ddr3;
2835
2836 /* Use MPP7 output state as a flag for PCDDR3 presence. */
2837 if (gpio_get_value_cansleep(PM8921_MPP_PM_TO_SYS(7)) > 0) {
2838 ext_ddr3 = regulator_get(NULL, "ext_ddr3");
2839 if (IS_ERR(ext_ddr3) || ext_ddr3 == NULL)
2840 pr_err("Could not get MPP7 regulator\n");
2841 else
2842 regulator_enable(ext_ddr3);
2843 }
2844}
2845
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002846static void enable_avc_i2c_bus(void)
2847{
2848 int avc_i2c_en_mpp = PM8921_MPP_PM_TO_SYS(8);
2849 int rc;
2850
2851 rc = gpio_request(avc_i2c_en_mpp, "avc_i2c_en");
2852 if (rc)
2853 pr_err("request for avc_i2c_en mpp failed,"
2854 "rc=%d\n", rc);
2855 else
2856 gpio_set_value_cansleep(avc_i2c_en_mpp, 1);
2857}
2858
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002859static void __init apq8064_common_init(void)
2860{
Joel King8f839b92012-04-01 14:37:46 -07002861 msm_tsens_early_init(&apq_tsens_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002862 if (socinfo_init() < 0)
2863 pr_err("socinfo_init() failed!\n");
Praveen Chidambaram78499012011-11-01 17:15:17 -06002864 BUG_ON(msm_rpm_init(&apq8064_rpm_data));
2865 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
David Collins2782b5c2012-02-06 10:02:42 -08002866 regulator_suppress_info_printing();
2867 platform_device_register(&apq8064_device_rpm_regulator);
Stephen Boyd4d0d2582012-02-10 14:49:40 -08002868 if (msm_xo_init())
2869 pr_err("Failed to initialize XO votes\n");
Matt Wagantallc51e5602012-02-27 17:25:25 -08002870 msm_clock_init(&apq8064_clock_init_data);
Stepan Moskovchenko2327a952011-12-14 16:31:28 -08002871 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -06002872 apq8064_i2c_init();
Jing Lin417fa452012-02-05 14:31:06 -08002873 register_i2c_devices();
Kenneth Heitke36920d32011-07-20 16:44:30 -06002874
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002875 apq8064_device_qup_spi_gsbi5.dev.platform_data =
2876 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -08002877 apq8064_init_pmic();
Hemant Kumar94e7da22012-02-03 16:52:29 -08002878 if (machine_is_apq8064_liquid())
2879 msm_otg_pdata.mhl_enable = true;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07002880
Ofir Cohen94213a72012-05-03 14:26:32 +03002881 android_usb_pdata.swfi_latency =
2882 msm_rpmrs_levels[0].latency_us;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07002883
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002884 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Manu Gautam91223e02011-11-08 15:27:22 +05302885 apq8064_ehci_host_init();
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002886 apq8064_init_buses();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Terence Hampson36b70722012-05-10 13:18:16 -04002888 if (!(machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
2889 machine_is_mpq8064_dtv()))
2890 platform_add_devices(common_not_mpq_devices,
2891 ARRAY_SIZE(common_not_mpq_devices));
Jay Chokshi994ff122012-03-27 15:43:48 -07002892 enable_ddr3_regulator();
Hemant Kumarf1ca9192012-02-07 18:59:33 -08002893 if (machine_is_apq8064_mtp()) {
2894 apq8064_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
2895 device_initialize(&apq8064_device_hsic_host.dev);
2896 }
Jay Chokshie8741282012-01-25 15:22:55 -08002897 apq8064_pm8xxx_gpio_mpp_init();
Sahitya Tummala3586ed92011-08-03 09:13:23 +05302898 apq8064_init_mmc();
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08002899
2900 if (machine_is_apq8064_mtp()) {
2901 mdm_8064_device.dev.platform_data = &mdm_platform_data;
2902 platform_device_register(&mdm_8064_device);
2903 }
2904 platform_device_register(&apq8064_slim_ctrl);
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002905 slim_register_board_info(apq8064_slim_devices,
2906 ARRAY_SIZE(apq8064_slim_devices));
Jin Hongd3024e62012-02-09 16:13:32 -08002907 apq8064_init_dsps();
Praveen Chidambaram78499012011-11-01 17:15:17 -06002908 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
Mahesh Sivasubramaniancbce1ec2012-01-24 10:32:44 -07002909 acpuclk_init(&acpuclk_8064_soc_data);
Praveen Chidambaram78499012011-11-01 17:15:17 -06002910 msm_spm_l2_init(msm_spm_l2_data);
Praveen Chidambaram78499012011-11-01 17:15:17 -06002911 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Praveen Chidambaram4d19be42012-04-03 18:05:52 -06002912 msm_pm_init_sleep_status_data(&msm_pm_slp_sts_data);
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002913 apq8064_epm_adc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002914}
2915
Huaibin Yang4a084e32011-12-15 15:25:52 -08002916static void __init apq8064_allocate_memory_regions(void)
2917{
2918 apq8064_allocate_fb_region();
2919}
2920
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002921static void __init apq8064_sim_init(void)
2922{
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002923 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
2924 &msm8064_device_watchdog.dev.platform_data;
2925
2926 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002927 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -07002928 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
2929}
2930
2931static void __init apq8064_rumi3_init(void)
2932{
2933 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002934 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -07002935 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002936 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002937}
2938
Joel King82b7e3f2012-01-05 10:03:27 -08002939static void __init apq8064_cdp_init(void)
2940{
Hanumant Singh50440d42012-04-23 19:27:16 -07002941 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
2942 pr_err("meminfo_init() failed!\n");
Joel King82b7e3f2012-01-05 10:03:27 -08002943 apq8064_common_init();
Joel King8f839b92012-04-01 14:37:46 -07002944 if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
2945 machine_is_mpq8064_dtv()) {
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002946 enable_avc_i2c_bus();
Joel King8f839b92012-04-01 14:37:46 -07002947 platform_add_devices(mpq_devices, ARRAY_SIZE(mpq_devices));
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002948 mpq8064_pcie_init();
Joel King8f839b92012-04-01 14:37:46 -07002949 } else {
2950 ethernet_init();
2951 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
2952 spi_register_board_info(spi_board_info,
2953 ARRAY_SIZE(spi_board_info));
2954 }
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08002955 apq8064_init_fb();
Jordan Crouseb3115fe2012-02-01 22:11:12 -07002956 apq8064_init_gpu();
Matt Wagantall1f65d9d2012-04-25 14:24:20 -07002957 platform_add_devices(apq8064_footswitch, apq8064_num_footswitch);
Kevin Chand07220e2012-02-13 15:52:22 -08002958 apq8064_init_cam();
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302959
2960 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid())
2961 platform_device_register(&cdp_kp_pdev);
2962
2963 if (machine_is_apq8064_mtp())
2964 platform_device_register(&mtp_kp_pdev);
Hanumant Singh50440d42012-04-23 19:27:16 -07002965
2966 change_memory_power = &apq8064_change_memory_power;
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302967
2968 if (machine_is_mpq8064_cdp()) {
2969 platform_device_register(&mpq_gpio_keys_pdev);
2970 platform_device_register(&mpq_keypad_device);
2971 }
Joel King82b7e3f2012-01-05 10:03:27 -08002972}
2973
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002974MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
2975 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -07002976 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002977 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302978 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979 .timer = &msm_timer,
2980 .init_machine = apq8064_sim_init,
2981MACHINE_END
2982
Joel King4e7ad222011-08-17 15:47:38 -07002983MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
2984 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -07002985 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -07002986 .init_irq = apq8064_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +05302987 .handle_irq = gic_handle_irq,
Joel King4e7ad222011-08-17 15:47:38 -07002988 .timer = &msm_timer,
2989 .init_machine = apq8064_rumi3_init,
Huaibin Yang4a084e32011-12-15 15:25:52 -08002990 .init_early = apq8064_allocate_memory_regions,
Joel King4e7ad222011-08-17 15:47:38 -07002991MACHINE_END
2992
Joel King82b7e3f2012-01-05 10:03:27 -08002993MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
2994 .map_io = apq8064_map_io,
2995 .reserve = apq8064_reserve,
2996 .init_irq = apq8064_init_irq,
2997 .handle_irq = gic_handle_irq,
2998 .timer = &msm_timer,
2999 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003000 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003001 .init_very_early = apq8064_early_reserve,
Joel King82b7e3f2012-01-05 10:03:27 -08003002MACHINE_END
3003
3004MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
3005 .map_io = apq8064_map_io,
3006 .reserve = apq8064_reserve,
3007 .init_irq = apq8064_init_irq,
3008 .handle_irq = gic_handle_irq,
3009 .timer = &msm_timer,
3010 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003011 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003012 .init_very_early = apq8064_early_reserve,
Joel King82b7e3f2012-01-05 10:03:27 -08003013MACHINE_END
3014
3015MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
3016 .map_io = apq8064_map_io,
3017 .reserve = apq8064_reserve,
3018 .init_irq = apq8064_init_irq,
3019 .handle_irq = gic_handle_irq,
3020 .timer = &msm_timer,
3021 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003022 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003023 .init_very_early = apq8064_early_reserve,
Joel King82b7e3f2012-01-05 10:03:27 -08003024MACHINE_END
3025
Joel King064bbf82012-04-01 13:23:39 -07003026MACHINE_START(MPQ8064_CDP, "QCT MPQ8064 CDP")
3027 .map_io = apq8064_map_io,
3028 .reserve = apq8064_reserve,
3029 .init_irq = apq8064_init_irq,
3030 .handle_irq = gic_handle_irq,
3031 .timer = &msm_timer,
3032 .init_machine = apq8064_cdp_init,
3033 .init_early = apq8064_allocate_memory_regions,
3034 .init_very_early = apq8064_early_reserve,
3035MACHINE_END
3036
Joel King11ca8202012-02-13 16:19:03 -08003037MACHINE_START(MPQ8064_HRD, "QCT MPQ8064 HRD")
3038 .map_io = apq8064_map_io,
3039 .reserve = apq8064_reserve,
3040 .init_irq = apq8064_init_irq,
3041 .handle_irq = gic_handle_irq,
3042 .timer = &msm_timer,
3043 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003044 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003045 .init_very_early = apq8064_early_reserve,
Joel King11ca8202012-02-13 16:19:03 -08003046MACHINE_END
3047
3048MACHINE_START(MPQ8064_DTV, "QCT MPQ8064 DTV")
3049 .map_io = apq8064_map_io,
3050 .reserve = apq8064_reserve,
3051 .init_irq = apq8064_init_irq,
3052 .handle_irq = gic_handle_irq,
3053 .timer = &msm_timer,
3054 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003055 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003056 .init_very_early = apq8064_early_reserve,
Joel King11ca8202012-02-13 16:19:03 -08003057MACHINE_END
3058