blob: 3eb8458d9bb2c2d95d523b9e9e826f17331ee23f [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>
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -060014#include <linux/bitops.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/platform_device.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070016#include <linux/gpio.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/io.h>
18#include <linux/irq.h>
Kenneth Heitke748593a2011-07-15 15:45:11 -060019#include <linux/i2c.h>
David Keitel2f613d92012-02-15 11:29:16 -080020#include <linux/i2c/smb349.h>
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -080021#include <linux/i2c/sx150x.h>
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -060022#include <linux/slimbus/slimbus.h>
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053023#include <linux/mfd/wcd9xxx/core.h>
24#include <linux/mfd/wcd9xxx/pdata.h>
Amy Maloche70090f992012-02-16 16:35:26 -080025#include <linux/mfd/pm8xxx/misc.h>
Kenneth Heitke36920d32011-07-20 16:44:30 -060026#include <linux/msm_ssbi.h>
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -070027#include <linux/spi/spi.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070028#include <linux/dma-mapping.h>
29#include <linux/platform_data/qcom_crypto_device.h>
Mitchel Humpherysca983d82012-09-06 11:32:54 -070030#include <linux/msm_ion.h>
Jack Cheung46bfffa2012-01-19 15:26:24 -080031#include <linux/memory.h>
Larry Bassel67b921d2012-04-06 10:23:27 -070032#include <linux/memblock.h>
Praveen Chidambaram877d7a42012-06-05 14:33:20 -060033#include <linux/msm_thermal.h>
Jing Lin21ed4de2012-02-05 15:53:28 -080034#include <linux/i2c/atmel_mxt_ts.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070035#include <linux/cyttsp-qc.h>
Amy Maloche70090f992012-02-16 16:35:26 -080036#include <linux/i2c/isa1200.h>
Mohan Pallaka474b94b2012-01-25 12:59:58 +053037#include <linux/gpio_keys.h>
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -080038#include <linux/epm_adc.h>
Jay Chokshie7d8d4f2012-04-04 14:47:57 -070039#include <linux/i2c/sx150x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040#include <asm/mach-types.h>
41#include <asm/mach/arch.h>
42#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053043#include <asm/mach/mmc.h>
Ankit Verma6b7e2ba2012-01-26 15:48:54 -080044#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045
46#include <mach/board.h>
47#include <mach/msm_iomap.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080048#include <mach/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049#include <linux/usb/msm_hsusb.h>
50#include <linux/usb/android.h>
51#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060052#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053#include "timer.h"
54#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070055#include <mach/gpiomux.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060056#include <mach/rpm.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080057#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -070058#include <linux/android_pmem.h>
Olav Haugan7c6aa742012-01-16 16:47:37 -080059#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070060#include <mach/msm_memtypes.h>
61#include <linux/bootmem.h>
62#include <asm/setup.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070063#include <mach/dma.h>
Jin Hongd3024e62012-02-09 16:13:32 -080064#include <mach/msm_dsps.h>
Gagan Mac8a7a5d32011-11-11 16:43:06 -070065#include <mach/msm_bus_board.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060066#include <mach/cpuidle.h>
Joel Kingdacbc822012-01-25 13:30:57 -080067#include <mach/mdm2.h>
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -080068#include <linux/msm_tsens.h>
Stephen Boyd4d0d2582012-02-10 14:49:40 -080069#include <mach/msm_xo.h>
Laura Abbott350c8362012-02-28 14:46:52 -080070#include <mach/msm_rtb.h>
Mayank Rana262e9032012-05-10 15:14:00 -070071#include <mach/msm_serial_hs.h>
Santosh Mardieff9a742012-04-09 23:23:39 +053072#include <sound/cs8427.h>
Ravi Kumar V05931a22012-04-04 17:09:37 +053073#include <media/gpio-ir-recv.h>
Larry Bassel67b921d2012-04-06 10:23:27 -070074#include <linux/fmem.h>
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -060075#include <mach/msm_pcie.h>
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070076#include <mach/restart.h>
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -060077#include <mach/msm_iomap.h>
Joel King4ebccc62011-07-22 09:43:22 -070078
Jeff Ohlstein7e668552011-10-06 16:17:25 -070079#include "msm_watchdog.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080080#include "board-8064.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060081#include "spm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053082#include <mach/mpm.h>
Praveen Chidambaram78499012011-11-01 17:15:17 -060083#include "rpm_resources.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080084#include "pm.h"
Praveen Chidambaram78499012011-11-01 17:15:17 -060085#include "pm-boot.h"
Rajesh Sastrulaaee8af32012-01-20 11:46:31 -080086#include "devices-msm8x60.h"
Hanumant Singh50440d42012-04-23 19:27:16 -070087#include "smd_private.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070088
Abhishek Kharbanda72dc72e2012-06-07 13:41:37 -070089#define MHL_GPIO_INT 30
90#define MHL_GPIO_RESET 35
91
Olav Haugan7c6aa742012-01-16 16:47:37 -080092#define MSM_PMEM_ADSP_SIZE 0x7800000
Bharath Ramachandramurthy2fd017a2012-03-13 10:21:09 -070093#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Olav Haugan7c6aa742012-01-16 16:47:37 -080094#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
95#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
96#else
Chetan Kalyan72aac4f2012-02-23 14:56:54 -080097#define MSM_PMEM_SIZE 0x4000000 /* 64 Mbytes */
Olav Haugan7c6aa742012-01-16 16:47:37 -080098#endif
Kevin Chan13be4e22011-10-20 11:30:32 -070099
Olav Haugan7c6aa742012-01-16 16:47:37 -0800100#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Hanumant Singheadb7502012-05-15 18:14:04 -0700101#define HOLE_SIZE 0x20000
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700102#define MSM_CONTIG_MEM_SIZE 0x65000
Olav Haugan129992c2012-03-22 09:54:01 -0700103#ifdef CONFIG_MSM_IOMMU
104#define MSM_ION_MM_SIZE 0x3800000
105#define MSM_ION_SF_SIZE 0
Olav Haugan39477bb2012-05-14 16:05:36 -0700106#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700107#define MSM_ION_HEAP_NUM 7
108#else
Olav Haugan7c6aa742012-01-16 16:47:37 -0800109#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan129992c2012-03-22 09:54:01 -0700110#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
Olav Haugan39477bb2012-05-14 16:05:36 -0700111#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Olav Haugan129992c2012-03-22 09:54:01 -0700112#define MSM_ION_HEAP_NUM 8
113#endif
Hanumant Singheadb7502012-05-15 18:14:04 -0700114#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* (2MB - 128KB) */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800115#define MSM_ION_MFC_SIZE SZ_8K
Olav Haugan2c43fac2012-01-19 11:06:37 -0800116#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan7c6aa742012-01-16 16:47:37 -0800117#else
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700118#define MSM_CONTIG_MEM_SIZE 0x110C000
Olav Haugan7c6aa742012-01-16 16:47:37 -0800119#define MSM_ION_HEAP_NUM 1
120#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700121
Hanumant Singheadb7502012-05-15 18:14:04 -0700122#define APQ8064_FIXED_AREA_START (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
123 HOLE_SIZE))
Larry Bassel67b921d2012-04-06 10:23:27 -0700124#define MAX_FIXED_AREA_SIZE 0x10000000
Hanumant Singheadb7502012-05-15 18:14:04 -0700125#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE)
126#define APQ8064_FW_START APQ8064_FIXED_AREA_START
Larry Bassel67b921d2012-04-06 10:23:27 -0700127
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -0600128#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB (MSM_QFPROM_BASE + 0x23c)
129#define QFPROM_RAW_OEM_CONFIG_ROW0_LSB (MSM_QFPROM_BASE + 0x220)
130
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -0600131/* PCIE AXI address space */
132#define PCIE_AXI_BAR_PHYS 0x08000000
133#define PCIE_AXI_BAR_SIZE SZ_128M
134
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -0600135/* PCIe pmic gpios */
136#define PCIE_WAKE_N_PMIC_GPIO 12
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600137#define PCIE_PWR_EN_PMIC_GPIO 13
138#define PCIE_RST_N_PMIC_MPP 1
139
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700140#ifdef CONFIG_KERNEL_MSM_CONTIG_MEM_REGION
141static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
142static int __init msm_contig_mem_size_setup(char *p)
Kevin Chan13be4e22011-10-20 11:30:32 -0700143{
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700144 msm_contig_mem_size = memparse(p, NULL);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800145 return 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700146}
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700147early_param("msm_contig_mem_size", msm_contig_mem_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800148#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700149
Olav Haugan7c6aa742012-01-16 16:47:37 -0800150#ifdef CONFIG_ANDROID_PMEM
Kevin Chan13be4e22011-10-20 11:30:32 -0700151static unsigned pmem_size = MSM_PMEM_SIZE;
152static int __init pmem_size_setup(char *p)
153{
154 pmem_size = memparse(p, NULL);
155 return 0;
156}
157early_param("pmem_size", pmem_size_setup);
158
159static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
160
161static int __init pmem_adsp_size_setup(char *p)
162{
163 pmem_adsp_size = memparse(p, NULL);
164 return 0;
165}
166early_param("pmem_adsp_size", pmem_adsp_size_setup);
167
168static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
169
170static int __init pmem_audio_size_setup(char *p)
171{
172 pmem_audio_size = memparse(p, NULL);
173 return 0;
174}
175early_param("pmem_audio_size", pmem_audio_size_setup);
Olav Haugan7c6aa742012-01-16 16:47:37 -0800176#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700177
Olav Haugan7c6aa742012-01-16 16:47:37 -0800178#ifdef CONFIG_ANDROID_PMEM
179#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700180static struct android_pmem_platform_data android_pmem_pdata = {
181 .name = "pmem",
182 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
183 .cached = 1,
184 .memory_type = MEMTYPE_EBI1,
185};
186
Laura Abbottb93525f2012-04-12 09:57:19 -0700187static struct platform_device apq8064_android_pmem_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700188 .name = "android_pmem",
189 .id = 0,
190 .dev = {.platform_data = &android_pmem_pdata},
191};
192
193static struct android_pmem_platform_data android_pmem_adsp_pdata = {
194 .name = "pmem_adsp",
195 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
196 .cached = 0,
197 .memory_type = MEMTYPE_EBI1,
198};
Laura Abbottb93525f2012-04-12 09:57:19 -0700199static struct platform_device apq8064_android_pmem_adsp_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700200 .name = "android_pmem",
201 .id = 2,
202 .dev = { .platform_data = &android_pmem_adsp_pdata },
203};
204
205static struct android_pmem_platform_data android_pmem_audio_pdata = {
206 .name = "pmem_audio",
207 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
208 .cached = 0,
209 .memory_type = MEMTYPE_EBI1,
210};
211
Laura Abbottb93525f2012-04-12 09:57:19 -0700212static struct platform_device apq8064_android_pmem_audio_device = {
Kevin Chan13be4e22011-10-20 11:30:32 -0700213 .name = "android_pmem",
214 .id = 4,
215 .dev = { .platform_data = &android_pmem_audio_pdata },
216};
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700217#endif /* CONFIG_MSM_MULTIMEDIA_USE_ION */
218#endif /* CONFIG_ANDROID_PMEM */
Olav Haugan7c6aa742012-01-16 16:47:37 -0800219
Binqiang Qiuf165c922012-08-15 18:00:18 -0700220#ifdef CONFIG_BATTERY_BCL
221static struct platform_device battery_bcl_device = {
222 .name = "battery_current_limit",
223 .id = -1,
224};
225#endif
226
Larry Bassel67b921d2012-04-06 10:23:27 -0700227struct fmem_platform_data apq8064_fmem_pdata = {
228};
229
Olav Haugan7c6aa742012-01-16 16:47:37 -0800230static struct memtype_reserve apq8064_reserve_table[] __initdata = {
231 [MEMTYPE_SMI] = {
232 },
233 [MEMTYPE_EBI0] = {
234 .flags = MEMTYPE_FLAGS_1M_ALIGN,
235 },
236 [MEMTYPE_EBI1] = {
237 .flags = MEMTYPE_FLAGS_1M_ALIGN,
238 },
239};
Kevin Chan13be4e22011-10-20 11:30:32 -0700240
Laura Abbott350c8362012-02-28 14:46:52 -0800241static void __init reserve_rtb_memory(void)
242{
243#if defined(CONFIG_MSM_RTB)
Laura Abbottb93525f2012-04-12 09:57:19 -0700244 apq8064_reserve_table[MEMTYPE_EBI1].size += apq8064_rtb_pdata.size;
Laura Abbott350c8362012-02-28 14:46:52 -0800245#endif
246}
247
248
Kevin Chan13be4e22011-10-20 11:30:32 -0700249static void __init size_pmem_devices(void)
250{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800251#ifdef CONFIG_ANDROID_PMEM
252#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700253 android_pmem_adsp_pdata.size = pmem_adsp_size;
254 android_pmem_pdata.size = pmem_size;
255 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700256#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
257#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700258}
259
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700260#ifdef CONFIG_ANDROID_PMEM
261#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700262static void __init reserve_memory_for(struct android_pmem_platform_data *p)
263{
264 apq8064_reserve_table[p->memory_type].size += p->size;
265}
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700266#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
267#endif /*CONFIG_ANDROID_PMEM*/
Kevin Chan13be4e22011-10-20 11:30:32 -0700268
Kevin Chan13be4e22011-10-20 11:30:32 -0700269static void __init reserve_pmem_memory(void)
270{
Olav Haugan7c6aa742012-01-16 16:47:37 -0800271#ifdef CONFIG_ANDROID_PMEM
272#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Kevin Chan13be4e22011-10-20 11:30:32 -0700273 reserve_memory_for(&android_pmem_adsp_pdata);
274 reserve_memory_for(&android_pmem_pdata);
275 reserve_memory_for(&android_pmem_audio_pdata);
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700276#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Mitchel Humpherys05e58812012-08-13 14:24:13 -0700277 apq8064_reserve_table[MEMTYPE_EBI1].size += msm_contig_mem_size;
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -0700278#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -0800279}
280
281static int apq8064_paddr_to_memtype(unsigned int paddr)
282{
283 return MEMTYPE_EBI1;
284}
285
Steve Mucklef132c6c2012-06-06 18:30:57 -0700286#define FMEM_ENABLED 0
Larry Bassel67b921d2012-04-06 10:23:27 -0700287
Olav Haugan7c6aa742012-01-16 16:47:37 -0800288#ifdef CONFIG_ION_MSM
289#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -0700290static struct ion_cp_heap_pdata cp_mm_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800291 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugand3d29682012-01-19 10:57:07 -0800292 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700293 .reusable = FMEM_ENABLED,
294 .mem_is_fmem = FMEM_ENABLED,
295 .fixed_position = FIXED_MIDDLE,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800296};
297
Laura Abbottb93525f2012-04-12 09:57:19 -0700298static struct ion_cp_heap_pdata cp_mfc_apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800299 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugand3d29682012-01-19 10:57:07 -0800300 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700301 .reusable = 0,
302 .mem_is_fmem = FMEM_ENABLED,
303 .fixed_position = FIXED_HIGH,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800304};
305
Laura Abbottb93525f2012-04-12 09:57:19 -0700306static struct ion_co_heap_pdata co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800307 .adjacent_mem_id = INVALID_HEAP_ID,
308 .align = PAGE_SIZE,
Larry Bassel67b921d2012-04-06 10:23:27 -0700309 .mem_is_fmem = 0,
Olav Haugand3d29682012-01-19 10:57:07 -0800310};
311
Laura Abbottb93525f2012-04-12 09:57:19 -0700312static struct ion_co_heap_pdata fw_co_apq8064_ion_pdata = {
Olav Haugand3d29682012-01-19 10:57:07 -0800313 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
314 .align = SZ_128K,
Larry Bassel67b921d2012-04-06 10:23:27 -0700315 .mem_is_fmem = FMEM_ENABLED,
316 .fixed_position = FIXED_LOW,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800317};
318#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800319
320/**
321 * These heaps are listed in the order they will be allocated. Due to
322 * video hardware restrictions and content protection the FW heap has to
323 * be allocated adjacent (below) the MM heap and the MFC heap has to be
324 * allocated after the MM heap to ensure MFC heap is not more than 256MB
325 * away from the base address of the FW heap.
326 * However, the order of FW heap and MM heap doesn't matter since these
327 * two heaps are taken care of by separate code to ensure they are adjacent
328 * to each other.
329 * Don't swap the order unless you know what you are doing!
330 */
Laura Abbottb93525f2012-04-12 09:57:19 -0700331static struct ion_platform_data apq8064_ion_pdata = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800332 .nr = MSM_ION_HEAP_NUM,
333 .heaps = {
334 {
335 .id = ION_SYSTEM_HEAP_ID,
336 .type = ION_HEAP_TYPE_SYSTEM,
337 .name = ION_VMALLOC_HEAP_NAME,
338 },
339#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
340 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800341 .id = ION_CP_MM_HEAP_ID,
342 .type = ION_HEAP_TYPE_CP,
343 .name = ION_MM_HEAP_NAME,
344 .size = MSM_ION_MM_SIZE,
345 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700346 .extra_data = (void *) &cp_mm_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800347 },
348 {
Olav Haugand3d29682012-01-19 10:57:07 -0800349 .id = ION_MM_FIRMWARE_HEAP_ID,
350 .type = ION_HEAP_TYPE_CARVEOUT,
351 .name = ION_MM_FIRMWARE_HEAP_NAME,
352 .size = MSM_ION_MM_FW_SIZE,
353 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700354 .extra_data = (void *) &fw_co_apq8064_ion_pdata,
Olav Haugand3d29682012-01-19 10:57:07 -0800355 },
356 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800357 .id = ION_CP_MFC_HEAP_ID,
358 .type = ION_HEAP_TYPE_CP,
359 .name = ION_MFC_HEAP_NAME,
360 .size = MSM_ION_MFC_SIZE,
361 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700362 .extra_data = (void *) &cp_mfc_apq8064_ion_pdata,
Olav Haugan7c6aa742012-01-16 16:47:37 -0800363 },
Olav Haugan129992c2012-03-22 09:54:01 -0700364#ifndef CONFIG_MSM_IOMMU
Olav Haugan7c6aa742012-01-16 16:47:37 -0800365 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800366 .id = ION_SF_HEAP_ID,
367 .type = ION_HEAP_TYPE_CARVEOUT,
368 .name = ION_SF_HEAP_NAME,
369 .size = MSM_ION_SF_SIZE,
370 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700371 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800372 },
Olav Haugan129992c2012-03-22 09:54:01 -0700373#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800374 {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800375 .id = ION_IOMMU_HEAP_ID,
376 .type = ION_HEAP_TYPE_IOMMU,
377 .name = ION_IOMMU_HEAP_NAME,
378 },
Olav Hauganf45e2142012-01-19 11:01:01 -0800379 {
380 .id = ION_QSECOM_HEAP_ID,
381 .type = ION_HEAP_TYPE_CARVEOUT,
382 .name = ION_QSECOM_HEAP_NAME,
383 .size = MSM_ION_QSECOM_SIZE,
384 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700385 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Hauganf45e2142012-01-19 11:01:01 -0800386 },
Olav Haugan2c43fac2012-01-19 11:06:37 -0800387 {
388 .id = ION_AUDIO_HEAP_ID,
389 .type = ION_HEAP_TYPE_CARVEOUT,
390 .name = ION_AUDIO_HEAP_NAME,
391 .size = MSM_ION_AUDIO_SIZE,
392 .memory_type = ION_EBI_TYPE,
Laura Abbottb93525f2012-04-12 09:57:19 -0700393 .extra_data = (void *) &co_apq8064_ion_pdata,
Olav Haugan2c43fac2012-01-19 11:06:37 -0800394 },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800395#endif
396 }
397};
398
Laura Abbottb93525f2012-04-12 09:57:19 -0700399static struct platform_device apq8064_ion_dev = {
Olav Haugan7c6aa742012-01-16 16:47:37 -0800400 .name = "ion-msm",
401 .id = 1,
Laura Abbottb93525f2012-04-12 09:57:19 -0700402 .dev = { .platform_data = &apq8064_ion_pdata },
Olav Haugan7c6aa742012-01-16 16:47:37 -0800403};
404#endif
405
Larry Bassel67b921d2012-04-06 10:23:27 -0700406static struct platform_device apq8064_fmem_device = {
407 .name = "fmem",
408 .id = 1,
409 .dev = { .platform_data = &apq8064_fmem_pdata },
410};
411
412static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
413 unsigned long size)
414{
415 apq8064_reserve_table[mem_type].size += size;
416}
417
418static void __init apq8064_reserve_fixed_area(unsigned long fixed_area_size)
419{
420#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
421 int ret;
422
423 if (fixed_area_size > MAX_FIXED_AREA_SIZE)
424 panic("fixed area size is larger than %dM\n",
425 MAX_FIXED_AREA_SIZE >> 20);
426
427 reserve_info->fixed_area_size = fixed_area_size;
428 reserve_info->fixed_area_start = APQ8064_FW_START;
429
430 ret = memblock_remove(reserve_info->fixed_area_start,
431 reserve_info->fixed_area_size);
432 BUG_ON(ret);
433#endif
434}
435
436/**
437 * Reserve memory for ION and calculate amount of reusable memory for fmem.
438 * We only reserve memory for heaps that are not reusable. However, we only
439 * support one reusable heap at the moment so we ignore the reusable flag for
440 * other than the first heap with reusable flag set. Also handle special case
441 * for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
442 * at a higher address than FW in addition to not more than 256MB away from the
443 * base address of the firmware. This means that if MM is reusable the other
444 * two heaps must be allocated in the same region as FW. This is handled by the
445 * mem_is_fmem flag in the platform data. In addition the MM heap must be
446 * adjacent to the FW heap for content protection purposes.
447 */
Stephen Boyd668d7652012-04-25 11:31:01 -0700448static void __init reserve_ion_memory(void)
Olav Haugan7c6aa742012-01-16 16:47:37 -0800449{
450#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Larry Bassel67b921d2012-04-06 10:23:27 -0700451 unsigned int i;
452 unsigned int reusable_count = 0;
453 unsigned int fixed_size = 0;
454 unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
455 unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
456
457 apq8064_fmem_pdata.size = 0;
458 apq8064_fmem_pdata.reserved_size_low = 0;
459 apq8064_fmem_pdata.reserved_size_high = 0;
Olav Haugan62436252012-05-16 09:09:43 -0700460 apq8064_fmem_pdata.align = PAGE_SIZE;
Larry Bassel67b921d2012-04-06 10:23:27 -0700461 fixed_low_size = 0;
462 fixed_middle_size = 0;
463 fixed_high_size = 0;
464
465 /* We only support 1 reusable heap. Check if more than one heap
466 * is specified as reusable and set as non-reusable if found.
467 */
468 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
469 const struct ion_platform_heap *heap =
470 &(apq8064_ion_pdata.heaps[i]);
471
472 if (heap->type == ION_HEAP_TYPE_CP && heap->extra_data) {
473 struct ion_cp_heap_pdata *data = heap->extra_data;
474
475 reusable_count += (data->reusable) ? 1 : 0;
476
477 if (data->reusable && reusable_count > 1) {
478 pr_err("%s: Too many heaps specified as "
479 "reusable. Heap %s was not configured "
480 "as reusable.\n", __func__, heap->name);
481 data->reusable = 0;
482 }
483 }
484 }
485
486 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
487 const struct ion_platform_heap *heap =
488 &(apq8064_ion_pdata.heaps[i]);
489
490 if (heap->extra_data) {
491 int fixed_position = NOT_FIXED;
492 int mem_is_fmem = 0;
493
494 switch (heap->type) {
495 case ION_HEAP_TYPE_CP:
496 mem_is_fmem = ((struct ion_cp_heap_pdata *)
497 heap->extra_data)->mem_is_fmem;
498 fixed_position = ((struct ion_cp_heap_pdata *)
499 heap->extra_data)->fixed_position;
500 break;
501 case ION_HEAP_TYPE_CARVEOUT:
502 mem_is_fmem = ((struct ion_co_heap_pdata *)
503 heap->extra_data)->mem_is_fmem;
504 fixed_position = ((struct ion_co_heap_pdata *)
505 heap->extra_data)->fixed_position;
506 break;
507 default:
508 break;
509 }
510
511 if (fixed_position != NOT_FIXED)
512 fixed_size += heap->size;
513 else
514 reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
515
516 if (fixed_position == FIXED_LOW)
517 fixed_low_size += heap->size;
518 else if (fixed_position == FIXED_MIDDLE)
519 fixed_middle_size += heap->size;
520 else if (fixed_position == FIXED_HIGH)
521 fixed_high_size += heap->size;
522
523 if (mem_is_fmem)
524 apq8064_fmem_pdata.size += heap->size;
525 }
526 }
527
528 if (!fixed_size)
529 return;
530
531 if (apq8064_fmem_pdata.size) {
Hanumant Singheadb7502012-05-15 18:14:04 -0700532 apq8064_fmem_pdata.reserved_size_low = fixed_low_size +
533 HOLE_SIZE;
Larry Bassel67b921d2012-04-06 10:23:27 -0700534 apq8064_fmem_pdata.reserved_size_high = fixed_high_size;
535 }
536
537 /* Since the fixed area may be carved out of lowmem,
538 * make sure the length is a multiple of 1M.
539 */
Hanumant Singheadb7502012-05-15 18:14:04 -0700540 fixed_size = (fixed_size + HOLE_SIZE + SECTION_SIZE - 1)
Larry Bassel67b921d2012-04-06 10:23:27 -0700541 & SECTION_MASK;
542 apq8064_reserve_fixed_area(fixed_size);
543
544 fixed_low_start = APQ8064_FIXED_AREA_START;
Hanumant Singheadb7502012-05-15 18:14:04 -0700545 fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
Larry Bassel67b921d2012-04-06 10:23:27 -0700546 fixed_high_start = fixed_middle_start + fixed_middle_size;
547
548 for (i = 0; i < apq8064_ion_pdata.nr; ++i) {
549 struct ion_platform_heap *heap = &(apq8064_ion_pdata.heaps[i]);
550
551 if (heap->extra_data) {
552 int fixed_position = NOT_FIXED;
Steve Mucklef132c6c2012-06-06 18:30:57 -0700553 struct ion_cp_heap_pdata *pdata = NULL;
Larry Bassel67b921d2012-04-06 10:23:27 -0700554
555 switch (heap->type) {
556 case ION_HEAP_TYPE_CP:
Hanumant Singheadb7502012-05-15 18:14:04 -0700557 pdata =
558 (struct ion_cp_heap_pdata *)heap->extra_data;
559 fixed_position = pdata->fixed_position;
Larry Bassel67b921d2012-04-06 10:23:27 -0700560 break;
561 case ION_HEAP_TYPE_CARVEOUT:
562 fixed_position = ((struct ion_co_heap_pdata *)
563 heap->extra_data)->fixed_position;
564 break;
565 default:
566 break;
567 }
568
569 switch (fixed_position) {
570 case FIXED_LOW:
571 heap->base = fixed_low_start;
572 break;
573 case FIXED_MIDDLE:
574 heap->base = fixed_middle_start;
Hanumant Singheadb7502012-05-15 18:14:04 -0700575 pdata->secure_base = fixed_middle_start
576 - HOLE_SIZE;
577 pdata->secure_size = HOLE_SIZE + heap->size;
Larry Bassel67b921d2012-04-06 10:23:27 -0700578 break;
579 case FIXED_HIGH:
580 heap->base = fixed_high_start;
581 break;
582 default:
583 break;
584 }
585 }
586 }
Olav Haugan7c6aa742012-01-16 16:47:37 -0800587#endif
Kevin Chan13be4e22011-10-20 11:30:32 -0700588}
589
Huaibin Yang4a084e32011-12-15 15:25:52 -0800590static void __init reserve_mdp_memory(void)
591{
592 apq8064_mdp_writeback(apq8064_reserve_table);
593}
594
Laura Abbott93a4a352012-05-25 09:26:35 -0700595static void __init reserve_cache_dump_memory(void)
596{
597#ifdef CONFIG_MSM_CACHE_DUMP
598 unsigned int total;
599
600 total = apq8064_cache_dump_pdata.l1_size +
601 apq8064_cache_dump_pdata.l2_size;
602 apq8064_reserve_table[MEMTYPE_EBI1].size += total;
603#endif
604}
605
Kevin Chan13be4e22011-10-20 11:30:32 -0700606static void __init apq8064_calculate_reserve_sizes(void)
607{
608 size_pmem_devices();
609 reserve_pmem_memory();
Olav Haugan7c6aa742012-01-16 16:47:37 -0800610 reserve_ion_memory();
Huaibin Yang4a084e32011-12-15 15:25:52 -0800611 reserve_mdp_memory();
Laura Abbott350c8362012-02-28 14:46:52 -0800612 reserve_rtb_memory();
Laura Abbott93a4a352012-05-25 09:26:35 -0700613 reserve_cache_dump_memory();
Kevin Chan13be4e22011-10-20 11:30:32 -0700614}
615
616static struct reserve_info apq8064_reserve_info __initdata = {
617 .memtype_reserve_table = apq8064_reserve_table,
618 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
Larry Bassel67b921d2012-04-06 10:23:27 -0700619 .reserve_fixed_area = apq8064_reserve_fixed_area,
Kevin Chan13be4e22011-10-20 11:30:32 -0700620 .paddr_to_memtype = apq8064_paddr_to_memtype,
621};
622
623static int apq8064_memory_bank_size(void)
624{
625 return 1<<29;
626}
627
628static void __init locate_unstable_memory(void)
629{
630 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
631 unsigned long bank_size;
632 unsigned long low, high;
633
634 bank_size = apq8064_memory_bank_size();
635 low = meminfo.bank[0].start;
636 high = mb->start + mb->size;
Olav Haugand76e3a82012-01-16 16:55:07 -0800637
638 /* Check if 32 bit overflow occured */
639 if (high < mb->start)
Larry Bassel67b921d2012-04-06 10:23:27 -0700640 high = -PAGE_SIZE;
Olav Haugand76e3a82012-01-16 16:55:07 -0800641
Kevin Chan13be4e22011-10-20 11:30:32 -0700642 low &= ~(bank_size - 1);
643
644 if (high - low <= bank_size)
Larry Bassel67b921d2012-04-06 10:23:27 -0700645 goto no_dmm;
646
647#ifdef CONFIG_ENABLE_DMM
Jack Cheung46bfffa2012-01-19 15:26:24 -0800648 apq8064_reserve_info.low_unstable_address = mb->start -
649 MIN_MEMORY_BLOCK_SIZE + mb->size;
650 apq8064_reserve_info.max_unstable_size = MIN_MEMORY_BLOCK_SIZE;
651
Kevin Chan13be4e22011-10-20 11:30:32 -0700652 apq8064_reserve_info.bank_size = bank_size;
653 pr_info("low unstable address %lx max size %lx bank size %lx\n",
654 apq8064_reserve_info.low_unstable_address,
655 apq8064_reserve_info.max_unstable_size,
656 apq8064_reserve_info.bank_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700657 return;
658#endif
659no_dmm:
660 apq8064_reserve_info.low_unstable_address = high;
661 apq8064_reserve_info.max_unstable_size = 0;
Kevin Chan13be4e22011-10-20 11:30:32 -0700662}
663
Hanumant Singh50440d42012-04-23 19:27:16 -0700664static int apq8064_change_memory_power(u64 start, u64 size,
665 int change_type)
666{
667 return soc_change_memory_power(start, size, change_type);
668}
669
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700670static char prim_panel_name[PANEL_NAME_MAX_LEN];
671static char ext_panel_name[PANEL_NAME_MAX_LEN];
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530672
673static int ext_resolution;
674
Aravind Venkateswaran8ac7f412012-03-16 17:57:30 -0700675static int __init prim_display_setup(char *param)
676{
677 if (strnlen(param, PANEL_NAME_MAX_LEN))
678 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
679 return 0;
680}
681early_param("prim_display", prim_display_setup);
682
683static int __init ext_display_setup(char *param)
684{
685 if (strnlen(param, PANEL_NAME_MAX_LEN))
686 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
687 return 0;
688}
689early_param("ext_display", ext_display_setup);
690
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530691static int __init hdmi_resulution_setup(char *param)
692{
693 int ret;
694 ret = kstrtoint(param, 10, &ext_resolution);
695 return ret;
696}
697early_param("ext_resolution", hdmi_resulution_setup);
698
Kevin Chan13be4e22011-10-20 11:30:32 -0700699static void __init apq8064_reserve(void)
700{
Ajay Singh Parmar6b82d2b2012-07-19 17:23:26 +0530701 apq8064_set_display_params(prim_panel_name, ext_panel_name,
702 ext_resolution);
Kevin Chan13be4e22011-10-20 11:30:32 -0700703 msm_reserve();
Larry Bassel67b921d2012-04-06 10:23:27 -0700704 if (apq8064_fmem_pdata.size) {
705#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
706 if (reserve_info->fixed_area_size) {
707 apq8064_fmem_pdata.phys =
708 reserve_info->fixed_area_start + MSM_MM_FW_SIZE;
709 pr_info("mm fw at %lx (fixed) size %x\n",
710 reserve_info->fixed_area_start, MSM_MM_FW_SIZE);
711 pr_info("fmem start %lx (fixed) size %lx\n",
712 apq8064_fmem_pdata.phys,
713 apq8064_fmem_pdata.size);
714 }
715#endif
716 }
Kevin Chan13be4e22011-10-20 11:30:32 -0700717}
718
Laura Abbott6988cef2012-03-15 14:27:13 -0700719static void __init place_movable_zone(void)
720{
Larry Bassel67b921d2012-04-06 10:23:27 -0700721#ifdef CONFIG_ENABLE_DMM
Laura Abbott6988cef2012-03-15 14:27:13 -0700722 movable_reserved_start = apq8064_reserve_info.low_unstable_address;
723 movable_reserved_size = apq8064_reserve_info.max_unstable_size;
724 pr_info("movable zone start %lx size %lx\n",
725 movable_reserved_start, movable_reserved_size);
Larry Bassel67b921d2012-04-06 10:23:27 -0700726#endif
Laura Abbott6988cef2012-03-15 14:27:13 -0700727}
728
729static void __init apq8064_early_reserve(void)
730{
731 reserve_info = &apq8064_reserve_info;
732 locate_unstable_memory();
733 place_movable_zone();
734
735}
Hemant Kumara945b472012-01-25 15:08:06 -0800736#ifdef CONFIG_USB_EHCI_MSM_HSIC
Hemant Kumare6275972012-02-29 20:06:21 -0800737/* Bandwidth requests (zero) if no vote placed */
738static struct msm_bus_vectors hsic_init_vectors[] = {
739 {
740 .src = MSM_BUS_MASTER_SPS,
741 .dst = MSM_BUS_SLAVE_EBI_CH0,
742 .ab = 0,
743 .ib = 0,
744 },
745 {
746 .src = MSM_BUS_MASTER_SPS,
747 .dst = MSM_BUS_SLAVE_SPS,
748 .ab = 0,
749 .ib = 0,
750 },
751};
752
753/* Bus bandwidth requests in Bytes/sec */
754static struct msm_bus_vectors hsic_max_vectors[] = {
755 {
756 .src = MSM_BUS_MASTER_SPS,
757 .dst = MSM_BUS_SLAVE_EBI_CH0,
758 .ab = 60000000, /* At least 480Mbps on bus. */
759 .ib = 960000000, /* MAX bursts rate */
760 },
761 {
762 .src = MSM_BUS_MASTER_SPS,
763 .dst = MSM_BUS_SLAVE_SPS,
764 .ab = 0,
765 .ib = 512000000, /*vote for 64Mhz dfab clk rate*/
766 },
767};
768
769static struct msm_bus_paths hsic_bus_scale_usecases[] = {
770 {
771 ARRAY_SIZE(hsic_init_vectors),
772 hsic_init_vectors,
773 },
774 {
775 ARRAY_SIZE(hsic_max_vectors),
776 hsic_max_vectors,
777 },
778};
779
780static struct msm_bus_scale_pdata hsic_bus_scale_pdata = {
781 hsic_bus_scale_usecases,
782 ARRAY_SIZE(hsic_bus_scale_usecases),
783 .name = "hsic",
784};
785
Hemant Kumara945b472012-01-25 15:08:06 -0800786static struct msm_hsic_host_platform_data msm_hsic_pdata = {
Hemant Kumare6275972012-02-29 20:06:21 -0800787 .strobe = 88,
788 .data = 89,
789 .bus_scale_table = &hsic_bus_scale_pdata,
Hemant Kumara945b472012-01-25 15:08:06 -0800790};
791#else
792static struct msm_hsic_host_platform_data msm_hsic_pdata;
793#endif
794
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800795#define PID_MAGIC_ID 0x71432909
796#define SERIAL_NUM_MAGIC_ID 0x61945374
797#define SERIAL_NUMBER_LENGTH 127
798#define DLOAD_USB_BASE_ADD 0x2A03F0C8
799
800struct magic_num_struct {
801 uint32_t pid;
802 uint32_t serial_num;
803};
804
805struct dload_struct {
806 uint32_t reserved1;
807 uint32_t reserved2;
808 uint32_t reserved3;
809 uint16_t reserved4;
810 uint16_t pid;
811 char serial_number[SERIAL_NUMBER_LENGTH];
812 uint16_t reserved5;
813 struct magic_num_struct magic_struct;
814};
815
816static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
817{
818 struct dload_struct __iomem *dload = 0;
819
820 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
821 if (!dload) {
822 pr_err("%s: cannot remap I/O memory region: %08x\n",
823 __func__, DLOAD_USB_BASE_ADD);
824 return -ENXIO;
825 }
826
827 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
828 __func__, dload, pid, snum);
829 /* update pid */
830 dload->magic_struct.pid = PID_MAGIC_ID;
831 dload->pid = pid;
832
833 /* update serial number */
834 dload->magic_struct.serial_num = 0;
835 if (!snum) {
836 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
837 goto out;
838 }
839
840 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
841 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
842out:
843 iounmap(dload);
844 return 0;
845}
846
847static struct android_usb_platform_data android_usb_pdata = {
848 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
849};
850
Hemant Kumar4933b072011-10-17 23:43:11 -0700851static struct platform_device android_usb_device = {
Hemant Kumarcb7d8a12012-01-25 12:25:55 -0800852 .name = "android_usb",
853 .id = -1,
854 .dev = {
855 .platform_data = &android_usb_pdata,
856 },
Hemant Kumar4933b072011-10-17 23:43:11 -0700857};
858
Hemant Kumar7620eed2012-02-26 09:08:43 -0800859/* Bandwidth requests (zero) if no vote placed */
860static struct msm_bus_vectors usb_init_vectors[] = {
861 {
862 .src = MSM_BUS_MASTER_SPS,
863 .dst = MSM_BUS_SLAVE_EBI_CH0,
864 .ab = 0,
865 .ib = 0,
866 },
867};
868
869/* Bus bandwidth requests in Bytes/sec */
870static struct msm_bus_vectors usb_max_vectors[] = {
871 {
872 .src = MSM_BUS_MASTER_SPS,
873 .dst = MSM_BUS_SLAVE_EBI_CH0,
874 .ab = 60000000, /* At least 480Mbps on bus. */
875 .ib = 960000000, /* MAX bursts rate */
876 },
877};
878
879static struct msm_bus_paths usb_bus_scale_usecases[] = {
880 {
881 ARRAY_SIZE(usb_init_vectors),
882 usb_init_vectors,
883 },
884 {
885 ARRAY_SIZE(usb_max_vectors),
886 usb_max_vectors,
887 },
888};
889
890static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
891 usb_bus_scale_usecases,
892 ARRAY_SIZE(usb_bus_scale_usecases),
893 .name = "usb",
894};
895
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700896static int phy_init_seq[] = {
Chiranjeevi Velempatif983aeb2012-08-23 08:16:50 +0530897 0x68, 0x81, /* update DC voltage level */
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700898 0x24, 0x82, /* set pre-emphasis and rise/fall time */
899 -1
900};
901
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530902#define PMIC_GPIO_DP 27 /* PMIC GPIO for D+ change */
903#define PMIC_GPIO_DP_IRQ PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PMIC_GPIO_DP)
Jack Pham87f202f2012-08-06 00:24:22 -0700904#define MSM_MPM_PIN_USB1_OTGSESSVLD 40
905
Hemant Kumar4933b072011-10-17 23:43:11 -0700906static struct msm_otg_platform_data msm_otg_pdata = {
Hemant Kumard86c4882012-01-24 19:39:37 -0800907 .mode = USB_OTG,
908 .otg_control = OTG_PMIC_CONTROL,
Hemant Kumar4933b072011-10-17 23:43:11 -0700909 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Hemant Kumard86c4882012-01-24 19:39:37 -0800910 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
911 .power_budget = 750,
Hemant Kumar7620eed2012-02-26 09:08:43 -0800912 .bus_scale_table = &usb_bus_scale_pdata,
Vamsi Krishna1f8704c2012-03-29 18:24:24 -0700913 .phy_init_seq = phy_init_seq,
Jack Pham87f202f2012-08-06 00:24:22 -0700914 .mpm_otgsessvld_int = MSM_MPM_PIN_USB1_OTGSESSVLD,
Hemant Kumar4933b072011-10-17 23:43:11 -0700915};
916
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800917static struct msm_usb_host_platform_data msm_ehci_host_pdata3 = {
Manu Gautam91223e02011-11-08 15:27:22 +0530918 .power_budget = 500,
919};
920
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800921#ifdef CONFIG_USB_EHCI_MSM_HOST4
922static struct msm_usb_host_platform_data msm_ehci_host_pdata4;
923#endif
924
Manu Gautam91223e02011-11-08 15:27:22 +0530925static void __init apq8064_ehci_host_init(void)
926{
Chiranjeevi Velempatib822fa32012-05-23 22:05:59 +0530927 if (machine_is_apq8064_liquid() || machine_is_mpq8064_cdp() ||
928 machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
929 if (machine_is_apq8064_liquid())
930 msm_ehci_host_pdata3.dock_connect_irq =
931 PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9);
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530932 else
933 msm_ehci_host_pdata3.pmic_gpio_dp_irq =
934 PMIC_GPIO_DP_IRQ;
Hemant Kumar56925352012-02-13 16:59:52 -0800935
Manu Gautam91223e02011-11-08 15:27:22 +0530936 apq8064_device_ehci_host3.dev.platform_data =
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800937 &msm_ehci_host_pdata3;
Manu Gautam91223e02011-11-08 15:27:22 +0530938 platform_device_register(&apq8064_device_ehci_host3);
Hemant Kumar1d66e1c2012-02-13 15:24:59 -0800939
940#ifdef CONFIG_USB_EHCI_MSM_HOST4
941 apq8064_device_ehci_host4.dev.platform_data =
942 &msm_ehci_host_pdata4;
943 platform_device_register(&apq8064_device_ehci_host4);
944#endif
Manu Gautam91223e02011-11-08 15:27:22 +0530945 }
946}
947
David Keitel2f613d92012-02-15 11:29:16 -0800948static struct smb349_platform_data smb349_data __initdata = {
949 .en_n_gpio = PM8921_GPIO_PM_TO_SYS(37),
950 .chg_susp_gpio = PM8921_GPIO_PM_TO_SYS(30),
951 .chg_current_ma = 2200,
952};
953
954static struct i2c_board_info smb349_charger_i2c_info[] __initdata = {
955 {
956 I2C_BOARD_INFO(SMB349_NAME, 0x1B),
957 .platform_data = &smb349_data,
958 },
959};
960
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -0800961struct sx150x_platform_data apq8064_sx150x_data[] = {
962 [SX150X_EPM] = {
963 .gpio_base = GPIO_EPM_EXPANDER_BASE,
964 .oscio_is_gpo = false,
965 .io_pullup_ena = 0x0,
966 .io_pulldn_ena = 0x0,
967 .io_open_drain_ena = 0x0,
968 .io_polarity = 0,
969 .irq_summary = -1,
970 },
971};
972
973static struct epm_chan_properties ads_adc_channel_data[] = {
Yan He44c59962012-08-31 11:14:58 -0700974 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
975 {10, 100}, {1000, 1}, {10, 100}, {1000, 1},
976 {10, 100}, {20, 100}, {500, 100}, {5, 100},
977 {1000, 1}, {200, 100}, {50, 100}, {10, 100},
978 {510, 100}, {50, 100}, {20, 100}, {100, 100},
979 {510, 100}, {20, 100}, {50, 100}, {200, 100},
980 {10, 100}, {20, 100}, {1000, 1}, {10, 100},
981 {200, 100}, {510, 100}, {1000, 100}, {200, 100},
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -0800982};
983
984static struct epm_adc_platform_data epm_adc_pdata = {
985 .channel = ads_adc_channel_data,
986 .bus_id = 0x0,
987 .epm_i2c_board_info = {
988 .type = "sx1509q",
989 .addr = 0x3e,
990 .platform_data = &apq8064_sx150x_data[SX150X_EPM],
991 },
992 .gpio_expander_base_addr = GPIO_EPM_EXPANDER_BASE,
993};
994
995static struct platform_device epm_adc_device = {
996 .name = "epm_adc",
997 .id = -1,
998 .dev = {
999 .platform_data = &epm_adc_pdata,
1000 },
1001};
1002
1003static void __init apq8064_epm_adc_init(void)
1004{
1005 epm_adc_pdata.num_channels = 32;
1006 epm_adc_pdata.num_adc = 2;
1007 epm_adc_pdata.chan_per_adc = 16;
1008 epm_adc_pdata.chan_per_mux = 8;
1009};
1010
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001011/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1012 * 4 micbiases are used to power various analog and digital
1013 * microphones operating at 1800 mV. Technically, all micbiases
1014 * can source from single cfilter since all microphones operate
1015 * at the same voltage level. The arrangement below is to make
1016 * sure all cfilters are exercised. LDO_H regulator ouput level
1017 * does not need to be as high as 2.85V. It is choosen for
1018 * microphone sensitivity purpose.
1019 */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301020static struct wcd9xxx_pdata apq8064_tabla_platform_data = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001021 .slimbus_slave_device = {
1022 .name = "tabla-slave",
1023 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1024 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001025 .irq = MSM_GPIO_TO_INT(42),
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001026 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301027 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001028 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1029 .micbias = {
1030 .ldoh_v = TABLA_LDOH_2P85_V,
1031 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001032 .cfilt2_mv = 2700,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001033 .cfilt3_mv = 1800,
1034 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1035 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1036 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1037 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301038 },
1039 .regulator = {
1040 {
1041 .name = "CDC_VDD_CP",
1042 .min_uV = 1800000,
1043 .max_uV = 1800000,
1044 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1045 },
1046 {
1047 .name = "CDC_VDDA_RX",
1048 .min_uV = 1800000,
1049 .max_uV = 1800000,
1050 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1051 },
1052 {
1053 .name = "CDC_VDDA_TX",
1054 .min_uV = 1800000,
1055 .max_uV = 1800000,
1056 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1057 },
1058 {
1059 .name = "VDDIO_CDC",
1060 .min_uV = 1800000,
1061 .max_uV = 1800000,
1062 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1063 },
1064 {
1065 .name = "VDDD_CDC_D",
1066 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001067 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301068 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1069 },
1070 {
1071 .name = "CDC_VDDA_A_1P2V",
1072 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001073 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301074 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1075 },
1076 },
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08001077};
1078
1079static struct slim_device apq8064_slim_tabla = {
1080 .name = "tabla-slim",
1081 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1082 .dev = {
1083 .platform_data = &apq8064_tabla_platform_data,
1084 },
1085};
1086
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301087static struct wcd9xxx_pdata apq8064_tabla20_platform_data = {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001088 .slimbus_slave_device = {
1089 .name = "tabla-slave",
1090 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
1091 },
1092 .irq = MSM_GPIO_TO_INT(42),
1093 .irq_base = TABLA_INTERRUPT_BASE,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301094 .num_irqs = NR_WCD9XXX_IRQS,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001095 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1096 .micbias = {
1097 .ldoh_v = TABLA_LDOH_2P85_V,
1098 .cfilt1_mv = 1800,
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -07001099 .cfilt2_mv = 2700,
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001100 .cfilt3_mv = 1800,
1101 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1102 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1103 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1104 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301105 },
1106 .regulator = {
1107 {
1108 .name = "CDC_VDD_CP",
1109 .min_uV = 1800000,
1110 .max_uV = 1800000,
1111 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1112 },
1113 {
1114 .name = "CDC_VDDA_RX",
1115 .min_uV = 1800000,
1116 .max_uV = 1800000,
1117 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1118 },
1119 {
1120 .name = "CDC_VDDA_TX",
1121 .min_uV = 1800000,
1122 .max_uV = 1800000,
1123 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1124 },
1125 {
1126 .name = "VDDIO_CDC",
1127 .min_uV = 1800000,
1128 .max_uV = 1800000,
1129 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1130 },
1131 {
1132 .name = "VDDD_CDC_D",
1133 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001134 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301135 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1136 },
1137 {
1138 .name = "CDC_VDDA_A_1P2V",
1139 .min_uV = 1225000,
David Collins62debe82012-06-06 17:01:03 -07001140 .max_uV = 1250000,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05301141 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1142 },
1143 },
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08001144};
1145
1146static struct slim_device apq8064_slim_tabla20 = {
1147 .name = "tabla2x-slim",
1148 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
1149 .dev = {
1150 .platform_data = &apq8064_tabla20_platform_data,
1151 },
1152};
1153
Kuirong Wangf8c5e142012-06-21 16:17:32 -07001154static struct wcd9xxx_pdata apq8064_tabla_i2c_platform_data = {
1155 .irq = MSM_GPIO_TO_INT(77),
1156 .irq_base = TABLA_INTERRUPT_BASE,
1157 .num_irqs = NR_WCD9XXX_IRQS,
1158 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
1159 .micbias = {
1160 .ldoh_v = TABLA_LDOH_2P85_V,
1161 .cfilt1_mv = 1800,
1162 .cfilt2_mv = 1800,
1163 .cfilt3_mv = 1800,
1164 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1165 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1166 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1167 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
1168 },
1169 .regulator = {
1170 {
1171 .name = "CDC_VDD_CP",
1172 .min_uV = 1800000,
1173 .max_uV = 1800000,
1174 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
1175 },
1176 {
1177 .name = "CDC_VDDA_RX",
1178 .min_uV = 1800000,
1179 .max_uV = 1800000,
1180 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
1181 },
1182 {
1183 .name = "CDC_VDDA_TX",
1184 .min_uV = 1800000,
1185 .max_uV = 1800000,
1186 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
1187 },
1188 {
1189 .name = "VDDIO_CDC",
1190 .min_uV = 1800000,
1191 .max_uV = 1800000,
1192 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
1193 },
1194 {
1195 .name = "VDDD_CDC_D",
1196 .min_uV = 1225000,
1197 .max_uV = 1250000,
1198 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
1199 },
1200 {
1201 .name = "CDC_VDDA_A_1P2V",
1202 .min_uV = 1225000,
1203 .max_uV = 1250000,
1204 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
1205 },
1206 },
1207};
1208
1209static struct i2c_board_info apq8064_tabla_i2c_device_info[] __initdata = {
1210 {
1211 I2C_BOARD_INFO("tabla top level",
1212 APQ_8064_TABLA_I2C_SLAVE_ADDR),
1213 .platform_data = &apq8064_tabla_i2c_platform_data,
1214 },
1215 {
1216 I2C_BOARD_INFO("tabla analog",
1217 APQ_8064_TABLA_ANALOG_I2C_SLAVE_ADDR),
1218 .platform_data = &apq8064_tabla_i2c_platform_data,
1219 },
1220 {
1221 I2C_BOARD_INFO("tabla digital1",
1222 APQ_8064_TABLA_DIGITAL1_I2C_SLAVE_ADDR),
1223 .platform_data = &apq8064_tabla_i2c_platform_data,
1224 },
1225 {
1226 I2C_BOARD_INFO("tabla digital2",
1227 APQ_8064_TABLA_DIGITAL2_I2C_SLAVE_ADDR),
1228 .platform_data = &apq8064_tabla_i2c_platform_data,
1229 },
1230};
1231
Santosh Mardi695be0d2012-04-10 23:21:12 +05301232/* enable the level shifter for cs8427 to make sure the I2C
1233 * clock is running at 100KHz and voltage levels are at 3.3
1234 * and 5 volts
1235 */
1236static int enable_100KHz_ls(int enable)
1237{
1238 int ret = 0;
1239 if (enable) {
1240 ret = gpio_request(SX150X_GPIO(1, 10),
1241 "cs8427_100KHZ_ENABLE");
1242 if (ret) {
1243 pr_err("%s: Failed to request gpio %d\n", __func__,
1244 SX150X_GPIO(1, 10));
1245 return ret;
1246 }
1247 gpio_direction_output(SX150X_GPIO(1, 10), 1);
Santosh Mardi3896ed32012-08-31 19:26:54 +05301248 } else {
1249 gpio_direction_output(SX150X_GPIO(1, 10), 0);
Santosh Mardi695be0d2012-04-10 23:21:12 +05301250 gpio_free(SX150X_GPIO(1, 10));
Santosh Mardi3896ed32012-08-31 19:26:54 +05301251 }
Santosh Mardi695be0d2012-04-10 23:21:12 +05301252 return ret;
1253}
1254
Santosh Mardieff9a742012-04-09 23:23:39 +05301255static struct cs8427_platform_data cs8427_i2c_platform_data = {
1256 .irq = SX150X_GPIO(1, 4),
1257 .reset_gpio = SX150X_GPIO(1, 6),
Santosh Mardi695be0d2012-04-10 23:21:12 +05301258 .enable = enable_100KHz_ls,
Santosh Mardieff9a742012-04-09 23:23:39 +05301259};
1260
1261static struct i2c_board_info cs8427_device_info[] __initdata = {
1262 {
1263 I2C_BOARD_INFO("cs8427", CS8427_ADDR4),
1264 .platform_data = &cs8427_i2c_platform_data,
1265 },
1266};
1267
Amy Maloche70090f992012-02-16 16:35:26 -08001268#define HAP_SHIFT_LVL_OE_GPIO PM8921_MPP_PM_TO_SYS(8)
1269#define ISA1200_HAP_EN_GPIO PM8921_GPIO_PM_TO_SYS(33)
1270#define ISA1200_HAP_LEN_GPIO PM8921_GPIO_PM_TO_SYS(20)
David Collinsd49a1c52012-08-22 13:18:06 -07001271#define ISA1200_HAP_CLK_PM8921 PM8921_GPIO_PM_TO_SYS(44)
1272#define ISA1200_HAP_CLK_PM8917 PM8921_GPIO_PM_TO_SYS(38)
Amy Maloche70090f992012-02-16 16:35:26 -08001273
Mohan Pallaka2d877602012-05-11 13:07:30 +05301274static int isa1200_clk_enable(bool on)
Amy Maloche70090f992012-02-16 16:35:26 -08001275{
David Collinsd49a1c52012-08-22 13:18:06 -07001276 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche8f973892012-03-26 14:53:13 -07001277 int rc = 0;
1278
David Collinsd49a1c52012-08-22 13:18:06 -07001279 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1280 gpio = ISA1200_HAP_CLK_PM8917;
1281
1282 gpio_set_value_cansleep(gpio, on);
Amy Maloche70090f992012-02-16 16:35:26 -08001283
Mohan Pallaka2d877602012-05-11 13:07:30 +05301284 if (on) {
Amy Maloche8f973892012-03-26 14:53:13 -07001285 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_1, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301286 if (rc) {
1287 pr_err("%s: unable to write aux clock register(%d)\n",
1288 __func__, rc);
1289 goto err_gpio_dis;
1290 }
1291 } else {
Amy Maloche8f973892012-03-26 14:53:13 -07001292 rc = pm8xxx_aux_clk_control(CLK_MP3_2, XO_DIV_NONE, true);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301293 if (rc)
1294 pr_err("%s: unable to write aux clock register(%d)\n",
1295 __func__, rc);
Amy Maloche8f973892012-03-26 14:53:13 -07001296 }
1297
1298 return rc;
Mohan Pallaka2d877602012-05-11 13:07:30 +05301299
1300err_gpio_dis:
David Collinsd49a1c52012-08-22 13:18:06 -07001301 gpio_set_value_cansleep(gpio, !on);
Mohan Pallaka2d877602012-05-11 13:07:30 +05301302 return rc;
Amy Maloche70090f992012-02-16 16:35:26 -08001303}
1304
1305static int isa1200_dev_setup(bool enable)
1306{
David Collinsd49a1c52012-08-22 13:18:06 -07001307 unsigned int gpio = ISA1200_HAP_CLK_PM8921;
Amy Maloche70090f992012-02-16 16:35:26 -08001308 int rc = 0;
1309
David Collinsd49a1c52012-08-22 13:18:06 -07001310 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
1311 gpio = ISA1200_HAP_CLK_PM8917;
1312
Amy Maloche70090f992012-02-16 16:35:26 -08001313 if (!enable)
1314 goto free_gpio;
1315
David Collinsd49a1c52012-08-22 13:18:06 -07001316 rc = gpio_request(gpio, "haptics_clk");
Amy Maloche70090f992012-02-16 16:35:26 -08001317 if (rc) {
1318 pr_err("%s: unable to request gpio %d config(%d)\n",
David Collinsd49a1c52012-08-22 13:18:06 -07001319 __func__, gpio, rc);
Amy Maloche70090f992012-02-16 16:35:26 -08001320 return rc;
1321 }
1322
David Collinsd49a1c52012-08-22 13:18:06 -07001323 rc = gpio_direction_output(gpio, 0);
Amy Maloche70090f992012-02-16 16:35:26 -08001324 if (rc) {
1325 pr_err("%s: unable to set direction\n", __func__);
1326 goto free_gpio;
1327 }
1328
1329 return 0;
1330
1331free_gpio:
David Collinsd49a1c52012-08-22 13:18:06 -07001332 gpio_free(gpio);
Amy Maloche70090f992012-02-16 16:35:26 -08001333 return rc;
1334}
1335
1336static struct isa1200_regulator isa1200_reg_data[] = {
1337 {
1338 .name = "vddp",
1339 .min_uV = ISA_I2C_VTG_MIN_UV,
1340 .max_uV = ISA_I2C_VTG_MAX_UV,
1341 .load_uA = ISA_I2C_CURR_UA,
1342 },
1343};
1344
1345static struct isa1200_platform_data isa1200_1_pdata = {
1346 .name = "vibrator",
1347 .dev_setup = isa1200_dev_setup,
Mohan Pallaka2d877602012-05-11 13:07:30 +05301348 .clk_enable = isa1200_clk_enable,
Mohan Pallaka32f20a72012-06-14 14:41:11 +05301349 .need_pwm_clk = true,
Amy Maloche70090f992012-02-16 16:35:26 -08001350 .hap_en_gpio = ISA1200_HAP_EN_GPIO,
1351 .hap_len_gpio = ISA1200_HAP_LEN_GPIO,
1352 .max_timeout = 15000,
1353 .mode_ctrl = PWM_GEN_MODE,
1354 .pwm_fd = {
1355 .pwm_div = 256,
1356 },
1357 .is_erm = false,
1358 .smart_en = true,
1359 .ext_clk_en = true,
1360 .chip_en = 1,
1361 .regulator_info = isa1200_reg_data,
1362 .num_regulators = ARRAY_SIZE(isa1200_reg_data),
1363};
1364
1365static struct i2c_board_info isa1200_board_info[] __initdata = {
1366 {
1367 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
1368 .platform_data = &isa1200_1_pdata,
1369 },
1370};
Jing Lin21ed4de2012-02-05 15:53:28 -08001371/* configuration data for mxt1386e using V2.1 firmware */
1372static const u8 mxt1386e_config_data_v2_1[] = {
1373 /* T6 Object */
1374 0, 0, 0, 0, 0, 0,
1375 /* T38 Object */
Jing Linc6a55cfc2012-08-31 10:54:44 -07001376 14, 3, 0, 5, 7, 12, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1378 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1379 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1381 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1382 0, 0, 0, 0,
1383 /* T7 Object */
Jing Linc6a55cfc2012-08-31 10:54:44 -07001384 32, 10, 50,
Jing Lin21ed4de2012-02-05 15:53:28 -08001385 /* T8 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001386 25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001387 /* T9 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001388 139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
Jing Linc6a55cfc2012-08-31 10:54:44 -07001389 0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
Jing Linf1208fd2012-02-23 11:15:42 -08001390 85, 5, 0, 5, 9, 5, 12, 35, 70, 40,
1391 20, 5, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001392 /* T18 Object */
1393 0, 0,
1394 /* T24 Object */
1395 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1396 0, 0, 0, 0, 0, 0, 0, 0, 0,
1397 /* T25 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001398 1, 0, 60, 115, 156, 99,
Jing Lin21ed4de2012-02-05 15:53:28 -08001399 /* T27 Object */
1400 0, 0, 0, 0, 0, 0, 0,
1401 /* T40 Object */
1402 0, 0, 0, 0, 0,
1403 /* T42 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001404 0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001405 /* T43 Object */
1406 0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
1407 16,
1408 /* T46 Object */
Jing Linf1208fd2012-02-23 11:15:42 -08001409 68, 0, 16, 16, 0, 0, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001410 /* T47 Object */
1411 0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
1412 /* T48 Object */
Jing Lin943fcec2012-05-25 13:58:57 -07001413 1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001414 32, 40, 0, 10, 10, 0, 0, 100, 10, 90,
1415 0, 0, 0, 0, 0, 0, 0, 10, 1, 10,
1416 52, 10, 12, 0, 33, 0, 1, 0, 0, 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001417 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1418 0, 0, 0, 0,
1419 /* T56 Object */
1420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1421 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1422 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Jing Linf1208fd2012-02-23 11:15:42 -08001424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1425 0,
Jing Lin21ed4de2012-02-05 15:53:28 -08001426};
1427
1428#define MXT_TS_GPIO_IRQ 6
1429#define MXT_TS_PWR_EN_GPIO PM8921_GPIO_PM_TO_SYS(23)
1430#define MXT_TS_RESET_GPIO 33
1431
1432static struct mxt_config_info mxt_config_array[] = {
1433 {
1434 .config = mxt1386e_config_data_v2_1,
1435 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1436 .family_id = 0xA0,
1437 .variant_id = 0x7,
1438 .version = 0x21,
1439 .build = 0xAA,
Jing Linef4aa9b2012-03-26 12:01:41 -07001440 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
1441 .fw_name = "atmel_8064_liquid_v2_2_AA.hex",
1442 },
1443 {
1444 /* The config data for V2.2.AA is the same as for V2.1.AA */
1445 .config = mxt1386e_config_data_v2_1,
1446 .config_length = ARRAY_SIZE(mxt1386e_config_data_v2_1),
1447 .family_id = 0xA0,
1448 .variant_id = 0x7,
1449 .version = 0x22,
1450 .build = 0xAA,
1451 .bootldr_id = MXT_BOOTLOADER_ID_1386E,
Jing Lin21ed4de2012-02-05 15:53:28 -08001452 },
1453};
1454
1455static struct mxt_platform_data mxt_platform_data = {
1456 .config_array = mxt_config_array,
1457 .config_array_size = ARRAY_SIZE(mxt_config_array),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08001458 .panel_minx = 0,
1459 .panel_maxx = 1365,
1460 .panel_miny = 0,
1461 .panel_maxy = 767,
1462 .disp_minx = 0,
1463 .disp_maxx = 1365,
1464 .disp_miny = 0,
1465 .disp_maxy = 767,
Anirudh Ghayal39dbe3f2012-04-13 15:43:16 +05301466 .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Jing Lin21ed4de2012-02-05 15:53:28 -08001467 .i2c_pull_up = true,
1468 .reset_gpio = MXT_TS_RESET_GPIO,
1469 .irq_gpio = MXT_TS_GPIO_IRQ,
1470};
1471
1472static struct i2c_board_info mxt_device_info[] __initdata = {
1473 {
1474 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
1475 .platform_data = &mxt_platform_data,
1476 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
1477 },
1478};
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001479#define CYTTSP_TS_GPIO_IRQ 6
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001480#define CYTTSP_TS_GPIO_SLEEP 33
Amy Maloche609bb5e2012-08-03 09:41:42 -07001481#define CYTTSP_TS_GPIO_SLEEP_ALT 12
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001482
1483static ssize_t tma340_vkeys_show(struct kobject *kobj,
1484 struct kobj_attribute *attr, char *buf)
1485{
1486 return snprintf(buf, 200,
1487 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
1488 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
1489 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
1490 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
1491 "\n");
1492}
1493
1494static struct kobj_attribute tma340_vkeys_attr = {
1495 .attr = {
1496 .mode = S_IRUGO,
1497 },
1498 .show = &tma340_vkeys_show,
1499};
1500
1501static struct attribute *tma340_properties_attrs[] = {
1502 &tma340_vkeys_attr.attr,
1503 NULL
1504};
1505
1506static struct attribute_group tma340_properties_attr_group = {
1507 .attrs = tma340_properties_attrs,
1508};
1509
1510static int cyttsp_platform_init(struct i2c_client *client)
1511{
1512 int rc = 0;
1513 static struct kobject *tma340_properties_kobj;
1514
1515 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
1516 tma340_properties_kobj = kobject_create_and_add("board_properties",
1517 NULL);
1518 if (tma340_properties_kobj)
1519 rc = sysfs_create_group(tma340_properties_kobj,
1520 &tma340_properties_attr_group);
1521 if (!tma340_properties_kobj || rc)
1522 pr_err("%s: failed to create board_properties\n",
1523 __func__);
1524
1525 return 0;
1526}
1527
1528static struct cyttsp_regulator cyttsp_regulator_data[] = {
1529 {
1530 .name = "vdd",
1531 .min_uV = CY_TMA300_VTG_MIN_UV,
1532 .max_uV = CY_TMA300_VTG_MAX_UV,
1533 .hpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1534 .lpm_load_uA = CY_TMA300_CURR_24HZ_UA,
1535 },
1536 {
1537 .name = "vcc_i2c",
1538 .min_uV = CY_I2C_VTG_MIN_UV,
1539 .max_uV = CY_I2C_VTG_MAX_UV,
1540 .hpm_load_uA = CY_I2C_CURR_UA,
1541 .lpm_load_uA = CY_I2C_CURR_UA,
1542 },
1543};
1544
1545static struct cyttsp_platform_data cyttsp_pdata = {
1546 .panel_maxx = 634,
1547 .panel_maxy = 1166,
1548 .disp_maxx = 599,
1549 .disp_maxy = 1023,
1550 .disp_minx = 0,
1551 .disp_miny = 0,
1552 .flags = 0x01,
1553 .gen = CY_GEN3,
1554 .use_st = CY_USE_ST,
1555 .use_mt = CY_USE_MT,
1556 .use_hndshk = CY_SEND_HNDSHK,
1557 .use_trk_id = CY_USE_TRACKING_ID,
1558 .use_sleep = CY_USE_DEEP_SLEEP_SEL,
1559 .use_gestures = CY_USE_GESTURES,
1560 .fw_fname = "cyttsp_8064_mtp.hex",
1561 /* change act_intrvl to customize the Active power state
1562 * scanning/processing refresh interval for Operating mode
1563 */
1564 .act_intrvl = CY_ACT_INTRVL_DFLT,
1565 /* change tch_tmout to customize the touch timeout for the
1566 * Active power state for Operating mode
1567 */
1568 .tch_tmout = CY_TCH_TMOUT_DFLT,
1569 /* change lp_intrvl to customize the Low Power power state
1570 * scanning/processing refresh interval for Operating mode
1571 */
1572 .lp_intrvl = CY_LP_INTRVL_DFLT,
1573 .sleep_gpio = CYTTSP_TS_GPIO_SLEEP,
Amy Maloche9ba3ffe2012-04-26 10:31:20 -07001574 .resout_gpio = -1,
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08001575 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
1576 .regulator_info = cyttsp_regulator_data,
1577 .num_regulators = ARRAY_SIZE(cyttsp_regulator_data),
1578 .init = cyttsp_platform_init,
1579 .correct_fw_ver = 17,
1580};
1581
1582static struct i2c_board_info cyttsp_info[] __initdata = {
1583 {
1584 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
1585 .platform_data = &cyttsp_pdata,
1586 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
1587 },
1588};
Jing Lin21ed4de2012-02-05 15:53:28 -08001589
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08001590#define MSM_WCNSS_PHYS 0x03000000
1591#define MSM_WCNSS_SIZE 0x280000
1592
1593static struct resource resources_wcnss_wlan[] = {
1594 {
1595 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1596 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1597 .name = "wcnss_wlanrx_irq",
1598 .flags = IORESOURCE_IRQ,
1599 },
1600 {
1601 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1602 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1603 .name = "wcnss_wlantx_irq",
1604 .flags = IORESOURCE_IRQ,
1605 },
1606 {
1607 .start = MSM_WCNSS_PHYS,
1608 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1609 .name = "wcnss_mmio",
1610 .flags = IORESOURCE_MEM,
1611 },
1612 {
1613 .start = 64,
1614 .end = 68,
1615 .name = "wcnss_gpios_5wire",
1616 .flags = IORESOURCE_IO,
1617 },
1618};
1619
1620static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1621 .has_48mhz_xo = 1,
1622};
1623
1624static struct platform_device msm_device_wcnss_wlan = {
1625 .name = "wcnss_wlan",
1626 .id = 0,
1627 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1628 .resource = resources_wcnss_wlan,
1629 .dev = {.platform_data = &qcom_wcnss_pdata},
1630};
1631
Ankit Vermab7c26e62012-02-28 15:04:15 -08001632static struct platform_device msm_device_iris_fm __devinitdata = {
1633 .name = "iris_fm",
1634 .id = -1,
1635};
1636
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07001637#ifdef CONFIG_QSEECOM
1638/* qseecom bus scaling */
1639static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
1640 {
1641 .src = MSM_BUS_MASTER_SPS,
1642 .dst = MSM_BUS_SLAVE_EBI_CH0,
1643 .ib = 0,
1644 .ab = 0,
1645 },
1646 {
1647 .src = MSM_BUS_MASTER_SPDM,
1648 .dst = MSM_BUS_SLAVE_SPDM,
1649 .ib = 0,
1650 .ab = 0,
1651 },
1652};
1653
1654static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
1655 {
1656 .src = MSM_BUS_MASTER_SPS,
1657 .dst = MSM_BUS_SLAVE_EBI_CH0,
1658 .ib = (492 * 8) * 1000000UL,
1659 .ab = (492 * 8) * 100000UL,
1660 },
1661 {
1662 .src = MSM_BUS_MASTER_SPDM,
1663 .dst = MSM_BUS_SLAVE_SPDM,
1664 .ib = 0,
1665 .ab = 0,
1666 },
1667};
1668
1669static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
1670 {
1671 .src = MSM_BUS_MASTER_SPS,
1672 .dst = MSM_BUS_SLAVE_EBI_CH0,
1673 .ib = 0,
1674 .ab = 0,
1675 },
1676 {
1677 .src = MSM_BUS_MASTER_SPDM,
1678 .dst = MSM_BUS_SLAVE_SPDM,
1679 .ib = (64 * 8) * 1000000UL,
1680 .ab = (64 * 8) * 100000UL,
1681 },
1682};
1683
1684static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
1685 {
1686 ARRAY_SIZE(qseecom_clks_init_vectors),
1687 qseecom_clks_init_vectors,
1688 },
1689 {
1690 ARRAY_SIZE(qseecom_enable_dfab_vectors),
1691 qseecom_enable_sfpb_vectors,
1692 },
1693 {
1694 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
1695 qseecom_enable_sfpb_vectors,
1696 },
1697};
1698
1699static struct msm_bus_scale_pdata qseecom_bus_pdata = {
1700 qseecom_hw_bus_scale_usecases,
1701 ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
1702 .name = "qsee",
1703};
1704
1705static struct platform_device qseecom_device = {
1706 .name = "qseecom",
1707 .id = 0,
1708 .dev = {
1709 .platform_data = &qseecom_bus_pdata,
1710 },
1711};
1712#endif
1713
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001714#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1715 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1716 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1717 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1718
1719#define QCE_SIZE 0x10000
1720#define QCE_0_BASE 0x11000000
1721
1722#define QCE_HW_KEY_SUPPORT 0
1723#define QCE_SHA_HMAC_SUPPORT 1
1724#define QCE_SHARE_CE_RESOURCE 3
1725#define QCE_CE_SHARED 0
1726
1727static struct resource qcrypto_resources[] = {
1728 [0] = {
1729 .start = QCE_0_BASE,
1730 .end = QCE_0_BASE + QCE_SIZE - 1,
1731 .flags = IORESOURCE_MEM,
1732 },
1733 [1] = {
1734 .name = "crypto_channels",
1735 .start = DMOV8064_CE_IN_CHAN,
1736 .end = DMOV8064_CE_OUT_CHAN,
1737 .flags = IORESOURCE_DMA,
1738 },
1739 [2] = {
1740 .name = "crypto_crci_in",
1741 .start = DMOV8064_CE_IN_CRCI,
1742 .end = DMOV8064_CE_IN_CRCI,
1743 .flags = IORESOURCE_DMA,
1744 },
1745 [3] = {
1746 .name = "crypto_crci_out",
1747 .start = DMOV8064_CE_OUT_CRCI,
1748 .end = DMOV8064_CE_OUT_CRCI,
1749 .flags = IORESOURCE_DMA,
1750 },
1751};
1752
1753static struct resource qcedev_resources[] = {
1754 [0] = {
1755 .start = QCE_0_BASE,
1756 .end = QCE_0_BASE + QCE_SIZE - 1,
1757 .flags = IORESOURCE_MEM,
1758 },
1759 [1] = {
1760 .name = "crypto_channels",
1761 .start = DMOV8064_CE_IN_CHAN,
1762 .end = DMOV8064_CE_OUT_CHAN,
1763 .flags = IORESOURCE_DMA,
1764 },
1765 [2] = {
1766 .name = "crypto_crci_in",
1767 .start = DMOV8064_CE_IN_CRCI,
1768 .end = DMOV8064_CE_IN_CRCI,
1769 .flags = IORESOURCE_DMA,
1770 },
1771 [3] = {
1772 .name = "crypto_crci_out",
1773 .start = DMOV8064_CE_OUT_CRCI,
1774 .end = DMOV8064_CE_OUT_CRCI,
1775 .flags = IORESOURCE_DMA,
1776 },
1777};
1778
1779#endif
1780
1781#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1782 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1783
1784static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1785 .ce_shared = QCE_CE_SHARED,
1786 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1787 .hw_key_support = QCE_HW_KEY_SUPPORT,
1788 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001789 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001790};
1791
1792static struct platform_device qcrypto_device = {
1793 .name = "qcrypto",
1794 .id = 0,
1795 .num_resources = ARRAY_SIZE(qcrypto_resources),
1796 .resource = qcrypto_resources,
1797 .dev = {
1798 .coherent_dma_mask = DMA_BIT_MASK(32),
1799 .platform_data = &qcrypto_ce_hw_suppport,
1800 },
1801};
1802#endif
1803
1804#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1805 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1806
1807static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1808 .ce_shared = QCE_CE_SHARED,
1809 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1810 .hw_key_support = QCE_HW_KEY_SUPPORT,
1811 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08001812 .bus_scale_table = NULL,
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001813};
1814
1815static struct platform_device qcedev_device = {
1816 .name = "qce",
1817 .id = 0,
1818 .num_resources = ARRAY_SIZE(qcedev_resources),
1819 .resource = qcedev_resources,
1820 .dev = {
1821 .coherent_dma_mask = DMA_BIT_MASK(32),
1822 .platform_data = &qcedev_ce_hw_suppport,
1823 },
1824};
1825#endif
1826
Joel Kingef390842012-05-23 16:42:48 -07001827static struct mdm_vddmin_resource mdm_vddmin_rscs = {
1828 .rpm_id = MSM_RPM_ID_VDDMIN_GPIO,
1829 .ap2mdm_vddmin_gpio = 30,
1830 .modes = 0x03,
1831 .drive_strength = 8,
1832 .mdm2ap_vddmin_gpio = 80,
1833};
1834
Joel King269aa602012-07-23 08:07:35 -07001835static struct gpiomux_setting mdm2ap_status_gpio_run_cfg = {
1836 .func = GPIOMUX_FUNC_GPIO,
1837 .drv = GPIOMUX_DRV_8MA,
1838 .pull = GPIOMUX_PULL_NONE,
1839};
1840
Joel Kingdacbc822012-01-25 13:30:57 -08001841static struct mdm_platform_data mdm_platform_data = {
1842 .mdm_version = "3.0",
1843 .ramdump_delay_ms = 2000,
Joel King14fe7fa2012-05-27 14:26:11 -07001844 .early_power_on = 1,
1845 .sfr_query = 1,
Joel Kingef390842012-05-23 16:42:48 -07001846 .vddmin_resource = &mdm_vddmin_rscs,
Hemant Kumara945b472012-01-25 15:08:06 -08001847 .peripheral_platform_device = &apq8064_device_hsic_host,
Ameya Thakurc9a7a842012-06-24 22:47:52 -07001848 .ramdump_timeout_ms = 120000,
Joel King269aa602012-07-23 08:07:35 -07001849 .mdm2ap_status_gpio_run_cfg = &mdm2ap_status_gpio_run_cfg,
Joel Kingdacbc822012-01-25 13:30:57 -08001850};
Ramesh Masavarapu28311912011-10-27 11:04:12 -07001851
Siddartha Mohanadosscaeaa922012-02-07 16:41:38 -08001852static struct tsens_platform_data apq_tsens_pdata = {
1853 .tsens_factor = 1000,
1854 .hw_type = APQ_8064,
1855 .tsens_num_sensor = 11,
1856 .slope = {1176, 1176, 1154, 1176, 1111,
1857 1132, 1132, 1199, 1132, 1199, 1132},
1858};
1859
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07001860static struct platform_device msm_tsens_device = {
1861 .name = "tsens8960-tm",
1862 .id = -1,
1863};
1864
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001865static struct msm_thermal_data msm_thermal_pdata = {
1866 .sensor_id = 7,
Eugene Seah2ee4a5d2012-06-25 18:16:41 -06001867 .poll_ms = 250,
1868 .limit_temp_degC = 60,
1869 .temp_hysteresis_degC = 10,
1870 .freq_step = 2,
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06001871};
1872
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001873#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001874static void __init apq8064_map_io(void)
1875{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06001876 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001877 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07001878 if (socinfo_init() < 0)
1879 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001880}
1881
1882static void __init apq8064_init_irq(void)
1883{
Praveen Chidambaram78499012011-11-01 17:15:17 -06001884 struct msm_mpm_device_data *data = NULL;
1885
1886#ifdef CONFIG_MSM_MPM
1887 data = &apq8064_mpm_dev_data;
1888#endif
1889
1890 msm_mpm_irq_extn_init(data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
1892 (void *)MSM_QGIC_CPU_BASE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893}
1894
Abhishek Kharbanda72dc72e2012-06-07 13:41:37 -07001895static struct msm_mhl_platform_data mhl_platform_data = {
1896 .irq = MSM_GPIO_TO_INT(MHL_GPIO_INT),
1897 .gpio_mhl_int = MHL_GPIO_INT,
1898 .gpio_mhl_reset = MHL_GPIO_RESET,
1899 .gpio_mhl_power = 0,
1900 .gpio_hdmi_mhl_mux = 0,
1901};
1902
1903static struct i2c_board_info sii_device_info[] __initdata = {
1904 {
1905 /*
1906 * keeps SI 8334 as the default
1907 * MHL TX
1908 */
1909 I2C_BOARD_INFO("sii8334", 0x39),
1910 .platform_data = &mhl_platform_data,
1911 .flags = I2C_CLIENT_WAKE,
1912 },
1913};
1914
Jay Chokshi7805b5a2011-11-07 15:55:30 -08001915static struct platform_device msm8064_device_saw_regulator_core0 = {
1916 .name = "saw-regulator",
1917 .id = 0,
1918 .dev = {
1919 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
1920 },
1921};
1922
1923static struct platform_device msm8064_device_saw_regulator_core1 = {
1924 .name = "saw-regulator",
1925 .id = 1,
1926 .dev = {
1927 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
1928 },
1929};
1930
1931static struct platform_device msm8064_device_saw_regulator_core2 = {
1932 .name = "saw-regulator",
1933 .id = 2,
1934 .dev = {
1935 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
1936 },
1937};
1938
1939static struct platform_device msm8064_device_saw_regulator_core3 = {
1940 .name = "saw-regulator",
1941 .id = 3,
1942 .dev = {
1943 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001944
1945 },
1946};
1947
Oluwafemi Adeyemif5a31422012-03-08 16:58:45 -08001948static struct msm_rpmrs_level msm_rpmrs_levels[] = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001949 {
1950 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
1951 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1952 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001953 1, 784, 180000, 100,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001954 },
1955
1956 {
Girish Mahadevan3bc98772012-08-15 10:01:27 -06001957 MSM_PM_SLEEP_MODE_RETENTION,
1958 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1959 true,
1960 415, 715, 340827, 475,
1961 },
1962
1963 {
Praveen Chidambaram78499012011-11-01 17:15:17 -06001964 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
1965 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
1966 true,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001967 1300, 228, 1200000, 2000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001968 },
1969
1970 {
1971 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1972 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
1973 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001974 2000, 138, 1208400, 3200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001975 },
1976
1977 {
1978 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
Praveen Chidambarame3380672012-02-08 10:32:27 -07001979 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
1980 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001981 6000, 119, 1850300, 9000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001982 },
1983
1984 {
1985 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1986 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
1987 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001988 9200, 68, 2839200, 16400,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001989 },
1990
1991 {
1992 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
1993 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
1994 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06001995 10300, 63, 3128000, 18200,
Praveen Chidambaram78499012011-11-01 17:15:17 -06001996 },
1997
1998 {
1999 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2000 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
2001 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002002 18000, 10, 4602600, 27000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002003 },
2004
2005 {
2006 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
2007 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
2008 false,
Girish Mahadevan9bf71562012-04-13 14:41:44 -06002009 20000, 2, 5752000, 32000,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002010 },
2011};
2012
2013static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2014 .mode = MSM_PM_BOOT_CONFIG_TZ,
2015};
2016
2017static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
2018 .levels = &msm_rpmrs_levels[0],
2019 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
2020 .vdd_mem_levels = {
2021 [MSM_RPMRS_VDD_MEM_RET_LOW] = 750000,
2022 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750000,
2023 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1050000,
2024 [MSM_RPMRS_VDD_MEM_MAX] = 1150000,
2025 },
2026 .vdd_dig_levels = {
2027 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500000,
2028 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750000,
2029 [MSM_RPMRS_VDD_DIG_ACTIVE] = 950000,
2030 [MSM_RPMRS_VDD_DIG_MAX] = 1150000,
2031 },
2032 .vdd_mask = 0x7FFFFF,
2033 .rpmrs_target_id = {
2034 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
2035 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_LAST,
2036 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_PM8921_S3_0,
2037 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_PM8921_S3_1,
2038 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_PM8921_L24_0,
2039 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_PM8921_L24_1,
2040 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_RPM_CTL,
2041 },
2042};
2043
Praveen Chidambaram78499012011-11-01 17:15:17 -06002044static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2045 0x03, 0x0f,
2046};
2047
2048static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2049 0x00, 0x24, 0x54, 0x10,
2050 0x09, 0x03, 0x01,
2051 0x10, 0x54, 0x30, 0x0C,
2052 0x24, 0x30, 0x0f,
2053};
2054
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002055static uint8_t spm_retention_cmd_sequence[] __initdata = {
2056 0x00, 0x05, 0x03, 0x0D,
2057 0x0B, 0x00, 0x0f,
2058};
2059
Praveen Chidambaram78499012011-11-01 17:15:17 -06002060static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2061 0x00, 0x24, 0x54, 0x10,
2062 0x09, 0x07, 0x01, 0x0B,
2063 0x10, 0x54, 0x30, 0x0C,
2064 0x24, 0x30, 0x0f,
2065};
2066
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002067static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
2068 [0] = {
2069 .mode = MSM_SPM_MODE_CLOCK_GATING,
2070 .notify_rpm = false,
2071 .cmd = spm_wfi_cmd_sequence,
2072 },
2073 [1] = {
2074 .mode = MSM_SPM_MODE_POWER_RETENTION,
2075 .notify_rpm = false,
2076 .cmd = spm_retention_cmd_sequence,
2077 },
2078 [2] = {
2079 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2080 .notify_rpm = false,
2081 .cmd = spm_power_collapse_without_rpm,
2082 },
2083 [3] = {
2084 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2085 .notify_rpm = true,
2086 .cmd = spm_power_collapse_with_rpm,
2087 },
2088};
2089static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
Praveen Chidambaram78499012011-11-01 17:15:17 -06002090 [0] = {
2091 .mode = MSM_SPM_MODE_CLOCK_GATING,
2092 .notify_rpm = false,
2093 .cmd = spm_wfi_cmd_sequence,
2094 },
2095 [1] = {
2096 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2097 .notify_rpm = false,
2098 .cmd = spm_power_collapse_without_rpm,
2099 },
2100 [2] = {
2101 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2102 .notify_rpm = true,
2103 .cmd = spm_power_collapse_with_rpm,
2104 },
2105};
2106
2107static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2108 0x00, 0x20, 0x03, 0x20,
2109 0x00, 0x0f,
2110};
2111
2112static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2113 0x00, 0x20, 0x34, 0x64,
2114 0x48, 0x07, 0x48, 0x20,
2115 0x50, 0x64, 0x04, 0x34,
2116 0x50, 0x0f,
2117};
2118static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2119 0x00, 0x10, 0x34, 0x64,
2120 0x48, 0x07, 0x48, 0x10,
2121 0x50, 0x64, 0x04, 0x34,
2122 0x50, 0x0F,
2123};
2124
2125static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2126 [0] = {
2127 .mode = MSM_SPM_L2_MODE_RETENTION,
2128 .notify_rpm = false,
2129 .cmd = l2_spm_wfi_cmd_sequence,
2130 },
2131 [1] = {
2132 .mode = MSM_SPM_L2_MODE_GDHS,
2133 .notify_rpm = true,
2134 .cmd = l2_spm_gdhs_cmd_sequence,
2135 },
2136 [2] = {
2137 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2138 .notify_rpm = true,
2139 .cmd = l2_spm_power_off_cmd_sequence,
2140 },
2141};
2142
2143
2144static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2145 [0] = {
2146 .reg_base_addr = MSM_SAW_L2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002147 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002148 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002149 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2150 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2151 .modes = msm_spm_l2_seq_list,
2152 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2153 },
2154};
2155
2156static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2157 [0] = {
2158 .reg_base_addr = MSM_SAW0_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002159 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002160#if defined(CONFIG_MSM_AVS_HW)
2161 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2162 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2163#endif
2164 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002165 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
2166 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
2167 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002168 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002169 .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
2170 .modes = msm_spm_boot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002171 },
2172 [1] = {
2173 .reg_base_addr = MSM_SAW1_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002174 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002175#if defined(CONFIG_MSM_AVS_HW)
2176 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2177 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2178#endif
2179 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002180 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002181 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2182 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2183 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002184 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2185 .modes = msm_spm_nonboot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002186 },
2187 [2] = {
2188 .reg_base_addr = MSM_SAW2_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002189 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002190#if defined(CONFIG_MSM_AVS_HW)
2191 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2192 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2193#endif
2194 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002195 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002196 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2197 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2198 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002199 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2200 .modes = msm_spm_nonboot_cpu_seq_list,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002201 },
2202 [3] = {
2203 .reg_base_addr = MSM_SAW3_BASE,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002204 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002205#if defined(CONFIG_MSM_AVS_HW)
2206 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2207 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2208#endif
2209 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
Praveen Chidambarame4b9eb12012-02-28 19:39:58 -07002210 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002211 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2212 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2213 .vctl_timeout_us = 50,
Girish Mahadevan3bc98772012-08-15 10:01:27 -06002214 .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
2215 .modes = msm_spm_nonboot_cpu_seq_list,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002216 },
2217};
2218
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002219static void __init apq8064_init_buses(void)
2220{
2221 msm_bus_rpm_set_mt_mask();
2222 msm_bus_8064_apps_fabric_pdata.rpm_enabled = 1;
2223 msm_bus_8064_sys_fabric_pdata.rpm_enabled = 1;
2224 msm_bus_8064_mm_fabric_pdata.rpm_enabled = 1;
2225 msm_bus_8064_apps_fabric.dev.platform_data =
2226 &msm_bus_8064_apps_fabric_pdata;
2227 msm_bus_8064_sys_fabric.dev.platform_data =
2228 &msm_bus_8064_sys_fabric_pdata;
2229 msm_bus_8064_mm_fabric.dev.platform_data =
2230 &msm_bus_8064_mm_fabric_pdata;
2231 msm_bus_8064_sys_fpb.dev.platform_data = &msm_bus_8064_sys_fpb_pdata;
2232 msm_bus_8064_cpss_fpb.dev.platform_data = &msm_bus_8064_cpss_fpb_pdata;
2233}
2234
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002235/* PCIe gpios */
2236static struct msm_pcie_gpio_info_t msm_pcie_gpio_info[MSM_PCIE_MAX_GPIO] = {
2237 {"rst_n", PM8921_MPP_PM_TO_SYS(PCIE_RST_N_PMIC_MPP), 0},
2238 {"pwr_en", PM8921_GPIO_PM_TO_SYS(PCIE_PWR_EN_PMIC_GPIO), 1},
2239};
2240
2241static struct msm_pcie_platform msm_pcie_platform_data = {
2242 .gpio = msm_pcie_gpio_info,
Niranjana Vishwanathapura68210ff2012-06-24 18:03:49 -06002243 .axi_addr = PCIE_AXI_BAR_PHYS,
2244 .axi_size = PCIE_AXI_BAR_SIZE,
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -06002245 .wake_n = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, PCIE_WAKE_N_PMIC_GPIO),
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002246};
2247
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002248static int __init mpq8064_pcie_enabled(void)
2249{
2250 return !((readl_relaxed(QFPROM_RAW_FEAT_CONFIG_ROW0_MSB) & BIT(21)) ||
2251 (readl_relaxed(QFPROM_RAW_OEM_CONFIG_ROW0_LSB) & BIT(4)));
2252}
2253
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002254static void __init mpq8064_pcie_init(void)
2255{
Niranjana Vishwanathapurac1edd402012-06-28 15:32:50 -06002256 if (mpq8064_pcie_enabled()) {
2257 msm_device_pcie.dev.platform_data = &msm_pcie_platform_data;
2258 platform_device_register(&msm_device_pcie);
2259 }
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06002260}
2261
David Collinsf0d00732012-01-25 15:46:50 -08002262static struct platform_device apq8064_device_ext_5v_vreg __devinitdata = {
2263 .name = GPIO_REGULATOR_DEV_NAME,
2264 .id = PM8921_MPP_PM_TO_SYS(7),
2265 .dev = {
2266 .platform_data
2267 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2268 },
2269};
2270
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002271static struct platform_device apq8064_device_ext_mpp8_vreg __devinitdata = {
2272 .name = GPIO_REGULATOR_DEV_NAME,
2273 .id = PM8921_MPP_PM_TO_SYS(8),
2274 .dev = {
2275 .platform_data
2276 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_MPP8],
2277 },
2278};
2279
David Collinsf0d00732012-01-25 15:46:50 -08002280static struct platform_device apq8064_device_ext_3p3v_vreg __devinitdata = {
2281 .name = GPIO_REGULATOR_DEV_NAME,
2282 .id = APQ8064_EXT_3P3V_REG_EN_GPIO,
2283 .dev = {
2284 .platform_data =
2285 &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2286 },
2287};
2288
David Collins390fc332012-02-07 14:38:16 -08002289static struct platform_device apq8064_device_ext_ts_sw_vreg __devinitdata = {
2290 .name = GPIO_REGULATOR_DEV_NAME,
2291 .id = PM8921_GPIO_PM_TO_SYS(23),
2292 .dev = {
2293 .platform_data
2294 = &apq8064_gpio_regulator_pdata[GPIO_VREG_ID_EXT_TS_SW],
2295 },
2296};
2297
David Collins2782b5c2012-02-06 10:02:42 -08002298static struct platform_device apq8064_device_rpm_regulator __devinitdata = {
2299 .name = "rpm-regulator",
David Collins793793b2012-08-21 15:43:02 -07002300 .id = 0,
David Collins2782b5c2012-02-06 10:02:42 -08002301 .dev = {
2302 .platform_data = &apq8064_rpm_regulator_pdata,
2303 },
2304};
2305
David Collins793793b2012-08-21 15:43:02 -07002306static struct platform_device
2307apq8064_pm8921_device_rpm_regulator __devinitdata = {
2308 .name = "rpm-regulator",
2309 .id = 1,
2310 .dev = {
2311 .platform_data = &apq8064_rpm_regulator_pm8921_pdata,
2312 },
2313};
2314
Ravi Kumar V05931a22012-04-04 17:09:37 +05302315static struct gpio_ir_recv_platform_data gpio_ir_recv_pdata = {
2316 .gpio_nr = 88,
2317 .active_low = 1,
2318};
2319
2320static struct platform_device gpio_ir_recv_pdev = {
2321 .name = "gpio-rc-recv",
2322 .dev = {
2323 .platform_data = &gpio_ir_recv_pdata,
2324 },
2325};
2326
Terence Hampson36b70722012-05-10 13:18:16 -04002327static struct platform_device *common_not_mpq_devices[] __initdata = {
David Keitel3c40fc52012-02-09 17:53:52 -08002328 &apq8064_device_qup_i2c_gsbi1,
Jing Lin04601f92012-02-05 15:36:07 -08002329 &apq8064_device_qup_i2c_gsbi3,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002330 &apq8064_device_qup_i2c_gsbi4,
Terence Hampson36b70722012-05-10 13:18:16 -04002331};
2332
Kuirong Wangf8c5e142012-06-21 16:17:32 -07002333static struct platform_device *common_mpq_devices[] __initdata = {
2334 &mpq_cpudai_sec_i2s_rx,
2335 &mpq_cpudai_mi2s_tx,
2336};
2337
2338static struct platform_device *common_i2s_devices[] __initdata = {
2339 &apq_cpudai_mi2s,
2340 &apq_cpudai_i2s_rx,
2341 &apq_cpudai_i2s_tx,
2342};
2343
David Collins793793b2012-08-21 15:43:02 -07002344static struct platform_device *early_common_devices[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -07002345 &apq8064_device_acpuclk,
Terence Hampson36b70722012-05-10 13:18:16 -04002346 &apq8064_device_dmov,
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002347 &apq8064_device_qup_spi_gsbi5,
David Collins793793b2012-08-21 15:43:02 -07002348};
2349
2350static struct platform_device *pm8921_common_devices[] __initdata = {
David Collinsf0d00732012-01-25 15:46:50 -08002351 &apq8064_device_ext_5v_vreg,
Jay Chokshi1de4f9d2012-02-07 16:11:31 -08002352 &apq8064_device_ext_mpp8_vreg,
David Collinsf0d00732012-01-25 15:46:50 -08002353 &apq8064_device_ext_3p3v_vreg,
Jay Chokshi9c25f072011-09-23 18:19:15 -07002354 &apq8064_device_ssbi_pmic1,
2355 &apq8064_device_ssbi_pmic2,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002356 &apq8064_device_ext_ts_sw_vreg,
David Collins793793b2012-08-21 15:43:02 -07002357};
2358
2359static struct platform_device *pm8917_common_devices[] __initdata = {
2360 &apq8064_device_ext_mpp8_vreg,
2361 &apq8064_device_ext_3p3v_vreg,
2362 &apq8064_device_ssbi_pmic1,
2363 &apq8064_device_ssbi_pmic2,
2364 &apq8064_device_ext_ts_sw_vreg,
2365};
2366
2367static struct platform_device *common_devices[] __initdata = {
Jeff Hugo0c0f5e92011-09-28 13:55:45 -06002368 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -07002369 &apq8064_device_otg,
2370 &apq8064_device_gadget_peripheral,
Hemant Kumard86c4882012-01-24 19:39:37 -08002371 &apq8064_device_hsusb_host,
Hemant Kumar4933b072011-10-17 23:43:11 -07002372 &android_usb_device,
Ankit Verma6b7e2ba2012-01-26 15:48:54 -08002373 &msm_device_wcnss_wlan,
Ankit Vermab7c26e62012-02-28 15:04:15 -08002374 &msm_device_iris_fm,
Larry Bassel67b921d2012-04-06 10:23:27 -07002375 &apq8064_fmem_device,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002376#ifdef CONFIG_ANDROID_PMEM
2377#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbottb93525f2012-04-12 09:57:19 -07002378 &apq8064_android_pmem_device,
2379 &apq8064_android_pmem_adsp_device,
2380 &apq8064_android_pmem_audio_device,
Bharath Ramachandramurthy4a3fa912012-03-13 19:16:24 -07002381#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2382#endif /*CONFIG_ANDROID_PMEM*/
Olav Haugan7c6aa742012-01-16 16:47:37 -08002383#ifdef CONFIG_ION_MSM
Laura Abbottb93525f2012-04-12 09:57:19 -07002384 &apq8064_ion_dev,
Olav Haugan7c6aa742012-01-16 16:47:37 -08002385#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07002386 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -08002387 &msm8064_device_saw_regulator_core0,
2388 &msm8064_device_saw_regulator_core1,
2389 &msm8064_device_saw_regulator_core2,
2390 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapua26cce72012-04-09 12:32:25 -07002391#if defined(CONFIG_QSEECOM)
2392 &qseecom_device,
2393#endif
2394
Joel Nider6b9a7bc2012-06-26 11:19:19 +03002395 &msm_8064_device_tsif[0],
2396 &msm_8064_device_tsif[1],
2397
Ramesh Masavarapu28311912011-10-27 11:04:12 -07002398#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2399 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2400 &qcrypto_device,
2401#endif
2402
2403#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2404 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2405 &qcedev_device,
2406#endif
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07002407
2408#ifdef CONFIG_HW_RANDOM_MSM
2409 &apq8064_device_rng,
2410#endif
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002411 &apq_pcm,
2412 &apq_pcm_routing,
2413 &apq_cpudai0,
2414 &apq_cpudai1,
2415 &apq_cpudai_hdmi_rx,
2416 &apq_cpudai_bt_rx,
2417 &apq_cpudai_bt_tx,
2418 &apq_cpudai_fm_rx,
2419 &apq_cpudai_fm_tx,
2420 &apq_cpu_fe,
2421 &apq_stub_codec,
2422 &apq_voice,
2423 &apq_voip,
2424 &apq_lpa_pcm,
Krishnankutty Kolathappilly4374e332012-03-18 22:27:30 -07002425 &apq_compr_dsp,
2426 &apq_multi_ch_pcm,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07002427 &apq_lowlatency_pcm,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002428 &apq_pcm_hostless,
2429 &apq_cpudai_afe_01_rx,
2430 &apq_cpudai_afe_01_tx,
2431 &apq_cpudai_afe_02_rx,
2432 &apq_cpudai_afe_02_tx,
2433 &apq_pcm_afe,
2434 &apq_cpudai_auxpcm_rx,
2435 &apq_cpudai_auxpcm_tx,
Neema Shetty8427c262012-02-16 11:23:43 -08002436 &apq_cpudai_stub,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002437 &apq_cpudai_slimbus_1_rx,
2438 &apq_cpudai_slimbus_1_tx,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002439 &apq_cpudai_slimbus_2_rx,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002440 &apq_cpudai_slimbus_2_tx,
Neema Shettyc9d86c32012-05-09 12:01:39 -07002441 &apq_cpudai_slimbus_3_rx,
Helen Zeng38c3c962012-05-17 14:56:20 -07002442 &apq_cpudai_slimbus_3_tx,
Praveen Chidambaram78499012011-11-01 17:15:17 -06002443 &apq8064_rpm_device,
2444 &apq8064_rpm_log_device,
2445 &apq8064_rpm_stat_device,
Ramesh Masavarapuf31ff242012-05-10 18:55:21 -07002446 &apq_device_tz_log,
Gagan Mac8a7a5d32011-11-11 16:43:06 -07002447 &msm_bus_8064_apps_fabric,
2448 &msm_bus_8064_sys_fabric,
2449 &msm_bus_8064_mm_fabric,
2450 &msm_bus_8064_sys_fpb,
2451 &msm_bus_8064_cpss_fpb,
Mohan Kumar Gubbihalli Lachma Naik7f72edd2012-02-06 17:26:47 -08002452 &apq8064_msm_device_vidc,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002453 &msm_pil_dsps,
Matt Wagantallb94b9a52012-02-02 21:59:54 -08002454 &msm_8960_q6_lpass,
Stephen Boyd7b973de2012-03-09 12:26:16 -08002455 &msm_pil_vidc,
Matt Wagantall292aace2012-01-26 19:12:34 -08002456 &msm_gss,
Laura Abbottb93525f2012-04-12 09:57:19 -07002457 &apq8064_rtb_device,
Praveen Chidambaram8ea3dcd2011-12-07 14:46:31 -07002458 &apq8064_cpu_idle_device,
Stepan Moskovchenko28662c52012-03-01 12:48:45 -08002459 &apq8064_device_cache_erp,
Stepan Moskovchenko0f3de112012-06-08 18:11:46 -07002460 &msm8960_device_ebi1_ch0_erp,
2461 &msm8960_device_ebi1_ch1_erp,
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002462 &epm_adc_device,
Pratik Patel3b0ca882012-06-01 16:54:14 -07002463 &coresight_tpiu_device,
2464 &coresight_etb_device,
2465 &apq8064_coresight_funnel_device,
2466 &coresight_etm0_device,
2467 &coresight_etm1_device,
2468 &coresight_etm2_device,
2469 &coresight_etm3_device,
Helen Zeng8f925502012-03-05 16:50:17 -08002470 &apq_cpudai_slim_4_rx,
2471 &apq_cpudai_slim_4_tx,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002472#ifdef CONFIG_MSM_GEMINI
Jignesh Mehta921649d2012-04-19 06:57:23 -07002473 &msm8960_gemini_device,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002474#endif
Laura Abbott0577d7b2012-04-17 11:14:30 -07002475 &apq8064_iommu_domain_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -07002476 &msm_tsens_device,
Laura Abbott93a4a352012-05-25 09:26:35 -07002477 &apq8064_cache_dump_device,
Joel Nider0e4a16d2012-08-05 14:20:11 +03002478 &msm_8064_device_tspp,
Binqiang Qiuf165c922012-08-15 18:00:18 -07002479#ifdef CONFIG_BATTERY_BCL
2480 &battery_bcl_device,
2481#endif
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002482};
2483
Joel King82b7e3f2012-01-05 10:03:27 -08002484static struct platform_device *cdp_devices[] __initdata = {
2485 &apq8064_device_uart_gsbi1,
Jin Hong4bbbfba2012-02-02 21:48:07 -08002486 &apq8064_device_uart_gsbi7,
Joel King82b7e3f2012-01-05 10:03:27 -08002487 &msm_device_sps_apq8064,
Aravind Venkateswaran4ca27532012-02-16 14:27:05 -08002488#ifdef CONFIG_MSM_ROTATOR
2489 &msm_rotator_device,
2490#endif
Joel King82b7e3f2012-01-05 10:03:27 -08002491};
2492
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002493static struct platform_device
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002494mpq8064_device_ext_1p2_buck_vreg __devinitdata = {
2495 .name = GPIO_REGULATOR_DEV_NAME,
2496 .id = SX150X_GPIO(4, 2),
2497 .dev = {
2498 .platform_data =
2499 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P2V],
2500 },
2501};
2502
2503static struct platform_device
2504mpq8064_device_ext_1p8_buck_vreg __devinitdata = {
2505 .name = GPIO_REGULATOR_DEV_NAME,
2506 .id = SX150X_GPIO(4, 4),
2507 .dev = {
2508 .platform_data =
2509 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_1P8V],
2510 },
2511};
2512
2513static struct platform_device
2514mpq8064_device_ext_2p2_buck_vreg __devinitdata = {
2515 .name = GPIO_REGULATOR_DEV_NAME,
2516 .id = SX150X_GPIO(4, 14),
2517 .dev = {
2518 .platform_data =
2519 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_2P2V],
2520 },
2521};
2522
2523static struct platform_device
2524mpq8064_device_ext_5v_buck_vreg __devinitdata = {
2525 .name = GPIO_REGULATOR_DEV_NAME,
2526 .id = SX150X_GPIO(4, 3),
2527 .dev = {
2528 .platform_data =
2529 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_5V],
2530 },
2531};
2532
2533static struct platform_device
2534mpq8064_device_ext_3p3v_ldo_vreg __devinitdata = {
2535 .name = GPIO_REGULATOR_DEV_NAME,
2536 .id = SX150X_GPIO(4, 15),
2537 .dev = {
2538 .platform_data =
2539 &mpq8064_gpio_regulator_pdata[GPIO_VREG_ID_AVC_3P3V],
2540 },
2541};
2542
Ravi Kumar V1c903012012-05-15 16:11:35 +05302543static struct platform_device rc_input_loopback_pdev = {
2544 .name = "rc-user-input",
2545 .id = -1,
2546};
2547
Ravi Kumar V040eeff2012-05-23 21:29:23 +05302548static int rf4ce_gpio_init(void)
2549{
2550 if (!machine_is_mpq8064_cdp())
2551 return -EINVAL;
2552
2553 /* CC2533 SRDY Input */
2554 if (!gpio_request(SX150X_GPIO(4, 6), "rf4ce_srdy")) {
2555 gpio_direction_input(SX150X_GPIO(4, 6));
2556 gpio_export(SX150X_GPIO(4, 6), true);
2557 }
2558
2559 /* CC2533 MRDY Output */
2560 if (!gpio_request(SX150X_GPIO(4, 5), "rf4ce_mrdy")) {
2561 gpio_direction_output(SX150X_GPIO(4, 5), 1);
2562 gpio_export(SX150X_GPIO(4, 5), true);
2563 }
2564
2565 /* CC2533 Reset Output */
2566 if (!gpio_request(SX150X_GPIO(4, 7), "rf4ce_reset")) {
2567 gpio_direction_output(SX150X_GPIO(4, 7), 0);
2568 gpio_export(SX150X_GPIO(4, 7), true);
2569 }
2570
2571 return 0;
2572}
2573late_initcall(rf4ce_gpio_init);
2574
Mayank Rana262e9032012-05-10 15:14:00 -07002575#ifdef CONFIG_SERIAL_MSM_HS
2576static int configure_uart_gpios(int on)
2577{
2578 int ret = 0, i;
2579 int uart_gpios[] = {14, 15, 16, 17};
2580
2581 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
2582 if (on) {
2583 ret = gpio_request(uart_gpios[i], NULL);
2584 if (ret) {
2585 pr_err("%s:unable to request uart gpio[%d]\n",
2586 __func__, uart_gpios[i]);
2587 break;
2588 }
2589 } else {
2590 gpio_free(uart_gpios[i]);
2591 }
2592 }
2593
2594 if (ret && on && i)
2595 for (; i >= 0; i--)
2596 gpio_free(uart_gpios[i]);
2597 return ret;
2598}
2599
2600static struct msm_serial_hs_platform_data mpq8064_gsbi6_uartdm_pdata = {
2601 .inject_rx_on_wakeup = 1,
2602 .rx_to_inject = 0xFD,
2603 .gpio_config = configure_uart_gpios,
2604};
2605#else
2606static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
2607#endif
2608
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002609static struct platform_device *mpq_devices[] __initdata = {
2610 &msm_device_sps_apq8064,
2611 &mpq8064_device_qup_i2c_gsbi5,
2612#ifdef CONFIG_MSM_ROTATOR
2613 &msm_rotator_device,
2614#endif
Ravi Kumar V05931a22012-04-04 17:09:37 +05302615 &gpio_ir_recv_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002616 &mpq8064_device_ext_1p2_buck_vreg,
2617 &mpq8064_device_ext_1p8_buck_vreg,
2618 &mpq8064_device_ext_2p2_buck_vreg,
2619 &mpq8064_device_ext_5v_buck_vreg,
2620 &mpq8064_device_ext_3p3v_ldo_vreg,
Terence Hampson2e1705f2012-04-11 19:55:29 -04002621#ifdef CONFIG_MSM_VCAP
2622 &msm8064_device_vcap,
2623#endif
Ravi Kumar V1c903012012-05-15 16:11:35 +05302624 &rc_input_loopback_pdev,
Jay Chokshi1b7eaa92012-04-04 14:53:14 -07002625};
2626
Harini Jayaramanc4c58692011-07-19 14:50:10 -06002627static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002628 .max_clock_speed = 1100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002629};
2630
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002631#define KS8851_IRQ_GPIO 43
2632
2633static struct spi_board_info spi_board_info[] __initdata = {
2634 {
2635 .modalias = "ks8851",
2636 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2637 .max_speed_hz = 19200000,
2638 .bus_num = 0,
2639 .chip_select = 2,
2640 .mode = SPI_MODE_0,
2641 },
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002642 {
2643 .modalias = "epm_adc",
2644 .max_speed_hz = 1100000,
2645 .bus_num = 0,
2646 .chip_select = 3,
2647 .mode = SPI_MODE_0,
2648 },
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002649};
2650
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002651static struct slim_boardinfo apq8064_slim_devices[] = {
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002652 {
Swaminathan Sathappancef966d2011-12-15 17:27:04 -08002653 .bus_num = 1,
2654 .slim_slave = &apq8064_slim_tabla,
2655 },
2656 {
2657 .bus_num = 1,
2658 .slim_slave = &apq8064_slim_tabla20,
Swaminathan Sathappan2f51a752011-12-05 12:51:19 -08002659 },
2660 /* add more slimbus slaves as needed */
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06002661};
2662
David Keitel3c40fc52012-02-09 17:53:52 -08002663static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi1_pdata = {
2664 .clk_freq = 100000,
2665 .src_clk_rate = 24000000,
2666};
2667
Jing Lin04601f92012-02-05 15:36:07 -08002668static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi3_pdata = {
Anirudh Ghayalc2163472012-04-10 14:58:14 +05302669 .clk_freq = 384000,
Jing Lin04601f92012-02-05 15:36:07 -08002670 .src_clk_rate = 24000000,
2671};
2672
Kenneth Heitke748593a2011-07-15 15:45:11 -06002673static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
2674 .clk_freq = 100000,
2675 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -06002676};
2677
Joel King8f839b92012-04-01 14:37:46 -07002678static struct msm_i2c_platform_data mpq8064_i2c_qup_gsbi5_pdata = {
2679 .clk_freq = 100000,
2680 .src_clk_rate = 24000000,
2681};
2682
David Keitel3c40fc52012-02-09 17:53:52 -08002683#define GSBI_DUAL_MODE_CODE 0x60
2684#define MSM_GSBI1_PHYS 0x12440000
Kenneth Heitke748593a2011-07-15 15:45:11 -06002685static void __init apq8064_i2c_init(void)
2686{
David Keitel3c40fc52012-02-09 17:53:52 -08002687 void __iomem *gsbi_mem;
2688
2689 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2690 &apq8064_i2c_qup_gsbi1_pdata;
2691 gsbi_mem = ioremap_nocache(MSM_GSBI1_PHYS, 4);
2692 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
2693 /* Ensure protocol code is written before proceeding */
2694 wmb();
2695 iounmap(gsbi_mem);
2696 apq8064_i2c_qup_gsbi1_pdata.use_gsbi_shared_mode = 1;
Jing Lin04601f92012-02-05 15:36:07 -08002697 apq8064_device_qup_i2c_gsbi3.dev.platform_data =
2698 &apq8064_i2c_qup_gsbi3_pdata;
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08002699 apq8064_device_qup_i2c_gsbi1.dev.platform_data =
2700 &apq8064_i2c_qup_gsbi1_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002701 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
2702 &apq8064_i2c_qup_gsbi4_pdata;
Joel King8f839b92012-04-01 14:37:46 -07002703 mpq8064_device_qup_i2c_gsbi5.dev.platform_data =
2704 &mpq8064_i2c_qup_gsbi5_pdata;
Kenneth Heitke748593a2011-07-15 15:45:11 -06002705}
2706
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -08002707#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -07002708static int ethernet_init(void)
2709{
2710 int ret;
2711 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
2712 if (ret) {
2713 pr_err("ks8851 gpio_request failed: %d\n", ret);
2714 goto fail;
2715 }
2716
2717 return 0;
2718fail:
2719 return ret;
2720}
2721#else
2722static int ethernet_init(void)
2723{
2724 return 0;
2725}
2726#endif
2727
David Collinsd49a1c52012-08-22 13:18:06 -07002728#define GPIO_KEY_HOME PM8921_GPIO_PM_TO_SYS(27)
2729#define GPIO_KEY_VOLUME_UP PM8921_GPIO_PM_TO_SYS(35)
2730#define GPIO_KEY_VOLUME_DOWN_PM8921 PM8921_GPIO_PM_TO_SYS(38)
2731#define GPIO_KEY_VOLUME_DOWN_PM8917 PM8921_GPIO_PM_TO_SYS(30)
2732#define GPIO_KEY_CAM_FOCUS PM8921_GPIO_PM_TO_SYS(3)
2733#define GPIO_KEY_CAM_SNAP PM8921_GPIO_PM_TO_SYS(4)
2734#define GPIO_KEY_ROTATION_PM8921 PM8921_GPIO_PM_TO_SYS(42)
2735#define GPIO_KEY_ROTATION_PM8917 PM8921_GPIO_PM_TO_SYS(8)
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302736
David Collinsd49a1c52012-08-22 13:18:06 -07002737static struct gpio_keys_button cdp_keys_pm8921[] = {
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302738 {
2739 .code = KEY_HOME,
2740 .gpio = GPIO_KEY_HOME,
2741 .desc = "home_key",
2742 .active_low = 1,
2743 .type = EV_KEY,
2744 .wakeup = 1,
2745 .debounce_interval = 15,
2746 },
2747 {
2748 .code = KEY_VOLUMEUP,
2749 .gpio = GPIO_KEY_VOLUME_UP,
2750 .desc = "volume_up_key",
2751 .active_low = 1,
2752 .type = EV_KEY,
2753 .wakeup = 1,
2754 .debounce_interval = 15,
2755 },
2756 {
2757 .code = KEY_VOLUMEDOWN,
David Collinsd49a1c52012-08-22 13:18:06 -07002758 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302759 .desc = "volume_down_key",
2760 .active_low = 1,
2761 .type = EV_KEY,
2762 .wakeup = 1,
2763 .debounce_interval = 15,
2764 },
2765 {
2766 .code = SW_ROTATE_LOCK,
David Collinsd49a1c52012-08-22 13:18:06 -07002767 .gpio = GPIO_KEY_ROTATION_PM8921,
2768 .desc = "rotate_key",
2769 .active_low = 1,
2770 .type = EV_SW,
2771 .debounce_interval = 15,
2772 },
2773};
2774
2775static struct gpio_keys_button cdp_keys_pm8917[] = {
2776 {
2777 .code = KEY_HOME,
2778 .gpio = GPIO_KEY_HOME,
2779 .desc = "home_key",
2780 .active_low = 1,
2781 .type = EV_KEY,
2782 .wakeup = 1,
2783 .debounce_interval = 15,
2784 },
2785 {
2786 .code = KEY_VOLUMEUP,
2787 .gpio = GPIO_KEY_VOLUME_UP,
2788 .desc = "volume_up_key",
2789 .active_low = 1,
2790 .type = EV_KEY,
2791 .wakeup = 1,
2792 .debounce_interval = 15,
2793 },
2794 {
2795 .code = KEY_VOLUMEDOWN,
2796 .gpio = GPIO_KEY_VOLUME_DOWN_PM8917,
2797 .desc = "volume_down_key",
2798 .active_low = 1,
2799 .type = EV_KEY,
2800 .wakeup = 1,
2801 .debounce_interval = 15,
2802 },
2803 {
2804 .code = SW_ROTATE_LOCK,
2805 .gpio = GPIO_KEY_ROTATION_PM8917,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302806 .desc = "rotate_key",
2807 .active_low = 1,
2808 .type = EV_SW,
2809 .debounce_interval = 15,
2810 },
2811};
2812
2813static struct gpio_keys_platform_data cdp_keys_data = {
David Collinsd49a1c52012-08-22 13:18:06 -07002814 .buttons = cdp_keys_pm8921,
2815 .nbuttons = ARRAY_SIZE(cdp_keys_pm8921),
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302816};
2817
2818static struct platform_device cdp_kp_pdev = {
2819 .name = "gpio-keys",
2820 .id = -1,
2821 .dev = {
2822 .platform_data = &cdp_keys_data,
2823 },
2824};
2825
2826static struct gpio_keys_button mtp_keys[] = {
2827 {
2828 .code = KEY_CAMERA_FOCUS,
2829 .gpio = GPIO_KEY_CAM_FOCUS,
2830 .desc = "cam_focus_key",
2831 .active_low = 1,
2832 .type = EV_KEY,
2833 .wakeup = 1,
2834 .debounce_interval = 15,
2835 },
2836 {
2837 .code = KEY_VOLUMEUP,
2838 .gpio = GPIO_KEY_VOLUME_UP,
2839 .desc = "volume_up_key",
2840 .active_low = 1,
2841 .type = EV_KEY,
2842 .wakeup = 1,
2843 .debounce_interval = 15,
2844 },
2845 {
2846 .code = KEY_VOLUMEDOWN,
David Collinsd49a1c52012-08-22 13:18:06 -07002847 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302848 .desc = "volume_down_key",
2849 .active_low = 1,
2850 .type = EV_KEY,
2851 .wakeup = 1,
2852 .debounce_interval = 15,
2853 },
2854 {
2855 .code = KEY_CAMERA_SNAPSHOT,
2856 .gpio = GPIO_KEY_CAM_SNAP,
2857 .desc = "cam_snap_key",
2858 .active_low = 1,
2859 .type = EV_KEY,
2860 .debounce_interval = 15,
2861 },
2862};
2863
2864static struct gpio_keys_platform_data mtp_keys_data = {
2865 .buttons = mtp_keys,
2866 .nbuttons = ARRAY_SIZE(mtp_keys),
2867};
2868
2869static struct platform_device mtp_kp_pdev = {
2870 .name = "gpio-keys",
2871 .id = -1,
2872 .dev = {
2873 .platform_data = &mtp_keys_data,
2874 },
2875};
2876
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302877static struct gpio_keys_button mpq_keys[] = {
2878 {
2879 .code = KEY_VOLUMEDOWN,
David Collinsd49a1c52012-08-22 13:18:06 -07002880 .gpio = GPIO_KEY_VOLUME_DOWN_PM8921,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05302881 .desc = "volume_down_key",
2882 .active_low = 1,
2883 .type = EV_KEY,
2884 .wakeup = 1,
2885 .debounce_interval = 15,
2886 },
2887 {
2888 .code = KEY_VOLUMEUP,
2889 .gpio = GPIO_KEY_VOLUME_UP,
2890 .desc = "volume_up_key",
2891 .active_low = 1,
2892 .type = EV_KEY,
2893 .wakeup = 1,
2894 .debounce_interval = 15,
2895 },
2896};
2897
2898static struct gpio_keys_platform_data mpq_keys_data = {
2899 .buttons = mpq_keys,
2900 .nbuttons = ARRAY_SIZE(mpq_keys),
2901};
2902
2903static struct platform_device mpq_gpio_keys_pdev = {
2904 .name = "gpio-keys",
2905 .id = -1,
2906 .dev = {
2907 .platform_data = &mpq_keys_data,
2908 },
2909};
2910
2911#define MPQ_KP_ROW_BASE SX150X_EXP2_GPIO_BASE
2912#define MPQ_KP_COL_BASE (SX150X_EXP2_GPIO_BASE + 4)
2913
2914static unsigned int mpq_row_gpios[] = {MPQ_KP_ROW_BASE, MPQ_KP_ROW_BASE + 1,
2915 MPQ_KP_ROW_BASE + 2, MPQ_KP_ROW_BASE + 3};
2916static unsigned int mpq_col_gpios[] = {MPQ_KP_COL_BASE, MPQ_KP_COL_BASE + 1,
2917 MPQ_KP_COL_BASE + 2};
2918
2919static const unsigned int mpq_keymap[] = {
2920 KEY(0, 0, KEY_UP),
2921 KEY(0, 1, KEY_ENTER),
2922 KEY(0, 2, KEY_3),
2923
2924 KEY(1, 0, KEY_DOWN),
2925 KEY(1, 1, KEY_EXIT),
2926 KEY(1, 2, KEY_4),
2927
2928 KEY(2, 0, KEY_LEFT),
2929 KEY(2, 1, KEY_1),
2930 KEY(2, 2, KEY_5),
2931
2932 KEY(3, 0, KEY_RIGHT),
2933 KEY(3, 1, KEY_2),
2934 KEY(3, 2, KEY_6),
2935};
2936
2937static struct matrix_keymap_data mpq_keymap_data = {
2938 .keymap_size = ARRAY_SIZE(mpq_keymap),
2939 .keymap = mpq_keymap,
2940};
2941
2942static struct matrix_keypad_platform_data mpq_keypad_data = {
2943 .keymap_data = &mpq_keymap_data,
2944 .row_gpios = mpq_row_gpios,
2945 .col_gpios = mpq_col_gpios,
2946 .num_row_gpios = ARRAY_SIZE(mpq_row_gpios),
2947 .num_col_gpios = ARRAY_SIZE(mpq_col_gpios),
2948 .col_scan_delay_us = 32000,
2949 .debounce_ms = 20,
2950 .wakeup = 1,
2951 .active_low = 1,
2952 .no_autorepeat = 1,
2953};
2954
2955static struct platform_device mpq_keypad_device = {
2956 .name = "matrix-keypad",
2957 .id = -1,
2958 .dev = {
2959 .platform_data = &mpq_keypad_data,
2960 },
2961};
2962
Jin Hongd3024e62012-02-09 16:13:32 -08002963/* Sensors DSPS platform data */
2964#define DSPS_PIL_GENERIC_NAME "dsps"
2965static void __init apq8064_init_dsps(void)
2966{
2967 struct msm_dsps_platform_data *pdata =
2968 msm_dsps_device_8064.dev.platform_data;
2969 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2970 pdata->gpios = NULL;
2971 pdata->gpios_num = 0;
2972
2973 platform_device_register(&msm_dsps_device_8064);
2974}
Mohan Pallaka474b94b2012-01-25 12:59:58 +05302975
Jing Lin417fa452012-02-05 14:31:06 -08002976#define I2C_SURF 1
2977#define I2C_FFA (1 << 1)
2978#define I2C_RUMI (1 << 2)
2979#define I2C_SIM (1 << 3)
2980#define I2C_LIQUID (1 << 4)
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07002981#define I2C_MPQ_CDP BIT(5)
2982#define I2C_MPQ_HRD BIT(6)
2983#define I2C_MPQ_DTV BIT(7)
Jing Lin417fa452012-02-05 14:31:06 -08002984
2985struct i2c_registry {
2986 u8 machs;
2987 int bus;
2988 struct i2c_board_info *info;
2989 int len;
2990};
2991
2992static struct i2c_registry apq8064_i2c_devices[] __initdata = {
Jing Lin21ed4de2012-02-05 15:53:28 -08002993 {
David Keitel2f613d92012-02-15 11:29:16 -08002994 I2C_LIQUID,
2995 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
2996 smb349_charger_i2c_info,
2997 ARRAY_SIZE(smb349_charger_i2c_info)
2998 },
2999 {
Jing Lin21ed4de2012-02-05 15:53:28 -08003000 I2C_SURF | I2C_LIQUID,
3001 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
3002 mxt_device_info,
3003 ARRAY_SIZE(mxt_device_info),
3004 },
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -08003005 {
3006 I2C_FFA,
3007 APQ_8064_GSBI3_QUP_I2C_BUS_ID,
3008 cyttsp_info,
3009 ARRAY_SIZE(cyttsp_info),
3010 },
Amy Maloche70090f992012-02-16 16:35:26 -08003011 {
3012 I2C_FFA | I2C_LIQUID,
3013 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
3014 isa1200_board_info,
3015 ARRAY_SIZE(isa1200_board_info),
3016 },
Santosh Mardieff9a742012-04-09 23:23:39 +05303017 {
3018 I2C_MPQ_CDP,
3019 APQ_8064_GSBI5_QUP_I2C_BUS_ID,
3020 cs8427_device_info,
3021 ARRAY_SIZE(cs8427_device_info),
3022 },
Abhishek Kharbanda72dc72e2012-06-07 13:41:37 -07003023 {
3024 I2C_SURF | I2C_FFA | I2C_LIQUID,
3025 APQ_8064_GSBI1_QUP_I2C_BUS_ID,
3026 sii_device_info,
3027 ARRAY_SIZE(sii_device_info),
3028 }
Jing Lin417fa452012-02-05 14:31:06 -08003029};
3030
Kuirong Wangf8c5e142012-06-21 16:17:32 -07003031static struct i2c_registry apq8064_tabla_i2c_devices[] __initdata = {
3032 {
3033 .bus = APQ_8064_GSBI1_QUP_I2C_BUS_ID,
3034 .info = apq8064_tabla_i2c_device_info,
3035 .len = ARRAY_SIZE(apq8064_tabla_i2c_device_info),
3036 },
3037};
3038
Jay Chokshi607f61b2012-04-25 18:21:21 -07003039#define SX150X_EXP1_INT_N PM8921_MPP_IRQ(PM8921_IRQ_BASE, 9)
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05303040#define SX150X_EXP2_INT_N MSM_GPIO_TO_INT(81)
Jay Chokshi607f61b2012-04-25 18:21:21 -07003041
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003042struct sx150x_platform_data mpq8064_sx150x_pdata[] = {
3043 [SX150X_EXP1] = {
3044 .gpio_base = SX150X_EXP1_GPIO_BASE,
3045 .oscio_is_gpo = false,
3046 .io_pullup_ena = 0x0,
3047 .io_pulldn_ena = 0x0,
3048 .io_open_drain_ena = 0x0,
3049 .io_polarity = 0,
Jay Chokshi607f61b2012-04-25 18:21:21 -07003050 .irq_summary = SX150X_EXP1_INT_N,
3051 .irq_base = SX150X_EXP1_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003052 },
3053 [SX150X_EXP2] = {
3054 .gpio_base = SX150X_EXP2_GPIO_BASE,
3055 .oscio_is_gpo = false,
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05303056 .io_pullup_ena = 0x0f,
3057 .io_pulldn_ena = 0x70,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003058 .io_open_drain_ena = 0x0,
3059 .io_polarity = 0,
Anirudh Ghayal9f1aaa72012-04-26 18:15:08 +05303060 .irq_summary = SX150X_EXP2_INT_N,
3061 .irq_base = SX150X_EXP2_IRQ_BASE,
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003062 },
3063 [SX150X_EXP3] = {
3064 .gpio_base = SX150X_EXP3_GPIO_BASE,
3065 .oscio_is_gpo = false,
3066 .io_pullup_ena = 0x0,
3067 .io_pulldn_ena = 0x0,
3068 .io_open_drain_ena = 0x0,
3069 .io_polarity = 0,
3070 .irq_summary = -1,
3071 },
3072 [SX150X_EXP4] = {
3073 .gpio_base = SX150X_EXP4_GPIO_BASE,
3074 .oscio_is_gpo = false,
3075 .io_pullup_ena = 0x0,
3076 .io_pulldn_ena = 0x0,
3077 .io_open_drain_ena = 0x0,
3078 .io_polarity = 0,
3079 .irq_summary = -1,
3080 },
3081};
3082
3083static struct i2c_board_info sx150x_gpio_exp_info[] = {
3084 {
3085 I2C_BOARD_INFO("sx1509q", 0x70),
3086 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP1],
3087 },
3088 {
3089 I2C_BOARD_INFO("sx1508q", 0x23),
3090 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP2],
3091 },
3092 {
3093 I2C_BOARD_INFO("sx1508q", 0x22),
3094 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP3],
3095 },
3096 {
3097 I2C_BOARD_INFO("sx1509q", 0x3E),
3098 .platform_data = &mpq8064_sx150x_pdata[SX150X_EXP4],
3099 },
3100};
3101
3102#define MPQ8064_I2C_GSBI5_BUS_ID 5
3103
3104static struct i2c_registry mpq8064_i2c_devices[] __initdata = {
3105 {
3106 I2C_MPQ_CDP,
3107 MPQ8064_I2C_GSBI5_BUS_ID,
3108 sx150x_gpio_exp_info,
3109 ARRAY_SIZE(sx150x_gpio_exp_info),
3110 },
3111};
3112
Jing Lin417fa452012-02-05 14:31:06 -08003113static void __init register_i2c_devices(void)
3114{
3115 u8 mach_mask = 0;
3116 int i;
Kuirong Wangf8c5e142012-06-21 16:17:32 -07003117 u32 version;
Jing Lin417fa452012-02-05 14:31:06 -08003118
Kevin Chand07220e2012-02-13 15:52:22 -08003119#ifdef CONFIG_MSM_CAMERA
3120 struct i2c_registry apq8064_camera_i2c_devices = {
3121 I2C_SURF | I2C_FFA | I2C_LIQUID | I2C_RUMI,
3122 APQ_8064_GSBI4_QUP_I2C_BUS_ID,
3123 apq8064_camera_board_info.board_info,
3124 apq8064_camera_board_info.num_i2c_board_info,
3125 };
3126#endif
Jing Lin417fa452012-02-05 14:31:06 -08003127 /* Build the matching 'supported_machs' bitmask */
3128 if (machine_is_apq8064_cdp())
3129 mach_mask = I2C_SURF;
3130 else if (machine_is_apq8064_mtp())
3131 mach_mask = I2C_FFA;
3132 else if (machine_is_apq8064_liquid())
3133 mach_mask = I2C_LIQUID;
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003134 else if (PLATFORM_IS_MPQ8064())
3135 mach_mask = I2C_MPQ_CDP;
Jing Lin417fa452012-02-05 14:31:06 -08003136 else
3137 pr_err("unmatched machine ID in register_i2c_devices\n");
3138
3139 /* Run the array and install devices as appropriate */
3140 for (i = 0; i < ARRAY_SIZE(apq8064_i2c_devices); ++i) {
3141 if (apq8064_i2c_devices[i].machs & mach_mask)
3142 i2c_register_board_info(apq8064_i2c_devices[i].bus,
3143 apq8064_i2c_devices[i].info,
3144 apq8064_i2c_devices[i].len);
3145 }
Kevin Chand07220e2012-02-13 15:52:22 -08003146#ifdef CONFIG_MSM_CAMERA
3147 if (apq8064_camera_i2c_devices.machs & mach_mask)
3148 i2c_register_board_info(apq8064_camera_i2c_devices.bus,
3149 apq8064_camera_i2c_devices.info,
3150 apq8064_camera_i2c_devices.len);
3151#endif
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003152
3153 for (i = 0; i < ARRAY_SIZE(mpq8064_i2c_devices); ++i) {
3154 if (mpq8064_i2c_devices[i].machs & mach_mask)
3155 i2c_register_board_info(
3156 mpq8064_i2c_devices[i].bus,
3157 mpq8064_i2c_devices[i].info,
3158 mpq8064_i2c_devices[i].len);
3159 }
Kuirong Wangf8c5e142012-06-21 16:17:32 -07003160
3161 if (machine_is_apq8064_mtp()) {
3162 version = socinfo_get_platform_version();
3163 if (SOCINFO_VERSION_MINOR(version) == 1)
3164 for (i = 0; i < ARRAY_SIZE(apq8064_tabla_i2c_devices);
3165 ++i)
3166 i2c_register_board_info(
3167 apq8064_tabla_i2c_devices[i].bus,
3168 apq8064_tabla_i2c_devices[i].info,
3169 apq8064_tabla_i2c_devices[i].len);
3170 }
3171
Jing Lin417fa452012-02-05 14:31:06 -08003172}
3173
Jay Chokshi994ff122012-03-27 15:43:48 -07003174static void enable_ddr3_regulator(void)
3175{
3176 static struct regulator *ext_ddr3;
3177
3178 /* Use MPP7 output state as a flag for PCDDR3 presence. */
3179 if (gpio_get_value_cansleep(PM8921_MPP_PM_TO_SYS(7)) > 0) {
3180 ext_ddr3 = regulator_get(NULL, "ext_ddr3");
3181 if (IS_ERR(ext_ddr3) || ext_ddr3 == NULL)
3182 pr_err("Could not get MPP7 regulator\n");
3183 else
3184 regulator_enable(ext_ddr3);
3185 }
3186}
3187
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003188static void enable_avc_i2c_bus(void)
3189{
3190 int avc_i2c_en_mpp = PM8921_MPP_PM_TO_SYS(8);
3191 int rc;
3192
3193 rc = gpio_request(avc_i2c_en_mpp, "avc_i2c_en");
3194 if (rc)
3195 pr_err("request for avc_i2c_en mpp failed,"
3196 "rc=%d\n", rc);
3197 else
3198 gpio_set_value_cansleep(avc_i2c_en_mpp, 1);
3199}
3200
David Collinsd49a1c52012-08-22 13:18:06 -07003201/* Modify platform data values to match requirements for PM8917. */
3202static void __init apq8064_pm8917_pdata_fixup(void)
3203{
3204 cdp_keys_data.buttons = cdp_keys_pm8917;
3205 cdp_keys_data.nbuttons = ARRAY_SIZE(cdp_keys_pm8917);
3206}
3207
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003208static void __init apq8064_common_init(void)
3209{
Kuirong Wangf8c5e142012-06-21 16:17:32 -07003210 u32 platform_version = socinfo_get_platform_version();
David Collinsd49a1c52012-08-22 13:18:06 -07003211
3212 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3213 apq8064_pm8917_pdata_fixup();
Rohit Vaswanib1cc4932012-07-23 21:30:11 -07003214 platform_device_register(&msm_gpio_device);
Joel King8f839b92012-04-01 14:37:46 -07003215 msm_tsens_early_init(&apq_tsens_pdata);
Praveen Chidambaram877d7a42012-06-05 14:33:20 -06003216 msm_thermal_init(&msm_thermal_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003217 if (socinfo_init() < 0)
3218 pr_err("socinfo_init() failed!\n");
Praveen Chidambaram78499012011-11-01 17:15:17 -06003219 BUG_ON(msm_rpm_init(&apq8064_rpm_data));
3220 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
David Collins2782b5c2012-02-06 10:02:42 -08003221 regulator_suppress_info_printing();
David Collins793793b2012-08-21 15:43:02 -07003222 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
3223 configure_apq8064_pm8917_power_grid();
David Collins2782b5c2012-02-06 10:02:42 -08003224 platform_device_register(&apq8064_device_rpm_regulator);
David Collins793793b2012-08-21 15:43:02 -07003225 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3226 platform_device_register(&apq8064_pm8921_device_rpm_regulator);
Stephen Boyd4d0d2582012-02-10 14:49:40 -08003227 if (msm_xo_init())
3228 pr_err("Failed to initialize XO votes\n");
Matt Wagantallc51e5602012-02-27 17:25:25 -08003229 msm_clock_init(&apq8064_clock_init_data);
Stepan Moskovchenko2327a952011-12-14 16:31:28 -08003230 apq8064_init_gpiomux();
Kenneth Heitke748593a2011-07-15 15:45:11 -06003231 apq8064_i2c_init();
Jing Lin417fa452012-02-05 14:31:06 -08003232 register_i2c_devices();
Kenneth Heitke36920d32011-07-20 16:44:30 -06003233
Harini Jayaramanc4c58692011-07-19 14:50:10 -06003234 apq8064_device_qup_spi_gsbi5.dev.platform_data =
3235 &apq8064_qup_spi_gsbi5_pdata;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -08003236 apq8064_init_pmic();
Hemant Kumar94e7da22012-02-03 16:52:29 -08003237 if (machine_is_apq8064_liquid())
3238 msm_otg_pdata.mhl_enable = true;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003239
Abhishek Kharbanda72dc72e2012-06-07 13:41:37 -07003240 if (apq8064_mhl_display_enabled())
3241 mhl_platform_data.mhl_enabled = true;
3242
Ofir Cohen94213a72012-05-03 14:26:32 +03003243 android_usb_pdata.swfi_latency =
3244 msm_rpmrs_levels[0].latency_us;
Vamsi Krishnad9863eb2012-03-26 17:34:48 -07003245
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003246 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Manu Gautam91223e02011-11-08 15:27:22 +05303247 apq8064_ehci_host_init();
Gagan Mac8a7a5d32011-11-11 16:43:06 -07003248 apq8064_init_buses();
David Collins793793b2012-08-21 15:43:02 -07003249
3250 platform_add_devices(early_common_devices,
3251 ARRAY_SIZE(early_common_devices));
3252 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
3253 platform_add_devices(pm8921_common_devices,
3254 ARRAY_SIZE(pm8921_common_devices));
3255 else
3256 platform_add_devices(pm8917_common_devices,
3257 ARRAY_SIZE(pm8917_common_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003258 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Terence Hampson36b70722012-05-10 13:18:16 -04003259 if (!(machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3260 machine_is_mpq8064_dtv()))
3261 platform_add_devices(common_not_mpq_devices,
3262 ARRAY_SIZE(common_not_mpq_devices));
Kuirong Wangf8c5e142012-06-21 16:17:32 -07003263
3264 if ((machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3265 machine_is_mpq8064_dtv()))
3266 platform_add_devices(common_mpq_devices,
3267 ARRAY_SIZE(common_mpq_devices));
3268
3269 if (machine_is_apq8064_mtp()) {
3270 if (SOCINFO_VERSION_MINOR(platform_version) == 1)
3271 platform_add_devices(common_i2s_devices,
3272 ARRAY_SIZE(common_i2s_devices));
3273 }
3274
Jay Chokshi994ff122012-03-27 15:43:48 -07003275 enable_ddr3_regulator();
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003276 if (machine_is_apq8064_mtp()) {
Hemant Kumar30d361c2012-08-20 14:44:40 -07003277 msm_hsic_pdata.log2_irq_thresh = 5,
Hemant Kumarf1ca9192012-02-07 18:59:33 -08003278 apq8064_device_hsic_host.dev.platform_data = &msm_hsic_pdata;
3279 device_initialize(&apq8064_device_hsic_host.dev);
3280 }
Jay Chokshie8741282012-01-25 15:22:55 -08003281 apq8064_pm8xxx_gpio_mpp_init();
Sahitya Tummala3586ed92011-08-03 09:13:23 +05303282 apq8064_init_mmc();
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003283
3284 if (machine_is_apq8064_mtp()) {
3285 mdm_8064_device.dev.platform_data = &mdm_platform_data;
Ameya Thakure155ece2012-07-09 12:08:37 -07003286 if (SOCINFO_VERSION_MINOR(platform_version) == 1) {
3287 i2s_mdm_8064_device.dev.platform_data =
3288 &mdm_platform_data;
3289 platform_device_register(&i2s_mdm_8064_device);
3290 } else {
3291 mdm_8064_device.dev.platform_data = &mdm_platform_data;
3292 platform_device_register(&mdm_8064_device);
3293 }
Swaminathan Sathappan144b4882012-02-06 17:01:20 -08003294 }
3295 platform_device_register(&apq8064_slim_ctrl);
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -06003296 slim_register_board_info(apq8064_slim_devices,
3297 ARRAY_SIZE(apq8064_slim_devices));
Taniya Dasbbf633d2012-07-31 16:07:47 +05303298 if (!PLATFORM_IS_MPQ8064()) {
Taniya Das30cae292012-07-31 15:56:12 +05303299 apq8064_init_dsps();
Taniya Dasbbf633d2012-07-31 16:07:47 +05303300 platform_device_register(&msm_8960_riva);
3301 }
Praveen Chidambaram78499012011-11-01 17:15:17 -06003302 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3303 msm_spm_l2_init(msm_spm_l2_data);
Praveen Chidambaram78499012011-11-01 17:15:17 -06003304 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadossb9df4942012-02-08 09:58:21 -08003305 apq8064_epm_adc_init();
Girish Mahadevan3bc98772012-08-15 10:01:27 -06003306 msm_pm_set_tz_retention_flag(1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003307}
3308
Huaibin Yang4a084e32011-12-15 15:25:52 -08003309static void __init apq8064_allocate_memory_regions(void)
3310{
3311 apq8064_allocate_fb_region();
3312}
3313
Joel King82b7e3f2012-01-05 10:03:27 -08003314static void __init apq8064_cdp_init(void)
3315{
Hanumant Singh50440d42012-04-23 19:27:16 -07003316 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
3317 pr_err("meminfo_init() failed!\n");
Amy Maloche609bb5e2012-08-03 09:41:42 -07003318 if (machine_is_apq8064_mtp() &&
3319 SOCINFO_VERSION_MINOR(socinfo_get_platform_version()) == 1)
3320 cyttsp_pdata.sleep_gpio = CYTTSP_TS_GPIO_SLEEP_ALT;
Joel King82b7e3f2012-01-05 10:03:27 -08003321 apq8064_common_init();
Joel King8f839b92012-04-01 14:37:46 -07003322 if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd() ||
3323 machine_is_mpq8064_dtv()) {
Jay Chokshie7d8d4f2012-04-04 14:47:57 -07003324 enable_avc_i2c_bus();
Olav Hauganef95ae32012-05-15 09:50:30 -07003325 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003326 platform_add_devices(mpq_devices, ARRAY_SIZE(mpq_devices));
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -06003327 mpq8064_pcie_init();
Joel King8f839b92012-04-01 14:37:46 -07003328 } else {
3329 ethernet_init();
Olav Hauganef95ae32012-05-15 09:50:30 -07003330 msm_rotator_set_split_iommu_domain();
Joel King8f839b92012-04-01 14:37:46 -07003331 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3332 spi_register_board_info(spi_board_info,
3333 ARRAY_SIZE(spi_board_info));
3334 }
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003335 apq8064_init_fb();
Jordan Crouseb3115fe2012-02-01 22:11:12 -07003336 apq8064_init_gpu();
Matt Wagantall1f65d9d2012-04-25 14:24:20 -07003337 platform_add_devices(apq8064_footswitch, apq8064_num_footswitch);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003338#ifdef CONFIG_MSM_CAMERA
Kevin Chand07220e2012-02-13 15:52:22 -08003339 apq8064_init_cam();
Steve Mucklef132c6c2012-06-06 18:30:57 -07003340#endif
Mohan Pallaka474b94b2012-01-25 12:59:58 +05303341
Mayank Rana262e9032012-05-10 15:14:00 -07003342 if (machine_is_mpq8064_hrd() || machine_is_mpq8064_dtv()) {
3343 platform_device_register(&mpq8064_device_uartdm_gsbi6);
3344#ifdef CONFIG_SERIAL_MSM_HS
3345 /* GSBI6(2) - UARTDM_RX */
3346 mpq8064_gsbi6_uartdm_pdata.wakeup_irq = gpio_to_irq(15);
3347 mpq8064_device_uartdm_gsbi6.dev.platform_data =
3348 &mpq8064_gsbi6_uartdm_pdata;
3349#endif
3350 }
3351
Mohan Pallaka474b94b2012-01-25 12:59:58 +05303352 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid())
3353 platform_device_register(&cdp_kp_pdev);
3354
3355 if (machine_is_apq8064_mtp())
3356 platform_device_register(&mtp_kp_pdev);
Hanumant Singh50440d42012-04-23 19:27:16 -07003357
3358 change_memory_power = &apq8064_change_memory_power;
Anirudh Ghayal32ea6252012-04-26 16:39:50 +05303359
3360 if (machine_is_mpq8064_cdp()) {
3361 platform_device_register(&mpq_gpio_keys_pdev);
3362 platform_device_register(&mpq_keypad_device);
3363 }
Joel King82b7e3f2012-01-05 10:03:27 -08003364}
3365
Joel King82b7e3f2012-01-05 10:03:27 -08003366MACHINE_START(APQ8064_CDP, "QCT APQ8064 CDP")
3367 .map_io = apq8064_map_io,
3368 .reserve = apq8064_reserve,
3369 .init_irq = apq8064_init_irq,
3370 .handle_irq = gic_handle_irq,
3371 .timer = &msm_timer,
3372 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003373 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003374 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003375 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003376MACHINE_END
3377
3378MACHINE_START(APQ8064_MTP, "QCT APQ8064 MTP")
3379 .map_io = apq8064_map_io,
3380 .reserve = apq8064_reserve,
3381 .init_irq = apq8064_init_irq,
3382 .handle_irq = gic_handle_irq,
3383 .timer = &msm_timer,
3384 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003385 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003386 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003387 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003388MACHINE_END
3389
3390MACHINE_START(APQ8064_LIQUID, "QCT APQ8064 LIQUID")
3391 .map_io = apq8064_map_io,
3392 .reserve = apq8064_reserve,
3393 .init_irq = apq8064_init_irq,
3394 .handle_irq = gic_handle_irq,
3395 .timer = &msm_timer,
3396 .init_machine = apq8064_cdp_init,
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08003397 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003398 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003399 .restart = msm_restart,
Joel King82b7e3f2012-01-05 10:03:27 -08003400MACHINE_END
3401
Joel King064bbf82012-04-01 13:23:39 -07003402MACHINE_START(MPQ8064_CDP, "QCT MPQ8064 CDP")
3403 .map_io = apq8064_map_io,
3404 .reserve = apq8064_reserve,
3405 .init_irq = apq8064_init_irq,
3406 .handle_irq = gic_handle_irq,
3407 .timer = &msm_timer,
3408 .init_machine = apq8064_cdp_init,
3409 .init_early = apq8064_allocate_memory_regions,
3410 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003411 .restart = msm_restart,
Joel King064bbf82012-04-01 13:23:39 -07003412MACHINE_END
3413
Joel King11ca8202012-02-13 16:19:03 -08003414MACHINE_START(MPQ8064_HRD, "QCT MPQ8064 HRD")
3415 .map_io = apq8064_map_io,
3416 .reserve = apq8064_reserve,
3417 .init_irq = apq8064_init_irq,
3418 .handle_irq = gic_handle_irq,
3419 .timer = &msm_timer,
3420 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003421 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003422 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003423 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003424MACHINE_END
3425
3426MACHINE_START(MPQ8064_DTV, "QCT MPQ8064 DTV")
3427 .map_io = apq8064_map_io,
3428 .reserve = apq8064_reserve,
3429 .init_irq = apq8064_init_irq,
3430 .handle_irq = gic_handle_irq,
3431 .timer = &msm_timer,
3432 .init_machine = apq8064_cdp_init,
Joel King3a57e772012-05-28 11:22:55 -07003433 .init_early = apq8064_allocate_memory_regions,
Laura Abbott6988cef2012-03-15 14:27:13 -07003434 .init_very_early = apq8064_early_reserve,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -07003435 .restart = msm_restart,
Joel King11ca8202012-02-13 16:19:03 -08003436MACHINE_END