blob: 54c8fbdcc7fc4fe3274c108557449db28ac8b7f5 [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Steve Mucklea55df6e2010-01-07 12:43:24 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Steve Mucklea55df6e2010-01-07 12:43:24 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <linux/gpio.h>
Steve Muckle9161d302010-02-11 11:50:40 -080017#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/io.h>
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053019#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/mfd/pmic8058.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080021
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022#include <linux/leds.h>
23#include <linux/pmic8058-othc.h>
24#include <linux/mfd/pmic8901.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070025#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/regulator/pmic8901-regulator.h>
27#include <linux/bootmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#include <linux/msm_adc.h>
29#include <linux/m_adcproc.h>
30#include <linux/mfd/marimba.h>
31#include <linux/msm-charger.h>
32#include <linux/i2c.h>
33#include <linux/i2c/sx150x.h>
34#include <linux/smsc911x.h>
35#include <linux/spi/spi.h>
36#include <linux/input/tdisc_shinetsu.h>
37#include <linux/input/cy8c_ts.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070038#include <linux/cyttsp-qc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039#include <linux/i2c/isa1200.h>
40#include <linux/dma-mapping.h>
41#include <linux/i2c/bq27520.h>
42
43#ifdef CONFIG_ANDROID_PMEM
44#include <linux/android_pmem.h>
45#endif
46
47#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
48#include <linux/i2c/smb137b.h>
49#endif
Lei Zhou338cab82011-08-19 13:38:17 -040050#ifdef CONFIG_SND_SOC_WM8903
51#include <sound/wm8903.h>
52#endif
Steve Mucklea55df6e2010-01-07 12:43:24 -080053#include <asm/mach-types.h>
54#include <asm/mach/arch.h>
Stephen Boyd9e775ad2011-08-12 00:14:28 +010055#include <asm/setup.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053056#include <asm/hardware/gic.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080057
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/dma.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080059#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#include <mach/irqs.h>
61#include <mach/msm_spi.h>
62#include <mach/msm_serial_hs.h>
63#include <mach/msm_serial_hs_lite.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080064#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#include <mach/msm_memtypes.h>
66#include <asm/mach/mmc.h>
67#include <mach/msm_battery.h>
68#include <mach/msm_hsusb.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070069#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#ifdef CONFIG_MSM_DSPS
71#include <mach/msm_dsps.h>
72#endif
73#include <mach/msm_xo.h>
74#include <mach/msm_bus_board.h>
75#include <mach/socinfo.h>
76#include <linux/i2c/isl9519.h>
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
81#include <linux/regulator/consumer.h>
82#include <linux/regulator/machine.h>
83#include <mach/sdio_al.h>
84#include <mach/rpm.h>
85#include <mach/rpm-regulator.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070086#include <mach/restart.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053087#include <mach/board-msm8660.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070088#include <mach/iommu_domains.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090#include "devices.h"
91#include "devices-msm8x60.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080092#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080093#include "pm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053094#include <mach/mpm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#include "spm.h"
96#include "rpm_log.h"
97#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098#include "gpiomux-8x60.h"
99#include "rpm_stats.h"
100#include "peripheral-loader.h"
101#include <linux/platform_data/qcom_crypto_device.h>
102#include "rpm_resources.h"
Matt 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 } \
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100271}
272
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530273#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
274{ \
275 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
276 .config = { \
277 .type = PM8XXX_MPP_TYPE_##_type, \
278 .level = _level, \
279 .control = PM8XXX_MPP_##_control, \
280 } \
281}
282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283/*
284 * The UI_INTx_N lines are pmic gpio lines which connect i2c
285 * gpio expanders to the pm8058.
286 */
287#define UI_INT1_N 25
288#define UI_INT2_N 34
289#define UI_INT3_N 14
290/*
291FM GPIO is GPIO 18 on PMIC 8058.
292As the index starts from 0 in the PMIC driver, and hence 17
293corresponds to GPIO 18 on PMIC 8058.
294*/
295#define FM_GPIO 17
296
297#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
298static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
299static void *sdc2_status_notify_cb_devid;
300#endif
301
302#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
303static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
304static void *sdc5_status_notify_cb_devid;
305#endif
306
307static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
308 [0] = {
309 .reg_base_addr = MSM_SAW0_BASE,
310
311#ifdef CONFIG_MSM_AVS_HW
312 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
313#endif
314 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
315 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
316 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
317 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
318
319 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
320 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
322
323 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
324 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
325 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
326
327 .awake_vlevel = 0x94,
328 .retention_vlevel = 0x81,
329 .collapse_vlevel = 0x20,
330 .retention_mid_vlevel = 0x94,
331 .collapse_mid_vlevel = 0x8C,
332
333 .vctl_timeout_us = 50,
334 },
335
336 [1] = {
337 .reg_base_addr = MSM_SAW1_BASE,
338
339#ifdef CONFIG_MSM_AVS_HW
340 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
341#endif
342 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
343 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
344 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
345 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
346
347 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
348 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
350
351 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
352 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
353 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
354
355 .awake_vlevel = 0x94,
356 .retention_vlevel = 0x81,
357 .collapse_vlevel = 0x20,
358 .retention_mid_vlevel = 0x94,
359 .collapse_mid_vlevel = 0x8C,
360
361 .vctl_timeout_us = 50,
362 },
363};
364
365static struct msm_spm_platform_data msm_spm_data[] __initdata = {
366 [0] = {
367 .reg_base_addr = MSM_SAW0_BASE,
368
369#ifdef CONFIG_MSM_AVS_HW
370 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
371#endif
372 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
373 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
374 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
375 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
376
377 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
378 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
380
381 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
382 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
383 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
384
385 .awake_vlevel = 0xA0,
386 .retention_vlevel = 0x89,
387 .collapse_vlevel = 0x20,
388 .retention_mid_vlevel = 0x89,
389 .collapse_mid_vlevel = 0x89,
390
391 .vctl_timeout_us = 50,
392 },
393
394 [1] = {
395 .reg_base_addr = MSM_SAW1_BASE,
396
397#ifdef CONFIG_MSM_AVS_HW
398 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
399#endif
400 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
401 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
402 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
403 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
404
405 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
406 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
408
409 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
410 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
411 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
412
413 .awake_vlevel = 0xA0,
414 .retention_vlevel = 0x89,
415 .collapse_vlevel = 0x20,
416 .retention_mid_vlevel = 0x89,
417 .collapse_mid_vlevel = 0x89,
418
419 .vctl_timeout_us = 50,
420 },
421};
422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700423/*
424 * Consumer specific regulator names:
425 * regulator name consumer dev_name
426 */
427static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
428 REGULATOR_SUPPLY("8901_s0", NULL),
429};
430static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
431 REGULATOR_SUPPLY("8901_s1", NULL),
432};
433
434static struct regulator_init_data saw_s0_init_data = {
435 .constraints = {
436 .name = "8901_s0",
437 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700438 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700439 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700440 },
441 .consumer_supplies = vreg_consumers_8901_S0,
442 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
443};
444
445static struct regulator_init_data saw_s1_init_data = {
446 .constraints = {
447 .name = "8901_s1",
448 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700449 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700450 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700451 },
452 .consumer_supplies = vreg_consumers_8901_S1,
453 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
454};
455
456static struct platform_device msm_device_saw_s0 = {
457 .name = "saw-regulator",
458 .id = 0,
459 .dev = {
460 .platform_data = &saw_s0_init_data,
461 },
462};
463
464static struct platform_device msm_device_saw_s1 = {
465 .name = "saw-regulator",
466 .id = 1,
467 .dev = {
468 .platform_data = &saw_s1_init_data,
469 },
470};
471
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
Ajay Singh Parmardf694562012-06-05 15:06:21 +05302607#define MSM_FB_EXT_BUF_SIZE 0
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002608#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002609
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002610/* Note: must be multiple of 4096 */
2611#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002612 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002613
2614#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302615#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002616
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002617#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002618unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002619#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002620unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002621#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002622
Huaibin Yanga5419422011-12-08 23:52:10 -08002623#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2624#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2625#else
2626#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2627#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2628
2629#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2630#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2631#else
2632#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2633#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2634
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302635#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002636#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302637#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002638
2639#define MSM_SMI_BASE 0x38000000
2640#define MSM_SMI_SIZE 0x4000000
2641
2642#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302643#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2644#define KERNEL_SMI_SIZE 0x000000
2645#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002646#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302647#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002648
2649#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2650#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2651#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2652
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302653#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
2654#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2655#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2656#define MSM_ION_MFC_SIZE SZ_8K
2657
2658#define MSM_MM_FW_BASE MSM_SMI_BASE
2659#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2660#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2661#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2662
Naseer Ahmed51860b02012-02-07 18:53:29 +05302663#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002664#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302665
Mayank Choprac22ace32012-03-03 00:45:04 +05302666#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2667#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2668#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002669#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302670#endif
2671
Olav Haugan424ff492012-03-13 11:41:23 -07002672#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002673
2674#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302675#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002676#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002677#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2678static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002679#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002680#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002681#endif
2682
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002683static unsigned fb_size;
2684static int __init fb_size_setup(char *p)
2685{
2686 fb_size = memparse(p, NULL);
2687 return 0;
2688}
2689early_param("fb_size", fb_size_setup);
2690
2691static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2692static int __init pmem_kernel_ebi1_size_setup(char *p)
2693{
2694 pmem_kernel_ebi1_size = memparse(p, NULL);
2695 return 0;
2696}
2697early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2698
2699#ifdef CONFIG_ANDROID_PMEM
2700static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2701static int __init pmem_sf_size_setup(char *p)
2702{
2703 pmem_sf_size = memparse(p, NULL);
2704 return 0;
2705}
2706early_param("pmem_sf_size", pmem_sf_size_setup);
2707
2708static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2709
2710static int __init pmem_adsp_size_setup(char *p)
2711{
2712 pmem_adsp_size = memparse(p, NULL);
2713 return 0;
2714}
2715early_param("pmem_adsp_size", pmem_adsp_size_setup);
2716
2717static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2718
2719static int __init pmem_audio_size_setup(char *p)
2720{
2721 pmem_audio_size = memparse(p, NULL);
2722 return 0;
2723}
2724early_param("pmem_audio_size", pmem_audio_size_setup);
2725#endif
2726
2727static struct resource msm_fb_resources[] = {
2728 {
2729 .flags = IORESOURCE_DMA,
2730 }
2731};
2732
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002733static void set_mdp_clocks_for_wuxga(void);
2734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002735static int msm_fb_detect_panel(const char *name)
2736{
2737 if (machine_is_msm8x60_fluid()) {
2738 uint32_t soc_platform_version = socinfo_get_platform_version();
2739 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2740#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2741 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002742 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2743 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744 return 0;
2745#endif
2746 } else { /*P3 and up use AUO panel */
2747#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2748 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002749 strnlen(LCDC_AUO_PANEL_NAME,
2750 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002751 return 0;
2752#endif
2753 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002754#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2755 } else if machine_is_msm8x60_dragon() {
2756 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002757 strnlen(LCDC_NT35582_PANEL_NAME,
2758 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002759 return 0;
2760#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002761 } else {
2762 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002763 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2764 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002765 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002766
2767#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2768 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2769 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2770 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2771 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2772 PANEL_NAME_MAX_LEN)))
2773 return 0;
2774
2775 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2776 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2777 PANEL_NAME_MAX_LEN)))
2778 return 0;
2779
2780 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2781 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2782 PANEL_NAME_MAX_LEN)))
2783 return 0;
2784#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002785 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002786
2787 if (!strncmp(name, HDMI_PANEL_NAME,
2788 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002789 PANEL_NAME_MAX_LEN))) {
2790 if (hdmi_is_primary)
2791 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002792 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002793 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002794
2795 if (!strncmp(name, TVOUT_PANEL_NAME,
2796 strnlen(TVOUT_PANEL_NAME,
2797 PANEL_NAME_MAX_LEN)))
2798 return 0;
2799
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002800 pr_warning("%s: not supported '%s'", __func__, name);
2801 return -ENODEV;
2802}
2803
2804static struct msm_fb_platform_data msm_fb_pdata = {
2805 .detect_client = msm_fb_detect_panel,
2806};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002807
2808static struct platform_device msm_fb_device = {
2809 .name = "msm_fb",
2810 .id = 0,
2811 .num_resources = ARRAY_SIZE(msm_fb_resources),
2812 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814};
2815
2816#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002817#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818static struct android_pmem_platform_data android_pmem_pdata = {
2819 .name = "pmem",
2820 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2821 .cached = 1,
2822 .memory_type = MEMTYPE_EBI1,
2823};
2824
2825static struct platform_device android_pmem_device = {
2826 .name = "android_pmem",
2827 .id = 0,
2828 .dev = {.platform_data = &android_pmem_pdata},
2829};
2830
2831static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2832 .name = "pmem_adsp",
2833 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2834 .cached = 0,
2835 .memory_type = MEMTYPE_EBI1,
2836};
2837
2838static struct platform_device android_pmem_adsp_device = {
2839 .name = "android_pmem",
2840 .id = 2,
2841 .dev = { .platform_data = &android_pmem_adsp_pdata },
2842};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302843
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844static struct android_pmem_platform_data android_pmem_audio_pdata = {
2845 .name = "pmem_audio",
2846 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2847 .cached = 0,
2848 .memory_type = MEMTYPE_EBI1,
2849};
2850
2851static struct platform_device android_pmem_audio_device = {
2852 .name = "android_pmem",
2853 .id = 4,
2854 .dev = { .platform_data = &android_pmem_audio_pdata },
2855};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302856#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002857#define PMEM_BUS_WIDTH(_bw) \
2858 { \
2859 .vectors = &(struct msm_bus_vectors){ \
2860 .src = MSM_BUS_MASTER_AMPSS_M0, \
2861 .dst = MSM_BUS_SLAVE_SMI, \
2862 .ib = (_bw), \
2863 .ab = 0, \
2864 }, \
2865 .num_paths = 1, \
2866 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002867
2868static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002869 [0] = PMEM_BUS_WIDTH(0), /* Off */
2870 [1] = PMEM_BUS_WIDTH(1), /* On */
2871};
2872
2873static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002874 .usecase = mem_smi_table,
2875 .num_usecases = ARRAY_SIZE(mem_smi_table),
2876 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002877};
2878
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002879int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002880{
2881 int bus_id = (int) data;
2882
2883 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002884 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002885}
2886
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002887int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002888{
2889 int bus_id = (int) data;
2890
2891 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002892 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002893}
2894
Alex Bird199980e2011-10-21 11:29:27 -07002895void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002896{
2897 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2898}
Olav Hauganee0f7802011-12-19 13:28:57 -08002899#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002900static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2901 .name = "pmem_smipool",
2902 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2903 .cached = 0,
2904 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002905 .request_region = request_smi_region,
2906 .release_region = release_smi_region,
2907 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002908 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909};
2910static struct platform_device android_pmem_smipool_device = {
2911 .name = "android_pmem",
2912 .id = 7,
2913 .dev = { .platform_data = &android_pmem_smipool_pdata },
2914};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302915#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2916#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002917
2918#define GPIO_DONGLE_PWR_EN 258
2919static void setup_display_power(void);
2920static int lcdc_vga_enabled;
2921static int vga_enable_request(int enable)
2922{
2923 if (enable)
2924 lcdc_vga_enabled = 1;
2925 else
2926 lcdc_vga_enabled = 0;
2927 setup_display_power();
2928
2929 return 0;
2930}
2931
2932#define GPIO_BACKLIGHT_PWM0 0
2933#define GPIO_BACKLIGHT_PWM1 1
2934
2935static int pmic_backlight_gpio[2]
2936 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2937static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2938 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2939 .vga_switch = vga_enable_request,
2940};
2941
2942static struct platform_device lcdc_samsung_panel_device = {
2943 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2944 .id = 0,
2945 .dev = {
2946 .platform_data = &lcdc_samsung_panel_data,
2947 }
2948};
2949#if (!defined(CONFIG_SPI_QUP)) && \
2950 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2951 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2952
2953static int lcdc_spi_gpio_array_num[] = {
2954 LCDC_SPI_GPIO_CLK,
2955 LCDC_SPI_GPIO_CS,
2956 LCDC_SPI_GPIO_MOSI,
2957};
2958
2959static uint32_t lcdc_spi_gpio_config_data[] = {
2960 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2961 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2962 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2963 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2964 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2965 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2966};
2967
2968static void lcdc_config_spi_gpios(int enable)
2969{
2970 int n;
2971 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2972 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2973}
2974#endif
2975
2976#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2977#ifdef CONFIG_SPI_QUP
2978static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2979 {
2980 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2981 .mode = SPI_MODE_3,
2982 .bus_num = 1,
2983 .chip_select = 0,
2984 .max_speed_hz = 10800000,
2985 }
2986};
2987#endif /* CONFIG_SPI_QUP */
2988
2989static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2990#ifndef CONFIG_SPI_QUP
2991 .panel_config_gpio = lcdc_config_spi_gpios,
2992 .gpio_num = lcdc_spi_gpio_array_num,
2993#endif
2994};
2995
2996static struct platform_device lcdc_samsung_oled_panel_device = {
2997 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2998 .id = 0,
2999 .dev.platform_data = &lcdc_samsung_oled_panel_data,
3000};
3001#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3002
3003#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3004#ifdef CONFIG_SPI_QUP
3005static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3006 {
3007 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3008 .mode = SPI_MODE_3,
3009 .bus_num = 1,
3010 .chip_select = 0,
3011 .max_speed_hz = 10800000,
3012 }
3013};
3014#endif
3015
3016static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3017#ifndef CONFIG_SPI_QUP
3018 .panel_config_gpio = lcdc_config_spi_gpios,
3019 .gpio_num = lcdc_spi_gpio_array_num,
3020#endif
3021};
3022
3023static struct platform_device lcdc_auo_wvga_panel_device = {
3024 .name = LCDC_AUO_PANEL_NAME,
3025 .id = 0,
3026 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3027};
3028#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3029
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003030#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3031
3032#define GPIO_NT35582_RESET 94
3033#define GPIO_NT35582_BL_EN_HW_PIN 24
3034#define GPIO_NT35582_BL_EN \
3035 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3036
3037static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3038
3039static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3040 .gpio_num = lcdc_nt35582_pmic_gpio,
3041};
3042
3043static struct platform_device lcdc_nt35582_panel_device = {
3044 .name = LCDC_NT35582_PANEL_NAME,
3045 .id = 0,
3046 .dev = {
3047 .platform_data = &lcdc_nt35582_panel_data,
3048 }
3049};
3050
3051static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3052 {
3053 .modalias = "lcdc_nt35582_spi",
3054 .mode = SPI_MODE_0,
3055 .bus_num = 0,
3056 .chip_select = 0,
3057 .max_speed_hz = 1100000,
3058 }
3059};
3060#endif
3061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003062#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3063static struct resource hdmi_msm_resources[] = {
3064 {
3065 .name = "hdmi_msm_qfprom_addr",
3066 .start = 0x00700000,
3067 .end = 0x007060FF,
3068 .flags = IORESOURCE_MEM,
3069 },
3070 {
3071 .name = "hdmi_msm_hdmi_addr",
3072 .start = 0x04A00000,
3073 .end = 0x04A00FFF,
3074 .flags = IORESOURCE_MEM,
3075 },
3076 {
3077 .name = "hdmi_msm_irq",
3078 .start = HDMI_IRQ,
3079 .end = HDMI_IRQ,
3080 .flags = IORESOURCE_IRQ,
3081 },
3082};
3083
3084static int hdmi_enable_5v(int on);
3085static int hdmi_core_power(int on, int show);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303086static int hdmi_gpio_config(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003087static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303088static int hdmi_panel_power(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003089
3090static struct msm_hdmi_platform_data hdmi_msm_data = {
3091 .irq = HDMI_IRQ,
3092 .enable_5v = hdmi_enable_5v,
3093 .core_power = hdmi_core_power,
3094 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303095 .panel_power = hdmi_panel_power,
3096 .gpio_config = hdmi_gpio_config,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003097};
3098
3099static struct platform_device hdmi_msm_device = {
3100 .name = "hdmi_msm",
3101 .id = 0,
3102 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3103 .resource = hdmi_msm_resources,
3104 .dev.platform_data = &hdmi_msm_data,
3105};
3106#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3107
3108#ifdef CONFIG_FB_MSM_MIPI_DSI
3109static struct platform_device mipi_dsi_toshiba_panel_device = {
3110 .name = "mipi_toshiba",
3111 .id = 0,
3112};
3113
3114#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3115
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003116static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003117 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003118 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003119};
3120
3121static struct platform_device mipi_dsi_novatek_panel_device = {
3122 .name = "mipi_novatek",
3123 .id = 0,
3124 .dev = {
3125 .platform_data = &novatek_pdata,
3126 }
3127};
3128#endif
3129
3130static void __init msm8x60_allocate_memory_regions(void)
3131{
3132 void *addr;
3133 unsigned long size;
3134
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003135 if (hdmi_is_primary)
3136 size = roundup((1920 * 1088 * 4 * 2), 4096);
3137 else
3138 size = MSM_FB_SIZE;
3139
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003140 addr = alloc_bootmem_align(size, 0x1000);
3141 msm_fb_resources[0].start = __pa(addr);
3142 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3143 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3144 size, addr, __pa(addr));
3145
3146}
3147
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003148void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3149{
3150 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3151 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3152 PANEL_NAME_MAX_LEN);
3153 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3154 msm_fb_pdata.prim_panel_name);
3155
3156 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3157 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3158 PANEL_NAME_MAX_LEN))) {
3159 pr_debug("HDMI is the primary display by"
3160 " boot parameter\n");
3161 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003162 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003163 }
3164 }
3165 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3166 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3167 PANEL_NAME_MAX_LEN);
3168 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3169 msm_fb_pdata.ext_panel_name);
3170 }
3171}
3172
Steve Mucklef132c6c2012-06-06 18:30:57 -07003173#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3174 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003175/*virtual key support */
3176static ssize_t tma300_vkeys_show(struct kobject *kobj,
3177 struct kobj_attribute *attr, char *buf)
3178{
3179 return sprintf(buf,
3180 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3181 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3182 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3183 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3184 "\n");
3185}
3186
3187static struct kobj_attribute tma300_vkeys_attr = {
3188 .attr = {
3189 .mode = S_IRUGO,
3190 },
3191 .show = &tma300_vkeys_show,
3192};
3193
3194static struct attribute *tma300_properties_attrs[] = {
3195 &tma300_vkeys_attr.attr,
3196 NULL
3197};
3198
3199static struct attribute_group tma300_properties_attr_group = {
3200 .attrs = tma300_properties_attrs,
3201};
3202
3203static struct kobject *properties_kobj;
3204
3205
3206
3207#define CYTTSP_TS_GPIO_IRQ 61
3208static int cyttsp_platform_init(struct i2c_client *client)
3209{
3210 int rc = -EINVAL;
3211 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3212
3213 if (machine_is_msm8x60_fluid()) {
3214 pm8058_l5 = regulator_get(NULL, "8058_l5");
3215 if (IS_ERR(pm8058_l5)) {
3216 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3217 __func__, PTR_ERR(pm8058_l5));
3218 rc = PTR_ERR(pm8058_l5);
3219 return rc;
3220 }
3221 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3222 if (rc) {
3223 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3224 __func__, rc);
3225 goto reg_l5_put;
3226 }
3227
3228 rc = regulator_enable(pm8058_l5);
3229 if (rc) {
3230 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3231 __func__, rc);
3232 goto reg_l5_put;
3233 }
3234 }
3235 /* vote for s3 to enable i2c communication lines */
3236 pm8058_s3 = regulator_get(NULL, "8058_s3");
3237 if (IS_ERR(pm8058_s3)) {
3238 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3239 __func__, PTR_ERR(pm8058_s3));
3240 rc = PTR_ERR(pm8058_s3);
3241 goto reg_l5_disable;
3242 }
3243
3244 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3245 if (rc) {
3246 pr_err("%s: regulator_set_voltage() = %d\n",
3247 __func__, rc);
3248 goto reg_s3_put;
3249 }
3250
3251 rc = regulator_enable(pm8058_s3);
3252 if (rc) {
3253 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3254 __func__, rc);
3255 goto reg_s3_put;
3256 }
3257
3258 /* wait for vregs to stabilize */
3259 usleep_range(10000, 10000);
3260
3261 /* check this device active by reading first byte/register */
3262 rc = i2c_smbus_read_byte_data(client, 0x01);
3263 if (rc < 0) {
3264 pr_err("%s: i2c sanity check failed\n", __func__);
3265 goto reg_s3_disable;
3266 }
3267
3268 /* virtual keys */
3269 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003270 properties_kobj = kobject_create_and_add("board_properties",
3271 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003272 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003273 if (!properties_kobj || rc)
3274 pr_err("%s: failed to create board_properties\n",
3275 __func__);
3276 }
3277 return CY_OK;
3278
3279reg_s3_disable:
3280 regulator_disable(pm8058_s3);
3281reg_s3_put:
3282 regulator_put(pm8058_s3);
3283reg_l5_disable:
3284 if (machine_is_msm8x60_fluid())
3285 regulator_disable(pm8058_l5);
3286reg_l5_put:
3287 if (machine_is_msm8x60_fluid())
3288 regulator_put(pm8058_l5);
3289 return rc;
3290}
3291
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303292/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3293static int cyttsp_platform_suspend(struct i2c_client *client)
3294{
3295 msleep(20);
3296
3297 return CY_OK;
3298}
3299
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003300static int cyttsp_platform_resume(struct i2c_client *client)
3301{
3302 /* add any special code to strobe a wakeup pin or chip reset */
3303 msleep(10);
3304
3305 return CY_OK;
3306}
3307
3308static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3309 .flags = 0x04,
3310 .gen = CY_GEN3, /* or */
3311 .use_st = CY_USE_ST,
3312 .use_mt = CY_USE_MT,
3313 .use_hndshk = CY_SEND_HNDSHK,
3314 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303315 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003316 .use_gestures = CY_USE_GESTURES,
3317 /* activate up to 4 groups
3318 * and set active distance
3319 */
3320 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3321 CY_GEST_GRP3 | CY_GEST_GRP4 |
3322 CY_ACT_DIST,
3323 /* change act_intrvl to customize the Active power state
3324 * scanning/processing refresh interval for Operating mode
3325 */
3326 .act_intrvl = CY_ACT_INTRVL_DFLT,
3327 /* change tch_tmout to customize the touch timeout for the
3328 * Active power state for Operating mode
3329 */
3330 .tch_tmout = CY_TCH_TMOUT_DFLT,
3331 /* change lp_intrvl to customize the Low Power power state
3332 * scanning/processing refresh interval for Operating mode
3333 */
3334 .lp_intrvl = CY_LP_INTRVL_DFLT,
3335 .sleep_gpio = -1,
3336 .resout_gpio = -1,
3337 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3338 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303339 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003340 .init = cyttsp_platform_init,
3341};
3342
3343static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3344 .panel_maxx = 1083,
3345 .panel_maxy = 659,
3346 .disp_minx = 30,
3347 .disp_maxx = 1053,
3348 .disp_miny = 30,
3349 .disp_maxy = 629,
3350 .correct_fw_ver = 8,
3351 .fw_fname = "cyttsp_8660_ffa.hex",
3352 .flags = 0x00,
3353 .gen = CY_GEN2, /* or */
3354 .use_st = CY_USE_ST,
3355 .use_mt = CY_USE_MT,
3356 .use_hndshk = CY_SEND_HNDSHK,
3357 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303358 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003359 .use_gestures = CY_USE_GESTURES,
3360 /* activate up to 4 groups
3361 * and set active distance
3362 */
3363 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3364 CY_GEST_GRP3 | CY_GEST_GRP4 |
3365 CY_ACT_DIST,
3366 /* change act_intrvl to customize the Active power state
3367 * scanning/processing refresh interval for Operating mode
3368 */
3369 .act_intrvl = CY_ACT_INTRVL_DFLT,
3370 /* change tch_tmout to customize the touch timeout for the
3371 * Active power state for Operating mode
3372 */
3373 .tch_tmout = CY_TCH_TMOUT_DFLT,
3374 /* change lp_intrvl to customize the Low Power power state
3375 * scanning/processing refresh interval for Operating mode
3376 */
3377 .lp_intrvl = CY_LP_INTRVL_DFLT,
3378 .sleep_gpio = -1,
3379 .resout_gpio = -1,
3380 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3381 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303382 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003383 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303384 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003385};
3386static void cyttsp_set_params(void)
3387{
3388 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3389 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3390 cyttsp_fluid_pdata.panel_maxx = 539;
3391 cyttsp_fluid_pdata.panel_maxy = 994;
3392 cyttsp_fluid_pdata.disp_minx = 30;
3393 cyttsp_fluid_pdata.disp_maxx = 509;
3394 cyttsp_fluid_pdata.disp_miny = 60;
3395 cyttsp_fluid_pdata.disp_maxy = 859;
3396 cyttsp_fluid_pdata.correct_fw_ver = 4;
3397 } else {
3398 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3399 cyttsp_fluid_pdata.panel_maxx = 550;
3400 cyttsp_fluid_pdata.panel_maxy = 1013;
3401 cyttsp_fluid_pdata.disp_minx = 35;
3402 cyttsp_fluid_pdata.disp_maxx = 515;
3403 cyttsp_fluid_pdata.disp_miny = 69;
3404 cyttsp_fluid_pdata.disp_maxy = 869;
3405 cyttsp_fluid_pdata.correct_fw_ver = 5;
3406 }
3407
3408}
3409
3410static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3411 {
3412 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3413 .platform_data = &cyttsp_fluid_pdata,
3414#ifndef CY_USE_TIMER
3415 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3416#endif /* CY_USE_TIMER */
3417 },
3418};
3419
3420static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3421 {
3422 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3423 .platform_data = &cyttsp_tmg240_pdata,
3424#ifndef CY_USE_TIMER
3425 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3426#endif /* CY_USE_TIMER */
3427 },
3428};
3429#endif
3430
3431static struct regulator *vreg_tmg200;
3432
3433#define TS_PEN_IRQ_GPIO 61
3434static int tmg200_power(int vreg_on)
3435{
3436 int rc = -EINVAL;
3437
3438 if (!vreg_tmg200) {
3439 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3440 __func__, rc);
3441 return rc;
3442 }
3443
3444 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3445 regulator_disable(vreg_tmg200);
3446 if (rc < 0)
3447 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3448 __func__, vreg_on ? "enable" : "disable", rc);
3449
3450 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003451 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003452
3453 return rc;
3454}
3455
3456static int tmg200_dev_setup(bool enable)
3457{
3458 int rc;
3459
3460 if (enable) {
3461 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3462 if (IS_ERR(vreg_tmg200)) {
3463 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3464 __func__, PTR_ERR(vreg_tmg200));
3465 rc = PTR_ERR(vreg_tmg200);
3466 return rc;
3467 }
3468
3469 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3470 if (rc) {
3471 pr_err("%s: regulator_set_voltage() = %d\n",
3472 __func__, rc);
3473 goto reg_put;
3474 }
3475 } else {
3476 /* put voltage sources */
3477 regulator_put(vreg_tmg200);
3478 }
3479 return 0;
3480reg_put:
3481 regulator_put(vreg_tmg200);
3482 return rc;
3483}
3484
3485static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3486 .ts_name = "msm_tmg200_ts",
3487 .dis_min_x = 0,
3488 .dis_max_x = 1023,
3489 .dis_min_y = 0,
3490 .dis_max_y = 599,
3491 .min_tid = 0,
3492 .max_tid = 255,
3493 .min_touch = 0,
3494 .max_touch = 255,
3495 .min_width = 0,
3496 .max_width = 255,
3497 .power_on = tmg200_power,
3498 .dev_setup = tmg200_dev_setup,
3499 .nfingers = 2,
3500 .irq_gpio = TS_PEN_IRQ_GPIO,
3501 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3502};
3503
3504static struct i2c_board_info cy8ctmg200_board_info[] = {
3505 {
3506 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3507 .platform_data = &cy8ctmg200_pdata,
3508 }
3509};
3510
Zhang Chang Ken211df572011-07-05 19:16:39 -04003511static struct regulator *vreg_tma340;
3512
3513static int tma340_power(int vreg_on)
3514{
3515 int rc = -EINVAL;
3516
3517 if (!vreg_tma340) {
3518 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3519 __func__, rc);
3520 return rc;
3521 }
3522
3523 rc = vreg_on ? regulator_enable(vreg_tma340) :
3524 regulator_disable(vreg_tma340);
3525 if (rc < 0)
3526 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3527 __func__, vreg_on ? "enable" : "disable", rc);
3528
3529 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003530 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003531
3532 return rc;
3533}
3534
3535static struct kobject *tma340_prop_kobj;
3536
3537static int tma340_dragon_dev_setup(bool enable)
3538{
3539 int rc;
3540
3541 if (enable) {
3542 vreg_tma340 = regulator_get(NULL, "8901_l2");
3543 if (IS_ERR(vreg_tma340)) {
3544 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3545 __func__, PTR_ERR(vreg_tma340));
3546 rc = PTR_ERR(vreg_tma340);
3547 return rc;
3548 }
3549
3550 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3551 if (rc) {
3552 pr_err("%s: regulator_set_voltage() = %d\n",
3553 __func__, rc);
3554 goto reg_put;
3555 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003556 tma340_prop_kobj = kobject_create_and_add("board_properties",
3557 NULL);
3558 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003559 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003560 if (rc) {
3561 kobject_put(tma340_prop_kobj);
3562 pr_err("%s: failed to create board_properties\n",
3563 __func__);
3564 goto reg_put;
3565 }
3566 }
3567
3568 } else {
3569 /* put voltage sources */
3570 regulator_put(vreg_tma340);
3571 /* destroy virtual keys */
3572 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003573 kobject_put(tma340_prop_kobj);
3574 }
3575 }
3576 return 0;
3577reg_put:
3578 regulator_put(vreg_tma340);
3579 return rc;
3580}
3581
3582
3583static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3584 .ts_name = "cy8ctma340",
3585 .dis_min_x = 0,
3586 .dis_max_x = 479,
3587 .dis_min_y = 0,
3588 .dis_max_y = 799,
3589 .min_tid = 0,
3590 .max_tid = 255,
3591 .min_touch = 0,
3592 .max_touch = 255,
3593 .min_width = 0,
3594 .max_width = 255,
3595 .power_on = tma340_power,
3596 .dev_setup = tma340_dragon_dev_setup,
3597 .nfingers = 2,
3598 .irq_gpio = TS_PEN_IRQ_GPIO,
3599 .resout_gpio = -1,
3600};
3601
3602static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3603 {
3604 I2C_BOARD_INFO("cy8ctma340", 0x24),
3605 .platform_data = &cy8ctma340_dragon_pdata,
3606 }
3607};
3608
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003609#ifdef CONFIG_SERIAL_MSM_HS
3610static int configure_uart_gpios(int on)
3611{
3612 int ret = 0, i;
3613 int uart_gpios[] = {53, 54, 55, 56};
3614 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3615 if (on) {
3616 ret = msm_gpiomux_get(uart_gpios[i]);
3617 if (unlikely(ret))
3618 break;
3619 } else {
3620 ret = msm_gpiomux_put(uart_gpios[i]);
3621 if (unlikely(ret))
3622 return ret;
3623 }
3624 }
3625 if (ret)
3626 for (; i >= 0; i--)
3627 msm_gpiomux_put(uart_gpios[i]);
3628 return ret;
3629}
3630static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3631 .inject_rx_on_wakeup = 1,
3632 .rx_to_inject = 0xFD,
3633 .gpio_config = configure_uart_gpios,
3634};
3635#endif
3636
3637
3638#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3639
3640static struct gpio_led gpio_exp_leds_config[] = {
3641 {
3642 .name = "left_led1:green",
3643 .gpio = GPIO_LEFT_LED_1,
3644 .active_low = 1,
3645 .retain_state_suspended = 0,
3646 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3647 },
3648 {
3649 .name = "left_led2:red",
3650 .gpio = GPIO_LEFT_LED_2,
3651 .active_low = 1,
3652 .retain_state_suspended = 0,
3653 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3654 },
3655 {
3656 .name = "left_led3:green",
3657 .gpio = GPIO_LEFT_LED_3,
3658 .active_low = 1,
3659 .retain_state_suspended = 0,
3660 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3661 },
3662 {
3663 .name = "wlan_led:orange",
3664 .gpio = GPIO_LEFT_LED_WLAN,
3665 .active_low = 1,
3666 .retain_state_suspended = 0,
3667 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3668 },
3669 {
3670 .name = "left_led5:green",
3671 .gpio = GPIO_LEFT_LED_5,
3672 .active_low = 1,
3673 .retain_state_suspended = 0,
3674 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3675 },
3676 {
3677 .name = "right_led1:green",
3678 .gpio = GPIO_RIGHT_LED_1,
3679 .active_low = 1,
3680 .retain_state_suspended = 0,
3681 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3682 },
3683 {
3684 .name = "right_led2:red",
3685 .gpio = GPIO_RIGHT_LED_2,
3686 .active_low = 1,
3687 .retain_state_suspended = 0,
3688 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3689 },
3690 {
3691 .name = "right_led3:green",
3692 .gpio = GPIO_RIGHT_LED_3,
3693 .active_low = 1,
3694 .retain_state_suspended = 0,
3695 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3696 },
3697 {
3698 .name = "bt_led:blue",
3699 .gpio = GPIO_RIGHT_LED_BT,
3700 .active_low = 1,
3701 .retain_state_suspended = 0,
3702 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3703 },
3704 {
3705 .name = "right_led5:green",
3706 .gpio = GPIO_RIGHT_LED_5,
3707 .active_low = 1,
3708 .retain_state_suspended = 0,
3709 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3710 },
3711};
3712
3713static struct gpio_led_platform_data gpio_leds_pdata = {
3714 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3715 .leds = gpio_exp_leds_config,
3716};
3717
3718static struct platform_device gpio_leds = {
3719 .name = "leds-gpio",
3720 .id = -1,
3721 .dev = {
3722 .platform_data = &gpio_leds_pdata,
3723 },
3724};
3725
3726static struct gpio_led fluid_gpio_leds[] = {
3727 {
3728 .name = "dual_led:green",
3729 .gpio = GPIO_LED1_GREEN_N,
3730 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3731 .active_low = 1,
3732 .retain_state_suspended = 0,
3733 },
3734 {
3735 .name = "dual_led:red",
3736 .gpio = GPIO_LED2_RED_N,
3737 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3738 .active_low = 1,
3739 .retain_state_suspended = 0,
3740 },
3741};
3742
3743static struct gpio_led_platform_data gpio_led_pdata = {
3744 .leds = fluid_gpio_leds,
3745 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3746};
3747
3748static struct platform_device fluid_leds_gpio = {
3749 .name = "leds-gpio",
3750 .id = -1,
3751 .dev = {
3752 .platform_data = &gpio_led_pdata,
3753 },
3754};
3755
3756#endif
3757
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003758#ifdef CONFIG_BATTERY_MSM8X60
3759static struct msm_charger_platform_data msm_charger_data = {
3760 .safety_time = 180,
3761 .update_time = 1,
3762 .max_voltage = 4200,
3763 .min_voltage = 3200,
3764};
3765
3766static struct platform_device msm_charger_device = {
3767 .name = "msm-charger",
3768 .id = -1,
3769 .dev = {
3770 .platform_data = &msm_charger_data,
3771 }
3772};
3773#endif
3774
3775/*
3776 * Consumer specific regulator names:
3777 * regulator name consumer dev_name
3778 */
3779static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3780 REGULATOR_SUPPLY("8058_l0", NULL),
3781};
3782static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3783 REGULATOR_SUPPLY("8058_l1", NULL),
3784};
3785static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3786 REGULATOR_SUPPLY("8058_l2", NULL),
3787};
3788static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3789 REGULATOR_SUPPLY("8058_l3", NULL),
3790};
3791static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3792 REGULATOR_SUPPLY("8058_l4", NULL),
3793};
3794static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3795 REGULATOR_SUPPLY("8058_l5", NULL),
3796};
3797static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3798 REGULATOR_SUPPLY("8058_l6", NULL),
3799};
3800static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3801 REGULATOR_SUPPLY("8058_l7", NULL),
3802};
3803static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3804 REGULATOR_SUPPLY("8058_l8", NULL),
3805};
3806static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3807 REGULATOR_SUPPLY("8058_l9", NULL),
3808};
3809static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3810 REGULATOR_SUPPLY("8058_l10", NULL),
3811};
3812static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3813 REGULATOR_SUPPLY("8058_l11", NULL),
3814};
3815static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3816 REGULATOR_SUPPLY("8058_l12", NULL),
3817};
3818static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3819 REGULATOR_SUPPLY("8058_l13", NULL),
3820};
3821static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3822 REGULATOR_SUPPLY("8058_l14", NULL),
3823};
3824static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3825 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003826 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003827 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003828 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003829};
3830static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3831 REGULATOR_SUPPLY("8058_l16", NULL),
3832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3834 REGULATOR_SUPPLY("8058_l17", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3837 REGULATOR_SUPPLY("8058_l18", NULL),
3838};
3839static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3840 REGULATOR_SUPPLY("8058_l19", NULL),
3841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3843 REGULATOR_SUPPLY("8058_l20", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3846 REGULATOR_SUPPLY("8058_l21", NULL),
3847};
3848static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3849 REGULATOR_SUPPLY("8058_l22", NULL),
3850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3852 REGULATOR_SUPPLY("8058_l23", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3855 REGULATOR_SUPPLY("8058_l24", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3858 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003859 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003860 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003861 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003862};
3863static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3864 REGULATOR_SUPPLY("8058_s0", NULL),
3865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3867 REGULATOR_SUPPLY("8058_s1", NULL),
3868};
3869static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3870 REGULATOR_SUPPLY("8058_s2", NULL),
3871};
3872static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3873 REGULATOR_SUPPLY("8058_s3", NULL),
3874};
3875static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3876 REGULATOR_SUPPLY("8058_s4", NULL),
3877};
3878static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3879 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003880 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003881 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003882 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003883};
3884static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3885 REGULATOR_SUPPLY("8058_lvs1", NULL),
3886};
3887static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3888 REGULATOR_SUPPLY("8058_ncp", NULL),
3889};
3890
3891static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3892 REGULATOR_SUPPLY("8901_l0", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3895 REGULATOR_SUPPLY("8901_l1", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3898 REGULATOR_SUPPLY("8901_l2", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3901 REGULATOR_SUPPLY("8901_l3", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3904 REGULATOR_SUPPLY("8901_l4", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3907 REGULATOR_SUPPLY("8901_l5", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3910 REGULATOR_SUPPLY("8901_l6", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3913 REGULATOR_SUPPLY("8901_s2", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3916 REGULATOR_SUPPLY("8901_s3", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3919 REGULATOR_SUPPLY("8901_s4", NULL),
3920};
3921static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3922 REGULATOR_SUPPLY("8901_lvs0", NULL),
3923};
3924static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3925 REGULATOR_SUPPLY("8901_lvs1", NULL),
3926};
3927static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3928 REGULATOR_SUPPLY("8901_lvs2", NULL),
3929};
3930static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3931 REGULATOR_SUPPLY("8901_lvs3", NULL),
3932};
3933static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3934 REGULATOR_SUPPLY("8901_mvs0", NULL),
3935};
3936
David Collins6f032ba2011-08-31 14:08:15 -07003937/* Pin control regulators */
3938static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3939 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3940};
3941static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3942 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3943};
3944static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3945 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3946};
3947static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3948 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3949};
3950static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3951 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3952};
3953static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3954 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3955};
3956
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003957#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3958 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003959 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3960 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003961 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003962 .init_data = { \
3963 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003964 .valid_modes_mask = _modes, \
3965 .valid_ops_mask = _ops, \
3966 .min_uV = _min_uV, \
3967 .max_uV = _max_uV, \
3968 .input_uV = _min_uV, \
3969 .apply_uV = _apply_uV, \
3970 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003971 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003972 .consumer_supplies = vreg_consumers_##_id, \
3973 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003974 ARRAY_SIZE(vreg_consumers_##_id), \
3975 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003976 .id = RPM_VREG_ID_##_id, \
3977 .default_uV = _default_uV, \
3978 .peak_uA = _peak_uA, \
3979 .avg_uA = _avg_uA, \
3980 .pull_down_enable = _pull_down, \
3981 .pin_ctrl = _pin_ctrl, \
3982 .freq = RPM_VREG_FREQ_##_freq, \
3983 .pin_fn = _pin_fn, \
3984 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003985 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003986 .state = _state, \
3987 .sleep_selectable = _sleep_selectable, \
3988 }
3989
3990/* Pin control initialization */
3991#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3992 { \
3993 .init_data = { \
3994 .constraints = { \
3995 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3996 .always_on = _always_on, \
3997 }, \
3998 .num_consumer_supplies = \
3999 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
4000 .consumer_supplies = vreg_consumers_##_id##_PC, \
4001 }, \
4002 .id = RPM_VREG_ID_##_id##_PC, \
4003 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004004 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004005 }
4006
4007/*
4008 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4009 * via the peak_uA value specified in the table below. If the value is less
4010 * than the high power min threshold for the regulator, then the regulator will
4011 * be set to LPM. Otherwise, it will be set to HPM.
4012 *
4013 * This value can be further overridden by specifying an initial mode via
4014 * .init_data.constraints.initial_mode.
4015 */
4016
David Collins6f032ba2011-08-31 14:08:15 -07004017#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4018 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004019 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4020 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4021 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4022 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4023 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004024 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4025 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004026 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004027 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004028 _sleep_selectable, _always_on)
4029
David Collins6f032ba2011-08-31 14:08:15 -07004030#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4031 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004032 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4033 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4034 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4035 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4036 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004037 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4038 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004039 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004040 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4041 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004042
David Collins6f032ba2011-08-31 14:08:15 -07004043#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004044 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4045 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004046 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4047 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004048 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004049 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4050 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004051
David Collins6f032ba2011-08-31 14:08:15 -07004052#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004053 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4054 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004055 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4056 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004057 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004058 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4059 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004060
David Collins6f032ba2011-08-31 14:08:15 -07004061#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4062#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4063#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4064#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4065#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004066
David Collins6f032ba2011-08-31 14:08:15 -07004067/* RPM early regulator constraints */
4068static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4069 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004070 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004071 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004072};
4073
David Collins6f032ba2011-08-31 14:08:15 -07004074/* RPM regulator constraints */
4075static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4076 /* ID a_on pd ss min_uV max_uV init_ip */
4077 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4078 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4079 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4080 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4081 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4082 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4083 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4084 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4085 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4086 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4087 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4088 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4089 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4090 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4091 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4092 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4093 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4094 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4095 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4096 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4097 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4098 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4099 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4100 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4101 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4102 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004103
David Collins6f032ba2011-08-31 14:08:15 -07004104 /* ID a_on pd ss min_uV max_uV init_ip freq */
4105 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4106 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4107 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4108
4109 /* ID a_on pd ss */
4110 RPM_VS(PM8058_LVS0, 0, 1, 0),
4111 RPM_VS(PM8058_LVS1, 0, 1, 0),
4112
4113 /* ID a_on pd ss min_uV max_uV */
4114 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4115
4116 /* ID a_on pd ss min_uV max_uV init_ip */
4117 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4118 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4119 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4120 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4121 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4122 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4123 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4124
4125 /* ID a_on pd ss min_uV max_uV init_ip freq */
4126 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4127 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4128 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4129
4130 /* ID a_on pd ss */
4131 RPM_VS(PM8901_LVS0, 1, 1, 0),
4132 RPM_VS(PM8901_LVS1, 0, 1, 0),
4133 RPM_VS(PM8901_LVS2, 0, 1, 0),
4134 RPM_VS(PM8901_LVS3, 0, 1, 0),
4135 RPM_VS(PM8901_MVS0, 0, 1, 0),
4136
4137 /* ID a_on pin_func pin_ctrl */
4138 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4139 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4140 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4141 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4142 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4143 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4144};
4145
4146static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4147 .init_data = rpm_regulator_early_init_data,
4148 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4149 .version = RPM_VREG_VERSION_8660,
4150 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4151 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4152};
4153
4154static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4155 .init_data = rpm_regulator_init_data,
4156 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4157 .version = RPM_VREG_VERSION_8660,
4158};
4159
4160static struct platform_device rpm_regulator_early_device = {
4161 .name = "rpm-regulator",
4162 .id = 0,
4163 .dev = {
4164 .platform_data = &rpm_regulator_early_pdata,
4165 },
4166};
4167
4168static struct platform_device rpm_regulator_device = {
4169 .name = "rpm-regulator",
4170 .id = 1,
4171 .dev = {
4172 .platform_data = &rpm_regulator_pdata,
4173 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004174};
4175
4176static struct platform_device *early_regulators[] __initdata = {
4177 &msm_device_saw_s0,
4178 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004179 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004180};
4181
4182static struct platform_device *early_devices[] __initdata = {
4183#ifdef CONFIG_MSM_BUS_SCALING
4184 &msm_bus_apps_fabric,
4185 &msm_bus_sys_fabric,
4186 &msm_bus_mm_fabric,
4187 &msm_bus_sys_fpb,
4188 &msm_bus_cpss_fpb,
4189#endif
4190 &msm_device_dmov_adm0,
4191 &msm_device_dmov_adm1,
4192};
4193
4194#if (defined(CONFIG_MARIMBA_CORE)) && \
4195 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4196
4197static int bluetooth_power(int);
4198static struct platform_device msm_bt_power_device = {
4199 .name = "bt_power",
4200 .id = -1,
4201 .dev = {
4202 .platform_data = &bluetooth_power,
4203 },
4204};
4205#endif
4206
4207static struct platform_device msm_tsens_device = {
4208 .name = "tsens-tm",
4209 .id = -1,
4210};
4211
4212static struct platform_device *rumi_sim_devices[] __initdata = {
4213 &smc91x_device,
4214 &msm_device_uart_dm12,
4215#ifdef CONFIG_I2C_QUP
4216 &msm_gsbi3_qup_i2c_device,
4217 &msm_gsbi4_qup_i2c_device,
4218 &msm_gsbi7_qup_i2c_device,
4219 &msm_gsbi8_qup_i2c_device,
4220 &msm_gsbi9_qup_i2c_device,
4221 &msm_gsbi12_qup_i2c_device,
4222#endif
4223#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004224 &msm_device_ssbi3,
4225#endif
4226#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004227#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004228 &android_pmem_device,
4229 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004230 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004231 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304232#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4233#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004234#ifdef CONFIG_MSM_ROTATOR
4235 &msm_rotator_device,
4236#endif
4237 &msm_fb_device,
4238 &msm_kgsl_3d0,
4239 &msm_kgsl_2d0,
4240 &msm_kgsl_2d1,
4241 &lcdc_samsung_panel_device,
4242#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4243 &hdmi_msm_device,
4244#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4245#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004246#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004247#ifdef CONFIG_MT9E013
4248 &msm_camera_sensor_mt9e013,
4249#endif
4250#ifdef CONFIG_IMX074
4251 &msm_camera_sensor_imx074,
4252#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004253#ifdef CONFIG_VX6953
4254 &msm_camera_sensor_vx6953,
4255#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004256#ifdef CONFIG_WEBCAM_OV7692
4257 &msm_camera_sensor_webcam_ov7692,
4258#endif
4259#ifdef CONFIG_WEBCAM_OV9726
4260 &msm_camera_sensor_webcam_ov9726,
4261#endif
4262#ifdef CONFIG_QS_S5K4E1
4263 &msm_camera_sensor_qs_s5k4e1,
4264#endif
4265#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004266#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267#ifdef CONFIG_MSM_GEMINI
4268 &msm_gemini_device,
4269#endif
4270#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004271#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004272 &msm_vpe_device,
4273#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004274#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004275 &msm_device_vidc,
4276};
4277
4278#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4279enum {
4280 SX150X_CORE,
4281 SX150X_DOCKING,
4282 SX150X_SURF,
4283 SX150X_LEFT_FHA,
4284 SX150X_RIGHT_FHA,
4285 SX150X_SOUTH,
4286 SX150X_NORTH,
4287 SX150X_CORE_FLUID,
4288};
4289
4290static struct sx150x_platform_data sx150x_data[] __initdata = {
4291 [SX150X_CORE] = {
4292 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4293 .oscio_is_gpo = false,
4294 .io_pullup_ena = 0x0c08,
4295 .io_pulldn_ena = 0x4060,
4296 .io_open_drain_ena = 0x000c,
4297 .io_polarity = 0,
4298 .irq_summary = -1, /* see fixup_i2c_configs() */
4299 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4300 },
4301 [SX150X_DOCKING] = {
4302 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4303 .oscio_is_gpo = false,
4304 .io_pullup_ena = 0x5e06,
4305 .io_pulldn_ena = 0x81b8,
4306 .io_open_drain_ena = 0,
4307 .io_polarity = 0,
4308 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4309 UI_INT2_N),
4310 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4311 GPIO_DOCKING_EXPANDER_BASE -
4312 GPIO_EXPANDER_GPIO_BASE,
4313 },
4314 [SX150X_SURF] = {
4315 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4316 .oscio_is_gpo = false,
4317 .io_pullup_ena = 0,
4318 .io_pulldn_ena = 0,
4319 .io_open_drain_ena = 0,
4320 .io_polarity = 0,
4321 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4322 UI_INT1_N),
4323 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4324 GPIO_SURF_EXPANDER_BASE -
4325 GPIO_EXPANDER_GPIO_BASE,
4326 },
4327 [SX150X_LEFT_FHA] = {
4328 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4329 .oscio_is_gpo = false,
4330 .io_pullup_ena = 0,
4331 .io_pulldn_ena = 0x40,
4332 .io_open_drain_ena = 0,
4333 .io_polarity = 0,
4334 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4335 UI_INT3_N),
4336 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4337 GPIO_LEFT_KB_EXPANDER_BASE -
4338 GPIO_EXPANDER_GPIO_BASE,
4339 },
4340 [SX150X_RIGHT_FHA] = {
4341 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4342 .oscio_is_gpo = true,
4343 .io_pullup_ena = 0,
4344 .io_pulldn_ena = 0,
4345 .io_open_drain_ena = 0,
4346 .io_polarity = 0,
4347 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4348 UI_INT3_N),
4349 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4350 GPIO_RIGHT_KB_EXPANDER_BASE -
4351 GPIO_EXPANDER_GPIO_BASE,
4352 },
4353 [SX150X_SOUTH] = {
4354 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4355 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4356 GPIO_SOUTH_EXPANDER_BASE -
4357 GPIO_EXPANDER_GPIO_BASE,
4358 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4359 },
4360 [SX150X_NORTH] = {
4361 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4362 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4363 GPIO_NORTH_EXPANDER_BASE -
4364 GPIO_EXPANDER_GPIO_BASE,
4365 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4366 .oscio_is_gpo = true,
4367 .io_open_drain_ena = 0x30,
4368 },
4369 [SX150X_CORE_FLUID] = {
4370 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4371 .oscio_is_gpo = false,
4372 .io_pullup_ena = 0x0408,
4373 .io_pulldn_ena = 0x4060,
4374 .io_open_drain_ena = 0x0008,
4375 .io_polarity = 0,
4376 .irq_summary = -1, /* see fixup_i2c_configs() */
4377 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4378 },
4379};
4380
4381#ifdef CONFIG_SENSORS_MSM_ADC
4382/* Configuration of EPM expander is done when client
4383 * request an adc read
4384 */
4385static struct sx150x_platform_data sx150x_epmdata = {
4386 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4387 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4388 GPIO_EPM_EXPANDER_BASE -
4389 GPIO_EXPANDER_GPIO_BASE,
4390 .irq_summary = -1,
4391};
4392#endif
4393
4394/* sx150x_low_power_cfg
4395 *
4396 * This data and init function are used to put unused gpio-expander output
4397 * lines into their low-power states at boot. The init
4398 * function must be deferred until a later init stage because the i2c
4399 * gpio expander drivers do not probe until after they are registered
4400 * (see register_i2c_devices) and the work-queues for those registrations
4401 * are processed. Because these lines are unused, there is no risk of
4402 * competing with a device driver for the gpio.
4403 *
4404 * gpio lines whose low-power states are input are naturally in their low-
4405 * power configurations once probed, see the platform data structures above.
4406 */
4407struct sx150x_low_power_cfg {
4408 unsigned gpio;
4409 unsigned val;
4410};
4411
4412static struct sx150x_low_power_cfg
4413common_sx150x_lp_cfgs[] __initdata = {
4414 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4415 {GPIO_EXT_GPS_LNA_EN, 0},
4416 {GPIO_MSM_WAKES_BT, 0},
4417 {GPIO_USB_UICC_EN, 0},
4418 {GPIO_BATT_GAUGE_EN, 0},
4419};
4420
4421static struct sx150x_low_power_cfg
4422surf_ffa_sx150x_lp_cfgs[] __initdata = {
4423 {GPIO_MIPI_DSI_RST_N, 0},
4424 {GPIO_DONGLE_PWR_EN, 0},
4425 {GPIO_CAP_TS_SLEEP, 1},
4426 {GPIO_WEB_CAMIF_RESET_N, 0},
4427};
4428
4429static void __init
4430cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4431{
4432 unsigned n;
4433 int rc;
4434
4435 for (n = 0; n < nelems; ++n) {
4436 rc = gpio_request(cfgs[n].gpio, NULL);
4437 if (!rc) {
4438 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4439 gpio_free(cfgs[n].gpio);
4440 }
4441
4442 if (rc) {
4443 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4444 __func__, cfgs[n].gpio, rc);
4445 }
Steve Muckle9161d302010-02-11 11:50:40 -08004446 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004447}
4448
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004449static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004450{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004451 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4452 ARRAY_SIZE(common_sx150x_lp_cfgs));
4453 if (!machine_is_msm8x60_fluid())
4454 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4455 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4456 return 0;
4457}
4458module_init(cfg_sx150xs_low_power);
4459
4460#ifdef CONFIG_I2C
4461static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4462 {
4463 I2C_BOARD_INFO("sx1509q", 0x3e),
4464 .platform_data = &sx150x_data[SX150X_CORE]
4465 },
4466};
4467
4468static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4469 {
4470 I2C_BOARD_INFO("sx1509q", 0x3f),
4471 .platform_data = &sx150x_data[SX150X_DOCKING]
4472 },
4473};
4474
4475static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4476 {
4477 I2C_BOARD_INFO("sx1509q", 0x70),
4478 .platform_data = &sx150x_data[SX150X_SURF]
4479 }
4480};
4481
4482static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4483 {
4484 I2C_BOARD_INFO("sx1508q", 0x21),
4485 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4486 },
4487 {
4488 I2C_BOARD_INFO("sx1508q", 0x22),
4489 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4490 }
4491};
4492
4493static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4494 {
4495 I2C_BOARD_INFO("sx1508q", 0x23),
4496 .platform_data = &sx150x_data[SX150X_SOUTH]
4497 },
4498 {
4499 I2C_BOARD_INFO("sx1508q", 0x20),
4500 .platform_data = &sx150x_data[SX150X_NORTH]
4501 }
4502};
4503
4504static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4505 {
4506 I2C_BOARD_INFO("sx1509q", 0x3e),
4507 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4508 },
4509};
4510
4511#ifdef CONFIG_SENSORS_MSM_ADC
4512static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4513 {
4514 I2C_BOARD_INFO("sx1509q", 0x3e),
4515 .platform_data = &sx150x_epmdata
4516 },
4517};
4518#endif
4519#endif
4520#endif
4521
4522#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004523
4524static struct adc_access_fn xoadc_fn = {
4525 pm8058_xoadc_select_chan_and_start_conv,
4526 pm8058_xoadc_read_adc_code,
4527 pm8058_xoadc_get_properties,
4528 pm8058_xoadc_slot_request,
4529 pm8058_xoadc_restore_slot,
4530 pm8058_xoadc_calibrate,
4531};
4532
4533#if defined(CONFIG_I2C) && \
4534 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4535static struct regulator *vreg_adc_epm1;
4536
4537static struct i2c_client *epm_expander_i2c_register_board(void)
4538
4539{
4540 struct i2c_adapter *i2c_adap;
4541 struct i2c_client *client = NULL;
4542 i2c_adap = i2c_get_adapter(0x0);
4543
4544 if (i2c_adap == NULL)
4545 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4546
4547 if (i2c_adap != NULL)
4548 client = i2c_new_device(i2c_adap,
4549 &fluid_expanders_i2c_epm_info[0]);
4550 return client;
4551
4552}
4553
4554static unsigned int msm_adc_gpio_configure_expander_enable(void)
4555{
4556 int rc = 0;
4557 static struct i2c_client *epm_i2c_client;
4558
4559 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4560
4561 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4562
4563 if (IS_ERR(vreg_adc_epm1)) {
4564 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4565 return 0;
4566 }
4567
4568 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4569 if (rc)
4570 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4571 "regulator set voltage failed\n");
4572
4573 rc = regulator_enable(vreg_adc_epm1);
4574 if (rc) {
4575 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4576 "Error while enabling regulator for epm s3 %d\n", rc);
4577 return rc;
4578 }
4579
4580 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4581 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4582
4583 msleep(1000);
4584
4585 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4586 if (!rc) {
4587 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4588 "Configure 5v boost\n");
4589 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4590 } else {
4591 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4592 "Error for epm 5v boost en\n");
4593 goto exit_vreg_epm;
4594 }
4595
4596 msleep(500);
4597
4598 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4599 if (!rc) {
4600 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4601 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4602 "Configure epm 3.3v\n");
4603 } else {
4604 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4605 "Error for gpio 3.3ven\n");
4606 goto exit_vreg_epm;
4607 }
4608 msleep(500);
4609
4610 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4611 "Trying to request EPM LVLSFT_EN\n");
4612 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4613 if (!rc) {
4614 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4615 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4616 "Configure the lvlsft\n");
4617 } else {
4618 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4619 "Error for epm lvlsft_en\n");
4620 goto exit_vreg_epm;
4621 }
4622
4623 msleep(500);
4624
4625 if (!epm_i2c_client)
4626 epm_i2c_client = epm_expander_i2c_register_board();
4627
4628 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4629 if (!rc)
4630 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4631 if (rc) {
4632 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4633 ": GPIO PWR MON Enable issue\n");
4634 goto exit_vreg_epm;
4635 }
4636
4637 msleep(1000);
4638
4639 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4640 if (!rc) {
4641 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4642 if (rc) {
4643 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4644 ": ADC1_PWDN error direction out\n");
4645 goto exit_vreg_epm;
4646 }
4647 }
4648
4649 msleep(100);
4650
4651 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4652 if (!rc) {
4653 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4654 if (rc) {
4655 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4656 ": ADC2_PWD error direction out\n");
4657 goto exit_vreg_epm;
4658 }
4659 }
4660
4661 msleep(1000);
4662
4663 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4664 if (!rc) {
4665 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4666 if (rc) {
4667 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4668 "Gpio request problem %d\n", rc);
4669 goto exit_vreg_epm;
4670 }
4671 }
4672
4673 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4674 if (!rc) {
4675 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4676 if (rc) {
4677 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4678 ": EPM_SPI_ADC1_CS_N error\n");
4679 goto exit_vreg_epm;
4680 }
4681 }
4682
4683 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4684 if (!rc) {
4685 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4686 if (rc) {
4687 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4688 ": EPM_SPI_ADC2_Cs_N error\n");
4689 goto exit_vreg_epm;
4690 }
4691 }
4692
4693 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4694 "the power monitor reset for epm\n");
4695
4696 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4697 if (!rc) {
4698 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4699 if (rc) {
4700 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4701 ": Error in the power mon reset\n");
4702 goto exit_vreg_epm;
4703 }
4704 }
4705
4706 msleep(1000);
4707
4708 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4709
4710 msleep(500);
4711
4712 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4713
4714 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4715
4716 return rc;
4717
4718exit_vreg_epm:
4719 regulator_disable(vreg_adc_epm1);
4720
4721 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4722 " rc = %d.\n", rc);
4723 return rc;
4724};
4725
4726static unsigned int msm_adc_gpio_configure_expander_disable(void)
4727{
4728 int rc = 0;
4729
4730 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4731 gpio_free(GPIO_PWR_MON_RESET_N);
4732
4733 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4734 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4735
4736 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4737 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4738
4739 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4740 gpio_free(GPIO_PWR_MON_START);
4741
4742 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4743 gpio_free(GPIO_ADC1_PWDN_N);
4744
4745 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4746 gpio_free(GPIO_ADC2_PWDN_N);
4747
4748 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4749 gpio_free(GPIO_PWR_MON_ENABLE);
4750
4751 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4752 gpio_free(GPIO_EPM_LVLSFT_EN);
4753
4754 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4755 gpio_free(GPIO_EPM_5V_BOOST_EN);
4756
4757 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4758 gpio_free(GPIO_EPM_3_3V_EN);
4759
4760 rc = regulator_disable(vreg_adc_epm1);
4761 if (rc)
4762 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4763 "Error while enabling regulator for epm s3 %d\n", rc);
4764 regulator_put(vreg_adc_epm1);
4765
4766 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4767 return rc;
4768};
4769
4770unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4771{
4772 int rc = 0;
4773
4774 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4775 cs_enable);
4776
4777 if (cs_enable < 16) {
4778 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4779 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4780 } else {
4781 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4782 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4783 }
4784 return rc;
4785};
4786
4787unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4788{
4789 int rc = 0;
4790
4791 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4792
4793 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4794
4795 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4796
4797 return rc;
4798};
4799#endif
4800
4801static struct msm_adc_channels msm_adc_channels_data[] = {
4802 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4803 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4804 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4805 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4806 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4807 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4808 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4809 CHAN_PATH_TYPE4,
4810 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4811 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4812 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4813 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4814 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4815 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4816 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4817 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4818 CHAN_PATH_TYPE12,
4819 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4820 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4822 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4823 CHAN_PATH_TYPE_NONE,
4824 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4825 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4826 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4827 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4828 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4829 scale_xtern_chgr_cur},
4830 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4831 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4832 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4833 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4834 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4835 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4836 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4837 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4838 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4839 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4840 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4841 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4842};
4843
4844static char *msm_adc_fluid_device_names[] = {
4845 "ADS_ADC1",
4846 "ADS_ADC2",
4847};
4848
4849static struct msm_adc_platform_data msm_adc_pdata = {
4850 .channel = msm_adc_channels_data,
4851 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4852#if defined(CONFIG_I2C) && \
4853 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4854 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4855 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4856 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4857 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4858#endif
4859};
4860
4861static struct platform_device msm_adc_device = {
4862 .name = "msm_adc",
4863 .id = -1,
4864 .dev = {
4865 .platform_data = &msm_adc_pdata,
4866 },
4867};
4868
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304869static struct msm_rtb_platform_data msm_rtb_pdata = {
4870 .size = SZ_1M,
4871};
4872
4873static int __init msm_rtb_set_buffer_size(char *p)
4874{
4875 int s;
4876
4877 s = memparse(p, NULL);
4878 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4879 return 0;
4880}
4881early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4882
4883
4884static struct platform_device msm_rtb_device = {
4885 .name = "msm_rtb",
4886 .id = -1,
4887 .dev = {
4888 .platform_data = &msm_rtb_pdata,
4889 },
4890};
4891
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004892static void pmic8058_xoadc_mpp_config(void)
4893{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304894 int rc, i;
4895 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304896 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304897 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304898 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304899 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304900 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304901 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304902 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304903 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304904 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304905 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304906 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4907 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304908 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004909
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304910 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4911 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4912 &xoadc_mpps[i].config);
4913 if (rc) {
4914 pr_err("%s: Config MPP %d of PM8058 failed\n",
4915 __func__, xoadc_mpps[i].mpp);
4916 }
4917 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004918}
4919
4920static struct regulator *vreg_ldo18_adc;
4921
4922static int pmic8058_xoadc_vreg_config(int on)
4923{
4924 int rc;
4925
4926 if (on) {
4927 rc = regulator_enable(vreg_ldo18_adc);
4928 if (rc)
4929 pr_err("%s: Enable of regulator ldo18_adc "
4930 "failed\n", __func__);
4931 } else {
4932 rc = regulator_disable(vreg_ldo18_adc);
4933 if (rc)
4934 pr_err("%s: Disable of regulator ldo18_adc "
4935 "failed\n", __func__);
4936 }
4937
4938 return rc;
4939}
4940
4941static int pmic8058_xoadc_vreg_setup(void)
4942{
4943 int rc;
4944
4945 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4946 if (IS_ERR(vreg_ldo18_adc)) {
4947 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4948 __func__, PTR_ERR(vreg_ldo18_adc));
4949 rc = PTR_ERR(vreg_ldo18_adc);
4950 goto fail;
4951 }
4952
4953 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4954 if (rc) {
4955 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4956 goto fail;
4957 }
4958
4959 return rc;
4960fail:
4961 regulator_put(vreg_ldo18_adc);
4962 return rc;
4963}
4964
4965static void pmic8058_xoadc_vreg_shutdown(void)
4966{
4967 regulator_put(vreg_ldo18_adc);
4968}
4969
4970/* usec. For this ADC,
4971 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4972 * Each channel has different configuration, thus at the time of starting
4973 * the conversion, xoadc will return actual conversion time
4974 * */
4975static struct adc_properties pm8058_xoadc_data = {
4976 .adc_reference = 2200, /* milli-voltage for this adc */
4977 .bitresolution = 15,
4978 .bipolar = 0,
4979 .conversiontime = 54,
4980};
4981
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304982static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004983 .xoadc_prop = &pm8058_xoadc_data,
4984 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4985 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4986 .xoadc_num = XOADC_PMIC_0,
4987 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4988 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4989};
4990#endif
4991
4992#ifdef CONFIG_MSM_SDIO_AL
4993
4994static unsigned mdm2ap_status = 140;
4995
4996static int configure_mdm2ap_status(int on)
4997{
4998 int ret = 0;
4999 if (on)
5000 ret = msm_gpiomux_get(mdm2ap_status);
5001 else
5002 ret = msm_gpiomux_put(mdm2ap_status);
5003
5004 if (ret)
5005 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
5006 on);
5007
5008 return ret;
5009}
5010
5011
5012static int get_mdm2ap_status(void)
5013{
5014 return gpio_get_value(mdm2ap_status);
5015}
5016
5017static struct sdio_al_platform_data sdio_al_pdata = {
5018 .config_mdm2ap_status = configure_mdm2ap_status,
5019 .get_mdm2ap_status = get_mdm2ap_status,
5020 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03005021 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005022 .peer_sdioc_version_major = 0x0004,
5023 .peer_sdioc_boot_version_minor = 0x0001,
5024 .peer_sdioc_boot_version_major = 0x0003
5025};
5026
5027struct platform_device msm_device_sdio_al = {
5028 .name = "msm_sdio_al",
5029 .id = -1,
5030 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03005031 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005032 .platform_data = &sdio_al_pdata,
5033 },
5034};
5035
5036#endif /* CONFIG_MSM_SDIO_AL */
5037
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305038#define GPIO_VREG_ID_EXT_5V 0
5039
5040static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5041 REGULATOR_SUPPLY("ext_5v", NULL),
5042 REGULATOR_SUPPLY("8901_mpp0", NULL),
5043};
5044
5045#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5046 [GPIO_VREG_ID_##_id] = { \
5047 .init_data = { \
5048 .constraints = { \
5049 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5050 }, \
5051 .num_consumer_supplies = \
5052 ARRAY_SIZE(vreg_consumers_##_id), \
5053 .consumer_supplies = vreg_consumers_##_id, \
5054 }, \
5055 .regulator_name = _reg_name, \
5056 .active_low = _active_low, \
5057 .gpio_label = _gpio_label, \
5058 .gpio = _gpio, \
5059 }
5060
5061/* GPIO regulator constraints */
5062static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5063 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5064 PM8901_MPP_PM_TO_SYS(0), 0),
5065};
5066
5067/* GPIO regulator */
5068static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5069 .name = GPIO_REGULATOR_DEV_NAME,
5070 .id = PM8901_MPP_PM_TO_SYS(0),
5071 .dev = {
5072 .platform_data =
5073 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5074 },
5075};
5076
5077static void __init pm8901_vreg_mpp0_init(void)
5078{
5079 int rc;
5080
5081 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5082 .mpp = PM8901_MPP_PM_TO_SYS(0),
5083 .config = {
5084 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5085 .level = PM8901_MPP_DIG_LEVEL_VPH,
5086 },
5087 };
5088
5089 /*
5090 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5091 * implies that the regulator connected to MPP0 is enabled when
5092 * MPP0 is low.
5093 */
5094 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5095 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5096 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5097 } else {
5098 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5099 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5100 }
5101
5102 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5103 if (rc)
5104 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5105}
5106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005107static struct platform_device *charm_devices[] __initdata = {
5108 &msm_charm_modem,
5109#ifdef CONFIG_MSM_SDIO_AL
5110 &msm_device_sdio_al,
5111#endif
5112};
5113
Lei Zhou338cab82011-08-19 13:38:17 -04005114#ifdef CONFIG_SND_SOC_MSM8660_APQ
5115static struct platform_device *dragon_alsa_devices[] __initdata = {
5116 &msm_pcm,
5117 &msm_pcm_routing,
5118 &msm_cpudai0,
5119 &msm_cpudai1,
5120 &msm_cpudai_hdmi_rx,
5121 &msm_cpudai_bt_rx,
5122 &msm_cpudai_bt_tx,
5123 &msm_cpudai_fm_rx,
5124 &msm_cpudai_fm_tx,
5125 &msm_cpu_fe,
5126 &msm_stub_codec,
5127 &msm_lpa_pcm,
5128};
5129#endif
5130
5131static struct platform_device *asoc_devices[] __initdata = {
5132 &asoc_msm_pcm,
5133 &asoc_msm_dai0,
5134 &asoc_msm_dai1,
5135};
5136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005137static struct platform_device *surf_devices[] __initdata = {
5138 &msm_device_smd,
5139 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005140 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005141 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005142 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005143 &msm_pil_dsps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005144#ifdef CONFIG_I2C_QUP
5145 &msm_gsbi3_qup_i2c_device,
5146 &msm_gsbi4_qup_i2c_device,
5147 &msm_gsbi7_qup_i2c_device,
5148 &msm_gsbi8_qup_i2c_device,
5149 &msm_gsbi9_qup_i2c_device,
5150 &msm_gsbi12_qup_i2c_device,
5151#endif
5152#ifdef CONFIG_SERIAL_MSM_HS
5153 &msm_device_uart_dm1,
5154#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305155#ifdef CONFIG_MSM_SSBI
5156 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305157 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305158#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005159#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005160 &msm_device_ssbi3,
5161#endif
5162#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5163 &isp1763_device,
5164#endif
5165
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005166#if defined (CONFIG_MSM_8x60_VOIP)
5167 &asoc_msm_mvs,
5168 &asoc_mvs_dai0,
5169 &asoc_mvs_dai1,
5170#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005171
Lena Salman57d167e2012-03-21 19:46:38 +02005172#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005173 &msm_device_otg,
5174#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005175#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005176 &msm_device_gadget_peripheral,
5177#endif
5178#ifdef CONFIG_USB_G_ANDROID
5179 &android_usb_device,
5180#endif
5181#ifdef CONFIG_BATTERY_MSM
5182 &msm_batt_device,
5183#endif
5184#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005185#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005186 &android_pmem_device,
5187 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005188 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005189 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305190#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5191#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005192#ifdef CONFIG_MSM_ROTATOR
5193 &msm_rotator_device,
5194#endif
5195 &msm_fb_device,
5196 &msm_kgsl_3d0,
5197 &msm_kgsl_2d0,
5198 &msm_kgsl_2d1,
5199 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005200#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5201 &lcdc_nt35582_panel_device,
5202#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5204 &lcdc_samsung_oled_panel_device,
5205#endif
5206#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5207 &lcdc_auo_wvga_panel_device,
5208#endif
5209#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5210 &hdmi_msm_device,
5211#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5212#ifdef CONFIG_FB_MSM_MIPI_DSI
5213 &mipi_dsi_toshiba_panel_device,
5214 &mipi_dsi_novatek_panel_device,
5215#endif
5216#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005217#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005218#ifdef CONFIG_MT9E013
5219 &msm_camera_sensor_mt9e013,
5220#endif
5221#ifdef CONFIG_IMX074
5222 &msm_camera_sensor_imx074,
5223#endif
5224#ifdef CONFIG_WEBCAM_OV7692
5225 &msm_camera_sensor_webcam_ov7692,
5226#endif
5227#ifdef CONFIG_WEBCAM_OV9726
5228 &msm_camera_sensor_webcam_ov9726,
5229#endif
5230#ifdef CONFIG_QS_S5K4E1
5231 &msm_camera_sensor_qs_s5k4e1,
5232#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005233#ifdef CONFIG_VX6953
5234 &msm_camera_sensor_vx6953,
5235#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005236#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005237#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005238#ifdef CONFIG_MSM_GEMINI
5239 &msm_gemini_device,
5240#endif
5241#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005242#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005243 &msm_vpe_device,
5244#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005245#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005246
5247#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005248 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005249#endif
5250#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005251 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005252#endif
5253 &msm_device_vidc,
5254#if (defined(CONFIG_MARIMBA_CORE)) && \
5255 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5256 &msm_bt_power_device,
5257#endif
5258#ifdef CONFIG_SENSORS_MSM_ADC
5259 &msm_adc_device,
5260#endif
David Collins6f032ba2011-08-31 14:08:15 -07005261 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005262
5263#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5264 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5265 &qcrypto_device,
5266#endif
5267
5268#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5269 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5270 &qcedev_device,
5271#endif
5272
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005273
5274#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5275#ifdef CONFIG_MSM_USE_TSIF1
5276 &msm_device_tsif[1],
5277#else
5278 &msm_device_tsif[0],
5279#endif /* CONFIG_MSM_USE_TSIF1 */
5280#endif /* CONFIG_TSIF */
5281
5282#ifdef CONFIG_HW_RANDOM_MSM
5283 &msm_device_rng,
5284#endif
5285
5286 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005287 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005288#ifdef CONFIG_ION_MSM
5289 &ion_dev,
5290#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005291 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005292 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305293 &msm_rtb_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005294};
5295
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005296#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005297#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5298static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5299 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005300 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005301 .request_region = request_smi_region,
5302 .release_region = release_smi_region,
5303 .setup_region = setup_smi_region,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305304 .secure_base = MSM_ION_HOLE_BASE,
5305 .secure_size = MSM_ION_HOLE_SIZE + MSM_ION_MM_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005306 .iommu_map_all = 1,
5307 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005308};
5309
5310static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5311 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005312 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005313 .request_region = request_smi_region,
5314 .release_region = release_smi_region,
5315 .setup_region = setup_smi_region,
5316};
5317
5318static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5319 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005320 .align = PAGE_SIZE,
5321};
5322
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305323static struct ion_co_heap_pdata hole_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005324 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005325};
5326
5327static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005328 .adjacent_mem_id = INVALID_HEAP_ID,
5329 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005330};
5331#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005332
5333/**
5334 * These heaps are listed in the order they will be allocated. Due to
5335 * video hardware restrictions and content protection the FW heap has to
5336 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5337 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5338 * away from the base address of the FW heap.
5339 * However, the order of FW heap and MM heap doesn't matter since these
5340 * two heaps are taken care of by separate code to ensure they are adjacent
5341 * to each other.
5342 * Don't swap the order unless you know what you are doing!
5343 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005344static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005345 .nr = MSM_ION_HEAP_NUM,
5346 .heaps = {
5347 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005348 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005349 .type = ION_HEAP_TYPE_SYSTEM,
5350 .name = ION_VMALLOC_HEAP_NAME,
5351 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005352#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5353 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005354 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005355 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005356 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305357 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005358 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005359 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005360 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005361 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005362 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005363 .id = ION_MM_FIRMWARE_HEAP_ID,
5364 .type = ION_HEAP_TYPE_CARVEOUT,
5365 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305366 .base = MSM_ION_HOLE_BASE,
5367 .size = MSM_ION_HOLE_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005368 .memory_type = ION_SMI_TYPE,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305369 .extra_data = (void *) &hole_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005370 },
5371 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005372 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005373 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005374 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305375 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005376 .size = MSM_ION_MFC_SIZE,
5377 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005378 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005379 },
5380 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005381 .id = ION_SF_HEAP_ID,
5382 .type = ION_HEAP_TYPE_CARVEOUT,
5383 .name = ION_SF_HEAP_NAME,
5384 .size = MSM_ION_SF_SIZE,
5385 .memory_type = ION_EBI_TYPE,
5386 .extra_data = (void *)&co_ion_pdata,
5387 },
5388 {
5389 .id = ION_CAMERA_HEAP_ID,
5390 .type = ION_HEAP_TYPE_CARVEOUT,
5391 .name = ION_CAMERA_HEAP_NAME,
5392 .size = MSM_ION_CAMERA_SIZE,
5393 .memory_type = ION_EBI_TYPE,
5394 .extra_data = &co_ion_pdata,
5395 },
5396 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005397 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005398 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005399 .name = ION_WB_HEAP_NAME,
5400 .size = MSM_ION_WB_SIZE,
5401 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005402 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005403 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005404 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005405 .id = ION_QSECOM_HEAP_ID,
5406 .type = ION_HEAP_TYPE_CARVEOUT,
5407 .name = ION_QSECOM_HEAP_NAME,
5408 .size = MSM_ION_QSECOM_SIZE,
5409 .memory_type = ION_EBI_TYPE,
5410 .extra_data = (void *) &co_ion_pdata,
5411 },
5412 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005413 .id = ION_AUDIO_HEAP_ID,
5414 .type = ION_HEAP_TYPE_CARVEOUT,
5415 .name = ION_AUDIO_HEAP_NAME,
5416 .size = MSM_ION_AUDIO_SIZE,
5417 .memory_type = ION_EBI_TYPE,
5418 .extra_data = (void *)&co_ion_pdata,
5419 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005420#endif
5421 }
5422};
5423
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005424static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005425 .name = "ion-msm",
5426 .id = 1,
5427 .dev = { .platform_data = &ion_pdata },
5428};
5429#endif
5430
5431
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005432static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5433 /* Kernel SMI memory pool for video core, used for firmware */
5434 /* and encoder, decoder scratch buffers */
5435 /* Kernel SMI memory pool should always precede the user space */
5436 /* SMI memory pool, as the video core will use offset address */
5437 /* from the Firmware base */
5438 [MEMTYPE_SMI_KERNEL] = {
5439 .start = KERNEL_SMI_BASE,
5440 .limit = KERNEL_SMI_SIZE,
5441 .size = KERNEL_SMI_SIZE,
5442 .flags = MEMTYPE_FLAGS_FIXED,
5443 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005444 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005445 },
5446 [MEMTYPE_EBI0] = {
5447 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5448 },
5449 [MEMTYPE_EBI1] = {
5450 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5451 },
5452};
5453
Stephen Boyd668d7652012-04-25 11:31:01 -07005454static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005455{
5456#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005457 unsigned int i;
5458
5459 if (hdmi_is_primary) {
5460 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5461 for (i = 0; i < ion_pdata.nr; i++) {
5462 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5463 ion_pdata.heaps[i].size = msm_ion_sf_size;
5464 pr_debug("msm_ion_sf_size 0x%x\n",
5465 msm_ion_sf_size);
5466 break;
5467 }
5468 }
5469 }
5470
Olav Haugan8726caf2012-05-10 15:11:35 -07005471 /* Verify size of heap is a multiple of 64K */
5472 for (i = 0; i < ion_pdata.nr; i++) {
5473 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5474
5475 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5476 int map_all = ((struct ion_cp_heap_pdata *)
5477 heap->extra_data)->iommu_map_all;
5478
5479 if (map_all && (heap->size & (SZ_64K-1))) {
5480 heap->size = ALIGN(heap->size, SZ_64K);
5481 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5482 heap->name, heap->size);
5483
5484 }
5485 }
5486 }
5487
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005488 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005489 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5490 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005491 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005492 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005493#endif
5494}
5495
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005496static void __init size_pmem_devices(void)
5497{
5498#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005499#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005500 android_pmem_adsp_pdata.size = pmem_adsp_size;
5501 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005502
5503 if (hdmi_is_primary)
5504 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005505 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005506 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305507#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5508#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005509}
5510
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305511#ifdef CONFIG_ANDROID_PMEM
5512#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005513static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5514{
5515 msm8x60_reserve_table[p->memory_type].size += p->size;
5516}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305517#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5518#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005519
5520static void __init reserve_pmem_memory(void)
5521{
5522#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005523#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005524 reserve_memory_for(&android_pmem_adsp_pdata);
5525 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005526 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005527 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305528#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005529 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305530#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005531}
5532
Huaibin Yanga5419422011-12-08 23:52:10 -08005533static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005534
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305535static void __init reserve_rtb_memory(void)
5536{
5537#if defined(CONFIG_MSM_RTB)
5538 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5539#endif
5540}
5541
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005542static void __init msm8x60_calculate_reserve_sizes(void)
5543{
5544 size_pmem_devices();
5545 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005546 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005547 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305548 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005549}
5550
5551static int msm8x60_paddr_to_memtype(unsigned int paddr)
5552{
5553 if (paddr >= 0x40000000 && paddr < 0x60000000)
5554 return MEMTYPE_EBI1;
5555 if (paddr >= 0x38000000 && paddr < 0x40000000)
5556 return MEMTYPE_SMI;
5557 return MEMTYPE_NONE;
5558}
5559
5560static struct reserve_info msm8x60_reserve_info __initdata = {
5561 .memtype_reserve_table = msm8x60_reserve_table,
5562 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5563 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5564};
5565
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005566static char prim_panel_name[PANEL_NAME_MAX_LEN];
5567static char ext_panel_name[PANEL_NAME_MAX_LEN];
5568static int __init prim_display_setup(char *param)
5569{
5570 if (strnlen(param, PANEL_NAME_MAX_LEN))
5571 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5572 return 0;
5573}
5574early_param("prim_display", prim_display_setup);
5575
5576static int __init ext_display_setup(char *param)
5577{
5578 if (strnlen(param, PANEL_NAME_MAX_LEN))
5579 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5580 return 0;
5581}
5582early_param("ext_display", ext_display_setup);
5583
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005584static void __init msm8x60_reserve(void)
5585{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005586 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587 reserve_info = &msm8x60_reserve_info;
5588 msm_reserve();
5589}
5590
5591#define EXT_CHG_VALID_MPP 10
5592#define EXT_CHG_VALID_MPP_2 11
5593
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305594static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305595 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305596 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305597 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305598 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5599};
5600
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005601#ifdef CONFIG_ISL9519_CHARGER
5602static int isl_detection_setup(void)
5603{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305604 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005605
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305606 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5607 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5608 &isl_mpp[i].config);
5609 if (ret) {
5610 pr_err("%s: Config MPP %d of PM8058 failed\n",
5611 __func__, isl_mpp[i].mpp);
5612 return ret;
5613 }
5614 }
5615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616 return ret;
5617}
5618
5619static struct isl_platform_data isl_data __initdata = {
5620 .chgcurrent = 700,
5621 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5622 .chg_detection_config = isl_detection_setup,
5623 .max_system_voltage = 4200,
5624 .min_system_voltage = 3200,
5625 .term_current = 120,
5626 .input_current = 2048,
5627};
5628
5629static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5630 {
5631 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305632 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005633 .platform_data = &isl_data,
5634 },
5635};
5636#endif
5637
5638#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5639static int smb137b_detection_setup(void)
5640{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305641 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005642
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305643 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5644 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5645 &isl_mpp[i].config);
5646 if (ret) {
5647 pr_err("%s: Config MPP %d of PM8058 failed\n",
5648 __func__, isl_mpp[i].mpp);
5649 return ret;
5650 }
5651 }
5652
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005653 return ret;
5654}
5655
5656static struct smb137b_platform_data smb137b_data __initdata = {
5657 .chg_detection_config = smb137b_detection_setup,
5658 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5659 .batt_mah_rating = 950,
5660};
5661
5662static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5663 {
5664 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305665 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005666 .platform_data = &smb137b_data,
5667 },
5668};
5669#endif
5670
5671#ifdef CONFIG_PMIC8058
5672#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305673#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005674
5675static int pm8058_gpios_init(void)
5676{
5677 int i;
5678 int rc;
5679 struct pm8058_gpio_cfg {
5680 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305681 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005682 };
5683
5684 struct pm8058_gpio_cfg gpio_cfgs[] = {
5685 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305686 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005687 {
5688 .direction = PM_GPIO_DIR_IN,
5689 .pull = PM_GPIO_PULL_DN,
5690 .vin_sel = 2,
5691 .function = PM_GPIO_FUNC_NORMAL,
5692 .inv_int_pol = 0,
5693 },
5694 },
5695#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5696 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305697 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005698 {
5699 .direction = PM_GPIO_DIR_IN,
5700 .pull = PM_GPIO_PULL_UP_30,
5701 .vin_sel = 2,
5702 .function = PM_GPIO_FUNC_NORMAL,
5703 .inv_int_pol = 0,
5704 },
5705 },
5706#endif
5707 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305708 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005709 {
5710 .direction = PM_GPIO_DIR_IN,
5711 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305712 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005713 .function = PM_GPIO_FUNC_NORMAL,
5714 .inv_int_pol = 0,
5715 },
5716 },
5717 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305718 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 {
5720 .direction = PM_GPIO_DIR_IN,
5721 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305722 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005723 .function = PM_GPIO_FUNC_NORMAL,
5724 .inv_int_pol = 0,
5725 },
5726 },
5727 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305728 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005729 {
5730 .direction = PM_GPIO_DIR_IN,
5731 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305732 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005733 .function = PM_GPIO_FUNC_NORMAL,
5734 .inv_int_pol = 0,
5735 },
5736 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005737 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305738 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005739 {
5740 .direction = PM_GPIO_DIR_OUT,
5741 .output_value = 1,
5742 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5743 .pull = PM_GPIO_PULL_DN,
5744 .out_strength = PM_GPIO_STRENGTH_HIGH,
5745 .function = PM_GPIO_FUNC_NORMAL,
5746 .vin_sel = 2,
5747 .inv_int_pol = 0,
5748 }
5749 },
5750 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305751 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752 {
5753 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305754 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005755 .function = PM_GPIO_FUNC_NORMAL,
5756 .vin_sel = 2,
5757 .inv_int_pol = 0,
5758 }
5759 },
5760 };
5761
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305762#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5763 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305764 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305765 .direction = PM_GPIO_DIR_IN,
5766 .pull = PM_GPIO_PULL_UP_1P5,
5767 .vin_sel = 2,
5768 .function = PM_GPIO_FUNC_NORMAL,
5769 };
5770#endif
5771
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005772#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305773 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305774 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305775 .direction = PM_GPIO_DIR_OUT,
5776 .pull = PM_GPIO_PULL_NO,
5777 .out_strength = PM_GPIO_STRENGTH_HIGH,
5778 .function = PM_GPIO_FUNC_NORMAL,
5779 .inv_int_pol = 0,
5780 .vin_sel = 2,
5781 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5782 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005783 };
5784#endif
5785
5786#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5787 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305788 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 {
5790 .direction = PM_GPIO_DIR_IN,
5791 .pull = PM_GPIO_PULL_UP_1P5,
5792 .vin_sel = 2,
5793 .function = PM_GPIO_FUNC_NORMAL,
5794 .inv_int_pol = 0,
5795 }
5796 };
5797#endif
5798
5799#if defined(CONFIG_QS_S5K4E1)
5800 {
5801 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305802 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005803 {
5804 .direction = PM_GPIO_DIR_OUT,
5805 .output_value = 0,
5806 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5807 .pull = PM_GPIO_PULL_DN,
5808 .out_strength = PM_GPIO_STRENGTH_HIGH,
5809 .function = PM_GPIO_FUNC_NORMAL,
5810 .vin_sel = 2,
5811 .inv_int_pol = 0,
5812 }
5813 };
5814#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005815#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5816 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305817 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005818 {
5819 .direction = PM_GPIO_DIR_OUT,
5820 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5821 .output_value = 1,
5822 .pull = PM_GPIO_PULL_UP_30,
5823 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305824 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005825 .out_strength = PM_GPIO_STRENGTH_HIGH,
5826 .function = PM_GPIO_FUNC_NORMAL,
5827 .inv_int_pol = 0,
5828 }
5829 };
5830#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005831#if defined(CONFIG_HAPTIC_ISA1200) || \
5832 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5833 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305834 rc = pm8xxx_gpio_config(
5835 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5836 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005837 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305838 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005839 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305840 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305841 rc = pm8xxx_gpio_config(
5842 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5843 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305844 if (rc < 0) {
5845 pr_err("%s: pmic haptics ldo gpio config failed\n",
5846 __func__);
5847 }
5848
5849 }
5850#endif
5851
5852#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5853 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5854 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5855 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305856 rc = pm8xxx_gpio_config(
5857 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5858 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305859 if (rc < 0) {
5860 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5861 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005862 }
5863 }
5864#endif
5865
5866#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5867 /* Line_in only for 8660 ffa & surf */
5868 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005869 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005870 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305871 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005872 &line_in_gpio_cfg.cfg);
5873 if (rc < 0) {
5874 pr_err("%s pmic line_in gpio config failed\n",
5875 __func__);
5876 return rc;
5877 }
5878 }
5879#endif
5880
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005881#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5882 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305883 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005884 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5885 if (rc < 0) {
5886 pr_err("%s pmic gpio config failed\n", __func__);
5887 return rc;
5888 }
5889 }
5890#endif
5891
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005892#if defined(CONFIG_QS_S5K4E1)
5893 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5894 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305895 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005896 &qs_hc37_cam_pd_gpio_cfg.cfg);
5897 if (rc < 0) {
5898 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5899 __func__);
5900 return rc;
5901 }
5902 }
5903 }
5904#endif
5905
5906 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305907 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005908 &gpio_cfgs[i].cfg);
5909 if (rc < 0) {
5910 pr_err("%s pmic gpio config failed\n",
5911 __func__);
5912 return rc;
5913 }
5914 }
5915
5916 return 0;
5917}
5918
5919static const unsigned int ffa_keymap[] = {
5920 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5921 KEY(0, 1, KEY_UP), /* NAV - UP */
5922 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5923 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5924
5925 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5926 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5927 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5928 KEY(1, 3, KEY_VOLUMEDOWN),
5929
5930 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5931
5932 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5933 KEY(4, 1, KEY_UP), /* USER_UP */
5934 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5935 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5936 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5937
5938 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5939 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5940 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5941 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5942 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5943};
5944
Zhang Chang Ken683be172011-08-10 17:45:34 -04005945static const unsigned int dragon_keymap[] = {
5946 KEY(0, 0, KEY_MENU),
5947 KEY(0, 2, KEY_1),
5948 KEY(0, 3, KEY_4),
5949 KEY(0, 4, KEY_7),
5950
5951 KEY(1, 0, KEY_UP),
5952 KEY(1, 1, KEY_LEFT),
5953 KEY(1, 2, KEY_DOWN),
5954 KEY(1, 3, KEY_5),
5955 KEY(1, 4, KEY_8),
5956
5957 KEY(2, 0, KEY_HOME),
5958 KEY(2, 1, KEY_REPLY),
5959 KEY(2, 2, KEY_2),
5960 KEY(2, 3, KEY_6),
5961 KEY(2, 4, KEY_0),
5962
5963 KEY(3, 0, KEY_VOLUMEUP),
5964 KEY(3, 1, KEY_RIGHT),
5965 KEY(3, 2, KEY_3),
5966 KEY(3, 3, KEY_9),
5967 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5968
5969 KEY(4, 0, KEY_VOLUMEDOWN),
5970 KEY(4, 1, KEY_BACK),
5971 KEY(4, 2, KEY_CAMERA),
5972 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5973};
5974
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005975static struct matrix_keymap_data ffa_keymap_data = {
5976 .keymap_size = ARRAY_SIZE(ffa_keymap),
5977 .keymap = ffa_keymap,
5978};
5979
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305980static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005981 .input_name = "ffa-keypad",
5982 .input_phys_device = "ffa-keypad/input0",
5983 .num_rows = 6,
5984 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305985 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5986 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5987 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005988 .scan_delay_ms = 32,
5989 .row_hold_ns = 91500,
5990 .wakeup = 1,
5991 .keymap_data = &ffa_keymap_data,
5992};
5993
Zhang Chang Ken683be172011-08-10 17:45:34 -04005994static struct matrix_keymap_data dragon_keymap_data = {
5995 .keymap_size = ARRAY_SIZE(dragon_keymap),
5996 .keymap = dragon_keymap,
5997};
5998
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305999static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006000 .input_name = "dragon-keypad",
6001 .input_phys_device = "dragon-keypad/input0",
6002 .num_rows = 6,
6003 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306004 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6005 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6006 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006007 .scan_delay_ms = 32,
6008 .row_hold_ns = 91500,
6009 .wakeup = 1,
6010 .keymap_data = &dragon_keymap_data,
6011};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306012
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006013static const unsigned int fluid_keymap[] = {
6014 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6015 KEY(0, 1, KEY_UP), /* NAV - UP */
6016 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6017 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6018
6019 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6020 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6021 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6022 KEY(1, 3, KEY_VOLUMEUP),
6023
6024 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6025
6026 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6027 KEY(4, 1, KEY_UP), /* USER_UP */
6028 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6029 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6030 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6031
Jilai Wang9a895102011-07-12 14:00:35 -04006032 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006033 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6034 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6035 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6036 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6037};
6038
6039static struct matrix_keymap_data fluid_keymap_data = {
6040 .keymap_size = ARRAY_SIZE(fluid_keymap),
6041 .keymap = fluid_keymap,
6042};
6043
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306044static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006045 .input_name = "fluid-keypad",
6046 .input_phys_device = "fluid-keypad/input0",
6047 .num_rows = 6,
6048 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306049 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6050 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6051 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006052 .scan_delay_ms = 32,
6053 .row_hold_ns = 91500,
6054 .wakeup = 1,
6055 .keymap_data = &fluid_keymap_data,
6056};
6057
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306058static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006059 .initial_vibrate_ms = 500,
6060 .level_mV = 3000,
6061 .max_timeout_ms = 15000,
6062};
6063
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306064static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6065 .rtc_write_enable = false,
6066 .rtc_alarm_powerup = false,
6067};
6068
6069static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6070 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006071 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306072 .wakeup = 1,
6073};
6074
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006075#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6076
6077static struct othc_accessory_info othc_accessories[] = {
6078 {
6079 .accessory = OTHC_SVIDEO_OUT,
6080 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6081 | OTHC_ADC_DETECT,
6082 .key_code = SW_VIDEOOUT_INSERT,
6083 .enabled = false,
6084 .adc_thres = {
6085 .min_threshold = 20,
6086 .max_threshold = 40,
6087 },
6088 },
6089 {
6090 .accessory = OTHC_ANC_HEADPHONE,
6091 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6092 OTHC_SWITCH_DETECT,
6093 .gpio = PM8058_LINE_IN_DET_GPIO,
6094 .active_low = 1,
6095 .key_code = SW_HEADPHONE_INSERT,
6096 .enabled = true,
6097 },
6098 {
6099 .accessory = OTHC_ANC_HEADSET,
6100 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6101 .gpio = PM8058_LINE_IN_DET_GPIO,
6102 .active_low = 1,
6103 .key_code = SW_HEADPHONE_INSERT,
6104 .enabled = true,
6105 },
6106 {
6107 .accessory = OTHC_HEADPHONE,
6108 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6109 .key_code = SW_HEADPHONE_INSERT,
6110 .enabled = true,
6111 },
6112 {
6113 .accessory = OTHC_MICROPHONE,
6114 .detect_flags = OTHC_GPIO_DETECT,
6115 .gpio = PM8058_LINE_IN_DET_GPIO,
6116 .active_low = 1,
6117 .key_code = SW_MICROPHONE_INSERT,
6118 .enabled = true,
6119 },
6120 {
6121 .accessory = OTHC_HEADSET,
6122 .detect_flags = OTHC_MICBIAS_DETECT,
6123 .key_code = SW_HEADPHONE_INSERT,
6124 .enabled = true,
6125 },
6126};
6127
6128static struct othc_switch_info switch_info[] = {
6129 {
6130 .min_adc_threshold = 0,
6131 .max_adc_threshold = 100,
6132 .key_code = KEY_PLAYPAUSE,
6133 },
6134 {
6135 .min_adc_threshold = 100,
6136 .max_adc_threshold = 200,
6137 .key_code = KEY_REWIND,
6138 },
6139 {
6140 .min_adc_threshold = 200,
6141 .max_adc_threshold = 500,
6142 .key_code = KEY_FASTFORWARD,
6143 },
6144};
6145
6146static struct othc_n_switch_config switch_config = {
6147 .voltage_settling_time_ms = 0,
6148 .num_adc_samples = 3,
6149 .adc_channel = CHANNEL_ADC_HDSET,
6150 .switch_info = switch_info,
6151 .num_keys = ARRAY_SIZE(switch_info),
6152 .default_sw_en = true,
6153 .default_sw_idx = 0,
6154};
6155
6156static struct hsed_bias_config hsed_bias_config = {
6157 /* HSED mic bias config info */
6158 .othc_headset = OTHC_HEADSET_NO,
6159 .othc_lowcurr_thresh_uA = 100,
6160 .othc_highcurr_thresh_uA = 600,
6161 .othc_hyst_prediv_us = 7800,
6162 .othc_period_clkdiv_us = 62500,
6163 .othc_hyst_clk_us = 121000,
6164 .othc_period_clk_us = 312500,
6165 .othc_wakeup = 1,
6166};
6167
6168static struct othc_hsed_config hsed_config_1 = {
6169 .hsed_bias_config = &hsed_bias_config,
6170 /*
6171 * The detection delay and switch reporting delay are
6172 * required to encounter a hardware bug (spurious switch
6173 * interrupts on slow insertion/removal of the headset).
6174 * This will introduce a delay in reporting the accessory
6175 * insertion and removal to the userspace.
6176 */
6177 .detection_delay_ms = 1500,
6178 /* Switch info */
6179 .switch_debounce_ms = 1500,
6180 .othc_support_n_switch = false,
6181 .switch_config = &switch_config,
6182 .ir_gpio = -1,
6183 /* Accessory info */
6184 .accessories_support = true,
6185 .accessories = othc_accessories,
6186 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6187};
6188
6189static struct othc_regulator_config othc_reg = {
6190 .regulator = "8058_l5",
6191 .max_uV = 2850000,
6192 .min_uV = 2850000,
6193};
6194
6195/* MIC_BIAS0 is configured as normal MIC BIAS */
6196static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6197 .micbias_select = OTHC_MICBIAS_0,
6198 .micbias_capability = OTHC_MICBIAS,
6199 .micbias_enable = OTHC_SIGNAL_OFF,
6200 .micbias_regulator = &othc_reg,
6201};
6202
6203/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6204static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6205 .micbias_select = OTHC_MICBIAS_1,
6206 .micbias_capability = OTHC_MICBIAS_HSED,
6207 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6208 .micbias_regulator = &othc_reg,
6209 .hsed_config = &hsed_config_1,
6210 .hsed_name = "8660_handset",
6211};
6212
6213/* MIC_BIAS2 is configured as normal MIC BIAS */
6214static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6215 .micbias_select = OTHC_MICBIAS_2,
6216 .micbias_capability = OTHC_MICBIAS,
6217 .micbias_enable = OTHC_SIGNAL_OFF,
6218 .micbias_regulator = &othc_reg,
6219};
6220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006221
6222static void __init msm8x60_init_pm8058_othc(void)
6223{
6224 int i;
6225
6226 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6227 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6228 machine_is_msm8x60_fusn_ffa()) {
6229 /* 3-switch headset supported only by V2 FFA and FLUID */
6230 hsed_config_1.accessories_adc_support = true,
6231 /* ADC based accessory detection works only on V2 and FLUID */
6232 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6233 hsed_config_1.othc_support_n_switch = true;
6234 }
6235
6236 /* IR GPIO is absent on FLUID */
6237 if (machine_is_msm8x60_fluid())
6238 hsed_config_1.ir_gpio = -1;
6239
6240 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6241 if (machine_is_msm8x60_fluid()) {
6242 switch (othc_accessories[i].accessory) {
6243 case OTHC_ANC_HEADPHONE:
6244 case OTHC_ANC_HEADSET:
6245 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6246 break;
6247 case OTHC_MICROPHONE:
6248 othc_accessories[i].enabled = false;
6249 break;
6250 case OTHC_SVIDEO_OUT:
6251 othc_accessories[i].enabled = true;
6252 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6253 break;
6254 }
6255 }
6256 }
6257}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006258
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006259
6260static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6261{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306262 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006263 .direction = PM_GPIO_DIR_OUT,
6264 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6265 .output_value = 0,
6266 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306267 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268 .out_strength = PM_GPIO_STRENGTH_HIGH,
6269 .function = PM_GPIO_FUNC_2,
6270 };
6271
6272 int rc = -EINVAL;
6273 int id, mode, max_mA;
6274
6275 id = mode = max_mA = 0;
6276 switch (ch) {
6277 case 0:
6278 case 1:
6279 case 2:
6280 if (on) {
6281 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306282 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6283 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006284 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306285 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006286 __func__, id, rc);
6287 }
6288 break;
6289
6290 case 6:
6291 id = PM_PWM_LED_FLASH;
6292 mode = PM_PWM_CONF_PWM1;
6293 max_mA = 300;
6294 break;
6295
6296 case 7:
6297 id = PM_PWM_LED_FLASH1;
6298 mode = PM_PWM_CONF_PWM1;
6299 max_mA = 300;
6300 break;
6301
6302 default:
6303 break;
6304 }
6305
6306 if (ch >= 6 && ch <= 7) {
6307 if (!on) {
6308 mode = PM_PWM_CONF_NONE;
6309 max_mA = 0;
6310 }
6311 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6312 if (rc)
6313 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6314 __func__, ch, rc);
6315 }
6316 return rc;
6317
6318}
6319
6320static struct pm8058_pwm_pdata pm8058_pwm_data = {
6321 .config = pm8058_pwm_config,
6322};
6323
6324#define PM8058_GPIO_INT 88
6325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006326static struct pmic8058_led pmic8058_flash_leds[] = {
6327 [0] = {
6328 .name = "camera:flash0",
6329 .max_brightness = 15,
6330 .id = PMIC8058_ID_FLASH_LED_0,
6331 },
6332 [1] = {
6333 .name = "camera:flash1",
6334 .max_brightness = 15,
6335 .id = PMIC8058_ID_FLASH_LED_1,
6336 },
6337};
6338
6339static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6340 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6341 .leds = pmic8058_flash_leds,
6342};
6343
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006344static struct pmic8058_led pmic8058_dragon_leds[] = {
6345 [0] = {
6346 /* RED */
6347 .name = "led_drv0",
6348 .max_brightness = 15,
6349 .id = PMIC8058_ID_LED_0,
6350 },/* 300 mA flash led0 drv sink */
6351 [1] = {
6352 /* Yellow */
6353 .name = "led_drv1",
6354 .max_brightness = 15,
6355 .id = PMIC8058_ID_LED_1,
6356 },/* 300 mA flash led0 drv sink */
6357 [2] = {
6358 /* Green */
6359 .name = "led_drv2",
6360 .max_brightness = 15,
6361 .id = PMIC8058_ID_LED_2,
6362 },/* 300 mA flash led0 drv sink */
6363 [3] = {
6364 .name = "led_psensor",
6365 .max_brightness = 15,
6366 .id = PMIC8058_ID_LED_KB_LIGHT,
6367 },/* 300 mA flash led0 drv sink */
6368};
6369
6370static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6371 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6372 .leds = pmic8058_dragon_leds,
6373};
6374
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006375static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6376 [0] = {
6377 .name = "led:drv0",
6378 .max_brightness = 15,
6379 .id = PMIC8058_ID_FLASH_LED_0,
6380 },/* 300 mA flash led0 drv sink */
6381 [1] = {
6382 .name = "led:drv1",
6383 .max_brightness = 15,
6384 .id = PMIC8058_ID_FLASH_LED_1,
6385 },/* 300 mA flash led1 sink */
6386 [2] = {
6387 .name = "led:drv2",
6388 .max_brightness = 20,
6389 .id = PMIC8058_ID_LED_0,
6390 },/* 40 mA led0 sink */
6391 [3] = {
6392 .name = "keypad:drv",
6393 .max_brightness = 15,
6394 .id = PMIC8058_ID_LED_KB_LIGHT,
6395 },/* 300 mA keypad drv sink */
6396};
6397
6398static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6399 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6400 .leds = pmic8058_fluid_flash_leds,
6401};
6402
Terence Hampson90508a92011-08-09 10:40:08 -04006403static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306404 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006405 .max_source_current = 1800,
6406 .charger_type = CHG_TYPE_AC,
6407};
6408
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306409static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6410 .charger_data_valid = false,
6411};
6412
6413static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6414 .priority = 0,
6415};
6416
6417static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6418 .irq_base = PM8058_IRQ_BASE,
6419 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6420 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6421};
6422
6423static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6424 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6425};
6426
6427static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6428 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006429};
6430
6431static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306432 .irq_pdata = &pm8058_irq_pdata,
6433 .gpio_pdata = &pm8058_gpio_pdata,
6434 .mpp_pdata = &pm8058_mpp_pdata,
6435 .rtc_pdata = &pm8058_rtc_pdata,
6436 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6437 .othc0_pdata = &othc_config_pdata_0,
6438 .othc1_pdata = &othc_config_pdata_1,
6439 .othc2_pdata = &othc_config_pdata_2,
6440 .pwm_pdata = &pm8058_pwm_data,
6441 .misc_pdata = &pm8058_misc_pdata,
6442#ifdef CONFIG_SENSORS_MSM_ADC
6443 .xoadc_pdata = &pm8058_xoadc_pdata,
6444#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006445};
6446
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306447#ifdef CONFIG_MSM_SSBI
6448static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6449 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6450 .slave = {
6451 .name = "pm8058-core",
6452 .platform_data = &pm8058_platform_data,
6453 },
6454};
6455#endif
6456#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006457
6458#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6459 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6460#define TDISC_I2C_SLAVE_ADDR 0x67
6461#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6462#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6463
6464static const char *vregs_tdisc_name[] = {
6465 "8058_l5",
6466 "8058_s3",
6467};
6468
6469static const int vregs_tdisc_val[] = {
6470 2850000,/* uV */
6471 1800000,
6472};
6473static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6474
6475static int tdisc_shinetsu_setup(void)
6476{
6477 int rc, i;
6478
6479 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6480 if (rc) {
6481 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6482 __func__);
6483 return rc;
6484 }
6485
6486 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6487 if (rc) {
6488 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6489 __func__);
6490 goto fail_gpio_oe;
6491 }
6492
6493 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6494 if (rc) {
6495 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6496 __func__);
6497 gpio_free(GPIO_JOYSTICK_EN);
6498 goto fail_gpio_oe;
6499 }
6500
6501 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6502 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6503 if (IS_ERR(vregs_tdisc[i])) {
6504 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6505 __func__, vregs_tdisc_name[i],
6506 PTR_ERR(vregs_tdisc[i]));
6507 rc = PTR_ERR(vregs_tdisc[i]);
6508 goto vreg_get_fail;
6509 }
6510
6511 rc = regulator_set_voltage(vregs_tdisc[i],
6512 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6513 if (rc) {
6514 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6515 __func__, rc);
6516 goto vreg_set_voltage_fail;
6517 }
6518 }
6519
6520 return rc;
6521vreg_set_voltage_fail:
6522 i++;
6523vreg_get_fail:
6524 while (i)
6525 regulator_put(vregs_tdisc[--i]);
6526fail_gpio_oe:
6527 gpio_free(PMIC_GPIO_TDISC);
6528 return rc;
6529}
6530
6531static void tdisc_shinetsu_release(void)
6532{
6533 int i;
6534
6535 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6536 regulator_put(vregs_tdisc[i]);
6537
6538 gpio_free(PMIC_GPIO_TDISC);
6539 gpio_free(GPIO_JOYSTICK_EN);
6540}
6541
6542static int tdisc_shinetsu_enable(void)
6543{
6544 int i, rc = -EINVAL;
6545
6546 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6547 rc = regulator_enable(vregs_tdisc[i]);
6548 if (rc < 0) {
6549 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6550 __func__, vregs_tdisc_name[i], rc);
6551 goto vreg_fail;
6552 }
6553 }
6554
6555 /* Enable the OE (output enable) gpio */
6556 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6557 /* voltage and gpio stabilization delay */
6558 msleep(50);
6559
6560 return 0;
6561vreg_fail:
6562 while (i)
6563 regulator_disable(vregs_tdisc[--i]);
6564 return rc;
6565}
6566
6567static int tdisc_shinetsu_disable(void)
6568{
6569 int i, rc;
6570
6571 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6572 rc = regulator_disable(vregs_tdisc[i]);
6573 if (rc < 0) {
6574 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6575 __func__, vregs_tdisc_name[i], rc);
6576 goto tdisc_reg_fail;
6577 }
6578 }
6579
6580 /* Disable the OE (output enable) gpio */
6581 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6582
6583 return 0;
6584
6585tdisc_reg_fail:
6586 while (i)
6587 regulator_enable(vregs_tdisc[--i]);
6588 return rc;
6589}
6590
6591static struct tdisc_abs_values tdisc_abs = {
6592 .x_max = 32,
6593 .y_max = 32,
6594 .x_min = -32,
6595 .y_min = -32,
6596 .pressure_max = 32,
6597 .pressure_min = 0,
6598};
6599
6600static struct tdisc_platform_data tdisc_data = {
6601 .tdisc_setup = tdisc_shinetsu_setup,
6602 .tdisc_release = tdisc_shinetsu_release,
6603 .tdisc_enable = tdisc_shinetsu_enable,
6604 .tdisc_disable = tdisc_shinetsu_disable,
6605 .tdisc_wakeup = 0,
6606 .tdisc_gpio = PMIC_GPIO_TDISC,
6607 .tdisc_report_keys = true,
6608 .tdisc_report_relative = true,
6609 .tdisc_report_absolute = false,
6610 .tdisc_report_wheel = false,
6611 .tdisc_reverse_x = false,
6612 .tdisc_reverse_y = true,
6613 .tdisc_abs = &tdisc_abs,
6614};
6615
6616static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6617 {
6618 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6619 .irq = TDISC_INT,
6620 .platform_data = &tdisc_data,
6621 },
6622};
6623#endif
6624
6625#define PM_GPIO_CDC_RST_N 20
6626#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6627
6628static struct regulator *vreg_timpani_1;
6629static struct regulator *vreg_timpani_2;
6630
6631static unsigned int msm_timpani_setup_power(void)
6632{
6633 int rc;
6634
6635 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6636 if (IS_ERR(vreg_timpani_1)) {
6637 pr_err("%s: Unable to get 8058_l0\n", __func__);
6638 return -ENODEV;
6639 }
6640
6641 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6642 if (IS_ERR(vreg_timpani_2)) {
6643 pr_err("%s: Unable to get 8058_s3\n", __func__);
6644 regulator_put(vreg_timpani_1);
6645 return -ENODEV;
6646 }
6647
6648 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6649 if (rc) {
6650 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6651 goto fail;
6652 }
6653
6654 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6655 if (rc) {
6656 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6657 goto fail;
6658 }
6659
6660 rc = regulator_enable(vreg_timpani_1);
6661 if (rc) {
6662 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6663 goto fail;
6664 }
6665
6666 /* The settings for LDO0 should be set such that
6667 * it doesn't require to reset the timpani. */
6668 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6669 if (rc < 0) {
6670 pr_err("Timpani regulator optimum mode setting failed\n");
6671 goto fail;
6672 }
6673
6674 rc = regulator_enable(vreg_timpani_2);
6675 if (rc) {
6676 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6677 regulator_disable(vreg_timpani_1);
6678 goto fail;
6679 }
6680
6681 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6682 if (rc) {
6683 pr_err("%s: GPIO Request %d failed\n", __func__,
6684 GPIO_CDC_RST_N);
6685 regulator_disable(vreg_timpani_1);
6686 regulator_disable(vreg_timpani_2);
6687 goto fail;
6688 } else {
6689 gpio_direction_output(GPIO_CDC_RST_N, 1);
6690 usleep_range(1000, 1050);
6691 gpio_direction_output(GPIO_CDC_RST_N, 0);
6692 usleep_range(1000, 1050);
6693 gpio_direction_output(GPIO_CDC_RST_N, 1);
6694 gpio_free(GPIO_CDC_RST_N);
6695 }
6696 return rc;
6697
6698fail:
6699 regulator_put(vreg_timpani_1);
6700 regulator_put(vreg_timpani_2);
6701 return rc;
6702}
6703
6704static void msm_timpani_shutdown_power(void)
6705{
6706 int rc;
6707
6708 rc = regulator_disable(vreg_timpani_1);
6709 if (rc)
6710 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6711
6712 regulator_put(vreg_timpani_1);
6713
6714 rc = regulator_disable(vreg_timpani_2);
6715 if (rc)
6716 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6717
6718 regulator_put(vreg_timpani_2);
6719}
6720
6721/* Power analog function of codec */
6722static struct regulator *vreg_timpani_cdc_apwr;
6723static int msm_timpani_codec_power(int vreg_on)
6724{
6725 int rc = 0;
6726
6727 if (!vreg_timpani_cdc_apwr) {
6728
6729 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6730
6731 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6732 pr_err("%s: vreg_get failed (%ld)\n",
6733 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6734 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6735 return rc;
6736 }
6737 }
6738
6739 if (vreg_on) {
6740
6741 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6742 2200000, 2200000);
6743 if (rc) {
6744 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6745 __func__);
6746 goto vreg_fail;
6747 }
6748
6749 rc = regulator_enable(vreg_timpani_cdc_apwr);
6750 if (rc) {
6751 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6752 goto vreg_fail;
6753 }
6754 } else {
6755 rc = regulator_disable(vreg_timpani_cdc_apwr);
6756 if (rc) {
6757 pr_err("%s: vreg_disable failed %d\n",
6758 __func__, rc);
6759 goto vreg_fail;
6760 }
6761 }
6762
6763 return 0;
6764
6765vreg_fail:
6766 regulator_put(vreg_timpani_cdc_apwr);
6767 vreg_timpani_cdc_apwr = NULL;
6768 return rc;
6769}
6770
6771static struct marimba_codec_platform_data timpani_codec_pdata = {
6772 .marimba_codec_power = msm_timpani_codec_power,
6773};
6774
6775#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6776#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6777
6778static struct marimba_platform_data timpani_pdata = {
6779 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6780 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6781 .marimba_setup = msm_timpani_setup_power,
6782 .marimba_shutdown = msm_timpani_shutdown_power,
6783 .codec = &timpani_codec_pdata,
6784 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6785};
6786
6787#define TIMPANI_I2C_SLAVE_ADDR 0xD
6788
6789static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6790 {
6791 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6792 .platform_data = &timpani_pdata,
6793 },
6794};
6795
Lei Zhou338cab82011-08-19 13:38:17 -04006796#ifdef CONFIG_SND_SOC_WM8903
6797static struct wm8903_platform_data wm8903_pdata = {
6798 .gpio_cfg[2] = 0x3A8,
6799};
6800
6801#define WM8903_I2C_SLAVE_ADDR 0x34
6802static struct i2c_board_info wm8903_codec_i2c_info[] = {
6803 {
6804 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6805 .platform_data = &wm8903_pdata,
6806 },
6807};
6808#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006809#ifdef CONFIG_PMIC8901
6810
6811#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006812/*
6813 * Consumer specific regulator names:
6814 * regulator name consumer dev_name
6815 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006816static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6817 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6818};
6819static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6820 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6821};
6822
6823#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306824 _always_on) \
6825 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006826 .init_data = { \
6827 .constraints = { \
6828 .valid_modes_mask = _modes, \
6829 .valid_ops_mask = _ops, \
6830 .min_uV = _min_uV, \
6831 .max_uV = _max_uV, \
6832 .input_uV = _min_uV, \
6833 .apply_uV = _apply_uV, \
6834 .always_on = _always_on, \
6835 }, \
6836 .consumer_supplies = vreg_consumers_8901_##_id, \
6837 .num_consumer_supplies = \
6838 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6839 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306840 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006841 }
6842
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006843#define PM8901_VREG_INIT_VS(_id) \
6844 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306845 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006846
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306847static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006848 PM8901_VREG_INIT_VS(USB_OTG),
6849 PM8901_VREG_INIT_VS(HDMI_MVS),
6850};
6851
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306852static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6853 .priority = 1,
6854};
6855
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306856static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6857 .irq_base = PM8901_IRQ_BASE,
6858 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6859 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6860};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006861
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306862static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6863 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006864};
6865
6866static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306867 .irq_pdata = &pm8901_irq_pdata,
6868 .mpp_pdata = &pm8901_mpp_pdata,
6869 .regulator_pdatas = pm8901_vreg_init,
6870 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306871 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006872};
6873
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306874static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6875 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6876 .slave = {
6877 .name = "pm8901-core",
6878 .platform_data = &pm8901_platform_data,
6879 },
6880};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006881#endif /* CONFIG_PMIC8901 */
6882
6883#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6884 || defined(CONFIG_GPIO_SX150X_MODULE))
6885
6886static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006887static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006888
6889struct bahama_config_register{
6890 u8 reg;
6891 u8 value;
6892 u8 mask;
6893};
6894
6895enum version{
6896 VER_1_0,
6897 VER_2_0,
6898 VER_UNSUPPORTED = 0xFF
6899};
6900
6901static u8 read_bahama_ver(void)
6902{
6903 int rc;
6904 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6905 u8 bahama_version;
6906
6907 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6908 if (rc < 0) {
6909 printk(KERN_ERR
6910 "%s: version read failed: %d\n",
6911 __func__, rc);
6912 return VER_UNSUPPORTED;
6913 } else {
6914 printk(KERN_INFO
6915 "%s: version read got: 0x%x\n",
6916 __func__, bahama_version);
6917 }
6918
6919 switch (bahama_version) {
6920 case 0x08: /* varient of bahama v1 */
6921 case 0x10:
6922 case 0x00:
6923 return VER_1_0;
6924 case 0x09: /* variant of bahama v2 */
6925 return VER_2_0;
6926 default:
6927 return VER_UNSUPPORTED;
6928 }
6929}
6930
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006931static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006932static unsigned int msm_bahama_setup_power(void)
6933{
6934 int rc = 0;
6935 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006936
6937 if (machine_is_msm8x60_dragon())
6938 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6939
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006940 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6941
6942 if (IS_ERR(vreg_bahama)) {
6943 rc = PTR_ERR(vreg_bahama);
6944 pr_err("%s: regulator_get %s = %d\n", __func__,
6945 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006946 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006947 }
6948
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006949 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6950 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006951 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6952 msm_bahama_regulator, rc);
6953 goto unget;
6954 }
6955
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006956 rc = regulator_enable(vreg_bahama);
6957 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006958 pr_err("%s: regulator_enable %s = %d\n", __func__,
6959 msm_bahama_regulator, rc);
6960 goto unget;
6961 }
6962
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006963 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6964 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006965 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006966 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006967 goto unenable;
6968 }
6969
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006970 gpio_direction_output(msm_bahama_sys_rst, 0);
6971 usleep_range(1000, 1050);
6972 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6973 usleep_range(1000, 1050);
6974 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006975 return rc;
6976
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006977unenable:
6978 regulator_disable(vreg_bahama);
6979unget:
6980 regulator_put(vreg_bahama);
6981 return rc;
6982};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006983
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006985{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006986 if (msm_bahama_setup_power_enable) {
6987 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6988 gpio_free(msm_bahama_sys_rst);
6989 regulator_disable(vreg_bahama);
6990 regulator_put(vreg_bahama);
6991 msm_bahama_setup_power_enable = 0;
6992 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006993
6994 return 0;
6995};
6996
6997static unsigned int msm_bahama_core_config(int type)
6998{
6999 int rc = 0;
7000
7001 if (type == BAHAMA_ID) {
7002
7003 int i;
7004 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7005
7006 const struct bahama_config_register v20_init[] = {
7007 /* reg, value, mask */
7008 { 0xF4, 0x84, 0xFF }, /* AREG */
7009 { 0xF0, 0x04, 0xFF } /* DREG */
7010 };
7011
7012 if (read_bahama_ver() == VER_2_0) {
7013 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7014 u8 value = v20_init[i].value;
7015 rc = marimba_write_bit_mask(&config,
7016 v20_init[i].reg,
7017 &value,
7018 sizeof(v20_init[i].value),
7019 v20_init[i].mask);
7020 if (rc < 0) {
7021 printk(KERN_ERR
7022 "%s: reg %d write failed: %d\n",
7023 __func__, v20_init[i].reg, rc);
7024 return rc;
7025 }
7026 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7027 " mask 0x%02x\n",
7028 __func__, v20_init[i].reg,
7029 v20_init[i].value, v20_init[i].mask);
7030 }
7031 }
7032 }
7033 printk(KERN_INFO "core type: %d\n", type);
7034
7035 return rc;
7036}
7037
7038static struct regulator *fm_regulator_s3;
7039static struct msm_xo_voter *fm_clock;
7040
7041static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7042{
7043 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307044 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007045 .direction = PM_GPIO_DIR_IN,
7046 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307047 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007048 .function = PM_GPIO_FUNC_NORMAL,
7049 .inv_int_pol = 0,
7050 };
7051
7052 if (!fm_regulator_s3) {
7053 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7054 if (IS_ERR(fm_regulator_s3)) {
7055 rc = PTR_ERR(fm_regulator_s3);
7056 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7057 __func__, rc);
7058 goto out;
7059 }
7060 }
7061
7062
7063 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7064 if (rc < 0) {
7065 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7066 __func__, rc);
7067 goto fm_fail_put;
7068 }
7069
7070 rc = regulator_enable(fm_regulator_s3);
7071 if (rc < 0) {
7072 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7073 __func__, rc);
7074 goto fm_fail_put;
7075 }
7076
7077 /*Vote for XO clock*/
7078 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7079
7080 if (IS_ERR(fm_clock)) {
7081 rc = PTR_ERR(fm_clock);
7082 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7083 __func__, rc);
7084 goto fm_fail_switch;
7085 }
7086
7087 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7088 if (rc < 0) {
7089 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7090 __func__, rc);
7091 goto fm_fail_vote;
7092 }
7093
7094 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307095 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007096 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307097 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007098 __func__, rc);
7099 goto fm_fail_clock;
7100 }
7101 goto out;
7102
7103fm_fail_clock:
7104 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7105fm_fail_vote:
7106 msm_xo_put(fm_clock);
7107fm_fail_switch:
7108 regulator_disable(fm_regulator_s3);
7109fm_fail_put:
7110 regulator_put(fm_regulator_s3);
7111out:
7112 return rc;
7113};
7114
7115static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7116{
7117 int rc = 0;
7118 if (fm_regulator_s3 != NULL) {
7119 rc = regulator_disable(fm_regulator_s3);
7120 if (rc < 0) {
7121 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7122 __func__, rc);
7123 }
7124 regulator_put(fm_regulator_s3);
7125 fm_regulator_s3 = NULL;
7126 }
7127 printk(KERN_ERR "%s: Voting off for XO", __func__);
7128
7129 if (fm_clock != NULL) {
7130 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7131 if (rc < 0) {
7132 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7133 __func__, rc);
7134 }
7135 msm_xo_put(fm_clock);
7136 }
7137 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7138}
7139
7140/* Slave id address for FM/CDC/QMEMBIST
7141 * Values can be programmed using Marimba slave id 0
7142 * should there be a conflict with other I2C devices
7143 * */
7144#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7145#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7146
7147static struct marimba_fm_platform_data marimba_fm_pdata = {
7148 .fm_setup = fm_radio_setup,
7149 .fm_shutdown = fm_radio_shutdown,
7150 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7151 .is_fm_soc_i2s_master = false,
7152 .config_i2s_gpio = NULL,
7153};
7154
7155/*
7156Just initializing the BAHAMA related slave
7157*/
7158static struct marimba_platform_data marimba_pdata = {
7159 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7160 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7161 .bahama_setup = msm_bahama_setup_power,
7162 .bahama_shutdown = msm_bahama_shutdown_power,
7163 .bahama_core_config = msm_bahama_core_config,
7164 .fm = &marimba_fm_pdata,
7165 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7166};
7167
7168
7169static struct i2c_board_info msm_marimba_board_info[] = {
7170 {
7171 I2C_BOARD_INFO("marimba", 0xc),
7172 .platform_data = &marimba_pdata,
7173 }
7174};
7175#endif /* CONFIG_MAIMBA_CORE */
7176
7177#ifdef CONFIG_I2C
7178#define I2C_SURF 1
7179#define I2C_FFA (1 << 1)
7180#define I2C_RUMI (1 << 2)
7181#define I2C_SIM (1 << 3)
7182#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007183#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007184
7185struct i2c_registry {
7186 u8 machs;
7187 int bus;
7188 struct i2c_board_info *info;
7189 int len;
7190};
7191
7192static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007193#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7194 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007195 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007196 MSM_GSBI8_QUP_I2C_BUS_ID,
7197 core_expander_i2c_info,
7198 ARRAY_SIZE(core_expander_i2c_info),
7199 },
7200 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007201 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007202 MSM_GSBI8_QUP_I2C_BUS_ID,
7203 docking_expander_i2c_info,
7204 ARRAY_SIZE(docking_expander_i2c_info),
7205 },
7206 {
7207 I2C_SURF,
7208 MSM_GSBI8_QUP_I2C_BUS_ID,
7209 surf_expanders_i2c_info,
7210 ARRAY_SIZE(surf_expanders_i2c_info),
7211 },
7212 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007213 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007214 MSM_GSBI3_QUP_I2C_BUS_ID,
7215 fha_expanders_i2c_info,
7216 ARRAY_SIZE(fha_expanders_i2c_info),
7217 },
7218 {
7219 I2C_FLUID,
7220 MSM_GSBI3_QUP_I2C_BUS_ID,
7221 fluid_expanders_i2c_info,
7222 ARRAY_SIZE(fluid_expanders_i2c_info),
7223 },
7224 {
7225 I2C_FLUID,
7226 MSM_GSBI8_QUP_I2C_BUS_ID,
7227 fluid_core_expander_i2c_info,
7228 ARRAY_SIZE(fluid_core_expander_i2c_info),
7229 },
7230#endif
7231#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7232 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7233 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007234 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007235 MSM_GSBI3_QUP_I2C_BUS_ID,
7236 msm_i2c_gsbi3_tdisc_info,
7237 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7238 },
7239#endif
7240 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007241 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007242 MSM_GSBI3_QUP_I2C_BUS_ID,
7243 cy8ctmg200_board_info,
7244 ARRAY_SIZE(cy8ctmg200_board_info),
7245 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007246 {
7247 I2C_DRAGON,
7248 MSM_GSBI3_QUP_I2C_BUS_ID,
7249 cy8ctma340_dragon_board_info,
7250 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7251 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007252#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7253 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007254 {
7255 I2C_FLUID,
7256 MSM_GSBI3_QUP_I2C_BUS_ID,
7257 cyttsp_fluid_info,
7258 ARRAY_SIZE(cyttsp_fluid_info),
7259 },
7260 {
7261 I2C_FFA | I2C_SURF,
7262 MSM_GSBI3_QUP_I2C_BUS_ID,
7263 cyttsp_ffa_info,
7264 ARRAY_SIZE(cyttsp_ffa_info),
7265 },
7266#endif
7267#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007268#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007269 {
7270 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007271 MSM_GSBI4_QUP_I2C_BUS_ID,
7272 msm_camera_boardinfo,
7273 ARRAY_SIZE(msm_camera_boardinfo),
7274 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007275 {
7276 I2C_DRAGON,
7277 MSM_GSBI4_QUP_I2C_BUS_ID,
7278 msm_camera_dragon_boardinfo,
7279 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7280 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007281#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007282#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007283 {
7284 I2C_SURF | I2C_FFA | I2C_FLUID,
7285 MSM_GSBI7_QUP_I2C_BUS_ID,
7286 msm_i2c_gsbi7_timpani_info,
7287 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7288 },
7289#if defined(CONFIG_MARIMBA_CORE)
7290 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007291 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007292 MSM_GSBI7_QUP_I2C_BUS_ID,
7293 msm_marimba_board_info,
7294 ARRAY_SIZE(msm_marimba_board_info),
7295 },
7296#endif /* CONFIG_MARIMBA_CORE */
7297#ifdef CONFIG_ISL9519_CHARGER
7298 {
7299 I2C_SURF | I2C_FFA,
7300 MSM_GSBI8_QUP_I2C_BUS_ID,
7301 isl_charger_i2c_info,
7302 ARRAY_SIZE(isl_charger_i2c_info),
7303 },
7304#endif
7305#if defined(CONFIG_HAPTIC_ISA1200) || \
7306 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7307 {
7308 I2C_FLUID,
7309 MSM_GSBI8_QUP_I2C_BUS_ID,
7310 msm_isa1200_board_info,
7311 ARRAY_SIZE(msm_isa1200_board_info),
7312 },
7313#endif
7314#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7315 {
7316 I2C_FLUID,
7317 MSM_GSBI8_QUP_I2C_BUS_ID,
7318 smb137b_charger_i2c_info,
7319 ARRAY_SIZE(smb137b_charger_i2c_info),
7320 },
7321#endif
7322#if defined(CONFIG_BATTERY_BQ27520) || \
7323 defined(CONFIG_BATTERY_BQ27520_MODULE)
7324 {
7325 I2C_FLUID,
7326 MSM_GSBI8_QUP_I2C_BUS_ID,
7327 msm_bq27520_board_info,
7328 ARRAY_SIZE(msm_bq27520_board_info),
7329 },
7330#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007331#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7332 {
7333 I2C_DRAGON,
7334 MSM_GSBI8_QUP_I2C_BUS_ID,
7335 wm8903_codec_i2c_info,
7336 ARRAY_SIZE(wm8903_codec_i2c_info),
7337 },
7338#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007339};
7340#endif /* CONFIG_I2C */
7341
Stephen Boyd668d7652012-04-25 11:31:01 -07007342static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007343{
7344#ifdef CONFIG_I2C
7345#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7346 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7347 sx150x_data[SX150X_CORE].irq_summary =
7348 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007349 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7350 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007351 sx150x_data[SX150X_CORE].irq_summary =
7352 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7353 else if (machine_is_msm8x60_fluid())
7354 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7355 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7356#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007357#endif
7358}
7359
Stephen Boyd668d7652012-04-25 11:31:01 -07007360static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007361{
7362#ifdef CONFIG_I2C
7363 u8 mach_mask = 0;
7364 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007365#ifdef CONFIG_MSM_CAMERA_V4L2
7366 struct i2c_registry msm8x60_camera_i2c_devices = {
7367 I2C_SURF | I2C_FFA | I2C_FLUID,
7368 MSM_GSBI4_QUP_I2C_BUS_ID,
7369 msm8x60_camera_board_info.board_info,
7370 msm8x60_camera_board_info.num_i2c_board_info,
7371 };
7372#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007373
7374 /* Build the matching 'supported_machs' bitmask */
7375 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7376 mach_mask = I2C_SURF;
7377 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7378 mach_mask = I2C_FFA;
7379 else if (machine_is_msm8x60_rumi3())
7380 mach_mask = I2C_RUMI;
7381 else if (machine_is_msm8x60_sim())
7382 mach_mask = I2C_SIM;
7383 else if (machine_is_msm8x60_fluid())
7384 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007385 else if (machine_is_msm8x60_dragon())
7386 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007387 else
7388 pr_err("unmatched machine ID in register_i2c_devices\n");
7389
7390 /* Run the array and install devices as appropriate */
7391 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7392 if (msm8x60_i2c_devices[i].machs & mach_mask)
7393 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7394 msm8x60_i2c_devices[i].info,
7395 msm8x60_i2c_devices[i].len);
7396 }
Kevin Chan3be11612012-03-22 20:05:40 -07007397#ifdef CONFIG_MSM_CAMERA_V4L2
7398 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7399 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7400 msm8x60_camera_i2c_devices.info,
7401 msm8x60_camera_i2c_devices.len);
7402#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007403#endif
7404}
7405
7406static void __init msm8x60_init_uart12dm(void)
7407{
7408#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7409 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7410 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7411
7412 if (!fpga_mem)
7413 pr_err("%s(): Error getting memory\n", __func__);
7414
7415 /* Advanced mode */
7416 writew(0xFFFF, fpga_mem + 0x15C);
7417 /* FPGA_UART_SEL */
7418 writew(0, fpga_mem + 0x172);
7419 /* FPGA_GPIO_CONFIG_117 */
7420 writew(1, fpga_mem + 0xEA);
7421 /* FPGA_GPIO_CONFIG_118 */
7422 writew(1, fpga_mem + 0xEC);
7423 mb();
7424 iounmap(fpga_mem);
7425#endif
7426}
7427
7428#define MSM_GSBI9_PHYS 0x19900000
7429#define GSBI_DUAL_MODE_CODE 0x60
7430
7431static void __init msm8x60_init_buses(void)
7432{
7433#ifdef CONFIG_I2C_QUP
7434 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7435 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7436 writel_relaxed(0x6 << 4, gsbi_mem);
7437 /* Ensure protocol code is written before proceeding further */
7438 mb();
7439 iounmap(gsbi_mem);
7440
7441 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7442 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7443 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7444 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7445
7446#ifdef CONFIG_MSM_GSBI9_UART
7447 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7448 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7449 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7450 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7451 iounmap(gsbi_mem);
7452 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7453 }
7454#endif
7455 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7456 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7457#endif
7458#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7459 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7460#endif
7461#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007462 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7463#endif
7464
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307465#ifdef CONFIG_MSM_SSBI
7466 msm_device_ssbi_pmic1.dev.platform_data =
7467 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307468 msm_device_ssbi_pmic2.dev.platform_data =
7469 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307470#endif
7471
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007472 if (machine_is_msm8x60_fluid()) {
7473#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7474 (defined(CONFIG_SMB137B_CHARGER) || \
7475 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7476 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7477#endif
7478#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7479 msm_gsbi10_qup_spi_device.dev.platform_data =
7480 &msm_gsbi10_qup_spi_pdata;
7481#endif
7482 }
7483
Lena Salman57d167e2012-03-21 19:46:38 +02007484#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007485 /*
7486 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7487 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7488 * and ID notifications are available only on V2 surf and FFA
7489 * with a hardware workaround.
7490 */
7491 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7492 (machine_is_msm8x60_surf() ||
7493 (machine_is_msm8x60_ffa() &&
7494 pmic_id_notif_supported)))
7495 msm_otg_pdata.phy_can_powercollapse = 1;
7496 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7497#endif
7498
Lena Salman57d167e2012-03-21 19:46:38 +02007499#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007500 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7501#endif
7502
7503#ifdef CONFIG_SERIAL_MSM_HS
7504 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7505 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7506#endif
7507#ifdef CONFIG_MSM_GSBI9_UART
7508 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7509 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7510 if (IS_ERR(msm_device_uart_gsbi9))
7511 pr_err("%s(): Failed to create uart gsbi9 device\n",
7512 __func__);
7513 }
7514#endif
7515
7516#ifdef CONFIG_MSM_BUS_SCALING
7517
7518 /* RPM calls are only enabled on V2 */
7519 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7520 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7521 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7522 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7523 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7524 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7525 }
7526
7527 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7528 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7529 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7530 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7531 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7532#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007533}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007534
7535static void __init msm8x60_map_io(void)
7536{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007537 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007538 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007539
7540 if (socinfo_init() < 0)
7541 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007542}
7543
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007544/*
7545 * Most segments of the EBI2 bus are disabled by default.
7546 */
7547static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007548{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007549 uint32_t ebi2_cfg;
7550 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007551 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007552
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007553 if (IS_ERR(mem_clk)) {
7554 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7555 "msm_ebi2", "mem_clk");
7556 return;
7557 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007558 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007559 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007560
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007561 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7562 if (ebi2_cfg_ptr != 0) {
7563 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007565 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007566 machine_is_msm8x60_fluid() ||
7567 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007568 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7569 else if (machine_is_msm8x60_sim())
7570 ebi2_cfg |= (1 << 4); /* CS2 */
7571 else if (machine_is_msm8x60_rumi3())
7572 ebi2_cfg |= (1 << 5); /* CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007573
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007574 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7575 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007576 }
7577
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007578 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007579 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007580 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7581 if (ebi2_cfg_ptr != 0) {
7582 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7583 writel_relaxed(0UL, ebi2_cfg_ptr);
7584
7585 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7586 * LAN9221 Ethernet controller reads and writes.
7587 * The lowest 4 bits are the read delay, the next
7588 * 4 are the write delay. */
7589 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7590#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7591 /*
7592 * RECOVERY=5, HOLD_WR=1
7593 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7594 * WAIT_WR=1, WAIT_RD=2
7595 */
7596 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7597 /*
7598 * HOLD_RD=1
7599 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7600 */
7601 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7602#else
7603 /* EBI2 CS3 muxed address/data,
7604 * two cyc addr enable */
7605 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7606
7607#endif
7608 iounmap(ebi2_cfg_ptr);
7609 }
7610 }
David Brown56e2d8a2011-08-04 02:01:02 -07007611}
7612
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007613static void __init msm8x60_configure_smc91x(void)
7614{
7615 if (machine_is_msm8x60_sim()) {
7616
7617 smc91x_resources[0].start = 0x1b800300;
7618 smc91x_resources[0].end = 0x1b8003ff;
7619
7620 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7621 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7622
7623 } else if (machine_is_msm8x60_rumi3()) {
7624
7625 smc91x_resources[0].start = 0x1d000300;
7626 smc91x_resources[0].end = 0x1d0003ff;
7627
7628 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7629 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7630 }
7631}
7632
7633static void __init msm8x60_init_tlmm(void)
7634{
7635 if (machine_is_msm8x60_rumi3())
7636 msm_gpio_install_direct_irq(0, 0, 1);
7637}
7638
7639#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7640 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7641 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7642 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7643 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7644
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007645/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007646#define MAX_SDCC_CONTROLLER 5
7647
7648struct msm_sdcc_gpio {
7649 /* maximum 10 GPIOs per SDCC controller */
7650 s16 no;
7651 /* name of this GPIO */
7652 const char *name;
7653 bool always_on;
7654 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007655};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007656
7657#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7658static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7659 {159, "sdc1_dat_0"},
7660 {160, "sdc1_dat_1"},
7661 {161, "sdc1_dat_2"},
7662 {162, "sdc1_dat_3"},
7663#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7664 {163, "sdc1_dat_4"},
7665 {164, "sdc1_dat_5"},
7666 {165, "sdc1_dat_6"},
7667 {166, "sdc1_dat_7"},
7668#endif
7669 {167, "sdc1_clk"},
7670 {168, "sdc1_cmd"}
7671};
7672#endif
7673
7674#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7675static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7676 {143, "sdc2_dat_0"},
7677 {144, "sdc2_dat_1", 1},
7678 {145, "sdc2_dat_2"},
7679 {146, "sdc2_dat_3"},
7680#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7681 {147, "sdc2_dat_4"},
7682 {148, "sdc2_dat_5"},
7683 {149, "sdc2_dat_6"},
7684 {150, "sdc2_dat_7"},
7685#endif
7686 {151, "sdc2_cmd"},
7687 {152, "sdc2_clk", 1}
7688};
7689#endif
7690
7691#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7692static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7693 {95, "sdc5_cmd"},
7694 {96, "sdc5_dat_3"},
7695 {97, "sdc5_clk", 1},
7696 {98, "sdc5_dat_2"},
7697 {99, "sdc5_dat_1", 1},
7698 {100, "sdc5_dat_0"}
7699};
7700#endif
7701
7702struct msm_sdcc_pad_pull_cfg {
7703 enum msm_tlmm_pull_tgt pull;
7704 u32 pull_val;
7705};
7706
7707struct msm_sdcc_pad_drv_cfg {
7708 enum msm_tlmm_hdrive_tgt drv;
7709 u32 drv_val;
7710};
7711
7712#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7713static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7714 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7715 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7716 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7717};
7718
7719static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7720 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7721 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7722};
7723
7724static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7725 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7726 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7727 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7728};
7729
7730static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7731 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7732 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7733};
7734#endif
7735
7736#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7737static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7738 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7739 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7740 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7741};
7742
7743static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7744 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7745 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7746};
7747
7748static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7749 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7750 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7751 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7752};
7753
7754static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7755 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7756 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7757};
7758#endif
7759
7760struct msm_sdcc_pin_cfg {
7761 /*
7762 * = 1 if controller pins are using gpios
7763 * = 0 if controller has dedicated MSM pins
7764 */
7765 u8 is_gpio;
7766 u8 cfg_sts;
7767 u8 gpio_data_size;
7768 struct msm_sdcc_gpio *gpio_data;
7769 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7770 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7771 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7772 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7773 u8 pad_drv_data_size;
7774 u8 pad_pull_data_size;
7775 u8 sdio_lpm_gpio_cfg;
7776};
7777
7778
7779static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7780#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7781 [0] = {
7782 .is_gpio = 1,
7783 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7784 .gpio_data = sdc1_gpio_cfg
7785 },
7786#endif
7787#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7788 [1] = {
7789 .is_gpio = 1,
7790 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7791 .gpio_data = sdc2_gpio_cfg
7792 },
7793#endif
7794#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7795 [2] = {
7796 .is_gpio = 0,
7797 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7798 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7799 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7800 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7801 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7802 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7803 },
7804#endif
7805#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7806 [3] = {
7807 .is_gpio = 0,
7808 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7809 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7810 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7811 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7812 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7813 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7814 },
7815#endif
7816#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7817 [4] = {
7818 .is_gpio = 1,
7819 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7820 .gpio_data = sdc5_gpio_cfg
7821 }
7822#endif
7823};
7824
7825static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7826{
7827 int rc = 0;
7828 struct msm_sdcc_pin_cfg *curr;
7829 int n;
7830
7831 curr = &sdcc_pin_cfg_data[dev_id - 1];
7832 if (!curr->gpio_data)
7833 goto out;
7834
7835 for (n = 0; n < curr->gpio_data_size; n++) {
7836 if (enable) {
7837
7838 if (curr->gpio_data[n].always_on &&
7839 curr->gpio_data[n].is_enabled)
7840 continue;
7841 pr_debug("%s: enable: %s\n", __func__,
7842 curr->gpio_data[n].name);
7843 rc = gpio_request(curr->gpio_data[n].no,
7844 curr->gpio_data[n].name);
7845 if (rc) {
7846 pr_err("%s: gpio_request(%d, %s)"
7847 "failed", __func__,
7848 curr->gpio_data[n].no,
7849 curr->gpio_data[n].name);
7850 goto free_gpios;
7851 }
7852 /* set direction as output for all GPIOs */
7853 rc = gpio_direction_output(
7854 curr->gpio_data[n].no, 1);
7855 if (rc) {
7856 pr_err("%s: gpio_direction_output"
7857 "(%d, 1) failed\n", __func__,
7858 curr->gpio_data[n].no);
7859 goto free_gpios;
7860 }
7861 curr->gpio_data[n].is_enabled = 1;
7862 } else {
7863 /*
7864 * now free this GPIO which will put GPIO
7865 * in low power mode and will also put GPIO
7866 * in input mode
7867 */
7868 if (curr->gpio_data[n].always_on)
7869 continue;
7870 pr_debug("%s: disable: %s\n", __func__,
7871 curr->gpio_data[n].name);
7872 gpio_free(curr->gpio_data[n].no);
7873 curr->gpio_data[n].is_enabled = 0;
7874 }
7875 }
7876 curr->cfg_sts = enable;
7877 goto out;
7878
7879free_gpios:
7880 for (; n >= 0; n--)
7881 gpio_free(curr->gpio_data[n].no);
7882out:
7883 return rc;
7884}
7885
7886static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7887{
7888 int rc = 0;
7889 struct msm_sdcc_pin_cfg *curr;
7890 int n;
7891
7892 curr = &sdcc_pin_cfg_data[dev_id - 1];
7893 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7894 goto out;
7895
7896 if (enable) {
7897 /*
7898 * set up the normal driver strength and
7899 * pull config for pads
7900 */
7901 for (n = 0; n < curr->pad_drv_data_size; n++) {
7902 if (curr->sdio_lpm_gpio_cfg) {
7903 if (curr->pad_drv_on_data[n].drv ==
7904 TLMM_HDRV_SDC4_DATA)
7905 continue;
7906 }
7907 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7908 curr->pad_drv_on_data[n].drv_val);
7909 }
7910 for (n = 0; n < curr->pad_pull_data_size; n++) {
7911 if (curr->sdio_lpm_gpio_cfg) {
7912 if (curr->pad_pull_on_data[n].pull ==
7913 TLMM_PULL_SDC4_DATA)
7914 continue;
7915 }
7916 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7917 curr->pad_pull_on_data[n].pull_val);
7918 }
7919 } else {
7920 /* set the low power config for pads */
7921 for (n = 0; n < curr->pad_drv_data_size; n++) {
7922 if (curr->sdio_lpm_gpio_cfg) {
7923 if (curr->pad_drv_off_data[n].drv ==
7924 TLMM_HDRV_SDC4_DATA)
7925 continue;
7926 }
7927 msm_tlmm_set_hdrive(
7928 curr->pad_drv_off_data[n].drv,
7929 curr->pad_drv_off_data[n].drv_val);
7930 }
7931 for (n = 0; n < curr->pad_pull_data_size; n++) {
7932 if (curr->sdio_lpm_gpio_cfg) {
7933 if (curr->pad_pull_off_data[n].pull ==
7934 TLMM_PULL_SDC4_DATA)
7935 continue;
7936 }
7937 msm_tlmm_set_pull(
7938 curr->pad_pull_off_data[n].pull,
7939 curr->pad_pull_off_data[n].pull_val);
7940 }
7941 }
7942 curr->cfg_sts = enable;
7943out:
7944 return rc;
7945}
7946
7947struct sdcc_reg {
7948 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7949 const char *reg_name;
7950 /*
7951 * is set voltage supported for this regulator?
7952 * 0 = not supported, 1 = supported
7953 */
7954 unsigned char set_voltage_sup;
7955 /* voltage level to be set */
7956 unsigned int level;
7957 /* VDD/VCC/VCCQ voltage regulator handle */
7958 struct regulator *reg;
7959 /* is this regulator enabled? */
7960 bool enabled;
7961 /* is this regulator needs to be always on? */
7962 bool always_on;
7963 /* is operating power mode setting required for this regulator? */
7964 bool op_pwr_mode_sup;
7965 /* Load values for low power and high power mode */
7966 unsigned int lpm_uA;
7967 unsigned int hpm_uA;
7968};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007969/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007970static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7971/* only SDCC1 requires VCCQ voltage */
7972static struct sdcc_reg sdcc_vccq_reg_data[1];
7973/* all SDCC controllers may require voting for VDD PAD voltage */
7974static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7975
7976struct sdcc_reg_data {
7977 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7978 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7979 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7980 unsigned char sts; /* regulator enable/disable status */
7981};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007982/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007983static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7984
7985static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7986{
7987 int rc = 0;
7988
7989 /* Get the regulator handle */
7990 vreg->reg = regulator_get(NULL, vreg->reg_name);
7991 if (IS_ERR(vreg->reg)) {
7992 rc = PTR_ERR(vreg->reg);
7993 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7994 __func__, vreg->reg_name, rc);
7995 goto out;
7996 }
7997
7998 /* Set the voltage level if required */
7999 if (vreg->set_voltage_sup) {
8000 rc = regulator_set_voltage(vreg->reg, vreg->level,
8001 vreg->level);
8002 if (rc) {
8003 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
8004 __func__, vreg->reg_name, rc);
8005 goto vreg_put;
8006 }
8007 }
8008 goto out;
8009
8010vreg_put:
8011 regulator_put(vreg->reg);
8012out:
8013 return rc;
8014}
8015
8016static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
8017{
8018 regulator_put(vreg->reg);
8019}
8020
8021/* this init function should be called only once for each SDCC */
8022static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
8023{
8024 int rc = 0;
8025 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8026 struct sdcc_reg_data *curr;
8027
8028 curr = &sdcc_vreg_data[dev_id - 1];
8029 curr_vdd_reg = curr->vdd_data;
8030 curr_vccq_reg = curr->vccq_data;
8031 curr_vddp_reg = curr->vddp_data;
8032
8033 if (init) {
8034 /*
8035 * get the regulator handle from voltage regulator framework
8036 * and then try to set the voltage level for the regulator
8037 */
8038 if (curr_vdd_reg) {
8039 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8040 if (rc)
8041 goto out;
8042 }
8043 if (curr_vccq_reg) {
8044 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8045 if (rc)
8046 goto vdd_reg_deinit;
8047 }
8048 if (curr_vddp_reg) {
8049 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8050 if (rc)
8051 goto vccq_reg_deinit;
8052 }
8053 goto out;
8054 } else
8055 /* deregister with all regulators from regulator framework */
8056 goto vddp_reg_deinit;
8057
8058vddp_reg_deinit:
8059 if (curr_vddp_reg)
8060 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8061vccq_reg_deinit:
8062 if (curr_vccq_reg)
8063 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8064vdd_reg_deinit:
8065 if (curr_vdd_reg)
8066 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8067out:
8068 return rc;
8069}
8070
8071static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8072{
8073 int rc;
8074
8075 if (!vreg->enabled) {
8076 rc = regulator_enable(vreg->reg);
8077 if (rc) {
8078 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8079 __func__, vreg->reg_name, rc);
8080 goto out;
8081 }
8082 vreg->enabled = 1;
8083 }
8084
8085 /* Put always_on regulator in HPM (high power mode) */
8086 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8087 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8088 if (rc < 0) {
8089 pr_err("%s: reg=%s: HPM setting failed"
8090 " hpm_uA=%d, rc=%d\n",
8091 __func__, vreg->reg_name,
8092 vreg->hpm_uA, rc);
8093 goto vreg_disable;
8094 }
8095 rc = 0;
8096 }
8097 goto out;
8098
8099vreg_disable:
8100 regulator_disable(vreg->reg);
8101 vreg->enabled = 0;
8102out:
8103 return rc;
8104}
8105
8106static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8107{
8108 int rc;
8109
8110 /* Never disable always_on regulator */
8111 if (!vreg->always_on) {
8112 rc = regulator_disable(vreg->reg);
8113 if (rc) {
8114 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8115 __func__, vreg->reg_name, rc);
8116 goto out;
8117 }
8118 vreg->enabled = 0;
8119 }
8120
8121 /* Put always_on regulator in LPM (low power mode) */
8122 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8123 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8124 if (rc < 0) {
8125 pr_err("%s: reg=%s: LPM setting failed"
8126 " lpm_uA=%d, rc=%d\n",
8127 __func__,
8128 vreg->reg_name,
8129 vreg->lpm_uA, rc);
8130 goto out;
8131 }
8132 rc = 0;
8133 }
8134
8135out:
8136 return rc;
8137}
8138
8139static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8140{
8141 int rc = 0;
8142 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8143 struct sdcc_reg_data *curr;
8144
8145 curr = &sdcc_vreg_data[dev_id - 1];
8146 curr_vdd_reg = curr->vdd_data;
8147 curr_vccq_reg = curr->vccq_data;
8148 curr_vddp_reg = curr->vddp_data;
8149
8150 /* check if regulators are initialized or not? */
8151 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8152 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8153 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8154 /* initialize voltage regulators required for this SDCC */
8155 rc = msm_sdcc_vreg_init(dev_id, 1);
8156 if (rc) {
8157 pr_err("%s: regulator init failed = %d\n",
8158 __func__, rc);
8159 goto out;
8160 }
8161 }
8162
8163 if (curr->sts == enable)
8164 goto out;
8165
8166 if (curr_vdd_reg) {
8167 if (enable)
8168 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8169 else
8170 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8171 if (rc)
8172 goto out;
8173 }
8174
8175 if (curr_vccq_reg) {
8176 if (enable)
8177 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8178 else
8179 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8180 if (rc)
8181 goto out;
8182 }
8183
8184 if (curr_vddp_reg) {
8185 if (enable)
8186 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8187 else
8188 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8189 if (rc)
8190 goto out;
8191 }
8192 curr->sts = enable;
8193
8194out:
8195 return rc;
8196}
8197
8198static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8199{
8200 u32 rc_pin_cfg = 0;
8201 u32 rc_vreg_cfg = 0;
8202 u32 rc = 0;
8203 struct platform_device *pdev;
8204 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8205
8206 pdev = container_of(dv, struct platform_device, dev);
8207
8208 /* setup gpio/pad */
8209 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8210 if (curr_pin_cfg->cfg_sts == !!vdd)
8211 goto setup_vreg;
8212
8213 if (curr_pin_cfg->is_gpio)
8214 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8215 else
8216 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8217
8218setup_vreg:
8219 /* setup voltage regulators */
8220 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8221
8222 if (rc_pin_cfg || rc_vreg_cfg)
8223 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8224
8225 return rc;
8226}
8227
8228static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8229{
8230 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8231 struct platform_device *pdev;
8232
8233 pdev = container_of(dv, struct platform_device, dev);
8234 /* setup gpio/pad */
8235 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8236
8237 if (curr_pin_cfg->cfg_sts == active)
8238 return;
8239
8240 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8241 if (curr_pin_cfg->is_gpio)
8242 msm_sdcc_setup_gpio(pdev->id, active);
8243 else
8244 msm_sdcc_setup_pad(pdev->id, active);
8245 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8246}
8247
8248static int msm_sdc3_get_wpswitch(struct device *dev)
8249{
8250 struct platform_device *pdev;
8251 int status;
8252 pdev = container_of(dev, struct platform_device, dev);
8253
8254 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8255 if (status) {
8256 pr_err("%s:Failed to request GPIO %d\n",
8257 __func__, GPIO_SDC_WP);
8258 } else {
8259 status = gpio_direction_input(GPIO_SDC_WP);
8260 if (!status) {
8261 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8262 pr_info("%s: WP Status for Slot %d = %d\n",
8263 __func__, pdev->id, status);
8264 }
8265 gpio_free(GPIO_SDC_WP);
8266 }
8267 return status;
8268}
8269
8270#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8271int sdc5_register_status_notify(void (*callback)(int, void *),
8272 void *dev_id)
8273{
8274 sdc5_status_notify_cb = callback;
8275 sdc5_status_notify_cb_devid = dev_id;
8276 return 0;
8277}
8278#endif
8279
8280#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8281int sdc2_register_status_notify(void (*callback)(int, void *),
8282 void *dev_id)
8283{
8284 sdc2_status_notify_cb = callback;
8285 sdc2_status_notify_cb_devid = dev_id;
8286 return 0;
8287}
8288#endif
8289
8290/* Interrupt handler for SDC2 and SDC5 detection
8291 * This function uses dual-edge interrputs settings in order
8292 * to get SDIO detection when the GPIO is rising and SDIO removal
8293 * when the GPIO is falling */
8294static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8295{
8296 int status;
8297
8298 if (!machine_is_msm8x60_fusion() &&
8299 !machine_is_msm8x60_fusn_ffa())
8300 return IRQ_NONE;
8301
8302 status = gpio_get_value(MDM2AP_SYNC);
8303 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8304 __func__, status);
8305
8306#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8307 if (sdc2_status_notify_cb) {
8308 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8309 sdc2_status_notify_cb(status,
8310 sdc2_status_notify_cb_devid);
8311 }
8312#endif
8313
8314#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8315 if (sdc5_status_notify_cb) {
8316 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8317 sdc5_status_notify_cb(status,
8318 sdc5_status_notify_cb_devid);
8319 }
8320#endif
8321 return IRQ_HANDLED;
8322}
8323
8324static int msm8x60_multi_sdio_init(void)
8325{
8326 int ret, irq_num;
8327
8328 if (!machine_is_msm8x60_fusion() &&
8329 !machine_is_msm8x60_fusn_ffa())
8330 return 0;
8331
8332 ret = msm_gpiomux_get(MDM2AP_SYNC);
8333 if (ret) {
8334 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8335 __func__, MDM2AP_SYNC, ret);
8336 return ret;
8337 }
8338
8339 irq_num = gpio_to_irq(MDM2AP_SYNC);
8340
8341 ret = request_irq(irq_num,
8342 msm8x60_multi_sdio_slot_status_irq,
8343 IRQ_TYPE_EDGE_BOTH,
8344 "sdio_multidetection", NULL);
8345
8346 if (ret) {
8347 pr_err("%s:Failed to request irq, ret=%d\n",
8348 __func__, ret);
8349 return ret;
8350 }
8351
8352 return ret;
8353}
8354
8355#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8356#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8357static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8358{
8359 int status;
8360
8361 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8362 , "SD_HW_Detect");
8363 if (status) {
8364 pr_err("%s:Failed to request GPIO %d\n", __func__,
8365 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8366 } else {
8367 status = gpio_direction_input(
8368 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8369 if (!status)
8370 status = !(gpio_get_value_cansleep(
8371 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8372 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8373 }
8374 return (unsigned int) status;
8375}
8376#endif
8377#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308378#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008379
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308380#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308381#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008382
8383#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8384static struct mmc_platform_data msm8x60_sdc1_data = {
8385 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8386 .translate_vdd = msm_sdcc_setup_power,
8387#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8388 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8389#else
8390 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8391#endif
8392 .msmsdcc_fmin = 400000,
8393 .msmsdcc_fmid = 24000000,
8394 .msmsdcc_fmax = 48000000,
8395 .nonremovable = 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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008410 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008411#ifdef CONFIG_MSM_SDIO_AL
8412 .is_sdio_al_client = 1,
8413#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308414 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008415};
8416#endif
8417
8418#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8419static struct mmc_platform_data msm8x60_sdc3_data = {
8420 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8421 .translate_vdd = msm_sdcc_setup_power,
8422 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8423 .wpswitch = msm_sdc3_get_wpswitch,
8424#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8425 .status = msm8x60_sdcc_slot_status,
8426 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8427 PMIC_GPIO_SDC3_DET - 1),
8428 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8429#endif
8430 .msmsdcc_fmin = 400000,
8431 .msmsdcc_fmid = 24000000,
8432 .msmsdcc_fmax = 48000000,
8433 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308434 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308435 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008436};
8437#endif
8438
8439#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8440static struct mmc_platform_data msm8x60_sdc4_data = {
8441 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8442 .translate_vdd = msm_sdcc_setup_power,
8443 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8444 .msmsdcc_fmin = 400000,
8445 .msmsdcc_fmid = 24000000,
8446 .msmsdcc_fmax = 48000000,
8447 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308448 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308449 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008450};
8451#endif
8452
8453#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8454static struct mmc_platform_data msm8x60_sdc5_data = {
8455 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8456 .translate_vdd = msm_sdcc_setup_power,
8457 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8458 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8459 .msmsdcc_fmin = 400000,
8460 .msmsdcc_fmid = 24000000,
8461 .msmsdcc_fmax = 48000000,
8462 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008463 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008464#ifdef CONFIG_MSM_SDIO_AL
8465 .is_sdio_al_client = 1,
8466#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308467 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008468};
8469#endif
8470
8471static void __init msm8x60_init_mmc(void)
8472{
8473#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8474 /* SDCC1 : eMMC card connected */
8475 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8476 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8477 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8478 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308479 sdcc_vreg_data[0].vdd_data->always_on = 1;
8480 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8481 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8482 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008483
8484 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8485 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8486 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8487 sdcc_vreg_data[0].vccq_data->always_on = 1;
8488
8489 msm_add_sdcc(1, &msm8x60_sdc1_data);
8490#endif
8491#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8492 /*
8493 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8494 * and no card is connected on 8660 SURF/FFA/FLUID.
8495 */
8496 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8497 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8498 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8499 sdcc_vreg_data[1].vdd_data->level = 1800000;
8500
8501 sdcc_vreg_data[1].vccq_data = NULL;
8502
8503 if (machine_is_msm8x60_fusion())
8504 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8505 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008506 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8507 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008508 msm_add_sdcc(2, &msm8x60_sdc2_data);
8509 }
8510#endif
8511#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8512 /* SDCC3 : External card slot connected */
8513 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8514 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8515 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8516 sdcc_vreg_data[2].vdd_data->level = 2850000;
8517 sdcc_vreg_data[2].vdd_data->always_on = 1;
8518 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8519 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8520 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8521
8522 sdcc_vreg_data[2].vccq_data = NULL;
8523
8524 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8525 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8526 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8527 sdcc_vreg_data[2].vddp_data->level = 2850000;
8528 sdcc_vreg_data[2].vddp_data->always_on = 1;
8529 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8530 /* Sleep current required is ~300 uA. But min. RPM
8531 * vote can be in terms of mA (min. 1 mA).
8532 * So let's vote for 2 mA during sleep.
8533 */
8534 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8535 /* Max. Active current required is 16 mA */
8536 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8537
8538 if (machine_is_msm8x60_fluid())
8539 msm8x60_sdc3_data.wpswitch = NULL;
8540 msm_add_sdcc(3, &msm8x60_sdc3_data);
8541#endif
8542#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8543 /* SDCC4 : WLAN WCN1314 chip is connected */
8544 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8545 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8546 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8547 sdcc_vreg_data[3].vdd_data->level = 1800000;
8548
8549 sdcc_vreg_data[3].vccq_data = NULL;
8550
8551 msm_add_sdcc(4, &msm8x60_sdc4_data);
8552#endif
8553#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8554 /*
8555 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8556 * and no card is connected on 8660 SURF/FFA/FLUID.
8557 */
8558 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8559 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8560 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8561 sdcc_vreg_data[4].vdd_data->level = 1800000;
8562
8563 sdcc_vreg_data[4].vccq_data = NULL;
8564
8565 if (machine_is_msm8x60_fusion())
8566 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8567 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008568 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8569 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008570 msm_add_sdcc(5, &msm8x60_sdc5_data);
8571 }
8572#endif
8573}
8574
8575#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8576static inline void display_common_power(int on) {}
8577#else
8578
8579#define _GET_REGULATOR(var, name) do { \
8580 if (var == NULL) { \
8581 var = regulator_get(NULL, name); \
8582 if (IS_ERR(var)) { \
8583 pr_err("'%s' regulator not found, rc=%ld\n", \
8584 name, PTR_ERR(var)); \
8585 var = NULL; \
8586 } \
8587 } \
8588} while (0)
8589
8590static int dsub_regulator(int on)
8591{
8592 static struct regulator *dsub_reg;
8593 static struct regulator *mpp0_reg;
8594 static int dsub_reg_enabled;
8595 int rc = 0;
8596
8597 _GET_REGULATOR(dsub_reg, "8901_l3");
8598 if (IS_ERR(dsub_reg)) {
8599 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8600 __func__, PTR_ERR(dsub_reg));
8601 return PTR_ERR(dsub_reg);
8602 }
8603
8604 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8605 if (IS_ERR(mpp0_reg)) {
8606 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8607 __func__, PTR_ERR(mpp0_reg));
8608 return PTR_ERR(mpp0_reg);
8609 }
8610
8611 if (on && !dsub_reg_enabled) {
8612 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8613 if (rc) {
8614 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8615 " err=%d", __func__, rc);
8616 goto dsub_regulator_err;
8617 }
8618 rc = regulator_enable(dsub_reg);
8619 if (rc) {
8620 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8621 " err=%d", __func__, rc);
8622 goto dsub_regulator_err;
8623 }
8624 rc = regulator_enable(mpp0_reg);
8625 if (rc) {
8626 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8627 " err=%d", __func__, rc);
8628 goto dsub_regulator_err;
8629 }
8630 dsub_reg_enabled = 1;
8631 } else if (!on && dsub_reg_enabled) {
8632 rc = regulator_disable(dsub_reg);
8633 if (rc)
8634 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8635 " err=%d", __func__, rc);
8636 rc = regulator_disable(mpp0_reg);
8637 if (rc)
8638 printk(KERN_WARNING "%s: failed to disable reg "
8639 "8901_mpp0 err=%d", __func__, rc);
8640 dsub_reg_enabled = 0;
8641 }
8642
8643 return rc;
8644
8645dsub_regulator_err:
8646 regulator_put(mpp0_reg);
8647 regulator_put(dsub_reg);
8648 return rc;
8649}
8650
8651static int display_power_on;
8652static void setup_display_power(void)
8653{
8654 if (display_power_on)
8655 if (lcdc_vga_enabled) {
8656 dsub_regulator(1);
8657 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8658 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8659 if (machine_is_msm8x60_ffa() ||
8660 machine_is_msm8x60_fusn_ffa())
8661 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8662 } else {
8663 dsub_regulator(0);
8664 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8665 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8666 if (machine_is_msm8x60_ffa() ||
8667 machine_is_msm8x60_fusn_ffa())
8668 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8669 }
8670 else {
8671 dsub_regulator(0);
8672 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8673 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8674 /* BACKLIGHT */
8675 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8676 /* LVDS */
8677 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8678 }
8679}
8680
8681#define _GET_REGULATOR(var, name) do { \
8682 if (var == NULL) { \
8683 var = regulator_get(NULL, name); \
8684 if (IS_ERR(var)) { \
8685 pr_err("'%s' regulator not found, rc=%ld\n", \
8686 name, PTR_ERR(var)); \
8687 var = NULL; \
8688 } \
8689 } \
8690} while (0)
8691
8692#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8693
8694static void display_common_power(int on)
8695{
8696 int rc;
8697 static struct regulator *display_reg;
8698
8699 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8700 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8701 if (on) {
8702 /* LVDS */
8703 _GET_REGULATOR(display_reg, "8901_l2");
8704 if (!display_reg)
8705 return;
8706 rc = regulator_set_voltage(display_reg,
8707 3300000, 3300000);
8708 if (rc)
8709 goto out;
8710 rc = regulator_enable(display_reg);
8711 if (rc)
8712 goto out;
8713 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8714 "LVDS_STDN_OUT_N");
8715 if (rc) {
8716 printk(KERN_ERR "%s: LVDS gpio %d request"
8717 "failed\n", __func__,
8718 GPIO_LVDS_SHUTDOWN_N);
8719 goto out2;
8720 }
8721
8722 /* BACKLIGHT */
8723 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8724 if (rc) {
8725 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8726 "failed\n", __func__,
8727 GPIO_BACKLIGHT_EN);
8728 goto out3;
8729 }
8730
8731 if (machine_is_msm8x60_ffa() ||
8732 machine_is_msm8x60_fusn_ffa()) {
8733 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8734 "DONGLE_PWR_EN");
8735 if (rc) {
8736 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8737 " %d request failed\n", __func__,
8738 GPIO_DONGLE_PWR_EN);
8739 goto out4;
8740 }
8741 }
8742
8743 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8744 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8745 if (machine_is_msm8x60_ffa() ||
8746 machine_is_msm8x60_fusn_ffa())
8747 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8748 mdelay(20);
8749 display_power_on = 1;
8750 setup_display_power();
8751 } else {
8752 if (display_power_on) {
8753 display_power_on = 0;
8754 setup_display_power();
8755 mdelay(20);
8756 if (machine_is_msm8x60_ffa() ||
8757 machine_is_msm8x60_fusn_ffa())
8758 gpio_free(GPIO_DONGLE_PWR_EN);
8759 goto out4;
8760 }
8761 }
8762 }
8763#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8764 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8765 else if (machine_is_msm8x60_fluid()) {
8766 static struct regulator *fluid_reg;
8767 static struct regulator *fluid_reg2;
8768
8769 if (on) {
8770 _GET_REGULATOR(fluid_reg, "8901_l2");
8771 if (!fluid_reg)
8772 return;
8773 _GET_REGULATOR(fluid_reg2, "8058_s3");
8774 if (!fluid_reg2) {
8775 regulator_put(fluid_reg);
8776 return;
8777 }
8778 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8779 if (rc) {
8780 regulator_put(fluid_reg2);
8781 regulator_put(fluid_reg);
8782 return;
8783 }
8784 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8785 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8786 regulator_enable(fluid_reg);
8787 regulator_enable(fluid_reg2);
8788 msleep(20);
8789 gpio_direction_output(GPIO_RESX_N, 0);
8790 udelay(10);
8791 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8792 display_power_on = 1;
8793 setup_display_power();
8794 } else {
8795 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8796 gpio_free(GPIO_RESX_N);
8797 msleep(20);
8798 regulator_disable(fluid_reg2);
8799 regulator_disable(fluid_reg);
8800 regulator_put(fluid_reg2);
8801 regulator_put(fluid_reg);
8802 display_power_on = 0;
8803 setup_display_power();
8804 fluid_reg = NULL;
8805 fluid_reg2 = NULL;
8806 }
8807 }
8808#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008809#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8810 else if (machine_is_msm8x60_dragon()) {
8811 static struct regulator *dragon_reg;
8812 static struct regulator *dragon_reg2;
8813
8814 if (on) {
8815 _GET_REGULATOR(dragon_reg, "8901_l2");
8816 if (!dragon_reg)
8817 return;
8818 _GET_REGULATOR(dragon_reg2, "8058_l16");
8819 if (!dragon_reg2) {
8820 regulator_put(dragon_reg);
8821 dragon_reg = NULL;
8822 return;
8823 }
8824
8825 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8826 if (rc) {
8827 pr_err("%s: gpio %d request failed with rc=%d\n",
8828 __func__, GPIO_NT35582_BL_EN, rc);
8829 regulator_put(dragon_reg);
8830 regulator_put(dragon_reg2);
8831 dragon_reg = NULL;
8832 dragon_reg2 = NULL;
8833 return;
8834 }
8835
8836 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8837 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8838 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8839 pr_err("%s: config gpio '%d' failed!\n",
8840 __func__, GPIO_NT35582_RESET);
8841 gpio_free(GPIO_NT35582_BL_EN);
8842 regulator_put(dragon_reg);
8843 regulator_put(dragon_reg2);
8844 dragon_reg = NULL;
8845 dragon_reg2 = NULL;
8846 return;
8847 }
8848
8849 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8850 if (rc) {
8851 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8852 __func__, GPIO_NT35582_RESET, rc);
8853 gpio_free(GPIO_NT35582_BL_EN);
8854 regulator_put(dragon_reg);
8855 regulator_put(dragon_reg2);
8856 dragon_reg = NULL;
8857 dragon_reg2 = NULL;
8858 return;
8859 }
8860
8861 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8862 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8863 regulator_enable(dragon_reg);
8864 regulator_enable(dragon_reg2);
8865 msleep(20);
8866
8867 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8868 msleep(20);
8869 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8870 msleep(20);
8871 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8872 msleep(50);
8873
8874 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8875
8876 display_power_on = 1;
8877 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8878 gpio_free(GPIO_NT35582_RESET);
8879 gpio_free(GPIO_NT35582_BL_EN);
8880 regulator_disable(dragon_reg2);
8881 regulator_disable(dragon_reg);
8882 regulator_put(dragon_reg2);
8883 regulator_put(dragon_reg);
8884 display_power_on = 0;
8885 dragon_reg = NULL;
8886 dragon_reg2 = NULL;
8887 }
8888 }
8889#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008890 return;
8891
8892out4:
8893 gpio_free(GPIO_BACKLIGHT_EN);
8894out3:
8895 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8896out2:
8897 regulator_disable(display_reg);
8898out:
8899 regulator_put(display_reg);
8900 display_reg = NULL;
8901}
8902#undef _GET_REGULATOR
8903#endif
8904
8905static int mipi_dsi_panel_power(int on);
8906
8907#define LCDC_NUM_GPIO 28
8908#define LCDC_GPIO_START 0
8909
8910static void lcdc_samsung_panel_power(int on)
8911{
8912 int n, ret = 0;
8913
8914 display_common_power(on);
8915
8916 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8917 if (on) {
8918 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8919 if (unlikely(ret)) {
8920 pr_err("%s not able to get gpio\n", __func__);
8921 break;
8922 }
8923 } else
8924 gpio_free(LCDC_GPIO_START + n);
8925 }
8926
8927 if (ret) {
8928 for (n--; n >= 0; n--)
8929 gpio_free(LCDC_GPIO_START + n);
8930 }
8931
8932 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8933}
8934
8935#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8936#define _GET_REGULATOR(var, name) do { \
8937 var = regulator_get(NULL, name); \
8938 if (IS_ERR(var)) { \
8939 pr_err("'%s' regulator not found, rc=%ld\n", \
8940 name, IS_ERR(var)); \
8941 var = NULL; \
8942 return -ENODEV; \
8943 } \
8944} while (0)
8945
8946static int hdmi_enable_5v(int on)
8947{
8948 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8949 static struct regulator *reg_8901_mpp0; /* External 5V */
8950 static int prev_on;
8951 int rc;
8952
8953 if (on == prev_on)
8954 return 0;
8955
8956 if (!reg_8901_hdmi_mvs)
8957 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8958 if (!reg_8901_mpp0)
8959 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8960
8961 if (on) {
8962 rc = regulator_enable(reg_8901_mpp0);
8963 if (rc) {
8964 pr_err("'%s' regulator enable failed, rc=%d\n",
8965 "reg_8901_mpp0", rc);
8966 return rc;
8967 }
8968 rc = regulator_enable(reg_8901_hdmi_mvs);
8969 if (rc) {
8970 pr_err("'%s' regulator enable failed, rc=%d\n",
8971 "8901_hdmi_mvs", rc);
8972 return rc;
8973 }
8974 pr_info("%s(on): success\n", __func__);
8975 } else {
8976 rc = regulator_disable(reg_8901_hdmi_mvs);
8977 if (rc)
8978 pr_warning("'%s' regulator disable failed, rc=%d\n",
8979 "8901_hdmi_mvs", rc);
8980 rc = regulator_disable(reg_8901_mpp0);
8981 if (rc)
8982 pr_warning("'%s' regulator disable failed, rc=%d\n",
8983 "reg_8901_mpp0", rc);
8984 pr_info("%s(off): success\n", __func__);
8985 }
8986
8987 prev_on = on;
8988
8989 return 0;
8990}
8991
8992static int hdmi_core_power(int on, int show)
8993{
8994 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8995 static int prev_on;
8996 int rc;
8997
8998 if (on == prev_on)
8999 return 0;
9000
9001 if (!reg_8058_l16)
9002 _GET_REGULATOR(reg_8058_l16, "8058_l16");
9003
9004 if (on) {
9005 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
9006 if (!rc)
9007 rc = regulator_enable(reg_8058_l16);
9008 if (rc) {
9009 pr_err("'%s' regulator enable failed, rc=%d\n",
9010 "8058_l16", rc);
9011 return rc;
9012 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309013 pr_debug("%s(on): success\n", __func__);
9014 } else {
9015 rc = regulator_disable(reg_8058_l16);
9016 if (rc)
9017 pr_warning("'%s' regulator disable failed, rc=%d\n",
9018 "8058_l16", rc);
9019 pr_debug("%s(off): success\n", __func__);
9020 }
9021
9022 prev_on = on;
9023
9024 return 0;
9025}
9026
9027static int hdmi_gpio_config(int on)
9028{
9029 int rc = 0;
9030 static int prev_on;
9031
9032 if (on == prev_on)
9033 return 0;
9034
9035 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009036 rc = gpio_request(170, "HDMI_DDC_CLK");
9037 if (rc) {
9038 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9039 "HDMI_DDC_CLK", 170, rc);
9040 goto error1;
9041 }
9042 rc = gpio_request(171, "HDMI_DDC_DATA");
9043 if (rc) {
9044 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9045 "HDMI_DDC_DATA", 171, rc);
9046 goto error2;
9047 }
9048 rc = gpio_request(172, "HDMI_HPD");
9049 if (rc) {
9050 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9051 "HDMI_HPD", 172, rc);
9052 goto error3;
9053 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309054 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009055 } else {
9056 gpio_free(170);
9057 gpio_free(171);
9058 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309059 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009060 }
9061
9062 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009063 return 0;
9064
9065error3:
9066 gpio_free(171);
9067error2:
9068 gpio_free(170);
9069error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009070 return rc;
9071}
9072
9073static int hdmi_cec_power(int on)
9074{
9075 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9076 static int prev_on;
9077 int rc;
9078
9079 if (on == prev_on)
9080 return 0;
9081
9082 if (!reg_8901_l3)
9083 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9084
9085 if (on) {
9086 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9087 if (!rc)
9088 rc = regulator_enable(reg_8901_l3);
9089 if (rc) {
9090 pr_err("'%s' regulator enable failed, rc=%d\n",
9091 "8901_l3", rc);
9092 return rc;
9093 }
9094 rc = gpio_request(169, "HDMI_CEC_VAR");
9095 if (rc) {
9096 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9097 "HDMI_CEC_VAR", 169, rc);
9098 goto error;
9099 }
9100 pr_info("%s(on): success\n", __func__);
9101 } else {
9102 gpio_free(169);
9103 rc = regulator_disable(reg_8901_l3);
9104 if (rc)
9105 pr_warning("'%s' regulator disable failed, rc=%d\n",
9106 "8901_l3", rc);
9107 pr_info("%s(off): success\n", __func__);
9108 }
9109
9110 prev_on = on;
9111
9112 return 0;
9113error:
9114 regulator_disable(reg_8901_l3);
9115 return rc;
9116}
9117
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309118static int hdmi_panel_power(int on)
9119{
9120 int rc;
9121
9122 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9123 rc = hdmi_core_power(on, 1);
9124 if (rc)
9125 rc = hdmi_cec_power(on);
9126
9127 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9128 return rc;
9129}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009130#undef _GET_REGULATOR
9131
9132#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9133
9134static int lcdc_panel_power(int on)
9135{
9136 int flag_on = !!on;
9137 static int lcdc_power_save_on;
9138
9139 if (lcdc_power_save_on == flag_on)
9140 return 0;
9141
9142 lcdc_power_save_on = flag_on;
9143
9144 lcdc_samsung_panel_power(on);
9145
9146 return 0;
9147}
9148
9149#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009150
9151static struct msm_bus_vectors rotator_init_vectors[] = {
9152 {
9153 .src = MSM_BUS_MASTER_ROTATOR,
9154 .dst = MSM_BUS_SLAVE_SMI,
9155 .ab = 0,
9156 .ib = 0,
9157 },
9158 {
9159 .src = MSM_BUS_MASTER_ROTATOR,
9160 .dst = MSM_BUS_SLAVE_EBI_CH0,
9161 .ab = 0,
9162 .ib = 0,
9163 },
9164};
9165
9166static struct msm_bus_vectors rotator_ui_vectors[] = {
9167 {
9168 .src = MSM_BUS_MASTER_ROTATOR,
9169 .dst = MSM_BUS_SLAVE_SMI,
9170 .ab = 0,
9171 .ib = 0,
9172 },
9173 {
9174 .src = MSM_BUS_MASTER_ROTATOR,
9175 .dst = MSM_BUS_SLAVE_EBI_CH0,
9176 .ab = (1024 * 600 * 4 * 2 * 60),
9177 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9178 },
9179};
9180
9181static struct msm_bus_vectors rotator_vga_vectors[] = {
9182 {
9183 .src = MSM_BUS_MASTER_ROTATOR,
9184 .dst = MSM_BUS_SLAVE_SMI,
9185 .ab = (640 * 480 * 2 * 2 * 30),
9186 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9187 },
9188 {
9189 .src = MSM_BUS_MASTER_ROTATOR,
9190 .dst = MSM_BUS_SLAVE_EBI_CH0,
9191 .ab = (640 * 480 * 2 * 2 * 30),
9192 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9193 },
9194};
9195
9196static struct msm_bus_vectors rotator_720p_vectors[] = {
9197 {
9198 .src = MSM_BUS_MASTER_ROTATOR,
9199 .dst = MSM_BUS_SLAVE_SMI,
9200 .ab = (1280 * 736 * 2 * 2 * 30),
9201 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9202 },
9203 {
9204 .src = MSM_BUS_MASTER_ROTATOR,
9205 .dst = MSM_BUS_SLAVE_EBI_CH0,
9206 .ab = (1280 * 736 * 2 * 2 * 30),
9207 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9208 },
9209};
9210
9211static struct msm_bus_vectors rotator_1080p_vectors[] = {
9212 {
9213 .src = MSM_BUS_MASTER_ROTATOR,
9214 .dst = MSM_BUS_SLAVE_SMI,
9215 .ab = (1920 * 1088 * 2 * 2 * 30),
9216 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9217 },
9218 {
9219 .src = MSM_BUS_MASTER_ROTATOR,
9220 .dst = MSM_BUS_SLAVE_EBI_CH0,
9221 .ab = (1920 * 1088 * 2 * 2 * 30),
9222 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9223 },
9224};
9225
9226static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9227 {
9228 ARRAY_SIZE(rotator_init_vectors),
9229 rotator_init_vectors,
9230 },
9231 {
9232 ARRAY_SIZE(rotator_ui_vectors),
9233 rotator_ui_vectors,
9234 },
9235 {
9236 ARRAY_SIZE(rotator_vga_vectors),
9237 rotator_vga_vectors,
9238 },
9239 {
9240 ARRAY_SIZE(rotator_720p_vectors),
9241 rotator_720p_vectors,
9242 },
9243 {
9244 ARRAY_SIZE(rotator_1080p_vectors),
9245 rotator_1080p_vectors,
9246 },
9247};
9248
9249struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9250 rotator_bus_scale_usecases,
9251 ARRAY_SIZE(rotator_bus_scale_usecases),
9252 .name = "rotator",
9253};
9254
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009255static struct msm_bus_vectors mdp_init_vectors[] = {
9256 /* For now, 0th array entry is reserved.
9257 * Please leave 0 as is and don't use it
9258 */
9259 {
9260 .src = MSM_BUS_MASTER_MDP_PORT0,
9261 .dst = MSM_BUS_SLAVE_SMI,
9262 .ab = 0,
9263 .ib = 0,
9264 },
9265 /* Master and slaves can be from different fabrics */
9266 {
9267 .src = MSM_BUS_MASTER_MDP_PORT0,
9268 .dst = MSM_BUS_SLAVE_EBI_CH0,
9269 .ab = 0,
9270 .ib = 0,
9271 },
9272};
9273
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009274#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009275static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9276 /* Default case static display/UI/2d/3d if FB SMI */
9277 {
9278 .src = MSM_BUS_MASTER_MDP_PORT0,
9279 .dst = MSM_BUS_SLAVE_SMI,
9280 .ab = 388800000,
9281 .ib = 486000000,
9282 },
9283 /* Master and slaves can be from different fabrics */
9284 {
9285 .src = MSM_BUS_MASTER_MDP_PORT0,
9286 .dst = MSM_BUS_SLAVE_EBI_CH0,
9287 .ab = 0,
9288 .ib = 0,
9289 },
9290};
9291
9292static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9293 /* Default case static display/UI/2d/3d if FB SMI */
9294 {
9295 .src = MSM_BUS_MASTER_MDP_PORT0,
9296 .dst = MSM_BUS_SLAVE_SMI,
9297 .ab = 0,
9298 .ib = 0,
9299 },
9300 /* Master and slaves can be from different fabrics */
9301 {
9302 .src = MSM_BUS_MASTER_MDP_PORT0,
9303 .dst = MSM_BUS_SLAVE_EBI_CH0,
9304 .ab = 388800000,
9305 .ib = 486000000 * 2,
9306 },
9307};
9308static struct msm_bus_vectors mdp_vga_vectors[] = {
9309 /* VGA and less video */
9310 {
9311 .src = MSM_BUS_MASTER_MDP_PORT0,
9312 .dst = MSM_BUS_SLAVE_SMI,
9313 .ab = 458092800,
9314 .ib = 572616000,
9315 },
9316 {
9317 .src = MSM_BUS_MASTER_MDP_PORT0,
9318 .dst = MSM_BUS_SLAVE_EBI_CH0,
9319 .ab = 458092800,
9320 .ib = 572616000 * 2,
9321 },
9322};
9323static struct msm_bus_vectors mdp_720p_vectors[] = {
9324 /* 720p and less video */
9325 {
9326 .src = MSM_BUS_MASTER_MDP_PORT0,
9327 .dst = MSM_BUS_SLAVE_SMI,
9328 .ab = 471744000,
9329 .ib = 589680000,
9330 },
9331 /* Master and slaves can be from different fabrics */
9332 {
9333 .src = MSM_BUS_MASTER_MDP_PORT0,
9334 .dst = MSM_BUS_SLAVE_EBI_CH0,
9335 .ab = 471744000,
9336 .ib = 589680000 * 2,
9337 },
9338};
9339
9340static struct msm_bus_vectors mdp_1080p_vectors[] = {
9341 /* 1080p and less video */
9342 {
9343 .src = MSM_BUS_MASTER_MDP_PORT0,
9344 .dst = MSM_BUS_SLAVE_SMI,
9345 .ab = 575424000,
9346 .ib = 719280000,
9347 },
9348 /* Master and slaves can be from different fabrics */
9349 {
9350 .src = MSM_BUS_MASTER_MDP_PORT0,
9351 .dst = MSM_BUS_SLAVE_EBI_CH0,
9352 .ab = 575424000,
9353 .ib = 719280000 * 2,
9354 },
9355};
9356
9357#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009358static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9359 /* Default case static display/UI/2d/3d if FB SMI */
9360 {
9361 .src = MSM_BUS_MASTER_MDP_PORT0,
9362 .dst = MSM_BUS_SLAVE_SMI,
9363 .ab = 175110000,
9364 .ib = 218887500,
9365 },
9366 /* Master and slaves can be from different fabrics */
9367 {
9368 .src = MSM_BUS_MASTER_MDP_PORT0,
9369 .dst = MSM_BUS_SLAVE_EBI_CH0,
9370 .ab = 0,
9371 .ib = 0,
9372 },
9373};
9374
9375static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9376 /* Default case static display/UI/2d/3d if FB SMI */
9377 {
9378 .src = MSM_BUS_MASTER_MDP_PORT0,
9379 .dst = MSM_BUS_SLAVE_SMI,
9380 .ab = 0,
9381 .ib = 0,
9382 },
9383 /* Master and slaves can be from different fabrics */
9384 {
9385 .src = MSM_BUS_MASTER_MDP_PORT0,
9386 .dst = MSM_BUS_SLAVE_EBI_CH0,
9387 .ab = 216000000,
9388 .ib = 270000000 * 2,
9389 },
9390};
9391static struct msm_bus_vectors mdp_vga_vectors[] = {
9392 /* VGA and less video */
9393 {
9394 .src = MSM_BUS_MASTER_MDP_PORT0,
9395 .dst = MSM_BUS_SLAVE_SMI,
9396 .ab = 216000000,
9397 .ib = 270000000,
9398 },
9399 {
9400 .src = MSM_BUS_MASTER_MDP_PORT0,
9401 .dst = MSM_BUS_SLAVE_EBI_CH0,
9402 .ab = 216000000,
9403 .ib = 270000000 * 2,
9404 },
9405};
9406
9407static struct msm_bus_vectors mdp_720p_vectors[] = {
9408 /* 720p and less video */
9409 {
9410 .src = MSM_BUS_MASTER_MDP_PORT0,
9411 .dst = MSM_BUS_SLAVE_SMI,
9412 .ab = 230400000,
9413 .ib = 288000000,
9414 },
9415 /* Master and slaves can be from different fabrics */
9416 {
9417 .src = MSM_BUS_MASTER_MDP_PORT0,
9418 .dst = MSM_BUS_SLAVE_EBI_CH0,
9419 .ab = 230400000,
9420 .ib = 288000000 * 2,
9421 },
9422};
9423
9424static struct msm_bus_vectors mdp_1080p_vectors[] = {
9425 /* 1080p and less video */
9426 {
9427 .src = MSM_BUS_MASTER_MDP_PORT0,
9428 .dst = MSM_BUS_SLAVE_SMI,
9429 .ab = 334080000,
9430 .ib = 417600000,
9431 },
9432 /* Master and slaves can be from different fabrics */
9433 {
9434 .src = MSM_BUS_MASTER_MDP_PORT0,
9435 .dst = MSM_BUS_SLAVE_EBI_CH0,
9436 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009437 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009438 },
9439};
9440
9441#endif
9442static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9443 {
9444 ARRAY_SIZE(mdp_init_vectors),
9445 mdp_init_vectors,
9446 },
9447 {
9448 ARRAY_SIZE(mdp_sd_smi_vectors),
9449 mdp_sd_smi_vectors,
9450 },
9451 {
9452 ARRAY_SIZE(mdp_sd_ebi_vectors),
9453 mdp_sd_ebi_vectors,
9454 },
9455 {
9456 ARRAY_SIZE(mdp_vga_vectors),
9457 mdp_vga_vectors,
9458 },
9459 {
9460 ARRAY_SIZE(mdp_720p_vectors),
9461 mdp_720p_vectors,
9462 },
9463 {
9464 ARRAY_SIZE(mdp_1080p_vectors),
9465 mdp_1080p_vectors,
9466 },
9467};
9468static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9469 mdp_bus_scale_usecases,
9470 ARRAY_SIZE(mdp_bus_scale_usecases),
9471 .name = "mdp",
9472};
9473
9474#endif
9475#ifdef CONFIG_MSM_BUS_SCALING
9476static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9477 /* For now, 0th array entry is reserved.
9478 * Please leave 0 as is and don't use it
9479 */
9480 {
9481 .src = MSM_BUS_MASTER_MDP_PORT0,
9482 .dst = MSM_BUS_SLAVE_SMI,
9483 .ab = 0,
9484 .ib = 0,
9485 },
9486 /* Master and slaves can be from different fabrics */
9487 {
9488 .src = MSM_BUS_MASTER_MDP_PORT0,
9489 .dst = MSM_BUS_SLAVE_EBI_CH0,
9490 .ab = 0,
9491 .ib = 0,
9492 },
9493};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009494
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009495static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9496 /* For now, 0th array entry is reserved.
9497 * Please leave 0 as is and don't use it
9498 */
9499 {
9500 .src = MSM_BUS_MASTER_MDP_PORT0,
9501 .dst = MSM_BUS_SLAVE_SMI,
9502 .ab = 566092800,
9503 .ib = 707616000,
9504 },
9505 /* Master and slaves can be from different fabrics */
9506 {
9507 .src = MSM_BUS_MASTER_MDP_PORT0,
9508 .dst = MSM_BUS_SLAVE_EBI_CH0,
9509 .ab = 566092800,
9510 .ib = 707616000,
9511 },
9512};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009513
9514static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9515 /* For now, 0th array entry is reserved.
9516 * Please leave 0 as is and don't use it
9517 */
9518 {
9519 .src = MSM_BUS_MASTER_MDP_PORT0,
9520 .dst = MSM_BUS_SLAVE_SMI,
9521 .ab = 2000000000,
9522 .ib = 2000000000,
9523 },
9524 /* Master and slaves can be from different fabrics */
9525 {
9526 .src = MSM_BUS_MASTER_MDP_PORT0,
9527 .dst = MSM_BUS_SLAVE_EBI_CH0,
9528 .ab = 2000000000,
9529 .ib = 2000000000,
9530 },
9531};
9532
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009533static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9534 {
9535 ARRAY_SIZE(dtv_bus_init_vectors),
9536 dtv_bus_init_vectors,
9537 },
9538 {
9539 ARRAY_SIZE(dtv_bus_def_vectors),
9540 dtv_bus_def_vectors,
9541 },
9542};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009543
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009544static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9545 dtv_bus_scale_usecases,
9546 ARRAY_SIZE(dtv_bus_scale_usecases),
9547 .name = "dtv",
9548};
9549
9550static struct lcdc_platform_data dtv_pdata = {
9551 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309552 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009553};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009554
9555static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9556 {
9557 ARRAY_SIZE(dtv_bus_init_vectors),
9558 dtv_bus_init_vectors,
9559 },
9560 {
9561 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9562 dtv_bus_hdmi_prim_vectors,
9563 },
9564};
9565
9566static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9567 dtv_hdmi_prim_bus_scale_usecases,
9568 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9569 .name = "dtv",
9570};
9571
9572static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9573 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9574};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009575#endif
9576
9577
9578static struct lcdc_platform_data lcdc_pdata = {
9579 .lcdc_power_save = lcdc_panel_power,
9580};
9581
9582
9583#define MDP_VSYNC_GPIO 28
9584
9585/*
9586 * MIPI_DSI only use 8058_LDO0 which need always on
9587 * therefore it need to be put at low power mode if
9588 * it was not used instead of turn it off.
9589 */
9590static int mipi_dsi_panel_power(int on)
9591{
9592 int flag_on = !!on;
9593 static int mipi_dsi_power_save_on;
9594 static struct regulator *ldo0;
9595 int rc = 0;
9596
9597 if (mipi_dsi_power_save_on == flag_on)
9598 return 0;
9599
9600 mipi_dsi_power_save_on = flag_on;
9601
9602 if (ldo0 == NULL) { /* init */
9603 ldo0 = regulator_get(NULL, "8058_l0");
9604 if (IS_ERR(ldo0)) {
9605 pr_debug("%s: LDO0 failed\n", __func__);
9606 rc = PTR_ERR(ldo0);
9607 return rc;
9608 }
9609
9610 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9611 if (rc)
9612 goto out;
9613
9614 rc = regulator_enable(ldo0);
9615 if (rc)
9616 goto out;
9617 }
9618
9619 if (on) {
9620 /* set ldo0 to HPM */
9621 rc = regulator_set_optimum_mode(ldo0, 100000);
9622 if (rc < 0)
9623 goto out;
9624 } else {
9625 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309626 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009627 if (rc < 0)
9628 goto out;
9629 }
9630
9631 return 0;
9632out:
9633 regulator_disable(ldo0);
9634 regulator_put(ldo0);
9635 ldo0 = NULL;
9636 return rc;
9637}
9638
9639static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9640 .vsync_gpio = MDP_VSYNC_GPIO,
9641 .dsi_power_save = mipi_dsi_panel_power,
9642};
9643
9644#ifdef CONFIG_FB_MSM_TVOUT
9645static struct regulator *reg_8058_l13;
9646
9647static int atv_dac_power(int on)
9648{
9649 int rc = 0;
9650 #define _GET_REGULATOR(var, name) do { \
9651 var = regulator_get(NULL, name); \
9652 if (IS_ERR(var)) { \
9653 pr_info("'%s' regulator not found, rc=%ld\n", \
9654 name, IS_ERR(var)); \
9655 var = NULL; \
9656 return -ENODEV; \
9657 } \
9658 } while (0)
9659
9660 if (!reg_8058_l13)
9661 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9662 #undef _GET_REGULATOR
9663
9664 if (on) {
9665 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9666 if (rc) {
9667 pr_info("%s: '%s' regulator set voltage failed,\
9668 rc=%d\n", __func__, "8058_l13", rc);
9669 return rc;
9670 }
9671
9672 rc = regulator_enable(reg_8058_l13);
9673 if (rc) {
9674 pr_err("%s: '%s' regulator enable failed,\
9675 rc=%d\n", __func__, "8058_l13", rc);
9676 return rc;
9677 }
9678 } else {
9679 rc = regulator_force_disable(reg_8058_l13);
9680 if (rc)
9681 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9682 __func__, "8058_l13", rc);
9683 }
9684 return rc;
9685
9686}
9687#endif
9688
9689#ifdef CONFIG_FB_MSM_MIPI_DSI
9690int mdp_core_clk_rate_table[] = {
9691 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009692 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009693 160000000,
9694 200000000,
9695};
9696#else
9697int mdp_core_clk_rate_table[] = {
9698 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009699 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009700 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009701 200000000,
9702};
9703#endif
9704
9705static struct msm_panel_common_pdata mdp_pdata = {
9706 .gpio = MDP_VSYNC_GPIO,
9707 .mdp_core_clk_rate = 59080000,
9708 .mdp_core_clk_table = mdp_core_clk_rate_table,
9709 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9710#ifdef CONFIG_MSM_BUS_SCALING
9711 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9712#endif
9713 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009714#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009715 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009716#else
9717 .mem_hid = MEMTYPE_EBI1,
9718#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009719};
9720
Huaibin Yanga5419422011-12-08 23:52:10 -08009721static void __init reserve_mdp_memory(void)
9722{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009723 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9724 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9725#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9726 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9727 mdp_pdata.ov0_wb_size;
9728 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9729 mdp_pdata.ov1_wb_size;
9730#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009731}
9732
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009733#ifdef CONFIG_FB_MSM_TVOUT
9734
9735#ifdef CONFIG_MSM_BUS_SCALING
9736static struct msm_bus_vectors atv_bus_init_vectors[] = {
9737 /* For now, 0th array entry is reserved.
9738 * Please leave 0 as is and don't use it
9739 */
9740 {
9741 .src = MSM_BUS_MASTER_MDP_PORT0,
9742 .dst = MSM_BUS_SLAVE_SMI,
9743 .ab = 0,
9744 .ib = 0,
9745 },
9746 /* Master and slaves can be from different fabrics */
9747 {
9748 .src = MSM_BUS_MASTER_MDP_PORT0,
9749 .dst = MSM_BUS_SLAVE_EBI_CH0,
9750 .ab = 0,
9751 .ib = 0,
9752 },
9753};
9754static struct msm_bus_vectors atv_bus_def_vectors[] = {
9755 /* For now, 0th array entry is reserved.
9756 * Please leave 0 as is and don't use it
9757 */
9758 {
9759 .src = MSM_BUS_MASTER_MDP_PORT0,
9760 .dst = MSM_BUS_SLAVE_SMI,
9761 .ab = 236390400,
9762 .ib = 265939200,
9763 },
9764 /* Master and slaves can be from different fabrics */
9765 {
9766 .src = MSM_BUS_MASTER_MDP_PORT0,
9767 .dst = MSM_BUS_SLAVE_EBI_CH0,
9768 .ab = 236390400,
9769 .ib = 265939200,
9770 },
9771};
9772static struct msm_bus_paths atv_bus_scale_usecases[] = {
9773 {
9774 ARRAY_SIZE(atv_bus_init_vectors),
9775 atv_bus_init_vectors,
9776 },
9777 {
9778 ARRAY_SIZE(atv_bus_def_vectors),
9779 atv_bus_def_vectors,
9780 },
9781};
9782static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9783 atv_bus_scale_usecases,
9784 ARRAY_SIZE(atv_bus_scale_usecases),
9785 .name = "atv",
9786};
9787#endif
9788
9789static struct tvenc_platform_data atv_pdata = {
9790 .poll = 0,
9791 .pm_vid_en = atv_dac_power,
9792#ifdef CONFIG_MSM_BUS_SCALING
9793 .bus_scale_table = &atv_bus_scale_pdata,
9794#endif
9795};
9796#endif
9797
9798static void __init msm_fb_add_devices(void)
9799{
9800#ifdef CONFIG_FB_MSM_LCDC_DSUB
9801 mdp_pdata.mdp_core_clk_table = NULL;
9802 mdp_pdata.num_mdp_clk = 0;
9803 mdp_pdata.mdp_core_clk_rate = 200000000;
9804#endif
9805 if (machine_is_msm8x60_rumi3())
9806 msm_fb_register_device("mdp", NULL);
9807 else
9808 msm_fb_register_device("mdp", &mdp_pdata);
9809
9810 msm_fb_register_device("lcdc", &lcdc_pdata);
9811 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9812#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009813 if (hdmi_is_primary)
9814 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9815 else
9816 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009817#endif
9818#ifdef CONFIG_FB_MSM_TVOUT
9819 msm_fb_register_device("tvenc", &atv_pdata);
9820 msm_fb_register_device("tvout_device", NULL);
9821#endif
9822}
9823
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009824/**
9825 * Set MDP clocks to high frequency to avoid underflow when
9826 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9827 */
9828static void set_mdp_clocks_for_wuxga(void)
9829{
9830 int i;
9831
9832 mdp_sd_smi_vectors[0].ab = 2000000000;
9833 mdp_sd_smi_vectors[0].ib = 2000000000;
9834 mdp_sd_smi_vectors[1].ab = 2000000000;
9835 mdp_sd_smi_vectors[1].ib = 2000000000;
9836
9837 mdp_sd_ebi_vectors[0].ab = 2000000000;
9838 mdp_sd_ebi_vectors[0].ib = 2000000000;
9839 mdp_sd_ebi_vectors[1].ab = 2000000000;
9840 mdp_sd_ebi_vectors[1].ib = 2000000000;
9841
9842 mdp_vga_vectors[0].ab = 2000000000;
9843 mdp_vga_vectors[0].ib = 2000000000;
9844 mdp_vga_vectors[1].ab = 2000000000;
9845 mdp_vga_vectors[1].ib = 2000000000;
9846
9847 mdp_720p_vectors[0].ab = 2000000000;
9848 mdp_720p_vectors[0].ib = 2000000000;
9849 mdp_720p_vectors[1].ab = 2000000000;
9850 mdp_720p_vectors[1].ib = 2000000000;
9851
9852 mdp_1080p_vectors[0].ab = 2000000000;
9853 mdp_1080p_vectors[0].ib = 2000000000;
9854 mdp_1080p_vectors[1].ab = 2000000000;
9855 mdp_1080p_vectors[1].ib = 2000000000;
9856
9857 mdp_pdata.mdp_core_clk_rate = 200000000;
9858
9859 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9860 mdp_core_clk_rate_table[i] = 200000000;
9861}
9862
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009863#if (defined(CONFIG_MARIMBA_CORE)) && \
9864 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9865
9866static const struct {
9867 char *name;
9868 int vmin;
9869 int vmax;
9870} bt_regs_info[] = {
9871 { "8058_s3", 1800000, 1800000 },
9872 { "8058_s2", 1300000, 1300000 },
9873 { "8058_l8", 2900000, 3050000 },
9874};
9875
9876static struct {
9877 bool enabled;
9878} bt_regs_status[] = {
9879 { false },
9880 { false },
9881 { false },
9882};
9883static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9884
9885static int bahama_bt(int on)
9886{
9887 int rc;
9888 int i;
9889 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9890
9891 struct bahama_variant_register {
9892 const size_t size;
9893 const struct bahama_config_register *set;
9894 };
9895
9896 const struct bahama_config_register *p;
9897
9898 u8 version;
9899
9900 const struct bahama_config_register v10_bt_on[] = {
9901 { 0xE9, 0x00, 0xFF },
9902 { 0xF4, 0x80, 0xFF },
9903 { 0xE4, 0x00, 0xFF },
9904 { 0xE5, 0x00, 0x0F },
9905#ifdef CONFIG_WLAN
9906 { 0xE6, 0x38, 0x7F },
9907 { 0xE7, 0x06, 0xFF },
9908#endif
9909 { 0xE9, 0x21, 0xFF },
9910 { 0x01, 0x0C, 0x1F },
9911 { 0x01, 0x08, 0x1F },
9912 };
9913
9914 const struct bahama_config_register v20_bt_on_fm_off[] = {
9915 { 0x11, 0x0C, 0xFF },
9916 { 0x13, 0x01, 0xFF },
9917 { 0xF4, 0x80, 0xFF },
9918 { 0xF0, 0x00, 0xFF },
9919 { 0xE9, 0x00, 0xFF },
9920#ifdef CONFIG_WLAN
9921 { 0x81, 0x00, 0x7F },
9922 { 0x82, 0x00, 0xFF },
9923 { 0xE6, 0x38, 0x7F },
9924 { 0xE7, 0x06, 0xFF },
9925#endif
9926 { 0xE9, 0x21, 0xFF },
9927 };
9928
9929 const struct bahama_config_register v20_bt_on_fm_on[] = {
9930 { 0x11, 0x0C, 0xFF },
9931 { 0x13, 0x01, 0xFF },
9932 { 0xF4, 0x86, 0xFF },
9933 { 0xF0, 0x06, 0xFF },
9934 { 0xE9, 0x00, 0xFF },
9935#ifdef CONFIG_WLAN
9936 { 0x81, 0x00, 0x7F },
9937 { 0x82, 0x00, 0xFF },
9938 { 0xE6, 0x38, 0x7F },
9939 { 0xE7, 0x06, 0xFF },
9940#endif
9941 { 0xE9, 0x21, 0xFF },
9942 };
9943
9944 const struct bahama_config_register v10_bt_off[] = {
9945 { 0xE9, 0x00, 0xFF },
9946 };
9947
9948 const struct bahama_config_register v20_bt_off_fm_off[] = {
9949 { 0xF4, 0x84, 0xFF },
9950 { 0xF0, 0x04, 0xFF },
9951 { 0xE9, 0x00, 0xFF }
9952 };
9953
9954 const struct bahama_config_register v20_bt_off_fm_on[] = {
9955 { 0xF4, 0x86, 0xFF },
9956 { 0xF0, 0x06, 0xFF },
9957 { 0xE9, 0x00, 0xFF }
9958 };
9959 const struct bahama_variant_register bt_bahama[2][3] = {
9960 {
9961 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9962 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9963 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9964 },
9965 {
9966 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9967 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9968 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9969 }
9970 };
9971
9972 u8 offset = 0; /* index into bahama configs */
9973
9974 on = on ? 1 : 0;
9975 version = read_bahama_ver();
9976
9977 if (version == VER_UNSUPPORTED) {
9978 dev_err(&msm_bt_power_device.dev,
9979 "%s: unsupported version\n",
9980 __func__);
9981 return -EIO;
9982 }
9983
9984 if (version == VER_2_0) {
9985 if (marimba_get_fm_status(&config))
9986 offset = 0x01;
9987 }
9988
9989 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9990 if (on && (version == VER_2_0)) {
9991 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9992 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9993 && (bt_regs_status[i].enabled == true)) {
9994 if (regulator_disable(bt_regs[i])) {
9995 dev_err(&msm_bt_power_device.dev,
9996 "%s: regulator disable failed",
9997 __func__);
9998 }
9999 bt_regs_status[i].enabled = false;
10000 break;
10001 }
10002 }
10003 }
10004
10005 p = bt_bahama[on][version + offset].set;
10006
10007 dev_info(&msm_bt_power_device.dev,
10008 "%s: found version %d\n", __func__, version);
10009
10010 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
10011 u8 value = (p+i)->value;
10012 rc = marimba_write_bit_mask(&config,
10013 (p+i)->reg,
10014 &value,
10015 sizeof((p+i)->value),
10016 (p+i)->mask);
10017 if (rc < 0) {
10018 dev_err(&msm_bt_power_device.dev,
10019 "%s: reg %d write failed: %d\n",
10020 __func__, (p+i)->reg, rc);
10021 return rc;
10022 }
10023 dev_dbg(&msm_bt_power_device.dev,
10024 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
10025 __func__, (p+i)->reg,
10026 value, (p+i)->mask);
10027 }
10028 /* Update BT Status */
10029 if (on)
10030 marimba_set_bt_status(&config, true);
10031 else
10032 marimba_set_bt_status(&config, false);
10033
10034 return 0;
10035}
10036
10037static int bluetooth_use_regulators(int on)
10038{
10039 int i, recover = -1, rc = 0;
10040
10041 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10042 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
10043 bt_regs_info[i].name) :
10044 (regulator_put(bt_regs[i]), NULL);
10045 if (IS_ERR(bt_regs[i])) {
10046 rc = PTR_ERR(bt_regs[i]);
10047 dev_err(&msm_bt_power_device.dev,
10048 "regulator %s get failed (%d)\n",
10049 bt_regs_info[i].name, rc);
10050 recover = i - 1;
10051 bt_regs[i] = NULL;
10052 break;
10053 }
10054
10055 if (!on)
10056 continue;
10057
10058 rc = regulator_set_voltage(bt_regs[i],
10059 bt_regs_info[i].vmin,
10060 bt_regs_info[i].vmax);
10061 if (rc < 0) {
10062 dev_err(&msm_bt_power_device.dev,
10063 "regulator %s voltage set (%d)\n",
10064 bt_regs_info[i].name, rc);
10065 recover = i;
10066 break;
10067 }
10068 }
10069
10070 if (on && (recover > -1))
10071 for (i = recover; i >= 0; i--) {
10072 regulator_put(bt_regs[i]);
10073 bt_regs[i] = NULL;
10074 }
10075
10076 return rc;
10077}
10078
10079static int bluetooth_switch_regulators(int on)
10080{
10081 int i, rc = 0;
10082
10083 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10084 if (on && (bt_regs_status[i].enabled == false)) {
10085 rc = regulator_enable(bt_regs[i]);
10086 if (rc < 0) {
10087 dev_err(&msm_bt_power_device.dev,
10088 "regulator %s %s failed (%d)\n",
10089 bt_regs_info[i].name,
10090 "enable", rc);
10091 if (i > 0) {
10092 while (--i) {
10093 regulator_disable(bt_regs[i]);
10094 bt_regs_status[i].enabled
10095 = false;
10096 }
10097 break;
10098 }
10099 }
10100 bt_regs_status[i].enabled = true;
10101 } else if (!on && (bt_regs_status[i].enabled == true)) {
10102 rc = regulator_disable(bt_regs[i]);
10103 if (rc < 0) {
10104 dev_err(&msm_bt_power_device.dev,
10105 "regulator %s %s failed (%d)\n",
10106 bt_regs_info[i].name,
10107 "disable", rc);
10108 break;
10109 }
10110 bt_regs_status[i].enabled = false;
10111 }
10112 }
10113 return rc;
10114}
10115
10116static struct msm_xo_voter *bt_clock;
10117
10118static int bluetooth_power(int on)
10119{
10120 int rc = 0;
10121 int id;
10122
10123 /* In case probe function fails, cur_connv_type would be -1 */
10124 id = adie_get_detected_connectivity_type();
10125 if (id != BAHAMA_ID) {
10126 pr_err("%s: unexpected adie connectivity type: %d\n",
10127 __func__, id);
10128 return -ENODEV;
10129 }
10130
10131 if (on) {
10132
10133 rc = bluetooth_use_regulators(1);
10134 if (rc < 0)
10135 goto out;
10136
10137 rc = bluetooth_switch_regulators(1);
10138
10139 if (rc < 0)
10140 goto fail_put;
10141
10142 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10143
10144 if (IS_ERR(bt_clock)) {
10145 pr_err("Couldn't get TCXO_D0 voter\n");
10146 goto fail_switch;
10147 }
10148
10149 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10150
10151 if (rc < 0) {
10152 pr_err("Failed to vote for TCXO_DO ON\n");
10153 goto fail_vote;
10154 }
10155
10156 rc = bahama_bt(1);
10157
10158 if (rc < 0)
10159 goto fail_clock;
10160
10161 msleep(10);
10162
10163 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10164
10165 if (rc < 0) {
10166 pr_err("Failed to vote for TCXO_DO pin control\n");
10167 goto fail_vote;
10168 }
10169 } else {
10170 /* check for initial RFKILL block (power off) */
10171 /* some RFKILL versions/configurations rfkill_register */
10172 /* calls here for an initial set_block */
10173 /* avoid calling i2c and regulator before unblock (on) */
10174 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10175 dev_info(&msm_bt_power_device.dev,
10176 "%s: initialized OFF/blocked\n", __func__);
10177 goto out;
10178 }
10179
10180 bahama_bt(0);
10181
10182fail_clock:
10183 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10184fail_vote:
10185 msm_xo_put(bt_clock);
10186fail_switch:
10187 bluetooth_switch_regulators(0);
10188fail_put:
10189 bluetooth_use_regulators(0);
10190 }
10191
10192out:
10193 if (rc < 0)
10194 on = 0;
10195 dev_info(&msm_bt_power_device.dev,
10196 "Bluetooth power switch: state %d result %d\n", on, rc);
10197
10198 return rc;
10199}
10200
10201#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10202
10203static void __init msm8x60_cfg_smsc911x(void)
10204{
10205 smsc911x_resources[1].start =
10206 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10207 smsc911x_resources[1].end =
10208 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10209}
10210
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010211void msm_fusion_setup_pinctrl(void)
10212{
10213 struct msm_xo_voter *a1;
10214
10215 if (socinfo_get_platform_subtype() == 0x3) {
10216 /*
10217 * Vote for the A1 clock to be in pin control mode before
10218 * the external images are loaded.
10219 */
10220 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10221 BUG_ON(!a1);
10222 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10223 }
10224}
10225
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010226struct msm_board_data {
10227 struct msm_gpiomux_configs *gpiomux_cfgs;
10228};
10229
10230static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10231 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10232};
10233
10234static struct msm_board_data msm8x60_sim_board_data __initdata = {
10235 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10236};
10237
10238static struct msm_board_data msm8x60_surf_board_data __initdata = {
10239 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10240};
10241
10242static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10243 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10244};
10245
10246static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10247 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10248};
10249
10250static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10251 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10252};
10253
10254static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10255 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10256};
10257
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010258static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10259 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10260};
10261
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010262static void __init msm8x60_init(struct msm_board_data *board_data)
10263{
10264 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010265#ifdef CONFIG_USB_EHCI_MSM_72K
10266 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10267 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10268 .level = PM8901_MPP_DIG_LEVEL_L5,
10269 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10270 };
10271#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010272 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010273
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010274 /*
10275 * Initialize RPM first as other drivers and devices may need
10276 * it for their initialization.
10277 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010278 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10279 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010280 if (msm_xo_init())
10281 pr_err("Failed to initialize XO votes\n");
10282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010283 msm8x60_check_2d_hardware();
10284
10285 /* Change SPM handling of core 1 if PMM 8160 is present. */
10286 soc_platform_version = socinfo_get_platform_version();
10287 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10288 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10289 struct msm_spm_platform_data *spm_data;
10290
10291 spm_data = &msm_spm_data_v1[1];
10292 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10293 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10294
10295 spm_data = &msm_spm_data[1];
10296 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10297 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10298 }
10299
10300 /*
10301 * Initialize SPM before acpuclock as the latter calls into SPM
10302 * driver to set ACPU voltages.
10303 */
10304 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10305 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10306 else
10307 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10308
10309 /*
10310 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10311 * devices so that the RPM doesn't drop into a low power mode that an
10312 * un-reworked SURF cannot resume from.
10313 */
10314 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010315 int i;
10316
10317 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10318 if (rpm_regulator_init_data[i].id
10319 == RPM_VREG_ID_PM8901_L4
10320 || rpm_regulator_init_data[i].id
10321 == RPM_VREG_ID_PM8901_L6)
10322 rpm_regulator_init_data[i]
10323 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010324 }
10325
10326 /*
10327 * Disable regulator info printing so that regulator registration
10328 * messages do not enter the kmsg log.
10329 */
10330 regulator_suppress_info_printing();
10331
10332 /* Initialize regulators needed for clock_init. */
10333 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10334
Stephen Boydbb600ae2011-08-02 20:11:40 -070010335 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010336
10337 /* Buses need to be initialized before early-device registration
10338 * to get the platform data for fabrics.
10339 */
10340 msm8x60_init_buses();
10341 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10342 /* CPU frequency control is not supported on simulated targets. */
10343 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010344 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010345
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010346 /*
10347 * Enable EBI2 only for boards which make use of it. Leave
10348 * it disabled for all others for additional power savings.
10349 */
10350 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10351 machine_is_msm8x60_rumi3() ||
10352 machine_is_msm8x60_sim() ||
10353 machine_is_msm8x60_fluid() ||
10354 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010355 msm8x60_init_ebi2();
10356 msm8x60_init_tlmm();
10357 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10358 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010359#ifdef CONFIG_MSM_CAMERA_V4L2
10360 msm8x60_init_cam();
10361#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010362 msm8x60_init_mmc();
10363
Kevin Chan3be11612012-03-22 20:05:40 -070010364
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010365#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10366 msm8x60_init_pm8058_othc();
10367#endif
10368
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010369 if (machine_is_msm8x60_fluid())
10370 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10371 else if (machine_is_msm8x60_dragon())
10372 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10373 else
10374 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010375#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010376 /* Specify reset pin for OV9726 */
10377 if (machine_is_msm8x60_dragon()) {
10378 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10379 ov9726_sensor_8660_info.mount_angle = 270;
10380 }
Kevin Chan3be11612012-03-22 20:05:40 -070010381#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010382#ifdef CONFIG_BATTERY_MSM8X60
10383 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10384 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10385 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10386 platform_device_register(&msm_charger_device);
10387#endif
10388
10389 if (machine_is_msm8x60_dragon())
10390 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10391 if (!machine_is_msm8x60_fluid())
10392 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10393
10394 /* configure pmic leds */
10395 if (machine_is_msm8x60_fluid())
10396 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10397 else if (machine_is_msm8x60_dragon())
10398 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10399 else
10400 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10401
10402 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10403 machine_is_msm8x60_dragon()) {
10404 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10405 }
10406
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010407 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10408 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010409 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010410 msm8x60_cfg_smsc911x();
10411 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010412 platform_add_devices(msm8660_footswitch,
10413 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010414 platform_add_devices(surf_devices,
10415 ARRAY_SIZE(surf_devices));
10416
10417#ifdef CONFIG_MSM_DSPS
10418 if (machine_is_msm8x60_fluid()) {
10419 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10420 msm8x60_init_dsps();
10421 }
10422#endif
10423
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010424 pm8901_vreg_mpp0_init();
10425
10426 platform_device_register(&msm8x60_8901_mpp_vreg);
10427
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010428#ifdef CONFIG_USB_EHCI_MSM_72K
10429 /*
10430 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10431 * fluid
10432 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010433 if (machine_is_msm8x60_fluid())
10434 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10435 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010436#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010437
10438#ifdef CONFIG_SND_SOC_MSM8660_APQ
10439 if (machine_is_msm8x60_dragon())
10440 platform_add_devices(dragon_alsa_devices,
10441 ARRAY_SIZE(dragon_alsa_devices));
10442 else
10443#endif
10444 platform_add_devices(asoc_devices,
10445 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010446 } else {
10447 msm8x60_configure_smc91x();
10448 platform_add_devices(rumi_sim_devices,
10449 ARRAY_SIZE(rumi_sim_devices));
10450 }
10451#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010452 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10453 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010454 msm8x60_cfg_isp1763();
10455#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010456
10457 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10458 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10459
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010460
10461#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10462 if (machine_is_msm8x60_fluid())
10463 platform_device_register(&msm_gsbi10_qup_spi_device);
10464 else
10465 platform_device_register(&msm_gsbi1_qup_spi_device);
10466#endif
10467
Steve Mucklef132c6c2012-06-06 18:30:57 -070010468#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10469 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010470 if (machine_is_msm8x60_fluid())
10471 cyttsp_set_params();
10472#endif
10473 if (!machine_is_msm8x60_sim())
10474 msm_fb_add_devices();
10475 fixup_i2c_configs();
10476 register_i2c_devices();
10477
Terence Hampson1c73fef2011-07-19 17:10:49 -040010478 if (machine_is_msm8x60_dragon())
10479 smsc911x_config.reset_gpio
10480 = GPIO_ETHERNET_RESET_N_DRAGON;
10481
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010482 platform_device_register(&smsc911x_device);
10483
10484#if (defined(CONFIG_SPI_QUP)) && \
10485 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010486 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10487 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010488
10489 if (machine_is_msm8x60_fluid()) {
10490#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10491 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10492 spi_register_board_info(lcdc_samsung_spi_board_info,
10493 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10494 } else
10495#endif
10496 {
10497#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10498 spi_register_board_info(lcdc_auo_spi_board_info,
10499 ARRAY_SIZE(lcdc_auo_spi_board_info));
10500#endif
10501 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010502#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10503 } else if (machine_is_msm8x60_dragon()) {
10504 spi_register_board_info(lcdc_nt35582_spi_board_info,
10505 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10506#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010507 }
10508#endif
10509
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010510 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010511
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010512 pm8058_gpios_init();
10513
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010514#ifdef CONFIG_SENSORS_MSM_ADC
10515 if (machine_is_msm8x60_fluid()) {
10516 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10517 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10518 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10519 msm_adc_pdata.gpio_config = APROC_CONFIG;
10520 else
10521 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10522 }
10523 msm_adc_pdata.target_hw = MSM_8x60;
10524#endif
10525#ifdef CONFIG_MSM8X60_AUDIO
10526 msm_snddev_init();
10527#endif
10528#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10529 if (machine_is_msm8x60_fluid())
10530 platform_device_register(&fluid_leds_gpio);
10531 else
10532 platform_device_register(&gpio_leds);
10533#endif
10534
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010535 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010536
10537 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10538 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010539}
10540
10541static void __init msm8x60_rumi3_init(void)
10542{
10543 msm8x60_init(&msm8x60_rumi3_board_data);
10544}
10545
10546static void __init msm8x60_sim_init(void)
10547{
10548 msm8x60_init(&msm8x60_sim_board_data);
10549}
10550
10551static void __init msm8x60_surf_init(void)
10552{
10553 msm8x60_init(&msm8x60_surf_board_data);
10554}
10555
10556static void __init msm8x60_ffa_init(void)
10557{
10558 msm8x60_init(&msm8x60_ffa_board_data);
10559}
10560
10561static void __init msm8x60_fluid_init(void)
10562{
10563 msm8x60_init(&msm8x60_fluid_board_data);
10564}
10565
10566static void __init msm8x60_charm_surf_init(void)
10567{
10568 msm8x60_init(&msm8x60_charm_surf_board_data);
10569}
10570
10571static void __init msm8x60_charm_ffa_init(void)
10572{
10573 msm8x60_init(&msm8x60_charm_ffa_board_data);
10574}
10575
10576static void __init msm8x60_charm_init_early(void)
10577{
10578 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010579}
10580
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010581static void __init msm8x60_dragon_init(void)
10582{
10583 msm8x60_init(&msm8x60_dragon_board_data);
10584}
David Brown56e2d8a2011-08-04 02:01:02 -070010585
Steve Mucklea55df6e2010-01-07 12:43:24 -080010586MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10587 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010588 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010589 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010590 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010591 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010592 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010593 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010594 .restart = msm_restart,
Steve Muckle49b76f72010-03-19 17:00:08 -070010595MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010596
10597MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10598 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010599 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010600 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010601 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010602 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010603 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010604 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010605 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010606MACHINE_END
10607
10608MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10609 .map_io = msm8x60_map_io,
10610 .reserve = msm8x60_reserve,
10611 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010612 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010613 .init_machine = msm8x60_surf_init,
10614 .timer = &msm_timer,
10615 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010616 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010617MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010618
10619MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10620 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010621 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010622 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010623 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010624 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010625 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010626 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010627 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010628MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010629
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010630MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010631 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010632 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010633 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010634 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010635 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010636 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010637 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010638 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010639MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010640
10641MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10642 .map_io = msm8x60_map_io,
10643 .reserve = msm8x60_reserve,
10644 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010645 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010646 .init_machine = msm8x60_charm_surf_init,
10647 .timer = &msm_timer,
10648 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010649 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010650MACHINE_END
10651
10652MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10653 .map_io = msm8x60_map_io,
10654 .reserve = msm8x60_reserve,
10655 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010656 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010657 .init_machine = msm8x60_charm_ffa_init,
10658 .timer = &msm_timer,
10659 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010660 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010661MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010662
10663MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10664 .map_io = msm8x60_map_io,
10665 .reserve = msm8x60_reserve,
10666 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010667 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010668 .init_machine = msm8x60_dragon_init,
10669 .timer = &msm_timer,
10670 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010671 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010672MACHINE_END