blob: f2f41cf63082fc3229fd541f6868087cb87e6de1 [file] [log] [blame]
Mayank Rana60ae1af2013-03-08 14:09:51 +05301/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
Steve Mucklea55df6e2010-01-07 12:43:24 -08002 *
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 *
Steve Mucklea55df6e2010-01-07 12:43:24 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <linux/gpio.h>
Steve Muckle9161d302010-02-11 11:50:40 -080017#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/io.h>
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053019#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/mfd/pmic8058.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080021
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022#include <linux/leds.h>
23#include <linux/pmic8058-othc.h>
24#include <linux/mfd/pmic8901.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070025#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/regulator/pmic8901-regulator.h>
27#include <linux/bootmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#include <linux/msm_adc.h>
29#include <linux/m_adcproc.h>
30#include <linux/mfd/marimba.h>
31#include <linux/msm-charger.h>
32#include <linux/i2c.h>
33#include <linux/i2c/sx150x.h>
34#include <linux/smsc911x.h>
35#include <linux/spi/spi.h>
36#include <linux/input/tdisc_shinetsu.h>
37#include <linux/input/cy8c_ts.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070038#include <linux/cyttsp-qc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039#include <linux/i2c/isa1200.h>
40#include <linux/dma-mapping.h>
41#include <linux/i2c/bq27520.h>
42
43#ifdef CONFIG_ANDROID_PMEM
44#include <linux/android_pmem.h>
45#endif
46
47#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
48#include <linux/i2c/smb137b.h>
49#endif
Lei Zhou338cab82011-08-19 13:38:17 -040050#ifdef CONFIG_SND_SOC_WM8903
51#include <sound/wm8903.h>
52#endif
Steve Mucklea55df6e2010-01-07 12:43:24 -080053#include <asm/mach-types.h>
54#include <asm/mach/arch.h>
Stephen Boyd9e775ad2011-08-12 00:14:28 +010055#include <asm/setup.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053056#include <asm/hardware/gic.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080057
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/dma.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080059#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#include <mach/irqs.h>
61#include <mach/msm_spi.h>
62#include <mach/msm_serial_hs.h>
63#include <mach/msm_serial_hs_lite.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080064#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#include <mach/msm_memtypes.h>
66#include <asm/mach/mmc.h>
67#include <mach/msm_battery.h>
68#include <mach/msm_hsusb.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070069#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#ifdef CONFIG_MSM_DSPS
71#include <mach/msm_dsps.h>
72#endif
73#include <mach/msm_xo.h>
74#include <mach/msm_bus_board.h>
75#include <mach/socinfo.h>
76#include <linux/i2c/isl9519.h>
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
81#include <linux/regulator/consumer.h>
82#include <linux/regulator/machine.h>
83#include <mach/sdio_al.h>
84#include <mach/rpm.h>
85#include <mach/rpm-regulator.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070086#include <mach/restart.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053087#include <mach/board-msm8660.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070088#include <mach/iommu_domains.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090#include "devices.h"
91#include "devices-msm8x60.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080092#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080093#include "pm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053094#include <mach/mpm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#include "spm.h"
96#include "rpm_log.h"
97#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098#include "gpiomux-8x60.h"
99#include "rpm_stats.h"
100#include "peripheral-loader.h"
101#include <linux/platform_data/qcom_crypto_device.h>
102#include "rpm_resources.h"
Matt Wagantalld55b90f2012-02-23 23:27:44 -0800103#include "clock.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600104#include "pm-boot.h"
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530105#include "board-storage-common-a.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700106
Mitchel Humpherysc75b47d2012-09-06 11:35:07 -0700107#include <linux/msm_ion.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700108#include <mach/ion.h>
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +0530109#include <mach/msm_rtb.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700110
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112#define MDM2AP_SYNC 129
113
Terence Hampson1c73fef2011-07-19 17:10:49 -0400114#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700115#define LCDC_SPI_GPIO_CLK 73
116#define LCDC_SPI_GPIO_CS 72
117#define LCDC_SPI_GPIO_MOSI 70
118#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
119#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
120#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
121#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
122#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400123#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700124
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700125#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
126#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
127#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
128#define HDMI_PANEL_NAME "hdmi_msm"
129#define TVOUT_PANEL_NAME "tvout_msm"
130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700131#define DSPS_PIL_GENERIC_NAME "dsps"
132#define DSPS_PIL_FLUID_NAME "dsps_fluid"
133
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800134#ifdef CONFIG_ION_MSM
135static struct platform_device ion_dev;
136#endif
137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700138enum {
139 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530140 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141 /* CORE expander */
142 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
143 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
144 GPIO_WLAN_DEEP_SLEEP_N,
145 GPIO_LVDS_SHUTDOWN_N,
146 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
147 GPIO_MS_SYS_RESET_N,
148 GPIO_CAP_TS_RESOUT_N,
149 GPIO_CAP_GAUGE_BI_TOUT,
150 GPIO_ETHERNET_PME,
151 GPIO_EXT_GPS_LNA_EN,
152 GPIO_MSM_WAKES_BT,
153 GPIO_ETHERNET_RESET_N,
154 GPIO_HEADSET_DET_N,
155 GPIO_USB_UICC_EN,
156 GPIO_BACKLIGHT_EN,
157 GPIO_EXT_CAMIF_PWR_EN,
158 GPIO_BATT_GAUGE_INT_N,
159 GPIO_BATT_GAUGE_EN,
160 /* DOCKING expander */
161 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
162 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
163 GPIO_AUX_JTAG_DET_N,
164 GPIO_DONGLE_DET_N,
165 GPIO_SVIDEO_LOAD_DET,
166 GPIO_SVID_AMP_SHUTDOWN1_N,
167 GPIO_SVID_AMP_SHUTDOWN0_N,
168 GPIO_SDC_WP,
169 GPIO_IRDA_PWDN,
170 GPIO_IRDA_RESET_N,
171 GPIO_DONGLE_GPIO0,
172 GPIO_DONGLE_GPIO1,
173 GPIO_DONGLE_GPIO2,
174 GPIO_DONGLE_GPIO3,
175 GPIO_DONGLE_PWR_EN,
176 GPIO_EMMC_RESET_N,
177 GPIO_TP_EXP2_IO15,
178 /* SURF expander */
179 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
180 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
181 GPIO_SD_CARD_DET_2,
182 GPIO_SD_CARD_DET_4,
183 GPIO_SD_CARD_DET_5,
184 GPIO_UIM3_RST,
185 GPIO_SURF_EXPANDER_IO5,
186 GPIO_SURF_EXPANDER_IO6,
187 GPIO_ADC_I2C_EN,
188 GPIO_SURF_EXPANDER_IO8,
189 GPIO_SURF_EXPANDER_IO9,
190 GPIO_SURF_EXPANDER_IO10,
191 GPIO_SURF_EXPANDER_IO11,
192 GPIO_SURF_EXPANDER_IO12,
193 GPIO_SURF_EXPANDER_IO13,
194 GPIO_SURF_EXPANDER_IO14,
195 GPIO_SURF_EXPANDER_IO15,
196 /* LEFT KB IO expander */
197 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
198 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
199 GPIO_LEFT_LED_2,
200 GPIO_LEFT_LED_3,
201 GPIO_LEFT_LED_WLAN,
202 GPIO_JOYSTICK_EN,
203 GPIO_CAP_TS_SLEEP,
204 GPIO_LEFT_KB_IO6,
205 GPIO_LEFT_LED_5,
206 /* RIGHT KB IO expander */
207 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
208 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
209 GPIO_RIGHT_LED_2,
210 GPIO_RIGHT_LED_3,
211 GPIO_RIGHT_LED_BT,
212 GPIO_WEB_CAMIF_STANDBY,
213 GPIO_COMPASS_RST_N,
214 GPIO_WEB_CAMIF_RESET_N,
215 GPIO_RIGHT_LED_5,
216 GPIO_R_ALTIMETER_RESET_N,
217 /* FLUID S IO expander */
218 GPIO_SOUTH_EXPANDER_BASE,
219 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
220 GPIO_MIC1_ANCL_SEL,
221 GPIO_HS_MIC4_SEL,
222 GPIO_FML_MIC3_SEL,
223 GPIO_FMR_MIC5_SEL,
224 GPIO_TS_SLEEP,
225 GPIO_HAP_SHIFT_LVL_OE,
226 GPIO_HS_SW_DIR,
227 /* FLUID N IO expander */
228 GPIO_NORTH_EXPANDER_BASE,
229 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
230 GPIO_EPM_5V_BOOST_EN,
231 GPIO_AUX_CAM_2P7_EN,
232 GPIO_LED_FLASH_EN,
233 GPIO_LED1_GREEN_N,
234 GPIO_LED2_RED_N,
235 GPIO_FRONT_CAM_RESET_N,
236 GPIO_EPM_LVLSFT_EN,
237 GPIO_N_ALTIMETER_RESET_N,
238 /* EPM expander */
239 GPIO_EPM_EXPANDER_BASE,
240 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
241 GPIO_PWR_MON_RESET_N,
242 GPIO_ADC1_PWDN_N,
243 GPIO_ADC2_PWDN_N,
244 GPIO_EPM_EXPANDER_IO4,
245 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
246 GPIO_ADC2_MUX_SPI_INT_N,
247 GPIO_EPM_EXPANDER_IO7,
248 GPIO_PWR_MON_ENABLE,
249 GPIO_EPM_SPI_ADC1_CS_N,
250 GPIO_EPM_SPI_ADC2_CS_N,
251 GPIO_EPM_EXPANDER_IO11,
252 GPIO_EPM_EXPANDER_IO12,
253 GPIO_EPM_EXPANDER_IO13,
254 GPIO_EPM_EXPANDER_IO14,
255 GPIO_EPM_EXPANDER_IO15,
256};
257
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530258struct pm8xxx_mpp_init_info {
259 unsigned mpp;
260 struct pm8xxx_mpp_config_data config;
261};
262
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530263#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530264{ \
265 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
266 .config = { \
267 .type = PM8XXX_MPP_TYPE_##_type, \
268 .level = _level, \
269 .control = PM8XXX_MPP_##_control, \
270 } \
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100271}
272
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530273#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
274{ \
275 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
276 .config = { \
277 .type = PM8XXX_MPP_TYPE_##_type, \
278 .level = _level, \
279 .control = PM8XXX_MPP_##_control, \
280 } \
281}
282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283/*
284 * The UI_INTx_N lines are pmic gpio lines which connect i2c
285 * gpio expanders to the pm8058.
286 */
287#define UI_INT1_N 25
288#define UI_INT2_N 34
289#define UI_INT3_N 14
290/*
291FM GPIO is GPIO 18 on PMIC 8058.
292As the index starts from 0 in the PMIC driver, and hence 17
293corresponds to GPIO 18 on PMIC 8058.
294*/
295#define FM_GPIO 17
296
297#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
298static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
299static void *sdc2_status_notify_cb_devid;
300#endif
301
302#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
303static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
304static void *sdc5_status_notify_cb_devid;
305#endif
306
307static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
308 [0] = {
309 .reg_base_addr = MSM_SAW0_BASE,
310
311#ifdef CONFIG_MSM_AVS_HW
312 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
313#endif
314 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
315 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
316 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
317 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
318
319 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
320 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
322
323 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
324 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
325 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
326
327 .awake_vlevel = 0x94,
328 .retention_vlevel = 0x81,
329 .collapse_vlevel = 0x20,
330 .retention_mid_vlevel = 0x94,
331 .collapse_mid_vlevel = 0x8C,
332
333 .vctl_timeout_us = 50,
334 },
335
336 [1] = {
337 .reg_base_addr = MSM_SAW1_BASE,
338
339#ifdef CONFIG_MSM_AVS_HW
340 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
341#endif
342 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
343 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
344 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
345 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
346
347 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
348 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
350
351 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
352 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
353 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
354
355 .awake_vlevel = 0x94,
356 .retention_vlevel = 0x81,
357 .collapse_vlevel = 0x20,
358 .retention_mid_vlevel = 0x94,
359 .collapse_mid_vlevel = 0x8C,
360
361 .vctl_timeout_us = 50,
362 },
363};
364
365static struct msm_spm_platform_data msm_spm_data[] __initdata = {
366 [0] = {
367 .reg_base_addr = MSM_SAW0_BASE,
368
369#ifdef CONFIG_MSM_AVS_HW
370 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
371#endif
372 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
373 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
374 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
375 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
376
377 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
378 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
380
381 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
382 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
383 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
384
385 .awake_vlevel = 0xA0,
386 .retention_vlevel = 0x89,
387 .collapse_vlevel = 0x20,
388 .retention_mid_vlevel = 0x89,
389 .collapse_mid_vlevel = 0x89,
390
391 .vctl_timeout_us = 50,
392 },
393
394 [1] = {
395 .reg_base_addr = MSM_SAW1_BASE,
396
397#ifdef CONFIG_MSM_AVS_HW
398 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
399#endif
400 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
401 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
402 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
403 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
404
405 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
406 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
408
409 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
410 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
411 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
412
413 .awake_vlevel = 0xA0,
414 .retention_vlevel = 0x89,
415 .collapse_vlevel = 0x20,
416 .retention_mid_vlevel = 0x89,
417 .collapse_mid_vlevel = 0x89,
418
419 .vctl_timeout_us = 50,
420 },
421};
422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700423/*
424 * Consumer specific regulator names:
425 * regulator name consumer dev_name
426 */
427static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
428 REGULATOR_SUPPLY("8901_s0", NULL),
429};
430static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
431 REGULATOR_SUPPLY("8901_s1", NULL),
432};
433
434static struct regulator_init_data saw_s0_init_data = {
435 .constraints = {
436 .name = "8901_s0",
437 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700438 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700439 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700440 },
441 .consumer_supplies = vreg_consumers_8901_S0,
442 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
443};
444
445static struct regulator_init_data saw_s1_init_data = {
446 .constraints = {
447 .name = "8901_s1",
448 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700449 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700450 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700451 },
452 .consumer_supplies = vreg_consumers_8901_S1,
453 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
454};
455
456static struct platform_device msm_device_saw_s0 = {
457 .name = "saw-regulator",
458 .id = 0,
459 .dev = {
460 .platform_data = &saw_s0_init_data,
461 },
462};
463
464static struct platform_device msm_device_saw_s1 = {
465 .name = "saw-regulator",
466 .id = 1,
467 .dev = {
468 .platform_data = &saw_s1_init_data,
469 },
470};
471
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700472static struct resource smsc911x_resources[] = {
473 [0] = {
474 .flags = IORESOURCE_MEM,
475 .start = 0x1b800000,
476 .end = 0x1b8000ff
477 },
478 [1] = {
479 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
480 },
481};
482
483static struct smsc911x_platform_config smsc911x_config = {
484 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
485 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
486 .flags = SMSC911X_USE_16BIT,
487 .has_reset_gpio = 1,
488 .reset_gpio = GPIO_ETHERNET_RESET_N
489};
490
491static struct platform_device smsc911x_device = {
492 .name = "smsc911x",
493 .id = 0,
494 .num_resources = ARRAY_SIZE(smsc911x_resources),
495 .resource = smsc911x_resources,
496 .dev = {
497 .platform_data = &smsc911x_config
498 }
499};
500
501#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
502 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
503 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
504 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
505
506#define QCE_SIZE 0x10000
507#define QCE_0_BASE 0x18500000
508
509#define QCE_HW_KEY_SUPPORT 0
510#define QCE_SHA_HMAC_SUPPORT 0
511#define QCE_SHARE_CE_RESOURCE 2
512#define QCE_CE_SHARED 1
513
514static struct resource qcrypto_resources[] = {
515 [0] = {
516 .start = QCE_0_BASE,
517 .end = QCE_0_BASE + QCE_SIZE - 1,
518 .flags = IORESOURCE_MEM,
519 },
520 [1] = {
521 .name = "crypto_channels",
522 .start = DMOV_CE_IN_CHAN,
523 .end = DMOV_CE_OUT_CHAN,
524 .flags = IORESOURCE_DMA,
525 },
526 [2] = {
527 .name = "crypto_crci_in",
528 .start = DMOV_CE_IN_CRCI,
529 .end = DMOV_CE_IN_CRCI,
530 .flags = IORESOURCE_DMA,
531 },
532 [3] = {
533 .name = "crypto_crci_out",
534 .start = DMOV_CE_OUT_CRCI,
535 .end = DMOV_CE_OUT_CRCI,
536 .flags = IORESOURCE_DMA,
537 },
538 [4] = {
539 .name = "crypto_crci_hash",
540 .start = DMOV_CE_HASH_CRCI,
541 .end = DMOV_CE_HASH_CRCI,
542 .flags = IORESOURCE_DMA,
543 },
544};
545
546static struct resource qcedev_resources[] = {
547 [0] = {
548 .start = QCE_0_BASE,
549 .end = QCE_0_BASE + QCE_SIZE - 1,
550 .flags = IORESOURCE_MEM,
551 },
552 [1] = {
553 .name = "crypto_channels",
554 .start = DMOV_CE_IN_CHAN,
555 .end = DMOV_CE_OUT_CHAN,
556 .flags = IORESOURCE_DMA,
557 },
558 [2] = {
559 .name = "crypto_crci_in",
560 .start = DMOV_CE_IN_CRCI,
561 .end = DMOV_CE_IN_CRCI,
562 .flags = IORESOURCE_DMA,
563 },
564 [3] = {
565 .name = "crypto_crci_out",
566 .start = DMOV_CE_OUT_CRCI,
567 .end = DMOV_CE_OUT_CRCI,
568 .flags = IORESOURCE_DMA,
569 },
570 [4] = {
571 .name = "crypto_crci_hash",
572 .start = DMOV_CE_HASH_CRCI,
573 .end = DMOV_CE_HASH_CRCI,
574 .flags = IORESOURCE_DMA,
575 },
576};
577
578#endif
579
580#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
581 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
582
583static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
584 .ce_shared = QCE_CE_SHARED,
585 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
586 .hw_key_support = QCE_HW_KEY_SUPPORT,
587 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800588 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700589};
590
591static struct platform_device qcrypto_device = {
592 .name = "qcrypto",
593 .id = 0,
594 .num_resources = ARRAY_SIZE(qcrypto_resources),
595 .resource = qcrypto_resources,
596 .dev = {
597 .coherent_dma_mask = DMA_BIT_MASK(32),
598 .platform_data = &qcrypto_ce_hw_suppport,
599 },
600};
601#endif
602
603#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
604 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
605
606static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
607 .ce_shared = QCE_CE_SHARED,
608 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
609 .hw_key_support = QCE_HW_KEY_SUPPORT,
610 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800611 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700612};
613
614static struct platform_device qcedev_device = {
615 .name = "qce",
616 .id = 0,
617 .num_resources = ARRAY_SIZE(qcedev_resources),
618 .resource = qcedev_resources,
619 .dev = {
620 .coherent_dma_mask = DMA_BIT_MASK(32),
621 .platform_data = &qcedev_ce_hw_suppport,
622 },
623};
624#endif
625
626#if defined(CONFIG_HAPTIC_ISA1200) || \
627 defined(CONFIG_HAPTIC_ISA1200_MODULE)
628
629static const char *vregs_isa1200_name[] = {
630 "8058_s3",
631 "8901_l4",
632};
633
634static const int vregs_isa1200_val[] = {
635 1800000,/* uV */
636 2600000,
637};
638static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
639static struct msm_xo_voter *xo_handle_a1;
640
641static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800642{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700643 int i, rc = 0;
644
645 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
646 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
647 regulator_disable(vregs_isa1200[i]);
648 if (rc < 0) {
649 pr_err("%s: vreg %s %s failed (%d)\n",
650 __func__, vregs_isa1200_name[i],
651 vreg_on ? "enable" : "disable", rc);
652 goto vreg_fail;
653 }
654 }
655
656 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
657 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
658 if (rc < 0) {
659 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
660 __func__, vreg_on ? "" : "de-", rc);
661 goto vreg_fail;
662 }
663 return 0;
664
665vreg_fail:
666 while (i--)
667 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
668 regulator_disable(vregs_isa1200[i]);
669 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800670}
671
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700672static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800673{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700674 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800675
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700676 if (enable == true) {
677 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
678 vregs_isa1200[i] = regulator_get(NULL,
679 vregs_isa1200_name[i]);
680 if (IS_ERR(vregs_isa1200[i])) {
681 pr_err("%s: regulator get of %s failed (%ld)\n",
682 __func__, vregs_isa1200_name[i],
683 PTR_ERR(vregs_isa1200[i]));
684 rc = PTR_ERR(vregs_isa1200[i]);
685 goto vreg_get_fail;
686 }
687 rc = regulator_set_voltage(vregs_isa1200[i],
688 vregs_isa1200_val[i], vregs_isa1200_val[i]);
689 if (rc) {
690 pr_err("%s: regulator_set_voltage(%s) failed\n",
691 __func__, vregs_isa1200_name[i]);
692 goto vreg_get_fail;
693 }
694 }
Steve Muckle9161d302010-02-11 11:50:40 -0800695
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700696 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
697 if (rc) {
698 pr_err("%s: unable to request gpio %d (%d)\n",
699 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
700 goto vreg_get_fail;
701 }
Steve Muckle9161d302010-02-11 11:50:40 -0800702
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700703 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
704 if (rc) {
705 pr_err("%s: Unable to set direction\n", __func__);;
706 goto free_gpio;
707 }
708
709 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
710 if (IS_ERR(xo_handle_a1)) {
711 rc = PTR_ERR(xo_handle_a1);
712 pr_err("%s: failed to get the handle for A1(%d)\n",
713 __func__, rc);
714 goto gpio_set_dir;
715 }
716 } else {
717 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
718 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
719
720 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
721 regulator_put(vregs_isa1200[i]);
722
723 msm_xo_put(xo_handle_a1);
724 }
725
726 return 0;
727gpio_set_dir:
728 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
729free_gpio:
730 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
731vreg_get_fail:
732 while (i)
733 regulator_put(vregs_isa1200[--i]);
734 return rc;
735}
736
737#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530738#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700739static struct isa1200_platform_data isa1200_1_pdata = {
740 .name = "vibrator",
741 .power_on = isa1200_power,
742 .dev_setup = isa1200_dev_setup,
743 /*gpio to enable haptic*/
744 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530745 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700746 .max_timeout = 15000,
747 .mode_ctrl = PWM_GEN_MODE,
748 .pwm_fd = {
749 .pwm_div = 256,
750 },
751 .is_erm = false,
752 .smart_en = true,
753 .ext_clk_en = true,
754 .chip_en = 1,
755};
756
757static struct i2c_board_info msm_isa1200_board_info[] = {
758 {
759 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
760 .platform_data = &isa1200_1_pdata,
761 },
762};
763#endif
764
765#if defined(CONFIG_BATTERY_BQ27520) || \
766 defined(CONFIG_BATTERY_BQ27520_MODULE)
767static struct bq27520_platform_data bq27520_pdata = {
768 .name = "fuel-gauge",
769 .vreg_name = "8058_s3",
770 .vreg_value = 1800000,
771 .soc_int = GPIO_BATT_GAUGE_INT_N,
772 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
773 .chip_en = GPIO_BATT_GAUGE_EN,
774 .enable_dlog = 0, /* if enable coulomb counter logger */
775};
776
777static struct i2c_board_info msm_bq27520_board_info[] = {
778 {
779 I2C_BOARD_INFO("bq27520", 0xaa>>1),
780 .platform_data = &bq27520_pdata,
781 },
782};
783#endif
784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700785static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
786 {
787 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
788 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
789 true,
790 1, 8000, 100000, 1,
791 },
792
793 {
794 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
795 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
796 true,
797 1500, 5000, 60100000, 3000,
798 },
799
800 {
801 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
802 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
803 false,
804 1800, 5000, 60350000, 3500,
805 },
806 {
807 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
808 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
809 false,
810 3800, 4500, 65350000, 5500,
811 },
812
813 {
814 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
815 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
816 false,
817 2800, 2500, 66850000, 4800,
818 },
819
820 {
821 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
822 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
823 false,
824 4800, 2000, 71850000, 6800,
825 },
826
827 {
828 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
829 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
830 false,
831 6800, 500, 75850000, 8800,
832 },
833
834 {
835 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
836 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
837 false,
838 7800, 0, 76350000, 9800,
839 },
840};
841
Praveen Chidambaram78499012011-11-01 17:15:17 -0600842static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
843 .levels = &msm_rpmrs_levels[0],
844 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
845 .vdd_mem_levels = {
846 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
847 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
848 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700849 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600850 },
851 .vdd_dig_levels = {
852 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
853 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
854 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
855 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
856 },
857 .vdd_mask = 0xFFF,
858 .rpmrs_target_id = {
859 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
860 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
861 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
862 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
863 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
864 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
865 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
866 },
867};
868
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600869static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
870 .mode = MSM_PM_BOOT_CONFIG_TZ,
871};
872
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
874
875#define ISP1763_INT_GPIO 117
876#define ISP1763_RST_GPIO 152
877static struct resource isp1763_resources[] = {
878 [0] = {
879 .flags = IORESOURCE_MEM,
880 .start = 0x1D000000,
881 .end = 0x1D005FFF, /* 24KB */
882 },
883 [1] = {
884 .flags = IORESOURCE_IRQ,
885 },
886};
887static void __init msm8x60_cfg_isp1763(void)
888{
889 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
890 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
891}
892
893static int isp1763_setup_gpio(int enable)
894{
895 int status = 0;
896
897 if (enable) {
898 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
899 if (status) {
900 pr_err("%s:Failed to request GPIO %d\n",
901 __func__, ISP1763_INT_GPIO);
902 return status;
903 }
904 status = gpio_direction_input(ISP1763_INT_GPIO);
905 if (status) {
906 pr_err("%s:Failed to configure GPIO %d\n",
907 __func__, ISP1763_INT_GPIO);
908 goto gpio_free_int;
909 }
910 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
911 if (status) {
912 pr_err("%s:Failed to request GPIO %d\n",
913 __func__, ISP1763_RST_GPIO);
914 goto gpio_free_int;
915 }
916 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
917 if (status) {
918 pr_err("%s:Failed to configure GPIO %d\n",
919 __func__, ISP1763_RST_GPIO);
920 goto gpio_free_rst;
921 }
922 pr_debug("\nISP GPIO configuration done\n");
923 return status;
924 }
925
926gpio_free_rst:
927 gpio_free(ISP1763_RST_GPIO);
928gpio_free_int:
929 gpio_free(ISP1763_INT_GPIO);
930
931 return status;
932}
933static struct isp1763_platform_data isp1763_pdata = {
934 .reset_gpio = ISP1763_RST_GPIO,
935 .setup_gpio = isp1763_setup_gpio
936};
937
938static struct platform_device isp1763_device = {
939 .name = "isp1763_usb",
940 .num_resources = ARRAY_SIZE(isp1763_resources),
941 .resource = isp1763_resources,
942 .dev = {
943 .platform_data = &isp1763_pdata
944 }
945};
946#endif
947
Lena Salman57d167e2012-03-21 19:46:38 +0200948#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530949static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700950static struct regulator *ldo6_3p3;
951static struct regulator *ldo7_1p8;
952static struct regulator *vdd_cx;
953#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530954#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700955notify_vbus_state notify_vbus_state_func_ptr;
956static int usb_phy_susp_dig_vol = 750000;
957static int pmic_id_notif_supported;
958
959#ifdef CONFIG_USB_EHCI_MSM_72K
960#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
961struct delayed_work pmic_id_det;
962
963static int __init usb_id_pin_rework_setup(char *support)
964{
965 if (strncmp(support, "true", 4) == 0)
966 pmic_id_notif_supported = 1;
967
968 return 1;
969}
970__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
971
972static void pmic_id_detect(struct work_struct *w)
973{
974 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
975 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
976
977 if (notify_vbus_state_func_ptr)
978 (*notify_vbus_state_func_ptr) (val);
979}
980
981static irqreturn_t pmic_id_on_irq(int irq, void *data)
982{
983 /*
984 * Spurious interrupts are observed on pmic gpio line
985 * even though there is no state change on USB ID. Schedule the
986 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -0800987 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700988 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -0800989
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700990 return IRQ_HANDLED;
991}
992
Anji jonnalaae745e92011-11-14 18:34:31 +0530993static int msm_hsusb_phy_id_setup_init(int init)
994{
995 unsigned ret;
996
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530997 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
998 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
999 .level = PM8901_MPP_DIG_LEVEL_L5,
1000 };
1001
Anji jonnalaae745e92011-11-14 18:34:31 +05301002 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301003 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1004 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1005 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301006 if (ret < 0)
1007 pr_err("%s:MPP2 configuration failed\n", __func__);
1008 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301009 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1010 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1011 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301012 if (ret < 0)
1013 pr_err("%s:MPP2 un config failed\n", __func__);
1014 }
1015 return ret;
1016}
1017
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001018static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1019{
1020 unsigned ret = -ENODEV;
1021
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301022 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301023 .direction = PM_GPIO_DIR_IN,
1024 .pull = PM_GPIO_PULL_UP_1P5,
1025 .function = PM_GPIO_FUNC_NORMAL,
1026 .vin_sel = 2,
1027 .inv_int_pol = 0,
1028 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301029 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301030 .direction = PM_GPIO_DIR_IN,
1031 .pull = PM_GPIO_PULL_NO,
1032 .function = PM_GPIO_FUNC_NORMAL,
1033 .vin_sel = 2,
1034 .inv_int_pol = 0,
1035 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001036 if (!callback)
1037 return -EINVAL;
1038
1039 if (machine_is_msm8x60_fluid())
1040 return -ENOTSUPP;
1041
1042 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1043 pr_debug("%s: USB_ID pin is not routed to PMIC"
1044 "on V1 surf/ffa\n", __func__);
1045 return -ENOTSUPP;
1046 }
1047
Manu Gautam62158eb2011-11-24 16:20:46 +05301048 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1049 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001050 pr_debug("%s: USB_ID is not routed to PMIC"
1051 "on V2 ffa\n", __func__);
1052 return -ENOTSUPP;
1053 }
1054
1055 usb_phy_susp_dig_vol = 500000;
1056
1057 if (init) {
1058 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301059 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301060 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1061 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301062 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301063 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301064 __func__, ret);
1065 return ret;
1066 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001067 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1068 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1069 "msm_otg_id", NULL);
1070 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001071 pr_err("%s:pmic_usb_id interrupt registration failed",
1072 __func__);
1073 return ret;
1074 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301075 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001076 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301077 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001078 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301079 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1080 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301081 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301082 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301083 __func__, ret);
1084 return ret;
1085 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301086 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001087 cancel_delayed_work_sync(&pmic_id_det);
1088 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001089 }
1090 return 0;
1091}
1092#endif
1093
1094#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1095#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1096static int msm_hsusb_init_vddcx(int init)
1097{
1098 int ret = 0;
1099
1100 if (init) {
1101 vdd_cx = regulator_get(NULL, "8058_s1");
1102 if (IS_ERR(vdd_cx)) {
1103 return PTR_ERR(vdd_cx);
1104 }
1105
1106 ret = regulator_set_voltage(vdd_cx,
1107 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1108 USB_PHY_MAX_VDD_DIG_VOL);
1109 if (ret) {
1110 pr_err("%s: unable to set the voltage for regulator"
1111 "vdd_cx\n", __func__);
1112 regulator_put(vdd_cx);
1113 return ret;
1114 }
1115
1116 ret = regulator_enable(vdd_cx);
1117 if (ret) {
1118 pr_err("%s: unable to enable regulator"
1119 "vdd_cx\n", __func__);
1120 regulator_put(vdd_cx);
1121 }
1122 } else {
1123 ret = regulator_disable(vdd_cx);
1124 if (ret) {
1125 pr_err("%s: Unable to disable the regulator:"
1126 "vdd_cx\n", __func__);
1127 return ret;
1128 }
1129
1130 regulator_put(vdd_cx);
1131 }
1132
1133 return ret;
1134}
1135
1136static int msm_hsusb_config_vddcx(int high)
1137{
1138 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1139 int min_vol;
1140 int ret;
1141
1142 if (high)
1143 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1144 else
1145 min_vol = usb_phy_susp_dig_vol;
1146
1147 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1148 if (ret) {
1149 pr_err("%s: unable to set the voltage for regulator"
1150 "vdd_cx\n", __func__);
1151 return ret;
1152 }
1153
1154 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1155
1156 return ret;
1157}
1158
1159#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1160#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1161#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1162#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1163
1164#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1165#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1166#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1167#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1168static int msm_hsusb_ldo_init(int init)
1169{
1170 int rc = 0;
1171
1172 if (init) {
1173 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1174 if (IS_ERR(ldo6_3p3))
1175 return PTR_ERR(ldo6_3p3);
1176
1177 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1178 if (IS_ERR(ldo7_1p8)) {
1179 rc = PTR_ERR(ldo7_1p8);
1180 goto put_3p3;
1181 }
1182
1183 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1184 USB_PHY_3P3_VOL_MAX);
1185 if (rc) {
1186 pr_err("%s: Unable to set voltage level for"
1187 "ldo6_3p3 regulator\n", __func__);
1188 goto put_1p8;
1189 }
1190 rc = regulator_enable(ldo6_3p3);
1191 if (rc) {
1192 pr_err("%s: Unable to enable the regulator:"
1193 "ldo6_3p3\n", __func__);
1194 goto put_1p8;
1195 }
1196 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1197 USB_PHY_1P8_VOL_MAX);
1198 if (rc) {
1199 pr_err("%s: Unable to set voltage level for"
1200 "ldo7_1p8 regulator\n", __func__);
1201 goto disable_3p3;
1202 }
1203 rc = regulator_enable(ldo7_1p8);
1204 if (rc) {
1205 pr_err("%s: Unable to enable the regulator:"
1206 "ldo7_1p8\n", __func__);
1207 goto disable_3p3;
1208 }
1209
1210 return 0;
1211 }
1212
1213 regulator_disable(ldo7_1p8);
1214disable_3p3:
1215 regulator_disable(ldo6_3p3);
1216put_1p8:
1217 regulator_put(ldo7_1p8);
1218put_3p3:
1219 regulator_put(ldo6_3p3);
1220 return rc;
1221}
1222
1223static int msm_hsusb_ldo_enable(int on)
1224{
1225 int ret = 0;
1226
1227 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1228 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1229 return -ENODEV;
1230 }
1231
1232 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1233 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1234 return -ENODEV;
1235 }
1236
1237 if (on) {
1238 ret = regulator_set_optimum_mode(ldo7_1p8,
1239 USB_PHY_1P8_HPM_LOAD);
1240 if (ret < 0) {
1241 pr_err("%s: Unable to set HPM of the regulator:"
1242 "ldo7_1p8\n", __func__);
1243 return ret;
1244 }
1245 ret = regulator_set_optimum_mode(ldo6_3p3,
1246 USB_PHY_3P3_HPM_LOAD);
1247 if (ret < 0) {
1248 pr_err("%s: Unable to set HPM of the regulator:"
1249 "ldo6_3p3\n", __func__);
1250 regulator_set_optimum_mode(ldo7_1p8,
1251 USB_PHY_1P8_LPM_LOAD);
1252 return ret;
1253 }
1254 } else {
1255 ret = regulator_set_optimum_mode(ldo7_1p8,
1256 USB_PHY_1P8_LPM_LOAD);
1257 if (ret < 0)
1258 pr_err("%s: Unable to set LPM of the regulator:"
1259 "ldo7_1p8\n", __func__);
1260 ret = regulator_set_optimum_mode(ldo6_3p3,
1261 USB_PHY_3P3_LPM_LOAD);
1262 if (ret < 0)
1263 pr_err("%s: Unable to set LPM of the regulator:"
1264 "ldo6_3p3\n", __func__);
1265 }
1266
1267 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1268 return ret < 0 ? ret : 0;
1269 }
1270#endif
1271#ifdef CONFIG_USB_EHCI_MSM_72K
1272#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1273static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1274{
1275 static int vbus_is_on;
1276
1277 /* If VBUS is already on (or off), do nothing. */
1278 if (on == vbus_is_on)
1279 return;
1280 smb137b_otg_power(on);
1281 vbus_is_on = on;
1282}
1283#endif
1284static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1285{
1286 static struct regulator *votg_5v_switch;
1287 static struct regulator *ext_5v_reg;
1288 static int vbus_is_on;
1289
1290 /* If VBUS is already on (or off), do nothing. */
1291 if (on == vbus_is_on)
1292 return;
1293
1294 if (!votg_5v_switch) {
1295 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1296 if (IS_ERR(votg_5v_switch)) {
1297 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1298 return;
1299 }
1300 }
1301 if (!ext_5v_reg) {
1302 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1303 if (IS_ERR(ext_5v_reg)) {
1304 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1305 return;
1306 }
1307 }
1308 if (on) {
1309 if (regulator_enable(ext_5v_reg)) {
1310 pr_err("%s: Unable to enable the regulator:"
1311 " ext_5v_reg\n", __func__);
1312 return;
1313 }
1314 if (regulator_enable(votg_5v_switch)) {
1315 pr_err("%s: Unable to enable the regulator:"
1316 " votg_5v_switch\n", __func__);
1317 return;
1318 }
1319 } else {
1320 if (regulator_disable(votg_5v_switch))
1321 pr_err("%s: Unable to enable the regulator:"
1322 " votg_5v_switch\n", __func__);
1323 if (regulator_disable(ext_5v_reg))
1324 pr_err("%s: Unable to enable the regulator:"
1325 " ext_5v_reg\n", __func__);
1326 }
1327
1328 vbus_is_on = on;
1329}
1330
1331static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1332 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1333 .power_budget = 390,
1334};
1335#endif
1336
1337#ifdef CONFIG_BATTERY_MSM8X60
1338static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1339 int init)
1340{
1341 int ret = -ENOTSUPP;
1342
1343#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1344 if (machine_is_msm8x60_fluid()) {
1345 if (init)
1346 msm_charger_register_vbus_sn(callback);
1347 else
1348 msm_charger_unregister_vbus_sn(callback);
1349 return 0;
1350 }
1351#endif
1352 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1353 * hence, irrespective of either peripheral only mode or
1354 * OTG (host and peripheral) modes, can depend on pmic for
1355 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001356 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001357 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1358 && (machine_is_msm8x60_surf() ||
1359 pmic_id_notif_supported)) {
1360 if (init)
1361 ret = msm_charger_register_vbus_sn(callback);
1362 else {
1363 msm_charger_unregister_vbus_sn(callback);
1364 ret = 0;
1365 }
1366 } else {
1367#if !defined(CONFIG_USB_EHCI_MSM_72K)
1368 if (init)
1369 ret = msm_charger_register_vbus_sn(callback);
1370 else {
1371 msm_charger_unregister_vbus_sn(callback);
1372 ret = 0;
1373 }
1374#endif
1375 }
1376 return ret;
1377}
1378#endif
1379
Lena Salman57d167e2012-03-21 19:46:38 +02001380#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001381static struct msm_otg_platform_data msm_otg_pdata = {
1382 /* if usb link is in sps there is no need for
1383 * usb pclk as dayatona fabric clock will be
1384 * used instead
1385 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001386 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1387 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1388 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301389 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001390#ifdef CONFIG_USB_EHCI_MSM_72K
1391 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301392 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001393#endif
1394#ifdef CONFIG_USB_EHCI_MSM_72K
1395 .vbus_power = msm_hsusb_vbus_power,
1396#endif
1397#ifdef CONFIG_BATTERY_MSM8X60
1398 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1399#endif
1400 .ldo_init = msm_hsusb_ldo_init,
1401 .ldo_enable = msm_hsusb_ldo_enable,
1402 .config_vddcx = msm_hsusb_config_vddcx,
1403 .init_vddcx = msm_hsusb_init_vddcx,
1404#ifdef CONFIG_BATTERY_MSM8X60
1405 .chg_vbus_draw = msm_charger_vbus_draw,
1406#endif
1407};
1408#endif
1409
Lena Salman57d167e2012-03-21 19:46:38 +02001410#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001411static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1412 .is_phy_status_timer_on = 1,
1413};
1414#endif
1415
1416#ifdef CONFIG_USB_G_ANDROID
1417
1418#define PID_MAGIC_ID 0x71432909
1419#define SERIAL_NUM_MAGIC_ID 0x61945374
1420#define SERIAL_NUMBER_LENGTH 127
1421#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1422
1423struct magic_num_struct {
1424 uint32_t pid;
1425 uint32_t serial_num;
1426};
1427
1428struct dload_struct {
1429 uint32_t reserved1;
1430 uint32_t reserved2;
1431 uint32_t reserved3;
1432 uint16_t reserved4;
1433 uint16_t pid;
1434 char serial_number[SERIAL_NUMBER_LENGTH];
1435 uint16_t reserved5;
1436 struct magic_num_struct
1437 magic_struct;
1438};
1439
1440static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1441{
1442 struct dload_struct __iomem *dload = 0;
1443
1444 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1445 if (!dload) {
1446 pr_err("%s: cannot remap I/O memory region: %08x\n",
1447 __func__, DLOAD_USB_BASE_ADD);
1448 return -ENXIO;
1449 }
1450
1451 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1452 __func__, dload, pid, snum);
1453 /* update pid */
1454 dload->magic_struct.pid = PID_MAGIC_ID;
1455 dload->pid = pid;
1456
1457 /* update serial number */
1458 dload->magic_struct.serial_num = 0;
1459 if (!snum)
1460 return 0;
1461
1462 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1463 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1464 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1465
1466 iounmap(dload);
1467
1468 return 0;
1469}
1470
1471static struct android_usb_platform_data android_usb_pdata = {
1472 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1473};
1474
1475static struct platform_device android_usb_device = {
1476 .name = "android_usb",
1477 .id = -1,
1478 .dev = {
1479 .platform_data = &android_usb_pdata,
1480 },
1481};
1482
1483
1484#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001485
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001486#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001487#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001488static struct resource msm_vpe_resources[] = {
1489 {
1490 .start = 0x05300000,
1491 .end = 0x05300000 + SZ_1M - 1,
1492 .flags = IORESOURCE_MEM,
1493 },
1494 {
1495 .start = INT_VPE,
1496 .end = INT_VPE,
1497 .flags = IORESOURCE_IRQ,
1498 },
1499};
1500
1501static struct platform_device msm_vpe_device = {
1502 .name = "msm_vpe",
1503 .id = 0,
1504 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1505 .resource = msm_vpe_resources,
1506};
1507#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001508#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001509
1510#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001511#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001512#ifdef CONFIG_MSM_CAMERA_FLASH
1513#define VFE_CAMIF_TIMER1_GPIO 29
1514#define VFE_CAMIF_TIMER2_GPIO 30
1515#define VFE_CAMIF_TIMER3_GPIO_INT 31
1516#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1517static struct msm_camera_sensor_flash_src msm_flash_src = {
1518 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1519 ._fsrc.pmic_src.num_of_src = 2,
1520 ._fsrc.pmic_src.low_current = 100,
1521 ._fsrc.pmic_src.high_current = 300,
1522 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1523 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1524 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1525};
1526#ifdef CONFIG_IMX074
1527static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1528 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1529 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1530 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1531 .flash_recharge_duration = 50000,
1532 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1533};
1534#endif
1535#endif
1536
1537int msm_cam_gpio_tbl[] = {
1538 32,/*CAMIF_MCLK*/
1539 47,/*CAMIF_I2C_DATA*/
1540 48,/*CAMIF_I2C_CLK*/
1541 105,/*STANDBY*/
1542};
1543
1544enum msm_cam_stat{
1545 MSM_CAM_OFF,
1546 MSM_CAM_ON,
1547};
1548
1549static int config_gpio_table(enum msm_cam_stat stat)
1550{
1551 int rc = 0, i = 0;
1552 if (stat == MSM_CAM_ON) {
1553 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1554 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1555 if (unlikely(rc < 0)) {
1556 pr_err("%s not able to get gpio\n", __func__);
1557 for (i--; i >= 0; i--)
1558 gpio_free(msm_cam_gpio_tbl[i]);
1559 break;
1560 }
1561 }
1562 } else {
1563 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1564 gpio_free(msm_cam_gpio_tbl[i]);
1565 }
1566 return rc;
1567}
1568
1569static struct msm_camera_sensor_platform_info sensor_board_info = {
1570 .mount_angle = 0
1571};
1572
1573/*external regulator VREG_5V*/
1574static struct regulator *reg_flash_5V;
1575
1576static int config_camera_on_gpios_fluid(void)
1577{
1578 int rc = 0;
1579
1580 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1581 if (IS_ERR(reg_flash_5V)) {
1582 pr_err("'%s' regulator not found, rc=%ld\n",
1583 "8901_mpp0", IS_ERR(reg_flash_5V));
1584 return -ENODEV;
1585 }
1586
1587 rc = regulator_enable(reg_flash_5V);
1588 if (rc) {
1589 pr_err("'%s' regulator enable failed, rc=%d\n",
1590 "8901_mpp0", rc);
1591 regulator_put(reg_flash_5V);
1592 return rc;
1593 }
1594
1595#ifdef CONFIG_IMX074
1596 sensor_board_info.mount_angle = 90;
1597#endif
1598 rc = config_gpio_table(MSM_CAM_ON);
1599 if (rc < 0) {
1600 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1601 "failed\n", __func__);
1602 return rc;
1603 }
1604
1605 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1606 if (rc < 0) {
1607 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1608 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1609 regulator_disable(reg_flash_5V);
1610 regulator_put(reg_flash_5V);
1611 return rc;
1612 }
1613 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1614 msleep(20);
1615 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1616
1617
1618 /*Enable LED_FLASH_EN*/
1619 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1620 if (rc < 0) {
1621 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1622 "failed\n", __func__, GPIO_LED_FLASH_EN);
1623
1624 regulator_disable(reg_flash_5V);
1625 regulator_put(reg_flash_5V);
1626 config_gpio_table(MSM_CAM_OFF);
1627 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1628 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1629 return rc;
1630 }
1631 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1632 msleep(20);
1633 return rc;
1634}
1635
1636
1637static void config_camera_off_gpios_fluid(void)
1638{
1639 regulator_disable(reg_flash_5V);
1640 regulator_put(reg_flash_5V);
1641
1642 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1643 gpio_free(GPIO_LED_FLASH_EN);
1644
1645 config_gpio_table(MSM_CAM_OFF);
1646
1647 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1648 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1649}
1650static int config_camera_on_gpios(void)
1651{
1652 int rc = 0;
1653
1654 if (machine_is_msm8x60_fluid())
1655 return config_camera_on_gpios_fluid();
1656
1657 rc = config_gpio_table(MSM_CAM_ON);
1658 if (rc < 0) {
1659 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1660 "failed\n", __func__);
1661 return rc;
1662 }
1663
Jilai Wang971f97f2011-07-13 14:25:25 -04001664 if (!machine_is_msm8x60_dragon()) {
1665 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1666 if (rc < 0) {
1667 config_gpio_table(MSM_CAM_OFF);
1668 pr_err("%s: CAMSENSOR gpio %d request"
1669 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1670 return rc;
1671 }
1672 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1673 msleep(20);
1674 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001676
1677#ifdef CONFIG_MSM_CAMERA_FLASH
1678#ifdef CONFIG_IMX074
1679 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1680 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1681#endif
1682#endif
1683 return rc;
1684}
1685
1686static void config_camera_off_gpios(void)
1687{
1688 if (machine_is_msm8x60_fluid())
1689 return config_camera_off_gpios_fluid();
1690
1691
1692 config_gpio_table(MSM_CAM_OFF);
1693
Jilai Wang971f97f2011-07-13 14:25:25 -04001694 if (!machine_is_msm8x60_dragon()) {
1695 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1696 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1697 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001698}
1699
1700#ifdef CONFIG_QS_S5K4E1
1701
1702#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1703
1704static int config_camera_on_gpios_qs_cam_fluid(void)
1705{
1706 int rc = 0;
1707
1708 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1709 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1710 if (rc < 0) {
1711 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1712 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1713 return rc;
1714 }
1715 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1716 msleep(20);
1717 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1718 msleep(20);
1719
1720 /*
1721 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1722 * to enable 2.7V power to Camera
1723 */
1724 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1725 if (rc < 0) {
1726 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1727 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1728 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1729 gpio_free(QS_CAM_HC37_CAM_PD);
1730 return rc;
1731 }
1732 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1733 msleep(20);
1734 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1735 msleep(20);
1736
1737 rc = config_camera_on_gpios_fluid();
1738 if (rc < 0) {
1739 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1740 " failed\n", __func__);
1741 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1742 gpio_free(QS_CAM_HC37_CAM_PD);
1743 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1744 gpio_free(GPIO_AUX_CAM_2P7_EN);
1745 return rc;
1746 }
1747 return rc;
1748}
1749
1750static void config_camera_off_gpios_qs_cam_fluid(void)
1751{
1752 /*
1753 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1754 * to disable 2.7V power to Camera
1755 */
1756 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1757 gpio_free(GPIO_AUX_CAM_2P7_EN);
1758
1759 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1760 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1761 gpio_free(QS_CAM_HC37_CAM_PD);
1762
1763 config_camera_off_gpios_fluid();
1764 return;
1765}
1766
1767static int config_camera_on_gpios_qs_cam(void)
1768{
1769 int rc = 0;
1770
1771 if (machine_is_msm8x60_fluid())
1772 return config_camera_on_gpios_qs_cam_fluid();
1773
1774 rc = config_camera_on_gpios();
1775 return rc;
1776}
1777
1778static void config_camera_off_gpios_qs_cam(void)
1779{
1780 if (machine_is_msm8x60_fluid())
1781 return config_camera_off_gpios_qs_cam_fluid();
1782
1783 config_camera_off_gpios();
1784 return;
1785}
1786#endif
1787
1788static int config_camera_on_gpios_web_cam(void)
1789{
1790 int rc = 0;
1791 rc = config_gpio_table(MSM_CAM_ON);
1792 if (rc < 0) {
1793 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1794 "failed\n", __func__);
1795 return rc;
1796 }
1797
Jilai Wang53d27a82011-07-13 14:32:58 -04001798 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001799 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1800 if (rc < 0) {
1801 config_gpio_table(MSM_CAM_OFF);
1802 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1803 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1804 return rc;
1805 }
1806 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1807 }
1808 return rc;
1809}
1810
1811static void config_camera_off_gpios_web_cam(void)
1812{
1813 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001814 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001815 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1816 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1817 }
1818 return;
1819}
1820
1821#ifdef CONFIG_MSM_BUS_SCALING
1822static struct msm_bus_vectors cam_init_vectors[] = {
1823 {
1824 .src = MSM_BUS_MASTER_VFE,
1825 .dst = MSM_BUS_SLAVE_SMI,
1826 .ab = 0,
1827 .ib = 0,
1828 },
1829 {
1830 .src = MSM_BUS_MASTER_VFE,
1831 .dst = MSM_BUS_SLAVE_EBI_CH0,
1832 .ab = 0,
1833 .ib = 0,
1834 },
1835 {
1836 .src = MSM_BUS_MASTER_VPE,
1837 .dst = MSM_BUS_SLAVE_SMI,
1838 .ab = 0,
1839 .ib = 0,
1840 },
1841 {
1842 .src = MSM_BUS_MASTER_VPE,
1843 .dst = MSM_BUS_SLAVE_EBI_CH0,
1844 .ab = 0,
1845 .ib = 0,
1846 },
1847 {
1848 .src = MSM_BUS_MASTER_JPEG_ENC,
1849 .dst = MSM_BUS_SLAVE_SMI,
1850 .ab = 0,
1851 .ib = 0,
1852 },
1853 {
1854 .src = MSM_BUS_MASTER_JPEG_ENC,
1855 .dst = MSM_BUS_SLAVE_EBI_CH0,
1856 .ab = 0,
1857 .ib = 0,
1858 },
1859};
1860
1861static struct msm_bus_vectors cam_preview_vectors[] = {
1862 {
1863 .src = MSM_BUS_MASTER_VFE,
1864 .dst = MSM_BUS_SLAVE_SMI,
1865 .ab = 0,
1866 .ib = 0,
1867 },
1868 {
1869 .src = MSM_BUS_MASTER_VFE,
1870 .dst = MSM_BUS_SLAVE_EBI_CH0,
1871 .ab = 283115520,
1872 .ib = 452984832,
1873 },
1874 {
1875 .src = MSM_BUS_MASTER_VPE,
1876 .dst = MSM_BUS_SLAVE_SMI,
1877 .ab = 0,
1878 .ib = 0,
1879 },
1880 {
1881 .src = MSM_BUS_MASTER_VPE,
1882 .dst = MSM_BUS_SLAVE_EBI_CH0,
1883 .ab = 0,
1884 .ib = 0,
1885 },
1886 {
1887 .src = MSM_BUS_MASTER_JPEG_ENC,
1888 .dst = MSM_BUS_SLAVE_SMI,
1889 .ab = 0,
1890 .ib = 0,
1891 },
1892 {
1893 .src = MSM_BUS_MASTER_JPEG_ENC,
1894 .dst = MSM_BUS_SLAVE_EBI_CH0,
1895 .ab = 0,
1896 .ib = 0,
1897 },
1898};
1899
1900static struct msm_bus_vectors cam_video_vectors[] = {
1901 {
1902 .src = MSM_BUS_MASTER_VFE,
1903 .dst = MSM_BUS_SLAVE_SMI,
1904 .ab = 283115520,
1905 .ib = 452984832,
1906 },
1907 {
1908 .src = MSM_BUS_MASTER_VFE,
1909 .dst = MSM_BUS_SLAVE_EBI_CH0,
1910 .ab = 283115520,
1911 .ib = 452984832,
1912 },
1913 {
1914 .src = MSM_BUS_MASTER_VPE,
1915 .dst = MSM_BUS_SLAVE_SMI,
1916 .ab = 319610880,
1917 .ib = 511377408,
1918 },
1919 {
1920 .src = MSM_BUS_MASTER_VPE,
1921 .dst = MSM_BUS_SLAVE_EBI_CH0,
1922 .ab = 0,
1923 .ib = 0,
1924 },
1925 {
1926 .src = MSM_BUS_MASTER_JPEG_ENC,
1927 .dst = MSM_BUS_SLAVE_SMI,
1928 .ab = 0,
1929 .ib = 0,
1930 },
1931 {
1932 .src = MSM_BUS_MASTER_JPEG_ENC,
1933 .dst = MSM_BUS_SLAVE_EBI_CH0,
1934 .ab = 0,
1935 .ib = 0,
1936 },
1937};
1938
1939static struct msm_bus_vectors cam_snapshot_vectors[] = {
1940 {
1941 .src = MSM_BUS_MASTER_VFE,
1942 .dst = MSM_BUS_SLAVE_SMI,
1943 .ab = 566231040,
1944 .ib = 905969664,
1945 },
1946 {
1947 .src = MSM_BUS_MASTER_VFE,
1948 .dst = MSM_BUS_SLAVE_EBI_CH0,
1949 .ab = 69984000,
1950 .ib = 111974400,
1951 },
1952 {
1953 .src = MSM_BUS_MASTER_VPE,
1954 .dst = MSM_BUS_SLAVE_SMI,
1955 .ab = 0,
1956 .ib = 0,
1957 },
1958 {
1959 .src = MSM_BUS_MASTER_VPE,
1960 .dst = MSM_BUS_SLAVE_EBI_CH0,
1961 .ab = 0,
1962 .ib = 0,
1963 },
1964 {
1965 .src = MSM_BUS_MASTER_JPEG_ENC,
1966 .dst = MSM_BUS_SLAVE_SMI,
1967 .ab = 320864256,
1968 .ib = 513382810,
1969 },
1970 {
1971 .src = MSM_BUS_MASTER_JPEG_ENC,
1972 .dst = MSM_BUS_SLAVE_EBI_CH0,
1973 .ab = 320864256,
1974 .ib = 513382810,
1975 },
1976};
1977
1978static struct msm_bus_vectors cam_zsl_vectors[] = {
1979 {
1980 .src = MSM_BUS_MASTER_VFE,
1981 .dst = MSM_BUS_SLAVE_SMI,
1982 .ab = 566231040,
1983 .ib = 905969664,
1984 },
1985 {
1986 .src = MSM_BUS_MASTER_VFE,
1987 .dst = MSM_BUS_SLAVE_EBI_CH0,
1988 .ab = 706199040,
1989 .ib = 1129918464,
1990 },
1991 {
1992 .src = MSM_BUS_MASTER_VPE,
1993 .dst = MSM_BUS_SLAVE_SMI,
1994 .ab = 0,
1995 .ib = 0,
1996 },
1997 {
1998 .src = MSM_BUS_MASTER_VPE,
1999 .dst = MSM_BUS_SLAVE_EBI_CH0,
2000 .ab = 0,
2001 .ib = 0,
2002 },
2003 {
2004 .src = MSM_BUS_MASTER_JPEG_ENC,
2005 .dst = MSM_BUS_SLAVE_SMI,
2006 .ab = 320864256,
2007 .ib = 513382810,
2008 },
2009 {
2010 .src = MSM_BUS_MASTER_JPEG_ENC,
2011 .dst = MSM_BUS_SLAVE_EBI_CH0,
2012 .ab = 320864256,
2013 .ib = 513382810,
2014 },
2015};
2016
2017static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2018 {
2019 .src = MSM_BUS_MASTER_VFE,
2020 .dst = MSM_BUS_SLAVE_SMI,
2021 .ab = 212336640,
2022 .ib = 339738624,
2023 },
2024 {
2025 .src = MSM_BUS_MASTER_VFE,
2026 .dst = MSM_BUS_SLAVE_EBI_CH0,
2027 .ab = 25090560,
2028 .ib = 40144896,
2029 },
2030 {
2031 .src = MSM_BUS_MASTER_VPE,
2032 .dst = MSM_BUS_SLAVE_SMI,
2033 .ab = 239708160,
2034 .ib = 383533056,
2035 },
2036 {
2037 .src = MSM_BUS_MASTER_VPE,
2038 .dst = MSM_BUS_SLAVE_EBI_CH0,
2039 .ab = 79902720,
2040 .ib = 127844352,
2041 },
2042 {
2043 .src = MSM_BUS_MASTER_JPEG_ENC,
2044 .dst = MSM_BUS_SLAVE_SMI,
2045 .ab = 0,
2046 .ib = 0,
2047 },
2048 {
2049 .src = MSM_BUS_MASTER_JPEG_ENC,
2050 .dst = MSM_BUS_SLAVE_EBI_CH0,
2051 .ab = 0,
2052 .ib = 0,
2053 },
2054};
2055
2056static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2057 {
2058 .src = MSM_BUS_MASTER_VFE,
2059 .dst = MSM_BUS_SLAVE_SMI,
2060 .ab = 0,
2061 .ib = 0,
2062 },
2063 {
2064 .src = MSM_BUS_MASTER_VFE,
2065 .dst = MSM_BUS_SLAVE_EBI_CH0,
2066 .ab = 300902400,
2067 .ib = 481443840,
2068 },
2069 {
2070 .src = MSM_BUS_MASTER_VPE,
2071 .dst = MSM_BUS_SLAVE_SMI,
2072 .ab = 230307840,
2073 .ib = 368492544,
2074 },
2075 {
2076 .src = MSM_BUS_MASTER_VPE,
2077 .dst = MSM_BUS_SLAVE_EBI_CH0,
2078 .ab = 245113344,
2079 .ib = 392181351,
2080 },
2081 {
2082 .src = MSM_BUS_MASTER_JPEG_ENC,
2083 .dst = MSM_BUS_SLAVE_SMI,
2084 .ab = 106536960,
2085 .ib = 170459136,
2086 },
2087 {
2088 .src = MSM_BUS_MASTER_JPEG_ENC,
2089 .dst = MSM_BUS_SLAVE_EBI_CH0,
2090 .ab = 106536960,
2091 .ib = 170459136,
2092 },
2093};
2094
2095static struct msm_bus_paths cam_bus_client_config[] = {
2096 {
2097 ARRAY_SIZE(cam_init_vectors),
2098 cam_init_vectors,
2099 },
2100 {
2101 ARRAY_SIZE(cam_preview_vectors),
2102 cam_preview_vectors,
2103 },
2104 {
2105 ARRAY_SIZE(cam_video_vectors),
2106 cam_video_vectors,
2107 },
2108 {
2109 ARRAY_SIZE(cam_snapshot_vectors),
2110 cam_snapshot_vectors,
2111 },
2112 {
2113 ARRAY_SIZE(cam_zsl_vectors),
2114 cam_zsl_vectors,
2115 },
2116 {
2117 ARRAY_SIZE(cam_stereo_video_vectors),
2118 cam_stereo_video_vectors,
2119 },
2120 {
2121 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2122 cam_stereo_snapshot_vectors,
2123 },
2124};
2125
2126static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2127 cam_bus_client_config,
2128 ARRAY_SIZE(cam_bus_client_config),
2129 .name = "msm_camera",
2130};
2131#endif
2132
2133struct msm_camera_device_platform_data msm_camera_device_data = {
2134 .camera_gpio_on = config_camera_on_gpios,
2135 .camera_gpio_off = config_camera_off_gpios,
2136 .ioext.csiphy = 0x04800000,
2137 .ioext.csisz = 0x00000400,
2138 .ioext.csiirq = CSI_0_IRQ,
2139 .ioclk.mclk_clk_rate = 24000000,
2140 .ioclk.vfe_clk_rate = 228570000,
2141#ifdef CONFIG_MSM_BUS_SCALING
2142 .cam_bus_scale_table = &cam_bus_client_pdata,
2143#endif
2144};
2145
2146#ifdef CONFIG_QS_S5K4E1
2147struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2148 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2149 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2150 .ioext.csiphy = 0x04800000,
2151 .ioext.csisz = 0x00000400,
2152 .ioext.csiirq = CSI_0_IRQ,
2153 .ioclk.mclk_clk_rate = 24000000,
2154 .ioclk.vfe_clk_rate = 228570000,
2155#ifdef CONFIG_MSM_BUS_SCALING
2156 .cam_bus_scale_table = &cam_bus_client_pdata,
2157#endif
2158};
2159#endif
2160
2161struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2162 .camera_gpio_on = config_camera_on_gpios_web_cam,
2163 .camera_gpio_off = config_camera_off_gpios_web_cam,
2164 .ioext.csiphy = 0x04900000,
2165 .ioext.csisz = 0x00000400,
2166 .ioext.csiirq = CSI_1_IRQ,
2167 .ioclk.mclk_clk_rate = 24000000,
2168 .ioclk.vfe_clk_rate = 228570000,
2169#ifdef CONFIG_MSM_BUS_SCALING
2170 .cam_bus_scale_table = &cam_bus_client_pdata,
2171#endif
2172};
2173
2174struct resource msm_camera_resources[] = {
2175 {
2176 .start = 0x04500000,
2177 .end = 0x04500000 + SZ_1M - 1,
2178 .flags = IORESOURCE_MEM,
2179 },
2180 {
2181 .start = VFE_IRQ,
2182 .end = VFE_IRQ,
2183 .flags = IORESOURCE_IRQ,
2184 },
2185};
2186#ifdef CONFIG_MT9E013
2187static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2188 .mount_angle = 0
2189};
2190
2191static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2192 .flash_type = MSM_CAMERA_FLASH_LED,
2193 .flash_src = &msm_flash_src
2194};
2195
2196static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2197 .sensor_name = "mt9e013",
2198 .sensor_reset = 106,
2199 .sensor_pwd = 85,
2200 .vcm_pwd = 1,
2201 .vcm_enable = 0,
2202 .pdata = &msm_camera_device_data,
2203 .resource = msm_camera_resources,
2204 .num_resources = ARRAY_SIZE(msm_camera_resources),
2205 .flash_data = &flash_mt9e013,
2206 .strobe_flash_data = &strobe_flash_xenon,
2207 .sensor_platform_info = &mt9e013_sensor_8660_info,
2208 .csi_if = 1
2209};
2210struct platform_device msm_camera_sensor_mt9e013 = {
2211 .name = "msm_camera_mt9e013",
2212 .dev = {
2213 .platform_data = &msm_camera_sensor_mt9e013_data,
2214 },
2215};
2216#endif
2217
2218#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302219static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2220 .mount_angle = 180
2221};
2222
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002223static struct msm_camera_sensor_flash_data flash_imx074 = {
2224 .flash_type = MSM_CAMERA_FLASH_LED,
2225 .flash_src = &msm_flash_src
2226};
2227
2228static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2229 .sensor_name = "imx074",
2230 .sensor_reset = 106,
2231 .sensor_pwd = 85,
2232 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2233 .vcm_enable = 1,
2234 .pdata = &msm_camera_device_data,
2235 .resource = msm_camera_resources,
2236 .num_resources = ARRAY_SIZE(msm_camera_resources),
2237 .flash_data = &flash_imx074,
2238 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302239 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002240 .csi_if = 1
2241};
2242struct platform_device msm_camera_sensor_imx074 = {
2243 .name = "msm_camera_imx074",
2244 .dev = {
2245 .platform_data = &msm_camera_sensor_imx074_data,
2246 },
2247};
2248#endif
2249#ifdef CONFIG_WEBCAM_OV9726
2250
2251static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2252 .mount_angle = 0
2253};
2254
2255static struct msm_camera_sensor_flash_data flash_ov9726 = {
2256 .flash_type = MSM_CAMERA_FLASH_LED,
2257 .flash_src = &msm_flash_src
2258};
2259static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2260 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002261 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002262 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2263 .sensor_pwd = 85,
2264 .vcm_pwd = 1,
2265 .vcm_enable = 0,
2266 .pdata = &msm_camera_device_data_web_cam,
2267 .resource = msm_camera_resources,
2268 .num_resources = ARRAY_SIZE(msm_camera_resources),
2269 .flash_data = &flash_ov9726,
2270 .sensor_platform_info = &ov9726_sensor_8660_info,
2271 .csi_if = 1
2272};
2273struct platform_device msm_camera_sensor_webcam_ov9726 = {
2274 .name = "msm_camera_ov9726",
2275 .dev = {
2276 .platform_data = &msm_camera_sensor_ov9726_data,
2277 },
2278};
2279#endif
2280#ifdef CONFIG_WEBCAM_OV7692
2281static struct msm_camera_sensor_flash_data flash_ov7692 = {
2282 .flash_type = MSM_CAMERA_FLASH_LED,
2283 .flash_src = &msm_flash_src
2284};
2285static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2286 .sensor_name = "ov7692",
2287 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2288 .sensor_pwd = 85,
2289 .vcm_pwd = 1,
2290 .vcm_enable = 0,
2291 .pdata = &msm_camera_device_data_web_cam,
2292 .resource = msm_camera_resources,
2293 .num_resources = ARRAY_SIZE(msm_camera_resources),
2294 .flash_data = &flash_ov7692,
2295 .csi_if = 1
2296};
2297
2298static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2299 .name = "msm_camera_ov7692",
2300 .dev = {
2301 .platform_data = &msm_camera_sensor_ov7692_data,
2302 },
2303};
2304#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002305#ifdef CONFIG_VX6953
2306static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2307 .mount_angle = 270
2308};
2309
2310static struct msm_camera_sensor_flash_data flash_vx6953 = {
2311 .flash_type = MSM_CAMERA_FLASH_NONE,
2312 .flash_src = &msm_flash_src
2313};
2314
2315static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2316 .sensor_name = "vx6953",
2317 .sensor_reset = 63,
2318 .sensor_pwd = 63,
2319 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2320 .vcm_enable = 1,
2321 .pdata = &msm_camera_device_data,
2322 .resource = msm_camera_resources,
2323 .num_resources = ARRAY_SIZE(msm_camera_resources),
2324 .flash_data = &flash_vx6953,
2325 .sensor_platform_info = &vx6953_sensor_8660_info,
2326 .csi_if = 1
2327};
2328struct platform_device msm_camera_sensor_vx6953 = {
2329 .name = "msm_camera_vx6953",
2330 .dev = {
2331 .platform_data = &msm_camera_sensor_vx6953_data,
2332 },
2333};
2334#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002335#ifdef CONFIG_QS_S5K4E1
2336
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302337static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2338#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2339 .mount_angle = 90
2340#else
2341 .mount_angle = 0
2342#endif
2343};
2344
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002345static char eeprom_data[864];
2346static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2347 .flash_type = MSM_CAMERA_FLASH_LED,
2348 .flash_src = &msm_flash_src
2349};
2350
2351static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2352 .sensor_name = "qs_s5k4e1",
2353 .sensor_reset = 106,
2354 .sensor_pwd = 85,
2355 .vcm_pwd = 1,
2356 .vcm_enable = 0,
2357 .pdata = &msm_camera_device_data_qs_cam,
2358 .resource = msm_camera_resources,
2359 .num_resources = ARRAY_SIZE(msm_camera_resources),
2360 .flash_data = &flash_qs_s5k4e1,
2361 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302362 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002363 .csi_if = 1,
2364 .eeprom_data = eeprom_data,
2365};
2366struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2367 .name = "msm_camera_qs_s5k4e1",
2368 .dev = {
2369 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2370 },
2371};
2372#endif
2373static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2374 #ifdef CONFIG_MT9E013
2375 {
2376 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2377 },
2378 #endif
2379 #ifdef CONFIG_IMX074
2380 {
2381 I2C_BOARD_INFO("imx074", 0x1A),
2382 },
2383 #endif
2384 #ifdef CONFIG_WEBCAM_OV7692
2385 {
2386 I2C_BOARD_INFO("ov7692", 0x78),
2387 },
2388 #endif
2389 #ifdef CONFIG_WEBCAM_OV9726
2390 {
2391 I2C_BOARD_INFO("ov9726", 0x10),
2392 },
2393 #endif
2394 #ifdef CONFIG_QS_S5K4E1
2395 {
2396 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2397 },
2398 #endif
2399};
Jilai Wang971f97f2011-07-13 14:25:25 -04002400
2401static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002402 #ifdef CONFIG_WEBCAM_OV9726
2403 {
2404 I2C_BOARD_INFO("ov9726", 0x10),
2405 },
2406 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002407 #ifdef CONFIG_VX6953
2408 {
2409 I2C_BOARD_INFO("vx6953", 0x20),
2410 },
2411 #endif
2412};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002413#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002414#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002415
2416#ifdef CONFIG_MSM_GEMINI
2417static struct resource msm_gemini_resources[] = {
2418 {
2419 .start = 0x04600000,
2420 .end = 0x04600000 + SZ_1M - 1,
2421 .flags = IORESOURCE_MEM,
2422 },
2423 {
2424 .start = INT_JPEG,
2425 .end = INT_JPEG,
2426 .flags = IORESOURCE_IRQ,
2427 },
2428};
2429
2430static struct platform_device msm_gemini_device = {
2431 .name = "msm_gemini",
2432 .resource = msm_gemini_resources,
2433 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2434};
2435#endif
2436
2437#ifdef CONFIG_I2C_QUP
2438static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2439{
2440}
2441
2442static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2443 .clk_freq = 384000,
2444 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002445 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2446};
2447
2448static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2449 .clk_freq = 100000,
2450 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002451 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2452};
2453
2454static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2455 .clk_freq = 100000,
2456 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002457 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2458};
2459
2460static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2461 .clk_freq = 100000,
2462 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002463 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2464};
2465
2466static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2467 .clk_freq = 100000,
2468 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002469 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2470};
2471
2472static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2473 .clk_freq = 100000,
2474 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002475 .use_gsbi_shared_mode = 1,
2476 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2477};
2478#endif
2479
2480#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2481static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2482 .max_clock_speed = 24000000,
2483};
2484
2485static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2486 .max_clock_speed = 24000000,
2487};
2488#endif
2489
2490#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002491/* CODEC/TSSC SSBI */
2492static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2493 .controller_type = MSM_SBI_CTRL_SSBI,
2494};
2495#endif
2496
2497#ifdef CONFIG_BATTERY_MSM
2498/* Use basic value for fake MSM battery */
2499static struct msm_psy_batt_pdata msm_psy_batt_data = {
2500 .avail_chg_sources = AC_CHG,
2501};
2502
2503static struct platform_device msm_batt_device = {
2504 .name = "msm-battery",
2505 .id = -1,
2506 .dev.platform_data = &msm_psy_batt_data,
2507};
2508#endif
2509
2510#ifdef CONFIG_FB_MSM_LCDC_DSUB
2511/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2512 prim = 1024 x 600 x 4(bpp) x 2(pages)
2513 This is the difference. */
2514#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2515#else
2516#define MSM_FB_DSUB_PMEM_ADDER (0)
2517#endif
2518
2519/* Sensors DSPS platform data */
2520#ifdef CONFIG_MSM_DSPS
2521
2522static struct dsps_gpio_info dsps_surf_gpios[] = {
2523 {
2524 .name = "compass_rst_n",
2525 .num = GPIO_COMPASS_RST_N,
2526 .on_val = 1, /* device not in reset */
2527 .off_val = 0, /* device in reset */
2528 },
2529 {
2530 .name = "gpio_r_altimeter_reset_n",
2531 .num = GPIO_R_ALTIMETER_RESET_N,
2532 .on_val = 1, /* device not in reset */
2533 .off_val = 0, /* device in reset */
2534 }
2535};
2536
2537static struct dsps_gpio_info dsps_fluid_gpios[] = {
2538 {
2539 .name = "gpio_n_altimeter_reset_n",
2540 .num = GPIO_N_ALTIMETER_RESET_N,
2541 .on_val = 1, /* device not in reset */
2542 .off_val = 0, /* device in reset */
2543 }
2544};
2545
2546static void __init msm8x60_init_dsps(void)
2547{
2548 struct msm_dsps_platform_data *pdata =
2549 msm_dsps_device.dev.platform_data;
2550 /*
2551 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2552 * to the power supply and not controled via GPIOs. Fluid uses a
2553 * different IO-Expender (north) than used on surf/ffa.
2554 */
2555 if (machine_is_msm8x60_fluid()) {
2556 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002557 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002558 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002559 pdata->gpios = dsps_fluid_gpios;
2560 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2561 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002562 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002563 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002564 pdata->gpios = dsps_surf_gpios;
2565 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2566 }
2567
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002568 platform_device_register(&msm_dsps_device);
2569}
2570#endif /* CONFIG_MSM_DSPS */
2571
2572#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302573#define MSM_FB_PRIM_BUF_SIZE \
2574 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002575#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302576#define MSM_FB_PRIM_BUF_SIZE \
2577 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002578#endif
2579
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002580#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302581#define MSM_FB_EXT_BUF_SIZE \
2582 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002583#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302584#define MSM_FB_EXT_BUF_SIZE \
2585 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002586#else
Ajay Singh Parmardf694562012-06-05 15:06:21 +05302587#define MSM_FB_EXT_BUF_SIZE 0
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002588#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002589
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002590/* Note: must be multiple of 4096 */
2591#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002592 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002593
2594#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302595#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002596
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002597#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002598unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002599#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002600unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002601#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002602
Huaibin Yanga5419422011-12-08 23:52:10 -08002603#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2604#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2605#else
2606#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2607#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2608
2609#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2610#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2611#else
2612#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2613#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2614
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302615#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002616#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302617#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002618
2619#define MSM_SMI_BASE 0x38000000
2620#define MSM_SMI_SIZE 0x4000000
2621
2622#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302623#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2624#define KERNEL_SMI_SIZE 0x000000
2625#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002626#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302627#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002628
2629#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2630#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2631#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2632
Chintan Pandya490c9712012-08-07 17:19:59 +05302633#ifdef CONFIG_MSM_CP
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302634#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
Chintan Pandya490c9712012-08-07 17:19:59 +05302635#else
2636#define MSM_ION_HOLE_SIZE 0
2637#endif
2638
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302639#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2640#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2641#define MSM_ION_MFC_SIZE SZ_8K
2642
2643#define MSM_MM_FW_BASE MSM_SMI_BASE
2644#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2645#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2646#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2647
Chintan Pandya490c9712012-08-07 17:19:59 +05302648#ifdef CONFIG_MSM_CP
2649#define SECURE_BASE (MSM_ION_HOLE_BASE)
2650#define SECURE_SIZE (MSM_ION_MM_SIZE + MSM_ION_HOLE_SIZE)
2651#else
2652#define SECURE_BASE (MSM_MM_FW_BASE)
2653#define SECURE_SIZE (MSM_ION_MM_SIZE + MSM_MM_FW_SIZE)
2654#endif
2655
Naseer Ahmed51860b02012-02-07 18:53:29 +05302656#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002657#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302658
Mayank Choprac22ace32012-03-03 00:45:04 +05302659#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2660#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2661#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002662#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302663#endif
2664
Olav Haugan424ff492012-03-13 11:41:23 -07002665#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002666
2667#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302668#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002669#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002670#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2671static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002672#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002673#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002674#endif
2675
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002676static unsigned fb_size;
2677static int __init fb_size_setup(char *p)
2678{
2679 fb_size = memparse(p, NULL);
2680 return 0;
2681}
2682early_param("fb_size", fb_size_setup);
2683
2684static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2685static int __init pmem_kernel_ebi1_size_setup(char *p)
2686{
2687 pmem_kernel_ebi1_size = memparse(p, NULL);
2688 return 0;
2689}
2690early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2691
2692#ifdef CONFIG_ANDROID_PMEM
2693static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2694static int __init pmem_sf_size_setup(char *p)
2695{
2696 pmem_sf_size = memparse(p, NULL);
2697 return 0;
2698}
2699early_param("pmem_sf_size", pmem_sf_size_setup);
2700
2701static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2702
2703static int __init pmem_adsp_size_setup(char *p)
2704{
2705 pmem_adsp_size = memparse(p, NULL);
2706 return 0;
2707}
2708early_param("pmem_adsp_size", pmem_adsp_size_setup);
2709
2710static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2711
2712static int __init pmem_audio_size_setup(char *p)
2713{
2714 pmem_audio_size = memparse(p, NULL);
2715 return 0;
2716}
2717early_param("pmem_audio_size", pmem_audio_size_setup);
2718#endif
2719
2720static struct resource msm_fb_resources[] = {
2721 {
2722 .flags = IORESOURCE_DMA,
2723 }
2724};
2725
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002726static void set_mdp_clocks_for_wuxga(void);
2727
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002728static int msm_fb_detect_panel(const char *name)
2729{
2730 if (machine_is_msm8x60_fluid()) {
2731 uint32_t soc_platform_version = socinfo_get_platform_version();
2732 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2733#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2734 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002735 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2736 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002737 return 0;
2738#endif
2739 } else { /*P3 and up use AUO panel */
2740#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2741 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002742 strnlen(LCDC_AUO_PANEL_NAME,
2743 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744 return 0;
2745#endif
2746 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002747#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2748 } else if machine_is_msm8x60_dragon() {
2749 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002750 strnlen(LCDC_NT35582_PANEL_NAME,
2751 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002752 return 0;
2753#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002754 } else {
2755 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002756 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2757 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002758 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002759
2760#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2761 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2762 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2763 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2764 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2765 PANEL_NAME_MAX_LEN)))
2766 return 0;
2767
2768 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2769 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2770 PANEL_NAME_MAX_LEN)))
2771 return 0;
2772
2773 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2774 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2775 PANEL_NAME_MAX_LEN)))
2776 return 0;
2777#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002778 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002779
2780 if (!strncmp(name, HDMI_PANEL_NAME,
2781 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002782 PANEL_NAME_MAX_LEN))) {
2783 if (hdmi_is_primary)
2784 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002785 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002786 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002787
2788 if (!strncmp(name, TVOUT_PANEL_NAME,
2789 strnlen(TVOUT_PANEL_NAME,
2790 PANEL_NAME_MAX_LEN)))
2791 return 0;
2792
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002793 pr_warning("%s: not supported '%s'", __func__, name);
2794 return -ENODEV;
2795}
2796
2797static struct msm_fb_platform_data msm_fb_pdata = {
2798 .detect_client = msm_fb_detect_panel,
2799};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002800
2801static struct platform_device msm_fb_device = {
2802 .name = "msm_fb",
2803 .id = 0,
2804 .num_resources = ARRAY_SIZE(msm_fb_resources),
2805 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002806 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002807};
2808
2809#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002810#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002811static struct android_pmem_platform_data android_pmem_pdata = {
2812 .name = "pmem",
2813 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2814 .cached = 1,
2815 .memory_type = MEMTYPE_EBI1,
2816};
2817
2818static struct platform_device android_pmem_device = {
2819 .name = "android_pmem",
2820 .id = 0,
2821 .dev = {.platform_data = &android_pmem_pdata},
2822};
2823
2824static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2825 .name = "pmem_adsp",
2826 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2827 .cached = 0,
2828 .memory_type = MEMTYPE_EBI1,
2829};
2830
2831static struct platform_device android_pmem_adsp_device = {
2832 .name = "android_pmem",
2833 .id = 2,
2834 .dev = { .platform_data = &android_pmem_adsp_pdata },
2835};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302836
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002837static struct android_pmem_platform_data android_pmem_audio_pdata = {
2838 .name = "pmem_audio",
2839 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2840 .cached = 0,
2841 .memory_type = MEMTYPE_EBI1,
2842};
2843
2844static struct platform_device android_pmem_audio_device = {
2845 .name = "android_pmem",
2846 .id = 4,
2847 .dev = { .platform_data = &android_pmem_audio_pdata },
2848};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302849#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002850#define PMEM_BUS_WIDTH(_bw) \
2851 { \
2852 .vectors = &(struct msm_bus_vectors){ \
2853 .src = MSM_BUS_MASTER_AMPSS_M0, \
2854 .dst = MSM_BUS_SLAVE_SMI, \
2855 .ib = (_bw), \
2856 .ab = 0, \
2857 }, \
2858 .num_paths = 1, \
2859 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002860
2861static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002862 [0] = PMEM_BUS_WIDTH(0), /* Off */
2863 [1] = PMEM_BUS_WIDTH(1), /* On */
2864};
2865
2866static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002867 .usecase = mem_smi_table,
2868 .num_usecases = ARRAY_SIZE(mem_smi_table),
2869 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002870};
2871
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002872int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002873{
2874 int bus_id = (int) data;
2875
2876 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002877 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002878}
2879
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002880int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002881{
2882 int bus_id = (int) data;
2883
2884 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002885 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002886}
2887
Alex Bird199980e2011-10-21 11:29:27 -07002888void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002889{
2890 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2891}
Olav Hauganee0f7802011-12-19 13:28:57 -08002892#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002893static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2894 .name = "pmem_smipool",
2895 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2896 .cached = 0,
2897 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002898 .request_region = request_smi_region,
2899 .release_region = release_smi_region,
2900 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002901 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002902};
2903static struct platform_device android_pmem_smipool_device = {
2904 .name = "android_pmem",
2905 .id = 7,
2906 .dev = { .platform_data = &android_pmem_smipool_pdata },
2907};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302908#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2909#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002910
2911#define GPIO_DONGLE_PWR_EN 258
2912static void setup_display_power(void);
2913static int lcdc_vga_enabled;
2914static int vga_enable_request(int enable)
2915{
2916 if (enable)
2917 lcdc_vga_enabled = 1;
2918 else
2919 lcdc_vga_enabled = 0;
2920 setup_display_power();
2921
2922 return 0;
2923}
2924
2925#define GPIO_BACKLIGHT_PWM0 0
2926#define GPIO_BACKLIGHT_PWM1 1
2927
2928static int pmic_backlight_gpio[2]
2929 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2930static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2931 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2932 .vga_switch = vga_enable_request,
2933};
2934
2935static struct platform_device lcdc_samsung_panel_device = {
2936 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2937 .id = 0,
2938 .dev = {
2939 .platform_data = &lcdc_samsung_panel_data,
2940 }
2941};
2942#if (!defined(CONFIG_SPI_QUP)) && \
2943 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2944 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2945
2946static int lcdc_spi_gpio_array_num[] = {
2947 LCDC_SPI_GPIO_CLK,
2948 LCDC_SPI_GPIO_CS,
2949 LCDC_SPI_GPIO_MOSI,
2950};
2951
2952static uint32_t lcdc_spi_gpio_config_data[] = {
2953 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2954 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2955 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2956 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2957 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2958 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2959};
2960
2961static void lcdc_config_spi_gpios(int enable)
2962{
2963 int n;
2964 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2965 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2966}
2967#endif
2968
2969#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2970#ifdef CONFIG_SPI_QUP
2971static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2972 {
2973 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2974 .mode = SPI_MODE_3,
2975 .bus_num = 1,
2976 .chip_select = 0,
2977 .max_speed_hz = 10800000,
2978 }
2979};
2980#endif /* CONFIG_SPI_QUP */
2981
2982static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2983#ifndef CONFIG_SPI_QUP
2984 .panel_config_gpio = lcdc_config_spi_gpios,
2985 .gpio_num = lcdc_spi_gpio_array_num,
2986#endif
2987};
2988
2989static struct platform_device lcdc_samsung_oled_panel_device = {
2990 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2991 .id = 0,
2992 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2993};
2994#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2995
2996#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2997#ifdef CONFIG_SPI_QUP
2998static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
2999 {
3000 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3001 .mode = SPI_MODE_3,
3002 .bus_num = 1,
3003 .chip_select = 0,
3004 .max_speed_hz = 10800000,
3005 }
3006};
3007#endif
3008
3009static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3010#ifndef CONFIG_SPI_QUP
3011 .panel_config_gpio = lcdc_config_spi_gpios,
3012 .gpio_num = lcdc_spi_gpio_array_num,
3013#endif
3014};
3015
3016static struct platform_device lcdc_auo_wvga_panel_device = {
3017 .name = LCDC_AUO_PANEL_NAME,
3018 .id = 0,
3019 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3020};
3021#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3022
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003023#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3024
3025#define GPIO_NT35582_RESET 94
3026#define GPIO_NT35582_BL_EN_HW_PIN 24
3027#define GPIO_NT35582_BL_EN \
3028 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3029
3030static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3031
3032static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3033 .gpio_num = lcdc_nt35582_pmic_gpio,
3034};
3035
3036static struct platform_device lcdc_nt35582_panel_device = {
3037 .name = LCDC_NT35582_PANEL_NAME,
3038 .id = 0,
3039 .dev = {
3040 .platform_data = &lcdc_nt35582_panel_data,
3041 }
3042};
3043
3044static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3045 {
3046 .modalias = "lcdc_nt35582_spi",
3047 .mode = SPI_MODE_0,
3048 .bus_num = 0,
3049 .chip_select = 0,
3050 .max_speed_hz = 1100000,
3051 }
3052};
3053#endif
3054
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003055#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3056static struct resource hdmi_msm_resources[] = {
3057 {
3058 .name = "hdmi_msm_qfprom_addr",
3059 .start = 0x00700000,
3060 .end = 0x007060FF,
3061 .flags = IORESOURCE_MEM,
3062 },
3063 {
3064 .name = "hdmi_msm_hdmi_addr",
3065 .start = 0x04A00000,
3066 .end = 0x04A00FFF,
3067 .flags = IORESOURCE_MEM,
3068 },
3069 {
3070 .name = "hdmi_msm_irq",
3071 .start = HDMI_IRQ,
3072 .end = HDMI_IRQ,
3073 .flags = IORESOURCE_IRQ,
3074 },
3075};
3076
3077static int hdmi_enable_5v(int on);
3078static int hdmi_core_power(int on, int show);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303079static int hdmi_gpio_config(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003080static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303081static int hdmi_panel_power(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003082
3083static struct msm_hdmi_platform_data hdmi_msm_data = {
3084 .irq = HDMI_IRQ,
3085 .enable_5v = hdmi_enable_5v,
3086 .core_power = hdmi_core_power,
3087 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303088 .panel_power = hdmi_panel_power,
3089 .gpio_config = hdmi_gpio_config,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003090};
3091
3092static struct platform_device hdmi_msm_device = {
3093 .name = "hdmi_msm",
3094 .id = 0,
3095 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3096 .resource = hdmi_msm_resources,
3097 .dev.platform_data = &hdmi_msm_data,
3098};
3099#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3100
3101#ifdef CONFIG_FB_MSM_MIPI_DSI
3102static struct platform_device mipi_dsi_toshiba_panel_device = {
3103 .name = "mipi_toshiba",
3104 .id = 0,
3105};
3106
3107#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3108
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003109static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003110 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003111 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003112};
3113
3114static struct platform_device mipi_dsi_novatek_panel_device = {
3115 .name = "mipi_novatek",
3116 .id = 0,
3117 .dev = {
3118 .platform_data = &novatek_pdata,
3119 }
3120};
3121#endif
3122
3123static void __init msm8x60_allocate_memory_regions(void)
3124{
3125 void *addr;
3126 unsigned long size;
3127
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003128 if (hdmi_is_primary)
3129 size = roundup((1920 * 1088 * 4 * 2), 4096);
3130 else
3131 size = MSM_FB_SIZE;
3132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003133 addr = alloc_bootmem_align(size, 0x1000);
3134 msm_fb_resources[0].start = __pa(addr);
3135 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3136 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3137 size, addr, __pa(addr));
3138
3139}
3140
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003141void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3142{
3143 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3144 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3145 PANEL_NAME_MAX_LEN);
3146 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3147 msm_fb_pdata.prim_panel_name);
3148
3149 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3150 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3151 PANEL_NAME_MAX_LEN))) {
3152 pr_debug("HDMI is the primary display by"
3153 " boot parameter\n");
3154 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003155 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003156 }
3157 }
3158 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3159 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3160 PANEL_NAME_MAX_LEN);
3161 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3162 msm_fb_pdata.ext_panel_name);
3163 }
3164}
3165
Steve Mucklef132c6c2012-06-06 18:30:57 -07003166#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3167 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003168/*virtual key support */
3169static ssize_t tma300_vkeys_show(struct kobject *kobj,
3170 struct kobj_attribute *attr, char *buf)
3171{
3172 return sprintf(buf,
3173 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3174 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3175 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3176 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3177 "\n");
3178}
3179
3180static struct kobj_attribute tma300_vkeys_attr = {
3181 .attr = {
3182 .mode = S_IRUGO,
3183 },
3184 .show = &tma300_vkeys_show,
3185};
3186
3187static struct attribute *tma300_properties_attrs[] = {
3188 &tma300_vkeys_attr.attr,
3189 NULL
3190};
3191
3192static struct attribute_group tma300_properties_attr_group = {
3193 .attrs = tma300_properties_attrs,
3194};
3195
3196static struct kobject *properties_kobj;
3197
3198
3199
3200#define CYTTSP_TS_GPIO_IRQ 61
3201static int cyttsp_platform_init(struct i2c_client *client)
3202{
3203 int rc = -EINVAL;
3204 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3205
3206 if (machine_is_msm8x60_fluid()) {
3207 pm8058_l5 = regulator_get(NULL, "8058_l5");
3208 if (IS_ERR(pm8058_l5)) {
3209 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3210 __func__, PTR_ERR(pm8058_l5));
3211 rc = PTR_ERR(pm8058_l5);
3212 return rc;
3213 }
3214 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3215 if (rc) {
3216 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3217 __func__, rc);
3218 goto reg_l5_put;
3219 }
3220
3221 rc = regulator_enable(pm8058_l5);
3222 if (rc) {
3223 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3224 __func__, rc);
3225 goto reg_l5_put;
3226 }
3227 }
3228 /* vote for s3 to enable i2c communication lines */
3229 pm8058_s3 = regulator_get(NULL, "8058_s3");
3230 if (IS_ERR(pm8058_s3)) {
3231 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3232 __func__, PTR_ERR(pm8058_s3));
3233 rc = PTR_ERR(pm8058_s3);
3234 goto reg_l5_disable;
3235 }
3236
3237 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3238 if (rc) {
3239 pr_err("%s: regulator_set_voltage() = %d\n",
3240 __func__, rc);
3241 goto reg_s3_put;
3242 }
3243
3244 rc = regulator_enable(pm8058_s3);
3245 if (rc) {
3246 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3247 __func__, rc);
3248 goto reg_s3_put;
3249 }
3250
3251 /* wait for vregs to stabilize */
3252 usleep_range(10000, 10000);
3253
3254 /* check this device active by reading first byte/register */
3255 rc = i2c_smbus_read_byte_data(client, 0x01);
3256 if (rc < 0) {
3257 pr_err("%s: i2c sanity check failed\n", __func__);
3258 goto reg_s3_disable;
3259 }
3260
3261 /* virtual keys */
3262 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003263 properties_kobj = kobject_create_and_add("board_properties",
3264 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003265 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003266 if (!properties_kobj || rc)
3267 pr_err("%s: failed to create board_properties\n",
3268 __func__);
3269 }
3270 return CY_OK;
3271
3272reg_s3_disable:
3273 regulator_disable(pm8058_s3);
3274reg_s3_put:
3275 regulator_put(pm8058_s3);
3276reg_l5_disable:
3277 if (machine_is_msm8x60_fluid())
3278 regulator_disable(pm8058_l5);
3279reg_l5_put:
3280 if (machine_is_msm8x60_fluid())
3281 regulator_put(pm8058_l5);
3282 return rc;
3283}
3284
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303285/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3286static int cyttsp_platform_suspend(struct i2c_client *client)
3287{
3288 msleep(20);
3289
3290 return CY_OK;
3291}
3292
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003293static int cyttsp_platform_resume(struct i2c_client *client)
3294{
3295 /* add any special code to strobe a wakeup pin or chip reset */
3296 msleep(10);
3297
3298 return CY_OK;
3299}
3300
3301static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3302 .flags = 0x04,
3303 .gen = CY_GEN3, /* or */
3304 .use_st = CY_USE_ST,
3305 .use_mt = CY_USE_MT,
3306 .use_hndshk = CY_SEND_HNDSHK,
3307 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303308 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003309 .use_gestures = CY_USE_GESTURES,
3310 /* activate up to 4 groups
3311 * and set active distance
3312 */
3313 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3314 CY_GEST_GRP3 | CY_GEST_GRP4 |
3315 CY_ACT_DIST,
3316 /* change act_intrvl to customize the Active power state
3317 * scanning/processing refresh interval for Operating mode
3318 */
3319 .act_intrvl = CY_ACT_INTRVL_DFLT,
3320 /* change tch_tmout to customize the touch timeout for the
3321 * Active power state for Operating mode
3322 */
3323 .tch_tmout = CY_TCH_TMOUT_DFLT,
3324 /* change lp_intrvl to customize the Low Power power state
3325 * scanning/processing refresh interval for Operating mode
3326 */
3327 .lp_intrvl = CY_LP_INTRVL_DFLT,
3328 .sleep_gpio = -1,
3329 .resout_gpio = -1,
3330 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3331 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303332 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003333 .init = cyttsp_platform_init,
3334};
3335
3336static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3337 .panel_maxx = 1083,
3338 .panel_maxy = 659,
3339 .disp_minx = 30,
3340 .disp_maxx = 1053,
3341 .disp_miny = 30,
3342 .disp_maxy = 629,
3343 .correct_fw_ver = 8,
3344 .fw_fname = "cyttsp_8660_ffa.hex",
3345 .flags = 0x00,
3346 .gen = CY_GEN2, /* or */
3347 .use_st = CY_USE_ST,
3348 .use_mt = CY_USE_MT,
3349 .use_hndshk = CY_SEND_HNDSHK,
3350 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303351 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003352 .use_gestures = CY_USE_GESTURES,
3353 /* activate up to 4 groups
3354 * and set active distance
3355 */
3356 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3357 CY_GEST_GRP3 | CY_GEST_GRP4 |
3358 CY_ACT_DIST,
3359 /* change act_intrvl to customize the Active power state
3360 * scanning/processing refresh interval for Operating mode
3361 */
3362 .act_intrvl = CY_ACT_INTRVL_DFLT,
3363 /* change tch_tmout to customize the touch timeout for the
3364 * Active power state for Operating mode
3365 */
3366 .tch_tmout = CY_TCH_TMOUT_DFLT,
3367 /* change lp_intrvl to customize the Low Power power state
3368 * scanning/processing refresh interval for Operating mode
3369 */
3370 .lp_intrvl = CY_LP_INTRVL_DFLT,
3371 .sleep_gpio = -1,
3372 .resout_gpio = -1,
3373 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3374 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303375 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003376 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303377 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003378};
3379static void cyttsp_set_params(void)
3380{
3381 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3382 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3383 cyttsp_fluid_pdata.panel_maxx = 539;
3384 cyttsp_fluid_pdata.panel_maxy = 994;
3385 cyttsp_fluid_pdata.disp_minx = 30;
3386 cyttsp_fluid_pdata.disp_maxx = 509;
3387 cyttsp_fluid_pdata.disp_miny = 60;
3388 cyttsp_fluid_pdata.disp_maxy = 859;
3389 cyttsp_fluid_pdata.correct_fw_ver = 4;
3390 } else {
3391 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3392 cyttsp_fluid_pdata.panel_maxx = 550;
3393 cyttsp_fluid_pdata.panel_maxy = 1013;
3394 cyttsp_fluid_pdata.disp_minx = 35;
3395 cyttsp_fluid_pdata.disp_maxx = 515;
3396 cyttsp_fluid_pdata.disp_miny = 69;
3397 cyttsp_fluid_pdata.disp_maxy = 869;
3398 cyttsp_fluid_pdata.correct_fw_ver = 5;
3399 }
3400
3401}
3402
3403static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3404 {
3405 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3406 .platform_data = &cyttsp_fluid_pdata,
3407#ifndef CY_USE_TIMER
3408 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3409#endif /* CY_USE_TIMER */
3410 },
3411};
3412
3413static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3414 {
3415 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3416 .platform_data = &cyttsp_tmg240_pdata,
3417#ifndef CY_USE_TIMER
3418 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3419#endif /* CY_USE_TIMER */
3420 },
3421};
3422#endif
3423
3424static struct regulator *vreg_tmg200;
3425
3426#define TS_PEN_IRQ_GPIO 61
3427static int tmg200_power(int vreg_on)
3428{
3429 int rc = -EINVAL;
3430
3431 if (!vreg_tmg200) {
3432 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3433 __func__, rc);
3434 return rc;
3435 }
3436
3437 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3438 regulator_disable(vreg_tmg200);
3439 if (rc < 0)
3440 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3441 __func__, vreg_on ? "enable" : "disable", rc);
3442
3443 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003444 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003445
3446 return rc;
3447}
3448
3449static int tmg200_dev_setup(bool enable)
3450{
3451 int rc;
3452
3453 if (enable) {
3454 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3455 if (IS_ERR(vreg_tmg200)) {
3456 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3457 __func__, PTR_ERR(vreg_tmg200));
3458 rc = PTR_ERR(vreg_tmg200);
3459 return rc;
3460 }
3461
3462 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3463 if (rc) {
3464 pr_err("%s: regulator_set_voltage() = %d\n",
3465 __func__, rc);
3466 goto reg_put;
3467 }
3468 } else {
3469 /* put voltage sources */
3470 regulator_put(vreg_tmg200);
3471 }
3472 return 0;
3473reg_put:
3474 regulator_put(vreg_tmg200);
3475 return rc;
3476}
3477
3478static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3479 .ts_name = "msm_tmg200_ts",
3480 .dis_min_x = 0,
3481 .dis_max_x = 1023,
3482 .dis_min_y = 0,
3483 .dis_max_y = 599,
3484 .min_tid = 0,
3485 .max_tid = 255,
3486 .min_touch = 0,
3487 .max_touch = 255,
3488 .min_width = 0,
3489 .max_width = 255,
3490 .power_on = tmg200_power,
3491 .dev_setup = tmg200_dev_setup,
3492 .nfingers = 2,
3493 .irq_gpio = TS_PEN_IRQ_GPIO,
3494 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3495};
3496
3497static struct i2c_board_info cy8ctmg200_board_info[] = {
3498 {
3499 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3500 .platform_data = &cy8ctmg200_pdata,
3501 }
3502};
3503
Zhang Chang Ken211df572011-07-05 19:16:39 -04003504static struct regulator *vreg_tma340;
3505
3506static int tma340_power(int vreg_on)
3507{
3508 int rc = -EINVAL;
3509
3510 if (!vreg_tma340) {
3511 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3512 __func__, rc);
3513 return rc;
3514 }
3515
3516 rc = vreg_on ? regulator_enable(vreg_tma340) :
3517 regulator_disable(vreg_tma340);
3518 if (rc < 0)
3519 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3520 __func__, vreg_on ? "enable" : "disable", rc);
3521
3522 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003523 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003524
3525 return rc;
3526}
3527
3528static struct kobject *tma340_prop_kobj;
3529
3530static int tma340_dragon_dev_setup(bool enable)
3531{
3532 int rc;
3533
3534 if (enable) {
3535 vreg_tma340 = regulator_get(NULL, "8901_l2");
3536 if (IS_ERR(vreg_tma340)) {
3537 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3538 __func__, PTR_ERR(vreg_tma340));
3539 rc = PTR_ERR(vreg_tma340);
3540 return rc;
3541 }
3542
3543 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3544 if (rc) {
3545 pr_err("%s: regulator_set_voltage() = %d\n",
3546 __func__, rc);
3547 goto reg_put;
3548 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003549 tma340_prop_kobj = kobject_create_and_add("board_properties",
3550 NULL);
3551 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003552 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003553 if (rc) {
3554 kobject_put(tma340_prop_kobj);
3555 pr_err("%s: failed to create board_properties\n",
3556 __func__);
3557 goto reg_put;
3558 }
3559 }
3560
3561 } else {
3562 /* put voltage sources */
3563 regulator_put(vreg_tma340);
3564 /* destroy virtual keys */
3565 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003566 kobject_put(tma340_prop_kobj);
3567 }
3568 }
3569 return 0;
3570reg_put:
3571 regulator_put(vreg_tma340);
3572 return rc;
3573}
3574
3575
3576static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3577 .ts_name = "cy8ctma340",
3578 .dis_min_x = 0,
3579 .dis_max_x = 479,
3580 .dis_min_y = 0,
3581 .dis_max_y = 799,
3582 .min_tid = 0,
3583 .max_tid = 255,
3584 .min_touch = 0,
3585 .max_touch = 255,
3586 .min_width = 0,
3587 .max_width = 255,
3588 .power_on = tma340_power,
3589 .dev_setup = tma340_dragon_dev_setup,
3590 .nfingers = 2,
3591 .irq_gpio = TS_PEN_IRQ_GPIO,
3592 .resout_gpio = -1,
3593};
3594
3595static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3596 {
3597 I2C_BOARD_INFO("cy8ctma340", 0x24),
3598 .platform_data = &cy8ctma340_dragon_pdata,
3599 }
3600};
3601
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003602#ifdef CONFIG_SERIAL_MSM_HS
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003603static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
Mayank Rana60ae1af2013-03-08 14:09:51 +05303604 .inject_rx_on_wakeup = 1,
3605 .rx_to_inject = 0xFD,
3606 .config_gpio = 4,
3607 .uart_tx_gpio = 53,
3608 .uart_rx_gpio = 54,
3609 .uart_cts_gpio = 55,
3610 .uart_rfr_gpio = 56,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003611};
3612#endif
3613
3614
3615#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3616
3617static struct gpio_led gpio_exp_leds_config[] = {
3618 {
3619 .name = "left_led1:green",
3620 .gpio = GPIO_LEFT_LED_1,
3621 .active_low = 1,
3622 .retain_state_suspended = 0,
3623 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3624 },
3625 {
3626 .name = "left_led2:red",
3627 .gpio = GPIO_LEFT_LED_2,
3628 .active_low = 1,
3629 .retain_state_suspended = 0,
3630 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3631 },
3632 {
3633 .name = "left_led3:green",
3634 .gpio = GPIO_LEFT_LED_3,
3635 .active_low = 1,
3636 .retain_state_suspended = 0,
3637 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3638 },
3639 {
3640 .name = "wlan_led:orange",
3641 .gpio = GPIO_LEFT_LED_WLAN,
3642 .active_low = 1,
3643 .retain_state_suspended = 0,
3644 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3645 },
3646 {
3647 .name = "left_led5:green",
3648 .gpio = GPIO_LEFT_LED_5,
3649 .active_low = 1,
3650 .retain_state_suspended = 0,
3651 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3652 },
3653 {
3654 .name = "right_led1:green",
3655 .gpio = GPIO_RIGHT_LED_1,
3656 .active_low = 1,
3657 .retain_state_suspended = 0,
3658 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3659 },
3660 {
3661 .name = "right_led2:red",
3662 .gpio = GPIO_RIGHT_LED_2,
3663 .active_low = 1,
3664 .retain_state_suspended = 0,
3665 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3666 },
3667 {
3668 .name = "right_led3:green",
3669 .gpio = GPIO_RIGHT_LED_3,
3670 .active_low = 1,
3671 .retain_state_suspended = 0,
3672 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3673 },
3674 {
3675 .name = "bt_led:blue",
3676 .gpio = GPIO_RIGHT_LED_BT,
3677 .active_low = 1,
3678 .retain_state_suspended = 0,
3679 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3680 },
3681 {
3682 .name = "right_led5:green",
3683 .gpio = GPIO_RIGHT_LED_5,
3684 .active_low = 1,
3685 .retain_state_suspended = 0,
3686 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3687 },
3688};
3689
3690static struct gpio_led_platform_data gpio_leds_pdata = {
3691 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3692 .leds = gpio_exp_leds_config,
3693};
3694
3695static struct platform_device gpio_leds = {
3696 .name = "leds-gpio",
3697 .id = -1,
3698 .dev = {
3699 .platform_data = &gpio_leds_pdata,
3700 },
3701};
3702
3703static struct gpio_led fluid_gpio_leds[] = {
3704 {
3705 .name = "dual_led:green",
3706 .gpio = GPIO_LED1_GREEN_N,
3707 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3708 .active_low = 1,
3709 .retain_state_suspended = 0,
3710 },
3711 {
3712 .name = "dual_led:red",
3713 .gpio = GPIO_LED2_RED_N,
3714 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3715 .active_low = 1,
3716 .retain_state_suspended = 0,
3717 },
3718};
3719
3720static struct gpio_led_platform_data gpio_led_pdata = {
3721 .leds = fluid_gpio_leds,
3722 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3723};
3724
3725static struct platform_device fluid_leds_gpio = {
3726 .name = "leds-gpio",
3727 .id = -1,
3728 .dev = {
3729 .platform_data = &gpio_led_pdata,
3730 },
3731};
3732
3733#endif
3734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003735#ifdef CONFIG_BATTERY_MSM8X60
3736static struct msm_charger_platform_data msm_charger_data = {
3737 .safety_time = 180,
3738 .update_time = 1,
3739 .max_voltage = 4200,
3740 .min_voltage = 3200,
3741};
3742
3743static struct platform_device msm_charger_device = {
3744 .name = "msm-charger",
3745 .id = -1,
3746 .dev = {
3747 .platform_data = &msm_charger_data,
3748 }
3749};
3750#endif
3751
3752/*
3753 * Consumer specific regulator names:
3754 * regulator name consumer dev_name
3755 */
3756static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3757 REGULATOR_SUPPLY("8058_l0", NULL),
3758};
3759static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3760 REGULATOR_SUPPLY("8058_l1", NULL),
3761};
3762static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3763 REGULATOR_SUPPLY("8058_l2", NULL),
3764};
3765static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3766 REGULATOR_SUPPLY("8058_l3", NULL),
3767};
3768static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3769 REGULATOR_SUPPLY("8058_l4", NULL),
3770};
3771static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3772 REGULATOR_SUPPLY("8058_l5", NULL),
3773};
3774static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3775 REGULATOR_SUPPLY("8058_l6", NULL),
3776};
3777static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3778 REGULATOR_SUPPLY("8058_l7", NULL),
3779};
3780static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3781 REGULATOR_SUPPLY("8058_l8", NULL),
3782};
3783static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3784 REGULATOR_SUPPLY("8058_l9", NULL),
3785};
3786static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3787 REGULATOR_SUPPLY("8058_l10", NULL),
3788};
3789static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3790 REGULATOR_SUPPLY("8058_l11", NULL),
3791};
3792static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3793 REGULATOR_SUPPLY("8058_l12", NULL),
3794};
3795static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3796 REGULATOR_SUPPLY("8058_l13", NULL),
3797};
3798static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3799 REGULATOR_SUPPLY("8058_l14", NULL),
3800};
3801static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3802 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003803 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003804 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003805 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003806};
3807static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3808 REGULATOR_SUPPLY("8058_l16", NULL),
3809};
3810static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3811 REGULATOR_SUPPLY("8058_l17", NULL),
3812};
3813static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3814 REGULATOR_SUPPLY("8058_l18", NULL),
3815};
3816static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3817 REGULATOR_SUPPLY("8058_l19", NULL),
3818};
3819static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3820 REGULATOR_SUPPLY("8058_l20", NULL),
3821};
3822static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3823 REGULATOR_SUPPLY("8058_l21", NULL),
3824};
3825static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3826 REGULATOR_SUPPLY("8058_l22", NULL),
3827};
3828static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3829 REGULATOR_SUPPLY("8058_l23", NULL),
3830};
3831static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3832 REGULATOR_SUPPLY("8058_l24", NULL),
3833};
3834static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3835 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003836 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003837 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003838 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003839};
3840static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3841 REGULATOR_SUPPLY("8058_s0", NULL),
3842};
3843static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3844 REGULATOR_SUPPLY("8058_s1", NULL),
3845};
3846static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3847 REGULATOR_SUPPLY("8058_s2", NULL),
3848};
3849static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3850 REGULATOR_SUPPLY("8058_s3", NULL),
3851};
3852static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3853 REGULATOR_SUPPLY("8058_s4", NULL),
3854};
3855static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3856 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003857 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003858 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003859 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003860};
3861static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3862 REGULATOR_SUPPLY("8058_lvs1", NULL),
3863};
3864static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3865 REGULATOR_SUPPLY("8058_ncp", NULL),
3866};
3867
3868static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3869 REGULATOR_SUPPLY("8901_l0", NULL),
3870};
3871static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3872 REGULATOR_SUPPLY("8901_l1", NULL),
3873};
3874static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3875 REGULATOR_SUPPLY("8901_l2", NULL),
3876};
3877static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3878 REGULATOR_SUPPLY("8901_l3", NULL),
3879};
3880static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3881 REGULATOR_SUPPLY("8901_l4", NULL),
3882};
3883static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3884 REGULATOR_SUPPLY("8901_l5", NULL),
3885};
3886static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3887 REGULATOR_SUPPLY("8901_l6", NULL),
3888};
3889static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3890 REGULATOR_SUPPLY("8901_s2", NULL),
3891};
3892static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3893 REGULATOR_SUPPLY("8901_s3", NULL),
3894};
3895static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3896 REGULATOR_SUPPLY("8901_s4", NULL),
3897};
3898static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3899 REGULATOR_SUPPLY("8901_lvs0", NULL),
3900};
3901static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3902 REGULATOR_SUPPLY("8901_lvs1", NULL),
3903};
3904static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3905 REGULATOR_SUPPLY("8901_lvs2", NULL),
3906};
3907static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3908 REGULATOR_SUPPLY("8901_lvs3", NULL),
3909};
3910static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3911 REGULATOR_SUPPLY("8901_mvs0", NULL),
3912};
3913
David Collins6f032ba2011-08-31 14:08:15 -07003914/* Pin control regulators */
3915static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3916 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3919 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3920};
3921static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3922 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3923};
3924static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3925 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3926};
3927static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3928 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3929};
3930static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3931 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3932};
3933
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003934#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3935 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003936 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3937 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003938 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003939 .init_data = { \
3940 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003941 .valid_modes_mask = _modes, \
3942 .valid_ops_mask = _ops, \
3943 .min_uV = _min_uV, \
3944 .max_uV = _max_uV, \
3945 .input_uV = _min_uV, \
3946 .apply_uV = _apply_uV, \
3947 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003948 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003949 .consumer_supplies = vreg_consumers_##_id, \
3950 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003951 ARRAY_SIZE(vreg_consumers_##_id), \
3952 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003953 .id = RPM_VREG_ID_##_id, \
3954 .default_uV = _default_uV, \
3955 .peak_uA = _peak_uA, \
3956 .avg_uA = _avg_uA, \
3957 .pull_down_enable = _pull_down, \
3958 .pin_ctrl = _pin_ctrl, \
3959 .freq = RPM_VREG_FREQ_##_freq, \
3960 .pin_fn = _pin_fn, \
3961 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003962 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003963 .state = _state, \
3964 .sleep_selectable = _sleep_selectable, \
3965 }
3966
3967/* Pin control initialization */
3968#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3969 { \
3970 .init_data = { \
3971 .constraints = { \
3972 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3973 .always_on = _always_on, \
3974 }, \
3975 .num_consumer_supplies = \
3976 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3977 .consumer_supplies = vreg_consumers_##_id##_PC, \
3978 }, \
3979 .id = RPM_VREG_ID_##_id##_PC, \
3980 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003981 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003982 }
3983
3984/*
3985 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3986 * via the peak_uA value specified in the table below. If the value is less
3987 * than the high power min threshold for the regulator, then the regulator will
3988 * be set to LPM. Otherwise, it will be set to HPM.
3989 *
3990 * This value can be further overridden by specifying an initial mode via
3991 * .init_data.constraints.initial_mode.
3992 */
3993
David Collins6f032ba2011-08-31 14:08:15 -07003994#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
3995 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003996 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
3997 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
3998 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
3999 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4000 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004001 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4002 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004003 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004004 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004005 _sleep_selectable, _always_on)
4006
David Collins6f032ba2011-08-31 14:08:15 -07004007#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4008 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004009 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4010 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4011 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4012 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4013 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004014 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4015 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004016 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004017 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4018 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004019
David Collins6f032ba2011-08-31 14:08:15 -07004020#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004021 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4022 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004023 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4024 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004025 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004026 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4027 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004028
David Collins6f032ba2011-08-31 14:08:15 -07004029#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4031 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004032 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4033 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004034 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004035 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4036 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004037
David Collins6f032ba2011-08-31 14:08:15 -07004038#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4039#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4040#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4041#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4042#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004043
David Collins6f032ba2011-08-31 14:08:15 -07004044/* RPM early regulator constraints */
4045static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4046 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004047 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004048 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004049};
4050
David Collins6f032ba2011-08-31 14:08:15 -07004051/* RPM regulator constraints */
4052static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4053 /* ID a_on pd ss min_uV max_uV init_ip */
4054 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4055 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4056 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4057 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4058 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4059 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4060 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4061 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4062 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4063 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4064 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4065 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4066 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4067 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4068 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4069 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4070 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4071 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4072 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4073 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4074 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4075 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4076 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4077 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4078 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4079 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004080
David Collins6f032ba2011-08-31 14:08:15 -07004081 /* ID a_on pd ss min_uV max_uV init_ip freq */
4082 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4083 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4084 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4085
4086 /* ID a_on pd ss */
4087 RPM_VS(PM8058_LVS0, 0, 1, 0),
4088 RPM_VS(PM8058_LVS1, 0, 1, 0),
4089
4090 /* ID a_on pd ss min_uV max_uV */
4091 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4092
4093 /* ID a_on pd ss min_uV max_uV init_ip */
4094 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4095 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4096 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4097 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4098 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4099 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4100 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4101
4102 /* ID a_on pd ss min_uV max_uV init_ip freq */
4103 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4104 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4105 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4106
4107 /* ID a_on pd ss */
4108 RPM_VS(PM8901_LVS0, 1, 1, 0),
4109 RPM_VS(PM8901_LVS1, 0, 1, 0),
4110 RPM_VS(PM8901_LVS2, 0, 1, 0),
4111 RPM_VS(PM8901_LVS3, 0, 1, 0),
4112 RPM_VS(PM8901_MVS0, 0, 1, 0),
4113
4114 /* ID a_on pin_func pin_ctrl */
4115 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4116 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4117 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4118 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4119 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4120 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4121};
4122
4123static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4124 .init_data = rpm_regulator_early_init_data,
4125 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4126 .version = RPM_VREG_VERSION_8660,
4127 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4128 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4129};
4130
4131static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4132 .init_data = rpm_regulator_init_data,
4133 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4134 .version = RPM_VREG_VERSION_8660,
4135};
4136
4137static struct platform_device rpm_regulator_early_device = {
4138 .name = "rpm-regulator",
4139 .id = 0,
4140 .dev = {
4141 .platform_data = &rpm_regulator_early_pdata,
4142 },
4143};
4144
4145static struct platform_device rpm_regulator_device = {
4146 .name = "rpm-regulator",
4147 .id = 1,
4148 .dev = {
4149 .platform_data = &rpm_regulator_pdata,
4150 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004151};
4152
4153static struct platform_device *early_regulators[] __initdata = {
4154 &msm_device_saw_s0,
4155 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004156 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004157};
4158
4159static struct platform_device *early_devices[] __initdata = {
4160#ifdef CONFIG_MSM_BUS_SCALING
4161 &msm_bus_apps_fabric,
4162 &msm_bus_sys_fabric,
4163 &msm_bus_mm_fabric,
4164 &msm_bus_sys_fpb,
4165 &msm_bus_cpss_fpb,
4166#endif
4167 &msm_device_dmov_adm0,
4168 &msm_device_dmov_adm1,
4169};
4170
4171#if (defined(CONFIG_MARIMBA_CORE)) && \
4172 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4173
4174static int bluetooth_power(int);
4175static struct platform_device msm_bt_power_device = {
4176 .name = "bt_power",
4177 .id = -1,
4178 .dev = {
4179 .platform_data = &bluetooth_power,
4180 },
4181};
4182#endif
4183
4184static struct platform_device msm_tsens_device = {
4185 .name = "tsens-tm",
4186 .id = -1,
4187};
4188
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004189#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4190enum {
4191 SX150X_CORE,
4192 SX150X_DOCKING,
4193 SX150X_SURF,
4194 SX150X_LEFT_FHA,
4195 SX150X_RIGHT_FHA,
4196 SX150X_SOUTH,
4197 SX150X_NORTH,
4198 SX150X_CORE_FLUID,
4199};
4200
4201static struct sx150x_platform_data sx150x_data[] __initdata = {
4202 [SX150X_CORE] = {
4203 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4204 .oscio_is_gpo = false,
4205 .io_pullup_ena = 0x0c08,
4206 .io_pulldn_ena = 0x4060,
4207 .io_open_drain_ena = 0x000c,
4208 .io_polarity = 0,
4209 .irq_summary = -1, /* see fixup_i2c_configs() */
4210 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4211 },
4212 [SX150X_DOCKING] = {
4213 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4214 .oscio_is_gpo = false,
4215 .io_pullup_ena = 0x5e06,
4216 .io_pulldn_ena = 0x81b8,
4217 .io_open_drain_ena = 0,
4218 .io_polarity = 0,
4219 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4220 UI_INT2_N),
4221 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4222 GPIO_DOCKING_EXPANDER_BASE -
4223 GPIO_EXPANDER_GPIO_BASE,
4224 },
4225 [SX150X_SURF] = {
4226 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4227 .oscio_is_gpo = false,
4228 .io_pullup_ena = 0,
4229 .io_pulldn_ena = 0,
4230 .io_open_drain_ena = 0,
4231 .io_polarity = 0,
4232 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4233 UI_INT1_N),
4234 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4235 GPIO_SURF_EXPANDER_BASE -
4236 GPIO_EXPANDER_GPIO_BASE,
4237 },
4238 [SX150X_LEFT_FHA] = {
4239 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4240 .oscio_is_gpo = false,
4241 .io_pullup_ena = 0,
4242 .io_pulldn_ena = 0x40,
4243 .io_open_drain_ena = 0,
4244 .io_polarity = 0,
4245 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4246 UI_INT3_N),
4247 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4248 GPIO_LEFT_KB_EXPANDER_BASE -
4249 GPIO_EXPANDER_GPIO_BASE,
4250 },
4251 [SX150X_RIGHT_FHA] = {
4252 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4253 .oscio_is_gpo = true,
4254 .io_pullup_ena = 0,
4255 .io_pulldn_ena = 0,
4256 .io_open_drain_ena = 0,
4257 .io_polarity = 0,
4258 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4259 UI_INT3_N),
4260 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4261 GPIO_RIGHT_KB_EXPANDER_BASE -
4262 GPIO_EXPANDER_GPIO_BASE,
4263 },
4264 [SX150X_SOUTH] = {
4265 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4266 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4267 GPIO_SOUTH_EXPANDER_BASE -
4268 GPIO_EXPANDER_GPIO_BASE,
4269 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4270 },
4271 [SX150X_NORTH] = {
4272 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4273 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4274 GPIO_NORTH_EXPANDER_BASE -
4275 GPIO_EXPANDER_GPIO_BASE,
4276 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4277 .oscio_is_gpo = true,
4278 .io_open_drain_ena = 0x30,
4279 },
4280 [SX150X_CORE_FLUID] = {
4281 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4282 .oscio_is_gpo = false,
4283 .io_pullup_ena = 0x0408,
4284 .io_pulldn_ena = 0x4060,
4285 .io_open_drain_ena = 0x0008,
4286 .io_polarity = 0,
4287 .irq_summary = -1, /* see fixup_i2c_configs() */
4288 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4289 },
4290};
4291
4292#ifdef CONFIG_SENSORS_MSM_ADC
4293/* Configuration of EPM expander is done when client
4294 * request an adc read
4295 */
4296static struct sx150x_platform_data sx150x_epmdata = {
4297 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4298 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4299 GPIO_EPM_EXPANDER_BASE -
4300 GPIO_EXPANDER_GPIO_BASE,
4301 .irq_summary = -1,
4302};
4303#endif
4304
4305/* sx150x_low_power_cfg
4306 *
4307 * This data and init function are used to put unused gpio-expander output
4308 * lines into their low-power states at boot. The init
4309 * function must be deferred until a later init stage because the i2c
4310 * gpio expander drivers do not probe until after they are registered
4311 * (see register_i2c_devices) and the work-queues for those registrations
4312 * are processed. Because these lines are unused, there is no risk of
4313 * competing with a device driver for the gpio.
4314 *
4315 * gpio lines whose low-power states are input are naturally in their low-
4316 * power configurations once probed, see the platform data structures above.
4317 */
4318struct sx150x_low_power_cfg {
4319 unsigned gpio;
4320 unsigned val;
4321};
4322
4323static struct sx150x_low_power_cfg
4324common_sx150x_lp_cfgs[] __initdata = {
4325 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4326 {GPIO_EXT_GPS_LNA_EN, 0},
4327 {GPIO_MSM_WAKES_BT, 0},
4328 {GPIO_USB_UICC_EN, 0},
4329 {GPIO_BATT_GAUGE_EN, 0},
4330};
4331
4332static struct sx150x_low_power_cfg
4333surf_ffa_sx150x_lp_cfgs[] __initdata = {
4334 {GPIO_MIPI_DSI_RST_N, 0},
4335 {GPIO_DONGLE_PWR_EN, 0},
4336 {GPIO_CAP_TS_SLEEP, 1},
4337 {GPIO_WEB_CAMIF_RESET_N, 0},
4338};
4339
4340static void __init
4341cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4342{
4343 unsigned n;
4344 int rc;
4345
4346 for (n = 0; n < nelems; ++n) {
4347 rc = gpio_request(cfgs[n].gpio, NULL);
4348 if (!rc) {
4349 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4350 gpio_free(cfgs[n].gpio);
4351 }
4352
4353 if (rc) {
4354 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4355 __func__, cfgs[n].gpio, rc);
4356 }
Steve Muckle9161d302010-02-11 11:50:40 -08004357 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004358}
4359
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004360static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004361{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4363 ARRAY_SIZE(common_sx150x_lp_cfgs));
4364 if (!machine_is_msm8x60_fluid())
4365 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4366 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4367 return 0;
4368}
4369module_init(cfg_sx150xs_low_power);
4370
4371#ifdef CONFIG_I2C
4372static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4373 {
4374 I2C_BOARD_INFO("sx1509q", 0x3e),
4375 .platform_data = &sx150x_data[SX150X_CORE]
4376 },
4377};
4378
4379static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4380 {
4381 I2C_BOARD_INFO("sx1509q", 0x3f),
4382 .platform_data = &sx150x_data[SX150X_DOCKING]
4383 },
4384};
4385
4386static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4387 {
4388 I2C_BOARD_INFO("sx1509q", 0x70),
4389 .platform_data = &sx150x_data[SX150X_SURF]
4390 }
4391};
4392
4393static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4394 {
4395 I2C_BOARD_INFO("sx1508q", 0x21),
4396 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4397 },
4398 {
4399 I2C_BOARD_INFO("sx1508q", 0x22),
4400 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4401 }
4402};
4403
4404static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4405 {
4406 I2C_BOARD_INFO("sx1508q", 0x23),
4407 .platform_data = &sx150x_data[SX150X_SOUTH]
4408 },
4409 {
4410 I2C_BOARD_INFO("sx1508q", 0x20),
4411 .platform_data = &sx150x_data[SX150X_NORTH]
4412 }
4413};
4414
4415static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4416 {
4417 I2C_BOARD_INFO("sx1509q", 0x3e),
4418 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4419 },
4420};
4421
4422#ifdef CONFIG_SENSORS_MSM_ADC
4423static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4424 {
4425 I2C_BOARD_INFO("sx1509q", 0x3e),
4426 .platform_data = &sx150x_epmdata
4427 },
4428};
4429#endif
4430#endif
4431#endif
4432
4433#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004434
4435static struct adc_access_fn xoadc_fn = {
4436 pm8058_xoadc_select_chan_and_start_conv,
4437 pm8058_xoadc_read_adc_code,
4438 pm8058_xoadc_get_properties,
4439 pm8058_xoadc_slot_request,
4440 pm8058_xoadc_restore_slot,
4441 pm8058_xoadc_calibrate,
4442};
4443
4444#if defined(CONFIG_I2C) && \
4445 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4446static struct regulator *vreg_adc_epm1;
4447
4448static struct i2c_client *epm_expander_i2c_register_board(void)
4449
4450{
4451 struct i2c_adapter *i2c_adap;
4452 struct i2c_client *client = NULL;
4453 i2c_adap = i2c_get_adapter(0x0);
4454
4455 if (i2c_adap == NULL)
4456 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4457
4458 if (i2c_adap != NULL)
4459 client = i2c_new_device(i2c_adap,
4460 &fluid_expanders_i2c_epm_info[0]);
4461 return client;
4462
4463}
4464
4465static unsigned int msm_adc_gpio_configure_expander_enable(void)
4466{
4467 int rc = 0;
4468 static struct i2c_client *epm_i2c_client;
4469
4470 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4471
4472 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4473
4474 if (IS_ERR(vreg_adc_epm1)) {
4475 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4476 return 0;
4477 }
4478
4479 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4480 if (rc)
4481 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4482 "regulator set voltage failed\n");
4483
4484 rc = regulator_enable(vreg_adc_epm1);
4485 if (rc) {
4486 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4487 "Error while enabling regulator for epm s3 %d\n", rc);
4488 return rc;
4489 }
4490
4491 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4492 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4493
4494 msleep(1000);
4495
4496 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4497 if (!rc) {
4498 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4499 "Configure 5v boost\n");
4500 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4501 } else {
4502 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4503 "Error for epm 5v boost en\n");
4504 goto exit_vreg_epm;
4505 }
4506
4507 msleep(500);
4508
4509 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4510 if (!rc) {
4511 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4512 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4513 "Configure epm 3.3v\n");
4514 } else {
4515 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4516 "Error for gpio 3.3ven\n");
4517 goto exit_vreg_epm;
4518 }
4519 msleep(500);
4520
4521 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4522 "Trying to request EPM LVLSFT_EN\n");
4523 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4524 if (!rc) {
4525 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4526 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4527 "Configure the lvlsft\n");
4528 } else {
4529 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4530 "Error for epm lvlsft_en\n");
4531 goto exit_vreg_epm;
4532 }
4533
4534 msleep(500);
4535
4536 if (!epm_i2c_client)
4537 epm_i2c_client = epm_expander_i2c_register_board();
4538
4539 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4540 if (!rc)
4541 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4542 if (rc) {
4543 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4544 ": GPIO PWR MON Enable issue\n");
4545 goto exit_vreg_epm;
4546 }
4547
4548 msleep(1000);
4549
4550 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4551 if (!rc) {
4552 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4553 if (rc) {
4554 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4555 ": ADC1_PWDN error direction out\n");
4556 goto exit_vreg_epm;
4557 }
4558 }
4559
4560 msleep(100);
4561
4562 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4563 if (!rc) {
4564 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4565 if (rc) {
4566 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4567 ": ADC2_PWD error direction out\n");
4568 goto exit_vreg_epm;
4569 }
4570 }
4571
4572 msleep(1000);
4573
4574 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4575 if (!rc) {
4576 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4577 if (rc) {
4578 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4579 "Gpio request problem %d\n", rc);
4580 goto exit_vreg_epm;
4581 }
4582 }
4583
4584 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4585 if (!rc) {
4586 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4587 if (rc) {
4588 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4589 ": EPM_SPI_ADC1_CS_N error\n");
4590 goto exit_vreg_epm;
4591 }
4592 }
4593
4594 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4595 if (!rc) {
4596 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4597 if (rc) {
4598 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4599 ": EPM_SPI_ADC2_Cs_N error\n");
4600 goto exit_vreg_epm;
4601 }
4602 }
4603
4604 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4605 "the power monitor reset for epm\n");
4606
4607 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4608 if (!rc) {
4609 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4610 if (rc) {
4611 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4612 ": Error in the power mon reset\n");
4613 goto exit_vreg_epm;
4614 }
4615 }
4616
4617 msleep(1000);
4618
4619 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4620
4621 msleep(500);
4622
4623 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4624
4625 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4626
4627 return rc;
4628
4629exit_vreg_epm:
4630 regulator_disable(vreg_adc_epm1);
4631
4632 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4633 " rc = %d.\n", rc);
4634 return rc;
4635};
4636
4637static unsigned int msm_adc_gpio_configure_expander_disable(void)
4638{
4639 int rc = 0;
4640
4641 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4642 gpio_free(GPIO_PWR_MON_RESET_N);
4643
4644 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4645 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4646
4647 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4648 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4649
4650 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4651 gpio_free(GPIO_PWR_MON_START);
4652
4653 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4654 gpio_free(GPIO_ADC1_PWDN_N);
4655
4656 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4657 gpio_free(GPIO_ADC2_PWDN_N);
4658
4659 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4660 gpio_free(GPIO_PWR_MON_ENABLE);
4661
4662 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4663 gpio_free(GPIO_EPM_LVLSFT_EN);
4664
4665 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4666 gpio_free(GPIO_EPM_5V_BOOST_EN);
4667
4668 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4669 gpio_free(GPIO_EPM_3_3V_EN);
4670
4671 rc = regulator_disable(vreg_adc_epm1);
4672 if (rc)
4673 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4674 "Error while enabling regulator for epm s3 %d\n", rc);
4675 regulator_put(vreg_adc_epm1);
4676
4677 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4678 return rc;
4679};
4680
4681unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4682{
4683 int rc = 0;
4684
4685 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4686 cs_enable);
4687
4688 if (cs_enable < 16) {
4689 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4690 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4691 } else {
4692 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4693 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4694 }
4695 return rc;
4696};
4697
4698unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4699{
4700 int rc = 0;
4701
4702 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4703
4704 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4705
4706 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4707
4708 return rc;
4709};
4710#endif
4711
4712static struct msm_adc_channels msm_adc_channels_data[] = {
4713 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4714 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4715 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4716 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4717 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4718 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4719 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4720 CHAN_PATH_TYPE4,
4721 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4722 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4723 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4724 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4725 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4726 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4727 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4728 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4729 CHAN_PATH_TYPE12,
4730 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4731 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4732 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4733 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4734 CHAN_PATH_TYPE_NONE,
4735 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4736 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4737 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4738 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4739 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4740 scale_xtern_chgr_cur},
4741 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4742 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4743 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4744 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4745 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4746 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4747 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4748 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4749 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4750 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4751 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4752 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4753};
4754
4755static char *msm_adc_fluid_device_names[] = {
4756 "ADS_ADC1",
4757 "ADS_ADC2",
4758};
4759
4760static struct msm_adc_platform_data msm_adc_pdata = {
4761 .channel = msm_adc_channels_data,
4762 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4763#if defined(CONFIG_I2C) && \
4764 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4765 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4766 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4767 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4768 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4769#endif
4770};
4771
4772static struct platform_device msm_adc_device = {
4773 .name = "msm_adc",
4774 .id = -1,
4775 .dev = {
4776 .platform_data = &msm_adc_pdata,
4777 },
4778};
4779
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304780static struct msm_rtb_platform_data msm_rtb_pdata = {
4781 .size = SZ_1M,
4782};
4783
4784static int __init msm_rtb_set_buffer_size(char *p)
4785{
4786 int s;
4787
4788 s = memparse(p, NULL);
4789 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4790 return 0;
4791}
4792early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4793
4794
4795static struct platform_device msm_rtb_device = {
4796 .name = "msm_rtb",
4797 .id = -1,
4798 .dev = {
4799 .platform_data = &msm_rtb_pdata,
4800 },
4801};
4802
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004803static void pmic8058_xoadc_mpp_config(void)
4804{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304805 int rc, i;
4806 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304807 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304808 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304809 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304810 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304811 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304812 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304813 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304814 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304815 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304816 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304817 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4818 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304819 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004820
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304821 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4822 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4823 &xoadc_mpps[i].config);
4824 if (rc) {
4825 pr_err("%s: Config MPP %d of PM8058 failed\n",
4826 __func__, xoadc_mpps[i].mpp);
4827 }
4828 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004829}
4830
4831static struct regulator *vreg_ldo18_adc;
4832
4833static int pmic8058_xoadc_vreg_config(int on)
4834{
4835 int rc;
4836
4837 if (on) {
4838 rc = regulator_enable(vreg_ldo18_adc);
4839 if (rc)
4840 pr_err("%s: Enable of regulator ldo18_adc "
4841 "failed\n", __func__);
4842 } else {
4843 rc = regulator_disable(vreg_ldo18_adc);
4844 if (rc)
4845 pr_err("%s: Disable of regulator ldo18_adc "
4846 "failed\n", __func__);
4847 }
4848
4849 return rc;
4850}
4851
4852static int pmic8058_xoadc_vreg_setup(void)
4853{
4854 int rc;
4855
4856 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4857 if (IS_ERR(vreg_ldo18_adc)) {
4858 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4859 __func__, PTR_ERR(vreg_ldo18_adc));
4860 rc = PTR_ERR(vreg_ldo18_adc);
4861 goto fail;
4862 }
4863
4864 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4865 if (rc) {
4866 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4867 goto fail;
4868 }
4869
4870 return rc;
4871fail:
4872 regulator_put(vreg_ldo18_adc);
4873 return rc;
4874}
4875
4876static void pmic8058_xoadc_vreg_shutdown(void)
4877{
4878 regulator_put(vreg_ldo18_adc);
4879}
4880
4881/* usec. For this ADC,
4882 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4883 * Each channel has different configuration, thus at the time of starting
4884 * the conversion, xoadc will return actual conversion time
4885 * */
4886static struct adc_properties pm8058_xoadc_data = {
4887 .adc_reference = 2200, /* milli-voltage for this adc */
4888 .bitresolution = 15,
4889 .bipolar = 0,
4890 .conversiontime = 54,
4891};
4892
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304893static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004894 .xoadc_prop = &pm8058_xoadc_data,
4895 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4896 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4897 .xoadc_num = XOADC_PMIC_0,
4898 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4899 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4900};
4901#endif
4902
4903#ifdef CONFIG_MSM_SDIO_AL
4904
4905static unsigned mdm2ap_status = 140;
4906
4907static int configure_mdm2ap_status(int on)
4908{
4909 int ret = 0;
4910 if (on)
4911 ret = msm_gpiomux_get(mdm2ap_status);
4912 else
4913 ret = msm_gpiomux_put(mdm2ap_status);
4914
4915 if (ret)
4916 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4917 on);
4918
4919 return ret;
4920}
4921
4922
4923static int get_mdm2ap_status(void)
4924{
4925 return gpio_get_value(mdm2ap_status);
4926}
4927
4928static struct sdio_al_platform_data sdio_al_pdata = {
4929 .config_mdm2ap_status = configure_mdm2ap_status,
4930 .get_mdm2ap_status = get_mdm2ap_status,
4931 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004932 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004933 .peer_sdioc_version_major = 0x0004,
4934 .peer_sdioc_boot_version_minor = 0x0001,
4935 .peer_sdioc_boot_version_major = 0x0003
4936};
4937
4938struct platform_device msm_device_sdio_al = {
4939 .name = "msm_sdio_al",
4940 .id = -1,
4941 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004942 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004943 .platform_data = &sdio_al_pdata,
4944 },
4945};
4946
4947#endif /* CONFIG_MSM_SDIO_AL */
4948
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304949#define GPIO_VREG_ID_EXT_5V 0
4950
4951static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4952 REGULATOR_SUPPLY("ext_5v", NULL),
4953 REGULATOR_SUPPLY("8901_mpp0", NULL),
4954};
4955
4956#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4957 [GPIO_VREG_ID_##_id] = { \
4958 .init_data = { \
4959 .constraints = { \
4960 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
4961 }, \
4962 .num_consumer_supplies = \
4963 ARRAY_SIZE(vreg_consumers_##_id), \
4964 .consumer_supplies = vreg_consumers_##_id, \
4965 }, \
4966 .regulator_name = _reg_name, \
4967 .active_low = _active_low, \
4968 .gpio_label = _gpio_label, \
4969 .gpio = _gpio, \
4970 }
4971
4972/* GPIO regulator constraints */
4973static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
4974 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
4975 PM8901_MPP_PM_TO_SYS(0), 0),
4976};
4977
4978/* GPIO regulator */
4979static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
4980 .name = GPIO_REGULATOR_DEV_NAME,
4981 .id = PM8901_MPP_PM_TO_SYS(0),
4982 .dev = {
4983 .platform_data =
4984 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
4985 },
4986};
4987
4988static void __init pm8901_vreg_mpp0_init(void)
4989{
4990 int rc;
4991
4992 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
4993 .mpp = PM8901_MPP_PM_TO_SYS(0),
4994 .config = {
4995 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
4996 .level = PM8901_MPP_DIG_LEVEL_VPH,
4997 },
4998 };
4999
5000 /*
5001 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5002 * implies that the regulator connected to MPP0 is enabled when
5003 * MPP0 is low.
5004 */
5005 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5006 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5007 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5008 } else {
5009 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5010 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5011 }
5012
5013 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5014 if (rc)
5015 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5016}
5017
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005018static struct platform_device *charm_devices[] __initdata = {
5019 &msm_charm_modem,
5020#ifdef CONFIG_MSM_SDIO_AL
5021 &msm_device_sdio_al,
5022#endif
5023};
5024
Lei Zhou338cab82011-08-19 13:38:17 -04005025#ifdef CONFIG_SND_SOC_MSM8660_APQ
5026static struct platform_device *dragon_alsa_devices[] __initdata = {
5027 &msm_pcm,
5028 &msm_pcm_routing,
5029 &msm_cpudai0,
5030 &msm_cpudai1,
5031 &msm_cpudai_hdmi_rx,
5032 &msm_cpudai_bt_rx,
5033 &msm_cpudai_bt_tx,
5034 &msm_cpudai_fm_rx,
5035 &msm_cpudai_fm_tx,
5036 &msm_cpu_fe,
5037 &msm_stub_codec,
5038 &msm_lpa_pcm,
5039};
5040#endif
5041
5042static struct platform_device *asoc_devices[] __initdata = {
5043 &asoc_msm_pcm,
5044 &asoc_msm_dai0,
5045 &asoc_msm_dai1,
5046};
5047
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305048/* qseecom bus scaling */
5049static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
5050 {
5051 .src = MSM_BUS_MASTER_SPS,
5052 .dst = MSM_BUS_SLAVE_EBI_CH0,
5053 .ib = 0,
5054 .ab = 0,
5055 },
5056 {
5057 .src = MSM_BUS_MASTER_SPDM,
5058 .dst = MSM_BUS_SLAVE_SPDM,
5059 .ib = 0,
5060 .ab = 0,
5061 },
5062};
5063
5064static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
5065 {
5066 .src = MSM_BUS_MASTER_SPS,
5067 .dst = MSM_BUS_SLAVE_EBI_CH0,
5068 .ib = (492 * 8) * 1000000UL,
5069 .ab = (492 * 8) * 100000UL,
5070 },
5071 {
5072 .src = MSM_BUS_MASTER_SPDM,
5073 .dst = MSM_BUS_SLAVE_SPDM,
5074 .ib = 0,
5075 .ab = 0,
5076 },
5077};
5078
5079static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
5080 {
5081 .src = MSM_BUS_MASTER_SPS,
5082 .dst = MSM_BUS_SLAVE_EBI_CH0,
5083 .ib = 0,
5084 .ab = 0,
5085 },
5086 {
5087 .src = MSM_BUS_MASTER_SPDM,
5088 .dst = MSM_BUS_SLAVE_SPDM,
5089 .ib = (64 * 8) * 1000000UL,
5090 .ab = (64 * 8) * 100000UL,
5091 },
5092};
5093
5094static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
5095 {
5096 ARRAY_SIZE(qseecom_clks_init_vectors),
5097 qseecom_clks_init_vectors,
5098 },
5099 {
5100 ARRAY_SIZE(qseecom_enable_dfab_vectors),
5101 qseecom_enable_sfpb_vectors,
5102 },
5103 {
5104 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
5105 qseecom_enable_sfpb_vectors,
5106 },
5107};
5108
5109static struct msm_bus_scale_pdata qseecom_bus_pdata = {
5110 .usecase = qseecom_hw_bus_scale_usecases,
5111 .num_usecases = ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
5112 .name = "qsee",
5113};
5114
5115static struct platform_device qseecom_device = {
5116 .name = "qseecom",
5117 .id = -1,
5118 .dev = {
5119 .platform_data = &qseecom_bus_pdata,
5120 },
5121};
5122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005123static struct platform_device *surf_devices[] __initdata = {
Matt Wagantallbf430eb2012-03-22 11:45:49 -07005124 &msm8x60_device_acpuclk,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005125 &msm_device_smd,
5126 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005127 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005128 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005129 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005130 &msm_pil_dsps,
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05305131 &msm_pil_vidc,
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305132 &qseecom_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005133#ifdef CONFIG_I2C_QUP
5134 &msm_gsbi3_qup_i2c_device,
5135 &msm_gsbi4_qup_i2c_device,
5136 &msm_gsbi7_qup_i2c_device,
5137 &msm_gsbi8_qup_i2c_device,
5138 &msm_gsbi9_qup_i2c_device,
5139 &msm_gsbi12_qup_i2c_device,
5140#endif
5141#ifdef CONFIG_SERIAL_MSM_HS
5142 &msm_device_uart_dm1,
5143#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305144#ifdef CONFIG_MSM_SSBI
5145 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305146 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305147#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005148#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005149 &msm_device_ssbi3,
5150#endif
5151#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5152 &isp1763_device,
5153#endif
5154
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005155#if defined (CONFIG_MSM_8x60_VOIP)
5156 &asoc_msm_mvs,
5157 &asoc_mvs_dai0,
5158 &asoc_mvs_dai1,
5159#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005160
Lena Salman57d167e2012-03-21 19:46:38 +02005161#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005162 &msm_device_otg,
5163#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005164#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005165 &msm_device_gadget_peripheral,
5166#endif
5167#ifdef CONFIG_USB_G_ANDROID
5168 &android_usb_device,
5169#endif
5170#ifdef CONFIG_BATTERY_MSM
5171 &msm_batt_device,
5172#endif
5173#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005174#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005175 &android_pmem_device,
5176 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005178 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305179#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5180#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005181#ifdef CONFIG_MSM_ROTATOR
5182 &msm_rotator_device,
5183#endif
5184 &msm_fb_device,
5185 &msm_kgsl_3d0,
5186 &msm_kgsl_2d0,
5187 &msm_kgsl_2d1,
5188 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005189#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5190 &lcdc_nt35582_panel_device,
5191#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005192#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5193 &lcdc_samsung_oled_panel_device,
5194#endif
5195#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5196 &lcdc_auo_wvga_panel_device,
5197#endif
5198#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5199 &hdmi_msm_device,
5200#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5201#ifdef CONFIG_FB_MSM_MIPI_DSI
5202 &mipi_dsi_toshiba_panel_device,
5203 &mipi_dsi_novatek_panel_device,
5204#endif
5205#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005206#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005207#ifdef CONFIG_MT9E013
5208 &msm_camera_sensor_mt9e013,
5209#endif
5210#ifdef CONFIG_IMX074
5211 &msm_camera_sensor_imx074,
5212#endif
5213#ifdef CONFIG_WEBCAM_OV7692
5214 &msm_camera_sensor_webcam_ov7692,
5215#endif
5216#ifdef CONFIG_WEBCAM_OV9726
5217 &msm_camera_sensor_webcam_ov9726,
5218#endif
5219#ifdef CONFIG_QS_S5K4E1
5220 &msm_camera_sensor_qs_s5k4e1,
5221#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005222#ifdef CONFIG_VX6953
5223 &msm_camera_sensor_vx6953,
5224#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005225#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005226#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005227#ifdef CONFIG_MSM_GEMINI
5228 &msm_gemini_device,
5229#endif
5230#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005231#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005232 &msm_vpe_device,
5233#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005234#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005235
5236#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005237 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005238#endif
5239#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005240 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005241#endif
5242 &msm_device_vidc,
5243#if (defined(CONFIG_MARIMBA_CORE)) && \
5244 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5245 &msm_bt_power_device,
5246#endif
5247#ifdef CONFIG_SENSORS_MSM_ADC
5248 &msm_adc_device,
5249#endif
David Collins6f032ba2011-08-31 14:08:15 -07005250 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005251
5252#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5253 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5254 &qcrypto_device,
5255#endif
5256
5257#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5258 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5259 &qcedev_device,
5260#endif
5261
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005262
5263#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5264#ifdef CONFIG_MSM_USE_TSIF1
5265 &msm_device_tsif[1],
5266#else
5267 &msm_device_tsif[0],
5268#endif /* CONFIG_MSM_USE_TSIF1 */
5269#endif /* CONFIG_TSIF */
5270
5271#ifdef CONFIG_HW_RANDOM_MSM
5272 &msm_device_rng,
5273#endif
5274
5275 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005276 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005277#ifdef CONFIG_ION_MSM
5278 &ion_dev,
5279#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005280 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005281 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305282 &msm_rtb_device,
Laura Abbottd92be422012-06-04 15:11:09 -07005283 &msm8660_iommu_domain_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005284};
5285
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005286#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005287#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5288static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5289 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005290 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005291 .request_region = request_smi_region,
5292 .release_region = release_smi_region,
5293 .setup_region = setup_smi_region,
Chintan Pandya490c9712012-08-07 17:19:59 +05305294 .secure_base = SECURE_BASE,
5295 .secure_size = SECURE_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005296 .iommu_map_all = 1,
5297 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005298};
5299
5300static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5301 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005302 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005303 .request_region = request_smi_region,
5304 .release_region = release_smi_region,
5305 .setup_region = setup_smi_region,
5306};
5307
5308static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5309 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005310 .align = PAGE_SIZE,
5311};
5312
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305313static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005314 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005315};
5316
5317static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005318 .adjacent_mem_id = INVALID_HEAP_ID,
5319 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005320};
5321#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005322
5323/**
5324 * These heaps are listed in the order they will be allocated. Due to
5325 * video hardware restrictions and content protection the FW heap has to
5326 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5327 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5328 * away from the base address of the FW heap.
5329 * However, the order of FW heap and MM heap doesn't matter since these
5330 * two heaps are taken care of by separate code to ensure they are adjacent
5331 * to each other.
5332 * Don't swap the order unless you know what you are doing!
5333 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -07005334struct ion_platform_heap msm8x60_heaps [] = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005335 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005336 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005337 .type = ION_HEAP_TYPE_SYSTEM,
5338 .name = ION_VMALLOC_HEAP_NAME,
5339 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005340#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5341 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005342 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005343 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005344 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305345 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005346 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005347 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005348 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005349 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005350 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005351 .id = ION_MM_FIRMWARE_HEAP_ID,
5352 .type = ION_HEAP_TYPE_CARVEOUT,
5353 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305354 .base = MSM_MM_FW_BASE,
5355 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005356 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305357 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005358 },
5359 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005360 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005361 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005362 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305363 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005364 .size = MSM_ION_MFC_SIZE,
5365 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005366 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005367 },
5368 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005369 .id = ION_SF_HEAP_ID,
5370 .type = ION_HEAP_TYPE_CARVEOUT,
5371 .name = ION_SF_HEAP_NAME,
5372 .size = MSM_ION_SF_SIZE,
5373 .memory_type = ION_EBI_TYPE,
5374 .extra_data = (void *)&co_ion_pdata,
5375 },
5376 {
5377 .id = ION_CAMERA_HEAP_ID,
5378 .type = ION_HEAP_TYPE_CARVEOUT,
5379 .name = ION_CAMERA_HEAP_NAME,
5380 .size = MSM_ION_CAMERA_SIZE,
5381 .memory_type = ION_EBI_TYPE,
5382 .extra_data = &co_ion_pdata,
5383 },
5384 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005385 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005386 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005387 .name = ION_WB_HEAP_NAME,
5388 .size = MSM_ION_WB_SIZE,
5389 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005390 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005391 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005392 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005393 .id = ION_QSECOM_HEAP_ID,
5394 .type = ION_HEAP_TYPE_CARVEOUT,
5395 .name = ION_QSECOM_HEAP_NAME,
5396 .size = MSM_ION_QSECOM_SIZE,
5397 .memory_type = ION_EBI_TYPE,
5398 .extra_data = (void *) &co_ion_pdata,
5399 },
5400 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005401 .id = ION_AUDIO_HEAP_ID,
5402 .type = ION_HEAP_TYPE_CARVEOUT,
5403 .name = ION_AUDIO_HEAP_NAME,
5404 .size = MSM_ION_AUDIO_SIZE,
5405 .memory_type = ION_EBI_TYPE,
5406 .extra_data = (void *)&co_ion_pdata,
5407 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005408#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -07005409};
5410
5411static struct ion_platform_data ion_pdata = {
5412 .nr = MSM_ION_HEAP_NUM,
5413 .heaps = msm8x60_heaps,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005414};
5415
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005416static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005417 .name = "ion-msm",
5418 .id = 1,
5419 .dev = { .platform_data = &ion_pdata },
5420};
5421#endif
5422
5423
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005424static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5425 /* Kernel SMI memory pool for video core, used for firmware */
5426 /* and encoder, decoder scratch buffers */
5427 /* Kernel SMI memory pool should always precede the user space */
5428 /* SMI memory pool, as the video core will use offset address */
5429 /* from the Firmware base */
5430 [MEMTYPE_SMI_KERNEL] = {
5431 .start = KERNEL_SMI_BASE,
5432 .limit = KERNEL_SMI_SIZE,
5433 .size = KERNEL_SMI_SIZE,
5434 .flags = MEMTYPE_FLAGS_FIXED,
5435 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005436 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005437 },
5438 [MEMTYPE_EBI0] = {
5439 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5440 },
5441 [MEMTYPE_EBI1] = {
5442 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5443 },
5444};
5445
Stephen Boyd668d7652012-04-25 11:31:01 -07005446static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005447{
5448#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005449 unsigned int i;
5450
5451 if (hdmi_is_primary) {
5452 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5453 for (i = 0; i < ion_pdata.nr; i++) {
5454 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5455 ion_pdata.heaps[i].size = msm_ion_sf_size;
5456 pr_debug("msm_ion_sf_size 0x%x\n",
5457 msm_ion_sf_size);
5458 break;
5459 }
5460 }
5461 }
5462
Olav Haugan8726caf2012-05-10 15:11:35 -07005463 /* Verify size of heap is a multiple of 64K */
5464 for (i = 0; i < ion_pdata.nr; i++) {
5465 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5466
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -07005467 if (heap->extra_data &&
5468 heap->type == (enum ion_heap_type) ION_HEAP_TYPE_CP) {
Olav Haugan8726caf2012-05-10 15:11:35 -07005469 int map_all = ((struct ion_cp_heap_pdata *)
5470 heap->extra_data)->iommu_map_all;
5471
5472 if (map_all && (heap->size & (SZ_64K-1))) {
5473 heap->size = ALIGN(heap->size, SZ_64K);
5474 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5475 heap->name, heap->size);
5476
5477 }
5478 }
5479 }
5480
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005481 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005482 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5483 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005484 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005485 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005486#endif
5487}
5488
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005489static void __init size_pmem_devices(void)
5490{
5491#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005492#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005493 android_pmem_adsp_pdata.size = pmem_adsp_size;
5494 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005495
5496 if (hdmi_is_primary)
5497 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005498 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005499 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305500#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5501#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005502}
5503
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305504#ifdef CONFIG_ANDROID_PMEM
5505#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005506static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5507{
5508 msm8x60_reserve_table[p->memory_type].size += p->size;
5509}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305510#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5511#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005512
5513static void __init reserve_pmem_memory(void)
5514{
5515#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005516#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005517 reserve_memory_for(&android_pmem_adsp_pdata);
5518 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005519 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005520 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305521#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305523#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005524}
5525
Huaibin Yanga5419422011-12-08 23:52:10 -08005526static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005527
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305528static void __init reserve_rtb_memory(void)
5529{
5530#if defined(CONFIG_MSM_RTB)
5531 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5532#endif
5533}
5534
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005535static void __init msm8x60_calculate_reserve_sizes(void)
5536{
5537 size_pmem_devices();
5538 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005539 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005540 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305541 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005542}
5543
5544static int msm8x60_paddr_to_memtype(unsigned int paddr)
5545{
5546 if (paddr >= 0x40000000 && paddr < 0x60000000)
5547 return MEMTYPE_EBI1;
5548 if (paddr >= 0x38000000 && paddr < 0x40000000)
5549 return MEMTYPE_SMI;
5550 return MEMTYPE_NONE;
5551}
5552
5553static struct reserve_info msm8x60_reserve_info __initdata = {
5554 .memtype_reserve_table = msm8x60_reserve_table,
5555 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5556 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5557};
5558
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005559static char prim_panel_name[PANEL_NAME_MAX_LEN];
5560static char ext_panel_name[PANEL_NAME_MAX_LEN];
5561static int __init prim_display_setup(char *param)
5562{
5563 if (strnlen(param, PANEL_NAME_MAX_LEN))
5564 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5565 return 0;
5566}
5567early_param("prim_display", prim_display_setup);
5568
5569static int __init ext_display_setup(char *param)
5570{
5571 if (strnlen(param, PANEL_NAME_MAX_LEN))
5572 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5573 return 0;
5574}
5575early_param("ext_display", ext_display_setup);
5576
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005577static void __init msm8x60_reserve(void)
5578{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005579 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005580 reserve_info = &msm8x60_reserve_info;
5581 msm_reserve();
5582}
5583
5584#define EXT_CHG_VALID_MPP 10
5585#define EXT_CHG_VALID_MPP_2 11
5586
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305587static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305588 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305589 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305590 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305591 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5592};
5593
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005594#ifdef CONFIG_ISL9519_CHARGER
5595static int isl_detection_setup(void)
5596{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305597 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005598
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305599 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5600 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5601 &isl_mpp[i].config);
5602 if (ret) {
5603 pr_err("%s: Config MPP %d of PM8058 failed\n",
5604 __func__, isl_mpp[i].mpp);
5605 return ret;
5606 }
5607 }
5608
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005609 return ret;
5610}
5611
5612static struct isl_platform_data isl_data __initdata = {
5613 .chgcurrent = 700,
5614 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5615 .chg_detection_config = isl_detection_setup,
5616 .max_system_voltage = 4200,
5617 .min_system_voltage = 3200,
5618 .term_current = 120,
5619 .input_current = 2048,
5620};
5621
5622static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5623 {
5624 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305625 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005626 .platform_data = &isl_data,
5627 },
5628};
5629#endif
5630
5631#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5632static int smb137b_detection_setup(void)
5633{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305634 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005635
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305636 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5637 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5638 &isl_mpp[i].config);
5639 if (ret) {
5640 pr_err("%s: Config MPP %d of PM8058 failed\n",
5641 __func__, isl_mpp[i].mpp);
5642 return ret;
5643 }
5644 }
5645
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005646 return ret;
5647}
5648
5649static struct smb137b_platform_data smb137b_data __initdata = {
5650 .chg_detection_config = smb137b_detection_setup,
5651 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5652 .batt_mah_rating = 950,
5653};
5654
5655static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5656 {
5657 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305658 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005659 .platform_data = &smb137b_data,
5660 },
5661};
5662#endif
5663
5664#ifdef CONFIG_PMIC8058
5665#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305666#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005667
5668static int pm8058_gpios_init(void)
5669{
5670 int i;
5671 int rc;
5672 struct pm8058_gpio_cfg {
5673 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305674 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005675 };
5676
5677 struct pm8058_gpio_cfg gpio_cfgs[] = {
5678 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305679 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005680 {
5681 .direction = PM_GPIO_DIR_IN,
5682 .pull = PM_GPIO_PULL_DN,
5683 .vin_sel = 2,
5684 .function = PM_GPIO_FUNC_NORMAL,
5685 .inv_int_pol = 0,
5686 },
5687 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005688 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305689 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005690 {
5691 .direction = PM_GPIO_DIR_IN,
5692 .pull = PM_GPIO_PULL_UP_30,
5693 .vin_sel = 2,
5694 .function = PM_GPIO_FUNC_NORMAL,
5695 .inv_int_pol = 0,
5696 },
5697 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005698 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305699 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005700 {
5701 .direction = PM_GPIO_DIR_IN,
5702 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305703 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005704 .function = PM_GPIO_FUNC_NORMAL,
5705 .inv_int_pol = 0,
5706 },
5707 },
5708 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305709 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005710 {
5711 .direction = PM_GPIO_DIR_IN,
5712 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305713 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005714 .function = PM_GPIO_FUNC_NORMAL,
5715 .inv_int_pol = 0,
5716 },
5717 },
5718 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305719 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005720 {
5721 .direction = PM_GPIO_DIR_IN,
5722 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305723 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005724 .function = PM_GPIO_FUNC_NORMAL,
5725 .inv_int_pol = 0,
5726 },
5727 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005728 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305729 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005730 {
5731 .direction = PM_GPIO_DIR_OUT,
5732 .output_value = 1,
5733 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5734 .pull = PM_GPIO_PULL_DN,
5735 .out_strength = PM_GPIO_STRENGTH_HIGH,
5736 .function = PM_GPIO_FUNC_NORMAL,
5737 .vin_sel = 2,
5738 .inv_int_pol = 0,
5739 }
5740 },
5741 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305742 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005743 {
5744 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305745 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005746 .function = PM_GPIO_FUNC_NORMAL,
5747 .vin_sel = 2,
5748 .inv_int_pol = 0,
5749 }
5750 },
5751 };
5752
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305753#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5754 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305755 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305756 .direction = PM_GPIO_DIR_IN,
5757 .pull = PM_GPIO_PULL_UP_1P5,
5758 .vin_sel = 2,
5759 .function = PM_GPIO_FUNC_NORMAL,
5760 };
5761#endif
5762
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005763#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305764 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305765 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305766 .direction = PM_GPIO_DIR_OUT,
5767 .pull = PM_GPIO_PULL_NO,
5768 .out_strength = PM_GPIO_STRENGTH_HIGH,
5769 .function = PM_GPIO_FUNC_NORMAL,
5770 .inv_int_pol = 0,
5771 .vin_sel = 2,
5772 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5773 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774 };
5775#endif
5776
5777#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5778 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305779 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005780 {
5781 .direction = PM_GPIO_DIR_IN,
5782 .pull = PM_GPIO_PULL_UP_1P5,
5783 .vin_sel = 2,
5784 .function = PM_GPIO_FUNC_NORMAL,
5785 .inv_int_pol = 0,
5786 }
5787 };
5788#endif
5789
5790#if defined(CONFIG_QS_S5K4E1)
5791 {
5792 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305793 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794 {
5795 .direction = PM_GPIO_DIR_OUT,
5796 .output_value = 0,
5797 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5798 .pull = PM_GPIO_PULL_DN,
5799 .out_strength = PM_GPIO_STRENGTH_HIGH,
5800 .function = PM_GPIO_FUNC_NORMAL,
5801 .vin_sel = 2,
5802 .inv_int_pol = 0,
5803 }
5804 };
5805#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005806#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5807 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305808 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005809 {
5810 .direction = PM_GPIO_DIR_OUT,
5811 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5812 .output_value = 1,
5813 .pull = PM_GPIO_PULL_UP_30,
5814 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305815 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005816 .out_strength = PM_GPIO_STRENGTH_HIGH,
5817 .function = PM_GPIO_FUNC_NORMAL,
5818 .inv_int_pol = 0,
5819 }
5820 };
5821#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005822#if defined(CONFIG_HAPTIC_ISA1200) || \
5823 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5824 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305825 rc = pm8xxx_gpio_config(
5826 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5827 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005828 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305829 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005830 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305831 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305832 rc = pm8xxx_gpio_config(
5833 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5834 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305835 if (rc < 0) {
5836 pr_err("%s: pmic haptics ldo gpio config failed\n",
5837 __func__);
5838 }
5839
5840 }
5841#endif
5842
5843#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5844 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5845 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5846 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305847 rc = pm8xxx_gpio_config(
5848 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5849 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305850 if (rc < 0) {
5851 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5852 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005853 }
5854 }
5855#endif
5856
5857#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5858 /* Line_in only for 8660 ffa & surf */
5859 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005860 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005861 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305862 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005863 &line_in_gpio_cfg.cfg);
5864 if (rc < 0) {
5865 pr_err("%s pmic line_in gpio config failed\n",
5866 __func__);
5867 return rc;
5868 }
5869 }
5870#endif
5871
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005872#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5873 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305874 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005875 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5876 if (rc < 0) {
5877 pr_err("%s pmic gpio config failed\n", __func__);
5878 return rc;
5879 }
5880 }
5881#endif
5882
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005883#if defined(CONFIG_QS_S5K4E1)
5884 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5885 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305886 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005887 &qs_hc37_cam_pd_gpio_cfg.cfg);
5888 if (rc < 0) {
5889 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5890 __func__);
5891 return rc;
5892 }
5893 }
5894 }
5895#endif
5896
5897 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305898 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005899 &gpio_cfgs[i].cfg);
5900 if (rc < 0) {
5901 pr_err("%s pmic gpio config failed\n",
5902 __func__);
5903 return rc;
5904 }
5905 }
5906
5907 return 0;
5908}
5909
5910static const unsigned int ffa_keymap[] = {
5911 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5912 KEY(0, 1, KEY_UP), /* NAV - UP */
5913 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5914 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5915
5916 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5917 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5918 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5919 KEY(1, 3, KEY_VOLUMEDOWN),
5920
5921 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5922
5923 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5924 KEY(4, 1, KEY_UP), /* USER_UP */
5925 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5926 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5927 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5928
5929 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5930 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5931 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5932 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5933 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5934};
5935
Zhang Chang Ken683be172011-08-10 17:45:34 -04005936static const unsigned int dragon_keymap[] = {
5937 KEY(0, 0, KEY_MENU),
5938 KEY(0, 2, KEY_1),
5939 KEY(0, 3, KEY_4),
5940 KEY(0, 4, KEY_7),
5941
5942 KEY(1, 0, KEY_UP),
5943 KEY(1, 1, KEY_LEFT),
5944 KEY(1, 2, KEY_DOWN),
5945 KEY(1, 3, KEY_5),
5946 KEY(1, 4, KEY_8),
5947
5948 KEY(2, 0, KEY_HOME),
5949 KEY(2, 1, KEY_REPLY),
5950 KEY(2, 2, KEY_2),
5951 KEY(2, 3, KEY_6),
5952 KEY(2, 4, KEY_0),
5953
5954 KEY(3, 0, KEY_VOLUMEUP),
5955 KEY(3, 1, KEY_RIGHT),
5956 KEY(3, 2, KEY_3),
5957 KEY(3, 3, KEY_9),
5958 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5959
5960 KEY(4, 0, KEY_VOLUMEDOWN),
5961 KEY(4, 1, KEY_BACK),
5962 KEY(4, 2, KEY_CAMERA),
5963 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5964};
5965
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005966static struct matrix_keymap_data ffa_keymap_data = {
5967 .keymap_size = ARRAY_SIZE(ffa_keymap),
5968 .keymap = ffa_keymap,
5969};
5970
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305971static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005972 .input_name = "ffa-keypad",
5973 .input_phys_device = "ffa-keypad/input0",
5974 .num_rows = 6,
5975 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305976 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5977 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5978 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005979 .scan_delay_ms = 32,
5980 .row_hold_ns = 91500,
5981 .wakeup = 1,
5982 .keymap_data = &ffa_keymap_data,
5983};
5984
Zhang Chang Ken683be172011-08-10 17:45:34 -04005985static struct matrix_keymap_data dragon_keymap_data = {
5986 .keymap_size = ARRAY_SIZE(dragon_keymap),
5987 .keymap = dragon_keymap,
5988};
5989
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305990static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005991 .input_name = "dragon-keypad",
5992 .input_phys_device = "dragon-keypad/input0",
5993 .num_rows = 6,
5994 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305995 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5996 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5997 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005998 .scan_delay_ms = 32,
5999 .row_hold_ns = 91500,
6000 .wakeup = 1,
6001 .keymap_data = &dragon_keymap_data,
6002};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306003
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006004static const unsigned int fluid_keymap[] = {
6005 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6006 KEY(0, 1, KEY_UP), /* NAV - UP */
6007 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6008 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6009
6010 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6011 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6012 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6013 KEY(1, 3, KEY_VOLUMEUP),
6014
6015 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6016
6017 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6018 KEY(4, 1, KEY_UP), /* USER_UP */
6019 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6020 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6021 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6022
Jilai Wang9a895102011-07-12 14:00:35 -04006023 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006024 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6025 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6026 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6027 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6028};
6029
6030static struct matrix_keymap_data fluid_keymap_data = {
6031 .keymap_size = ARRAY_SIZE(fluid_keymap),
6032 .keymap = fluid_keymap,
6033};
6034
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306035static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006036 .input_name = "fluid-keypad",
6037 .input_phys_device = "fluid-keypad/input0",
6038 .num_rows = 6,
6039 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306040 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6041 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6042 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006043 .scan_delay_ms = 32,
6044 .row_hold_ns = 91500,
6045 .wakeup = 1,
6046 .keymap_data = &fluid_keymap_data,
6047};
6048
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306049static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006050 .initial_vibrate_ms = 500,
6051 .level_mV = 3000,
6052 .max_timeout_ms = 15000,
6053};
6054
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306055static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6056 .rtc_write_enable = false,
6057 .rtc_alarm_powerup = false,
6058};
6059
6060static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6061 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006062 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306063 .wakeup = 1,
6064};
6065
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006066#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6067
6068static struct othc_accessory_info othc_accessories[] = {
6069 {
6070 .accessory = OTHC_SVIDEO_OUT,
6071 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6072 | OTHC_ADC_DETECT,
6073 .key_code = SW_VIDEOOUT_INSERT,
6074 .enabled = false,
6075 .adc_thres = {
6076 .min_threshold = 20,
6077 .max_threshold = 40,
6078 },
6079 },
6080 {
6081 .accessory = OTHC_ANC_HEADPHONE,
6082 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6083 OTHC_SWITCH_DETECT,
6084 .gpio = PM8058_LINE_IN_DET_GPIO,
6085 .active_low = 1,
6086 .key_code = SW_HEADPHONE_INSERT,
6087 .enabled = true,
6088 },
6089 {
6090 .accessory = OTHC_ANC_HEADSET,
6091 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6092 .gpio = PM8058_LINE_IN_DET_GPIO,
6093 .active_low = 1,
6094 .key_code = SW_HEADPHONE_INSERT,
6095 .enabled = true,
6096 },
6097 {
6098 .accessory = OTHC_HEADPHONE,
6099 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6100 .key_code = SW_HEADPHONE_INSERT,
6101 .enabled = true,
6102 },
6103 {
6104 .accessory = OTHC_MICROPHONE,
6105 .detect_flags = OTHC_GPIO_DETECT,
6106 .gpio = PM8058_LINE_IN_DET_GPIO,
6107 .active_low = 1,
6108 .key_code = SW_MICROPHONE_INSERT,
6109 .enabled = true,
6110 },
6111 {
6112 .accessory = OTHC_HEADSET,
6113 .detect_flags = OTHC_MICBIAS_DETECT,
6114 .key_code = SW_HEADPHONE_INSERT,
6115 .enabled = true,
6116 },
6117};
6118
6119static struct othc_switch_info switch_info[] = {
6120 {
6121 .min_adc_threshold = 0,
6122 .max_adc_threshold = 100,
6123 .key_code = KEY_PLAYPAUSE,
6124 },
6125 {
6126 .min_adc_threshold = 100,
6127 .max_adc_threshold = 200,
6128 .key_code = KEY_REWIND,
6129 },
6130 {
6131 .min_adc_threshold = 200,
6132 .max_adc_threshold = 500,
6133 .key_code = KEY_FASTFORWARD,
6134 },
6135};
6136
6137static struct othc_n_switch_config switch_config = {
6138 .voltage_settling_time_ms = 0,
6139 .num_adc_samples = 3,
6140 .adc_channel = CHANNEL_ADC_HDSET,
6141 .switch_info = switch_info,
6142 .num_keys = ARRAY_SIZE(switch_info),
6143 .default_sw_en = true,
6144 .default_sw_idx = 0,
6145};
6146
6147static struct hsed_bias_config hsed_bias_config = {
6148 /* HSED mic bias config info */
6149 .othc_headset = OTHC_HEADSET_NO,
6150 .othc_lowcurr_thresh_uA = 100,
6151 .othc_highcurr_thresh_uA = 600,
6152 .othc_hyst_prediv_us = 7800,
6153 .othc_period_clkdiv_us = 62500,
6154 .othc_hyst_clk_us = 121000,
6155 .othc_period_clk_us = 312500,
6156 .othc_wakeup = 1,
6157};
6158
6159static struct othc_hsed_config hsed_config_1 = {
6160 .hsed_bias_config = &hsed_bias_config,
6161 /*
6162 * The detection delay and switch reporting delay are
6163 * required to encounter a hardware bug (spurious switch
6164 * interrupts on slow insertion/removal of the headset).
6165 * This will introduce a delay in reporting the accessory
6166 * insertion and removal to the userspace.
6167 */
6168 .detection_delay_ms = 1500,
6169 /* Switch info */
6170 .switch_debounce_ms = 1500,
6171 .othc_support_n_switch = false,
6172 .switch_config = &switch_config,
6173 .ir_gpio = -1,
6174 /* Accessory info */
6175 .accessories_support = true,
6176 .accessories = othc_accessories,
6177 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6178};
6179
6180static struct othc_regulator_config othc_reg = {
6181 .regulator = "8058_l5",
6182 .max_uV = 2850000,
6183 .min_uV = 2850000,
6184};
6185
6186/* MIC_BIAS0 is configured as normal MIC BIAS */
6187static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6188 .micbias_select = OTHC_MICBIAS_0,
6189 .micbias_capability = OTHC_MICBIAS,
6190 .micbias_enable = OTHC_SIGNAL_OFF,
6191 .micbias_regulator = &othc_reg,
6192};
6193
6194/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6195static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6196 .micbias_select = OTHC_MICBIAS_1,
6197 .micbias_capability = OTHC_MICBIAS_HSED,
6198 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6199 .micbias_regulator = &othc_reg,
6200 .hsed_config = &hsed_config_1,
6201 .hsed_name = "8660_handset",
6202};
6203
6204/* MIC_BIAS2 is configured as normal MIC BIAS */
6205static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6206 .micbias_select = OTHC_MICBIAS_2,
6207 .micbias_capability = OTHC_MICBIAS,
6208 .micbias_enable = OTHC_SIGNAL_OFF,
6209 .micbias_regulator = &othc_reg,
6210};
6211
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006212
6213static void __init msm8x60_init_pm8058_othc(void)
6214{
6215 int i;
6216
6217 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6218 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6219 machine_is_msm8x60_fusn_ffa()) {
6220 /* 3-switch headset supported only by V2 FFA and FLUID */
6221 hsed_config_1.accessories_adc_support = true,
6222 /* ADC based accessory detection works only on V2 and FLUID */
6223 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6224 hsed_config_1.othc_support_n_switch = true;
6225 }
6226
6227 /* IR GPIO is absent on FLUID */
6228 if (machine_is_msm8x60_fluid())
6229 hsed_config_1.ir_gpio = -1;
6230
6231 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6232 if (machine_is_msm8x60_fluid()) {
6233 switch (othc_accessories[i].accessory) {
6234 case OTHC_ANC_HEADPHONE:
6235 case OTHC_ANC_HEADSET:
6236 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6237 break;
6238 case OTHC_MICROPHONE:
6239 othc_accessories[i].enabled = false;
6240 break;
6241 case OTHC_SVIDEO_OUT:
6242 othc_accessories[i].enabled = true;
6243 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6244 break;
6245 }
6246 }
6247 }
6248}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006249
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006250
6251static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6252{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306253 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006254 .direction = PM_GPIO_DIR_OUT,
6255 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6256 .output_value = 0,
6257 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306258 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006259 .out_strength = PM_GPIO_STRENGTH_HIGH,
6260 .function = PM_GPIO_FUNC_2,
6261 };
6262
6263 int rc = -EINVAL;
6264 int id, mode, max_mA;
6265
6266 id = mode = max_mA = 0;
6267 switch (ch) {
6268 case 0:
6269 case 1:
6270 case 2:
6271 if (on) {
6272 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306273 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6274 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006275 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306276 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006277 __func__, id, rc);
6278 }
6279 break;
6280
6281 case 6:
6282 id = PM_PWM_LED_FLASH;
6283 mode = PM_PWM_CONF_PWM1;
6284 max_mA = 300;
6285 break;
6286
6287 case 7:
6288 id = PM_PWM_LED_FLASH1;
6289 mode = PM_PWM_CONF_PWM1;
6290 max_mA = 300;
6291 break;
6292
6293 default:
6294 break;
6295 }
6296
6297 if (ch >= 6 && ch <= 7) {
6298 if (!on) {
6299 mode = PM_PWM_CONF_NONE;
6300 max_mA = 0;
6301 }
6302 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6303 if (rc)
6304 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6305 __func__, ch, rc);
6306 }
6307 return rc;
6308
6309}
6310
6311static struct pm8058_pwm_pdata pm8058_pwm_data = {
6312 .config = pm8058_pwm_config,
6313};
6314
6315#define PM8058_GPIO_INT 88
6316
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006317static struct pmic8058_led pmic8058_flash_leds[] = {
6318 [0] = {
6319 .name = "camera:flash0",
6320 .max_brightness = 15,
6321 .id = PMIC8058_ID_FLASH_LED_0,
6322 },
6323 [1] = {
6324 .name = "camera:flash1",
6325 .max_brightness = 15,
6326 .id = PMIC8058_ID_FLASH_LED_1,
6327 },
6328};
6329
6330static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6331 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6332 .leds = pmic8058_flash_leds,
6333};
6334
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006335static struct pmic8058_led pmic8058_dragon_leds[] = {
6336 [0] = {
6337 /* RED */
6338 .name = "led_drv0",
6339 .max_brightness = 15,
6340 .id = PMIC8058_ID_LED_0,
6341 },/* 300 mA flash led0 drv sink */
6342 [1] = {
6343 /* Yellow */
6344 .name = "led_drv1",
6345 .max_brightness = 15,
6346 .id = PMIC8058_ID_LED_1,
6347 },/* 300 mA flash led0 drv sink */
6348 [2] = {
6349 /* Green */
6350 .name = "led_drv2",
6351 .max_brightness = 15,
6352 .id = PMIC8058_ID_LED_2,
6353 },/* 300 mA flash led0 drv sink */
6354 [3] = {
6355 .name = "led_psensor",
6356 .max_brightness = 15,
6357 .id = PMIC8058_ID_LED_KB_LIGHT,
6358 },/* 300 mA flash led0 drv sink */
6359};
6360
6361static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6362 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6363 .leds = pmic8058_dragon_leds,
6364};
6365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006366static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6367 [0] = {
6368 .name = "led:drv0",
6369 .max_brightness = 15,
6370 .id = PMIC8058_ID_FLASH_LED_0,
6371 },/* 300 mA flash led0 drv sink */
6372 [1] = {
6373 .name = "led:drv1",
6374 .max_brightness = 15,
6375 .id = PMIC8058_ID_FLASH_LED_1,
6376 },/* 300 mA flash led1 sink */
6377 [2] = {
6378 .name = "led:drv2",
6379 .max_brightness = 20,
6380 .id = PMIC8058_ID_LED_0,
6381 },/* 40 mA led0 sink */
6382 [3] = {
6383 .name = "keypad:drv",
6384 .max_brightness = 15,
6385 .id = PMIC8058_ID_LED_KB_LIGHT,
6386 },/* 300 mA keypad drv sink */
6387};
6388
6389static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6390 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6391 .leds = pmic8058_fluid_flash_leds,
6392};
6393
Terence Hampson90508a92011-08-09 10:40:08 -04006394static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306395 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006396 .max_source_current = 1800,
6397 .charger_type = CHG_TYPE_AC,
6398};
6399
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306400static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6401 .charger_data_valid = false,
6402};
6403
6404static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6405 .priority = 0,
6406};
6407
6408static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6409 .irq_base = PM8058_IRQ_BASE,
6410 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6411 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6412};
6413
6414static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6415 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6416};
6417
6418static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6419 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006420};
6421
6422static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306423 .irq_pdata = &pm8058_irq_pdata,
6424 .gpio_pdata = &pm8058_gpio_pdata,
6425 .mpp_pdata = &pm8058_mpp_pdata,
6426 .rtc_pdata = &pm8058_rtc_pdata,
6427 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6428 .othc0_pdata = &othc_config_pdata_0,
6429 .othc1_pdata = &othc_config_pdata_1,
6430 .othc2_pdata = &othc_config_pdata_2,
6431 .pwm_pdata = &pm8058_pwm_data,
6432 .misc_pdata = &pm8058_misc_pdata,
6433#ifdef CONFIG_SENSORS_MSM_ADC
6434 .xoadc_pdata = &pm8058_xoadc_pdata,
6435#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006436};
6437
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306438#ifdef CONFIG_MSM_SSBI
6439static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6440 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6441 .slave = {
6442 .name = "pm8058-core",
6443 .platform_data = &pm8058_platform_data,
6444 },
6445};
6446#endif
6447#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006448
6449#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6450 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6451#define TDISC_I2C_SLAVE_ADDR 0x67
6452#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6453#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6454
6455static const char *vregs_tdisc_name[] = {
6456 "8058_l5",
6457 "8058_s3",
6458};
6459
6460static const int vregs_tdisc_val[] = {
6461 2850000,/* uV */
6462 1800000,
6463};
6464static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6465
6466static int tdisc_shinetsu_setup(void)
6467{
6468 int rc, i;
6469
6470 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6471 if (rc) {
6472 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6473 __func__);
6474 return rc;
6475 }
6476
6477 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6478 if (rc) {
6479 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6480 __func__);
6481 goto fail_gpio_oe;
6482 }
6483
6484 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6485 if (rc) {
6486 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6487 __func__);
6488 gpio_free(GPIO_JOYSTICK_EN);
6489 goto fail_gpio_oe;
6490 }
6491
6492 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6493 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6494 if (IS_ERR(vregs_tdisc[i])) {
6495 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6496 __func__, vregs_tdisc_name[i],
6497 PTR_ERR(vregs_tdisc[i]));
6498 rc = PTR_ERR(vregs_tdisc[i]);
6499 goto vreg_get_fail;
6500 }
6501
6502 rc = regulator_set_voltage(vregs_tdisc[i],
6503 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6504 if (rc) {
6505 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6506 __func__, rc);
6507 goto vreg_set_voltage_fail;
6508 }
6509 }
6510
6511 return rc;
6512vreg_set_voltage_fail:
6513 i++;
6514vreg_get_fail:
6515 while (i)
6516 regulator_put(vregs_tdisc[--i]);
6517fail_gpio_oe:
6518 gpio_free(PMIC_GPIO_TDISC);
6519 return rc;
6520}
6521
6522static void tdisc_shinetsu_release(void)
6523{
6524 int i;
6525
6526 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6527 regulator_put(vregs_tdisc[i]);
6528
6529 gpio_free(PMIC_GPIO_TDISC);
6530 gpio_free(GPIO_JOYSTICK_EN);
6531}
6532
6533static int tdisc_shinetsu_enable(void)
6534{
6535 int i, rc = -EINVAL;
6536
6537 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6538 rc = regulator_enable(vregs_tdisc[i]);
6539 if (rc < 0) {
6540 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6541 __func__, vregs_tdisc_name[i], rc);
6542 goto vreg_fail;
6543 }
6544 }
6545
6546 /* Enable the OE (output enable) gpio */
6547 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6548 /* voltage and gpio stabilization delay */
6549 msleep(50);
6550
6551 return 0;
6552vreg_fail:
6553 while (i)
6554 regulator_disable(vregs_tdisc[--i]);
6555 return rc;
6556}
6557
6558static int tdisc_shinetsu_disable(void)
6559{
6560 int i, rc;
6561
6562 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6563 rc = regulator_disable(vregs_tdisc[i]);
6564 if (rc < 0) {
6565 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6566 __func__, vregs_tdisc_name[i], rc);
6567 goto tdisc_reg_fail;
6568 }
6569 }
6570
6571 /* Disable the OE (output enable) gpio */
6572 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6573
6574 return 0;
6575
6576tdisc_reg_fail:
6577 while (i)
6578 regulator_enable(vregs_tdisc[--i]);
6579 return rc;
6580}
6581
6582static struct tdisc_abs_values tdisc_abs = {
6583 .x_max = 32,
6584 .y_max = 32,
6585 .x_min = -32,
6586 .y_min = -32,
6587 .pressure_max = 32,
6588 .pressure_min = 0,
6589};
6590
6591static struct tdisc_platform_data tdisc_data = {
6592 .tdisc_setup = tdisc_shinetsu_setup,
6593 .tdisc_release = tdisc_shinetsu_release,
6594 .tdisc_enable = tdisc_shinetsu_enable,
6595 .tdisc_disable = tdisc_shinetsu_disable,
6596 .tdisc_wakeup = 0,
6597 .tdisc_gpio = PMIC_GPIO_TDISC,
6598 .tdisc_report_keys = true,
6599 .tdisc_report_relative = true,
6600 .tdisc_report_absolute = false,
6601 .tdisc_report_wheel = false,
6602 .tdisc_reverse_x = false,
6603 .tdisc_reverse_y = true,
6604 .tdisc_abs = &tdisc_abs,
6605};
6606
6607static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6608 {
6609 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6610 .irq = TDISC_INT,
6611 .platform_data = &tdisc_data,
6612 },
6613};
6614#endif
6615
6616#define PM_GPIO_CDC_RST_N 20
6617#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6618
6619static struct regulator *vreg_timpani_1;
6620static struct regulator *vreg_timpani_2;
6621
6622static unsigned int msm_timpani_setup_power(void)
6623{
6624 int rc;
6625
6626 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6627 if (IS_ERR(vreg_timpani_1)) {
6628 pr_err("%s: Unable to get 8058_l0\n", __func__);
6629 return -ENODEV;
6630 }
6631
6632 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6633 if (IS_ERR(vreg_timpani_2)) {
6634 pr_err("%s: Unable to get 8058_s3\n", __func__);
6635 regulator_put(vreg_timpani_1);
6636 return -ENODEV;
6637 }
6638
6639 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6640 if (rc) {
6641 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6642 goto fail;
6643 }
6644
6645 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6646 if (rc) {
6647 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6648 goto fail;
6649 }
6650
6651 rc = regulator_enable(vreg_timpani_1);
6652 if (rc) {
6653 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6654 goto fail;
6655 }
6656
6657 /* The settings for LDO0 should be set such that
6658 * it doesn't require to reset the timpani. */
6659 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6660 if (rc < 0) {
6661 pr_err("Timpani regulator optimum mode setting failed\n");
6662 goto fail;
6663 }
6664
6665 rc = regulator_enable(vreg_timpani_2);
6666 if (rc) {
6667 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6668 regulator_disable(vreg_timpani_1);
6669 goto fail;
6670 }
6671
6672 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6673 if (rc) {
6674 pr_err("%s: GPIO Request %d failed\n", __func__,
6675 GPIO_CDC_RST_N);
6676 regulator_disable(vreg_timpani_1);
6677 regulator_disable(vreg_timpani_2);
6678 goto fail;
6679 } else {
6680 gpio_direction_output(GPIO_CDC_RST_N, 1);
6681 usleep_range(1000, 1050);
6682 gpio_direction_output(GPIO_CDC_RST_N, 0);
6683 usleep_range(1000, 1050);
6684 gpio_direction_output(GPIO_CDC_RST_N, 1);
6685 gpio_free(GPIO_CDC_RST_N);
6686 }
6687 return rc;
6688
6689fail:
6690 regulator_put(vreg_timpani_1);
6691 regulator_put(vreg_timpani_2);
6692 return rc;
6693}
6694
6695static void msm_timpani_shutdown_power(void)
6696{
6697 int rc;
6698
6699 rc = regulator_disable(vreg_timpani_1);
6700 if (rc)
6701 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6702
6703 regulator_put(vreg_timpani_1);
6704
6705 rc = regulator_disable(vreg_timpani_2);
6706 if (rc)
6707 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6708
6709 regulator_put(vreg_timpani_2);
6710}
6711
6712/* Power analog function of codec */
6713static struct regulator *vreg_timpani_cdc_apwr;
6714static int msm_timpani_codec_power(int vreg_on)
6715{
6716 int rc = 0;
6717
6718 if (!vreg_timpani_cdc_apwr) {
6719
6720 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6721
6722 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6723 pr_err("%s: vreg_get failed (%ld)\n",
6724 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6725 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6726 return rc;
6727 }
6728 }
6729
6730 if (vreg_on) {
6731
6732 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6733 2200000, 2200000);
6734 if (rc) {
6735 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6736 __func__);
6737 goto vreg_fail;
6738 }
6739
6740 rc = regulator_enable(vreg_timpani_cdc_apwr);
6741 if (rc) {
6742 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6743 goto vreg_fail;
6744 }
6745 } else {
6746 rc = regulator_disable(vreg_timpani_cdc_apwr);
6747 if (rc) {
6748 pr_err("%s: vreg_disable failed %d\n",
6749 __func__, rc);
6750 goto vreg_fail;
6751 }
6752 }
6753
6754 return 0;
6755
6756vreg_fail:
6757 regulator_put(vreg_timpani_cdc_apwr);
6758 vreg_timpani_cdc_apwr = NULL;
6759 return rc;
6760}
6761
6762static struct marimba_codec_platform_data timpani_codec_pdata = {
6763 .marimba_codec_power = msm_timpani_codec_power,
6764};
6765
6766#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6767#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6768
6769static struct marimba_platform_data timpani_pdata = {
6770 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6771 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6772 .marimba_setup = msm_timpani_setup_power,
6773 .marimba_shutdown = msm_timpani_shutdown_power,
6774 .codec = &timpani_codec_pdata,
6775 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6776};
6777
6778#define TIMPANI_I2C_SLAVE_ADDR 0xD
6779
6780static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6781 {
6782 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6783 .platform_data = &timpani_pdata,
6784 },
6785};
6786
Lei Zhou338cab82011-08-19 13:38:17 -04006787#ifdef CONFIG_SND_SOC_WM8903
6788static struct wm8903_platform_data wm8903_pdata = {
6789 .gpio_cfg[2] = 0x3A8,
6790};
6791
6792#define WM8903_I2C_SLAVE_ADDR 0x34
6793static struct i2c_board_info wm8903_codec_i2c_info[] = {
6794 {
6795 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6796 .platform_data = &wm8903_pdata,
6797 },
6798};
6799#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006800#ifdef CONFIG_PMIC8901
6801
6802#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006803/*
6804 * Consumer specific regulator names:
6805 * regulator name consumer dev_name
6806 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006807static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6808 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6809};
6810static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6811 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6812};
6813
6814#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306815 _always_on) \
6816 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006817 .init_data = { \
6818 .constraints = { \
6819 .valid_modes_mask = _modes, \
6820 .valid_ops_mask = _ops, \
6821 .min_uV = _min_uV, \
6822 .max_uV = _max_uV, \
6823 .input_uV = _min_uV, \
6824 .apply_uV = _apply_uV, \
6825 .always_on = _always_on, \
6826 }, \
6827 .consumer_supplies = vreg_consumers_8901_##_id, \
6828 .num_consumer_supplies = \
6829 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6830 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306831 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006832 }
6833
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006834#define PM8901_VREG_INIT_VS(_id) \
6835 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306836 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006837
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306838static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006839 PM8901_VREG_INIT_VS(USB_OTG),
6840 PM8901_VREG_INIT_VS(HDMI_MVS),
6841};
6842
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306843static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6844 .priority = 1,
6845};
6846
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306847static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6848 .irq_base = PM8901_IRQ_BASE,
6849 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6850 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6851};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306853static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6854 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006855};
6856
6857static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306858 .irq_pdata = &pm8901_irq_pdata,
6859 .mpp_pdata = &pm8901_mpp_pdata,
6860 .regulator_pdatas = pm8901_vreg_init,
6861 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306862 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006863};
6864
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306865static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6866 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6867 .slave = {
6868 .name = "pm8901-core",
6869 .platform_data = &pm8901_platform_data,
6870 },
6871};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006872#endif /* CONFIG_PMIC8901 */
6873
6874#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6875 || defined(CONFIG_GPIO_SX150X_MODULE))
6876
6877static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006878static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006879
6880struct bahama_config_register{
6881 u8 reg;
6882 u8 value;
6883 u8 mask;
6884};
6885
6886enum version{
6887 VER_1_0,
6888 VER_2_0,
6889 VER_UNSUPPORTED = 0xFF
6890};
6891
6892static u8 read_bahama_ver(void)
6893{
6894 int rc;
6895 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6896 u8 bahama_version;
6897
6898 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6899 if (rc < 0) {
6900 printk(KERN_ERR
6901 "%s: version read failed: %d\n",
6902 __func__, rc);
6903 return VER_UNSUPPORTED;
6904 } else {
6905 printk(KERN_INFO
6906 "%s: version read got: 0x%x\n",
6907 __func__, bahama_version);
6908 }
6909
6910 switch (bahama_version) {
6911 case 0x08: /* varient of bahama v1 */
6912 case 0x10:
6913 case 0x00:
6914 return VER_1_0;
6915 case 0x09: /* variant of bahama v2 */
6916 return VER_2_0;
6917 default:
6918 return VER_UNSUPPORTED;
6919 }
6920}
6921
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006922static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006923static unsigned int msm_bahama_setup_power(void)
6924{
6925 int rc = 0;
6926 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006927
6928 if (machine_is_msm8x60_dragon())
6929 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6930
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006931 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6932
6933 if (IS_ERR(vreg_bahama)) {
6934 rc = PTR_ERR(vreg_bahama);
6935 pr_err("%s: regulator_get %s = %d\n", __func__,
6936 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006937 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006938 }
6939
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006940 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6941 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006942 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6943 msm_bahama_regulator, rc);
6944 goto unget;
6945 }
6946
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006947 rc = regulator_enable(vreg_bahama);
6948 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006949 pr_err("%s: regulator_enable %s = %d\n", __func__,
6950 msm_bahama_regulator, rc);
6951 goto unget;
6952 }
6953
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006954 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6955 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006957 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006958 goto unenable;
6959 }
6960
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006961 gpio_direction_output(msm_bahama_sys_rst, 0);
6962 usleep_range(1000, 1050);
6963 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6964 usleep_range(1000, 1050);
6965 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006966 return rc;
6967
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006968unenable:
6969 regulator_disable(vreg_bahama);
6970unget:
6971 regulator_put(vreg_bahama);
6972 return rc;
6973};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006974
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006975static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006976{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006977 if (msm_bahama_setup_power_enable) {
6978 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6979 gpio_free(msm_bahama_sys_rst);
6980 regulator_disable(vreg_bahama);
6981 regulator_put(vreg_bahama);
6982 msm_bahama_setup_power_enable = 0;
6983 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984
6985 return 0;
6986};
6987
6988static unsigned int msm_bahama_core_config(int type)
6989{
6990 int rc = 0;
6991
6992 if (type == BAHAMA_ID) {
6993
6994 int i;
6995 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6996
6997 const struct bahama_config_register v20_init[] = {
6998 /* reg, value, mask */
6999 { 0xF4, 0x84, 0xFF }, /* AREG */
7000 { 0xF0, 0x04, 0xFF } /* DREG */
7001 };
7002
7003 if (read_bahama_ver() == VER_2_0) {
7004 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7005 u8 value = v20_init[i].value;
7006 rc = marimba_write_bit_mask(&config,
7007 v20_init[i].reg,
7008 &value,
7009 sizeof(v20_init[i].value),
7010 v20_init[i].mask);
7011 if (rc < 0) {
7012 printk(KERN_ERR
7013 "%s: reg %d write failed: %d\n",
7014 __func__, v20_init[i].reg, rc);
7015 return rc;
7016 }
7017 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7018 " mask 0x%02x\n",
7019 __func__, v20_init[i].reg,
7020 v20_init[i].value, v20_init[i].mask);
7021 }
7022 }
7023 }
7024 printk(KERN_INFO "core type: %d\n", type);
7025
7026 return rc;
7027}
7028
7029static struct regulator *fm_regulator_s3;
7030static struct msm_xo_voter *fm_clock;
7031
7032static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7033{
7034 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307035 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007036 .direction = PM_GPIO_DIR_IN,
7037 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307038 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007039 .function = PM_GPIO_FUNC_NORMAL,
7040 .inv_int_pol = 0,
7041 };
7042
7043 if (!fm_regulator_s3) {
7044 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7045 if (IS_ERR(fm_regulator_s3)) {
7046 rc = PTR_ERR(fm_regulator_s3);
7047 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7048 __func__, rc);
7049 goto out;
7050 }
7051 }
7052
7053
7054 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7055 if (rc < 0) {
7056 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7057 __func__, rc);
7058 goto fm_fail_put;
7059 }
7060
7061 rc = regulator_enable(fm_regulator_s3);
7062 if (rc < 0) {
7063 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7064 __func__, rc);
7065 goto fm_fail_put;
7066 }
7067
7068 /*Vote for XO clock*/
7069 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7070
7071 if (IS_ERR(fm_clock)) {
7072 rc = PTR_ERR(fm_clock);
7073 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7074 __func__, rc);
7075 goto fm_fail_switch;
7076 }
7077
7078 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7079 if (rc < 0) {
7080 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7081 __func__, rc);
7082 goto fm_fail_vote;
7083 }
7084
7085 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307086 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007087 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307088 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007089 __func__, rc);
7090 goto fm_fail_clock;
7091 }
7092 goto out;
7093
7094fm_fail_clock:
7095 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7096fm_fail_vote:
7097 msm_xo_put(fm_clock);
7098fm_fail_switch:
7099 regulator_disable(fm_regulator_s3);
7100fm_fail_put:
7101 regulator_put(fm_regulator_s3);
7102out:
7103 return rc;
7104};
7105
7106static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7107{
7108 int rc = 0;
7109 if (fm_regulator_s3 != NULL) {
7110 rc = regulator_disable(fm_regulator_s3);
7111 if (rc < 0) {
7112 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7113 __func__, rc);
7114 }
7115 regulator_put(fm_regulator_s3);
7116 fm_regulator_s3 = NULL;
7117 }
7118 printk(KERN_ERR "%s: Voting off for XO", __func__);
7119
7120 if (fm_clock != NULL) {
7121 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7122 if (rc < 0) {
7123 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7124 __func__, rc);
7125 }
7126 msm_xo_put(fm_clock);
7127 }
7128 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7129}
7130
7131/* Slave id address for FM/CDC/QMEMBIST
7132 * Values can be programmed using Marimba slave id 0
7133 * should there be a conflict with other I2C devices
7134 * */
7135#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7136#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7137
7138static struct marimba_fm_platform_data marimba_fm_pdata = {
7139 .fm_setup = fm_radio_setup,
7140 .fm_shutdown = fm_radio_shutdown,
7141 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7142 .is_fm_soc_i2s_master = false,
7143 .config_i2s_gpio = NULL,
7144};
7145
7146/*
7147Just initializing the BAHAMA related slave
7148*/
7149static struct marimba_platform_data marimba_pdata = {
7150 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7151 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7152 .bahama_setup = msm_bahama_setup_power,
7153 .bahama_shutdown = msm_bahama_shutdown_power,
7154 .bahama_core_config = msm_bahama_core_config,
7155 .fm = &marimba_fm_pdata,
7156 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7157};
7158
7159
7160static struct i2c_board_info msm_marimba_board_info[] = {
7161 {
7162 I2C_BOARD_INFO("marimba", 0xc),
7163 .platform_data = &marimba_pdata,
7164 }
7165};
7166#endif /* CONFIG_MAIMBA_CORE */
7167
7168#ifdef CONFIG_I2C
7169#define I2C_SURF 1
7170#define I2C_FFA (1 << 1)
7171#define I2C_RUMI (1 << 2)
7172#define I2C_SIM (1 << 3)
7173#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007174#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007175
7176struct i2c_registry {
7177 u8 machs;
7178 int bus;
7179 struct i2c_board_info *info;
7180 int len;
7181};
7182
7183static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007184#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7185 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007186 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007187 MSM_GSBI8_QUP_I2C_BUS_ID,
7188 core_expander_i2c_info,
7189 ARRAY_SIZE(core_expander_i2c_info),
7190 },
7191 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007192 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007193 MSM_GSBI8_QUP_I2C_BUS_ID,
7194 docking_expander_i2c_info,
7195 ARRAY_SIZE(docking_expander_i2c_info),
7196 },
7197 {
7198 I2C_SURF,
7199 MSM_GSBI8_QUP_I2C_BUS_ID,
7200 surf_expanders_i2c_info,
7201 ARRAY_SIZE(surf_expanders_i2c_info),
7202 },
7203 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007204 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007205 MSM_GSBI3_QUP_I2C_BUS_ID,
7206 fha_expanders_i2c_info,
7207 ARRAY_SIZE(fha_expanders_i2c_info),
7208 },
7209 {
7210 I2C_FLUID,
7211 MSM_GSBI3_QUP_I2C_BUS_ID,
7212 fluid_expanders_i2c_info,
7213 ARRAY_SIZE(fluid_expanders_i2c_info),
7214 },
7215 {
7216 I2C_FLUID,
7217 MSM_GSBI8_QUP_I2C_BUS_ID,
7218 fluid_core_expander_i2c_info,
7219 ARRAY_SIZE(fluid_core_expander_i2c_info),
7220 },
7221#endif
7222#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7223 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7224 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007225 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007226 MSM_GSBI3_QUP_I2C_BUS_ID,
7227 msm_i2c_gsbi3_tdisc_info,
7228 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7229 },
7230#endif
7231 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007232 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007233 MSM_GSBI3_QUP_I2C_BUS_ID,
7234 cy8ctmg200_board_info,
7235 ARRAY_SIZE(cy8ctmg200_board_info),
7236 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007237 {
7238 I2C_DRAGON,
7239 MSM_GSBI3_QUP_I2C_BUS_ID,
7240 cy8ctma340_dragon_board_info,
7241 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7242 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007243#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7244 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007245 {
7246 I2C_FLUID,
7247 MSM_GSBI3_QUP_I2C_BUS_ID,
7248 cyttsp_fluid_info,
7249 ARRAY_SIZE(cyttsp_fluid_info),
7250 },
7251 {
7252 I2C_FFA | I2C_SURF,
7253 MSM_GSBI3_QUP_I2C_BUS_ID,
7254 cyttsp_ffa_info,
7255 ARRAY_SIZE(cyttsp_ffa_info),
7256 },
7257#endif
7258#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007259#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007260 {
7261 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007262 MSM_GSBI4_QUP_I2C_BUS_ID,
7263 msm_camera_boardinfo,
7264 ARRAY_SIZE(msm_camera_boardinfo),
7265 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007266 {
7267 I2C_DRAGON,
7268 MSM_GSBI4_QUP_I2C_BUS_ID,
7269 msm_camera_dragon_boardinfo,
7270 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7271 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007272#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007273#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007274 {
7275 I2C_SURF | I2C_FFA | I2C_FLUID,
7276 MSM_GSBI7_QUP_I2C_BUS_ID,
7277 msm_i2c_gsbi7_timpani_info,
7278 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7279 },
7280#if defined(CONFIG_MARIMBA_CORE)
7281 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007282 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007283 MSM_GSBI7_QUP_I2C_BUS_ID,
7284 msm_marimba_board_info,
7285 ARRAY_SIZE(msm_marimba_board_info),
7286 },
7287#endif /* CONFIG_MARIMBA_CORE */
7288#ifdef CONFIG_ISL9519_CHARGER
7289 {
7290 I2C_SURF | I2C_FFA,
7291 MSM_GSBI8_QUP_I2C_BUS_ID,
7292 isl_charger_i2c_info,
7293 ARRAY_SIZE(isl_charger_i2c_info),
7294 },
7295#endif
7296#if defined(CONFIG_HAPTIC_ISA1200) || \
7297 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7298 {
7299 I2C_FLUID,
7300 MSM_GSBI8_QUP_I2C_BUS_ID,
7301 msm_isa1200_board_info,
7302 ARRAY_SIZE(msm_isa1200_board_info),
7303 },
7304#endif
7305#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7306 {
7307 I2C_FLUID,
7308 MSM_GSBI8_QUP_I2C_BUS_ID,
7309 smb137b_charger_i2c_info,
7310 ARRAY_SIZE(smb137b_charger_i2c_info),
7311 },
7312#endif
7313#if defined(CONFIG_BATTERY_BQ27520) || \
7314 defined(CONFIG_BATTERY_BQ27520_MODULE)
7315 {
7316 I2C_FLUID,
7317 MSM_GSBI8_QUP_I2C_BUS_ID,
7318 msm_bq27520_board_info,
7319 ARRAY_SIZE(msm_bq27520_board_info),
7320 },
7321#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007322#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7323 {
7324 I2C_DRAGON,
7325 MSM_GSBI8_QUP_I2C_BUS_ID,
7326 wm8903_codec_i2c_info,
7327 ARRAY_SIZE(wm8903_codec_i2c_info),
7328 },
7329#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007330};
7331#endif /* CONFIG_I2C */
7332
Stephen Boyd668d7652012-04-25 11:31:01 -07007333static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007334{
7335#ifdef CONFIG_I2C
7336#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7337 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7338 sx150x_data[SX150X_CORE].irq_summary =
7339 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007340 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7341 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007342 sx150x_data[SX150X_CORE].irq_summary =
7343 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7344 else if (machine_is_msm8x60_fluid())
7345 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7346 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7347#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007348#endif
7349}
7350
Stephen Boyd668d7652012-04-25 11:31:01 -07007351static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007352{
7353#ifdef CONFIG_I2C
7354 u8 mach_mask = 0;
7355 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007356#ifdef CONFIG_MSM_CAMERA_V4L2
7357 struct i2c_registry msm8x60_camera_i2c_devices = {
7358 I2C_SURF | I2C_FFA | I2C_FLUID,
7359 MSM_GSBI4_QUP_I2C_BUS_ID,
7360 msm8x60_camera_board_info.board_info,
7361 msm8x60_camera_board_info.num_i2c_board_info,
7362 };
7363#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007364
7365 /* Build the matching 'supported_machs' bitmask */
7366 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7367 mach_mask = I2C_SURF;
7368 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7369 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007370 else if (machine_is_msm8x60_fluid())
7371 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007372 else if (machine_is_msm8x60_dragon())
7373 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007374 else
7375 pr_err("unmatched machine ID in register_i2c_devices\n");
7376
7377 /* Run the array and install devices as appropriate */
7378 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7379 if (msm8x60_i2c_devices[i].machs & mach_mask)
7380 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7381 msm8x60_i2c_devices[i].info,
7382 msm8x60_i2c_devices[i].len);
7383 }
Kevin Chan3be11612012-03-22 20:05:40 -07007384#ifdef CONFIG_MSM_CAMERA_V4L2
7385 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7386 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7387 msm8x60_camera_i2c_devices.info,
7388 msm8x60_camera_i2c_devices.len);
7389#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007390#endif
7391}
7392
7393static void __init msm8x60_init_uart12dm(void)
7394{
7395#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7396 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7397 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7398
7399 if (!fpga_mem)
7400 pr_err("%s(): Error getting memory\n", __func__);
7401
7402 /* Advanced mode */
7403 writew(0xFFFF, fpga_mem + 0x15C);
7404 /* FPGA_UART_SEL */
7405 writew(0, fpga_mem + 0x172);
7406 /* FPGA_GPIO_CONFIG_117 */
7407 writew(1, fpga_mem + 0xEA);
7408 /* FPGA_GPIO_CONFIG_118 */
7409 writew(1, fpga_mem + 0xEC);
7410 mb();
7411 iounmap(fpga_mem);
7412#endif
7413}
7414
7415#define MSM_GSBI9_PHYS 0x19900000
7416#define GSBI_DUAL_MODE_CODE 0x60
7417
7418static void __init msm8x60_init_buses(void)
7419{
7420#ifdef CONFIG_I2C_QUP
7421 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7422 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7423 writel_relaxed(0x6 << 4, gsbi_mem);
7424 /* Ensure protocol code is written before proceeding further */
7425 mb();
7426 iounmap(gsbi_mem);
7427
7428 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7429 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7430 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7431 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7432
7433#ifdef CONFIG_MSM_GSBI9_UART
7434 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7435 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7436 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7437 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7438 iounmap(gsbi_mem);
7439 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7440 }
7441#endif
7442 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7443 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7444#endif
7445#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7446 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7447#endif
7448#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007449 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7450#endif
7451
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307452#ifdef CONFIG_MSM_SSBI
7453 msm_device_ssbi_pmic1.dev.platform_data =
7454 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307455 msm_device_ssbi_pmic2.dev.platform_data =
7456 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307457#endif
7458
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007459 if (machine_is_msm8x60_fluid()) {
7460#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7461 (defined(CONFIG_SMB137B_CHARGER) || \
7462 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7463 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7464#endif
7465#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7466 msm_gsbi10_qup_spi_device.dev.platform_data =
7467 &msm_gsbi10_qup_spi_pdata;
7468#endif
7469 }
7470
Lena Salman57d167e2012-03-21 19:46:38 +02007471#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007472 /*
7473 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7474 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7475 * and ID notifications are available only on V2 surf and FFA
7476 * with a hardware workaround.
7477 */
7478 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7479 (machine_is_msm8x60_surf() ||
7480 (machine_is_msm8x60_ffa() &&
7481 pmic_id_notif_supported)))
7482 msm_otg_pdata.phy_can_powercollapse = 1;
7483 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7484#endif
7485
Lena Salman57d167e2012-03-21 19:46:38 +02007486#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007487 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7488#endif
7489
7490#ifdef CONFIG_SERIAL_MSM_HS
7491 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7492 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7493#endif
7494#ifdef CONFIG_MSM_GSBI9_UART
7495 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7496 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7497 if (IS_ERR(msm_device_uart_gsbi9))
7498 pr_err("%s(): Failed to create uart gsbi9 device\n",
7499 __func__);
7500 }
7501#endif
7502
7503#ifdef CONFIG_MSM_BUS_SCALING
7504
7505 /* RPM calls are only enabled on V2 */
7506 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7507 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7508 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7509 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7510 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7511 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7512 }
7513
7514 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7515 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7516 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7517 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7518 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7519#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007520}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007521
7522static void __init msm8x60_map_io(void)
7523{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007524 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007525 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007526
7527 if (socinfo_init() < 0)
7528 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007529}
7530
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007531/*
7532 * Most segments of the EBI2 bus are disabled by default.
7533 */
7534static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007535{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007536 uint32_t ebi2_cfg;
7537 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007538 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007539
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007540 if (IS_ERR(mem_clk)) {
7541 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7542 "msm_ebi2", "mem_clk");
7543 return;
7544 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007545 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007546 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007547
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007548 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7549 if (ebi2_cfg_ptr != 0) {
7550 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007551
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007552 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007553 machine_is_msm8x60_fluid() ||
7554 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007555 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007556
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007557 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7558 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007559 }
7560
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007561 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007562 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007563 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7564 if (ebi2_cfg_ptr != 0) {
7565 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7566 writel_relaxed(0UL, ebi2_cfg_ptr);
7567
7568 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7569 * LAN9221 Ethernet controller reads and writes.
7570 * The lowest 4 bits are the read delay, the next
7571 * 4 are the write delay. */
7572 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7573#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7574 /*
7575 * RECOVERY=5, HOLD_WR=1
7576 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7577 * WAIT_WR=1, WAIT_RD=2
7578 */
7579 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7580 /*
7581 * HOLD_RD=1
7582 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7583 */
7584 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7585#else
7586 /* EBI2 CS3 muxed address/data,
7587 * two cyc addr enable */
7588 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7589
7590#endif
7591 iounmap(ebi2_cfg_ptr);
7592 }
7593 }
David Brown56e2d8a2011-08-04 02:01:02 -07007594}
7595
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007596#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7597 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7598 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7599 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7600 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7601
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007602/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007603#define MAX_SDCC_CONTROLLER 5
7604
7605struct msm_sdcc_gpio {
7606 /* maximum 10 GPIOs per SDCC controller */
7607 s16 no;
7608 /* name of this GPIO */
7609 const char *name;
7610 bool always_on;
7611 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007612};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007613
7614#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7615static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7616 {159, "sdc1_dat_0"},
7617 {160, "sdc1_dat_1"},
7618 {161, "sdc1_dat_2"},
7619 {162, "sdc1_dat_3"},
7620#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7621 {163, "sdc1_dat_4"},
7622 {164, "sdc1_dat_5"},
7623 {165, "sdc1_dat_6"},
7624 {166, "sdc1_dat_7"},
7625#endif
7626 {167, "sdc1_clk"},
7627 {168, "sdc1_cmd"}
7628};
7629#endif
7630
7631#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7632static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7633 {143, "sdc2_dat_0"},
7634 {144, "sdc2_dat_1", 1},
7635 {145, "sdc2_dat_2"},
7636 {146, "sdc2_dat_3"},
7637#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7638 {147, "sdc2_dat_4"},
7639 {148, "sdc2_dat_5"},
7640 {149, "sdc2_dat_6"},
7641 {150, "sdc2_dat_7"},
7642#endif
7643 {151, "sdc2_cmd"},
7644 {152, "sdc2_clk", 1}
7645};
7646#endif
7647
7648#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7649static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7650 {95, "sdc5_cmd"},
7651 {96, "sdc5_dat_3"},
7652 {97, "sdc5_clk", 1},
7653 {98, "sdc5_dat_2"},
7654 {99, "sdc5_dat_1", 1},
7655 {100, "sdc5_dat_0"}
7656};
7657#endif
7658
7659struct msm_sdcc_pad_pull_cfg {
7660 enum msm_tlmm_pull_tgt pull;
7661 u32 pull_val;
7662};
7663
7664struct msm_sdcc_pad_drv_cfg {
7665 enum msm_tlmm_hdrive_tgt drv;
7666 u32 drv_val;
7667};
7668
7669#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7670static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7671 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7672 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7673 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7674};
7675
7676static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7677 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7678 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7679};
7680
7681static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7682 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7683 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7684 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7685};
7686
7687static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7688 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7689 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7690};
7691#endif
7692
7693#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7694static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7695 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7696 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7697 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7698};
7699
7700static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7701 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7702 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7703};
7704
7705static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7706 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7707 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7708 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7709};
7710
7711static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7712 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7713 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7714};
7715#endif
7716
7717struct msm_sdcc_pin_cfg {
7718 /*
7719 * = 1 if controller pins are using gpios
7720 * = 0 if controller has dedicated MSM pins
7721 */
7722 u8 is_gpio;
7723 u8 cfg_sts;
7724 u8 gpio_data_size;
7725 struct msm_sdcc_gpio *gpio_data;
7726 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7727 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7728 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7729 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7730 u8 pad_drv_data_size;
7731 u8 pad_pull_data_size;
7732 u8 sdio_lpm_gpio_cfg;
7733};
7734
7735
7736static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7737#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7738 [0] = {
7739 .is_gpio = 1,
7740 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7741 .gpio_data = sdc1_gpio_cfg
7742 },
7743#endif
7744#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7745 [1] = {
7746 .is_gpio = 1,
7747 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7748 .gpio_data = sdc2_gpio_cfg
7749 },
7750#endif
7751#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7752 [2] = {
7753 .is_gpio = 0,
7754 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7755 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7756 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7757 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7758 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7759 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7760 },
7761#endif
7762#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7763 [3] = {
7764 .is_gpio = 0,
7765 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7766 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7767 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7768 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7769 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7770 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7771 },
7772#endif
7773#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7774 [4] = {
7775 .is_gpio = 1,
7776 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7777 .gpio_data = sdc5_gpio_cfg
7778 }
7779#endif
7780};
7781
7782static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7783{
7784 int rc = 0;
7785 struct msm_sdcc_pin_cfg *curr;
7786 int n;
7787
7788 curr = &sdcc_pin_cfg_data[dev_id - 1];
7789 if (!curr->gpio_data)
7790 goto out;
7791
7792 for (n = 0; n < curr->gpio_data_size; n++) {
7793 if (enable) {
7794
7795 if (curr->gpio_data[n].always_on &&
7796 curr->gpio_data[n].is_enabled)
7797 continue;
7798 pr_debug("%s: enable: %s\n", __func__,
7799 curr->gpio_data[n].name);
7800 rc = gpio_request(curr->gpio_data[n].no,
7801 curr->gpio_data[n].name);
7802 if (rc) {
7803 pr_err("%s: gpio_request(%d, %s)"
7804 "failed", __func__,
7805 curr->gpio_data[n].no,
7806 curr->gpio_data[n].name);
7807 goto free_gpios;
7808 }
7809 /* set direction as output for all GPIOs */
7810 rc = gpio_direction_output(
7811 curr->gpio_data[n].no, 1);
7812 if (rc) {
7813 pr_err("%s: gpio_direction_output"
7814 "(%d, 1) failed\n", __func__,
7815 curr->gpio_data[n].no);
7816 goto free_gpios;
7817 }
7818 curr->gpio_data[n].is_enabled = 1;
7819 } else {
7820 /*
7821 * now free this GPIO which will put GPIO
7822 * in low power mode and will also put GPIO
7823 * in input mode
7824 */
7825 if (curr->gpio_data[n].always_on)
7826 continue;
7827 pr_debug("%s: disable: %s\n", __func__,
7828 curr->gpio_data[n].name);
7829 gpio_free(curr->gpio_data[n].no);
7830 curr->gpio_data[n].is_enabled = 0;
7831 }
7832 }
7833 curr->cfg_sts = enable;
7834 goto out;
7835
7836free_gpios:
7837 for (; n >= 0; n--)
7838 gpio_free(curr->gpio_data[n].no);
7839out:
7840 return rc;
7841}
7842
7843static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7844{
7845 int rc = 0;
7846 struct msm_sdcc_pin_cfg *curr;
7847 int n;
7848
7849 curr = &sdcc_pin_cfg_data[dev_id - 1];
7850 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7851 goto out;
7852
7853 if (enable) {
7854 /*
7855 * set up the normal driver strength and
7856 * pull config for pads
7857 */
7858 for (n = 0; n < curr->pad_drv_data_size; n++) {
7859 if (curr->sdio_lpm_gpio_cfg) {
7860 if (curr->pad_drv_on_data[n].drv ==
7861 TLMM_HDRV_SDC4_DATA)
7862 continue;
7863 }
7864 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7865 curr->pad_drv_on_data[n].drv_val);
7866 }
7867 for (n = 0; n < curr->pad_pull_data_size; n++) {
7868 if (curr->sdio_lpm_gpio_cfg) {
7869 if (curr->pad_pull_on_data[n].pull ==
7870 TLMM_PULL_SDC4_DATA)
7871 continue;
7872 }
7873 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7874 curr->pad_pull_on_data[n].pull_val);
7875 }
7876 } else {
7877 /* set the low power config for pads */
7878 for (n = 0; n < curr->pad_drv_data_size; n++) {
7879 if (curr->sdio_lpm_gpio_cfg) {
7880 if (curr->pad_drv_off_data[n].drv ==
7881 TLMM_HDRV_SDC4_DATA)
7882 continue;
7883 }
7884 msm_tlmm_set_hdrive(
7885 curr->pad_drv_off_data[n].drv,
7886 curr->pad_drv_off_data[n].drv_val);
7887 }
7888 for (n = 0; n < curr->pad_pull_data_size; n++) {
7889 if (curr->sdio_lpm_gpio_cfg) {
7890 if (curr->pad_pull_off_data[n].pull ==
7891 TLMM_PULL_SDC4_DATA)
7892 continue;
7893 }
7894 msm_tlmm_set_pull(
7895 curr->pad_pull_off_data[n].pull,
7896 curr->pad_pull_off_data[n].pull_val);
7897 }
7898 }
7899 curr->cfg_sts = enable;
7900out:
7901 return rc;
7902}
7903
7904struct sdcc_reg {
7905 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7906 const char *reg_name;
7907 /*
7908 * is set voltage supported for this regulator?
7909 * 0 = not supported, 1 = supported
7910 */
7911 unsigned char set_voltage_sup;
7912 /* voltage level to be set */
7913 unsigned int level;
7914 /* VDD/VCC/VCCQ voltage regulator handle */
7915 struct regulator *reg;
7916 /* is this regulator enabled? */
7917 bool enabled;
7918 /* is this regulator needs to be always on? */
7919 bool always_on;
7920 /* is operating power mode setting required for this regulator? */
7921 bool op_pwr_mode_sup;
7922 /* Load values for low power and high power mode */
7923 unsigned int lpm_uA;
7924 unsigned int hpm_uA;
7925};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007926/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007927static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7928/* only SDCC1 requires VCCQ voltage */
7929static struct sdcc_reg sdcc_vccq_reg_data[1];
7930/* all SDCC controllers may require voting for VDD PAD voltage */
7931static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7932
7933struct sdcc_reg_data {
7934 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7935 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7936 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7937 unsigned char sts; /* regulator enable/disable status */
7938};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007939/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007940static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7941
7942static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7943{
7944 int rc = 0;
7945
7946 /* Get the regulator handle */
7947 vreg->reg = regulator_get(NULL, vreg->reg_name);
7948 if (IS_ERR(vreg->reg)) {
7949 rc = PTR_ERR(vreg->reg);
7950 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7951 __func__, vreg->reg_name, rc);
7952 goto out;
7953 }
7954
7955 /* Set the voltage level if required */
7956 if (vreg->set_voltage_sup) {
7957 rc = regulator_set_voltage(vreg->reg, vreg->level,
7958 vreg->level);
7959 if (rc) {
7960 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7961 __func__, vreg->reg_name, rc);
7962 goto vreg_put;
7963 }
7964 }
7965 goto out;
7966
7967vreg_put:
7968 regulator_put(vreg->reg);
7969out:
7970 return rc;
7971}
7972
7973static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7974{
7975 regulator_put(vreg->reg);
7976}
7977
7978/* this init function should be called only once for each SDCC */
7979static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7980{
7981 int rc = 0;
7982 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7983 struct sdcc_reg_data *curr;
7984
7985 curr = &sdcc_vreg_data[dev_id - 1];
7986 curr_vdd_reg = curr->vdd_data;
7987 curr_vccq_reg = curr->vccq_data;
7988 curr_vddp_reg = curr->vddp_data;
7989
7990 if (init) {
7991 /*
7992 * get the regulator handle from voltage regulator framework
7993 * and then try to set the voltage level for the regulator
7994 */
7995 if (curr_vdd_reg) {
7996 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7997 if (rc)
7998 goto out;
7999 }
8000 if (curr_vccq_reg) {
8001 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8002 if (rc)
8003 goto vdd_reg_deinit;
8004 }
8005 if (curr_vddp_reg) {
8006 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8007 if (rc)
8008 goto vccq_reg_deinit;
8009 }
8010 goto out;
8011 } else
8012 /* deregister with all regulators from regulator framework */
8013 goto vddp_reg_deinit;
8014
8015vddp_reg_deinit:
8016 if (curr_vddp_reg)
8017 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8018vccq_reg_deinit:
8019 if (curr_vccq_reg)
8020 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8021vdd_reg_deinit:
8022 if (curr_vdd_reg)
8023 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8024out:
8025 return rc;
8026}
8027
8028static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8029{
8030 int rc;
8031
8032 if (!vreg->enabled) {
8033 rc = regulator_enable(vreg->reg);
8034 if (rc) {
8035 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8036 __func__, vreg->reg_name, rc);
8037 goto out;
8038 }
8039 vreg->enabled = 1;
8040 }
8041
8042 /* Put always_on regulator in HPM (high power mode) */
8043 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8044 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8045 if (rc < 0) {
8046 pr_err("%s: reg=%s: HPM setting failed"
8047 " hpm_uA=%d, rc=%d\n",
8048 __func__, vreg->reg_name,
8049 vreg->hpm_uA, rc);
8050 goto vreg_disable;
8051 }
8052 rc = 0;
8053 }
8054 goto out;
8055
8056vreg_disable:
8057 regulator_disable(vreg->reg);
8058 vreg->enabled = 0;
8059out:
8060 return rc;
8061}
8062
8063static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8064{
8065 int rc;
8066
8067 /* Never disable always_on regulator */
8068 if (!vreg->always_on) {
8069 rc = regulator_disable(vreg->reg);
8070 if (rc) {
8071 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8072 __func__, vreg->reg_name, rc);
8073 goto out;
8074 }
8075 vreg->enabled = 0;
8076 }
8077
8078 /* Put always_on regulator in LPM (low power mode) */
8079 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8080 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8081 if (rc < 0) {
8082 pr_err("%s: reg=%s: LPM setting failed"
8083 " lpm_uA=%d, rc=%d\n",
8084 __func__,
8085 vreg->reg_name,
8086 vreg->lpm_uA, rc);
8087 goto out;
8088 }
8089 rc = 0;
8090 }
8091
8092out:
8093 return rc;
8094}
8095
8096static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8097{
8098 int rc = 0;
8099 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8100 struct sdcc_reg_data *curr;
8101
8102 curr = &sdcc_vreg_data[dev_id - 1];
8103 curr_vdd_reg = curr->vdd_data;
8104 curr_vccq_reg = curr->vccq_data;
8105 curr_vddp_reg = curr->vddp_data;
8106
8107 /* check if regulators are initialized or not? */
8108 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8109 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8110 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8111 /* initialize voltage regulators required for this SDCC */
8112 rc = msm_sdcc_vreg_init(dev_id, 1);
8113 if (rc) {
8114 pr_err("%s: regulator init failed = %d\n",
8115 __func__, rc);
8116 goto out;
8117 }
8118 }
8119
8120 if (curr->sts == enable)
8121 goto out;
8122
8123 if (curr_vdd_reg) {
8124 if (enable)
8125 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8126 else
8127 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8128 if (rc)
8129 goto out;
8130 }
8131
8132 if (curr_vccq_reg) {
8133 if (enable)
8134 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8135 else
8136 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8137 if (rc)
8138 goto out;
8139 }
8140
8141 if (curr_vddp_reg) {
8142 if (enable)
8143 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8144 else
8145 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8146 if (rc)
8147 goto out;
8148 }
8149 curr->sts = enable;
8150
8151out:
8152 return rc;
8153}
8154
8155static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8156{
8157 u32 rc_pin_cfg = 0;
8158 u32 rc_vreg_cfg = 0;
8159 u32 rc = 0;
8160 struct platform_device *pdev;
8161 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8162
8163 pdev = container_of(dv, struct platform_device, dev);
8164
8165 /* setup gpio/pad */
8166 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8167 if (curr_pin_cfg->cfg_sts == !!vdd)
8168 goto setup_vreg;
8169
8170 if (curr_pin_cfg->is_gpio)
8171 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8172 else
8173 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8174
8175setup_vreg:
8176 /* setup voltage regulators */
8177 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8178
8179 if (rc_pin_cfg || rc_vreg_cfg)
8180 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8181
8182 return rc;
8183}
8184
8185static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8186{
8187 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8188 struct platform_device *pdev;
8189
8190 pdev = container_of(dv, struct platform_device, dev);
8191 /* setup gpio/pad */
8192 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8193
8194 if (curr_pin_cfg->cfg_sts == active)
8195 return;
8196
8197 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8198 if (curr_pin_cfg->is_gpio)
8199 msm_sdcc_setup_gpio(pdev->id, active);
8200 else
8201 msm_sdcc_setup_pad(pdev->id, active);
8202 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8203}
8204
8205static int msm_sdc3_get_wpswitch(struct device *dev)
8206{
8207 struct platform_device *pdev;
8208 int status;
8209 pdev = container_of(dev, struct platform_device, dev);
8210
8211 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8212 if (status) {
8213 pr_err("%s:Failed to request GPIO %d\n",
8214 __func__, GPIO_SDC_WP);
8215 } else {
8216 status = gpio_direction_input(GPIO_SDC_WP);
8217 if (!status) {
8218 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8219 pr_info("%s: WP Status for Slot %d = %d\n",
8220 __func__, pdev->id, status);
8221 }
8222 gpio_free(GPIO_SDC_WP);
8223 }
8224 return status;
8225}
8226
8227#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8228int sdc5_register_status_notify(void (*callback)(int, void *),
8229 void *dev_id)
8230{
8231 sdc5_status_notify_cb = callback;
8232 sdc5_status_notify_cb_devid = dev_id;
8233 return 0;
8234}
8235#endif
8236
8237#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8238int sdc2_register_status_notify(void (*callback)(int, void *),
8239 void *dev_id)
8240{
8241 sdc2_status_notify_cb = callback;
8242 sdc2_status_notify_cb_devid = dev_id;
8243 return 0;
8244}
8245#endif
8246
8247/* Interrupt handler for SDC2 and SDC5 detection
8248 * This function uses dual-edge interrputs settings in order
8249 * to get SDIO detection when the GPIO is rising and SDIO removal
8250 * when the GPIO is falling */
8251static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8252{
8253 int status;
8254
8255 if (!machine_is_msm8x60_fusion() &&
8256 !machine_is_msm8x60_fusn_ffa())
8257 return IRQ_NONE;
8258
8259 status = gpio_get_value(MDM2AP_SYNC);
8260 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8261 __func__, status);
8262
8263#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8264 if (sdc2_status_notify_cb) {
8265 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8266 sdc2_status_notify_cb(status,
8267 sdc2_status_notify_cb_devid);
8268 }
8269#endif
8270
8271#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8272 if (sdc5_status_notify_cb) {
8273 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8274 sdc5_status_notify_cb(status,
8275 sdc5_status_notify_cb_devid);
8276 }
8277#endif
8278 return IRQ_HANDLED;
8279}
8280
8281static int msm8x60_multi_sdio_init(void)
8282{
8283 int ret, irq_num;
8284
8285 if (!machine_is_msm8x60_fusion() &&
8286 !machine_is_msm8x60_fusn_ffa())
8287 return 0;
8288
8289 ret = msm_gpiomux_get(MDM2AP_SYNC);
8290 if (ret) {
8291 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8292 __func__, MDM2AP_SYNC, ret);
8293 return ret;
8294 }
8295
8296 irq_num = gpio_to_irq(MDM2AP_SYNC);
8297
8298 ret = request_irq(irq_num,
8299 msm8x60_multi_sdio_slot_status_irq,
8300 IRQ_TYPE_EDGE_BOTH,
8301 "sdio_multidetection", NULL);
8302
8303 if (ret) {
8304 pr_err("%s:Failed to request irq, ret=%d\n",
8305 __func__, ret);
8306 return ret;
8307 }
8308
8309 return ret;
8310}
8311
8312#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008313static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8314{
8315 int status;
8316
8317 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8318 , "SD_HW_Detect");
8319 if (status) {
8320 pr_err("%s:Failed to request GPIO %d\n", __func__,
8321 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8322 } else {
8323 status = gpio_direction_input(
8324 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8325 if (!status)
8326 status = !(gpio_get_value_cansleep(
8327 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8328 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8329 }
8330 return (unsigned int) status;
8331}
8332#endif
8333#endif
8334
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308335#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308336#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008337
8338#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8339static struct mmc_platform_data msm8x60_sdc1_data = {
8340 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8341 .translate_vdd = msm_sdcc_setup_power,
8342#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8343 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8344#else
8345 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8346#endif
8347 .msmsdcc_fmin = 400000,
8348 .msmsdcc_fmid = 24000000,
8349 .msmsdcc_fmax = 48000000,
8350 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308351 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008352};
8353#endif
8354
8355#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8356static struct mmc_platform_data msm8x60_sdc2_data = {
8357 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8358 .translate_vdd = msm_sdcc_setup_power,
8359 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8360 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8361 .msmsdcc_fmin = 400000,
8362 .msmsdcc_fmid = 24000000,
8363 .msmsdcc_fmax = 48000000,
8364 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008365 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008366#ifdef CONFIG_MSM_SDIO_AL
8367 .is_sdio_al_client = 1,
8368#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308369 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008370};
8371#endif
8372
8373#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8374static struct mmc_platform_data msm8x60_sdc3_data = {
8375 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8376 .translate_vdd = msm_sdcc_setup_power,
8377 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8378 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008379 .status = msm8x60_sdcc_slot_status,
8380 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8381 PMIC_GPIO_SDC3_DET - 1),
8382 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008383 .msmsdcc_fmin = 400000,
8384 .msmsdcc_fmid = 24000000,
8385 .msmsdcc_fmax = 48000000,
8386 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308387 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308388 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008389};
8390#endif
8391
8392#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8393static struct mmc_platform_data msm8x60_sdc4_data = {
8394 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8395 .translate_vdd = msm_sdcc_setup_power,
8396 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8397 .msmsdcc_fmin = 400000,
8398 .msmsdcc_fmid = 24000000,
8399 .msmsdcc_fmax = 48000000,
8400 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308401 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308402 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008403};
8404#endif
8405
8406#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8407static struct mmc_platform_data msm8x60_sdc5_data = {
8408 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8409 .translate_vdd = msm_sdcc_setup_power,
8410 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8411 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8412 .msmsdcc_fmin = 400000,
8413 .msmsdcc_fmid = 24000000,
8414 .msmsdcc_fmax = 48000000,
8415 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008416 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008417#ifdef CONFIG_MSM_SDIO_AL
8418 .is_sdio_al_client = 1,
8419#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308420 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008421};
8422#endif
8423
8424static void __init msm8x60_init_mmc(void)
8425{
8426#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8427 /* SDCC1 : eMMC card connected */
8428 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8429 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8430 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8431 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308432 sdcc_vreg_data[0].vdd_data->always_on = 1;
8433 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8434 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8435 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008436
8437 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8438 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8439 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8440 sdcc_vreg_data[0].vccq_data->always_on = 1;
8441
8442 msm_add_sdcc(1, &msm8x60_sdc1_data);
8443#endif
8444#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8445 /*
8446 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8447 * and no card is connected on 8660 SURF/FFA/FLUID.
8448 */
8449 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8450 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8451 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8452 sdcc_vreg_data[1].vdd_data->level = 1800000;
8453
8454 sdcc_vreg_data[1].vccq_data = NULL;
8455
8456 if (machine_is_msm8x60_fusion())
8457 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8458 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008459 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8460 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008461 msm_add_sdcc(2, &msm8x60_sdc2_data);
8462 }
8463#endif
8464#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8465 /* SDCC3 : External card slot connected */
8466 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8467 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8468 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8469 sdcc_vreg_data[2].vdd_data->level = 2850000;
8470 sdcc_vreg_data[2].vdd_data->always_on = 1;
8471 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8472 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8473 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8474
8475 sdcc_vreg_data[2].vccq_data = NULL;
8476
8477 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8478 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8479 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8480 sdcc_vreg_data[2].vddp_data->level = 2850000;
8481 sdcc_vreg_data[2].vddp_data->always_on = 1;
8482 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8483 /* Sleep current required is ~300 uA. But min. RPM
8484 * vote can be in terms of mA (min. 1 mA).
8485 * So let's vote for 2 mA during sleep.
8486 */
8487 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8488 /* Max. Active current required is 16 mA */
8489 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8490
8491 if (machine_is_msm8x60_fluid())
8492 msm8x60_sdc3_data.wpswitch = NULL;
8493 msm_add_sdcc(3, &msm8x60_sdc3_data);
8494#endif
8495#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8496 /* SDCC4 : WLAN WCN1314 chip is connected */
8497 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8498 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8499 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8500 sdcc_vreg_data[3].vdd_data->level = 1800000;
8501
8502 sdcc_vreg_data[3].vccq_data = NULL;
8503
8504 msm_add_sdcc(4, &msm8x60_sdc4_data);
8505#endif
8506#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8507 /*
8508 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8509 * and no card is connected on 8660 SURF/FFA/FLUID.
8510 */
8511 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8512 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8513 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8514 sdcc_vreg_data[4].vdd_data->level = 1800000;
8515
8516 sdcc_vreg_data[4].vccq_data = NULL;
8517
8518 if (machine_is_msm8x60_fusion())
8519 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8520 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008521 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8522 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008523 msm_add_sdcc(5, &msm8x60_sdc5_data);
8524 }
8525#endif
8526}
8527
8528#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8529static inline void display_common_power(int on) {}
8530#else
8531
8532#define _GET_REGULATOR(var, name) do { \
8533 if (var == NULL) { \
8534 var = regulator_get(NULL, name); \
8535 if (IS_ERR(var)) { \
8536 pr_err("'%s' regulator not found, rc=%ld\n", \
8537 name, PTR_ERR(var)); \
8538 var = NULL; \
8539 } \
8540 } \
8541} while (0)
8542
8543static int dsub_regulator(int on)
8544{
8545 static struct regulator *dsub_reg;
8546 static struct regulator *mpp0_reg;
8547 static int dsub_reg_enabled;
8548 int rc = 0;
8549
8550 _GET_REGULATOR(dsub_reg, "8901_l3");
8551 if (IS_ERR(dsub_reg)) {
8552 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8553 __func__, PTR_ERR(dsub_reg));
8554 return PTR_ERR(dsub_reg);
8555 }
8556
8557 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8558 if (IS_ERR(mpp0_reg)) {
8559 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8560 __func__, PTR_ERR(mpp0_reg));
8561 return PTR_ERR(mpp0_reg);
8562 }
8563
8564 if (on && !dsub_reg_enabled) {
8565 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8566 if (rc) {
8567 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8568 " err=%d", __func__, rc);
8569 goto dsub_regulator_err;
8570 }
8571 rc = regulator_enable(dsub_reg);
8572 if (rc) {
8573 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8574 " err=%d", __func__, rc);
8575 goto dsub_regulator_err;
8576 }
8577 rc = regulator_enable(mpp0_reg);
8578 if (rc) {
8579 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8580 " err=%d", __func__, rc);
8581 goto dsub_regulator_err;
8582 }
8583 dsub_reg_enabled = 1;
8584 } else if (!on && dsub_reg_enabled) {
8585 rc = regulator_disable(dsub_reg);
8586 if (rc)
8587 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8588 " err=%d", __func__, rc);
8589 rc = regulator_disable(mpp0_reg);
8590 if (rc)
8591 printk(KERN_WARNING "%s: failed to disable reg "
8592 "8901_mpp0 err=%d", __func__, rc);
8593 dsub_reg_enabled = 0;
8594 }
8595
8596 return rc;
8597
8598dsub_regulator_err:
8599 regulator_put(mpp0_reg);
8600 regulator_put(dsub_reg);
8601 return rc;
8602}
8603
8604static int display_power_on;
8605static void setup_display_power(void)
8606{
8607 if (display_power_on)
8608 if (lcdc_vga_enabled) {
8609 dsub_regulator(1);
8610 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8611 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8612 if (machine_is_msm8x60_ffa() ||
8613 machine_is_msm8x60_fusn_ffa())
8614 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8615 } else {
8616 dsub_regulator(0);
8617 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8618 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8619 if (machine_is_msm8x60_ffa() ||
8620 machine_is_msm8x60_fusn_ffa())
8621 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8622 }
8623 else {
8624 dsub_regulator(0);
8625 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8626 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8627 /* BACKLIGHT */
8628 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8629 /* LVDS */
8630 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8631 }
8632}
8633
8634#define _GET_REGULATOR(var, name) do { \
8635 if (var == NULL) { \
8636 var = regulator_get(NULL, name); \
8637 if (IS_ERR(var)) { \
8638 pr_err("'%s' regulator not found, rc=%ld\n", \
8639 name, PTR_ERR(var)); \
8640 var = NULL; \
8641 } \
8642 } \
8643} while (0)
8644
8645#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8646
8647static void display_common_power(int on)
8648{
8649 int rc;
8650 static struct regulator *display_reg;
8651
8652 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8653 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8654 if (on) {
8655 /* LVDS */
8656 _GET_REGULATOR(display_reg, "8901_l2");
8657 if (!display_reg)
8658 return;
8659 rc = regulator_set_voltage(display_reg,
8660 3300000, 3300000);
8661 if (rc)
8662 goto out;
8663 rc = regulator_enable(display_reg);
8664 if (rc)
8665 goto out;
8666 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8667 "LVDS_STDN_OUT_N");
8668 if (rc) {
8669 printk(KERN_ERR "%s: LVDS gpio %d request"
8670 "failed\n", __func__,
8671 GPIO_LVDS_SHUTDOWN_N);
8672 goto out2;
8673 }
8674
8675 /* BACKLIGHT */
8676 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8677 if (rc) {
8678 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8679 "failed\n", __func__,
8680 GPIO_BACKLIGHT_EN);
8681 goto out3;
8682 }
8683
8684 if (machine_is_msm8x60_ffa() ||
8685 machine_is_msm8x60_fusn_ffa()) {
8686 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8687 "DONGLE_PWR_EN");
8688 if (rc) {
8689 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8690 " %d request failed\n", __func__,
8691 GPIO_DONGLE_PWR_EN);
8692 goto out4;
8693 }
8694 }
8695
8696 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8697 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8698 if (machine_is_msm8x60_ffa() ||
8699 machine_is_msm8x60_fusn_ffa())
8700 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8701 mdelay(20);
8702 display_power_on = 1;
8703 setup_display_power();
8704 } else {
8705 if (display_power_on) {
8706 display_power_on = 0;
8707 setup_display_power();
8708 mdelay(20);
8709 if (machine_is_msm8x60_ffa() ||
8710 machine_is_msm8x60_fusn_ffa())
8711 gpio_free(GPIO_DONGLE_PWR_EN);
8712 goto out4;
8713 }
8714 }
8715 }
8716#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8717 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8718 else if (machine_is_msm8x60_fluid()) {
8719 static struct regulator *fluid_reg;
8720 static struct regulator *fluid_reg2;
8721
8722 if (on) {
8723 _GET_REGULATOR(fluid_reg, "8901_l2");
8724 if (!fluid_reg)
8725 return;
8726 _GET_REGULATOR(fluid_reg2, "8058_s3");
8727 if (!fluid_reg2) {
8728 regulator_put(fluid_reg);
8729 return;
8730 }
8731 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8732 if (rc) {
8733 regulator_put(fluid_reg2);
8734 regulator_put(fluid_reg);
8735 return;
8736 }
8737 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8738 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8739 regulator_enable(fluid_reg);
8740 regulator_enable(fluid_reg2);
8741 msleep(20);
8742 gpio_direction_output(GPIO_RESX_N, 0);
8743 udelay(10);
8744 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8745 display_power_on = 1;
8746 setup_display_power();
8747 } else {
8748 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8749 gpio_free(GPIO_RESX_N);
8750 msleep(20);
8751 regulator_disable(fluid_reg2);
8752 regulator_disable(fluid_reg);
8753 regulator_put(fluid_reg2);
8754 regulator_put(fluid_reg);
8755 display_power_on = 0;
8756 setup_display_power();
8757 fluid_reg = NULL;
8758 fluid_reg2 = NULL;
8759 }
8760 }
8761#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008762#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8763 else if (machine_is_msm8x60_dragon()) {
8764 static struct regulator *dragon_reg;
8765 static struct regulator *dragon_reg2;
8766
8767 if (on) {
8768 _GET_REGULATOR(dragon_reg, "8901_l2");
8769 if (!dragon_reg)
8770 return;
8771 _GET_REGULATOR(dragon_reg2, "8058_l16");
8772 if (!dragon_reg2) {
8773 regulator_put(dragon_reg);
8774 dragon_reg = NULL;
8775 return;
8776 }
8777
8778 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8779 if (rc) {
8780 pr_err("%s: gpio %d request failed with rc=%d\n",
8781 __func__, GPIO_NT35582_BL_EN, rc);
8782 regulator_put(dragon_reg);
8783 regulator_put(dragon_reg2);
8784 dragon_reg = NULL;
8785 dragon_reg2 = NULL;
8786 return;
8787 }
8788
8789 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8790 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8791 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8792 pr_err("%s: config gpio '%d' failed!\n",
8793 __func__, GPIO_NT35582_RESET);
8794 gpio_free(GPIO_NT35582_BL_EN);
8795 regulator_put(dragon_reg);
8796 regulator_put(dragon_reg2);
8797 dragon_reg = NULL;
8798 dragon_reg2 = NULL;
8799 return;
8800 }
8801
8802 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8803 if (rc) {
8804 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8805 __func__, GPIO_NT35582_RESET, rc);
8806 gpio_free(GPIO_NT35582_BL_EN);
8807 regulator_put(dragon_reg);
8808 regulator_put(dragon_reg2);
8809 dragon_reg = NULL;
8810 dragon_reg2 = NULL;
8811 return;
8812 }
8813
8814 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8815 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8816 regulator_enable(dragon_reg);
8817 regulator_enable(dragon_reg2);
8818 msleep(20);
8819
8820 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8821 msleep(20);
8822 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8823 msleep(20);
8824 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8825 msleep(50);
8826
8827 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8828
8829 display_power_on = 1;
8830 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8831 gpio_free(GPIO_NT35582_RESET);
8832 gpio_free(GPIO_NT35582_BL_EN);
8833 regulator_disable(dragon_reg2);
8834 regulator_disable(dragon_reg);
8835 regulator_put(dragon_reg2);
8836 regulator_put(dragon_reg);
8837 display_power_on = 0;
8838 dragon_reg = NULL;
8839 dragon_reg2 = NULL;
8840 }
8841 }
8842#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008843 return;
8844
8845out4:
8846 gpio_free(GPIO_BACKLIGHT_EN);
8847out3:
8848 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8849out2:
8850 regulator_disable(display_reg);
8851out:
8852 regulator_put(display_reg);
8853 display_reg = NULL;
8854}
8855#undef _GET_REGULATOR
8856#endif
8857
8858static int mipi_dsi_panel_power(int on);
8859
8860#define LCDC_NUM_GPIO 28
8861#define LCDC_GPIO_START 0
8862
8863static void lcdc_samsung_panel_power(int on)
8864{
8865 int n, ret = 0;
8866
8867 display_common_power(on);
8868
8869 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8870 if (on) {
8871 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8872 if (unlikely(ret)) {
8873 pr_err("%s not able to get gpio\n", __func__);
8874 break;
8875 }
8876 } else
8877 gpio_free(LCDC_GPIO_START + n);
8878 }
8879
8880 if (ret) {
8881 for (n--; n >= 0; n--)
8882 gpio_free(LCDC_GPIO_START + n);
8883 }
8884
8885 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8886}
8887
8888#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8889#define _GET_REGULATOR(var, name) do { \
8890 var = regulator_get(NULL, name); \
8891 if (IS_ERR(var)) { \
8892 pr_err("'%s' regulator not found, rc=%ld\n", \
8893 name, IS_ERR(var)); \
8894 var = NULL; \
8895 return -ENODEV; \
8896 } \
8897} while (0)
8898
8899static int hdmi_enable_5v(int on)
8900{
8901 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8902 static struct regulator *reg_8901_mpp0; /* External 5V */
8903 static int prev_on;
8904 int rc;
8905
8906 if (on == prev_on)
8907 return 0;
8908
8909 if (!reg_8901_hdmi_mvs)
8910 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8911 if (!reg_8901_mpp0)
8912 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8913
8914 if (on) {
8915 rc = regulator_enable(reg_8901_mpp0);
8916 if (rc) {
8917 pr_err("'%s' regulator enable failed, rc=%d\n",
8918 "reg_8901_mpp0", rc);
8919 return rc;
8920 }
8921 rc = regulator_enable(reg_8901_hdmi_mvs);
8922 if (rc) {
8923 pr_err("'%s' regulator enable failed, rc=%d\n",
8924 "8901_hdmi_mvs", rc);
8925 return rc;
8926 }
8927 pr_info("%s(on): success\n", __func__);
8928 } else {
8929 rc = regulator_disable(reg_8901_hdmi_mvs);
8930 if (rc)
8931 pr_warning("'%s' regulator disable failed, rc=%d\n",
8932 "8901_hdmi_mvs", rc);
8933 rc = regulator_disable(reg_8901_mpp0);
8934 if (rc)
8935 pr_warning("'%s' regulator disable failed, rc=%d\n",
8936 "reg_8901_mpp0", rc);
8937 pr_info("%s(off): success\n", __func__);
8938 }
8939
8940 prev_on = on;
8941
8942 return 0;
8943}
8944
8945static int hdmi_core_power(int on, int show)
8946{
8947 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8948 static int prev_on;
8949 int rc;
8950
8951 if (on == prev_on)
8952 return 0;
8953
8954 if (!reg_8058_l16)
8955 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8956
8957 if (on) {
8958 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8959 if (!rc)
8960 rc = regulator_enable(reg_8058_l16);
8961 if (rc) {
8962 pr_err("'%s' regulator enable failed, rc=%d\n",
8963 "8058_l16", rc);
8964 return rc;
8965 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05308966 pr_debug("%s(on): success\n", __func__);
8967 } else {
8968 rc = regulator_disable(reg_8058_l16);
8969 if (rc)
8970 pr_warning("'%s' regulator disable failed, rc=%d\n",
8971 "8058_l16", rc);
8972 pr_debug("%s(off): success\n", __func__);
8973 }
8974
8975 prev_on = on;
8976
8977 return 0;
8978}
8979
8980static int hdmi_gpio_config(int on)
8981{
8982 int rc = 0;
8983 static int prev_on;
8984
8985 if (on == prev_on)
8986 return 0;
8987
8988 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008989 rc = gpio_request(170, "HDMI_DDC_CLK");
8990 if (rc) {
8991 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8992 "HDMI_DDC_CLK", 170, rc);
8993 goto error1;
8994 }
8995 rc = gpio_request(171, "HDMI_DDC_DATA");
8996 if (rc) {
8997 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8998 "HDMI_DDC_DATA", 171, rc);
8999 goto error2;
9000 }
9001 rc = gpio_request(172, "HDMI_HPD");
9002 if (rc) {
9003 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9004 "HDMI_HPD", 172, rc);
9005 goto error3;
9006 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309007 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009008 } else {
9009 gpio_free(170);
9010 gpio_free(171);
9011 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309012 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009013 }
9014
9015 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009016 return 0;
9017
9018error3:
9019 gpio_free(171);
9020error2:
9021 gpio_free(170);
9022error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009023 return rc;
9024}
9025
9026static int hdmi_cec_power(int on)
9027{
9028 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9029 static int prev_on;
9030 int rc;
9031
9032 if (on == prev_on)
9033 return 0;
9034
9035 if (!reg_8901_l3)
9036 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9037
9038 if (on) {
9039 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9040 if (!rc)
9041 rc = regulator_enable(reg_8901_l3);
9042 if (rc) {
9043 pr_err("'%s' regulator enable failed, rc=%d\n",
9044 "8901_l3", rc);
9045 return rc;
9046 }
9047 rc = gpio_request(169, "HDMI_CEC_VAR");
9048 if (rc) {
9049 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9050 "HDMI_CEC_VAR", 169, rc);
9051 goto error;
9052 }
9053 pr_info("%s(on): success\n", __func__);
9054 } else {
9055 gpio_free(169);
9056 rc = regulator_disable(reg_8901_l3);
9057 if (rc)
9058 pr_warning("'%s' regulator disable failed, rc=%d\n",
9059 "8901_l3", rc);
9060 pr_info("%s(off): success\n", __func__);
9061 }
9062
9063 prev_on = on;
9064
9065 return 0;
9066error:
9067 regulator_disable(reg_8901_l3);
9068 return rc;
9069}
9070
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309071static int hdmi_panel_power(int on)
9072{
9073 int rc;
9074
9075 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9076 rc = hdmi_core_power(on, 1);
9077 if (rc)
9078 rc = hdmi_cec_power(on);
9079
9080 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9081 return rc;
9082}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009083#undef _GET_REGULATOR
9084
9085#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9086
9087static int lcdc_panel_power(int on)
9088{
9089 int flag_on = !!on;
9090 static int lcdc_power_save_on;
9091
9092 if (lcdc_power_save_on == flag_on)
9093 return 0;
9094
9095 lcdc_power_save_on = flag_on;
9096
9097 lcdc_samsung_panel_power(on);
9098
9099 return 0;
9100}
9101
9102#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009103
9104static struct msm_bus_vectors rotator_init_vectors[] = {
9105 {
9106 .src = MSM_BUS_MASTER_ROTATOR,
9107 .dst = MSM_BUS_SLAVE_SMI,
9108 .ab = 0,
9109 .ib = 0,
9110 },
9111 {
9112 .src = MSM_BUS_MASTER_ROTATOR,
9113 .dst = MSM_BUS_SLAVE_EBI_CH0,
9114 .ab = 0,
9115 .ib = 0,
9116 },
9117};
9118
9119static struct msm_bus_vectors rotator_ui_vectors[] = {
9120 {
9121 .src = MSM_BUS_MASTER_ROTATOR,
9122 .dst = MSM_BUS_SLAVE_SMI,
9123 .ab = 0,
9124 .ib = 0,
9125 },
9126 {
9127 .src = MSM_BUS_MASTER_ROTATOR,
9128 .dst = MSM_BUS_SLAVE_EBI_CH0,
9129 .ab = (1024 * 600 * 4 * 2 * 60),
9130 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9131 },
9132};
9133
9134static struct msm_bus_vectors rotator_vga_vectors[] = {
9135 {
9136 .src = MSM_BUS_MASTER_ROTATOR,
9137 .dst = MSM_BUS_SLAVE_SMI,
9138 .ab = (640 * 480 * 2 * 2 * 30),
9139 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9140 },
9141 {
9142 .src = MSM_BUS_MASTER_ROTATOR,
9143 .dst = MSM_BUS_SLAVE_EBI_CH0,
9144 .ab = (640 * 480 * 2 * 2 * 30),
9145 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9146 },
9147};
9148
9149static struct msm_bus_vectors rotator_720p_vectors[] = {
9150 {
9151 .src = MSM_BUS_MASTER_ROTATOR,
9152 .dst = MSM_BUS_SLAVE_SMI,
9153 .ab = (1280 * 736 * 2 * 2 * 30),
9154 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9155 },
9156 {
9157 .src = MSM_BUS_MASTER_ROTATOR,
9158 .dst = MSM_BUS_SLAVE_EBI_CH0,
9159 .ab = (1280 * 736 * 2 * 2 * 30),
9160 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9161 },
9162};
9163
9164static struct msm_bus_vectors rotator_1080p_vectors[] = {
9165 {
9166 .src = MSM_BUS_MASTER_ROTATOR,
9167 .dst = MSM_BUS_SLAVE_SMI,
9168 .ab = (1920 * 1088 * 2 * 2 * 30),
9169 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9170 },
9171 {
9172 .src = MSM_BUS_MASTER_ROTATOR,
9173 .dst = MSM_BUS_SLAVE_EBI_CH0,
9174 .ab = (1920 * 1088 * 2 * 2 * 30),
9175 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9176 },
9177};
9178
9179static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9180 {
9181 ARRAY_SIZE(rotator_init_vectors),
9182 rotator_init_vectors,
9183 },
9184 {
9185 ARRAY_SIZE(rotator_ui_vectors),
9186 rotator_ui_vectors,
9187 },
9188 {
9189 ARRAY_SIZE(rotator_vga_vectors),
9190 rotator_vga_vectors,
9191 },
9192 {
9193 ARRAY_SIZE(rotator_720p_vectors),
9194 rotator_720p_vectors,
9195 },
9196 {
9197 ARRAY_SIZE(rotator_1080p_vectors),
9198 rotator_1080p_vectors,
9199 },
9200};
9201
9202struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9203 rotator_bus_scale_usecases,
9204 ARRAY_SIZE(rotator_bus_scale_usecases),
9205 .name = "rotator",
9206};
9207
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009208static struct msm_bus_vectors mdp_init_vectors[] = {
9209 /* For now, 0th array entry is reserved.
9210 * Please leave 0 as is and don't use it
9211 */
9212 {
9213 .src = MSM_BUS_MASTER_MDP_PORT0,
9214 .dst = MSM_BUS_SLAVE_SMI,
9215 .ab = 0,
9216 .ib = 0,
9217 },
9218 /* Master and slaves can be from different fabrics */
9219 {
9220 .src = MSM_BUS_MASTER_MDP_PORT0,
9221 .dst = MSM_BUS_SLAVE_EBI_CH0,
9222 .ab = 0,
9223 .ib = 0,
9224 },
9225};
9226
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009227#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009228static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9229 /* Default case static display/UI/2d/3d if FB SMI */
9230 {
9231 .src = MSM_BUS_MASTER_MDP_PORT0,
9232 .dst = MSM_BUS_SLAVE_SMI,
9233 .ab = 388800000,
9234 .ib = 486000000,
9235 },
9236 /* Master and slaves can be from different fabrics */
9237 {
9238 .src = MSM_BUS_MASTER_MDP_PORT0,
9239 .dst = MSM_BUS_SLAVE_EBI_CH0,
9240 .ab = 0,
9241 .ib = 0,
9242 },
9243};
9244
9245static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9246 /* Default case static display/UI/2d/3d if FB SMI */
9247 {
9248 .src = MSM_BUS_MASTER_MDP_PORT0,
9249 .dst = MSM_BUS_SLAVE_SMI,
9250 .ab = 0,
9251 .ib = 0,
9252 },
9253 /* Master and slaves can be from different fabrics */
9254 {
9255 .src = MSM_BUS_MASTER_MDP_PORT0,
9256 .dst = MSM_BUS_SLAVE_EBI_CH0,
9257 .ab = 388800000,
9258 .ib = 486000000 * 2,
9259 },
9260};
9261static struct msm_bus_vectors mdp_vga_vectors[] = {
9262 /* VGA and less video */
9263 {
9264 .src = MSM_BUS_MASTER_MDP_PORT0,
9265 .dst = MSM_BUS_SLAVE_SMI,
9266 .ab = 458092800,
9267 .ib = 572616000,
9268 },
9269 {
9270 .src = MSM_BUS_MASTER_MDP_PORT0,
9271 .dst = MSM_BUS_SLAVE_EBI_CH0,
9272 .ab = 458092800,
9273 .ib = 572616000 * 2,
9274 },
9275};
9276static struct msm_bus_vectors mdp_720p_vectors[] = {
9277 /* 720p and less video */
9278 {
9279 .src = MSM_BUS_MASTER_MDP_PORT0,
9280 .dst = MSM_BUS_SLAVE_SMI,
9281 .ab = 471744000,
9282 .ib = 589680000,
9283 },
9284 /* Master and slaves can be from different fabrics */
9285 {
9286 .src = MSM_BUS_MASTER_MDP_PORT0,
9287 .dst = MSM_BUS_SLAVE_EBI_CH0,
9288 .ab = 471744000,
9289 .ib = 589680000 * 2,
9290 },
9291};
9292
9293static struct msm_bus_vectors mdp_1080p_vectors[] = {
9294 /* 1080p and less video */
9295 {
9296 .src = MSM_BUS_MASTER_MDP_PORT0,
9297 .dst = MSM_BUS_SLAVE_SMI,
9298 .ab = 575424000,
9299 .ib = 719280000,
9300 },
9301 /* Master and slaves can be from different fabrics */
9302 {
9303 .src = MSM_BUS_MASTER_MDP_PORT0,
9304 .dst = MSM_BUS_SLAVE_EBI_CH0,
9305 .ab = 575424000,
9306 .ib = 719280000 * 2,
9307 },
9308};
9309
9310#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009311static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9312 /* Default case static display/UI/2d/3d if FB SMI */
9313 {
9314 .src = MSM_BUS_MASTER_MDP_PORT0,
9315 .dst = MSM_BUS_SLAVE_SMI,
9316 .ab = 175110000,
9317 .ib = 218887500,
9318 },
9319 /* Master and slaves can be from different fabrics */
9320 {
9321 .src = MSM_BUS_MASTER_MDP_PORT0,
9322 .dst = MSM_BUS_SLAVE_EBI_CH0,
9323 .ab = 0,
9324 .ib = 0,
9325 },
9326};
9327
9328static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9329 /* Default case static display/UI/2d/3d if FB SMI */
9330 {
9331 .src = MSM_BUS_MASTER_MDP_PORT0,
9332 .dst = MSM_BUS_SLAVE_SMI,
9333 .ab = 0,
9334 .ib = 0,
9335 },
9336 /* Master and slaves can be from different fabrics */
9337 {
9338 .src = MSM_BUS_MASTER_MDP_PORT0,
9339 .dst = MSM_BUS_SLAVE_EBI_CH0,
9340 .ab = 216000000,
9341 .ib = 270000000 * 2,
9342 },
9343};
9344static struct msm_bus_vectors mdp_vga_vectors[] = {
9345 /* VGA and less video */
9346 {
9347 .src = MSM_BUS_MASTER_MDP_PORT0,
9348 .dst = MSM_BUS_SLAVE_SMI,
9349 .ab = 216000000,
9350 .ib = 270000000,
9351 },
9352 {
9353 .src = MSM_BUS_MASTER_MDP_PORT0,
9354 .dst = MSM_BUS_SLAVE_EBI_CH0,
9355 .ab = 216000000,
9356 .ib = 270000000 * 2,
9357 },
9358};
9359
9360static struct msm_bus_vectors mdp_720p_vectors[] = {
9361 /* 720p and less video */
9362 {
9363 .src = MSM_BUS_MASTER_MDP_PORT0,
9364 .dst = MSM_BUS_SLAVE_SMI,
9365 .ab = 230400000,
9366 .ib = 288000000,
9367 },
9368 /* Master and slaves can be from different fabrics */
9369 {
9370 .src = MSM_BUS_MASTER_MDP_PORT0,
9371 .dst = MSM_BUS_SLAVE_EBI_CH0,
9372 .ab = 230400000,
9373 .ib = 288000000 * 2,
9374 },
9375};
9376
9377static struct msm_bus_vectors mdp_1080p_vectors[] = {
9378 /* 1080p and less video */
9379 {
9380 .src = MSM_BUS_MASTER_MDP_PORT0,
9381 .dst = MSM_BUS_SLAVE_SMI,
9382 .ab = 334080000,
9383 .ib = 417600000,
9384 },
9385 /* Master and slaves can be from different fabrics */
9386 {
9387 .src = MSM_BUS_MASTER_MDP_PORT0,
9388 .dst = MSM_BUS_SLAVE_EBI_CH0,
9389 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009390 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009391 },
9392};
9393
9394#endif
9395static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9396 {
9397 ARRAY_SIZE(mdp_init_vectors),
9398 mdp_init_vectors,
9399 },
9400 {
9401 ARRAY_SIZE(mdp_sd_smi_vectors),
9402 mdp_sd_smi_vectors,
9403 },
9404 {
9405 ARRAY_SIZE(mdp_sd_ebi_vectors),
9406 mdp_sd_ebi_vectors,
9407 },
9408 {
9409 ARRAY_SIZE(mdp_vga_vectors),
9410 mdp_vga_vectors,
9411 },
9412 {
9413 ARRAY_SIZE(mdp_720p_vectors),
9414 mdp_720p_vectors,
9415 },
9416 {
9417 ARRAY_SIZE(mdp_1080p_vectors),
9418 mdp_1080p_vectors,
9419 },
9420};
9421static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9422 mdp_bus_scale_usecases,
9423 ARRAY_SIZE(mdp_bus_scale_usecases),
9424 .name = "mdp",
9425};
9426
9427#endif
9428#ifdef CONFIG_MSM_BUS_SCALING
9429static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9430 /* For now, 0th array entry is reserved.
9431 * Please leave 0 as is and don't use it
9432 */
9433 {
9434 .src = MSM_BUS_MASTER_MDP_PORT0,
9435 .dst = MSM_BUS_SLAVE_SMI,
9436 .ab = 0,
9437 .ib = 0,
9438 },
9439 /* Master and slaves can be from different fabrics */
9440 {
9441 .src = MSM_BUS_MASTER_MDP_PORT0,
9442 .dst = MSM_BUS_SLAVE_EBI_CH0,
9443 .ab = 0,
9444 .ib = 0,
9445 },
9446};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009447
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009448static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9449 /* For now, 0th array entry is reserved.
9450 * Please leave 0 as is and don't use it
9451 */
9452 {
9453 .src = MSM_BUS_MASTER_MDP_PORT0,
9454 .dst = MSM_BUS_SLAVE_SMI,
9455 .ab = 566092800,
9456 .ib = 707616000,
9457 },
9458 /* Master and slaves can be from different fabrics */
9459 {
9460 .src = MSM_BUS_MASTER_MDP_PORT0,
9461 .dst = MSM_BUS_SLAVE_EBI_CH0,
9462 .ab = 566092800,
9463 .ib = 707616000,
9464 },
9465};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009466
9467static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9468 /* For now, 0th array entry is reserved.
9469 * Please leave 0 as is and don't use it
9470 */
9471 {
9472 .src = MSM_BUS_MASTER_MDP_PORT0,
9473 .dst = MSM_BUS_SLAVE_SMI,
9474 .ab = 2000000000,
9475 .ib = 2000000000,
9476 },
9477 /* Master and slaves can be from different fabrics */
9478 {
9479 .src = MSM_BUS_MASTER_MDP_PORT0,
9480 .dst = MSM_BUS_SLAVE_EBI_CH0,
9481 .ab = 2000000000,
9482 .ib = 2000000000,
9483 },
9484};
9485
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009486static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9487 {
9488 ARRAY_SIZE(dtv_bus_init_vectors),
9489 dtv_bus_init_vectors,
9490 },
9491 {
9492 ARRAY_SIZE(dtv_bus_def_vectors),
9493 dtv_bus_def_vectors,
9494 },
9495};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009496
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009497static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9498 dtv_bus_scale_usecases,
9499 ARRAY_SIZE(dtv_bus_scale_usecases),
9500 .name = "dtv",
9501};
9502
9503static struct lcdc_platform_data dtv_pdata = {
9504 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309505 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009506};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009507
9508static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9509 {
9510 ARRAY_SIZE(dtv_bus_init_vectors),
9511 dtv_bus_init_vectors,
9512 },
9513 {
9514 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9515 dtv_bus_hdmi_prim_vectors,
9516 },
9517};
9518
9519static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9520 dtv_hdmi_prim_bus_scale_usecases,
9521 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9522 .name = "dtv",
9523};
9524
9525static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9526 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9527};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009528#endif
9529
9530
9531static struct lcdc_platform_data lcdc_pdata = {
9532 .lcdc_power_save = lcdc_panel_power,
9533};
9534
9535
9536#define MDP_VSYNC_GPIO 28
9537
9538/*
9539 * MIPI_DSI only use 8058_LDO0 which need always on
9540 * therefore it need to be put at low power mode if
9541 * it was not used instead of turn it off.
9542 */
9543static int mipi_dsi_panel_power(int on)
9544{
9545 int flag_on = !!on;
9546 static int mipi_dsi_power_save_on;
9547 static struct regulator *ldo0;
9548 int rc = 0;
9549
9550 if (mipi_dsi_power_save_on == flag_on)
9551 return 0;
9552
9553 mipi_dsi_power_save_on = flag_on;
9554
9555 if (ldo0 == NULL) { /* init */
9556 ldo0 = regulator_get(NULL, "8058_l0");
9557 if (IS_ERR(ldo0)) {
9558 pr_debug("%s: LDO0 failed\n", __func__);
9559 rc = PTR_ERR(ldo0);
9560 return rc;
9561 }
9562
9563 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9564 if (rc)
9565 goto out;
9566
9567 rc = regulator_enable(ldo0);
9568 if (rc)
9569 goto out;
9570 }
9571
9572 if (on) {
9573 /* set ldo0 to HPM */
9574 rc = regulator_set_optimum_mode(ldo0, 100000);
9575 if (rc < 0)
9576 goto out;
9577 } else {
9578 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309579 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009580 if (rc < 0)
9581 goto out;
9582 }
9583
9584 return 0;
9585out:
9586 regulator_disable(ldo0);
9587 regulator_put(ldo0);
9588 ldo0 = NULL;
9589 return rc;
9590}
9591
9592static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9593 .vsync_gpio = MDP_VSYNC_GPIO,
9594 .dsi_power_save = mipi_dsi_panel_power,
9595};
9596
9597#ifdef CONFIG_FB_MSM_TVOUT
9598static struct regulator *reg_8058_l13;
9599
9600static int atv_dac_power(int on)
9601{
9602 int rc = 0;
9603 #define _GET_REGULATOR(var, name) do { \
9604 var = regulator_get(NULL, name); \
9605 if (IS_ERR(var)) { \
9606 pr_info("'%s' regulator not found, rc=%ld\n", \
9607 name, IS_ERR(var)); \
9608 var = NULL; \
9609 return -ENODEV; \
9610 } \
9611 } while (0)
9612
9613 if (!reg_8058_l13)
9614 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9615 #undef _GET_REGULATOR
9616
9617 if (on) {
9618 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9619 if (rc) {
9620 pr_info("%s: '%s' regulator set voltage failed,\
9621 rc=%d\n", __func__, "8058_l13", rc);
9622 return rc;
9623 }
9624
9625 rc = regulator_enable(reg_8058_l13);
9626 if (rc) {
9627 pr_err("%s: '%s' regulator enable failed,\
9628 rc=%d\n", __func__, "8058_l13", rc);
9629 return rc;
9630 }
9631 } else {
9632 rc = regulator_force_disable(reg_8058_l13);
9633 if (rc)
9634 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9635 __func__, "8058_l13", rc);
9636 }
9637 return rc;
9638
9639}
9640#endif
9641
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009642static struct msm_panel_common_pdata mdp_pdata = {
9643 .gpio = MDP_VSYNC_GPIO,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009644 .mdp_max_clk = 200000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009645#ifdef CONFIG_MSM_BUS_SCALING
9646 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9647#endif
9648 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009649#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009650 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009651#else
9652 .mem_hid = MEMTYPE_EBI1,
9653#endif
Olav Hauganef95ae32012-05-15 09:50:30 -07009654 .mdp_iommu_split_domain = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009655};
9656
Huaibin Yanga5419422011-12-08 23:52:10 -08009657static void __init reserve_mdp_memory(void)
9658{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009659 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9660 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9661#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9662 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9663 mdp_pdata.ov0_wb_size;
9664 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9665 mdp_pdata.ov1_wb_size;
9666#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009667}
9668
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009669#ifdef CONFIG_FB_MSM_TVOUT
9670
9671#ifdef CONFIG_MSM_BUS_SCALING
9672static struct msm_bus_vectors atv_bus_init_vectors[] = {
9673 /* For now, 0th array entry is reserved.
9674 * Please leave 0 as is and don't use it
9675 */
9676 {
9677 .src = MSM_BUS_MASTER_MDP_PORT0,
9678 .dst = MSM_BUS_SLAVE_SMI,
9679 .ab = 0,
9680 .ib = 0,
9681 },
9682 /* Master and slaves can be from different fabrics */
9683 {
9684 .src = MSM_BUS_MASTER_MDP_PORT0,
9685 .dst = MSM_BUS_SLAVE_EBI_CH0,
9686 .ab = 0,
9687 .ib = 0,
9688 },
9689};
9690static struct msm_bus_vectors atv_bus_def_vectors[] = {
9691 /* For now, 0th array entry is reserved.
9692 * Please leave 0 as is and don't use it
9693 */
9694 {
9695 .src = MSM_BUS_MASTER_MDP_PORT0,
9696 .dst = MSM_BUS_SLAVE_SMI,
9697 .ab = 236390400,
9698 .ib = 265939200,
9699 },
9700 /* Master and slaves can be from different fabrics */
9701 {
9702 .src = MSM_BUS_MASTER_MDP_PORT0,
9703 .dst = MSM_BUS_SLAVE_EBI_CH0,
9704 .ab = 236390400,
9705 .ib = 265939200,
9706 },
9707};
9708static struct msm_bus_paths atv_bus_scale_usecases[] = {
9709 {
9710 ARRAY_SIZE(atv_bus_init_vectors),
9711 atv_bus_init_vectors,
9712 },
9713 {
9714 ARRAY_SIZE(atv_bus_def_vectors),
9715 atv_bus_def_vectors,
9716 },
9717};
9718static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9719 atv_bus_scale_usecases,
9720 ARRAY_SIZE(atv_bus_scale_usecases),
9721 .name = "atv",
9722};
9723#endif
9724
9725static struct tvenc_platform_data atv_pdata = {
9726 .poll = 0,
9727 .pm_vid_en = atv_dac_power,
9728#ifdef CONFIG_MSM_BUS_SCALING
9729 .bus_scale_table = &atv_bus_scale_pdata,
9730#endif
9731};
9732#endif
9733
9734static void __init msm_fb_add_devices(void)
9735{
9736#ifdef CONFIG_FB_MSM_LCDC_DSUB
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009737 mdp_pdata.mdp_max_clk = 200000000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009738#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -07009739 msm_fb_register_device("mdp", &mdp_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009740
9741 msm_fb_register_device("lcdc", &lcdc_pdata);
9742 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9743#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009744 if (hdmi_is_primary)
9745 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9746 else
9747 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009748#endif
9749#ifdef CONFIG_FB_MSM_TVOUT
9750 msm_fb_register_device("tvenc", &atv_pdata);
9751 msm_fb_register_device("tvout_device", NULL);
9752#endif
9753}
9754
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009755/**
9756 * Set MDP clocks to high frequency to avoid underflow when
9757 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9758 */
9759static void set_mdp_clocks_for_wuxga(void)
9760{
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009761 mdp_sd_smi_vectors[0].ab = 2000000000;
9762 mdp_sd_smi_vectors[0].ib = 2000000000;
9763 mdp_sd_smi_vectors[1].ab = 2000000000;
9764 mdp_sd_smi_vectors[1].ib = 2000000000;
9765
9766 mdp_sd_ebi_vectors[0].ab = 2000000000;
9767 mdp_sd_ebi_vectors[0].ib = 2000000000;
9768 mdp_sd_ebi_vectors[1].ab = 2000000000;
9769 mdp_sd_ebi_vectors[1].ib = 2000000000;
9770
9771 mdp_vga_vectors[0].ab = 2000000000;
9772 mdp_vga_vectors[0].ib = 2000000000;
9773 mdp_vga_vectors[1].ab = 2000000000;
9774 mdp_vga_vectors[1].ib = 2000000000;
9775
9776 mdp_720p_vectors[0].ab = 2000000000;
9777 mdp_720p_vectors[0].ib = 2000000000;
9778 mdp_720p_vectors[1].ab = 2000000000;
9779 mdp_720p_vectors[1].ib = 2000000000;
9780
9781 mdp_1080p_vectors[0].ab = 2000000000;
9782 mdp_1080p_vectors[0].ib = 2000000000;
9783 mdp_1080p_vectors[1].ab = 2000000000;
9784 mdp_1080p_vectors[1].ib = 2000000000;
9785
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009786 mdp_pdata.mdp_max_clk = 200000000;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009787}
9788
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009789#if (defined(CONFIG_MARIMBA_CORE)) && \
9790 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9791
9792static const struct {
9793 char *name;
9794 int vmin;
9795 int vmax;
9796} bt_regs_info[] = {
9797 { "8058_s3", 1800000, 1800000 },
9798 { "8058_s2", 1300000, 1300000 },
9799 { "8058_l8", 2900000, 3050000 },
9800};
9801
9802static struct {
9803 bool enabled;
9804} bt_regs_status[] = {
9805 { false },
9806 { false },
9807 { false },
9808};
9809static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9810
9811static int bahama_bt(int on)
9812{
9813 int rc;
9814 int i;
9815 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9816
9817 struct bahama_variant_register {
9818 const size_t size;
9819 const struct bahama_config_register *set;
9820 };
9821
9822 const struct bahama_config_register *p;
9823
9824 u8 version;
9825
9826 const struct bahama_config_register v10_bt_on[] = {
9827 { 0xE9, 0x00, 0xFF },
9828 { 0xF4, 0x80, 0xFF },
9829 { 0xE4, 0x00, 0xFF },
9830 { 0xE5, 0x00, 0x0F },
9831#ifdef CONFIG_WLAN
9832 { 0xE6, 0x38, 0x7F },
9833 { 0xE7, 0x06, 0xFF },
9834#endif
9835 { 0xE9, 0x21, 0xFF },
9836 { 0x01, 0x0C, 0x1F },
9837 { 0x01, 0x08, 0x1F },
9838 };
9839
9840 const struct bahama_config_register v20_bt_on_fm_off[] = {
9841 { 0x11, 0x0C, 0xFF },
9842 { 0x13, 0x01, 0xFF },
9843 { 0xF4, 0x80, 0xFF },
9844 { 0xF0, 0x00, 0xFF },
9845 { 0xE9, 0x00, 0xFF },
9846#ifdef CONFIG_WLAN
9847 { 0x81, 0x00, 0x7F },
9848 { 0x82, 0x00, 0xFF },
9849 { 0xE6, 0x38, 0x7F },
9850 { 0xE7, 0x06, 0xFF },
9851#endif
9852 { 0xE9, 0x21, 0xFF },
9853 };
9854
9855 const struct bahama_config_register v20_bt_on_fm_on[] = {
9856 { 0x11, 0x0C, 0xFF },
9857 { 0x13, 0x01, 0xFF },
9858 { 0xF4, 0x86, 0xFF },
9859 { 0xF0, 0x06, 0xFF },
9860 { 0xE9, 0x00, 0xFF },
9861#ifdef CONFIG_WLAN
9862 { 0x81, 0x00, 0x7F },
9863 { 0x82, 0x00, 0xFF },
9864 { 0xE6, 0x38, 0x7F },
9865 { 0xE7, 0x06, 0xFF },
9866#endif
9867 { 0xE9, 0x21, 0xFF },
9868 };
9869
9870 const struct bahama_config_register v10_bt_off[] = {
9871 { 0xE9, 0x00, 0xFF },
9872 };
9873
9874 const struct bahama_config_register v20_bt_off_fm_off[] = {
9875 { 0xF4, 0x84, 0xFF },
9876 { 0xF0, 0x04, 0xFF },
9877 { 0xE9, 0x00, 0xFF }
9878 };
9879
9880 const struct bahama_config_register v20_bt_off_fm_on[] = {
9881 { 0xF4, 0x86, 0xFF },
9882 { 0xF0, 0x06, 0xFF },
9883 { 0xE9, 0x00, 0xFF }
9884 };
9885 const struct bahama_variant_register bt_bahama[2][3] = {
9886 {
9887 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9888 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9889 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9890 },
9891 {
9892 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9893 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9894 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9895 }
9896 };
9897
9898 u8 offset = 0; /* index into bahama configs */
9899
9900 on = on ? 1 : 0;
9901 version = read_bahama_ver();
9902
9903 if (version == VER_UNSUPPORTED) {
9904 dev_err(&msm_bt_power_device.dev,
9905 "%s: unsupported version\n",
9906 __func__);
9907 return -EIO;
9908 }
9909
9910 if (version == VER_2_0) {
9911 if (marimba_get_fm_status(&config))
9912 offset = 0x01;
9913 }
9914
9915 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9916 if (on && (version == VER_2_0)) {
9917 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9918 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9919 && (bt_regs_status[i].enabled == true)) {
9920 if (regulator_disable(bt_regs[i])) {
9921 dev_err(&msm_bt_power_device.dev,
9922 "%s: regulator disable failed",
9923 __func__);
9924 }
9925 bt_regs_status[i].enabled = false;
9926 break;
9927 }
9928 }
9929 }
9930
9931 p = bt_bahama[on][version + offset].set;
9932
9933 dev_info(&msm_bt_power_device.dev,
9934 "%s: found version %d\n", __func__, version);
9935
9936 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9937 u8 value = (p+i)->value;
9938 rc = marimba_write_bit_mask(&config,
9939 (p+i)->reg,
9940 &value,
9941 sizeof((p+i)->value),
9942 (p+i)->mask);
9943 if (rc < 0) {
9944 dev_err(&msm_bt_power_device.dev,
9945 "%s: reg %d write failed: %d\n",
9946 __func__, (p+i)->reg, rc);
9947 return rc;
9948 }
9949 dev_dbg(&msm_bt_power_device.dev,
9950 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9951 __func__, (p+i)->reg,
9952 value, (p+i)->mask);
9953 }
9954 /* Update BT Status */
9955 if (on)
9956 marimba_set_bt_status(&config, true);
9957 else
9958 marimba_set_bt_status(&config, false);
9959
9960 return 0;
9961}
9962
9963static int bluetooth_use_regulators(int on)
9964{
9965 int i, recover = -1, rc = 0;
9966
9967 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9968 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9969 bt_regs_info[i].name) :
9970 (regulator_put(bt_regs[i]), NULL);
9971 if (IS_ERR(bt_regs[i])) {
9972 rc = PTR_ERR(bt_regs[i]);
9973 dev_err(&msm_bt_power_device.dev,
9974 "regulator %s get failed (%d)\n",
9975 bt_regs_info[i].name, rc);
9976 recover = i - 1;
9977 bt_regs[i] = NULL;
9978 break;
9979 }
9980
9981 if (!on)
9982 continue;
9983
9984 rc = regulator_set_voltage(bt_regs[i],
9985 bt_regs_info[i].vmin,
9986 bt_regs_info[i].vmax);
9987 if (rc < 0) {
9988 dev_err(&msm_bt_power_device.dev,
9989 "regulator %s voltage set (%d)\n",
9990 bt_regs_info[i].name, rc);
9991 recover = i;
9992 break;
9993 }
9994 }
9995
9996 if (on && (recover > -1))
9997 for (i = recover; i >= 0; i--) {
9998 regulator_put(bt_regs[i]);
9999 bt_regs[i] = NULL;
10000 }
10001
10002 return rc;
10003}
10004
10005static int bluetooth_switch_regulators(int on)
10006{
10007 int i, rc = 0;
10008
10009 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10010 if (on && (bt_regs_status[i].enabled == false)) {
10011 rc = regulator_enable(bt_regs[i]);
10012 if (rc < 0) {
10013 dev_err(&msm_bt_power_device.dev,
10014 "regulator %s %s failed (%d)\n",
10015 bt_regs_info[i].name,
10016 "enable", rc);
10017 if (i > 0) {
10018 while (--i) {
10019 regulator_disable(bt_regs[i]);
10020 bt_regs_status[i].enabled
10021 = false;
10022 }
10023 break;
10024 }
10025 }
10026 bt_regs_status[i].enabled = true;
10027 } else if (!on && (bt_regs_status[i].enabled == true)) {
10028 rc = regulator_disable(bt_regs[i]);
10029 if (rc < 0) {
10030 dev_err(&msm_bt_power_device.dev,
10031 "regulator %s %s failed (%d)\n",
10032 bt_regs_info[i].name,
10033 "disable", rc);
10034 break;
10035 }
10036 bt_regs_status[i].enabled = false;
10037 }
10038 }
10039 return rc;
10040}
10041
10042static struct msm_xo_voter *bt_clock;
10043
10044static int bluetooth_power(int on)
10045{
10046 int rc = 0;
10047 int id;
10048
10049 /* In case probe function fails, cur_connv_type would be -1 */
10050 id = adie_get_detected_connectivity_type();
10051 if (id != BAHAMA_ID) {
10052 pr_err("%s: unexpected adie connectivity type: %d\n",
10053 __func__, id);
10054 return -ENODEV;
10055 }
10056
10057 if (on) {
10058
10059 rc = bluetooth_use_regulators(1);
10060 if (rc < 0)
10061 goto out;
10062
10063 rc = bluetooth_switch_regulators(1);
10064
10065 if (rc < 0)
10066 goto fail_put;
10067
10068 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10069
10070 if (IS_ERR(bt_clock)) {
10071 pr_err("Couldn't get TCXO_D0 voter\n");
10072 goto fail_switch;
10073 }
10074
10075 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10076
10077 if (rc < 0) {
10078 pr_err("Failed to vote for TCXO_DO ON\n");
10079 goto fail_vote;
10080 }
10081
10082 rc = bahama_bt(1);
10083
10084 if (rc < 0)
10085 goto fail_clock;
10086
10087 msleep(10);
10088
10089 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10090
10091 if (rc < 0) {
10092 pr_err("Failed to vote for TCXO_DO pin control\n");
10093 goto fail_vote;
10094 }
10095 } else {
10096 /* check for initial RFKILL block (power off) */
10097 /* some RFKILL versions/configurations rfkill_register */
10098 /* calls here for an initial set_block */
10099 /* avoid calling i2c and regulator before unblock (on) */
10100 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10101 dev_info(&msm_bt_power_device.dev,
10102 "%s: initialized OFF/blocked\n", __func__);
10103 goto out;
10104 }
10105
10106 bahama_bt(0);
10107
10108fail_clock:
10109 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10110fail_vote:
10111 msm_xo_put(bt_clock);
10112fail_switch:
10113 bluetooth_switch_regulators(0);
10114fail_put:
10115 bluetooth_use_regulators(0);
10116 }
10117
10118out:
10119 if (rc < 0)
10120 on = 0;
10121 dev_info(&msm_bt_power_device.dev,
10122 "Bluetooth power switch: state %d result %d\n", on, rc);
10123
10124 return rc;
10125}
10126
10127#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10128
10129static void __init msm8x60_cfg_smsc911x(void)
10130{
10131 smsc911x_resources[1].start =
10132 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10133 smsc911x_resources[1].end =
10134 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10135}
10136
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010137void msm_fusion_setup_pinctrl(void)
10138{
10139 struct msm_xo_voter *a1;
10140
10141 if (socinfo_get_platform_subtype() == 0x3) {
10142 /*
10143 * Vote for the A1 clock to be in pin control mode before
10144 * the external images are loaded.
10145 */
10146 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10147 BUG_ON(!a1);
10148 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10149 }
10150}
10151
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010152struct msm_board_data {
10153 struct msm_gpiomux_configs *gpiomux_cfgs;
10154};
10155
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010156static struct msm_board_data msm8x60_surf_board_data __initdata = {
10157 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10158};
10159
10160static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10161 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10162};
10163
10164static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10165 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10166};
10167
10168static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10169 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10170};
10171
10172static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10173 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10174};
10175
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010176static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10177 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10178};
10179
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010180static void __init msm8x60_init(struct msm_board_data *board_data)
10181{
10182 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010183#ifdef CONFIG_USB_EHCI_MSM_72K
10184 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10185 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10186 .level = PM8901_MPP_DIG_LEVEL_L5,
10187 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10188 };
10189#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010190 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010191
Rohit Vaswanib1cc4932012-07-23 21:30:11 -070010192 platform_device_register(&msm_gpio_device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010193 /*
10194 * Initialize RPM first as other drivers and devices may need
10195 * it for their initialization.
10196 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010197 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10198 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010199 if (msm_xo_init())
10200 pr_err("Failed to initialize XO votes\n");
10201
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010202 msm8x60_check_2d_hardware();
10203
10204 /* Change SPM handling of core 1 if PMM 8160 is present. */
10205 soc_platform_version = socinfo_get_platform_version();
10206 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10207 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10208 struct msm_spm_platform_data *spm_data;
10209
10210 spm_data = &msm_spm_data_v1[1];
10211 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10212 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10213
10214 spm_data = &msm_spm_data[1];
10215 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10216 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10217 }
10218
10219 /*
10220 * Initialize SPM before acpuclock as the latter calls into SPM
10221 * driver to set ACPU voltages.
10222 */
10223 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10224 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10225 else
10226 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10227
10228 /*
10229 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10230 * devices so that the RPM doesn't drop into a low power mode that an
10231 * un-reworked SURF cannot resume from.
10232 */
10233 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010234 int i;
10235
10236 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10237 if (rpm_regulator_init_data[i].id
10238 == RPM_VREG_ID_PM8901_L4
10239 || rpm_regulator_init_data[i].id
10240 == RPM_VREG_ID_PM8901_L6)
10241 rpm_regulator_init_data[i]
10242 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010243 }
10244
10245 /*
10246 * Disable regulator info printing so that regulator registration
10247 * messages do not enter the kmsg log.
10248 */
10249 regulator_suppress_info_printing();
10250
10251 /* Initialize regulators needed for clock_init. */
10252 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10253
Stephen Boydbb600ae2011-08-02 20:11:40 -070010254 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010255
10256 /* Buses need to be initialized before early-device registration
10257 * to get the platform data for fabrics.
10258 */
10259 msm8x60_init_buses();
10260 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010261
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010262 /*
10263 * Enable EBI2 only for boards which make use of it. Leave
10264 * it disabled for all others for additional power savings.
10265 */
10266 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010267 machine_is_msm8x60_fluid() ||
10268 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010269 msm8x60_init_ebi2();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010270 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10271 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010272#ifdef CONFIG_MSM_CAMERA_V4L2
10273 msm8x60_init_cam();
10274#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010275 msm8x60_init_mmc();
10276
Kevin Chan3be11612012-03-22 20:05:40 -070010277
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010278#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10279 msm8x60_init_pm8058_othc();
10280#endif
10281
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010282 if (machine_is_msm8x60_fluid())
10283 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10284 else if (machine_is_msm8x60_dragon())
10285 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10286 else
10287 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010288#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010289 /* Specify reset pin for OV9726 */
10290 if (machine_is_msm8x60_dragon()) {
10291 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10292 ov9726_sensor_8660_info.mount_angle = 270;
10293 }
Kevin Chan3be11612012-03-22 20:05:40 -070010294#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010295#ifdef CONFIG_BATTERY_MSM8X60
10296 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10297 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10298 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10299 platform_device_register(&msm_charger_device);
10300#endif
10301
10302 if (machine_is_msm8x60_dragon())
10303 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10304 if (!machine_is_msm8x60_fluid())
10305 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10306
10307 /* configure pmic leds */
10308 if (machine_is_msm8x60_fluid())
10309 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10310 else if (machine_is_msm8x60_dragon())
10311 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10312 else
10313 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10314
10315 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10316 machine_is_msm8x60_dragon()) {
10317 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10318 }
10319
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010320 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10321 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010322 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010323 msm8x60_cfg_smsc911x();
10324 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010325 platform_add_devices(msm8660_footswitch,
10326 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010327 platform_add_devices(surf_devices,
10328 ARRAY_SIZE(surf_devices));
10329
10330#ifdef CONFIG_MSM_DSPS
10331 if (machine_is_msm8x60_fluid()) {
10332 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10333 msm8x60_init_dsps();
10334 }
10335#endif
10336
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010337 pm8901_vreg_mpp0_init();
10338
10339 platform_device_register(&msm8x60_8901_mpp_vreg);
10340
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010341#ifdef CONFIG_USB_EHCI_MSM_72K
10342 /*
10343 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10344 * fluid
10345 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010346 if (machine_is_msm8x60_fluid())
10347 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10348 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010349#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010350
10351#ifdef CONFIG_SND_SOC_MSM8660_APQ
10352 if (machine_is_msm8x60_dragon())
10353 platform_add_devices(dragon_alsa_devices,
10354 ARRAY_SIZE(dragon_alsa_devices));
10355 else
10356#endif
10357 platform_add_devices(asoc_devices,
10358 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010359 }
10360#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010361 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10362 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010363 msm8x60_cfg_isp1763();
10364#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010365
10366 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10367 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010369
10370#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10371 if (machine_is_msm8x60_fluid())
10372 platform_device_register(&msm_gsbi10_qup_spi_device);
10373 else
10374 platform_device_register(&msm_gsbi1_qup_spi_device);
10375#endif
10376
Steve Mucklef132c6c2012-06-06 18:30:57 -070010377#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10378 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010379 if (machine_is_msm8x60_fluid())
10380 cyttsp_set_params();
10381#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -070010382 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010383 fixup_i2c_configs();
10384 register_i2c_devices();
10385
Terence Hampson1c73fef2011-07-19 17:10:49 -040010386 if (machine_is_msm8x60_dragon())
10387 smsc911x_config.reset_gpio
10388 = GPIO_ETHERNET_RESET_N_DRAGON;
10389
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010390 platform_device_register(&smsc911x_device);
10391
10392#if (defined(CONFIG_SPI_QUP)) && \
10393 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010394 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10395 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010396
10397 if (machine_is_msm8x60_fluid()) {
10398#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10399 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10400 spi_register_board_info(lcdc_samsung_spi_board_info,
10401 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10402 } else
10403#endif
10404 {
10405#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10406 spi_register_board_info(lcdc_auo_spi_board_info,
10407 ARRAY_SIZE(lcdc_auo_spi_board_info));
10408#endif
10409 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010410#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10411 } else if (machine_is_msm8x60_dragon()) {
10412 spi_register_board_info(lcdc_nt35582_spi_board_info,
10413 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10414#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010415 }
10416#endif
10417
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010418 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010419
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010420 pm8058_gpios_init();
10421
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010422#ifdef CONFIG_SENSORS_MSM_ADC
10423 if (machine_is_msm8x60_fluid()) {
10424 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10425 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10426 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10427 msm_adc_pdata.gpio_config = APROC_CONFIG;
10428 else
10429 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10430 }
10431 msm_adc_pdata.target_hw = MSM_8x60;
10432#endif
10433#ifdef CONFIG_MSM8X60_AUDIO
10434 msm_snddev_init();
10435#endif
10436#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10437 if (machine_is_msm8x60_fluid())
10438 platform_device_register(&fluid_leds_gpio);
10439 else
10440 platform_device_register(&gpio_leds);
10441#endif
10442
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010443 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010444
10445 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10446 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010447}
10448
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010449static void __init msm8x60_surf_init(void)
10450{
10451 msm8x60_init(&msm8x60_surf_board_data);
10452}
10453
10454static void __init msm8x60_ffa_init(void)
10455{
10456 msm8x60_init(&msm8x60_ffa_board_data);
10457}
10458
10459static void __init msm8x60_fluid_init(void)
10460{
10461 msm8x60_init(&msm8x60_fluid_board_data);
10462}
10463
10464static void __init msm8x60_charm_surf_init(void)
10465{
10466 msm8x60_init(&msm8x60_charm_surf_board_data);
10467}
10468
10469static void __init msm8x60_charm_ffa_init(void)
10470{
10471 msm8x60_init(&msm8x60_charm_ffa_board_data);
10472}
10473
10474static void __init msm8x60_charm_init_early(void)
10475{
10476 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010477}
10478
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010479static void __init msm8x60_dragon_init(void)
10480{
10481 msm8x60_init(&msm8x60_dragon_board_data);
10482}
David Brown56e2d8a2011-08-04 02:01:02 -070010483
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010484MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10485 .map_io = msm8x60_map_io,
10486 .reserve = msm8x60_reserve,
10487 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010488 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010489 .init_machine = msm8x60_surf_init,
10490 .timer = &msm_timer,
10491 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010492 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010493MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010494
10495MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10496 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010497 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010498 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010499 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010500 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010501 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010502 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010503 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010504MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010505
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010506MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010507 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010508 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010509 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010510 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010511 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010512 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010513 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010514 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010515MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010516
10517MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10518 .map_io = msm8x60_map_io,
10519 .reserve = msm8x60_reserve,
10520 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010521 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010522 .init_machine = msm8x60_charm_surf_init,
10523 .timer = &msm_timer,
10524 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010525 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010526MACHINE_END
10527
10528MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10529 .map_io = msm8x60_map_io,
10530 .reserve = msm8x60_reserve,
10531 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010532 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010533 .init_machine = msm8x60_charm_ffa_init,
10534 .timer = &msm_timer,
10535 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010536 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010537MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010538
10539MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10540 .map_io = msm8x60_map_io,
10541 .reserve = msm8x60_reserve,
10542 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010543 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010544 .init_machine = msm8x60_dragon_init,
10545 .timer = &msm_timer,
10546 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010547 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010548MACHINE_END