blob: c6e20ca6c3b5dec6a65e5cbe80b92a8f5be6159f [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>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053025#include <linux/regulator/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>
38#include <linux/cyttsp.h>
39#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>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#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 Wagantall6d9ebee2011-08-26 12:15:24 -0700103#include "acpuclock.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 } \
271}
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
472/*
473 * The smc91x configuration varies depending on platform.
474 * The resources data structure is filled in at runtime.
475 */
476static struct resource smc91x_resources[] = {
477 [0] = {
478 .flags = IORESOURCE_MEM,
479 },
480 [1] = {
481 .flags = IORESOURCE_IRQ,
482 },
483};
484
485static struct platform_device smc91x_device = {
486 .name = "smc91x",
487 .id = 0,
488 .num_resources = ARRAY_SIZE(smc91x_resources),
489 .resource = smc91x_resources,
490};
491
492static struct resource smsc911x_resources[] = {
493 [0] = {
494 .flags = IORESOURCE_MEM,
495 .start = 0x1b800000,
496 .end = 0x1b8000ff
497 },
498 [1] = {
499 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
500 },
501};
502
503static struct smsc911x_platform_config smsc911x_config = {
504 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
505 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
506 .flags = SMSC911X_USE_16BIT,
507 .has_reset_gpio = 1,
508 .reset_gpio = GPIO_ETHERNET_RESET_N
509};
510
511static struct platform_device smsc911x_device = {
512 .name = "smsc911x",
513 .id = 0,
514 .num_resources = ARRAY_SIZE(smsc911x_resources),
515 .resource = smsc911x_resources,
516 .dev = {
517 .platform_data = &smsc911x_config
518 }
519};
520
521#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
522 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
523 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
524 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
525
526#define QCE_SIZE 0x10000
527#define QCE_0_BASE 0x18500000
528
529#define QCE_HW_KEY_SUPPORT 0
530#define QCE_SHA_HMAC_SUPPORT 0
531#define QCE_SHARE_CE_RESOURCE 2
532#define QCE_CE_SHARED 1
533
534static struct resource qcrypto_resources[] = {
535 [0] = {
536 .start = QCE_0_BASE,
537 .end = QCE_0_BASE + QCE_SIZE - 1,
538 .flags = IORESOURCE_MEM,
539 },
540 [1] = {
541 .name = "crypto_channels",
542 .start = DMOV_CE_IN_CHAN,
543 .end = DMOV_CE_OUT_CHAN,
544 .flags = IORESOURCE_DMA,
545 },
546 [2] = {
547 .name = "crypto_crci_in",
548 .start = DMOV_CE_IN_CRCI,
549 .end = DMOV_CE_IN_CRCI,
550 .flags = IORESOURCE_DMA,
551 },
552 [3] = {
553 .name = "crypto_crci_out",
554 .start = DMOV_CE_OUT_CRCI,
555 .end = DMOV_CE_OUT_CRCI,
556 .flags = IORESOURCE_DMA,
557 },
558 [4] = {
559 .name = "crypto_crci_hash",
560 .start = DMOV_CE_HASH_CRCI,
561 .end = DMOV_CE_HASH_CRCI,
562 .flags = IORESOURCE_DMA,
563 },
564};
565
566static struct resource qcedev_resources[] = {
567 [0] = {
568 .start = QCE_0_BASE,
569 .end = QCE_0_BASE + QCE_SIZE - 1,
570 .flags = IORESOURCE_MEM,
571 },
572 [1] = {
573 .name = "crypto_channels",
574 .start = DMOV_CE_IN_CHAN,
575 .end = DMOV_CE_OUT_CHAN,
576 .flags = IORESOURCE_DMA,
577 },
578 [2] = {
579 .name = "crypto_crci_in",
580 .start = DMOV_CE_IN_CRCI,
581 .end = DMOV_CE_IN_CRCI,
582 .flags = IORESOURCE_DMA,
583 },
584 [3] = {
585 .name = "crypto_crci_out",
586 .start = DMOV_CE_OUT_CRCI,
587 .end = DMOV_CE_OUT_CRCI,
588 .flags = IORESOURCE_DMA,
589 },
590 [4] = {
591 .name = "crypto_crci_hash",
592 .start = DMOV_CE_HASH_CRCI,
593 .end = DMOV_CE_HASH_CRCI,
594 .flags = IORESOURCE_DMA,
595 },
596};
597
598#endif
599
600#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
601 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
602
603static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
604 .ce_shared = QCE_CE_SHARED,
605 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
606 .hw_key_support = QCE_HW_KEY_SUPPORT,
607 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800608 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700609};
610
611static struct platform_device qcrypto_device = {
612 .name = "qcrypto",
613 .id = 0,
614 .num_resources = ARRAY_SIZE(qcrypto_resources),
615 .resource = qcrypto_resources,
616 .dev = {
617 .coherent_dma_mask = DMA_BIT_MASK(32),
618 .platform_data = &qcrypto_ce_hw_suppport,
619 },
620};
621#endif
622
623#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
624 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
625
626static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
627 .ce_shared = QCE_CE_SHARED,
628 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
629 .hw_key_support = QCE_HW_KEY_SUPPORT,
630 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800631 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700632};
633
634static struct platform_device qcedev_device = {
635 .name = "qce",
636 .id = 0,
637 .num_resources = ARRAY_SIZE(qcedev_resources),
638 .resource = qcedev_resources,
639 .dev = {
640 .coherent_dma_mask = DMA_BIT_MASK(32),
641 .platform_data = &qcedev_ce_hw_suppport,
642 },
643};
644#endif
645
646#if defined(CONFIG_HAPTIC_ISA1200) || \
647 defined(CONFIG_HAPTIC_ISA1200_MODULE)
648
649static const char *vregs_isa1200_name[] = {
650 "8058_s3",
651 "8901_l4",
652};
653
654static const int vregs_isa1200_val[] = {
655 1800000,/* uV */
656 2600000,
657};
658static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
659static struct msm_xo_voter *xo_handle_a1;
660
661static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800662{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700663 int i, rc = 0;
664
665 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
666 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
667 regulator_disable(vregs_isa1200[i]);
668 if (rc < 0) {
669 pr_err("%s: vreg %s %s failed (%d)\n",
670 __func__, vregs_isa1200_name[i],
671 vreg_on ? "enable" : "disable", rc);
672 goto vreg_fail;
673 }
674 }
675
676 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
677 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
678 if (rc < 0) {
679 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
680 __func__, vreg_on ? "" : "de-", rc);
681 goto vreg_fail;
682 }
683 return 0;
684
685vreg_fail:
686 while (i--)
687 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
688 regulator_disable(vregs_isa1200[i]);
689 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800690}
691
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800693{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700694 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800695
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700696 if (enable == true) {
697 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
698 vregs_isa1200[i] = regulator_get(NULL,
699 vregs_isa1200_name[i]);
700 if (IS_ERR(vregs_isa1200[i])) {
701 pr_err("%s: regulator get of %s failed (%ld)\n",
702 __func__, vregs_isa1200_name[i],
703 PTR_ERR(vregs_isa1200[i]));
704 rc = PTR_ERR(vregs_isa1200[i]);
705 goto vreg_get_fail;
706 }
707 rc = regulator_set_voltage(vregs_isa1200[i],
708 vregs_isa1200_val[i], vregs_isa1200_val[i]);
709 if (rc) {
710 pr_err("%s: regulator_set_voltage(%s) failed\n",
711 __func__, vregs_isa1200_name[i]);
712 goto vreg_get_fail;
713 }
714 }
Steve Muckle9161d302010-02-11 11:50:40 -0800715
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700716 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
717 if (rc) {
718 pr_err("%s: unable to request gpio %d (%d)\n",
719 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
720 goto vreg_get_fail;
721 }
Steve Muckle9161d302010-02-11 11:50:40 -0800722
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
724 if (rc) {
725 pr_err("%s: Unable to set direction\n", __func__);;
726 goto free_gpio;
727 }
728
729 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
730 if (IS_ERR(xo_handle_a1)) {
731 rc = PTR_ERR(xo_handle_a1);
732 pr_err("%s: failed to get the handle for A1(%d)\n",
733 __func__, rc);
734 goto gpio_set_dir;
735 }
736 } else {
737 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
738 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
739
740 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
741 regulator_put(vregs_isa1200[i]);
742
743 msm_xo_put(xo_handle_a1);
744 }
745
746 return 0;
747gpio_set_dir:
748 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
749free_gpio:
750 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
751vreg_get_fail:
752 while (i)
753 regulator_put(vregs_isa1200[--i]);
754 return rc;
755}
756
757#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530758#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700759static struct isa1200_platform_data isa1200_1_pdata = {
760 .name = "vibrator",
761 .power_on = isa1200_power,
762 .dev_setup = isa1200_dev_setup,
763 /*gpio to enable haptic*/
764 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530765 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700766 .max_timeout = 15000,
767 .mode_ctrl = PWM_GEN_MODE,
768 .pwm_fd = {
769 .pwm_div = 256,
770 },
771 .is_erm = false,
772 .smart_en = true,
773 .ext_clk_en = true,
774 .chip_en = 1,
775};
776
777static struct i2c_board_info msm_isa1200_board_info[] = {
778 {
779 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
780 .platform_data = &isa1200_1_pdata,
781 },
782};
783#endif
784
785#if defined(CONFIG_BATTERY_BQ27520) || \
786 defined(CONFIG_BATTERY_BQ27520_MODULE)
787static struct bq27520_platform_data bq27520_pdata = {
788 .name = "fuel-gauge",
789 .vreg_name = "8058_s3",
790 .vreg_value = 1800000,
791 .soc_int = GPIO_BATT_GAUGE_INT_N,
792 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
793 .chip_en = GPIO_BATT_GAUGE_EN,
794 .enable_dlog = 0, /* if enable coulomb counter logger */
795};
796
797static struct i2c_board_info msm_bq27520_board_info[] = {
798 {
799 I2C_BOARD_INFO("bq27520", 0xaa>>1),
800 .platform_data = &bq27520_pdata,
801 },
802};
803#endif
804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
806 {
807 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
808 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
809 true,
810 1, 8000, 100000, 1,
811 },
812
813 {
814 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
815 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
816 true,
817 1500, 5000, 60100000, 3000,
818 },
819
820 {
821 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
822 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
823 false,
824 1800, 5000, 60350000, 3500,
825 },
826 {
827 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
828 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
829 false,
830 3800, 4500, 65350000, 5500,
831 },
832
833 {
834 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
835 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
836 false,
837 2800, 2500, 66850000, 4800,
838 },
839
840 {
841 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
842 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
843 false,
844 4800, 2000, 71850000, 6800,
845 },
846
847 {
848 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
849 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
850 false,
851 6800, 500, 75850000, 8800,
852 },
853
854 {
855 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
856 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
857 false,
858 7800, 0, 76350000, 9800,
859 },
860};
861
Praveen Chidambaram78499012011-11-01 17:15:17 -0600862static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
863 .levels = &msm_rpmrs_levels[0],
864 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
865 .vdd_mem_levels = {
866 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
867 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
868 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700869 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600870 },
871 .vdd_dig_levels = {
872 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
873 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
874 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
875 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
876 },
877 .vdd_mask = 0xFFF,
878 .rpmrs_target_id = {
879 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
880 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
881 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
882 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
883 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
884 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
885 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
886 },
887};
888
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600889static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
890 .mode = MSM_PM_BOOT_CONFIG_TZ,
891};
892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700893#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
894
895#define ISP1763_INT_GPIO 117
896#define ISP1763_RST_GPIO 152
897static struct resource isp1763_resources[] = {
898 [0] = {
899 .flags = IORESOURCE_MEM,
900 .start = 0x1D000000,
901 .end = 0x1D005FFF, /* 24KB */
902 },
903 [1] = {
904 .flags = IORESOURCE_IRQ,
905 },
906};
907static void __init msm8x60_cfg_isp1763(void)
908{
909 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
910 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
911}
912
913static int isp1763_setup_gpio(int enable)
914{
915 int status = 0;
916
917 if (enable) {
918 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
919 if (status) {
920 pr_err("%s:Failed to request GPIO %d\n",
921 __func__, ISP1763_INT_GPIO);
922 return status;
923 }
924 status = gpio_direction_input(ISP1763_INT_GPIO);
925 if (status) {
926 pr_err("%s:Failed to configure GPIO %d\n",
927 __func__, ISP1763_INT_GPIO);
928 goto gpio_free_int;
929 }
930 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
931 if (status) {
932 pr_err("%s:Failed to request GPIO %d\n",
933 __func__, ISP1763_RST_GPIO);
934 goto gpio_free_int;
935 }
936 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
937 if (status) {
938 pr_err("%s:Failed to configure GPIO %d\n",
939 __func__, ISP1763_RST_GPIO);
940 goto gpio_free_rst;
941 }
942 pr_debug("\nISP GPIO configuration done\n");
943 return status;
944 }
945
946gpio_free_rst:
947 gpio_free(ISP1763_RST_GPIO);
948gpio_free_int:
949 gpio_free(ISP1763_INT_GPIO);
950
951 return status;
952}
953static struct isp1763_platform_data isp1763_pdata = {
954 .reset_gpio = ISP1763_RST_GPIO,
955 .setup_gpio = isp1763_setup_gpio
956};
957
958static struct platform_device isp1763_device = {
959 .name = "isp1763_usb",
960 .num_resources = ARRAY_SIZE(isp1763_resources),
961 .resource = isp1763_resources,
962 .dev = {
963 .platform_data = &isp1763_pdata
964 }
965};
966#endif
967
Lena Salman57d167e2012-03-21 19:46:38 +0200968#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530969static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700970static struct regulator *ldo6_3p3;
971static struct regulator *ldo7_1p8;
972static struct regulator *vdd_cx;
973#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530974#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700975notify_vbus_state notify_vbus_state_func_ptr;
976static int usb_phy_susp_dig_vol = 750000;
977static int pmic_id_notif_supported;
978
979#ifdef CONFIG_USB_EHCI_MSM_72K
980#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
981struct delayed_work pmic_id_det;
982
983static int __init usb_id_pin_rework_setup(char *support)
984{
985 if (strncmp(support, "true", 4) == 0)
986 pmic_id_notif_supported = 1;
987
988 return 1;
989}
990__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
991
992static void pmic_id_detect(struct work_struct *w)
993{
994 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
995 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
996
997 if (notify_vbus_state_func_ptr)
998 (*notify_vbus_state_func_ptr) (val);
999}
1000
1001static irqreturn_t pmic_id_on_irq(int irq, void *data)
1002{
1003 /*
1004 * Spurious interrupts are observed on pmic gpio line
1005 * even though there is no state change on USB ID. Schedule the
1006 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001007 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001008 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001010 return IRQ_HANDLED;
1011}
1012
Anji jonnalaae745e92011-11-14 18:34:31 +05301013static int msm_hsusb_phy_id_setup_init(int init)
1014{
1015 unsigned ret;
1016
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301017 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1018 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1019 .level = PM8901_MPP_DIG_LEVEL_L5,
1020 };
1021
Anji jonnalaae745e92011-11-14 18:34:31 +05301022 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301023 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1024 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1025 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301026 if (ret < 0)
1027 pr_err("%s:MPP2 configuration failed\n", __func__);
1028 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301029 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1030 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1031 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301032 if (ret < 0)
1033 pr_err("%s:MPP2 un config failed\n", __func__);
1034 }
1035 return ret;
1036}
1037
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001038static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1039{
1040 unsigned ret = -ENODEV;
1041
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301042 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301043 .direction = PM_GPIO_DIR_IN,
1044 .pull = PM_GPIO_PULL_UP_1P5,
1045 .function = PM_GPIO_FUNC_NORMAL,
1046 .vin_sel = 2,
1047 .inv_int_pol = 0,
1048 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301049 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301050 .direction = PM_GPIO_DIR_IN,
1051 .pull = PM_GPIO_PULL_NO,
1052 .function = PM_GPIO_FUNC_NORMAL,
1053 .vin_sel = 2,
1054 .inv_int_pol = 0,
1055 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001056 if (!callback)
1057 return -EINVAL;
1058
1059 if (machine_is_msm8x60_fluid())
1060 return -ENOTSUPP;
1061
1062 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1063 pr_debug("%s: USB_ID pin is not routed to PMIC"
1064 "on V1 surf/ffa\n", __func__);
1065 return -ENOTSUPP;
1066 }
1067
Manu Gautam62158eb2011-11-24 16:20:46 +05301068 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1069 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070 pr_debug("%s: USB_ID is not routed to PMIC"
1071 "on V2 ffa\n", __func__);
1072 return -ENOTSUPP;
1073 }
1074
1075 usb_phy_susp_dig_vol = 500000;
1076
1077 if (init) {
1078 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301079 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301080 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1081 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301082 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301083 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301084 __func__, ret);
1085 return ret;
1086 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001087 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1088 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1089 "msm_otg_id", NULL);
1090 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001091 pr_err("%s:pmic_usb_id interrupt registration failed",
1092 __func__);
1093 return ret;
1094 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301095 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001096 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301097 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001098 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301099 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1100 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301101 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301102 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301103 __func__, ret);
1104 return ret;
1105 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301106 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001107 cancel_delayed_work_sync(&pmic_id_det);
1108 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001109 }
1110 return 0;
1111}
1112#endif
1113
1114#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1115#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1116static int msm_hsusb_init_vddcx(int init)
1117{
1118 int ret = 0;
1119
1120 if (init) {
1121 vdd_cx = regulator_get(NULL, "8058_s1");
1122 if (IS_ERR(vdd_cx)) {
1123 return PTR_ERR(vdd_cx);
1124 }
1125
1126 ret = regulator_set_voltage(vdd_cx,
1127 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1128 USB_PHY_MAX_VDD_DIG_VOL);
1129 if (ret) {
1130 pr_err("%s: unable to set the voltage for regulator"
1131 "vdd_cx\n", __func__);
1132 regulator_put(vdd_cx);
1133 return ret;
1134 }
1135
1136 ret = regulator_enable(vdd_cx);
1137 if (ret) {
1138 pr_err("%s: unable to enable regulator"
1139 "vdd_cx\n", __func__);
1140 regulator_put(vdd_cx);
1141 }
1142 } else {
1143 ret = regulator_disable(vdd_cx);
1144 if (ret) {
1145 pr_err("%s: Unable to disable the regulator:"
1146 "vdd_cx\n", __func__);
1147 return ret;
1148 }
1149
1150 regulator_put(vdd_cx);
1151 }
1152
1153 return ret;
1154}
1155
1156static int msm_hsusb_config_vddcx(int high)
1157{
1158 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1159 int min_vol;
1160 int ret;
1161
1162 if (high)
1163 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1164 else
1165 min_vol = usb_phy_susp_dig_vol;
1166
1167 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1168 if (ret) {
1169 pr_err("%s: unable to set the voltage for regulator"
1170 "vdd_cx\n", __func__);
1171 return ret;
1172 }
1173
1174 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1175
1176 return ret;
1177}
1178
1179#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1180#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1181#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1182#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1183
1184#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1185#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1186#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1187#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1188static int msm_hsusb_ldo_init(int init)
1189{
1190 int rc = 0;
1191
1192 if (init) {
1193 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1194 if (IS_ERR(ldo6_3p3))
1195 return PTR_ERR(ldo6_3p3);
1196
1197 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1198 if (IS_ERR(ldo7_1p8)) {
1199 rc = PTR_ERR(ldo7_1p8);
1200 goto put_3p3;
1201 }
1202
1203 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1204 USB_PHY_3P3_VOL_MAX);
1205 if (rc) {
1206 pr_err("%s: Unable to set voltage level for"
1207 "ldo6_3p3 regulator\n", __func__);
1208 goto put_1p8;
1209 }
1210 rc = regulator_enable(ldo6_3p3);
1211 if (rc) {
1212 pr_err("%s: Unable to enable the regulator:"
1213 "ldo6_3p3\n", __func__);
1214 goto put_1p8;
1215 }
1216 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1217 USB_PHY_1P8_VOL_MAX);
1218 if (rc) {
1219 pr_err("%s: Unable to set voltage level for"
1220 "ldo7_1p8 regulator\n", __func__);
1221 goto disable_3p3;
1222 }
1223 rc = regulator_enable(ldo7_1p8);
1224 if (rc) {
1225 pr_err("%s: Unable to enable the regulator:"
1226 "ldo7_1p8\n", __func__);
1227 goto disable_3p3;
1228 }
1229
1230 return 0;
1231 }
1232
1233 regulator_disable(ldo7_1p8);
1234disable_3p3:
1235 regulator_disable(ldo6_3p3);
1236put_1p8:
1237 regulator_put(ldo7_1p8);
1238put_3p3:
1239 regulator_put(ldo6_3p3);
1240 return rc;
1241}
1242
1243static int msm_hsusb_ldo_enable(int on)
1244{
1245 int ret = 0;
1246
1247 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1248 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1249 return -ENODEV;
1250 }
1251
1252 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1253 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1254 return -ENODEV;
1255 }
1256
1257 if (on) {
1258 ret = regulator_set_optimum_mode(ldo7_1p8,
1259 USB_PHY_1P8_HPM_LOAD);
1260 if (ret < 0) {
1261 pr_err("%s: Unable to set HPM of the regulator:"
1262 "ldo7_1p8\n", __func__);
1263 return ret;
1264 }
1265 ret = regulator_set_optimum_mode(ldo6_3p3,
1266 USB_PHY_3P3_HPM_LOAD);
1267 if (ret < 0) {
1268 pr_err("%s: Unable to set HPM of the regulator:"
1269 "ldo6_3p3\n", __func__);
1270 regulator_set_optimum_mode(ldo7_1p8,
1271 USB_PHY_1P8_LPM_LOAD);
1272 return ret;
1273 }
1274 } else {
1275 ret = regulator_set_optimum_mode(ldo7_1p8,
1276 USB_PHY_1P8_LPM_LOAD);
1277 if (ret < 0)
1278 pr_err("%s: Unable to set LPM of the regulator:"
1279 "ldo7_1p8\n", __func__);
1280 ret = regulator_set_optimum_mode(ldo6_3p3,
1281 USB_PHY_3P3_LPM_LOAD);
1282 if (ret < 0)
1283 pr_err("%s: Unable to set LPM of the regulator:"
1284 "ldo6_3p3\n", __func__);
1285 }
1286
1287 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1288 return ret < 0 ? ret : 0;
1289 }
1290#endif
1291#ifdef CONFIG_USB_EHCI_MSM_72K
1292#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1293static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1294{
1295 static int vbus_is_on;
1296
1297 /* If VBUS is already on (or off), do nothing. */
1298 if (on == vbus_is_on)
1299 return;
1300 smb137b_otg_power(on);
1301 vbus_is_on = on;
1302}
1303#endif
1304static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1305{
1306 static struct regulator *votg_5v_switch;
1307 static struct regulator *ext_5v_reg;
1308 static int vbus_is_on;
1309
1310 /* If VBUS is already on (or off), do nothing. */
1311 if (on == vbus_is_on)
1312 return;
1313
1314 if (!votg_5v_switch) {
1315 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1316 if (IS_ERR(votg_5v_switch)) {
1317 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1318 return;
1319 }
1320 }
1321 if (!ext_5v_reg) {
1322 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1323 if (IS_ERR(ext_5v_reg)) {
1324 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1325 return;
1326 }
1327 }
1328 if (on) {
1329 if (regulator_enable(ext_5v_reg)) {
1330 pr_err("%s: Unable to enable the regulator:"
1331 " ext_5v_reg\n", __func__);
1332 return;
1333 }
1334 if (regulator_enable(votg_5v_switch)) {
1335 pr_err("%s: Unable to enable the regulator:"
1336 " votg_5v_switch\n", __func__);
1337 return;
1338 }
1339 } else {
1340 if (regulator_disable(votg_5v_switch))
1341 pr_err("%s: Unable to enable the regulator:"
1342 " votg_5v_switch\n", __func__);
1343 if (regulator_disable(ext_5v_reg))
1344 pr_err("%s: Unable to enable the regulator:"
1345 " ext_5v_reg\n", __func__);
1346 }
1347
1348 vbus_is_on = on;
1349}
1350
1351static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1352 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1353 .power_budget = 390,
1354};
1355#endif
1356
1357#ifdef CONFIG_BATTERY_MSM8X60
1358static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1359 int init)
1360{
1361 int ret = -ENOTSUPP;
1362
1363#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1364 if (machine_is_msm8x60_fluid()) {
1365 if (init)
1366 msm_charger_register_vbus_sn(callback);
1367 else
1368 msm_charger_unregister_vbus_sn(callback);
1369 return 0;
1370 }
1371#endif
1372 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1373 * hence, irrespective of either peripheral only mode or
1374 * OTG (host and peripheral) modes, can depend on pmic for
1375 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001376 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1378 && (machine_is_msm8x60_surf() ||
1379 pmic_id_notif_supported)) {
1380 if (init)
1381 ret = msm_charger_register_vbus_sn(callback);
1382 else {
1383 msm_charger_unregister_vbus_sn(callback);
1384 ret = 0;
1385 }
1386 } else {
1387#if !defined(CONFIG_USB_EHCI_MSM_72K)
1388 if (init)
1389 ret = msm_charger_register_vbus_sn(callback);
1390 else {
1391 msm_charger_unregister_vbus_sn(callback);
1392 ret = 0;
1393 }
1394#endif
1395 }
1396 return ret;
1397}
1398#endif
1399
Lena Salman57d167e2012-03-21 19:46:38 +02001400#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001401static struct msm_otg_platform_data msm_otg_pdata = {
1402 /* if usb link is in sps there is no need for
1403 * usb pclk as dayatona fabric clock will be
1404 * used instead
1405 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1407 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1408 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301409 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410#ifdef CONFIG_USB_EHCI_MSM_72K
1411 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301412 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001413#endif
1414#ifdef CONFIG_USB_EHCI_MSM_72K
1415 .vbus_power = msm_hsusb_vbus_power,
1416#endif
1417#ifdef CONFIG_BATTERY_MSM8X60
1418 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1419#endif
1420 .ldo_init = msm_hsusb_ldo_init,
1421 .ldo_enable = msm_hsusb_ldo_enable,
1422 .config_vddcx = msm_hsusb_config_vddcx,
1423 .init_vddcx = msm_hsusb_init_vddcx,
1424#ifdef CONFIG_BATTERY_MSM8X60
1425 .chg_vbus_draw = msm_charger_vbus_draw,
1426#endif
1427};
1428#endif
1429
Lena Salman57d167e2012-03-21 19:46:38 +02001430#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001431static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1432 .is_phy_status_timer_on = 1,
1433};
1434#endif
1435
1436#ifdef CONFIG_USB_G_ANDROID
1437
1438#define PID_MAGIC_ID 0x71432909
1439#define SERIAL_NUM_MAGIC_ID 0x61945374
1440#define SERIAL_NUMBER_LENGTH 127
1441#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1442
1443struct magic_num_struct {
1444 uint32_t pid;
1445 uint32_t serial_num;
1446};
1447
1448struct dload_struct {
1449 uint32_t reserved1;
1450 uint32_t reserved2;
1451 uint32_t reserved3;
1452 uint16_t reserved4;
1453 uint16_t pid;
1454 char serial_number[SERIAL_NUMBER_LENGTH];
1455 uint16_t reserved5;
1456 struct magic_num_struct
1457 magic_struct;
1458};
1459
1460static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1461{
1462 struct dload_struct __iomem *dload = 0;
1463
1464 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1465 if (!dload) {
1466 pr_err("%s: cannot remap I/O memory region: %08x\n",
1467 __func__, DLOAD_USB_BASE_ADD);
1468 return -ENXIO;
1469 }
1470
1471 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1472 __func__, dload, pid, snum);
1473 /* update pid */
1474 dload->magic_struct.pid = PID_MAGIC_ID;
1475 dload->pid = pid;
1476
1477 /* update serial number */
1478 dload->magic_struct.serial_num = 0;
1479 if (!snum)
1480 return 0;
1481
1482 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1483 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1484 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1485
1486 iounmap(dload);
1487
1488 return 0;
1489}
1490
1491static struct android_usb_platform_data android_usb_pdata = {
1492 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1493};
1494
1495static struct platform_device android_usb_device = {
1496 .name = "android_usb",
1497 .id = -1,
1498 .dev = {
1499 .platform_data = &android_usb_pdata,
1500 },
1501};
1502
1503
1504#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001505
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001506#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001507#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001508static struct resource msm_vpe_resources[] = {
1509 {
1510 .start = 0x05300000,
1511 .end = 0x05300000 + SZ_1M - 1,
1512 .flags = IORESOURCE_MEM,
1513 },
1514 {
1515 .start = INT_VPE,
1516 .end = INT_VPE,
1517 .flags = IORESOURCE_IRQ,
1518 },
1519};
1520
1521static struct platform_device msm_vpe_device = {
1522 .name = "msm_vpe",
1523 .id = 0,
1524 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1525 .resource = msm_vpe_resources,
1526};
1527#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001528#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001529
1530#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001531#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001532#ifdef CONFIG_MSM_CAMERA_FLASH
1533#define VFE_CAMIF_TIMER1_GPIO 29
1534#define VFE_CAMIF_TIMER2_GPIO 30
1535#define VFE_CAMIF_TIMER3_GPIO_INT 31
1536#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1537static struct msm_camera_sensor_flash_src msm_flash_src = {
1538 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1539 ._fsrc.pmic_src.num_of_src = 2,
1540 ._fsrc.pmic_src.low_current = 100,
1541 ._fsrc.pmic_src.high_current = 300,
1542 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1543 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1544 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1545};
1546#ifdef CONFIG_IMX074
1547static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1548 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1549 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1550 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1551 .flash_recharge_duration = 50000,
1552 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1553};
1554#endif
1555#endif
1556
1557int msm_cam_gpio_tbl[] = {
1558 32,/*CAMIF_MCLK*/
1559 47,/*CAMIF_I2C_DATA*/
1560 48,/*CAMIF_I2C_CLK*/
1561 105,/*STANDBY*/
1562};
1563
1564enum msm_cam_stat{
1565 MSM_CAM_OFF,
1566 MSM_CAM_ON,
1567};
1568
1569static int config_gpio_table(enum msm_cam_stat stat)
1570{
1571 int rc = 0, i = 0;
1572 if (stat == MSM_CAM_ON) {
1573 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1574 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1575 if (unlikely(rc < 0)) {
1576 pr_err("%s not able to get gpio\n", __func__);
1577 for (i--; i >= 0; i--)
1578 gpio_free(msm_cam_gpio_tbl[i]);
1579 break;
1580 }
1581 }
1582 } else {
1583 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1584 gpio_free(msm_cam_gpio_tbl[i]);
1585 }
1586 return rc;
1587}
1588
1589static struct msm_camera_sensor_platform_info sensor_board_info = {
1590 .mount_angle = 0
1591};
1592
1593/*external regulator VREG_5V*/
1594static struct regulator *reg_flash_5V;
1595
1596static int config_camera_on_gpios_fluid(void)
1597{
1598 int rc = 0;
1599
1600 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1601 if (IS_ERR(reg_flash_5V)) {
1602 pr_err("'%s' regulator not found, rc=%ld\n",
1603 "8901_mpp0", IS_ERR(reg_flash_5V));
1604 return -ENODEV;
1605 }
1606
1607 rc = regulator_enable(reg_flash_5V);
1608 if (rc) {
1609 pr_err("'%s' regulator enable failed, rc=%d\n",
1610 "8901_mpp0", rc);
1611 regulator_put(reg_flash_5V);
1612 return rc;
1613 }
1614
1615#ifdef CONFIG_IMX074
1616 sensor_board_info.mount_angle = 90;
1617#endif
1618 rc = config_gpio_table(MSM_CAM_ON);
1619 if (rc < 0) {
1620 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1621 "failed\n", __func__);
1622 return rc;
1623 }
1624
1625 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1626 if (rc < 0) {
1627 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1628 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1629 regulator_disable(reg_flash_5V);
1630 regulator_put(reg_flash_5V);
1631 return rc;
1632 }
1633 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1634 msleep(20);
1635 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1636
1637
1638 /*Enable LED_FLASH_EN*/
1639 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1640 if (rc < 0) {
1641 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1642 "failed\n", __func__, GPIO_LED_FLASH_EN);
1643
1644 regulator_disable(reg_flash_5V);
1645 regulator_put(reg_flash_5V);
1646 config_gpio_table(MSM_CAM_OFF);
1647 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1648 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1649 return rc;
1650 }
1651 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1652 msleep(20);
1653 return rc;
1654}
1655
1656
1657static void config_camera_off_gpios_fluid(void)
1658{
1659 regulator_disable(reg_flash_5V);
1660 regulator_put(reg_flash_5V);
1661
1662 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1663 gpio_free(GPIO_LED_FLASH_EN);
1664
1665 config_gpio_table(MSM_CAM_OFF);
1666
1667 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1668 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1669}
1670static int config_camera_on_gpios(void)
1671{
1672 int rc = 0;
1673
1674 if (machine_is_msm8x60_fluid())
1675 return config_camera_on_gpios_fluid();
1676
1677 rc = config_gpio_table(MSM_CAM_ON);
1678 if (rc < 0) {
1679 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1680 "failed\n", __func__);
1681 return rc;
1682 }
1683
Jilai Wang971f97f2011-07-13 14:25:25 -04001684 if (!machine_is_msm8x60_dragon()) {
1685 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1686 if (rc < 0) {
1687 config_gpio_table(MSM_CAM_OFF);
1688 pr_err("%s: CAMSENSOR gpio %d request"
1689 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1690 return rc;
1691 }
1692 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1693 msleep(20);
1694 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001695 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001696
1697#ifdef CONFIG_MSM_CAMERA_FLASH
1698#ifdef CONFIG_IMX074
1699 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1700 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1701#endif
1702#endif
1703 return rc;
1704}
1705
1706static void config_camera_off_gpios(void)
1707{
1708 if (machine_is_msm8x60_fluid())
1709 return config_camera_off_gpios_fluid();
1710
1711
1712 config_gpio_table(MSM_CAM_OFF);
1713
Jilai Wang971f97f2011-07-13 14:25:25 -04001714 if (!machine_is_msm8x60_dragon()) {
1715 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1716 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1717 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001718}
1719
1720#ifdef CONFIG_QS_S5K4E1
1721
1722#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1723
1724static int config_camera_on_gpios_qs_cam_fluid(void)
1725{
1726 int rc = 0;
1727
1728 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1729 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1730 if (rc < 0) {
1731 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1732 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1733 return rc;
1734 }
1735 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1736 msleep(20);
1737 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1738 msleep(20);
1739
1740 /*
1741 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1742 * to enable 2.7V power to Camera
1743 */
1744 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1745 if (rc < 0) {
1746 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1747 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1748 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1749 gpio_free(QS_CAM_HC37_CAM_PD);
1750 return rc;
1751 }
1752 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1753 msleep(20);
1754 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1755 msleep(20);
1756
1757 rc = config_camera_on_gpios_fluid();
1758 if (rc < 0) {
1759 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1760 " failed\n", __func__);
1761 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1762 gpio_free(QS_CAM_HC37_CAM_PD);
1763 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1764 gpio_free(GPIO_AUX_CAM_2P7_EN);
1765 return rc;
1766 }
1767 return rc;
1768}
1769
1770static void config_camera_off_gpios_qs_cam_fluid(void)
1771{
1772 /*
1773 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1774 * to disable 2.7V power to Camera
1775 */
1776 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1777 gpio_free(GPIO_AUX_CAM_2P7_EN);
1778
1779 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1780 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1781 gpio_free(QS_CAM_HC37_CAM_PD);
1782
1783 config_camera_off_gpios_fluid();
1784 return;
1785}
1786
1787static int config_camera_on_gpios_qs_cam(void)
1788{
1789 int rc = 0;
1790
1791 if (machine_is_msm8x60_fluid())
1792 return config_camera_on_gpios_qs_cam_fluid();
1793
1794 rc = config_camera_on_gpios();
1795 return rc;
1796}
1797
1798static void config_camera_off_gpios_qs_cam(void)
1799{
1800 if (machine_is_msm8x60_fluid())
1801 return config_camera_off_gpios_qs_cam_fluid();
1802
1803 config_camera_off_gpios();
1804 return;
1805}
1806#endif
1807
1808static int config_camera_on_gpios_web_cam(void)
1809{
1810 int rc = 0;
1811 rc = config_gpio_table(MSM_CAM_ON);
1812 if (rc < 0) {
1813 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1814 "failed\n", __func__);
1815 return rc;
1816 }
1817
Jilai Wang53d27a82011-07-13 14:32:58 -04001818 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001819 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1820 if (rc < 0) {
1821 config_gpio_table(MSM_CAM_OFF);
1822 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1823 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1824 return rc;
1825 }
1826 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1827 }
1828 return rc;
1829}
1830
1831static void config_camera_off_gpios_web_cam(void)
1832{
1833 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001834 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001835 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1836 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1837 }
1838 return;
1839}
1840
1841#ifdef CONFIG_MSM_BUS_SCALING
1842static struct msm_bus_vectors cam_init_vectors[] = {
1843 {
1844 .src = MSM_BUS_MASTER_VFE,
1845 .dst = MSM_BUS_SLAVE_SMI,
1846 .ab = 0,
1847 .ib = 0,
1848 },
1849 {
1850 .src = MSM_BUS_MASTER_VFE,
1851 .dst = MSM_BUS_SLAVE_EBI_CH0,
1852 .ab = 0,
1853 .ib = 0,
1854 },
1855 {
1856 .src = MSM_BUS_MASTER_VPE,
1857 .dst = MSM_BUS_SLAVE_SMI,
1858 .ab = 0,
1859 .ib = 0,
1860 },
1861 {
1862 .src = MSM_BUS_MASTER_VPE,
1863 .dst = MSM_BUS_SLAVE_EBI_CH0,
1864 .ab = 0,
1865 .ib = 0,
1866 },
1867 {
1868 .src = MSM_BUS_MASTER_JPEG_ENC,
1869 .dst = MSM_BUS_SLAVE_SMI,
1870 .ab = 0,
1871 .ib = 0,
1872 },
1873 {
1874 .src = MSM_BUS_MASTER_JPEG_ENC,
1875 .dst = MSM_BUS_SLAVE_EBI_CH0,
1876 .ab = 0,
1877 .ib = 0,
1878 },
1879};
1880
1881static struct msm_bus_vectors cam_preview_vectors[] = {
1882 {
1883 .src = MSM_BUS_MASTER_VFE,
1884 .dst = MSM_BUS_SLAVE_SMI,
1885 .ab = 0,
1886 .ib = 0,
1887 },
1888 {
1889 .src = MSM_BUS_MASTER_VFE,
1890 .dst = MSM_BUS_SLAVE_EBI_CH0,
1891 .ab = 283115520,
1892 .ib = 452984832,
1893 },
1894 {
1895 .src = MSM_BUS_MASTER_VPE,
1896 .dst = MSM_BUS_SLAVE_SMI,
1897 .ab = 0,
1898 .ib = 0,
1899 },
1900 {
1901 .src = MSM_BUS_MASTER_VPE,
1902 .dst = MSM_BUS_SLAVE_EBI_CH0,
1903 .ab = 0,
1904 .ib = 0,
1905 },
1906 {
1907 .src = MSM_BUS_MASTER_JPEG_ENC,
1908 .dst = MSM_BUS_SLAVE_SMI,
1909 .ab = 0,
1910 .ib = 0,
1911 },
1912 {
1913 .src = MSM_BUS_MASTER_JPEG_ENC,
1914 .dst = MSM_BUS_SLAVE_EBI_CH0,
1915 .ab = 0,
1916 .ib = 0,
1917 },
1918};
1919
1920static struct msm_bus_vectors cam_video_vectors[] = {
1921 {
1922 .src = MSM_BUS_MASTER_VFE,
1923 .dst = MSM_BUS_SLAVE_SMI,
1924 .ab = 283115520,
1925 .ib = 452984832,
1926 },
1927 {
1928 .src = MSM_BUS_MASTER_VFE,
1929 .dst = MSM_BUS_SLAVE_EBI_CH0,
1930 .ab = 283115520,
1931 .ib = 452984832,
1932 },
1933 {
1934 .src = MSM_BUS_MASTER_VPE,
1935 .dst = MSM_BUS_SLAVE_SMI,
1936 .ab = 319610880,
1937 .ib = 511377408,
1938 },
1939 {
1940 .src = MSM_BUS_MASTER_VPE,
1941 .dst = MSM_BUS_SLAVE_EBI_CH0,
1942 .ab = 0,
1943 .ib = 0,
1944 },
1945 {
1946 .src = MSM_BUS_MASTER_JPEG_ENC,
1947 .dst = MSM_BUS_SLAVE_SMI,
1948 .ab = 0,
1949 .ib = 0,
1950 },
1951 {
1952 .src = MSM_BUS_MASTER_JPEG_ENC,
1953 .dst = MSM_BUS_SLAVE_EBI_CH0,
1954 .ab = 0,
1955 .ib = 0,
1956 },
1957};
1958
1959static struct msm_bus_vectors cam_snapshot_vectors[] = {
1960 {
1961 .src = MSM_BUS_MASTER_VFE,
1962 .dst = MSM_BUS_SLAVE_SMI,
1963 .ab = 566231040,
1964 .ib = 905969664,
1965 },
1966 {
1967 .src = MSM_BUS_MASTER_VFE,
1968 .dst = MSM_BUS_SLAVE_EBI_CH0,
1969 .ab = 69984000,
1970 .ib = 111974400,
1971 },
1972 {
1973 .src = MSM_BUS_MASTER_VPE,
1974 .dst = MSM_BUS_SLAVE_SMI,
1975 .ab = 0,
1976 .ib = 0,
1977 },
1978 {
1979 .src = MSM_BUS_MASTER_VPE,
1980 .dst = MSM_BUS_SLAVE_EBI_CH0,
1981 .ab = 0,
1982 .ib = 0,
1983 },
1984 {
1985 .src = MSM_BUS_MASTER_JPEG_ENC,
1986 .dst = MSM_BUS_SLAVE_SMI,
1987 .ab = 320864256,
1988 .ib = 513382810,
1989 },
1990 {
1991 .src = MSM_BUS_MASTER_JPEG_ENC,
1992 .dst = MSM_BUS_SLAVE_EBI_CH0,
1993 .ab = 320864256,
1994 .ib = 513382810,
1995 },
1996};
1997
1998static struct msm_bus_vectors cam_zsl_vectors[] = {
1999 {
2000 .src = MSM_BUS_MASTER_VFE,
2001 .dst = MSM_BUS_SLAVE_SMI,
2002 .ab = 566231040,
2003 .ib = 905969664,
2004 },
2005 {
2006 .src = MSM_BUS_MASTER_VFE,
2007 .dst = MSM_BUS_SLAVE_EBI_CH0,
2008 .ab = 706199040,
2009 .ib = 1129918464,
2010 },
2011 {
2012 .src = MSM_BUS_MASTER_VPE,
2013 .dst = MSM_BUS_SLAVE_SMI,
2014 .ab = 0,
2015 .ib = 0,
2016 },
2017 {
2018 .src = MSM_BUS_MASTER_VPE,
2019 .dst = MSM_BUS_SLAVE_EBI_CH0,
2020 .ab = 0,
2021 .ib = 0,
2022 },
2023 {
2024 .src = MSM_BUS_MASTER_JPEG_ENC,
2025 .dst = MSM_BUS_SLAVE_SMI,
2026 .ab = 320864256,
2027 .ib = 513382810,
2028 },
2029 {
2030 .src = MSM_BUS_MASTER_JPEG_ENC,
2031 .dst = MSM_BUS_SLAVE_EBI_CH0,
2032 .ab = 320864256,
2033 .ib = 513382810,
2034 },
2035};
2036
2037static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2038 {
2039 .src = MSM_BUS_MASTER_VFE,
2040 .dst = MSM_BUS_SLAVE_SMI,
2041 .ab = 212336640,
2042 .ib = 339738624,
2043 },
2044 {
2045 .src = MSM_BUS_MASTER_VFE,
2046 .dst = MSM_BUS_SLAVE_EBI_CH0,
2047 .ab = 25090560,
2048 .ib = 40144896,
2049 },
2050 {
2051 .src = MSM_BUS_MASTER_VPE,
2052 .dst = MSM_BUS_SLAVE_SMI,
2053 .ab = 239708160,
2054 .ib = 383533056,
2055 },
2056 {
2057 .src = MSM_BUS_MASTER_VPE,
2058 .dst = MSM_BUS_SLAVE_EBI_CH0,
2059 .ab = 79902720,
2060 .ib = 127844352,
2061 },
2062 {
2063 .src = MSM_BUS_MASTER_JPEG_ENC,
2064 .dst = MSM_BUS_SLAVE_SMI,
2065 .ab = 0,
2066 .ib = 0,
2067 },
2068 {
2069 .src = MSM_BUS_MASTER_JPEG_ENC,
2070 .dst = MSM_BUS_SLAVE_EBI_CH0,
2071 .ab = 0,
2072 .ib = 0,
2073 },
2074};
2075
2076static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2077 {
2078 .src = MSM_BUS_MASTER_VFE,
2079 .dst = MSM_BUS_SLAVE_SMI,
2080 .ab = 0,
2081 .ib = 0,
2082 },
2083 {
2084 .src = MSM_BUS_MASTER_VFE,
2085 .dst = MSM_BUS_SLAVE_EBI_CH0,
2086 .ab = 300902400,
2087 .ib = 481443840,
2088 },
2089 {
2090 .src = MSM_BUS_MASTER_VPE,
2091 .dst = MSM_BUS_SLAVE_SMI,
2092 .ab = 230307840,
2093 .ib = 368492544,
2094 },
2095 {
2096 .src = MSM_BUS_MASTER_VPE,
2097 .dst = MSM_BUS_SLAVE_EBI_CH0,
2098 .ab = 245113344,
2099 .ib = 392181351,
2100 },
2101 {
2102 .src = MSM_BUS_MASTER_JPEG_ENC,
2103 .dst = MSM_BUS_SLAVE_SMI,
2104 .ab = 106536960,
2105 .ib = 170459136,
2106 },
2107 {
2108 .src = MSM_BUS_MASTER_JPEG_ENC,
2109 .dst = MSM_BUS_SLAVE_EBI_CH0,
2110 .ab = 106536960,
2111 .ib = 170459136,
2112 },
2113};
2114
2115static struct msm_bus_paths cam_bus_client_config[] = {
2116 {
2117 ARRAY_SIZE(cam_init_vectors),
2118 cam_init_vectors,
2119 },
2120 {
2121 ARRAY_SIZE(cam_preview_vectors),
2122 cam_preview_vectors,
2123 },
2124 {
2125 ARRAY_SIZE(cam_video_vectors),
2126 cam_video_vectors,
2127 },
2128 {
2129 ARRAY_SIZE(cam_snapshot_vectors),
2130 cam_snapshot_vectors,
2131 },
2132 {
2133 ARRAY_SIZE(cam_zsl_vectors),
2134 cam_zsl_vectors,
2135 },
2136 {
2137 ARRAY_SIZE(cam_stereo_video_vectors),
2138 cam_stereo_video_vectors,
2139 },
2140 {
2141 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2142 cam_stereo_snapshot_vectors,
2143 },
2144};
2145
2146static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2147 cam_bus_client_config,
2148 ARRAY_SIZE(cam_bus_client_config),
2149 .name = "msm_camera",
2150};
2151#endif
2152
2153struct msm_camera_device_platform_data msm_camera_device_data = {
2154 .camera_gpio_on = config_camera_on_gpios,
2155 .camera_gpio_off = config_camera_off_gpios,
2156 .ioext.csiphy = 0x04800000,
2157 .ioext.csisz = 0x00000400,
2158 .ioext.csiirq = CSI_0_IRQ,
2159 .ioclk.mclk_clk_rate = 24000000,
2160 .ioclk.vfe_clk_rate = 228570000,
2161#ifdef CONFIG_MSM_BUS_SCALING
2162 .cam_bus_scale_table = &cam_bus_client_pdata,
2163#endif
2164};
2165
2166#ifdef CONFIG_QS_S5K4E1
2167struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2168 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2169 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2170 .ioext.csiphy = 0x04800000,
2171 .ioext.csisz = 0x00000400,
2172 .ioext.csiirq = CSI_0_IRQ,
2173 .ioclk.mclk_clk_rate = 24000000,
2174 .ioclk.vfe_clk_rate = 228570000,
2175#ifdef CONFIG_MSM_BUS_SCALING
2176 .cam_bus_scale_table = &cam_bus_client_pdata,
2177#endif
2178};
2179#endif
2180
2181struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2182 .camera_gpio_on = config_camera_on_gpios_web_cam,
2183 .camera_gpio_off = config_camera_off_gpios_web_cam,
2184 .ioext.csiphy = 0x04900000,
2185 .ioext.csisz = 0x00000400,
2186 .ioext.csiirq = CSI_1_IRQ,
2187 .ioclk.mclk_clk_rate = 24000000,
2188 .ioclk.vfe_clk_rate = 228570000,
2189#ifdef CONFIG_MSM_BUS_SCALING
2190 .cam_bus_scale_table = &cam_bus_client_pdata,
2191#endif
2192};
2193
2194struct resource msm_camera_resources[] = {
2195 {
2196 .start = 0x04500000,
2197 .end = 0x04500000 + SZ_1M - 1,
2198 .flags = IORESOURCE_MEM,
2199 },
2200 {
2201 .start = VFE_IRQ,
2202 .end = VFE_IRQ,
2203 .flags = IORESOURCE_IRQ,
2204 },
2205};
2206#ifdef CONFIG_MT9E013
2207static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2208 .mount_angle = 0
2209};
2210
2211static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2212 .flash_type = MSM_CAMERA_FLASH_LED,
2213 .flash_src = &msm_flash_src
2214};
2215
2216static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2217 .sensor_name = "mt9e013",
2218 .sensor_reset = 106,
2219 .sensor_pwd = 85,
2220 .vcm_pwd = 1,
2221 .vcm_enable = 0,
2222 .pdata = &msm_camera_device_data,
2223 .resource = msm_camera_resources,
2224 .num_resources = ARRAY_SIZE(msm_camera_resources),
2225 .flash_data = &flash_mt9e013,
2226 .strobe_flash_data = &strobe_flash_xenon,
2227 .sensor_platform_info = &mt9e013_sensor_8660_info,
2228 .csi_if = 1
2229};
2230struct platform_device msm_camera_sensor_mt9e013 = {
2231 .name = "msm_camera_mt9e013",
2232 .dev = {
2233 .platform_data = &msm_camera_sensor_mt9e013_data,
2234 },
2235};
2236#endif
2237
2238#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302239static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2240 .mount_angle = 180
2241};
2242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002243static struct msm_camera_sensor_flash_data flash_imx074 = {
2244 .flash_type = MSM_CAMERA_FLASH_LED,
2245 .flash_src = &msm_flash_src
2246};
2247
2248static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2249 .sensor_name = "imx074",
2250 .sensor_reset = 106,
2251 .sensor_pwd = 85,
2252 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2253 .vcm_enable = 1,
2254 .pdata = &msm_camera_device_data,
2255 .resource = msm_camera_resources,
2256 .num_resources = ARRAY_SIZE(msm_camera_resources),
2257 .flash_data = &flash_imx074,
2258 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302259 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002260 .csi_if = 1
2261};
2262struct platform_device msm_camera_sensor_imx074 = {
2263 .name = "msm_camera_imx074",
2264 .dev = {
2265 .platform_data = &msm_camera_sensor_imx074_data,
2266 },
2267};
2268#endif
2269#ifdef CONFIG_WEBCAM_OV9726
2270
2271static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2272 .mount_angle = 0
2273};
2274
2275static struct msm_camera_sensor_flash_data flash_ov9726 = {
2276 .flash_type = MSM_CAMERA_FLASH_LED,
2277 .flash_src = &msm_flash_src
2278};
2279static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2280 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002281 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2283 .sensor_pwd = 85,
2284 .vcm_pwd = 1,
2285 .vcm_enable = 0,
2286 .pdata = &msm_camera_device_data_web_cam,
2287 .resource = msm_camera_resources,
2288 .num_resources = ARRAY_SIZE(msm_camera_resources),
2289 .flash_data = &flash_ov9726,
2290 .sensor_platform_info = &ov9726_sensor_8660_info,
2291 .csi_if = 1
2292};
2293struct platform_device msm_camera_sensor_webcam_ov9726 = {
2294 .name = "msm_camera_ov9726",
2295 .dev = {
2296 .platform_data = &msm_camera_sensor_ov9726_data,
2297 },
2298};
2299#endif
2300#ifdef CONFIG_WEBCAM_OV7692
2301static struct msm_camera_sensor_flash_data flash_ov7692 = {
2302 .flash_type = MSM_CAMERA_FLASH_LED,
2303 .flash_src = &msm_flash_src
2304};
2305static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2306 .sensor_name = "ov7692",
2307 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2308 .sensor_pwd = 85,
2309 .vcm_pwd = 1,
2310 .vcm_enable = 0,
2311 .pdata = &msm_camera_device_data_web_cam,
2312 .resource = msm_camera_resources,
2313 .num_resources = ARRAY_SIZE(msm_camera_resources),
2314 .flash_data = &flash_ov7692,
2315 .csi_if = 1
2316};
2317
2318static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2319 .name = "msm_camera_ov7692",
2320 .dev = {
2321 .platform_data = &msm_camera_sensor_ov7692_data,
2322 },
2323};
2324#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002325#ifdef CONFIG_VX6953
2326static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2327 .mount_angle = 270
2328};
2329
2330static struct msm_camera_sensor_flash_data flash_vx6953 = {
2331 .flash_type = MSM_CAMERA_FLASH_NONE,
2332 .flash_src = &msm_flash_src
2333};
2334
2335static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2336 .sensor_name = "vx6953",
2337 .sensor_reset = 63,
2338 .sensor_pwd = 63,
2339 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2340 .vcm_enable = 1,
2341 .pdata = &msm_camera_device_data,
2342 .resource = msm_camera_resources,
2343 .num_resources = ARRAY_SIZE(msm_camera_resources),
2344 .flash_data = &flash_vx6953,
2345 .sensor_platform_info = &vx6953_sensor_8660_info,
2346 .csi_if = 1
2347};
2348struct platform_device msm_camera_sensor_vx6953 = {
2349 .name = "msm_camera_vx6953",
2350 .dev = {
2351 .platform_data = &msm_camera_sensor_vx6953_data,
2352 },
2353};
2354#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002355#ifdef CONFIG_QS_S5K4E1
2356
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302357static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2358#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2359 .mount_angle = 90
2360#else
2361 .mount_angle = 0
2362#endif
2363};
2364
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002365static char eeprom_data[864];
2366static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2367 .flash_type = MSM_CAMERA_FLASH_LED,
2368 .flash_src = &msm_flash_src
2369};
2370
2371static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2372 .sensor_name = "qs_s5k4e1",
2373 .sensor_reset = 106,
2374 .sensor_pwd = 85,
2375 .vcm_pwd = 1,
2376 .vcm_enable = 0,
2377 .pdata = &msm_camera_device_data_qs_cam,
2378 .resource = msm_camera_resources,
2379 .num_resources = ARRAY_SIZE(msm_camera_resources),
2380 .flash_data = &flash_qs_s5k4e1,
2381 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302382 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002383 .csi_if = 1,
2384 .eeprom_data = eeprom_data,
2385};
2386struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2387 .name = "msm_camera_qs_s5k4e1",
2388 .dev = {
2389 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2390 },
2391};
2392#endif
2393static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2394 #ifdef CONFIG_MT9E013
2395 {
2396 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2397 },
2398 #endif
2399 #ifdef CONFIG_IMX074
2400 {
2401 I2C_BOARD_INFO("imx074", 0x1A),
2402 },
2403 #endif
2404 #ifdef CONFIG_WEBCAM_OV7692
2405 {
2406 I2C_BOARD_INFO("ov7692", 0x78),
2407 },
2408 #endif
2409 #ifdef CONFIG_WEBCAM_OV9726
2410 {
2411 I2C_BOARD_INFO("ov9726", 0x10),
2412 },
2413 #endif
2414 #ifdef CONFIG_QS_S5K4E1
2415 {
2416 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2417 },
2418 #endif
2419};
Jilai Wang971f97f2011-07-13 14:25:25 -04002420
2421static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002422 #ifdef CONFIG_WEBCAM_OV9726
2423 {
2424 I2C_BOARD_INFO("ov9726", 0x10),
2425 },
2426 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002427 #ifdef CONFIG_VX6953
2428 {
2429 I2C_BOARD_INFO("vx6953", 0x20),
2430 },
2431 #endif
2432};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002433#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002434#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002435
2436#ifdef CONFIG_MSM_GEMINI
2437static struct resource msm_gemini_resources[] = {
2438 {
2439 .start = 0x04600000,
2440 .end = 0x04600000 + SZ_1M - 1,
2441 .flags = IORESOURCE_MEM,
2442 },
2443 {
2444 .start = INT_JPEG,
2445 .end = INT_JPEG,
2446 .flags = IORESOURCE_IRQ,
2447 },
2448};
2449
2450static struct platform_device msm_gemini_device = {
2451 .name = "msm_gemini",
2452 .resource = msm_gemini_resources,
2453 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2454};
2455#endif
2456
2457#ifdef CONFIG_I2C_QUP
2458static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2459{
2460}
2461
2462static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2463 .clk_freq = 384000,
2464 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002465 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2466};
2467
2468static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2469 .clk_freq = 100000,
2470 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002471 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2472};
2473
2474static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2475 .clk_freq = 100000,
2476 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002477 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2478};
2479
2480static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2481 .clk_freq = 100000,
2482 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002483 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2484};
2485
2486static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2487 .clk_freq = 100000,
2488 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002489 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2490};
2491
2492static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2493 .clk_freq = 100000,
2494 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002495 .use_gsbi_shared_mode = 1,
2496 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2497};
2498#endif
2499
2500#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2501static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2502 .max_clock_speed = 24000000,
2503};
2504
2505static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2506 .max_clock_speed = 24000000,
2507};
2508#endif
2509
2510#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002511/* CODEC/TSSC SSBI */
2512static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2513 .controller_type = MSM_SBI_CTRL_SSBI,
2514};
2515#endif
2516
2517#ifdef CONFIG_BATTERY_MSM
2518/* Use basic value for fake MSM battery */
2519static struct msm_psy_batt_pdata msm_psy_batt_data = {
2520 .avail_chg_sources = AC_CHG,
2521};
2522
2523static struct platform_device msm_batt_device = {
2524 .name = "msm-battery",
2525 .id = -1,
2526 .dev.platform_data = &msm_psy_batt_data,
2527};
2528#endif
2529
2530#ifdef CONFIG_FB_MSM_LCDC_DSUB
2531/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2532 prim = 1024 x 600 x 4(bpp) x 2(pages)
2533 This is the difference. */
2534#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2535#else
2536#define MSM_FB_DSUB_PMEM_ADDER (0)
2537#endif
2538
2539/* Sensors DSPS platform data */
2540#ifdef CONFIG_MSM_DSPS
2541
2542static struct dsps_gpio_info dsps_surf_gpios[] = {
2543 {
2544 .name = "compass_rst_n",
2545 .num = GPIO_COMPASS_RST_N,
2546 .on_val = 1, /* device not in reset */
2547 .off_val = 0, /* device in reset */
2548 },
2549 {
2550 .name = "gpio_r_altimeter_reset_n",
2551 .num = GPIO_R_ALTIMETER_RESET_N,
2552 .on_val = 1, /* device not in reset */
2553 .off_val = 0, /* device in reset */
2554 }
2555};
2556
2557static struct dsps_gpio_info dsps_fluid_gpios[] = {
2558 {
2559 .name = "gpio_n_altimeter_reset_n",
2560 .num = GPIO_N_ALTIMETER_RESET_N,
2561 .on_val = 1, /* device not in reset */
2562 .off_val = 0, /* device in reset */
2563 }
2564};
2565
2566static void __init msm8x60_init_dsps(void)
2567{
2568 struct msm_dsps_platform_data *pdata =
2569 msm_dsps_device.dev.platform_data;
2570 /*
2571 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2572 * to the power supply and not controled via GPIOs. Fluid uses a
2573 * different IO-Expender (north) than used on surf/ffa.
2574 */
2575 if (machine_is_msm8x60_fluid()) {
2576 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002577 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002578 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002579 pdata->gpios = dsps_fluid_gpios;
2580 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2581 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002582 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002583 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002584 pdata->gpios = dsps_surf_gpios;
2585 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2586 }
2587
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002588 platform_device_register(&msm_dsps_device);
2589}
2590#endif /* CONFIG_MSM_DSPS */
2591
2592#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302593#define MSM_FB_PRIM_BUF_SIZE \
2594 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002595#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302596#define MSM_FB_PRIM_BUF_SIZE \
2597 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002598#endif
2599
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002600#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302601#define MSM_FB_EXT_BUF_SIZE \
2602 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002603#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302604#define MSM_FB_EXT_BUF_SIZE \
2605 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002606#else
2607#define MSM_FB_EXT_BUFT_SIZE 0
2608#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002609
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002610/* Note: must be multiple of 4096 */
2611#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002612 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002613
2614#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302615#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002616
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002617#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002618unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002619#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002620unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002621#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002622
Huaibin Yanga5419422011-12-08 23:52:10 -08002623#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2624#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2625#else
2626#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2627#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2628
2629#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2630#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2631#else
2632#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2633#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2634
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302635#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002636#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302637#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002638
2639#define MSM_SMI_BASE 0x38000000
2640#define MSM_SMI_SIZE 0x4000000
2641
2642#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302643#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2644#define KERNEL_SMI_SIZE 0x000000
2645#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002646#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302647#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002648
2649#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2650#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2651#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2652
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302653#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
2654#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2655#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2656#define MSM_ION_MFC_SIZE SZ_8K
2657
2658#define MSM_MM_FW_BASE MSM_SMI_BASE
2659#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2660#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2661#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2662
Naseer Ahmed51860b02012-02-07 18:53:29 +05302663#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002664#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302665
Mayank Choprac22ace32012-03-03 00:45:04 +05302666#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2667#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2668#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002669#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302670#endif
2671
Olav Haugan424ff492012-03-13 11:41:23 -07002672#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002673
2674#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302675#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002676#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002677#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2678static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002679#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002680#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002681#endif
2682
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002683static unsigned fb_size;
2684static int __init fb_size_setup(char *p)
2685{
2686 fb_size = memparse(p, NULL);
2687 return 0;
2688}
2689early_param("fb_size", fb_size_setup);
2690
2691static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2692static int __init pmem_kernel_ebi1_size_setup(char *p)
2693{
2694 pmem_kernel_ebi1_size = memparse(p, NULL);
2695 return 0;
2696}
2697early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2698
2699#ifdef CONFIG_ANDROID_PMEM
2700static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2701static int __init pmem_sf_size_setup(char *p)
2702{
2703 pmem_sf_size = memparse(p, NULL);
2704 return 0;
2705}
2706early_param("pmem_sf_size", pmem_sf_size_setup);
2707
2708static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2709
2710static int __init pmem_adsp_size_setup(char *p)
2711{
2712 pmem_adsp_size = memparse(p, NULL);
2713 return 0;
2714}
2715early_param("pmem_adsp_size", pmem_adsp_size_setup);
2716
2717static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2718
2719static int __init pmem_audio_size_setup(char *p)
2720{
2721 pmem_audio_size = memparse(p, NULL);
2722 return 0;
2723}
2724early_param("pmem_audio_size", pmem_audio_size_setup);
2725#endif
2726
2727static struct resource msm_fb_resources[] = {
2728 {
2729 .flags = IORESOURCE_DMA,
2730 }
2731};
2732
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002733static void set_mdp_clocks_for_wuxga(void);
2734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002735static int msm_fb_detect_panel(const char *name)
2736{
2737 if (machine_is_msm8x60_fluid()) {
2738 uint32_t soc_platform_version = socinfo_get_platform_version();
2739 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2740#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2741 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002742 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2743 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744 return 0;
2745#endif
2746 } else { /*P3 and up use AUO panel */
2747#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2748 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002749 strnlen(LCDC_AUO_PANEL_NAME,
2750 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002751 return 0;
2752#endif
2753 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002754#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2755 } else if machine_is_msm8x60_dragon() {
2756 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002757 strnlen(LCDC_NT35582_PANEL_NAME,
2758 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002759 return 0;
2760#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002761 } else {
2762 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002763 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2764 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002765 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002766
2767#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2768 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2769 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2770 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2771 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2772 PANEL_NAME_MAX_LEN)))
2773 return 0;
2774
2775 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2776 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2777 PANEL_NAME_MAX_LEN)))
2778 return 0;
2779
2780 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2781 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2782 PANEL_NAME_MAX_LEN)))
2783 return 0;
2784#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002785 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002786
2787 if (!strncmp(name, HDMI_PANEL_NAME,
2788 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002789 PANEL_NAME_MAX_LEN))) {
2790 if (hdmi_is_primary)
2791 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002792 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002793 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002794
2795 if (!strncmp(name, TVOUT_PANEL_NAME,
2796 strnlen(TVOUT_PANEL_NAME,
2797 PANEL_NAME_MAX_LEN)))
2798 return 0;
2799
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002800 pr_warning("%s: not supported '%s'", __func__, name);
2801 return -ENODEV;
2802}
2803
2804static struct msm_fb_platform_data msm_fb_pdata = {
2805 .detect_client = msm_fb_detect_panel,
2806};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002807
2808static struct platform_device msm_fb_device = {
2809 .name = "msm_fb",
2810 .id = 0,
2811 .num_resources = ARRAY_SIZE(msm_fb_resources),
2812 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814};
2815
2816#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002817#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818static struct android_pmem_platform_data android_pmem_pdata = {
2819 .name = "pmem",
2820 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2821 .cached = 1,
2822 .memory_type = MEMTYPE_EBI1,
2823};
2824
2825static struct platform_device android_pmem_device = {
2826 .name = "android_pmem",
2827 .id = 0,
2828 .dev = {.platform_data = &android_pmem_pdata},
2829};
2830
2831static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2832 .name = "pmem_adsp",
2833 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2834 .cached = 0,
2835 .memory_type = MEMTYPE_EBI1,
2836};
2837
2838static struct platform_device android_pmem_adsp_device = {
2839 .name = "android_pmem",
2840 .id = 2,
2841 .dev = { .platform_data = &android_pmem_adsp_pdata },
2842};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302843
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844static struct android_pmem_platform_data android_pmem_audio_pdata = {
2845 .name = "pmem_audio",
2846 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2847 .cached = 0,
2848 .memory_type = MEMTYPE_EBI1,
2849};
2850
2851static struct platform_device android_pmem_audio_device = {
2852 .name = "android_pmem",
2853 .id = 4,
2854 .dev = { .platform_data = &android_pmem_audio_pdata },
2855};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302856#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002857#define PMEM_BUS_WIDTH(_bw) \
2858 { \
2859 .vectors = &(struct msm_bus_vectors){ \
2860 .src = MSM_BUS_MASTER_AMPSS_M0, \
2861 .dst = MSM_BUS_SLAVE_SMI, \
2862 .ib = (_bw), \
2863 .ab = 0, \
2864 }, \
2865 .num_paths = 1, \
2866 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002867
2868static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002869 [0] = PMEM_BUS_WIDTH(0), /* Off */
2870 [1] = PMEM_BUS_WIDTH(1), /* On */
2871};
2872
2873static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002874 .usecase = mem_smi_table,
2875 .num_usecases = ARRAY_SIZE(mem_smi_table),
2876 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002877};
2878
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002879int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002880{
2881 int bus_id = (int) data;
2882
2883 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002884 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002885}
2886
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002887int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002888{
2889 int bus_id = (int) data;
2890
2891 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002892 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002893}
2894
Alex Bird199980e2011-10-21 11:29:27 -07002895void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002896{
2897 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2898}
Olav Hauganee0f7802011-12-19 13:28:57 -08002899#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002900static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2901 .name = "pmem_smipool",
2902 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2903 .cached = 0,
2904 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002905 .request_region = request_smi_region,
2906 .release_region = release_smi_region,
2907 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002908 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909};
2910static struct platform_device android_pmem_smipool_device = {
2911 .name = "android_pmem",
2912 .id = 7,
2913 .dev = { .platform_data = &android_pmem_smipool_pdata },
2914};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302915#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2916#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002917
2918#define GPIO_DONGLE_PWR_EN 258
2919static void setup_display_power(void);
2920static int lcdc_vga_enabled;
2921static int vga_enable_request(int enable)
2922{
2923 if (enable)
2924 lcdc_vga_enabled = 1;
2925 else
2926 lcdc_vga_enabled = 0;
2927 setup_display_power();
2928
2929 return 0;
2930}
2931
2932#define GPIO_BACKLIGHT_PWM0 0
2933#define GPIO_BACKLIGHT_PWM1 1
2934
2935static int pmic_backlight_gpio[2]
2936 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2937static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2938 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2939 .vga_switch = vga_enable_request,
2940};
2941
2942static struct platform_device lcdc_samsung_panel_device = {
2943 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2944 .id = 0,
2945 .dev = {
2946 .platform_data = &lcdc_samsung_panel_data,
2947 }
2948};
2949#if (!defined(CONFIG_SPI_QUP)) && \
2950 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2951 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2952
2953static int lcdc_spi_gpio_array_num[] = {
2954 LCDC_SPI_GPIO_CLK,
2955 LCDC_SPI_GPIO_CS,
2956 LCDC_SPI_GPIO_MOSI,
2957};
2958
2959static uint32_t lcdc_spi_gpio_config_data[] = {
2960 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2961 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2962 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2963 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2964 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2965 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2966};
2967
2968static void lcdc_config_spi_gpios(int enable)
2969{
2970 int n;
2971 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2972 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2973}
2974#endif
2975
2976#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2977#ifdef CONFIG_SPI_QUP
2978static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2979 {
2980 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2981 .mode = SPI_MODE_3,
2982 .bus_num = 1,
2983 .chip_select = 0,
2984 .max_speed_hz = 10800000,
2985 }
2986};
2987#endif /* CONFIG_SPI_QUP */
2988
2989static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2990#ifndef CONFIG_SPI_QUP
2991 .panel_config_gpio = lcdc_config_spi_gpios,
2992 .gpio_num = lcdc_spi_gpio_array_num,
2993#endif
2994};
2995
2996static struct platform_device lcdc_samsung_oled_panel_device = {
2997 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2998 .id = 0,
2999 .dev.platform_data = &lcdc_samsung_oled_panel_data,
3000};
3001#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3002
3003#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3004#ifdef CONFIG_SPI_QUP
3005static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3006 {
3007 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3008 .mode = SPI_MODE_3,
3009 .bus_num = 1,
3010 .chip_select = 0,
3011 .max_speed_hz = 10800000,
3012 }
3013};
3014#endif
3015
3016static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3017#ifndef CONFIG_SPI_QUP
3018 .panel_config_gpio = lcdc_config_spi_gpios,
3019 .gpio_num = lcdc_spi_gpio_array_num,
3020#endif
3021};
3022
3023static struct platform_device lcdc_auo_wvga_panel_device = {
3024 .name = LCDC_AUO_PANEL_NAME,
3025 .id = 0,
3026 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3027};
3028#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3029
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003030#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3031
3032#define GPIO_NT35582_RESET 94
3033#define GPIO_NT35582_BL_EN_HW_PIN 24
3034#define GPIO_NT35582_BL_EN \
3035 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3036
3037static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3038
3039static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3040 .gpio_num = lcdc_nt35582_pmic_gpio,
3041};
3042
3043static struct platform_device lcdc_nt35582_panel_device = {
3044 .name = LCDC_NT35582_PANEL_NAME,
3045 .id = 0,
3046 .dev = {
3047 .platform_data = &lcdc_nt35582_panel_data,
3048 }
3049};
3050
3051static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3052 {
3053 .modalias = "lcdc_nt35582_spi",
3054 .mode = SPI_MODE_0,
3055 .bus_num = 0,
3056 .chip_select = 0,
3057 .max_speed_hz = 1100000,
3058 }
3059};
3060#endif
3061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003062#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3063static struct resource hdmi_msm_resources[] = {
3064 {
3065 .name = "hdmi_msm_qfprom_addr",
3066 .start = 0x00700000,
3067 .end = 0x007060FF,
3068 .flags = IORESOURCE_MEM,
3069 },
3070 {
3071 .name = "hdmi_msm_hdmi_addr",
3072 .start = 0x04A00000,
3073 .end = 0x04A00FFF,
3074 .flags = IORESOURCE_MEM,
3075 },
3076 {
3077 .name = "hdmi_msm_irq",
3078 .start = HDMI_IRQ,
3079 .end = HDMI_IRQ,
3080 .flags = IORESOURCE_IRQ,
3081 },
3082};
3083
3084static int hdmi_enable_5v(int on);
3085static int hdmi_core_power(int on, int show);
3086static int hdmi_cec_power(int on);
3087
3088static struct msm_hdmi_platform_data hdmi_msm_data = {
3089 .irq = HDMI_IRQ,
3090 .enable_5v = hdmi_enable_5v,
3091 .core_power = hdmi_core_power,
3092 .cec_power = hdmi_cec_power,
3093};
3094
3095static struct platform_device hdmi_msm_device = {
3096 .name = "hdmi_msm",
3097 .id = 0,
3098 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3099 .resource = hdmi_msm_resources,
3100 .dev.platform_data = &hdmi_msm_data,
3101};
3102#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3103
3104#ifdef CONFIG_FB_MSM_MIPI_DSI
3105static struct platform_device mipi_dsi_toshiba_panel_device = {
3106 .name = "mipi_toshiba",
3107 .id = 0,
3108};
3109
3110#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3111
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003112static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003113 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003114 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003115};
3116
3117static struct platform_device mipi_dsi_novatek_panel_device = {
3118 .name = "mipi_novatek",
3119 .id = 0,
3120 .dev = {
3121 .platform_data = &novatek_pdata,
3122 }
3123};
3124#endif
3125
3126static void __init msm8x60_allocate_memory_regions(void)
3127{
3128 void *addr;
3129 unsigned long size;
3130
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003131 if (hdmi_is_primary)
3132 size = roundup((1920 * 1088 * 4 * 2), 4096);
3133 else
3134 size = MSM_FB_SIZE;
3135
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003136 addr = alloc_bootmem_align(size, 0x1000);
3137 msm_fb_resources[0].start = __pa(addr);
3138 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3139 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3140 size, addr, __pa(addr));
3141
3142}
3143
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003144void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3145{
3146 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3147 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3148 PANEL_NAME_MAX_LEN);
3149 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3150 msm_fb_pdata.prim_panel_name);
3151
3152 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3153 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3154 PANEL_NAME_MAX_LEN))) {
3155 pr_debug("HDMI is the primary display by"
3156 " boot parameter\n");
3157 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003158 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003159 }
3160 }
3161 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3162 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3163 PANEL_NAME_MAX_LEN);
3164 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3165 msm_fb_pdata.ext_panel_name);
3166 }
3167}
3168
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003169#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3170 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3171/*virtual key support */
3172static ssize_t tma300_vkeys_show(struct kobject *kobj,
3173 struct kobj_attribute *attr, char *buf)
3174{
3175 return sprintf(buf,
3176 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3177 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3178 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3179 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3180 "\n");
3181}
3182
3183static struct kobj_attribute tma300_vkeys_attr = {
3184 .attr = {
3185 .mode = S_IRUGO,
3186 },
3187 .show = &tma300_vkeys_show,
3188};
3189
3190static struct attribute *tma300_properties_attrs[] = {
3191 &tma300_vkeys_attr.attr,
3192 NULL
3193};
3194
3195static struct attribute_group tma300_properties_attr_group = {
3196 .attrs = tma300_properties_attrs,
3197};
3198
3199static struct kobject *properties_kobj;
3200
3201
3202
3203#define CYTTSP_TS_GPIO_IRQ 61
3204static int cyttsp_platform_init(struct i2c_client *client)
3205{
3206 int rc = -EINVAL;
3207 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3208
3209 if (machine_is_msm8x60_fluid()) {
3210 pm8058_l5 = regulator_get(NULL, "8058_l5");
3211 if (IS_ERR(pm8058_l5)) {
3212 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3213 __func__, PTR_ERR(pm8058_l5));
3214 rc = PTR_ERR(pm8058_l5);
3215 return rc;
3216 }
3217 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3218 if (rc) {
3219 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3220 __func__, rc);
3221 goto reg_l5_put;
3222 }
3223
3224 rc = regulator_enable(pm8058_l5);
3225 if (rc) {
3226 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3227 __func__, rc);
3228 goto reg_l5_put;
3229 }
3230 }
3231 /* vote for s3 to enable i2c communication lines */
3232 pm8058_s3 = regulator_get(NULL, "8058_s3");
3233 if (IS_ERR(pm8058_s3)) {
3234 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3235 __func__, PTR_ERR(pm8058_s3));
3236 rc = PTR_ERR(pm8058_s3);
3237 goto reg_l5_disable;
3238 }
3239
3240 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3241 if (rc) {
3242 pr_err("%s: regulator_set_voltage() = %d\n",
3243 __func__, rc);
3244 goto reg_s3_put;
3245 }
3246
3247 rc = regulator_enable(pm8058_s3);
3248 if (rc) {
3249 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3250 __func__, rc);
3251 goto reg_s3_put;
3252 }
3253
3254 /* wait for vregs to stabilize */
3255 usleep_range(10000, 10000);
3256
3257 /* check this device active by reading first byte/register */
3258 rc = i2c_smbus_read_byte_data(client, 0x01);
3259 if (rc < 0) {
3260 pr_err("%s: i2c sanity check failed\n", __func__);
3261 goto reg_s3_disable;
3262 }
3263
3264 /* virtual keys */
3265 if (machine_is_msm8x60_fluid()) {
3266 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3267 properties_kobj = kobject_create_and_add("board_properties",
3268 NULL);
3269 if (properties_kobj)
3270 rc = sysfs_create_group(properties_kobj,
3271 &tma300_properties_attr_group);
3272 if (!properties_kobj || rc)
3273 pr_err("%s: failed to create board_properties\n",
3274 __func__);
3275 }
3276 return CY_OK;
3277
3278reg_s3_disable:
3279 regulator_disable(pm8058_s3);
3280reg_s3_put:
3281 regulator_put(pm8058_s3);
3282reg_l5_disable:
3283 if (machine_is_msm8x60_fluid())
3284 regulator_disable(pm8058_l5);
3285reg_l5_put:
3286 if (machine_is_msm8x60_fluid())
3287 regulator_put(pm8058_l5);
3288 return rc;
3289}
3290
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303291/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3292static int cyttsp_platform_suspend(struct i2c_client *client)
3293{
3294 msleep(20);
3295
3296 return CY_OK;
3297}
3298
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003299static int cyttsp_platform_resume(struct i2c_client *client)
3300{
3301 /* add any special code to strobe a wakeup pin or chip reset */
3302 msleep(10);
3303
3304 return CY_OK;
3305}
3306
3307static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3308 .flags = 0x04,
3309 .gen = CY_GEN3, /* or */
3310 .use_st = CY_USE_ST,
3311 .use_mt = CY_USE_MT,
3312 .use_hndshk = CY_SEND_HNDSHK,
3313 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303314 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003315 .use_gestures = CY_USE_GESTURES,
3316 /* activate up to 4 groups
3317 * and set active distance
3318 */
3319 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3320 CY_GEST_GRP3 | CY_GEST_GRP4 |
3321 CY_ACT_DIST,
3322 /* change act_intrvl to customize the Active power state
3323 * scanning/processing refresh interval for Operating mode
3324 */
3325 .act_intrvl = CY_ACT_INTRVL_DFLT,
3326 /* change tch_tmout to customize the touch timeout for the
3327 * Active power state for Operating mode
3328 */
3329 .tch_tmout = CY_TCH_TMOUT_DFLT,
3330 /* change lp_intrvl to customize the Low Power power state
3331 * scanning/processing refresh interval for Operating mode
3332 */
3333 .lp_intrvl = CY_LP_INTRVL_DFLT,
3334 .sleep_gpio = -1,
3335 .resout_gpio = -1,
3336 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3337 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303338 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003339 .init = cyttsp_platform_init,
3340};
3341
3342static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3343 .panel_maxx = 1083,
3344 .panel_maxy = 659,
3345 .disp_minx = 30,
3346 .disp_maxx = 1053,
3347 .disp_miny = 30,
3348 .disp_maxy = 629,
3349 .correct_fw_ver = 8,
3350 .fw_fname = "cyttsp_8660_ffa.hex",
3351 .flags = 0x00,
3352 .gen = CY_GEN2, /* or */
3353 .use_st = CY_USE_ST,
3354 .use_mt = CY_USE_MT,
3355 .use_hndshk = CY_SEND_HNDSHK,
3356 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303357 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003358 .use_gestures = CY_USE_GESTURES,
3359 /* activate up to 4 groups
3360 * and set active distance
3361 */
3362 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3363 CY_GEST_GRP3 | CY_GEST_GRP4 |
3364 CY_ACT_DIST,
3365 /* change act_intrvl to customize the Active power state
3366 * scanning/processing refresh interval for Operating mode
3367 */
3368 .act_intrvl = CY_ACT_INTRVL_DFLT,
3369 /* change tch_tmout to customize the touch timeout for the
3370 * Active power state for Operating mode
3371 */
3372 .tch_tmout = CY_TCH_TMOUT_DFLT,
3373 /* change lp_intrvl to customize the Low Power power state
3374 * scanning/processing refresh interval for Operating mode
3375 */
3376 .lp_intrvl = CY_LP_INTRVL_DFLT,
3377 .sleep_gpio = -1,
3378 .resout_gpio = -1,
3379 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3380 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303381 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003382 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303383 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384};
3385static void cyttsp_set_params(void)
3386{
3387 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3388 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3389 cyttsp_fluid_pdata.panel_maxx = 539;
3390 cyttsp_fluid_pdata.panel_maxy = 994;
3391 cyttsp_fluid_pdata.disp_minx = 30;
3392 cyttsp_fluid_pdata.disp_maxx = 509;
3393 cyttsp_fluid_pdata.disp_miny = 60;
3394 cyttsp_fluid_pdata.disp_maxy = 859;
3395 cyttsp_fluid_pdata.correct_fw_ver = 4;
3396 } else {
3397 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3398 cyttsp_fluid_pdata.panel_maxx = 550;
3399 cyttsp_fluid_pdata.panel_maxy = 1013;
3400 cyttsp_fluid_pdata.disp_minx = 35;
3401 cyttsp_fluid_pdata.disp_maxx = 515;
3402 cyttsp_fluid_pdata.disp_miny = 69;
3403 cyttsp_fluid_pdata.disp_maxy = 869;
3404 cyttsp_fluid_pdata.correct_fw_ver = 5;
3405 }
3406
3407}
3408
3409static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3410 {
3411 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3412 .platform_data = &cyttsp_fluid_pdata,
3413#ifndef CY_USE_TIMER
3414 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3415#endif /* CY_USE_TIMER */
3416 },
3417};
3418
3419static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3420 {
3421 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3422 .platform_data = &cyttsp_tmg240_pdata,
3423#ifndef CY_USE_TIMER
3424 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3425#endif /* CY_USE_TIMER */
3426 },
3427};
3428#endif
3429
3430static struct regulator *vreg_tmg200;
3431
3432#define TS_PEN_IRQ_GPIO 61
3433static int tmg200_power(int vreg_on)
3434{
3435 int rc = -EINVAL;
3436
3437 if (!vreg_tmg200) {
3438 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3439 __func__, rc);
3440 return rc;
3441 }
3442
3443 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3444 regulator_disable(vreg_tmg200);
3445 if (rc < 0)
3446 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3447 __func__, vreg_on ? "enable" : "disable", rc);
3448
3449 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003450 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003451
3452 return rc;
3453}
3454
3455static int tmg200_dev_setup(bool enable)
3456{
3457 int rc;
3458
3459 if (enable) {
3460 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3461 if (IS_ERR(vreg_tmg200)) {
3462 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3463 __func__, PTR_ERR(vreg_tmg200));
3464 rc = PTR_ERR(vreg_tmg200);
3465 return rc;
3466 }
3467
3468 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3469 if (rc) {
3470 pr_err("%s: regulator_set_voltage() = %d\n",
3471 __func__, rc);
3472 goto reg_put;
3473 }
3474 } else {
3475 /* put voltage sources */
3476 regulator_put(vreg_tmg200);
3477 }
3478 return 0;
3479reg_put:
3480 regulator_put(vreg_tmg200);
3481 return rc;
3482}
3483
3484static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3485 .ts_name = "msm_tmg200_ts",
3486 .dis_min_x = 0,
3487 .dis_max_x = 1023,
3488 .dis_min_y = 0,
3489 .dis_max_y = 599,
3490 .min_tid = 0,
3491 .max_tid = 255,
3492 .min_touch = 0,
3493 .max_touch = 255,
3494 .min_width = 0,
3495 .max_width = 255,
3496 .power_on = tmg200_power,
3497 .dev_setup = tmg200_dev_setup,
3498 .nfingers = 2,
3499 .irq_gpio = TS_PEN_IRQ_GPIO,
3500 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3501};
3502
3503static struct i2c_board_info cy8ctmg200_board_info[] = {
3504 {
3505 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3506 .platform_data = &cy8ctmg200_pdata,
3507 }
3508};
3509
Zhang Chang Ken211df572011-07-05 19:16:39 -04003510static struct regulator *vreg_tma340;
3511
3512static int tma340_power(int vreg_on)
3513{
3514 int rc = -EINVAL;
3515
3516 if (!vreg_tma340) {
3517 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3518 __func__, rc);
3519 return rc;
3520 }
3521
3522 rc = vreg_on ? regulator_enable(vreg_tma340) :
3523 regulator_disable(vreg_tma340);
3524 if (rc < 0)
3525 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3526 __func__, vreg_on ? "enable" : "disable", rc);
3527
3528 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003529 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003530
3531 return rc;
3532}
3533
3534static struct kobject *tma340_prop_kobj;
3535
3536static int tma340_dragon_dev_setup(bool enable)
3537{
3538 int rc;
3539
3540 if (enable) {
3541 vreg_tma340 = regulator_get(NULL, "8901_l2");
3542 if (IS_ERR(vreg_tma340)) {
3543 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3544 __func__, PTR_ERR(vreg_tma340));
3545 rc = PTR_ERR(vreg_tma340);
3546 return rc;
3547 }
3548
3549 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3550 if (rc) {
3551 pr_err("%s: regulator_set_voltage() = %d\n",
3552 __func__, rc);
3553 goto reg_put;
3554 }
3555 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3556 tma340_prop_kobj = kobject_create_and_add("board_properties",
3557 NULL);
3558 if (tma340_prop_kobj) {
3559 rc = sysfs_create_group(tma340_prop_kobj,
3560 &tma300_properties_attr_group);
3561 if (rc) {
3562 kobject_put(tma340_prop_kobj);
3563 pr_err("%s: failed to create board_properties\n",
3564 __func__);
3565 goto reg_put;
3566 }
3567 }
3568
3569 } else {
3570 /* put voltage sources */
3571 regulator_put(vreg_tma340);
3572 /* destroy virtual keys */
3573 if (tma340_prop_kobj) {
3574 sysfs_remove_group(tma340_prop_kobj,
3575 &tma300_properties_attr_group);
3576 kobject_put(tma340_prop_kobj);
3577 }
3578 }
3579 return 0;
3580reg_put:
3581 regulator_put(vreg_tma340);
3582 return rc;
3583}
3584
3585
3586static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3587 .ts_name = "cy8ctma340",
3588 .dis_min_x = 0,
3589 .dis_max_x = 479,
3590 .dis_min_y = 0,
3591 .dis_max_y = 799,
3592 .min_tid = 0,
3593 .max_tid = 255,
3594 .min_touch = 0,
3595 .max_touch = 255,
3596 .min_width = 0,
3597 .max_width = 255,
3598 .power_on = tma340_power,
3599 .dev_setup = tma340_dragon_dev_setup,
3600 .nfingers = 2,
3601 .irq_gpio = TS_PEN_IRQ_GPIO,
3602 .resout_gpio = -1,
3603};
3604
3605static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3606 {
3607 I2C_BOARD_INFO("cy8ctma340", 0x24),
3608 .platform_data = &cy8ctma340_dragon_pdata,
3609 }
3610};
3611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003612#ifdef CONFIG_SERIAL_MSM_HS
3613static int configure_uart_gpios(int on)
3614{
3615 int ret = 0, i;
3616 int uart_gpios[] = {53, 54, 55, 56};
3617 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3618 if (on) {
3619 ret = msm_gpiomux_get(uart_gpios[i]);
3620 if (unlikely(ret))
3621 break;
3622 } else {
3623 ret = msm_gpiomux_put(uart_gpios[i]);
3624 if (unlikely(ret))
3625 return ret;
3626 }
3627 }
3628 if (ret)
3629 for (; i >= 0; i--)
3630 msm_gpiomux_put(uart_gpios[i]);
3631 return ret;
3632}
3633static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3634 .inject_rx_on_wakeup = 1,
3635 .rx_to_inject = 0xFD,
3636 .gpio_config = configure_uart_gpios,
3637};
3638#endif
3639
3640
3641#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3642
3643static struct gpio_led gpio_exp_leds_config[] = {
3644 {
3645 .name = "left_led1:green",
3646 .gpio = GPIO_LEFT_LED_1,
3647 .active_low = 1,
3648 .retain_state_suspended = 0,
3649 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3650 },
3651 {
3652 .name = "left_led2:red",
3653 .gpio = GPIO_LEFT_LED_2,
3654 .active_low = 1,
3655 .retain_state_suspended = 0,
3656 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3657 },
3658 {
3659 .name = "left_led3:green",
3660 .gpio = GPIO_LEFT_LED_3,
3661 .active_low = 1,
3662 .retain_state_suspended = 0,
3663 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3664 },
3665 {
3666 .name = "wlan_led:orange",
3667 .gpio = GPIO_LEFT_LED_WLAN,
3668 .active_low = 1,
3669 .retain_state_suspended = 0,
3670 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3671 },
3672 {
3673 .name = "left_led5:green",
3674 .gpio = GPIO_LEFT_LED_5,
3675 .active_low = 1,
3676 .retain_state_suspended = 0,
3677 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3678 },
3679 {
3680 .name = "right_led1:green",
3681 .gpio = GPIO_RIGHT_LED_1,
3682 .active_low = 1,
3683 .retain_state_suspended = 0,
3684 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3685 },
3686 {
3687 .name = "right_led2:red",
3688 .gpio = GPIO_RIGHT_LED_2,
3689 .active_low = 1,
3690 .retain_state_suspended = 0,
3691 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3692 },
3693 {
3694 .name = "right_led3:green",
3695 .gpio = GPIO_RIGHT_LED_3,
3696 .active_low = 1,
3697 .retain_state_suspended = 0,
3698 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3699 },
3700 {
3701 .name = "bt_led:blue",
3702 .gpio = GPIO_RIGHT_LED_BT,
3703 .active_low = 1,
3704 .retain_state_suspended = 0,
3705 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3706 },
3707 {
3708 .name = "right_led5:green",
3709 .gpio = GPIO_RIGHT_LED_5,
3710 .active_low = 1,
3711 .retain_state_suspended = 0,
3712 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3713 },
3714};
3715
3716static struct gpio_led_platform_data gpio_leds_pdata = {
3717 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3718 .leds = gpio_exp_leds_config,
3719};
3720
3721static struct platform_device gpio_leds = {
3722 .name = "leds-gpio",
3723 .id = -1,
3724 .dev = {
3725 .platform_data = &gpio_leds_pdata,
3726 },
3727};
3728
3729static struct gpio_led fluid_gpio_leds[] = {
3730 {
3731 .name = "dual_led:green",
3732 .gpio = GPIO_LED1_GREEN_N,
3733 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3734 .active_low = 1,
3735 .retain_state_suspended = 0,
3736 },
3737 {
3738 .name = "dual_led:red",
3739 .gpio = GPIO_LED2_RED_N,
3740 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3741 .active_low = 1,
3742 .retain_state_suspended = 0,
3743 },
3744};
3745
3746static struct gpio_led_platform_data gpio_led_pdata = {
3747 .leds = fluid_gpio_leds,
3748 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3749};
3750
3751static struct platform_device fluid_leds_gpio = {
3752 .name = "leds-gpio",
3753 .id = -1,
3754 .dev = {
3755 .platform_data = &gpio_led_pdata,
3756 },
3757};
3758
3759#endif
3760
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003761#ifdef CONFIG_BATTERY_MSM8X60
3762static struct msm_charger_platform_data msm_charger_data = {
3763 .safety_time = 180,
3764 .update_time = 1,
3765 .max_voltage = 4200,
3766 .min_voltage = 3200,
3767};
3768
3769static struct platform_device msm_charger_device = {
3770 .name = "msm-charger",
3771 .id = -1,
3772 .dev = {
3773 .platform_data = &msm_charger_data,
3774 }
3775};
3776#endif
3777
3778/*
3779 * Consumer specific regulator names:
3780 * regulator name consumer dev_name
3781 */
3782static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3783 REGULATOR_SUPPLY("8058_l0", NULL),
3784};
3785static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3786 REGULATOR_SUPPLY("8058_l1", NULL),
3787};
3788static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3789 REGULATOR_SUPPLY("8058_l2", NULL),
3790};
3791static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3792 REGULATOR_SUPPLY("8058_l3", NULL),
3793};
3794static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3795 REGULATOR_SUPPLY("8058_l4", NULL),
3796};
3797static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3798 REGULATOR_SUPPLY("8058_l5", NULL),
3799};
3800static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3801 REGULATOR_SUPPLY("8058_l6", NULL),
3802};
3803static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3804 REGULATOR_SUPPLY("8058_l7", NULL),
3805};
3806static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3807 REGULATOR_SUPPLY("8058_l8", NULL),
3808};
3809static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3810 REGULATOR_SUPPLY("8058_l9", NULL),
3811};
3812static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3813 REGULATOR_SUPPLY("8058_l10", NULL),
3814};
3815static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3816 REGULATOR_SUPPLY("8058_l11", NULL),
3817};
3818static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3819 REGULATOR_SUPPLY("8058_l12", NULL),
3820};
3821static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3822 REGULATOR_SUPPLY("8058_l13", NULL),
3823};
3824static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3825 REGULATOR_SUPPLY("8058_l14", NULL),
3826};
3827static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3828 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003829 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003830 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003831 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3834 REGULATOR_SUPPLY("8058_l16", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3837 REGULATOR_SUPPLY("8058_l17", NULL),
3838};
3839static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3840 REGULATOR_SUPPLY("8058_l18", NULL),
3841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3843 REGULATOR_SUPPLY("8058_l19", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3846 REGULATOR_SUPPLY("8058_l20", NULL),
3847};
3848static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3849 REGULATOR_SUPPLY("8058_l21", NULL),
3850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3852 REGULATOR_SUPPLY("8058_l22", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3855 REGULATOR_SUPPLY("8058_l23", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3858 REGULATOR_SUPPLY("8058_l24", NULL),
3859};
3860static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3861 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003862 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003863 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003864 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3867 REGULATOR_SUPPLY("8058_s0", NULL),
3868};
3869static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3870 REGULATOR_SUPPLY("8058_s1", NULL),
3871};
3872static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3873 REGULATOR_SUPPLY("8058_s2", NULL),
3874};
3875static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3876 REGULATOR_SUPPLY("8058_s3", NULL),
3877};
3878static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3879 REGULATOR_SUPPLY("8058_s4", NULL),
3880};
3881static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3882 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003883 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003884 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003885 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003886};
3887static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3888 REGULATOR_SUPPLY("8058_lvs1", NULL),
3889};
3890static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3891 REGULATOR_SUPPLY("8058_ncp", NULL),
3892};
3893
3894static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3895 REGULATOR_SUPPLY("8901_l0", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3898 REGULATOR_SUPPLY("8901_l1", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3901 REGULATOR_SUPPLY("8901_l2", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3904 REGULATOR_SUPPLY("8901_l3", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3907 REGULATOR_SUPPLY("8901_l4", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3910 REGULATOR_SUPPLY("8901_l5", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3913 REGULATOR_SUPPLY("8901_l6", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3916 REGULATOR_SUPPLY("8901_s2", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3919 REGULATOR_SUPPLY("8901_s3", NULL),
3920};
3921static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3922 REGULATOR_SUPPLY("8901_s4", NULL),
3923};
3924static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3925 REGULATOR_SUPPLY("8901_lvs0", NULL),
3926};
3927static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3928 REGULATOR_SUPPLY("8901_lvs1", NULL),
3929};
3930static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3931 REGULATOR_SUPPLY("8901_lvs2", NULL),
3932};
3933static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3934 REGULATOR_SUPPLY("8901_lvs3", NULL),
3935};
3936static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3937 REGULATOR_SUPPLY("8901_mvs0", NULL),
3938};
3939
David Collins6f032ba2011-08-31 14:08:15 -07003940/* Pin control regulators */
3941static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3942 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3943};
3944static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3945 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3946};
3947static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3948 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3949};
3950static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3951 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3952};
3953static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3954 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3955};
3956static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3957 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3958};
3959
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003960#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3961 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003962 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3963 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003964 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003965 .init_data = { \
3966 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003967 .valid_modes_mask = _modes, \
3968 .valid_ops_mask = _ops, \
3969 .min_uV = _min_uV, \
3970 .max_uV = _max_uV, \
3971 .input_uV = _min_uV, \
3972 .apply_uV = _apply_uV, \
3973 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003974 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003975 .consumer_supplies = vreg_consumers_##_id, \
3976 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003977 ARRAY_SIZE(vreg_consumers_##_id), \
3978 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003979 .id = RPM_VREG_ID_##_id, \
3980 .default_uV = _default_uV, \
3981 .peak_uA = _peak_uA, \
3982 .avg_uA = _avg_uA, \
3983 .pull_down_enable = _pull_down, \
3984 .pin_ctrl = _pin_ctrl, \
3985 .freq = RPM_VREG_FREQ_##_freq, \
3986 .pin_fn = _pin_fn, \
3987 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003988 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003989 .state = _state, \
3990 .sleep_selectable = _sleep_selectable, \
3991 }
3992
3993/* Pin control initialization */
3994#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3995 { \
3996 .init_data = { \
3997 .constraints = { \
3998 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3999 .always_on = _always_on, \
4000 }, \
4001 .num_consumer_supplies = \
4002 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
4003 .consumer_supplies = vreg_consumers_##_id##_PC, \
4004 }, \
4005 .id = RPM_VREG_ID_##_id##_PC, \
4006 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004007 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004008 }
4009
4010/*
4011 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4012 * via the peak_uA value specified in the table below. If the value is less
4013 * than the high power min threshold for the regulator, then the regulator will
4014 * be set to LPM. Otherwise, it will be set to HPM.
4015 *
4016 * This value can be further overridden by specifying an initial mode via
4017 * .init_data.constraints.initial_mode.
4018 */
4019
David Collins6f032ba2011-08-31 14:08:15 -07004020#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4021 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004022 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4023 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4024 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4025 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4026 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004027 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4028 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004029 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004030 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004031 _sleep_selectable, _always_on)
4032
David Collins6f032ba2011-08-31 14:08:15 -07004033#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4034 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004035 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4036 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4037 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4038 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4039 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004040 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4041 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004042 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004043 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4044 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045
David Collins6f032ba2011-08-31 14:08:15 -07004046#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004047 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4048 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004049 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4050 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004051 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004052 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4053 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004054
David Collins6f032ba2011-08-31 14:08:15 -07004055#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004056 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4057 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004058 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4059 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004060 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004061 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4062 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004063
David Collins6f032ba2011-08-31 14:08:15 -07004064#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4065#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4066#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4067#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4068#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004069
David Collins6f032ba2011-08-31 14:08:15 -07004070/* RPM early regulator constraints */
4071static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4072 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004073 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004074 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004075};
4076
David Collins6f032ba2011-08-31 14:08:15 -07004077/* RPM regulator constraints */
4078static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4079 /* ID a_on pd ss min_uV max_uV init_ip */
4080 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4081 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4082 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4083 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4084 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4085 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4086 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4087 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4088 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4089 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4090 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4091 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4092 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4093 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4094 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4095 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4096 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4097 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4098 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4099 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4100 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4101 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4102 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4103 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4104 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4105 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004106
David Collins6f032ba2011-08-31 14:08:15 -07004107 /* ID a_on pd ss min_uV max_uV init_ip freq */
4108 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4109 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4110 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4111
4112 /* ID a_on pd ss */
4113 RPM_VS(PM8058_LVS0, 0, 1, 0),
4114 RPM_VS(PM8058_LVS1, 0, 1, 0),
4115
4116 /* ID a_on pd ss min_uV max_uV */
4117 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4118
4119 /* ID a_on pd ss min_uV max_uV init_ip */
4120 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4121 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4122 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4123 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4124 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4125 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4126 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4127
4128 /* ID a_on pd ss min_uV max_uV init_ip freq */
4129 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4130 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4131 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4132
4133 /* ID a_on pd ss */
4134 RPM_VS(PM8901_LVS0, 1, 1, 0),
4135 RPM_VS(PM8901_LVS1, 0, 1, 0),
4136 RPM_VS(PM8901_LVS2, 0, 1, 0),
4137 RPM_VS(PM8901_LVS3, 0, 1, 0),
4138 RPM_VS(PM8901_MVS0, 0, 1, 0),
4139
4140 /* ID a_on pin_func pin_ctrl */
4141 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4142 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4143 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4144 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4145 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4146 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4147};
4148
4149static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4150 .init_data = rpm_regulator_early_init_data,
4151 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4152 .version = RPM_VREG_VERSION_8660,
4153 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4154 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4155};
4156
4157static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4158 .init_data = rpm_regulator_init_data,
4159 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4160 .version = RPM_VREG_VERSION_8660,
4161};
4162
4163static struct platform_device rpm_regulator_early_device = {
4164 .name = "rpm-regulator",
4165 .id = 0,
4166 .dev = {
4167 .platform_data = &rpm_regulator_early_pdata,
4168 },
4169};
4170
4171static struct platform_device rpm_regulator_device = {
4172 .name = "rpm-regulator",
4173 .id = 1,
4174 .dev = {
4175 .platform_data = &rpm_regulator_pdata,
4176 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004177};
4178
4179static struct platform_device *early_regulators[] __initdata = {
4180 &msm_device_saw_s0,
4181 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004182 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004183};
4184
4185static struct platform_device *early_devices[] __initdata = {
4186#ifdef CONFIG_MSM_BUS_SCALING
4187 &msm_bus_apps_fabric,
4188 &msm_bus_sys_fabric,
4189 &msm_bus_mm_fabric,
4190 &msm_bus_sys_fpb,
4191 &msm_bus_cpss_fpb,
4192#endif
4193 &msm_device_dmov_adm0,
4194 &msm_device_dmov_adm1,
4195};
4196
4197#if (defined(CONFIG_MARIMBA_CORE)) && \
4198 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4199
4200static int bluetooth_power(int);
4201static struct platform_device msm_bt_power_device = {
4202 .name = "bt_power",
4203 .id = -1,
4204 .dev = {
4205 .platform_data = &bluetooth_power,
4206 },
4207};
4208#endif
4209
4210static struct platform_device msm_tsens_device = {
4211 .name = "tsens-tm",
4212 .id = -1,
4213};
4214
4215static struct platform_device *rumi_sim_devices[] __initdata = {
4216 &smc91x_device,
4217 &msm_device_uart_dm12,
4218#ifdef CONFIG_I2C_QUP
4219 &msm_gsbi3_qup_i2c_device,
4220 &msm_gsbi4_qup_i2c_device,
4221 &msm_gsbi7_qup_i2c_device,
4222 &msm_gsbi8_qup_i2c_device,
4223 &msm_gsbi9_qup_i2c_device,
4224 &msm_gsbi12_qup_i2c_device,
4225#endif
4226#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004227 &msm_device_ssbi3,
4228#endif
4229#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004230#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004231 &android_pmem_device,
4232 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004233 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004234 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304235#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4236#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004237#ifdef CONFIG_MSM_ROTATOR
4238 &msm_rotator_device,
4239#endif
4240 &msm_fb_device,
4241 &msm_kgsl_3d0,
4242 &msm_kgsl_2d0,
4243 &msm_kgsl_2d1,
4244 &lcdc_samsung_panel_device,
4245#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4246 &hdmi_msm_device,
4247#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4248#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004249#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004250#ifdef CONFIG_MT9E013
4251 &msm_camera_sensor_mt9e013,
4252#endif
4253#ifdef CONFIG_IMX074
4254 &msm_camera_sensor_imx074,
4255#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004256#ifdef CONFIG_VX6953
4257 &msm_camera_sensor_vx6953,
4258#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004259#ifdef CONFIG_WEBCAM_OV7692
4260 &msm_camera_sensor_webcam_ov7692,
4261#endif
4262#ifdef CONFIG_WEBCAM_OV9726
4263 &msm_camera_sensor_webcam_ov9726,
4264#endif
4265#ifdef CONFIG_QS_S5K4E1
4266 &msm_camera_sensor_qs_s5k4e1,
4267#endif
4268#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004269#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004270#ifdef CONFIG_MSM_GEMINI
4271 &msm_gemini_device,
4272#endif
4273#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004274#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004275 &msm_vpe_device,
4276#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004277#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004278 &msm_device_vidc,
4279};
4280
4281#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4282enum {
4283 SX150X_CORE,
4284 SX150X_DOCKING,
4285 SX150X_SURF,
4286 SX150X_LEFT_FHA,
4287 SX150X_RIGHT_FHA,
4288 SX150X_SOUTH,
4289 SX150X_NORTH,
4290 SX150X_CORE_FLUID,
4291};
4292
4293static struct sx150x_platform_data sx150x_data[] __initdata = {
4294 [SX150X_CORE] = {
4295 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4296 .oscio_is_gpo = false,
4297 .io_pullup_ena = 0x0c08,
4298 .io_pulldn_ena = 0x4060,
4299 .io_open_drain_ena = 0x000c,
4300 .io_polarity = 0,
4301 .irq_summary = -1, /* see fixup_i2c_configs() */
4302 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4303 },
4304 [SX150X_DOCKING] = {
4305 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4306 .oscio_is_gpo = false,
4307 .io_pullup_ena = 0x5e06,
4308 .io_pulldn_ena = 0x81b8,
4309 .io_open_drain_ena = 0,
4310 .io_polarity = 0,
4311 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4312 UI_INT2_N),
4313 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4314 GPIO_DOCKING_EXPANDER_BASE -
4315 GPIO_EXPANDER_GPIO_BASE,
4316 },
4317 [SX150X_SURF] = {
4318 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4319 .oscio_is_gpo = false,
4320 .io_pullup_ena = 0,
4321 .io_pulldn_ena = 0,
4322 .io_open_drain_ena = 0,
4323 .io_polarity = 0,
4324 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4325 UI_INT1_N),
4326 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4327 GPIO_SURF_EXPANDER_BASE -
4328 GPIO_EXPANDER_GPIO_BASE,
4329 },
4330 [SX150X_LEFT_FHA] = {
4331 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4332 .oscio_is_gpo = false,
4333 .io_pullup_ena = 0,
4334 .io_pulldn_ena = 0x40,
4335 .io_open_drain_ena = 0,
4336 .io_polarity = 0,
4337 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4338 UI_INT3_N),
4339 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4340 GPIO_LEFT_KB_EXPANDER_BASE -
4341 GPIO_EXPANDER_GPIO_BASE,
4342 },
4343 [SX150X_RIGHT_FHA] = {
4344 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4345 .oscio_is_gpo = true,
4346 .io_pullup_ena = 0,
4347 .io_pulldn_ena = 0,
4348 .io_open_drain_ena = 0,
4349 .io_polarity = 0,
4350 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4351 UI_INT3_N),
4352 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4353 GPIO_RIGHT_KB_EXPANDER_BASE -
4354 GPIO_EXPANDER_GPIO_BASE,
4355 },
4356 [SX150X_SOUTH] = {
4357 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4358 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4359 GPIO_SOUTH_EXPANDER_BASE -
4360 GPIO_EXPANDER_GPIO_BASE,
4361 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4362 },
4363 [SX150X_NORTH] = {
4364 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4365 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4366 GPIO_NORTH_EXPANDER_BASE -
4367 GPIO_EXPANDER_GPIO_BASE,
4368 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4369 .oscio_is_gpo = true,
4370 .io_open_drain_ena = 0x30,
4371 },
4372 [SX150X_CORE_FLUID] = {
4373 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4374 .oscio_is_gpo = false,
4375 .io_pullup_ena = 0x0408,
4376 .io_pulldn_ena = 0x4060,
4377 .io_open_drain_ena = 0x0008,
4378 .io_polarity = 0,
4379 .irq_summary = -1, /* see fixup_i2c_configs() */
4380 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4381 },
4382};
4383
4384#ifdef CONFIG_SENSORS_MSM_ADC
4385/* Configuration of EPM expander is done when client
4386 * request an adc read
4387 */
4388static struct sx150x_platform_data sx150x_epmdata = {
4389 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4390 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4391 GPIO_EPM_EXPANDER_BASE -
4392 GPIO_EXPANDER_GPIO_BASE,
4393 .irq_summary = -1,
4394};
4395#endif
4396
4397/* sx150x_low_power_cfg
4398 *
4399 * This data and init function are used to put unused gpio-expander output
4400 * lines into their low-power states at boot. The init
4401 * function must be deferred until a later init stage because the i2c
4402 * gpio expander drivers do not probe until after they are registered
4403 * (see register_i2c_devices) and the work-queues for those registrations
4404 * are processed. Because these lines are unused, there is no risk of
4405 * competing with a device driver for the gpio.
4406 *
4407 * gpio lines whose low-power states are input are naturally in their low-
4408 * power configurations once probed, see the platform data structures above.
4409 */
4410struct sx150x_low_power_cfg {
4411 unsigned gpio;
4412 unsigned val;
4413};
4414
4415static struct sx150x_low_power_cfg
4416common_sx150x_lp_cfgs[] __initdata = {
4417 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4418 {GPIO_EXT_GPS_LNA_EN, 0},
4419 {GPIO_MSM_WAKES_BT, 0},
4420 {GPIO_USB_UICC_EN, 0},
4421 {GPIO_BATT_GAUGE_EN, 0},
4422};
4423
4424static struct sx150x_low_power_cfg
4425surf_ffa_sx150x_lp_cfgs[] __initdata = {
4426 {GPIO_MIPI_DSI_RST_N, 0},
4427 {GPIO_DONGLE_PWR_EN, 0},
4428 {GPIO_CAP_TS_SLEEP, 1},
4429 {GPIO_WEB_CAMIF_RESET_N, 0},
4430};
4431
4432static void __init
4433cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4434{
4435 unsigned n;
4436 int rc;
4437
4438 for (n = 0; n < nelems; ++n) {
4439 rc = gpio_request(cfgs[n].gpio, NULL);
4440 if (!rc) {
4441 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4442 gpio_free(cfgs[n].gpio);
4443 }
4444
4445 if (rc) {
4446 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4447 __func__, cfgs[n].gpio, rc);
4448 }
Steve Muckle9161d302010-02-11 11:50:40 -08004449 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004450}
4451
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004452static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004453{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004454 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4455 ARRAY_SIZE(common_sx150x_lp_cfgs));
4456 if (!machine_is_msm8x60_fluid())
4457 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4458 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4459 return 0;
4460}
4461module_init(cfg_sx150xs_low_power);
4462
4463#ifdef CONFIG_I2C
4464static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4465 {
4466 I2C_BOARD_INFO("sx1509q", 0x3e),
4467 .platform_data = &sx150x_data[SX150X_CORE]
4468 },
4469};
4470
4471static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4472 {
4473 I2C_BOARD_INFO("sx1509q", 0x3f),
4474 .platform_data = &sx150x_data[SX150X_DOCKING]
4475 },
4476};
4477
4478static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4479 {
4480 I2C_BOARD_INFO("sx1509q", 0x70),
4481 .platform_data = &sx150x_data[SX150X_SURF]
4482 }
4483};
4484
4485static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4486 {
4487 I2C_BOARD_INFO("sx1508q", 0x21),
4488 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4489 },
4490 {
4491 I2C_BOARD_INFO("sx1508q", 0x22),
4492 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4493 }
4494};
4495
4496static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4497 {
4498 I2C_BOARD_INFO("sx1508q", 0x23),
4499 .platform_data = &sx150x_data[SX150X_SOUTH]
4500 },
4501 {
4502 I2C_BOARD_INFO("sx1508q", 0x20),
4503 .platform_data = &sx150x_data[SX150X_NORTH]
4504 }
4505};
4506
4507static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4508 {
4509 I2C_BOARD_INFO("sx1509q", 0x3e),
4510 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4511 },
4512};
4513
4514#ifdef CONFIG_SENSORS_MSM_ADC
4515static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4516 {
4517 I2C_BOARD_INFO("sx1509q", 0x3e),
4518 .platform_data = &sx150x_epmdata
4519 },
4520};
4521#endif
4522#endif
4523#endif
4524
4525#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004526
4527static struct adc_access_fn xoadc_fn = {
4528 pm8058_xoadc_select_chan_and_start_conv,
4529 pm8058_xoadc_read_adc_code,
4530 pm8058_xoadc_get_properties,
4531 pm8058_xoadc_slot_request,
4532 pm8058_xoadc_restore_slot,
4533 pm8058_xoadc_calibrate,
4534};
4535
4536#if defined(CONFIG_I2C) && \
4537 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4538static struct regulator *vreg_adc_epm1;
4539
4540static struct i2c_client *epm_expander_i2c_register_board(void)
4541
4542{
4543 struct i2c_adapter *i2c_adap;
4544 struct i2c_client *client = NULL;
4545 i2c_adap = i2c_get_adapter(0x0);
4546
4547 if (i2c_adap == NULL)
4548 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4549
4550 if (i2c_adap != NULL)
4551 client = i2c_new_device(i2c_adap,
4552 &fluid_expanders_i2c_epm_info[0]);
4553 return client;
4554
4555}
4556
4557static unsigned int msm_adc_gpio_configure_expander_enable(void)
4558{
4559 int rc = 0;
4560 static struct i2c_client *epm_i2c_client;
4561
4562 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4563
4564 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4565
4566 if (IS_ERR(vreg_adc_epm1)) {
4567 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4568 return 0;
4569 }
4570
4571 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4572 if (rc)
4573 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4574 "regulator set voltage failed\n");
4575
4576 rc = regulator_enable(vreg_adc_epm1);
4577 if (rc) {
4578 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4579 "Error while enabling regulator for epm s3 %d\n", rc);
4580 return rc;
4581 }
4582
4583 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4584 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4585
4586 msleep(1000);
4587
4588 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4589 if (!rc) {
4590 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4591 "Configure 5v boost\n");
4592 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4593 } else {
4594 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4595 "Error for epm 5v boost en\n");
4596 goto exit_vreg_epm;
4597 }
4598
4599 msleep(500);
4600
4601 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4602 if (!rc) {
4603 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4604 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4605 "Configure epm 3.3v\n");
4606 } else {
4607 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4608 "Error for gpio 3.3ven\n");
4609 goto exit_vreg_epm;
4610 }
4611 msleep(500);
4612
4613 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4614 "Trying to request EPM LVLSFT_EN\n");
4615 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4616 if (!rc) {
4617 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4618 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4619 "Configure the lvlsft\n");
4620 } else {
4621 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4622 "Error for epm lvlsft_en\n");
4623 goto exit_vreg_epm;
4624 }
4625
4626 msleep(500);
4627
4628 if (!epm_i2c_client)
4629 epm_i2c_client = epm_expander_i2c_register_board();
4630
4631 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4632 if (!rc)
4633 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4634 if (rc) {
4635 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4636 ": GPIO PWR MON Enable issue\n");
4637 goto exit_vreg_epm;
4638 }
4639
4640 msleep(1000);
4641
4642 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4643 if (!rc) {
4644 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4645 if (rc) {
4646 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4647 ": ADC1_PWDN error direction out\n");
4648 goto exit_vreg_epm;
4649 }
4650 }
4651
4652 msleep(100);
4653
4654 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4655 if (!rc) {
4656 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4657 if (rc) {
4658 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4659 ": ADC2_PWD error direction out\n");
4660 goto exit_vreg_epm;
4661 }
4662 }
4663
4664 msleep(1000);
4665
4666 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4667 if (!rc) {
4668 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4669 if (rc) {
4670 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4671 "Gpio request problem %d\n", rc);
4672 goto exit_vreg_epm;
4673 }
4674 }
4675
4676 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4677 if (!rc) {
4678 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4679 if (rc) {
4680 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4681 ": EPM_SPI_ADC1_CS_N error\n");
4682 goto exit_vreg_epm;
4683 }
4684 }
4685
4686 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4687 if (!rc) {
4688 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4689 if (rc) {
4690 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4691 ": EPM_SPI_ADC2_Cs_N error\n");
4692 goto exit_vreg_epm;
4693 }
4694 }
4695
4696 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4697 "the power monitor reset for epm\n");
4698
4699 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4700 if (!rc) {
4701 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4702 if (rc) {
4703 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4704 ": Error in the power mon reset\n");
4705 goto exit_vreg_epm;
4706 }
4707 }
4708
4709 msleep(1000);
4710
4711 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4712
4713 msleep(500);
4714
4715 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4716
4717 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4718
4719 return rc;
4720
4721exit_vreg_epm:
4722 regulator_disable(vreg_adc_epm1);
4723
4724 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4725 " rc = %d.\n", rc);
4726 return rc;
4727};
4728
4729static unsigned int msm_adc_gpio_configure_expander_disable(void)
4730{
4731 int rc = 0;
4732
4733 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4734 gpio_free(GPIO_PWR_MON_RESET_N);
4735
4736 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4737 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4738
4739 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4740 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4741
4742 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4743 gpio_free(GPIO_PWR_MON_START);
4744
4745 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4746 gpio_free(GPIO_ADC1_PWDN_N);
4747
4748 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4749 gpio_free(GPIO_ADC2_PWDN_N);
4750
4751 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4752 gpio_free(GPIO_PWR_MON_ENABLE);
4753
4754 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4755 gpio_free(GPIO_EPM_LVLSFT_EN);
4756
4757 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4758 gpio_free(GPIO_EPM_5V_BOOST_EN);
4759
4760 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4761 gpio_free(GPIO_EPM_3_3V_EN);
4762
4763 rc = regulator_disable(vreg_adc_epm1);
4764 if (rc)
4765 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4766 "Error while enabling regulator for epm s3 %d\n", rc);
4767 regulator_put(vreg_adc_epm1);
4768
4769 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4770 return rc;
4771};
4772
4773unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4774{
4775 int rc = 0;
4776
4777 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4778 cs_enable);
4779
4780 if (cs_enable < 16) {
4781 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4782 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4783 } else {
4784 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4785 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4786 }
4787 return rc;
4788};
4789
4790unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4791{
4792 int rc = 0;
4793
4794 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4795
4796 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4797
4798 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4799
4800 return rc;
4801};
4802#endif
4803
4804static struct msm_adc_channels msm_adc_channels_data[] = {
4805 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4806 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4807 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4808 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4809 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4810 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4811 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4812 CHAN_PATH_TYPE4,
4813 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4814 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4815 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4816 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4817 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4818 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4819 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4820 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4821 CHAN_PATH_TYPE12,
4822 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4823 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4824 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4825 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4826 CHAN_PATH_TYPE_NONE,
4827 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4828 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4829 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4830 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4831 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4832 scale_xtern_chgr_cur},
4833 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4834 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4835 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4836 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4837 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4838 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4839 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4840 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4841 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4842 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4843 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4844 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4845};
4846
4847static char *msm_adc_fluid_device_names[] = {
4848 "ADS_ADC1",
4849 "ADS_ADC2",
4850};
4851
4852static struct msm_adc_platform_data msm_adc_pdata = {
4853 .channel = msm_adc_channels_data,
4854 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4855#if defined(CONFIG_I2C) && \
4856 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4857 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4858 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4859 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4860 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4861#endif
4862};
4863
4864static struct platform_device msm_adc_device = {
4865 .name = "msm_adc",
4866 .id = -1,
4867 .dev = {
4868 .platform_data = &msm_adc_pdata,
4869 },
4870};
4871
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304872static struct msm_rtb_platform_data msm_rtb_pdata = {
4873 .size = SZ_1M,
4874};
4875
4876static int __init msm_rtb_set_buffer_size(char *p)
4877{
4878 int s;
4879
4880 s = memparse(p, NULL);
4881 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4882 return 0;
4883}
4884early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4885
4886
4887static struct platform_device msm_rtb_device = {
4888 .name = "msm_rtb",
4889 .id = -1,
4890 .dev = {
4891 .platform_data = &msm_rtb_pdata,
4892 },
4893};
4894
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004895static void pmic8058_xoadc_mpp_config(void)
4896{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304897 int rc, i;
4898 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304899 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304900 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304901 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304902 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304903 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304904 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304905 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304906 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304907 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304908 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304909 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4910 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304911 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004912
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304913 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4914 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4915 &xoadc_mpps[i].config);
4916 if (rc) {
4917 pr_err("%s: Config MPP %d of PM8058 failed\n",
4918 __func__, xoadc_mpps[i].mpp);
4919 }
4920 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004921}
4922
4923static struct regulator *vreg_ldo18_adc;
4924
4925static int pmic8058_xoadc_vreg_config(int on)
4926{
4927 int rc;
4928
4929 if (on) {
4930 rc = regulator_enable(vreg_ldo18_adc);
4931 if (rc)
4932 pr_err("%s: Enable of regulator ldo18_adc "
4933 "failed\n", __func__);
4934 } else {
4935 rc = regulator_disable(vreg_ldo18_adc);
4936 if (rc)
4937 pr_err("%s: Disable of regulator ldo18_adc "
4938 "failed\n", __func__);
4939 }
4940
4941 return rc;
4942}
4943
4944static int pmic8058_xoadc_vreg_setup(void)
4945{
4946 int rc;
4947
4948 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4949 if (IS_ERR(vreg_ldo18_adc)) {
4950 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4951 __func__, PTR_ERR(vreg_ldo18_adc));
4952 rc = PTR_ERR(vreg_ldo18_adc);
4953 goto fail;
4954 }
4955
4956 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4957 if (rc) {
4958 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4959 goto fail;
4960 }
4961
4962 return rc;
4963fail:
4964 regulator_put(vreg_ldo18_adc);
4965 return rc;
4966}
4967
4968static void pmic8058_xoadc_vreg_shutdown(void)
4969{
4970 regulator_put(vreg_ldo18_adc);
4971}
4972
4973/* usec. For this ADC,
4974 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4975 * Each channel has different configuration, thus at the time of starting
4976 * the conversion, xoadc will return actual conversion time
4977 * */
4978static struct adc_properties pm8058_xoadc_data = {
4979 .adc_reference = 2200, /* milli-voltage for this adc */
4980 .bitresolution = 15,
4981 .bipolar = 0,
4982 .conversiontime = 54,
4983};
4984
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304985static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004986 .xoadc_prop = &pm8058_xoadc_data,
4987 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4988 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4989 .xoadc_num = XOADC_PMIC_0,
4990 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4991 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4992};
4993#endif
4994
4995#ifdef CONFIG_MSM_SDIO_AL
4996
4997static unsigned mdm2ap_status = 140;
4998
4999static int configure_mdm2ap_status(int on)
5000{
5001 int ret = 0;
5002 if (on)
5003 ret = msm_gpiomux_get(mdm2ap_status);
5004 else
5005 ret = msm_gpiomux_put(mdm2ap_status);
5006
5007 if (ret)
5008 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
5009 on);
5010
5011 return ret;
5012}
5013
5014
5015static int get_mdm2ap_status(void)
5016{
5017 return gpio_get_value(mdm2ap_status);
5018}
5019
5020static struct sdio_al_platform_data sdio_al_pdata = {
5021 .config_mdm2ap_status = configure_mdm2ap_status,
5022 .get_mdm2ap_status = get_mdm2ap_status,
5023 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03005024 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005025 .peer_sdioc_version_major = 0x0004,
5026 .peer_sdioc_boot_version_minor = 0x0001,
5027 .peer_sdioc_boot_version_major = 0x0003
5028};
5029
5030struct platform_device msm_device_sdio_al = {
5031 .name = "msm_sdio_al",
5032 .id = -1,
5033 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03005034 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005035 .platform_data = &sdio_al_pdata,
5036 },
5037};
5038
5039#endif /* CONFIG_MSM_SDIO_AL */
5040
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305041#define GPIO_VREG_ID_EXT_5V 0
5042
5043static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5044 REGULATOR_SUPPLY("ext_5v", NULL),
5045 REGULATOR_SUPPLY("8901_mpp0", NULL),
5046};
5047
5048#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5049 [GPIO_VREG_ID_##_id] = { \
5050 .init_data = { \
5051 .constraints = { \
5052 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5053 }, \
5054 .num_consumer_supplies = \
5055 ARRAY_SIZE(vreg_consumers_##_id), \
5056 .consumer_supplies = vreg_consumers_##_id, \
5057 }, \
5058 .regulator_name = _reg_name, \
5059 .active_low = _active_low, \
5060 .gpio_label = _gpio_label, \
5061 .gpio = _gpio, \
5062 }
5063
5064/* GPIO regulator constraints */
5065static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5066 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5067 PM8901_MPP_PM_TO_SYS(0), 0),
5068};
5069
5070/* GPIO regulator */
5071static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5072 .name = GPIO_REGULATOR_DEV_NAME,
5073 .id = PM8901_MPP_PM_TO_SYS(0),
5074 .dev = {
5075 .platform_data =
5076 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5077 },
5078};
5079
5080static void __init pm8901_vreg_mpp0_init(void)
5081{
5082 int rc;
5083
5084 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5085 .mpp = PM8901_MPP_PM_TO_SYS(0),
5086 .config = {
5087 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5088 .level = PM8901_MPP_DIG_LEVEL_VPH,
5089 },
5090 };
5091
5092 /*
5093 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5094 * implies that the regulator connected to MPP0 is enabled when
5095 * MPP0 is low.
5096 */
5097 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5098 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5099 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5100 } else {
5101 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5102 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5103 }
5104
5105 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5106 if (rc)
5107 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5108}
5109
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005110static struct platform_device *charm_devices[] __initdata = {
5111 &msm_charm_modem,
5112#ifdef CONFIG_MSM_SDIO_AL
5113 &msm_device_sdio_al,
5114#endif
5115};
5116
Lei Zhou338cab82011-08-19 13:38:17 -04005117#ifdef CONFIG_SND_SOC_MSM8660_APQ
5118static struct platform_device *dragon_alsa_devices[] __initdata = {
5119 &msm_pcm,
5120 &msm_pcm_routing,
5121 &msm_cpudai0,
5122 &msm_cpudai1,
5123 &msm_cpudai_hdmi_rx,
5124 &msm_cpudai_bt_rx,
5125 &msm_cpudai_bt_tx,
5126 &msm_cpudai_fm_rx,
5127 &msm_cpudai_fm_tx,
5128 &msm_cpu_fe,
5129 &msm_stub_codec,
5130 &msm_lpa_pcm,
5131};
5132#endif
5133
5134static struct platform_device *asoc_devices[] __initdata = {
5135 &asoc_msm_pcm,
5136 &asoc_msm_dai0,
5137 &asoc_msm_dai1,
5138};
5139
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005140static struct platform_device *surf_devices[] __initdata = {
5141 &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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005147#ifdef CONFIG_I2C_QUP
5148 &msm_gsbi3_qup_i2c_device,
5149 &msm_gsbi4_qup_i2c_device,
5150 &msm_gsbi7_qup_i2c_device,
5151 &msm_gsbi8_qup_i2c_device,
5152 &msm_gsbi9_qup_i2c_device,
5153 &msm_gsbi12_qup_i2c_device,
5154#endif
5155#ifdef CONFIG_SERIAL_MSM_HS
5156 &msm_device_uart_dm1,
5157#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305158#ifdef CONFIG_MSM_SSBI
5159 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305160 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305161#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005162#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005163 &msm_device_ssbi3,
5164#endif
5165#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5166 &isp1763_device,
5167#endif
5168
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005169#if defined (CONFIG_MSM_8x60_VOIP)
5170 &asoc_msm_mvs,
5171 &asoc_mvs_dai0,
5172 &asoc_mvs_dai1,
5173#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005174
Lena Salman57d167e2012-03-21 19:46:38 +02005175#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005176 &msm_device_otg,
5177#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005178#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005179 &msm_device_gadget_peripheral,
5180#endif
5181#ifdef CONFIG_USB_G_ANDROID
5182 &android_usb_device,
5183#endif
5184#ifdef CONFIG_BATTERY_MSM
5185 &msm_batt_device,
5186#endif
5187#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005188#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005189 &android_pmem_device,
5190 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005191 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005192 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305193#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5194#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005195#ifdef CONFIG_MSM_ROTATOR
5196 &msm_rotator_device,
5197#endif
5198 &msm_fb_device,
5199 &msm_kgsl_3d0,
5200 &msm_kgsl_2d0,
5201 &msm_kgsl_2d1,
5202 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005203#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5204 &lcdc_nt35582_panel_device,
5205#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005206#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5207 &lcdc_samsung_oled_panel_device,
5208#endif
5209#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5210 &lcdc_auo_wvga_panel_device,
5211#endif
5212#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5213 &hdmi_msm_device,
5214#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5215#ifdef CONFIG_FB_MSM_MIPI_DSI
5216 &mipi_dsi_toshiba_panel_device,
5217 &mipi_dsi_novatek_panel_device,
5218#endif
5219#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005220#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005221#ifdef CONFIG_MT9E013
5222 &msm_camera_sensor_mt9e013,
5223#endif
5224#ifdef CONFIG_IMX074
5225 &msm_camera_sensor_imx074,
5226#endif
5227#ifdef CONFIG_WEBCAM_OV7692
5228 &msm_camera_sensor_webcam_ov7692,
5229#endif
5230#ifdef CONFIG_WEBCAM_OV9726
5231 &msm_camera_sensor_webcam_ov9726,
5232#endif
5233#ifdef CONFIG_QS_S5K4E1
5234 &msm_camera_sensor_qs_s5k4e1,
5235#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005236#ifdef CONFIG_VX6953
5237 &msm_camera_sensor_vx6953,
5238#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005239#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005240#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005241#ifdef CONFIG_MSM_GEMINI
5242 &msm_gemini_device,
5243#endif
5244#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005245#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005246 &msm_vpe_device,
5247#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005248#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005249
5250#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005251 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005252#endif
5253#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005254 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005255#endif
5256 &msm_device_vidc,
5257#if (defined(CONFIG_MARIMBA_CORE)) && \
5258 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5259 &msm_bt_power_device,
5260#endif
5261#ifdef CONFIG_SENSORS_MSM_ADC
5262 &msm_adc_device,
5263#endif
David Collins6f032ba2011-08-31 14:08:15 -07005264 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005265
5266#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5267 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5268 &qcrypto_device,
5269#endif
5270
5271#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5272 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5273 &qcedev_device,
5274#endif
5275
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005276
5277#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5278#ifdef CONFIG_MSM_USE_TSIF1
5279 &msm_device_tsif[1],
5280#else
5281 &msm_device_tsif[0],
5282#endif /* CONFIG_MSM_USE_TSIF1 */
5283#endif /* CONFIG_TSIF */
5284
5285#ifdef CONFIG_HW_RANDOM_MSM
5286 &msm_device_rng,
5287#endif
5288
5289 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005290 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005291#ifdef CONFIG_ION_MSM
5292 &ion_dev,
5293#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005294 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005295 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305296 &msm_rtb_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005297};
5298
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005299#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005300#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5301static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5302 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005303 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005304 .request_region = request_smi_region,
5305 .release_region = release_smi_region,
5306 .setup_region = setup_smi_region,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305307 .secure_base = MSM_ION_HOLE_BASE,
5308 .secure_size = MSM_ION_HOLE_SIZE + MSM_ION_MM_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005309 .iommu_map_all = 1,
5310 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005311};
5312
5313static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5314 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005315 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005316 .request_region = request_smi_region,
5317 .release_region = release_smi_region,
5318 .setup_region = setup_smi_region,
5319};
5320
5321static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5322 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005323 .align = PAGE_SIZE,
5324};
5325
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305326static struct ion_co_heap_pdata hole_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005327 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005328};
5329
5330static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005331 .adjacent_mem_id = INVALID_HEAP_ID,
5332 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005333};
5334#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005335
5336/**
5337 * These heaps are listed in the order they will be allocated. Due to
5338 * video hardware restrictions and content protection the FW heap has to
5339 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5340 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5341 * away from the base address of the FW heap.
5342 * However, the order of FW heap and MM heap doesn't matter since these
5343 * two heaps are taken care of by separate code to ensure they are adjacent
5344 * to each other.
5345 * Don't swap the order unless you know what you are doing!
5346 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005347static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005348 .nr = MSM_ION_HEAP_NUM,
5349 .heaps = {
5350 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005351 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005352 .type = ION_HEAP_TYPE_SYSTEM,
5353 .name = ION_VMALLOC_HEAP_NAME,
5354 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005355#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5356 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005357 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005358 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005359 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305360 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005361 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005362 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005363 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005364 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005365 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005366 .id = ION_MM_FIRMWARE_HEAP_ID,
5367 .type = ION_HEAP_TYPE_CARVEOUT,
5368 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305369 .base = MSM_ION_HOLE_BASE,
5370 .size = MSM_ION_HOLE_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005371 .memory_type = ION_SMI_TYPE,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305372 .extra_data = (void *) &hole_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005373 },
5374 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005375 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005376 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005377 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305378 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005379 .size = MSM_ION_MFC_SIZE,
5380 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005381 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005382 },
5383 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005384 .id = ION_SF_HEAP_ID,
5385 .type = ION_HEAP_TYPE_CARVEOUT,
5386 .name = ION_SF_HEAP_NAME,
5387 .size = MSM_ION_SF_SIZE,
5388 .memory_type = ION_EBI_TYPE,
5389 .extra_data = (void *)&co_ion_pdata,
5390 },
5391 {
5392 .id = ION_CAMERA_HEAP_ID,
5393 .type = ION_HEAP_TYPE_CARVEOUT,
5394 .name = ION_CAMERA_HEAP_NAME,
5395 .size = MSM_ION_CAMERA_SIZE,
5396 .memory_type = ION_EBI_TYPE,
5397 .extra_data = &co_ion_pdata,
5398 },
5399 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005400 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005401 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005402 .name = ION_WB_HEAP_NAME,
5403 .size = MSM_ION_WB_SIZE,
5404 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005405 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005406 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005407 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005408 .id = ION_QSECOM_HEAP_ID,
5409 .type = ION_HEAP_TYPE_CARVEOUT,
5410 .name = ION_QSECOM_HEAP_NAME,
5411 .size = MSM_ION_QSECOM_SIZE,
5412 .memory_type = ION_EBI_TYPE,
5413 .extra_data = (void *) &co_ion_pdata,
5414 },
5415 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005416 .id = ION_AUDIO_HEAP_ID,
5417 .type = ION_HEAP_TYPE_CARVEOUT,
5418 .name = ION_AUDIO_HEAP_NAME,
5419 .size = MSM_ION_AUDIO_SIZE,
5420 .memory_type = ION_EBI_TYPE,
5421 .extra_data = (void *)&co_ion_pdata,
5422 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005423#endif
5424 }
5425};
5426
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005427static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005428 .name = "ion-msm",
5429 .id = 1,
5430 .dev = { .platform_data = &ion_pdata },
5431};
5432#endif
5433
5434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005435static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5436 /* Kernel SMI memory pool for video core, used for firmware */
5437 /* and encoder, decoder scratch buffers */
5438 /* Kernel SMI memory pool should always precede the user space */
5439 /* SMI memory pool, as the video core will use offset address */
5440 /* from the Firmware base */
5441 [MEMTYPE_SMI_KERNEL] = {
5442 .start = KERNEL_SMI_BASE,
5443 .limit = KERNEL_SMI_SIZE,
5444 .size = KERNEL_SMI_SIZE,
5445 .flags = MEMTYPE_FLAGS_FIXED,
5446 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005447 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005448 },
5449 [MEMTYPE_EBI0] = {
5450 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5451 },
5452 [MEMTYPE_EBI1] = {
5453 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5454 },
5455};
5456
Stephen Boyd668d7652012-04-25 11:31:01 -07005457static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005458{
5459#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005460 unsigned int i;
5461
5462 if (hdmi_is_primary) {
5463 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5464 for (i = 0; i < ion_pdata.nr; i++) {
5465 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5466 ion_pdata.heaps[i].size = msm_ion_sf_size;
5467 pr_debug("msm_ion_sf_size 0x%x\n",
5468 msm_ion_sf_size);
5469 break;
5470 }
5471 }
5472 }
5473
Olav Haugan8726caf2012-05-10 15:11:35 -07005474 /* Verify size of heap is a multiple of 64K */
5475 for (i = 0; i < ion_pdata.nr; i++) {
5476 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5477
5478 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5479 int map_all = ((struct ion_cp_heap_pdata *)
5480 heap->extra_data)->iommu_map_all;
5481
5482 if (map_all && (heap->size & (SZ_64K-1))) {
5483 heap->size = ALIGN(heap->size, SZ_64K);
5484 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5485 heap->name, heap->size);
5486
5487 }
5488 }
5489 }
5490
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005491 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005492 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5493 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005494 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005495 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005496#endif
5497}
5498
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005499static void __init size_pmem_devices(void)
5500{
5501#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005502#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005503 android_pmem_adsp_pdata.size = pmem_adsp_size;
5504 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005505
5506 if (hdmi_is_primary)
5507 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005508 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005509 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305510#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5511#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005512}
5513
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305514#ifdef CONFIG_ANDROID_PMEM
5515#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005516static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5517{
5518 msm8x60_reserve_table[p->memory_type].size += p->size;
5519}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305520#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5521#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522
5523static void __init reserve_pmem_memory(void)
5524{
5525#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005526#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005527 reserve_memory_for(&android_pmem_adsp_pdata);
5528 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005529 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005530 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305531#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305533#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005534}
5535
Huaibin Yanga5419422011-12-08 23:52:10 -08005536static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005537
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305538static void __init reserve_rtb_memory(void)
5539{
5540#if defined(CONFIG_MSM_RTB)
5541 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5542#endif
5543}
5544
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005545static void __init msm8x60_calculate_reserve_sizes(void)
5546{
5547 size_pmem_devices();
5548 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005549 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005550 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305551 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005552}
5553
5554static int msm8x60_paddr_to_memtype(unsigned int paddr)
5555{
5556 if (paddr >= 0x40000000 && paddr < 0x60000000)
5557 return MEMTYPE_EBI1;
5558 if (paddr >= 0x38000000 && paddr < 0x40000000)
5559 return MEMTYPE_SMI;
5560 return MEMTYPE_NONE;
5561}
5562
5563static struct reserve_info msm8x60_reserve_info __initdata = {
5564 .memtype_reserve_table = msm8x60_reserve_table,
5565 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5566 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5567};
5568
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005569static char prim_panel_name[PANEL_NAME_MAX_LEN];
5570static char ext_panel_name[PANEL_NAME_MAX_LEN];
5571static int __init prim_display_setup(char *param)
5572{
5573 if (strnlen(param, PANEL_NAME_MAX_LEN))
5574 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5575 return 0;
5576}
5577early_param("prim_display", prim_display_setup);
5578
5579static int __init ext_display_setup(char *param)
5580{
5581 if (strnlen(param, PANEL_NAME_MAX_LEN))
5582 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5583 return 0;
5584}
5585early_param("ext_display", ext_display_setup);
5586
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587static void __init msm8x60_reserve(void)
5588{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005589 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005590 reserve_info = &msm8x60_reserve_info;
5591 msm_reserve();
5592}
5593
5594#define EXT_CHG_VALID_MPP 10
5595#define EXT_CHG_VALID_MPP_2 11
5596
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305597static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305598 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305599 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305600 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305601 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5602};
5603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604#ifdef CONFIG_ISL9519_CHARGER
5605static int isl_detection_setup(void)
5606{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305607 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305609 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5610 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5611 &isl_mpp[i].config);
5612 if (ret) {
5613 pr_err("%s: Config MPP %d of PM8058 failed\n",
5614 __func__, isl_mpp[i].mpp);
5615 return ret;
5616 }
5617 }
5618
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005619 return ret;
5620}
5621
5622static struct isl_platform_data isl_data __initdata = {
5623 .chgcurrent = 700,
5624 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5625 .chg_detection_config = isl_detection_setup,
5626 .max_system_voltage = 4200,
5627 .min_system_voltage = 3200,
5628 .term_current = 120,
5629 .input_current = 2048,
5630};
5631
5632static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5633 {
5634 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305635 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005636 .platform_data = &isl_data,
5637 },
5638};
5639#endif
5640
5641#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5642static int smb137b_detection_setup(void)
5643{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305644 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305646 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5647 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5648 &isl_mpp[i].config);
5649 if (ret) {
5650 pr_err("%s: Config MPP %d of PM8058 failed\n",
5651 __func__, isl_mpp[i].mpp);
5652 return ret;
5653 }
5654 }
5655
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005656 return ret;
5657}
5658
5659static struct smb137b_platform_data smb137b_data __initdata = {
5660 .chg_detection_config = smb137b_detection_setup,
5661 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5662 .batt_mah_rating = 950,
5663};
5664
5665static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5666 {
5667 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305668 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005669 .platform_data = &smb137b_data,
5670 },
5671};
5672#endif
5673
5674#ifdef CONFIG_PMIC8058
5675#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305676#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005677
5678static int pm8058_gpios_init(void)
5679{
5680 int i;
5681 int rc;
5682 struct pm8058_gpio_cfg {
5683 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305684 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005685 };
5686
5687 struct pm8058_gpio_cfg gpio_cfgs[] = {
5688 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305689 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005690 {
5691 .direction = PM_GPIO_DIR_IN,
5692 .pull = PM_GPIO_PULL_DN,
5693 .vin_sel = 2,
5694 .function = PM_GPIO_FUNC_NORMAL,
5695 .inv_int_pol = 0,
5696 },
5697 },
5698#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5699 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305700 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005701 {
5702 .direction = PM_GPIO_DIR_IN,
5703 .pull = PM_GPIO_PULL_UP_30,
5704 .vin_sel = 2,
5705 .function = PM_GPIO_FUNC_NORMAL,
5706 .inv_int_pol = 0,
5707 },
5708 },
5709#endif
5710 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305711 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005712 {
5713 .direction = PM_GPIO_DIR_IN,
5714 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305715 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005716 .function = PM_GPIO_FUNC_NORMAL,
5717 .inv_int_pol = 0,
5718 },
5719 },
5720 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305721 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005722 {
5723 .direction = PM_GPIO_DIR_IN,
5724 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305725 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005726 .function = PM_GPIO_FUNC_NORMAL,
5727 .inv_int_pol = 0,
5728 },
5729 },
5730 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305731 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005732 {
5733 .direction = PM_GPIO_DIR_IN,
5734 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305735 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005736 .function = PM_GPIO_FUNC_NORMAL,
5737 .inv_int_pol = 0,
5738 },
5739 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005740 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305741 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005742 {
5743 .direction = PM_GPIO_DIR_OUT,
5744 .output_value = 1,
5745 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5746 .pull = PM_GPIO_PULL_DN,
5747 .out_strength = PM_GPIO_STRENGTH_HIGH,
5748 .function = PM_GPIO_FUNC_NORMAL,
5749 .vin_sel = 2,
5750 .inv_int_pol = 0,
5751 }
5752 },
5753 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305754 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005755 {
5756 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305757 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005758 .function = PM_GPIO_FUNC_NORMAL,
5759 .vin_sel = 2,
5760 .inv_int_pol = 0,
5761 }
5762 },
5763 };
5764
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305765#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5766 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305767 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305768 .direction = PM_GPIO_DIR_IN,
5769 .pull = PM_GPIO_PULL_UP_1P5,
5770 .vin_sel = 2,
5771 .function = PM_GPIO_FUNC_NORMAL,
5772 };
5773#endif
5774
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005775#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305776 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305777 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305778 .direction = PM_GPIO_DIR_OUT,
5779 .pull = PM_GPIO_PULL_NO,
5780 .out_strength = PM_GPIO_STRENGTH_HIGH,
5781 .function = PM_GPIO_FUNC_NORMAL,
5782 .inv_int_pol = 0,
5783 .vin_sel = 2,
5784 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5785 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005786 };
5787#endif
5788
5789#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5790 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305791 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005792 {
5793 .direction = PM_GPIO_DIR_IN,
5794 .pull = PM_GPIO_PULL_UP_1P5,
5795 .vin_sel = 2,
5796 .function = PM_GPIO_FUNC_NORMAL,
5797 .inv_int_pol = 0,
5798 }
5799 };
5800#endif
5801
5802#if defined(CONFIG_QS_S5K4E1)
5803 {
5804 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305805 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005806 {
5807 .direction = PM_GPIO_DIR_OUT,
5808 .output_value = 0,
5809 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5810 .pull = PM_GPIO_PULL_DN,
5811 .out_strength = PM_GPIO_STRENGTH_HIGH,
5812 .function = PM_GPIO_FUNC_NORMAL,
5813 .vin_sel = 2,
5814 .inv_int_pol = 0,
5815 }
5816 };
5817#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005818#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5819 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305820 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005821 {
5822 .direction = PM_GPIO_DIR_OUT,
5823 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5824 .output_value = 1,
5825 .pull = PM_GPIO_PULL_UP_30,
5826 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305827 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005828 .out_strength = PM_GPIO_STRENGTH_HIGH,
5829 .function = PM_GPIO_FUNC_NORMAL,
5830 .inv_int_pol = 0,
5831 }
5832 };
5833#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005834#if defined(CONFIG_HAPTIC_ISA1200) || \
5835 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5836 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305837 rc = pm8xxx_gpio_config(
5838 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5839 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005840 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305841 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005842 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305843 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305844 rc = pm8xxx_gpio_config(
5845 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5846 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305847 if (rc < 0) {
5848 pr_err("%s: pmic haptics ldo gpio config failed\n",
5849 __func__);
5850 }
5851
5852 }
5853#endif
5854
5855#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5856 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5857 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5858 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305859 rc = pm8xxx_gpio_config(
5860 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5861 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305862 if (rc < 0) {
5863 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5864 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005865 }
5866 }
5867#endif
5868
5869#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5870 /* Line_in only for 8660 ffa & surf */
5871 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005872 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005873 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305874 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005875 &line_in_gpio_cfg.cfg);
5876 if (rc < 0) {
5877 pr_err("%s pmic line_in gpio config failed\n",
5878 __func__);
5879 return rc;
5880 }
5881 }
5882#endif
5883
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005884#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5885 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305886 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005887 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5888 if (rc < 0) {
5889 pr_err("%s pmic gpio config failed\n", __func__);
5890 return rc;
5891 }
5892 }
5893#endif
5894
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005895#if defined(CONFIG_QS_S5K4E1)
5896 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5897 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305898 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005899 &qs_hc37_cam_pd_gpio_cfg.cfg);
5900 if (rc < 0) {
5901 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5902 __func__);
5903 return rc;
5904 }
5905 }
5906 }
5907#endif
5908
5909 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305910 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005911 &gpio_cfgs[i].cfg);
5912 if (rc < 0) {
5913 pr_err("%s pmic gpio config failed\n",
5914 __func__);
5915 return rc;
5916 }
5917 }
5918
5919 return 0;
5920}
5921
5922static const unsigned int ffa_keymap[] = {
5923 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5924 KEY(0, 1, KEY_UP), /* NAV - UP */
5925 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5926 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5927
5928 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5929 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5930 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5931 KEY(1, 3, KEY_VOLUMEDOWN),
5932
5933 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5934
5935 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5936 KEY(4, 1, KEY_UP), /* USER_UP */
5937 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5938 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5939 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5940
5941 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5942 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5943 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5944 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5945 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5946};
5947
Zhang Chang Ken683be172011-08-10 17:45:34 -04005948static const unsigned int dragon_keymap[] = {
5949 KEY(0, 0, KEY_MENU),
5950 KEY(0, 2, KEY_1),
5951 KEY(0, 3, KEY_4),
5952 KEY(0, 4, KEY_7),
5953
5954 KEY(1, 0, KEY_UP),
5955 KEY(1, 1, KEY_LEFT),
5956 KEY(1, 2, KEY_DOWN),
5957 KEY(1, 3, KEY_5),
5958 KEY(1, 4, KEY_8),
5959
5960 KEY(2, 0, KEY_HOME),
5961 KEY(2, 1, KEY_REPLY),
5962 KEY(2, 2, KEY_2),
5963 KEY(2, 3, KEY_6),
5964 KEY(2, 4, KEY_0),
5965
5966 KEY(3, 0, KEY_VOLUMEUP),
5967 KEY(3, 1, KEY_RIGHT),
5968 KEY(3, 2, KEY_3),
5969 KEY(3, 3, KEY_9),
5970 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5971
5972 KEY(4, 0, KEY_VOLUMEDOWN),
5973 KEY(4, 1, KEY_BACK),
5974 KEY(4, 2, KEY_CAMERA),
5975 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5976};
5977
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005978static struct matrix_keymap_data ffa_keymap_data = {
5979 .keymap_size = ARRAY_SIZE(ffa_keymap),
5980 .keymap = ffa_keymap,
5981};
5982
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305983static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005984 .input_name = "ffa-keypad",
5985 .input_phys_device = "ffa-keypad/input0",
5986 .num_rows = 6,
5987 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305988 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5989 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5990 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005991 .scan_delay_ms = 32,
5992 .row_hold_ns = 91500,
5993 .wakeup = 1,
5994 .keymap_data = &ffa_keymap_data,
5995};
5996
Zhang Chang Ken683be172011-08-10 17:45:34 -04005997static struct matrix_keymap_data dragon_keymap_data = {
5998 .keymap_size = ARRAY_SIZE(dragon_keymap),
5999 .keymap = dragon_keymap,
6000};
6001
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306002static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006003 .input_name = "dragon-keypad",
6004 .input_phys_device = "dragon-keypad/input0",
6005 .num_rows = 6,
6006 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306007 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6008 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6009 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006010 .scan_delay_ms = 32,
6011 .row_hold_ns = 91500,
6012 .wakeup = 1,
6013 .keymap_data = &dragon_keymap_data,
6014};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306015
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006016static const unsigned int fluid_keymap[] = {
6017 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6018 KEY(0, 1, KEY_UP), /* NAV - UP */
6019 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6020 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6021
6022 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6023 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6024 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6025 KEY(1, 3, KEY_VOLUMEUP),
6026
6027 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6028
6029 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6030 KEY(4, 1, KEY_UP), /* USER_UP */
6031 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6032 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6033 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6034
Jilai Wang9a895102011-07-12 14:00:35 -04006035 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006036 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6037 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6038 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6039 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6040};
6041
6042static struct matrix_keymap_data fluid_keymap_data = {
6043 .keymap_size = ARRAY_SIZE(fluid_keymap),
6044 .keymap = fluid_keymap,
6045};
6046
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306047static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006048 .input_name = "fluid-keypad",
6049 .input_phys_device = "fluid-keypad/input0",
6050 .num_rows = 6,
6051 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306052 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6053 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6054 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006055 .scan_delay_ms = 32,
6056 .row_hold_ns = 91500,
6057 .wakeup = 1,
6058 .keymap_data = &fluid_keymap_data,
6059};
6060
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306061static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006062 .initial_vibrate_ms = 500,
6063 .level_mV = 3000,
6064 .max_timeout_ms = 15000,
6065};
6066
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306067static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6068 .rtc_write_enable = false,
6069 .rtc_alarm_powerup = false,
6070};
6071
6072static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6073 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006074 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306075 .wakeup = 1,
6076};
6077
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006078#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6079
6080static struct othc_accessory_info othc_accessories[] = {
6081 {
6082 .accessory = OTHC_SVIDEO_OUT,
6083 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6084 | OTHC_ADC_DETECT,
6085 .key_code = SW_VIDEOOUT_INSERT,
6086 .enabled = false,
6087 .adc_thres = {
6088 .min_threshold = 20,
6089 .max_threshold = 40,
6090 },
6091 },
6092 {
6093 .accessory = OTHC_ANC_HEADPHONE,
6094 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6095 OTHC_SWITCH_DETECT,
6096 .gpio = PM8058_LINE_IN_DET_GPIO,
6097 .active_low = 1,
6098 .key_code = SW_HEADPHONE_INSERT,
6099 .enabled = true,
6100 },
6101 {
6102 .accessory = OTHC_ANC_HEADSET,
6103 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6104 .gpio = PM8058_LINE_IN_DET_GPIO,
6105 .active_low = 1,
6106 .key_code = SW_HEADPHONE_INSERT,
6107 .enabled = true,
6108 },
6109 {
6110 .accessory = OTHC_HEADPHONE,
6111 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6112 .key_code = SW_HEADPHONE_INSERT,
6113 .enabled = true,
6114 },
6115 {
6116 .accessory = OTHC_MICROPHONE,
6117 .detect_flags = OTHC_GPIO_DETECT,
6118 .gpio = PM8058_LINE_IN_DET_GPIO,
6119 .active_low = 1,
6120 .key_code = SW_MICROPHONE_INSERT,
6121 .enabled = true,
6122 },
6123 {
6124 .accessory = OTHC_HEADSET,
6125 .detect_flags = OTHC_MICBIAS_DETECT,
6126 .key_code = SW_HEADPHONE_INSERT,
6127 .enabled = true,
6128 },
6129};
6130
6131static struct othc_switch_info switch_info[] = {
6132 {
6133 .min_adc_threshold = 0,
6134 .max_adc_threshold = 100,
6135 .key_code = KEY_PLAYPAUSE,
6136 },
6137 {
6138 .min_adc_threshold = 100,
6139 .max_adc_threshold = 200,
6140 .key_code = KEY_REWIND,
6141 },
6142 {
6143 .min_adc_threshold = 200,
6144 .max_adc_threshold = 500,
6145 .key_code = KEY_FASTFORWARD,
6146 },
6147};
6148
6149static struct othc_n_switch_config switch_config = {
6150 .voltage_settling_time_ms = 0,
6151 .num_adc_samples = 3,
6152 .adc_channel = CHANNEL_ADC_HDSET,
6153 .switch_info = switch_info,
6154 .num_keys = ARRAY_SIZE(switch_info),
6155 .default_sw_en = true,
6156 .default_sw_idx = 0,
6157};
6158
6159static struct hsed_bias_config hsed_bias_config = {
6160 /* HSED mic bias config info */
6161 .othc_headset = OTHC_HEADSET_NO,
6162 .othc_lowcurr_thresh_uA = 100,
6163 .othc_highcurr_thresh_uA = 600,
6164 .othc_hyst_prediv_us = 7800,
6165 .othc_period_clkdiv_us = 62500,
6166 .othc_hyst_clk_us = 121000,
6167 .othc_period_clk_us = 312500,
6168 .othc_wakeup = 1,
6169};
6170
6171static struct othc_hsed_config hsed_config_1 = {
6172 .hsed_bias_config = &hsed_bias_config,
6173 /*
6174 * The detection delay and switch reporting delay are
6175 * required to encounter a hardware bug (spurious switch
6176 * interrupts on slow insertion/removal of the headset).
6177 * This will introduce a delay in reporting the accessory
6178 * insertion and removal to the userspace.
6179 */
6180 .detection_delay_ms = 1500,
6181 /* Switch info */
6182 .switch_debounce_ms = 1500,
6183 .othc_support_n_switch = false,
6184 .switch_config = &switch_config,
6185 .ir_gpio = -1,
6186 /* Accessory info */
6187 .accessories_support = true,
6188 .accessories = othc_accessories,
6189 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6190};
6191
6192static struct othc_regulator_config othc_reg = {
6193 .regulator = "8058_l5",
6194 .max_uV = 2850000,
6195 .min_uV = 2850000,
6196};
6197
6198/* MIC_BIAS0 is configured as normal MIC BIAS */
6199static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6200 .micbias_select = OTHC_MICBIAS_0,
6201 .micbias_capability = OTHC_MICBIAS,
6202 .micbias_enable = OTHC_SIGNAL_OFF,
6203 .micbias_regulator = &othc_reg,
6204};
6205
6206/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6207static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6208 .micbias_select = OTHC_MICBIAS_1,
6209 .micbias_capability = OTHC_MICBIAS_HSED,
6210 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6211 .micbias_regulator = &othc_reg,
6212 .hsed_config = &hsed_config_1,
6213 .hsed_name = "8660_handset",
6214};
6215
6216/* MIC_BIAS2 is configured as normal MIC BIAS */
6217static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6218 .micbias_select = OTHC_MICBIAS_2,
6219 .micbias_capability = OTHC_MICBIAS,
6220 .micbias_enable = OTHC_SIGNAL_OFF,
6221 .micbias_regulator = &othc_reg,
6222};
6223
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006224
6225static void __init msm8x60_init_pm8058_othc(void)
6226{
6227 int i;
6228
6229 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6230 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6231 machine_is_msm8x60_fusn_ffa()) {
6232 /* 3-switch headset supported only by V2 FFA and FLUID */
6233 hsed_config_1.accessories_adc_support = true,
6234 /* ADC based accessory detection works only on V2 and FLUID */
6235 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6236 hsed_config_1.othc_support_n_switch = true;
6237 }
6238
6239 /* IR GPIO is absent on FLUID */
6240 if (machine_is_msm8x60_fluid())
6241 hsed_config_1.ir_gpio = -1;
6242
6243 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6244 if (machine_is_msm8x60_fluid()) {
6245 switch (othc_accessories[i].accessory) {
6246 case OTHC_ANC_HEADPHONE:
6247 case OTHC_ANC_HEADSET:
6248 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6249 break;
6250 case OTHC_MICROPHONE:
6251 othc_accessories[i].enabled = false;
6252 break;
6253 case OTHC_SVIDEO_OUT:
6254 othc_accessories[i].enabled = true;
6255 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6256 break;
6257 }
6258 }
6259 }
6260}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006261
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006262
6263static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6264{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306265 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006266 .direction = PM_GPIO_DIR_OUT,
6267 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6268 .output_value = 0,
6269 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306270 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006271 .out_strength = PM_GPIO_STRENGTH_HIGH,
6272 .function = PM_GPIO_FUNC_2,
6273 };
6274
6275 int rc = -EINVAL;
6276 int id, mode, max_mA;
6277
6278 id = mode = max_mA = 0;
6279 switch (ch) {
6280 case 0:
6281 case 1:
6282 case 2:
6283 if (on) {
6284 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306285 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6286 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006287 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306288 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006289 __func__, id, rc);
6290 }
6291 break;
6292
6293 case 6:
6294 id = PM_PWM_LED_FLASH;
6295 mode = PM_PWM_CONF_PWM1;
6296 max_mA = 300;
6297 break;
6298
6299 case 7:
6300 id = PM_PWM_LED_FLASH1;
6301 mode = PM_PWM_CONF_PWM1;
6302 max_mA = 300;
6303 break;
6304
6305 default:
6306 break;
6307 }
6308
6309 if (ch >= 6 && ch <= 7) {
6310 if (!on) {
6311 mode = PM_PWM_CONF_NONE;
6312 max_mA = 0;
6313 }
6314 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6315 if (rc)
6316 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6317 __func__, ch, rc);
6318 }
6319 return rc;
6320
6321}
6322
6323static struct pm8058_pwm_pdata pm8058_pwm_data = {
6324 .config = pm8058_pwm_config,
6325};
6326
6327#define PM8058_GPIO_INT 88
6328
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006329static struct pmic8058_led pmic8058_flash_leds[] = {
6330 [0] = {
6331 .name = "camera:flash0",
6332 .max_brightness = 15,
6333 .id = PMIC8058_ID_FLASH_LED_0,
6334 },
6335 [1] = {
6336 .name = "camera:flash1",
6337 .max_brightness = 15,
6338 .id = PMIC8058_ID_FLASH_LED_1,
6339 },
6340};
6341
6342static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6343 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6344 .leds = pmic8058_flash_leds,
6345};
6346
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006347static struct pmic8058_led pmic8058_dragon_leds[] = {
6348 [0] = {
6349 /* RED */
6350 .name = "led_drv0",
6351 .max_brightness = 15,
6352 .id = PMIC8058_ID_LED_0,
6353 },/* 300 mA flash led0 drv sink */
6354 [1] = {
6355 /* Yellow */
6356 .name = "led_drv1",
6357 .max_brightness = 15,
6358 .id = PMIC8058_ID_LED_1,
6359 },/* 300 mA flash led0 drv sink */
6360 [2] = {
6361 /* Green */
6362 .name = "led_drv2",
6363 .max_brightness = 15,
6364 .id = PMIC8058_ID_LED_2,
6365 },/* 300 mA flash led0 drv sink */
6366 [3] = {
6367 .name = "led_psensor",
6368 .max_brightness = 15,
6369 .id = PMIC8058_ID_LED_KB_LIGHT,
6370 },/* 300 mA flash led0 drv sink */
6371};
6372
6373static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6374 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6375 .leds = pmic8058_dragon_leds,
6376};
6377
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006378static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6379 [0] = {
6380 .name = "led:drv0",
6381 .max_brightness = 15,
6382 .id = PMIC8058_ID_FLASH_LED_0,
6383 },/* 300 mA flash led0 drv sink */
6384 [1] = {
6385 .name = "led:drv1",
6386 .max_brightness = 15,
6387 .id = PMIC8058_ID_FLASH_LED_1,
6388 },/* 300 mA flash led1 sink */
6389 [2] = {
6390 .name = "led:drv2",
6391 .max_brightness = 20,
6392 .id = PMIC8058_ID_LED_0,
6393 },/* 40 mA led0 sink */
6394 [3] = {
6395 .name = "keypad:drv",
6396 .max_brightness = 15,
6397 .id = PMIC8058_ID_LED_KB_LIGHT,
6398 },/* 300 mA keypad drv sink */
6399};
6400
6401static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6402 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6403 .leds = pmic8058_fluid_flash_leds,
6404};
6405
Terence Hampson90508a92011-08-09 10:40:08 -04006406static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306407 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006408 .max_source_current = 1800,
6409 .charger_type = CHG_TYPE_AC,
6410};
6411
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306412static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6413 .charger_data_valid = false,
6414};
6415
6416static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6417 .priority = 0,
6418};
6419
6420static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6421 .irq_base = PM8058_IRQ_BASE,
6422 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6423 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6424};
6425
6426static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6427 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6428};
6429
6430static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6431 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006432};
6433
6434static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306435 .irq_pdata = &pm8058_irq_pdata,
6436 .gpio_pdata = &pm8058_gpio_pdata,
6437 .mpp_pdata = &pm8058_mpp_pdata,
6438 .rtc_pdata = &pm8058_rtc_pdata,
6439 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6440 .othc0_pdata = &othc_config_pdata_0,
6441 .othc1_pdata = &othc_config_pdata_1,
6442 .othc2_pdata = &othc_config_pdata_2,
6443 .pwm_pdata = &pm8058_pwm_data,
6444 .misc_pdata = &pm8058_misc_pdata,
6445#ifdef CONFIG_SENSORS_MSM_ADC
6446 .xoadc_pdata = &pm8058_xoadc_pdata,
6447#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006448};
6449
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306450#ifdef CONFIG_MSM_SSBI
6451static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6452 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6453 .slave = {
6454 .name = "pm8058-core",
6455 .platform_data = &pm8058_platform_data,
6456 },
6457};
6458#endif
6459#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006460
6461#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6462 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6463#define TDISC_I2C_SLAVE_ADDR 0x67
6464#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6465#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6466
6467static const char *vregs_tdisc_name[] = {
6468 "8058_l5",
6469 "8058_s3",
6470};
6471
6472static const int vregs_tdisc_val[] = {
6473 2850000,/* uV */
6474 1800000,
6475};
6476static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6477
6478static int tdisc_shinetsu_setup(void)
6479{
6480 int rc, i;
6481
6482 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6483 if (rc) {
6484 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6485 __func__);
6486 return rc;
6487 }
6488
6489 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6490 if (rc) {
6491 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6492 __func__);
6493 goto fail_gpio_oe;
6494 }
6495
6496 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6497 if (rc) {
6498 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6499 __func__);
6500 gpio_free(GPIO_JOYSTICK_EN);
6501 goto fail_gpio_oe;
6502 }
6503
6504 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6505 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6506 if (IS_ERR(vregs_tdisc[i])) {
6507 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6508 __func__, vregs_tdisc_name[i],
6509 PTR_ERR(vregs_tdisc[i]));
6510 rc = PTR_ERR(vregs_tdisc[i]);
6511 goto vreg_get_fail;
6512 }
6513
6514 rc = regulator_set_voltage(vregs_tdisc[i],
6515 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6516 if (rc) {
6517 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6518 __func__, rc);
6519 goto vreg_set_voltage_fail;
6520 }
6521 }
6522
6523 return rc;
6524vreg_set_voltage_fail:
6525 i++;
6526vreg_get_fail:
6527 while (i)
6528 regulator_put(vregs_tdisc[--i]);
6529fail_gpio_oe:
6530 gpio_free(PMIC_GPIO_TDISC);
6531 return rc;
6532}
6533
6534static void tdisc_shinetsu_release(void)
6535{
6536 int i;
6537
6538 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6539 regulator_put(vregs_tdisc[i]);
6540
6541 gpio_free(PMIC_GPIO_TDISC);
6542 gpio_free(GPIO_JOYSTICK_EN);
6543}
6544
6545static int tdisc_shinetsu_enable(void)
6546{
6547 int i, rc = -EINVAL;
6548
6549 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6550 rc = regulator_enable(vregs_tdisc[i]);
6551 if (rc < 0) {
6552 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6553 __func__, vregs_tdisc_name[i], rc);
6554 goto vreg_fail;
6555 }
6556 }
6557
6558 /* Enable the OE (output enable) gpio */
6559 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6560 /* voltage and gpio stabilization delay */
6561 msleep(50);
6562
6563 return 0;
6564vreg_fail:
6565 while (i)
6566 regulator_disable(vregs_tdisc[--i]);
6567 return rc;
6568}
6569
6570static int tdisc_shinetsu_disable(void)
6571{
6572 int i, rc;
6573
6574 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6575 rc = regulator_disable(vregs_tdisc[i]);
6576 if (rc < 0) {
6577 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6578 __func__, vregs_tdisc_name[i], rc);
6579 goto tdisc_reg_fail;
6580 }
6581 }
6582
6583 /* Disable the OE (output enable) gpio */
6584 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6585
6586 return 0;
6587
6588tdisc_reg_fail:
6589 while (i)
6590 regulator_enable(vregs_tdisc[--i]);
6591 return rc;
6592}
6593
6594static struct tdisc_abs_values tdisc_abs = {
6595 .x_max = 32,
6596 .y_max = 32,
6597 .x_min = -32,
6598 .y_min = -32,
6599 .pressure_max = 32,
6600 .pressure_min = 0,
6601};
6602
6603static struct tdisc_platform_data tdisc_data = {
6604 .tdisc_setup = tdisc_shinetsu_setup,
6605 .tdisc_release = tdisc_shinetsu_release,
6606 .tdisc_enable = tdisc_shinetsu_enable,
6607 .tdisc_disable = tdisc_shinetsu_disable,
6608 .tdisc_wakeup = 0,
6609 .tdisc_gpio = PMIC_GPIO_TDISC,
6610 .tdisc_report_keys = true,
6611 .tdisc_report_relative = true,
6612 .tdisc_report_absolute = false,
6613 .tdisc_report_wheel = false,
6614 .tdisc_reverse_x = false,
6615 .tdisc_reverse_y = true,
6616 .tdisc_abs = &tdisc_abs,
6617};
6618
6619static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6620 {
6621 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6622 .irq = TDISC_INT,
6623 .platform_data = &tdisc_data,
6624 },
6625};
6626#endif
6627
6628#define PM_GPIO_CDC_RST_N 20
6629#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6630
6631static struct regulator *vreg_timpani_1;
6632static struct regulator *vreg_timpani_2;
6633
6634static unsigned int msm_timpani_setup_power(void)
6635{
6636 int rc;
6637
6638 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6639 if (IS_ERR(vreg_timpani_1)) {
6640 pr_err("%s: Unable to get 8058_l0\n", __func__);
6641 return -ENODEV;
6642 }
6643
6644 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6645 if (IS_ERR(vreg_timpani_2)) {
6646 pr_err("%s: Unable to get 8058_s3\n", __func__);
6647 regulator_put(vreg_timpani_1);
6648 return -ENODEV;
6649 }
6650
6651 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6652 if (rc) {
6653 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6654 goto fail;
6655 }
6656
6657 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6658 if (rc) {
6659 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6660 goto fail;
6661 }
6662
6663 rc = regulator_enable(vreg_timpani_1);
6664 if (rc) {
6665 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6666 goto fail;
6667 }
6668
6669 /* The settings for LDO0 should be set such that
6670 * it doesn't require to reset the timpani. */
6671 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6672 if (rc < 0) {
6673 pr_err("Timpani regulator optimum mode setting failed\n");
6674 goto fail;
6675 }
6676
6677 rc = regulator_enable(vreg_timpani_2);
6678 if (rc) {
6679 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6680 regulator_disable(vreg_timpani_1);
6681 goto fail;
6682 }
6683
6684 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6685 if (rc) {
6686 pr_err("%s: GPIO Request %d failed\n", __func__,
6687 GPIO_CDC_RST_N);
6688 regulator_disable(vreg_timpani_1);
6689 regulator_disable(vreg_timpani_2);
6690 goto fail;
6691 } else {
6692 gpio_direction_output(GPIO_CDC_RST_N, 1);
6693 usleep_range(1000, 1050);
6694 gpio_direction_output(GPIO_CDC_RST_N, 0);
6695 usleep_range(1000, 1050);
6696 gpio_direction_output(GPIO_CDC_RST_N, 1);
6697 gpio_free(GPIO_CDC_RST_N);
6698 }
6699 return rc;
6700
6701fail:
6702 regulator_put(vreg_timpani_1);
6703 regulator_put(vreg_timpani_2);
6704 return rc;
6705}
6706
6707static void msm_timpani_shutdown_power(void)
6708{
6709 int rc;
6710
6711 rc = regulator_disable(vreg_timpani_1);
6712 if (rc)
6713 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6714
6715 regulator_put(vreg_timpani_1);
6716
6717 rc = regulator_disable(vreg_timpani_2);
6718 if (rc)
6719 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6720
6721 regulator_put(vreg_timpani_2);
6722}
6723
6724/* Power analog function of codec */
6725static struct regulator *vreg_timpani_cdc_apwr;
6726static int msm_timpani_codec_power(int vreg_on)
6727{
6728 int rc = 0;
6729
6730 if (!vreg_timpani_cdc_apwr) {
6731
6732 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6733
6734 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6735 pr_err("%s: vreg_get failed (%ld)\n",
6736 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6737 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6738 return rc;
6739 }
6740 }
6741
6742 if (vreg_on) {
6743
6744 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6745 2200000, 2200000);
6746 if (rc) {
6747 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6748 __func__);
6749 goto vreg_fail;
6750 }
6751
6752 rc = regulator_enable(vreg_timpani_cdc_apwr);
6753 if (rc) {
6754 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6755 goto vreg_fail;
6756 }
6757 } else {
6758 rc = regulator_disable(vreg_timpani_cdc_apwr);
6759 if (rc) {
6760 pr_err("%s: vreg_disable failed %d\n",
6761 __func__, rc);
6762 goto vreg_fail;
6763 }
6764 }
6765
6766 return 0;
6767
6768vreg_fail:
6769 regulator_put(vreg_timpani_cdc_apwr);
6770 vreg_timpani_cdc_apwr = NULL;
6771 return rc;
6772}
6773
6774static struct marimba_codec_platform_data timpani_codec_pdata = {
6775 .marimba_codec_power = msm_timpani_codec_power,
6776};
6777
6778#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6779#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6780
6781static struct marimba_platform_data timpani_pdata = {
6782 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6783 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6784 .marimba_setup = msm_timpani_setup_power,
6785 .marimba_shutdown = msm_timpani_shutdown_power,
6786 .codec = &timpani_codec_pdata,
6787 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6788};
6789
6790#define TIMPANI_I2C_SLAVE_ADDR 0xD
6791
6792static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6793 {
6794 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6795 .platform_data = &timpani_pdata,
6796 },
6797};
6798
Lei Zhou338cab82011-08-19 13:38:17 -04006799#ifdef CONFIG_SND_SOC_WM8903
6800static struct wm8903_platform_data wm8903_pdata = {
6801 .gpio_cfg[2] = 0x3A8,
6802};
6803
6804#define WM8903_I2C_SLAVE_ADDR 0x34
6805static struct i2c_board_info wm8903_codec_i2c_info[] = {
6806 {
6807 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6808 .platform_data = &wm8903_pdata,
6809 },
6810};
6811#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006812#ifdef CONFIG_PMIC8901
6813
6814#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006815/*
6816 * Consumer specific regulator names:
6817 * regulator name consumer dev_name
6818 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006819static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6820 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6821};
6822static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6823 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6824};
6825
6826#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306827 _always_on) \
6828 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006829 .init_data = { \
6830 .constraints = { \
6831 .valid_modes_mask = _modes, \
6832 .valid_ops_mask = _ops, \
6833 .min_uV = _min_uV, \
6834 .max_uV = _max_uV, \
6835 .input_uV = _min_uV, \
6836 .apply_uV = _apply_uV, \
6837 .always_on = _always_on, \
6838 }, \
6839 .consumer_supplies = vreg_consumers_8901_##_id, \
6840 .num_consumer_supplies = \
6841 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6842 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306843 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006844 }
6845
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006846#define PM8901_VREG_INIT_VS(_id) \
6847 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306848 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006849
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306850static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006851 PM8901_VREG_INIT_VS(USB_OTG),
6852 PM8901_VREG_INIT_VS(HDMI_MVS),
6853};
6854
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306855static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6856 .priority = 1,
6857};
6858
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306859static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6860 .irq_base = PM8901_IRQ_BASE,
6861 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6862 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6863};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006864
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306865static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6866 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006867};
6868
6869static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306870 .irq_pdata = &pm8901_irq_pdata,
6871 .mpp_pdata = &pm8901_mpp_pdata,
6872 .regulator_pdatas = pm8901_vreg_init,
6873 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306874 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006875};
6876
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306877static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6878 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6879 .slave = {
6880 .name = "pm8901-core",
6881 .platform_data = &pm8901_platform_data,
6882 },
6883};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006884#endif /* CONFIG_PMIC8901 */
6885
6886#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6887 || defined(CONFIG_GPIO_SX150X_MODULE))
6888
6889static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006890static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006891
6892struct bahama_config_register{
6893 u8 reg;
6894 u8 value;
6895 u8 mask;
6896};
6897
6898enum version{
6899 VER_1_0,
6900 VER_2_0,
6901 VER_UNSUPPORTED = 0xFF
6902};
6903
6904static u8 read_bahama_ver(void)
6905{
6906 int rc;
6907 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6908 u8 bahama_version;
6909
6910 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6911 if (rc < 0) {
6912 printk(KERN_ERR
6913 "%s: version read failed: %d\n",
6914 __func__, rc);
6915 return VER_UNSUPPORTED;
6916 } else {
6917 printk(KERN_INFO
6918 "%s: version read got: 0x%x\n",
6919 __func__, bahama_version);
6920 }
6921
6922 switch (bahama_version) {
6923 case 0x08: /* varient of bahama v1 */
6924 case 0x10:
6925 case 0x00:
6926 return VER_1_0;
6927 case 0x09: /* variant of bahama v2 */
6928 return VER_2_0;
6929 default:
6930 return VER_UNSUPPORTED;
6931 }
6932}
6933
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006934static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006935static unsigned int msm_bahama_setup_power(void)
6936{
6937 int rc = 0;
6938 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006939
6940 if (machine_is_msm8x60_dragon())
6941 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6942
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006943 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6944
6945 if (IS_ERR(vreg_bahama)) {
6946 rc = PTR_ERR(vreg_bahama);
6947 pr_err("%s: regulator_get %s = %d\n", __func__,
6948 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006949 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006950 }
6951
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006952 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6953 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006954 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6955 msm_bahama_regulator, rc);
6956 goto unget;
6957 }
6958
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006959 rc = regulator_enable(vreg_bahama);
6960 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006961 pr_err("%s: regulator_enable %s = %d\n", __func__,
6962 msm_bahama_regulator, rc);
6963 goto unget;
6964 }
6965
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006966 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6967 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006968 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006969 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006970 goto unenable;
6971 }
6972
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006973 gpio_direction_output(msm_bahama_sys_rst, 0);
6974 usleep_range(1000, 1050);
6975 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6976 usleep_range(1000, 1050);
6977 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006978 return rc;
6979
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006980unenable:
6981 regulator_disable(vreg_bahama);
6982unget:
6983 regulator_put(vreg_bahama);
6984 return rc;
6985};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006986
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006987static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006988{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006989 if (msm_bahama_setup_power_enable) {
6990 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6991 gpio_free(msm_bahama_sys_rst);
6992 regulator_disable(vreg_bahama);
6993 regulator_put(vreg_bahama);
6994 msm_bahama_setup_power_enable = 0;
6995 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006996
6997 return 0;
6998};
6999
7000static unsigned int msm_bahama_core_config(int type)
7001{
7002 int rc = 0;
7003
7004 if (type == BAHAMA_ID) {
7005
7006 int i;
7007 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7008
7009 const struct bahama_config_register v20_init[] = {
7010 /* reg, value, mask */
7011 { 0xF4, 0x84, 0xFF }, /* AREG */
7012 { 0xF0, 0x04, 0xFF } /* DREG */
7013 };
7014
7015 if (read_bahama_ver() == VER_2_0) {
7016 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7017 u8 value = v20_init[i].value;
7018 rc = marimba_write_bit_mask(&config,
7019 v20_init[i].reg,
7020 &value,
7021 sizeof(v20_init[i].value),
7022 v20_init[i].mask);
7023 if (rc < 0) {
7024 printk(KERN_ERR
7025 "%s: reg %d write failed: %d\n",
7026 __func__, v20_init[i].reg, rc);
7027 return rc;
7028 }
7029 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7030 " mask 0x%02x\n",
7031 __func__, v20_init[i].reg,
7032 v20_init[i].value, v20_init[i].mask);
7033 }
7034 }
7035 }
7036 printk(KERN_INFO "core type: %d\n", type);
7037
7038 return rc;
7039}
7040
7041static struct regulator *fm_regulator_s3;
7042static struct msm_xo_voter *fm_clock;
7043
7044static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7045{
7046 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307047 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007048 .direction = PM_GPIO_DIR_IN,
7049 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307050 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007051 .function = PM_GPIO_FUNC_NORMAL,
7052 .inv_int_pol = 0,
7053 };
7054
7055 if (!fm_regulator_s3) {
7056 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7057 if (IS_ERR(fm_regulator_s3)) {
7058 rc = PTR_ERR(fm_regulator_s3);
7059 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7060 __func__, rc);
7061 goto out;
7062 }
7063 }
7064
7065
7066 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7067 if (rc < 0) {
7068 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7069 __func__, rc);
7070 goto fm_fail_put;
7071 }
7072
7073 rc = regulator_enable(fm_regulator_s3);
7074 if (rc < 0) {
7075 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7076 __func__, rc);
7077 goto fm_fail_put;
7078 }
7079
7080 /*Vote for XO clock*/
7081 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7082
7083 if (IS_ERR(fm_clock)) {
7084 rc = PTR_ERR(fm_clock);
7085 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7086 __func__, rc);
7087 goto fm_fail_switch;
7088 }
7089
7090 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7091 if (rc < 0) {
7092 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7093 __func__, rc);
7094 goto fm_fail_vote;
7095 }
7096
7097 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307098 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007099 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307100 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007101 __func__, rc);
7102 goto fm_fail_clock;
7103 }
7104 goto out;
7105
7106fm_fail_clock:
7107 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7108fm_fail_vote:
7109 msm_xo_put(fm_clock);
7110fm_fail_switch:
7111 regulator_disable(fm_regulator_s3);
7112fm_fail_put:
7113 regulator_put(fm_regulator_s3);
7114out:
7115 return rc;
7116};
7117
7118static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7119{
7120 int rc = 0;
7121 if (fm_regulator_s3 != NULL) {
7122 rc = regulator_disable(fm_regulator_s3);
7123 if (rc < 0) {
7124 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7125 __func__, rc);
7126 }
7127 regulator_put(fm_regulator_s3);
7128 fm_regulator_s3 = NULL;
7129 }
7130 printk(KERN_ERR "%s: Voting off for XO", __func__);
7131
7132 if (fm_clock != NULL) {
7133 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7134 if (rc < 0) {
7135 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7136 __func__, rc);
7137 }
7138 msm_xo_put(fm_clock);
7139 }
7140 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7141}
7142
7143/* Slave id address for FM/CDC/QMEMBIST
7144 * Values can be programmed using Marimba slave id 0
7145 * should there be a conflict with other I2C devices
7146 * */
7147#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7148#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7149
7150static struct marimba_fm_platform_data marimba_fm_pdata = {
7151 .fm_setup = fm_radio_setup,
7152 .fm_shutdown = fm_radio_shutdown,
7153 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7154 .is_fm_soc_i2s_master = false,
7155 .config_i2s_gpio = NULL,
7156};
7157
7158/*
7159Just initializing the BAHAMA related slave
7160*/
7161static struct marimba_platform_data marimba_pdata = {
7162 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7163 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7164 .bahama_setup = msm_bahama_setup_power,
7165 .bahama_shutdown = msm_bahama_shutdown_power,
7166 .bahama_core_config = msm_bahama_core_config,
7167 .fm = &marimba_fm_pdata,
7168 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7169};
7170
7171
7172static struct i2c_board_info msm_marimba_board_info[] = {
7173 {
7174 I2C_BOARD_INFO("marimba", 0xc),
7175 .platform_data = &marimba_pdata,
7176 }
7177};
7178#endif /* CONFIG_MAIMBA_CORE */
7179
7180#ifdef CONFIG_I2C
7181#define I2C_SURF 1
7182#define I2C_FFA (1 << 1)
7183#define I2C_RUMI (1 << 2)
7184#define I2C_SIM (1 << 3)
7185#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007186#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007187
7188struct i2c_registry {
7189 u8 machs;
7190 int bus;
7191 struct i2c_board_info *info;
7192 int len;
7193};
7194
7195static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007196#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7197 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007198 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007199 MSM_GSBI8_QUP_I2C_BUS_ID,
7200 core_expander_i2c_info,
7201 ARRAY_SIZE(core_expander_i2c_info),
7202 },
7203 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007204 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007205 MSM_GSBI8_QUP_I2C_BUS_ID,
7206 docking_expander_i2c_info,
7207 ARRAY_SIZE(docking_expander_i2c_info),
7208 },
7209 {
7210 I2C_SURF,
7211 MSM_GSBI8_QUP_I2C_BUS_ID,
7212 surf_expanders_i2c_info,
7213 ARRAY_SIZE(surf_expanders_i2c_info),
7214 },
7215 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007216 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007217 MSM_GSBI3_QUP_I2C_BUS_ID,
7218 fha_expanders_i2c_info,
7219 ARRAY_SIZE(fha_expanders_i2c_info),
7220 },
7221 {
7222 I2C_FLUID,
7223 MSM_GSBI3_QUP_I2C_BUS_ID,
7224 fluid_expanders_i2c_info,
7225 ARRAY_SIZE(fluid_expanders_i2c_info),
7226 },
7227 {
7228 I2C_FLUID,
7229 MSM_GSBI8_QUP_I2C_BUS_ID,
7230 fluid_core_expander_i2c_info,
7231 ARRAY_SIZE(fluid_core_expander_i2c_info),
7232 },
7233#endif
7234#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7235 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7236 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007237 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007238 MSM_GSBI3_QUP_I2C_BUS_ID,
7239 msm_i2c_gsbi3_tdisc_info,
7240 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7241 },
7242#endif
7243 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007244 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007245 MSM_GSBI3_QUP_I2C_BUS_ID,
7246 cy8ctmg200_board_info,
7247 ARRAY_SIZE(cy8ctmg200_board_info),
7248 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007249 {
7250 I2C_DRAGON,
7251 MSM_GSBI3_QUP_I2C_BUS_ID,
7252 cy8ctma340_dragon_board_info,
7253 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7254 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007255#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7256 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7257 {
7258 I2C_FLUID,
7259 MSM_GSBI3_QUP_I2C_BUS_ID,
7260 cyttsp_fluid_info,
7261 ARRAY_SIZE(cyttsp_fluid_info),
7262 },
7263 {
7264 I2C_FFA | I2C_SURF,
7265 MSM_GSBI3_QUP_I2C_BUS_ID,
7266 cyttsp_ffa_info,
7267 ARRAY_SIZE(cyttsp_ffa_info),
7268 },
7269#endif
7270#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007271#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007272 {
7273 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007274 MSM_GSBI4_QUP_I2C_BUS_ID,
7275 msm_camera_boardinfo,
7276 ARRAY_SIZE(msm_camera_boardinfo),
7277 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007278 {
7279 I2C_DRAGON,
7280 MSM_GSBI4_QUP_I2C_BUS_ID,
7281 msm_camera_dragon_boardinfo,
7282 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7283 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007284#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007285#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007286 {
7287 I2C_SURF | I2C_FFA | I2C_FLUID,
7288 MSM_GSBI7_QUP_I2C_BUS_ID,
7289 msm_i2c_gsbi7_timpani_info,
7290 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7291 },
7292#if defined(CONFIG_MARIMBA_CORE)
7293 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007294 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007295 MSM_GSBI7_QUP_I2C_BUS_ID,
7296 msm_marimba_board_info,
7297 ARRAY_SIZE(msm_marimba_board_info),
7298 },
7299#endif /* CONFIG_MARIMBA_CORE */
7300#ifdef CONFIG_ISL9519_CHARGER
7301 {
7302 I2C_SURF | I2C_FFA,
7303 MSM_GSBI8_QUP_I2C_BUS_ID,
7304 isl_charger_i2c_info,
7305 ARRAY_SIZE(isl_charger_i2c_info),
7306 },
7307#endif
7308#if defined(CONFIG_HAPTIC_ISA1200) || \
7309 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7310 {
7311 I2C_FLUID,
7312 MSM_GSBI8_QUP_I2C_BUS_ID,
7313 msm_isa1200_board_info,
7314 ARRAY_SIZE(msm_isa1200_board_info),
7315 },
7316#endif
7317#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7318 {
7319 I2C_FLUID,
7320 MSM_GSBI8_QUP_I2C_BUS_ID,
7321 smb137b_charger_i2c_info,
7322 ARRAY_SIZE(smb137b_charger_i2c_info),
7323 },
7324#endif
7325#if defined(CONFIG_BATTERY_BQ27520) || \
7326 defined(CONFIG_BATTERY_BQ27520_MODULE)
7327 {
7328 I2C_FLUID,
7329 MSM_GSBI8_QUP_I2C_BUS_ID,
7330 msm_bq27520_board_info,
7331 ARRAY_SIZE(msm_bq27520_board_info),
7332 },
7333#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007334#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7335 {
7336 I2C_DRAGON,
7337 MSM_GSBI8_QUP_I2C_BUS_ID,
7338 wm8903_codec_i2c_info,
7339 ARRAY_SIZE(wm8903_codec_i2c_info),
7340 },
7341#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007342};
7343#endif /* CONFIG_I2C */
7344
Stephen Boyd668d7652012-04-25 11:31:01 -07007345static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007346{
7347#ifdef CONFIG_I2C
7348#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7349 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7350 sx150x_data[SX150X_CORE].irq_summary =
7351 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007352 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7353 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007354 sx150x_data[SX150X_CORE].irq_summary =
7355 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7356 else if (machine_is_msm8x60_fluid())
7357 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7358 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7359#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007360#endif
7361}
7362
Stephen Boyd668d7652012-04-25 11:31:01 -07007363static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007364{
7365#ifdef CONFIG_I2C
7366 u8 mach_mask = 0;
7367 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007368#ifdef CONFIG_MSM_CAMERA_V4L2
7369 struct i2c_registry msm8x60_camera_i2c_devices = {
7370 I2C_SURF | I2C_FFA | I2C_FLUID,
7371 MSM_GSBI4_QUP_I2C_BUS_ID,
7372 msm8x60_camera_board_info.board_info,
7373 msm8x60_camera_board_info.num_i2c_board_info,
7374 };
7375#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007376
7377 /* Build the matching 'supported_machs' bitmask */
7378 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7379 mach_mask = I2C_SURF;
7380 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7381 mach_mask = I2C_FFA;
7382 else if (machine_is_msm8x60_rumi3())
7383 mach_mask = I2C_RUMI;
7384 else if (machine_is_msm8x60_sim())
7385 mach_mask = I2C_SIM;
7386 else if (machine_is_msm8x60_fluid())
7387 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007388 else if (machine_is_msm8x60_dragon())
7389 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007390 else
7391 pr_err("unmatched machine ID in register_i2c_devices\n");
7392
7393 /* Run the array and install devices as appropriate */
7394 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7395 if (msm8x60_i2c_devices[i].machs & mach_mask)
7396 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7397 msm8x60_i2c_devices[i].info,
7398 msm8x60_i2c_devices[i].len);
7399 }
Kevin Chan3be11612012-03-22 20:05:40 -07007400#ifdef CONFIG_MSM_CAMERA_V4L2
7401 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7402 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7403 msm8x60_camera_i2c_devices.info,
7404 msm8x60_camera_i2c_devices.len);
7405#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007406#endif
7407}
7408
7409static void __init msm8x60_init_uart12dm(void)
7410{
7411#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7412 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7413 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7414
7415 if (!fpga_mem)
7416 pr_err("%s(): Error getting memory\n", __func__);
7417
7418 /* Advanced mode */
7419 writew(0xFFFF, fpga_mem + 0x15C);
7420 /* FPGA_UART_SEL */
7421 writew(0, fpga_mem + 0x172);
7422 /* FPGA_GPIO_CONFIG_117 */
7423 writew(1, fpga_mem + 0xEA);
7424 /* FPGA_GPIO_CONFIG_118 */
7425 writew(1, fpga_mem + 0xEC);
7426 mb();
7427 iounmap(fpga_mem);
7428#endif
7429}
7430
7431#define MSM_GSBI9_PHYS 0x19900000
7432#define GSBI_DUAL_MODE_CODE 0x60
7433
7434static void __init msm8x60_init_buses(void)
7435{
7436#ifdef CONFIG_I2C_QUP
7437 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7438 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7439 writel_relaxed(0x6 << 4, gsbi_mem);
7440 /* Ensure protocol code is written before proceeding further */
7441 mb();
7442 iounmap(gsbi_mem);
7443
7444 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7445 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7446 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7447 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7448
7449#ifdef CONFIG_MSM_GSBI9_UART
7450 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7451 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7452 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7453 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7454 iounmap(gsbi_mem);
7455 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7456 }
7457#endif
7458 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7459 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7460#endif
7461#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7462 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7463#endif
7464#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007465 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7466#endif
7467
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307468#ifdef CONFIG_MSM_SSBI
7469 msm_device_ssbi_pmic1.dev.platform_data =
7470 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307471 msm_device_ssbi_pmic2.dev.platform_data =
7472 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307473#endif
7474
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007475 if (machine_is_msm8x60_fluid()) {
7476#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7477 (defined(CONFIG_SMB137B_CHARGER) || \
7478 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7479 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7480#endif
7481#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7482 msm_gsbi10_qup_spi_device.dev.platform_data =
7483 &msm_gsbi10_qup_spi_pdata;
7484#endif
7485 }
7486
Lena Salman57d167e2012-03-21 19:46:38 +02007487#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007488 /*
7489 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7490 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7491 * and ID notifications are available only on V2 surf and FFA
7492 * with a hardware workaround.
7493 */
7494 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7495 (machine_is_msm8x60_surf() ||
7496 (machine_is_msm8x60_ffa() &&
7497 pmic_id_notif_supported)))
7498 msm_otg_pdata.phy_can_powercollapse = 1;
7499 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7500#endif
7501
Lena Salman57d167e2012-03-21 19:46:38 +02007502#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007503 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7504#endif
7505
7506#ifdef CONFIG_SERIAL_MSM_HS
7507 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7508 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7509#endif
7510#ifdef CONFIG_MSM_GSBI9_UART
7511 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7512 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7513 if (IS_ERR(msm_device_uart_gsbi9))
7514 pr_err("%s(): Failed to create uart gsbi9 device\n",
7515 __func__);
7516 }
7517#endif
7518
7519#ifdef CONFIG_MSM_BUS_SCALING
7520
7521 /* RPM calls are only enabled on V2 */
7522 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7523 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7524 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7525 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7526 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7527 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7528 }
7529
7530 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7531 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7532 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7533 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7534 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7535#endif
7536}
7537
7538static void __init msm8x60_map_io(void)
7539{
7540 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7541 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007542
7543 if (socinfo_init() < 0)
7544 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007545}
7546
7547/*
7548 * Most segments of the EBI2 bus are disabled by default.
7549 */
7550static void __init msm8x60_init_ebi2(void)
7551{
7552 uint32_t ebi2_cfg;
7553 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007554 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7555
7556 if (IS_ERR(mem_clk)) {
7557 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7558 "msm_ebi2", "mem_clk");
7559 return;
7560 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007561 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007562 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007563
7564 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7565 if (ebi2_cfg_ptr != 0) {
7566 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7567
7568 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007569 machine_is_msm8x60_fluid() ||
7570 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007571 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7572 else if (machine_is_msm8x60_sim())
7573 ebi2_cfg |= (1 << 4); /* CS2 */
7574 else if (machine_is_msm8x60_rumi3())
7575 ebi2_cfg |= (1 << 5); /* CS3 */
7576
7577 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7578 iounmap(ebi2_cfg_ptr);
7579 }
7580
7581 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007582 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007583 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7584 if (ebi2_cfg_ptr != 0) {
7585 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7586 writel_relaxed(0UL, ebi2_cfg_ptr);
7587
7588 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7589 * LAN9221 Ethernet controller reads and writes.
7590 * The lowest 4 bits are the read delay, the next
7591 * 4 are the write delay. */
7592 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7593#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7594 /*
7595 * RECOVERY=5, HOLD_WR=1
7596 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7597 * WAIT_WR=1, WAIT_RD=2
7598 */
7599 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7600 /*
7601 * HOLD_RD=1
7602 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7603 */
7604 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7605#else
7606 /* EBI2 CS3 muxed address/data,
7607 * two cyc addr enable */
7608 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7609
7610#endif
7611 iounmap(ebi2_cfg_ptr);
7612 }
7613 }
7614}
7615
7616static void __init msm8x60_configure_smc91x(void)
7617{
7618 if (machine_is_msm8x60_sim()) {
7619
7620 smc91x_resources[0].start = 0x1b800300;
7621 smc91x_resources[0].end = 0x1b8003ff;
7622
7623 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7624 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7625
7626 } else if (machine_is_msm8x60_rumi3()) {
7627
7628 smc91x_resources[0].start = 0x1d000300;
7629 smc91x_resources[0].end = 0x1d0003ff;
7630
7631 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7632 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7633 }
7634}
7635
7636static void __init msm8x60_init_tlmm(void)
7637{
7638 if (machine_is_msm8x60_rumi3())
7639 msm_gpio_install_direct_irq(0, 0, 1);
7640}
7641
7642#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7643 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7644 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7645 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7646 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7647
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007648/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007649#define MAX_SDCC_CONTROLLER 5
7650
7651struct msm_sdcc_gpio {
7652 /* maximum 10 GPIOs per SDCC controller */
7653 s16 no;
7654 /* name of this GPIO */
7655 const char *name;
7656 bool always_on;
7657 bool is_enabled;
7658};
7659
7660#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7661static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7662 {159, "sdc1_dat_0"},
7663 {160, "sdc1_dat_1"},
7664 {161, "sdc1_dat_2"},
7665 {162, "sdc1_dat_3"},
7666#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7667 {163, "sdc1_dat_4"},
7668 {164, "sdc1_dat_5"},
7669 {165, "sdc1_dat_6"},
7670 {166, "sdc1_dat_7"},
7671#endif
7672 {167, "sdc1_clk"},
7673 {168, "sdc1_cmd"}
7674};
7675#endif
7676
7677#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7678static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7679 {143, "sdc2_dat_0"},
7680 {144, "sdc2_dat_1", 1},
7681 {145, "sdc2_dat_2"},
7682 {146, "sdc2_dat_3"},
7683#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7684 {147, "sdc2_dat_4"},
7685 {148, "sdc2_dat_5"},
7686 {149, "sdc2_dat_6"},
7687 {150, "sdc2_dat_7"},
7688#endif
7689 {151, "sdc2_cmd"},
7690 {152, "sdc2_clk", 1}
7691};
7692#endif
7693
7694#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7695static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7696 {95, "sdc5_cmd"},
7697 {96, "sdc5_dat_3"},
7698 {97, "sdc5_clk", 1},
7699 {98, "sdc5_dat_2"},
7700 {99, "sdc5_dat_1", 1},
7701 {100, "sdc5_dat_0"}
7702};
7703#endif
7704
7705struct msm_sdcc_pad_pull_cfg {
7706 enum msm_tlmm_pull_tgt pull;
7707 u32 pull_val;
7708};
7709
7710struct msm_sdcc_pad_drv_cfg {
7711 enum msm_tlmm_hdrive_tgt drv;
7712 u32 drv_val;
7713};
7714
7715#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7716static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7717 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7718 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7719 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7720};
7721
7722static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7723 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7724 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7725};
7726
7727static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7728 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7729 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7730 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7731};
7732
7733static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7734 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7735 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7736};
7737#endif
7738
7739#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7740static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7741 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7742 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7743 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7744};
7745
7746static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7747 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7748 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7749};
7750
7751static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7752 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7753 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7754 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7755};
7756
7757static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7758 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7759 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7760};
7761#endif
7762
7763struct msm_sdcc_pin_cfg {
7764 /*
7765 * = 1 if controller pins are using gpios
7766 * = 0 if controller has dedicated MSM pins
7767 */
7768 u8 is_gpio;
7769 u8 cfg_sts;
7770 u8 gpio_data_size;
7771 struct msm_sdcc_gpio *gpio_data;
7772 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7773 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7774 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7775 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7776 u8 pad_drv_data_size;
7777 u8 pad_pull_data_size;
7778 u8 sdio_lpm_gpio_cfg;
7779};
7780
7781
7782static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7783#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7784 [0] = {
7785 .is_gpio = 1,
7786 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7787 .gpio_data = sdc1_gpio_cfg
7788 },
7789#endif
7790#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7791 [1] = {
7792 .is_gpio = 1,
7793 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7794 .gpio_data = sdc2_gpio_cfg
7795 },
7796#endif
7797#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7798 [2] = {
7799 .is_gpio = 0,
7800 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7801 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7802 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7803 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7804 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7805 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7806 },
7807#endif
7808#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7809 [3] = {
7810 .is_gpio = 0,
7811 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7812 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7813 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7814 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7815 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7816 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7817 },
7818#endif
7819#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7820 [4] = {
7821 .is_gpio = 1,
7822 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7823 .gpio_data = sdc5_gpio_cfg
7824 }
7825#endif
7826};
7827
7828static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7829{
7830 int rc = 0;
7831 struct msm_sdcc_pin_cfg *curr;
7832 int n;
7833
7834 curr = &sdcc_pin_cfg_data[dev_id - 1];
7835 if (!curr->gpio_data)
7836 goto out;
7837
7838 for (n = 0; n < curr->gpio_data_size; n++) {
7839 if (enable) {
7840
7841 if (curr->gpio_data[n].always_on &&
7842 curr->gpio_data[n].is_enabled)
7843 continue;
7844 pr_debug("%s: enable: %s\n", __func__,
7845 curr->gpio_data[n].name);
7846 rc = gpio_request(curr->gpio_data[n].no,
7847 curr->gpio_data[n].name);
7848 if (rc) {
7849 pr_err("%s: gpio_request(%d, %s)"
7850 "failed", __func__,
7851 curr->gpio_data[n].no,
7852 curr->gpio_data[n].name);
7853 goto free_gpios;
7854 }
7855 /* set direction as output for all GPIOs */
7856 rc = gpio_direction_output(
7857 curr->gpio_data[n].no, 1);
7858 if (rc) {
7859 pr_err("%s: gpio_direction_output"
7860 "(%d, 1) failed\n", __func__,
7861 curr->gpio_data[n].no);
7862 goto free_gpios;
7863 }
7864 curr->gpio_data[n].is_enabled = 1;
7865 } else {
7866 /*
7867 * now free this GPIO which will put GPIO
7868 * in low power mode and will also put GPIO
7869 * in input mode
7870 */
7871 if (curr->gpio_data[n].always_on)
7872 continue;
7873 pr_debug("%s: disable: %s\n", __func__,
7874 curr->gpio_data[n].name);
7875 gpio_free(curr->gpio_data[n].no);
7876 curr->gpio_data[n].is_enabled = 0;
7877 }
7878 }
7879 curr->cfg_sts = enable;
7880 goto out;
7881
7882free_gpios:
7883 for (; n >= 0; n--)
7884 gpio_free(curr->gpio_data[n].no);
7885out:
7886 return rc;
7887}
7888
7889static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7890{
7891 int rc = 0;
7892 struct msm_sdcc_pin_cfg *curr;
7893 int n;
7894
7895 curr = &sdcc_pin_cfg_data[dev_id - 1];
7896 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7897 goto out;
7898
7899 if (enable) {
7900 /*
7901 * set up the normal driver strength and
7902 * pull config for pads
7903 */
7904 for (n = 0; n < curr->pad_drv_data_size; n++) {
7905 if (curr->sdio_lpm_gpio_cfg) {
7906 if (curr->pad_drv_on_data[n].drv ==
7907 TLMM_HDRV_SDC4_DATA)
7908 continue;
7909 }
7910 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7911 curr->pad_drv_on_data[n].drv_val);
7912 }
7913 for (n = 0; n < curr->pad_pull_data_size; n++) {
7914 if (curr->sdio_lpm_gpio_cfg) {
7915 if (curr->pad_pull_on_data[n].pull ==
7916 TLMM_PULL_SDC4_DATA)
7917 continue;
7918 }
7919 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7920 curr->pad_pull_on_data[n].pull_val);
7921 }
7922 } else {
7923 /* set the low power config for pads */
7924 for (n = 0; n < curr->pad_drv_data_size; n++) {
7925 if (curr->sdio_lpm_gpio_cfg) {
7926 if (curr->pad_drv_off_data[n].drv ==
7927 TLMM_HDRV_SDC4_DATA)
7928 continue;
7929 }
7930 msm_tlmm_set_hdrive(
7931 curr->pad_drv_off_data[n].drv,
7932 curr->pad_drv_off_data[n].drv_val);
7933 }
7934 for (n = 0; n < curr->pad_pull_data_size; n++) {
7935 if (curr->sdio_lpm_gpio_cfg) {
7936 if (curr->pad_pull_off_data[n].pull ==
7937 TLMM_PULL_SDC4_DATA)
7938 continue;
7939 }
7940 msm_tlmm_set_pull(
7941 curr->pad_pull_off_data[n].pull,
7942 curr->pad_pull_off_data[n].pull_val);
7943 }
7944 }
7945 curr->cfg_sts = enable;
7946out:
7947 return rc;
7948}
7949
7950struct sdcc_reg {
7951 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7952 const char *reg_name;
7953 /*
7954 * is set voltage supported for this regulator?
7955 * 0 = not supported, 1 = supported
7956 */
7957 unsigned char set_voltage_sup;
7958 /* voltage level to be set */
7959 unsigned int level;
7960 /* VDD/VCC/VCCQ voltage regulator handle */
7961 struct regulator *reg;
7962 /* is this regulator enabled? */
7963 bool enabled;
7964 /* is this regulator needs to be always on? */
7965 bool always_on;
7966 /* is operating power mode setting required for this regulator? */
7967 bool op_pwr_mode_sup;
7968 /* Load values for low power and high power mode */
7969 unsigned int lpm_uA;
7970 unsigned int hpm_uA;
7971};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007972/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007973static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7974/* only SDCC1 requires VCCQ voltage */
7975static struct sdcc_reg sdcc_vccq_reg_data[1];
7976/* all SDCC controllers may require voting for VDD PAD voltage */
7977static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7978
7979struct sdcc_reg_data {
7980 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7981 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7982 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7983 unsigned char sts; /* regulator enable/disable status */
7984};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007985/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007986static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7987
7988static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7989{
7990 int rc = 0;
7991
7992 /* Get the regulator handle */
7993 vreg->reg = regulator_get(NULL, vreg->reg_name);
7994 if (IS_ERR(vreg->reg)) {
7995 rc = PTR_ERR(vreg->reg);
7996 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7997 __func__, vreg->reg_name, rc);
7998 goto out;
7999 }
8000
8001 /* Set the voltage level if required */
8002 if (vreg->set_voltage_sup) {
8003 rc = regulator_set_voltage(vreg->reg, vreg->level,
8004 vreg->level);
8005 if (rc) {
8006 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
8007 __func__, vreg->reg_name, rc);
8008 goto vreg_put;
8009 }
8010 }
8011 goto out;
8012
8013vreg_put:
8014 regulator_put(vreg->reg);
8015out:
8016 return rc;
8017}
8018
8019static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
8020{
8021 regulator_put(vreg->reg);
8022}
8023
8024/* this init function should be called only once for each SDCC */
8025static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
8026{
8027 int rc = 0;
8028 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8029 struct sdcc_reg_data *curr;
8030
8031 curr = &sdcc_vreg_data[dev_id - 1];
8032 curr_vdd_reg = curr->vdd_data;
8033 curr_vccq_reg = curr->vccq_data;
8034 curr_vddp_reg = curr->vddp_data;
8035
8036 if (init) {
8037 /*
8038 * get the regulator handle from voltage regulator framework
8039 * and then try to set the voltage level for the regulator
8040 */
8041 if (curr_vdd_reg) {
8042 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8043 if (rc)
8044 goto out;
8045 }
8046 if (curr_vccq_reg) {
8047 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8048 if (rc)
8049 goto vdd_reg_deinit;
8050 }
8051 if (curr_vddp_reg) {
8052 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8053 if (rc)
8054 goto vccq_reg_deinit;
8055 }
8056 goto out;
8057 } else
8058 /* deregister with all regulators from regulator framework */
8059 goto vddp_reg_deinit;
8060
8061vddp_reg_deinit:
8062 if (curr_vddp_reg)
8063 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8064vccq_reg_deinit:
8065 if (curr_vccq_reg)
8066 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8067vdd_reg_deinit:
8068 if (curr_vdd_reg)
8069 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8070out:
8071 return rc;
8072}
8073
8074static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8075{
8076 int rc;
8077
8078 if (!vreg->enabled) {
8079 rc = regulator_enable(vreg->reg);
8080 if (rc) {
8081 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8082 __func__, vreg->reg_name, rc);
8083 goto out;
8084 }
8085 vreg->enabled = 1;
8086 }
8087
8088 /* Put always_on regulator in HPM (high power mode) */
8089 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8090 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8091 if (rc < 0) {
8092 pr_err("%s: reg=%s: HPM setting failed"
8093 " hpm_uA=%d, rc=%d\n",
8094 __func__, vreg->reg_name,
8095 vreg->hpm_uA, rc);
8096 goto vreg_disable;
8097 }
8098 rc = 0;
8099 }
8100 goto out;
8101
8102vreg_disable:
8103 regulator_disable(vreg->reg);
8104 vreg->enabled = 0;
8105out:
8106 return rc;
8107}
8108
8109static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8110{
8111 int rc;
8112
8113 /* Never disable always_on regulator */
8114 if (!vreg->always_on) {
8115 rc = regulator_disable(vreg->reg);
8116 if (rc) {
8117 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8118 __func__, vreg->reg_name, rc);
8119 goto out;
8120 }
8121 vreg->enabled = 0;
8122 }
8123
8124 /* Put always_on regulator in LPM (low power mode) */
8125 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8126 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8127 if (rc < 0) {
8128 pr_err("%s: reg=%s: LPM setting failed"
8129 " lpm_uA=%d, rc=%d\n",
8130 __func__,
8131 vreg->reg_name,
8132 vreg->lpm_uA, rc);
8133 goto out;
8134 }
8135 rc = 0;
8136 }
8137
8138out:
8139 return rc;
8140}
8141
8142static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8143{
8144 int rc = 0;
8145 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8146 struct sdcc_reg_data *curr;
8147
8148 curr = &sdcc_vreg_data[dev_id - 1];
8149 curr_vdd_reg = curr->vdd_data;
8150 curr_vccq_reg = curr->vccq_data;
8151 curr_vddp_reg = curr->vddp_data;
8152
8153 /* check if regulators are initialized or not? */
8154 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8155 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8156 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8157 /* initialize voltage regulators required for this SDCC */
8158 rc = msm_sdcc_vreg_init(dev_id, 1);
8159 if (rc) {
8160 pr_err("%s: regulator init failed = %d\n",
8161 __func__, rc);
8162 goto out;
8163 }
8164 }
8165
8166 if (curr->sts == enable)
8167 goto out;
8168
8169 if (curr_vdd_reg) {
8170 if (enable)
8171 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8172 else
8173 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8174 if (rc)
8175 goto out;
8176 }
8177
8178 if (curr_vccq_reg) {
8179 if (enable)
8180 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8181 else
8182 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8183 if (rc)
8184 goto out;
8185 }
8186
8187 if (curr_vddp_reg) {
8188 if (enable)
8189 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8190 else
8191 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8192 if (rc)
8193 goto out;
8194 }
8195 curr->sts = enable;
8196
8197out:
8198 return rc;
8199}
8200
8201static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8202{
8203 u32 rc_pin_cfg = 0;
8204 u32 rc_vreg_cfg = 0;
8205 u32 rc = 0;
8206 struct platform_device *pdev;
8207 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8208
8209 pdev = container_of(dv, struct platform_device, dev);
8210
8211 /* setup gpio/pad */
8212 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8213 if (curr_pin_cfg->cfg_sts == !!vdd)
8214 goto setup_vreg;
8215
8216 if (curr_pin_cfg->is_gpio)
8217 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8218 else
8219 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8220
8221setup_vreg:
8222 /* setup voltage regulators */
8223 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8224
8225 if (rc_pin_cfg || rc_vreg_cfg)
8226 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8227
8228 return rc;
8229}
8230
8231static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8232{
8233 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8234 struct platform_device *pdev;
8235
8236 pdev = container_of(dv, struct platform_device, dev);
8237 /* setup gpio/pad */
8238 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8239
8240 if (curr_pin_cfg->cfg_sts == active)
8241 return;
8242
8243 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8244 if (curr_pin_cfg->is_gpio)
8245 msm_sdcc_setup_gpio(pdev->id, active);
8246 else
8247 msm_sdcc_setup_pad(pdev->id, active);
8248 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8249}
8250
8251static int msm_sdc3_get_wpswitch(struct device *dev)
8252{
8253 struct platform_device *pdev;
8254 int status;
8255 pdev = container_of(dev, struct platform_device, dev);
8256
8257 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8258 if (status) {
8259 pr_err("%s:Failed to request GPIO %d\n",
8260 __func__, GPIO_SDC_WP);
8261 } else {
8262 status = gpio_direction_input(GPIO_SDC_WP);
8263 if (!status) {
8264 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8265 pr_info("%s: WP Status for Slot %d = %d\n",
8266 __func__, pdev->id, status);
8267 }
8268 gpio_free(GPIO_SDC_WP);
8269 }
8270 return status;
8271}
8272
8273#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8274int sdc5_register_status_notify(void (*callback)(int, void *),
8275 void *dev_id)
8276{
8277 sdc5_status_notify_cb = callback;
8278 sdc5_status_notify_cb_devid = dev_id;
8279 return 0;
8280}
8281#endif
8282
8283#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8284int sdc2_register_status_notify(void (*callback)(int, void *),
8285 void *dev_id)
8286{
8287 sdc2_status_notify_cb = callback;
8288 sdc2_status_notify_cb_devid = dev_id;
8289 return 0;
8290}
8291#endif
8292
8293/* Interrupt handler for SDC2 and SDC5 detection
8294 * This function uses dual-edge interrputs settings in order
8295 * to get SDIO detection when the GPIO is rising and SDIO removal
8296 * when the GPIO is falling */
8297static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8298{
8299 int status;
8300
8301 if (!machine_is_msm8x60_fusion() &&
8302 !machine_is_msm8x60_fusn_ffa())
8303 return IRQ_NONE;
8304
8305 status = gpio_get_value(MDM2AP_SYNC);
8306 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8307 __func__, status);
8308
8309#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8310 if (sdc2_status_notify_cb) {
8311 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8312 sdc2_status_notify_cb(status,
8313 sdc2_status_notify_cb_devid);
8314 }
8315#endif
8316
8317#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8318 if (sdc5_status_notify_cb) {
8319 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8320 sdc5_status_notify_cb(status,
8321 sdc5_status_notify_cb_devid);
8322 }
8323#endif
8324 return IRQ_HANDLED;
8325}
8326
8327static int msm8x60_multi_sdio_init(void)
8328{
8329 int ret, irq_num;
8330
8331 if (!machine_is_msm8x60_fusion() &&
8332 !machine_is_msm8x60_fusn_ffa())
8333 return 0;
8334
8335 ret = msm_gpiomux_get(MDM2AP_SYNC);
8336 if (ret) {
8337 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8338 __func__, MDM2AP_SYNC, ret);
8339 return ret;
8340 }
8341
8342 irq_num = gpio_to_irq(MDM2AP_SYNC);
8343
8344 ret = request_irq(irq_num,
8345 msm8x60_multi_sdio_slot_status_irq,
8346 IRQ_TYPE_EDGE_BOTH,
8347 "sdio_multidetection", NULL);
8348
8349 if (ret) {
8350 pr_err("%s:Failed to request irq, ret=%d\n",
8351 __func__, ret);
8352 return ret;
8353 }
8354
8355 return ret;
8356}
8357
8358#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8359#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8360static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8361{
8362 int status;
8363
8364 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8365 , "SD_HW_Detect");
8366 if (status) {
8367 pr_err("%s:Failed to request GPIO %d\n", __func__,
8368 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8369 } else {
8370 status = gpio_direction_input(
8371 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8372 if (!status)
8373 status = !(gpio_get_value_cansleep(
8374 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8375 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8376 }
8377 return (unsigned int) status;
8378}
8379#endif
8380#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308381#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008382
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308383#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308384#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008385
8386#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8387static struct mmc_platform_data msm8x60_sdc1_data = {
8388 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8389 .translate_vdd = msm_sdcc_setup_power,
8390#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8391 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8392#else
8393 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8394#endif
8395 .msmsdcc_fmin = 400000,
8396 .msmsdcc_fmid = 24000000,
8397 .msmsdcc_fmax = 48000000,
8398 .nonremovable = 1,
8399 .pclk_src_dfab = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308400 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008401};
8402#endif
8403
8404#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8405static struct mmc_platform_data msm8x60_sdc2_data = {
8406 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8407 .translate_vdd = msm_sdcc_setup_power,
8408 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8409 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8410 .msmsdcc_fmin = 400000,
8411 .msmsdcc_fmid = 24000000,
8412 .msmsdcc_fmax = 48000000,
8413 .nonremovable = 0,
8414 .pclk_src_dfab = 1,
8415 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008416#ifdef CONFIG_MSM_SDIO_AL
8417 .is_sdio_al_client = 1,
8418#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308419 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008420};
8421#endif
8422
8423#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8424static struct mmc_platform_data msm8x60_sdc3_data = {
8425 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8426 .translate_vdd = msm_sdcc_setup_power,
8427 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8428 .wpswitch = msm_sdc3_get_wpswitch,
8429#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8430 .status = msm8x60_sdcc_slot_status,
8431 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8432 PMIC_GPIO_SDC3_DET - 1),
8433 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8434#endif
8435 .msmsdcc_fmin = 400000,
8436 .msmsdcc_fmid = 24000000,
8437 .msmsdcc_fmax = 48000000,
8438 .nonremovable = 0,
8439 .pclk_src_dfab = 1,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308440 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308441 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008442};
8443#endif
8444
8445#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8446static struct mmc_platform_data msm8x60_sdc4_data = {
8447 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8448 .translate_vdd = msm_sdcc_setup_power,
8449 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8450 .msmsdcc_fmin = 400000,
8451 .msmsdcc_fmid = 24000000,
8452 .msmsdcc_fmax = 48000000,
8453 .nonremovable = 0,
8454 .pclk_src_dfab = 1,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308455 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308456 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008457};
8458#endif
8459
8460#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8461static struct mmc_platform_data msm8x60_sdc5_data = {
8462 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8463 .translate_vdd = msm_sdcc_setup_power,
8464 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8465 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8466 .msmsdcc_fmin = 400000,
8467 .msmsdcc_fmid = 24000000,
8468 .msmsdcc_fmax = 48000000,
8469 .nonremovable = 0,
8470 .pclk_src_dfab = 1,
8471 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008472#ifdef CONFIG_MSM_SDIO_AL
8473 .is_sdio_al_client = 1,
8474#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308475 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008476};
8477#endif
8478
8479static void __init msm8x60_init_mmc(void)
8480{
8481#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8482 /* SDCC1 : eMMC card connected */
8483 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8484 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8485 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8486 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308487 sdcc_vreg_data[0].vdd_data->always_on = 1;
8488 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8489 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8490 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008491
8492 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8493 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8494 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8495 sdcc_vreg_data[0].vccq_data->always_on = 1;
8496
8497 msm_add_sdcc(1, &msm8x60_sdc1_data);
8498#endif
8499#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8500 /*
8501 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8502 * and no card is connected on 8660 SURF/FFA/FLUID.
8503 */
8504 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8505 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8506 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8507 sdcc_vreg_data[1].vdd_data->level = 1800000;
8508
8509 sdcc_vreg_data[1].vccq_data = NULL;
8510
8511 if (machine_is_msm8x60_fusion())
8512 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8513 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008514 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8515 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008516 msm_add_sdcc(2, &msm8x60_sdc2_data);
8517 }
8518#endif
8519#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8520 /* SDCC3 : External card slot connected */
8521 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8522 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8523 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8524 sdcc_vreg_data[2].vdd_data->level = 2850000;
8525 sdcc_vreg_data[2].vdd_data->always_on = 1;
8526 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8527 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8528 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8529
8530 sdcc_vreg_data[2].vccq_data = NULL;
8531
8532 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8533 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8534 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8535 sdcc_vreg_data[2].vddp_data->level = 2850000;
8536 sdcc_vreg_data[2].vddp_data->always_on = 1;
8537 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8538 /* Sleep current required is ~300 uA. But min. RPM
8539 * vote can be in terms of mA (min. 1 mA).
8540 * So let's vote for 2 mA during sleep.
8541 */
8542 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8543 /* Max. Active current required is 16 mA */
8544 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8545
8546 if (machine_is_msm8x60_fluid())
8547 msm8x60_sdc3_data.wpswitch = NULL;
8548 msm_add_sdcc(3, &msm8x60_sdc3_data);
8549#endif
8550#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8551 /* SDCC4 : WLAN WCN1314 chip is connected */
8552 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8553 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8554 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8555 sdcc_vreg_data[3].vdd_data->level = 1800000;
8556
8557 sdcc_vreg_data[3].vccq_data = NULL;
8558
8559 msm_add_sdcc(4, &msm8x60_sdc4_data);
8560#endif
8561#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8562 /*
8563 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8564 * and no card is connected on 8660 SURF/FFA/FLUID.
8565 */
8566 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8567 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8568 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8569 sdcc_vreg_data[4].vdd_data->level = 1800000;
8570
8571 sdcc_vreg_data[4].vccq_data = NULL;
8572
8573 if (machine_is_msm8x60_fusion())
8574 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8575 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008576 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8577 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008578 msm_add_sdcc(5, &msm8x60_sdc5_data);
8579 }
8580#endif
8581}
8582
8583#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8584static inline void display_common_power(int on) {}
8585#else
8586
8587#define _GET_REGULATOR(var, name) do { \
8588 if (var == NULL) { \
8589 var = regulator_get(NULL, name); \
8590 if (IS_ERR(var)) { \
8591 pr_err("'%s' regulator not found, rc=%ld\n", \
8592 name, PTR_ERR(var)); \
8593 var = NULL; \
8594 } \
8595 } \
8596} while (0)
8597
8598static int dsub_regulator(int on)
8599{
8600 static struct regulator *dsub_reg;
8601 static struct regulator *mpp0_reg;
8602 static int dsub_reg_enabled;
8603 int rc = 0;
8604
8605 _GET_REGULATOR(dsub_reg, "8901_l3");
8606 if (IS_ERR(dsub_reg)) {
8607 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8608 __func__, PTR_ERR(dsub_reg));
8609 return PTR_ERR(dsub_reg);
8610 }
8611
8612 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8613 if (IS_ERR(mpp0_reg)) {
8614 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8615 __func__, PTR_ERR(mpp0_reg));
8616 return PTR_ERR(mpp0_reg);
8617 }
8618
8619 if (on && !dsub_reg_enabled) {
8620 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8621 if (rc) {
8622 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8623 " err=%d", __func__, rc);
8624 goto dsub_regulator_err;
8625 }
8626 rc = regulator_enable(dsub_reg);
8627 if (rc) {
8628 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8629 " err=%d", __func__, rc);
8630 goto dsub_regulator_err;
8631 }
8632 rc = regulator_enable(mpp0_reg);
8633 if (rc) {
8634 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8635 " err=%d", __func__, rc);
8636 goto dsub_regulator_err;
8637 }
8638 dsub_reg_enabled = 1;
8639 } else if (!on && dsub_reg_enabled) {
8640 rc = regulator_disable(dsub_reg);
8641 if (rc)
8642 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8643 " err=%d", __func__, rc);
8644 rc = regulator_disable(mpp0_reg);
8645 if (rc)
8646 printk(KERN_WARNING "%s: failed to disable reg "
8647 "8901_mpp0 err=%d", __func__, rc);
8648 dsub_reg_enabled = 0;
8649 }
8650
8651 return rc;
8652
8653dsub_regulator_err:
8654 regulator_put(mpp0_reg);
8655 regulator_put(dsub_reg);
8656 return rc;
8657}
8658
8659static int display_power_on;
8660static void setup_display_power(void)
8661{
8662 if (display_power_on)
8663 if (lcdc_vga_enabled) {
8664 dsub_regulator(1);
8665 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8666 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8667 if (machine_is_msm8x60_ffa() ||
8668 machine_is_msm8x60_fusn_ffa())
8669 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8670 } else {
8671 dsub_regulator(0);
8672 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8673 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8674 if (machine_is_msm8x60_ffa() ||
8675 machine_is_msm8x60_fusn_ffa())
8676 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8677 }
8678 else {
8679 dsub_regulator(0);
8680 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8681 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8682 /* BACKLIGHT */
8683 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8684 /* LVDS */
8685 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8686 }
8687}
8688
8689#define _GET_REGULATOR(var, name) do { \
8690 if (var == NULL) { \
8691 var = regulator_get(NULL, name); \
8692 if (IS_ERR(var)) { \
8693 pr_err("'%s' regulator not found, rc=%ld\n", \
8694 name, PTR_ERR(var)); \
8695 var = NULL; \
8696 } \
8697 } \
8698} while (0)
8699
8700#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8701
8702static void display_common_power(int on)
8703{
8704 int rc;
8705 static struct regulator *display_reg;
8706
8707 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8708 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8709 if (on) {
8710 /* LVDS */
8711 _GET_REGULATOR(display_reg, "8901_l2");
8712 if (!display_reg)
8713 return;
8714 rc = regulator_set_voltage(display_reg,
8715 3300000, 3300000);
8716 if (rc)
8717 goto out;
8718 rc = regulator_enable(display_reg);
8719 if (rc)
8720 goto out;
8721 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8722 "LVDS_STDN_OUT_N");
8723 if (rc) {
8724 printk(KERN_ERR "%s: LVDS gpio %d request"
8725 "failed\n", __func__,
8726 GPIO_LVDS_SHUTDOWN_N);
8727 goto out2;
8728 }
8729
8730 /* BACKLIGHT */
8731 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8732 if (rc) {
8733 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8734 "failed\n", __func__,
8735 GPIO_BACKLIGHT_EN);
8736 goto out3;
8737 }
8738
8739 if (machine_is_msm8x60_ffa() ||
8740 machine_is_msm8x60_fusn_ffa()) {
8741 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8742 "DONGLE_PWR_EN");
8743 if (rc) {
8744 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8745 " %d request failed\n", __func__,
8746 GPIO_DONGLE_PWR_EN);
8747 goto out4;
8748 }
8749 }
8750
8751 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8752 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8753 if (machine_is_msm8x60_ffa() ||
8754 machine_is_msm8x60_fusn_ffa())
8755 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8756 mdelay(20);
8757 display_power_on = 1;
8758 setup_display_power();
8759 } else {
8760 if (display_power_on) {
8761 display_power_on = 0;
8762 setup_display_power();
8763 mdelay(20);
8764 if (machine_is_msm8x60_ffa() ||
8765 machine_is_msm8x60_fusn_ffa())
8766 gpio_free(GPIO_DONGLE_PWR_EN);
8767 goto out4;
8768 }
8769 }
8770 }
8771#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8772 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8773 else if (machine_is_msm8x60_fluid()) {
8774 static struct regulator *fluid_reg;
8775 static struct regulator *fluid_reg2;
8776
8777 if (on) {
8778 _GET_REGULATOR(fluid_reg, "8901_l2");
8779 if (!fluid_reg)
8780 return;
8781 _GET_REGULATOR(fluid_reg2, "8058_s3");
8782 if (!fluid_reg2) {
8783 regulator_put(fluid_reg);
8784 return;
8785 }
8786 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8787 if (rc) {
8788 regulator_put(fluid_reg2);
8789 regulator_put(fluid_reg);
8790 return;
8791 }
8792 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8793 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8794 regulator_enable(fluid_reg);
8795 regulator_enable(fluid_reg2);
8796 msleep(20);
8797 gpio_direction_output(GPIO_RESX_N, 0);
8798 udelay(10);
8799 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8800 display_power_on = 1;
8801 setup_display_power();
8802 } else {
8803 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8804 gpio_free(GPIO_RESX_N);
8805 msleep(20);
8806 regulator_disable(fluid_reg2);
8807 regulator_disable(fluid_reg);
8808 regulator_put(fluid_reg2);
8809 regulator_put(fluid_reg);
8810 display_power_on = 0;
8811 setup_display_power();
8812 fluid_reg = NULL;
8813 fluid_reg2 = NULL;
8814 }
8815 }
8816#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008817#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8818 else if (machine_is_msm8x60_dragon()) {
8819 static struct regulator *dragon_reg;
8820 static struct regulator *dragon_reg2;
8821
8822 if (on) {
8823 _GET_REGULATOR(dragon_reg, "8901_l2");
8824 if (!dragon_reg)
8825 return;
8826 _GET_REGULATOR(dragon_reg2, "8058_l16");
8827 if (!dragon_reg2) {
8828 regulator_put(dragon_reg);
8829 dragon_reg = NULL;
8830 return;
8831 }
8832
8833 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8834 if (rc) {
8835 pr_err("%s: gpio %d request failed with rc=%d\n",
8836 __func__, GPIO_NT35582_BL_EN, rc);
8837 regulator_put(dragon_reg);
8838 regulator_put(dragon_reg2);
8839 dragon_reg = NULL;
8840 dragon_reg2 = NULL;
8841 return;
8842 }
8843
8844 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8845 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8846 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8847 pr_err("%s: config gpio '%d' failed!\n",
8848 __func__, GPIO_NT35582_RESET);
8849 gpio_free(GPIO_NT35582_BL_EN);
8850 regulator_put(dragon_reg);
8851 regulator_put(dragon_reg2);
8852 dragon_reg = NULL;
8853 dragon_reg2 = NULL;
8854 return;
8855 }
8856
8857 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8858 if (rc) {
8859 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8860 __func__, GPIO_NT35582_RESET, rc);
8861 gpio_free(GPIO_NT35582_BL_EN);
8862 regulator_put(dragon_reg);
8863 regulator_put(dragon_reg2);
8864 dragon_reg = NULL;
8865 dragon_reg2 = NULL;
8866 return;
8867 }
8868
8869 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8870 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8871 regulator_enable(dragon_reg);
8872 regulator_enable(dragon_reg2);
8873 msleep(20);
8874
8875 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8876 msleep(20);
8877 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8878 msleep(20);
8879 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8880 msleep(50);
8881
8882 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8883
8884 display_power_on = 1;
8885 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8886 gpio_free(GPIO_NT35582_RESET);
8887 gpio_free(GPIO_NT35582_BL_EN);
8888 regulator_disable(dragon_reg2);
8889 regulator_disable(dragon_reg);
8890 regulator_put(dragon_reg2);
8891 regulator_put(dragon_reg);
8892 display_power_on = 0;
8893 dragon_reg = NULL;
8894 dragon_reg2 = NULL;
8895 }
8896 }
8897#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008898 return;
8899
8900out4:
8901 gpio_free(GPIO_BACKLIGHT_EN);
8902out3:
8903 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8904out2:
8905 regulator_disable(display_reg);
8906out:
8907 regulator_put(display_reg);
8908 display_reg = NULL;
8909}
8910#undef _GET_REGULATOR
8911#endif
8912
8913static int mipi_dsi_panel_power(int on);
8914
8915#define LCDC_NUM_GPIO 28
8916#define LCDC_GPIO_START 0
8917
8918static void lcdc_samsung_panel_power(int on)
8919{
8920 int n, ret = 0;
8921
8922 display_common_power(on);
8923
8924 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8925 if (on) {
8926 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8927 if (unlikely(ret)) {
8928 pr_err("%s not able to get gpio\n", __func__);
8929 break;
8930 }
8931 } else
8932 gpio_free(LCDC_GPIO_START + n);
8933 }
8934
8935 if (ret) {
8936 for (n--; n >= 0; n--)
8937 gpio_free(LCDC_GPIO_START + n);
8938 }
8939
8940 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8941}
8942
8943#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8944#define _GET_REGULATOR(var, name) do { \
8945 var = regulator_get(NULL, name); \
8946 if (IS_ERR(var)) { \
8947 pr_err("'%s' regulator not found, rc=%ld\n", \
8948 name, IS_ERR(var)); \
8949 var = NULL; \
8950 return -ENODEV; \
8951 } \
8952} while (0)
8953
8954static int hdmi_enable_5v(int on)
8955{
8956 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8957 static struct regulator *reg_8901_mpp0; /* External 5V */
8958 static int prev_on;
8959 int rc;
8960
8961 if (on == prev_on)
8962 return 0;
8963
8964 if (!reg_8901_hdmi_mvs)
8965 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8966 if (!reg_8901_mpp0)
8967 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8968
8969 if (on) {
8970 rc = regulator_enable(reg_8901_mpp0);
8971 if (rc) {
8972 pr_err("'%s' regulator enable failed, rc=%d\n",
8973 "reg_8901_mpp0", rc);
8974 return rc;
8975 }
8976 rc = regulator_enable(reg_8901_hdmi_mvs);
8977 if (rc) {
8978 pr_err("'%s' regulator enable failed, rc=%d\n",
8979 "8901_hdmi_mvs", rc);
8980 return rc;
8981 }
8982 pr_info("%s(on): success\n", __func__);
8983 } else {
8984 rc = regulator_disable(reg_8901_hdmi_mvs);
8985 if (rc)
8986 pr_warning("'%s' regulator disable failed, rc=%d\n",
8987 "8901_hdmi_mvs", rc);
8988 rc = regulator_disable(reg_8901_mpp0);
8989 if (rc)
8990 pr_warning("'%s' regulator disable failed, rc=%d\n",
8991 "reg_8901_mpp0", rc);
8992 pr_info("%s(off): success\n", __func__);
8993 }
8994
8995 prev_on = on;
8996
8997 return 0;
8998}
8999
9000static int hdmi_core_power(int on, int show)
9001{
9002 static struct regulator *reg_8058_l16; /* VDD_HDMI */
9003 static int prev_on;
9004 int rc;
9005
9006 if (on == prev_on)
9007 return 0;
9008
9009 if (!reg_8058_l16)
9010 _GET_REGULATOR(reg_8058_l16, "8058_l16");
9011
9012 if (on) {
9013 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
9014 if (!rc)
9015 rc = regulator_enable(reg_8058_l16);
9016 if (rc) {
9017 pr_err("'%s' regulator enable failed, rc=%d\n",
9018 "8058_l16", rc);
9019 return rc;
9020 }
9021 rc = gpio_request(170, "HDMI_DDC_CLK");
9022 if (rc) {
9023 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9024 "HDMI_DDC_CLK", 170, rc);
9025 goto error1;
9026 }
9027 rc = gpio_request(171, "HDMI_DDC_DATA");
9028 if (rc) {
9029 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9030 "HDMI_DDC_DATA", 171, rc);
9031 goto error2;
9032 }
9033 rc = gpio_request(172, "HDMI_HPD");
9034 if (rc) {
9035 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9036 "HDMI_HPD", 172, rc);
9037 goto error3;
9038 }
9039 pr_info("%s(on): success\n", __func__);
9040 } else {
9041 gpio_free(170);
9042 gpio_free(171);
9043 gpio_free(172);
9044 rc = regulator_disable(reg_8058_l16);
9045 if (rc)
9046 pr_warning("'%s' regulator disable failed, rc=%d\n",
9047 "8058_l16", rc);
9048 pr_info("%s(off): success\n", __func__);
9049 }
9050
9051 prev_on = on;
9052
9053 return 0;
9054
9055error3:
9056 gpio_free(171);
9057error2:
9058 gpio_free(170);
9059error1:
9060 regulator_disable(reg_8058_l16);
9061 return rc;
9062}
9063
9064static int hdmi_cec_power(int on)
9065{
9066 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9067 static int prev_on;
9068 int rc;
9069
9070 if (on == prev_on)
9071 return 0;
9072
9073 if (!reg_8901_l3)
9074 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9075
9076 if (on) {
9077 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9078 if (!rc)
9079 rc = regulator_enable(reg_8901_l3);
9080 if (rc) {
9081 pr_err("'%s' regulator enable failed, rc=%d\n",
9082 "8901_l3", rc);
9083 return rc;
9084 }
9085 rc = gpio_request(169, "HDMI_CEC_VAR");
9086 if (rc) {
9087 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9088 "HDMI_CEC_VAR", 169, rc);
9089 goto error;
9090 }
9091 pr_info("%s(on): success\n", __func__);
9092 } else {
9093 gpio_free(169);
9094 rc = regulator_disable(reg_8901_l3);
9095 if (rc)
9096 pr_warning("'%s' regulator disable failed, rc=%d\n",
9097 "8901_l3", rc);
9098 pr_info("%s(off): success\n", __func__);
9099 }
9100
9101 prev_on = on;
9102
9103 return 0;
9104error:
9105 regulator_disable(reg_8901_l3);
9106 return rc;
9107}
9108
9109#undef _GET_REGULATOR
9110
9111#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9112
9113static int lcdc_panel_power(int on)
9114{
9115 int flag_on = !!on;
9116 static int lcdc_power_save_on;
9117
9118 if (lcdc_power_save_on == flag_on)
9119 return 0;
9120
9121 lcdc_power_save_on = flag_on;
9122
9123 lcdc_samsung_panel_power(on);
9124
9125 return 0;
9126}
9127
9128#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009129
9130static struct msm_bus_vectors rotator_init_vectors[] = {
9131 {
9132 .src = MSM_BUS_MASTER_ROTATOR,
9133 .dst = MSM_BUS_SLAVE_SMI,
9134 .ab = 0,
9135 .ib = 0,
9136 },
9137 {
9138 .src = MSM_BUS_MASTER_ROTATOR,
9139 .dst = MSM_BUS_SLAVE_EBI_CH0,
9140 .ab = 0,
9141 .ib = 0,
9142 },
9143};
9144
9145static struct msm_bus_vectors rotator_ui_vectors[] = {
9146 {
9147 .src = MSM_BUS_MASTER_ROTATOR,
9148 .dst = MSM_BUS_SLAVE_SMI,
9149 .ab = 0,
9150 .ib = 0,
9151 },
9152 {
9153 .src = MSM_BUS_MASTER_ROTATOR,
9154 .dst = MSM_BUS_SLAVE_EBI_CH0,
9155 .ab = (1024 * 600 * 4 * 2 * 60),
9156 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9157 },
9158};
9159
9160static struct msm_bus_vectors rotator_vga_vectors[] = {
9161 {
9162 .src = MSM_BUS_MASTER_ROTATOR,
9163 .dst = MSM_BUS_SLAVE_SMI,
9164 .ab = (640 * 480 * 2 * 2 * 30),
9165 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9166 },
9167 {
9168 .src = MSM_BUS_MASTER_ROTATOR,
9169 .dst = MSM_BUS_SLAVE_EBI_CH0,
9170 .ab = (640 * 480 * 2 * 2 * 30),
9171 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9172 },
9173};
9174
9175static struct msm_bus_vectors rotator_720p_vectors[] = {
9176 {
9177 .src = MSM_BUS_MASTER_ROTATOR,
9178 .dst = MSM_BUS_SLAVE_SMI,
9179 .ab = (1280 * 736 * 2 * 2 * 30),
9180 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9181 },
9182 {
9183 .src = MSM_BUS_MASTER_ROTATOR,
9184 .dst = MSM_BUS_SLAVE_EBI_CH0,
9185 .ab = (1280 * 736 * 2 * 2 * 30),
9186 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9187 },
9188};
9189
9190static struct msm_bus_vectors rotator_1080p_vectors[] = {
9191 {
9192 .src = MSM_BUS_MASTER_ROTATOR,
9193 .dst = MSM_BUS_SLAVE_SMI,
9194 .ab = (1920 * 1088 * 2 * 2 * 30),
9195 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9196 },
9197 {
9198 .src = MSM_BUS_MASTER_ROTATOR,
9199 .dst = MSM_BUS_SLAVE_EBI_CH0,
9200 .ab = (1920 * 1088 * 2 * 2 * 30),
9201 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9202 },
9203};
9204
9205static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9206 {
9207 ARRAY_SIZE(rotator_init_vectors),
9208 rotator_init_vectors,
9209 },
9210 {
9211 ARRAY_SIZE(rotator_ui_vectors),
9212 rotator_ui_vectors,
9213 },
9214 {
9215 ARRAY_SIZE(rotator_vga_vectors),
9216 rotator_vga_vectors,
9217 },
9218 {
9219 ARRAY_SIZE(rotator_720p_vectors),
9220 rotator_720p_vectors,
9221 },
9222 {
9223 ARRAY_SIZE(rotator_1080p_vectors),
9224 rotator_1080p_vectors,
9225 },
9226};
9227
9228struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9229 rotator_bus_scale_usecases,
9230 ARRAY_SIZE(rotator_bus_scale_usecases),
9231 .name = "rotator",
9232};
9233
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009234static struct msm_bus_vectors mdp_init_vectors[] = {
9235 /* For now, 0th array entry is reserved.
9236 * Please leave 0 as is and don't use it
9237 */
9238 {
9239 .src = MSM_BUS_MASTER_MDP_PORT0,
9240 .dst = MSM_BUS_SLAVE_SMI,
9241 .ab = 0,
9242 .ib = 0,
9243 },
9244 /* Master and slaves can be from different fabrics */
9245 {
9246 .src = MSM_BUS_MASTER_MDP_PORT0,
9247 .dst = MSM_BUS_SLAVE_EBI_CH0,
9248 .ab = 0,
9249 .ib = 0,
9250 },
9251};
9252
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009253#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009254static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9255 /* Default case static display/UI/2d/3d if FB SMI */
9256 {
9257 .src = MSM_BUS_MASTER_MDP_PORT0,
9258 .dst = MSM_BUS_SLAVE_SMI,
9259 .ab = 388800000,
9260 .ib = 486000000,
9261 },
9262 /* Master and slaves can be from different fabrics */
9263 {
9264 .src = MSM_BUS_MASTER_MDP_PORT0,
9265 .dst = MSM_BUS_SLAVE_EBI_CH0,
9266 .ab = 0,
9267 .ib = 0,
9268 },
9269};
9270
9271static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9272 /* Default case static display/UI/2d/3d if FB SMI */
9273 {
9274 .src = MSM_BUS_MASTER_MDP_PORT0,
9275 .dst = MSM_BUS_SLAVE_SMI,
9276 .ab = 0,
9277 .ib = 0,
9278 },
9279 /* Master and slaves can be from different fabrics */
9280 {
9281 .src = MSM_BUS_MASTER_MDP_PORT0,
9282 .dst = MSM_BUS_SLAVE_EBI_CH0,
9283 .ab = 388800000,
9284 .ib = 486000000 * 2,
9285 },
9286};
9287static struct msm_bus_vectors mdp_vga_vectors[] = {
9288 /* VGA and less video */
9289 {
9290 .src = MSM_BUS_MASTER_MDP_PORT0,
9291 .dst = MSM_BUS_SLAVE_SMI,
9292 .ab = 458092800,
9293 .ib = 572616000,
9294 },
9295 {
9296 .src = MSM_BUS_MASTER_MDP_PORT0,
9297 .dst = MSM_BUS_SLAVE_EBI_CH0,
9298 .ab = 458092800,
9299 .ib = 572616000 * 2,
9300 },
9301};
9302static struct msm_bus_vectors mdp_720p_vectors[] = {
9303 /* 720p and less video */
9304 {
9305 .src = MSM_BUS_MASTER_MDP_PORT0,
9306 .dst = MSM_BUS_SLAVE_SMI,
9307 .ab = 471744000,
9308 .ib = 589680000,
9309 },
9310 /* Master and slaves can be from different fabrics */
9311 {
9312 .src = MSM_BUS_MASTER_MDP_PORT0,
9313 .dst = MSM_BUS_SLAVE_EBI_CH0,
9314 .ab = 471744000,
9315 .ib = 589680000 * 2,
9316 },
9317};
9318
9319static struct msm_bus_vectors mdp_1080p_vectors[] = {
9320 /* 1080p and less video */
9321 {
9322 .src = MSM_BUS_MASTER_MDP_PORT0,
9323 .dst = MSM_BUS_SLAVE_SMI,
9324 .ab = 575424000,
9325 .ib = 719280000,
9326 },
9327 /* Master and slaves can be from different fabrics */
9328 {
9329 .src = MSM_BUS_MASTER_MDP_PORT0,
9330 .dst = MSM_BUS_SLAVE_EBI_CH0,
9331 .ab = 575424000,
9332 .ib = 719280000 * 2,
9333 },
9334};
9335
9336#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009337static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9338 /* Default case static display/UI/2d/3d if FB SMI */
9339 {
9340 .src = MSM_BUS_MASTER_MDP_PORT0,
9341 .dst = MSM_BUS_SLAVE_SMI,
9342 .ab = 175110000,
9343 .ib = 218887500,
9344 },
9345 /* Master and slaves can be from different fabrics */
9346 {
9347 .src = MSM_BUS_MASTER_MDP_PORT0,
9348 .dst = MSM_BUS_SLAVE_EBI_CH0,
9349 .ab = 0,
9350 .ib = 0,
9351 },
9352};
9353
9354static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9355 /* Default case static display/UI/2d/3d if FB SMI */
9356 {
9357 .src = MSM_BUS_MASTER_MDP_PORT0,
9358 .dst = MSM_BUS_SLAVE_SMI,
9359 .ab = 0,
9360 .ib = 0,
9361 },
9362 /* Master and slaves can be from different fabrics */
9363 {
9364 .src = MSM_BUS_MASTER_MDP_PORT0,
9365 .dst = MSM_BUS_SLAVE_EBI_CH0,
9366 .ab = 216000000,
9367 .ib = 270000000 * 2,
9368 },
9369};
9370static struct msm_bus_vectors mdp_vga_vectors[] = {
9371 /* VGA and less video */
9372 {
9373 .src = MSM_BUS_MASTER_MDP_PORT0,
9374 .dst = MSM_BUS_SLAVE_SMI,
9375 .ab = 216000000,
9376 .ib = 270000000,
9377 },
9378 {
9379 .src = MSM_BUS_MASTER_MDP_PORT0,
9380 .dst = MSM_BUS_SLAVE_EBI_CH0,
9381 .ab = 216000000,
9382 .ib = 270000000 * 2,
9383 },
9384};
9385
9386static struct msm_bus_vectors mdp_720p_vectors[] = {
9387 /* 720p and less video */
9388 {
9389 .src = MSM_BUS_MASTER_MDP_PORT0,
9390 .dst = MSM_BUS_SLAVE_SMI,
9391 .ab = 230400000,
9392 .ib = 288000000,
9393 },
9394 /* Master and slaves can be from different fabrics */
9395 {
9396 .src = MSM_BUS_MASTER_MDP_PORT0,
9397 .dst = MSM_BUS_SLAVE_EBI_CH0,
9398 .ab = 230400000,
9399 .ib = 288000000 * 2,
9400 },
9401};
9402
9403static struct msm_bus_vectors mdp_1080p_vectors[] = {
9404 /* 1080p and less video */
9405 {
9406 .src = MSM_BUS_MASTER_MDP_PORT0,
9407 .dst = MSM_BUS_SLAVE_SMI,
9408 .ab = 334080000,
9409 .ib = 417600000,
9410 },
9411 /* Master and slaves can be from different fabrics */
9412 {
9413 .src = MSM_BUS_MASTER_MDP_PORT0,
9414 .dst = MSM_BUS_SLAVE_EBI_CH0,
9415 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009416 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009417 },
9418};
9419
9420#endif
9421static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9422 {
9423 ARRAY_SIZE(mdp_init_vectors),
9424 mdp_init_vectors,
9425 },
9426 {
9427 ARRAY_SIZE(mdp_sd_smi_vectors),
9428 mdp_sd_smi_vectors,
9429 },
9430 {
9431 ARRAY_SIZE(mdp_sd_ebi_vectors),
9432 mdp_sd_ebi_vectors,
9433 },
9434 {
9435 ARRAY_SIZE(mdp_vga_vectors),
9436 mdp_vga_vectors,
9437 },
9438 {
9439 ARRAY_SIZE(mdp_720p_vectors),
9440 mdp_720p_vectors,
9441 },
9442 {
9443 ARRAY_SIZE(mdp_1080p_vectors),
9444 mdp_1080p_vectors,
9445 },
9446};
9447static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9448 mdp_bus_scale_usecases,
9449 ARRAY_SIZE(mdp_bus_scale_usecases),
9450 .name = "mdp",
9451};
9452
9453#endif
9454#ifdef CONFIG_MSM_BUS_SCALING
9455static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9456 /* For now, 0th array entry is reserved.
9457 * Please leave 0 as is and don't use it
9458 */
9459 {
9460 .src = MSM_BUS_MASTER_MDP_PORT0,
9461 .dst = MSM_BUS_SLAVE_SMI,
9462 .ab = 0,
9463 .ib = 0,
9464 },
9465 /* Master and slaves can be from different fabrics */
9466 {
9467 .src = MSM_BUS_MASTER_MDP_PORT0,
9468 .dst = MSM_BUS_SLAVE_EBI_CH0,
9469 .ab = 0,
9470 .ib = 0,
9471 },
9472};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009473
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009474static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9475 /* For now, 0th array entry is reserved.
9476 * Please leave 0 as is and don't use it
9477 */
9478 {
9479 .src = MSM_BUS_MASTER_MDP_PORT0,
9480 .dst = MSM_BUS_SLAVE_SMI,
9481 .ab = 566092800,
9482 .ib = 707616000,
9483 },
9484 /* Master and slaves can be from different fabrics */
9485 {
9486 .src = MSM_BUS_MASTER_MDP_PORT0,
9487 .dst = MSM_BUS_SLAVE_EBI_CH0,
9488 .ab = 566092800,
9489 .ib = 707616000,
9490 },
9491};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009492
9493static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9494 /* For now, 0th array entry is reserved.
9495 * Please leave 0 as is and don't use it
9496 */
9497 {
9498 .src = MSM_BUS_MASTER_MDP_PORT0,
9499 .dst = MSM_BUS_SLAVE_SMI,
9500 .ab = 2000000000,
9501 .ib = 2000000000,
9502 },
9503 /* Master and slaves can be from different fabrics */
9504 {
9505 .src = MSM_BUS_MASTER_MDP_PORT0,
9506 .dst = MSM_BUS_SLAVE_EBI_CH0,
9507 .ab = 2000000000,
9508 .ib = 2000000000,
9509 },
9510};
9511
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009512static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9513 {
9514 ARRAY_SIZE(dtv_bus_init_vectors),
9515 dtv_bus_init_vectors,
9516 },
9517 {
9518 ARRAY_SIZE(dtv_bus_def_vectors),
9519 dtv_bus_def_vectors,
9520 },
9521};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009522
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009523static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9524 dtv_bus_scale_usecases,
9525 ARRAY_SIZE(dtv_bus_scale_usecases),
9526 .name = "dtv",
9527};
9528
9529static struct lcdc_platform_data dtv_pdata = {
9530 .bus_scale_table = &dtv_bus_scale_pdata,
9531};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009532
9533static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9534 {
9535 ARRAY_SIZE(dtv_bus_init_vectors),
9536 dtv_bus_init_vectors,
9537 },
9538 {
9539 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9540 dtv_bus_hdmi_prim_vectors,
9541 },
9542};
9543
9544static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9545 dtv_hdmi_prim_bus_scale_usecases,
9546 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9547 .name = "dtv",
9548};
9549
9550static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9551 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9552};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009553#endif
9554
9555
9556static struct lcdc_platform_data lcdc_pdata = {
9557 .lcdc_power_save = lcdc_panel_power,
9558};
9559
9560
9561#define MDP_VSYNC_GPIO 28
9562
9563/*
9564 * MIPI_DSI only use 8058_LDO0 which need always on
9565 * therefore it need to be put at low power mode if
9566 * it was not used instead of turn it off.
9567 */
9568static int mipi_dsi_panel_power(int on)
9569{
9570 int flag_on = !!on;
9571 static int mipi_dsi_power_save_on;
9572 static struct regulator *ldo0;
9573 int rc = 0;
9574
9575 if (mipi_dsi_power_save_on == flag_on)
9576 return 0;
9577
9578 mipi_dsi_power_save_on = flag_on;
9579
9580 if (ldo0 == NULL) { /* init */
9581 ldo0 = regulator_get(NULL, "8058_l0");
9582 if (IS_ERR(ldo0)) {
9583 pr_debug("%s: LDO0 failed\n", __func__);
9584 rc = PTR_ERR(ldo0);
9585 return rc;
9586 }
9587
9588 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9589 if (rc)
9590 goto out;
9591
9592 rc = regulator_enable(ldo0);
9593 if (rc)
9594 goto out;
9595 }
9596
9597 if (on) {
9598 /* set ldo0 to HPM */
9599 rc = regulator_set_optimum_mode(ldo0, 100000);
9600 if (rc < 0)
9601 goto out;
9602 } else {
9603 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309604 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009605 if (rc < 0)
9606 goto out;
9607 }
9608
9609 return 0;
9610out:
9611 regulator_disable(ldo0);
9612 regulator_put(ldo0);
9613 ldo0 = NULL;
9614 return rc;
9615}
9616
9617static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9618 .vsync_gpio = MDP_VSYNC_GPIO,
9619 .dsi_power_save = mipi_dsi_panel_power,
9620};
9621
9622#ifdef CONFIG_FB_MSM_TVOUT
9623static struct regulator *reg_8058_l13;
9624
9625static int atv_dac_power(int on)
9626{
9627 int rc = 0;
9628 #define _GET_REGULATOR(var, name) do { \
9629 var = regulator_get(NULL, name); \
9630 if (IS_ERR(var)) { \
9631 pr_info("'%s' regulator not found, rc=%ld\n", \
9632 name, IS_ERR(var)); \
9633 var = NULL; \
9634 return -ENODEV; \
9635 } \
9636 } while (0)
9637
9638 if (!reg_8058_l13)
9639 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9640 #undef _GET_REGULATOR
9641
9642 if (on) {
9643 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9644 if (rc) {
9645 pr_info("%s: '%s' regulator set voltage failed,\
9646 rc=%d\n", __func__, "8058_l13", rc);
9647 return rc;
9648 }
9649
9650 rc = regulator_enable(reg_8058_l13);
9651 if (rc) {
9652 pr_err("%s: '%s' regulator enable failed,\
9653 rc=%d\n", __func__, "8058_l13", rc);
9654 return rc;
9655 }
9656 } else {
9657 rc = regulator_force_disable(reg_8058_l13);
9658 if (rc)
9659 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9660 __func__, "8058_l13", rc);
9661 }
9662 return rc;
9663
9664}
9665#endif
9666
9667#ifdef CONFIG_FB_MSM_MIPI_DSI
9668int mdp_core_clk_rate_table[] = {
9669 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009670 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009671 160000000,
9672 200000000,
9673};
9674#else
9675int mdp_core_clk_rate_table[] = {
9676 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009677 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009678 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009679 200000000,
9680};
9681#endif
9682
9683static struct msm_panel_common_pdata mdp_pdata = {
9684 .gpio = MDP_VSYNC_GPIO,
9685 .mdp_core_clk_rate = 59080000,
9686 .mdp_core_clk_table = mdp_core_clk_rate_table,
9687 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9688#ifdef CONFIG_MSM_BUS_SCALING
9689 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9690#endif
9691 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009692#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009693 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009694#else
9695 .mem_hid = MEMTYPE_EBI1,
9696#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009697};
9698
Huaibin Yanga5419422011-12-08 23:52:10 -08009699static void __init reserve_mdp_memory(void)
9700{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009701 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9702 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9703#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9704 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9705 mdp_pdata.ov0_wb_size;
9706 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9707 mdp_pdata.ov1_wb_size;
9708#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009709}
9710
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009711#ifdef CONFIG_FB_MSM_TVOUT
9712
9713#ifdef CONFIG_MSM_BUS_SCALING
9714static struct msm_bus_vectors atv_bus_init_vectors[] = {
9715 /* For now, 0th array entry is reserved.
9716 * Please leave 0 as is and don't use it
9717 */
9718 {
9719 .src = MSM_BUS_MASTER_MDP_PORT0,
9720 .dst = MSM_BUS_SLAVE_SMI,
9721 .ab = 0,
9722 .ib = 0,
9723 },
9724 /* Master and slaves can be from different fabrics */
9725 {
9726 .src = MSM_BUS_MASTER_MDP_PORT0,
9727 .dst = MSM_BUS_SLAVE_EBI_CH0,
9728 .ab = 0,
9729 .ib = 0,
9730 },
9731};
9732static struct msm_bus_vectors atv_bus_def_vectors[] = {
9733 /* For now, 0th array entry is reserved.
9734 * Please leave 0 as is and don't use it
9735 */
9736 {
9737 .src = MSM_BUS_MASTER_MDP_PORT0,
9738 .dst = MSM_BUS_SLAVE_SMI,
9739 .ab = 236390400,
9740 .ib = 265939200,
9741 },
9742 /* Master and slaves can be from different fabrics */
9743 {
9744 .src = MSM_BUS_MASTER_MDP_PORT0,
9745 .dst = MSM_BUS_SLAVE_EBI_CH0,
9746 .ab = 236390400,
9747 .ib = 265939200,
9748 },
9749};
9750static struct msm_bus_paths atv_bus_scale_usecases[] = {
9751 {
9752 ARRAY_SIZE(atv_bus_init_vectors),
9753 atv_bus_init_vectors,
9754 },
9755 {
9756 ARRAY_SIZE(atv_bus_def_vectors),
9757 atv_bus_def_vectors,
9758 },
9759};
9760static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9761 atv_bus_scale_usecases,
9762 ARRAY_SIZE(atv_bus_scale_usecases),
9763 .name = "atv",
9764};
9765#endif
9766
9767static struct tvenc_platform_data atv_pdata = {
9768 .poll = 0,
9769 .pm_vid_en = atv_dac_power,
9770#ifdef CONFIG_MSM_BUS_SCALING
9771 .bus_scale_table = &atv_bus_scale_pdata,
9772#endif
9773};
9774#endif
9775
9776static void __init msm_fb_add_devices(void)
9777{
9778#ifdef CONFIG_FB_MSM_LCDC_DSUB
9779 mdp_pdata.mdp_core_clk_table = NULL;
9780 mdp_pdata.num_mdp_clk = 0;
9781 mdp_pdata.mdp_core_clk_rate = 200000000;
9782#endif
9783 if (machine_is_msm8x60_rumi3())
9784 msm_fb_register_device("mdp", NULL);
9785 else
9786 msm_fb_register_device("mdp", &mdp_pdata);
9787
9788 msm_fb_register_device("lcdc", &lcdc_pdata);
9789 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9790#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009791 if (hdmi_is_primary)
9792 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9793 else
9794 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009795#endif
9796#ifdef CONFIG_FB_MSM_TVOUT
9797 msm_fb_register_device("tvenc", &atv_pdata);
9798 msm_fb_register_device("tvout_device", NULL);
9799#endif
9800}
9801
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009802/**
9803 * Set MDP clocks to high frequency to avoid underflow when
9804 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9805 */
9806static void set_mdp_clocks_for_wuxga(void)
9807{
9808 int i;
9809
9810 mdp_sd_smi_vectors[0].ab = 2000000000;
9811 mdp_sd_smi_vectors[0].ib = 2000000000;
9812 mdp_sd_smi_vectors[1].ab = 2000000000;
9813 mdp_sd_smi_vectors[1].ib = 2000000000;
9814
9815 mdp_sd_ebi_vectors[0].ab = 2000000000;
9816 mdp_sd_ebi_vectors[0].ib = 2000000000;
9817 mdp_sd_ebi_vectors[1].ab = 2000000000;
9818 mdp_sd_ebi_vectors[1].ib = 2000000000;
9819
9820 mdp_vga_vectors[0].ab = 2000000000;
9821 mdp_vga_vectors[0].ib = 2000000000;
9822 mdp_vga_vectors[1].ab = 2000000000;
9823 mdp_vga_vectors[1].ib = 2000000000;
9824
9825 mdp_720p_vectors[0].ab = 2000000000;
9826 mdp_720p_vectors[0].ib = 2000000000;
9827 mdp_720p_vectors[1].ab = 2000000000;
9828 mdp_720p_vectors[1].ib = 2000000000;
9829
9830 mdp_1080p_vectors[0].ab = 2000000000;
9831 mdp_1080p_vectors[0].ib = 2000000000;
9832 mdp_1080p_vectors[1].ab = 2000000000;
9833 mdp_1080p_vectors[1].ib = 2000000000;
9834
9835 mdp_pdata.mdp_core_clk_rate = 200000000;
9836
9837 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9838 mdp_core_clk_rate_table[i] = 200000000;
9839}
9840
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009841#if (defined(CONFIG_MARIMBA_CORE)) && \
9842 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9843
9844static const struct {
9845 char *name;
9846 int vmin;
9847 int vmax;
9848} bt_regs_info[] = {
9849 { "8058_s3", 1800000, 1800000 },
9850 { "8058_s2", 1300000, 1300000 },
9851 { "8058_l8", 2900000, 3050000 },
9852};
9853
9854static struct {
9855 bool enabled;
9856} bt_regs_status[] = {
9857 { false },
9858 { false },
9859 { false },
9860};
9861static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9862
9863static int bahama_bt(int on)
9864{
9865 int rc;
9866 int i;
9867 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9868
9869 struct bahama_variant_register {
9870 const size_t size;
9871 const struct bahama_config_register *set;
9872 };
9873
9874 const struct bahama_config_register *p;
9875
9876 u8 version;
9877
9878 const struct bahama_config_register v10_bt_on[] = {
9879 { 0xE9, 0x00, 0xFF },
9880 { 0xF4, 0x80, 0xFF },
9881 { 0xE4, 0x00, 0xFF },
9882 { 0xE5, 0x00, 0x0F },
9883#ifdef CONFIG_WLAN
9884 { 0xE6, 0x38, 0x7F },
9885 { 0xE7, 0x06, 0xFF },
9886#endif
9887 { 0xE9, 0x21, 0xFF },
9888 { 0x01, 0x0C, 0x1F },
9889 { 0x01, 0x08, 0x1F },
9890 };
9891
9892 const struct bahama_config_register v20_bt_on_fm_off[] = {
9893 { 0x11, 0x0C, 0xFF },
9894 { 0x13, 0x01, 0xFF },
9895 { 0xF4, 0x80, 0xFF },
9896 { 0xF0, 0x00, 0xFF },
9897 { 0xE9, 0x00, 0xFF },
9898#ifdef CONFIG_WLAN
9899 { 0x81, 0x00, 0x7F },
9900 { 0x82, 0x00, 0xFF },
9901 { 0xE6, 0x38, 0x7F },
9902 { 0xE7, 0x06, 0xFF },
9903#endif
9904 { 0xE9, 0x21, 0xFF },
9905 };
9906
9907 const struct bahama_config_register v20_bt_on_fm_on[] = {
9908 { 0x11, 0x0C, 0xFF },
9909 { 0x13, 0x01, 0xFF },
9910 { 0xF4, 0x86, 0xFF },
9911 { 0xF0, 0x06, 0xFF },
9912 { 0xE9, 0x00, 0xFF },
9913#ifdef CONFIG_WLAN
9914 { 0x81, 0x00, 0x7F },
9915 { 0x82, 0x00, 0xFF },
9916 { 0xE6, 0x38, 0x7F },
9917 { 0xE7, 0x06, 0xFF },
9918#endif
9919 { 0xE9, 0x21, 0xFF },
9920 };
9921
9922 const struct bahama_config_register v10_bt_off[] = {
9923 { 0xE9, 0x00, 0xFF },
9924 };
9925
9926 const struct bahama_config_register v20_bt_off_fm_off[] = {
9927 { 0xF4, 0x84, 0xFF },
9928 { 0xF0, 0x04, 0xFF },
9929 { 0xE9, 0x00, 0xFF }
9930 };
9931
9932 const struct bahama_config_register v20_bt_off_fm_on[] = {
9933 { 0xF4, 0x86, 0xFF },
9934 { 0xF0, 0x06, 0xFF },
9935 { 0xE9, 0x00, 0xFF }
9936 };
9937 const struct bahama_variant_register bt_bahama[2][3] = {
9938 {
9939 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9940 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9941 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9942 },
9943 {
9944 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9945 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9946 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9947 }
9948 };
9949
9950 u8 offset = 0; /* index into bahama configs */
9951
9952 on = on ? 1 : 0;
9953 version = read_bahama_ver();
9954
9955 if (version == VER_UNSUPPORTED) {
9956 dev_err(&msm_bt_power_device.dev,
9957 "%s: unsupported version\n",
9958 __func__);
9959 return -EIO;
9960 }
9961
9962 if (version == VER_2_0) {
9963 if (marimba_get_fm_status(&config))
9964 offset = 0x01;
9965 }
9966
9967 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9968 if (on && (version == VER_2_0)) {
9969 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9970 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9971 && (bt_regs_status[i].enabled == true)) {
9972 if (regulator_disable(bt_regs[i])) {
9973 dev_err(&msm_bt_power_device.dev,
9974 "%s: regulator disable failed",
9975 __func__);
9976 }
9977 bt_regs_status[i].enabled = false;
9978 break;
9979 }
9980 }
9981 }
9982
9983 p = bt_bahama[on][version + offset].set;
9984
9985 dev_info(&msm_bt_power_device.dev,
9986 "%s: found version %d\n", __func__, version);
9987
9988 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9989 u8 value = (p+i)->value;
9990 rc = marimba_write_bit_mask(&config,
9991 (p+i)->reg,
9992 &value,
9993 sizeof((p+i)->value),
9994 (p+i)->mask);
9995 if (rc < 0) {
9996 dev_err(&msm_bt_power_device.dev,
9997 "%s: reg %d write failed: %d\n",
9998 __func__, (p+i)->reg, rc);
9999 return rc;
10000 }
10001 dev_dbg(&msm_bt_power_device.dev,
10002 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
10003 __func__, (p+i)->reg,
10004 value, (p+i)->mask);
10005 }
10006 /* Update BT Status */
10007 if (on)
10008 marimba_set_bt_status(&config, true);
10009 else
10010 marimba_set_bt_status(&config, false);
10011
10012 return 0;
10013}
10014
10015static int bluetooth_use_regulators(int on)
10016{
10017 int i, recover = -1, rc = 0;
10018
10019 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10020 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
10021 bt_regs_info[i].name) :
10022 (regulator_put(bt_regs[i]), NULL);
10023 if (IS_ERR(bt_regs[i])) {
10024 rc = PTR_ERR(bt_regs[i]);
10025 dev_err(&msm_bt_power_device.dev,
10026 "regulator %s get failed (%d)\n",
10027 bt_regs_info[i].name, rc);
10028 recover = i - 1;
10029 bt_regs[i] = NULL;
10030 break;
10031 }
10032
10033 if (!on)
10034 continue;
10035
10036 rc = regulator_set_voltage(bt_regs[i],
10037 bt_regs_info[i].vmin,
10038 bt_regs_info[i].vmax);
10039 if (rc < 0) {
10040 dev_err(&msm_bt_power_device.dev,
10041 "regulator %s voltage set (%d)\n",
10042 bt_regs_info[i].name, rc);
10043 recover = i;
10044 break;
10045 }
10046 }
10047
10048 if (on && (recover > -1))
10049 for (i = recover; i >= 0; i--) {
10050 regulator_put(bt_regs[i]);
10051 bt_regs[i] = NULL;
10052 }
10053
10054 return rc;
10055}
10056
10057static int bluetooth_switch_regulators(int on)
10058{
10059 int i, rc = 0;
10060
10061 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10062 if (on && (bt_regs_status[i].enabled == false)) {
10063 rc = regulator_enable(bt_regs[i]);
10064 if (rc < 0) {
10065 dev_err(&msm_bt_power_device.dev,
10066 "regulator %s %s failed (%d)\n",
10067 bt_regs_info[i].name,
10068 "enable", rc);
10069 if (i > 0) {
10070 while (--i) {
10071 regulator_disable(bt_regs[i]);
10072 bt_regs_status[i].enabled
10073 = false;
10074 }
10075 break;
10076 }
10077 }
10078 bt_regs_status[i].enabled = true;
10079 } else if (!on && (bt_regs_status[i].enabled == true)) {
10080 rc = regulator_disable(bt_regs[i]);
10081 if (rc < 0) {
10082 dev_err(&msm_bt_power_device.dev,
10083 "regulator %s %s failed (%d)\n",
10084 bt_regs_info[i].name,
10085 "disable", rc);
10086 break;
10087 }
10088 bt_regs_status[i].enabled = false;
10089 }
10090 }
10091 return rc;
10092}
10093
10094static struct msm_xo_voter *bt_clock;
10095
10096static int bluetooth_power(int on)
10097{
10098 int rc = 0;
10099 int id;
10100
10101 /* In case probe function fails, cur_connv_type would be -1 */
10102 id = adie_get_detected_connectivity_type();
10103 if (id != BAHAMA_ID) {
10104 pr_err("%s: unexpected adie connectivity type: %d\n",
10105 __func__, id);
10106 return -ENODEV;
10107 }
10108
10109 if (on) {
10110
10111 rc = bluetooth_use_regulators(1);
10112 if (rc < 0)
10113 goto out;
10114
10115 rc = bluetooth_switch_regulators(1);
10116
10117 if (rc < 0)
10118 goto fail_put;
10119
10120 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10121
10122 if (IS_ERR(bt_clock)) {
10123 pr_err("Couldn't get TCXO_D0 voter\n");
10124 goto fail_switch;
10125 }
10126
10127 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10128
10129 if (rc < 0) {
10130 pr_err("Failed to vote for TCXO_DO ON\n");
10131 goto fail_vote;
10132 }
10133
10134 rc = bahama_bt(1);
10135
10136 if (rc < 0)
10137 goto fail_clock;
10138
10139 msleep(10);
10140
10141 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10142
10143 if (rc < 0) {
10144 pr_err("Failed to vote for TCXO_DO pin control\n");
10145 goto fail_vote;
10146 }
10147 } else {
10148 /* check for initial RFKILL block (power off) */
10149 /* some RFKILL versions/configurations rfkill_register */
10150 /* calls here for an initial set_block */
10151 /* avoid calling i2c and regulator before unblock (on) */
10152 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10153 dev_info(&msm_bt_power_device.dev,
10154 "%s: initialized OFF/blocked\n", __func__);
10155 goto out;
10156 }
10157
10158 bahama_bt(0);
10159
10160fail_clock:
10161 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10162fail_vote:
10163 msm_xo_put(bt_clock);
10164fail_switch:
10165 bluetooth_switch_regulators(0);
10166fail_put:
10167 bluetooth_use_regulators(0);
10168 }
10169
10170out:
10171 if (rc < 0)
10172 on = 0;
10173 dev_info(&msm_bt_power_device.dev,
10174 "Bluetooth power switch: state %d result %d\n", on, rc);
10175
10176 return rc;
10177}
10178
10179#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10180
10181static void __init msm8x60_cfg_smsc911x(void)
10182{
10183 smsc911x_resources[1].start =
10184 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10185 smsc911x_resources[1].end =
10186 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10187}
10188
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010189void msm_fusion_setup_pinctrl(void)
10190{
10191 struct msm_xo_voter *a1;
10192
10193 if (socinfo_get_platform_subtype() == 0x3) {
10194 /*
10195 * Vote for the A1 clock to be in pin control mode before
10196 * the external images are loaded.
10197 */
10198 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10199 BUG_ON(!a1);
10200 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10201 }
10202}
10203
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010204struct msm_board_data {
10205 struct msm_gpiomux_configs *gpiomux_cfgs;
10206};
10207
10208static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10209 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10210};
10211
10212static struct msm_board_data msm8x60_sim_board_data __initdata = {
10213 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10214};
10215
10216static struct msm_board_data msm8x60_surf_board_data __initdata = {
10217 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10218};
10219
10220static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10221 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10222};
10223
10224static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10225 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10226};
10227
10228static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10229 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10230};
10231
10232static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10233 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10234};
10235
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010236static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10237 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10238};
10239
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010240static void __init msm8x60_init(struct msm_board_data *board_data)
10241{
10242 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010243#ifdef CONFIG_USB_EHCI_MSM_72K
10244 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10245 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10246 .level = PM8901_MPP_DIG_LEVEL_L5,
10247 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10248 };
10249#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010250 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010251
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010252 /*
10253 * Initialize RPM first as other drivers and devices may need
10254 * it for their initialization.
10255 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010256 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10257 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010258 if (msm_xo_init())
10259 pr_err("Failed to initialize XO votes\n");
10260
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010261 msm8x60_check_2d_hardware();
10262
10263 /* Change SPM handling of core 1 if PMM 8160 is present. */
10264 soc_platform_version = socinfo_get_platform_version();
10265 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10266 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10267 struct msm_spm_platform_data *spm_data;
10268
10269 spm_data = &msm_spm_data_v1[1];
10270 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10271 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10272
10273 spm_data = &msm_spm_data[1];
10274 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10275 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10276 }
10277
10278 /*
10279 * Initialize SPM before acpuclock as the latter calls into SPM
10280 * driver to set ACPU voltages.
10281 */
10282 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10283 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10284 else
10285 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10286
10287 /*
10288 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10289 * devices so that the RPM doesn't drop into a low power mode that an
10290 * un-reworked SURF cannot resume from.
10291 */
10292 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010293 int i;
10294
10295 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10296 if (rpm_regulator_init_data[i].id
10297 == RPM_VREG_ID_PM8901_L4
10298 || rpm_regulator_init_data[i].id
10299 == RPM_VREG_ID_PM8901_L6)
10300 rpm_regulator_init_data[i]
10301 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010302 }
10303
10304 /*
10305 * Disable regulator info printing so that regulator registration
10306 * messages do not enter the kmsg log.
10307 */
10308 regulator_suppress_info_printing();
10309
10310 /* Initialize regulators needed for clock_init. */
10311 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10312
Stephen Boydbb600ae2011-08-02 20:11:40 -070010313 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010314
10315 /* Buses need to be initialized before early-device registration
10316 * to get the platform data for fabrics.
10317 */
10318 msm8x60_init_buses();
10319 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10320 /* CPU frequency control is not supported on simulated targets. */
10321 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010322 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010323
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010324 /*
10325 * Enable EBI2 only for boards which make use of it. Leave
10326 * it disabled for all others for additional power savings.
10327 */
10328 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10329 machine_is_msm8x60_rumi3() ||
10330 machine_is_msm8x60_sim() ||
10331 machine_is_msm8x60_fluid() ||
10332 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010333 msm8x60_init_ebi2();
10334 msm8x60_init_tlmm();
10335 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10336 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010337#ifdef CONFIG_MSM_CAMERA_V4L2
10338 msm8x60_init_cam();
10339#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010340 msm8x60_init_mmc();
10341
Kevin Chan3be11612012-03-22 20:05:40 -070010342
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010343#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10344 msm8x60_init_pm8058_othc();
10345#endif
10346
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010347 if (machine_is_msm8x60_fluid())
10348 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10349 else if (machine_is_msm8x60_dragon())
10350 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10351 else
10352 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Kevin Chan3be11612012-03-22 20:05:40 -070010353#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang53d27a82011-07-13 14:32:58 -040010354 /* Specify reset pin for OV9726 */
10355 if (machine_is_msm8x60_dragon()) {
10356 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10357 ov9726_sensor_8660_info.mount_angle = 270;
10358 }
Kevin Chan3be11612012-03-22 20:05:40 -070010359#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010360#ifdef CONFIG_BATTERY_MSM8X60
10361 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10362 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10363 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10364 platform_device_register(&msm_charger_device);
10365#endif
10366
10367 if (machine_is_msm8x60_dragon())
10368 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10369 if (!machine_is_msm8x60_fluid())
10370 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10371
10372 /* configure pmic leds */
10373 if (machine_is_msm8x60_fluid())
10374 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10375 else if (machine_is_msm8x60_dragon())
10376 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10377 else
10378 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10379
10380 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10381 machine_is_msm8x60_dragon()) {
10382 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10383 }
10384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010385 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10386 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010387 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010388 msm8x60_cfg_smsc911x();
10389 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010390 platform_add_devices(msm8660_footswitch,
10391 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010392 platform_add_devices(surf_devices,
10393 ARRAY_SIZE(surf_devices));
10394
10395#ifdef CONFIG_MSM_DSPS
10396 if (machine_is_msm8x60_fluid()) {
10397 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10398 msm8x60_init_dsps();
10399 }
10400#endif
10401
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010402 pm8901_vreg_mpp0_init();
10403
10404 platform_device_register(&msm8x60_8901_mpp_vreg);
10405
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010406#ifdef CONFIG_USB_EHCI_MSM_72K
10407 /*
10408 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10409 * fluid
10410 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010411 if (machine_is_msm8x60_fluid())
10412 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10413 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010414#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010415
10416#ifdef CONFIG_SND_SOC_MSM8660_APQ
10417 if (machine_is_msm8x60_dragon())
10418 platform_add_devices(dragon_alsa_devices,
10419 ARRAY_SIZE(dragon_alsa_devices));
10420 else
10421#endif
10422 platform_add_devices(asoc_devices,
10423 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010424 } else {
10425 msm8x60_configure_smc91x();
10426 platform_add_devices(rumi_sim_devices,
10427 ARRAY_SIZE(rumi_sim_devices));
10428 }
10429#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010430 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10431 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010432 msm8x60_cfg_isp1763();
10433#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010434
10435 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10436 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10437
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010438
10439#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10440 if (machine_is_msm8x60_fluid())
10441 platform_device_register(&msm_gsbi10_qup_spi_device);
10442 else
10443 platform_device_register(&msm_gsbi1_qup_spi_device);
10444#endif
10445
10446#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10447 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10448 if (machine_is_msm8x60_fluid())
10449 cyttsp_set_params();
10450#endif
10451 if (!machine_is_msm8x60_sim())
10452 msm_fb_add_devices();
10453 fixup_i2c_configs();
10454 register_i2c_devices();
10455
Terence Hampson1c73fef2011-07-19 17:10:49 -040010456 if (machine_is_msm8x60_dragon())
10457 smsc911x_config.reset_gpio
10458 = GPIO_ETHERNET_RESET_N_DRAGON;
10459
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010460 platform_device_register(&smsc911x_device);
10461
10462#if (defined(CONFIG_SPI_QUP)) && \
10463 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010464 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10465 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010466
10467 if (machine_is_msm8x60_fluid()) {
10468#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10469 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10470 spi_register_board_info(lcdc_samsung_spi_board_info,
10471 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10472 } else
10473#endif
10474 {
10475#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10476 spi_register_board_info(lcdc_auo_spi_board_info,
10477 ARRAY_SIZE(lcdc_auo_spi_board_info));
10478#endif
10479 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010480#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10481 } else if (machine_is_msm8x60_dragon()) {
10482 spi_register_board_info(lcdc_nt35582_spi_board_info,
10483 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10484#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010485 }
10486#endif
10487
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010488 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010489
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010490 pm8058_gpios_init();
10491
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010492#ifdef CONFIG_SENSORS_MSM_ADC
10493 if (machine_is_msm8x60_fluid()) {
10494 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10495 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10496 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10497 msm_adc_pdata.gpio_config = APROC_CONFIG;
10498 else
10499 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10500 }
10501 msm_adc_pdata.target_hw = MSM_8x60;
10502#endif
10503#ifdef CONFIG_MSM8X60_AUDIO
10504 msm_snddev_init();
10505#endif
10506#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10507 if (machine_is_msm8x60_fluid())
10508 platform_device_register(&fluid_leds_gpio);
10509 else
10510 platform_device_register(&gpio_leds);
10511#endif
10512
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010513 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010514
10515 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10516 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010517}
10518
10519static void __init msm8x60_rumi3_init(void)
10520{
10521 msm8x60_init(&msm8x60_rumi3_board_data);
10522}
10523
10524static void __init msm8x60_sim_init(void)
10525{
10526 msm8x60_init(&msm8x60_sim_board_data);
10527}
10528
10529static void __init msm8x60_surf_init(void)
10530{
10531 msm8x60_init(&msm8x60_surf_board_data);
10532}
10533
10534static void __init msm8x60_ffa_init(void)
10535{
10536 msm8x60_init(&msm8x60_ffa_board_data);
10537}
10538
10539static void __init msm8x60_fluid_init(void)
10540{
10541 msm8x60_init(&msm8x60_fluid_board_data);
10542}
10543
10544static void __init msm8x60_charm_surf_init(void)
10545{
10546 msm8x60_init(&msm8x60_charm_surf_board_data);
10547}
10548
10549static void __init msm8x60_charm_ffa_init(void)
10550{
10551 msm8x60_init(&msm8x60_charm_ffa_board_data);
10552}
10553
10554static void __init msm8x60_charm_init_early(void)
10555{
10556 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010557}
10558
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010559static void __init msm8x60_dragon_init(void)
10560{
10561 msm8x60_init(&msm8x60_dragon_board_data);
10562}
10563
Steve Mucklea55df6e2010-01-07 12:43:24 -080010564MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10565 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010566 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010567 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010568 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010569 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010570 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010571 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010572MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010573
10574MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10575 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010576 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010577 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010578 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010579 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010580 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010581 .init_early = msm8x60_charm_init_early,
10582MACHINE_END
10583
10584MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10585 .map_io = msm8x60_map_io,
10586 .reserve = msm8x60_reserve,
10587 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010588 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010589 .init_machine = msm8x60_surf_init,
10590 .timer = &msm_timer,
10591 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010592MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010593
10594MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10595 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010596 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010597 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010598 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010599 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010600 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010601 .init_early = msm8x60_charm_init_early,
10602MACHINE_END
10603
10604MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10605 .map_io = msm8x60_map_io,
10606 .reserve = msm8x60_reserve,
10607 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010608 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010609 .init_machine = msm8x60_fluid_init,
10610 .timer = &msm_timer,
10611 .init_early = msm8x60_charm_init_early,
10612MACHINE_END
10613
10614MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10615 .map_io = msm8x60_map_io,
10616 .reserve = msm8x60_reserve,
10617 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010618 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010619 .init_machine = msm8x60_charm_surf_init,
10620 .timer = &msm_timer,
10621 .init_early = msm8x60_charm_init_early,
10622MACHINE_END
10623
10624MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10625 .map_io = msm8x60_map_io,
10626 .reserve = msm8x60_reserve,
10627 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010628 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010629 .init_machine = msm8x60_charm_ffa_init,
10630 .timer = &msm_timer,
10631 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010632MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010633
10634MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10635 .map_io = msm8x60_map_io,
10636 .reserve = msm8x60_reserve,
10637 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010638 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010639 .init_machine = msm8x60_dragon_init,
10640 .timer = &msm_timer,
10641 .init_early = msm8x60_charm_init_early,
10642MACHINE_END