blob: d57dde0283a61b036f4b2ef357d35e195878ff8f [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. 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
107#include <linux/ion.h>
108#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
3603static int configure_uart_gpios(int on)
3604{
3605 int ret = 0, i;
3606 int uart_gpios[] = {53, 54, 55, 56};
3607 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3608 if (on) {
3609 ret = msm_gpiomux_get(uart_gpios[i]);
3610 if (unlikely(ret))
3611 break;
3612 } else {
3613 ret = msm_gpiomux_put(uart_gpios[i]);
3614 if (unlikely(ret))
3615 return ret;
3616 }
3617 }
3618 if (ret)
3619 for (; i >= 0; i--)
3620 msm_gpiomux_put(uart_gpios[i]);
3621 return ret;
3622}
3623static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3624 .inject_rx_on_wakeup = 1,
3625 .rx_to_inject = 0xFD,
3626 .gpio_config = configure_uart_gpios,
3627};
3628#endif
3629
3630
3631#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3632
3633static struct gpio_led gpio_exp_leds_config[] = {
3634 {
3635 .name = "left_led1:green",
3636 .gpio = GPIO_LEFT_LED_1,
3637 .active_low = 1,
3638 .retain_state_suspended = 0,
3639 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3640 },
3641 {
3642 .name = "left_led2:red",
3643 .gpio = GPIO_LEFT_LED_2,
3644 .active_low = 1,
3645 .retain_state_suspended = 0,
3646 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3647 },
3648 {
3649 .name = "left_led3:green",
3650 .gpio = GPIO_LEFT_LED_3,
3651 .active_low = 1,
3652 .retain_state_suspended = 0,
3653 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3654 },
3655 {
3656 .name = "wlan_led:orange",
3657 .gpio = GPIO_LEFT_LED_WLAN,
3658 .active_low = 1,
3659 .retain_state_suspended = 0,
3660 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3661 },
3662 {
3663 .name = "left_led5:green",
3664 .gpio = GPIO_LEFT_LED_5,
3665 .active_low = 1,
3666 .retain_state_suspended = 0,
3667 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3668 },
3669 {
3670 .name = "right_led1:green",
3671 .gpio = GPIO_RIGHT_LED_1,
3672 .active_low = 1,
3673 .retain_state_suspended = 0,
3674 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3675 },
3676 {
3677 .name = "right_led2:red",
3678 .gpio = GPIO_RIGHT_LED_2,
3679 .active_low = 1,
3680 .retain_state_suspended = 0,
3681 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3682 },
3683 {
3684 .name = "right_led3:green",
3685 .gpio = GPIO_RIGHT_LED_3,
3686 .active_low = 1,
3687 .retain_state_suspended = 0,
3688 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3689 },
3690 {
3691 .name = "bt_led:blue",
3692 .gpio = GPIO_RIGHT_LED_BT,
3693 .active_low = 1,
3694 .retain_state_suspended = 0,
3695 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3696 },
3697 {
3698 .name = "right_led5:green",
3699 .gpio = GPIO_RIGHT_LED_5,
3700 .active_low = 1,
3701 .retain_state_suspended = 0,
3702 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3703 },
3704};
3705
3706static struct gpio_led_platform_data gpio_leds_pdata = {
3707 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3708 .leds = gpio_exp_leds_config,
3709};
3710
3711static struct platform_device gpio_leds = {
3712 .name = "leds-gpio",
3713 .id = -1,
3714 .dev = {
3715 .platform_data = &gpio_leds_pdata,
3716 },
3717};
3718
3719static struct gpio_led fluid_gpio_leds[] = {
3720 {
3721 .name = "dual_led:green",
3722 .gpio = GPIO_LED1_GREEN_N,
3723 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3724 .active_low = 1,
3725 .retain_state_suspended = 0,
3726 },
3727 {
3728 .name = "dual_led:red",
3729 .gpio = GPIO_LED2_RED_N,
3730 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3731 .active_low = 1,
3732 .retain_state_suspended = 0,
3733 },
3734};
3735
3736static struct gpio_led_platform_data gpio_led_pdata = {
3737 .leds = fluid_gpio_leds,
3738 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3739};
3740
3741static struct platform_device fluid_leds_gpio = {
3742 .name = "leds-gpio",
3743 .id = -1,
3744 .dev = {
3745 .platform_data = &gpio_led_pdata,
3746 },
3747};
3748
3749#endif
3750
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003751#ifdef CONFIG_BATTERY_MSM8X60
3752static struct msm_charger_platform_data msm_charger_data = {
3753 .safety_time = 180,
3754 .update_time = 1,
3755 .max_voltage = 4200,
3756 .min_voltage = 3200,
3757};
3758
3759static struct platform_device msm_charger_device = {
3760 .name = "msm-charger",
3761 .id = -1,
3762 .dev = {
3763 .platform_data = &msm_charger_data,
3764 }
3765};
3766#endif
3767
3768/*
3769 * Consumer specific regulator names:
3770 * regulator name consumer dev_name
3771 */
3772static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3773 REGULATOR_SUPPLY("8058_l0", NULL),
3774};
3775static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3776 REGULATOR_SUPPLY("8058_l1", NULL),
3777};
3778static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3779 REGULATOR_SUPPLY("8058_l2", NULL),
3780};
3781static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3782 REGULATOR_SUPPLY("8058_l3", NULL),
3783};
3784static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3785 REGULATOR_SUPPLY("8058_l4", NULL),
3786};
3787static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3788 REGULATOR_SUPPLY("8058_l5", NULL),
3789};
3790static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3791 REGULATOR_SUPPLY("8058_l6", NULL),
3792};
3793static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3794 REGULATOR_SUPPLY("8058_l7", NULL),
3795};
3796static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3797 REGULATOR_SUPPLY("8058_l8", NULL),
3798};
3799static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3800 REGULATOR_SUPPLY("8058_l9", NULL),
3801};
3802static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3803 REGULATOR_SUPPLY("8058_l10", NULL),
3804};
3805static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3806 REGULATOR_SUPPLY("8058_l11", NULL),
3807};
3808static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3809 REGULATOR_SUPPLY("8058_l12", NULL),
3810};
3811static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3812 REGULATOR_SUPPLY("8058_l13", NULL),
3813};
3814static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3815 REGULATOR_SUPPLY("8058_l14", NULL),
3816};
3817static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3818 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003819 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003820 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003821 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822};
3823static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3824 REGULATOR_SUPPLY("8058_l16", NULL),
3825};
3826static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3827 REGULATOR_SUPPLY("8058_l17", NULL),
3828};
3829static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3830 REGULATOR_SUPPLY("8058_l18", NULL),
3831};
3832static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3833 REGULATOR_SUPPLY("8058_l19", NULL),
3834};
3835static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3836 REGULATOR_SUPPLY("8058_l20", NULL),
3837};
3838static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3839 REGULATOR_SUPPLY("8058_l21", NULL),
3840};
3841static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3842 REGULATOR_SUPPLY("8058_l22", NULL),
3843};
3844static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3845 REGULATOR_SUPPLY("8058_l23", NULL),
3846};
3847static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3848 REGULATOR_SUPPLY("8058_l24", NULL),
3849};
3850static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3851 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003852 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003853 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003854 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003855};
3856static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3857 REGULATOR_SUPPLY("8058_s0", NULL),
3858};
3859static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3860 REGULATOR_SUPPLY("8058_s1", NULL),
3861};
3862static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3863 REGULATOR_SUPPLY("8058_s2", NULL),
3864};
3865static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3866 REGULATOR_SUPPLY("8058_s3", NULL),
3867};
3868static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3869 REGULATOR_SUPPLY("8058_s4", NULL),
3870};
3871static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3872 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003873 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003874 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003875 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003876};
3877static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3878 REGULATOR_SUPPLY("8058_lvs1", NULL),
3879};
3880static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3881 REGULATOR_SUPPLY("8058_ncp", NULL),
3882};
3883
3884static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3885 REGULATOR_SUPPLY("8901_l0", NULL),
3886};
3887static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3888 REGULATOR_SUPPLY("8901_l1", NULL),
3889};
3890static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3891 REGULATOR_SUPPLY("8901_l2", NULL),
3892};
3893static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3894 REGULATOR_SUPPLY("8901_l3", NULL),
3895};
3896static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3897 REGULATOR_SUPPLY("8901_l4", NULL),
3898};
3899static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3900 REGULATOR_SUPPLY("8901_l5", NULL),
3901};
3902static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3903 REGULATOR_SUPPLY("8901_l6", NULL),
3904};
3905static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3906 REGULATOR_SUPPLY("8901_s2", NULL),
3907};
3908static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3909 REGULATOR_SUPPLY("8901_s3", NULL),
3910};
3911static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3912 REGULATOR_SUPPLY("8901_s4", NULL),
3913};
3914static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3915 REGULATOR_SUPPLY("8901_lvs0", NULL),
3916};
3917static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3918 REGULATOR_SUPPLY("8901_lvs1", NULL),
3919};
3920static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3921 REGULATOR_SUPPLY("8901_lvs2", NULL),
3922};
3923static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3924 REGULATOR_SUPPLY("8901_lvs3", NULL),
3925};
3926static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3927 REGULATOR_SUPPLY("8901_mvs0", NULL),
3928};
3929
David Collins6f032ba2011-08-31 14:08:15 -07003930/* Pin control regulators */
3931static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3932 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3933};
3934static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3935 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3936};
3937static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3938 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3939};
3940static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3941 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3942};
3943static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3944 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3945};
3946static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3947 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3948};
3949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003950#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3951 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003952 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3953 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003954 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003955 .init_data = { \
3956 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003957 .valid_modes_mask = _modes, \
3958 .valid_ops_mask = _ops, \
3959 .min_uV = _min_uV, \
3960 .max_uV = _max_uV, \
3961 .input_uV = _min_uV, \
3962 .apply_uV = _apply_uV, \
3963 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003964 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003965 .consumer_supplies = vreg_consumers_##_id, \
3966 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003967 ARRAY_SIZE(vreg_consumers_##_id), \
3968 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003969 .id = RPM_VREG_ID_##_id, \
3970 .default_uV = _default_uV, \
3971 .peak_uA = _peak_uA, \
3972 .avg_uA = _avg_uA, \
3973 .pull_down_enable = _pull_down, \
3974 .pin_ctrl = _pin_ctrl, \
3975 .freq = RPM_VREG_FREQ_##_freq, \
3976 .pin_fn = _pin_fn, \
3977 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003978 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003979 .state = _state, \
3980 .sleep_selectable = _sleep_selectable, \
3981 }
3982
3983/* Pin control initialization */
3984#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3985 { \
3986 .init_data = { \
3987 .constraints = { \
3988 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3989 .always_on = _always_on, \
3990 }, \
3991 .num_consumer_supplies = \
3992 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3993 .consumer_supplies = vreg_consumers_##_id##_PC, \
3994 }, \
3995 .id = RPM_VREG_ID_##_id##_PC, \
3996 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003997 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003998 }
3999
4000/*
4001 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4002 * via the peak_uA value specified in the table below. If the value is less
4003 * than the high power min threshold for the regulator, then the regulator will
4004 * be set to LPM. Otherwise, it will be set to HPM.
4005 *
4006 * This value can be further overridden by specifying an initial mode via
4007 * .init_data.constraints.initial_mode.
4008 */
4009
David Collins6f032ba2011-08-31 14:08:15 -07004010#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4011 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004012 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4013 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4014 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4015 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4016 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004017 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4018 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004019 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004020 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004021 _sleep_selectable, _always_on)
4022
David Collins6f032ba2011-08-31 14:08:15 -07004023#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4024 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004025 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4026 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4027 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4028 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4029 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004030 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4031 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004032 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004033 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4034 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004035
David Collins6f032ba2011-08-31 14:08:15 -07004036#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004037 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4038 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004039 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4040 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004041 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004042 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4043 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004044
David Collins6f032ba2011-08-31 14:08:15 -07004045#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4047 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004048 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4049 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004050 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004051 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4052 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004053
David Collins6f032ba2011-08-31 14:08:15 -07004054#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4055#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4056#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4057#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4058#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004059
David Collins6f032ba2011-08-31 14:08:15 -07004060/* RPM early regulator constraints */
4061static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4062 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004063 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004064 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004065};
4066
David Collins6f032ba2011-08-31 14:08:15 -07004067/* RPM regulator constraints */
4068static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4069 /* ID a_on pd ss min_uV max_uV init_ip */
4070 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4071 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4072 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4073 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4074 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4075 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4076 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4077 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4078 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4079 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4080 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4081 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4082 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4083 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4084 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4085 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4086 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4087 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4088 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4089 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4090 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4091 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4092 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4093 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4094 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4095 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004096
David Collins6f032ba2011-08-31 14:08:15 -07004097 /* ID a_on pd ss min_uV max_uV init_ip freq */
4098 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4099 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4100 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4101
4102 /* ID a_on pd ss */
4103 RPM_VS(PM8058_LVS0, 0, 1, 0),
4104 RPM_VS(PM8058_LVS1, 0, 1, 0),
4105
4106 /* ID a_on pd ss min_uV max_uV */
4107 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4108
4109 /* ID a_on pd ss min_uV max_uV init_ip */
4110 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4111 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4112 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4113 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4114 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4115 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4116 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4117
4118 /* ID a_on pd ss min_uV max_uV init_ip freq */
4119 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4120 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4121 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4122
4123 /* ID a_on pd ss */
4124 RPM_VS(PM8901_LVS0, 1, 1, 0),
4125 RPM_VS(PM8901_LVS1, 0, 1, 0),
4126 RPM_VS(PM8901_LVS2, 0, 1, 0),
4127 RPM_VS(PM8901_LVS3, 0, 1, 0),
4128 RPM_VS(PM8901_MVS0, 0, 1, 0),
4129
4130 /* ID a_on pin_func pin_ctrl */
4131 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4132 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4133 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4134 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4135 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4136 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4137};
4138
4139static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4140 .init_data = rpm_regulator_early_init_data,
4141 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4142 .version = RPM_VREG_VERSION_8660,
4143 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4144 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4145};
4146
4147static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4148 .init_data = rpm_regulator_init_data,
4149 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4150 .version = RPM_VREG_VERSION_8660,
4151};
4152
4153static struct platform_device rpm_regulator_early_device = {
4154 .name = "rpm-regulator",
4155 .id = 0,
4156 .dev = {
4157 .platform_data = &rpm_regulator_early_pdata,
4158 },
4159};
4160
4161static struct platform_device rpm_regulator_device = {
4162 .name = "rpm-regulator",
4163 .id = 1,
4164 .dev = {
4165 .platform_data = &rpm_regulator_pdata,
4166 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004167};
4168
4169static struct platform_device *early_regulators[] __initdata = {
4170 &msm_device_saw_s0,
4171 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004172 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004173};
4174
4175static struct platform_device *early_devices[] __initdata = {
4176#ifdef CONFIG_MSM_BUS_SCALING
4177 &msm_bus_apps_fabric,
4178 &msm_bus_sys_fabric,
4179 &msm_bus_mm_fabric,
4180 &msm_bus_sys_fpb,
4181 &msm_bus_cpss_fpb,
4182#endif
4183 &msm_device_dmov_adm0,
4184 &msm_device_dmov_adm1,
4185};
4186
4187#if (defined(CONFIG_MARIMBA_CORE)) && \
4188 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4189
4190static int bluetooth_power(int);
4191static struct platform_device msm_bt_power_device = {
4192 .name = "bt_power",
4193 .id = -1,
4194 .dev = {
4195 .platform_data = &bluetooth_power,
4196 },
4197};
4198#endif
4199
4200static struct platform_device msm_tsens_device = {
4201 .name = "tsens-tm",
4202 .id = -1,
4203};
4204
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004205#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4206enum {
4207 SX150X_CORE,
4208 SX150X_DOCKING,
4209 SX150X_SURF,
4210 SX150X_LEFT_FHA,
4211 SX150X_RIGHT_FHA,
4212 SX150X_SOUTH,
4213 SX150X_NORTH,
4214 SX150X_CORE_FLUID,
4215};
4216
4217static struct sx150x_platform_data sx150x_data[] __initdata = {
4218 [SX150X_CORE] = {
4219 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4220 .oscio_is_gpo = false,
4221 .io_pullup_ena = 0x0c08,
4222 .io_pulldn_ena = 0x4060,
4223 .io_open_drain_ena = 0x000c,
4224 .io_polarity = 0,
4225 .irq_summary = -1, /* see fixup_i2c_configs() */
4226 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4227 },
4228 [SX150X_DOCKING] = {
4229 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4230 .oscio_is_gpo = false,
4231 .io_pullup_ena = 0x5e06,
4232 .io_pulldn_ena = 0x81b8,
4233 .io_open_drain_ena = 0,
4234 .io_polarity = 0,
4235 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4236 UI_INT2_N),
4237 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4238 GPIO_DOCKING_EXPANDER_BASE -
4239 GPIO_EXPANDER_GPIO_BASE,
4240 },
4241 [SX150X_SURF] = {
4242 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4243 .oscio_is_gpo = false,
4244 .io_pullup_ena = 0,
4245 .io_pulldn_ena = 0,
4246 .io_open_drain_ena = 0,
4247 .io_polarity = 0,
4248 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4249 UI_INT1_N),
4250 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4251 GPIO_SURF_EXPANDER_BASE -
4252 GPIO_EXPANDER_GPIO_BASE,
4253 },
4254 [SX150X_LEFT_FHA] = {
4255 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4256 .oscio_is_gpo = false,
4257 .io_pullup_ena = 0,
4258 .io_pulldn_ena = 0x40,
4259 .io_open_drain_ena = 0,
4260 .io_polarity = 0,
4261 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4262 UI_INT3_N),
4263 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4264 GPIO_LEFT_KB_EXPANDER_BASE -
4265 GPIO_EXPANDER_GPIO_BASE,
4266 },
4267 [SX150X_RIGHT_FHA] = {
4268 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4269 .oscio_is_gpo = true,
4270 .io_pullup_ena = 0,
4271 .io_pulldn_ena = 0,
4272 .io_open_drain_ena = 0,
4273 .io_polarity = 0,
4274 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4275 UI_INT3_N),
4276 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4277 GPIO_RIGHT_KB_EXPANDER_BASE -
4278 GPIO_EXPANDER_GPIO_BASE,
4279 },
4280 [SX150X_SOUTH] = {
4281 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4282 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4283 GPIO_SOUTH_EXPANDER_BASE -
4284 GPIO_EXPANDER_GPIO_BASE,
4285 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4286 },
4287 [SX150X_NORTH] = {
4288 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4289 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4290 GPIO_NORTH_EXPANDER_BASE -
4291 GPIO_EXPANDER_GPIO_BASE,
4292 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4293 .oscio_is_gpo = true,
4294 .io_open_drain_ena = 0x30,
4295 },
4296 [SX150X_CORE_FLUID] = {
4297 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4298 .oscio_is_gpo = false,
4299 .io_pullup_ena = 0x0408,
4300 .io_pulldn_ena = 0x4060,
4301 .io_open_drain_ena = 0x0008,
4302 .io_polarity = 0,
4303 .irq_summary = -1, /* see fixup_i2c_configs() */
4304 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4305 },
4306};
4307
4308#ifdef CONFIG_SENSORS_MSM_ADC
4309/* Configuration of EPM expander is done when client
4310 * request an adc read
4311 */
4312static struct sx150x_platform_data sx150x_epmdata = {
4313 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4314 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4315 GPIO_EPM_EXPANDER_BASE -
4316 GPIO_EXPANDER_GPIO_BASE,
4317 .irq_summary = -1,
4318};
4319#endif
4320
4321/* sx150x_low_power_cfg
4322 *
4323 * This data and init function are used to put unused gpio-expander output
4324 * lines into their low-power states at boot. The init
4325 * function must be deferred until a later init stage because the i2c
4326 * gpio expander drivers do not probe until after they are registered
4327 * (see register_i2c_devices) and the work-queues for those registrations
4328 * are processed. Because these lines are unused, there is no risk of
4329 * competing with a device driver for the gpio.
4330 *
4331 * gpio lines whose low-power states are input are naturally in their low-
4332 * power configurations once probed, see the platform data structures above.
4333 */
4334struct sx150x_low_power_cfg {
4335 unsigned gpio;
4336 unsigned val;
4337};
4338
4339static struct sx150x_low_power_cfg
4340common_sx150x_lp_cfgs[] __initdata = {
4341 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4342 {GPIO_EXT_GPS_LNA_EN, 0},
4343 {GPIO_MSM_WAKES_BT, 0},
4344 {GPIO_USB_UICC_EN, 0},
4345 {GPIO_BATT_GAUGE_EN, 0},
4346};
4347
4348static struct sx150x_low_power_cfg
4349surf_ffa_sx150x_lp_cfgs[] __initdata = {
4350 {GPIO_MIPI_DSI_RST_N, 0},
4351 {GPIO_DONGLE_PWR_EN, 0},
4352 {GPIO_CAP_TS_SLEEP, 1},
4353 {GPIO_WEB_CAMIF_RESET_N, 0},
4354};
4355
4356static void __init
4357cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4358{
4359 unsigned n;
4360 int rc;
4361
4362 for (n = 0; n < nelems; ++n) {
4363 rc = gpio_request(cfgs[n].gpio, NULL);
4364 if (!rc) {
4365 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4366 gpio_free(cfgs[n].gpio);
4367 }
4368
4369 if (rc) {
4370 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4371 __func__, cfgs[n].gpio, rc);
4372 }
Steve Muckle9161d302010-02-11 11:50:40 -08004373 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004374}
4375
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004376static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004377{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004378 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4379 ARRAY_SIZE(common_sx150x_lp_cfgs));
4380 if (!machine_is_msm8x60_fluid())
4381 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4382 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4383 return 0;
4384}
4385module_init(cfg_sx150xs_low_power);
4386
4387#ifdef CONFIG_I2C
4388static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4389 {
4390 I2C_BOARD_INFO("sx1509q", 0x3e),
4391 .platform_data = &sx150x_data[SX150X_CORE]
4392 },
4393};
4394
4395static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4396 {
4397 I2C_BOARD_INFO("sx1509q", 0x3f),
4398 .platform_data = &sx150x_data[SX150X_DOCKING]
4399 },
4400};
4401
4402static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4403 {
4404 I2C_BOARD_INFO("sx1509q", 0x70),
4405 .platform_data = &sx150x_data[SX150X_SURF]
4406 }
4407};
4408
4409static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4410 {
4411 I2C_BOARD_INFO("sx1508q", 0x21),
4412 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4413 },
4414 {
4415 I2C_BOARD_INFO("sx1508q", 0x22),
4416 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4417 }
4418};
4419
4420static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4421 {
4422 I2C_BOARD_INFO("sx1508q", 0x23),
4423 .platform_data = &sx150x_data[SX150X_SOUTH]
4424 },
4425 {
4426 I2C_BOARD_INFO("sx1508q", 0x20),
4427 .platform_data = &sx150x_data[SX150X_NORTH]
4428 }
4429};
4430
4431static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4432 {
4433 I2C_BOARD_INFO("sx1509q", 0x3e),
4434 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4435 },
4436};
4437
4438#ifdef CONFIG_SENSORS_MSM_ADC
4439static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4440 {
4441 I2C_BOARD_INFO("sx1509q", 0x3e),
4442 .platform_data = &sx150x_epmdata
4443 },
4444};
4445#endif
4446#endif
4447#endif
4448
4449#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004450
4451static struct adc_access_fn xoadc_fn = {
4452 pm8058_xoadc_select_chan_and_start_conv,
4453 pm8058_xoadc_read_adc_code,
4454 pm8058_xoadc_get_properties,
4455 pm8058_xoadc_slot_request,
4456 pm8058_xoadc_restore_slot,
4457 pm8058_xoadc_calibrate,
4458};
4459
4460#if defined(CONFIG_I2C) && \
4461 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4462static struct regulator *vreg_adc_epm1;
4463
4464static struct i2c_client *epm_expander_i2c_register_board(void)
4465
4466{
4467 struct i2c_adapter *i2c_adap;
4468 struct i2c_client *client = NULL;
4469 i2c_adap = i2c_get_adapter(0x0);
4470
4471 if (i2c_adap == NULL)
4472 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4473
4474 if (i2c_adap != NULL)
4475 client = i2c_new_device(i2c_adap,
4476 &fluid_expanders_i2c_epm_info[0]);
4477 return client;
4478
4479}
4480
4481static unsigned int msm_adc_gpio_configure_expander_enable(void)
4482{
4483 int rc = 0;
4484 static struct i2c_client *epm_i2c_client;
4485
4486 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4487
4488 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4489
4490 if (IS_ERR(vreg_adc_epm1)) {
4491 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4492 return 0;
4493 }
4494
4495 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4496 if (rc)
4497 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4498 "regulator set voltage failed\n");
4499
4500 rc = regulator_enable(vreg_adc_epm1);
4501 if (rc) {
4502 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4503 "Error while enabling regulator for epm s3 %d\n", rc);
4504 return rc;
4505 }
4506
4507 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4508 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4509
4510 msleep(1000);
4511
4512 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4513 if (!rc) {
4514 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4515 "Configure 5v boost\n");
4516 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4517 } else {
4518 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4519 "Error for epm 5v boost en\n");
4520 goto exit_vreg_epm;
4521 }
4522
4523 msleep(500);
4524
4525 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4526 if (!rc) {
4527 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4528 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4529 "Configure epm 3.3v\n");
4530 } else {
4531 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4532 "Error for gpio 3.3ven\n");
4533 goto exit_vreg_epm;
4534 }
4535 msleep(500);
4536
4537 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4538 "Trying to request EPM LVLSFT_EN\n");
4539 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4540 if (!rc) {
4541 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4542 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4543 "Configure the lvlsft\n");
4544 } else {
4545 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4546 "Error for epm lvlsft_en\n");
4547 goto exit_vreg_epm;
4548 }
4549
4550 msleep(500);
4551
4552 if (!epm_i2c_client)
4553 epm_i2c_client = epm_expander_i2c_register_board();
4554
4555 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4556 if (!rc)
4557 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4558 if (rc) {
4559 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4560 ": GPIO PWR MON Enable issue\n");
4561 goto exit_vreg_epm;
4562 }
4563
4564 msleep(1000);
4565
4566 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4567 if (!rc) {
4568 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4569 if (rc) {
4570 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4571 ": ADC1_PWDN error direction out\n");
4572 goto exit_vreg_epm;
4573 }
4574 }
4575
4576 msleep(100);
4577
4578 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4579 if (!rc) {
4580 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4581 if (rc) {
4582 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4583 ": ADC2_PWD error direction out\n");
4584 goto exit_vreg_epm;
4585 }
4586 }
4587
4588 msleep(1000);
4589
4590 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4591 if (!rc) {
4592 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4593 if (rc) {
4594 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4595 "Gpio request problem %d\n", rc);
4596 goto exit_vreg_epm;
4597 }
4598 }
4599
4600 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4601 if (!rc) {
4602 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4603 if (rc) {
4604 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4605 ": EPM_SPI_ADC1_CS_N error\n");
4606 goto exit_vreg_epm;
4607 }
4608 }
4609
4610 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4611 if (!rc) {
4612 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4613 if (rc) {
4614 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4615 ": EPM_SPI_ADC2_Cs_N error\n");
4616 goto exit_vreg_epm;
4617 }
4618 }
4619
4620 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4621 "the power monitor reset for epm\n");
4622
4623 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4624 if (!rc) {
4625 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4626 if (rc) {
4627 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4628 ": Error in the power mon reset\n");
4629 goto exit_vreg_epm;
4630 }
4631 }
4632
4633 msleep(1000);
4634
4635 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4636
4637 msleep(500);
4638
4639 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4640
4641 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4642
4643 return rc;
4644
4645exit_vreg_epm:
4646 regulator_disable(vreg_adc_epm1);
4647
4648 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4649 " rc = %d.\n", rc);
4650 return rc;
4651};
4652
4653static unsigned int msm_adc_gpio_configure_expander_disable(void)
4654{
4655 int rc = 0;
4656
4657 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4658 gpio_free(GPIO_PWR_MON_RESET_N);
4659
4660 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4661 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4662
4663 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4664 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4665
4666 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4667 gpio_free(GPIO_PWR_MON_START);
4668
4669 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4670 gpio_free(GPIO_ADC1_PWDN_N);
4671
4672 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4673 gpio_free(GPIO_ADC2_PWDN_N);
4674
4675 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4676 gpio_free(GPIO_PWR_MON_ENABLE);
4677
4678 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4679 gpio_free(GPIO_EPM_LVLSFT_EN);
4680
4681 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4682 gpio_free(GPIO_EPM_5V_BOOST_EN);
4683
4684 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4685 gpio_free(GPIO_EPM_3_3V_EN);
4686
4687 rc = regulator_disable(vreg_adc_epm1);
4688 if (rc)
4689 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4690 "Error while enabling regulator for epm s3 %d\n", rc);
4691 regulator_put(vreg_adc_epm1);
4692
4693 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4694 return rc;
4695};
4696
4697unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4698{
4699 int rc = 0;
4700
4701 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4702 cs_enable);
4703
4704 if (cs_enable < 16) {
4705 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4706 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4707 } else {
4708 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4709 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4710 }
4711 return rc;
4712};
4713
4714unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4715{
4716 int rc = 0;
4717
4718 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4719
4720 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4721
4722 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4723
4724 return rc;
4725};
4726#endif
4727
4728static struct msm_adc_channels msm_adc_channels_data[] = {
4729 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4730 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4731 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4732 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4733 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4734 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4735 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4736 CHAN_PATH_TYPE4,
4737 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4738 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4739 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4740 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4741 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4742 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4743 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4744 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4745 CHAN_PATH_TYPE12,
4746 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4747 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4748 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4749 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4750 CHAN_PATH_TYPE_NONE,
4751 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4752 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4753 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4754 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4755 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4756 scale_xtern_chgr_cur},
4757 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4758 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4759 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4760 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4761 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4762 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4763 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4764 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4765 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4766 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4767 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4768 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4769};
4770
4771static char *msm_adc_fluid_device_names[] = {
4772 "ADS_ADC1",
4773 "ADS_ADC2",
4774};
4775
4776static struct msm_adc_platform_data msm_adc_pdata = {
4777 .channel = msm_adc_channels_data,
4778 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4779#if defined(CONFIG_I2C) && \
4780 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4781 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4782 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4783 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4784 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4785#endif
4786};
4787
4788static struct platform_device msm_adc_device = {
4789 .name = "msm_adc",
4790 .id = -1,
4791 .dev = {
4792 .platform_data = &msm_adc_pdata,
4793 },
4794};
4795
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304796static struct msm_rtb_platform_data msm_rtb_pdata = {
4797 .size = SZ_1M,
4798};
4799
4800static int __init msm_rtb_set_buffer_size(char *p)
4801{
4802 int s;
4803
4804 s = memparse(p, NULL);
4805 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4806 return 0;
4807}
4808early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4809
4810
4811static struct platform_device msm_rtb_device = {
4812 .name = "msm_rtb",
4813 .id = -1,
4814 .dev = {
4815 .platform_data = &msm_rtb_pdata,
4816 },
4817};
4818
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004819static void pmic8058_xoadc_mpp_config(void)
4820{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304821 int rc, i;
4822 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304823 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304824 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304825 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304826 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304827 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304828 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304829 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304830 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304831 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304832 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304833 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4834 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304835 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004836
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304837 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4838 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4839 &xoadc_mpps[i].config);
4840 if (rc) {
4841 pr_err("%s: Config MPP %d of PM8058 failed\n",
4842 __func__, xoadc_mpps[i].mpp);
4843 }
4844 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004845}
4846
4847static struct regulator *vreg_ldo18_adc;
4848
4849static int pmic8058_xoadc_vreg_config(int on)
4850{
4851 int rc;
4852
4853 if (on) {
4854 rc = regulator_enable(vreg_ldo18_adc);
4855 if (rc)
4856 pr_err("%s: Enable of regulator ldo18_adc "
4857 "failed\n", __func__);
4858 } else {
4859 rc = regulator_disable(vreg_ldo18_adc);
4860 if (rc)
4861 pr_err("%s: Disable of regulator ldo18_adc "
4862 "failed\n", __func__);
4863 }
4864
4865 return rc;
4866}
4867
4868static int pmic8058_xoadc_vreg_setup(void)
4869{
4870 int rc;
4871
4872 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4873 if (IS_ERR(vreg_ldo18_adc)) {
4874 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4875 __func__, PTR_ERR(vreg_ldo18_adc));
4876 rc = PTR_ERR(vreg_ldo18_adc);
4877 goto fail;
4878 }
4879
4880 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4881 if (rc) {
4882 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4883 goto fail;
4884 }
4885
4886 return rc;
4887fail:
4888 regulator_put(vreg_ldo18_adc);
4889 return rc;
4890}
4891
4892static void pmic8058_xoadc_vreg_shutdown(void)
4893{
4894 regulator_put(vreg_ldo18_adc);
4895}
4896
4897/* usec. For this ADC,
4898 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4899 * Each channel has different configuration, thus at the time of starting
4900 * the conversion, xoadc will return actual conversion time
4901 * */
4902static struct adc_properties pm8058_xoadc_data = {
4903 .adc_reference = 2200, /* milli-voltage for this adc */
4904 .bitresolution = 15,
4905 .bipolar = 0,
4906 .conversiontime = 54,
4907};
4908
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304909static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004910 .xoadc_prop = &pm8058_xoadc_data,
4911 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4912 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4913 .xoadc_num = XOADC_PMIC_0,
4914 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4915 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4916};
4917#endif
4918
4919#ifdef CONFIG_MSM_SDIO_AL
4920
4921static unsigned mdm2ap_status = 140;
4922
4923static int configure_mdm2ap_status(int on)
4924{
4925 int ret = 0;
4926 if (on)
4927 ret = msm_gpiomux_get(mdm2ap_status);
4928 else
4929 ret = msm_gpiomux_put(mdm2ap_status);
4930
4931 if (ret)
4932 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4933 on);
4934
4935 return ret;
4936}
4937
4938
4939static int get_mdm2ap_status(void)
4940{
4941 return gpio_get_value(mdm2ap_status);
4942}
4943
4944static struct sdio_al_platform_data sdio_al_pdata = {
4945 .config_mdm2ap_status = configure_mdm2ap_status,
4946 .get_mdm2ap_status = get_mdm2ap_status,
4947 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004948 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004949 .peer_sdioc_version_major = 0x0004,
4950 .peer_sdioc_boot_version_minor = 0x0001,
4951 .peer_sdioc_boot_version_major = 0x0003
4952};
4953
4954struct platform_device msm_device_sdio_al = {
4955 .name = "msm_sdio_al",
4956 .id = -1,
4957 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004958 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004959 .platform_data = &sdio_al_pdata,
4960 },
4961};
4962
4963#endif /* CONFIG_MSM_SDIO_AL */
4964
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304965#define GPIO_VREG_ID_EXT_5V 0
4966
4967static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4968 REGULATOR_SUPPLY("ext_5v", NULL),
4969 REGULATOR_SUPPLY("8901_mpp0", NULL),
4970};
4971
4972#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4973 [GPIO_VREG_ID_##_id] = { \
4974 .init_data = { \
4975 .constraints = { \
4976 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
4977 }, \
4978 .num_consumer_supplies = \
4979 ARRAY_SIZE(vreg_consumers_##_id), \
4980 .consumer_supplies = vreg_consumers_##_id, \
4981 }, \
4982 .regulator_name = _reg_name, \
4983 .active_low = _active_low, \
4984 .gpio_label = _gpio_label, \
4985 .gpio = _gpio, \
4986 }
4987
4988/* GPIO regulator constraints */
4989static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
4990 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
4991 PM8901_MPP_PM_TO_SYS(0), 0),
4992};
4993
4994/* GPIO regulator */
4995static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
4996 .name = GPIO_REGULATOR_DEV_NAME,
4997 .id = PM8901_MPP_PM_TO_SYS(0),
4998 .dev = {
4999 .platform_data =
5000 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5001 },
5002};
5003
5004static void __init pm8901_vreg_mpp0_init(void)
5005{
5006 int rc;
5007
5008 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5009 .mpp = PM8901_MPP_PM_TO_SYS(0),
5010 .config = {
5011 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5012 .level = PM8901_MPP_DIG_LEVEL_VPH,
5013 },
5014 };
5015
5016 /*
5017 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5018 * implies that the regulator connected to MPP0 is enabled when
5019 * MPP0 is low.
5020 */
5021 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5022 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5023 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5024 } else {
5025 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5026 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5027 }
5028
5029 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5030 if (rc)
5031 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5032}
5033
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005034static struct platform_device *charm_devices[] __initdata = {
5035 &msm_charm_modem,
5036#ifdef CONFIG_MSM_SDIO_AL
5037 &msm_device_sdio_al,
5038#endif
5039};
5040
Lei Zhou338cab82011-08-19 13:38:17 -04005041#ifdef CONFIG_SND_SOC_MSM8660_APQ
5042static struct platform_device *dragon_alsa_devices[] __initdata = {
5043 &msm_pcm,
5044 &msm_pcm_routing,
5045 &msm_cpudai0,
5046 &msm_cpudai1,
5047 &msm_cpudai_hdmi_rx,
5048 &msm_cpudai_bt_rx,
5049 &msm_cpudai_bt_tx,
5050 &msm_cpudai_fm_rx,
5051 &msm_cpudai_fm_tx,
5052 &msm_cpu_fe,
5053 &msm_stub_codec,
5054 &msm_lpa_pcm,
5055};
5056#endif
5057
5058static struct platform_device *asoc_devices[] __initdata = {
5059 &asoc_msm_pcm,
5060 &asoc_msm_dai0,
5061 &asoc_msm_dai1,
5062};
5063
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305064/* qseecom bus scaling */
5065static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
5066 {
5067 .src = MSM_BUS_MASTER_SPS,
5068 .dst = MSM_BUS_SLAVE_EBI_CH0,
5069 .ib = 0,
5070 .ab = 0,
5071 },
5072 {
5073 .src = MSM_BUS_MASTER_SPDM,
5074 .dst = MSM_BUS_SLAVE_SPDM,
5075 .ib = 0,
5076 .ab = 0,
5077 },
5078};
5079
5080static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
5081 {
5082 .src = MSM_BUS_MASTER_SPS,
5083 .dst = MSM_BUS_SLAVE_EBI_CH0,
5084 .ib = (492 * 8) * 1000000UL,
5085 .ab = (492 * 8) * 100000UL,
5086 },
5087 {
5088 .src = MSM_BUS_MASTER_SPDM,
5089 .dst = MSM_BUS_SLAVE_SPDM,
5090 .ib = 0,
5091 .ab = 0,
5092 },
5093};
5094
5095static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
5096 {
5097 .src = MSM_BUS_MASTER_SPS,
5098 .dst = MSM_BUS_SLAVE_EBI_CH0,
5099 .ib = 0,
5100 .ab = 0,
5101 },
5102 {
5103 .src = MSM_BUS_MASTER_SPDM,
5104 .dst = MSM_BUS_SLAVE_SPDM,
5105 .ib = (64 * 8) * 1000000UL,
5106 .ab = (64 * 8) * 100000UL,
5107 },
5108};
5109
5110static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
5111 {
5112 ARRAY_SIZE(qseecom_clks_init_vectors),
5113 qseecom_clks_init_vectors,
5114 },
5115 {
5116 ARRAY_SIZE(qseecom_enable_dfab_vectors),
5117 qseecom_enable_sfpb_vectors,
5118 },
5119 {
5120 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
5121 qseecom_enable_sfpb_vectors,
5122 },
5123};
5124
5125static struct msm_bus_scale_pdata qseecom_bus_pdata = {
5126 .usecase = qseecom_hw_bus_scale_usecases,
5127 .num_usecases = ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
5128 .name = "qsee",
5129};
5130
5131static struct platform_device qseecom_device = {
5132 .name = "qseecom",
5133 .id = -1,
5134 .dev = {
5135 .platform_data = &qseecom_bus_pdata,
5136 },
5137};
5138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005139static struct platform_device *surf_devices[] __initdata = {
Matt Wagantallbf430eb2012-03-22 11:45:49 -07005140 &msm8x60_device_acpuclk,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005141 &msm_device_smd,
5142 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005143 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005144 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005145 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005146 &msm_pil_dsps,
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05305147 &msm_pil_vidc,
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305148 &qseecom_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005149#ifdef CONFIG_I2C_QUP
5150 &msm_gsbi3_qup_i2c_device,
5151 &msm_gsbi4_qup_i2c_device,
5152 &msm_gsbi7_qup_i2c_device,
5153 &msm_gsbi8_qup_i2c_device,
5154 &msm_gsbi9_qup_i2c_device,
5155 &msm_gsbi12_qup_i2c_device,
5156#endif
5157#ifdef CONFIG_SERIAL_MSM_HS
5158 &msm_device_uart_dm1,
5159#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305160#ifdef CONFIG_MSM_SSBI
5161 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305162 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305163#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005164#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005165 &msm_device_ssbi3,
5166#endif
5167#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5168 &isp1763_device,
5169#endif
5170
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005171#if defined (CONFIG_MSM_8x60_VOIP)
5172 &asoc_msm_mvs,
5173 &asoc_mvs_dai0,
5174 &asoc_mvs_dai1,
5175#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005176
Lena Salman57d167e2012-03-21 19:46:38 +02005177#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005178 &msm_device_otg,
5179#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005180#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005181 &msm_device_gadget_peripheral,
5182#endif
5183#ifdef CONFIG_USB_G_ANDROID
5184 &android_usb_device,
5185#endif
5186#ifdef CONFIG_BATTERY_MSM
5187 &msm_batt_device,
5188#endif
5189#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005190#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005191 &android_pmem_device,
5192 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005193 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005194 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305195#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5196#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005197#ifdef CONFIG_MSM_ROTATOR
5198 &msm_rotator_device,
5199#endif
5200 &msm_fb_device,
5201 &msm_kgsl_3d0,
5202 &msm_kgsl_2d0,
5203 &msm_kgsl_2d1,
5204 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005205#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5206 &lcdc_nt35582_panel_device,
5207#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005208#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5209 &lcdc_samsung_oled_panel_device,
5210#endif
5211#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5212 &lcdc_auo_wvga_panel_device,
5213#endif
5214#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5215 &hdmi_msm_device,
5216#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5217#ifdef CONFIG_FB_MSM_MIPI_DSI
5218 &mipi_dsi_toshiba_panel_device,
5219 &mipi_dsi_novatek_panel_device,
5220#endif
5221#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005222#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005223#ifdef CONFIG_MT9E013
5224 &msm_camera_sensor_mt9e013,
5225#endif
5226#ifdef CONFIG_IMX074
5227 &msm_camera_sensor_imx074,
5228#endif
5229#ifdef CONFIG_WEBCAM_OV7692
5230 &msm_camera_sensor_webcam_ov7692,
5231#endif
5232#ifdef CONFIG_WEBCAM_OV9726
5233 &msm_camera_sensor_webcam_ov9726,
5234#endif
5235#ifdef CONFIG_QS_S5K4E1
5236 &msm_camera_sensor_qs_s5k4e1,
5237#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005238#ifdef CONFIG_VX6953
5239 &msm_camera_sensor_vx6953,
5240#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005241#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005242#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005243#ifdef CONFIG_MSM_GEMINI
5244 &msm_gemini_device,
5245#endif
5246#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005247#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005248 &msm_vpe_device,
5249#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005250#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005251
5252#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005253 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005254#endif
5255#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005256 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005257#endif
5258 &msm_device_vidc,
5259#if (defined(CONFIG_MARIMBA_CORE)) && \
5260 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5261 &msm_bt_power_device,
5262#endif
5263#ifdef CONFIG_SENSORS_MSM_ADC
5264 &msm_adc_device,
5265#endif
David Collins6f032ba2011-08-31 14:08:15 -07005266 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005267
5268#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5269 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5270 &qcrypto_device,
5271#endif
5272
5273#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5274 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5275 &qcedev_device,
5276#endif
5277
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005278
5279#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5280#ifdef CONFIG_MSM_USE_TSIF1
5281 &msm_device_tsif[1],
5282#else
5283 &msm_device_tsif[0],
5284#endif /* CONFIG_MSM_USE_TSIF1 */
5285#endif /* CONFIG_TSIF */
5286
5287#ifdef CONFIG_HW_RANDOM_MSM
5288 &msm_device_rng,
5289#endif
5290
5291 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005292 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005293#ifdef CONFIG_ION_MSM
5294 &ion_dev,
5295#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005296 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005297 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305298 &msm_rtb_device,
Laura Abbottd92be422012-06-04 15:11:09 -07005299 &msm8660_iommu_domain_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005300};
5301
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005302#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005303#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5304static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5305 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005306 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005307 .request_region = request_smi_region,
5308 .release_region = release_smi_region,
5309 .setup_region = setup_smi_region,
Chintan Pandya490c9712012-08-07 17:19:59 +05305310 .secure_base = SECURE_BASE,
5311 .secure_size = SECURE_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005312 .iommu_map_all = 1,
5313 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005314};
5315
5316static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5317 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005318 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005319 .request_region = request_smi_region,
5320 .release_region = release_smi_region,
5321 .setup_region = setup_smi_region,
5322};
5323
5324static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5325 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005326 .align = PAGE_SIZE,
5327};
5328
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305329static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005330 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005331};
5332
5333static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005334 .adjacent_mem_id = INVALID_HEAP_ID,
5335 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005336};
5337#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005338
5339/**
5340 * These heaps are listed in the order they will be allocated. Due to
5341 * video hardware restrictions and content protection the FW heap has to
5342 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5343 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5344 * away from the base address of the FW heap.
5345 * However, the order of FW heap and MM heap doesn't matter since these
5346 * two heaps are taken care of by separate code to ensure they are adjacent
5347 * to each other.
5348 * Don't swap the order unless you know what you are doing!
5349 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005350static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005351 .nr = MSM_ION_HEAP_NUM,
5352 .heaps = {
5353 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005354 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005355 .type = ION_HEAP_TYPE_SYSTEM,
5356 .name = ION_VMALLOC_HEAP_NAME,
5357 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005358#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5359 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005360 .id = ION_CP_MM_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_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305363 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005364 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005365 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005366 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005367 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005368 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005369 .id = ION_MM_FIRMWARE_HEAP_ID,
5370 .type = ION_HEAP_TYPE_CARVEOUT,
5371 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305372 .base = MSM_MM_FW_BASE,
5373 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005374 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305375 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005376 },
5377 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005378 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005379 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005380 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305381 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005382 .size = MSM_ION_MFC_SIZE,
5383 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005384 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005385 },
5386 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005387 .id = ION_SF_HEAP_ID,
5388 .type = ION_HEAP_TYPE_CARVEOUT,
5389 .name = ION_SF_HEAP_NAME,
5390 .size = MSM_ION_SF_SIZE,
5391 .memory_type = ION_EBI_TYPE,
5392 .extra_data = (void *)&co_ion_pdata,
5393 },
5394 {
5395 .id = ION_CAMERA_HEAP_ID,
5396 .type = ION_HEAP_TYPE_CARVEOUT,
5397 .name = ION_CAMERA_HEAP_NAME,
5398 .size = MSM_ION_CAMERA_SIZE,
5399 .memory_type = ION_EBI_TYPE,
5400 .extra_data = &co_ion_pdata,
5401 },
5402 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005403 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005404 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005405 .name = ION_WB_HEAP_NAME,
5406 .size = MSM_ION_WB_SIZE,
5407 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005408 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005409 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005410 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005411 .id = ION_QSECOM_HEAP_ID,
5412 .type = ION_HEAP_TYPE_CARVEOUT,
5413 .name = ION_QSECOM_HEAP_NAME,
5414 .size = MSM_ION_QSECOM_SIZE,
5415 .memory_type = ION_EBI_TYPE,
5416 .extra_data = (void *) &co_ion_pdata,
5417 },
5418 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005419 .id = ION_AUDIO_HEAP_ID,
5420 .type = ION_HEAP_TYPE_CARVEOUT,
5421 .name = ION_AUDIO_HEAP_NAME,
5422 .size = MSM_ION_AUDIO_SIZE,
5423 .memory_type = ION_EBI_TYPE,
5424 .extra_data = (void *)&co_ion_pdata,
5425 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005426#endif
5427 }
5428};
5429
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005430static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005431 .name = "ion-msm",
5432 .id = 1,
5433 .dev = { .platform_data = &ion_pdata },
5434};
5435#endif
5436
5437
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005438static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5439 /* Kernel SMI memory pool for video core, used for firmware */
5440 /* and encoder, decoder scratch buffers */
5441 /* Kernel SMI memory pool should always precede the user space */
5442 /* SMI memory pool, as the video core will use offset address */
5443 /* from the Firmware base */
5444 [MEMTYPE_SMI_KERNEL] = {
5445 .start = KERNEL_SMI_BASE,
5446 .limit = KERNEL_SMI_SIZE,
5447 .size = KERNEL_SMI_SIZE,
5448 .flags = MEMTYPE_FLAGS_FIXED,
5449 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005450 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005451 },
5452 [MEMTYPE_EBI0] = {
5453 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5454 },
5455 [MEMTYPE_EBI1] = {
5456 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5457 },
5458};
5459
Stephen Boyd668d7652012-04-25 11:31:01 -07005460static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005461{
5462#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005463 unsigned int i;
5464
5465 if (hdmi_is_primary) {
5466 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5467 for (i = 0; i < ion_pdata.nr; i++) {
5468 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5469 ion_pdata.heaps[i].size = msm_ion_sf_size;
5470 pr_debug("msm_ion_sf_size 0x%x\n",
5471 msm_ion_sf_size);
5472 break;
5473 }
5474 }
5475 }
5476
Olav Haugan8726caf2012-05-10 15:11:35 -07005477 /* Verify size of heap is a multiple of 64K */
5478 for (i = 0; i < ion_pdata.nr; i++) {
5479 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5480
5481 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5482 int map_all = ((struct ion_cp_heap_pdata *)
5483 heap->extra_data)->iommu_map_all;
5484
5485 if (map_all && (heap->size & (SZ_64K-1))) {
5486 heap->size = ALIGN(heap->size, SZ_64K);
5487 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5488 heap->name, heap->size);
5489
5490 }
5491 }
5492 }
5493
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005494 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005495 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5496 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005497 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005498 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005499#endif
5500}
5501
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005502static void __init size_pmem_devices(void)
5503{
5504#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005505#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005506 android_pmem_adsp_pdata.size = pmem_adsp_size;
5507 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005508
5509 if (hdmi_is_primary)
5510 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005511 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005512 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305513#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5514#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005515}
5516
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305517#ifdef CONFIG_ANDROID_PMEM
5518#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005519static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5520{
5521 msm8x60_reserve_table[p->memory_type].size += p->size;
5522}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305523#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5524#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005525
5526static void __init reserve_pmem_memory(void)
5527{
5528#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005529#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005530 reserve_memory_for(&android_pmem_adsp_pdata);
5531 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005533 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305534#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005535 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305536#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005537}
5538
Huaibin Yanga5419422011-12-08 23:52:10 -08005539static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005540
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305541static void __init reserve_rtb_memory(void)
5542{
5543#if defined(CONFIG_MSM_RTB)
5544 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5545#endif
5546}
5547
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005548static void __init msm8x60_calculate_reserve_sizes(void)
5549{
5550 size_pmem_devices();
5551 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005552 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005553 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305554 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005555}
5556
5557static int msm8x60_paddr_to_memtype(unsigned int paddr)
5558{
5559 if (paddr >= 0x40000000 && paddr < 0x60000000)
5560 return MEMTYPE_EBI1;
5561 if (paddr >= 0x38000000 && paddr < 0x40000000)
5562 return MEMTYPE_SMI;
5563 return MEMTYPE_NONE;
5564}
5565
5566static struct reserve_info msm8x60_reserve_info __initdata = {
5567 .memtype_reserve_table = msm8x60_reserve_table,
5568 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5569 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5570};
5571
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005572static char prim_panel_name[PANEL_NAME_MAX_LEN];
5573static char ext_panel_name[PANEL_NAME_MAX_LEN];
5574static int __init prim_display_setup(char *param)
5575{
5576 if (strnlen(param, PANEL_NAME_MAX_LEN))
5577 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5578 return 0;
5579}
5580early_param("prim_display", prim_display_setup);
5581
5582static int __init ext_display_setup(char *param)
5583{
5584 if (strnlen(param, PANEL_NAME_MAX_LEN))
5585 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5586 return 0;
5587}
5588early_param("ext_display", ext_display_setup);
5589
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005590static void __init msm8x60_reserve(void)
5591{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005592 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593 reserve_info = &msm8x60_reserve_info;
5594 msm_reserve();
5595}
5596
5597#define EXT_CHG_VALID_MPP 10
5598#define EXT_CHG_VALID_MPP_2 11
5599
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305600static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305601 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305602 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305603 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305604 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5605};
5606
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607#ifdef CONFIG_ISL9519_CHARGER
5608static int isl_detection_setup(void)
5609{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305610 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005611
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305612 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5613 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5614 &isl_mpp[i].config);
5615 if (ret) {
5616 pr_err("%s: Config MPP %d of PM8058 failed\n",
5617 __func__, isl_mpp[i].mpp);
5618 return ret;
5619 }
5620 }
5621
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005622 return ret;
5623}
5624
5625static struct isl_platform_data isl_data __initdata = {
5626 .chgcurrent = 700,
5627 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5628 .chg_detection_config = isl_detection_setup,
5629 .max_system_voltage = 4200,
5630 .min_system_voltage = 3200,
5631 .term_current = 120,
5632 .input_current = 2048,
5633};
5634
5635static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5636 {
5637 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305638 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005639 .platform_data = &isl_data,
5640 },
5641};
5642#endif
5643
5644#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5645static int smb137b_detection_setup(void)
5646{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305647 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005648
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305649 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5650 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5651 &isl_mpp[i].config);
5652 if (ret) {
5653 pr_err("%s: Config MPP %d of PM8058 failed\n",
5654 __func__, isl_mpp[i].mpp);
5655 return ret;
5656 }
5657 }
5658
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005659 return ret;
5660}
5661
5662static struct smb137b_platform_data smb137b_data __initdata = {
5663 .chg_detection_config = smb137b_detection_setup,
5664 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5665 .batt_mah_rating = 950,
5666};
5667
5668static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5669 {
5670 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305671 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005672 .platform_data = &smb137b_data,
5673 },
5674};
5675#endif
5676
5677#ifdef CONFIG_PMIC8058
5678#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305679#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005680
5681static int pm8058_gpios_init(void)
5682{
5683 int i;
5684 int rc;
5685 struct pm8058_gpio_cfg {
5686 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305687 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005688 };
5689
5690 struct pm8058_gpio_cfg gpio_cfgs[] = {
5691 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305692 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005693 {
5694 .direction = PM_GPIO_DIR_IN,
5695 .pull = PM_GPIO_PULL_DN,
5696 .vin_sel = 2,
5697 .function = PM_GPIO_FUNC_NORMAL,
5698 .inv_int_pol = 0,
5699 },
5700 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005701 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305702 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005703 {
5704 .direction = PM_GPIO_DIR_IN,
5705 .pull = PM_GPIO_PULL_UP_30,
5706 .vin_sel = 2,
5707 .function = PM_GPIO_FUNC_NORMAL,
5708 .inv_int_pol = 0,
5709 },
5710 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005711 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305712 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005713 {
5714 .direction = PM_GPIO_DIR_IN,
5715 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305716 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005717 .function = PM_GPIO_FUNC_NORMAL,
5718 .inv_int_pol = 0,
5719 },
5720 },
5721 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305722 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005723 {
5724 .direction = PM_GPIO_DIR_IN,
5725 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305726 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005727 .function = PM_GPIO_FUNC_NORMAL,
5728 .inv_int_pol = 0,
5729 },
5730 },
5731 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305732 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005733 {
5734 .direction = PM_GPIO_DIR_IN,
5735 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305736 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005737 .function = PM_GPIO_FUNC_NORMAL,
5738 .inv_int_pol = 0,
5739 },
5740 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005741 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305742 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005743 {
5744 .direction = PM_GPIO_DIR_OUT,
5745 .output_value = 1,
5746 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5747 .pull = PM_GPIO_PULL_DN,
5748 .out_strength = PM_GPIO_STRENGTH_HIGH,
5749 .function = PM_GPIO_FUNC_NORMAL,
5750 .vin_sel = 2,
5751 .inv_int_pol = 0,
5752 }
5753 },
5754 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305755 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005756 {
5757 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305758 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005759 .function = PM_GPIO_FUNC_NORMAL,
5760 .vin_sel = 2,
5761 .inv_int_pol = 0,
5762 }
5763 },
5764 };
5765
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305766#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5767 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305768 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305769 .direction = PM_GPIO_DIR_IN,
5770 .pull = PM_GPIO_PULL_UP_1P5,
5771 .vin_sel = 2,
5772 .function = PM_GPIO_FUNC_NORMAL,
5773 };
5774#endif
5775
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005776#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305777 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305778 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305779 .direction = PM_GPIO_DIR_OUT,
5780 .pull = PM_GPIO_PULL_NO,
5781 .out_strength = PM_GPIO_STRENGTH_HIGH,
5782 .function = PM_GPIO_FUNC_NORMAL,
5783 .inv_int_pol = 0,
5784 .vin_sel = 2,
5785 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5786 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005787 };
5788#endif
5789
5790#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5791 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305792 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005793 {
5794 .direction = PM_GPIO_DIR_IN,
5795 .pull = PM_GPIO_PULL_UP_1P5,
5796 .vin_sel = 2,
5797 .function = PM_GPIO_FUNC_NORMAL,
5798 .inv_int_pol = 0,
5799 }
5800 };
5801#endif
5802
5803#if defined(CONFIG_QS_S5K4E1)
5804 {
5805 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305806 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005807 {
5808 .direction = PM_GPIO_DIR_OUT,
5809 .output_value = 0,
5810 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5811 .pull = PM_GPIO_PULL_DN,
5812 .out_strength = PM_GPIO_STRENGTH_HIGH,
5813 .function = PM_GPIO_FUNC_NORMAL,
5814 .vin_sel = 2,
5815 .inv_int_pol = 0,
5816 }
5817 };
5818#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005819#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5820 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305821 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005822 {
5823 .direction = PM_GPIO_DIR_OUT,
5824 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5825 .output_value = 1,
5826 .pull = PM_GPIO_PULL_UP_30,
5827 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305828 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005829 .out_strength = PM_GPIO_STRENGTH_HIGH,
5830 .function = PM_GPIO_FUNC_NORMAL,
5831 .inv_int_pol = 0,
5832 }
5833 };
5834#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005835#if defined(CONFIG_HAPTIC_ISA1200) || \
5836 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5837 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305838 rc = pm8xxx_gpio_config(
5839 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5840 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005841 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305842 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005843 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305844 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305845 rc = pm8xxx_gpio_config(
5846 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5847 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305848 if (rc < 0) {
5849 pr_err("%s: pmic haptics ldo gpio config failed\n",
5850 __func__);
5851 }
5852
5853 }
5854#endif
5855
5856#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5857 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5858 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5859 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305860 rc = pm8xxx_gpio_config(
5861 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5862 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305863 if (rc < 0) {
5864 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5865 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005866 }
5867 }
5868#endif
5869
5870#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5871 /* Line_in only for 8660 ffa & surf */
5872 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005873 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005874 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305875 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005876 &line_in_gpio_cfg.cfg);
5877 if (rc < 0) {
5878 pr_err("%s pmic line_in gpio config failed\n",
5879 __func__);
5880 return rc;
5881 }
5882 }
5883#endif
5884
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005885#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5886 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305887 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005888 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5889 if (rc < 0) {
5890 pr_err("%s pmic gpio config failed\n", __func__);
5891 return rc;
5892 }
5893 }
5894#endif
5895
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005896#if defined(CONFIG_QS_S5K4E1)
5897 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5898 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305899 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005900 &qs_hc37_cam_pd_gpio_cfg.cfg);
5901 if (rc < 0) {
5902 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5903 __func__);
5904 return rc;
5905 }
5906 }
5907 }
5908#endif
5909
5910 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305911 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005912 &gpio_cfgs[i].cfg);
5913 if (rc < 0) {
5914 pr_err("%s pmic gpio config failed\n",
5915 __func__);
5916 return rc;
5917 }
5918 }
5919
5920 return 0;
5921}
5922
5923static const unsigned int ffa_keymap[] = {
5924 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5925 KEY(0, 1, KEY_UP), /* NAV - UP */
5926 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5927 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5928
5929 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5930 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5931 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5932 KEY(1, 3, KEY_VOLUMEDOWN),
5933
5934 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5935
5936 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5937 KEY(4, 1, KEY_UP), /* USER_UP */
5938 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5939 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5940 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5941
5942 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5943 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5944 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5945 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5946 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5947};
5948
Zhang Chang Ken683be172011-08-10 17:45:34 -04005949static const unsigned int dragon_keymap[] = {
5950 KEY(0, 0, KEY_MENU),
5951 KEY(0, 2, KEY_1),
5952 KEY(0, 3, KEY_4),
5953 KEY(0, 4, KEY_7),
5954
5955 KEY(1, 0, KEY_UP),
5956 KEY(1, 1, KEY_LEFT),
5957 KEY(1, 2, KEY_DOWN),
5958 KEY(1, 3, KEY_5),
5959 KEY(1, 4, KEY_8),
5960
5961 KEY(2, 0, KEY_HOME),
5962 KEY(2, 1, KEY_REPLY),
5963 KEY(2, 2, KEY_2),
5964 KEY(2, 3, KEY_6),
5965 KEY(2, 4, KEY_0),
5966
5967 KEY(3, 0, KEY_VOLUMEUP),
5968 KEY(3, 1, KEY_RIGHT),
5969 KEY(3, 2, KEY_3),
5970 KEY(3, 3, KEY_9),
5971 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5972
5973 KEY(4, 0, KEY_VOLUMEDOWN),
5974 KEY(4, 1, KEY_BACK),
5975 KEY(4, 2, KEY_CAMERA),
5976 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5977};
5978
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005979static struct matrix_keymap_data ffa_keymap_data = {
5980 .keymap_size = ARRAY_SIZE(ffa_keymap),
5981 .keymap = ffa_keymap,
5982};
5983
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305984static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005985 .input_name = "ffa-keypad",
5986 .input_phys_device = "ffa-keypad/input0",
5987 .num_rows = 6,
5988 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305989 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5990 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5991 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005992 .scan_delay_ms = 32,
5993 .row_hold_ns = 91500,
5994 .wakeup = 1,
5995 .keymap_data = &ffa_keymap_data,
5996};
5997
Zhang Chang Ken683be172011-08-10 17:45:34 -04005998static struct matrix_keymap_data dragon_keymap_data = {
5999 .keymap_size = ARRAY_SIZE(dragon_keymap),
6000 .keymap = dragon_keymap,
6001};
6002
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306003static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006004 .input_name = "dragon-keypad",
6005 .input_phys_device = "dragon-keypad/input0",
6006 .num_rows = 6,
6007 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306008 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6009 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6010 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006011 .scan_delay_ms = 32,
6012 .row_hold_ns = 91500,
6013 .wakeup = 1,
6014 .keymap_data = &dragon_keymap_data,
6015};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306016
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006017static const unsigned int fluid_keymap[] = {
6018 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6019 KEY(0, 1, KEY_UP), /* NAV - UP */
6020 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6021 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6022
6023 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6024 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6025 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6026 KEY(1, 3, KEY_VOLUMEUP),
6027
6028 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6029
6030 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6031 KEY(4, 1, KEY_UP), /* USER_UP */
6032 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6033 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6034 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6035
Jilai Wang9a895102011-07-12 14:00:35 -04006036 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006037 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6038 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6039 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6040 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6041};
6042
6043static struct matrix_keymap_data fluid_keymap_data = {
6044 .keymap_size = ARRAY_SIZE(fluid_keymap),
6045 .keymap = fluid_keymap,
6046};
6047
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306048static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006049 .input_name = "fluid-keypad",
6050 .input_phys_device = "fluid-keypad/input0",
6051 .num_rows = 6,
6052 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306053 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6054 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6055 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006056 .scan_delay_ms = 32,
6057 .row_hold_ns = 91500,
6058 .wakeup = 1,
6059 .keymap_data = &fluid_keymap_data,
6060};
6061
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306062static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006063 .initial_vibrate_ms = 500,
6064 .level_mV = 3000,
6065 .max_timeout_ms = 15000,
6066};
6067
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306068static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6069 .rtc_write_enable = false,
6070 .rtc_alarm_powerup = false,
6071};
6072
6073static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6074 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006075 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306076 .wakeup = 1,
6077};
6078
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006079#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6080
6081static struct othc_accessory_info othc_accessories[] = {
6082 {
6083 .accessory = OTHC_SVIDEO_OUT,
6084 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6085 | OTHC_ADC_DETECT,
6086 .key_code = SW_VIDEOOUT_INSERT,
6087 .enabled = false,
6088 .adc_thres = {
6089 .min_threshold = 20,
6090 .max_threshold = 40,
6091 },
6092 },
6093 {
6094 .accessory = OTHC_ANC_HEADPHONE,
6095 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6096 OTHC_SWITCH_DETECT,
6097 .gpio = PM8058_LINE_IN_DET_GPIO,
6098 .active_low = 1,
6099 .key_code = SW_HEADPHONE_INSERT,
6100 .enabled = true,
6101 },
6102 {
6103 .accessory = OTHC_ANC_HEADSET,
6104 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6105 .gpio = PM8058_LINE_IN_DET_GPIO,
6106 .active_low = 1,
6107 .key_code = SW_HEADPHONE_INSERT,
6108 .enabled = true,
6109 },
6110 {
6111 .accessory = OTHC_HEADPHONE,
6112 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6113 .key_code = SW_HEADPHONE_INSERT,
6114 .enabled = true,
6115 },
6116 {
6117 .accessory = OTHC_MICROPHONE,
6118 .detect_flags = OTHC_GPIO_DETECT,
6119 .gpio = PM8058_LINE_IN_DET_GPIO,
6120 .active_low = 1,
6121 .key_code = SW_MICROPHONE_INSERT,
6122 .enabled = true,
6123 },
6124 {
6125 .accessory = OTHC_HEADSET,
6126 .detect_flags = OTHC_MICBIAS_DETECT,
6127 .key_code = SW_HEADPHONE_INSERT,
6128 .enabled = true,
6129 },
6130};
6131
6132static struct othc_switch_info switch_info[] = {
6133 {
6134 .min_adc_threshold = 0,
6135 .max_adc_threshold = 100,
6136 .key_code = KEY_PLAYPAUSE,
6137 },
6138 {
6139 .min_adc_threshold = 100,
6140 .max_adc_threshold = 200,
6141 .key_code = KEY_REWIND,
6142 },
6143 {
6144 .min_adc_threshold = 200,
6145 .max_adc_threshold = 500,
6146 .key_code = KEY_FASTFORWARD,
6147 },
6148};
6149
6150static struct othc_n_switch_config switch_config = {
6151 .voltage_settling_time_ms = 0,
6152 .num_adc_samples = 3,
6153 .adc_channel = CHANNEL_ADC_HDSET,
6154 .switch_info = switch_info,
6155 .num_keys = ARRAY_SIZE(switch_info),
6156 .default_sw_en = true,
6157 .default_sw_idx = 0,
6158};
6159
6160static struct hsed_bias_config hsed_bias_config = {
6161 /* HSED mic bias config info */
6162 .othc_headset = OTHC_HEADSET_NO,
6163 .othc_lowcurr_thresh_uA = 100,
6164 .othc_highcurr_thresh_uA = 600,
6165 .othc_hyst_prediv_us = 7800,
6166 .othc_period_clkdiv_us = 62500,
6167 .othc_hyst_clk_us = 121000,
6168 .othc_period_clk_us = 312500,
6169 .othc_wakeup = 1,
6170};
6171
6172static struct othc_hsed_config hsed_config_1 = {
6173 .hsed_bias_config = &hsed_bias_config,
6174 /*
6175 * The detection delay and switch reporting delay are
6176 * required to encounter a hardware bug (spurious switch
6177 * interrupts on slow insertion/removal of the headset).
6178 * This will introduce a delay in reporting the accessory
6179 * insertion and removal to the userspace.
6180 */
6181 .detection_delay_ms = 1500,
6182 /* Switch info */
6183 .switch_debounce_ms = 1500,
6184 .othc_support_n_switch = false,
6185 .switch_config = &switch_config,
6186 .ir_gpio = -1,
6187 /* Accessory info */
6188 .accessories_support = true,
6189 .accessories = othc_accessories,
6190 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6191};
6192
6193static struct othc_regulator_config othc_reg = {
6194 .regulator = "8058_l5",
6195 .max_uV = 2850000,
6196 .min_uV = 2850000,
6197};
6198
6199/* MIC_BIAS0 is configured as normal MIC BIAS */
6200static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6201 .micbias_select = OTHC_MICBIAS_0,
6202 .micbias_capability = OTHC_MICBIAS,
6203 .micbias_enable = OTHC_SIGNAL_OFF,
6204 .micbias_regulator = &othc_reg,
6205};
6206
6207/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6208static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6209 .micbias_select = OTHC_MICBIAS_1,
6210 .micbias_capability = OTHC_MICBIAS_HSED,
6211 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6212 .micbias_regulator = &othc_reg,
6213 .hsed_config = &hsed_config_1,
6214 .hsed_name = "8660_handset",
6215};
6216
6217/* MIC_BIAS2 is configured as normal MIC BIAS */
6218static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6219 .micbias_select = OTHC_MICBIAS_2,
6220 .micbias_capability = OTHC_MICBIAS,
6221 .micbias_enable = OTHC_SIGNAL_OFF,
6222 .micbias_regulator = &othc_reg,
6223};
6224
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006225
6226static void __init msm8x60_init_pm8058_othc(void)
6227{
6228 int i;
6229
6230 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6231 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6232 machine_is_msm8x60_fusn_ffa()) {
6233 /* 3-switch headset supported only by V2 FFA and FLUID */
6234 hsed_config_1.accessories_adc_support = true,
6235 /* ADC based accessory detection works only on V2 and FLUID */
6236 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6237 hsed_config_1.othc_support_n_switch = true;
6238 }
6239
6240 /* IR GPIO is absent on FLUID */
6241 if (machine_is_msm8x60_fluid())
6242 hsed_config_1.ir_gpio = -1;
6243
6244 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6245 if (machine_is_msm8x60_fluid()) {
6246 switch (othc_accessories[i].accessory) {
6247 case OTHC_ANC_HEADPHONE:
6248 case OTHC_ANC_HEADSET:
6249 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6250 break;
6251 case OTHC_MICROPHONE:
6252 othc_accessories[i].enabled = false;
6253 break;
6254 case OTHC_SVIDEO_OUT:
6255 othc_accessories[i].enabled = true;
6256 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6257 break;
6258 }
6259 }
6260 }
6261}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006262
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006263
6264static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6265{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306266 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006267 .direction = PM_GPIO_DIR_OUT,
6268 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6269 .output_value = 0,
6270 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306271 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006272 .out_strength = PM_GPIO_STRENGTH_HIGH,
6273 .function = PM_GPIO_FUNC_2,
6274 };
6275
6276 int rc = -EINVAL;
6277 int id, mode, max_mA;
6278
6279 id = mode = max_mA = 0;
6280 switch (ch) {
6281 case 0:
6282 case 1:
6283 case 2:
6284 if (on) {
6285 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306286 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6287 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006288 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306289 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006290 __func__, id, rc);
6291 }
6292 break;
6293
6294 case 6:
6295 id = PM_PWM_LED_FLASH;
6296 mode = PM_PWM_CONF_PWM1;
6297 max_mA = 300;
6298 break;
6299
6300 case 7:
6301 id = PM_PWM_LED_FLASH1;
6302 mode = PM_PWM_CONF_PWM1;
6303 max_mA = 300;
6304 break;
6305
6306 default:
6307 break;
6308 }
6309
6310 if (ch >= 6 && ch <= 7) {
6311 if (!on) {
6312 mode = PM_PWM_CONF_NONE;
6313 max_mA = 0;
6314 }
6315 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6316 if (rc)
6317 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6318 __func__, ch, rc);
6319 }
6320 return rc;
6321
6322}
6323
6324static struct pm8058_pwm_pdata pm8058_pwm_data = {
6325 .config = pm8058_pwm_config,
6326};
6327
6328#define PM8058_GPIO_INT 88
6329
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006330static struct pmic8058_led pmic8058_flash_leds[] = {
6331 [0] = {
6332 .name = "camera:flash0",
6333 .max_brightness = 15,
6334 .id = PMIC8058_ID_FLASH_LED_0,
6335 },
6336 [1] = {
6337 .name = "camera:flash1",
6338 .max_brightness = 15,
6339 .id = PMIC8058_ID_FLASH_LED_1,
6340 },
6341};
6342
6343static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6344 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6345 .leds = pmic8058_flash_leds,
6346};
6347
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006348static struct pmic8058_led pmic8058_dragon_leds[] = {
6349 [0] = {
6350 /* RED */
6351 .name = "led_drv0",
6352 .max_brightness = 15,
6353 .id = PMIC8058_ID_LED_0,
6354 },/* 300 mA flash led0 drv sink */
6355 [1] = {
6356 /* Yellow */
6357 .name = "led_drv1",
6358 .max_brightness = 15,
6359 .id = PMIC8058_ID_LED_1,
6360 },/* 300 mA flash led0 drv sink */
6361 [2] = {
6362 /* Green */
6363 .name = "led_drv2",
6364 .max_brightness = 15,
6365 .id = PMIC8058_ID_LED_2,
6366 },/* 300 mA flash led0 drv sink */
6367 [3] = {
6368 .name = "led_psensor",
6369 .max_brightness = 15,
6370 .id = PMIC8058_ID_LED_KB_LIGHT,
6371 },/* 300 mA flash led0 drv sink */
6372};
6373
6374static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6375 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6376 .leds = pmic8058_dragon_leds,
6377};
6378
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006379static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6380 [0] = {
6381 .name = "led:drv0",
6382 .max_brightness = 15,
6383 .id = PMIC8058_ID_FLASH_LED_0,
6384 },/* 300 mA flash led0 drv sink */
6385 [1] = {
6386 .name = "led:drv1",
6387 .max_brightness = 15,
6388 .id = PMIC8058_ID_FLASH_LED_1,
6389 },/* 300 mA flash led1 sink */
6390 [2] = {
6391 .name = "led:drv2",
6392 .max_brightness = 20,
6393 .id = PMIC8058_ID_LED_0,
6394 },/* 40 mA led0 sink */
6395 [3] = {
6396 .name = "keypad:drv",
6397 .max_brightness = 15,
6398 .id = PMIC8058_ID_LED_KB_LIGHT,
6399 },/* 300 mA keypad drv sink */
6400};
6401
6402static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6403 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6404 .leds = pmic8058_fluid_flash_leds,
6405};
6406
Terence Hampson90508a92011-08-09 10:40:08 -04006407static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306408 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006409 .max_source_current = 1800,
6410 .charger_type = CHG_TYPE_AC,
6411};
6412
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306413static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6414 .charger_data_valid = false,
6415};
6416
6417static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6418 .priority = 0,
6419};
6420
6421static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6422 .irq_base = PM8058_IRQ_BASE,
6423 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6424 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6425};
6426
6427static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6428 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6429};
6430
6431static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6432 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006433};
6434
6435static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306436 .irq_pdata = &pm8058_irq_pdata,
6437 .gpio_pdata = &pm8058_gpio_pdata,
6438 .mpp_pdata = &pm8058_mpp_pdata,
6439 .rtc_pdata = &pm8058_rtc_pdata,
6440 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6441 .othc0_pdata = &othc_config_pdata_0,
6442 .othc1_pdata = &othc_config_pdata_1,
6443 .othc2_pdata = &othc_config_pdata_2,
6444 .pwm_pdata = &pm8058_pwm_data,
6445 .misc_pdata = &pm8058_misc_pdata,
6446#ifdef CONFIG_SENSORS_MSM_ADC
6447 .xoadc_pdata = &pm8058_xoadc_pdata,
6448#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006449};
6450
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306451#ifdef CONFIG_MSM_SSBI
6452static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6453 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6454 .slave = {
6455 .name = "pm8058-core",
6456 .platform_data = &pm8058_platform_data,
6457 },
6458};
6459#endif
6460#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006461
6462#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6463 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6464#define TDISC_I2C_SLAVE_ADDR 0x67
6465#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6466#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6467
6468static const char *vregs_tdisc_name[] = {
6469 "8058_l5",
6470 "8058_s3",
6471};
6472
6473static const int vregs_tdisc_val[] = {
6474 2850000,/* uV */
6475 1800000,
6476};
6477static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6478
6479static int tdisc_shinetsu_setup(void)
6480{
6481 int rc, i;
6482
6483 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6484 if (rc) {
6485 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6486 __func__);
6487 return rc;
6488 }
6489
6490 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6491 if (rc) {
6492 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6493 __func__);
6494 goto fail_gpio_oe;
6495 }
6496
6497 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6498 if (rc) {
6499 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6500 __func__);
6501 gpio_free(GPIO_JOYSTICK_EN);
6502 goto fail_gpio_oe;
6503 }
6504
6505 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6506 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6507 if (IS_ERR(vregs_tdisc[i])) {
6508 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6509 __func__, vregs_tdisc_name[i],
6510 PTR_ERR(vregs_tdisc[i]));
6511 rc = PTR_ERR(vregs_tdisc[i]);
6512 goto vreg_get_fail;
6513 }
6514
6515 rc = regulator_set_voltage(vregs_tdisc[i],
6516 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6517 if (rc) {
6518 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6519 __func__, rc);
6520 goto vreg_set_voltage_fail;
6521 }
6522 }
6523
6524 return rc;
6525vreg_set_voltage_fail:
6526 i++;
6527vreg_get_fail:
6528 while (i)
6529 regulator_put(vregs_tdisc[--i]);
6530fail_gpio_oe:
6531 gpio_free(PMIC_GPIO_TDISC);
6532 return rc;
6533}
6534
6535static void tdisc_shinetsu_release(void)
6536{
6537 int i;
6538
6539 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6540 regulator_put(vregs_tdisc[i]);
6541
6542 gpio_free(PMIC_GPIO_TDISC);
6543 gpio_free(GPIO_JOYSTICK_EN);
6544}
6545
6546static int tdisc_shinetsu_enable(void)
6547{
6548 int i, rc = -EINVAL;
6549
6550 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6551 rc = regulator_enable(vregs_tdisc[i]);
6552 if (rc < 0) {
6553 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6554 __func__, vregs_tdisc_name[i], rc);
6555 goto vreg_fail;
6556 }
6557 }
6558
6559 /* Enable the OE (output enable) gpio */
6560 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6561 /* voltage and gpio stabilization delay */
6562 msleep(50);
6563
6564 return 0;
6565vreg_fail:
6566 while (i)
6567 regulator_disable(vregs_tdisc[--i]);
6568 return rc;
6569}
6570
6571static int tdisc_shinetsu_disable(void)
6572{
6573 int i, rc;
6574
6575 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6576 rc = regulator_disable(vregs_tdisc[i]);
6577 if (rc < 0) {
6578 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6579 __func__, vregs_tdisc_name[i], rc);
6580 goto tdisc_reg_fail;
6581 }
6582 }
6583
6584 /* Disable the OE (output enable) gpio */
6585 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6586
6587 return 0;
6588
6589tdisc_reg_fail:
6590 while (i)
6591 regulator_enable(vregs_tdisc[--i]);
6592 return rc;
6593}
6594
6595static struct tdisc_abs_values tdisc_abs = {
6596 .x_max = 32,
6597 .y_max = 32,
6598 .x_min = -32,
6599 .y_min = -32,
6600 .pressure_max = 32,
6601 .pressure_min = 0,
6602};
6603
6604static struct tdisc_platform_data tdisc_data = {
6605 .tdisc_setup = tdisc_shinetsu_setup,
6606 .tdisc_release = tdisc_shinetsu_release,
6607 .tdisc_enable = tdisc_shinetsu_enable,
6608 .tdisc_disable = tdisc_shinetsu_disable,
6609 .tdisc_wakeup = 0,
6610 .tdisc_gpio = PMIC_GPIO_TDISC,
6611 .tdisc_report_keys = true,
6612 .tdisc_report_relative = true,
6613 .tdisc_report_absolute = false,
6614 .tdisc_report_wheel = false,
6615 .tdisc_reverse_x = false,
6616 .tdisc_reverse_y = true,
6617 .tdisc_abs = &tdisc_abs,
6618};
6619
6620static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6621 {
6622 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6623 .irq = TDISC_INT,
6624 .platform_data = &tdisc_data,
6625 },
6626};
6627#endif
6628
6629#define PM_GPIO_CDC_RST_N 20
6630#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6631
6632static struct regulator *vreg_timpani_1;
6633static struct regulator *vreg_timpani_2;
6634
6635static unsigned int msm_timpani_setup_power(void)
6636{
6637 int rc;
6638
6639 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6640 if (IS_ERR(vreg_timpani_1)) {
6641 pr_err("%s: Unable to get 8058_l0\n", __func__);
6642 return -ENODEV;
6643 }
6644
6645 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6646 if (IS_ERR(vreg_timpani_2)) {
6647 pr_err("%s: Unable to get 8058_s3\n", __func__);
6648 regulator_put(vreg_timpani_1);
6649 return -ENODEV;
6650 }
6651
6652 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6653 if (rc) {
6654 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6655 goto fail;
6656 }
6657
6658 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6659 if (rc) {
6660 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6661 goto fail;
6662 }
6663
6664 rc = regulator_enable(vreg_timpani_1);
6665 if (rc) {
6666 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6667 goto fail;
6668 }
6669
6670 /* The settings for LDO0 should be set such that
6671 * it doesn't require to reset the timpani. */
6672 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6673 if (rc < 0) {
6674 pr_err("Timpani regulator optimum mode setting failed\n");
6675 goto fail;
6676 }
6677
6678 rc = regulator_enable(vreg_timpani_2);
6679 if (rc) {
6680 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6681 regulator_disable(vreg_timpani_1);
6682 goto fail;
6683 }
6684
6685 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6686 if (rc) {
6687 pr_err("%s: GPIO Request %d failed\n", __func__,
6688 GPIO_CDC_RST_N);
6689 regulator_disable(vreg_timpani_1);
6690 regulator_disable(vreg_timpani_2);
6691 goto fail;
6692 } else {
6693 gpio_direction_output(GPIO_CDC_RST_N, 1);
6694 usleep_range(1000, 1050);
6695 gpio_direction_output(GPIO_CDC_RST_N, 0);
6696 usleep_range(1000, 1050);
6697 gpio_direction_output(GPIO_CDC_RST_N, 1);
6698 gpio_free(GPIO_CDC_RST_N);
6699 }
6700 return rc;
6701
6702fail:
6703 regulator_put(vreg_timpani_1);
6704 regulator_put(vreg_timpani_2);
6705 return rc;
6706}
6707
6708static void msm_timpani_shutdown_power(void)
6709{
6710 int rc;
6711
6712 rc = regulator_disable(vreg_timpani_1);
6713 if (rc)
6714 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6715
6716 regulator_put(vreg_timpani_1);
6717
6718 rc = regulator_disable(vreg_timpani_2);
6719 if (rc)
6720 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6721
6722 regulator_put(vreg_timpani_2);
6723}
6724
6725/* Power analog function of codec */
6726static struct regulator *vreg_timpani_cdc_apwr;
6727static int msm_timpani_codec_power(int vreg_on)
6728{
6729 int rc = 0;
6730
6731 if (!vreg_timpani_cdc_apwr) {
6732
6733 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6734
6735 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6736 pr_err("%s: vreg_get failed (%ld)\n",
6737 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6738 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6739 return rc;
6740 }
6741 }
6742
6743 if (vreg_on) {
6744
6745 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6746 2200000, 2200000);
6747 if (rc) {
6748 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6749 __func__);
6750 goto vreg_fail;
6751 }
6752
6753 rc = regulator_enable(vreg_timpani_cdc_apwr);
6754 if (rc) {
6755 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6756 goto vreg_fail;
6757 }
6758 } else {
6759 rc = regulator_disable(vreg_timpani_cdc_apwr);
6760 if (rc) {
6761 pr_err("%s: vreg_disable failed %d\n",
6762 __func__, rc);
6763 goto vreg_fail;
6764 }
6765 }
6766
6767 return 0;
6768
6769vreg_fail:
6770 regulator_put(vreg_timpani_cdc_apwr);
6771 vreg_timpani_cdc_apwr = NULL;
6772 return rc;
6773}
6774
6775static struct marimba_codec_platform_data timpani_codec_pdata = {
6776 .marimba_codec_power = msm_timpani_codec_power,
6777};
6778
6779#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6780#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6781
6782static struct marimba_platform_data timpani_pdata = {
6783 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6784 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6785 .marimba_setup = msm_timpani_setup_power,
6786 .marimba_shutdown = msm_timpani_shutdown_power,
6787 .codec = &timpani_codec_pdata,
6788 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6789};
6790
6791#define TIMPANI_I2C_SLAVE_ADDR 0xD
6792
6793static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6794 {
6795 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6796 .platform_data = &timpani_pdata,
6797 },
6798};
6799
Lei Zhou338cab82011-08-19 13:38:17 -04006800#ifdef CONFIG_SND_SOC_WM8903
6801static struct wm8903_platform_data wm8903_pdata = {
6802 .gpio_cfg[2] = 0x3A8,
6803};
6804
6805#define WM8903_I2C_SLAVE_ADDR 0x34
6806static struct i2c_board_info wm8903_codec_i2c_info[] = {
6807 {
6808 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6809 .platform_data = &wm8903_pdata,
6810 },
6811};
6812#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006813#ifdef CONFIG_PMIC8901
6814
6815#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006816/*
6817 * Consumer specific regulator names:
6818 * regulator name consumer dev_name
6819 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006820static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6821 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6822};
6823static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6824 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6825};
6826
6827#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306828 _always_on) \
6829 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006830 .init_data = { \
6831 .constraints = { \
6832 .valid_modes_mask = _modes, \
6833 .valid_ops_mask = _ops, \
6834 .min_uV = _min_uV, \
6835 .max_uV = _max_uV, \
6836 .input_uV = _min_uV, \
6837 .apply_uV = _apply_uV, \
6838 .always_on = _always_on, \
6839 }, \
6840 .consumer_supplies = vreg_consumers_8901_##_id, \
6841 .num_consumer_supplies = \
6842 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6843 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306844 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006845 }
6846
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006847#define PM8901_VREG_INIT_VS(_id) \
6848 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306849 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006850
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306851static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852 PM8901_VREG_INIT_VS(USB_OTG),
6853 PM8901_VREG_INIT_VS(HDMI_MVS),
6854};
6855
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306856static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6857 .priority = 1,
6858};
6859
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306860static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6861 .irq_base = PM8901_IRQ_BASE,
6862 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6863 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6864};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006865
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306866static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6867 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006868};
6869
6870static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306871 .irq_pdata = &pm8901_irq_pdata,
6872 .mpp_pdata = &pm8901_mpp_pdata,
6873 .regulator_pdatas = pm8901_vreg_init,
6874 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306875 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006876};
6877
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306878static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6879 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6880 .slave = {
6881 .name = "pm8901-core",
6882 .platform_data = &pm8901_platform_data,
6883 },
6884};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006885#endif /* CONFIG_PMIC8901 */
6886
6887#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6888 || defined(CONFIG_GPIO_SX150X_MODULE))
6889
6890static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006891static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006892
6893struct bahama_config_register{
6894 u8 reg;
6895 u8 value;
6896 u8 mask;
6897};
6898
6899enum version{
6900 VER_1_0,
6901 VER_2_0,
6902 VER_UNSUPPORTED = 0xFF
6903};
6904
6905static u8 read_bahama_ver(void)
6906{
6907 int rc;
6908 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6909 u8 bahama_version;
6910
6911 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6912 if (rc < 0) {
6913 printk(KERN_ERR
6914 "%s: version read failed: %d\n",
6915 __func__, rc);
6916 return VER_UNSUPPORTED;
6917 } else {
6918 printk(KERN_INFO
6919 "%s: version read got: 0x%x\n",
6920 __func__, bahama_version);
6921 }
6922
6923 switch (bahama_version) {
6924 case 0x08: /* varient of bahama v1 */
6925 case 0x10:
6926 case 0x00:
6927 return VER_1_0;
6928 case 0x09: /* variant of bahama v2 */
6929 return VER_2_0;
6930 default:
6931 return VER_UNSUPPORTED;
6932 }
6933}
6934
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006935static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006936static unsigned int msm_bahama_setup_power(void)
6937{
6938 int rc = 0;
6939 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006940
6941 if (machine_is_msm8x60_dragon())
6942 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6943
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006944 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6945
6946 if (IS_ERR(vreg_bahama)) {
6947 rc = PTR_ERR(vreg_bahama);
6948 pr_err("%s: regulator_get %s = %d\n", __func__,
6949 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006950 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006951 }
6952
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006953 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6954 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006955 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6956 msm_bahama_regulator, rc);
6957 goto unget;
6958 }
6959
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006960 rc = regulator_enable(vreg_bahama);
6961 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006962 pr_err("%s: regulator_enable %s = %d\n", __func__,
6963 msm_bahama_regulator, rc);
6964 goto unget;
6965 }
6966
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006967 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6968 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006969 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006970 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006971 goto unenable;
6972 }
6973
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006974 gpio_direction_output(msm_bahama_sys_rst, 0);
6975 usleep_range(1000, 1050);
6976 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6977 usleep_range(1000, 1050);
6978 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006979 return rc;
6980
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006981unenable:
6982 regulator_disable(vreg_bahama);
6983unget:
6984 regulator_put(vreg_bahama);
6985 return rc;
6986};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006987
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006988static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006989{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006990 if (msm_bahama_setup_power_enable) {
6991 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6992 gpio_free(msm_bahama_sys_rst);
6993 regulator_disable(vreg_bahama);
6994 regulator_put(vreg_bahama);
6995 msm_bahama_setup_power_enable = 0;
6996 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006997
6998 return 0;
6999};
7000
7001static unsigned int msm_bahama_core_config(int type)
7002{
7003 int rc = 0;
7004
7005 if (type == BAHAMA_ID) {
7006
7007 int i;
7008 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7009
7010 const struct bahama_config_register v20_init[] = {
7011 /* reg, value, mask */
7012 { 0xF4, 0x84, 0xFF }, /* AREG */
7013 { 0xF0, 0x04, 0xFF } /* DREG */
7014 };
7015
7016 if (read_bahama_ver() == VER_2_0) {
7017 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7018 u8 value = v20_init[i].value;
7019 rc = marimba_write_bit_mask(&config,
7020 v20_init[i].reg,
7021 &value,
7022 sizeof(v20_init[i].value),
7023 v20_init[i].mask);
7024 if (rc < 0) {
7025 printk(KERN_ERR
7026 "%s: reg %d write failed: %d\n",
7027 __func__, v20_init[i].reg, rc);
7028 return rc;
7029 }
7030 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7031 " mask 0x%02x\n",
7032 __func__, v20_init[i].reg,
7033 v20_init[i].value, v20_init[i].mask);
7034 }
7035 }
7036 }
7037 printk(KERN_INFO "core type: %d\n", type);
7038
7039 return rc;
7040}
7041
7042static struct regulator *fm_regulator_s3;
7043static struct msm_xo_voter *fm_clock;
7044
7045static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7046{
7047 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307048 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007049 .direction = PM_GPIO_DIR_IN,
7050 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307051 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007052 .function = PM_GPIO_FUNC_NORMAL,
7053 .inv_int_pol = 0,
7054 };
7055
7056 if (!fm_regulator_s3) {
7057 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7058 if (IS_ERR(fm_regulator_s3)) {
7059 rc = PTR_ERR(fm_regulator_s3);
7060 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7061 __func__, rc);
7062 goto out;
7063 }
7064 }
7065
7066
7067 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7068 if (rc < 0) {
7069 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7070 __func__, rc);
7071 goto fm_fail_put;
7072 }
7073
7074 rc = regulator_enable(fm_regulator_s3);
7075 if (rc < 0) {
7076 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7077 __func__, rc);
7078 goto fm_fail_put;
7079 }
7080
7081 /*Vote for XO clock*/
7082 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7083
7084 if (IS_ERR(fm_clock)) {
7085 rc = PTR_ERR(fm_clock);
7086 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7087 __func__, rc);
7088 goto fm_fail_switch;
7089 }
7090
7091 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7092 if (rc < 0) {
7093 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7094 __func__, rc);
7095 goto fm_fail_vote;
7096 }
7097
7098 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307099 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007100 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307101 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007102 __func__, rc);
7103 goto fm_fail_clock;
7104 }
7105 goto out;
7106
7107fm_fail_clock:
7108 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7109fm_fail_vote:
7110 msm_xo_put(fm_clock);
7111fm_fail_switch:
7112 regulator_disable(fm_regulator_s3);
7113fm_fail_put:
7114 regulator_put(fm_regulator_s3);
7115out:
7116 return rc;
7117};
7118
7119static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7120{
7121 int rc = 0;
7122 if (fm_regulator_s3 != NULL) {
7123 rc = regulator_disable(fm_regulator_s3);
7124 if (rc < 0) {
7125 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7126 __func__, rc);
7127 }
7128 regulator_put(fm_regulator_s3);
7129 fm_regulator_s3 = NULL;
7130 }
7131 printk(KERN_ERR "%s: Voting off for XO", __func__);
7132
7133 if (fm_clock != NULL) {
7134 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7135 if (rc < 0) {
7136 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7137 __func__, rc);
7138 }
7139 msm_xo_put(fm_clock);
7140 }
7141 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7142}
7143
7144/* Slave id address for FM/CDC/QMEMBIST
7145 * Values can be programmed using Marimba slave id 0
7146 * should there be a conflict with other I2C devices
7147 * */
7148#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7149#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7150
7151static struct marimba_fm_platform_data marimba_fm_pdata = {
7152 .fm_setup = fm_radio_setup,
7153 .fm_shutdown = fm_radio_shutdown,
7154 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7155 .is_fm_soc_i2s_master = false,
7156 .config_i2s_gpio = NULL,
7157};
7158
7159/*
7160Just initializing the BAHAMA related slave
7161*/
7162static struct marimba_platform_data marimba_pdata = {
7163 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7164 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7165 .bahama_setup = msm_bahama_setup_power,
7166 .bahama_shutdown = msm_bahama_shutdown_power,
7167 .bahama_core_config = msm_bahama_core_config,
7168 .fm = &marimba_fm_pdata,
7169 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7170};
7171
7172
7173static struct i2c_board_info msm_marimba_board_info[] = {
7174 {
7175 I2C_BOARD_INFO("marimba", 0xc),
7176 .platform_data = &marimba_pdata,
7177 }
7178};
7179#endif /* CONFIG_MAIMBA_CORE */
7180
7181#ifdef CONFIG_I2C
7182#define I2C_SURF 1
7183#define I2C_FFA (1 << 1)
7184#define I2C_RUMI (1 << 2)
7185#define I2C_SIM (1 << 3)
7186#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007187#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007188
7189struct i2c_registry {
7190 u8 machs;
7191 int bus;
7192 struct i2c_board_info *info;
7193 int len;
7194};
7195
7196static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007197#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7198 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007199 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007200 MSM_GSBI8_QUP_I2C_BUS_ID,
7201 core_expander_i2c_info,
7202 ARRAY_SIZE(core_expander_i2c_info),
7203 },
7204 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007205 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007206 MSM_GSBI8_QUP_I2C_BUS_ID,
7207 docking_expander_i2c_info,
7208 ARRAY_SIZE(docking_expander_i2c_info),
7209 },
7210 {
7211 I2C_SURF,
7212 MSM_GSBI8_QUP_I2C_BUS_ID,
7213 surf_expanders_i2c_info,
7214 ARRAY_SIZE(surf_expanders_i2c_info),
7215 },
7216 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007217 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007218 MSM_GSBI3_QUP_I2C_BUS_ID,
7219 fha_expanders_i2c_info,
7220 ARRAY_SIZE(fha_expanders_i2c_info),
7221 },
7222 {
7223 I2C_FLUID,
7224 MSM_GSBI3_QUP_I2C_BUS_ID,
7225 fluid_expanders_i2c_info,
7226 ARRAY_SIZE(fluid_expanders_i2c_info),
7227 },
7228 {
7229 I2C_FLUID,
7230 MSM_GSBI8_QUP_I2C_BUS_ID,
7231 fluid_core_expander_i2c_info,
7232 ARRAY_SIZE(fluid_core_expander_i2c_info),
7233 },
7234#endif
7235#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7236 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7237 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007238 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007239 MSM_GSBI3_QUP_I2C_BUS_ID,
7240 msm_i2c_gsbi3_tdisc_info,
7241 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7242 },
7243#endif
7244 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007245 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007246 MSM_GSBI3_QUP_I2C_BUS_ID,
7247 cy8ctmg200_board_info,
7248 ARRAY_SIZE(cy8ctmg200_board_info),
7249 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007250 {
7251 I2C_DRAGON,
7252 MSM_GSBI3_QUP_I2C_BUS_ID,
7253 cy8ctma340_dragon_board_info,
7254 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7255 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007256#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7257 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007258 {
7259 I2C_FLUID,
7260 MSM_GSBI3_QUP_I2C_BUS_ID,
7261 cyttsp_fluid_info,
7262 ARRAY_SIZE(cyttsp_fluid_info),
7263 },
7264 {
7265 I2C_FFA | I2C_SURF,
7266 MSM_GSBI3_QUP_I2C_BUS_ID,
7267 cyttsp_ffa_info,
7268 ARRAY_SIZE(cyttsp_ffa_info),
7269 },
7270#endif
7271#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007272#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007273 {
7274 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007275 MSM_GSBI4_QUP_I2C_BUS_ID,
7276 msm_camera_boardinfo,
7277 ARRAY_SIZE(msm_camera_boardinfo),
7278 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007279 {
7280 I2C_DRAGON,
7281 MSM_GSBI4_QUP_I2C_BUS_ID,
7282 msm_camera_dragon_boardinfo,
7283 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7284 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007285#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007286#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007287 {
7288 I2C_SURF | I2C_FFA | I2C_FLUID,
7289 MSM_GSBI7_QUP_I2C_BUS_ID,
7290 msm_i2c_gsbi7_timpani_info,
7291 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7292 },
7293#if defined(CONFIG_MARIMBA_CORE)
7294 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007295 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007296 MSM_GSBI7_QUP_I2C_BUS_ID,
7297 msm_marimba_board_info,
7298 ARRAY_SIZE(msm_marimba_board_info),
7299 },
7300#endif /* CONFIG_MARIMBA_CORE */
7301#ifdef CONFIG_ISL9519_CHARGER
7302 {
7303 I2C_SURF | I2C_FFA,
7304 MSM_GSBI8_QUP_I2C_BUS_ID,
7305 isl_charger_i2c_info,
7306 ARRAY_SIZE(isl_charger_i2c_info),
7307 },
7308#endif
7309#if defined(CONFIG_HAPTIC_ISA1200) || \
7310 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7311 {
7312 I2C_FLUID,
7313 MSM_GSBI8_QUP_I2C_BUS_ID,
7314 msm_isa1200_board_info,
7315 ARRAY_SIZE(msm_isa1200_board_info),
7316 },
7317#endif
7318#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7319 {
7320 I2C_FLUID,
7321 MSM_GSBI8_QUP_I2C_BUS_ID,
7322 smb137b_charger_i2c_info,
7323 ARRAY_SIZE(smb137b_charger_i2c_info),
7324 },
7325#endif
7326#if defined(CONFIG_BATTERY_BQ27520) || \
7327 defined(CONFIG_BATTERY_BQ27520_MODULE)
7328 {
7329 I2C_FLUID,
7330 MSM_GSBI8_QUP_I2C_BUS_ID,
7331 msm_bq27520_board_info,
7332 ARRAY_SIZE(msm_bq27520_board_info),
7333 },
7334#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007335#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7336 {
7337 I2C_DRAGON,
7338 MSM_GSBI8_QUP_I2C_BUS_ID,
7339 wm8903_codec_i2c_info,
7340 ARRAY_SIZE(wm8903_codec_i2c_info),
7341 },
7342#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007343};
7344#endif /* CONFIG_I2C */
7345
Stephen Boyd668d7652012-04-25 11:31:01 -07007346static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007347{
7348#ifdef CONFIG_I2C
7349#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7350 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7351 sx150x_data[SX150X_CORE].irq_summary =
7352 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007353 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7354 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007355 sx150x_data[SX150X_CORE].irq_summary =
7356 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7357 else if (machine_is_msm8x60_fluid())
7358 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7359 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7360#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007361#endif
7362}
7363
Stephen Boyd668d7652012-04-25 11:31:01 -07007364static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007365{
7366#ifdef CONFIG_I2C
7367 u8 mach_mask = 0;
7368 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007369#ifdef CONFIG_MSM_CAMERA_V4L2
7370 struct i2c_registry msm8x60_camera_i2c_devices = {
7371 I2C_SURF | I2C_FFA | I2C_FLUID,
7372 MSM_GSBI4_QUP_I2C_BUS_ID,
7373 msm8x60_camera_board_info.board_info,
7374 msm8x60_camera_board_info.num_i2c_board_info,
7375 };
7376#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007377
7378 /* Build the matching 'supported_machs' bitmask */
7379 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7380 mach_mask = I2C_SURF;
7381 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7382 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007383 else if (machine_is_msm8x60_fluid())
7384 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007385 else if (machine_is_msm8x60_dragon())
7386 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007387 else
7388 pr_err("unmatched machine ID in register_i2c_devices\n");
7389
7390 /* Run the array and install devices as appropriate */
7391 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7392 if (msm8x60_i2c_devices[i].machs & mach_mask)
7393 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7394 msm8x60_i2c_devices[i].info,
7395 msm8x60_i2c_devices[i].len);
7396 }
Kevin Chan3be11612012-03-22 20:05:40 -07007397#ifdef CONFIG_MSM_CAMERA_V4L2
7398 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7399 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7400 msm8x60_camera_i2c_devices.info,
7401 msm8x60_camera_i2c_devices.len);
7402#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007403#endif
7404}
7405
7406static void __init msm8x60_init_uart12dm(void)
7407{
7408#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7409 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7410 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7411
7412 if (!fpga_mem)
7413 pr_err("%s(): Error getting memory\n", __func__);
7414
7415 /* Advanced mode */
7416 writew(0xFFFF, fpga_mem + 0x15C);
7417 /* FPGA_UART_SEL */
7418 writew(0, fpga_mem + 0x172);
7419 /* FPGA_GPIO_CONFIG_117 */
7420 writew(1, fpga_mem + 0xEA);
7421 /* FPGA_GPIO_CONFIG_118 */
7422 writew(1, fpga_mem + 0xEC);
7423 mb();
7424 iounmap(fpga_mem);
7425#endif
7426}
7427
7428#define MSM_GSBI9_PHYS 0x19900000
7429#define GSBI_DUAL_MODE_CODE 0x60
7430
7431static void __init msm8x60_init_buses(void)
7432{
7433#ifdef CONFIG_I2C_QUP
7434 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7435 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7436 writel_relaxed(0x6 << 4, gsbi_mem);
7437 /* Ensure protocol code is written before proceeding further */
7438 mb();
7439 iounmap(gsbi_mem);
7440
7441 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7442 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7443 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7444 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7445
7446#ifdef CONFIG_MSM_GSBI9_UART
7447 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7448 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7449 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7450 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7451 iounmap(gsbi_mem);
7452 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7453 }
7454#endif
7455 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7456 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7457#endif
7458#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7459 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7460#endif
7461#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007462 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7463#endif
7464
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307465#ifdef CONFIG_MSM_SSBI
7466 msm_device_ssbi_pmic1.dev.platform_data =
7467 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307468 msm_device_ssbi_pmic2.dev.platform_data =
7469 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307470#endif
7471
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007472 if (machine_is_msm8x60_fluid()) {
7473#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7474 (defined(CONFIG_SMB137B_CHARGER) || \
7475 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7476 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7477#endif
7478#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7479 msm_gsbi10_qup_spi_device.dev.platform_data =
7480 &msm_gsbi10_qup_spi_pdata;
7481#endif
7482 }
7483
Lena Salman57d167e2012-03-21 19:46:38 +02007484#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007485 /*
7486 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7487 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7488 * and ID notifications are available only on V2 surf and FFA
7489 * with a hardware workaround.
7490 */
7491 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7492 (machine_is_msm8x60_surf() ||
7493 (machine_is_msm8x60_ffa() &&
7494 pmic_id_notif_supported)))
7495 msm_otg_pdata.phy_can_powercollapse = 1;
7496 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7497#endif
7498
Lena Salman57d167e2012-03-21 19:46:38 +02007499#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007500 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7501#endif
7502
7503#ifdef CONFIG_SERIAL_MSM_HS
7504 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7505 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7506#endif
7507#ifdef CONFIG_MSM_GSBI9_UART
7508 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7509 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7510 if (IS_ERR(msm_device_uart_gsbi9))
7511 pr_err("%s(): Failed to create uart gsbi9 device\n",
7512 __func__);
7513 }
7514#endif
7515
7516#ifdef CONFIG_MSM_BUS_SCALING
7517
7518 /* RPM calls are only enabled on V2 */
7519 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7520 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7521 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7522 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7523 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7524 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7525 }
7526
7527 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7528 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7529 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7530 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7531 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7532#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007533}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007534
7535static void __init msm8x60_map_io(void)
7536{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007537 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007538 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007539
7540 if (socinfo_init() < 0)
7541 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007542}
7543
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007544/*
7545 * Most segments of the EBI2 bus are disabled by default.
7546 */
7547static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007548{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007549 uint32_t ebi2_cfg;
7550 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007551 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007552
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007553 if (IS_ERR(mem_clk)) {
7554 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7555 "msm_ebi2", "mem_clk");
7556 return;
7557 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007558 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007559 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007560
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007561 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7562 if (ebi2_cfg_ptr != 0) {
7563 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007565 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007566 machine_is_msm8x60_fluid() ||
7567 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007568 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007570 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7571 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007572 }
7573
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007574 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007575 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007576 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7577 if (ebi2_cfg_ptr != 0) {
7578 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7579 writel_relaxed(0UL, ebi2_cfg_ptr);
7580
7581 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7582 * LAN9221 Ethernet controller reads and writes.
7583 * The lowest 4 bits are the read delay, the next
7584 * 4 are the write delay. */
7585 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7586#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7587 /*
7588 * RECOVERY=5, HOLD_WR=1
7589 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7590 * WAIT_WR=1, WAIT_RD=2
7591 */
7592 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7593 /*
7594 * HOLD_RD=1
7595 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7596 */
7597 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7598#else
7599 /* EBI2 CS3 muxed address/data,
7600 * two cyc addr enable */
7601 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7602
7603#endif
7604 iounmap(ebi2_cfg_ptr);
7605 }
7606 }
David Brown56e2d8a2011-08-04 02:01:02 -07007607}
7608
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007609#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7610 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7611 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7612 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7613 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7614
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007615/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007616#define MAX_SDCC_CONTROLLER 5
7617
7618struct msm_sdcc_gpio {
7619 /* maximum 10 GPIOs per SDCC controller */
7620 s16 no;
7621 /* name of this GPIO */
7622 const char *name;
7623 bool always_on;
7624 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007625};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007626
7627#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7628static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7629 {159, "sdc1_dat_0"},
7630 {160, "sdc1_dat_1"},
7631 {161, "sdc1_dat_2"},
7632 {162, "sdc1_dat_3"},
7633#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7634 {163, "sdc1_dat_4"},
7635 {164, "sdc1_dat_5"},
7636 {165, "sdc1_dat_6"},
7637 {166, "sdc1_dat_7"},
7638#endif
7639 {167, "sdc1_clk"},
7640 {168, "sdc1_cmd"}
7641};
7642#endif
7643
7644#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7645static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7646 {143, "sdc2_dat_0"},
7647 {144, "sdc2_dat_1", 1},
7648 {145, "sdc2_dat_2"},
7649 {146, "sdc2_dat_3"},
7650#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7651 {147, "sdc2_dat_4"},
7652 {148, "sdc2_dat_5"},
7653 {149, "sdc2_dat_6"},
7654 {150, "sdc2_dat_7"},
7655#endif
7656 {151, "sdc2_cmd"},
7657 {152, "sdc2_clk", 1}
7658};
7659#endif
7660
7661#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7662static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7663 {95, "sdc5_cmd"},
7664 {96, "sdc5_dat_3"},
7665 {97, "sdc5_clk", 1},
7666 {98, "sdc5_dat_2"},
7667 {99, "sdc5_dat_1", 1},
7668 {100, "sdc5_dat_0"}
7669};
7670#endif
7671
7672struct msm_sdcc_pad_pull_cfg {
7673 enum msm_tlmm_pull_tgt pull;
7674 u32 pull_val;
7675};
7676
7677struct msm_sdcc_pad_drv_cfg {
7678 enum msm_tlmm_hdrive_tgt drv;
7679 u32 drv_val;
7680};
7681
7682#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7683static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7684 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7685 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7686 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7687};
7688
7689static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7690 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7691 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7692};
7693
7694static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7695 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7696 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7697 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7698};
7699
7700static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7701 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7702 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7703};
7704#endif
7705
7706#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7707static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7708 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7709 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7710 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7711};
7712
7713static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7714 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7715 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7716};
7717
7718static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7719 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7720 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7721 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7722};
7723
7724static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7725 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7726 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7727};
7728#endif
7729
7730struct msm_sdcc_pin_cfg {
7731 /*
7732 * = 1 if controller pins are using gpios
7733 * = 0 if controller has dedicated MSM pins
7734 */
7735 u8 is_gpio;
7736 u8 cfg_sts;
7737 u8 gpio_data_size;
7738 struct msm_sdcc_gpio *gpio_data;
7739 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7740 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7741 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7742 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7743 u8 pad_drv_data_size;
7744 u8 pad_pull_data_size;
7745 u8 sdio_lpm_gpio_cfg;
7746};
7747
7748
7749static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7750#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7751 [0] = {
7752 .is_gpio = 1,
7753 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7754 .gpio_data = sdc1_gpio_cfg
7755 },
7756#endif
7757#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7758 [1] = {
7759 .is_gpio = 1,
7760 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7761 .gpio_data = sdc2_gpio_cfg
7762 },
7763#endif
7764#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7765 [2] = {
7766 .is_gpio = 0,
7767 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7768 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7769 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7770 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7771 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7772 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7773 },
7774#endif
7775#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7776 [3] = {
7777 .is_gpio = 0,
7778 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7779 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7780 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7781 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7782 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7783 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7784 },
7785#endif
7786#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7787 [4] = {
7788 .is_gpio = 1,
7789 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7790 .gpio_data = sdc5_gpio_cfg
7791 }
7792#endif
7793};
7794
7795static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7796{
7797 int rc = 0;
7798 struct msm_sdcc_pin_cfg *curr;
7799 int n;
7800
7801 curr = &sdcc_pin_cfg_data[dev_id - 1];
7802 if (!curr->gpio_data)
7803 goto out;
7804
7805 for (n = 0; n < curr->gpio_data_size; n++) {
7806 if (enable) {
7807
7808 if (curr->gpio_data[n].always_on &&
7809 curr->gpio_data[n].is_enabled)
7810 continue;
7811 pr_debug("%s: enable: %s\n", __func__,
7812 curr->gpio_data[n].name);
7813 rc = gpio_request(curr->gpio_data[n].no,
7814 curr->gpio_data[n].name);
7815 if (rc) {
7816 pr_err("%s: gpio_request(%d, %s)"
7817 "failed", __func__,
7818 curr->gpio_data[n].no,
7819 curr->gpio_data[n].name);
7820 goto free_gpios;
7821 }
7822 /* set direction as output for all GPIOs */
7823 rc = gpio_direction_output(
7824 curr->gpio_data[n].no, 1);
7825 if (rc) {
7826 pr_err("%s: gpio_direction_output"
7827 "(%d, 1) failed\n", __func__,
7828 curr->gpio_data[n].no);
7829 goto free_gpios;
7830 }
7831 curr->gpio_data[n].is_enabled = 1;
7832 } else {
7833 /*
7834 * now free this GPIO which will put GPIO
7835 * in low power mode and will also put GPIO
7836 * in input mode
7837 */
7838 if (curr->gpio_data[n].always_on)
7839 continue;
7840 pr_debug("%s: disable: %s\n", __func__,
7841 curr->gpio_data[n].name);
7842 gpio_free(curr->gpio_data[n].no);
7843 curr->gpio_data[n].is_enabled = 0;
7844 }
7845 }
7846 curr->cfg_sts = enable;
7847 goto out;
7848
7849free_gpios:
7850 for (; n >= 0; n--)
7851 gpio_free(curr->gpio_data[n].no);
7852out:
7853 return rc;
7854}
7855
7856static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7857{
7858 int rc = 0;
7859 struct msm_sdcc_pin_cfg *curr;
7860 int n;
7861
7862 curr = &sdcc_pin_cfg_data[dev_id - 1];
7863 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7864 goto out;
7865
7866 if (enable) {
7867 /*
7868 * set up the normal driver strength and
7869 * pull config for pads
7870 */
7871 for (n = 0; n < curr->pad_drv_data_size; n++) {
7872 if (curr->sdio_lpm_gpio_cfg) {
7873 if (curr->pad_drv_on_data[n].drv ==
7874 TLMM_HDRV_SDC4_DATA)
7875 continue;
7876 }
7877 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7878 curr->pad_drv_on_data[n].drv_val);
7879 }
7880 for (n = 0; n < curr->pad_pull_data_size; n++) {
7881 if (curr->sdio_lpm_gpio_cfg) {
7882 if (curr->pad_pull_on_data[n].pull ==
7883 TLMM_PULL_SDC4_DATA)
7884 continue;
7885 }
7886 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7887 curr->pad_pull_on_data[n].pull_val);
7888 }
7889 } else {
7890 /* set the low power config for pads */
7891 for (n = 0; n < curr->pad_drv_data_size; n++) {
7892 if (curr->sdio_lpm_gpio_cfg) {
7893 if (curr->pad_drv_off_data[n].drv ==
7894 TLMM_HDRV_SDC4_DATA)
7895 continue;
7896 }
7897 msm_tlmm_set_hdrive(
7898 curr->pad_drv_off_data[n].drv,
7899 curr->pad_drv_off_data[n].drv_val);
7900 }
7901 for (n = 0; n < curr->pad_pull_data_size; n++) {
7902 if (curr->sdio_lpm_gpio_cfg) {
7903 if (curr->pad_pull_off_data[n].pull ==
7904 TLMM_PULL_SDC4_DATA)
7905 continue;
7906 }
7907 msm_tlmm_set_pull(
7908 curr->pad_pull_off_data[n].pull,
7909 curr->pad_pull_off_data[n].pull_val);
7910 }
7911 }
7912 curr->cfg_sts = enable;
7913out:
7914 return rc;
7915}
7916
7917struct sdcc_reg {
7918 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7919 const char *reg_name;
7920 /*
7921 * is set voltage supported for this regulator?
7922 * 0 = not supported, 1 = supported
7923 */
7924 unsigned char set_voltage_sup;
7925 /* voltage level to be set */
7926 unsigned int level;
7927 /* VDD/VCC/VCCQ voltage regulator handle */
7928 struct regulator *reg;
7929 /* is this regulator enabled? */
7930 bool enabled;
7931 /* is this regulator needs to be always on? */
7932 bool always_on;
7933 /* is operating power mode setting required for this regulator? */
7934 bool op_pwr_mode_sup;
7935 /* Load values for low power and high power mode */
7936 unsigned int lpm_uA;
7937 unsigned int hpm_uA;
7938};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007939/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007940static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7941/* only SDCC1 requires VCCQ voltage */
7942static struct sdcc_reg sdcc_vccq_reg_data[1];
7943/* all SDCC controllers may require voting for VDD PAD voltage */
7944static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7945
7946struct sdcc_reg_data {
7947 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7948 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7949 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7950 unsigned char sts; /* regulator enable/disable status */
7951};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007952/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007953static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7954
7955static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7956{
7957 int rc = 0;
7958
7959 /* Get the regulator handle */
7960 vreg->reg = regulator_get(NULL, vreg->reg_name);
7961 if (IS_ERR(vreg->reg)) {
7962 rc = PTR_ERR(vreg->reg);
7963 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7964 __func__, vreg->reg_name, rc);
7965 goto out;
7966 }
7967
7968 /* Set the voltage level if required */
7969 if (vreg->set_voltage_sup) {
7970 rc = regulator_set_voltage(vreg->reg, vreg->level,
7971 vreg->level);
7972 if (rc) {
7973 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7974 __func__, vreg->reg_name, rc);
7975 goto vreg_put;
7976 }
7977 }
7978 goto out;
7979
7980vreg_put:
7981 regulator_put(vreg->reg);
7982out:
7983 return rc;
7984}
7985
7986static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7987{
7988 regulator_put(vreg->reg);
7989}
7990
7991/* this init function should be called only once for each SDCC */
7992static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7993{
7994 int rc = 0;
7995 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7996 struct sdcc_reg_data *curr;
7997
7998 curr = &sdcc_vreg_data[dev_id - 1];
7999 curr_vdd_reg = curr->vdd_data;
8000 curr_vccq_reg = curr->vccq_data;
8001 curr_vddp_reg = curr->vddp_data;
8002
8003 if (init) {
8004 /*
8005 * get the regulator handle from voltage regulator framework
8006 * and then try to set the voltage level for the regulator
8007 */
8008 if (curr_vdd_reg) {
8009 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8010 if (rc)
8011 goto out;
8012 }
8013 if (curr_vccq_reg) {
8014 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8015 if (rc)
8016 goto vdd_reg_deinit;
8017 }
8018 if (curr_vddp_reg) {
8019 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8020 if (rc)
8021 goto vccq_reg_deinit;
8022 }
8023 goto out;
8024 } else
8025 /* deregister with all regulators from regulator framework */
8026 goto vddp_reg_deinit;
8027
8028vddp_reg_deinit:
8029 if (curr_vddp_reg)
8030 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8031vccq_reg_deinit:
8032 if (curr_vccq_reg)
8033 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8034vdd_reg_deinit:
8035 if (curr_vdd_reg)
8036 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8037out:
8038 return rc;
8039}
8040
8041static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8042{
8043 int rc;
8044
8045 if (!vreg->enabled) {
8046 rc = regulator_enable(vreg->reg);
8047 if (rc) {
8048 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8049 __func__, vreg->reg_name, rc);
8050 goto out;
8051 }
8052 vreg->enabled = 1;
8053 }
8054
8055 /* Put always_on regulator in HPM (high power mode) */
8056 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8057 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8058 if (rc < 0) {
8059 pr_err("%s: reg=%s: HPM setting failed"
8060 " hpm_uA=%d, rc=%d\n",
8061 __func__, vreg->reg_name,
8062 vreg->hpm_uA, rc);
8063 goto vreg_disable;
8064 }
8065 rc = 0;
8066 }
8067 goto out;
8068
8069vreg_disable:
8070 regulator_disable(vreg->reg);
8071 vreg->enabled = 0;
8072out:
8073 return rc;
8074}
8075
8076static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8077{
8078 int rc;
8079
8080 /* Never disable always_on regulator */
8081 if (!vreg->always_on) {
8082 rc = regulator_disable(vreg->reg);
8083 if (rc) {
8084 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8085 __func__, vreg->reg_name, rc);
8086 goto out;
8087 }
8088 vreg->enabled = 0;
8089 }
8090
8091 /* Put always_on regulator in LPM (low power mode) */
8092 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8093 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8094 if (rc < 0) {
8095 pr_err("%s: reg=%s: LPM setting failed"
8096 " lpm_uA=%d, rc=%d\n",
8097 __func__,
8098 vreg->reg_name,
8099 vreg->lpm_uA, rc);
8100 goto out;
8101 }
8102 rc = 0;
8103 }
8104
8105out:
8106 return rc;
8107}
8108
8109static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8110{
8111 int rc = 0;
8112 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8113 struct sdcc_reg_data *curr;
8114
8115 curr = &sdcc_vreg_data[dev_id - 1];
8116 curr_vdd_reg = curr->vdd_data;
8117 curr_vccq_reg = curr->vccq_data;
8118 curr_vddp_reg = curr->vddp_data;
8119
8120 /* check if regulators are initialized or not? */
8121 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8122 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8123 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8124 /* initialize voltage regulators required for this SDCC */
8125 rc = msm_sdcc_vreg_init(dev_id, 1);
8126 if (rc) {
8127 pr_err("%s: regulator init failed = %d\n",
8128 __func__, rc);
8129 goto out;
8130 }
8131 }
8132
8133 if (curr->sts == enable)
8134 goto out;
8135
8136 if (curr_vdd_reg) {
8137 if (enable)
8138 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8139 else
8140 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8141 if (rc)
8142 goto out;
8143 }
8144
8145 if (curr_vccq_reg) {
8146 if (enable)
8147 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8148 else
8149 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8150 if (rc)
8151 goto out;
8152 }
8153
8154 if (curr_vddp_reg) {
8155 if (enable)
8156 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8157 else
8158 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8159 if (rc)
8160 goto out;
8161 }
8162 curr->sts = enable;
8163
8164out:
8165 return rc;
8166}
8167
8168static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8169{
8170 u32 rc_pin_cfg = 0;
8171 u32 rc_vreg_cfg = 0;
8172 u32 rc = 0;
8173 struct platform_device *pdev;
8174 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8175
8176 pdev = container_of(dv, struct platform_device, dev);
8177
8178 /* setup gpio/pad */
8179 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8180 if (curr_pin_cfg->cfg_sts == !!vdd)
8181 goto setup_vreg;
8182
8183 if (curr_pin_cfg->is_gpio)
8184 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8185 else
8186 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8187
8188setup_vreg:
8189 /* setup voltage regulators */
8190 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8191
8192 if (rc_pin_cfg || rc_vreg_cfg)
8193 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8194
8195 return rc;
8196}
8197
8198static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8199{
8200 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8201 struct platform_device *pdev;
8202
8203 pdev = container_of(dv, struct platform_device, dev);
8204 /* setup gpio/pad */
8205 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8206
8207 if (curr_pin_cfg->cfg_sts == active)
8208 return;
8209
8210 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8211 if (curr_pin_cfg->is_gpio)
8212 msm_sdcc_setup_gpio(pdev->id, active);
8213 else
8214 msm_sdcc_setup_pad(pdev->id, active);
8215 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8216}
8217
8218static int msm_sdc3_get_wpswitch(struct device *dev)
8219{
8220 struct platform_device *pdev;
8221 int status;
8222 pdev = container_of(dev, struct platform_device, dev);
8223
8224 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8225 if (status) {
8226 pr_err("%s:Failed to request GPIO %d\n",
8227 __func__, GPIO_SDC_WP);
8228 } else {
8229 status = gpio_direction_input(GPIO_SDC_WP);
8230 if (!status) {
8231 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8232 pr_info("%s: WP Status for Slot %d = %d\n",
8233 __func__, pdev->id, status);
8234 }
8235 gpio_free(GPIO_SDC_WP);
8236 }
8237 return status;
8238}
8239
8240#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8241int sdc5_register_status_notify(void (*callback)(int, void *),
8242 void *dev_id)
8243{
8244 sdc5_status_notify_cb = callback;
8245 sdc5_status_notify_cb_devid = dev_id;
8246 return 0;
8247}
8248#endif
8249
8250#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8251int sdc2_register_status_notify(void (*callback)(int, void *),
8252 void *dev_id)
8253{
8254 sdc2_status_notify_cb = callback;
8255 sdc2_status_notify_cb_devid = dev_id;
8256 return 0;
8257}
8258#endif
8259
8260/* Interrupt handler for SDC2 and SDC5 detection
8261 * This function uses dual-edge interrputs settings in order
8262 * to get SDIO detection when the GPIO is rising and SDIO removal
8263 * when the GPIO is falling */
8264static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8265{
8266 int status;
8267
8268 if (!machine_is_msm8x60_fusion() &&
8269 !machine_is_msm8x60_fusn_ffa())
8270 return IRQ_NONE;
8271
8272 status = gpio_get_value(MDM2AP_SYNC);
8273 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8274 __func__, status);
8275
8276#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8277 if (sdc2_status_notify_cb) {
8278 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8279 sdc2_status_notify_cb(status,
8280 sdc2_status_notify_cb_devid);
8281 }
8282#endif
8283
8284#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8285 if (sdc5_status_notify_cb) {
8286 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8287 sdc5_status_notify_cb(status,
8288 sdc5_status_notify_cb_devid);
8289 }
8290#endif
8291 return IRQ_HANDLED;
8292}
8293
8294static int msm8x60_multi_sdio_init(void)
8295{
8296 int ret, irq_num;
8297
8298 if (!machine_is_msm8x60_fusion() &&
8299 !machine_is_msm8x60_fusn_ffa())
8300 return 0;
8301
8302 ret = msm_gpiomux_get(MDM2AP_SYNC);
8303 if (ret) {
8304 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8305 __func__, MDM2AP_SYNC, ret);
8306 return ret;
8307 }
8308
8309 irq_num = gpio_to_irq(MDM2AP_SYNC);
8310
8311 ret = request_irq(irq_num,
8312 msm8x60_multi_sdio_slot_status_irq,
8313 IRQ_TYPE_EDGE_BOTH,
8314 "sdio_multidetection", NULL);
8315
8316 if (ret) {
8317 pr_err("%s:Failed to request irq, ret=%d\n",
8318 __func__, ret);
8319 return ret;
8320 }
8321
8322 return ret;
8323}
8324
8325#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008326static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8327{
8328 int status;
8329
8330 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8331 , "SD_HW_Detect");
8332 if (status) {
8333 pr_err("%s:Failed to request GPIO %d\n", __func__,
8334 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8335 } else {
8336 status = gpio_direction_input(
8337 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8338 if (!status)
8339 status = !(gpio_get_value_cansleep(
8340 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8341 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8342 }
8343 return (unsigned int) status;
8344}
8345#endif
8346#endif
8347
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308348#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308349#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008350
8351#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8352static struct mmc_platform_data msm8x60_sdc1_data = {
8353 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8354 .translate_vdd = msm_sdcc_setup_power,
8355#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8356 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8357#else
8358 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8359#endif
8360 .msmsdcc_fmin = 400000,
8361 .msmsdcc_fmid = 24000000,
8362 .msmsdcc_fmax = 48000000,
8363 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308364 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008365};
8366#endif
8367
8368#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8369static struct mmc_platform_data msm8x60_sdc2_data = {
8370 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8371 .translate_vdd = msm_sdcc_setup_power,
8372 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8373 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8374 .msmsdcc_fmin = 400000,
8375 .msmsdcc_fmid = 24000000,
8376 .msmsdcc_fmax = 48000000,
8377 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008378 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008379#ifdef CONFIG_MSM_SDIO_AL
8380 .is_sdio_al_client = 1,
8381#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308382 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008383};
8384#endif
8385
8386#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8387static struct mmc_platform_data msm8x60_sdc3_data = {
8388 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8389 .translate_vdd = msm_sdcc_setup_power,
8390 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8391 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008392 .status = msm8x60_sdcc_slot_status,
8393 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8394 PMIC_GPIO_SDC3_DET - 1),
8395 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008396 .msmsdcc_fmin = 400000,
8397 .msmsdcc_fmid = 24000000,
8398 .msmsdcc_fmax = 48000000,
8399 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308400 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308401 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008402};
8403#endif
8404
8405#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8406static struct mmc_platform_data msm8x60_sdc4_data = {
8407 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8408 .translate_vdd = msm_sdcc_setup_power,
8409 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8410 .msmsdcc_fmin = 400000,
8411 .msmsdcc_fmid = 24000000,
8412 .msmsdcc_fmax = 48000000,
8413 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308414 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308415 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008416};
8417#endif
8418
8419#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8420static struct mmc_platform_data msm8x60_sdc5_data = {
8421 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8422 .translate_vdd = msm_sdcc_setup_power,
8423 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8424 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8425 .msmsdcc_fmin = 400000,
8426 .msmsdcc_fmid = 24000000,
8427 .msmsdcc_fmax = 48000000,
8428 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008429 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008430#ifdef CONFIG_MSM_SDIO_AL
8431 .is_sdio_al_client = 1,
8432#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308433 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008434};
8435#endif
8436
8437static void __init msm8x60_init_mmc(void)
8438{
8439#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8440 /* SDCC1 : eMMC card connected */
8441 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8442 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8443 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8444 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308445 sdcc_vreg_data[0].vdd_data->always_on = 1;
8446 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8447 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8448 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008449
8450 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8451 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8452 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8453 sdcc_vreg_data[0].vccq_data->always_on = 1;
8454
8455 msm_add_sdcc(1, &msm8x60_sdc1_data);
8456#endif
8457#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8458 /*
8459 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8460 * and no card is connected on 8660 SURF/FFA/FLUID.
8461 */
8462 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8463 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8464 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8465 sdcc_vreg_data[1].vdd_data->level = 1800000;
8466
8467 sdcc_vreg_data[1].vccq_data = NULL;
8468
8469 if (machine_is_msm8x60_fusion())
8470 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8471 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008472 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8473 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008474 msm_add_sdcc(2, &msm8x60_sdc2_data);
8475 }
8476#endif
8477#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8478 /* SDCC3 : External card slot connected */
8479 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8480 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8481 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8482 sdcc_vreg_data[2].vdd_data->level = 2850000;
8483 sdcc_vreg_data[2].vdd_data->always_on = 1;
8484 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8485 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8486 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8487
8488 sdcc_vreg_data[2].vccq_data = NULL;
8489
8490 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8491 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8492 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8493 sdcc_vreg_data[2].vddp_data->level = 2850000;
8494 sdcc_vreg_data[2].vddp_data->always_on = 1;
8495 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8496 /* Sleep current required is ~300 uA. But min. RPM
8497 * vote can be in terms of mA (min. 1 mA).
8498 * So let's vote for 2 mA during sleep.
8499 */
8500 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8501 /* Max. Active current required is 16 mA */
8502 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8503
8504 if (machine_is_msm8x60_fluid())
8505 msm8x60_sdc3_data.wpswitch = NULL;
8506 msm_add_sdcc(3, &msm8x60_sdc3_data);
8507#endif
8508#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8509 /* SDCC4 : WLAN WCN1314 chip is connected */
8510 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8511 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8512 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8513 sdcc_vreg_data[3].vdd_data->level = 1800000;
8514
8515 sdcc_vreg_data[3].vccq_data = NULL;
8516
8517 msm_add_sdcc(4, &msm8x60_sdc4_data);
8518#endif
8519#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8520 /*
8521 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8522 * and no card is connected on 8660 SURF/FFA/FLUID.
8523 */
8524 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8525 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8526 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8527 sdcc_vreg_data[4].vdd_data->level = 1800000;
8528
8529 sdcc_vreg_data[4].vccq_data = NULL;
8530
8531 if (machine_is_msm8x60_fusion())
8532 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8533 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008534 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8535 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008536 msm_add_sdcc(5, &msm8x60_sdc5_data);
8537 }
8538#endif
8539}
8540
8541#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8542static inline void display_common_power(int on) {}
8543#else
8544
8545#define _GET_REGULATOR(var, name) do { \
8546 if (var == NULL) { \
8547 var = regulator_get(NULL, name); \
8548 if (IS_ERR(var)) { \
8549 pr_err("'%s' regulator not found, rc=%ld\n", \
8550 name, PTR_ERR(var)); \
8551 var = NULL; \
8552 } \
8553 } \
8554} while (0)
8555
8556static int dsub_regulator(int on)
8557{
8558 static struct regulator *dsub_reg;
8559 static struct regulator *mpp0_reg;
8560 static int dsub_reg_enabled;
8561 int rc = 0;
8562
8563 _GET_REGULATOR(dsub_reg, "8901_l3");
8564 if (IS_ERR(dsub_reg)) {
8565 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8566 __func__, PTR_ERR(dsub_reg));
8567 return PTR_ERR(dsub_reg);
8568 }
8569
8570 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8571 if (IS_ERR(mpp0_reg)) {
8572 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8573 __func__, PTR_ERR(mpp0_reg));
8574 return PTR_ERR(mpp0_reg);
8575 }
8576
8577 if (on && !dsub_reg_enabled) {
8578 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8579 if (rc) {
8580 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8581 " err=%d", __func__, rc);
8582 goto dsub_regulator_err;
8583 }
8584 rc = regulator_enable(dsub_reg);
8585 if (rc) {
8586 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8587 " err=%d", __func__, rc);
8588 goto dsub_regulator_err;
8589 }
8590 rc = regulator_enable(mpp0_reg);
8591 if (rc) {
8592 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8593 " err=%d", __func__, rc);
8594 goto dsub_regulator_err;
8595 }
8596 dsub_reg_enabled = 1;
8597 } else if (!on && dsub_reg_enabled) {
8598 rc = regulator_disable(dsub_reg);
8599 if (rc)
8600 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8601 " err=%d", __func__, rc);
8602 rc = regulator_disable(mpp0_reg);
8603 if (rc)
8604 printk(KERN_WARNING "%s: failed to disable reg "
8605 "8901_mpp0 err=%d", __func__, rc);
8606 dsub_reg_enabled = 0;
8607 }
8608
8609 return rc;
8610
8611dsub_regulator_err:
8612 regulator_put(mpp0_reg);
8613 regulator_put(dsub_reg);
8614 return rc;
8615}
8616
8617static int display_power_on;
8618static void setup_display_power(void)
8619{
8620 if (display_power_on)
8621 if (lcdc_vga_enabled) {
8622 dsub_regulator(1);
8623 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8624 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8625 if (machine_is_msm8x60_ffa() ||
8626 machine_is_msm8x60_fusn_ffa())
8627 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8628 } else {
8629 dsub_regulator(0);
8630 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8631 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8632 if (machine_is_msm8x60_ffa() ||
8633 machine_is_msm8x60_fusn_ffa())
8634 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8635 }
8636 else {
8637 dsub_regulator(0);
8638 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8639 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8640 /* BACKLIGHT */
8641 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8642 /* LVDS */
8643 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8644 }
8645}
8646
8647#define _GET_REGULATOR(var, name) do { \
8648 if (var == NULL) { \
8649 var = regulator_get(NULL, name); \
8650 if (IS_ERR(var)) { \
8651 pr_err("'%s' regulator not found, rc=%ld\n", \
8652 name, PTR_ERR(var)); \
8653 var = NULL; \
8654 } \
8655 } \
8656} while (0)
8657
8658#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8659
8660static void display_common_power(int on)
8661{
8662 int rc;
8663 static struct regulator *display_reg;
8664
8665 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8666 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8667 if (on) {
8668 /* LVDS */
8669 _GET_REGULATOR(display_reg, "8901_l2");
8670 if (!display_reg)
8671 return;
8672 rc = regulator_set_voltage(display_reg,
8673 3300000, 3300000);
8674 if (rc)
8675 goto out;
8676 rc = regulator_enable(display_reg);
8677 if (rc)
8678 goto out;
8679 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8680 "LVDS_STDN_OUT_N");
8681 if (rc) {
8682 printk(KERN_ERR "%s: LVDS gpio %d request"
8683 "failed\n", __func__,
8684 GPIO_LVDS_SHUTDOWN_N);
8685 goto out2;
8686 }
8687
8688 /* BACKLIGHT */
8689 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8690 if (rc) {
8691 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8692 "failed\n", __func__,
8693 GPIO_BACKLIGHT_EN);
8694 goto out3;
8695 }
8696
8697 if (machine_is_msm8x60_ffa() ||
8698 machine_is_msm8x60_fusn_ffa()) {
8699 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8700 "DONGLE_PWR_EN");
8701 if (rc) {
8702 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8703 " %d request failed\n", __func__,
8704 GPIO_DONGLE_PWR_EN);
8705 goto out4;
8706 }
8707 }
8708
8709 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8710 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8711 if (machine_is_msm8x60_ffa() ||
8712 machine_is_msm8x60_fusn_ffa())
8713 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8714 mdelay(20);
8715 display_power_on = 1;
8716 setup_display_power();
8717 } else {
8718 if (display_power_on) {
8719 display_power_on = 0;
8720 setup_display_power();
8721 mdelay(20);
8722 if (machine_is_msm8x60_ffa() ||
8723 machine_is_msm8x60_fusn_ffa())
8724 gpio_free(GPIO_DONGLE_PWR_EN);
8725 goto out4;
8726 }
8727 }
8728 }
8729#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8730 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8731 else if (machine_is_msm8x60_fluid()) {
8732 static struct regulator *fluid_reg;
8733 static struct regulator *fluid_reg2;
8734
8735 if (on) {
8736 _GET_REGULATOR(fluid_reg, "8901_l2");
8737 if (!fluid_reg)
8738 return;
8739 _GET_REGULATOR(fluid_reg2, "8058_s3");
8740 if (!fluid_reg2) {
8741 regulator_put(fluid_reg);
8742 return;
8743 }
8744 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8745 if (rc) {
8746 regulator_put(fluid_reg2);
8747 regulator_put(fluid_reg);
8748 return;
8749 }
8750 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8751 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8752 regulator_enable(fluid_reg);
8753 regulator_enable(fluid_reg2);
8754 msleep(20);
8755 gpio_direction_output(GPIO_RESX_N, 0);
8756 udelay(10);
8757 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8758 display_power_on = 1;
8759 setup_display_power();
8760 } else {
8761 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8762 gpio_free(GPIO_RESX_N);
8763 msleep(20);
8764 regulator_disable(fluid_reg2);
8765 regulator_disable(fluid_reg);
8766 regulator_put(fluid_reg2);
8767 regulator_put(fluid_reg);
8768 display_power_on = 0;
8769 setup_display_power();
8770 fluid_reg = NULL;
8771 fluid_reg2 = NULL;
8772 }
8773 }
8774#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008775#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8776 else if (machine_is_msm8x60_dragon()) {
8777 static struct regulator *dragon_reg;
8778 static struct regulator *dragon_reg2;
8779
8780 if (on) {
8781 _GET_REGULATOR(dragon_reg, "8901_l2");
8782 if (!dragon_reg)
8783 return;
8784 _GET_REGULATOR(dragon_reg2, "8058_l16");
8785 if (!dragon_reg2) {
8786 regulator_put(dragon_reg);
8787 dragon_reg = NULL;
8788 return;
8789 }
8790
8791 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8792 if (rc) {
8793 pr_err("%s: gpio %d request failed with rc=%d\n",
8794 __func__, GPIO_NT35582_BL_EN, rc);
8795 regulator_put(dragon_reg);
8796 regulator_put(dragon_reg2);
8797 dragon_reg = NULL;
8798 dragon_reg2 = NULL;
8799 return;
8800 }
8801
8802 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8803 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8804 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8805 pr_err("%s: config gpio '%d' failed!\n",
8806 __func__, GPIO_NT35582_RESET);
8807 gpio_free(GPIO_NT35582_BL_EN);
8808 regulator_put(dragon_reg);
8809 regulator_put(dragon_reg2);
8810 dragon_reg = NULL;
8811 dragon_reg2 = NULL;
8812 return;
8813 }
8814
8815 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8816 if (rc) {
8817 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8818 __func__, GPIO_NT35582_RESET, rc);
8819 gpio_free(GPIO_NT35582_BL_EN);
8820 regulator_put(dragon_reg);
8821 regulator_put(dragon_reg2);
8822 dragon_reg = NULL;
8823 dragon_reg2 = NULL;
8824 return;
8825 }
8826
8827 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8828 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8829 regulator_enable(dragon_reg);
8830 regulator_enable(dragon_reg2);
8831 msleep(20);
8832
8833 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8834 msleep(20);
8835 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8836 msleep(20);
8837 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8838 msleep(50);
8839
8840 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8841
8842 display_power_on = 1;
8843 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8844 gpio_free(GPIO_NT35582_RESET);
8845 gpio_free(GPIO_NT35582_BL_EN);
8846 regulator_disable(dragon_reg2);
8847 regulator_disable(dragon_reg);
8848 regulator_put(dragon_reg2);
8849 regulator_put(dragon_reg);
8850 display_power_on = 0;
8851 dragon_reg = NULL;
8852 dragon_reg2 = NULL;
8853 }
8854 }
8855#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008856 return;
8857
8858out4:
8859 gpio_free(GPIO_BACKLIGHT_EN);
8860out3:
8861 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8862out2:
8863 regulator_disable(display_reg);
8864out:
8865 regulator_put(display_reg);
8866 display_reg = NULL;
8867}
8868#undef _GET_REGULATOR
8869#endif
8870
8871static int mipi_dsi_panel_power(int on);
8872
8873#define LCDC_NUM_GPIO 28
8874#define LCDC_GPIO_START 0
8875
8876static void lcdc_samsung_panel_power(int on)
8877{
8878 int n, ret = 0;
8879
8880 display_common_power(on);
8881
8882 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8883 if (on) {
8884 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8885 if (unlikely(ret)) {
8886 pr_err("%s not able to get gpio\n", __func__);
8887 break;
8888 }
8889 } else
8890 gpio_free(LCDC_GPIO_START + n);
8891 }
8892
8893 if (ret) {
8894 for (n--; n >= 0; n--)
8895 gpio_free(LCDC_GPIO_START + n);
8896 }
8897
8898 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8899}
8900
8901#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8902#define _GET_REGULATOR(var, name) do { \
8903 var = regulator_get(NULL, name); \
8904 if (IS_ERR(var)) { \
8905 pr_err("'%s' regulator not found, rc=%ld\n", \
8906 name, IS_ERR(var)); \
8907 var = NULL; \
8908 return -ENODEV; \
8909 } \
8910} while (0)
8911
8912static int hdmi_enable_5v(int on)
8913{
8914 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8915 static struct regulator *reg_8901_mpp0; /* External 5V */
8916 static int prev_on;
8917 int rc;
8918
8919 if (on == prev_on)
8920 return 0;
8921
8922 if (!reg_8901_hdmi_mvs)
8923 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8924 if (!reg_8901_mpp0)
8925 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8926
8927 if (on) {
8928 rc = regulator_enable(reg_8901_mpp0);
8929 if (rc) {
8930 pr_err("'%s' regulator enable failed, rc=%d\n",
8931 "reg_8901_mpp0", rc);
8932 return rc;
8933 }
8934 rc = regulator_enable(reg_8901_hdmi_mvs);
8935 if (rc) {
8936 pr_err("'%s' regulator enable failed, rc=%d\n",
8937 "8901_hdmi_mvs", rc);
8938 return rc;
8939 }
8940 pr_info("%s(on): success\n", __func__);
8941 } else {
8942 rc = regulator_disable(reg_8901_hdmi_mvs);
8943 if (rc)
8944 pr_warning("'%s' regulator disable failed, rc=%d\n",
8945 "8901_hdmi_mvs", rc);
8946 rc = regulator_disable(reg_8901_mpp0);
8947 if (rc)
8948 pr_warning("'%s' regulator disable failed, rc=%d\n",
8949 "reg_8901_mpp0", rc);
8950 pr_info("%s(off): success\n", __func__);
8951 }
8952
8953 prev_on = on;
8954
8955 return 0;
8956}
8957
8958static int hdmi_core_power(int on, int show)
8959{
8960 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8961 static int prev_on;
8962 int rc;
8963
8964 if (on == prev_on)
8965 return 0;
8966
8967 if (!reg_8058_l16)
8968 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8969
8970 if (on) {
8971 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8972 if (!rc)
8973 rc = regulator_enable(reg_8058_l16);
8974 if (rc) {
8975 pr_err("'%s' regulator enable failed, rc=%d\n",
8976 "8058_l16", rc);
8977 return rc;
8978 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05308979 pr_debug("%s(on): success\n", __func__);
8980 } else {
8981 rc = regulator_disable(reg_8058_l16);
8982 if (rc)
8983 pr_warning("'%s' regulator disable failed, rc=%d\n",
8984 "8058_l16", rc);
8985 pr_debug("%s(off): success\n", __func__);
8986 }
8987
8988 prev_on = on;
8989
8990 return 0;
8991}
8992
8993static int hdmi_gpio_config(int on)
8994{
8995 int rc = 0;
8996 static int prev_on;
8997
8998 if (on == prev_on)
8999 return 0;
9000
9001 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009002 rc = gpio_request(170, "HDMI_DDC_CLK");
9003 if (rc) {
9004 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9005 "HDMI_DDC_CLK", 170, rc);
9006 goto error1;
9007 }
9008 rc = gpio_request(171, "HDMI_DDC_DATA");
9009 if (rc) {
9010 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9011 "HDMI_DDC_DATA", 171, rc);
9012 goto error2;
9013 }
9014 rc = gpio_request(172, "HDMI_HPD");
9015 if (rc) {
9016 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9017 "HDMI_HPD", 172, rc);
9018 goto error3;
9019 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309020 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009021 } else {
9022 gpio_free(170);
9023 gpio_free(171);
9024 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309025 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009026 }
9027
9028 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009029 return 0;
9030
9031error3:
9032 gpio_free(171);
9033error2:
9034 gpio_free(170);
9035error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009036 return rc;
9037}
9038
9039static int hdmi_cec_power(int on)
9040{
9041 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9042 static int prev_on;
9043 int rc;
9044
9045 if (on == prev_on)
9046 return 0;
9047
9048 if (!reg_8901_l3)
9049 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9050
9051 if (on) {
9052 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9053 if (!rc)
9054 rc = regulator_enable(reg_8901_l3);
9055 if (rc) {
9056 pr_err("'%s' regulator enable failed, rc=%d\n",
9057 "8901_l3", rc);
9058 return rc;
9059 }
9060 rc = gpio_request(169, "HDMI_CEC_VAR");
9061 if (rc) {
9062 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9063 "HDMI_CEC_VAR", 169, rc);
9064 goto error;
9065 }
9066 pr_info("%s(on): success\n", __func__);
9067 } else {
9068 gpio_free(169);
9069 rc = regulator_disable(reg_8901_l3);
9070 if (rc)
9071 pr_warning("'%s' regulator disable failed, rc=%d\n",
9072 "8901_l3", rc);
9073 pr_info("%s(off): success\n", __func__);
9074 }
9075
9076 prev_on = on;
9077
9078 return 0;
9079error:
9080 regulator_disable(reg_8901_l3);
9081 return rc;
9082}
9083
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309084static int hdmi_panel_power(int on)
9085{
9086 int rc;
9087
9088 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9089 rc = hdmi_core_power(on, 1);
9090 if (rc)
9091 rc = hdmi_cec_power(on);
9092
9093 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9094 return rc;
9095}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009096#undef _GET_REGULATOR
9097
9098#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9099
9100static int lcdc_panel_power(int on)
9101{
9102 int flag_on = !!on;
9103 static int lcdc_power_save_on;
9104
9105 if (lcdc_power_save_on == flag_on)
9106 return 0;
9107
9108 lcdc_power_save_on = flag_on;
9109
9110 lcdc_samsung_panel_power(on);
9111
9112 return 0;
9113}
9114
9115#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009116
9117static struct msm_bus_vectors rotator_init_vectors[] = {
9118 {
9119 .src = MSM_BUS_MASTER_ROTATOR,
9120 .dst = MSM_BUS_SLAVE_SMI,
9121 .ab = 0,
9122 .ib = 0,
9123 },
9124 {
9125 .src = MSM_BUS_MASTER_ROTATOR,
9126 .dst = MSM_BUS_SLAVE_EBI_CH0,
9127 .ab = 0,
9128 .ib = 0,
9129 },
9130};
9131
9132static struct msm_bus_vectors rotator_ui_vectors[] = {
9133 {
9134 .src = MSM_BUS_MASTER_ROTATOR,
9135 .dst = MSM_BUS_SLAVE_SMI,
9136 .ab = 0,
9137 .ib = 0,
9138 },
9139 {
9140 .src = MSM_BUS_MASTER_ROTATOR,
9141 .dst = MSM_BUS_SLAVE_EBI_CH0,
9142 .ab = (1024 * 600 * 4 * 2 * 60),
9143 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9144 },
9145};
9146
9147static struct msm_bus_vectors rotator_vga_vectors[] = {
9148 {
9149 .src = MSM_BUS_MASTER_ROTATOR,
9150 .dst = MSM_BUS_SLAVE_SMI,
9151 .ab = (640 * 480 * 2 * 2 * 30),
9152 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9153 },
9154 {
9155 .src = MSM_BUS_MASTER_ROTATOR,
9156 .dst = MSM_BUS_SLAVE_EBI_CH0,
9157 .ab = (640 * 480 * 2 * 2 * 30),
9158 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9159 },
9160};
9161
9162static struct msm_bus_vectors rotator_720p_vectors[] = {
9163 {
9164 .src = MSM_BUS_MASTER_ROTATOR,
9165 .dst = MSM_BUS_SLAVE_SMI,
9166 .ab = (1280 * 736 * 2 * 2 * 30),
9167 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9168 },
9169 {
9170 .src = MSM_BUS_MASTER_ROTATOR,
9171 .dst = MSM_BUS_SLAVE_EBI_CH0,
9172 .ab = (1280 * 736 * 2 * 2 * 30),
9173 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9174 },
9175};
9176
9177static struct msm_bus_vectors rotator_1080p_vectors[] = {
9178 {
9179 .src = MSM_BUS_MASTER_ROTATOR,
9180 .dst = MSM_BUS_SLAVE_SMI,
9181 .ab = (1920 * 1088 * 2 * 2 * 30),
9182 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9183 },
9184 {
9185 .src = MSM_BUS_MASTER_ROTATOR,
9186 .dst = MSM_BUS_SLAVE_EBI_CH0,
9187 .ab = (1920 * 1088 * 2 * 2 * 30),
9188 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9189 },
9190};
9191
9192static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9193 {
9194 ARRAY_SIZE(rotator_init_vectors),
9195 rotator_init_vectors,
9196 },
9197 {
9198 ARRAY_SIZE(rotator_ui_vectors),
9199 rotator_ui_vectors,
9200 },
9201 {
9202 ARRAY_SIZE(rotator_vga_vectors),
9203 rotator_vga_vectors,
9204 },
9205 {
9206 ARRAY_SIZE(rotator_720p_vectors),
9207 rotator_720p_vectors,
9208 },
9209 {
9210 ARRAY_SIZE(rotator_1080p_vectors),
9211 rotator_1080p_vectors,
9212 },
9213};
9214
9215struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9216 rotator_bus_scale_usecases,
9217 ARRAY_SIZE(rotator_bus_scale_usecases),
9218 .name = "rotator",
9219};
9220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009221static struct msm_bus_vectors mdp_init_vectors[] = {
9222 /* For now, 0th array entry is reserved.
9223 * Please leave 0 as is and don't use it
9224 */
9225 {
9226 .src = MSM_BUS_MASTER_MDP_PORT0,
9227 .dst = MSM_BUS_SLAVE_SMI,
9228 .ab = 0,
9229 .ib = 0,
9230 },
9231 /* Master and slaves can be from different fabrics */
9232 {
9233 .src = MSM_BUS_MASTER_MDP_PORT0,
9234 .dst = MSM_BUS_SLAVE_EBI_CH0,
9235 .ab = 0,
9236 .ib = 0,
9237 },
9238};
9239
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009240#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009241static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9242 /* Default case static display/UI/2d/3d if FB SMI */
9243 {
9244 .src = MSM_BUS_MASTER_MDP_PORT0,
9245 .dst = MSM_BUS_SLAVE_SMI,
9246 .ab = 388800000,
9247 .ib = 486000000,
9248 },
9249 /* Master and slaves can be from different fabrics */
9250 {
9251 .src = MSM_BUS_MASTER_MDP_PORT0,
9252 .dst = MSM_BUS_SLAVE_EBI_CH0,
9253 .ab = 0,
9254 .ib = 0,
9255 },
9256};
9257
9258static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9259 /* Default case static display/UI/2d/3d if FB SMI */
9260 {
9261 .src = MSM_BUS_MASTER_MDP_PORT0,
9262 .dst = MSM_BUS_SLAVE_SMI,
9263 .ab = 0,
9264 .ib = 0,
9265 },
9266 /* Master and slaves can be from different fabrics */
9267 {
9268 .src = MSM_BUS_MASTER_MDP_PORT0,
9269 .dst = MSM_BUS_SLAVE_EBI_CH0,
9270 .ab = 388800000,
9271 .ib = 486000000 * 2,
9272 },
9273};
9274static struct msm_bus_vectors mdp_vga_vectors[] = {
9275 /* VGA and less video */
9276 {
9277 .src = MSM_BUS_MASTER_MDP_PORT0,
9278 .dst = MSM_BUS_SLAVE_SMI,
9279 .ab = 458092800,
9280 .ib = 572616000,
9281 },
9282 {
9283 .src = MSM_BUS_MASTER_MDP_PORT0,
9284 .dst = MSM_BUS_SLAVE_EBI_CH0,
9285 .ab = 458092800,
9286 .ib = 572616000 * 2,
9287 },
9288};
9289static struct msm_bus_vectors mdp_720p_vectors[] = {
9290 /* 720p and less video */
9291 {
9292 .src = MSM_BUS_MASTER_MDP_PORT0,
9293 .dst = MSM_BUS_SLAVE_SMI,
9294 .ab = 471744000,
9295 .ib = 589680000,
9296 },
9297 /* Master and slaves can be from different fabrics */
9298 {
9299 .src = MSM_BUS_MASTER_MDP_PORT0,
9300 .dst = MSM_BUS_SLAVE_EBI_CH0,
9301 .ab = 471744000,
9302 .ib = 589680000 * 2,
9303 },
9304};
9305
9306static struct msm_bus_vectors mdp_1080p_vectors[] = {
9307 /* 1080p and less video */
9308 {
9309 .src = MSM_BUS_MASTER_MDP_PORT0,
9310 .dst = MSM_BUS_SLAVE_SMI,
9311 .ab = 575424000,
9312 .ib = 719280000,
9313 },
9314 /* Master and slaves can be from different fabrics */
9315 {
9316 .src = MSM_BUS_MASTER_MDP_PORT0,
9317 .dst = MSM_BUS_SLAVE_EBI_CH0,
9318 .ab = 575424000,
9319 .ib = 719280000 * 2,
9320 },
9321};
9322
9323#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009324static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9325 /* Default case static display/UI/2d/3d if FB SMI */
9326 {
9327 .src = MSM_BUS_MASTER_MDP_PORT0,
9328 .dst = MSM_BUS_SLAVE_SMI,
9329 .ab = 175110000,
9330 .ib = 218887500,
9331 },
9332 /* Master and slaves can be from different fabrics */
9333 {
9334 .src = MSM_BUS_MASTER_MDP_PORT0,
9335 .dst = MSM_BUS_SLAVE_EBI_CH0,
9336 .ab = 0,
9337 .ib = 0,
9338 },
9339};
9340
9341static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9342 /* Default case static display/UI/2d/3d if FB SMI */
9343 {
9344 .src = MSM_BUS_MASTER_MDP_PORT0,
9345 .dst = MSM_BUS_SLAVE_SMI,
9346 .ab = 0,
9347 .ib = 0,
9348 },
9349 /* Master and slaves can be from different fabrics */
9350 {
9351 .src = MSM_BUS_MASTER_MDP_PORT0,
9352 .dst = MSM_BUS_SLAVE_EBI_CH0,
9353 .ab = 216000000,
9354 .ib = 270000000 * 2,
9355 },
9356};
9357static struct msm_bus_vectors mdp_vga_vectors[] = {
9358 /* VGA and less video */
9359 {
9360 .src = MSM_BUS_MASTER_MDP_PORT0,
9361 .dst = MSM_BUS_SLAVE_SMI,
9362 .ab = 216000000,
9363 .ib = 270000000,
9364 },
9365 {
9366 .src = MSM_BUS_MASTER_MDP_PORT0,
9367 .dst = MSM_BUS_SLAVE_EBI_CH0,
9368 .ab = 216000000,
9369 .ib = 270000000 * 2,
9370 },
9371};
9372
9373static struct msm_bus_vectors mdp_720p_vectors[] = {
9374 /* 720p and less video */
9375 {
9376 .src = MSM_BUS_MASTER_MDP_PORT0,
9377 .dst = MSM_BUS_SLAVE_SMI,
9378 .ab = 230400000,
9379 .ib = 288000000,
9380 },
9381 /* Master and slaves can be from different fabrics */
9382 {
9383 .src = MSM_BUS_MASTER_MDP_PORT0,
9384 .dst = MSM_BUS_SLAVE_EBI_CH0,
9385 .ab = 230400000,
9386 .ib = 288000000 * 2,
9387 },
9388};
9389
9390static struct msm_bus_vectors mdp_1080p_vectors[] = {
9391 /* 1080p and less video */
9392 {
9393 .src = MSM_BUS_MASTER_MDP_PORT0,
9394 .dst = MSM_BUS_SLAVE_SMI,
9395 .ab = 334080000,
9396 .ib = 417600000,
9397 },
9398 /* Master and slaves can be from different fabrics */
9399 {
9400 .src = MSM_BUS_MASTER_MDP_PORT0,
9401 .dst = MSM_BUS_SLAVE_EBI_CH0,
9402 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009403 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009404 },
9405};
9406
9407#endif
9408static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9409 {
9410 ARRAY_SIZE(mdp_init_vectors),
9411 mdp_init_vectors,
9412 },
9413 {
9414 ARRAY_SIZE(mdp_sd_smi_vectors),
9415 mdp_sd_smi_vectors,
9416 },
9417 {
9418 ARRAY_SIZE(mdp_sd_ebi_vectors),
9419 mdp_sd_ebi_vectors,
9420 },
9421 {
9422 ARRAY_SIZE(mdp_vga_vectors),
9423 mdp_vga_vectors,
9424 },
9425 {
9426 ARRAY_SIZE(mdp_720p_vectors),
9427 mdp_720p_vectors,
9428 },
9429 {
9430 ARRAY_SIZE(mdp_1080p_vectors),
9431 mdp_1080p_vectors,
9432 },
9433};
9434static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9435 mdp_bus_scale_usecases,
9436 ARRAY_SIZE(mdp_bus_scale_usecases),
9437 .name = "mdp",
9438};
9439
9440#endif
9441#ifdef CONFIG_MSM_BUS_SCALING
9442static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9443 /* For now, 0th array entry is reserved.
9444 * Please leave 0 as is and don't use it
9445 */
9446 {
9447 .src = MSM_BUS_MASTER_MDP_PORT0,
9448 .dst = MSM_BUS_SLAVE_SMI,
9449 .ab = 0,
9450 .ib = 0,
9451 },
9452 /* Master and slaves can be from different fabrics */
9453 {
9454 .src = MSM_BUS_MASTER_MDP_PORT0,
9455 .dst = MSM_BUS_SLAVE_EBI_CH0,
9456 .ab = 0,
9457 .ib = 0,
9458 },
9459};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009460
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009461static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9462 /* For now, 0th array entry is reserved.
9463 * Please leave 0 as is and don't use it
9464 */
9465 {
9466 .src = MSM_BUS_MASTER_MDP_PORT0,
9467 .dst = MSM_BUS_SLAVE_SMI,
9468 .ab = 566092800,
9469 .ib = 707616000,
9470 },
9471 /* Master and slaves can be from different fabrics */
9472 {
9473 .src = MSM_BUS_MASTER_MDP_PORT0,
9474 .dst = MSM_BUS_SLAVE_EBI_CH0,
9475 .ab = 566092800,
9476 .ib = 707616000,
9477 },
9478};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009479
9480static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9481 /* For now, 0th array entry is reserved.
9482 * Please leave 0 as is and don't use it
9483 */
9484 {
9485 .src = MSM_BUS_MASTER_MDP_PORT0,
9486 .dst = MSM_BUS_SLAVE_SMI,
9487 .ab = 2000000000,
9488 .ib = 2000000000,
9489 },
9490 /* Master and slaves can be from different fabrics */
9491 {
9492 .src = MSM_BUS_MASTER_MDP_PORT0,
9493 .dst = MSM_BUS_SLAVE_EBI_CH0,
9494 .ab = 2000000000,
9495 .ib = 2000000000,
9496 },
9497};
9498
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009499static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9500 {
9501 ARRAY_SIZE(dtv_bus_init_vectors),
9502 dtv_bus_init_vectors,
9503 },
9504 {
9505 ARRAY_SIZE(dtv_bus_def_vectors),
9506 dtv_bus_def_vectors,
9507 },
9508};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009509
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009510static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9511 dtv_bus_scale_usecases,
9512 ARRAY_SIZE(dtv_bus_scale_usecases),
9513 .name = "dtv",
9514};
9515
9516static struct lcdc_platform_data dtv_pdata = {
9517 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309518 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009519};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009520
9521static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9522 {
9523 ARRAY_SIZE(dtv_bus_init_vectors),
9524 dtv_bus_init_vectors,
9525 },
9526 {
9527 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9528 dtv_bus_hdmi_prim_vectors,
9529 },
9530};
9531
9532static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9533 dtv_hdmi_prim_bus_scale_usecases,
9534 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9535 .name = "dtv",
9536};
9537
9538static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9539 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9540};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009541#endif
9542
9543
9544static struct lcdc_platform_data lcdc_pdata = {
9545 .lcdc_power_save = lcdc_panel_power,
9546};
9547
9548
9549#define MDP_VSYNC_GPIO 28
9550
9551/*
9552 * MIPI_DSI only use 8058_LDO0 which need always on
9553 * therefore it need to be put at low power mode if
9554 * it was not used instead of turn it off.
9555 */
9556static int mipi_dsi_panel_power(int on)
9557{
9558 int flag_on = !!on;
9559 static int mipi_dsi_power_save_on;
9560 static struct regulator *ldo0;
9561 int rc = 0;
9562
9563 if (mipi_dsi_power_save_on == flag_on)
9564 return 0;
9565
9566 mipi_dsi_power_save_on = flag_on;
9567
9568 if (ldo0 == NULL) { /* init */
9569 ldo0 = regulator_get(NULL, "8058_l0");
9570 if (IS_ERR(ldo0)) {
9571 pr_debug("%s: LDO0 failed\n", __func__);
9572 rc = PTR_ERR(ldo0);
9573 return rc;
9574 }
9575
9576 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9577 if (rc)
9578 goto out;
9579
9580 rc = regulator_enable(ldo0);
9581 if (rc)
9582 goto out;
9583 }
9584
9585 if (on) {
9586 /* set ldo0 to HPM */
9587 rc = regulator_set_optimum_mode(ldo0, 100000);
9588 if (rc < 0)
9589 goto out;
9590 } else {
9591 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309592 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009593 if (rc < 0)
9594 goto out;
9595 }
9596
9597 return 0;
9598out:
9599 regulator_disable(ldo0);
9600 regulator_put(ldo0);
9601 ldo0 = NULL;
9602 return rc;
9603}
9604
9605static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9606 .vsync_gpio = MDP_VSYNC_GPIO,
9607 .dsi_power_save = mipi_dsi_panel_power,
9608};
9609
9610#ifdef CONFIG_FB_MSM_TVOUT
9611static struct regulator *reg_8058_l13;
9612
9613static int atv_dac_power(int on)
9614{
9615 int rc = 0;
9616 #define _GET_REGULATOR(var, name) do { \
9617 var = regulator_get(NULL, name); \
9618 if (IS_ERR(var)) { \
9619 pr_info("'%s' regulator not found, rc=%ld\n", \
9620 name, IS_ERR(var)); \
9621 var = NULL; \
9622 return -ENODEV; \
9623 } \
9624 } while (0)
9625
9626 if (!reg_8058_l13)
9627 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9628 #undef _GET_REGULATOR
9629
9630 if (on) {
9631 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9632 if (rc) {
9633 pr_info("%s: '%s' regulator set voltage failed,\
9634 rc=%d\n", __func__, "8058_l13", rc);
9635 return rc;
9636 }
9637
9638 rc = regulator_enable(reg_8058_l13);
9639 if (rc) {
9640 pr_err("%s: '%s' regulator enable failed,\
9641 rc=%d\n", __func__, "8058_l13", rc);
9642 return rc;
9643 }
9644 } else {
9645 rc = regulator_force_disable(reg_8058_l13);
9646 if (rc)
9647 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9648 __func__, "8058_l13", rc);
9649 }
9650 return rc;
9651
9652}
9653#endif
9654
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009655static struct msm_panel_common_pdata mdp_pdata = {
9656 .gpio = MDP_VSYNC_GPIO,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009657 .mdp_max_clk = 200000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009658#ifdef CONFIG_MSM_BUS_SCALING
9659 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9660#endif
9661 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009662#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009663 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009664#else
9665 .mem_hid = MEMTYPE_EBI1,
9666#endif
Olav Hauganef95ae32012-05-15 09:50:30 -07009667 .mdp_iommu_split_domain = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009668};
9669
Huaibin Yanga5419422011-12-08 23:52:10 -08009670static void __init reserve_mdp_memory(void)
9671{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009672 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9673 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9674#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9675 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9676 mdp_pdata.ov0_wb_size;
9677 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9678 mdp_pdata.ov1_wb_size;
9679#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009680}
9681
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009682#ifdef CONFIG_FB_MSM_TVOUT
9683
9684#ifdef CONFIG_MSM_BUS_SCALING
9685static struct msm_bus_vectors atv_bus_init_vectors[] = {
9686 /* For now, 0th array entry is reserved.
9687 * Please leave 0 as is and don't use it
9688 */
9689 {
9690 .src = MSM_BUS_MASTER_MDP_PORT0,
9691 .dst = MSM_BUS_SLAVE_SMI,
9692 .ab = 0,
9693 .ib = 0,
9694 },
9695 /* Master and slaves can be from different fabrics */
9696 {
9697 .src = MSM_BUS_MASTER_MDP_PORT0,
9698 .dst = MSM_BUS_SLAVE_EBI_CH0,
9699 .ab = 0,
9700 .ib = 0,
9701 },
9702};
9703static struct msm_bus_vectors atv_bus_def_vectors[] = {
9704 /* For now, 0th array entry is reserved.
9705 * Please leave 0 as is and don't use it
9706 */
9707 {
9708 .src = MSM_BUS_MASTER_MDP_PORT0,
9709 .dst = MSM_BUS_SLAVE_SMI,
9710 .ab = 236390400,
9711 .ib = 265939200,
9712 },
9713 /* Master and slaves can be from different fabrics */
9714 {
9715 .src = MSM_BUS_MASTER_MDP_PORT0,
9716 .dst = MSM_BUS_SLAVE_EBI_CH0,
9717 .ab = 236390400,
9718 .ib = 265939200,
9719 },
9720};
9721static struct msm_bus_paths atv_bus_scale_usecases[] = {
9722 {
9723 ARRAY_SIZE(atv_bus_init_vectors),
9724 atv_bus_init_vectors,
9725 },
9726 {
9727 ARRAY_SIZE(atv_bus_def_vectors),
9728 atv_bus_def_vectors,
9729 },
9730};
9731static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9732 atv_bus_scale_usecases,
9733 ARRAY_SIZE(atv_bus_scale_usecases),
9734 .name = "atv",
9735};
9736#endif
9737
9738static struct tvenc_platform_data atv_pdata = {
9739 .poll = 0,
9740 .pm_vid_en = atv_dac_power,
9741#ifdef CONFIG_MSM_BUS_SCALING
9742 .bus_scale_table = &atv_bus_scale_pdata,
9743#endif
9744};
9745#endif
9746
9747static void __init msm_fb_add_devices(void)
9748{
9749#ifdef CONFIG_FB_MSM_LCDC_DSUB
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009750 mdp_pdata.mdp_max_clk = 200000000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009751#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -07009752 msm_fb_register_device("mdp", &mdp_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009753
9754 msm_fb_register_device("lcdc", &lcdc_pdata);
9755 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9756#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009757 if (hdmi_is_primary)
9758 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9759 else
9760 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009761#endif
9762#ifdef CONFIG_FB_MSM_TVOUT
9763 msm_fb_register_device("tvenc", &atv_pdata);
9764 msm_fb_register_device("tvout_device", NULL);
9765#endif
9766}
9767
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009768/**
9769 * Set MDP clocks to high frequency to avoid underflow when
9770 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9771 */
9772static void set_mdp_clocks_for_wuxga(void)
9773{
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009774 mdp_sd_smi_vectors[0].ab = 2000000000;
9775 mdp_sd_smi_vectors[0].ib = 2000000000;
9776 mdp_sd_smi_vectors[1].ab = 2000000000;
9777 mdp_sd_smi_vectors[1].ib = 2000000000;
9778
9779 mdp_sd_ebi_vectors[0].ab = 2000000000;
9780 mdp_sd_ebi_vectors[0].ib = 2000000000;
9781 mdp_sd_ebi_vectors[1].ab = 2000000000;
9782 mdp_sd_ebi_vectors[1].ib = 2000000000;
9783
9784 mdp_vga_vectors[0].ab = 2000000000;
9785 mdp_vga_vectors[0].ib = 2000000000;
9786 mdp_vga_vectors[1].ab = 2000000000;
9787 mdp_vga_vectors[1].ib = 2000000000;
9788
9789 mdp_720p_vectors[0].ab = 2000000000;
9790 mdp_720p_vectors[0].ib = 2000000000;
9791 mdp_720p_vectors[1].ab = 2000000000;
9792 mdp_720p_vectors[1].ib = 2000000000;
9793
9794 mdp_1080p_vectors[0].ab = 2000000000;
9795 mdp_1080p_vectors[0].ib = 2000000000;
9796 mdp_1080p_vectors[1].ab = 2000000000;
9797 mdp_1080p_vectors[1].ib = 2000000000;
9798
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009799 mdp_pdata.mdp_max_clk = 200000000;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009800}
9801
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009802#if (defined(CONFIG_MARIMBA_CORE)) && \
9803 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9804
9805static const struct {
9806 char *name;
9807 int vmin;
9808 int vmax;
9809} bt_regs_info[] = {
9810 { "8058_s3", 1800000, 1800000 },
9811 { "8058_s2", 1300000, 1300000 },
9812 { "8058_l8", 2900000, 3050000 },
9813};
9814
9815static struct {
9816 bool enabled;
9817} bt_regs_status[] = {
9818 { false },
9819 { false },
9820 { false },
9821};
9822static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9823
9824static int bahama_bt(int on)
9825{
9826 int rc;
9827 int i;
9828 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9829
9830 struct bahama_variant_register {
9831 const size_t size;
9832 const struct bahama_config_register *set;
9833 };
9834
9835 const struct bahama_config_register *p;
9836
9837 u8 version;
9838
9839 const struct bahama_config_register v10_bt_on[] = {
9840 { 0xE9, 0x00, 0xFF },
9841 { 0xF4, 0x80, 0xFF },
9842 { 0xE4, 0x00, 0xFF },
9843 { 0xE5, 0x00, 0x0F },
9844#ifdef CONFIG_WLAN
9845 { 0xE6, 0x38, 0x7F },
9846 { 0xE7, 0x06, 0xFF },
9847#endif
9848 { 0xE9, 0x21, 0xFF },
9849 { 0x01, 0x0C, 0x1F },
9850 { 0x01, 0x08, 0x1F },
9851 };
9852
9853 const struct bahama_config_register v20_bt_on_fm_off[] = {
9854 { 0x11, 0x0C, 0xFF },
9855 { 0x13, 0x01, 0xFF },
9856 { 0xF4, 0x80, 0xFF },
9857 { 0xF0, 0x00, 0xFF },
9858 { 0xE9, 0x00, 0xFF },
9859#ifdef CONFIG_WLAN
9860 { 0x81, 0x00, 0x7F },
9861 { 0x82, 0x00, 0xFF },
9862 { 0xE6, 0x38, 0x7F },
9863 { 0xE7, 0x06, 0xFF },
9864#endif
9865 { 0xE9, 0x21, 0xFF },
9866 };
9867
9868 const struct bahama_config_register v20_bt_on_fm_on[] = {
9869 { 0x11, 0x0C, 0xFF },
9870 { 0x13, 0x01, 0xFF },
9871 { 0xF4, 0x86, 0xFF },
9872 { 0xF0, 0x06, 0xFF },
9873 { 0xE9, 0x00, 0xFF },
9874#ifdef CONFIG_WLAN
9875 { 0x81, 0x00, 0x7F },
9876 { 0x82, 0x00, 0xFF },
9877 { 0xE6, 0x38, 0x7F },
9878 { 0xE7, 0x06, 0xFF },
9879#endif
9880 { 0xE9, 0x21, 0xFF },
9881 };
9882
9883 const struct bahama_config_register v10_bt_off[] = {
9884 { 0xE9, 0x00, 0xFF },
9885 };
9886
9887 const struct bahama_config_register v20_bt_off_fm_off[] = {
9888 { 0xF4, 0x84, 0xFF },
9889 { 0xF0, 0x04, 0xFF },
9890 { 0xE9, 0x00, 0xFF }
9891 };
9892
9893 const struct bahama_config_register v20_bt_off_fm_on[] = {
9894 { 0xF4, 0x86, 0xFF },
9895 { 0xF0, 0x06, 0xFF },
9896 { 0xE9, 0x00, 0xFF }
9897 };
9898 const struct bahama_variant_register bt_bahama[2][3] = {
9899 {
9900 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9901 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9902 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9903 },
9904 {
9905 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9906 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9907 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9908 }
9909 };
9910
9911 u8 offset = 0; /* index into bahama configs */
9912
9913 on = on ? 1 : 0;
9914 version = read_bahama_ver();
9915
9916 if (version == VER_UNSUPPORTED) {
9917 dev_err(&msm_bt_power_device.dev,
9918 "%s: unsupported version\n",
9919 __func__);
9920 return -EIO;
9921 }
9922
9923 if (version == VER_2_0) {
9924 if (marimba_get_fm_status(&config))
9925 offset = 0x01;
9926 }
9927
9928 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9929 if (on && (version == VER_2_0)) {
9930 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9931 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9932 && (bt_regs_status[i].enabled == true)) {
9933 if (regulator_disable(bt_regs[i])) {
9934 dev_err(&msm_bt_power_device.dev,
9935 "%s: regulator disable failed",
9936 __func__);
9937 }
9938 bt_regs_status[i].enabled = false;
9939 break;
9940 }
9941 }
9942 }
9943
9944 p = bt_bahama[on][version + offset].set;
9945
9946 dev_info(&msm_bt_power_device.dev,
9947 "%s: found version %d\n", __func__, version);
9948
9949 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9950 u8 value = (p+i)->value;
9951 rc = marimba_write_bit_mask(&config,
9952 (p+i)->reg,
9953 &value,
9954 sizeof((p+i)->value),
9955 (p+i)->mask);
9956 if (rc < 0) {
9957 dev_err(&msm_bt_power_device.dev,
9958 "%s: reg %d write failed: %d\n",
9959 __func__, (p+i)->reg, rc);
9960 return rc;
9961 }
9962 dev_dbg(&msm_bt_power_device.dev,
9963 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9964 __func__, (p+i)->reg,
9965 value, (p+i)->mask);
9966 }
9967 /* Update BT Status */
9968 if (on)
9969 marimba_set_bt_status(&config, true);
9970 else
9971 marimba_set_bt_status(&config, false);
9972
9973 return 0;
9974}
9975
9976static int bluetooth_use_regulators(int on)
9977{
9978 int i, recover = -1, rc = 0;
9979
9980 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9981 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9982 bt_regs_info[i].name) :
9983 (regulator_put(bt_regs[i]), NULL);
9984 if (IS_ERR(bt_regs[i])) {
9985 rc = PTR_ERR(bt_regs[i]);
9986 dev_err(&msm_bt_power_device.dev,
9987 "regulator %s get failed (%d)\n",
9988 bt_regs_info[i].name, rc);
9989 recover = i - 1;
9990 bt_regs[i] = NULL;
9991 break;
9992 }
9993
9994 if (!on)
9995 continue;
9996
9997 rc = regulator_set_voltage(bt_regs[i],
9998 bt_regs_info[i].vmin,
9999 bt_regs_info[i].vmax);
10000 if (rc < 0) {
10001 dev_err(&msm_bt_power_device.dev,
10002 "regulator %s voltage set (%d)\n",
10003 bt_regs_info[i].name, rc);
10004 recover = i;
10005 break;
10006 }
10007 }
10008
10009 if (on && (recover > -1))
10010 for (i = recover; i >= 0; i--) {
10011 regulator_put(bt_regs[i]);
10012 bt_regs[i] = NULL;
10013 }
10014
10015 return rc;
10016}
10017
10018static int bluetooth_switch_regulators(int on)
10019{
10020 int i, rc = 0;
10021
10022 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10023 if (on && (bt_regs_status[i].enabled == false)) {
10024 rc = regulator_enable(bt_regs[i]);
10025 if (rc < 0) {
10026 dev_err(&msm_bt_power_device.dev,
10027 "regulator %s %s failed (%d)\n",
10028 bt_regs_info[i].name,
10029 "enable", rc);
10030 if (i > 0) {
10031 while (--i) {
10032 regulator_disable(bt_regs[i]);
10033 bt_regs_status[i].enabled
10034 = false;
10035 }
10036 break;
10037 }
10038 }
10039 bt_regs_status[i].enabled = true;
10040 } else if (!on && (bt_regs_status[i].enabled == true)) {
10041 rc = regulator_disable(bt_regs[i]);
10042 if (rc < 0) {
10043 dev_err(&msm_bt_power_device.dev,
10044 "regulator %s %s failed (%d)\n",
10045 bt_regs_info[i].name,
10046 "disable", rc);
10047 break;
10048 }
10049 bt_regs_status[i].enabled = false;
10050 }
10051 }
10052 return rc;
10053}
10054
10055static struct msm_xo_voter *bt_clock;
10056
10057static int bluetooth_power(int on)
10058{
10059 int rc = 0;
10060 int id;
10061
10062 /* In case probe function fails, cur_connv_type would be -1 */
10063 id = adie_get_detected_connectivity_type();
10064 if (id != BAHAMA_ID) {
10065 pr_err("%s: unexpected adie connectivity type: %d\n",
10066 __func__, id);
10067 return -ENODEV;
10068 }
10069
10070 if (on) {
10071
10072 rc = bluetooth_use_regulators(1);
10073 if (rc < 0)
10074 goto out;
10075
10076 rc = bluetooth_switch_regulators(1);
10077
10078 if (rc < 0)
10079 goto fail_put;
10080
10081 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10082
10083 if (IS_ERR(bt_clock)) {
10084 pr_err("Couldn't get TCXO_D0 voter\n");
10085 goto fail_switch;
10086 }
10087
10088 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10089
10090 if (rc < 0) {
10091 pr_err("Failed to vote for TCXO_DO ON\n");
10092 goto fail_vote;
10093 }
10094
10095 rc = bahama_bt(1);
10096
10097 if (rc < 0)
10098 goto fail_clock;
10099
10100 msleep(10);
10101
10102 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10103
10104 if (rc < 0) {
10105 pr_err("Failed to vote for TCXO_DO pin control\n");
10106 goto fail_vote;
10107 }
10108 } else {
10109 /* check for initial RFKILL block (power off) */
10110 /* some RFKILL versions/configurations rfkill_register */
10111 /* calls here for an initial set_block */
10112 /* avoid calling i2c and regulator before unblock (on) */
10113 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10114 dev_info(&msm_bt_power_device.dev,
10115 "%s: initialized OFF/blocked\n", __func__);
10116 goto out;
10117 }
10118
10119 bahama_bt(0);
10120
10121fail_clock:
10122 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10123fail_vote:
10124 msm_xo_put(bt_clock);
10125fail_switch:
10126 bluetooth_switch_regulators(0);
10127fail_put:
10128 bluetooth_use_regulators(0);
10129 }
10130
10131out:
10132 if (rc < 0)
10133 on = 0;
10134 dev_info(&msm_bt_power_device.dev,
10135 "Bluetooth power switch: state %d result %d\n", on, rc);
10136
10137 return rc;
10138}
10139
10140#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10141
10142static void __init msm8x60_cfg_smsc911x(void)
10143{
10144 smsc911x_resources[1].start =
10145 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10146 smsc911x_resources[1].end =
10147 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10148}
10149
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010150void msm_fusion_setup_pinctrl(void)
10151{
10152 struct msm_xo_voter *a1;
10153
10154 if (socinfo_get_platform_subtype() == 0x3) {
10155 /*
10156 * Vote for the A1 clock to be in pin control mode before
10157 * the external images are loaded.
10158 */
10159 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10160 BUG_ON(!a1);
10161 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10162 }
10163}
10164
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010165struct msm_board_data {
10166 struct msm_gpiomux_configs *gpiomux_cfgs;
10167};
10168
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010169static struct msm_board_data msm8x60_surf_board_data __initdata = {
10170 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10171};
10172
10173static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10174 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10175};
10176
10177static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10178 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10179};
10180
10181static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10182 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10183};
10184
10185static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10186 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10187};
10188
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010189static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10190 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10191};
10192
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010193static void __init msm8x60_init(struct msm_board_data *board_data)
10194{
10195 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010196#ifdef CONFIG_USB_EHCI_MSM_72K
10197 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10198 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10199 .level = PM8901_MPP_DIG_LEVEL_L5,
10200 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10201 };
10202#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010203 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010204
Rohit Vaswanib1cc4932012-07-23 21:30:11 -070010205 platform_device_register(&msm_gpio_device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010206 /*
10207 * Initialize RPM first as other drivers and devices may need
10208 * it for their initialization.
10209 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010210 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10211 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010212 if (msm_xo_init())
10213 pr_err("Failed to initialize XO votes\n");
10214
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010215 msm8x60_check_2d_hardware();
10216
10217 /* Change SPM handling of core 1 if PMM 8160 is present. */
10218 soc_platform_version = socinfo_get_platform_version();
10219 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10220 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10221 struct msm_spm_platform_data *spm_data;
10222
10223 spm_data = &msm_spm_data_v1[1];
10224 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10225 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10226
10227 spm_data = &msm_spm_data[1];
10228 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10229 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10230 }
10231
10232 /*
10233 * Initialize SPM before acpuclock as the latter calls into SPM
10234 * driver to set ACPU voltages.
10235 */
10236 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10237 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10238 else
10239 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10240
10241 /*
10242 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10243 * devices so that the RPM doesn't drop into a low power mode that an
10244 * un-reworked SURF cannot resume from.
10245 */
10246 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010247 int i;
10248
10249 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10250 if (rpm_regulator_init_data[i].id
10251 == RPM_VREG_ID_PM8901_L4
10252 || rpm_regulator_init_data[i].id
10253 == RPM_VREG_ID_PM8901_L6)
10254 rpm_regulator_init_data[i]
10255 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010256 }
10257
10258 /*
10259 * Disable regulator info printing so that regulator registration
10260 * messages do not enter the kmsg log.
10261 */
10262 regulator_suppress_info_printing();
10263
10264 /* Initialize regulators needed for clock_init. */
10265 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10266
Stephen Boydbb600ae2011-08-02 20:11:40 -070010267 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010268
10269 /* Buses need to be initialized before early-device registration
10270 * to get the platform data for fabrics.
10271 */
10272 msm8x60_init_buses();
10273 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010274
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010275 /*
10276 * Enable EBI2 only for boards which make use of it. Leave
10277 * it disabled for all others for additional power savings.
10278 */
10279 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010280 machine_is_msm8x60_fluid() ||
10281 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010282 msm8x60_init_ebi2();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010283 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10284 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010285#ifdef CONFIG_MSM_CAMERA_V4L2
10286 msm8x60_init_cam();
10287#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010288 msm8x60_init_mmc();
10289
Kevin Chan3be11612012-03-22 20:05:40 -070010290
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010291#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10292 msm8x60_init_pm8058_othc();
10293#endif
10294
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010295 if (machine_is_msm8x60_fluid())
10296 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10297 else if (machine_is_msm8x60_dragon())
10298 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10299 else
10300 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010301#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010302 /* Specify reset pin for OV9726 */
10303 if (machine_is_msm8x60_dragon()) {
10304 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10305 ov9726_sensor_8660_info.mount_angle = 270;
10306 }
Kevin Chan3be11612012-03-22 20:05:40 -070010307#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010308#ifdef CONFIG_BATTERY_MSM8X60
10309 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10310 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10311 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10312 platform_device_register(&msm_charger_device);
10313#endif
10314
10315 if (machine_is_msm8x60_dragon())
10316 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10317 if (!machine_is_msm8x60_fluid())
10318 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10319
10320 /* configure pmic leds */
10321 if (machine_is_msm8x60_fluid())
10322 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10323 else if (machine_is_msm8x60_dragon())
10324 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10325 else
10326 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10327
10328 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10329 machine_is_msm8x60_dragon()) {
10330 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10331 }
10332
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010333 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10334 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010335 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010336 msm8x60_cfg_smsc911x();
10337 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010338 platform_add_devices(msm8660_footswitch,
10339 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010340 platform_add_devices(surf_devices,
10341 ARRAY_SIZE(surf_devices));
10342
10343#ifdef CONFIG_MSM_DSPS
10344 if (machine_is_msm8x60_fluid()) {
10345 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10346 msm8x60_init_dsps();
10347 }
10348#endif
10349
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010350 pm8901_vreg_mpp0_init();
10351
10352 platform_device_register(&msm8x60_8901_mpp_vreg);
10353
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010354#ifdef CONFIG_USB_EHCI_MSM_72K
10355 /*
10356 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10357 * fluid
10358 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010359 if (machine_is_msm8x60_fluid())
10360 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10361 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010362#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010363
10364#ifdef CONFIG_SND_SOC_MSM8660_APQ
10365 if (machine_is_msm8x60_dragon())
10366 platform_add_devices(dragon_alsa_devices,
10367 ARRAY_SIZE(dragon_alsa_devices));
10368 else
10369#endif
10370 platform_add_devices(asoc_devices,
10371 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010372 }
10373#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010374 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10375 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010376 msm8x60_cfg_isp1763();
10377#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010378
10379 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10380 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10381
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010382
10383#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10384 if (machine_is_msm8x60_fluid())
10385 platform_device_register(&msm_gsbi10_qup_spi_device);
10386 else
10387 platform_device_register(&msm_gsbi1_qup_spi_device);
10388#endif
10389
Steve Mucklef132c6c2012-06-06 18:30:57 -070010390#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10391 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010392 if (machine_is_msm8x60_fluid())
10393 cyttsp_set_params();
10394#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -070010395 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010396 fixup_i2c_configs();
10397 register_i2c_devices();
10398
Terence Hampson1c73fef2011-07-19 17:10:49 -040010399 if (machine_is_msm8x60_dragon())
10400 smsc911x_config.reset_gpio
10401 = GPIO_ETHERNET_RESET_N_DRAGON;
10402
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010403 platform_device_register(&smsc911x_device);
10404
10405#if (defined(CONFIG_SPI_QUP)) && \
10406 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010407 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10408 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010409
10410 if (machine_is_msm8x60_fluid()) {
10411#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10412 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10413 spi_register_board_info(lcdc_samsung_spi_board_info,
10414 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10415 } else
10416#endif
10417 {
10418#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10419 spi_register_board_info(lcdc_auo_spi_board_info,
10420 ARRAY_SIZE(lcdc_auo_spi_board_info));
10421#endif
10422 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010423#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10424 } else if (machine_is_msm8x60_dragon()) {
10425 spi_register_board_info(lcdc_nt35582_spi_board_info,
10426 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10427#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010428 }
10429#endif
10430
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010431 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010432
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010433 pm8058_gpios_init();
10434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010435#ifdef CONFIG_SENSORS_MSM_ADC
10436 if (machine_is_msm8x60_fluid()) {
10437 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10438 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10439 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10440 msm_adc_pdata.gpio_config = APROC_CONFIG;
10441 else
10442 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10443 }
10444 msm_adc_pdata.target_hw = MSM_8x60;
10445#endif
10446#ifdef CONFIG_MSM8X60_AUDIO
10447 msm_snddev_init();
10448#endif
10449#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10450 if (machine_is_msm8x60_fluid())
10451 platform_device_register(&fluid_leds_gpio);
10452 else
10453 platform_device_register(&gpio_leds);
10454#endif
10455
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010456 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010457
10458 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10459 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010460}
10461
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010462static void __init msm8x60_surf_init(void)
10463{
10464 msm8x60_init(&msm8x60_surf_board_data);
10465}
10466
10467static void __init msm8x60_ffa_init(void)
10468{
10469 msm8x60_init(&msm8x60_ffa_board_data);
10470}
10471
10472static void __init msm8x60_fluid_init(void)
10473{
10474 msm8x60_init(&msm8x60_fluid_board_data);
10475}
10476
10477static void __init msm8x60_charm_surf_init(void)
10478{
10479 msm8x60_init(&msm8x60_charm_surf_board_data);
10480}
10481
10482static void __init msm8x60_charm_ffa_init(void)
10483{
10484 msm8x60_init(&msm8x60_charm_ffa_board_data);
10485}
10486
10487static void __init msm8x60_charm_init_early(void)
10488{
10489 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010490}
10491
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010492static void __init msm8x60_dragon_init(void)
10493{
10494 msm8x60_init(&msm8x60_dragon_board_data);
10495}
David Brown56e2d8a2011-08-04 02:01:02 -070010496
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010497MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10498 .map_io = msm8x60_map_io,
10499 .reserve = msm8x60_reserve,
10500 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010501 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010502 .init_machine = msm8x60_surf_init,
10503 .timer = &msm_timer,
10504 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010505 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010506MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010507
10508MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10509 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010510 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010511 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010512 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010513 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010514 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010515 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010516 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010517MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010518
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010519MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010520 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010521 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010522 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010523 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010524 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010525 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010526 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010527 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010528MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010529
10530MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10531 .map_io = msm8x60_map_io,
10532 .reserve = msm8x60_reserve,
10533 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010534 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010535 .init_machine = msm8x60_charm_surf_init,
10536 .timer = &msm_timer,
10537 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010538 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010539MACHINE_END
10540
10541MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10542 .map_io = msm8x60_map_io,
10543 .reserve = msm8x60_reserve,
10544 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010545 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010546 .init_machine = msm8x60_charm_ffa_init,
10547 .timer = &msm_timer,
10548 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010549 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010550MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010551
10552MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10553 .map_io = msm8x60_map_io,
10554 .reserve = msm8x60_reserve,
10555 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010556 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010557 .init_machine = msm8x60_dragon_init,
10558 .timer = &msm_timer,
10559 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010560 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010561MACHINE_END