blob: e2ec60f0503e371a5aae3d10fda0400512b58c5b [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
Naseer Ahmed51860b02012-02-07 18:53:29 +05302653#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002654#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan42ebe712012-01-10 16:30:58 -08002655#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302656#define MSM_ION_MM_SIZE 0x3c00000 /* (60MB) Must be a multiple of 64K */
Olav Hauganb5be7992011-11-18 14:29:02 -08002657#define MSM_ION_MFC_SIZE SZ_8K
Mayank Choprac22ace32012-03-03 00:45:04 +05302658#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2659#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2660#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002661#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302662#endif
2663
Olav Haugan424ff492012-03-13 11:41:23 -07002664#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002665
2666#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302667#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002668#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002669#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2670static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002671#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002672#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002673#endif
2674
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002675static unsigned fb_size;
2676static int __init fb_size_setup(char *p)
2677{
2678 fb_size = memparse(p, NULL);
2679 return 0;
2680}
2681early_param("fb_size", fb_size_setup);
2682
2683static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2684static int __init pmem_kernel_ebi1_size_setup(char *p)
2685{
2686 pmem_kernel_ebi1_size = memparse(p, NULL);
2687 return 0;
2688}
2689early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2690
2691#ifdef CONFIG_ANDROID_PMEM
2692static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2693static int __init pmem_sf_size_setup(char *p)
2694{
2695 pmem_sf_size = memparse(p, NULL);
2696 return 0;
2697}
2698early_param("pmem_sf_size", pmem_sf_size_setup);
2699
2700static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2701
2702static int __init pmem_adsp_size_setup(char *p)
2703{
2704 pmem_adsp_size = memparse(p, NULL);
2705 return 0;
2706}
2707early_param("pmem_adsp_size", pmem_adsp_size_setup);
2708
2709static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2710
2711static int __init pmem_audio_size_setup(char *p)
2712{
2713 pmem_audio_size = memparse(p, NULL);
2714 return 0;
2715}
2716early_param("pmem_audio_size", pmem_audio_size_setup);
2717#endif
2718
2719static struct resource msm_fb_resources[] = {
2720 {
2721 .flags = IORESOURCE_DMA,
2722 }
2723};
2724
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002725static void set_mdp_clocks_for_wuxga(void);
2726
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002727static int msm_fb_detect_panel(const char *name)
2728{
2729 if (machine_is_msm8x60_fluid()) {
2730 uint32_t soc_platform_version = socinfo_get_platform_version();
2731 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2732#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2733 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002734 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2735 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736 return 0;
2737#endif
2738 } else { /*P3 and up use AUO panel */
2739#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2740 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002741 strnlen(LCDC_AUO_PANEL_NAME,
2742 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002743 return 0;
2744#endif
2745 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002746#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2747 } else if machine_is_msm8x60_dragon() {
2748 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002749 strnlen(LCDC_NT35582_PANEL_NAME,
2750 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002751 return 0;
2752#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002753 } else {
2754 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002755 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2756 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002757 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002758
2759#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2760 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2761 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2762 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2763 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2764 PANEL_NAME_MAX_LEN)))
2765 return 0;
2766
2767 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2768 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2769 PANEL_NAME_MAX_LEN)))
2770 return 0;
2771
2772 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2773 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2774 PANEL_NAME_MAX_LEN)))
2775 return 0;
2776#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002777 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002778
2779 if (!strncmp(name, HDMI_PANEL_NAME,
2780 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002781 PANEL_NAME_MAX_LEN))) {
2782 if (hdmi_is_primary)
2783 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002784 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002785 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002786
2787 if (!strncmp(name, TVOUT_PANEL_NAME,
2788 strnlen(TVOUT_PANEL_NAME,
2789 PANEL_NAME_MAX_LEN)))
2790 return 0;
2791
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002792 pr_warning("%s: not supported '%s'", __func__, name);
2793 return -ENODEV;
2794}
2795
2796static struct msm_fb_platform_data msm_fb_pdata = {
2797 .detect_client = msm_fb_detect_panel,
2798};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799
2800static struct platform_device msm_fb_device = {
2801 .name = "msm_fb",
2802 .id = 0,
2803 .num_resources = ARRAY_SIZE(msm_fb_resources),
2804 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002806};
2807
2808#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002809#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810static struct android_pmem_platform_data android_pmem_pdata = {
2811 .name = "pmem",
2812 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2813 .cached = 1,
2814 .memory_type = MEMTYPE_EBI1,
2815};
2816
2817static struct platform_device android_pmem_device = {
2818 .name = "android_pmem",
2819 .id = 0,
2820 .dev = {.platform_data = &android_pmem_pdata},
2821};
2822
2823static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2824 .name = "pmem_adsp",
2825 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2826 .cached = 0,
2827 .memory_type = MEMTYPE_EBI1,
2828};
2829
2830static struct platform_device android_pmem_adsp_device = {
2831 .name = "android_pmem",
2832 .id = 2,
2833 .dev = { .platform_data = &android_pmem_adsp_pdata },
2834};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302835
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002836static struct android_pmem_platform_data android_pmem_audio_pdata = {
2837 .name = "pmem_audio",
2838 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2839 .cached = 0,
2840 .memory_type = MEMTYPE_EBI1,
2841};
2842
2843static struct platform_device android_pmem_audio_device = {
2844 .name = "android_pmem",
2845 .id = 4,
2846 .dev = { .platform_data = &android_pmem_audio_pdata },
2847};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302848#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002849#define PMEM_BUS_WIDTH(_bw) \
2850 { \
2851 .vectors = &(struct msm_bus_vectors){ \
2852 .src = MSM_BUS_MASTER_AMPSS_M0, \
2853 .dst = MSM_BUS_SLAVE_SMI, \
2854 .ib = (_bw), \
2855 .ab = 0, \
2856 }, \
2857 .num_paths = 1, \
2858 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002859
2860static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002861 [0] = PMEM_BUS_WIDTH(0), /* Off */
2862 [1] = PMEM_BUS_WIDTH(1), /* On */
2863};
2864
2865static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002866 .usecase = mem_smi_table,
2867 .num_usecases = ARRAY_SIZE(mem_smi_table),
2868 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002869};
2870
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002871int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002872{
2873 int bus_id = (int) data;
2874
2875 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002876 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002877}
2878
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002879int release_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, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002884 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002885}
2886
Alex Bird199980e2011-10-21 11:29:27 -07002887void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002888{
2889 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2890}
Olav Hauganee0f7802011-12-19 13:28:57 -08002891#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2893 .name = "pmem_smipool",
2894 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2895 .cached = 0,
2896 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002897 .request_region = request_smi_region,
2898 .release_region = release_smi_region,
2899 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002900 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002901};
2902static struct platform_device android_pmem_smipool_device = {
2903 .name = "android_pmem",
2904 .id = 7,
2905 .dev = { .platform_data = &android_pmem_smipool_pdata },
2906};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302907#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2908#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909
2910#define GPIO_DONGLE_PWR_EN 258
2911static void setup_display_power(void);
2912static int lcdc_vga_enabled;
2913static int vga_enable_request(int enable)
2914{
2915 if (enable)
2916 lcdc_vga_enabled = 1;
2917 else
2918 lcdc_vga_enabled = 0;
2919 setup_display_power();
2920
2921 return 0;
2922}
2923
2924#define GPIO_BACKLIGHT_PWM0 0
2925#define GPIO_BACKLIGHT_PWM1 1
2926
2927static int pmic_backlight_gpio[2]
2928 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2929static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2930 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2931 .vga_switch = vga_enable_request,
2932};
2933
2934static struct platform_device lcdc_samsung_panel_device = {
2935 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2936 .id = 0,
2937 .dev = {
2938 .platform_data = &lcdc_samsung_panel_data,
2939 }
2940};
2941#if (!defined(CONFIG_SPI_QUP)) && \
2942 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2943 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2944
2945static int lcdc_spi_gpio_array_num[] = {
2946 LCDC_SPI_GPIO_CLK,
2947 LCDC_SPI_GPIO_CS,
2948 LCDC_SPI_GPIO_MOSI,
2949};
2950
2951static uint32_t lcdc_spi_gpio_config_data[] = {
2952 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2953 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2954 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2955 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2956 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2957 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2958};
2959
2960static void lcdc_config_spi_gpios(int enable)
2961{
2962 int n;
2963 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2964 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2965}
2966#endif
2967
2968#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2969#ifdef CONFIG_SPI_QUP
2970static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2971 {
2972 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2973 .mode = SPI_MODE_3,
2974 .bus_num = 1,
2975 .chip_select = 0,
2976 .max_speed_hz = 10800000,
2977 }
2978};
2979#endif /* CONFIG_SPI_QUP */
2980
2981static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2982#ifndef CONFIG_SPI_QUP
2983 .panel_config_gpio = lcdc_config_spi_gpios,
2984 .gpio_num = lcdc_spi_gpio_array_num,
2985#endif
2986};
2987
2988static struct platform_device lcdc_samsung_oled_panel_device = {
2989 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2990 .id = 0,
2991 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2992};
2993#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2994
2995#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2996#ifdef CONFIG_SPI_QUP
2997static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
2998 {
2999 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3000 .mode = SPI_MODE_3,
3001 .bus_num = 1,
3002 .chip_select = 0,
3003 .max_speed_hz = 10800000,
3004 }
3005};
3006#endif
3007
3008static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3009#ifndef CONFIG_SPI_QUP
3010 .panel_config_gpio = lcdc_config_spi_gpios,
3011 .gpio_num = lcdc_spi_gpio_array_num,
3012#endif
3013};
3014
3015static struct platform_device lcdc_auo_wvga_panel_device = {
3016 .name = LCDC_AUO_PANEL_NAME,
3017 .id = 0,
3018 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3019};
3020#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3021
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003022#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3023
3024#define GPIO_NT35582_RESET 94
3025#define GPIO_NT35582_BL_EN_HW_PIN 24
3026#define GPIO_NT35582_BL_EN \
3027 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3028
3029static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3030
3031static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3032 .gpio_num = lcdc_nt35582_pmic_gpio,
3033};
3034
3035static struct platform_device lcdc_nt35582_panel_device = {
3036 .name = LCDC_NT35582_PANEL_NAME,
3037 .id = 0,
3038 .dev = {
3039 .platform_data = &lcdc_nt35582_panel_data,
3040 }
3041};
3042
3043static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3044 {
3045 .modalias = "lcdc_nt35582_spi",
3046 .mode = SPI_MODE_0,
3047 .bus_num = 0,
3048 .chip_select = 0,
3049 .max_speed_hz = 1100000,
3050 }
3051};
3052#endif
3053
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003054#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3055static struct resource hdmi_msm_resources[] = {
3056 {
3057 .name = "hdmi_msm_qfprom_addr",
3058 .start = 0x00700000,
3059 .end = 0x007060FF,
3060 .flags = IORESOURCE_MEM,
3061 },
3062 {
3063 .name = "hdmi_msm_hdmi_addr",
3064 .start = 0x04A00000,
3065 .end = 0x04A00FFF,
3066 .flags = IORESOURCE_MEM,
3067 },
3068 {
3069 .name = "hdmi_msm_irq",
3070 .start = HDMI_IRQ,
3071 .end = HDMI_IRQ,
3072 .flags = IORESOURCE_IRQ,
3073 },
3074};
3075
3076static int hdmi_enable_5v(int on);
3077static int hdmi_core_power(int on, int show);
3078static int hdmi_cec_power(int on);
3079
3080static struct msm_hdmi_platform_data hdmi_msm_data = {
3081 .irq = HDMI_IRQ,
3082 .enable_5v = hdmi_enable_5v,
3083 .core_power = hdmi_core_power,
3084 .cec_power = hdmi_cec_power,
3085};
3086
3087static struct platform_device hdmi_msm_device = {
3088 .name = "hdmi_msm",
3089 .id = 0,
3090 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3091 .resource = hdmi_msm_resources,
3092 .dev.platform_data = &hdmi_msm_data,
3093};
3094#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3095
3096#ifdef CONFIG_FB_MSM_MIPI_DSI
3097static struct platform_device mipi_dsi_toshiba_panel_device = {
3098 .name = "mipi_toshiba",
3099 .id = 0,
3100};
3101
3102#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3103
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003104static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003106 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003107};
3108
3109static struct platform_device mipi_dsi_novatek_panel_device = {
3110 .name = "mipi_novatek",
3111 .id = 0,
3112 .dev = {
3113 .platform_data = &novatek_pdata,
3114 }
3115};
3116#endif
3117
3118static void __init msm8x60_allocate_memory_regions(void)
3119{
3120 void *addr;
3121 unsigned long size;
3122
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003123 if (hdmi_is_primary)
3124 size = roundup((1920 * 1088 * 4 * 2), 4096);
3125 else
3126 size = MSM_FB_SIZE;
3127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003128 addr = alloc_bootmem_align(size, 0x1000);
3129 msm_fb_resources[0].start = __pa(addr);
3130 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3131 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3132 size, addr, __pa(addr));
3133
3134}
3135
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003136void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3137{
3138 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3139 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3140 PANEL_NAME_MAX_LEN);
3141 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3142 msm_fb_pdata.prim_panel_name);
3143
3144 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3145 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3146 PANEL_NAME_MAX_LEN))) {
3147 pr_debug("HDMI is the primary display by"
3148 " boot parameter\n");
3149 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003150 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003151 }
3152 }
3153 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3154 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3155 PANEL_NAME_MAX_LEN);
3156 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3157 msm_fb_pdata.ext_panel_name);
3158 }
3159}
3160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003161#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3162 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3163/*virtual key support */
3164static ssize_t tma300_vkeys_show(struct kobject *kobj,
3165 struct kobj_attribute *attr, char *buf)
3166{
3167 return sprintf(buf,
3168 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3169 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3170 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3171 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3172 "\n");
3173}
3174
3175static struct kobj_attribute tma300_vkeys_attr = {
3176 .attr = {
3177 .mode = S_IRUGO,
3178 },
3179 .show = &tma300_vkeys_show,
3180};
3181
3182static struct attribute *tma300_properties_attrs[] = {
3183 &tma300_vkeys_attr.attr,
3184 NULL
3185};
3186
3187static struct attribute_group tma300_properties_attr_group = {
3188 .attrs = tma300_properties_attrs,
3189};
3190
3191static struct kobject *properties_kobj;
3192
3193
3194
3195#define CYTTSP_TS_GPIO_IRQ 61
3196static int cyttsp_platform_init(struct i2c_client *client)
3197{
3198 int rc = -EINVAL;
3199 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3200
3201 if (machine_is_msm8x60_fluid()) {
3202 pm8058_l5 = regulator_get(NULL, "8058_l5");
3203 if (IS_ERR(pm8058_l5)) {
3204 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3205 __func__, PTR_ERR(pm8058_l5));
3206 rc = PTR_ERR(pm8058_l5);
3207 return rc;
3208 }
3209 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3210 if (rc) {
3211 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3212 __func__, rc);
3213 goto reg_l5_put;
3214 }
3215
3216 rc = regulator_enable(pm8058_l5);
3217 if (rc) {
3218 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3219 __func__, rc);
3220 goto reg_l5_put;
3221 }
3222 }
3223 /* vote for s3 to enable i2c communication lines */
3224 pm8058_s3 = regulator_get(NULL, "8058_s3");
3225 if (IS_ERR(pm8058_s3)) {
3226 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3227 __func__, PTR_ERR(pm8058_s3));
3228 rc = PTR_ERR(pm8058_s3);
3229 goto reg_l5_disable;
3230 }
3231
3232 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3233 if (rc) {
3234 pr_err("%s: regulator_set_voltage() = %d\n",
3235 __func__, rc);
3236 goto reg_s3_put;
3237 }
3238
3239 rc = regulator_enable(pm8058_s3);
3240 if (rc) {
3241 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3242 __func__, rc);
3243 goto reg_s3_put;
3244 }
3245
3246 /* wait for vregs to stabilize */
3247 usleep_range(10000, 10000);
3248
3249 /* check this device active by reading first byte/register */
3250 rc = i2c_smbus_read_byte_data(client, 0x01);
3251 if (rc < 0) {
3252 pr_err("%s: i2c sanity check failed\n", __func__);
3253 goto reg_s3_disable;
3254 }
3255
3256 /* virtual keys */
3257 if (machine_is_msm8x60_fluid()) {
3258 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3259 properties_kobj = kobject_create_and_add("board_properties",
3260 NULL);
3261 if (properties_kobj)
3262 rc = sysfs_create_group(properties_kobj,
3263 &tma300_properties_attr_group);
3264 if (!properties_kobj || rc)
3265 pr_err("%s: failed to create board_properties\n",
3266 __func__);
3267 }
3268 return CY_OK;
3269
3270reg_s3_disable:
3271 regulator_disable(pm8058_s3);
3272reg_s3_put:
3273 regulator_put(pm8058_s3);
3274reg_l5_disable:
3275 if (machine_is_msm8x60_fluid())
3276 regulator_disable(pm8058_l5);
3277reg_l5_put:
3278 if (machine_is_msm8x60_fluid())
3279 regulator_put(pm8058_l5);
3280 return rc;
3281}
3282
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303283/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3284static int cyttsp_platform_suspend(struct i2c_client *client)
3285{
3286 msleep(20);
3287
3288 return CY_OK;
3289}
3290
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003291static int cyttsp_platform_resume(struct i2c_client *client)
3292{
3293 /* add any special code to strobe a wakeup pin or chip reset */
3294 msleep(10);
3295
3296 return CY_OK;
3297}
3298
3299static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3300 .flags = 0x04,
3301 .gen = CY_GEN3, /* or */
3302 .use_st = CY_USE_ST,
3303 .use_mt = CY_USE_MT,
3304 .use_hndshk = CY_SEND_HNDSHK,
3305 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303306 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003307 .use_gestures = CY_USE_GESTURES,
3308 /* activate up to 4 groups
3309 * and set active distance
3310 */
3311 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3312 CY_GEST_GRP3 | CY_GEST_GRP4 |
3313 CY_ACT_DIST,
3314 /* change act_intrvl to customize the Active power state
3315 * scanning/processing refresh interval for Operating mode
3316 */
3317 .act_intrvl = CY_ACT_INTRVL_DFLT,
3318 /* change tch_tmout to customize the touch timeout for the
3319 * Active power state for Operating mode
3320 */
3321 .tch_tmout = CY_TCH_TMOUT_DFLT,
3322 /* change lp_intrvl to customize the Low Power power state
3323 * scanning/processing refresh interval for Operating mode
3324 */
3325 .lp_intrvl = CY_LP_INTRVL_DFLT,
3326 .sleep_gpio = -1,
3327 .resout_gpio = -1,
3328 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3329 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303330 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003331 .init = cyttsp_platform_init,
3332};
3333
3334static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3335 .panel_maxx = 1083,
3336 .panel_maxy = 659,
3337 .disp_minx = 30,
3338 .disp_maxx = 1053,
3339 .disp_miny = 30,
3340 .disp_maxy = 629,
3341 .correct_fw_ver = 8,
3342 .fw_fname = "cyttsp_8660_ffa.hex",
3343 .flags = 0x00,
3344 .gen = CY_GEN2, /* or */
3345 .use_st = CY_USE_ST,
3346 .use_mt = CY_USE_MT,
3347 .use_hndshk = CY_SEND_HNDSHK,
3348 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303349 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003350 .use_gestures = CY_USE_GESTURES,
3351 /* activate up to 4 groups
3352 * and set active distance
3353 */
3354 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3355 CY_GEST_GRP3 | CY_GEST_GRP4 |
3356 CY_ACT_DIST,
3357 /* change act_intrvl to customize the Active power state
3358 * scanning/processing refresh interval for Operating mode
3359 */
3360 .act_intrvl = CY_ACT_INTRVL_DFLT,
3361 /* change tch_tmout to customize the touch timeout for the
3362 * Active power state for Operating mode
3363 */
3364 .tch_tmout = CY_TCH_TMOUT_DFLT,
3365 /* change lp_intrvl to customize the Low Power power state
3366 * scanning/processing refresh interval for Operating mode
3367 */
3368 .lp_intrvl = CY_LP_INTRVL_DFLT,
3369 .sleep_gpio = -1,
3370 .resout_gpio = -1,
3371 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3372 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303373 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003374 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303375 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003376};
3377static void cyttsp_set_params(void)
3378{
3379 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3380 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3381 cyttsp_fluid_pdata.panel_maxx = 539;
3382 cyttsp_fluid_pdata.panel_maxy = 994;
3383 cyttsp_fluid_pdata.disp_minx = 30;
3384 cyttsp_fluid_pdata.disp_maxx = 509;
3385 cyttsp_fluid_pdata.disp_miny = 60;
3386 cyttsp_fluid_pdata.disp_maxy = 859;
3387 cyttsp_fluid_pdata.correct_fw_ver = 4;
3388 } else {
3389 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3390 cyttsp_fluid_pdata.panel_maxx = 550;
3391 cyttsp_fluid_pdata.panel_maxy = 1013;
3392 cyttsp_fluid_pdata.disp_minx = 35;
3393 cyttsp_fluid_pdata.disp_maxx = 515;
3394 cyttsp_fluid_pdata.disp_miny = 69;
3395 cyttsp_fluid_pdata.disp_maxy = 869;
3396 cyttsp_fluid_pdata.correct_fw_ver = 5;
3397 }
3398
3399}
3400
3401static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3402 {
3403 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3404 .platform_data = &cyttsp_fluid_pdata,
3405#ifndef CY_USE_TIMER
3406 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3407#endif /* CY_USE_TIMER */
3408 },
3409};
3410
3411static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3412 {
3413 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3414 .platform_data = &cyttsp_tmg240_pdata,
3415#ifndef CY_USE_TIMER
3416 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3417#endif /* CY_USE_TIMER */
3418 },
3419};
3420#endif
3421
3422static struct regulator *vreg_tmg200;
3423
3424#define TS_PEN_IRQ_GPIO 61
3425static int tmg200_power(int vreg_on)
3426{
3427 int rc = -EINVAL;
3428
3429 if (!vreg_tmg200) {
3430 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3431 __func__, rc);
3432 return rc;
3433 }
3434
3435 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3436 regulator_disable(vreg_tmg200);
3437 if (rc < 0)
3438 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3439 __func__, vreg_on ? "enable" : "disable", rc);
3440
3441 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003442 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003443
3444 return rc;
3445}
3446
3447static int tmg200_dev_setup(bool enable)
3448{
3449 int rc;
3450
3451 if (enable) {
3452 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3453 if (IS_ERR(vreg_tmg200)) {
3454 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3455 __func__, PTR_ERR(vreg_tmg200));
3456 rc = PTR_ERR(vreg_tmg200);
3457 return rc;
3458 }
3459
3460 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3461 if (rc) {
3462 pr_err("%s: regulator_set_voltage() = %d\n",
3463 __func__, rc);
3464 goto reg_put;
3465 }
3466 } else {
3467 /* put voltage sources */
3468 regulator_put(vreg_tmg200);
3469 }
3470 return 0;
3471reg_put:
3472 regulator_put(vreg_tmg200);
3473 return rc;
3474}
3475
3476static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3477 .ts_name = "msm_tmg200_ts",
3478 .dis_min_x = 0,
3479 .dis_max_x = 1023,
3480 .dis_min_y = 0,
3481 .dis_max_y = 599,
3482 .min_tid = 0,
3483 .max_tid = 255,
3484 .min_touch = 0,
3485 .max_touch = 255,
3486 .min_width = 0,
3487 .max_width = 255,
3488 .power_on = tmg200_power,
3489 .dev_setup = tmg200_dev_setup,
3490 .nfingers = 2,
3491 .irq_gpio = TS_PEN_IRQ_GPIO,
3492 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3493};
3494
3495static struct i2c_board_info cy8ctmg200_board_info[] = {
3496 {
3497 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3498 .platform_data = &cy8ctmg200_pdata,
3499 }
3500};
3501
Zhang Chang Ken211df572011-07-05 19:16:39 -04003502static struct regulator *vreg_tma340;
3503
3504static int tma340_power(int vreg_on)
3505{
3506 int rc = -EINVAL;
3507
3508 if (!vreg_tma340) {
3509 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3510 __func__, rc);
3511 return rc;
3512 }
3513
3514 rc = vreg_on ? regulator_enable(vreg_tma340) :
3515 regulator_disable(vreg_tma340);
3516 if (rc < 0)
3517 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3518 __func__, vreg_on ? "enable" : "disable", rc);
3519
3520 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003521 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003522
3523 return rc;
3524}
3525
3526static struct kobject *tma340_prop_kobj;
3527
3528static int tma340_dragon_dev_setup(bool enable)
3529{
3530 int rc;
3531
3532 if (enable) {
3533 vreg_tma340 = regulator_get(NULL, "8901_l2");
3534 if (IS_ERR(vreg_tma340)) {
3535 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3536 __func__, PTR_ERR(vreg_tma340));
3537 rc = PTR_ERR(vreg_tma340);
3538 return rc;
3539 }
3540
3541 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3542 if (rc) {
3543 pr_err("%s: regulator_set_voltage() = %d\n",
3544 __func__, rc);
3545 goto reg_put;
3546 }
3547 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3548 tma340_prop_kobj = kobject_create_and_add("board_properties",
3549 NULL);
3550 if (tma340_prop_kobj) {
3551 rc = sysfs_create_group(tma340_prop_kobj,
3552 &tma300_properties_attr_group);
3553 if (rc) {
3554 kobject_put(tma340_prop_kobj);
3555 pr_err("%s: failed to create board_properties\n",
3556 __func__);
3557 goto reg_put;
3558 }
3559 }
3560
3561 } else {
3562 /* put voltage sources */
3563 regulator_put(vreg_tma340);
3564 /* destroy virtual keys */
3565 if (tma340_prop_kobj) {
3566 sysfs_remove_group(tma340_prop_kobj,
3567 &tma300_properties_attr_group);
3568 kobject_put(tma340_prop_kobj);
3569 }
3570 }
3571 return 0;
3572reg_put:
3573 regulator_put(vreg_tma340);
3574 return rc;
3575}
3576
3577
3578static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3579 .ts_name = "cy8ctma340",
3580 .dis_min_x = 0,
3581 .dis_max_x = 479,
3582 .dis_min_y = 0,
3583 .dis_max_y = 799,
3584 .min_tid = 0,
3585 .max_tid = 255,
3586 .min_touch = 0,
3587 .max_touch = 255,
3588 .min_width = 0,
3589 .max_width = 255,
3590 .power_on = tma340_power,
3591 .dev_setup = tma340_dragon_dev_setup,
3592 .nfingers = 2,
3593 .irq_gpio = TS_PEN_IRQ_GPIO,
3594 .resout_gpio = -1,
3595};
3596
3597static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3598 {
3599 I2C_BOARD_INFO("cy8ctma340", 0x24),
3600 .platform_data = &cy8ctma340_dragon_pdata,
3601 }
3602};
3603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003604#ifdef CONFIG_SERIAL_MSM_HS
3605static int configure_uart_gpios(int on)
3606{
3607 int ret = 0, i;
3608 int uart_gpios[] = {53, 54, 55, 56};
3609 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3610 if (on) {
3611 ret = msm_gpiomux_get(uart_gpios[i]);
3612 if (unlikely(ret))
3613 break;
3614 } else {
3615 ret = msm_gpiomux_put(uart_gpios[i]);
3616 if (unlikely(ret))
3617 return ret;
3618 }
3619 }
3620 if (ret)
3621 for (; i >= 0; i--)
3622 msm_gpiomux_put(uart_gpios[i]);
3623 return ret;
3624}
3625static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3626 .inject_rx_on_wakeup = 1,
3627 .rx_to_inject = 0xFD,
3628 .gpio_config = configure_uart_gpios,
3629};
3630#endif
3631
3632
3633#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3634
3635static struct gpio_led gpio_exp_leds_config[] = {
3636 {
3637 .name = "left_led1:green",
3638 .gpio = GPIO_LEFT_LED_1,
3639 .active_low = 1,
3640 .retain_state_suspended = 0,
3641 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3642 },
3643 {
3644 .name = "left_led2:red",
3645 .gpio = GPIO_LEFT_LED_2,
3646 .active_low = 1,
3647 .retain_state_suspended = 0,
3648 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3649 },
3650 {
3651 .name = "left_led3:green",
3652 .gpio = GPIO_LEFT_LED_3,
3653 .active_low = 1,
3654 .retain_state_suspended = 0,
3655 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3656 },
3657 {
3658 .name = "wlan_led:orange",
3659 .gpio = GPIO_LEFT_LED_WLAN,
3660 .active_low = 1,
3661 .retain_state_suspended = 0,
3662 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3663 },
3664 {
3665 .name = "left_led5:green",
3666 .gpio = GPIO_LEFT_LED_5,
3667 .active_low = 1,
3668 .retain_state_suspended = 0,
3669 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3670 },
3671 {
3672 .name = "right_led1:green",
3673 .gpio = GPIO_RIGHT_LED_1,
3674 .active_low = 1,
3675 .retain_state_suspended = 0,
3676 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3677 },
3678 {
3679 .name = "right_led2:red",
3680 .gpio = GPIO_RIGHT_LED_2,
3681 .active_low = 1,
3682 .retain_state_suspended = 0,
3683 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3684 },
3685 {
3686 .name = "right_led3:green",
3687 .gpio = GPIO_RIGHT_LED_3,
3688 .active_low = 1,
3689 .retain_state_suspended = 0,
3690 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3691 },
3692 {
3693 .name = "bt_led:blue",
3694 .gpio = GPIO_RIGHT_LED_BT,
3695 .active_low = 1,
3696 .retain_state_suspended = 0,
3697 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3698 },
3699 {
3700 .name = "right_led5:green",
3701 .gpio = GPIO_RIGHT_LED_5,
3702 .active_low = 1,
3703 .retain_state_suspended = 0,
3704 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3705 },
3706};
3707
3708static struct gpio_led_platform_data gpio_leds_pdata = {
3709 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3710 .leds = gpio_exp_leds_config,
3711};
3712
3713static struct platform_device gpio_leds = {
3714 .name = "leds-gpio",
3715 .id = -1,
3716 .dev = {
3717 .platform_data = &gpio_leds_pdata,
3718 },
3719};
3720
3721static struct gpio_led fluid_gpio_leds[] = {
3722 {
3723 .name = "dual_led:green",
3724 .gpio = GPIO_LED1_GREEN_N,
3725 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3726 .active_low = 1,
3727 .retain_state_suspended = 0,
3728 },
3729 {
3730 .name = "dual_led:red",
3731 .gpio = GPIO_LED2_RED_N,
3732 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3733 .active_low = 1,
3734 .retain_state_suspended = 0,
3735 },
3736};
3737
3738static struct gpio_led_platform_data gpio_led_pdata = {
3739 .leds = fluid_gpio_leds,
3740 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3741};
3742
3743static struct platform_device fluid_leds_gpio = {
3744 .name = "leds-gpio",
3745 .id = -1,
3746 .dev = {
3747 .platform_data = &gpio_led_pdata,
3748 },
3749};
3750
3751#endif
3752
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003753#ifdef CONFIG_BATTERY_MSM8X60
3754static struct msm_charger_platform_data msm_charger_data = {
3755 .safety_time = 180,
3756 .update_time = 1,
3757 .max_voltage = 4200,
3758 .min_voltage = 3200,
3759};
3760
3761static struct platform_device msm_charger_device = {
3762 .name = "msm-charger",
3763 .id = -1,
3764 .dev = {
3765 .platform_data = &msm_charger_data,
3766 }
3767};
3768#endif
3769
3770/*
3771 * Consumer specific regulator names:
3772 * regulator name consumer dev_name
3773 */
3774static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3775 REGULATOR_SUPPLY("8058_l0", NULL),
3776};
3777static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3778 REGULATOR_SUPPLY("8058_l1", NULL),
3779};
3780static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3781 REGULATOR_SUPPLY("8058_l2", NULL),
3782};
3783static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3784 REGULATOR_SUPPLY("8058_l3", NULL),
3785};
3786static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3787 REGULATOR_SUPPLY("8058_l4", NULL),
3788};
3789static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3790 REGULATOR_SUPPLY("8058_l5", NULL),
3791};
3792static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3793 REGULATOR_SUPPLY("8058_l6", NULL),
3794};
3795static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3796 REGULATOR_SUPPLY("8058_l7", NULL),
3797};
3798static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3799 REGULATOR_SUPPLY("8058_l8", NULL),
3800};
3801static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3802 REGULATOR_SUPPLY("8058_l9", NULL),
3803};
3804static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3805 REGULATOR_SUPPLY("8058_l10", NULL),
3806};
3807static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3808 REGULATOR_SUPPLY("8058_l11", NULL),
3809};
3810static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3811 REGULATOR_SUPPLY("8058_l12", NULL),
3812};
3813static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3814 REGULATOR_SUPPLY("8058_l13", NULL),
3815};
3816static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3817 REGULATOR_SUPPLY("8058_l14", NULL),
3818};
3819static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3820 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003821 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003822 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003823 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003824};
3825static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3826 REGULATOR_SUPPLY("8058_l16", NULL),
3827};
3828static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3829 REGULATOR_SUPPLY("8058_l17", NULL),
3830};
3831static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3832 REGULATOR_SUPPLY("8058_l18", NULL),
3833};
3834static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3835 REGULATOR_SUPPLY("8058_l19", NULL),
3836};
3837static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3838 REGULATOR_SUPPLY("8058_l20", NULL),
3839};
3840static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3841 REGULATOR_SUPPLY("8058_l21", NULL),
3842};
3843static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3844 REGULATOR_SUPPLY("8058_l22", NULL),
3845};
3846static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3847 REGULATOR_SUPPLY("8058_l23", NULL),
3848};
3849static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3850 REGULATOR_SUPPLY("8058_l24", NULL),
3851};
3852static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3853 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003854 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003855 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003856 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003857};
3858static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3859 REGULATOR_SUPPLY("8058_s0", NULL),
3860};
3861static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3862 REGULATOR_SUPPLY("8058_s1", NULL),
3863};
3864static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3865 REGULATOR_SUPPLY("8058_s2", NULL),
3866};
3867static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3868 REGULATOR_SUPPLY("8058_s3", NULL),
3869};
3870static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3871 REGULATOR_SUPPLY("8058_s4", NULL),
3872};
3873static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3874 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003875 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003876 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003877 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003878};
3879static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3880 REGULATOR_SUPPLY("8058_lvs1", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3883 REGULATOR_SUPPLY("8058_ncp", NULL),
3884};
3885
3886static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3887 REGULATOR_SUPPLY("8901_l0", NULL),
3888};
3889static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3890 REGULATOR_SUPPLY("8901_l1", NULL),
3891};
3892static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3893 REGULATOR_SUPPLY("8901_l2", NULL),
3894};
3895static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3896 REGULATOR_SUPPLY("8901_l3", NULL),
3897};
3898static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3899 REGULATOR_SUPPLY("8901_l4", NULL),
3900};
3901static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3902 REGULATOR_SUPPLY("8901_l5", NULL),
3903};
3904static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3905 REGULATOR_SUPPLY("8901_l6", NULL),
3906};
3907static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3908 REGULATOR_SUPPLY("8901_s2", NULL),
3909};
3910static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3911 REGULATOR_SUPPLY("8901_s3", NULL),
3912};
3913static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3914 REGULATOR_SUPPLY("8901_s4", NULL),
3915};
3916static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3917 REGULATOR_SUPPLY("8901_lvs0", NULL),
3918};
3919static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3920 REGULATOR_SUPPLY("8901_lvs1", NULL),
3921};
3922static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3923 REGULATOR_SUPPLY("8901_lvs2", NULL),
3924};
3925static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3926 REGULATOR_SUPPLY("8901_lvs3", NULL),
3927};
3928static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3929 REGULATOR_SUPPLY("8901_mvs0", NULL),
3930};
3931
David Collins6f032ba2011-08-31 14:08:15 -07003932/* Pin control regulators */
3933static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3934 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3935};
3936static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3937 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3938};
3939static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3940 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3941};
3942static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3943 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3944};
3945static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3946 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3947};
3948static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3949 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3950};
3951
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003952#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3953 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003954 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3955 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003956 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003957 .init_data = { \
3958 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003959 .valid_modes_mask = _modes, \
3960 .valid_ops_mask = _ops, \
3961 .min_uV = _min_uV, \
3962 .max_uV = _max_uV, \
3963 .input_uV = _min_uV, \
3964 .apply_uV = _apply_uV, \
3965 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003966 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003967 .consumer_supplies = vreg_consumers_##_id, \
3968 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003969 ARRAY_SIZE(vreg_consumers_##_id), \
3970 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003971 .id = RPM_VREG_ID_##_id, \
3972 .default_uV = _default_uV, \
3973 .peak_uA = _peak_uA, \
3974 .avg_uA = _avg_uA, \
3975 .pull_down_enable = _pull_down, \
3976 .pin_ctrl = _pin_ctrl, \
3977 .freq = RPM_VREG_FREQ_##_freq, \
3978 .pin_fn = _pin_fn, \
3979 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003980 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003981 .state = _state, \
3982 .sleep_selectable = _sleep_selectable, \
3983 }
3984
3985/* Pin control initialization */
3986#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3987 { \
3988 .init_data = { \
3989 .constraints = { \
3990 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3991 .always_on = _always_on, \
3992 }, \
3993 .num_consumer_supplies = \
3994 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3995 .consumer_supplies = vreg_consumers_##_id##_PC, \
3996 }, \
3997 .id = RPM_VREG_ID_##_id##_PC, \
3998 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003999 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004000 }
4001
4002/*
4003 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4004 * via the peak_uA value specified in the table below. If the value is less
4005 * than the high power min threshold for the regulator, then the regulator will
4006 * be set to LPM. Otherwise, it will be set to HPM.
4007 *
4008 * This value can be further overridden by specifying an initial mode via
4009 * .init_data.constraints.initial_mode.
4010 */
4011
David Collins6f032ba2011-08-31 14:08:15 -07004012#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4013 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004014 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4015 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4016 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4017 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4018 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004019 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4020 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004021 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004022 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004023 _sleep_selectable, _always_on)
4024
David Collins6f032ba2011-08-31 14:08:15 -07004025#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4026 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004027 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4028 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4029 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4030 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4031 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004032 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4033 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004034 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004035 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4036 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004037
David Collins6f032ba2011-08-31 14:08:15 -07004038#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004039 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4040 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004041 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4042 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004043 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004044 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4045 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046
David Collins6f032ba2011-08-31 14:08:15 -07004047#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004048 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4049 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004050 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4051 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004052 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004053 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4054 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004055
David Collins6f032ba2011-08-31 14:08:15 -07004056#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4057#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4058#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4059#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4060#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004061
David Collins6f032ba2011-08-31 14:08:15 -07004062/* RPM early regulator constraints */
4063static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4064 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004065 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004066 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004067};
4068
David Collins6f032ba2011-08-31 14:08:15 -07004069/* RPM regulator constraints */
4070static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4071 /* ID a_on pd ss min_uV max_uV init_ip */
4072 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4073 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4074 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4075 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4076 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4077 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4078 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4079 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4080 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4081 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4082 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4083 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4084 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4085 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4086 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4087 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4088 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4089 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4090 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4091 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4092 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4093 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4094 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4095 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4096 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4097 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004098
David Collins6f032ba2011-08-31 14:08:15 -07004099 /* ID a_on pd ss min_uV max_uV init_ip freq */
4100 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4101 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4102 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4103
4104 /* ID a_on pd ss */
4105 RPM_VS(PM8058_LVS0, 0, 1, 0),
4106 RPM_VS(PM8058_LVS1, 0, 1, 0),
4107
4108 /* ID a_on pd ss min_uV max_uV */
4109 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4110
4111 /* ID a_on pd ss min_uV max_uV init_ip */
4112 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4113 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4114 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4115 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4116 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4117 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4118 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4119
4120 /* ID a_on pd ss min_uV max_uV init_ip freq */
4121 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4122 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4123 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4124
4125 /* ID a_on pd ss */
4126 RPM_VS(PM8901_LVS0, 1, 1, 0),
4127 RPM_VS(PM8901_LVS1, 0, 1, 0),
4128 RPM_VS(PM8901_LVS2, 0, 1, 0),
4129 RPM_VS(PM8901_LVS3, 0, 1, 0),
4130 RPM_VS(PM8901_MVS0, 0, 1, 0),
4131
4132 /* ID a_on pin_func pin_ctrl */
4133 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4134 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4135 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4136 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4137 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4138 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4139};
4140
4141static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4142 .init_data = rpm_regulator_early_init_data,
4143 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4144 .version = RPM_VREG_VERSION_8660,
4145 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4146 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4147};
4148
4149static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4150 .init_data = rpm_regulator_init_data,
4151 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4152 .version = RPM_VREG_VERSION_8660,
4153};
4154
4155static struct platform_device rpm_regulator_early_device = {
4156 .name = "rpm-regulator",
4157 .id = 0,
4158 .dev = {
4159 .platform_data = &rpm_regulator_early_pdata,
4160 },
4161};
4162
4163static struct platform_device rpm_regulator_device = {
4164 .name = "rpm-regulator",
4165 .id = 1,
4166 .dev = {
4167 .platform_data = &rpm_regulator_pdata,
4168 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004169};
4170
4171static struct platform_device *early_regulators[] __initdata = {
4172 &msm_device_saw_s0,
4173 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004174 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004175};
4176
4177static struct platform_device *early_devices[] __initdata = {
4178#ifdef CONFIG_MSM_BUS_SCALING
4179 &msm_bus_apps_fabric,
4180 &msm_bus_sys_fabric,
4181 &msm_bus_mm_fabric,
4182 &msm_bus_sys_fpb,
4183 &msm_bus_cpss_fpb,
4184#endif
4185 &msm_device_dmov_adm0,
4186 &msm_device_dmov_adm1,
4187};
4188
4189#if (defined(CONFIG_MARIMBA_CORE)) && \
4190 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4191
4192static int bluetooth_power(int);
4193static struct platform_device msm_bt_power_device = {
4194 .name = "bt_power",
4195 .id = -1,
4196 .dev = {
4197 .platform_data = &bluetooth_power,
4198 },
4199};
4200#endif
4201
4202static struct platform_device msm_tsens_device = {
4203 .name = "tsens-tm",
4204 .id = -1,
4205};
4206
4207static struct platform_device *rumi_sim_devices[] __initdata = {
4208 &smc91x_device,
4209 &msm_device_uart_dm12,
4210#ifdef CONFIG_I2C_QUP
4211 &msm_gsbi3_qup_i2c_device,
4212 &msm_gsbi4_qup_i2c_device,
4213 &msm_gsbi7_qup_i2c_device,
4214 &msm_gsbi8_qup_i2c_device,
4215 &msm_gsbi9_qup_i2c_device,
4216 &msm_gsbi12_qup_i2c_device,
4217#endif
4218#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004219 &msm_device_ssbi3,
4220#endif
4221#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004222#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004223 &android_pmem_device,
4224 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004225 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004226 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304227#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4228#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004229#ifdef CONFIG_MSM_ROTATOR
4230 &msm_rotator_device,
4231#endif
4232 &msm_fb_device,
4233 &msm_kgsl_3d0,
4234 &msm_kgsl_2d0,
4235 &msm_kgsl_2d1,
4236 &lcdc_samsung_panel_device,
4237#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4238 &hdmi_msm_device,
4239#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4240#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004241#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004242#ifdef CONFIG_MT9E013
4243 &msm_camera_sensor_mt9e013,
4244#endif
4245#ifdef CONFIG_IMX074
4246 &msm_camera_sensor_imx074,
4247#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004248#ifdef CONFIG_VX6953
4249 &msm_camera_sensor_vx6953,
4250#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004251#ifdef CONFIG_WEBCAM_OV7692
4252 &msm_camera_sensor_webcam_ov7692,
4253#endif
4254#ifdef CONFIG_WEBCAM_OV9726
4255 &msm_camera_sensor_webcam_ov9726,
4256#endif
4257#ifdef CONFIG_QS_S5K4E1
4258 &msm_camera_sensor_qs_s5k4e1,
4259#endif
4260#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004261#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004262#ifdef CONFIG_MSM_GEMINI
4263 &msm_gemini_device,
4264#endif
4265#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004266#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267 &msm_vpe_device,
4268#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004269#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004270 &msm_device_vidc,
4271};
4272
4273#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4274enum {
4275 SX150X_CORE,
4276 SX150X_DOCKING,
4277 SX150X_SURF,
4278 SX150X_LEFT_FHA,
4279 SX150X_RIGHT_FHA,
4280 SX150X_SOUTH,
4281 SX150X_NORTH,
4282 SX150X_CORE_FLUID,
4283};
4284
4285static struct sx150x_platform_data sx150x_data[] __initdata = {
4286 [SX150X_CORE] = {
4287 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4288 .oscio_is_gpo = false,
4289 .io_pullup_ena = 0x0c08,
4290 .io_pulldn_ena = 0x4060,
4291 .io_open_drain_ena = 0x000c,
4292 .io_polarity = 0,
4293 .irq_summary = -1, /* see fixup_i2c_configs() */
4294 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4295 },
4296 [SX150X_DOCKING] = {
4297 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4298 .oscio_is_gpo = false,
4299 .io_pullup_ena = 0x5e06,
4300 .io_pulldn_ena = 0x81b8,
4301 .io_open_drain_ena = 0,
4302 .io_polarity = 0,
4303 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4304 UI_INT2_N),
4305 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4306 GPIO_DOCKING_EXPANDER_BASE -
4307 GPIO_EXPANDER_GPIO_BASE,
4308 },
4309 [SX150X_SURF] = {
4310 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4311 .oscio_is_gpo = false,
4312 .io_pullup_ena = 0,
4313 .io_pulldn_ena = 0,
4314 .io_open_drain_ena = 0,
4315 .io_polarity = 0,
4316 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4317 UI_INT1_N),
4318 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4319 GPIO_SURF_EXPANDER_BASE -
4320 GPIO_EXPANDER_GPIO_BASE,
4321 },
4322 [SX150X_LEFT_FHA] = {
4323 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4324 .oscio_is_gpo = false,
4325 .io_pullup_ena = 0,
4326 .io_pulldn_ena = 0x40,
4327 .io_open_drain_ena = 0,
4328 .io_polarity = 0,
4329 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4330 UI_INT3_N),
4331 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4332 GPIO_LEFT_KB_EXPANDER_BASE -
4333 GPIO_EXPANDER_GPIO_BASE,
4334 },
4335 [SX150X_RIGHT_FHA] = {
4336 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4337 .oscio_is_gpo = true,
4338 .io_pullup_ena = 0,
4339 .io_pulldn_ena = 0,
4340 .io_open_drain_ena = 0,
4341 .io_polarity = 0,
4342 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4343 UI_INT3_N),
4344 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4345 GPIO_RIGHT_KB_EXPANDER_BASE -
4346 GPIO_EXPANDER_GPIO_BASE,
4347 },
4348 [SX150X_SOUTH] = {
4349 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4350 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4351 GPIO_SOUTH_EXPANDER_BASE -
4352 GPIO_EXPANDER_GPIO_BASE,
4353 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4354 },
4355 [SX150X_NORTH] = {
4356 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4357 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4358 GPIO_NORTH_EXPANDER_BASE -
4359 GPIO_EXPANDER_GPIO_BASE,
4360 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4361 .oscio_is_gpo = true,
4362 .io_open_drain_ena = 0x30,
4363 },
4364 [SX150X_CORE_FLUID] = {
4365 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4366 .oscio_is_gpo = false,
4367 .io_pullup_ena = 0x0408,
4368 .io_pulldn_ena = 0x4060,
4369 .io_open_drain_ena = 0x0008,
4370 .io_polarity = 0,
4371 .irq_summary = -1, /* see fixup_i2c_configs() */
4372 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4373 },
4374};
4375
4376#ifdef CONFIG_SENSORS_MSM_ADC
4377/* Configuration of EPM expander is done when client
4378 * request an adc read
4379 */
4380static struct sx150x_platform_data sx150x_epmdata = {
4381 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4382 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4383 GPIO_EPM_EXPANDER_BASE -
4384 GPIO_EXPANDER_GPIO_BASE,
4385 .irq_summary = -1,
4386};
4387#endif
4388
4389/* sx150x_low_power_cfg
4390 *
4391 * This data and init function are used to put unused gpio-expander output
4392 * lines into their low-power states at boot. The init
4393 * function must be deferred until a later init stage because the i2c
4394 * gpio expander drivers do not probe until after they are registered
4395 * (see register_i2c_devices) and the work-queues for those registrations
4396 * are processed. Because these lines are unused, there is no risk of
4397 * competing with a device driver for the gpio.
4398 *
4399 * gpio lines whose low-power states are input are naturally in their low-
4400 * power configurations once probed, see the platform data structures above.
4401 */
4402struct sx150x_low_power_cfg {
4403 unsigned gpio;
4404 unsigned val;
4405};
4406
4407static struct sx150x_low_power_cfg
4408common_sx150x_lp_cfgs[] __initdata = {
4409 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4410 {GPIO_EXT_GPS_LNA_EN, 0},
4411 {GPIO_MSM_WAKES_BT, 0},
4412 {GPIO_USB_UICC_EN, 0},
4413 {GPIO_BATT_GAUGE_EN, 0},
4414};
4415
4416static struct sx150x_low_power_cfg
4417surf_ffa_sx150x_lp_cfgs[] __initdata = {
4418 {GPIO_MIPI_DSI_RST_N, 0},
4419 {GPIO_DONGLE_PWR_EN, 0},
4420 {GPIO_CAP_TS_SLEEP, 1},
4421 {GPIO_WEB_CAMIF_RESET_N, 0},
4422};
4423
4424static void __init
4425cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4426{
4427 unsigned n;
4428 int rc;
4429
4430 for (n = 0; n < nelems; ++n) {
4431 rc = gpio_request(cfgs[n].gpio, NULL);
4432 if (!rc) {
4433 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4434 gpio_free(cfgs[n].gpio);
4435 }
4436
4437 if (rc) {
4438 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4439 __func__, cfgs[n].gpio, rc);
4440 }
Steve Muckle9161d302010-02-11 11:50:40 -08004441 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004442}
4443
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004444static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004445{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004446 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4447 ARRAY_SIZE(common_sx150x_lp_cfgs));
4448 if (!machine_is_msm8x60_fluid())
4449 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4450 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4451 return 0;
4452}
4453module_init(cfg_sx150xs_low_power);
4454
4455#ifdef CONFIG_I2C
4456static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4457 {
4458 I2C_BOARD_INFO("sx1509q", 0x3e),
4459 .platform_data = &sx150x_data[SX150X_CORE]
4460 },
4461};
4462
4463static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4464 {
4465 I2C_BOARD_INFO("sx1509q", 0x3f),
4466 .platform_data = &sx150x_data[SX150X_DOCKING]
4467 },
4468};
4469
4470static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4471 {
4472 I2C_BOARD_INFO("sx1509q", 0x70),
4473 .platform_data = &sx150x_data[SX150X_SURF]
4474 }
4475};
4476
4477static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4478 {
4479 I2C_BOARD_INFO("sx1508q", 0x21),
4480 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4481 },
4482 {
4483 I2C_BOARD_INFO("sx1508q", 0x22),
4484 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4485 }
4486};
4487
4488static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4489 {
4490 I2C_BOARD_INFO("sx1508q", 0x23),
4491 .platform_data = &sx150x_data[SX150X_SOUTH]
4492 },
4493 {
4494 I2C_BOARD_INFO("sx1508q", 0x20),
4495 .platform_data = &sx150x_data[SX150X_NORTH]
4496 }
4497};
4498
4499static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4500 {
4501 I2C_BOARD_INFO("sx1509q", 0x3e),
4502 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4503 },
4504};
4505
4506#ifdef CONFIG_SENSORS_MSM_ADC
4507static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4508 {
4509 I2C_BOARD_INFO("sx1509q", 0x3e),
4510 .platform_data = &sx150x_epmdata
4511 },
4512};
4513#endif
4514#endif
4515#endif
4516
4517#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004518
4519static struct adc_access_fn xoadc_fn = {
4520 pm8058_xoadc_select_chan_and_start_conv,
4521 pm8058_xoadc_read_adc_code,
4522 pm8058_xoadc_get_properties,
4523 pm8058_xoadc_slot_request,
4524 pm8058_xoadc_restore_slot,
4525 pm8058_xoadc_calibrate,
4526};
4527
4528#if defined(CONFIG_I2C) && \
4529 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4530static struct regulator *vreg_adc_epm1;
4531
4532static struct i2c_client *epm_expander_i2c_register_board(void)
4533
4534{
4535 struct i2c_adapter *i2c_adap;
4536 struct i2c_client *client = NULL;
4537 i2c_adap = i2c_get_adapter(0x0);
4538
4539 if (i2c_adap == NULL)
4540 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4541
4542 if (i2c_adap != NULL)
4543 client = i2c_new_device(i2c_adap,
4544 &fluid_expanders_i2c_epm_info[0]);
4545 return client;
4546
4547}
4548
4549static unsigned int msm_adc_gpio_configure_expander_enable(void)
4550{
4551 int rc = 0;
4552 static struct i2c_client *epm_i2c_client;
4553
4554 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4555
4556 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4557
4558 if (IS_ERR(vreg_adc_epm1)) {
4559 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4560 return 0;
4561 }
4562
4563 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4564 if (rc)
4565 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4566 "regulator set voltage failed\n");
4567
4568 rc = regulator_enable(vreg_adc_epm1);
4569 if (rc) {
4570 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4571 "Error while enabling regulator for epm s3 %d\n", rc);
4572 return rc;
4573 }
4574
4575 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4576 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4577
4578 msleep(1000);
4579
4580 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4581 if (!rc) {
4582 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4583 "Configure 5v boost\n");
4584 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4585 } else {
4586 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4587 "Error for epm 5v boost en\n");
4588 goto exit_vreg_epm;
4589 }
4590
4591 msleep(500);
4592
4593 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4594 if (!rc) {
4595 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4596 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4597 "Configure epm 3.3v\n");
4598 } else {
4599 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4600 "Error for gpio 3.3ven\n");
4601 goto exit_vreg_epm;
4602 }
4603 msleep(500);
4604
4605 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4606 "Trying to request EPM LVLSFT_EN\n");
4607 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4608 if (!rc) {
4609 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4610 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4611 "Configure the lvlsft\n");
4612 } else {
4613 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4614 "Error for epm lvlsft_en\n");
4615 goto exit_vreg_epm;
4616 }
4617
4618 msleep(500);
4619
4620 if (!epm_i2c_client)
4621 epm_i2c_client = epm_expander_i2c_register_board();
4622
4623 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4624 if (!rc)
4625 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4626 if (rc) {
4627 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4628 ": GPIO PWR MON Enable issue\n");
4629 goto exit_vreg_epm;
4630 }
4631
4632 msleep(1000);
4633
4634 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4635 if (!rc) {
4636 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4637 if (rc) {
4638 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4639 ": ADC1_PWDN error direction out\n");
4640 goto exit_vreg_epm;
4641 }
4642 }
4643
4644 msleep(100);
4645
4646 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4647 if (!rc) {
4648 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4649 if (rc) {
4650 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4651 ": ADC2_PWD error direction out\n");
4652 goto exit_vreg_epm;
4653 }
4654 }
4655
4656 msleep(1000);
4657
4658 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4659 if (!rc) {
4660 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4661 if (rc) {
4662 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4663 "Gpio request problem %d\n", rc);
4664 goto exit_vreg_epm;
4665 }
4666 }
4667
4668 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4669 if (!rc) {
4670 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4671 if (rc) {
4672 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4673 ": EPM_SPI_ADC1_CS_N error\n");
4674 goto exit_vreg_epm;
4675 }
4676 }
4677
4678 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4679 if (!rc) {
4680 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4681 if (rc) {
4682 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4683 ": EPM_SPI_ADC2_Cs_N error\n");
4684 goto exit_vreg_epm;
4685 }
4686 }
4687
4688 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4689 "the power monitor reset for epm\n");
4690
4691 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4692 if (!rc) {
4693 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4694 if (rc) {
4695 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4696 ": Error in the power mon reset\n");
4697 goto exit_vreg_epm;
4698 }
4699 }
4700
4701 msleep(1000);
4702
4703 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4704
4705 msleep(500);
4706
4707 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4708
4709 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4710
4711 return rc;
4712
4713exit_vreg_epm:
4714 regulator_disable(vreg_adc_epm1);
4715
4716 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4717 " rc = %d.\n", rc);
4718 return rc;
4719};
4720
4721static unsigned int msm_adc_gpio_configure_expander_disable(void)
4722{
4723 int rc = 0;
4724
4725 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4726 gpio_free(GPIO_PWR_MON_RESET_N);
4727
4728 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4729 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4730
4731 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4732 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4733
4734 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4735 gpio_free(GPIO_PWR_MON_START);
4736
4737 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4738 gpio_free(GPIO_ADC1_PWDN_N);
4739
4740 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4741 gpio_free(GPIO_ADC2_PWDN_N);
4742
4743 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4744 gpio_free(GPIO_PWR_MON_ENABLE);
4745
4746 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4747 gpio_free(GPIO_EPM_LVLSFT_EN);
4748
4749 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4750 gpio_free(GPIO_EPM_5V_BOOST_EN);
4751
4752 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4753 gpio_free(GPIO_EPM_3_3V_EN);
4754
4755 rc = regulator_disable(vreg_adc_epm1);
4756 if (rc)
4757 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4758 "Error while enabling regulator for epm s3 %d\n", rc);
4759 regulator_put(vreg_adc_epm1);
4760
4761 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4762 return rc;
4763};
4764
4765unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4766{
4767 int rc = 0;
4768
4769 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4770 cs_enable);
4771
4772 if (cs_enable < 16) {
4773 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4774 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4775 } else {
4776 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4777 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4778 }
4779 return rc;
4780};
4781
4782unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4783{
4784 int rc = 0;
4785
4786 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4787
4788 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4789
4790 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4791
4792 return rc;
4793};
4794#endif
4795
4796static struct msm_adc_channels msm_adc_channels_data[] = {
4797 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4798 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4799 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4800 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4801 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4802 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4803 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4804 CHAN_PATH_TYPE4,
4805 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4806 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4807 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4808 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4809 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4810 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4811 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4812 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4813 CHAN_PATH_TYPE12,
4814 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4815 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4816 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4817 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4818 CHAN_PATH_TYPE_NONE,
4819 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4820 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4822 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4823 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4824 scale_xtern_chgr_cur},
4825 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4826 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4827 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4828 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4829 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4830 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4831 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4832 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4833 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4834 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4835 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4836 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4837};
4838
4839static char *msm_adc_fluid_device_names[] = {
4840 "ADS_ADC1",
4841 "ADS_ADC2",
4842};
4843
4844static struct msm_adc_platform_data msm_adc_pdata = {
4845 .channel = msm_adc_channels_data,
4846 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4847#if defined(CONFIG_I2C) && \
4848 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4849 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4850 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4851 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4852 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4853#endif
4854};
4855
4856static struct platform_device msm_adc_device = {
4857 .name = "msm_adc",
4858 .id = -1,
4859 .dev = {
4860 .platform_data = &msm_adc_pdata,
4861 },
4862};
4863
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304864static struct msm_rtb_platform_data msm_rtb_pdata = {
4865 .size = SZ_1M,
4866};
4867
4868static int __init msm_rtb_set_buffer_size(char *p)
4869{
4870 int s;
4871
4872 s = memparse(p, NULL);
4873 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4874 return 0;
4875}
4876early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4877
4878
4879static struct platform_device msm_rtb_device = {
4880 .name = "msm_rtb",
4881 .id = -1,
4882 .dev = {
4883 .platform_data = &msm_rtb_pdata,
4884 },
4885};
4886
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004887static void pmic8058_xoadc_mpp_config(void)
4888{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304889 int rc, i;
4890 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304891 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304892 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304893 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304894 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304895 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304896 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304897 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304898 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304899 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304900 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304901 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4902 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304903 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004904
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304905 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4906 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4907 &xoadc_mpps[i].config);
4908 if (rc) {
4909 pr_err("%s: Config MPP %d of PM8058 failed\n",
4910 __func__, xoadc_mpps[i].mpp);
4911 }
4912 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004913}
4914
4915static struct regulator *vreg_ldo18_adc;
4916
4917static int pmic8058_xoadc_vreg_config(int on)
4918{
4919 int rc;
4920
4921 if (on) {
4922 rc = regulator_enable(vreg_ldo18_adc);
4923 if (rc)
4924 pr_err("%s: Enable of regulator ldo18_adc "
4925 "failed\n", __func__);
4926 } else {
4927 rc = regulator_disable(vreg_ldo18_adc);
4928 if (rc)
4929 pr_err("%s: Disable of regulator ldo18_adc "
4930 "failed\n", __func__);
4931 }
4932
4933 return rc;
4934}
4935
4936static int pmic8058_xoadc_vreg_setup(void)
4937{
4938 int rc;
4939
4940 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4941 if (IS_ERR(vreg_ldo18_adc)) {
4942 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4943 __func__, PTR_ERR(vreg_ldo18_adc));
4944 rc = PTR_ERR(vreg_ldo18_adc);
4945 goto fail;
4946 }
4947
4948 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4949 if (rc) {
4950 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4951 goto fail;
4952 }
4953
4954 return rc;
4955fail:
4956 regulator_put(vreg_ldo18_adc);
4957 return rc;
4958}
4959
4960static void pmic8058_xoadc_vreg_shutdown(void)
4961{
4962 regulator_put(vreg_ldo18_adc);
4963}
4964
4965/* usec. For this ADC,
4966 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4967 * Each channel has different configuration, thus at the time of starting
4968 * the conversion, xoadc will return actual conversion time
4969 * */
4970static struct adc_properties pm8058_xoadc_data = {
4971 .adc_reference = 2200, /* milli-voltage for this adc */
4972 .bitresolution = 15,
4973 .bipolar = 0,
4974 .conversiontime = 54,
4975};
4976
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304977static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004978 .xoadc_prop = &pm8058_xoadc_data,
4979 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4980 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4981 .xoadc_num = XOADC_PMIC_0,
4982 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4983 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4984};
4985#endif
4986
4987#ifdef CONFIG_MSM_SDIO_AL
4988
4989static unsigned mdm2ap_status = 140;
4990
4991static int configure_mdm2ap_status(int on)
4992{
4993 int ret = 0;
4994 if (on)
4995 ret = msm_gpiomux_get(mdm2ap_status);
4996 else
4997 ret = msm_gpiomux_put(mdm2ap_status);
4998
4999 if (ret)
5000 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
5001 on);
5002
5003 return ret;
5004}
5005
5006
5007static int get_mdm2ap_status(void)
5008{
5009 return gpio_get_value(mdm2ap_status);
5010}
5011
5012static struct sdio_al_platform_data sdio_al_pdata = {
5013 .config_mdm2ap_status = configure_mdm2ap_status,
5014 .get_mdm2ap_status = get_mdm2ap_status,
5015 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03005016 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005017 .peer_sdioc_version_major = 0x0004,
5018 .peer_sdioc_boot_version_minor = 0x0001,
5019 .peer_sdioc_boot_version_major = 0x0003
5020};
5021
5022struct platform_device msm_device_sdio_al = {
5023 .name = "msm_sdio_al",
5024 .id = -1,
5025 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03005026 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005027 .platform_data = &sdio_al_pdata,
5028 },
5029};
5030
5031#endif /* CONFIG_MSM_SDIO_AL */
5032
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305033#define GPIO_VREG_ID_EXT_5V 0
5034
5035static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5036 REGULATOR_SUPPLY("ext_5v", NULL),
5037 REGULATOR_SUPPLY("8901_mpp0", NULL),
5038};
5039
5040#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5041 [GPIO_VREG_ID_##_id] = { \
5042 .init_data = { \
5043 .constraints = { \
5044 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5045 }, \
5046 .num_consumer_supplies = \
5047 ARRAY_SIZE(vreg_consumers_##_id), \
5048 .consumer_supplies = vreg_consumers_##_id, \
5049 }, \
5050 .regulator_name = _reg_name, \
5051 .active_low = _active_low, \
5052 .gpio_label = _gpio_label, \
5053 .gpio = _gpio, \
5054 }
5055
5056/* GPIO regulator constraints */
5057static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5058 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5059 PM8901_MPP_PM_TO_SYS(0), 0),
5060};
5061
5062/* GPIO regulator */
5063static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5064 .name = GPIO_REGULATOR_DEV_NAME,
5065 .id = PM8901_MPP_PM_TO_SYS(0),
5066 .dev = {
5067 .platform_data =
5068 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5069 },
5070};
5071
5072static void __init pm8901_vreg_mpp0_init(void)
5073{
5074 int rc;
5075
5076 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5077 .mpp = PM8901_MPP_PM_TO_SYS(0),
5078 .config = {
5079 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5080 .level = PM8901_MPP_DIG_LEVEL_VPH,
5081 },
5082 };
5083
5084 /*
5085 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5086 * implies that the regulator connected to MPP0 is enabled when
5087 * MPP0 is low.
5088 */
5089 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5090 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5091 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5092 } else {
5093 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5094 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5095 }
5096
5097 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5098 if (rc)
5099 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5100}
5101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005102static struct platform_device *charm_devices[] __initdata = {
5103 &msm_charm_modem,
5104#ifdef CONFIG_MSM_SDIO_AL
5105 &msm_device_sdio_al,
5106#endif
5107};
5108
Lei Zhou338cab82011-08-19 13:38:17 -04005109#ifdef CONFIG_SND_SOC_MSM8660_APQ
5110static struct platform_device *dragon_alsa_devices[] __initdata = {
5111 &msm_pcm,
5112 &msm_pcm_routing,
5113 &msm_cpudai0,
5114 &msm_cpudai1,
5115 &msm_cpudai_hdmi_rx,
5116 &msm_cpudai_bt_rx,
5117 &msm_cpudai_bt_tx,
5118 &msm_cpudai_fm_rx,
5119 &msm_cpudai_fm_tx,
5120 &msm_cpu_fe,
5121 &msm_stub_codec,
5122 &msm_lpa_pcm,
5123};
5124#endif
5125
5126static struct platform_device *asoc_devices[] __initdata = {
5127 &asoc_msm_pcm,
5128 &asoc_msm_dai0,
5129 &asoc_msm_dai1,
5130};
5131
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005132static struct platform_device *surf_devices[] __initdata = {
5133 &msm_device_smd,
5134 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005135 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005136 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005137 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005138 &msm_pil_dsps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005139#ifdef CONFIG_I2C_QUP
5140 &msm_gsbi3_qup_i2c_device,
5141 &msm_gsbi4_qup_i2c_device,
5142 &msm_gsbi7_qup_i2c_device,
5143 &msm_gsbi8_qup_i2c_device,
5144 &msm_gsbi9_qup_i2c_device,
5145 &msm_gsbi12_qup_i2c_device,
5146#endif
5147#ifdef CONFIG_SERIAL_MSM_HS
5148 &msm_device_uart_dm1,
5149#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305150#ifdef CONFIG_MSM_SSBI
5151 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305152 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305153#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005154#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005155 &msm_device_ssbi3,
5156#endif
5157#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5158 &isp1763_device,
5159#endif
5160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005161#if defined (CONFIG_MSM_8x60_VOIP)
5162 &asoc_msm_mvs,
5163 &asoc_mvs_dai0,
5164 &asoc_mvs_dai1,
5165#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005166
Lena Salman57d167e2012-03-21 19:46:38 +02005167#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005168 &msm_device_otg,
5169#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005170#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005171 &msm_device_gadget_peripheral,
5172#endif
5173#ifdef CONFIG_USB_G_ANDROID
5174 &android_usb_device,
5175#endif
5176#ifdef CONFIG_BATTERY_MSM
5177 &msm_batt_device,
5178#endif
5179#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005180#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005181 &android_pmem_device,
5182 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005183 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005184 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305185#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5186#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005187#ifdef CONFIG_MSM_ROTATOR
5188 &msm_rotator_device,
5189#endif
5190 &msm_fb_device,
5191 &msm_kgsl_3d0,
5192 &msm_kgsl_2d0,
5193 &msm_kgsl_2d1,
5194 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005195#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5196 &lcdc_nt35582_panel_device,
5197#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005198#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5199 &lcdc_samsung_oled_panel_device,
5200#endif
5201#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5202 &lcdc_auo_wvga_panel_device,
5203#endif
5204#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5205 &hdmi_msm_device,
5206#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5207#ifdef CONFIG_FB_MSM_MIPI_DSI
5208 &mipi_dsi_toshiba_panel_device,
5209 &mipi_dsi_novatek_panel_device,
5210#endif
5211#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005212#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005213#ifdef CONFIG_MT9E013
5214 &msm_camera_sensor_mt9e013,
5215#endif
5216#ifdef CONFIG_IMX074
5217 &msm_camera_sensor_imx074,
5218#endif
5219#ifdef CONFIG_WEBCAM_OV7692
5220 &msm_camera_sensor_webcam_ov7692,
5221#endif
5222#ifdef CONFIG_WEBCAM_OV9726
5223 &msm_camera_sensor_webcam_ov9726,
5224#endif
5225#ifdef CONFIG_QS_S5K4E1
5226 &msm_camera_sensor_qs_s5k4e1,
5227#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005228#ifdef CONFIG_VX6953
5229 &msm_camera_sensor_vx6953,
5230#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005231#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005232#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005233#ifdef CONFIG_MSM_GEMINI
5234 &msm_gemini_device,
5235#endif
5236#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005237#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005238 &msm_vpe_device,
5239#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005240#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005241
5242#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005243 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005244#endif
5245#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005246 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005247#endif
5248 &msm_device_vidc,
5249#if (defined(CONFIG_MARIMBA_CORE)) && \
5250 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5251 &msm_bt_power_device,
5252#endif
5253#ifdef CONFIG_SENSORS_MSM_ADC
5254 &msm_adc_device,
5255#endif
David Collins6f032ba2011-08-31 14:08:15 -07005256 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005257
5258#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5259 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5260 &qcrypto_device,
5261#endif
5262
5263#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5264 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5265 &qcedev_device,
5266#endif
5267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005268
5269#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5270#ifdef CONFIG_MSM_USE_TSIF1
5271 &msm_device_tsif[1],
5272#else
5273 &msm_device_tsif[0],
5274#endif /* CONFIG_MSM_USE_TSIF1 */
5275#endif /* CONFIG_TSIF */
5276
5277#ifdef CONFIG_HW_RANDOM_MSM
5278 &msm_device_rng,
5279#endif
5280
5281 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005282 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005283#ifdef CONFIG_ION_MSM
5284 &ion_dev,
5285#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005286 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005287 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305288 &msm_rtb_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005289};
5290
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005291#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005292#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5293static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5294 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005295 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005296 .request_region = request_smi_region,
5297 .release_region = release_smi_region,
5298 .setup_region = setup_smi_region,
Olav Haugan8726caf2012-05-10 15:11:35 -07005299 .iommu_map_all = 1,
5300 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005301};
5302
5303static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5304 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005305 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005306 .request_region = request_smi_region,
5307 .release_region = release_smi_region,
5308 .setup_region = setup_smi_region,
5309};
5310
5311static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5312 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005313 .align = PAGE_SIZE,
5314};
5315
5316static struct ion_co_heap_pdata fw_co_ion_pdata = {
5317 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5318 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005319};
5320
5321static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005322 .adjacent_mem_id = INVALID_HEAP_ID,
5323 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005324};
5325#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005326
5327/**
5328 * These heaps are listed in the order they will be allocated. Due to
5329 * video hardware restrictions and content protection the FW heap has to
5330 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5331 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5332 * away from the base address of the FW heap.
5333 * However, the order of FW heap and MM heap doesn't matter since these
5334 * two heaps are taken care of by separate code to ensure they are adjacent
5335 * to each other.
5336 * Don't swap the order unless you know what you are doing!
5337 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005338static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005339 .nr = MSM_ION_HEAP_NUM,
5340 .heaps = {
5341 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005342 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005343 .type = ION_HEAP_TYPE_SYSTEM,
5344 .name = ION_VMALLOC_HEAP_NAME,
5345 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005346#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5347 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005348 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005349 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005350 .name = ION_MM_HEAP_NAME,
5351 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005352 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005353 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005354 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005355 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005356 .id = ION_MM_FIRMWARE_HEAP_ID,
5357 .type = ION_HEAP_TYPE_CARVEOUT,
5358 .name = ION_MM_FIRMWARE_HEAP_NAME,
5359 .size = MSM_ION_MM_FW_SIZE,
5360 .memory_type = ION_SMI_TYPE,
5361 .extra_data = (void *) &fw_co_ion_pdata,
5362 },
5363 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005364 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005365 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005366 .name = ION_MFC_HEAP_NAME,
5367 .size = MSM_ION_MFC_SIZE,
5368 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005369 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005370 },
5371 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005372 .id = ION_SF_HEAP_ID,
5373 .type = ION_HEAP_TYPE_CARVEOUT,
5374 .name = ION_SF_HEAP_NAME,
5375 .size = MSM_ION_SF_SIZE,
5376 .memory_type = ION_EBI_TYPE,
5377 .extra_data = (void *)&co_ion_pdata,
5378 },
5379 {
5380 .id = ION_CAMERA_HEAP_ID,
5381 .type = ION_HEAP_TYPE_CARVEOUT,
5382 .name = ION_CAMERA_HEAP_NAME,
5383 .size = MSM_ION_CAMERA_SIZE,
5384 .memory_type = ION_EBI_TYPE,
5385 .extra_data = &co_ion_pdata,
5386 },
5387 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005388 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005389 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005390 .name = ION_WB_HEAP_NAME,
5391 .size = MSM_ION_WB_SIZE,
5392 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005393 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005394 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005395 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005396 .id = ION_QSECOM_HEAP_ID,
5397 .type = ION_HEAP_TYPE_CARVEOUT,
5398 .name = ION_QSECOM_HEAP_NAME,
5399 .size = MSM_ION_QSECOM_SIZE,
5400 .memory_type = ION_EBI_TYPE,
5401 .extra_data = (void *) &co_ion_pdata,
5402 },
5403 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005404 .id = ION_AUDIO_HEAP_ID,
5405 .type = ION_HEAP_TYPE_CARVEOUT,
5406 .name = ION_AUDIO_HEAP_NAME,
5407 .size = MSM_ION_AUDIO_SIZE,
5408 .memory_type = ION_EBI_TYPE,
5409 .extra_data = (void *)&co_ion_pdata,
5410 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005411#endif
5412 }
5413};
5414
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005415static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005416 .name = "ion-msm",
5417 .id = 1,
5418 .dev = { .platform_data = &ion_pdata },
5419};
5420#endif
5421
5422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005423static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5424 /* Kernel SMI memory pool for video core, used for firmware */
5425 /* and encoder, decoder scratch buffers */
5426 /* Kernel SMI memory pool should always precede the user space */
5427 /* SMI memory pool, as the video core will use offset address */
5428 /* from the Firmware base */
5429 [MEMTYPE_SMI_KERNEL] = {
5430 .start = KERNEL_SMI_BASE,
5431 .limit = KERNEL_SMI_SIZE,
5432 .size = KERNEL_SMI_SIZE,
5433 .flags = MEMTYPE_FLAGS_FIXED,
5434 },
5435 /* User space SMI memory pool for video core */
5436 /* used for encoder, decoder input & output buffers */
5437 [MEMTYPE_SMI] = {
5438 .start = USER_SMI_BASE,
5439 .limit = USER_SMI_SIZE,
5440 .flags = MEMTYPE_FLAGS_FIXED,
5441 },
5442 [MEMTYPE_EBI0] = {
5443 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5444 },
5445 [MEMTYPE_EBI1] = {
5446 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5447 },
5448};
5449
Stephen Boyd668d7652012-04-25 11:31:01 -07005450static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005451{
5452#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005453 unsigned int i;
5454
5455 if (hdmi_is_primary) {
5456 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5457 for (i = 0; i < ion_pdata.nr; i++) {
5458 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5459 ion_pdata.heaps[i].size = msm_ion_sf_size;
5460 pr_debug("msm_ion_sf_size 0x%x\n",
5461 msm_ion_sf_size);
5462 break;
5463 }
5464 }
5465 }
5466
Olav Haugan8726caf2012-05-10 15:11:35 -07005467 /* Verify size of heap is a multiple of 64K */
5468 for (i = 0; i < ion_pdata.nr; i++) {
5469 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5470
5471 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5472 int map_all = ((struct ion_cp_heap_pdata *)
5473 heap->extra_data)->iommu_map_all;
5474
5475 if (map_all && (heap->size & (SZ_64K-1))) {
5476 heap->size = ALIGN(heap->size, SZ_64K);
5477 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5478 heap->name, heap->size);
5479
5480 }
5481 }
5482 }
5483
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005484 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Haugan42ebe712012-01-10 16:30:58 -08005485 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005486 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5487 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5488 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5489 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005490 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005491 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005492#endif
5493}
5494
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005495static void __init size_pmem_devices(void)
5496{
5497#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005498#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005499 android_pmem_adsp_pdata.size = pmem_adsp_size;
5500 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005501
5502 if (hdmi_is_primary)
5503 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005504 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005505 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305506#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5507#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005508}
5509
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305510#ifdef CONFIG_ANDROID_PMEM
5511#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005512static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5513{
5514 msm8x60_reserve_table[p->memory_type].size += p->size;
5515}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305516#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5517#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005518
5519static void __init reserve_pmem_memory(void)
5520{
5521#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005522#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523 reserve_memory_for(&android_pmem_adsp_pdata);
5524 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005525 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005526 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305527#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005528 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305529#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005530}
5531
Huaibin Yanga5419422011-12-08 23:52:10 -08005532static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005533
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305534static void __init reserve_rtb_memory(void)
5535{
5536#if defined(CONFIG_MSM_RTB)
5537 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5538#endif
5539}
5540
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005541static void __init msm8x60_calculate_reserve_sizes(void)
5542{
5543 size_pmem_devices();
5544 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005545 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005546 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305547 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005548}
5549
5550static int msm8x60_paddr_to_memtype(unsigned int paddr)
5551{
5552 if (paddr >= 0x40000000 && paddr < 0x60000000)
5553 return MEMTYPE_EBI1;
5554 if (paddr >= 0x38000000 && paddr < 0x40000000)
5555 return MEMTYPE_SMI;
5556 return MEMTYPE_NONE;
5557}
5558
5559static struct reserve_info msm8x60_reserve_info __initdata = {
5560 .memtype_reserve_table = msm8x60_reserve_table,
5561 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5562 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5563};
5564
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005565static char prim_panel_name[PANEL_NAME_MAX_LEN];
5566static char ext_panel_name[PANEL_NAME_MAX_LEN];
5567static int __init prim_display_setup(char *param)
5568{
5569 if (strnlen(param, PANEL_NAME_MAX_LEN))
5570 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5571 return 0;
5572}
5573early_param("prim_display", prim_display_setup);
5574
5575static int __init ext_display_setup(char *param)
5576{
5577 if (strnlen(param, PANEL_NAME_MAX_LEN))
5578 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5579 return 0;
5580}
5581early_param("ext_display", ext_display_setup);
5582
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005583static void __init msm8x60_reserve(void)
5584{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005585 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005586 reserve_info = &msm8x60_reserve_info;
5587 msm_reserve();
5588}
5589
5590#define EXT_CHG_VALID_MPP 10
5591#define EXT_CHG_VALID_MPP_2 11
5592
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305593static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305594 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305595 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305596 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305597 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5598};
5599
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005600#ifdef CONFIG_ISL9519_CHARGER
5601static int isl_detection_setup(void)
5602{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305603 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305605 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5606 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5607 &isl_mpp[i].config);
5608 if (ret) {
5609 pr_err("%s: Config MPP %d of PM8058 failed\n",
5610 __func__, isl_mpp[i].mpp);
5611 return ret;
5612 }
5613 }
5614
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005615 return ret;
5616}
5617
5618static struct isl_platform_data isl_data __initdata = {
5619 .chgcurrent = 700,
5620 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5621 .chg_detection_config = isl_detection_setup,
5622 .max_system_voltage = 4200,
5623 .min_system_voltage = 3200,
5624 .term_current = 120,
5625 .input_current = 2048,
5626};
5627
5628static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5629 {
5630 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305631 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005632 .platform_data = &isl_data,
5633 },
5634};
5635#endif
5636
5637#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5638static int smb137b_detection_setup(void)
5639{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305640 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005641
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305642 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5643 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5644 &isl_mpp[i].config);
5645 if (ret) {
5646 pr_err("%s: Config MPP %d of PM8058 failed\n",
5647 __func__, isl_mpp[i].mpp);
5648 return ret;
5649 }
5650 }
5651
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005652 return ret;
5653}
5654
5655static struct smb137b_platform_data smb137b_data __initdata = {
5656 .chg_detection_config = smb137b_detection_setup,
5657 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5658 .batt_mah_rating = 950,
5659};
5660
5661static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5662 {
5663 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305664 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005665 .platform_data = &smb137b_data,
5666 },
5667};
5668#endif
5669
5670#ifdef CONFIG_PMIC8058
5671#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305672#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005673
5674static int pm8058_gpios_init(void)
5675{
5676 int i;
5677 int rc;
5678 struct pm8058_gpio_cfg {
5679 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305680 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005681 };
5682
5683 struct pm8058_gpio_cfg gpio_cfgs[] = {
5684 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305685 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005686 {
5687 .direction = PM_GPIO_DIR_IN,
5688 .pull = PM_GPIO_PULL_DN,
5689 .vin_sel = 2,
5690 .function = PM_GPIO_FUNC_NORMAL,
5691 .inv_int_pol = 0,
5692 },
5693 },
5694#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5695 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305696 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005697 {
5698 .direction = PM_GPIO_DIR_IN,
5699 .pull = PM_GPIO_PULL_UP_30,
5700 .vin_sel = 2,
5701 .function = PM_GPIO_FUNC_NORMAL,
5702 .inv_int_pol = 0,
5703 },
5704 },
5705#endif
5706 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305707 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005708 {
5709 .direction = PM_GPIO_DIR_IN,
5710 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305711 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005712 .function = PM_GPIO_FUNC_NORMAL,
5713 .inv_int_pol = 0,
5714 },
5715 },
5716 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305717 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005718 {
5719 .direction = PM_GPIO_DIR_IN,
5720 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305721 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005722 .function = PM_GPIO_FUNC_NORMAL,
5723 .inv_int_pol = 0,
5724 },
5725 },
5726 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305727 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005728 {
5729 .direction = PM_GPIO_DIR_IN,
5730 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305731 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005732 .function = PM_GPIO_FUNC_NORMAL,
5733 .inv_int_pol = 0,
5734 },
5735 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005736 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305737 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005738 {
5739 .direction = PM_GPIO_DIR_OUT,
5740 .output_value = 1,
5741 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5742 .pull = PM_GPIO_PULL_DN,
5743 .out_strength = PM_GPIO_STRENGTH_HIGH,
5744 .function = PM_GPIO_FUNC_NORMAL,
5745 .vin_sel = 2,
5746 .inv_int_pol = 0,
5747 }
5748 },
5749 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305750 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005751 {
5752 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305753 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005754 .function = PM_GPIO_FUNC_NORMAL,
5755 .vin_sel = 2,
5756 .inv_int_pol = 0,
5757 }
5758 },
5759 };
5760
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305761#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5762 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305763 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305764 .direction = PM_GPIO_DIR_IN,
5765 .pull = PM_GPIO_PULL_UP_1P5,
5766 .vin_sel = 2,
5767 .function = PM_GPIO_FUNC_NORMAL,
5768 };
5769#endif
5770
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005771#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305772 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305773 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305774 .direction = PM_GPIO_DIR_OUT,
5775 .pull = PM_GPIO_PULL_NO,
5776 .out_strength = PM_GPIO_STRENGTH_HIGH,
5777 .function = PM_GPIO_FUNC_NORMAL,
5778 .inv_int_pol = 0,
5779 .vin_sel = 2,
5780 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5781 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005782 };
5783#endif
5784
5785#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5786 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305787 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788 {
5789 .direction = PM_GPIO_DIR_IN,
5790 .pull = PM_GPIO_PULL_UP_1P5,
5791 .vin_sel = 2,
5792 .function = PM_GPIO_FUNC_NORMAL,
5793 .inv_int_pol = 0,
5794 }
5795 };
5796#endif
5797
5798#if defined(CONFIG_QS_S5K4E1)
5799 {
5800 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305801 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005802 {
5803 .direction = PM_GPIO_DIR_OUT,
5804 .output_value = 0,
5805 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5806 .pull = PM_GPIO_PULL_DN,
5807 .out_strength = PM_GPIO_STRENGTH_HIGH,
5808 .function = PM_GPIO_FUNC_NORMAL,
5809 .vin_sel = 2,
5810 .inv_int_pol = 0,
5811 }
5812 };
5813#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005814#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5815 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305816 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005817 {
5818 .direction = PM_GPIO_DIR_OUT,
5819 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5820 .output_value = 1,
5821 .pull = PM_GPIO_PULL_UP_30,
5822 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305823 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005824 .out_strength = PM_GPIO_STRENGTH_HIGH,
5825 .function = PM_GPIO_FUNC_NORMAL,
5826 .inv_int_pol = 0,
5827 }
5828 };
5829#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005830#if defined(CONFIG_HAPTIC_ISA1200) || \
5831 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5832 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305833 rc = pm8xxx_gpio_config(
5834 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5835 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005836 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305837 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005838 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305839 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305840 rc = pm8xxx_gpio_config(
5841 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5842 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305843 if (rc < 0) {
5844 pr_err("%s: pmic haptics ldo gpio config failed\n",
5845 __func__);
5846 }
5847
5848 }
5849#endif
5850
5851#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5852 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5853 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5854 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305855 rc = pm8xxx_gpio_config(
5856 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5857 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305858 if (rc < 0) {
5859 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5860 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005861 }
5862 }
5863#endif
5864
5865#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5866 /* Line_in only for 8660 ffa & surf */
5867 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005868 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005869 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305870 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005871 &line_in_gpio_cfg.cfg);
5872 if (rc < 0) {
5873 pr_err("%s pmic line_in gpio config failed\n",
5874 __func__);
5875 return rc;
5876 }
5877 }
5878#endif
5879
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005880#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5881 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305882 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005883 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5884 if (rc < 0) {
5885 pr_err("%s pmic gpio config failed\n", __func__);
5886 return rc;
5887 }
5888 }
5889#endif
5890
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005891#if defined(CONFIG_QS_S5K4E1)
5892 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5893 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305894 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005895 &qs_hc37_cam_pd_gpio_cfg.cfg);
5896 if (rc < 0) {
5897 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5898 __func__);
5899 return rc;
5900 }
5901 }
5902 }
5903#endif
5904
5905 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305906 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005907 &gpio_cfgs[i].cfg);
5908 if (rc < 0) {
5909 pr_err("%s pmic gpio config failed\n",
5910 __func__);
5911 return rc;
5912 }
5913 }
5914
5915 return 0;
5916}
5917
5918static const unsigned int ffa_keymap[] = {
5919 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5920 KEY(0, 1, KEY_UP), /* NAV - UP */
5921 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5922 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5923
5924 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5925 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5926 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5927 KEY(1, 3, KEY_VOLUMEDOWN),
5928
5929 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5930
5931 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5932 KEY(4, 1, KEY_UP), /* USER_UP */
5933 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5934 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5935 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5936
5937 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5938 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5939 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5940 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5941 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5942};
5943
Zhang Chang Ken683be172011-08-10 17:45:34 -04005944static const unsigned int dragon_keymap[] = {
5945 KEY(0, 0, KEY_MENU),
5946 KEY(0, 2, KEY_1),
5947 KEY(0, 3, KEY_4),
5948 KEY(0, 4, KEY_7),
5949
5950 KEY(1, 0, KEY_UP),
5951 KEY(1, 1, KEY_LEFT),
5952 KEY(1, 2, KEY_DOWN),
5953 KEY(1, 3, KEY_5),
5954 KEY(1, 4, KEY_8),
5955
5956 KEY(2, 0, KEY_HOME),
5957 KEY(2, 1, KEY_REPLY),
5958 KEY(2, 2, KEY_2),
5959 KEY(2, 3, KEY_6),
5960 KEY(2, 4, KEY_0),
5961
5962 KEY(3, 0, KEY_VOLUMEUP),
5963 KEY(3, 1, KEY_RIGHT),
5964 KEY(3, 2, KEY_3),
5965 KEY(3, 3, KEY_9),
5966 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5967
5968 KEY(4, 0, KEY_VOLUMEDOWN),
5969 KEY(4, 1, KEY_BACK),
5970 KEY(4, 2, KEY_CAMERA),
5971 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5972};
5973
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005974static struct matrix_keymap_data ffa_keymap_data = {
5975 .keymap_size = ARRAY_SIZE(ffa_keymap),
5976 .keymap = ffa_keymap,
5977};
5978
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305979static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 .input_name = "ffa-keypad",
5981 .input_phys_device = "ffa-keypad/input0",
5982 .num_rows = 6,
5983 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305984 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5985 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5986 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005987 .scan_delay_ms = 32,
5988 .row_hold_ns = 91500,
5989 .wakeup = 1,
5990 .keymap_data = &ffa_keymap_data,
5991};
5992
Zhang Chang Ken683be172011-08-10 17:45:34 -04005993static struct matrix_keymap_data dragon_keymap_data = {
5994 .keymap_size = ARRAY_SIZE(dragon_keymap),
5995 .keymap = dragon_keymap,
5996};
5997
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305998static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005999 .input_name = "dragon-keypad",
6000 .input_phys_device = "dragon-keypad/input0",
6001 .num_rows = 6,
6002 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306003 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6004 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6005 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006006 .scan_delay_ms = 32,
6007 .row_hold_ns = 91500,
6008 .wakeup = 1,
6009 .keymap_data = &dragon_keymap_data,
6010};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306011
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006012static const unsigned int fluid_keymap[] = {
6013 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6014 KEY(0, 1, KEY_UP), /* NAV - UP */
6015 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6016 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6017
6018 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6019 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6020 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6021 KEY(1, 3, KEY_VOLUMEUP),
6022
6023 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6024
6025 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6026 KEY(4, 1, KEY_UP), /* USER_UP */
6027 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6028 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6029 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6030
Jilai Wang9a895102011-07-12 14:00:35 -04006031 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006032 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6033 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6034 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6035 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6036};
6037
6038static struct matrix_keymap_data fluid_keymap_data = {
6039 .keymap_size = ARRAY_SIZE(fluid_keymap),
6040 .keymap = fluid_keymap,
6041};
6042
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306043static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006044 .input_name = "fluid-keypad",
6045 .input_phys_device = "fluid-keypad/input0",
6046 .num_rows = 6,
6047 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306048 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6049 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6050 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006051 .scan_delay_ms = 32,
6052 .row_hold_ns = 91500,
6053 .wakeup = 1,
6054 .keymap_data = &fluid_keymap_data,
6055};
6056
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306057static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006058 .initial_vibrate_ms = 500,
6059 .level_mV = 3000,
6060 .max_timeout_ms = 15000,
6061};
6062
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306063static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6064 .rtc_write_enable = false,
6065 .rtc_alarm_powerup = false,
6066};
6067
6068static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6069 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006070 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306071 .wakeup = 1,
6072};
6073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006074#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6075
6076static struct othc_accessory_info othc_accessories[] = {
6077 {
6078 .accessory = OTHC_SVIDEO_OUT,
6079 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6080 | OTHC_ADC_DETECT,
6081 .key_code = SW_VIDEOOUT_INSERT,
6082 .enabled = false,
6083 .adc_thres = {
6084 .min_threshold = 20,
6085 .max_threshold = 40,
6086 },
6087 },
6088 {
6089 .accessory = OTHC_ANC_HEADPHONE,
6090 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6091 OTHC_SWITCH_DETECT,
6092 .gpio = PM8058_LINE_IN_DET_GPIO,
6093 .active_low = 1,
6094 .key_code = SW_HEADPHONE_INSERT,
6095 .enabled = true,
6096 },
6097 {
6098 .accessory = OTHC_ANC_HEADSET,
6099 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6100 .gpio = PM8058_LINE_IN_DET_GPIO,
6101 .active_low = 1,
6102 .key_code = SW_HEADPHONE_INSERT,
6103 .enabled = true,
6104 },
6105 {
6106 .accessory = OTHC_HEADPHONE,
6107 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6108 .key_code = SW_HEADPHONE_INSERT,
6109 .enabled = true,
6110 },
6111 {
6112 .accessory = OTHC_MICROPHONE,
6113 .detect_flags = OTHC_GPIO_DETECT,
6114 .gpio = PM8058_LINE_IN_DET_GPIO,
6115 .active_low = 1,
6116 .key_code = SW_MICROPHONE_INSERT,
6117 .enabled = true,
6118 },
6119 {
6120 .accessory = OTHC_HEADSET,
6121 .detect_flags = OTHC_MICBIAS_DETECT,
6122 .key_code = SW_HEADPHONE_INSERT,
6123 .enabled = true,
6124 },
6125};
6126
6127static struct othc_switch_info switch_info[] = {
6128 {
6129 .min_adc_threshold = 0,
6130 .max_adc_threshold = 100,
6131 .key_code = KEY_PLAYPAUSE,
6132 },
6133 {
6134 .min_adc_threshold = 100,
6135 .max_adc_threshold = 200,
6136 .key_code = KEY_REWIND,
6137 },
6138 {
6139 .min_adc_threshold = 200,
6140 .max_adc_threshold = 500,
6141 .key_code = KEY_FASTFORWARD,
6142 },
6143};
6144
6145static struct othc_n_switch_config switch_config = {
6146 .voltage_settling_time_ms = 0,
6147 .num_adc_samples = 3,
6148 .adc_channel = CHANNEL_ADC_HDSET,
6149 .switch_info = switch_info,
6150 .num_keys = ARRAY_SIZE(switch_info),
6151 .default_sw_en = true,
6152 .default_sw_idx = 0,
6153};
6154
6155static struct hsed_bias_config hsed_bias_config = {
6156 /* HSED mic bias config info */
6157 .othc_headset = OTHC_HEADSET_NO,
6158 .othc_lowcurr_thresh_uA = 100,
6159 .othc_highcurr_thresh_uA = 600,
6160 .othc_hyst_prediv_us = 7800,
6161 .othc_period_clkdiv_us = 62500,
6162 .othc_hyst_clk_us = 121000,
6163 .othc_period_clk_us = 312500,
6164 .othc_wakeup = 1,
6165};
6166
6167static struct othc_hsed_config hsed_config_1 = {
6168 .hsed_bias_config = &hsed_bias_config,
6169 /*
6170 * The detection delay and switch reporting delay are
6171 * required to encounter a hardware bug (spurious switch
6172 * interrupts on slow insertion/removal of the headset).
6173 * This will introduce a delay in reporting the accessory
6174 * insertion and removal to the userspace.
6175 */
6176 .detection_delay_ms = 1500,
6177 /* Switch info */
6178 .switch_debounce_ms = 1500,
6179 .othc_support_n_switch = false,
6180 .switch_config = &switch_config,
6181 .ir_gpio = -1,
6182 /* Accessory info */
6183 .accessories_support = true,
6184 .accessories = othc_accessories,
6185 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6186};
6187
6188static struct othc_regulator_config othc_reg = {
6189 .regulator = "8058_l5",
6190 .max_uV = 2850000,
6191 .min_uV = 2850000,
6192};
6193
6194/* MIC_BIAS0 is configured as normal MIC BIAS */
6195static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6196 .micbias_select = OTHC_MICBIAS_0,
6197 .micbias_capability = OTHC_MICBIAS,
6198 .micbias_enable = OTHC_SIGNAL_OFF,
6199 .micbias_regulator = &othc_reg,
6200};
6201
6202/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6203static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6204 .micbias_select = OTHC_MICBIAS_1,
6205 .micbias_capability = OTHC_MICBIAS_HSED,
6206 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6207 .micbias_regulator = &othc_reg,
6208 .hsed_config = &hsed_config_1,
6209 .hsed_name = "8660_handset",
6210};
6211
6212/* MIC_BIAS2 is configured as normal MIC BIAS */
6213static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6214 .micbias_select = OTHC_MICBIAS_2,
6215 .micbias_capability = OTHC_MICBIAS,
6216 .micbias_enable = OTHC_SIGNAL_OFF,
6217 .micbias_regulator = &othc_reg,
6218};
6219
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006220
6221static void __init msm8x60_init_pm8058_othc(void)
6222{
6223 int i;
6224
6225 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6226 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6227 machine_is_msm8x60_fusn_ffa()) {
6228 /* 3-switch headset supported only by V2 FFA and FLUID */
6229 hsed_config_1.accessories_adc_support = true,
6230 /* ADC based accessory detection works only on V2 and FLUID */
6231 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6232 hsed_config_1.othc_support_n_switch = true;
6233 }
6234
6235 /* IR GPIO is absent on FLUID */
6236 if (machine_is_msm8x60_fluid())
6237 hsed_config_1.ir_gpio = -1;
6238
6239 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6240 if (machine_is_msm8x60_fluid()) {
6241 switch (othc_accessories[i].accessory) {
6242 case OTHC_ANC_HEADPHONE:
6243 case OTHC_ANC_HEADSET:
6244 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6245 break;
6246 case OTHC_MICROPHONE:
6247 othc_accessories[i].enabled = false;
6248 break;
6249 case OTHC_SVIDEO_OUT:
6250 othc_accessories[i].enabled = true;
6251 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6252 break;
6253 }
6254 }
6255 }
6256}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006257
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006258
6259static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6260{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306261 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006262 .direction = PM_GPIO_DIR_OUT,
6263 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6264 .output_value = 0,
6265 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306266 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006267 .out_strength = PM_GPIO_STRENGTH_HIGH,
6268 .function = PM_GPIO_FUNC_2,
6269 };
6270
6271 int rc = -EINVAL;
6272 int id, mode, max_mA;
6273
6274 id = mode = max_mA = 0;
6275 switch (ch) {
6276 case 0:
6277 case 1:
6278 case 2:
6279 if (on) {
6280 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306281 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6282 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006283 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306284 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006285 __func__, id, rc);
6286 }
6287 break;
6288
6289 case 6:
6290 id = PM_PWM_LED_FLASH;
6291 mode = PM_PWM_CONF_PWM1;
6292 max_mA = 300;
6293 break;
6294
6295 case 7:
6296 id = PM_PWM_LED_FLASH1;
6297 mode = PM_PWM_CONF_PWM1;
6298 max_mA = 300;
6299 break;
6300
6301 default:
6302 break;
6303 }
6304
6305 if (ch >= 6 && ch <= 7) {
6306 if (!on) {
6307 mode = PM_PWM_CONF_NONE;
6308 max_mA = 0;
6309 }
6310 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6311 if (rc)
6312 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6313 __func__, ch, rc);
6314 }
6315 return rc;
6316
6317}
6318
6319static struct pm8058_pwm_pdata pm8058_pwm_data = {
6320 .config = pm8058_pwm_config,
6321};
6322
6323#define PM8058_GPIO_INT 88
6324
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006325static struct pmic8058_led pmic8058_flash_leds[] = {
6326 [0] = {
6327 .name = "camera:flash0",
6328 .max_brightness = 15,
6329 .id = PMIC8058_ID_FLASH_LED_0,
6330 },
6331 [1] = {
6332 .name = "camera:flash1",
6333 .max_brightness = 15,
6334 .id = PMIC8058_ID_FLASH_LED_1,
6335 },
6336};
6337
6338static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6339 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6340 .leds = pmic8058_flash_leds,
6341};
6342
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006343static struct pmic8058_led pmic8058_dragon_leds[] = {
6344 [0] = {
6345 /* RED */
6346 .name = "led_drv0",
6347 .max_brightness = 15,
6348 .id = PMIC8058_ID_LED_0,
6349 },/* 300 mA flash led0 drv sink */
6350 [1] = {
6351 /* Yellow */
6352 .name = "led_drv1",
6353 .max_brightness = 15,
6354 .id = PMIC8058_ID_LED_1,
6355 },/* 300 mA flash led0 drv sink */
6356 [2] = {
6357 /* Green */
6358 .name = "led_drv2",
6359 .max_brightness = 15,
6360 .id = PMIC8058_ID_LED_2,
6361 },/* 300 mA flash led0 drv sink */
6362 [3] = {
6363 .name = "led_psensor",
6364 .max_brightness = 15,
6365 .id = PMIC8058_ID_LED_KB_LIGHT,
6366 },/* 300 mA flash led0 drv sink */
6367};
6368
6369static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6370 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6371 .leds = pmic8058_dragon_leds,
6372};
6373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006374static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6375 [0] = {
6376 .name = "led:drv0",
6377 .max_brightness = 15,
6378 .id = PMIC8058_ID_FLASH_LED_0,
6379 },/* 300 mA flash led0 drv sink */
6380 [1] = {
6381 .name = "led:drv1",
6382 .max_brightness = 15,
6383 .id = PMIC8058_ID_FLASH_LED_1,
6384 },/* 300 mA flash led1 sink */
6385 [2] = {
6386 .name = "led:drv2",
6387 .max_brightness = 20,
6388 .id = PMIC8058_ID_LED_0,
6389 },/* 40 mA led0 sink */
6390 [3] = {
6391 .name = "keypad:drv",
6392 .max_brightness = 15,
6393 .id = PMIC8058_ID_LED_KB_LIGHT,
6394 },/* 300 mA keypad drv sink */
6395};
6396
6397static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6398 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6399 .leds = pmic8058_fluid_flash_leds,
6400};
6401
Terence Hampson90508a92011-08-09 10:40:08 -04006402static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306403 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006404 .max_source_current = 1800,
6405 .charger_type = CHG_TYPE_AC,
6406};
6407
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306408static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6409 .charger_data_valid = false,
6410};
6411
6412static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6413 .priority = 0,
6414};
6415
6416static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6417 .irq_base = PM8058_IRQ_BASE,
6418 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6419 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6420};
6421
6422static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6423 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6424};
6425
6426static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6427 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006428};
6429
6430static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306431 .irq_pdata = &pm8058_irq_pdata,
6432 .gpio_pdata = &pm8058_gpio_pdata,
6433 .mpp_pdata = &pm8058_mpp_pdata,
6434 .rtc_pdata = &pm8058_rtc_pdata,
6435 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6436 .othc0_pdata = &othc_config_pdata_0,
6437 .othc1_pdata = &othc_config_pdata_1,
6438 .othc2_pdata = &othc_config_pdata_2,
6439 .pwm_pdata = &pm8058_pwm_data,
6440 .misc_pdata = &pm8058_misc_pdata,
6441#ifdef CONFIG_SENSORS_MSM_ADC
6442 .xoadc_pdata = &pm8058_xoadc_pdata,
6443#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006444};
6445
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306446#ifdef CONFIG_MSM_SSBI
6447static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6448 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6449 .slave = {
6450 .name = "pm8058-core",
6451 .platform_data = &pm8058_platform_data,
6452 },
6453};
6454#endif
6455#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006456
6457#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6458 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6459#define TDISC_I2C_SLAVE_ADDR 0x67
6460#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6461#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6462
6463static const char *vregs_tdisc_name[] = {
6464 "8058_l5",
6465 "8058_s3",
6466};
6467
6468static const int vregs_tdisc_val[] = {
6469 2850000,/* uV */
6470 1800000,
6471};
6472static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6473
6474static int tdisc_shinetsu_setup(void)
6475{
6476 int rc, i;
6477
6478 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6479 if (rc) {
6480 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6481 __func__);
6482 return rc;
6483 }
6484
6485 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6486 if (rc) {
6487 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6488 __func__);
6489 goto fail_gpio_oe;
6490 }
6491
6492 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6493 if (rc) {
6494 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6495 __func__);
6496 gpio_free(GPIO_JOYSTICK_EN);
6497 goto fail_gpio_oe;
6498 }
6499
6500 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6501 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6502 if (IS_ERR(vregs_tdisc[i])) {
6503 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6504 __func__, vregs_tdisc_name[i],
6505 PTR_ERR(vregs_tdisc[i]));
6506 rc = PTR_ERR(vregs_tdisc[i]);
6507 goto vreg_get_fail;
6508 }
6509
6510 rc = regulator_set_voltage(vregs_tdisc[i],
6511 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6512 if (rc) {
6513 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6514 __func__, rc);
6515 goto vreg_set_voltage_fail;
6516 }
6517 }
6518
6519 return rc;
6520vreg_set_voltage_fail:
6521 i++;
6522vreg_get_fail:
6523 while (i)
6524 regulator_put(vregs_tdisc[--i]);
6525fail_gpio_oe:
6526 gpio_free(PMIC_GPIO_TDISC);
6527 return rc;
6528}
6529
6530static void tdisc_shinetsu_release(void)
6531{
6532 int i;
6533
6534 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6535 regulator_put(vregs_tdisc[i]);
6536
6537 gpio_free(PMIC_GPIO_TDISC);
6538 gpio_free(GPIO_JOYSTICK_EN);
6539}
6540
6541static int tdisc_shinetsu_enable(void)
6542{
6543 int i, rc = -EINVAL;
6544
6545 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6546 rc = regulator_enable(vregs_tdisc[i]);
6547 if (rc < 0) {
6548 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6549 __func__, vregs_tdisc_name[i], rc);
6550 goto vreg_fail;
6551 }
6552 }
6553
6554 /* Enable the OE (output enable) gpio */
6555 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6556 /* voltage and gpio stabilization delay */
6557 msleep(50);
6558
6559 return 0;
6560vreg_fail:
6561 while (i)
6562 regulator_disable(vregs_tdisc[--i]);
6563 return rc;
6564}
6565
6566static int tdisc_shinetsu_disable(void)
6567{
6568 int i, rc;
6569
6570 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6571 rc = regulator_disable(vregs_tdisc[i]);
6572 if (rc < 0) {
6573 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6574 __func__, vregs_tdisc_name[i], rc);
6575 goto tdisc_reg_fail;
6576 }
6577 }
6578
6579 /* Disable the OE (output enable) gpio */
6580 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6581
6582 return 0;
6583
6584tdisc_reg_fail:
6585 while (i)
6586 regulator_enable(vregs_tdisc[--i]);
6587 return rc;
6588}
6589
6590static struct tdisc_abs_values tdisc_abs = {
6591 .x_max = 32,
6592 .y_max = 32,
6593 .x_min = -32,
6594 .y_min = -32,
6595 .pressure_max = 32,
6596 .pressure_min = 0,
6597};
6598
6599static struct tdisc_platform_data tdisc_data = {
6600 .tdisc_setup = tdisc_shinetsu_setup,
6601 .tdisc_release = tdisc_shinetsu_release,
6602 .tdisc_enable = tdisc_shinetsu_enable,
6603 .tdisc_disable = tdisc_shinetsu_disable,
6604 .tdisc_wakeup = 0,
6605 .tdisc_gpio = PMIC_GPIO_TDISC,
6606 .tdisc_report_keys = true,
6607 .tdisc_report_relative = true,
6608 .tdisc_report_absolute = false,
6609 .tdisc_report_wheel = false,
6610 .tdisc_reverse_x = false,
6611 .tdisc_reverse_y = true,
6612 .tdisc_abs = &tdisc_abs,
6613};
6614
6615static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6616 {
6617 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6618 .irq = TDISC_INT,
6619 .platform_data = &tdisc_data,
6620 },
6621};
6622#endif
6623
6624#define PM_GPIO_CDC_RST_N 20
6625#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6626
6627static struct regulator *vreg_timpani_1;
6628static struct regulator *vreg_timpani_2;
6629
6630static unsigned int msm_timpani_setup_power(void)
6631{
6632 int rc;
6633
6634 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6635 if (IS_ERR(vreg_timpani_1)) {
6636 pr_err("%s: Unable to get 8058_l0\n", __func__);
6637 return -ENODEV;
6638 }
6639
6640 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6641 if (IS_ERR(vreg_timpani_2)) {
6642 pr_err("%s: Unable to get 8058_s3\n", __func__);
6643 regulator_put(vreg_timpani_1);
6644 return -ENODEV;
6645 }
6646
6647 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6648 if (rc) {
6649 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6650 goto fail;
6651 }
6652
6653 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6654 if (rc) {
6655 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6656 goto fail;
6657 }
6658
6659 rc = regulator_enable(vreg_timpani_1);
6660 if (rc) {
6661 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6662 goto fail;
6663 }
6664
6665 /* The settings for LDO0 should be set such that
6666 * it doesn't require to reset the timpani. */
6667 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6668 if (rc < 0) {
6669 pr_err("Timpani regulator optimum mode setting failed\n");
6670 goto fail;
6671 }
6672
6673 rc = regulator_enable(vreg_timpani_2);
6674 if (rc) {
6675 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6676 regulator_disable(vreg_timpani_1);
6677 goto fail;
6678 }
6679
6680 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6681 if (rc) {
6682 pr_err("%s: GPIO Request %d failed\n", __func__,
6683 GPIO_CDC_RST_N);
6684 regulator_disable(vreg_timpani_1);
6685 regulator_disable(vreg_timpani_2);
6686 goto fail;
6687 } else {
6688 gpio_direction_output(GPIO_CDC_RST_N, 1);
6689 usleep_range(1000, 1050);
6690 gpio_direction_output(GPIO_CDC_RST_N, 0);
6691 usleep_range(1000, 1050);
6692 gpio_direction_output(GPIO_CDC_RST_N, 1);
6693 gpio_free(GPIO_CDC_RST_N);
6694 }
6695 return rc;
6696
6697fail:
6698 regulator_put(vreg_timpani_1);
6699 regulator_put(vreg_timpani_2);
6700 return rc;
6701}
6702
6703static void msm_timpani_shutdown_power(void)
6704{
6705 int rc;
6706
6707 rc = regulator_disable(vreg_timpani_1);
6708 if (rc)
6709 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6710
6711 regulator_put(vreg_timpani_1);
6712
6713 rc = regulator_disable(vreg_timpani_2);
6714 if (rc)
6715 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6716
6717 regulator_put(vreg_timpani_2);
6718}
6719
6720/* Power analog function of codec */
6721static struct regulator *vreg_timpani_cdc_apwr;
6722static int msm_timpani_codec_power(int vreg_on)
6723{
6724 int rc = 0;
6725
6726 if (!vreg_timpani_cdc_apwr) {
6727
6728 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6729
6730 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6731 pr_err("%s: vreg_get failed (%ld)\n",
6732 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6733 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6734 return rc;
6735 }
6736 }
6737
6738 if (vreg_on) {
6739
6740 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6741 2200000, 2200000);
6742 if (rc) {
6743 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6744 __func__);
6745 goto vreg_fail;
6746 }
6747
6748 rc = regulator_enable(vreg_timpani_cdc_apwr);
6749 if (rc) {
6750 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6751 goto vreg_fail;
6752 }
6753 } else {
6754 rc = regulator_disable(vreg_timpani_cdc_apwr);
6755 if (rc) {
6756 pr_err("%s: vreg_disable failed %d\n",
6757 __func__, rc);
6758 goto vreg_fail;
6759 }
6760 }
6761
6762 return 0;
6763
6764vreg_fail:
6765 regulator_put(vreg_timpani_cdc_apwr);
6766 vreg_timpani_cdc_apwr = NULL;
6767 return rc;
6768}
6769
6770static struct marimba_codec_platform_data timpani_codec_pdata = {
6771 .marimba_codec_power = msm_timpani_codec_power,
6772};
6773
6774#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6775#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6776
6777static struct marimba_platform_data timpani_pdata = {
6778 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6779 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6780 .marimba_setup = msm_timpani_setup_power,
6781 .marimba_shutdown = msm_timpani_shutdown_power,
6782 .codec = &timpani_codec_pdata,
6783 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6784};
6785
6786#define TIMPANI_I2C_SLAVE_ADDR 0xD
6787
6788static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6789 {
6790 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6791 .platform_data = &timpani_pdata,
6792 },
6793};
6794
Lei Zhou338cab82011-08-19 13:38:17 -04006795#ifdef CONFIG_SND_SOC_WM8903
6796static struct wm8903_platform_data wm8903_pdata = {
6797 .gpio_cfg[2] = 0x3A8,
6798};
6799
6800#define WM8903_I2C_SLAVE_ADDR 0x34
6801static struct i2c_board_info wm8903_codec_i2c_info[] = {
6802 {
6803 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6804 .platform_data = &wm8903_pdata,
6805 },
6806};
6807#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006808#ifdef CONFIG_PMIC8901
6809
6810#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006811/*
6812 * Consumer specific regulator names:
6813 * regulator name consumer dev_name
6814 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006815static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6816 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6817};
6818static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6819 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6820};
6821
6822#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306823 _always_on) \
6824 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006825 .init_data = { \
6826 .constraints = { \
6827 .valid_modes_mask = _modes, \
6828 .valid_ops_mask = _ops, \
6829 .min_uV = _min_uV, \
6830 .max_uV = _max_uV, \
6831 .input_uV = _min_uV, \
6832 .apply_uV = _apply_uV, \
6833 .always_on = _always_on, \
6834 }, \
6835 .consumer_supplies = vreg_consumers_8901_##_id, \
6836 .num_consumer_supplies = \
6837 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6838 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306839 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006840 }
6841
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006842#define PM8901_VREG_INIT_VS(_id) \
6843 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306844 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006845
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306846static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006847 PM8901_VREG_INIT_VS(USB_OTG),
6848 PM8901_VREG_INIT_VS(HDMI_MVS),
6849};
6850
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306851static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6852 .priority = 1,
6853};
6854
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306855static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6856 .irq_base = PM8901_IRQ_BASE,
6857 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6858 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6859};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006860
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306861static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6862 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006863};
6864
6865static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306866 .irq_pdata = &pm8901_irq_pdata,
6867 .mpp_pdata = &pm8901_mpp_pdata,
6868 .regulator_pdatas = pm8901_vreg_init,
6869 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306870 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006871};
6872
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306873static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6874 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6875 .slave = {
6876 .name = "pm8901-core",
6877 .platform_data = &pm8901_platform_data,
6878 },
6879};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006880#endif /* CONFIG_PMIC8901 */
6881
6882#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6883 || defined(CONFIG_GPIO_SX150X_MODULE))
6884
6885static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006886static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006887
6888struct bahama_config_register{
6889 u8 reg;
6890 u8 value;
6891 u8 mask;
6892};
6893
6894enum version{
6895 VER_1_0,
6896 VER_2_0,
6897 VER_UNSUPPORTED = 0xFF
6898};
6899
6900static u8 read_bahama_ver(void)
6901{
6902 int rc;
6903 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6904 u8 bahama_version;
6905
6906 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6907 if (rc < 0) {
6908 printk(KERN_ERR
6909 "%s: version read failed: %d\n",
6910 __func__, rc);
6911 return VER_UNSUPPORTED;
6912 } else {
6913 printk(KERN_INFO
6914 "%s: version read got: 0x%x\n",
6915 __func__, bahama_version);
6916 }
6917
6918 switch (bahama_version) {
6919 case 0x08: /* varient of bahama v1 */
6920 case 0x10:
6921 case 0x00:
6922 return VER_1_0;
6923 case 0x09: /* variant of bahama v2 */
6924 return VER_2_0;
6925 default:
6926 return VER_UNSUPPORTED;
6927 }
6928}
6929
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006930static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006931static unsigned int msm_bahama_setup_power(void)
6932{
6933 int rc = 0;
6934 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006935
6936 if (machine_is_msm8x60_dragon())
6937 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6938
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006939 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6940
6941 if (IS_ERR(vreg_bahama)) {
6942 rc = PTR_ERR(vreg_bahama);
6943 pr_err("%s: regulator_get %s = %d\n", __func__,
6944 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006945 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006946 }
6947
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006948 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6949 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006950 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6951 msm_bahama_regulator, rc);
6952 goto unget;
6953 }
6954
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006955 rc = regulator_enable(vreg_bahama);
6956 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 pr_err("%s: regulator_enable %s = %d\n", __func__,
6958 msm_bahama_regulator, rc);
6959 goto unget;
6960 }
6961
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006962 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6963 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006964 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006965 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006966 goto unenable;
6967 }
6968
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006969 gpio_direction_output(msm_bahama_sys_rst, 0);
6970 usleep_range(1000, 1050);
6971 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6972 usleep_range(1000, 1050);
6973 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006974 return rc;
6975
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006976unenable:
6977 regulator_disable(vreg_bahama);
6978unget:
6979 regulator_put(vreg_bahama);
6980 return rc;
6981};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006982
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006983static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006985 if (msm_bahama_setup_power_enable) {
6986 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6987 gpio_free(msm_bahama_sys_rst);
6988 regulator_disable(vreg_bahama);
6989 regulator_put(vreg_bahama);
6990 msm_bahama_setup_power_enable = 0;
6991 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006992
6993 return 0;
6994};
6995
6996static unsigned int msm_bahama_core_config(int type)
6997{
6998 int rc = 0;
6999
7000 if (type == BAHAMA_ID) {
7001
7002 int i;
7003 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7004
7005 const struct bahama_config_register v20_init[] = {
7006 /* reg, value, mask */
7007 { 0xF4, 0x84, 0xFF }, /* AREG */
7008 { 0xF0, 0x04, 0xFF } /* DREG */
7009 };
7010
7011 if (read_bahama_ver() == VER_2_0) {
7012 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7013 u8 value = v20_init[i].value;
7014 rc = marimba_write_bit_mask(&config,
7015 v20_init[i].reg,
7016 &value,
7017 sizeof(v20_init[i].value),
7018 v20_init[i].mask);
7019 if (rc < 0) {
7020 printk(KERN_ERR
7021 "%s: reg %d write failed: %d\n",
7022 __func__, v20_init[i].reg, rc);
7023 return rc;
7024 }
7025 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7026 " mask 0x%02x\n",
7027 __func__, v20_init[i].reg,
7028 v20_init[i].value, v20_init[i].mask);
7029 }
7030 }
7031 }
7032 printk(KERN_INFO "core type: %d\n", type);
7033
7034 return rc;
7035}
7036
7037static struct regulator *fm_regulator_s3;
7038static struct msm_xo_voter *fm_clock;
7039
7040static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7041{
7042 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307043 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007044 .direction = PM_GPIO_DIR_IN,
7045 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307046 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007047 .function = PM_GPIO_FUNC_NORMAL,
7048 .inv_int_pol = 0,
7049 };
7050
7051 if (!fm_regulator_s3) {
7052 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7053 if (IS_ERR(fm_regulator_s3)) {
7054 rc = PTR_ERR(fm_regulator_s3);
7055 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7056 __func__, rc);
7057 goto out;
7058 }
7059 }
7060
7061
7062 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7063 if (rc < 0) {
7064 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7065 __func__, rc);
7066 goto fm_fail_put;
7067 }
7068
7069 rc = regulator_enable(fm_regulator_s3);
7070 if (rc < 0) {
7071 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7072 __func__, rc);
7073 goto fm_fail_put;
7074 }
7075
7076 /*Vote for XO clock*/
7077 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7078
7079 if (IS_ERR(fm_clock)) {
7080 rc = PTR_ERR(fm_clock);
7081 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7082 __func__, rc);
7083 goto fm_fail_switch;
7084 }
7085
7086 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7087 if (rc < 0) {
7088 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7089 __func__, rc);
7090 goto fm_fail_vote;
7091 }
7092
7093 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307094 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007095 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307096 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007097 __func__, rc);
7098 goto fm_fail_clock;
7099 }
7100 goto out;
7101
7102fm_fail_clock:
7103 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7104fm_fail_vote:
7105 msm_xo_put(fm_clock);
7106fm_fail_switch:
7107 regulator_disable(fm_regulator_s3);
7108fm_fail_put:
7109 regulator_put(fm_regulator_s3);
7110out:
7111 return rc;
7112};
7113
7114static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7115{
7116 int rc = 0;
7117 if (fm_regulator_s3 != NULL) {
7118 rc = regulator_disable(fm_regulator_s3);
7119 if (rc < 0) {
7120 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7121 __func__, rc);
7122 }
7123 regulator_put(fm_regulator_s3);
7124 fm_regulator_s3 = NULL;
7125 }
7126 printk(KERN_ERR "%s: Voting off for XO", __func__);
7127
7128 if (fm_clock != NULL) {
7129 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7130 if (rc < 0) {
7131 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7132 __func__, rc);
7133 }
7134 msm_xo_put(fm_clock);
7135 }
7136 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7137}
7138
7139/* Slave id address for FM/CDC/QMEMBIST
7140 * Values can be programmed using Marimba slave id 0
7141 * should there be a conflict with other I2C devices
7142 * */
7143#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7144#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7145
7146static struct marimba_fm_platform_data marimba_fm_pdata = {
7147 .fm_setup = fm_radio_setup,
7148 .fm_shutdown = fm_radio_shutdown,
7149 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7150 .is_fm_soc_i2s_master = false,
7151 .config_i2s_gpio = NULL,
7152};
7153
7154/*
7155Just initializing the BAHAMA related slave
7156*/
7157static struct marimba_platform_data marimba_pdata = {
7158 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7159 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7160 .bahama_setup = msm_bahama_setup_power,
7161 .bahama_shutdown = msm_bahama_shutdown_power,
7162 .bahama_core_config = msm_bahama_core_config,
7163 .fm = &marimba_fm_pdata,
7164 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7165};
7166
7167
7168static struct i2c_board_info msm_marimba_board_info[] = {
7169 {
7170 I2C_BOARD_INFO("marimba", 0xc),
7171 .platform_data = &marimba_pdata,
7172 }
7173};
7174#endif /* CONFIG_MAIMBA_CORE */
7175
7176#ifdef CONFIG_I2C
7177#define I2C_SURF 1
7178#define I2C_FFA (1 << 1)
7179#define I2C_RUMI (1 << 2)
7180#define I2C_SIM (1 << 3)
7181#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007182#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007183
7184struct i2c_registry {
7185 u8 machs;
7186 int bus;
7187 struct i2c_board_info *info;
7188 int len;
7189};
7190
7191static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007192#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7193 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007194 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007195 MSM_GSBI8_QUP_I2C_BUS_ID,
7196 core_expander_i2c_info,
7197 ARRAY_SIZE(core_expander_i2c_info),
7198 },
7199 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007200 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007201 MSM_GSBI8_QUP_I2C_BUS_ID,
7202 docking_expander_i2c_info,
7203 ARRAY_SIZE(docking_expander_i2c_info),
7204 },
7205 {
7206 I2C_SURF,
7207 MSM_GSBI8_QUP_I2C_BUS_ID,
7208 surf_expanders_i2c_info,
7209 ARRAY_SIZE(surf_expanders_i2c_info),
7210 },
7211 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007212 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007213 MSM_GSBI3_QUP_I2C_BUS_ID,
7214 fha_expanders_i2c_info,
7215 ARRAY_SIZE(fha_expanders_i2c_info),
7216 },
7217 {
7218 I2C_FLUID,
7219 MSM_GSBI3_QUP_I2C_BUS_ID,
7220 fluid_expanders_i2c_info,
7221 ARRAY_SIZE(fluid_expanders_i2c_info),
7222 },
7223 {
7224 I2C_FLUID,
7225 MSM_GSBI8_QUP_I2C_BUS_ID,
7226 fluid_core_expander_i2c_info,
7227 ARRAY_SIZE(fluid_core_expander_i2c_info),
7228 },
7229#endif
7230#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7231 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7232 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007233 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007234 MSM_GSBI3_QUP_I2C_BUS_ID,
7235 msm_i2c_gsbi3_tdisc_info,
7236 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7237 },
7238#endif
7239 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007240 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007241 MSM_GSBI3_QUP_I2C_BUS_ID,
7242 cy8ctmg200_board_info,
7243 ARRAY_SIZE(cy8ctmg200_board_info),
7244 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007245 {
7246 I2C_DRAGON,
7247 MSM_GSBI3_QUP_I2C_BUS_ID,
7248 cy8ctma340_dragon_board_info,
7249 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7250 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007251#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7252 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7253 {
7254 I2C_FLUID,
7255 MSM_GSBI3_QUP_I2C_BUS_ID,
7256 cyttsp_fluid_info,
7257 ARRAY_SIZE(cyttsp_fluid_info),
7258 },
7259 {
7260 I2C_FFA | I2C_SURF,
7261 MSM_GSBI3_QUP_I2C_BUS_ID,
7262 cyttsp_ffa_info,
7263 ARRAY_SIZE(cyttsp_ffa_info),
7264 },
7265#endif
7266#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007267#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007268 {
7269 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007270 MSM_GSBI4_QUP_I2C_BUS_ID,
7271 msm_camera_boardinfo,
7272 ARRAY_SIZE(msm_camera_boardinfo),
7273 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007274 {
7275 I2C_DRAGON,
7276 MSM_GSBI4_QUP_I2C_BUS_ID,
7277 msm_camera_dragon_boardinfo,
7278 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7279 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007280#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007281#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007282 {
7283 I2C_SURF | I2C_FFA | I2C_FLUID,
7284 MSM_GSBI7_QUP_I2C_BUS_ID,
7285 msm_i2c_gsbi7_timpani_info,
7286 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7287 },
7288#if defined(CONFIG_MARIMBA_CORE)
7289 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007290 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007291 MSM_GSBI7_QUP_I2C_BUS_ID,
7292 msm_marimba_board_info,
7293 ARRAY_SIZE(msm_marimba_board_info),
7294 },
7295#endif /* CONFIG_MARIMBA_CORE */
7296#ifdef CONFIG_ISL9519_CHARGER
7297 {
7298 I2C_SURF | I2C_FFA,
7299 MSM_GSBI8_QUP_I2C_BUS_ID,
7300 isl_charger_i2c_info,
7301 ARRAY_SIZE(isl_charger_i2c_info),
7302 },
7303#endif
7304#if defined(CONFIG_HAPTIC_ISA1200) || \
7305 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7306 {
7307 I2C_FLUID,
7308 MSM_GSBI8_QUP_I2C_BUS_ID,
7309 msm_isa1200_board_info,
7310 ARRAY_SIZE(msm_isa1200_board_info),
7311 },
7312#endif
7313#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7314 {
7315 I2C_FLUID,
7316 MSM_GSBI8_QUP_I2C_BUS_ID,
7317 smb137b_charger_i2c_info,
7318 ARRAY_SIZE(smb137b_charger_i2c_info),
7319 },
7320#endif
7321#if defined(CONFIG_BATTERY_BQ27520) || \
7322 defined(CONFIG_BATTERY_BQ27520_MODULE)
7323 {
7324 I2C_FLUID,
7325 MSM_GSBI8_QUP_I2C_BUS_ID,
7326 msm_bq27520_board_info,
7327 ARRAY_SIZE(msm_bq27520_board_info),
7328 },
7329#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007330#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7331 {
7332 I2C_DRAGON,
7333 MSM_GSBI8_QUP_I2C_BUS_ID,
7334 wm8903_codec_i2c_info,
7335 ARRAY_SIZE(wm8903_codec_i2c_info),
7336 },
7337#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007338};
7339#endif /* CONFIG_I2C */
7340
Stephen Boyd668d7652012-04-25 11:31:01 -07007341static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007342{
7343#ifdef CONFIG_I2C
7344#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7345 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7346 sx150x_data[SX150X_CORE].irq_summary =
7347 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007348 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7349 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007350 sx150x_data[SX150X_CORE].irq_summary =
7351 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7352 else if (machine_is_msm8x60_fluid())
7353 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7354 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7355#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007356#endif
7357}
7358
Stephen Boyd668d7652012-04-25 11:31:01 -07007359static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007360{
7361#ifdef CONFIG_I2C
7362 u8 mach_mask = 0;
7363 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007364#ifdef CONFIG_MSM_CAMERA_V4L2
7365 struct i2c_registry msm8x60_camera_i2c_devices = {
7366 I2C_SURF | I2C_FFA | I2C_FLUID,
7367 MSM_GSBI4_QUP_I2C_BUS_ID,
7368 msm8x60_camera_board_info.board_info,
7369 msm8x60_camera_board_info.num_i2c_board_info,
7370 };
7371#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007372
7373 /* Build the matching 'supported_machs' bitmask */
7374 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7375 mach_mask = I2C_SURF;
7376 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7377 mach_mask = I2C_FFA;
7378 else if (machine_is_msm8x60_rumi3())
7379 mach_mask = I2C_RUMI;
7380 else if (machine_is_msm8x60_sim())
7381 mach_mask = I2C_SIM;
7382 else if (machine_is_msm8x60_fluid())
7383 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007384 else if (machine_is_msm8x60_dragon())
7385 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007386 else
7387 pr_err("unmatched machine ID in register_i2c_devices\n");
7388
7389 /* Run the array and install devices as appropriate */
7390 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7391 if (msm8x60_i2c_devices[i].machs & mach_mask)
7392 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7393 msm8x60_i2c_devices[i].info,
7394 msm8x60_i2c_devices[i].len);
7395 }
Kevin Chan3be11612012-03-22 20:05:40 -07007396#ifdef CONFIG_MSM_CAMERA_V4L2
7397 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7398 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7399 msm8x60_camera_i2c_devices.info,
7400 msm8x60_camera_i2c_devices.len);
7401#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007402#endif
7403}
7404
7405static void __init msm8x60_init_uart12dm(void)
7406{
7407#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7408 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7409 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7410
7411 if (!fpga_mem)
7412 pr_err("%s(): Error getting memory\n", __func__);
7413
7414 /* Advanced mode */
7415 writew(0xFFFF, fpga_mem + 0x15C);
7416 /* FPGA_UART_SEL */
7417 writew(0, fpga_mem + 0x172);
7418 /* FPGA_GPIO_CONFIG_117 */
7419 writew(1, fpga_mem + 0xEA);
7420 /* FPGA_GPIO_CONFIG_118 */
7421 writew(1, fpga_mem + 0xEC);
7422 mb();
7423 iounmap(fpga_mem);
7424#endif
7425}
7426
7427#define MSM_GSBI9_PHYS 0x19900000
7428#define GSBI_DUAL_MODE_CODE 0x60
7429
7430static void __init msm8x60_init_buses(void)
7431{
7432#ifdef CONFIG_I2C_QUP
7433 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7434 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7435 writel_relaxed(0x6 << 4, gsbi_mem);
7436 /* Ensure protocol code is written before proceeding further */
7437 mb();
7438 iounmap(gsbi_mem);
7439
7440 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7441 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7442 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7443 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7444
7445#ifdef CONFIG_MSM_GSBI9_UART
7446 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7447 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7448 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7449 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7450 iounmap(gsbi_mem);
7451 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7452 }
7453#endif
7454 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7455 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7456#endif
7457#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7458 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7459#endif
7460#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007461 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7462#endif
7463
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307464#ifdef CONFIG_MSM_SSBI
7465 msm_device_ssbi_pmic1.dev.platform_data =
7466 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307467 msm_device_ssbi_pmic2.dev.platform_data =
7468 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307469#endif
7470
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007471 if (machine_is_msm8x60_fluid()) {
7472#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7473 (defined(CONFIG_SMB137B_CHARGER) || \
7474 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7475 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7476#endif
7477#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7478 msm_gsbi10_qup_spi_device.dev.platform_data =
7479 &msm_gsbi10_qup_spi_pdata;
7480#endif
7481 }
7482
Lena Salman57d167e2012-03-21 19:46:38 +02007483#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007484 /*
7485 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7486 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7487 * and ID notifications are available only on V2 surf and FFA
7488 * with a hardware workaround.
7489 */
7490 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7491 (machine_is_msm8x60_surf() ||
7492 (machine_is_msm8x60_ffa() &&
7493 pmic_id_notif_supported)))
7494 msm_otg_pdata.phy_can_powercollapse = 1;
7495 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7496#endif
7497
Lena Salman57d167e2012-03-21 19:46:38 +02007498#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007499 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7500#endif
7501
7502#ifdef CONFIG_SERIAL_MSM_HS
7503 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7504 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7505#endif
7506#ifdef CONFIG_MSM_GSBI9_UART
7507 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7508 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7509 if (IS_ERR(msm_device_uart_gsbi9))
7510 pr_err("%s(): Failed to create uart gsbi9 device\n",
7511 __func__);
7512 }
7513#endif
7514
7515#ifdef CONFIG_MSM_BUS_SCALING
7516
7517 /* RPM calls are only enabled on V2 */
7518 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7519 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7520 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7521 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7522 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7523 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7524 }
7525
7526 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7527 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7528 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7529 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7530 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7531#endif
7532}
7533
7534static void __init msm8x60_map_io(void)
7535{
7536 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7537 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007538
7539 if (socinfo_init() < 0)
7540 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007541}
7542
7543/*
7544 * Most segments of the EBI2 bus are disabled by default.
7545 */
7546static void __init msm8x60_init_ebi2(void)
7547{
7548 uint32_t ebi2_cfg;
7549 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007550 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7551
7552 if (IS_ERR(mem_clk)) {
7553 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7554 "msm_ebi2", "mem_clk");
7555 return;
7556 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007557 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007558 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007559
7560 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7561 if (ebi2_cfg_ptr != 0) {
7562 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7563
7564 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007565 machine_is_msm8x60_fluid() ||
7566 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007567 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7568 else if (machine_is_msm8x60_sim())
7569 ebi2_cfg |= (1 << 4); /* CS2 */
7570 else if (machine_is_msm8x60_rumi3())
7571 ebi2_cfg |= (1 << 5); /* CS3 */
7572
7573 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7574 iounmap(ebi2_cfg_ptr);
7575 }
7576
7577 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007578 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007579 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7580 if (ebi2_cfg_ptr != 0) {
7581 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7582 writel_relaxed(0UL, ebi2_cfg_ptr);
7583
7584 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7585 * LAN9221 Ethernet controller reads and writes.
7586 * The lowest 4 bits are the read delay, the next
7587 * 4 are the write delay. */
7588 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7589#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7590 /*
7591 * RECOVERY=5, HOLD_WR=1
7592 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7593 * WAIT_WR=1, WAIT_RD=2
7594 */
7595 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7596 /*
7597 * HOLD_RD=1
7598 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7599 */
7600 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7601#else
7602 /* EBI2 CS3 muxed address/data,
7603 * two cyc addr enable */
7604 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7605
7606#endif
7607 iounmap(ebi2_cfg_ptr);
7608 }
7609 }
7610}
7611
7612static void __init msm8x60_configure_smc91x(void)
7613{
7614 if (machine_is_msm8x60_sim()) {
7615
7616 smc91x_resources[0].start = 0x1b800300;
7617 smc91x_resources[0].end = 0x1b8003ff;
7618
7619 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7620 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7621
7622 } else if (machine_is_msm8x60_rumi3()) {
7623
7624 smc91x_resources[0].start = 0x1d000300;
7625 smc91x_resources[0].end = 0x1d0003ff;
7626
7627 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7628 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7629 }
7630}
7631
7632static void __init msm8x60_init_tlmm(void)
7633{
7634 if (machine_is_msm8x60_rumi3())
7635 msm_gpio_install_direct_irq(0, 0, 1);
7636}
7637
7638#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7639 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7640 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7641 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7642 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7643
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007644/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007645#define MAX_SDCC_CONTROLLER 5
7646
7647struct msm_sdcc_gpio {
7648 /* maximum 10 GPIOs per SDCC controller */
7649 s16 no;
7650 /* name of this GPIO */
7651 const char *name;
7652 bool always_on;
7653 bool is_enabled;
7654};
7655
7656#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7657static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7658 {159, "sdc1_dat_0"},
7659 {160, "sdc1_dat_1"},
7660 {161, "sdc1_dat_2"},
7661 {162, "sdc1_dat_3"},
7662#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7663 {163, "sdc1_dat_4"},
7664 {164, "sdc1_dat_5"},
7665 {165, "sdc1_dat_6"},
7666 {166, "sdc1_dat_7"},
7667#endif
7668 {167, "sdc1_clk"},
7669 {168, "sdc1_cmd"}
7670};
7671#endif
7672
7673#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7674static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7675 {143, "sdc2_dat_0"},
7676 {144, "sdc2_dat_1", 1},
7677 {145, "sdc2_dat_2"},
7678 {146, "sdc2_dat_3"},
7679#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7680 {147, "sdc2_dat_4"},
7681 {148, "sdc2_dat_5"},
7682 {149, "sdc2_dat_6"},
7683 {150, "sdc2_dat_7"},
7684#endif
7685 {151, "sdc2_cmd"},
7686 {152, "sdc2_clk", 1}
7687};
7688#endif
7689
7690#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7691static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7692 {95, "sdc5_cmd"},
7693 {96, "sdc5_dat_3"},
7694 {97, "sdc5_clk", 1},
7695 {98, "sdc5_dat_2"},
7696 {99, "sdc5_dat_1", 1},
7697 {100, "sdc5_dat_0"}
7698};
7699#endif
7700
7701struct msm_sdcc_pad_pull_cfg {
7702 enum msm_tlmm_pull_tgt pull;
7703 u32 pull_val;
7704};
7705
7706struct msm_sdcc_pad_drv_cfg {
7707 enum msm_tlmm_hdrive_tgt drv;
7708 u32 drv_val;
7709};
7710
7711#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7712static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7713 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7714 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7715 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7716};
7717
7718static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7719 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7720 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7721};
7722
7723static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7724 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7725 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7726 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7727};
7728
7729static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7730 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7731 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7732};
7733#endif
7734
7735#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7736static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7737 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7738 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7739 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7740};
7741
7742static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7743 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7744 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7745};
7746
7747static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7748 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7749 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7750 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7751};
7752
7753static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7754 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7755 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7756};
7757#endif
7758
7759struct msm_sdcc_pin_cfg {
7760 /*
7761 * = 1 if controller pins are using gpios
7762 * = 0 if controller has dedicated MSM pins
7763 */
7764 u8 is_gpio;
7765 u8 cfg_sts;
7766 u8 gpio_data_size;
7767 struct msm_sdcc_gpio *gpio_data;
7768 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7769 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7770 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7771 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7772 u8 pad_drv_data_size;
7773 u8 pad_pull_data_size;
7774 u8 sdio_lpm_gpio_cfg;
7775};
7776
7777
7778static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7779#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7780 [0] = {
7781 .is_gpio = 1,
7782 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7783 .gpio_data = sdc1_gpio_cfg
7784 },
7785#endif
7786#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7787 [1] = {
7788 .is_gpio = 1,
7789 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7790 .gpio_data = sdc2_gpio_cfg
7791 },
7792#endif
7793#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7794 [2] = {
7795 .is_gpio = 0,
7796 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7797 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7798 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7799 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7800 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7801 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7802 },
7803#endif
7804#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7805 [3] = {
7806 .is_gpio = 0,
7807 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7808 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7809 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7810 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7811 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7812 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7813 },
7814#endif
7815#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7816 [4] = {
7817 .is_gpio = 1,
7818 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7819 .gpio_data = sdc5_gpio_cfg
7820 }
7821#endif
7822};
7823
7824static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7825{
7826 int rc = 0;
7827 struct msm_sdcc_pin_cfg *curr;
7828 int n;
7829
7830 curr = &sdcc_pin_cfg_data[dev_id - 1];
7831 if (!curr->gpio_data)
7832 goto out;
7833
7834 for (n = 0; n < curr->gpio_data_size; n++) {
7835 if (enable) {
7836
7837 if (curr->gpio_data[n].always_on &&
7838 curr->gpio_data[n].is_enabled)
7839 continue;
7840 pr_debug("%s: enable: %s\n", __func__,
7841 curr->gpio_data[n].name);
7842 rc = gpio_request(curr->gpio_data[n].no,
7843 curr->gpio_data[n].name);
7844 if (rc) {
7845 pr_err("%s: gpio_request(%d, %s)"
7846 "failed", __func__,
7847 curr->gpio_data[n].no,
7848 curr->gpio_data[n].name);
7849 goto free_gpios;
7850 }
7851 /* set direction as output for all GPIOs */
7852 rc = gpio_direction_output(
7853 curr->gpio_data[n].no, 1);
7854 if (rc) {
7855 pr_err("%s: gpio_direction_output"
7856 "(%d, 1) failed\n", __func__,
7857 curr->gpio_data[n].no);
7858 goto free_gpios;
7859 }
7860 curr->gpio_data[n].is_enabled = 1;
7861 } else {
7862 /*
7863 * now free this GPIO which will put GPIO
7864 * in low power mode and will also put GPIO
7865 * in input mode
7866 */
7867 if (curr->gpio_data[n].always_on)
7868 continue;
7869 pr_debug("%s: disable: %s\n", __func__,
7870 curr->gpio_data[n].name);
7871 gpio_free(curr->gpio_data[n].no);
7872 curr->gpio_data[n].is_enabled = 0;
7873 }
7874 }
7875 curr->cfg_sts = enable;
7876 goto out;
7877
7878free_gpios:
7879 for (; n >= 0; n--)
7880 gpio_free(curr->gpio_data[n].no);
7881out:
7882 return rc;
7883}
7884
7885static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7886{
7887 int rc = 0;
7888 struct msm_sdcc_pin_cfg *curr;
7889 int n;
7890
7891 curr = &sdcc_pin_cfg_data[dev_id - 1];
7892 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7893 goto out;
7894
7895 if (enable) {
7896 /*
7897 * set up the normal driver strength and
7898 * pull config for pads
7899 */
7900 for (n = 0; n < curr->pad_drv_data_size; n++) {
7901 if (curr->sdio_lpm_gpio_cfg) {
7902 if (curr->pad_drv_on_data[n].drv ==
7903 TLMM_HDRV_SDC4_DATA)
7904 continue;
7905 }
7906 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7907 curr->pad_drv_on_data[n].drv_val);
7908 }
7909 for (n = 0; n < curr->pad_pull_data_size; n++) {
7910 if (curr->sdio_lpm_gpio_cfg) {
7911 if (curr->pad_pull_on_data[n].pull ==
7912 TLMM_PULL_SDC4_DATA)
7913 continue;
7914 }
7915 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7916 curr->pad_pull_on_data[n].pull_val);
7917 }
7918 } else {
7919 /* set the low power config for pads */
7920 for (n = 0; n < curr->pad_drv_data_size; n++) {
7921 if (curr->sdio_lpm_gpio_cfg) {
7922 if (curr->pad_drv_off_data[n].drv ==
7923 TLMM_HDRV_SDC4_DATA)
7924 continue;
7925 }
7926 msm_tlmm_set_hdrive(
7927 curr->pad_drv_off_data[n].drv,
7928 curr->pad_drv_off_data[n].drv_val);
7929 }
7930 for (n = 0; n < curr->pad_pull_data_size; n++) {
7931 if (curr->sdio_lpm_gpio_cfg) {
7932 if (curr->pad_pull_off_data[n].pull ==
7933 TLMM_PULL_SDC4_DATA)
7934 continue;
7935 }
7936 msm_tlmm_set_pull(
7937 curr->pad_pull_off_data[n].pull,
7938 curr->pad_pull_off_data[n].pull_val);
7939 }
7940 }
7941 curr->cfg_sts = enable;
7942out:
7943 return rc;
7944}
7945
7946struct sdcc_reg {
7947 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7948 const char *reg_name;
7949 /*
7950 * is set voltage supported for this regulator?
7951 * 0 = not supported, 1 = supported
7952 */
7953 unsigned char set_voltage_sup;
7954 /* voltage level to be set */
7955 unsigned int level;
7956 /* VDD/VCC/VCCQ voltage regulator handle */
7957 struct regulator *reg;
7958 /* is this regulator enabled? */
7959 bool enabled;
7960 /* is this regulator needs to be always on? */
7961 bool always_on;
7962 /* is operating power mode setting required for this regulator? */
7963 bool op_pwr_mode_sup;
7964 /* Load values for low power and high power mode */
7965 unsigned int lpm_uA;
7966 unsigned int hpm_uA;
7967};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007968/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007969static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7970/* only SDCC1 requires VCCQ voltage */
7971static struct sdcc_reg sdcc_vccq_reg_data[1];
7972/* all SDCC controllers may require voting for VDD PAD voltage */
7973static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7974
7975struct sdcc_reg_data {
7976 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7977 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7978 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7979 unsigned char sts; /* regulator enable/disable status */
7980};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007981/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007982static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7983
7984static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7985{
7986 int rc = 0;
7987
7988 /* Get the regulator handle */
7989 vreg->reg = regulator_get(NULL, vreg->reg_name);
7990 if (IS_ERR(vreg->reg)) {
7991 rc = PTR_ERR(vreg->reg);
7992 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7993 __func__, vreg->reg_name, rc);
7994 goto out;
7995 }
7996
7997 /* Set the voltage level if required */
7998 if (vreg->set_voltage_sup) {
7999 rc = regulator_set_voltage(vreg->reg, vreg->level,
8000 vreg->level);
8001 if (rc) {
8002 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
8003 __func__, vreg->reg_name, rc);
8004 goto vreg_put;
8005 }
8006 }
8007 goto out;
8008
8009vreg_put:
8010 regulator_put(vreg->reg);
8011out:
8012 return rc;
8013}
8014
8015static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
8016{
8017 regulator_put(vreg->reg);
8018}
8019
8020/* this init function should be called only once for each SDCC */
8021static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
8022{
8023 int rc = 0;
8024 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8025 struct sdcc_reg_data *curr;
8026
8027 curr = &sdcc_vreg_data[dev_id - 1];
8028 curr_vdd_reg = curr->vdd_data;
8029 curr_vccq_reg = curr->vccq_data;
8030 curr_vddp_reg = curr->vddp_data;
8031
8032 if (init) {
8033 /*
8034 * get the regulator handle from voltage regulator framework
8035 * and then try to set the voltage level for the regulator
8036 */
8037 if (curr_vdd_reg) {
8038 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8039 if (rc)
8040 goto out;
8041 }
8042 if (curr_vccq_reg) {
8043 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8044 if (rc)
8045 goto vdd_reg_deinit;
8046 }
8047 if (curr_vddp_reg) {
8048 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8049 if (rc)
8050 goto vccq_reg_deinit;
8051 }
8052 goto out;
8053 } else
8054 /* deregister with all regulators from regulator framework */
8055 goto vddp_reg_deinit;
8056
8057vddp_reg_deinit:
8058 if (curr_vddp_reg)
8059 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8060vccq_reg_deinit:
8061 if (curr_vccq_reg)
8062 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8063vdd_reg_deinit:
8064 if (curr_vdd_reg)
8065 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8066out:
8067 return rc;
8068}
8069
8070static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8071{
8072 int rc;
8073
8074 if (!vreg->enabled) {
8075 rc = regulator_enable(vreg->reg);
8076 if (rc) {
8077 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8078 __func__, vreg->reg_name, rc);
8079 goto out;
8080 }
8081 vreg->enabled = 1;
8082 }
8083
8084 /* Put always_on regulator in HPM (high power mode) */
8085 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8086 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8087 if (rc < 0) {
8088 pr_err("%s: reg=%s: HPM setting failed"
8089 " hpm_uA=%d, rc=%d\n",
8090 __func__, vreg->reg_name,
8091 vreg->hpm_uA, rc);
8092 goto vreg_disable;
8093 }
8094 rc = 0;
8095 }
8096 goto out;
8097
8098vreg_disable:
8099 regulator_disable(vreg->reg);
8100 vreg->enabled = 0;
8101out:
8102 return rc;
8103}
8104
8105static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8106{
8107 int rc;
8108
8109 /* Never disable always_on regulator */
8110 if (!vreg->always_on) {
8111 rc = regulator_disable(vreg->reg);
8112 if (rc) {
8113 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8114 __func__, vreg->reg_name, rc);
8115 goto out;
8116 }
8117 vreg->enabled = 0;
8118 }
8119
8120 /* Put always_on regulator in LPM (low power mode) */
8121 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8122 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8123 if (rc < 0) {
8124 pr_err("%s: reg=%s: LPM setting failed"
8125 " lpm_uA=%d, rc=%d\n",
8126 __func__,
8127 vreg->reg_name,
8128 vreg->lpm_uA, rc);
8129 goto out;
8130 }
8131 rc = 0;
8132 }
8133
8134out:
8135 return rc;
8136}
8137
8138static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8139{
8140 int rc = 0;
8141 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8142 struct sdcc_reg_data *curr;
8143
8144 curr = &sdcc_vreg_data[dev_id - 1];
8145 curr_vdd_reg = curr->vdd_data;
8146 curr_vccq_reg = curr->vccq_data;
8147 curr_vddp_reg = curr->vddp_data;
8148
8149 /* check if regulators are initialized or not? */
8150 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8151 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8152 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8153 /* initialize voltage regulators required for this SDCC */
8154 rc = msm_sdcc_vreg_init(dev_id, 1);
8155 if (rc) {
8156 pr_err("%s: regulator init failed = %d\n",
8157 __func__, rc);
8158 goto out;
8159 }
8160 }
8161
8162 if (curr->sts == enable)
8163 goto out;
8164
8165 if (curr_vdd_reg) {
8166 if (enable)
8167 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8168 else
8169 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8170 if (rc)
8171 goto out;
8172 }
8173
8174 if (curr_vccq_reg) {
8175 if (enable)
8176 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8177 else
8178 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8179 if (rc)
8180 goto out;
8181 }
8182
8183 if (curr_vddp_reg) {
8184 if (enable)
8185 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8186 else
8187 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8188 if (rc)
8189 goto out;
8190 }
8191 curr->sts = enable;
8192
8193out:
8194 return rc;
8195}
8196
8197static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8198{
8199 u32 rc_pin_cfg = 0;
8200 u32 rc_vreg_cfg = 0;
8201 u32 rc = 0;
8202 struct platform_device *pdev;
8203 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8204
8205 pdev = container_of(dv, struct platform_device, dev);
8206
8207 /* setup gpio/pad */
8208 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8209 if (curr_pin_cfg->cfg_sts == !!vdd)
8210 goto setup_vreg;
8211
8212 if (curr_pin_cfg->is_gpio)
8213 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8214 else
8215 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8216
8217setup_vreg:
8218 /* setup voltage regulators */
8219 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8220
8221 if (rc_pin_cfg || rc_vreg_cfg)
8222 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8223
8224 return rc;
8225}
8226
8227static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8228{
8229 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8230 struct platform_device *pdev;
8231
8232 pdev = container_of(dv, struct platform_device, dev);
8233 /* setup gpio/pad */
8234 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8235
8236 if (curr_pin_cfg->cfg_sts == active)
8237 return;
8238
8239 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8240 if (curr_pin_cfg->is_gpio)
8241 msm_sdcc_setup_gpio(pdev->id, active);
8242 else
8243 msm_sdcc_setup_pad(pdev->id, active);
8244 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8245}
8246
8247static int msm_sdc3_get_wpswitch(struct device *dev)
8248{
8249 struct platform_device *pdev;
8250 int status;
8251 pdev = container_of(dev, struct platform_device, dev);
8252
8253 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8254 if (status) {
8255 pr_err("%s:Failed to request GPIO %d\n",
8256 __func__, GPIO_SDC_WP);
8257 } else {
8258 status = gpio_direction_input(GPIO_SDC_WP);
8259 if (!status) {
8260 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8261 pr_info("%s: WP Status for Slot %d = %d\n",
8262 __func__, pdev->id, status);
8263 }
8264 gpio_free(GPIO_SDC_WP);
8265 }
8266 return status;
8267}
8268
8269#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8270int sdc5_register_status_notify(void (*callback)(int, void *),
8271 void *dev_id)
8272{
8273 sdc5_status_notify_cb = callback;
8274 sdc5_status_notify_cb_devid = dev_id;
8275 return 0;
8276}
8277#endif
8278
8279#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8280int sdc2_register_status_notify(void (*callback)(int, void *),
8281 void *dev_id)
8282{
8283 sdc2_status_notify_cb = callback;
8284 sdc2_status_notify_cb_devid = dev_id;
8285 return 0;
8286}
8287#endif
8288
8289/* Interrupt handler for SDC2 and SDC5 detection
8290 * This function uses dual-edge interrputs settings in order
8291 * to get SDIO detection when the GPIO is rising and SDIO removal
8292 * when the GPIO is falling */
8293static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8294{
8295 int status;
8296
8297 if (!machine_is_msm8x60_fusion() &&
8298 !machine_is_msm8x60_fusn_ffa())
8299 return IRQ_NONE;
8300
8301 status = gpio_get_value(MDM2AP_SYNC);
8302 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8303 __func__, status);
8304
8305#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8306 if (sdc2_status_notify_cb) {
8307 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8308 sdc2_status_notify_cb(status,
8309 sdc2_status_notify_cb_devid);
8310 }
8311#endif
8312
8313#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8314 if (sdc5_status_notify_cb) {
8315 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8316 sdc5_status_notify_cb(status,
8317 sdc5_status_notify_cb_devid);
8318 }
8319#endif
8320 return IRQ_HANDLED;
8321}
8322
8323static int msm8x60_multi_sdio_init(void)
8324{
8325 int ret, irq_num;
8326
8327 if (!machine_is_msm8x60_fusion() &&
8328 !machine_is_msm8x60_fusn_ffa())
8329 return 0;
8330
8331 ret = msm_gpiomux_get(MDM2AP_SYNC);
8332 if (ret) {
8333 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8334 __func__, MDM2AP_SYNC, ret);
8335 return ret;
8336 }
8337
8338 irq_num = gpio_to_irq(MDM2AP_SYNC);
8339
8340 ret = request_irq(irq_num,
8341 msm8x60_multi_sdio_slot_status_irq,
8342 IRQ_TYPE_EDGE_BOTH,
8343 "sdio_multidetection", NULL);
8344
8345 if (ret) {
8346 pr_err("%s:Failed to request irq, ret=%d\n",
8347 __func__, ret);
8348 return ret;
8349 }
8350
8351 return ret;
8352}
8353
8354#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8355#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8356static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8357{
8358 int status;
8359
8360 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8361 , "SD_HW_Detect");
8362 if (status) {
8363 pr_err("%s:Failed to request GPIO %d\n", __func__,
8364 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8365 } else {
8366 status = gpio_direction_input(
8367 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8368 if (!status)
8369 status = !(gpio_get_value_cansleep(
8370 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8371 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8372 }
8373 return (unsigned int) status;
8374}
8375#endif
8376#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308377#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008378
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308379#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308380#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008381
8382#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8383static struct mmc_platform_data msm8x60_sdc1_data = {
8384 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8385 .translate_vdd = msm_sdcc_setup_power,
8386#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8387 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8388#else
8389 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8390#endif
8391 .msmsdcc_fmin = 400000,
8392 .msmsdcc_fmid = 24000000,
8393 .msmsdcc_fmax = 48000000,
8394 .nonremovable = 1,
8395 .pclk_src_dfab = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308396 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008397};
8398#endif
8399
8400#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8401static struct mmc_platform_data msm8x60_sdc2_data = {
8402 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8403 .translate_vdd = msm_sdcc_setup_power,
8404 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8405 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8406 .msmsdcc_fmin = 400000,
8407 .msmsdcc_fmid = 24000000,
8408 .msmsdcc_fmax = 48000000,
8409 .nonremovable = 0,
8410 .pclk_src_dfab = 1,
8411 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008412#ifdef CONFIG_MSM_SDIO_AL
8413 .is_sdio_al_client = 1,
8414#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308415 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008416};
8417#endif
8418
8419#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8420static struct mmc_platform_data msm8x60_sdc3_data = {
8421 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8422 .translate_vdd = msm_sdcc_setup_power,
8423 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8424 .wpswitch = msm_sdc3_get_wpswitch,
8425#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8426 .status = msm8x60_sdcc_slot_status,
8427 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8428 PMIC_GPIO_SDC3_DET - 1),
8429 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8430#endif
8431 .msmsdcc_fmin = 400000,
8432 .msmsdcc_fmid = 24000000,
8433 .msmsdcc_fmax = 48000000,
8434 .nonremovable = 0,
8435 .pclk_src_dfab = 1,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308436 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308437 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008438};
8439#endif
8440
8441#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8442static struct mmc_platform_data msm8x60_sdc4_data = {
8443 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8444 .translate_vdd = msm_sdcc_setup_power,
8445 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8446 .msmsdcc_fmin = 400000,
8447 .msmsdcc_fmid = 24000000,
8448 .msmsdcc_fmax = 48000000,
8449 .nonremovable = 0,
8450 .pclk_src_dfab = 1,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308451 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308452 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008453};
8454#endif
8455
8456#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8457static struct mmc_platform_data msm8x60_sdc5_data = {
8458 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8459 .translate_vdd = msm_sdcc_setup_power,
8460 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8461 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8462 .msmsdcc_fmin = 400000,
8463 .msmsdcc_fmid = 24000000,
8464 .msmsdcc_fmax = 48000000,
8465 .nonremovable = 0,
8466 .pclk_src_dfab = 1,
8467 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008468#ifdef CONFIG_MSM_SDIO_AL
8469 .is_sdio_al_client = 1,
8470#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308471 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008472};
8473#endif
8474
8475static void __init msm8x60_init_mmc(void)
8476{
8477#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8478 /* SDCC1 : eMMC card connected */
8479 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8480 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8481 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8482 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308483 sdcc_vreg_data[0].vdd_data->always_on = 1;
8484 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8485 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8486 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008487
8488 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8489 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8490 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8491 sdcc_vreg_data[0].vccq_data->always_on = 1;
8492
8493 msm_add_sdcc(1, &msm8x60_sdc1_data);
8494#endif
8495#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8496 /*
8497 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8498 * and no card is connected on 8660 SURF/FFA/FLUID.
8499 */
8500 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8501 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8502 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8503 sdcc_vreg_data[1].vdd_data->level = 1800000;
8504
8505 sdcc_vreg_data[1].vccq_data = NULL;
8506
8507 if (machine_is_msm8x60_fusion())
8508 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8509 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008510 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8511 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008512 msm_add_sdcc(2, &msm8x60_sdc2_data);
8513 }
8514#endif
8515#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8516 /* SDCC3 : External card slot connected */
8517 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8518 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8519 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8520 sdcc_vreg_data[2].vdd_data->level = 2850000;
8521 sdcc_vreg_data[2].vdd_data->always_on = 1;
8522 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8523 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8524 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8525
8526 sdcc_vreg_data[2].vccq_data = NULL;
8527
8528 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8529 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8530 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8531 sdcc_vreg_data[2].vddp_data->level = 2850000;
8532 sdcc_vreg_data[2].vddp_data->always_on = 1;
8533 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8534 /* Sleep current required is ~300 uA. But min. RPM
8535 * vote can be in terms of mA (min. 1 mA).
8536 * So let's vote for 2 mA during sleep.
8537 */
8538 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8539 /* Max. Active current required is 16 mA */
8540 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8541
8542 if (machine_is_msm8x60_fluid())
8543 msm8x60_sdc3_data.wpswitch = NULL;
8544 msm_add_sdcc(3, &msm8x60_sdc3_data);
8545#endif
8546#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8547 /* SDCC4 : WLAN WCN1314 chip is connected */
8548 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8549 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8550 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8551 sdcc_vreg_data[3].vdd_data->level = 1800000;
8552
8553 sdcc_vreg_data[3].vccq_data = NULL;
8554
8555 msm_add_sdcc(4, &msm8x60_sdc4_data);
8556#endif
8557#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8558 /*
8559 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8560 * and no card is connected on 8660 SURF/FFA/FLUID.
8561 */
8562 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8563 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8564 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8565 sdcc_vreg_data[4].vdd_data->level = 1800000;
8566
8567 sdcc_vreg_data[4].vccq_data = NULL;
8568
8569 if (machine_is_msm8x60_fusion())
8570 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8571 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008572 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8573 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008574 msm_add_sdcc(5, &msm8x60_sdc5_data);
8575 }
8576#endif
8577}
8578
8579#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8580static inline void display_common_power(int on) {}
8581#else
8582
8583#define _GET_REGULATOR(var, name) do { \
8584 if (var == NULL) { \
8585 var = regulator_get(NULL, name); \
8586 if (IS_ERR(var)) { \
8587 pr_err("'%s' regulator not found, rc=%ld\n", \
8588 name, PTR_ERR(var)); \
8589 var = NULL; \
8590 } \
8591 } \
8592} while (0)
8593
8594static int dsub_regulator(int on)
8595{
8596 static struct regulator *dsub_reg;
8597 static struct regulator *mpp0_reg;
8598 static int dsub_reg_enabled;
8599 int rc = 0;
8600
8601 _GET_REGULATOR(dsub_reg, "8901_l3");
8602 if (IS_ERR(dsub_reg)) {
8603 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8604 __func__, PTR_ERR(dsub_reg));
8605 return PTR_ERR(dsub_reg);
8606 }
8607
8608 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8609 if (IS_ERR(mpp0_reg)) {
8610 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8611 __func__, PTR_ERR(mpp0_reg));
8612 return PTR_ERR(mpp0_reg);
8613 }
8614
8615 if (on && !dsub_reg_enabled) {
8616 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8617 if (rc) {
8618 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8619 " err=%d", __func__, rc);
8620 goto dsub_regulator_err;
8621 }
8622 rc = regulator_enable(dsub_reg);
8623 if (rc) {
8624 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8625 " err=%d", __func__, rc);
8626 goto dsub_regulator_err;
8627 }
8628 rc = regulator_enable(mpp0_reg);
8629 if (rc) {
8630 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8631 " err=%d", __func__, rc);
8632 goto dsub_regulator_err;
8633 }
8634 dsub_reg_enabled = 1;
8635 } else if (!on && dsub_reg_enabled) {
8636 rc = regulator_disable(dsub_reg);
8637 if (rc)
8638 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8639 " err=%d", __func__, rc);
8640 rc = regulator_disable(mpp0_reg);
8641 if (rc)
8642 printk(KERN_WARNING "%s: failed to disable reg "
8643 "8901_mpp0 err=%d", __func__, rc);
8644 dsub_reg_enabled = 0;
8645 }
8646
8647 return rc;
8648
8649dsub_regulator_err:
8650 regulator_put(mpp0_reg);
8651 regulator_put(dsub_reg);
8652 return rc;
8653}
8654
8655static int display_power_on;
8656static void setup_display_power(void)
8657{
8658 if (display_power_on)
8659 if (lcdc_vga_enabled) {
8660 dsub_regulator(1);
8661 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8662 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8663 if (machine_is_msm8x60_ffa() ||
8664 machine_is_msm8x60_fusn_ffa())
8665 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8666 } else {
8667 dsub_regulator(0);
8668 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8669 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8670 if (machine_is_msm8x60_ffa() ||
8671 machine_is_msm8x60_fusn_ffa())
8672 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8673 }
8674 else {
8675 dsub_regulator(0);
8676 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8677 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8678 /* BACKLIGHT */
8679 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8680 /* LVDS */
8681 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8682 }
8683}
8684
8685#define _GET_REGULATOR(var, name) do { \
8686 if (var == NULL) { \
8687 var = regulator_get(NULL, name); \
8688 if (IS_ERR(var)) { \
8689 pr_err("'%s' regulator not found, rc=%ld\n", \
8690 name, PTR_ERR(var)); \
8691 var = NULL; \
8692 } \
8693 } \
8694} while (0)
8695
8696#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8697
8698static void display_common_power(int on)
8699{
8700 int rc;
8701 static struct regulator *display_reg;
8702
8703 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8704 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8705 if (on) {
8706 /* LVDS */
8707 _GET_REGULATOR(display_reg, "8901_l2");
8708 if (!display_reg)
8709 return;
8710 rc = regulator_set_voltage(display_reg,
8711 3300000, 3300000);
8712 if (rc)
8713 goto out;
8714 rc = regulator_enable(display_reg);
8715 if (rc)
8716 goto out;
8717 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8718 "LVDS_STDN_OUT_N");
8719 if (rc) {
8720 printk(KERN_ERR "%s: LVDS gpio %d request"
8721 "failed\n", __func__,
8722 GPIO_LVDS_SHUTDOWN_N);
8723 goto out2;
8724 }
8725
8726 /* BACKLIGHT */
8727 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8728 if (rc) {
8729 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8730 "failed\n", __func__,
8731 GPIO_BACKLIGHT_EN);
8732 goto out3;
8733 }
8734
8735 if (machine_is_msm8x60_ffa() ||
8736 machine_is_msm8x60_fusn_ffa()) {
8737 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8738 "DONGLE_PWR_EN");
8739 if (rc) {
8740 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8741 " %d request failed\n", __func__,
8742 GPIO_DONGLE_PWR_EN);
8743 goto out4;
8744 }
8745 }
8746
8747 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8748 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8749 if (machine_is_msm8x60_ffa() ||
8750 machine_is_msm8x60_fusn_ffa())
8751 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8752 mdelay(20);
8753 display_power_on = 1;
8754 setup_display_power();
8755 } else {
8756 if (display_power_on) {
8757 display_power_on = 0;
8758 setup_display_power();
8759 mdelay(20);
8760 if (machine_is_msm8x60_ffa() ||
8761 machine_is_msm8x60_fusn_ffa())
8762 gpio_free(GPIO_DONGLE_PWR_EN);
8763 goto out4;
8764 }
8765 }
8766 }
8767#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8768 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8769 else if (machine_is_msm8x60_fluid()) {
8770 static struct regulator *fluid_reg;
8771 static struct regulator *fluid_reg2;
8772
8773 if (on) {
8774 _GET_REGULATOR(fluid_reg, "8901_l2");
8775 if (!fluid_reg)
8776 return;
8777 _GET_REGULATOR(fluid_reg2, "8058_s3");
8778 if (!fluid_reg2) {
8779 regulator_put(fluid_reg);
8780 return;
8781 }
8782 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8783 if (rc) {
8784 regulator_put(fluid_reg2);
8785 regulator_put(fluid_reg);
8786 return;
8787 }
8788 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8789 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8790 regulator_enable(fluid_reg);
8791 regulator_enable(fluid_reg2);
8792 msleep(20);
8793 gpio_direction_output(GPIO_RESX_N, 0);
8794 udelay(10);
8795 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8796 display_power_on = 1;
8797 setup_display_power();
8798 } else {
8799 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8800 gpio_free(GPIO_RESX_N);
8801 msleep(20);
8802 regulator_disable(fluid_reg2);
8803 regulator_disable(fluid_reg);
8804 regulator_put(fluid_reg2);
8805 regulator_put(fluid_reg);
8806 display_power_on = 0;
8807 setup_display_power();
8808 fluid_reg = NULL;
8809 fluid_reg2 = NULL;
8810 }
8811 }
8812#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008813#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8814 else if (machine_is_msm8x60_dragon()) {
8815 static struct regulator *dragon_reg;
8816 static struct regulator *dragon_reg2;
8817
8818 if (on) {
8819 _GET_REGULATOR(dragon_reg, "8901_l2");
8820 if (!dragon_reg)
8821 return;
8822 _GET_REGULATOR(dragon_reg2, "8058_l16");
8823 if (!dragon_reg2) {
8824 regulator_put(dragon_reg);
8825 dragon_reg = NULL;
8826 return;
8827 }
8828
8829 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8830 if (rc) {
8831 pr_err("%s: gpio %d request failed with rc=%d\n",
8832 __func__, GPIO_NT35582_BL_EN, rc);
8833 regulator_put(dragon_reg);
8834 regulator_put(dragon_reg2);
8835 dragon_reg = NULL;
8836 dragon_reg2 = NULL;
8837 return;
8838 }
8839
8840 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8841 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8842 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8843 pr_err("%s: config gpio '%d' failed!\n",
8844 __func__, GPIO_NT35582_RESET);
8845 gpio_free(GPIO_NT35582_BL_EN);
8846 regulator_put(dragon_reg);
8847 regulator_put(dragon_reg2);
8848 dragon_reg = NULL;
8849 dragon_reg2 = NULL;
8850 return;
8851 }
8852
8853 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8854 if (rc) {
8855 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8856 __func__, GPIO_NT35582_RESET, rc);
8857 gpio_free(GPIO_NT35582_BL_EN);
8858 regulator_put(dragon_reg);
8859 regulator_put(dragon_reg2);
8860 dragon_reg = NULL;
8861 dragon_reg2 = NULL;
8862 return;
8863 }
8864
8865 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8866 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8867 regulator_enable(dragon_reg);
8868 regulator_enable(dragon_reg2);
8869 msleep(20);
8870
8871 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8872 msleep(20);
8873 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8874 msleep(20);
8875 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8876 msleep(50);
8877
8878 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8879
8880 display_power_on = 1;
8881 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8882 gpio_free(GPIO_NT35582_RESET);
8883 gpio_free(GPIO_NT35582_BL_EN);
8884 regulator_disable(dragon_reg2);
8885 regulator_disable(dragon_reg);
8886 regulator_put(dragon_reg2);
8887 regulator_put(dragon_reg);
8888 display_power_on = 0;
8889 dragon_reg = NULL;
8890 dragon_reg2 = NULL;
8891 }
8892 }
8893#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008894 return;
8895
8896out4:
8897 gpio_free(GPIO_BACKLIGHT_EN);
8898out3:
8899 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8900out2:
8901 regulator_disable(display_reg);
8902out:
8903 regulator_put(display_reg);
8904 display_reg = NULL;
8905}
8906#undef _GET_REGULATOR
8907#endif
8908
8909static int mipi_dsi_panel_power(int on);
8910
8911#define LCDC_NUM_GPIO 28
8912#define LCDC_GPIO_START 0
8913
8914static void lcdc_samsung_panel_power(int on)
8915{
8916 int n, ret = 0;
8917
8918 display_common_power(on);
8919
8920 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8921 if (on) {
8922 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8923 if (unlikely(ret)) {
8924 pr_err("%s not able to get gpio\n", __func__);
8925 break;
8926 }
8927 } else
8928 gpio_free(LCDC_GPIO_START + n);
8929 }
8930
8931 if (ret) {
8932 for (n--; n >= 0; n--)
8933 gpio_free(LCDC_GPIO_START + n);
8934 }
8935
8936 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8937}
8938
8939#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8940#define _GET_REGULATOR(var, name) do { \
8941 var = regulator_get(NULL, name); \
8942 if (IS_ERR(var)) { \
8943 pr_err("'%s' regulator not found, rc=%ld\n", \
8944 name, IS_ERR(var)); \
8945 var = NULL; \
8946 return -ENODEV; \
8947 } \
8948} while (0)
8949
8950static int hdmi_enable_5v(int on)
8951{
8952 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8953 static struct regulator *reg_8901_mpp0; /* External 5V */
8954 static int prev_on;
8955 int rc;
8956
8957 if (on == prev_on)
8958 return 0;
8959
8960 if (!reg_8901_hdmi_mvs)
8961 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8962 if (!reg_8901_mpp0)
8963 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8964
8965 if (on) {
8966 rc = regulator_enable(reg_8901_mpp0);
8967 if (rc) {
8968 pr_err("'%s' regulator enable failed, rc=%d\n",
8969 "reg_8901_mpp0", rc);
8970 return rc;
8971 }
8972 rc = regulator_enable(reg_8901_hdmi_mvs);
8973 if (rc) {
8974 pr_err("'%s' regulator enable failed, rc=%d\n",
8975 "8901_hdmi_mvs", rc);
8976 return rc;
8977 }
8978 pr_info("%s(on): success\n", __func__);
8979 } else {
8980 rc = regulator_disable(reg_8901_hdmi_mvs);
8981 if (rc)
8982 pr_warning("'%s' regulator disable failed, rc=%d\n",
8983 "8901_hdmi_mvs", rc);
8984 rc = regulator_disable(reg_8901_mpp0);
8985 if (rc)
8986 pr_warning("'%s' regulator disable failed, rc=%d\n",
8987 "reg_8901_mpp0", rc);
8988 pr_info("%s(off): success\n", __func__);
8989 }
8990
8991 prev_on = on;
8992
8993 return 0;
8994}
8995
8996static int hdmi_core_power(int on, int show)
8997{
8998 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8999 static int prev_on;
9000 int rc;
9001
9002 if (on == prev_on)
9003 return 0;
9004
9005 if (!reg_8058_l16)
9006 _GET_REGULATOR(reg_8058_l16, "8058_l16");
9007
9008 if (on) {
9009 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
9010 if (!rc)
9011 rc = regulator_enable(reg_8058_l16);
9012 if (rc) {
9013 pr_err("'%s' regulator enable failed, rc=%d\n",
9014 "8058_l16", rc);
9015 return rc;
9016 }
9017 rc = gpio_request(170, "HDMI_DDC_CLK");
9018 if (rc) {
9019 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9020 "HDMI_DDC_CLK", 170, rc);
9021 goto error1;
9022 }
9023 rc = gpio_request(171, "HDMI_DDC_DATA");
9024 if (rc) {
9025 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9026 "HDMI_DDC_DATA", 171, rc);
9027 goto error2;
9028 }
9029 rc = gpio_request(172, "HDMI_HPD");
9030 if (rc) {
9031 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9032 "HDMI_HPD", 172, rc);
9033 goto error3;
9034 }
9035 pr_info("%s(on): success\n", __func__);
9036 } else {
9037 gpio_free(170);
9038 gpio_free(171);
9039 gpio_free(172);
9040 rc = regulator_disable(reg_8058_l16);
9041 if (rc)
9042 pr_warning("'%s' regulator disable failed, rc=%d\n",
9043 "8058_l16", rc);
9044 pr_info("%s(off): success\n", __func__);
9045 }
9046
9047 prev_on = on;
9048
9049 return 0;
9050
9051error3:
9052 gpio_free(171);
9053error2:
9054 gpio_free(170);
9055error1:
9056 regulator_disable(reg_8058_l16);
9057 return rc;
9058}
9059
9060static int hdmi_cec_power(int on)
9061{
9062 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9063 static int prev_on;
9064 int rc;
9065
9066 if (on == prev_on)
9067 return 0;
9068
9069 if (!reg_8901_l3)
9070 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9071
9072 if (on) {
9073 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9074 if (!rc)
9075 rc = regulator_enable(reg_8901_l3);
9076 if (rc) {
9077 pr_err("'%s' regulator enable failed, rc=%d\n",
9078 "8901_l3", rc);
9079 return rc;
9080 }
9081 rc = gpio_request(169, "HDMI_CEC_VAR");
9082 if (rc) {
9083 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9084 "HDMI_CEC_VAR", 169, rc);
9085 goto error;
9086 }
9087 pr_info("%s(on): success\n", __func__);
9088 } else {
9089 gpio_free(169);
9090 rc = regulator_disable(reg_8901_l3);
9091 if (rc)
9092 pr_warning("'%s' regulator disable failed, rc=%d\n",
9093 "8901_l3", rc);
9094 pr_info("%s(off): success\n", __func__);
9095 }
9096
9097 prev_on = on;
9098
9099 return 0;
9100error:
9101 regulator_disable(reg_8901_l3);
9102 return rc;
9103}
9104
9105#undef _GET_REGULATOR
9106
9107#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9108
9109static int lcdc_panel_power(int on)
9110{
9111 int flag_on = !!on;
9112 static int lcdc_power_save_on;
9113
9114 if (lcdc_power_save_on == flag_on)
9115 return 0;
9116
9117 lcdc_power_save_on = flag_on;
9118
9119 lcdc_samsung_panel_power(on);
9120
9121 return 0;
9122}
9123
9124#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009125
9126static struct msm_bus_vectors rotator_init_vectors[] = {
9127 {
9128 .src = MSM_BUS_MASTER_ROTATOR,
9129 .dst = MSM_BUS_SLAVE_SMI,
9130 .ab = 0,
9131 .ib = 0,
9132 },
9133 {
9134 .src = MSM_BUS_MASTER_ROTATOR,
9135 .dst = MSM_BUS_SLAVE_EBI_CH0,
9136 .ab = 0,
9137 .ib = 0,
9138 },
9139};
9140
9141static struct msm_bus_vectors rotator_ui_vectors[] = {
9142 {
9143 .src = MSM_BUS_MASTER_ROTATOR,
9144 .dst = MSM_BUS_SLAVE_SMI,
9145 .ab = 0,
9146 .ib = 0,
9147 },
9148 {
9149 .src = MSM_BUS_MASTER_ROTATOR,
9150 .dst = MSM_BUS_SLAVE_EBI_CH0,
9151 .ab = (1024 * 600 * 4 * 2 * 60),
9152 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9153 },
9154};
9155
9156static struct msm_bus_vectors rotator_vga_vectors[] = {
9157 {
9158 .src = MSM_BUS_MASTER_ROTATOR,
9159 .dst = MSM_BUS_SLAVE_SMI,
9160 .ab = (640 * 480 * 2 * 2 * 30),
9161 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9162 },
9163 {
9164 .src = MSM_BUS_MASTER_ROTATOR,
9165 .dst = MSM_BUS_SLAVE_EBI_CH0,
9166 .ab = (640 * 480 * 2 * 2 * 30),
9167 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9168 },
9169};
9170
9171static struct msm_bus_vectors rotator_720p_vectors[] = {
9172 {
9173 .src = MSM_BUS_MASTER_ROTATOR,
9174 .dst = MSM_BUS_SLAVE_SMI,
9175 .ab = (1280 * 736 * 2 * 2 * 30),
9176 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9177 },
9178 {
9179 .src = MSM_BUS_MASTER_ROTATOR,
9180 .dst = MSM_BUS_SLAVE_EBI_CH0,
9181 .ab = (1280 * 736 * 2 * 2 * 30),
9182 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9183 },
9184};
9185
9186static struct msm_bus_vectors rotator_1080p_vectors[] = {
9187 {
9188 .src = MSM_BUS_MASTER_ROTATOR,
9189 .dst = MSM_BUS_SLAVE_SMI,
9190 .ab = (1920 * 1088 * 2 * 2 * 30),
9191 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9192 },
9193 {
9194 .src = MSM_BUS_MASTER_ROTATOR,
9195 .dst = MSM_BUS_SLAVE_EBI_CH0,
9196 .ab = (1920 * 1088 * 2 * 2 * 30),
9197 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9198 },
9199};
9200
9201static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9202 {
9203 ARRAY_SIZE(rotator_init_vectors),
9204 rotator_init_vectors,
9205 },
9206 {
9207 ARRAY_SIZE(rotator_ui_vectors),
9208 rotator_ui_vectors,
9209 },
9210 {
9211 ARRAY_SIZE(rotator_vga_vectors),
9212 rotator_vga_vectors,
9213 },
9214 {
9215 ARRAY_SIZE(rotator_720p_vectors),
9216 rotator_720p_vectors,
9217 },
9218 {
9219 ARRAY_SIZE(rotator_1080p_vectors),
9220 rotator_1080p_vectors,
9221 },
9222};
9223
9224struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9225 rotator_bus_scale_usecases,
9226 ARRAY_SIZE(rotator_bus_scale_usecases),
9227 .name = "rotator",
9228};
9229
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009230static struct msm_bus_vectors mdp_init_vectors[] = {
9231 /* For now, 0th array entry is reserved.
9232 * Please leave 0 as is and don't use it
9233 */
9234 {
9235 .src = MSM_BUS_MASTER_MDP_PORT0,
9236 .dst = MSM_BUS_SLAVE_SMI,
9237 .ab = 0,
9238 .ib = 0,
9239 },
9240 /* Master and slaves can be from different fabrics */
9241 {
9242 .src = MSM_BUS_MASTER_MDP_PORT0,
9243 .dst = MSM_BUS_SLAVE_EBI_CH0,
9244 .ab = 0,
9245 .ib = 0,
9246 },
9247};
9248
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009249#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009250static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9251 /* Default case static display/UI/2d/3d if FB SMI */
9252 {
9253 .src = MSM_BUS_MASTER_MDP_PORT0,
9254 .dst = MSM_BUS_SLAVE_SMI,
9255 .ab = 388800000,
9256 .ib = 486000000,
9257 },
9258 /* Master and slaves can be from different fabrics */
9259 {
9260 .src = MSM_BUS_MASTER_MDP_PORT0,
9261 .dst = MSM_BUS_SLAVE_EBI_CH0,
9262 .ab = 0,
9263 .ib = 0,
9264 },
9265};
9266
9267static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9268 /* Default case static display/UI/2d/3d if FB SMI */
9269 {
9270 .src = MSM_BUS_MASTER_MDP_PORT0,
9271 .dst = MSM_BUS_SLAVE_SMI,
9272 .ab = 0,
9273 .ib = 0,
9274 },
9275 /* Master and slaves can be from different fabrics */
9276 {
9277 .src = MSM_BUS_MASTER_MDP_PORT0,
9278 .dst = MSM_BUS_SLAVE_EBI_CH0,
9279 .ab = 388800000,
9280 .ib = 486000000 * 2,
9281 },
9282};
9283static struct msm_bus_vectors mdp_vga_vectors[] = {
9284 /* VGA and less video */
9285 {
9286 .src = MSM_BUS_MASTER_MDP_PORT0,
9287 .dst = MSM_BUS_SLAVE_SMI,
9288 .ab = 458092800,
9289 .ib = 572616000,
9290 },
9291 {
9292 .src = MSM_BUS_MASTER_MDP_PORT0,
9293 .dst = MSM_BUS_SLAVE_EBI_CH0,
9294 .ab = 458092800,
9295 .ib = 572616000 * 2,
9296 },
9297};
9298static struct msm_bus_vectors mdp_720p_vectors[] = {
9299 /* 720p and less video */
9300 {
9301 .src = MSM_BUS_MASTER_MDP_PORT0,
9302 .dst = MSM_BUS_SLAVE_SMI,
9303 .ab = 471744000,
9304 .ib = 589680000,
9305 },
9306 /* Master and slaves can be from different fabrics */
9307 {
9308 .src = MSM_BUS_MASTER_MDP_PORT0,
9309 .dst = MSM_BUS_SLAVE_EBI_CH0,
9310 .ab = 471744000,
9311 .ib = 589680000 * 2,
9312 },
9313};
9314
9315static struct msm_bus_vectors mdp_1080p_vectors[] = {
9316 /* 1080p and less video */
9317 {
9318 .src = MSM_BUS_MASTER_MDP_PORT0,
9319 .dst = MSM_BUS_SLAVE_SMI,
9320 .ab = 575424000,
9321 .ib = 719280000,
9322 },
9323 /* Master and slaves can be from different fabrics */
9324 {
9325 .src = MSM_BUS_MASTER_MDP_PORT0,
9326 .dst = MSM_BUS_SLAVE_EBI_CH0,
9327 .ab = 575424000,
9328 .ib = 719280000 * 2,
9329 },
9330};
9331
9332#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009333static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9334 /* Default case static display/UI/2d/3d if FB SMI */
9335 {
9336 .src = MSM_BUS_MASTER_MDP_PORT0,
9337 .dst = MSM_BUS_SLAVE_SMI,
9338 .ab = 175110000,
9339 .ib = 218887500,
9340 },
9341 /* Master and slaves can be from different fabrics */
9342 {
9343 .src = MSM_BUS_MASTER_MDP_PORT0,
9344 .dst = MSM_BUS_SLAVE_EBI_CH0,
9345 .ab = 0,
9346 .ib = 0,
9347 },
9348};
9349
9350static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9351 /* Default case static display/UI/2d/3d if FB SMI */
9352 {
9353 .src = MSM_BUS_MASTER_MDP_PORT0,
9354 .dst = MSM_BUS_SLAVE_SMI,
9355 .ab = 0,
9356 .ib = 0,
9357 },
9358 /* Master and slaves can be from different fabrics */
9359 {
9360 .src = MSM_BUS_MASTER_MDP_PORT0,
9361 .dst = MSM_BUS_SLAVE_EBI_CH0,
9362 .ab = 216000000,
9363 .ib = 270000000 * 2,
9364 },
9365};
9366static struct msm_bus_vectors mdp_vga_vectors[] = {
9367 /* VGA and less video */
9368 {
9369 .src = MSM_BUS_MASTER_MDP_PORT0,
9370 .dst = MSM_BUS_SLAVE_SMI,
9371 .ab = 216000000,
9372 .ib = 270000000,
9373 },
9374 {
9375 .src = MSM_BUS_MASTER_MDP_PORT0,
9376 .dst = MSM_BUS_SLAVE_EBI_CH0,
9377 .ab = 216000000,
9378 .ib = 270000000 * 2,
9379 },
9380};
9381
9382static struct msm_bus_vectors mdp_720p_vectors[] = {
9383 /* 720p and less video */
9384 {
9385 .src = MSM_BUS_MASTER_MDP_PORT0,
9386 .dst = MSM_BUS_SLAVE_SMI,
9387 .ab = 230400000,
9388 .ib = 288000000,
9389 },
9390 /* Master and slaves can be from different fabrics */
9391 {
9392 .src = MSM_BUS_MASTER_MDP_PORT0,
9393 .dst = MSM_BUS_SLAVE_EBI_CH0,
9394 .ab = 230400000,
9395 .ib = 288000000 * 2,
9396 },
9397};
9398
9399static struct msm_bus_vectors mdp_1080p_vectors[] = {
9400 /* 1080p and less video */
9401 {
9402 .src = MSM_BUS_MASTER_MDP_PORT0,
9403 .dst = MSM_BUS_SLAVE_SMI,
9404 .ab = 334080000,
9405 .ib = 417600000,
9406 },
9407 /* Master and slaves can be from different fabrics */
9408 {
9409 .src = MSM_BUS_MASTER_MDP_PORT0,
9410 .dst = MSM_BUS_SLAVE_EBI_CH0,
9411 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009412 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009413 },
9414};
9415
9416#endif
9417static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9418 {
9419 ARRAY_SIZE(mdp_init_vectors),
9420 mdp_init_vectors,
9421 },
9422 {
9423 ARRAY_SIZE(mdp_sd_smi_vectors),
9424 mdp_sd_smi_vectors,
9425 },
9426 {
9427 ARRAY_SIZE(mdp_sd_ebi_vectors),
9428 mdp_sd_ebi_vectors,
9429 },
9430 {
9431 ARRAY_SIZE(mdp_vga_vectors),
9432 mdp_vga_vectors,
9433 },
9434 {
9435 ARRAY_SIZE(mdp_720p_vectors),
9436 mdp_720p_vectors,
9437 },
9438 {
9439 ARRAY_SIZE(mdp_1080p_vectors),
9440 mdp_1080p_vectors,
9441 },
9442};
9443static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9444 mdp_bus_scale_usecases,
9445 ARRAY_SIZE(mdp_bus_scale_usecases),
9446 .name = "mdp",
9447};
9448
9449#endif
9450#ifdef CONFIG_MSM_BUS_SCALING
9451static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9452 /* For now, 0th array entry is reserved.
9453 * Please leave 0 as is and don't use it
9454 */
9455 {
9456 .src = MSM_BUS_MASTER_MDP_PORT0,
9457 .dst = MSM_BUS_SLAVE_SMI,
9458 .ab = 0,
9459 .ib = 0,
9460 },
9461 /* Master and slaves can be from different fabrics */
9462 {
9463 .src = MSM_BUS_MASTER_MDP_PORT0,
9464 .dst = MSM_BUS_SLAVE_EBI_CH0,
9465 .ab = 0,
9466 .ib = 0,
9467 },
9468};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009469
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009470static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9471 /* For now, 0th array entry is reserved.
9472 * Please leave 0 as is and don't use it
9473 */
9474 {
9475 .src = MSM_BUS_MASTER_MDP_PORT0,
9476 .dst = MSM_BUS_SLAVE_SMI,
9477 .ab = 566092800,
9478 .ib = 707616000,
9479 },
9480 /* Master and slaves can be from different fabrics */
9481 {
9482 .src = MSM_BUS_MASTER_MDP_PORT0,
9483 .dst = MSM_BUS_SLAVE_EBI_CH0,
9484 .ab = 566092800,
9485 .ib = 707616000,
9486 },
9487};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009488
9489static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9490 /* For now, 0th array entry is reserved.
9491 * Please leave 0 as is and don't use it
9492 */
9493 {
9494 .src = MSM_BUS_MASTER_MDP_PORT0,
9495 .dst = MSM_BUS_SLAVE_SMI,
9496 .ab = 2000000000,
9497 .ib = 2000000000,
9498 },
9499 /* Master and slaves can be from different fabrics */
9500 {
9501 .src = MSM_BUS_MASTER_MDP_PORT0,
9502 .dst = MSM_BUS_SLAVE_EBI_CH0,
9503 .ab = 2000000000,
9504 .ib = 2000000000,
9505 },
9506};
9507
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009508static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9509 {
9510 ARRAY_SIZE(dtv_bus_init_vectors),
9511 dtv_bus_init_vectors,
9512 },
9513 {
9514 ARRAY_SIZE(dtv_bus_def_vectors),
9515 dtv_bus_def_vectors,
9516 },
9517};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009518
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009519static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9520 dtv_bus_scale_usecases,
9521 ARRAY_SIZE(dtv_bus_scale_usecases),
9522 .name = "dtv",
9523};
9524
9525static struct lcdc_platform_data dtv_pdata = {
9526 .bus_scale_table = &dtv_bus_scale_pdata,
9527};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009528
9529static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9530 {
9531 ARRAY_SIZE(dtv_bus_init_vectors),
9532 dtv_bus_init_vectors,
9533 },
9534 {
9535 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9536 dtv_bus_hdmi_prim_vectors,
9537 },
9538};
9539
9540static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9541 dtv_hdmi_prim_bus_scale_usecases,
9542 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9543 .name = "dtv",
9544};
9545
9546static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9547 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9548};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009549#endif
9550
9551
9552static struct lcdc_platform_data lcdc_pdata = {
9553 .lcdc_power_save = lcdc_panel_power,
9554};
9555
9556
9557#define MDP_VSYNC_GPIO 28
9558
9559/*
9560 * MIPI_DSI only use 8058_LDO0 which need always on
9561 * therefore it need to be put at low power mode if
9562 * it was not used instead of turn it off.
9563 */
9564static int mipi_dsi_panel_power(int on)
9565{
9566 int flag_on = !!on;
9567 static int mipi_dsi_power_save_on;
9568 static struct regulator *ldo0;
9569 int rc = 0;
9570
9571 if (mipi_dsi_power_save_on == flag_on)
9572 return 0;
9573
9574 mipi_dsi_power_save_on = flag_on;
9575
9576 if (ldo0 == NULL) { /* init */
9577 ldo0 = regulator_get(NULL, "8058_l0");
9578 if (IS_ERR(ldo0)) {
9579 pr_debug("%s: LDO0 failed\n", __func__);
9580 rc = PTR_ERR(ldo0);
9581 return rc;
9582 }
9583
9584 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9585 if (rc)
9586 goto out;
9587
9588 rc = regulator_enable(ldo0);
9589 if (rc)
9590 goto out;
9591 }
9592
9593 if (on) {
9594 /* set ldo0 to HPM */
9595 rc = regulator_set_optimum_mode(ldo0, 100000);
9596 if (rc < 0)
9597 goto out;
9598 } else {
9599 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309600 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009601 if (rc < 0)
9602 goto out;
9603 }
9604
9605 return 0;
9606out:
9607 regulator_disable(ldo0);
9608 regulator_put(ldo0);
9609 ldo0 = NULL;
9610 return rc;
9611}
9612
9613static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9614 .vsync_gpio = MDP_VSYNC_GPIO,
9615 .dsi_power_save = mipi_dsi_panel_power,
9616};
9617
9618#ifdef CONFIG_FB_MSM_TVOUT
9619static struct regulator *reg_8058_l13;
9620
9621static int atv_dac_power(int on)
9622{
9623 int rc = 0;
9624 #define _GET_REGULATOR(var, name) do { \
9625 var = regulator_get(NULL, name); \
9626 if (IS_ERR(var)) { \
9627 pr_info("'%s' regulator not found, rc=%ld\n", \
9628 name, IS_ERR(var)); \
9629 var = NULL; \
9630 return -ENODEV; \
9631 } \
9632 } while (0)
9633
9634 if (!reg_8058_l13)
9635 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9636 #undef _GET_REGULATOR
9637
9638 if (on) {
9639 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9640 if (rc) {
9641 pr_info("%s: '%s' regulator set voltage failed,\
9642 rc=%d\n", __func__, "8058_l13", rc);
9643 return rc;
9644 }
9645
9646 rc = regulator_enable(reg_8058_l13);
9647 if (rc) {
9648 pr_err("%s: '%s' regulator enable failed,\
9649 rc=%d\n", __func__, "8058_l13", rc);
9650 return rc;
9651 }
9652 } else {
9653 rc = regulator_force_disable(reg_8058_l13);
9654 if (rc)
9655 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9656 __func__, "8058_l13", rc);
9657 }
9658 return rc;
9659
9660}
9661#endif
9662
9663#ifdef CONFIG_FB_MSM_MIPI_DSI
9664int mdp_core_clk_rate_table[] = {
9665 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009666 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009667 160000000,
9668 200000000,
9669};
9670#else
9671int mdp_core_clk_rate_table[] = {
9672 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009673 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009674 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009675 200000000,
9676};
9677#endif
9678
9679static struct msm_panel_common_pdata mdp_pdata = {
9680 .gpio = MDP_VSYNC_GPIO,
9681 .mdp_core_clk_rate = 59080000,
9682 .mdp_core_clk_table = mdp_core_clk_rate_table,
9683 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9684#ifdef CONFIG_MSM_BUS_SCALING
9685 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9686#endif
9687 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009688#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009689 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009690#else
9691 .mem_hid = MEMTYPE_EBI1,
9692#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009693};
9694
Huaibin Yanga5419422011-12-08 23:52:10 -08009695static void __init reserve_mdp_memory(void)
9696{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009697 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9698 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9699#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9700 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9701 mdp_pdata.ov0_wb_size;
9702 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9703 mdp_pdata.ov1_wb_size;
9704#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009705}
9706
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009707#ifdef CONFIG_FB_MSM_TVOUT
9708
9709#ifdef CONFIG_MSM_BUS_SCALING
9710static struct msm_bus_vectors atv_bus_init_vectors[] = {
9711 /* For now, 0th array entry is reserved.
9712 * Please leave 0 as is and don't use it
9713 */
9714 {
9715 .src = MSM_BUS_MASTER_MDP_PORT0,
9716 .dst = MSM_BUS_SLAVE_SMI,
9717 .ab = 0,
9718 .ib = 0,
9719 },
9720 /* Master and slaves can be from different fabrics */
9721 {
9722 .src = MSM_BUS_MASTER_MDP_PORT0,
9723 .dst = MSM_BUS_SLAVE_EBI_CH0,
9724 .ab = 0,
9725 .ib = 0,
9726 },
9727};
9728static struct msm_bus_vectors atv_bus_def_vectors[] = {
9729 /* For now, 0th array entry is reserved.
9730 * Please leave 0 as is and don't use it
9731 */
9732 {
9733 .src = MSM_BUS_MASTER_MDP_PORT0,
9734 .dst = MSM_BUS_SLAVE_SMI,
9735 .ab = 236390400,
9736 .ib = 265939200,
9737 },
9738 /* Master and slaves can be from different fabrics */
9739 {
9740 .src = MSM_BUS_MASTER_MDP_PORT0,
9741 .dst = MSM_BUS_SLAVE_EBI_CH0,
9742 .ab = 236390400,
9743 .ib = 265939200,
9744 },
9745};
9746static struct msm_bus_paths atv_bus_scale_usecases[] = {
9747 {
9748 ARRAY_SIZE(atv_bus_init_vectors),
9749 atv_bus_init_vectors,
9750 },
9751 {
9752 ARRAY_SIZE(atv_bus_def_vectors),
9753 atv_bus_def_vectors,
9754 },
9755};
9756static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9757 atv_bus_scale_usecases,
9758 ARRAY_SIZE(atv_bus_scale_usecases),
9759 .name = "atv",
9760};
9761#endif
9762
9763static struct tvenc_platform_data atv_pdata = {
9764 .poll = 0,
9765 .pm_vid_en = atv_dac_power,
9766#ifdef CONFIG_MSM_BUS_SCALING
9767 .bus_scale_table = &atv_bus_scale_pdata,
9768#endif
9769};
9770#endif
9771
9772static void __init msm_fb_add_devices(void)
9773{
9774#ifdef CONFIG_FB_MSM_LCDC_DSUB
9775 mdp_pdata.mdp_core_clk_table = NULL;
9776 mdp_pdata.num_mdp_clk = 0;
9777 mdp_pdata.mdp_core_clk_rate = 200000000;
9778#endif
9779 if (machine_is_msm8x60_rumi3())
9780 msm_fb_register_device("mdp", NULL);
9781 else
9782 msm_fb_register_device("mdp", &mdp_pdata);
9783
9784 msm_fb_register_device("lcdc", &lcdc_pdata);
9785 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9786#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009787 if (hdmi_is_primary)
9788 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9789 else
9790 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009791#endif
9792#ifdef CONFIG_FB_MSM_TVOUT
9793 msm_fb_register_device("tvenc", &atv_pdata);
9794 msm_fb_register_device("tvout_device", NULL);
9795#endif
9796}
9797
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009798/**
9799 * Set MDP clocks to high frequency to avoid underflow when
9800 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9801 */
9802static void set_mdp_clocks_for_wuxga(void)
9803{
9804 int i;
9805
9806 mdp_sd_smi_vectors[0].ab = 2000000000;
9807 mdp_sd_smi_vectors[0].ib = 2000000000;
9808 mdp_sd_smi_vectors[1].ab = 2000000000;
9809 mdp_sd_smi_vectors[1].ib = 2000000000;
9810
9811 mdp_sd_ebi_vectors[0].ab = 2000000000;
9812 mdp_sd_ebi_vectors[0].ib = 2000000000;
9813 mdp_sd_ebi_vectors[1].ab = 2000000000;
9814 mdp_sd_ebi_vectors[1].ib = 2000000000;
9815
9816 mdp_vga_vectors[0].ab = 2000000000;
9817 mdp_vga_vectors[0].ib = 2000000000;
9818 mdp_vga_vectors[1].ab = 2000000000;
9819 mdp_vga_vectors[1].ib = 2000000000;
9820
9821 mdp_720p_vectors[0].ab = 2000000000;
9822 mdp_720p_vectors[0].ib = 2000000000;
9823 mdp_720p_vectors[1].ab = 2000000000;
9824 mdp_720p_vectors[1].ib = 2000000000;
9825
9826 mdp_1080p_vectors[0].ab = 2000000000;
9827 mdp_1080p_vectors[0].ib = 2000000000;
9828 mdp_1080p_vectors[1].ab = 2000000000;
9829 mdp_1080p_vectors[1].ib = 2000000000;
9830
9831 mdp_pdata.mdp_core_clk_rate = 200000000;
9832
9833 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9834 mdp_core_clk_rate_table[i] = 200000000;
9835}
9836
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009837#if (defined(CONFIG_MARIMBA_CORE)) && \
9838 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9839
9840static const struct {
9841 char *name;
9842 int vmin;
9843 int vmax;
9844} bt_regs_info[] = {
9845 { "8058_s3", 1800000, 1800000 },
9846 { "8058_s2", 1300000, 1300000 },
9847 { "8058_l8", 2900000, 3050000 },
9848};
9849
9850static struct {
9851 bool enabled;
9852} bt_regs_status[] = {
9853 { false },
9854 { false },
9855 { false },
9856};
9857static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9858
9859static int bahama_bt(int on)
9860{
9861 int rc;
9862 int i;
9863 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9864
9865 struct bahama_variant_register {
9866 const size_t size;
9867 const struct bahama_config_register *set;
9868 };
9869
9870 const struct bahama_config_register *p;
9871
9872 u8 version;
9873
9874 const struct bahama_config_register v10_bt_on[] = {
9875 { 0xE9, 0x00, 0xFF },
9876 { 0xF4, 0x80, 0xFF },
9877 { 0xE4, 0x00, 0xFF },
9878 { 0xE5, 0x00, 0x0F },
9879#ifdef CONFIG_WLAN
9880 { 0xE6, 0x38, 0x7F },
9881 { 0xE7, 0x06, 0xFF },
9882#endif
9883 { 0xE9, 0x21, 0xFF },
9884 { 0x01, 0x0C, 0x1F },
9885 { 0x01, 0x08, 0x1F },
9886 };
9887
9888 const struct bahama_config_register v20_bt_on_fm_off[] = {
9889 { 0x11, 0x0C, 0xFF },
9890 { 0x13, 0x01, 0xFF },
9891 { 0xF4, 0x80, 0xFF },
9892 { 0xF0, 0x00, 0xFF },
9893 { 0xE9, 0x00, 0xFF },
9894#ifdef CONFIG_WLAN
9895 { 0x81, 0x00, 0x7F },
9896 { 0x82, 0x00, 0xFF },
9897 { 0xE6, 0x38, 0x7F },
9898 { 0xE7, 0x06, 0xFF },
9899#endif
9900 { 0xE9, 0x21, 0xFF },
9901 };
9902
9903 const struct bahama_config_register v20_bt_on_fm_on[] = {
9904 { 0x11, 0x0C, 0xFF },
9905 { 0x13, 0x01, 0xFF },
9906 { 0xF4, 0x86, 0xFF },
9907 { 0xF0, 0x06, 0xFF },
9908 { 0xE9, 0x00, 0xFF },
9909#ifdef CONFIG_WLAN
9910 { 0x81, 0x00, 0x7F },
9911 { 0x82, 0x00, 0xFF },
9912 { 0xE6, 0x38, 0x7F },
9913 { 0xE7, 0x06, 0xFF },
9914#endif
9915 { 0xE9, 0x21, 0xFF },
9916 };
9917
9918 const struct bahama_config_register v10_bt_off[] = {
9919 { 0xE9, 0x00, 0xFF },
9920 };
9921
9922 const struct bahama_config_register v20_bt_off_fm_off[] = {
9923 { 0xF4, 0x84, 0xFF },
9924 { 0xF0, 0x04, 0xFF },
9925 { 0xE9, 0x00, 0xFF }
9926 };
9927
9928 const struct bahama_config_register v20_bt_off_fm_on[] = {
9929 { 0xF4, 0x86, 0xFF },
9930 { 0xF0, 0x06, 0xFF },
9931 { 0xE9, 0x00, 0xFF }
9932 };
9933 const struct bahama_variant_register bt_bahama[2][3] = {
9934 {
9935 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9936 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9937 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9938 },
9939 {
9940 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9941 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9942 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9943 }
9944 };
9945
9946 u8 offset = 0; /* index into bahama configs */
9947
9948 on = on ? 1 : 0;
9949 version = read_bahama_ver();
9950
9951 if (version == VER_UNSUPPORTED) {
9952 dev_err(&msm_bt_power_device.dev,
9953 "%s: unsupported version\n",
9954 __func__);
9955 return -EIO;
9956 }
9957
9958 if (version == VER_2_0) {
9959 if (marimba_get_fm_status(&config))
9960 offset = 0x01;
9961 }
9962
9963 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9964 if (on && (version == VER_2_0)) {
9965 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9966 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9967 && (bt_regs_status[i].enabled == true)) {
9968 if (regulator_disable(bt_regs[i])) {
9969 dev_err(&msm_bt_power_device.dev,
9970 "%s: regulator disable failed",
9971 __func__);
9972 }
9973 bt_regs_status[i].enabled = false;
9974 break;
9975 }
9976 }
9977 }
9978
9979 p = bt_bahama[on][version + offset].set;
9980
9981 dev_info(&msm_bt_power_device.dev,
9982 "%s: found version %d\n", __func__, version);
9983
9984 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9985 u8 value = (p+i)->value;
9986 rc = marimba_write_bit_mask(&config,
9987 (p+i)->reg,
9988 &value,
9989 sizeof((p+i)->value),
9990 (p+i)->mask);
9991 if (rc < 0) {
9992 dev_err(&msm_bt_power_device.dev,
9993 "%s: reg %d write failed: %d\n",
9994 __func__, (p+i)->reg, rc);
9995 return rc;
9996 }
9997 dev_dbg(&msm_bt_power_device.dev,
9998 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9999 __func__, (p+i)->reg,
10000 value, (p+i)->mask);
10001 }
10002 /* Update BT Status */
10003 if (on)
10004 marimba_set_bt_status(&config, true);
10005 else
10006 marimba_set_bt_status(&config, false);
10007
10008 return 0;
10009}
10010
10011static int bluetooth_use_regulators(int on)
10012{
10013 int i, recover = -1, rc = 0;
10014
10015 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10016 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
10017 bt_regs_info[i].name) :
10018 (regulator_put(bt_regs[i]), NULL);
10019 if (IS_ERR(bt_regs[i])) {
10020 rc = PTR_ERR(bt_regs[i]);
10021 dev_err(&msm_bt_power_device.dev,
10022 "regulator %s get failed (%d)\n",
10023 bt_regs_info[i].name, rc);
10024 recover = i - 1;
10025 bt_regs[i] = NULL;
10026 break;
10027 }
10028
10029 if (!on)
10030 continue;
10031
10032 rc = regulator_set_voltage(bt_regs[i],
10033 bt_regs_info[i].vmin,
10034 bt_regs_info[i].vmax);
10035 if (rc < 0) {
10036 dev_err(&msm_bt_power_device.dev,
10037 "regulator %s voltage set (%d)\n",
10038 bt_regs_info[i].name, rc);
10039 recover = i;
10040 break;
10041 }
10042 }
10043
10044 if (on && (recover > -1))
10045 for (i = recover; i >= 0; i--) {
10046 regulator_put(bt_regs[i]);
10047 bt_regs[i] = NULL;
10048 }
10049
10050 return rc;
10051}
10052
10053static int bluetooth_switch_regulators(int on)
10054{
10055 int i, rc = 0;
10056
10057 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10058 if (on && (bt_regs_status[i].enabled == false)) {
10059 rc = regulator_enable(bt_regs[i]);
10060 if (rc < 0) {
10061 dev_err(&msm_bt_power_device.dev,
10062 "regulator %s %s failed (%d)\n",
10063 bt_regs_info[i].name,
10064 "enable", rc);
10065 if (i > 0) {
10066 while (--i) {
10067 regulator_disable(bt_regs[i]);
10068 bt_regs_status[i].enabled
10069 = false;
10070 }
10071 break;
10072 }
10073 }
10074 bt_regs_status[i].enabled = true;
10075 } else if (!on && (bt_regs_status[i].enabled == true)) {
10076 rc = regulator_disable(bt_regs[i]);
10077 if (rc < 0) {
10078 dev_err(&msm_bt_power_device.dev,
10079 "regulator %s %s failed (%d)\n",
10080 bt_regs_info[i].name,
10081 "disable", rc);
10082 break;
10083 }
10084 bt_regs_status[i].enabled = false;
10085 }
10086 }
10087 return rc;
10088}
10089
10090static struct msm_xo_voter *bt_clock;
10091
10092static int bluetooth_power(int on)
10093{
10094 int rc = 0;
10095 int id;
10096
10097 /* In case probe function fails, cur_connv_type would be -1 */
10098 id = adie_get_detected_connectivity_type();
10099 if (id != BAHAMA_ID) {
10100 pr_err("%s: unexpected adie connectivity type: %d\n",
10101 __func__, id);
10102 return -ENODEV;
10103 }
10104
10105 if (on) {
10106
10107 rc = bluetooth_use_regulators(1);
10108 if (rc < 0)
10109 goto out;
10110
10111 rc = bluetooth_switch_regulators(1);
10112
10113 if (rc < 0)
10114 goto fail_put;
10115
10116 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10117
10118 if (IS_ERR(bt_clock)) {
10119 pr_err("Couldn't get TCXO_D0 voter\n");
10120 goto fail_switch;
10121 }
10122
10123 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10124
10125 if (rc < 0) {
10126 pr_err("Failed to vote for TCXO_DO ON\n");
10127 goto fail_vote;
10128 }
10129
10130 rc = bahama_bt(1);
10131
10132 if (rc < 0)
10133 goto fail_clock;
10134
10135 msleep(10);
10136
10137 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10138
10139 if (rc < 0) {
10140 pr_err("Failed to vote for TCXO_DO pin control\n");
10141 goto fail_vote;
10142 }
10143 } else {
10144 /* check for initial RFKILL block (power off) */
10145 /* some RFKILL versions/configurations rfkill_register */
10146 /* calls here for an initial set_block */
10147 /* avoid calling i2c and regulator before unblock (on) */
10148 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10149 dev_info(&msm_bt_power_device.dev,
10150 "%s: initialized OFF/blocked\n", __func__);
10151 goto out;
10152 }
10153
10154 bahama_bt(0);
10155
10156fail_clock:
10157 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10158fail_vote:
10159 msm_xo_put(bt_clock);
10160fail_switch:
10161 bluetooth_switch_regulators(0);
10162fail_put:
10163 bluetooth_use_regulators(0);
10164 }
10165
10166out:
10167 if (rc < 0)
10168 on = 0;
10169 dev_info(&msm_bt_power_device.dev,
10170 "Bluetooth power switch: state %d result %d\n", on, rc);
10171
10172 return rc;
10173}
10174
10175#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10176
10177static void __init msm8x60_cfg_smsc911x(void)
10178{
10179 smsc911x_resources[1].start =
10180 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10181 smsc911x_resources[1].end =
10182 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10183}
10184
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010185void msm_fusion_setup_pinctrl(void)
10186{
10187 struct msm_xo_voter *a1;
10188
10189 if (socinfo_get_platform_subtype() == 0x3) {
10190 /*
10191 * Vote for the A1 clock to be in pin control mode before
10192 * the external images are loaded.
10193 */
10194 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10195 BUG_ON(!a1);
10196 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10197 }
10198}
10199
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010200struct msm_board_data {
10201 struct msm_gpiomux_configs *gpiomux_cfgs;
10202};
10203
10204static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10205 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10206};
10207
10208static struct msm_board_data msm8x60_sim_board_data __initdata = {
10209 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10210};
10211
10212static struct msm_board_data msm8x60_surf_board_data __initdata = {
10213 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10214};
10215
10216static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10217 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10218};
10219
10220static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10221 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10222};
10223
10224static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10225 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10226};
10227
10228static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10229 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10230};
10231
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010232static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10233 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10234};
10235
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010236static void __init msm8x60_init(struct msm_board_data *board_data)
10237{
10238 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010239#ifdef CONFIG_USB_EHCI_MSM_72K
10240 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10241 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10242 .level = PM8901_MPP_DIG_LEVEL_L5,
10243 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10244 };
10245#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010246 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010247
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010248 /*
10249 * Initialize RPM first as other drivers and devices may need
10250 * it for their initialization.
10251 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010252 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10253 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010254 if (msm_xo_init())
10255 pr_err("Failed to initialize XO votes\n");
10256
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010257 msm8x60_check_2d_hardware();
10258
10259 /* Change SPM handling of core 1 if PMM 8160 is present. */
10260 soc_platform_version = socinfo_get_platform_version();
10261 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10262 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10263 struct msm_spm_platform_data *spm_data;
10264
10265 spm_data = &msm_spm_data_v1[1];
10266 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10267 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10268
10269 spm_data = &msm_spm_data[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
10274 /*
10275 * Initialize SPM before acpuclock as the latter calls into SPM
10276 * driver to set ACPU voltages.
10277 */
10278 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10279 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10280 else
10281 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10282
10283 /*
10284 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10285 * devices so that the RPM doesn't drop into a low power mode that an
10286 * un-reworked SURF cannot resume from.
10287 */
10288 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010289 int i;
10290
10291 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10292 if (rpm_regulator_init_data[i].id
10293 == RPM_VREG_ID_PM8901_L4
10294 || rpm_regulator_init_data[i].id
10295 == RPM_VREG_ID_PM8901_L6)
10296 rpm_regulator_init_data[i]
10297 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010298 }
10299
10300 /*
10301 * Disable regulator info printing so that regulator registration
10302 * messages do not enter the kmsg log.
10303 */
10304 regulator_suppress_info_printing();
10305
10306 /* Initialize regulators needed for clock_init. */
10307 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10308
Stephen Boydbb600ae2011-08-02 20:11:40 -070010309 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010310
10311 /* Buses need to be initialized before early-device registration
10312 * to get the platform data for fabrics.
10313 */
10314 msm8x60_init_buses();
10315 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10316 /* CPU frequency control is not supported on simulated targets. */
10317 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010318 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010319
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010320 /*
10321 * Enable EBI2 only for boards which make use of it. Leave
10322 * it disabled for all others for additional power savings.
10323 */
10324 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10325 machine_is_msm8x60_rumi3() ||
10326 machine_is_msm8x60_sim() ||
10327 machine_is_msm8x60_fluid() ||
10328 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010329 msm8x60_init_ebi2();
10330 msm8x60_init_tlmm();
10331 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10332 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010333#ifdef CONFIG_MSM_CAMERA_V4L2
10334 msm8x60_init_cam();
10335#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010336 msm8x60_init_mmc();
10337
Kevin Chan3be11612012-03-22 20:05:40 -070010338
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010339#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10340 msm8x60_init_pm8058_othc();
10341#endif
10342
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010343 if (machine_is_msm8x60_fluid())
10344 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10345 else if (machine_is_msm8x60_dragon())
10346 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10347 else
10348 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Kevin Chan3be11612012-03-22 20:05:40 -070010349#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang53d27a82011-07-13 14:32:58 -040010350 /* Specify reset pin for OV9726 */
10351 if (machine_is_msm8x60_dragon()) {
10352 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10353 ov9726_sensor_8660_info.mount_angle = 270;
10354 }
Kevin Chan3be11612012-03-22 20:05:40 -070010355#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010356#ifdef CONFIG_BATTERY_MSM8X60
10357 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10358 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10359 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10360 platform_device_register(&msm_charger_device);
10361#endif
10362
10363 if (machine_is_msm8x60_dragon())
10364 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10365 if (!machine_is_msm8x60_fluid())
10366 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10367
10368 /* configure pmic leds */
10369 if (machine_is_msm8x60_fluid())
10370 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10371 else if (machine_is_msm8x60_dragon())
10372 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10373 else
10374 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10375
10376 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10377 machine_is_msm8x60_dragon()) {
10378 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10379 }
10380
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010381 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10382 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010383 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010384 msm8x60_cfg_smsc911x();
10385 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010386 platform_add_devices(msm8660_footswitch,
10387 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010388 platform_add_devices(surf_devices,
10389 ARRAY_SIZE(surf_devices));
10390
10391#ifdef CONFIG_MSM_DSPS
10392 if (machine_is_msm8x60_fluid()) {
10393 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10394 msm8x60_init_dsps();
10395 }
10396#endif
10397
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010398 pm8901_vreg_mpp0_init();
10399
10400 platform_device_register(&msm8x60_8901_mpp_vreg);
10401
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010402#ifdef CONFIG_USB_EHCI_MSM_72K
10403 /*
10404 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10405 * fluid
10406 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010407 if (machine_is_msm8x60_fluid())
10408 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10409 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010410#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010411
10412#ifdef CONFIG_SND_SOC_MSM8660_APQ
10413 if (machine_is_msm8x60_dragon())
10414 platform_add_devices(dragon_alsa_devices,
10415 ARRAY_SIZE(dragon_alsa_devices));
10416 else
10417#endif
10418 platform_add_devices(asoc_devices,
10419 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010420 } else {
10421 msm8x60_configure_smc91x();
10422 platform_add_devices(rumi_sim_devices,
10423 ARRAY_SIZE(rumi_sim_devices));
10424 }
10425#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010426 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10427 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010428 msm8x60_cfg_isp1763();
10429#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010430
10431 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10432 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10433
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010434
10435#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10436 if (machine_is_msm8x60_fluid())
10437 platform_device_register(&msm_gsbi10_qup_spi_device);
10438 else
10439 platform_device_register(&msm_gsbi1_qup_spi_device);
10440#endif
10441
10442#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10443 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10444 if (machine_is_msm8x60_fluid())
10445 cyttsp_set_params();
10446#endif
10447 if (!machine_is_msm8x60_sim())
10448 msm_fb_add_devices();
10449 fixup_i2c_configs();
10450 register_i2c_devices();
10451
Terence Hampson1c73fef2011-07-19 17:10:49 -040010452 if (machine_is_msm8x60_dragon())
10453 smsc911x_config.reset_gpio
10454 = GPIO_ETHERNET_RESET_N_DRAGON;
10455
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010456 platform_device_register(&smsc911x_device);
10457
10458#if (defined(CONFIG_SPI_QUP)) && \
10459 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010460 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10461 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010462
10463 if (machine_is_msm8x60_fluid()) {
10464#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10465 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10466 spi_register_board_info(lcdc_samsung_spi_board_info,
10467 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10468 } else
10469#endif
10470 {
10471#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10472 spi_register_board_info(lcdc_auo_spi_board_info,
10473 ARRAY_SIZE(lcdc_auo_spi_board_info));
10474#endif
10475 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010476#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10477 } else if (machine_is_msm8x60_dragon()) {
10478 spi_register_board_info(lcdc_nt35582_spi_board_info,
10479 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10480#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010481 }
10482#endif
10483
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010484 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010485
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010486 pm8058_gpios_init();
10487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010488#ifdef CONFIG_SENSORS_MSM_ADC
10489 if (machine_is_msm8x60_fluid()) {
10490 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10491 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10492 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10493 msm_adc_pdata.gpio_config = APROC_CONFIG;
10494 else
10495 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10496 }
10497 msm_adc_pdata.target_hw = MSM_8x60;
10498#endif
10499#ifdef CONFIG_MSM8X60_AUDIO
10500 msm_snddev_init();
10501#endif
10502#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10503 if (machine_is_msm8x60_fluid())
10504 platform_device_register(&fluid_leds_gpio);
10505 else
10506 platform_device_register(&gpio_leds);
10507#endif
10508
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010509 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010510
10511 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10512 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010513}
10514
10515static void __init msm8x60_rumi3_init(void)
10516{
10517 msm8x60_init(&msm8x60_rumi3_board_data);
10518}
10519
10520static void __init msm8x60_sim_init(void)
10521{
10522 msm8x60_init(&msm8x60_sim_board_data);
10523}
10524
10525static void __init msm8x60_surf_init(void)
10526{
10527 msm8x60_init(&msm8x60_surf_board_data);
10528}
10529
10530static void __init msm8x60_ffa_init(void)
10531{
10532 msm8x60_init(&msm8x60_ffa_board_data);
10533}
10534
10535static void __init msm8x60_fluid_init(void)
10536{
10537 msm8x60_init(&msm8x60_fluid_board_data);
10538}
10539
10540static void __init msm8x60_charm_surf_init(void)
10541{
10542 msm8x60_init(&msm8x60_charm_surf_board_data);
10543}
10544
10545static void __init msm8x60_charm_ffa_init(void)
10546{
10547 msm8x60_init(&msm8x60_charm_ffa_board_data);
10548}
10549
10550static void __init msm8x60_charm_init_early(void)
10551{
10552 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010553}
10554
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010555static void __init msm8x60_dragon_init(void)
10556{
10557 msm8x60_init(&msm8x60_dragon_board_data);
10558}
10559
Steve Mucklea55df6e2010-01-07 12:43:24 -080010560MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10561 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010562 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010563 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010564 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010565 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010566 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010567 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010568MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010569
10570MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10571 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010572 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010573 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010574 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010575 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010576 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010577 .init_early = msm8x60_charm_init_early,
10578MACHINE_END
10579
10580MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10581 .map_io = msm8x60_map_io,
10582 .reserve = msm8x60_reserve,
10583 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010584 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010585 .init_machine = msm8x60_surf_init,
10586 .timer = &msm_timer,
10587 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010588MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010589
10590MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10591 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010592 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010593 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010594 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010595 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010596 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010597 .init_early = msm8x60_charm_init_early,
10598MACHINE_END
10599
10600MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10601 .map_io = msm8x60_map_io,
10602 .reserve = msm8x60_reserve,
10603 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010604 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010605 .init_machine = msm8x60_fluid_init,
10606 .timer = &msm_timer,
10607 .init_early = msm8x60_charm_init_early,
10608MACHINE_END
10609
10610MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10611 .map_io = msm8x60_map_io,
10612 .reserve = msm8x60_reserve,
10613 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010614 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010615 .init_machine = msm8x60_charm_surf_init,
10616 .timer = &msm_timer,
10617 .init_early = msm8x60_charm_init_early,
10618MACHINE_END
10619
10620MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10621 .map_io = msm8x60_map_io,
10622 .reserve = msm8x60_reserve,
10623 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010624 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010625 .init_machine = msm8x60_charm_ffa_init,
10626 .timer = &msm_timer,
10627 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010628MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010629
10630MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10631 .map_io = msm8x60_map_io,
10632 .reserve = msm8x60_reserve,
10633 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010634 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010635 .init_machine = msm8x60_dragon_init,
10636 .timer = &msm_timer,
10637 .init_early = msm8x60_charm_init_early,
10638MACHINE_END