blob: 77b232de5cf6ebe7870b1ed94e12a4e066a00401 [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Steve Mucklea55df6e2010-01-07 12:43:24 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Steve Mucklea55df6e2010-01-07 12:43:24 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <linux/gpio.h>
Steve Muckle9161d302010-02-11 11:50:40 -080017#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/io.h>
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053019#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/mfd/pmic8058.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080021
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022#include <linux/leds.h>
23#include <linux/pmic8058-othc.h>
24#include <linux/mfd/pmic8901.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053025#include <linux/regulator/gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/regulator/pmic8901-regulator.h>
27#include <linux/bootmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#include <linux/msm_adc.h>
29#include <linux/m_adcproc.h>
30#include <linux/mfd/marimba.h>
31#include <linux/msm-charger.h>
32#include <linux/i2c.h>
33#include <linux/i2c/sx150x.h>
34#include <linux/smsc911x.h>
35#include <linux/spi/spi.h>
36#include <linux/input/tdisc_shinetsu.h>
37#include <linux/input/cy8c_ts.h>
38#include <linux/cyttsp.h>
39#include <linux/i2c/isa1200.h>
40#include <linux/dma-mapping.h>
41#include <linux/i2c/bq27520.h>
42
43#ifdef CONFIG_ANDROID_PMEM
44#include <linux/android_pmem.h>
45#endif
46
47#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
48#include <linux/i2c/smb137b.h>
49#endif
Lei Zhou338cab82011-08-19 13:38:17 -040050#ifdef CONFIG_SND_SOC_WM8903
51#include <sound/wm8903.h>
52#endif
Steve Mucklea55df6e2010-01-07 12:43:24 -080053#include <asm/mach-types.h>
54#include <asm/mach/arch.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include <asm/setup.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053056#include <asm/hardware/gic.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080057
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/dma.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080059#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#include <mach/irqs.h>
61#include <mach/msm_spi.h>
62#include <mach/msm_serial_hs.h>
63#include <mach/msm_serial_hs_lite.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080064#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#include <mach/msm_memtypes.h>
66#include <asm/mach/mmc.h>
67#include <mach/msm_battery.h>
68#include <mach/msm_hsusb.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070069#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#ifdef CONFIG_MSM_DSPS
71#include <mach/msm_dsps.h>
72#endif
73#include <mach/msm_xo.h>
74#include <mach/msm_bus_board.h>
75#include <mach/socinfo.h>
76#include <linux/i2c/isl9519.h>
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
81#include <linux/regulator/consumer.h>
82#include <linux/regulator/machine.h>
83#include <mach/sdio_al.h>
84#include <mach/rpm.h>
85#include <mach/rpm-regulator.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070086#include <mach/restart.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053087#include <mach/board-msm8660.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#include "devices.h"
90#include "devices-msm8x60.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080091#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080092#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093#include "mpm.h"
94#include "spm.h"
95#include "rpm_log.h"
96#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097#include "gpiomux-8x60.h"
98#include "rpm_stats.h"
99#include "peripheral-loader.h"
100#include <linux/platform_data/qcom_crypto_device.h>
101#include "rpm_resources.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -0700102#include "acpuclock.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600103#include "pm-boot.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700104
105#include <linux/ion.h>
106#include <mach/ion.h>
107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109#define MDM2AP_SYNC 129
110
Terence Hampson1c73fef2011-07-19 17:10:49 -0400111#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112#define LCDC_SPI_GPIO_CLK 73
113#define LCDC_SPI_GPIO_CS 72
114#define LCDC_SPI_GPIO_MOSI 70
115#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
116#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
117#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
118#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
119#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400120#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700122#define PANEL_NAME_MAX_LEN 30
123#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
124#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
125#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
126#define HDMI_PANEL_NAME "hdmi_msm"
127#define TVOUT_PANEL_NAME "tvout_msm"
128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129#define DSPS_PIL_GENERIC_NAME "dsps"
130#define DSPS_PIL_FLUID_NAME "dsps_fluid"
131
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800132#ifdef CONFIG_ION_MSM
133static struct platform_device ion_dev;
134#endif
135
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136enum {
137 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530138 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700139 /* CORE expander */
140 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
141 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
142 GPIO_WLAN_DEEP_SLEEP_N,
143 GPIO_LVDS_SHUTDOWN_N,
144 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
145 GPIO_MS_SYS_RESET_N,
146 GPIO_CAP_TS_RESOUT_N,
147 GPIO_CAP_GAUGE_BI_TOUT,
148 GPIO_ETHERNET_PME,
149 GPIO_EXT_GPS_LNA_EN,
150 GPIO_MSM_WAKES_BT,
151 GPIO_ETHERNET_RESET_N,
152 GPIO_HEADSET_DET_N,
153 GPIO_USB_UICC_EN,
154 GPIO_BACKLIGHT_EN,
155 GPIO_EXT_CAMIF_PWR_EN,
156 GPIO_BATT_GAUGE_INT_N,
157 GPIO_BATT_GAUGE_EN,
158 /* DOCKING expander */
159 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
160 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
161 GPIO_AUX_JTAG_DET_N,
162 GPIO_DONGLE_DET_N,
163 GPIO_SVIDEO_LOAD_DET,
164 GPIO_SVID_AMP_SHUTDOWN1_N,
165 GPIO_SVID_AMP_SHUTDOWN0_N,
166 GPIO_SDC_WP,
167 GPIO_IRDA_PWDN,
168 GPIO_IRDA_RESET_N,
169 GPIO_DONGLE_GPIO0,
170 GPIO_DONGLE_GPIO1,
171 GPIO_DONGLE_GPIO2,
172 GPIO_DONGLE_GPIO3,
173 GPIO_DONGLE_PWR_EN,
174 GPIO_EMMC_RESET_N,
175 GPIO_TP_EXP2_IO15,
176 /* SURF expander */
177 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
178 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
179 GPIO_SD_CARD_DET_2,
180 GPIO_SD_CARD_DET_4,
181 GPIO_SD_CARD_DET_5,
182 GPIO_UIM3_RST,
183 GPIO_SURF_EXPANDER_IO5,
184 GPIO_SURF_EXPANDER_IO6,
185 GPIO_ADC_I2C_EN,
186 GPIO_SURF_EXPANDER_IO8,
187 GPIO_SURF_EXPANDER_IO9,
188 GPIO_SURF_EXPANDER_IO10,
189 GPIO_SURF_EXPANDER_IO11,
190 GPIO_SURF_EXPANDER_IO12,
191 GPIO_SURF_EXPANDER_IO13,
192 GPIO_SURF_EXPANDER_IO14,
193 GPIO_SURF_EXPANDER_IO15,
194 /* LEFT KB IO expander */
195 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
196 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
197 GPIO_LEFT_LED_2,
198 GPIO_LEFT_LED_3,
199 GPIO_LEFT_LED_WLAN,
200 GPIO_JOYSTICK_EN,
201 GPIO_CAP_TS_SLEEP,
202 GPIO_LEFT_KB_IO6,
203 GPIO_LEFT_LED_5,
204 /* RIGHT KB IO expander */
205 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
206 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
207 GPIO_RIGHT_LED_2,
208 GPIO_RIGHT_LED_3,
209 GPIO_RIGHT_LED_BT,
210 GPIO_WEB_CAMIF_STANDBY,
211 GPIO_COMPASS_RST_N,
212 GPIO_WEB_CAMIF_RESET_N,
213 GPIO_RIGHT_LED_5,
214 GPIO_R_ALTIMETER_RESET_N,
215 /* FLUID S IO expander */
216 GPIO_SOUTH_EXPANDER_BASE,
217 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
218 GPIO_MIC1_ANCL_SEL,
219 GPIO_HS_MIC4_SEL,
220 GPIO_FML_MIC3_SEL,
221 GPIO_FMR_MIC5_SEL,
222 GPIO_TS_SLEEP,
223 GPIO_HAP_SHIFT_LVL_OE,
224 GPIO_HS_SW_DIR,
225 /* FLUID N IO expander */
226 GPIO_NORTH_EXPANDER_BASE,
227 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
228 GPIO_EPM_5V_BOOST_EN,
229 GPIO_AUX_CAM_2P7_EN,
230 GPIO_LED_FLASH_EN,
231 GPIO_LED1_GREEN_N,
232 GPIO_LED2_RED_N,
233 GPIO_FRONT_CAM_RESET_N,
234 GPIO_EPM_LVLSFT_EN,
235 GPIO_N_ALTIMETER_RESET_N,
236 /* EPM expander */
237 GPIO_EPM_EXPANDER_BASE,
238 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
239 GPIO_PWR_MON_RESET_N,
240 GPIO_ADC1_PWDN_N,
241 GPIO_ADC2_PWDN_N,
242 GPIO_EPM_EXPANDER_IO4,
243 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
244 GPIO_ADC2_MUX_SPI_INT_N,
245 GPIO_EPM_EXPANDER_IO7,
246 GPIO_PWR_MON_ENABLE,
247 GPIO_EPM_SPI_ADC1_CS_N,
248 GPIO_EPM_SPI_ADC2_CS_N,
249 GPIO_EPM_EXPANDER_IO11,
250 GPIO_EPM_EXPANDER_IO12,
251 GPIO_EPM_EXPANDER_IO13,
252 GPIO_EPM_EXPANDER_IO14,
253 GPIO_EPM_EXPANDER_IO15,
254};
255
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530256struct pm8xxx_mpp_init_info {
257 unsigned mpp;
258 struct pm8xxx_mpp_config_data config;
259};
260
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530261#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530262{ \
263 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
264 .config = { \
265 .type = PM8XXX_MPP_TYPE_##_type, \
266 .level = _level, \
267 .control = PM8XXX_MPP_##_control, \
268 } \
269}
270
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530271#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
272{ \
273 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
274 .config = { \
275 .type = PM8XXX_MPP_TYPE_##_type, \
276 .level = _level, \
277 .control = PM8XXX_MPP_##_control, \
278 } \
279}
280
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700281/*
282 * The UI_INTx_N lines are pmic gpio lines which connect i2c
283 * gpio expanders to the pm8058.
284 */
285#define UI_INT1_N 25
286#define UI_INT2_N 34
287#define UI_INT3_N 14
288/*
289FM GPIO is GPIO 18 on PMIC 8058.
290As the index starts from 0 in the PMIC driver, and hence 17
291corresponds to GPIO 18 on PMIC 8058.
292*/
293#define FM_GPIO 17
294
295#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
296static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
297static void *sdc2_status_notify_cb_devid;
298#endif
299
300#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
301static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
302static void *sdc5_status_notify_cb_devid;
303#endif
304
305static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
306 [0] = {
307 .reg_base_addr = MSM_SAW0_BASE,
308
309#ifdef CONFIG_MSM_AVS_HW
310 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
311#endif
312 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
313 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
314 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
315 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
316
317 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
318 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
319 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
320
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
322 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
323 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
324
325 .awake_vlevel = 0x94,
326 .retention_vlevel = 0x81,
327 .collapse_vlevel = 0x20,
328 .retention_mid_vlevel = 0x94,
329 .collapse_mid_vlevel = 0x8C,
330
331 .vctl_timeout_us = 50,
332 },
333
334 [1] = {
335 .reg_base_addr = MSM_SAW1_BASE,
336
337#ifdef CONFIG_MSM_AVS_HW
338 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
339#endif
340 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
341 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
342 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
343 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
344
345 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
346 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
347 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
348
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
350 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
351 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
352
353 .awake_vlevel = 0x94,
354 .retention_vlevel = 0x81,
355 .collapse_vlevel = 0x20,
356 .retention_mid_vlevel = 0x94,
357 .collapse_mid_vlevel = 0x8C,
358
359 .vctl_timeout_us = 50,
360 },
361};
362
363static struct msm_spm_platform_data msm_spm_data[] __initdata = {
364 [0] = {
365 .reg_base_addr = MSM_SAW0_BASE,
366
367#ifdef CONFIG_MSM_AVS_HW
368 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
369#endif
370 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
371 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
372 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
373 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
374
375 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
376 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
377 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
378
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
380 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
381 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
382
383 .awake_vlevel = 0xA0,
384 .retention_vlevel = 0x89,
385 .collapse_vlevel = 0x20,
386 .retention_mid_vlevel = 0x89,
387 .collapse_mid_vlevel = 0x89,
388
389 .vctl_timeout_us = 50,
390 },
391
392 [1] = {
393 .reg_base_addr = MSM_SAW1_BASE,
394
395#ifdef CONFIG_MSM_AVS_HW
396 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
397#endif
398 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
399 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
400 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
401 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
402
403 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
404 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
405 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
406
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
408 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
409 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
410
411 .awake_vlevel = 0xA0,
412 .retention_vlevel = 0x89,
413 .collapse_vlevel = 0x20,
414 .retention_mid_vlevel = 0x89,
415 .collapse_mid_vlevel = 0x89,
416
417 .vctl_timeout_us = 50,
418 },
419};
420
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700421/*
422 * Consumer specific regulator names:
423 * regulator name consumer dev_name
424 */
425static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
426 REGULATOR_SUPPLY("8901_s0", NULL),
427};
428static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
429 REGULATOR_SUPPLY("8901_s1", NULL),
430};
431
432static struct regulator_init_data saw_s0_init_data = {
433 .constraints = {
434 .name = "8901_s0",
435 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700436 .min_uV = 800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700437 .max_uV = 1250000,
438 },
439 .consumer_supplies = vreg_consumers_8901_S0,
440 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
441};
442
443static struct regulator_init_data saw_s1_init_data = {
444 .constraints = {
445 .name = "8901_s1",
446 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700447 .min_uV = 800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700448 .max_uV = 1250000,
449 },
450 .consumer_supplies = vreg_consumers_8901_S1,
451 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
452};
453
454static struct platform_device msm_device_saw_s0 = {
455 .name = "saw-regulator",
456 .id = 0,
457 .dev = {
458 .platform_data = &saw_s0_init_data,
459 },
460};
461
462static struct platform_device msm_device_saw_s1 = {
463 .name = "saw-regulator",
464 .id = 1,
465 .dev = {
466 .platform_data = &saw_s1_init_data,
467 },
468};
469
470/*
471 * The smc91x configuration varies depending on platform.
472 * The resources data structure is filled in at runtime.
473 */
474static struct resource smc91x_resources[] = {
475 [0] = {
476 .flags = IORESOURCE_MEM,
477 },
478 [1] = {
479 .flags = IORESOURCE_IRQ,
480 },
481};
482
483static struct platform_device smc91x_device = {
484 .name = "smc91x",
485 .id = 0,
486 .num_resources = ARRAY_SIZE(smc91x_resources),
487 .resource = smc91x_resources,
488};
489
490static struct resource smsc911x_resources[] = {
491 [0] = {
492 .flags = IORESOURCE_MEM,
493 .start = 0x1b800000,
494 .end = 0x1b8000ff
495 },
496 [1] = {
497 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
498 },
499};
500
501static struct smsc911x_platform_config smsc911x_config = {
502 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
503 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
504 .flags = SMSC911X_USE_16BIT,
505 .has_reset_gpio = 1,
506 .reset_gpio = GPIO_ETHERNET_RESET_N
507};
508
509static struct platform_device smsc911x_device = {
510 .name = "smsc911x",
511 .id = 0,
512 .num_resources = ARRAY_SIZE(smsc911x_resources),
513 .resource = smsc911x_resources,
514 .dev = {
515 .platform_data = &smsc911x_config
516 }
517};
518
519#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
520 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
521 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
522 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
523
524#define QCE_SIZE 0x10000
525#define QCE_0_BASE 0x18500000
526
527#define QCE_HW_KEY_SUPPORT 0
528#define QCE_SHA_HMAC_SUPPORT 0
529#define QCE_SHARE_CE_RESOURCE 2
530#define QCE_CE_SHARED 1
531
532static struct resource qcrypto_resources[] = {
533 [0] = {
534 .start = QCE_0_BASE,
535 .end = QCE_0_BASE + QCE_SIZE - 1,
536 .flags = IORESOURCE_MEM,
537 },
538 [1] = {
539 .name = "crypto_channels",
540 .start = DMOV_CE_IN_CHAN,
541 .end = DMOV_CE_OUT_CHAN,
542 .flags = IORESOURCE_DMA,
543 },
544 [2] = {
545 .name = "crypto_crci_in",
546 .start = DMOV_CE_IN_CRCI,
547 .end = DMOV_CE_IN_CRCI,
548 .flags = IORESOURCE_DMA,
549 },
550 [3] = {
551 .name = "crypto_crci_out",
552 .start = DMOV_CE_OUT_CRCI,
553 .end = DMOV_CE_OUT_CRCI,
554 .flags = IORESOURCE_DMA,
555 },
556 [4] = {
557 .name = "crypto_crci_hash",
558 .start = DMOV_CE_HASH_CRCI,
559 .end = DMOV_CE_HASH_CRCI,
560 .flags = IORESOURCE_DMA,
561 },
562};
563
564static struct resource qcedev_resources[] = {
565 [0] = {
566 .start = QCE_0_BASE,
567 .end = QCE_0_BASE + QCE_SIZE - 1,
568 .flags = IORESOURCE_MEM,
569 },
570 [1] = {
571 .name = "crypto_channels",
572 .start = DMOV_CE_IN_CHAN,
573 .end = DMOV_CE_OUT_CHAN,
574 .flags = IORESOURCE_DMA,
575 },
576 [2] = {
577 .name = "crypto_crci_in",
578 .start = DMOV_CE_IN_CRCI,
579 .end = DMOV_CE_IN_CRCI,
580 .flags = IORESOURCE_DMA,
581 },
582 [3] = {
583 .name = "crypto_crci_out",
584 .start = DMOV_CE_OUT_CRCI,
585 .end = DMOV_CE_OUT_CRCI,
586 .flags = IORESOURCE_DMA,
587 },
588 [4] = {
589 .name = "crypto_crci_hash",
590 .start = DMOV_CE_HASH_CRCI,
591 .end = DMOV_CE_HASH_CRCI,
592 .flags = IORESOURCE_DMA,
593 },
594};
595
596#endif
597
598#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
599 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
600
601static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
602 .ce_shared = QCE_CE_SHARED,
603 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
604 .hw_key_support = QCE_HW_KEY_SUPPORT,
605 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800606 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700607};
608
609static struct platform_device qcrypto_device = {
610 .name = "qcrypto",
611 .id = 0,
612 .num_resources = ARRAY_SIZE(qcrypto_resources),
613 .resource = qcrypto_resources,
614 .dev = {
615 .coherent_dma_mask = DMA_BIT_MASK(32),
616 .platform_data = &qcrypto_ce_hw_suppport,
617 },
618};
619#endif
620
621#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
622 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
623
624static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
625 .ce_shared = QCE_CE_SHARED,
626 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
627 .hw_key_support = QCE_HW_KEY_SUPPORT,
628 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800629 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700630};
631
632static struct platform_device qcedev_device = {
633 .name = "qce",
634 .id = 0,
635 .num_resources = ARRAY_SIZE(qcedev_resources),
636 .resource = qcedev_resources,
637 .dev = {
638 .coherent_dma_mask = DMA_BIT_MASK(32),
639 .platform_data = &qcedev_ce_hw_suppport,
640 },
641};
642#endif
643
644#if defined(CONFIG_HAPTIC_ISA1200) || \
645 defined(CONFIG_HAPTIC_ISA1200_MODULE)
646
647static const char *vregs_isa1200_name[] = {
648 "8058_s3",
649 "8901_l4",
650};
651
652static const int vregs_isa1200_val[] = {
653 1800000,/* uV */
654 2600000,
655};
656static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
657static struct msm_xo_voter *xo_handle_a1;
658
659static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800660{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700661 int i, rc = 0;
662
663 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
664 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
665 regulator_disable(vregs_isa1200[i]);
666 if (rc < 0) {
667 pr_err("%s: vreg %s %s failed (%d)\n",
668 __func__, vregs_isa1200_name[i],
669 vreg_on ? "enable" : "disable", rc);
670 goto vreg_fail;
671 }
672 }
673
674 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
675 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
676 if (rc < 0) {
677 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
678 __func__, vreg_on ? "" : "de-", rc);
679 goto vreg_fail;
680 }
681 return 0;
682
683vreg_fail:
684 while (i--)
685 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
686 regulator_disable(vregs_isa1200[i]);
687 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800688}
689
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700690static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800691{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800693
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700694 if (enable == true) {
695 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
696 vregs_isa1200[i] = regulator_get(NULL,
697 vregs_isa1200_name[i]);
698 if (IS_ERR(vregs_isa1200[i])) {
699 pr_err("%s: regulator get of %s failed (%ld)\n",
700 __func__, vregs_isa1200_name[i],
701 PTR_ERR(vregs_isa1200[i]));
702 rc = PTR_ERR(vregs_isa1200[i]);
703 goto vreg_get_fail;
704 }
705 rc = regulator_set_voltage(vregs_isa1200[i],
706 vregs_isa1200_val[i], vregs_isa1200_val[i]);
707 if (rc) {
708 pr_err("%s: regulator_set_voltage(%s) failed\n",
709 __func__, vregs_isa1200_name[i]);
710 goto vreg_get_fail;
711 }
712 }
Steve Muckle9161d302010-02-11 11:50:40 -0800713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700714 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
715 if (rc) {
716 pr_err("%s: unable to request gpio %d (%d)\n",
717 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
718 goto vreg_get_fail;
719 }
Steve Muckle9161d302010-02-11 11:50:40 -0800720
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700721 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
722 if (rc) {
723 pr_err("%s: Unable to set direction\n", __func__);;
724 goto free_gpio;
725 }
726
727 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
728 if (IS_ERR(xo_handle_a1)) {
729 rc = PTR_ERR(xo_handle_a1);
730 pr_err("%s: failed to get the handle for A1(%d)\n",
731 __func__, rc);
732 goto gpio_set_dir;
733 }
734 } else {
735 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
736 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
737
738 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
739 regulator_put(vregs_isa1200[i]);
740
741 msm_xo_put(xo_handle_a1);
742 }
743
744 return 0;
745gpio_set_dir:
746 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
747free_gpio:
748 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
749vreg_get_fail:
750 while (i)
751 regulator_put(vregs_isa1200[--i]);
752 return rc;
753}
754
755#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530756#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757static struct isa1200_platform_data isa1200_1_pdata = {
758 .name = "vibrator",
759 .power_on = isa1200_power,
760 .dev_setup = isa1200_dev_setup,
761 /*gpio to enable haptic*/
762 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530763 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700764 .max_timeout = 15000,
765 .mode_ctrl = PWM_GEN_MODE,
766 .pwm_fd = {
767 .pwm_div = 256,
768 },
769 .is_erm = false,
770 .smart_en = true,
771 .ext_clk_en = true,
772 .chip_en = 1,
773};
774
775static struct i2c_board_info msm_isa1200_board_info[] = {
776 {
777 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
778 .platform_data = &isa1200_1_pdata,
779 },
780};
781#endif
782
783#if defined(CONFIG_BATTERY_BQ27520) || \
784 defined(CONFIG_BATTERY_BQ27520_MODULE)
785static struct bq27520_platform_data bq27520_pdata = {
786 .name = "fuel-gauge",
787 .vreg_name = "8058_s3",
788 .vreg_value = 1800000,
789 .soc_int = GPIO_BATT_GAUGE_INT_N,
790 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
791 .chip_en = GPIO_BATT_GAUGE_EN,
792 .enable_dlog = 0, /* if enable coulomb counter logger */
793};
794
795static struct i2c_board_info msm_bq27520_board_info[] = {
796 {
797 I2C_BOARD_INFO("bq27520", 0xaa>>1),
798 .platform_data = &bq27520_pdata,
799 },
800};
801#endif
802
803static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
804 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
805 .idle_supported = 1,
806 .suspend_supported = 1,
807 .idle_enabled = 0,
808 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700809 },
810
811 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
812 .idle_supported = 1,
813 .suspend_supported = 1,
814 .idle_enabled = 0,
815 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816 },
817
818 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
819 .idle_supported = 1,
820 .suspend_supported = 1,
821 .idle_enabled = 1,
822 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700823 },
824
825 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
826 .idle_supported = 1,
827 .suspend_supported = 1,
828 .idle_enabled = 0,
829 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700830 },
831
832 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
833 .idle_supported = 1,
834 .suspend_supported = 1,
835 .idle_enabled = 0,
836 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837 },
838
839 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
840 .idle_supported = 1,
841 .suspend_supported = 1,
842 .idle_enabled = 1,
843 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700844 },
845};
846
847static struct msm_cpuidle_state msm_cstates[] __initdata = {
848 {0, 0, "C0", "WFI",
849 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
850
851 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
852 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
853
854 {0, 2, "C2", "POWER_COLLAPSE",
855 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
856
857 {1, 0, "C0", "WFI",
858 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
859
860 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
861 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
862};
863
864static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
865 {
866 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
867 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
868 true,
869 1, 8000, 100000, 1,
870 },
871
872 {
873 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
874 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
875 true,
876 1500, 5000, 60100000, 3000,
877 },
878
879 {
880 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
881 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
882 false,
883 1800, 5000, 60350000, 3500,
884 },
885 {
886 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
887 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
888 false,
889 3800, 4500, 65350000, 5500,
890 },
891
892 {
893 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
894 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
895 false,
896 2800, 2500, 66850000, 4800,
897 },
898
899 {
900 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
901 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
902 false,
903 4800, 2000, 71850000, 6800,
904 },
905
906 {
907 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
908 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
909 false,
910 6800, 500, 75850000, 8800,
911 },
912
913 {
914 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
915 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
916 false,
917 7800, 0, 76350000, 9800,
918 },
919};
920
Praveen Chidambaram78499012011-11-01 17:15:17 -0600921static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
922 .levels = &msm_rpmrs_levels[0],
923 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
924 .vdd_mem_levels = {
925 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
926 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
927 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
928 [MSM_RPMRS_VDD_MEM_MAX] = 1250,
929 },
930 .vdd_dig_levels = {
931 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
932 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
933 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
934 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
935 },
936 .vdd_mask = 0xFFF,
937 .rpmrs_target_id = {
938 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
939 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
940 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
941 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
942 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
943 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
944 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
945 },
946};
947
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600948static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
949 .mode = MSM_PM_BOOT_CONFIG_TZ,
950};
951
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700952#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
953
954#define ISP1763_INT_GPIO 117
955#define ISP1763_RST_GPIO 152
956static struct resource isp1763_resources[] = {
957 [0] = {
958 .flags = IORESOURCE_MEM,
959 .start = 0x1D000000,
960 .end = 0x1D005FFF, /* 24KB */
961 },
962 [1] = {
963 .flags = IORESOURCE_IRQ,
964 },
965};
966static void __init msm8x60_cfg_isp1763(void)
967{
968 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
969 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
970}
971
972static int isp1763_setup_gpio(int enable)
973{
974 int status = 0;
975
976 if (enable) {
977 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
978 if (status) {
979 pr_err("%s:Failed to request GPIO %d\n",
980 __func__, ISP1763_INT_GPIO);
981 return status;
982 }
983 status = gpio_direction_input(ISP1763_INT_GPIO);
984 if (status) {
985 pr_err("%s:Failed to configure GPIO %d\n",
986 __func__, ISP1763_INT_GPIO);
987 goto gpio_free_int;
988 }
989 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
990 if (status) {
991 pr_err("%s:Failed to request GPIO %d\n",
992 __func__, ISP1763_RST_GPIO);
993 goto gpio_free_int;
994 }
995 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
996 if (status) {
997 pr_err("%s:Failed to configure GPIO %d\n",
998 __func__, ISP1763_RST_GPIO);
999 goto gpio_free_rst;
1000 }
1001 pr_debug("\nISP GPIO configuration done\n");
1002 return status;
1003 }
1004
1005gpio_free_rst:
1006 gpio_free(ISP1763_RST_GPIO);
1007gpio_free_int:
1008 gpio_free(ISP1763_INT_GPIO);
1009
1010 return status;
1011}
1012static struct isp1763_platform_data isp1763_pdata = {
1013 .reset_gpio = ISP1763_RST_GPIO,
1014 .setup_gpio = isp1763_setup_gpio
1015};
1016
1017static struct platform_device isp1763_device = {
1018 .name = "isp1763_usb",
1019 .num_resources = ARRAY_SIZE(isp1763_resources),
1020 .resource = isp1763_resources,
1021 .dev = {
1022 .platform_data = &isp1763_pdata
1023 }
1024};
1025#endif
1026
1027#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301028static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001029static struct regulator *ldo6_3p3;
1030static struct regulator *ldo7_1p8;
1031static struct regulator *vdd_cx;
1032#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +05301033#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001034notify_vbus_state notify_vbus_state_func_ptr;
1035static int usb_phy_susp_dig_vol = 750000;
1036static int pmic_id_notif_supported;
1037
1038#ifdef CONFIG_USB_EHCI_MSM_72K
1039#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
1040struct delayed_work pmic_id_det;
1041
1042static int __init usb_id_pin_rework_setup(char *support)
1043{
1044 if (strncmp(support, "true", 4) == 0)
1045 pmic_id_notif_supported = 1;
1046
1047 return 1;
1048}
1049__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
1050
1051static void pmic_id_detect(struct work_struct *w)
1052{
1053 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
1054 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
1055
1056 if (notify_vbus_state_func_ptr)
1057 (*notify_vbus_state_func_ptr) (val);
1058}
1059
1060static irqreturn_t pmic_id_on_irq(int irq, void *data)
1061{
1062 /*
1063 * Spurious interrupts are observed on pmic gpio line
1064 * even though there is no state change on USB ID. Schedule the
1065 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001066 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001067 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001068
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001069 return IRQ_HANDLED;
1070}
1071
Anji jonnalaae745e92011-11-14 18:34:31 +05301072static int msm_hsusb_phy_id_setup_init(int init)
1073{
1074 unsigned ret;
1075
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301076 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1077 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1078 .level = PM8901_MPP_DIG_LEVEL_L5,
1079 };
1080
Anji jonnalaae745e92011-11-14 18:34:31 +05301081 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301082 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1083 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1084 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301085 if (ret < 0)
1086 pr_err("%s:MPP2 configuration failed\n", __func__);
1087 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301088 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1089 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1090 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301091 if (ret < 0)
1092 pr_err("%s:MPP2 un config failed\n", __func__);
1093 }
1094 return ret;
1095}
1096
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001097static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1098{
1099 unsigned ret = -ENODEV;
1100
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301101 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301102 .direction = PM_GPIO_DIR_IN,
1103 .pull = PM_GPIO_PULL_UP_1P5,
1104 .function = PM_GPIO_FUNC_NORMAL,
1105 .vin_sel = 2,
1106 .inv_int_pol = 0,
1107 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301108 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301109 .direction = PM_GPIO_DIR_IN,
1110 .pull = PM_GPIO_PULL_NO,
1111 .function = PM_GPIO_FUNC_NORMAL,
1112 .vin_sel = 2,
1113 .inv_int_pol = 0,
1114 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001115 if (!callback)
1116 return -EINVAL;
1117
1118 if (machine_is_msm8x60_fluid())
1119 return -ENOTSUPP;
1120
1121 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1122 pr_debug("%s: USB_ID pin is not routed to PMIC"
1123 "on V1 surf/ffa\n", __func__);
1124 return -ENOTSUPP;
1125 }
1126
Manu Gautam62158eb2011-11-24 16:20:46 +05301127 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1128 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001129 pr_debug("%s: USB_ID is not routed to PMIC"
1130 "on V2 ffa\n", __func__);
1131 return -ENOTSUPP;
1132 }
1133
1134 usb_phy_susp_dig_vol = 500000;
1135
1136 if (init) {
1137 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301138 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301139 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1140 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301141 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301142 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301143 __func__, ret);
1144 return ret;
1145 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001146 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1147 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1148 "msm_otg_id", NULL);
1149 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001150 pr_err("%s:pmic_usb_id interrupt registration failed",
1151 __func__);
1152 return ret;
1153 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301154 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001155 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301156 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001157 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301158 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1159 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301160 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301161 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301162 __func__, ret);
1163 return ret;
1164 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301165 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001166 cancel_delayed_work_sync(&pmic_id_det);
1167 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001168 }
1169 return 0;
1170}
1171#endif
1172
1173#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1174#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1175static int msm_hsusb_init_vddcx(int init)
1176{
1177 int ret = 0;
1178
1179 if (init) {
1180 vdd_cx = regulator_get(NULL, "8058_s1");
1181 if (IS_ERR(vdd_cx)) {
1182 return PTR_ERR(vdd_cx);
1183 }
1184
1185 ret = regulator_set_voltage(vdd_cx,
1186 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1187 USB_PHY_MAX_VDD_DIG_VOL);
1188 if (ret) {
1189 pr_err("%s: unable to set the voltage for regulator"
1190 "vdd_cx\n", __func__);
1191 regulator_put(vdd_cx);
1192 return ret;
1193 }
1194
1195 ret = regulator_enable(vdd_cx);
1196 if (ret) {
1197 pr_err("%s: unable to enable regulator"
1198 "vdd_cx\n", __func__);
1199 regulator_put(vdd_cx);
1200 }
1201 } else {
1202 ret = regulator_disable(vdd_cx);
1203 if (ret) {
1204 pr_err("%s: Unable to disable the regulator:"
1205 "vdd_cx\n", __func__);
1206 return ret;
1207 }
1208
1209 regulator_put(vdd_cx);
1210 }
1211
1212 return ret;
1213}
1214
1215static int msm_hsusb_config_vddcx(int high)
1216{
1217 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1218 int min_vol;
1219 int ret;
1220
1221 if (high)
1222 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1223 else
1224 min_vol = usb_phy_susp_dig_vol;
1225
1226 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1227 if (ret) {
1228 pr_err("%s: unable to set the voltage for regulator"
1229 "vdd_cx\n", __func__);
1230 return ret;
1231 }
1232
1233 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1234
1235 return ret;
1236}
1237
1238#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1239#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1240#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1241#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1242
1243#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1244#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1245#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1246#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1247static int msm_hsusb_ldo_init(int init)
1248{
1249 int rc = 0;
1250
1251 if (init) {
1252 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1253 if (IS_ERR(ldo6_3p3))
1254 return PTR_ERR(ldo6_3p3);
1255
1256 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1257 if (IS_ERR(ldo7_1p8)) {
1258 rc = PTR_ERR(ldo7_1p8);
1259 goto put_3p3;
1260 }
1261
1262 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1263 USB_PHY_3P3_VOL_MAX);
1264 if (rc) {
1265 pr_err("%s: Unable to set voltage level for"
1266 "ldo6_3p3 regulator\n", __func__);
1267 goto put_1p8;
1268 }
1269 rc = regulator_enable(ldo6_3p3);
1270 if (rc) {
1271 pr_err("%s: Unable to enable the regulator:"
1272 "ldo6_3p3\n", __func__);
1273 goto put_1p8;
1274 }
1275 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1276 USB_PHY_1P8_VOL_MAX);
1277 if (rc) {
1278 pr_err("%s: Unable to set voltage level for"
1279 "ldo7_1p8 regulator\n", __func__);
1280 goto disable_3p3;
1281 }
1282 rc = regulator_enable(ldo7_1p8);
1283 if (rc) {
1284 pr_err("%s: Unable to enable the regulator:"
1285 "ldo7_1p8\n", __func__);
1286 goto disable_3p3;
1287 }
1288
1289 return 0;
1290 }
1291
1292 regulator_disable(ldo7_1p8);
1293disable_3p3:
1294 regulator_disable(ldo6_3p3);
1295put_1p8:
1296 regulator_put(ldo7_1p8);
1297put_3p3:
1298 regulator_put(ldo6_3p3);
1299 return rc;
1300}
1301
1302static int msm_hsusb_ldo_enable(int on)
1303{
1304 int ret = 0;
1305
1306 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1307 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1308 return -ENODEV;
1309 }
1310
1311 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1312 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1313 return -ENODEV;
1314 }
1315
1316 if (on) {
1317 ret = regulator_set_optimum_mode(ldo7_1p8,
1318 USB_PHY_1P8_HPM_LOAD);
1319 if (ret < 0) {
1320 pr_err("%s: Unable to set HPM of the regulator:"
1321 "ldo7_1p8\n", __func__);
1322 return ret;
1323 }
1324 ret = regulator_set_optimum_mode(ldo6_3p3,
1325 USB_PHY_3P3_HPM_LOAD);
1326 if (ret < 0) {
1327 pr_err("%s: Unable to set HPM of the regulator:"
1328 "ldo6_3p3\n", __func__);
1329 regulator_set_optimum_mode(ldo7_1p8,
1330 USB_PHY_1P8_LPM_LOAD);
1331 return ret;
1332 }
1333 } else {
1334 ret = regulator_set_optimum_mode(ldo7_1p8,
1335 USB_PHY_1P8_LPM_LOAD);
1336 if (ret < 0)
1337 pr_err("%s: Unable to set LPM of the regulator:"
1338 "ldo7_1p8\n", __func__);
1339 ret = regulator_set_optimum_mode(ldo6_3p3,
1340 USB_PHY_3P3_LPM_LOAD);
1341 if (ret < 0)
1342 pr_err("%s: Unable to set LPM of the regulator:"
1343 "ldo6_3p3\n", __func__);
1344 }
1345
1346 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1347 return ret < 0 ? ret : 0;
1348 }
1349#endif
1350#ifdef CONFIG_USB_EHCI_MSM_72K
1351#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1352static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1353{
1354 static int vbus_is_on;
1355
1356 /* If VBUS is already on (or off), do nothing. */
1357 if (on == vbus_is_on)
1358 return;
1359 smb137b_otg_power(on);
1360 vbus_is_on = on;
1361}
1362#endif
1363static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1364{
1365 static struct regulator *votg_5v_switch;
1366 static struct regulator *ext_5v_reg;
1367 static int vbus_is_on;
1368
1369 /* If VBUS is already on (or off), do nothing. */
1370 if (on == vbus_is_on)
1371 return;
1372
1373 if (!votg_5v_switch) {
1374 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1375 if (IS_ERR(votg_5v_switch)) {
1376 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1377 return;
1378 }
1379 }
1380 if (!ext_5v_reg) {
1381 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1382 if (IS_ERR(ext_5v_reg)) {
1383 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1384 return;
1385 }
1386 }
1387 if (on) {
1388 if (regulator_enable(ext_5v_reg)) {
1389 pr_err("%s: Unable to enable the regulator:"
1390 " ext_5v_reg\n", __func__);
1391 return;
1392 }
1393 if (regulator_enable(votg_5v_switch)) {
1394 pr_err("%s: Unable to enable the regulator:"
1395 " votg_5v_switch\n", __func__);
1396 return;
1397 }
1398 } else {
1399 if (regulator_disable(votg_5v_switch))
1400 pr_err("%s: Unable to enable the regulator:"
1401 " votg_5v_switch\n", __func__);
1402 if (regulator_disable(ext_5v_reg))
1403 pr_err("%s: Unable to enable the regulator:"
1404 " ext_5v_reg\n", __func__);
1405 }
1406
1407 vbus_is_on = on;
1408}
1409
1410static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1411 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1412 .power_budget = 390,
1413};
1414#endif
1415
1416#ifdef CONFIG_BATTERY_MSM8X60
1417static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1418 int init)
1419{
1420 int ret = -ENOTSUPP;
1421
1422#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1423 if (machine_is_msm8x60_fluid()) {
1424 if (init)
1425 msm_charger_register_vbus_sn(callback);
1426 else
1427 msm_charger_unregister_vbus_sn(callback);
1428 return 0;
1429 }
1430#endif
1431 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1432 * hence, irrespective of either peripheral only mode or
1433 * OTG (host and peripheral) modes, can depend on pmic for
1434 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001435 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001436 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1437 && (machine_is_msm8x60_surf() ||
1438 pmic_id_notif_supported)) {
1439 if (init)
1440 ret = msm_charger_register_vbus_sn(callback);
1441 else {
1442 msm_charger_unregister_vbus_sn(callback);
1443 ret = 0;
1444 }
1445 } else {
1446#if !defined(CONFIG_USB_EHCI_MSM_72K)
1447 if (init)
1448 ret = msm_charger_register_vbus_sn(callback);
1449 else {
1450 msm_charger_unregister_vbus_sn(callback);
1451 ret = 0;
1452 }
1453#endif
1454 }
1455 return ret;
1456}
1457#endif
1458
1459#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
1460static struct msm_otg_platform_data msm_otg_pdata = {
1461 /* if usb link is in sps there is no need for
1462 * usb pclk as dayatona fabric clock will be
1463 * used instead
1464 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001465 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1466 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1467 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301468 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001469#ifdef CONFIG_USB_EHCI_MSM_72K
1470 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301471 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001472#endif
1473#ifdef CONFIG_USB_EHCI_MSM_72K
1474 .vbus_power = msm_hsusb_vbus_power,
1475#endif
1476#ifdef CONFIG_BATTERY_MSM8X60
1477 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1478#endif
1479 .ldo_init = msm_hsusb_ldo_init,
1480 .ldo_enable = msm_hsusb_ldo_enable,
1481 .config_vddcx = msm_hsusb_config_vddcx,
1482 .init_vddcx = msm_hsusb_init_vddcx,
1483#ifdef CONFIG_BATTERY_MSM8X60
1484 .chg_vbus_draw = msm_charger_vbus_draw,
1485#endif
1486};
1487#endif
1488
1489#ifdef CONFIG_USB_GADGET_MSM_72K
1490static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1491 .is_phy_status_timer_on = 1,
1492};
1493#endif
1494
1495#ifdef CONFIG_USB_G_ANDROID
1496
1497#define PID_MAGIC_ID 0x71432909
1498#define SERIAL_NUM_MAGIC_ID 0x61945374
1499#define SERIAL_NUMBER_LENGTH 127
1500#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1501
1502struct magic_num_struct {
1503 uint32_t pid;
1504 uint32_t serial_num;
1505};
1506
1507struct dload_struct {
1508 uint32_t reserved1;
1509 uint32_t reserved2;
1510 uint32_t reserved3;
1511 uint16_t reserved4;
1512 uint16_t pid;
1513 char serial_number[SERIAL_NUMBER_LENGTH];
1514 uint16_t reserved5;
1515 struct magic_num_struct
1516 magic_struct;
1517};
1518
1519static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1520{
1521 struct dload_struct __iomem *dload = 0;
1522
1523 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1524 if (!dload) {
1525 pr_err("%s: cannot remap I/O memory region: %08x\n",
1526 __func__, DLOAD_USB_BASE_ADD);
1527 return -ENXIO;
1528 }
1529
1530 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1531 __func__, dload, pid, snum);
1532 /* update pid */
1533 dload->magic_struct.pid = PID_MAGIC_ID;
1534 dload->pid = pid;
1535
1536 /* update serial number */
1537 dload->magic_struct.serial_num = 0;
1538 if (!snum)
1539 return 0;
1540
1541 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1542 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1543 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1544
1545 iounmap(dload);
1546
1547 return 0;
1548}
1549
1550static struct android_usb_platform_data android_usb_pdata = {
1551 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1552};
1553
1554static struct platform_device android_usb_device = {
1555 .name = "android_usb",
1556 .id = -1,
1557 .dev = {
1558 .platform_data = &android_usb_pdata,
1559 },
1560};
1561
1562
1563#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001565#ifdef CONFIG_MSM_VPE
1566static struct resource msm_vpe_resources[] = {
1567 {
1568 .start = 0x05300000,
1569 .end = 0x05300000 + SZ_1M - 1,
1570 .flags = IORESOURCE_MEM,
1571 },
1572 {
1573 .start = INT_VPE,
1574 .end = INT_VPE,
1575 .flags = IORESOURCE_IRQ,
1576 },
1577};
1578
1579static struct platform_device msm_vpe_device = {
1580 .name = "msm_vpe",
1581 .id = 0,
1582 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1583 .resource = msm_vpe_resources,
1584};
1585#endif
1586
1587#ifdef CONFIG_MSM_CAMERA
1588#ifdef CONFIG_MSM_CAMERA_FLASH
1589#define VFE_CAMIF_TIMER1_GPIO 29
1590#define VFE_CAMIF_TIMER2_GPIO 30
1591#define VFE_CAMIF_TIMER3_GPIO_INT 31
1592#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1593static struct msm_camera_sensor_flash_src msm_flash_src = {
1594 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1595 ._fsrc.pmic_src.num_of_src = 2,
1596 ._fsrc.pmic_src.low_current = 100,
1597 ._fsrc.pmic_src.high_current = 300,
1598 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1599 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1600 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1601};
1602#ifdef CONFIG_IMX074
1603static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1604 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1605 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1606 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1607 .flash_recharge_duration = 50000,
1608 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1609};
1610#endif
1611#endif
1612
1613int msm_cam_gpio_tbl[] = {
1614 32,/*CAMIF_MCLK*/
1615 47,/*CAMIF_I2C_DATA*/
1616 48,/*CAMIF_I2C_CLK*/
1617 105,/*STANDBY*/
1618};
1619
1620enum msm_cam_stat{
1621 MSM_CAM_OFF,
1622 MSM_CAM_ON,
1623};
1624
1625static int config_gpio_table(enum msm_cam_stat stat)
1626{
1627 int rc = 0, i = 0;
1628 if (stat == MSM_CAM_ON) {
1629 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1630 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1631 if (unlikely(rc < 0)) {
1632 pr_err("%s not able to get gpio\n", __func__);
1633 for (i--; i >= 0; i--)
1634 gpio_free(msm_cam_gpio_tbl[i]);
1635 break;
1636 }
1637 }
1638 } else {
1639 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1640 gpio_free(msm_cam_gpio_tbl[i]);
1641 }
1642 return rc;
1643}
1644
1645static struct msm_camera_sensor_platform_info sensor_board_info = {
1646 .mount_angle = 0
1647};
1648
1649/*external regulator VREG_5V*/
1650static struct regulator *reg_flash_5V;
1651
1652static int config_camera_on_gpios_fluid(void)
1653{
1654 int rc = 0;
1655
1656 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1657 if (IS_ERR(reg_flash_5V)) {
1658 pr_err("'%s' regulator not found, rc=%ld\n",
1659 "8901_mpp0", IS_ERR(reg_flash_5V));
1660 return -ENODEV;
1661 }
1662
1663 rc = regulator_enable(reg_flash_5V);
1664 if (rc) {
1665 pr_err("'%s' regulator enable failed, rc=%d\n",
1666 "8901_mpp0", rc);
1667 regulator_put(reg_flash_5V);
1668 return rc;
1669 }
1670
1671#ifdef CONFIG_IMX074
1672 sensor_board_info.mount_angle = 90;
1673#endif
1674 rc = config_gpio_table(MSM_CAM_ON);
1675 if (rc < 0) {
1676 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1677 "failed\n", __func__);
1678 return rc;
1679 }
1680
1681 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1682 if (rc < 0) {
1683 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1684 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1685 regulator_disable(reg_flash_5V);
1686 regulator_put(reg_flash_5V);
1687 return rc;
1688 }
1689 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1690 msleep(20);
1691 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1692
1693
1694 /*Enable LED_FLASH_EN*/
1695 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1696 if (rc < 0) {
1697 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1698 "failed\n", __func__, GPIO_LED_FLASH_EN);
1699
1700 regulator_disable(reg_flash_5V);
1701 regulator_put(reg_flash_5V);
1702 config_gpio_table(MSM_CAM_OFF);
1703 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1704 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1705 return rc;
1706 }
1707 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1708 msleep(20);
1709 return rc;
1710}
1711
1712
1713static void config_camera_off_gpios_fluid(void)
1714{
1715 regulator_disable(reg_flash_5V);
1716 regulator_put(reg_flash_5V);
1717
1718 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1719 gpio_free(GPIO_LED_FLASH_EN);
1720
1721 config_gpio_table(MSM_CAM_OFF);
1722
1723 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1724 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1725}
1726static int config_camera_on_gpios(void)
1727{
1728 int rc = 0;
1729
1730 if (machine_is_msm8x60_fluid())
1731 return config_camera_on_gpios_fluid();
1732
1733 rc = config_gpio_table(MSM_CAM_ON);
1734 if (rc < 0) {
1735 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1736 "failed\n", __func__);
1737 return rc;
1738 }
1739
Jilai Wang971f97f2011-07-13 14:25:25 -04001740 if (!machine_is_msm8x60_dragon()) {
1741 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1742 if (rc < 0) {
1743 config_gpio_table(MSM_CAM_OFF);
1744 pr_err("%s: CAMSENSOR gpio %d request"
1745 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1746 return rc;
1747 }
1748 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1749 msleep(20);
1750 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001751 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001752
1753#ifdef CONFIG_MSM_CAMERA_FLASH
1754#ifdef CONFIG_IMX074
1755 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1756 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1757#endif
1758#endif
1759 return rc;
1760}
1761
1762static void config_camera_off_gpios(void)
1763{
1764 if (machine_is_msm8x60_fluid())
1765 return config_camera_off_gpios_fluid();
1766
1767
1768 config_gpio_table(MSM_CAM_OFF);
1769
Jilai Wang971f97f2011-07-13 14:25:25 -04001770 if (!machine_is_msm8x60_dragon()) {
1771 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1772 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1773 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001774}
1775
1776#ifdef CONFIG_QS_S5K4E1
1777
1778#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1779
1780static int config_camera_on_gpios_qs_cam_fluid(void)
1781{
1782 int rc = 0;
1783
1784 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1785 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1786 if (rc < 0) {
1787 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1788 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1789 return rc;
1790 }
1791 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1792 msleep(20);
1793 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1794 msleep(20);
1795
1796 /*
1797 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1798 * to enable 2.7V power to Camera
1799 */
1800 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1801 if (rc < 0) {
1802 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1803 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1804 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1805 gpio_free(QS_CAM_HC37_CAM_PD);
1806 return rc;
1807 }
1808 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1809 msleep(20);
1810 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1811 msleep(20);
1812
1813 rc = config_camera_on_gpios_fluid();
1814 if (rc < 0) {
1815 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1816 " failed\n", __func__);
1817 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1818 gpio_free(QS_CAM_HC37_CAM_PD);
1819 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1820 gpio_free(GPIO_AUX_CAM_2P7_EN);
1821 return rc;
1822 }
1823 return rc;
1824}
1825
1826static void config_camera_off_gpios_qs_cam_fluid(void)
1827{
1828 /*
1829 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1830 * to disable 2.7V power to Camera
1831 */
1832 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1833 gpio_free(GPIO_AUX_CAM_2P7_EN);
1834
1835 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1836 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1837 gpio_free(QS_CAM_HC37_CAM_PD);
1838
1839 config_camera_off_gpios_fluid();
1840 return;
1841}
1842
1843static int config_camera_on_gpios_qs_cam(void)
1844{
1845 int rc = 0;
1846
1847 if (machine_is_msm8x60_fluid())
1848 return config_camera_on_gpios_qs_cam_fluid();
1849
1850 rc = config_camera_on_gpios();
1851 return rc;
1852}
1853
1854static void config_camera_off_gpios_qs_cam(void)
1855{
1856 if (machine_is_msm8x60_fluid())
1857 return config_camera_off_gpios_qs_cam_fluid();
1858
1859 config_camera_off_gpios();
1860 return;
1861}
1862#endif
1863
1864static int config_camera_on_gpios_web_cam(void)
1865{
1866 int rc = 0;
1867 rc = config_gpio_table(MSM_CAM_ON);
1868 if (rc < 0) {
1869 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1870 "failed\n", __func__);
1871 return rc;
1872 }
1873
Jilai Wang53d27a82011-07-13 14:32:58 -04001874 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001875 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1876 if (rc < 0) {
1877 config_gpio_table(MSM_CAM_OFF);
1878 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1879 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1880 return rc;
1881 }
1882 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1883 }
1884 return rc;
1885}
1886
1887static void config_camera_off_gpios_web_cam(void)
1888{
1889 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001890 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1892 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1893 }
1894 return;
1895}
1896
1897#ifdef CONFIG_MSM_BUS_SCALING
1898static struct msm_bus_vectors cam_init_vectors[] = {
1899 {
1900 .src = MSM_BUS_MASTER_VFE,
1901 .dst = MSM_BUS_SLAVE_SMI,
1902 .ab = 0,
1903 .ib = 0,
1904 },
1905 {
1906 .src = MSM_BUS_MASTER_VFE,
1907 .dst = MSM_BUS_SLAVE_EBI_CH0,
1908 .ab = 0,
1909 .ib = 0,
1910 },
1911 {
1912 .src = MSM_BUS_MASTER_VPE,
1913 .dst = MSM_BUS_SLAVE_SMI,
1914 .ab = 0,
1915 .ib = 0,
1916 },
1917 {
1918 .src = MSM_BUS_MASTER_VPE,
1919 .dst = MSM_BUS_SLAVE_EBI_CH0,
1920 .ab = 0,
1921 .ib = 0,
1922 },
1923 {
1924 .src = MSM_BUS_MASTER_JPEG_ENC,
1925 .dst = MSM_BUS_SLAVE_SMI,
1926 .ab = 0,
1927 .ib = 0,
1928 },
1929 {
1930 .src = MSM_BUS_MASTER_JPEG_ENC,
1931 .dst = MSM_BUS_SLAVE_EBI_CH0,
1932 .ab = 0,
1933 .ib = 0,
1934 },
1935};
1936
1937static struct msm_bus_vectors cam_preview_vectors[] = {
1938 {
1939 .src = MSM_BUS_MASTER_VFE,
1940 .dst = MSM_BUS_SLAVE_SMI,
1941 .ab = 0,
1942 .ib = 0,
1943 },
1944 {
1945 .src = MSM_BUS_MASTER_VFE,
1946 .dst = MSM_BUS_SLAVE_EBI_CH0,
1947 .ab = 283115520,
1948 .ib = 452984832,
1949 },
1950 {
1951 .src = MSM_BUS_MASTER_VPE,
1952 .dst = MSM_BUS_SLAVE_SMI,
1953 .ab = 0,
1954 .ib = 0,
1955 },
1956 {
1957 .src = MSM_BUS_MASTER_VPE,
1958 .dst = MSM_BUS_SLAVE_EBI_CH0,
1959 .ab = 0,
1960 .ib = 0,
1961 },
1962 {
1963 .src = MSM_BUS_MASTER_JPEG_ENC,
1964 .dst = MSM_BUS_SLAVE_SMI,
1965 .ab = 0,
1966 .ib = 0,
1967 },
1968 {
1969 .src = MSM_BUS_MASTER_JPEG_ENC,
1970 .dst = MSM_BUS_SLAVE_EBI_CH0,
1971 .ab = 0,
1972 .ib = 0,
1973 },
1974};
1975
1976static struct msm_bus_vectors cam_video_vectors[] = {
1977 {
1978 .src = MSM_BUS_MASTER_VFE,
1979 .dst = MSM_BUS_SLAVE_SMI,
1980 .ab = 283115520,
1981 .ib = 452984832,
1982 },
1983 {
1984 .src = MSM_BUS_MASTER_VFE,
1985 .dst = MSM_BUS_SLAVE_EBI_CH0,
1986 .ab = 283115520,
1987 .ib = 452984832,
1988 },
1989 {
1990 .src = MSM_BUS_MASTER_VPE,
1991 .dst = MSM_BUS_SLAVE_SMI,
1992 .ab = 319610880,
1993 .ib = 511377408,
1994 },
1995 {
1996 .src = MSM_BUS_MASTER_VPE,
1997 .dst = MSM_BUS_SLAVE_EBI_CH0,
1998 .ab = 0,
1999 .ib = 0,
2000 },
2001 {
2002 .src = MSM_BUS_MASTER_JPEG_ENC,
2003 .dst = MSM_BUS_SLAVE_SMI,
2004 .ab = 0,
2005 .ib = 0,
2006 },
2007 {
2008 .src = MSM_BUS_MASTER_JPEG_ENC,
2009 .dst = MSM_BUS_SLAVE_EBI_CH0,
2010 .ab = 0,
2011 .ib = 0,
2012 },
2013};
2014
2015static struct msm_bus_vectors cam_snapshot_vectors[] = {
2016 {
2017 .src = MSM_BUS_MASTER_VFE,
2018 .dst = MSM_BUS_SLAVE_SMI,
2019 .ab = 566231040,
2020 .ib = 905969664,
2021 },
2022 {
2023 .src = MSM_BUS_MASTER_VFE,
2024 .dst = MSM_BUS_SLAVE_EBI_CH0,
2025 .ab = 69984000,
2026 .ib = 111974400,
2027 },
2028 {
2029 .src = MSM_BUS_MASTER_VPE,
2030 .dst = MSM_BUS_SLAVE_SMI,
2031 .ab = 0,
2032 .ib = 0,
2033 },
2034 {
2035 .src = MSM_BUS_MASTER_VPE,
2036 .dst = MSM_BUS_SLAVE_EBI_CH0,
2037 .ab = 0,
2038 .ib = 0,
2039 },
2040 {
2041 .src = MSM_BUS_MASTER_JPEG_ENC,
2042 .dst = MSM_BUS_SLAVE_SMI,
2043 .ab = 320864256,
2044 .ib = 513382810,
2045 },
2046 {
2047 .src = MSM_BUS_MASTER_JPEG_ENC,
2048 .dst = MSM_BUS_SLAVE_EBI_CH0,
2049 .ab = 320864256,
2050 .ib = 513382810,
2051 },
2052};
2053
2054static struct msm_bus_vectors cam_zsl_vectors[] = {
2055 {
2056 .src = MSM_BUS_MASTER_VFE,
2057 .dst = MSM_BUS_SLAVE_SMI,
2058 .ab = 566231040,
2059 .ib = 905969664,
2060 },
2061 {
2062 .src = MSM_BUS_MASTER_VFE,
2063 .dst = MSM_BUS_SLAVE_EBI_CH0,
2064 .ab = 706199040,
2065 .ib = 1129918464,
2066 },
2067 {
2068 .src = MSM_BUS_MASTER_VPE,
2069 .dst = MSM_BUS_SLAVE_SMI,
2070 .ab = 0,
2071 .ib = 0,
2072 },
2073 {
2074 .src = MSM_BUS_MASTER_VPE,
2075 .dst = MSM_BUS_SLAVE_EBI_CH0,
2076 .ab = 0,
2077 .ib = 0,
2078 },
2079 {
2080 .src = MSM_BUS_MASTER_JPEG_ENC,
2081 .dst = MSM_BUS_SLAVE_SMI,
2082 .ab = 320864256,
2083 .ib = 513382810,
2084 },
2085 {
2086 .src = MSM_BUS_MASTER_JPEG_ENC,
2087 .dst = MSM_BUS_SLAVE_EBI_CH0,
2088 .ab = 320864256,
2089 .ib = 513382810,
2090 },
2091};
2092
2093static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2094 {
2095 .src = MSM_BUS_MASTER_VFE,
2096 .dst = MSM_BUS_SLAVE_SMI,
2097 .ab = 212336640,
2098 .ib = 339738624,
2099 },
2100 {
2101 .src = MSM_BUS_MASTER_VFE,
2102 .dst = MSM_BUS_SLAVE_EBI_CH0,
2103 .ab = 25090560,
2104 .ib = 40144896,
2105 },
2106 {
2107 .src = MSM_BUS_MASTER_VPE,
2108 .dst = MSM_BUS_SLAVE_SMI,
2109 .ab = 239708160,
2110 .ib = 383533056,
2111 },
2112 {
2113 .src = MSM_BUS_MASTER_VPE,
2114 .dst = MSM_BUS_SLAVE_EBI_CH0,
2115 .ab = 79902720,
2116 .ib = 127844352,
2117 },
2118 {
2119 .src = MSM_BUS_MASTER_JPEG_ENC,
2120 .dst = MSM_BUS_SLAVE_SMI,
2121 .ab = 0,
2122 .ib = 0,
2123 },
2124 {
2125 .src = MSM_BUS_MASTER_JPEG_ENC,
2126 .dst = MSM_BUS_SLAVE_EBI_CH0,
2127 .ab = 0,
2128 .ib = 0,
2129 },
2130};
2131
2132static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2133 {
2134 .src = MSM_BUS_MASTER_VFE,
2135 .dst = MSM_BUS_SLAVE_SMI,
2136 .ab = 0,
2137 .ib = 0,
2138 },
2139 {
2140 .src = MSM_BUS_MASTER_VFE,
2141 .dst = MSM_BUS_SLAVE_EBI_CH0,
2142 .ab = 300902400,
2143 .ib = 481443840,
2144 },
2145 {
2146 .src = MSM_BUS_MASTER_VPE,
2147 .dst = MSM_BUS_SLAVE_SMI,
2148 .ab = 230307840,
2149 .ib = 368492544,
2150 },
2151 {
2152 .src = MSM_BUS_MASTER_VPE,
2153 .dst = MSM_BUS_SLAVE_EBI_CH0,
2154 .ab = 245113344,
2155 .ib = 392181351,
2156 },
2157 {
2158 .src = MSM_BUS_MASTER_JPEG_ENC,
2159 .dst = MSM_BUS_SLAVE_SMI,
2160 .ab = 106536960,
2161 .ib = 170459136,
2162 },
2163 {
2164 .src = MSM_BUS_MASTER_JPEG_ENC,
2165 .dst = MSM_BUS_SLAVE_EBI_CH0,
2166 .ab = 106536960,
2167 .ib = 170459136,
2168 },
2169};
2170
2171static struct msm_bus_paths cam_bus_client_config[] = {
2172 {
2173 ARRAY_SIZE(cam_init_vectors),
2174 cam_init_vectors,
2175 },
2176 {
2177 ARRAY_SIZE(cam_preview_vectors),
2178 cam_preview_vectors,
2179 },
2180 {
2181 ARRAY_SIZE(cam_video_vectors),
2182 cam_video_vectors,
2183 },
2184 {
2185 ARRAY_SIZE(cam_snapshot_vectors),
2186 cam_snapshot_vectors,
2187 },
2188 {
2189 ARRAY_SIZE(cam_zsl_vectors),
2190 cam_zsl_vectors,
2191 },
2192 {
2193 ARRAY_SIZE(cam_stereo_video_vectors),
2194 cam_stereo_video_vectors,
2195 },
2196 {
2197 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2198 cam_stereo_snapshot_vectors,
2199 },
2200};
2201
2202static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2203 cam_bus_client_config,
2204 ARRAY_SIZE(cam_bus_client_config),
2205 .name = "msm_camera",
2206};
2207#endif
2208
2209struct msm_camera_device_platform_data msm_camera_device_data = {
2210 .camera_gpio_on = config_camera_on_gpios,
2211 .camera_gpio_off = config_camera_off_gpios,
2212 .ioext.csiphy = 0x04800000,
2213 .ioext.csisz = 0x00000400,
2214 .ioext.csiirq = CSI_0_IRQ,
2215 .ioclk.mclk_clk_rate = 24000000,
2216 .ioclk.vfe_clk_rate = 228570000,
2217#ifdef CONFIG_MSM_BUS_SCALING
2218 .cam_bus_scale_table = &cam_bus_client_pdata,
2219#endif
2220};
2221
2222#ifdef CONFIG_QS_S5K4E1
2223struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2224 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2225 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2226 .ioext.csiphy = 0x04800000,
2227 .ioext.csisz = 0x00000400,
2228 .ioext.csiirq = CSI_0_IRQ,
2229 .ioclk.mclk_clk_rate = 24000000,
2230 .ioclk.vfe_clk_rate = 228570000,
2231#ifdef CONFIG_MSM_BUS_SCALING
2232 .cam_bus_scale_table = &cam_bus_client_pdata,
2233#endif
2234};
2235#endif
2236
2237struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2238 .camera_gpio_on = config_camera_on_gpios_web_cam,
2239 .camera_gpio_off = config_camera_off_gpios_web_cam,
2240 .ioext.csiphy = 0x04900000,
2241 .ioext.csisz = 0x00000400,
2242 .ioext.csiirq = CSI_1_IRQ,
2243 .ioclk.mclk_clk_rate = 24000000,
2244 .ioclk.vfe_clk_rate = 228570000,
2245#ifdef CONFIG_MSM_BUS_SCALING
2246 .cam_bus_scale_table = &cam_bus_client_pdata,
2247#endif
2248};
2249
2250struct resource msm_camera_resources[] = {
2251 {
2252 .start = 0x04500000,
2253 .end = 0x04500000 + SZ_1M - 1,
2254 .flags = IORESOURCE_MEM,
2255 },
2256 {
2257 .start = VFE_IRQ,
2258 .end = VFE_IRQ,
2259 .flags = IORESOURCE_IRQ,
2260 },
2261};
2262#ifdef CONFIG_MT9E013
2263static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2264 .mount_angle = 0
2265};
2266
2267static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2268 .flash_type = MSM_CAMERA_FLASH_LED,
2269 .flash_src = &msm_flash_src
2270};
2271
2272static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2273 .sensor_name = "mt9e013",
2274 .sensor_reset = 106,
2275 .sensor_pwd = 85,
2276 .vcm_pwd = 1,
2277 .vcm_enable = 0,
2278 .pdata = &msm_camera_device_data,
2279 .resource = msm_camera_resources,
2280 .num_resources = ARRAY_SIZE(msm_camera_resources),
2281 .flash_data = &flash_mt9e013,
2282 .strobe_flash_data = &strobe_flash_xenon,
2283 .sensor_platform_info = &mt9e013_sensor_8660_info,
2284 .csi_if = 1
2285};
2286struct platform_device msm_camera_sensor_mt9e013 = {
2287 .name = "msm_camera_mt9e013",
2288 .dev = {
2289 .platform_data = &msm_camera_sensor_mt9e013_data,
2290 },
2291};
2292#endif
2293
2294#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302295static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2296 .mount_angle = 180
2297};
2298
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002299static struct msm_camera_sensor_flash_data flash_imx074 = {
2300 .flash_type = MSM_CAMERA_FLASH_LED,
2301 .flash_src = &msm_flash_src
2302};
2303
2304static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2305 .sensor_name = "imx074",
2306 .sensor_reset = 106,
2307 .sensor_pwd = 85,
2308 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2309 .vcm_enable = 1,
2310 .pdata = &msm_camera_device_data,
2311 .resource = msm_camera_resources,
2312 .num_resources = ARRAY_SIZE(msm_camera_resources),
2313 .flash_data = &flash_imx074,
2314 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302315 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002316 .csi_if = 1
2317};
2318struct platform_device msm_camera_sensor_imx074 = {
2319 .name = "msm_camera_imx074",
2320 .dev = {
2321 .platform_data = &msm_camera_sensor_imx074_data,
2322 },
2323};
2324#endif
2325#ifdef CONFIG_WEBCAM_OV9726
2326
2327static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2328 .mount_angle = 0
2329};
2330
2331static struct msm_camera_sensor_flash_data flash_ov9726 = {
2332 .flash_type = MSM_CAMERA_FLASH_LED,
2333 .flash_src = &msm_flash_src
2334};
2335static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2336 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002337 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002338 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2339 .sensor_pwd = 85,
2340 .vcm_pwd = 1,
2341 .vcm_enable = 0,
2342 .pdata = &msm_camera_device_data_web_cam,
2343 .resource = msm_camera_resources,
2344 .num_resources = ARRAY_SIZE(msm_camera_resources),
2345 .flash_data = &flash_ov9726,
2346 .sensor_platform_info = &ov9726_sensor_8660_info,
2347 .csi_if = 1
2348};
2349struct platform_device msm_camera_sensor_webcam_ov9726 = {
2350 .name = "msm_camera_ov9726",
2351 .dev = {
2352 .platform_data = &msm_camera_sensor_ov9726_data,
2353 },
2354};
2355#endif
2356#ifdef CONFIG_WEBCAM_OV7692
2357static struct msm_camera_sensor_flash_data flash_ov7692 = {
2358 .flash_type = MSM_CAMERA_FLASH_LED,
2359 .flash_src = &msm_flash_src
2360};
2361static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2362 .sensor_name = "ov7692",
2363 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2364 .sensor_pwd = 85,
2365 .vcm_pwd = 1,
2366 .vcm_enable = 0,
2367 .pdata = &msm_camera_device_data_web_cam,
2368 .resource = msm_camera_resources,
2369 .num_resources = ARRAY_SIZE(msm_camera_resources),
2370 .flash_data = &flash_ov7692,
2371 .csi_if = 1
2372};
2373
2374static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2375 .name = "msm_camera_ov7692",
2376 .dev = {
2377 .platform_data = &msm_camera_sensor_ov7692_data,
2378 },
2379};
2380#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002381#ifdef CONFIG_VX6953
2382static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2383 .mount_angle = 270
2384};
2385
2386static struct msm_camera_sensor_flash_data flash_vx6953 = {
2387 .flash_type = MSM_CAMERA_FLASH_NONE,
2388 .flash_src = &msm_flash_src
2389};
2390
2391static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2392 .sensor_name = "vx6953",
2393 .sensor_reset = 63,
2394 .sensor_pwd = 63,
2395 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2396 .vcm_enable = 1,
2397 .pdata = &msm_camera_device_data,
2398 .resource = msm_camera_resources,
2399 .num_resources = ARRAY_SIZE(msm_camera_resources),
2400 .flash_data = &flash_vx6953,
2401 .sensor_platform_info = &vx6953_sensor_8660_info,
2402 .csi_if = 1
2403};
2404struct platform_device msm_camera_sensor_vx6953 = {
2405 .name = "msm_camera_vx6953",
2406 .dev = {
2407 .platform_data = &msm_camera_sensor_vx6953_data,
2408 },
2409};
2410#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002411#ifdef CONFIG_QS_S5K4E1
2412
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302413static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2414#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2415 .mount_angle = 90
2416#else
2417 .mount_angle = 0
2418#endif
2419};
2420
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002421static char eeprom_data[864];
2422static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2423 .flash_type = MSM_CAMERA_FLASH_LED,
2424 .flash_src = &msm_flash_src
2425};
2426
2427static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2428 .sensor_name = "qs_s5k4e1",
2429 .sensor_reset = 106,
2430 .sensor_pwd = 85,
2431 .vcm_pwd = 1,
2432 .vcm_enable = 0,
2433 .pdata = &msm_camera_device_data_qs_cam,
2434 .resource = msm_camera_resources,
2435 .num_resources = ARRAY_SIZE(msm_camera_resources),
2436 .flash_data = &flash_qs_s5k4e1,
2437 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302438 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002439 .csi_if = 1,
2440 .eeprom_data = eeprom_data,
2441};
2442struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2443 .name = "msm_camera_qs_s5k4e1",
2444 .dev = {
2445 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2446 },
2447};
2448#endif
2449static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2450 #ifdef CONFIG_MT9E013
2451 {
2452 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2453 },
2454 #endif
2455 #ifdef CONFIG_IMX074
2456 {
2457 I2C_BOARD_INFO("imx074", 0x1A),
2458 },
2459 #endif
2460 #ifdef CONFIG_WEBCAM_OV7692
2461 {
2462 I2C_BOARD_INFO("ov7692", 0x78),
2463 },
2464 #endif
2465 #ifdef CONFIG_WEBCAM_OV9726
2466 {
2467 I2C_BOARD_INFO("ov9726", 0x10),
2468 },
2469 #endif
2470 #ifdef CONFIG_QS_S5K4E1
2471 {
2472 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2473 },
2474 #endif
2475};
Jilai Wang971f97f2011-07-13 14:25:25 -04002476
2477static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002478 #ifdef CONFIG_WEBCAM_OV9726
2479 {
2480 I2C_BOARD_INFO("ov9726", 0x10),
2481 },
2482 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002483 #ifdef CONFIG_VX6953
2484 {
2485 I2C_BOARD_INFO("vx6953", 0x20),
2486 },
2487 #endif
2488};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002489#endif
2490
2491#ifdef CONFIG_MSM_GEMINI
2492static struct resource msm_gemini_resources[] = {
2493 {
2494 .start = 0x04600000,
2495 .end = 0x04600000 + SZ_1M - 1,
2496 .flags = IORESOURCE_MEM,
2497 },
2498 {
2499 .start = INT_JPEG,
2500 .end = INT_JPEG,
2501 .flags = IORESOURCE_IRQ,
2502 },
2503};
2504
2505static struct platform_device msm_gemini_device = {
2506 .name = "msm_gemini",
2507 .resource = msm_gemini_resources,
2508 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2509};
2510#endif
2511
2512#ifdef CONFIG_I2C_QUP
2513static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2514{
2515}
2516
2517static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2518 .clk_freq = 384000,
2519 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002520 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2521};
2522
2523static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2524 .clk_freq = 100000,
2525 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002526 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2527};
2528
2529static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2530 .clk_freq = 100000,
2531 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002532 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2533};
2534
2535static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2536 .clk_freq = 100000,
2537 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002538 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2539};
2540
2541static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2542 .clk_freq = 100000,
2543 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002544 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2545};
2546
2547static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2548 .clk_freq = 100000,
2549 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002550 .use_gsbi_shared_mode = 1,
2551 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2552};
2553#endif
2554
2555#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2556static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2557 .max_clock_speed = 24000000,
2558};
2559
2560static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2561 .max_clock_speed = 24000000,
2562};
2563#endif
2564
2565#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002566/* CODEC/TSSC SSBI */
2567static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2568 .controller_type = MSM_SBI_CTRL_SSBI,
2569};
2570#endif
2571
2572#ifdef CONFIG_BATTERY_MSM
2573/* Use basic value for fake MSM battery */
2574static struct msm_psy_batt_pdata msm_psy_batt_data = {
2575 .avail_chg_sources = AC_CHG,
2576};
2577
2578static struct platform_device msm_batt_device = {
2579 .name = "msm-battery",
2580 .id = -1,
2581 .dev.platform_data = &msm_psy_batt_data,
2582};
2583#endif
2584
2585#ifdef CONFIG_FB_MSM_LCDC_DSUB
2586/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2587 prim = 1024 x 600 x 4(bpp) x 2(pages)
2588 This is the difference. */
2589#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2590#else
2591#define MSM_FB_DSUB_PMEM_ADDER (0)
2592#endif
2593
2594/* Sensors DSPS platform data */
2595#ifdef CONFIG_MSM_DSPS
2596
2597static struct dsps_gpio_info dsps_surf_gpios[] = {
2598 {
2599 .name = "compass_rst_n",
2600 .num = GPIO_COMPASS_RST_N,
2601 .on_val = 1, /* device not in reset */
2602 .off_val = 0, /* device in reset */
2603 },
2604 {
2605 .name = "gpio_r_altimeter_reset_n",
2606 .num = GPIO_R_ALTIMETER_RESET_N,
2607 .on_val = 1, /* device not in reset */
2608 .off_val = 0, /* device in reset */
2609 }
2610};
2611
2612static struct dsps_gpio_info dsps_fluid_gpios[] = {
2613 {
2614 .name = "gpio_n_altimeter_reset_n",
2615 .num = GPIO_N_ALTIMETER_RESET_N,
2616 .on_val = 1, /* device not in reset */
2617 .off_val = 0, /* device in reset */
2618 }
2619};
2620
2621static void __init msm8x60_init_dsps(void)
2622{
2623 struct msm_dsps_platform_data *pdata =
2624 msm_dsps_device.dev.platform_data;
2625 /*
2626 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2627 * to the power supply and not controled via GPIOs. Fluid uses a
2628 * different IO-Expender (north) than used on surf/ffa.
2629 */
2630 if (machine_is_msm8x60_fluid()) {
2631 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002632 pdata->pil_name = DSPS_PIL_FLUID_NAME;
2633 pdata->gpios = dsps_fluid_gpios;
2634 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2635 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002636 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2637 pdata->gpios = dsps_surf_gpios;
2638 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2639 }
2640
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002641 platform_device_register(&msm_dsps_device);
2642}
2643#endif /* CONFIG_MSM_DSPS */
2644
2645#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002646#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002647#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002648#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002649#endif
2650
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002651#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2652#define MSM_FB_EXT_BUF_SIZE (1920 * 1080 * 2 * 1) /* 2 bpp x 1 page */
2653#elif defined(CONFIG_FB_MSM_TVOUT)
2654#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
2655#else
2656#define MSM_FB_EXT_BUFT_SIZE 0
2657#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002658
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002659#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2660/* 4 bpp x 2 page HDMI case */
2661#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
2662#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002663/* Note: must be multiple of 4096 */
2664#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002665 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002666#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002667
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002668#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2669#define MSM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
2670#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002671#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002672#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002673
Huaibin Yanga5419422011-12-08 23:52:10 -08002674#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2675#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2676#else
2677#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2678#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2679
2680#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2681#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2682#else
2683#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2684#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2685
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002686#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
2687#define MSM_PMEM_ADSP_SIZE 0x2000000
Ben Romberger09e462d2011-08-09 15:24:37 -07002688#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002689
2690#define MSM_SMI_BASE 0x38000000
2691#define MSM_SMI_SIZE 0x4000000
2692
2693#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002694#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002695
2696#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2697#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2698#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2699
Naseer Ahmed51860b02012-02-07 18:53:29 +05302700#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002701#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan42ebe712012-01-10 16:30:58 -08002702#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
2703#define MSM_ION_MM_SIZE 0x3600000 /* (54MB) */
Olav Hauganb5be7992011-11-18 14:29:02 -08002704#define MSM_ION_MFC_SIZE SZ_8K
2705#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Olav Haugan3a55e322012-01-23 14:24:01 -08002706#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002707
2708#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Olav Haugan3a55e322012-01-23 14:24:01 -08002709#define MSM_ION_HEAP_NUM 8
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002710#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002711#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002712#endif
2713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002714static unsigned fb_size;
2715static int __init fb_size_setup(char *p)
2716{
2717 fb_size = memparse(p, NULL);
2718 return 0;
2719}
2720early_param("fb_size", fb_size_setup);
2721
2722static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2723static int __init pmem_kernel_ebi1_size_setup(char *p)
2724{
2725 pmem_kernel_ebi1_size = memparse(p, NULL);
2726 return 0;
2727}
2728early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2729
2730#ifdef CONFIG_ANDROID_PMEM
2731static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2732static int __init pmem_sf_size_setup(char *p)
2733{
2734 pmem_sf_size = memparse(p, NULL);
2735 return 0;
2736}
2737early_param("pmem_sf_size", pmem_sf_size_setup);
2738
2739static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2740
2741static int __init pmem_adsp_size_setup(char *p)
2742{
2743 pmem_adsp_size = memparse(p, NULL);
2744 return 0;
2745}
2746early_param("pmem_adsp_size", pmem_adsp_size_setup);
2747
2748static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2749
2750static int __init pmem_audio_size_setup(char *p)
2751{
2752 pmem_audio_size = memparse(p, NULL);
2753 return 0;
2754}
2755early_param("pmem_audio_size", pmem_audio_size_setup);
2756#endif
2757
2758static struct resource msm_fb_resources[] = {
2759 {
2760 .flags = IORESOURCE_DMA,
2761 }
2762};
2763
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002764static int msm_fb_detect_panel(const char *name)
2765{
2766 if (machine_is_msm8x60_fluid()) {
2767 uint32_t soc_platform_version = socinfo_get_platform_version();
2768 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2769#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2770 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002771 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2772 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002773 return 0;
2774#endif
2775 } else { /*P3 and up use AUO panel */
2776#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2777 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002778 strnlen(LCDC_AUO_PANEL_NAME,
2779 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002780 return 0;
2781#endif
2782 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002783#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2784 } else if machine_is_msm8x60_dragon() {
2785 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002786 strnlen(LCDC_NT35582_PANEL_NAME,
2787 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002788 return 0;
2789#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002790 } else {
2791 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002792 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2793 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002794 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002795
2796#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2797 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2798 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2799 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2800 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2801 PANEL_NAME_MAX_LEN)))
2802 return 0;
2803
2804 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2805 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2806 PANEL_NAME_MAX_LEN)))
2807 return 0;
2808
2809 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2810 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2811 PANEL_NAME_MAX_LEN)))
2812 return 0;
2813#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002815
2816 if (!strncmp(name, HDMI_PANEL_NAME,
2817 strnlen(HDMI_PANEL_NAME,
2818 PANEL_NAME_MAX_LEN)))
2819 return 0;
2820
2821 if (!strncmp(name, TVOUT_PANEL_NAME,
2822 strnlen(TVOUT_PANEL_NAME,
2823 PANEL_NAME_MAX_LEN)))
2824 return 0;
2825
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002826 pr_warning("%s: not supported '%s'", __func__, name);
2827 return -ENODEV;
2828}
2829
2830static struct msm_fb_platform_data msm_fb_pdata = {
2831 .detect_client = msm_fb_detect_panel,
2832};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002833
2834static struct platform_device msm_fb_device = {
2835 .name = "msm_fb",
2836 .id = 0,
2837 .num_resources = ARRAY_SIZE(msm_fb_resources),
2838 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002839 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002840};
2841
2842#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002843#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844static struct android_pmem_platform_data android_pmem_pdata = {
2845 .name = "pmem",
2846 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2847 .cached = 1,
2848 .memory_type = MEMTYPE_EBI1,
2849};
2850
2851static struct platform_device android_pmem_device = {
2852 .name = "android_pmem",
2853 .id = 0,
2854 .dev = {.platform_data = &android_pmem_pdata},
2855};
2856
2857static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2858 .name = "pmem_adsp",
2859 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2860 .cached = 0,
2861 .memory_type = MEMTYPE_EBI1,
2862};
2863
2864static struct platform_device android_pmem_adsp_device = {
2865 .name = "android_pmem",
2866 .id = 2,
2867 .dev = { .platform_data = &android_pmem_adsp_pdata },
2868};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002869#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002870static struct android_pmem_platform_data android_pmem_audio_pdata = {
2871 .name = "pmem_audio",
2872 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2873 .cached = 0,
2874 .memory_type = MEMTYPE_EBI1,
2875};
2876
2877static struct platform_device android_pmem_audio_device = {
2878 .name = "android_pmem",
2879 .id = 4,
2880 .dev = { .platform_data = &android_pmem_audio_pdata },
2881};
2882
Laura Abbott1e36a022011-06-22 17:08:13 -07002883#define PMEM_BUS_WIDTH(_bw) \
2884 { \
2885 .vectors = &(struct msm_bus_vectors){ \
2886 .src = MSM_BUS_MASTER_AMPSS_M0, \
2887 .dst = MSM_BUS_SLAVE_SMI, \
2888 .ib = (_bw), \
2889 .ab = 0, \
2890 }, \
2891 .num_paths = 1, \
2892 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002893
2894static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002895 [0] = PMEM_BUS_WIDTH(0), /* Off */
2896 [1] = PMEM_BUS_WIDTH(1), /* On */
2897};
2898
2899static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002900 .usecase = mem_smi_table,
2901 .num_usecases = ARRAY_SIZE(mem_smi_table),
2902 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002903};
2904
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002905int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002906{
2907 int bus_id = (int) data;
2908
2909 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002910 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002911}
2912
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002913int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002914{
2915 int bus_id = (int) data;
2916
2917 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002918 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002919}
2920
Alex Bird199980e2011-10-21 11:29:27 -07002921void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002922{
2923 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2924}
Olav Hauganee0f7802011-12-19 13:28:57 -08002925#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002926static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2927 .name = "pmem_smipool",
2928 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2929 .cached = 0,
2930 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002931 .request_region = request_smi_region,
2932 .release_region = release_smi_region,
2933 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002934 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002935};
2936static struct platform_device android_pmem_smipool_device = {
2937 .name = "android_pmem",
2938 .id = 7,
2939 .dev = { .platform_data = &android_pmem_smipool_pdata },
2940};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002941#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002942#endif
2943
2944#define GPIO_DONGLE_PWR_EN 258
2945static void setup_display_power(void);
2946static int lcdc_vga_enabled;
2947static int vga_enable_request(int enable)
2948{
2949 if (enable)
2950 lcdc_vga_enabled = 1;
2951 else
2952 lcdc_vga_enabled = 0;
2953 setup_display_power();
2954
2955 return 0;
2956}
2957
2958#define GPIO_BACKLIGHT_PWM0 0
2959#define GPIO_BACKLIGHT_PWM1 1
2960
2961static int pmic_backlight_gpio[2]
2962 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2963static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2964 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2965 .vga_switch = vga_enable_request,
2966};
2967
2968static struct platform_device lcdc_samsung_panel_device = {
2969 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2970 .id = 0,
2971 .dev = {
2972 .platform_data = &lcdc_samsung_panel_data,
2973 }
2974};
2975#if (!defined(CONFIG_SPI_QUP)) && \
2976 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2977 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2978
2979static int lcdc_spi_gpio_array_num[] = {
2980 LCDC_SPI_GPIO_CLK,
2981 LCDC_SPI_GPIO_CS,
2982 LCDC_SPI_GPIO_MOSI,
2983};
2984
2985static uint32_t lcdc_spi_gpio_config_data[] = {
2986 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2987 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2988 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2989 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2990 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2991 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2992};
2993
2994static void lcdc_config_spi_gpios(int enable)
2995{
2996 int n;
2997 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2998 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2999}
3000#endif
3001
3002#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
3003#ifdef CONFIG_SPI_QUP
3004static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
3005 {
3006 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
3007 .mode = SPI_MODE_3,
3008 .bus_num = 1,
3009 .chip_select = 0,
3010 .max_speed_hz = 10800000,
3011 }
3012};
3013#endif /* CONFIG_SPI_QUP */
3014
3015static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
3016#ifndef CONFIG_SPI_QUP
3017 .panel_config_gpio = lcdc_config_spi_gpios,
3018 .gpio_num = lcdc_spi_gpio_array_num,
3019#endif
3020};
3021
3022static struct platform_device lcdc_samsung_oled_panel_device = {
3023 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
3024 .id = 0,
3025 .dev.platform_data = &lcdc_samsung_oled_panel_data,
3026};
3027#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3028
3029#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3030#ifdef CONFIG_SPI_QUP
3031static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3032 {
3033 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3034 .mode = SPI_MODE_3,
3035 .bus_num = 1,
3036 .chip_select = 0,
3037 .max_speed_hz = 10800000,
3038 }
3039};
3040#endif
3041
3042static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3043#ifndef CONFIG_SPI_QUP
3044 .panel_config_gpio = lcdc_config_spi_gpios,
3045 .gpio_num = lcdc_spi_gpio_array_num,
3046#endif
3047};
3048
3049static struct platform_device lcdc_auo_wvga_panel_device = {
3050 .name = LCDC_AUO_PANEL_NAME,
3051 .id = 0,
3052 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3053};
3054#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3055
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003056#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3057
3058#define GPIO_NT35582_RESET 94
3059#define GPIO_NT35582_BL_EN_HW_PIN 24
3060#define GPIO_NT35582_BL_EN \
3061 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3062
3063static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3064
3065static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3066 .gpio_num = lcdc_nt35582_pmic_gpio,
3067};
3068
3069static struct platform_device lcdc_nt35582_panel_device = {
3070 .name = LCDC_NT35582_PANEL_NAME,
3071 .id = 0,
3072 .dev = {
3073 .platform_data = &lcdc_nt35582_panel_data,
3074 }
3075};
3076
3077static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3078 {
3079 .modalias = "lcdc_nt35582_spi",
3080 .mode = SPI_MODE_0,
3081 .bus_num = 0,
3082 .chip_select = 0,
3083 .max_speed_hz = 1100000,
3084 }
3085};
3086#endif
3087
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003088#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3089static struct resource hdmi_msm_resources[] = {
3090 {
3091 .name = "hdmi_msm_qfprom_addr",
3092 .start = 0x00700000,
3093 .end = 0x007060FF,
3094 .flags = IORESOURCE_MEM,
3095 },
3096 {
3097 .name = "hdmi_msm_hdmi_addr",
3098 .start = 0x04A00000,
3099 .end = 0x04A00FFF,
3100 .flags = IORESOURCE_MEM,
3101 },
3102 {
3103 .name = "hdmi_msm_irq",
3104 .start = HDMI_IRQ,
3105 .end = HDMI_IRQ,
3106 .flags = IORESOURCE_IRQ,
3107 },
3108};
3109
3110static int hdmi_enable_5v(int on);
3111static int hdmi_core_power(int on, int show);
3112static int hdmi_cec_power(int on);
3113
3114static struct msm_hdmi_platform_data hdmi_msm_data = {
3115 .irq = HDMI_IRQ,
3116 .enable_5v = hdmi_enable_5v,
3117 .core_power = hdmi_core_power,
3118 .cec_power = hdmi_cec_power,
3119};
3120
3121static struct platform_device hdmi_msm_device = {
3122 .name = "hdmi_msm",
3123 .id = 0,
3124 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3125 .resource = hdmi_msm_resources,
3126 .dev.platform_data = &hdmi_msm_data,
3127};
3128#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3129
3130#ifdef CONFIG_FB_MSM_MIPI_DSI
3131static struct platform_device mipi_dsi_toshiba_panel_device = {
3132 .name = "mipi_toshiba",
3133 .id = 0,
3134};
3135
3136#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3137
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003138static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003139 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003140 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003141};
3142
3143static struct platform_device mipi_dsi_novatek_panel_device = {
3144 .name = "mipi_novatek",
3145 .id = 0,
3146 .dev = {
3147 .platform_data = &novatek_pdata,
3148 }
3149};
3150#endif
3151
3152static void __init msm8x60_allocate_memory_regions(void)
3153{
3154 void *addr;
3155 unsigned long size;
3156
3157 size = MSM_FB_SIZE;
3158 addr = alloc_bootmem_align(size, 0x1000);
3159 msm_fb_resources[0].start = __pa(addr);
3160 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3161 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3162 size, addr, __pa(addr));
3163
3164}
3165
3166#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3167 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3168/*virtual key support */
3169static ssize_t tma300_vkeys_show(struct kobject *kobj,
3170 struct kobj_attribute *attr, char *buf)
3171{
3172 return sprintf(buf,
3173 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3174 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3175 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3176 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3177 "\n");
3178}
3179
3180static struct kobj_attribute tma300_vkeys_attr = {
3181 .attr = {
3182 .mode = S_IRUGO,
3183 },
3184 .show = &tma300_vkeys_show,
3185};
3186
3187static struct attribute *tma300_properties_attrs[] = {
3188 &tma300_vkeys_attr.attr,
3189 NULL
3190};
3191
3192static struct attribute_group tma300_properties_attr_group = {
3193 .attrs = tma300_properties_attrs,
3194};
3195
3196static struct kobject *properties_kobj;
3197
3198
3199
3200#define CYTTSP_TS_GPIO_IRQ 61
3201static int cyttsp_platform_init(struct i2c_client *client)
3202{
3203 int rc = -EINVAL;
3204 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3205
3206 if (machine_is_msm8x60_fluid()) {
3207 pm8058_l5 = regulator_get(NULL, "8058_l5");
3208 if (IS_ERR(pm8058_l5)) {
3209 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3210 __func__, PTR_ERR(pm8058_l5));
3211 rc = PTR_ERR(pm8058_l5);
3212 return rc;
3213 }
3214 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3215 if (rc) {
3216 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3217 __func__, rc);
3218 goto reg_l5_put;
3219 }
3220
3221 rc = regulator_enable(pm8058_l5);
3222 if (rc) {
3223 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3224 __func__, rc);
3225 goto reg_l5_put;
3226 }
3227 }
3228 /* vote for s3 to enable i2c communication lines */
3229 pm8058_s3 = regulator_get(NULL, "8058_s3");
3230 if (IS_ERR(pm8058_s3)) {
3231 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3232 __func__, PTR_ERR(pm8058_s3));
3233 rc = PTR_ERR(pm8058_s3);
3234 goto reg_l5_disable;
3235 }
3236
3237 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3238 if (rc) {
3239 pr_err("%s: regulator_set_voltage() = %d\n",
3240 __func__, rc);
3241 goto reg_s3_put;
3242 }
3243
3244 rc = regulator_enable(pm8058_s3);
3245 if (rc) {
3246 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3247 __func__, rc);
3248 goto reg_s3_put;
3249 }
3250
3251 /* wait for vregs to stabilize */
3252 usleep_range(10000, 10000);
3253
3254 /* check this device active by reading first byte/register */
3255 rc = i2c_smbus_read_byte_data(client, 0x01);
3256 if (rc < 0) {
3257 pr_err("%s: i2c sanity check failed\n", __func__);
3258 goto reg_s3_disable;
3259 }
3260
3261 /* virtual keys */
3262 if (machine_is_msm8x60_fluid()) {
3263 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3264 properties_kobj = kobject_create_and_add("board_properties",
3265 NULL);
3266 if (properties_kobj)
3267 rc = sysfs_create_group(properties_kobj,
3268 &tma300_properties_attr_group);
3269 if (!properties_kobj || rc)
3270 pr_err("%s: failed to create board_properties\n",
3271 __func__);
3272 }
3273 return CY_OK;
3274
3275reg_s3_disable:
3276 regulator_disable(pm8058_s3);
3277reg_s3_put:
3278 regulator_put(pm8058_s3);
3279reg_l5_disable:
3280 if (machine_is_msm8x60_fluid())
3281 regulator_disable(pm8058_l5);
3282reg_l5_put:
3283 if (machine_is_msm8x60_fluid())
3284 regulator_put(pm8058_l5);
3285 return rc;
3286}
3287
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303288/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3289static int cyttsp_platform_suspend(struct i2c_client *client)
3290{
3291 msleep(20);
3292
3293 return CY_OK;
3294}
3295
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003296static int cyttsp_platform_resume(struct i2c_client *client)
3297{
3298 /* add any special code to strobe a wakeup pin or chip reset */
3299 msleep(10);
3300
3301 return CY_OK;
3302}
3303
3304static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3305 .flags = 0x04,
3306 .gen = CY_GEN3, /* or */
3307 .use_st = CY_USE_ST,
3308 .use_mt = CY_USE_MT,
3309 .use_hndshk = CY_SEND_HNDSHK,
3310 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303311 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003312 .use_gestures = CY_USE_GESTURES,
3313 /* activate up to 4 groups
3314 * and set active distance
3315 */
3316 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3317 CY_GEST_GRP3 | CY_GEST_GRP4 |
3318 CY_ACT_DIST,
3319 /* change act_intrvl to customize the Active power state
3320 * scanning/processing refresh interval for Operating mode
3321 */
3322 .act_intrvl = CY_ACT_INTRVL_DFLT,
3323 /* change tch_tmout to customize the touch timeout for the
3324 * Active power state for Operating mode
3325 */
3326 .tch_tmout = CY_TCH_TMOUT_DFLT,
3327 /* change lp_intrvl to customize the Low Power power state
3328 * scanning/processing refresh interval for Operating mode
3329 */
3330 .lp_intrvl = CY_LP_INTRVL_DFLT,
3331 .sleep_gpio = -1,
3332 .resout_gpio = -1,
3333 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3334 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303335 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003336 .init = cyttsp_platform_init,
3337};
3338
3339static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3340 .panel_maxx = 1083,
3341 .panel_maxy = 659,
3342 .disp_minx = 30,
3343 .disp_maxx = 1053,
3344 .disp_miny = 30,
3345 .disp_maxy = 629,
3346 .correct_fw_ver = 8,
3347 .fw_fname = "cyttsp_8660_ffa.hex",
3348 .flags = 0x00,
3349 .gen = CY_GEN2, /* or */
3350 .use_st = CY_USE_ST,
3351 .use_mt = CY_USE_MT,
3352 .use_hndshk = CY_SEND_HNDSHK,
3353 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303354 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003355 .use_gestures = CY_USE_GESTURES,
3356 /* activate up to 4 groups
3357 * and set active distance
3358 */
3359 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3360 CY_GEST_GRP3 | CY_GEST_GRP4 |
3361 CY_ACT_DIST,
3362 /* change act_intrvl to customize the Active power state
3363 * scanning/processing refresh interval for Operating mode
3364 */
3365 .act_intrvl = CY_ACT_INTRVL_DFLT,
3366 /* change tch_tmout to customize the touch timeout for the
3367 * Active power state for Operating mode
3368 */
3369 .tch_tmout = CY_TCH_TMOUT_DFLT,
3370 /* change lp_intrvl to customize the Low Power power state
3371 * scanning/processing refresh interval for Operating mode
3372 */
3373 .lp_intrvl = CY_LP_INTRVL_DFLT,
3374 .sleep_gpio = -1,
3375 .resout_gpio = -1,
3376 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3377 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303378 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003379 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303380 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003381};
3382static void cyttsp_set_params(void)
3383{
3384 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3385 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3386 cyttsp_fluid_pdata.panel_maxx = 539;
3387 cyttsp_fluid_pdata.panel_maxy = 994;
3388 cyttsp_fluid_pdata.disp_minx = 30;
3389 cyttsp_fluid_pdata.disp_maxx = 509;
3390 cyttsp_fluid_pdata.disp_miny = 60;
3391 cyttsp_fluid_pdata.disp_maxy = 859;
3392 cyttsp_fluid_pdata.correct_fw_ver = 4;
3393 } else {
3394 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3395 cyttsp_fluid_pdata.panel_maxx = 550;
3396 cyttsp_fluid_pdata.panel_maxy = 1013;
3397 cyttsp_fluid_pdata.disp_minx = 35;
3398 cyttsp_fluid_pdata.disp_maxx = 515;
3399 cyttsp_fluid_pdata.disp_miny = 69;
3400 cyttsp_fluid_pdata.disp_maxy = 869;
3401 cyttsp_fluid_pdata.correct_fw_ver = 5;
3402 }
3403
3404}
3405
3406static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3407 {
3408 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3409 .platform_data = &cyttsp_fluid_pdata,
3410#ifndef CY_USE_TIMER
3411 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3412#endif /* CY_USE_TIMER */
3413 },
3414};
3415
3416static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3417 {
3418 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3419 .platform_data = &cyttsp_tmg240_pdata,
3420#ifndef CY_USE_TIMER
3421 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3422#endif /* CY_USE_TIMER */
3423 },
3424};
3425#endif
3426
3427static struct regulator *vreg_tmg200;
3428
3429#define TS_PEN_IRQ_GPIO 61
3430static int tmg200_power(int vreg_on)
3431{
3432 int rc = -EINVAL;
3433
3434 if (!vreg_tmg200) {
3435 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3436 __func__, rc);
3437 return rc;
3438 }
3439
3440 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3441 regulator_disable(vreg_tmg200);
3442 if (rc < 0)
3443 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3444 __func__, vreg_on ? "enable" : "disable", rc);
3445
3446 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003447 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003448
3449 return rc;
3450}
3451
3452static int tmg200_dev_setup(bool enable)
3453{
3454 int rc;
3455
3456 if (enable) {
3457 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3458 if (IS_ERR(vreg_tmg200)) {
3459 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3460 __func__, PTR_ERR(vreg_tmg200));
3461 rc = PTR_ERR(vreg_tmg200);
3462 return rc;
3463 }
3464
3465 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3466 if (rc) {
3467 pr_err("%s: regulator_set_voltage() = %d\n",
3468 __func__, rc);
3469 goto reg_put;
3470 }
3471 } else {
3472 /* put voltage sources */
3473 regulator_put(vreg_tmg200);
3474 }
3475 return 0;
3476reg_put:
3477 regulator_put(vreg_tmg200);
3478 return rc;
3479}
3480
3481static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3482 .ts_name = "msm_tmg200_ts",
3483 .dis_min_x = 0,
3484 .dis_max_x = 1023,
3485 .dis_min_y = 0,
3486 .dis_max_y = 599,
3487 .min_tid = 0,
3488 .max_tid = 255,
3489 .min_touch = 0,
3490 .max_touch = 255,
3491 .min_width = 0,
3492 .max_width = 255,
3493 .power_on = tmg200_power,
3494 .dev_setup = tmg200_dev_setup,
3495 .nfingers = 2,
3496 .irq_gpio = TS_PEN_IRQ_GPIO,
3497 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3498};
3499
3500static struct i2c_board_info cy8ctmg200_board_info[] = {
3501 {
3502 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3503 .platform_data = &cy8ctmg200_pdata,
3504 }
3505};
3506
Zhang Chang Ken211df572011-07-05 19:16:39 -04003507static struct regulator *vreg_tma340;
3508
3509static int tma340_power(int vreg_on)
3510{
3511 int rc = -EINVAL;
3512
3513 if (!vreg_tma340) {
3514 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3515 __func__, rc);
3516 return rc;
3517 }
3518
3519 rc = vreg_on ? regulator_enable(vreg_tma340) :
3520 regulator_disable(vreg_tma340);
3521 if (rc < 0)
3522 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3523 __func__, vreg_on ? "enable" : "disable", rc);
3524
3525 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003526 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003527
3528 return rc;
3529}
3530
3531static struct kobject *tma340_prop_kobj;
3532
3533static int tma340_dragon_dev_setup(bool enable)
3534{
3535 int rc;
3536
3537 if (enable) {
3538 vreg_tma340 = regulator_get(NULL, "8901_l2");
3539 if (IS_ERR(vreg_tma340)) {
3540 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3541 __func__, PTR_ERR(vreg_tma340));
3542 rc = PTR_ERR(vreg_tma340);
3543 return rc;
3544 }
3545
3546 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3547 if (rc) {
3548 pr_err("%s: regulator_set_voltage() = %d\n",
3549 __func__, rc);
3550 goto reg_put;
3551 }
3552 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3553 tma340_prop_kobj = kobject_create_and_add("board_properties",
3554 NULL);
3555 if (tma340_prop_kobj) {
3556 rc = sysfs_create_group(tma340_prop_kobj,
3557 &tma300_properties_attr_group);
3558 if (rc) {
3559 kobject_put(tma340_prop_kobj);
3560 pr_err("%s: failed to create board_properties\n",
3561 __func__);
3562 goto reg_put;
3563 }
3564 }
3565
3566 } else {
3567 /* put voltage sources */
3568 regulator_put(vreg_tma340);
3569 /* destroy virtual keys */
3570 if (tma340_prop_kobj) {
3571 sysfs_remove_group(tma340_prop_kobj,
3572 &tma300_properties_attr_group);
3573 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),
3826};
3827static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3828 REGULATOR_SUPPLY("8058_l16", NULL),
3829};
3830static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3831 REGULATOR_SUPPLY("8058_l17", NULL),
3832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3834 REGULATOR_SUPPLY("8058_l18", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3837 REGULATOR_SUPPLY("8058_l19", NULL),
3838};
3839static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3840 REGULATOR_SUPPLY("8058_l20", NULL),
3841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3843 REGULATOR_SUPPLY("8058_l21", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3846 REGULATOR_SUPPLY("8058_l22", NULL),
3847};
3848static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3849 REGULATOR_SUPPLY("8058_l23", NULL),
3850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3852 REGULATOR_SUPPLY("8058_l24", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3855 REGULATOR_SUPPLY("8058_l25", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3858 REGULATOR_SUPPLY("8058_s0", NULL),
3859};
3860static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3861 REGULATOR_SUPPLY("8058_s1", NULL),
3862};
3863static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3864 REGULATOR_SUPPLY("8058_s2", NULL),
3865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3867 REGULATOR_SUPPLY("8058_s3", NULL),
3868};
3869static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3870 REGULATOR_SUPPLY("8058_s4", NULL),
3871};
3872static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3873 REGULATOR_SUPPLY("8058_lvs0", NULL),
3874};
3875static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3876 REGULATOR_SUPPLY("8058_lvs1", NULL),
3877};
3878static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3879 REGULATOR_SUPPLY("8058_ncp", NULL),
3880};
3881
3882static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3883 REGULATOR_SUPPLY("8901_l0", NULL),
3884};
3885static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3886 REGULATOR_SUPPLY("8901_l1", NULL),
3887};
3888static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3889 REGULATOR_SUPPLY("8901_l2", NULL),
3890};
3891static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3892 REGULATOR_SUPPLY("8901_l3", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3895 REGULATOR_SUPPLY("8901_l4", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3898 REGULATOR_SUPPLY("8901_l5", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3901 REGULATOR_SUPPLY("8901_l6", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3904 REGULATOR_SUPPLY("8901_s2", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3907 REGULATOR_SUPPLY("8901_s3", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3910 REGULATOR_SUPPLY("8901_s4", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3913 REGULATOR_SUPPLY("8901_lvs0", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3916 REGULATOR_SUPPLY("8901_lvs1", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3919 REGULATOR_SUPPLY("8901_lvs2", NULL),
3920};
3921static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3922 REGULATOR_SUPPLY("8901_lvs3", NULL),
3923};
3924static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3925 REGULATOR_SUPPLY("8901_mvs0", NULL),
3926};
3927
David Collins6f032ba2011-08-31 14:08:15 -07003928/* Pin control regulators */
3929static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3930 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3933 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3934};
3935static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3936 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3937};
3938static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3939 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3940};
3941static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3942 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3943};
3944static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3945 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3946};
3947
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003948#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3949 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins6f032ba2011-08-31 14:08:15 -07003950 _freq, _pin_fn, _force_mode, _state, _sleep_selectable, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003951 _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003952 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003953 .init_data = { \
3954 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003955 .valid_modes_mask = _modes, \
3956 .valid_ops_mask = _ops, \
3957 .min_uV = _min_uV, \
3958 .max_uV = _max_uV, \
3959 .input_uV = _min_uV, \
3960 .apply_uV = _apply_uV, \
3961 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003962 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003963 .consumer_supplies = vreg_consumers_##_id, \
3964 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003965 ARRAY_SIZE(vreg_consumers_##_id), \
3966 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003967 .id = RPM_VREG_ID_##_id, \
3968 .default_uV = _default_uV, \
3969 .peak_uA = _peak_uA, \
3970 .avg_uA = _avg_uA, \
3971 .pull_down_enable = _pull_down, \
3972 .pin_ctrl = _pin_ctrl, \
3973 .freq = RPM_VREG_FREQ_##_freq, \
3974 .pin_fn = _pin_fn, \
3975 .force_mode = _force_mode, \
3976 .state = _state, \
3977 .sleep_selectable = _sleep_selectable, \
3978 }
3979
3980/* Pin control initialization */
3981#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3982 { \
3983 .init_data = { \
3984 .constraints = { \
3985 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3986 .always_on = _always_on, \
3987 }, \
3988 .num_consumer_supplies = \
3989 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3990 .consumer_supplies = vreg_consumers_##_id##_PC, \
3991 }, \
3992 .id = RPM_VREG_ID_##_id##_PC, \
3993 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003994 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003995 }
3996
3997/*
3998 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3999 * via the peak_uA value specified in the table below. If the value is less
4000 * than the high power min threshold for the regulator, then the regulator will
4001 * be set to LPM. Otherwise, it will be set to HPM.
4002 *
4003 * This value can be further overridden by specifying an initial mode via
4004 * .init_data.constraints.initial_mode.
4005 */
4006
David Collins6f032ba2011-08-31 14:08:15 -07004007#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4008 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004009 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4010 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4011 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4012 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4013 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004014 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4015 RPM_VREG_PIN_FN_8660_ENABLE, \
4016 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004017 _sleep_selectable, _always_on)
4018
David Collins6f032ba2011-08-31 14:08:15 -07004019#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4020 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004021 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4022 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4023 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4024 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4025 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004026 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4027 RPM_VREG_PIN_FN_8660_ENABLE, \
4028 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4029 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030
David Collins6f032ba2011-08-31 14:08:15 -07004031#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004032 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4033 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004034 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4035 RPM_VREG_PIN_FN_8660_ENABLE, \
4036 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4037 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004038
David Collins6f032ba2011-08-31 14:08:15 -07004039#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004040 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4041 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004042 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4043 RPM_VREG_PIN_FN_8660_ENABLE, \
4044 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4045 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046
David Collins6f032ba2011-08-31 14:08:15 -07004047#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4048#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4049#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4050#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4051#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052
David Collins6f032ba2011-08-31 14:08:15 -07004053/* RPM early regulator constraints */
4054static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4055 /* ID a_on pd ss min_uV max_uV init_ip freq */
4056 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
4057 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004058};
4059
David Collins6f032ba2011-08-31 14:08:15 -07004060/* RPM regulator constraints */
4061static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4062 /* ID a_on pd ss min_uV max_uV init_ip */
4063 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4064 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4065 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4066 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4067 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4068 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4069 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4070 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4071 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4072 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4073 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4074 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4075 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4076 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4077 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4078 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4079 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4080 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4081 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4082 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4083 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4084 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4085 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4086 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4087 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4088 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004089
David Collins6f032ba2011-08-31 14:08:15 -07004090 /* ID a_on pd ss min_uV max_uV init_ip freq */
4091 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4092 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4093 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4094
4095 /* ID a_on pd ss */
4096 RPM_VS(PM8058_LVS0, 0, 1, 0),
4097 RPM_VS(PM8058_LVS1, 0, 1, 0),
4098
4099 /* ID a_on pd ss min_uV max_uV */
4100 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4101
4102 /* ID a_on pd ss min_uV max_uV init_ip */
4103 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4104 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4105 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4106 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4107 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4108 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4109 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4110
4111 /* ID a_on pd ss min_uV max_uV init_ip freq */
4112 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4113 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4114 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4115
4116 /* ID a_on pd ss */
4117 RPM_VS(PM8901_LVS0, 1, 1, 0),
4118 RPM_VS(PM8901_LVS1, 0, 1, 0),
4119 RPM_VS(PM8901_LVS2, 0, 1, 0),
4120 RPM_VS(PM8901_LVS3, 0, 1, 0),
4121 RPM_VS(PM8901_MVS0, 0, 1, 0),
4122
4123 /* ID a_on pin_func pin_ctrl */
4124 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4125 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4126 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4127 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4128 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4129 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4130};
4131
4132static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4133 .init_data = rpm_regulator_early_init_data,
4134 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4135 .version = RPM_VREG_VERSION_8660,
4136 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4137 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4138};
4139
4140static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4141 .init_data = rpm_regulator_init_data,
4142 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4143 .version = RPM_VREG_VERSION_8660,
4144};
4145
4146static struct platform_device rpm_regulator_early_device = {
4147 .name = "rpm-regulator",
4148 .id = 0,
4149 .dev = {
4150 .platform_data = &rpm_regulator_early_pdata,
4151 },
4152};
4153
4154static struct platform_device rpm_regulator_device = {
4155 .name = "rpm-regulator",
4156 .id = 1,
4157 .dev = {
4158 .platform_data = &rpm_regulator_pdata,
4159 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004160};
4161
4162static struct platform_device *early_regulators[] __initdata = {
4163 &msm_device_saw_s0,
4164 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004165 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004166};
4167
4168static struct platform_device *early_devices[] __initdata = {
4169#ifdef CONFIG_MSM_BUS_SCALING
4170 &msm_bus_apps_fabric,
4171 &msm_bus_sys_fabric,
4172 &msm_bus_mm_fabric,
4173 &msm_bus_sys_fpb,
4174 &msm_bus_cpss_fpb,
4175#endif
4176 &msm_device_dmov_adm0,
4177 &msm_device_dmov_adm1,
4178};
4179
4180#if (defined(CONFIG_MARIMBA_CORE)) && \
4181 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4182
4183static int bluetooth_power(int);
4184static struct platform_device msm_bt_power_device = {
4185 .name = "bt_power",
4186 .id = -1,
4187 .dev = {
4188 .platform_data = &bluetooth_power,
4189 },
4190};
4191#endif
4192
4193static struct platform_device msm_tsens_device = {
4194 .name = "tsens-tm",
4195 .id = -1,
4196};
4197
4198static struct platform_device *rumi_sim_devices[] __initdata = {
4199 &smc91x_device,
4200 &msm_device_uart_dm12,
4201#ifdef CONFIG_I2C_QUP
4202 &msm_gsbi3_qup_i2c_device,
4203 &msm_gsbi4_qup_i2c_device,
4204 &msm_gsbi7_qup_i2c_device,
4205 &msm_gsbi8_qup_i2c_device,
4206 &msm_gsbi9_qup_i2c_device,
4207 &msm_gsbi12_qup_i2c_device,
4208#endif
4209#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004210 &msm_device_ssbi3,
4211#endif
4212#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004213#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004214 &android_pmem_device,
4215 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004216 &android_pmem_smipool_device,
4217#endif
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004218 &android_pmem_audio_device,
4219#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004220#ifdef CONFIG_MSM_ROTATOR
4221 &msm_rotator_device,
4222#endif
4223 &msm_fb_device,
4224 &msm_kgsl_3d0,
4225 &msm_kgsl_2d0,
4226 &msm_kgsl_2d1,
4227 &lcdc_samsung_panel_device,
4228#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4229 &hdmi_msm_device,
4230#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4231#ifdef CONFIG_MSM_CAMERA
4232#ifdef CONFIG_MT9E013
4233 &msm_camera_sensor_mt9e013,
4234#endif
4235#ifdef CONFIG_IMX074
4236 &msm_camera_sensor_imx074,
4237#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004238#ifdef CONFIG_VX6953
4239 &msm_camera_sensor_vx6953,
4240#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004241#ifdef CONFIG_WEBCAM_OV7692
4242 &msm_camera_sensor_webcam_ov7692,
4243#endif
4244#ifdef CONFIG_WEBCAM_OV9726
4245 &msm_camera_sensor_webcam_ov9726,
4246#endif
4247#ifdef CONFIG_QS_S5K4E1
4248 &msm_camera_sensor_qs_s5k4e1,
4249#endif
4250#endif
4251#ifdef CONFIG_MSM_GEMINI
4252 &msm_gemini_device,
4253#endif
4254#ifdef CONFIG_MSM_VPE
4255 &msm_vpe_device,
4256#endif
4257 &msm_device_vidc,
4258};
4259
4260#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4261enum {
4262 SX150X_CORE,
4263 SX150X_DOCKING,
4264 SX150X_SURF,
4265 SX150X_LEFT_FHA,
4266 SX150X_RIGHT_FHA,
4267 SX150X_SOUTH,
4268 SX150X_NORTH,
4269 SX150X_CORE_FLUID,
4270};
4271
4272static struct sx150x_platform_data sx150x_data[] __initdata = {
4273 [SX150X_CORE] = {
4274 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4275 .oscio_is_gpo = false,
4276 .io_pullup_ena = 0x0c08,
4277 .io_pulldn_ena = 0x4060,
4278 .io_open_drain_ena = 0x000c,
4279 .io_polarity = 0,
4280 .irq_summary = -1, /* see fixup_i2c_configs() */
4281 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4282 },
4283 [SX150X_DOCKING] = {
4284 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4285 .oscio_is_gpo = false,
4286 .io_pullup_ena = 0x5e06,
4287 .io_pulldn_ena = 0x81b8,
4288 .io_open_drain_ena = 0,
4289 .io_polarity = 0,
4290 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4291 UI_INT2_N),
4292 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4293 GPIO_DOCKING_EXPANDER_BASE -
4294 GPIO_EXPANDER_GPIO_BASE,
4295 },
4296 [SX150X_SURF] = {
4297 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4298 .oscio_is_gpo = false,
4299 .io_pullup_ena = 0,
4300 .io_pulldn_ena = 0,
4301 .io_open_drain_ena = 0,
4302 .io_polarity = 0,
4303 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4304 UI_INT1_N),
4305 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4306 GPIO_SURF_EXPANDER_BASE -
4307 GPIO_EXPANDER_GPIO_BASE,
4308 },
4309 [SX150X_LEFT_FHA] = {
4310 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4311 .oscio_is_gpo = false,
4312 .io_pullup_ena = 0,
4313 .io_pulldn_ena = 0x40,
4314 .io_open_drain_ena = 0,
4315 .io_polarity = 0,
4316 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4317 UI_INT3_N),
4318 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4319 GPIO_LEFT_KB_EXPANDER_BASE -
4320 GPIO_EXPANDER_GPIO_BASE,
4321 },
4322 [SX150X_RIGHT_FHA] = {
4323 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4324 .oscio_is_gpo = true,
4325 .io_pullup_ena = 0,
4326 .io_pulldn_ena = 0,
4327 .io_open_drain_ena = 0,
4328 .io_polarity = 0,
4329 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4330 UI_INT3_N),
4331 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4332 GPIO_RIGHT_KB_EXPANDER_BASE -
4333 GPIO_EXPANDER_GPIO_BASE,
4334 },
4335 [SX150X_SOUTH] = {
4336 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4337 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4338 GPIO_SOUTH_EXPANDER_BASE -
4339 GPIO_EXPANDER_GPIO_BASE,
4340 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4341 },
4342 [SX150X_NORTH] = {
4343 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4344 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4345 GPIO_NORTH_EXPANDER_BASE -
4346 GPIO_EXPANDER_GPIO_BASE,
4347 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4348 .oscio_is_gpo = true,
4349 .io_open_drain_ena = 0x30,
4350 },
4351 [SX150X_CORE_FLUID] = {
4352 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4353 .oscio_is_gpo = false,
4354 .io_pullup_ena = 0x0408,
4355 .io_pulldn_ena = 0x4060,
4356 .io_open_drain_ena = 0x0008,
4357 .io_polarity = 0,
4358 .irq_summary = -1, /* see fixup_i2c_configs() */
4359 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4360 },
4361};
4362
4363#ifdef CONFIG_SENSORS_MSM_ADC
4364/* Configuration of EPM expander is done when client
4365 * request an adc read
4366 */
4367static struct sx150x_platform_data sx150x_epmdata = {
4368 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4369 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4370 GPIO_EPM_EXPANDER_BASE -
4371 GPIO_EXPANDER_GPIO_BASE,
4372 .irq_summary = -1,
4373};
4374#endif
4375
4376/* sx150x_low_power_cfg
4377 *
4378 * This data and init function are used to put unused gpio-expander output
4379 * lines into their low-power states at boot. The init
4380 * function must be deferred until a later init stage because the i2c
4381 * gpio expander drivers do not probe until after they are registered
4382 * (see register_i2c_devices) and the work-queues for those registrations
4383 * are processed. Because these lines are unused, there is no risk of
4384 * competing with a device driver for the gpio.
4385 *
4386 * gpio lines whose low-power states are input are naturally in their low-
4387 * power configurations once probed, see the platform data structures above.
4388 */
4389struct sx150x_low_power_cfg {
4390 unsigned gpio;
4391 unsigned val;
4392};
4393
4394static struct sx150x_low_power_cfg
4395common_sx150x_lp_cfgs[] __initdata = {
4396 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4397 {GPIO_EXT_GPS_LNA_EN, 0},
4398 {GPIO_MSM_WAKES_BT, 0},
4399 {GPIO_USB_UICC_EN, 0},
4400 {GPIO_BATT_GAUGE_EN, 0},
4401};
4402
4403static struct sx150x_low_power_cfg
4404surf_ffa_sx150x_lp_cfgs[] __initdata = {
4405 {GPIO_MIPI_DSI_RST_N, 0},
4406 {GPIO_DONGLE_PWR_EN, 0},
4407 {GPIO_CAP_TS_SLEEP, 1},
4408 {GPIO_WEB_CAMIF_RESET_N, 0},
4409};
4410
4411static void __init
4412cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4413{
4414 unsigned n;
4415 int rc;
4416
4417 for (n = 0; n < nelems; ++n) {
4418 rc = gpio_request(cfgs[n].gpio, NULL);
4419 if (!rc) {
4420 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4421 gpio_free(cfgs[n].gpio);
4422 }
4423
4424 if (rc) {
4425 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4426 __func__, cfgs[n].gpio, rc);
4427 }
Steve Muckle9161d302010-02-11 11:50:40 -08004428 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004429}
4430
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004431static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004432{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004433 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4434 ARRAY_SIZE(common_sx150x_lp_cfgs));
4435 if (!machine_is_msm8x60_fluid())
4436 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4437 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4438 return 0;
4439}
4440module_init(cfg_sx150xs_low_power);
4441
4442#ifdef CONFIG_I2C
4443static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4444 {
4445 I2C_BOARD_INFO("sx1509q", 0x3e),
4446 .platform_data = &sx150x_data[SX150X_CORE]
4447 },
4448};
4449
4450static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4451 {
4452 I2C_BOARD_INFO("sx1509q", 0x3f),
4453 .platform_data = &sx150x_data[SX150X_DOCKING]
4454 },
4455};
4456
4457static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4458 {
4459 I2C_BOARD_INFO("sx1509q", 0x70),
4460 .platform_data = &sx150x_data[SX150X_SURF]
4461 }
4462};
4463
4464static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4465 {
4466 I2C_BOARD_INFO("sx1508q", 0x21),
4467 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4468 },
4469 {
4470 I2C_BOARD_INFO("sx1508q", 0x22),
4471 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4472 }
4473};
4474
4475static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4476 {
4477 I2C_BOARD_INFO("sx1508q", 0x23),
4478 .platform_data = &sx150x_data[SX150X_SOUTH]
4479 },
4480 {
4481 I2C_BOARD_INFO("sx1508q", 0x20),
4482 .platform_data = &sx150x_data[SX150X_NORTH]
4483 }
4484};
4485
4486static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4487 {
4488 I2C_BOARD_INFO("sx1509q", 0x3e),
4489 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4490 },
4491};
4492
4493#ifdef CONFIG_SENSORS_MSM_ADC
4494static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4495 {
4496 I2C_BOARD_INFO("sx1509q", 0x3e),
4497 .platform_data = &sx150x_epmdata
4498 },
4499};
4500#endif
4501#endif
4502#endif
4503
4504#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004505
4506static struct adc_access_fn xoadc_fn = {
4507 pm8058_xoadc_select_chan_and_start_conv,
4508 pm8058_xoadc_read_adc_code,
4509 pm8058_xoadc_get_properties,
4510 pm8058_xoadc_slot_request,
4511 pm8058_xoadc_restore_slot,
4512 pm8058_xoadc_calibrate,
4513};
4514
4515#if defined(CONFIG_I2C) && \
4516 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4517static struct regulator *vreg_adc_epm1;
4518
4519static struct i2c_client *epm_expander_i2c_register_board(void)
4520
4521{
4522 struct i2c_adapter *i2c_adap;
4523 struct i2c_client *client = NULL;
4524 i2c_adap = i2c_get_adapter(0x0);
4525
4526 if (i2c_adap == NULL)
4527 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4528
4529 if (i2c_adap != NULL)
4530 client = i2c_new_device(i2c_adap,
4531 &fluid_expanders_i2c_epm_info[0]);
4532 return client;
4533
4534}
4535
4536static unsigned int msm_adc_gpio_configure_expander_enable(void)
4537{
4538 int rc = 0;
4539 static struct i2c_client *epm_i2c_client;
4540
4541 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4542
4543 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4544
4545 if (IS_ERR(vreg_adc_epm1)) {
4546 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4547 return 0;
4548 }
4549
4550 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4551 if (rc)
4552 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4553 "regulator set voltage failed\n");
4554
4555 rc = regulator_enable(vreg_adc_epm1);
4556 if (rc) {
4557 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4558 "Error while enabling regulator for epm s3 %d\n", rc);
4559 return rc;
4560 }
4561
4562 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4563 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4564
4565 msleep(1000);
4566
4567 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4568 if (!rc) {
4569 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4570 "Configure 5v boost\n");
4571 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4572 } else {
4573 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4574 "Error for epm 5v boost en\n");
4575 goto exit_vreg_epm;
4576 }
4577
4578 msleep(500);
4579
4580 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4581 if (!rc) {
4582 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4583 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4584 "Configure epm 3.3v\n");
4585 } else {
4586 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4587 "Error for gpio 3.3ven\n");
4588 goto exit_vreg_epm;
4589 }
4590 msleep(500);
4591
4592 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4593 "Trying to request EPM LVLSFT_EN\n");
4594 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4595 if (!rc) {
4596 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4597 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4598 "Configure the lvlsft\n");
4599 } else {
4600 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4601 "Error for epm lvlsft_en\n");
4602 goto exit_vreg_epm;
4603 }
4604
4605 msleep(500);
4606
4607 if (!epm_i2c_client)
4608 epm_i2c_client = epm_expander_i2c_register_board();
4609
4610 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4611 if (!rc)
4612 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4613 if (rc) {
4614 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4615 ": GPIO PWR MON Enable issue\n");
4616 goto exit_vreg_epm;
4617 }
4618
4619 msleep(1000);
4620
4621 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4622 if (!rc) {
4623 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4624 if (rc) {
4625 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4626 ": ADC1_PWDN error direction out\n");
4627 goto exit_vreg_epm;
4628 }
4629 }
4630
4631 msleep(100);
4632
4633 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4634 if (!rc) {
4635 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4636 if (rc) {
4637 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4638 ": ADC2_PWD error direction out\n");
4639 goto exit_vreg_epm;
4640 }
4641 }
4642
4643 msleep(1000);
4644
4645 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4646 if (!rc) {
4647 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4648 if (rc) {
4649 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4650 "Gpio request problem %d\n", rc);
4651 goto exit_vreg_epm;
4652 }
4653 }
4654
4655 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4656 if (!rc) {
4657 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4658 if (rc) {
4659 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4660 ": EPM_SPI_ADC1_CS_N error\n");
4661 goto exit_vreg_epm;
4662 }
4663 }
4664
4665 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4666 if (!rc) {
4667 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4668 if (rc) {
4669 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4670 ": EPM_SPI_ADC2_Cs_N error\n");
4671 goto exit_vreg_epm;
4672 }
4673 }
4674
4675 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4676 "the power monitor reset for epm\n");
4677
4678 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4679 if (!rc) {
4680 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4681 if (rc) {
4682 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4683 ": Error in the power mon reset\n");
4684 goto exit_vreg_epm;
4685 }
4686 }
4687
4688 msleep(1000);
4689
4690 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4691
4692 msleep(500);
4693
4694 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4695
4696 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4697
4698 return rc;
4699
4700exit_vreg_epm:
4701 regulator_disable(vreg_adc_epm1);
4702
4703 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4704 " rc = %d.\n", rc);
4705 return rc;
4706};
4707
4708static unsigned int msm_adc_gpio_configure_expander_disable(void)
4709{
4710 int rc = 0;
4711
4712 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4713 gpio_free(GPIO_PWR_MON_RESET_N);
4714
4715 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4716 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4717
4718 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4719 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4720
4721 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4722 gpio_free(GPIO_PWR_MON_START);
4723
4724 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4725 gpio_free(GPIO_ADC1_PWDN_N);
4726
4727 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4728 gpio_free(GPIO_ADC2_PWDN_N);
4729
4730 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4731 gpio_free(GPIO_PWR_MON_ENABLE);
4732
4733 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4734 gpio_free(GPIO_EPM_LVLSFT_EN);
4735
4736 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4737 gpio_free(GPIO_EPM_5V_BOOST_EN);
4738
4739 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4740 gpio_free(GPIO_EPM_3_3V_EN);
4741
4742 rc = regulator_disable(vreg_adc_epm1);
4743 if (rc)
4744 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4745 "Error while enabling regulator for epm s3 %d\n", rc);
4746 regulator_put(vreg_adc_epm1);
4747
4748 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4749 return rc;
4750};
4751
4752unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4753{
4754 int rc = 0;
4755
4756 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4757 cs_enable);
4758
4759 if (cs_enable < 16) {
4760 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4761 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4762 } else {
4763 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4764 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4765 }
4766 return rc;
4767};
4768
4769unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4770{
4771 int rc = 0;
4772
4773 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4774
4775 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4776
4777 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4778
4779 return rc;
4780};
4781#endif
4782
4783static struct msm_adc_channels msm_adc_channels_data[] = {
4784 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4785 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4786 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4787 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4788 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4789 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4790 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4791 CHAN_PATH_TYPE4,
4792 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4793 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4794 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4795 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4796 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4797 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4798 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4799 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4800 CHAN_PATH_TYPE12,
4801 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4802 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4803 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4804 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4805 CHAN_PATH_TYPE_NONE,
4806 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4807 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4808 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4809 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4810 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4811 scale_xtern_chgr_cur},
4812 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4813 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4814 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4815 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4816 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4817 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4818 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4819 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4820 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4822 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4823 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4824};
4825
4826static char *msm_adc_fluid_device_names[] = {
4827 "ADS_ADC1",
4828 "ADS_ADC2",
4829};
4830
4831static struct msm_adc_platform_data msm_adc_pdata = {
4832 .channel = msm_adc_channels_data,
4833 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4834#if defined(CONFIG_I2C) && \
4835 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4836 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4837 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4838 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4839 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4840#endif
4841};
4842
4843static struct platform_device msm_adc_device = {
4844 .name = "msm_adc",
4845 .id = -1,
4846 .dev = {
4847 .platform_data = &msm_adc_pdata,
4848 },
4849};
4850
4851static void pmic8058_xoadc_mpp_config(void)
4852{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304853 int rc, i;
4854 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304855 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304856 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304857 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304858 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304859 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304860 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304861 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304862 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304863 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304864 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304865 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4866 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304867 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004868
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304869 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4870 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4871 &xoadc_mpps[i].config);
4872 if (rc) {
4873 pr_err("%s: Config MPP %d of PM8058 failed\n",
4874 __func__, xoadc_mpps[i].mpp);
4875 }
4876 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004877}
4878
4879static struct regulator *vreg_ldo18_adc;
4880
4881static int pmic8058_xoadc_vreg_config(int on)
4882{
4883 int rc;
4884
4885 if (on) {
4886 rc = regulator_enable(vreg_ldo18_adc);
4887 if (rc)
4888 pr_err("%s: Enable of regulator ldo18_adc "
4889 "failed\n", __func__);
4890 } else {
4891 rc = regulator_disable(vreg_ldo18_adc);
4892 if (rc)
4893 pr_err("%s: Disable of regulator ldo18_adc "
4894 "failed\n", __func__);
4895 }
4896
4897 return rc;
4898}
4899
4900static int pmic8058_xoadc_vreg_setup(void)
4901{
4902 int rc;
4903
4904 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4905 if (IS_ERR(vreg_ldo18_adc)) {
4906 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4907 __func__, PTR_ERR(vreg_ldo18_adc));
4908 rc = PTR_ERR(vreg_ldo18_adc);
4909 goto fail;
4910 }
4911
4912 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4913 if (rc) {
4914 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4915 goto fail;
4916 }
4917
4918 return rc;
4919fail:
4920 regulator_put(vreg_ldo18_adc);
4921 return rc;
4922}
4923
4924static void pmic8058_xoadc_vreg_shutdown(void)
4925{
4926 regulator_put(vreg_ldo18_adc);
4927}
4928
4929/* usec. For this ADC,
4930 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4931 * Each channel has different configuration, thus at the time of starting
4932 * the conversion, xoadc will return actual conversion time
4933 * */
4934static struct adc_properties pm8058_xoadc_data = {
4935 .adc_reference = 2200, /* milli-voltage for this adc */
4936 .bitresolution = 15,
4937 .bipolar = 0,
4938 .conversiontime = 54,
4939};
4940
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304941static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004942 .xoadc_prop = &pm8058_xoadc_data,
4943 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4944 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4945 .xoadc_num = XOADC_PMIC_0,
4946 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4947 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4948};
4949#endif
4950
4951#ifdef CONFIG_MSM_SDIO_AL
4952
4953static unsigned mdm2ap_status = 140;
4954
4955static int configure_mdm2ap_status(int on)
4956{
4957 int ret = 0;
4958 if (on)
4959 ret = msm_gpiomux_get(mdm2ap_status);
4960 else
4961 ret = msm_gpiomux_put(mdm2ap_status);
4962
4963 if (ret)
4964 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4965 on);
4966
4967 return ret;
4968}
4969
4970
4971static int get_mdm2ap_status(void)
4972{
4973 return gpio_get_value(mdm2ap_status);
4974}
4975
4976static struct sdio_al_platform_data sdio_al_pdata = {
4977 .config_mdm2ap_status = configure_mdm2ap_status,
4978 .get_mdm2ap_status = get_mdm2ap_status,
4979 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004980 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004981 .peer_sdioc_version_major = 0x0004,
4982 .peer_sdioc_boot_version_minor = 0x0001,
4983 .peer_sdioc_boot_version_major = 0x0003
4984};
4985
4986struct platform_device msm_device_sdio_al = {
4987 .name = "msm_sdio_al",
4988 .id = -1,
4989 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004990 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004991 .platform_data = &sdio_al_pdata,
4992 },
4993};
4994
4995#endif /* CONFIG_MSM_SDIO_AL */
4996
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304997#define GPIO_VREG_ID_EXT_5V 0
4998
4999static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5000 REGULATOR_SUPPLY("ext_5v", NULL),
5001 REGULATOR_SUPPLY("8901_mpp0", NULL),
5002};
5003
5004#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5005 [GPIO_VREG_ID_##_id] = { \
5006 .init_data = { \
5007 .constraints = { \
5008 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5009 }, \
5010 .num_consumer_supplies = \
5011 ARRAY_SIZE(vreg_consumers_##_id), \
5012 .consumer_supplies = vreg_consumers_##_id, \
5013 }, \
5014 .regulator_name = _reg_name, \
5015 .active_low = _active_low, \
5016 .gpio_label = _gpio_label, \
5017 .gpio = _gpio, \
5018 }
5019
5020/* GPIO regulator constraints */
5021static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5022 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5023 PM8901_MPP_PM_TO_SYS(0), 0),
5024};
5025
5026/* GPIO regulator */
5027static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5028 .name = GPIO_REGULATOR_DEV_NAME,
5029 .id = PM8901_MPP_PM_TO_SYS(0),
5030 .dev = {
5031 .platform_data =
5032 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5033 },
5034};
5035
5036static void __init pm8901_vreg_mpp0_init(void)
5037{
5038 int rc;
5039
5040 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5041 .mpp = PM8901_MPP_PM_TO_SYS(0),
5042 .config = {
5043 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5044 .level = PM8901_MPP_DIG_LEVEL_VPH,
5045 },
5046 };
5047
5048 /*
5049 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5050 * implies that the regulator connected to MPP0 is enabled when
5051 * MPP0 is low.
5052 */
5053 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5054 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5055 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5056 } else {
5057 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5058 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5059 }
5060
5061 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5062 if (rc)
5063 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5064}
5065
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005066static struct platform_device *charm_devices[] __initdata = {
5067 &msm_charm_modem,
5068#ifdef CONFIG_MSM_SDIO_AL
5069 &msm_device_sdio_al,
5070#endif
5071};
5072
Lei Zhou338cab82011-08-19 13:38:17 -04005073#ifdef CONFIG_SND_SOC_MSM8660_APQ
5074static struct platform_device *dragon_alsa_devices[] __initdata = {
5075 &msm_pcm,
5076 &msm_pcm_routing,
5077 &msm_cpudai0,
5078 &msm_cpudai1,
5079 &msm_cpudai_hdmi_rx,
5080 &msm_cpudai_bt_rx,
5081 &msm_cpudai_bt_tx,
5082 &msm_cpudai_fm_rx,
5083 &msm_cpudai_fm_tx,
5084 &msm_cpu_fe,
5085 &msm_stub_codec,
5086 &msm_lpa_pcm,
5087};
5088#endif
5089
5090static struct platform_device *asoc_devices[] __initdata = {
5091 &asoc_msm_pcm,
5092 &asoc_msm_dai0,
5093 &asoc_msm_dai1,
5094};
5095
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005096static struct platform_device *surf_devices[] __initdata = {
5097 &msm_device_smd,
5098 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005099 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005100 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005101 &msm_pil_tzapps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005102#ifdef CONFIG_I2C_QUP
5103 &msm_gsbi3_qup_i2c_device,
5104 &msm_gsbi4_qup_i2c_device,
5105 &msm_gsbi7_qup_i2c_device,
5106 &msm_gsbi8_qup_i2c_device,
5107 &msm_gsbi9_qup_i2c_device,
5108 &msm_gsbi12_qup_i2c_device,
5109#endif
5110#ifdef CONFIG_SERIAL_MSM_HS
5111 &msm_device_uart_dm1,
5112#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305113#ifdef CONFIG_MSM_SSBI
5114 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305115 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305116#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005117#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005118 &msm_device_ssbi3,
5119#endif
5120#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5121 &isp1763_device,
5122#endif
5123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005124#if defined (CONFIG_MSM_8x60_VOIP)
5125 &asoc_msm_mvs,
5126 &asoc_mvs_dai0,
5127 &asoc_mvs_dai1,
5128#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005130#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
5131 &msm_device_otg,
5132#endif
5133#ifdef CONFIG_USB_GADGET_MSM_72K
5134 &msm_device_gadget_peripheral,
5135#endif
5136#ifdef CONFIG_USB_G_ANDROID
5137 &android_usb_device,
5138#endif
5139#ifdef CONFIG_BATTERY_MSM
5140 &msm_batt_device,
5141#endif
5142#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005143#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005144 &android_pmem_device,
5145 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005146 &android_pmem_smipool_device,
5147#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005148 &android_pmem_audio_device,
5149#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005150#ifdef CONFIG_MSM_ROTATOR
5151 &msm_rotator_device,
5152#endif
5153 &msm_fb_device,
5154 &msm_kgsl_3d0,
5155 &msm_kgsl_2d0,
5156 &msm_kgsl_2d1,
5157 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005158#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5159 &lcdc_nt35582_panel_device,
5160#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005161#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5162 &lcdc_samsung_oled_panel_device,
5163#endif
5164#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5165 &lcdc_auo_wvga_panel_device,
5166#endif
5167#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5168 &hdmi_msm_device,
5169#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5170#ifdef CONFIG_FB_MSM_MIPI_DSI
5171 &mipi_dsi_toshiba_panel_device,
5172 &mipi_dsi_novatek_panel_device,
5173#endif
5174#ifdef CONFIG_MSM_CAMERA
5175#ifdef CONFIG_MT9E013
5176 &msm_camera_sensor_mt9e013,
5177#endif
5178#ifdef CONFIG_IMX074
5179 &msm_camera_sensor_imx074,
5180#endif
5181#ifdef CONFIG_WEBCAM_OV7692
5182 &msm_camera_sensor_webcam_ov7692,
5183#endif
5184#ifdef CONFIG_WEBCAM_OV9726
5185 &msm_camera_sensor_webcam_ov9726,
5186#endif
5187#ifdef CONFIG_QS_S5K4E1
5188 &msm_camera_sensor_qs_s5k4e1,
5189#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005190#ifdef CONFIG_VX6953
5191 &msm_camera_sensor_vx6953,
5192#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005193#endif
5194#ifdef CONFIG_MSM_GEMINI
5195 &msm_gemini_device,
5196#endif
5197#ifdef CONFIG_MSM_VPE
5198 &msm_vpe_device,
5199#endif
5200
5201#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005202 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203#endif
5204#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005205 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005206#endif
5207 &msm_device_vidc,
5208#if (defined(CONFIG_MARIMBA_CORE)) && \
5209 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5210 &msm_bt_power_device,
5211#endif
5212#ifdef CONFIG_SENSORS_MSM_ADC
5213 &msm_adc_device,
5214#endif
David Collins6f032ba2011-08-31 14:08:15 -07005215 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005216
5217#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5218 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5219 &qcrypto_device,
5220#endif
5221
5222#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5223 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5224 &qcedev_device,
5225#endif
5226
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005227
5228#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5229#ifdef CONFIG_MSM_USE_TSIF1
5230 &msm_device_tsif[1],
5231#else
5232 &msm_device_tsif[0],
5233#endif /* CONFIG_MSM_USE_TSIF1 */
5234#endif /* CONFIG_TSIF */
5235
5236#ifdef CONFIG_HW_RANDOM_MSM
5237 &msm_device_rng,
5238#endif
5239
5240 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005241 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005242#ifdef CONFIG_ION_MSM
5243 &ion_dev,
5244#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005245 &msm8660_device_watchdog,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005246};
5247
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005248#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005249#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5250static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5251 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan42ebe712012-01-10 16:30:58 -08005252 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005253 .request_region = request_smi_region,
5254 .release_region = release_smi_region,
5255 .setup_region = setup_smi_region,
5256};
5257
5258static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5259 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005260 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005261 .request_region = request_smi_region,
5262 .release_region = release_smi_region,
5263 .setup_region = setup_smi_region,
5264};
5265
5266static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5267 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005268 .align = PAGE_SIZE,
5269};
5270
5271static struct ion_co_heap_pdata fw_co_ion_pdata = {
5272 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5273 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005274};
5275
5276static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005277 .adjacent_mem_id = INVALID_HEAP_ID,
5278 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005279};
5280#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005281
5282/**
5283 * These heaps are listed in the order they will be allocated. Due to
5284 * video hardware restrictions and content protection the FW heap has to
5285 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5286 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5287 * away from the base address of the FW heap.
5288 * However, the order of FW heap and MM heap doesn't matter since these
5289 * two heaps are taken care of by separate code to ensure they are adjacent
5290 * to each other.
5291 * Don't swap the order unless you know what you are doing!
5292 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005293static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005294 .nr = MSM_ION_HEAP_NUM,
5295 .heaps = {
5296 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005297 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005298 .type = ION_HEAP_TYPE_SYSTEM,
5299 .name = ION_VMALLOC_HEAP_NAME,
5300 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005301#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5302 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005303 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005304 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005305 .name = ION_MM_HEAP_NAME,
5306 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005307 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005308 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005309 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005310 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005311 .id = ION_MM_FIRMWARE_HEAP_ID,
5312 .type = ION_HEAP_TYPE_CARVEOUT,
5313 .name = ION_MM_FIRMWARE_HEAP_NAME,
5314 .size = MSM_ION_MM_FW_SIZE,
5315 .memory_type = ION_SMI_TYPE,
5316 .extra_data = (void *) &fw_co_ion_pdata,
5317 },
5318 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005319 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005320 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005321 .name = ION_MFC_HEAP_NAME,
5322 .size = MSM_ION_MFC_SIZE,
5323 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005324 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005325 },
5326 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005327 .id = ION_SF_HEAP_ID,
5328 .type = ION_HEAP_TYPE_CARVEOUT,
5329 .name = ION_SF_HEAP_NAME,
5330 .size = MSM_ION_SF_SIZE,
5331 .memory_type = ION_EBI_TYPE,
5332 .extra_data = (void *)&co_ion_pdata,
5333 },
5334 {
5335 .id = ION_CAMERA_HEAP_ID,
5336 .type = ION_HEAP_TYPE_CARVEOUT,
5337 .name = ION_CAMERA_HEAP_NAME,
5338 .size = MSM_ION_CAMERA_SIZE,
5339 .memory_type = ION_EBI_TYPE,
5340 .extra_data = &co_ion_pdata,
5341 },
5342 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005343 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005344 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005345 .name = ION_WB_HEAP_NAME,
5346 .size = MSM_ION_WB_SIZE,
5347 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005348 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005349 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005350 {
5351 .id = ION_AUDIO_HEAP_ID,
5352 .type = ION_HEAP_TYPE_CARVEOUT,
5353 .name = ION_AUDIO_HEAP_NAME,
5354 .size = MSM_ION_AUDIO_SIZE,
5355 .memory_type = ION_EBI_TYPE,
5356 .extra_data = (void *)&co_ion_pdata,
5357 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005358#endif
5359 }
5360};
5361
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005362static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005363 .name = "ion-msm",
5364 .id = 1,
5365 .dev = { .platform_data = &ion_pdata },
5366};
5367#endif
5368
5369
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005370static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5371 /* Kernel SMI memory pool for video core, used for firmware */
5372 /* and encoder, decoder scratch buffers */
5373 /* Kernel SMI memory pool should always precede the user space */
5374 /* SMI memory pool, as the video core will use offset address */
5375 /* from the Firmware base */
5376 [MEMTYPE_SMI_KERNEL] = {
5377 .start = KERNEL_SMI_BASE,
5378 .limit = KERNEL_SMI_SIZE,
5379 .size = KERNEL_SMI_SIZE,
5380 .flags = MEMTYPE_FLAGS_FIXED,
5381 },
5382 /* User space SMI memory pool for video core */
5383 /* used for encoder, decoder input & output buffers */
5384 [MEMTYPE_SMI] = {
5385 .start = USER_SMI_BASE,
5386 .limit = USER_SMI_SIZE,
5387 .flags = MEMTYPE_FLAGS_FIXED,
5388 },
5389 [MEMTYPE_EBI0] = {
5390 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5391 },
5392 [MEMTYPE_EBI1] = {
5393 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5394 },
5395};
5396
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005397static void reserve_ion_memory(void)
5398{
5399#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Olav Hauganb5be7992011-11-18 14:29:02 -08005400 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
Olav Haugan42ebe712012-01-10 16:30:58 -08005401 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005402 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5403 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5404 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5405 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005406 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005407#endif
5408}
5409
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005410static void __init size_pmem_devices(void)
5411{
5412#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005413#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005414 android_pmem_adsp_pdata.size = pmem_adsp_size;
5415 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005416 android_pmem_pdata.size = pmem_sf_size;
5417#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005418 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
5419#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005420}
5421
5422static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5423{
5424 msm8x60_reserve_table[p->memory_type].size += p->size;
5425}
5426
5427static void __init reserve_pmem_memory(void)
5428{
5429#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005430#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005431 reserve_memory_for(&android_pmem_adsp_pdata);
5432 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005433 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005434#endif
5435 reserve_memory_for(&android_pmem_audio_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005436 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
5437#endif
5438}
5439
Huaibin Yanga5419422011-12-08 23:52:10 -08005440static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005441
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005442static void __init msm8x60_calculate_reserve_sizes(void)
5443{
5444 size_pmem_devices();
5445 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005446 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005447 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005448}
5449
5450static int msm8x60_paddr_to_memtype(unsigned int paddr)
5451{
5452 if (paddr >= 0x40000000 && paddr < 0x60000000)
5453 return MEMTYPE_EBI1;
5454 if (paddr >= 0x38000000 && paddr < 0x40000000)
5455 return MEMTYPE_SMI;
5456 return MEMTYPE_NONE;
5457}
5458
5459static struct reserve_info msm8x60_reserve_info __initdata = {
5460 .memtype_reserve_table = msm8x60_reserve_table,
5461 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5462 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5463};
5464
5465static void __init msm8x60_reserve(void)
5466{
5467 reserve_info = &msm8x60_reserve_info;
5468 msm_reserve();
5469}
5470
5471#define EXT_CHG_VALID_MPP 10
5472#define EXT_CHG_VALID_MPP_2 11
5473
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305474static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305475 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305476 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305477 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305478 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5479};
5480
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005481#ifdef CONFIG_ISL9519_CHARGER
5482static int isl_detection_setup(void)
5483{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305484 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005485
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305486 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5487 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5488 &isl_mpp[i].config);
5489 if (ret) {
5490 pr_err("%s: Config MPP %d of PM8058 failed\n",
5491 __func__, isl_mpp[i].mpp);
5492 return ret;
5493 }
5494 }
5495
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005496 return ret;
5497}
5498
5499static struct isl_platform_data isl_data __initdata = {
5500 .chgcurrent = 700,
5501 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5502 .chg_detection_config = isl_detection_setup,
5503 .max_system_voltage = 4200,
5504 .min_system_voltage = 3200,
5505 .term_current = 120,
5506 .input_current = 2048,
5507};
5508
5509static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5510 {
5511 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305512 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005513 .platform_data = &isl_data,
5514 },
5515};
5516#endif
5517
5518#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5519static int smb137b_detection_setup(void)
5520{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305521 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305523 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5524 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5525 &isl_mpp[i].config);
5526 if (ret) {
5527 pr_err("%s: Config MPP %d of PM8058 failed\n",
5528 __func__, isl_mpp[i].mpp);
5529 return ret;
5530 }
5531 }
5532
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005533 return ret;
5534}
5535
5536static struct smb137b_platform_data smb137b_data __initdata = {
5537 .chg_detection_config = smb137b_detection_setup,
5538 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5539 .batt_mah_rating = 950,
5540};
5541
5542static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5543 {
5544 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305545 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005546 .platform_data = &smb137b_data,
5547 },
5548};
5549#endif
5550
5551#ifdef CONFIG_PMIC8058
5552#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305553#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005554
5555static int pm8058_gpios_init(void)
5556{
5557 int i;
5558 int rc;
5559 struct pm8058_gpio_cfg {
5560 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305561 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005562 };
5563
5564 struct pm8058_gpio_cfg gpio_cfgs[] = {
5565 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305566 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005567 {
5568 .direction = PM_GPIO_DIR_IN,
5569 .pull = PM_GPIO_PULL_DN,
5570 .vin_sel = 2,
5571 .function = PM_GPIO_FUNC_NORMAL,
5572 .inv_int_pol = 0,
5573 },
5574 },
5575#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5576 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305577 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005578 {
5579 .direction = PM_GPIO_DIR_IN,
5580 .pull = PM_GPIO_PULL_UP_30,
5581 .vin_sel = 2,
5582 .function = PM_GPIO_FUNC_NORMAL,
5583 .inv_int_pol = 0,
5584 },
5585 },
5586#endif
5587 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305588 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005589 {
5590 .direction = PM_GPIO_DIR_IN,
5591 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305592 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593 .function = PM_GPIO_FUNC_NORMAL,
5594 .inv_int_pol = 0,
5595 },
5596 },
5597 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305598 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005599 {
5600 .direction = PM_GPIO_DIR_IN,
5601 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305602 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005603 .function = PM_GPIO_FUNC_NORMAL,
5604 .inv_int_pol = 0,
5605 },
5606 },
5607 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305608 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005609 {
5610 .direction = PM_GPIO_DIR_IN,
5611 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305612 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005613 .function = PM_GPIO_FUNC_NORMAL,
5614 .inv_int_pol = 0,
5615 },
5616 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005617 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305618 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005619 {
5620 .direction = PM_GPIO_DIR_OUT,
5621 .output_value = 1,
5622 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5623 .pull = PM_GPIO_PULL_DN,
5624 .out_strength = PM_GPIO_STRENGTH_HIGH,
5625 .function = PM_GPIO_FUNC_NORMAL,
5626 .vin_sel = 2,
5627 .inv_int_pol = 0,
5628 }
5629 },
5630 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305631 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005632 {
5633 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305634 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005635 .function = PM_GPIO_FUNC_NORMAL,
5636 .vin_sel = 2,
5637 .inv_int_pol = 0,
5638 }
5639 },
5640 };
5641
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305642#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5643 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305644 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305645 .direction = PM_GPIO_DIR_IN,
5646 .pull = PM_GPIO_PULL_UP_1P5,
5647 .vin_sel = 2,
5648 .function = PM_GPIO_FUNC_NORMAL,
5649 };
5650#endif
5651
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005652#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305653 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305654 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305655 .direction = PM_GPIO_DIR_OUT,
5656 .pull = PM_GPIO_PULL_NO,
5657 .out_strength = PM_GPIO_STRENGTH_HIGH,
5658 .function = PM_GPIO_FUNC_NORMAL,
5659 .inv_int_pol = 0,
5660 .vin_sel = 2,
5661 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5662 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005663 };
5664#endif
5665
5666#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5667 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305668 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005669 {
5670 .direction = PM_GPIO_DIR_IN,
5671 .pull = PM_GPIO_PULL_UP_1P5,
5672 .vin_sel = 2,
5673 .function = PM_GPIO_FUNC_NORMAL,
5674 .inv_int_pol = 0,
5675 }
5676 };
5677#endif
5678
5679#if defined(CONFIG_QS_S5K4E1)
5680 {
5681 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305682 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005683 {
5684 .direction = PM_GPIO_DIR_OUT,
5685 .output_value = 0,
5686 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5687 .pull = PM_GPIO_PULL_DN,
5688 .out_strength = PM_GPIO_STRENGTH_HIGH,
5689 .function = PM_GPIO_FUNC_NORMAL,
5690 .vin_sel = 2,
5691 .inv_int_pol = 0,
5692 }
5693 };
5694#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005695#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5696 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305697 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005698 {
5699 .direction = PM_GPIO_DIR_OUT,
5700 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5701 .output_value = 1,
5702 .pull = PM_GPIO_PULL_UP_30,
5703 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305704 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005705 .out_strength = PM_GPIO_STRENGTH_HIGH,
5706 .function = PM_GPIO_FUNC_NORMAL,
5707 .inv_int_pol = 0,
5708 }
5709 };
5710#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005711#if defined(CONFIG_HAPTIC_ISA1200) || \
5712 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5713 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305714 rc = pm8xxx_gpio_config(
5715 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5716 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005717 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305718 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305720 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305721 rc = pm8xxx_gpio_config(
5722 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5723 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305724 if (rc < 0) {
5725 pr_err("%s: pmic haptics ldo gpio config failed\n",
5726 __func__);
5727 }
5728
5729 }
5730#endif
5731
5732#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5733 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5734 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5735 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305736 rc = pm8xxx_gpio_config(
5737 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5738 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305739 if (rc < 0) {
5740 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5741 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005742 }
5743 }
5744#endif
5745
5746#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5747 /* Line_in only for 8660 ffa & surf */
5748 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005749 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005750 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305751 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752 &line_in_gpio_cfg.cfg);
5753 if (rc < 0) {
5754 pr_err("%s pmic line_in gpio config failed\n",
5755 __func__);
5756 return rc;
5757 }
5758 }
5759#endif
5760
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005761#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5762 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305763 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005764 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5765 if (rc < 0) {
5766 pr_err("%s pmic gpio config failed\n", __func__);
5767 return rc;
5768 }
5769 }
5770#endif
5771
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005772#if defined(CONFIG_QS_S5K4E1)
5773 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5774 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305775 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005776 &qs_hc37_cam_pd_gpio_cfg.cfg);
5777 if (rc < 0) {
5778 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5779 __func__);
5780 return rc;
5781 }
5782 }
5783 }
5784#endif
5785
5786 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305787 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788 &gpio_cfgs[i].cfg);
5789 if (rc < 0) {
5790 pr_err("%s pmic gpio config failed\n",
5791 __func__);
5792 return rc;
5793 }
5794 }
5795
5796 return 0;
5797}
5798
5799static const unsigned int ffa_keymap[] = {
5800 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5801 KEY(0, 1, KEY_UP), /* NAV - UP */
5802 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5803 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5804
5805 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5806 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5807 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5808 KEY(1, 3, KEY_VOLUMEDOWN),
5809
5810 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5811
5812 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5813 KEY(4, 1, KEY_UP), /* USER_UP */
5814 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5815 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5816 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5817
5818 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5819 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5820 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5821 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5822 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5823};
5824
Zhang Chang Ken683be172011-08-10 17:45:34 -04005825static const unsigned int dragon_keymap[] = {
5826 KEY(0, 0, KEY_MENU),
5827 KEY(0, 2, KEY_1),
5828 KEY(0, 3, KEY_4),
5829 KEY(0, 4, KEY_7),
5830
5831 KEY(1, 0, KEY_UP),
5832 KEY(1, 1, KEY_LEFT),
5833 KEY(1, 2, KEY_DOWN),
5834 KEY(1, 3, KEY_5),
5835 KEY(1, 4, KEY_8),
5836
5837 KEY(2, 0, KEY_HOME),
5838 KEY(2, 1, KEY_REPLY),
5839 KEY(2, 2, KEY_2),
5840 KEY(2, 3, KEY_6),
5841 KEY(2, 4, KEY_0),
5842
5843 KEY(3, 0, KEY_VOLUMEUP),
5844 KEY(3, 1, KEY_RIGHT),
5845 KEY(3, 2, KEY_3),
5846 KEY(3, 3, KEY_9),
5847 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5848
5849 KEY(4, 0, KEY_VOLUMEDOWN),
5850 KEY(4, 1, KEY_BACK),
5851 KEY(4, 2, KEY_CAMERA),
5852 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5853};
5854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005855static struct matrix_keymap_data ffa_keymap_data = {
5856 .keymap_size = ARRAY_SIZE(ffa_keymap),
5857 .keymap = ffa_keymap,
5858};
5859
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305860static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005861 .input_name = "ffa-keypad",
5862 .input_phys_device = "ffa-keypad/input0",
5863 .num_rows = 6,
5864 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305865 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5866 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5867 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005868 .scan_delay_ms = 32,
5869 .row_hold_ns = 91500,
5870 .wakeup = 1,
5871 .keymap_data = &ffa_keymap_data,
5872};
5873
Zhang Chang Ken683be172011-08-10 17:45:34 -04005874static struct matrix_keymap_data dragon_keymap_data = {
5875 .keymap_size = ARRAY_SIZE(dragon_keymap),
5876 .keymap = dragon_keymap,
5877};
5878
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305879static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005880 .input_name = "dragon-keypad",
5881 .input_phys_device = "dragon-keypad/input0",
5882 .num_rows = 6,
5883 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305884 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5885 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5886 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005887 .scan_delay_ms = 32,
5888 .row_hold_ns = 91500,
5889 .wakeup = 1,
5890 .keymap_data = &dragon_keymap_data,
5891};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005893static const unsigned int fluid_keymap[] = {
5894 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5895 KEY(0, 1, KEY_UP), /* NAV - UP */
5896 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5897 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5898
5899 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5900 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5901 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5902 KEY(1, 3, KEY_VOLUMEUP),
5903
5904 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5905
5906 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5907 KEY(4, 1, KEY_UP), /* USER_UP */
5908 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5909 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5910 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5911
Jilai Wang9a895102011-07-12 14:00:35 -04005912 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005913 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5914 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5915 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5916 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5917};
5918
5919static struct matrix_keymap_data fluid_keymap_data = {
5920 .keymap_size = ARRAY_SIZE(fluid_keymap),
5921 .keymap = fluid_keymap,
5922};
5923
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305924static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005925 .input_name = "fluid-keypad",
5926 .input_phys_device = "fluid-keypad/input0",
5927 .num_rows = 6,
5928 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305929 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5930 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5931 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005932 .scan_delay_ms = 32,
5933 .row_hold_ns = 91500,
5934 .wakeup = 1,
5935 .keymap_data = &fluid_keymap_data,
5936};
5937
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305938static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005939 .initial_vibrate_ms = 500,
5940 .level_mV = 3000,
5941 .max_timeout_ms = 15000,
5942};
5943
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305944static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
5945 .rtc_write_enable = false,
5946 .rtc_alarm_powerup = false,
5947};
5948
5949static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
5950 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08005951 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305952 .wakeup = 1,
5953};
5954
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005955#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5956
5957static struct othc_accessory_info othc_accessories[] = {
5958 {
5959 .accessory = OTHC_SVIDEO_OUT,
5960 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5961 | OTHC_ADC_DETECT,
5962 .key_code = SW_VIDEOOUT_INSERT,
5963 .enabled = false,
5964 .adc_thres = {
5965 .min_threshold = 20,
5966 .max_threshold = 40,
5967 },
5968 },
5969 {
5970 .accessory = OTHC_ANC_HEADPHONE,
5971 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5972 OTHC_SWITCH_DETECT,
5973 .gpio = PM8058_LINE_IN_DET_GPIO,
5974 .active_low = 1,
5975 .key_code = SW_HEADPHONE_INSERT,
5976 .enabled = true,
5977 },
5978 {
5979 .accessory = OTHC_ANC_HEADSET,
5980 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5981 .gpio = PM8058_LINE_IN_DET_GPIO,
5982 .active_low = 1,
5983 .key_code = SW_HEADPHONE_INSERT,
5984 .enabled = true,
5985 },
5986 {
5987 .accessory = OTHC_HEADPHONE,
5988 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
5989 .key_code = SW_HEADPHONE_INSERT,
5990 .enabled = true,
5991 },
5992 {
5993 .accessory = OTHC_MICROPHONE,
5994 .detect_flags = OTHC_GPIO_DETECT,
5995 .gpio = PM8058_LINE_IN_DET_GPIO,
5996 .active_low = 1,
5997 .key_code = SW_MICROPHONE_INSERT,
5998 .enabled = true,
5999 },
6000 {
6001 .accessory = OTHC_HEADSET,
6002 .detect_flags = OTHC_MICBIAS_DETECT,
6003 .key_code = SW_HEADPHONE_INSERT,
6004 .enabled = true,
6005 },
6006};
6007
6008static struct othc_switch_info switch_info[] = {
6009 {
6010 .min_adc_threshold = 0,
6011 .max_adc_threshold = 100,
6012 .key_code = KEY_PLAYPAUSE,
6013 },
6014 {
6015 .min_adc_threshold = 100,
6016 .max_adc_threshold = 200,
6017 .key_code = KEY_REWIND,
6018 },
6019 {
6020 .min_adc_threshold = 200,
6021 .max_adc_threshold = 500,
6022 .key_code = KEY_FASTFORWARD,
6023 },
6024};
6025
6026static struct othc_n_switch_config switch_config = {
6027 .voltage_settling_time_ms = 0,
6028 .num_adc_samples = 3,
6029 .adc_channel = CHANNEL_ADC_HDSET,
6030 .switch_info = switch_info,
6031 .num_keys = ARRAY_SIZE(switch_info),
6032 .default_sw_en = true,
6033 .default_sw_idx = 0,
6034};
6035
6036static struct hsed_bias_config hsed_bias_config = {
6037 /* HSED mic bias config info */
6038 .othc_headset = OTHC_HEADSET_NO,
6039 .othc_lowcurr_thresh_uA = 100,
6040 .othc_highcurr_thresh_uA = 600,
6041 .othc_hyst_prediv_us = 7800,
6042 .othc_period_clkdiv_us = 62500,
6043 .othc_hyst_clk_us = 121000,
6044 .othc_period_clk_us = 312500,
6045 .othc_wakeup = 1,
6046};
6047
6048static struct othc_hsed_config hsed_config_1 = {
6049 .hsed_bias_config = &hsed_bias_config,
6050 /*
6051 * The detection delay and switch reporting delay are
6052 * required to encounter a hardware bug (spurious switch
6053 * interrupts on slow insertion/removal of the headset).
6054 * This will introduce a delay in reporting the accessory
6055 * insertion and removal to the userspace.
6056 */
6057 .detection_delay_ms = 1500,
6058 /* Switch info */
6059 .switch_debounce_ms = 1500,
6060 .othc_support_n_switch = false,
6061 .switch_config = &switch_config,
6062 .ir_gpio = -1,
6063 /* Accessory info */
6064 .accessories_support = true,
6065 .accessories = othc_accessories,
6066 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6067};
6068
6069static struct othc_regulator_config othc_reg = {
6070 .regulator = "8058_l5",
6071 .max_uV = 2850000,
6072 .min_uV = 2850000,
6073};
6074
6075/* MIC_BIAS0 is configured as normal MIC BIAS */
6076static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6077 .micbias_select = OTHC_MICBIAS_0,
6078 .micbias_capability = OTHC_MICBIAS,
6079 .micbias_enable = OTHC_SIGNAL_OFF,
6080 .micbias_regulator = &othc_reg,
6081};
6082
6083/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6084static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6085 .micbias_select = OTHC_MICBIAS_1,
6086 .micbias_capability = OTHC_MICBIAS_HSED,
6087 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6088 .micbias_regulator = &othc_reg,
6089 .hsed_config = &hsed_config_1,
6090 .hsed_name = "8660_handset",
6091};
6092
6093/* MIC_BIAS2 is configured as normal MIC BIAS */
6094static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6095 .micbias_select = OTHC_MICBIAS_2,
6096 .micbias_capability = OTHC_MICBIAS,
6097 .micbias_enable = OTHC_SIGNAL_OFF,
6098 .micbias_regulator = &othc_reg,
6099};
6100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006101
6102static void __init msm8x60_init_pm8058_othc(void)
6103{
6104 int i;
6105
6106 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6107 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6108 machine_is_msm8x60_fusn_ffa()) {
6109 /* 3-switch headset supported only by V2 FFA and FLUID */
6110 hsed_config_1.accessories_adc_support = true,
6111 /* ADC based accessory detection works only on V2 and FLUID */
6112 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6113 hsed_config_1.othc_support_n_switch = true;
6114 }
6115
6116 /* IR GPIO is absent on FLUID */
6117 if (machine_is_msm8x60_fluid())
6118 hsed_config_1.ir_gpio = -1;
6119
6120 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6121 if (machine_is_msm8x60_fluid()) {
6122 switch (othc_accessories[i].accessory) {
6123 case OTHC_ANC_HEADPHONE:
6124 case OTHC_ANC_HEADSET:
6125 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6126 break;
6127 case OTHC_MICROPHONE:
6128 othc_accessories[i].enabled = false;
6129 break;
6130 case OTHC_SVIDEO_OUT:
6131 othc_accessories[i].enabled = true;
6132 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6133 break;
6134 }
6135 }
6136 }
6137}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006139
6140static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6141{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306142 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006143 .direction = PM_GPIO_DIR_OUT,
6144 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6145 .output_value = 0,
6146 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306147 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006148 .out_strength = PM_GPIO_STRENGTH_HIGH,
6149 .function = PM_GPIO_FUNC_2,
6150 };
6151
6152 int rc = -EINVAL;
6153 int id, mode, max_mA;
6154
6155 id = mode = max_mA = 0;
6156 switch (ch) {
6157 case 0:
6158 case 1:
6159 case 2:
6160 if (on) {
6161 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306162 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6163 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006164 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306165 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006166 __func__, id, rc);
6167 }
6168 break;
6169
6170 case 6:
6171 id = PM_PWM_LED_FLASH;
6172 mode = PM_PWM_CONF_PWM1;
6173 max_mA = 300;
6174 break;
6175
6176 case 7:
6177 id = PM_PWM_LED_FLASH1;
6178 mode = PM_PWM_CONF_PWM1;
6179 max_mA = 300;
6180 break;
6181
6182 default:
6183 break;
6184 }
6185
6186 if (ch >= 6 && ch <= 7) {
6187 if (!on) {
6188 mode = PM_PWM_CONF_NONE;
6189 max_mA = 0;
6190 }
6191 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6192 if (rc)
6193 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6194 __func__, ch, rc);
6195 }
6196 return rc;
6197
6198}
6199
6200static struct pm8058_pwm_pdata pm8058_pwm_data = {
6201 .config = pm8058_pwm_config,
6202};
6203
6204#define PM8058_GPIO_INT 88
6205
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006206static struct pmic8058_led pmic8058_flash_leds[] = {
6207 [0] = {
6208 .name = "camera:flash0",
6209 .max_brightness = 15,
6210 .id = PMIC8058_ID_FLASH_LED_0,
6211 },
6212 [1] = {
6213 .name = "camera:flash1",
6214 .max_brightness = 15,
6215 .id = PMIC8058_ID_FLASH_LED_1,
6216 },
6217};
6218
6219static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6220 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6221 .leds = pmic8058_flash_leds,
6222};
6223
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006224static struct pmic8058_led pmic8058_dragon_leds[] = {
6225 [0] = {
6226 /* RED */
6227 .name = "led_drv0",
6228 .max_brightness = 15,
6229 .id = PMIC8058_ID_LED_0,
6230 },/* 300 mA flash led0 drv sink */
6231 [1] = {
6232 /* Yellow */
6233 .name = "led_drv1",
6234 .max_brightness = 15,
6235 .id = PMIC8058_ID_LED_1,
6236 },/* 300 mA flash led0 drv sink */
6237 [2] = {
6238 /* Green */
6239 .name = "led_drv2",
6240 .max_brightness = 15,
6241 .id = PMIC8058_ID_LED_2,
6242 },/* 300 mA flash led0 drv sink */
6243 [3] = {
6244 .name = "led_psensor",
6245 .max_brightness = 15,
6246 .id = PMIC8058_ID_LED_KB_LIGHT,
6247 },/* 300 mA flash led0 drv sink */
6248};
6249
6250static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6251 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6252 .leds = pmic8058_dragon_leds,
6253};
6254
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006255static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6256 [0] = {
6257 .name = "led:drv0",
6258 .max_brightness = 15,
6259 .id = PMIC8058_ID_FLASH_LED_0,
6260 },/* 300 mA flash led0 drv sink */
6261 [1] = {
6262 .name = "led:drv1",
6263 .max_brightness = 15,
6264 .id = PMIC8058_ID_FLASH_LED_1,
6265 },/* 300 mA flash led1 sink */
6266 [2] = {
6267 .name = "led:drv2",
6268 .max_brightness = 20,
6269 .id = PMIC8058_ID_LED_0,
6270 },/* 40 mA led0 sink */
6271 [3] = {
6272 .name = "keypad:drv",
6273 .max_brightness = 15,
6274 .id = PMIC8058_ID_LED_KB_LIGHT,
6275 },/* 300 mA keypad drv sink */
6276};
6277
6278static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6279 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6280 .leds = pmic8058_fluid_flash_leds,
6281};
6282
Terence Hampson90508a92011-08-09 10:40:08 -04006283static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306284 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006285 .max_source_current = 1800,
6286 .charger_type = CHG_TYPE_AC,
6287};
6288
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306289static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6290 .charger_data_valid = false,
6291};
6292
6293static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6294 .priority = 0,
6295};
6296
6297static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6298 .irq_base = PM8058_IRQ_BASE,
6299 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6300 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6301};
6302
6303static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6304 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6305};
6306
6307static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6308 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006309};
6310
6311static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306312 .irq_pdata = &pm8058_irq_pdata,
6313 .gpio_pdata = &pm8058_gpio_pdata,
6314 .mpp_pdata = &pm8058_mpp_pdata,
6315 .rtc_pdata = &pm8058_rtc_pdata,
6316 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6317 .othc0_pdata = &othc_config_pdata_0,
6318 .othc1_pdata = &othc_config_pdata_1,
6319 .othc2_pdata = &othc_config_pdata_2,
6320 .pwm_pdata = &pm8058_pwm_data,
6321 .misc_pdata = &pm8058_misc_pdata,
6322#ifdef CONFIG_SENSORS_MSM_ADC
6323 .xoadc_pdata = &pm8058_xoadc_pdata,
6324#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006325};
6326
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306327#ifdef CONFIG_MSM_SSBI
6328static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6329 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6330 .slave = {
6331 .name = "pm8058-core",
6332 .platform_data = &pm8058_platform_data,
6333 },
6334};
6335#endif
6336#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006337
6338#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6339 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6340#define TDISC_I2C_SLAVE_ADDR 0x67
6341#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6342#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6343
6344static const char *vregs_tdisc_name[] = {
6345 "8058_l5",
6346 "8058_s3",
6347};
6348
6349static const int vregs_tdisc_val[] = {
6350 2850000,/* uV */
6351 1800000,
6352};
6353static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6354
6355static int tdisc_shinetsu_setup(void)
6356{
6357 int rc, i;
6358
6359 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6360 if (rc) {
6361 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6362 __func__);
6363 return rc;
6364 }
6365
6366 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6367 if (rc) {
6368 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6369 __func__);
6370 goto fail_gpio_oe;
6371 }
6372
6373 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6374 if (rc) {
6375 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6376 __func__);
6377 gpio_free(GPIO_JOYSTICK_EN);
6378 goto fail_gpio_oe;
6379 }
6380
6381 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6382 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6383 if (IS_ERR(vregs_tdisc[i])) {
6384 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6385 __func__, vregs_tdisc_name[i],
6386 PTR_ERR(vregs_tdisc[i]));
6387 rc = PTR_ERR(vregs_tdisc[i]);
6388 goto vreg_get_fail;
6389 }
6390
6391 rc = regulator_set_voltage(vregs_tdisc[i],
6392 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6393 if (rc) {
6394 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6395 __func__, rc);
6396 goto vreg_set_voltage_fail;
6397 }
6398 }
6399
6400 return rc;
6401vreg_set_voltage_fail:
6402 i++;
6403vreg_get_fail:
6404 while (i)
6405 regulator_put(vregs_tdisc[--i]);
6406fail_gpio_oe:
6407 gpio_free(PMIC_GPIO_TDISC);
6408 return rc;
6409}
6410
6411static void tdisc_shinetsu_release(void)
6412{
6413 int i;
6414
6415 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6416 regulator_put(vregs_tdisc[i]);
6417
6418 gpio_free(PMIC_GPIO_TDISC);
6419 gpio_free(GPIO_JOYSTICK_EN);
6420}
6421
6422static int tdisc_shinetsu_enable(void)
6423{
6424 int i, rc = -EINVAL;
6425
6426 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6427 rc = regulator_enable(vregs_tdisc[i]);
6428 if (rc < 0) {
6429 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6430 __func__, vregs_tdisc_name[i], rc);
6431 goto vreg_fail;
6432 }
6433 }
6434
6435 /* Enable the OE (output enable) gpio */
6436 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6437 /* voltage and gpio stabilization delay */
6438 msleep(50);
6439
6440 return 0;
6441vreg_fail:
6442 while (i)
6443 regulator_disable(vregs_tdisc[--i]);
6444 return rc;
6445}
6446
6447static int tdisc_shinetsu_disable(void)
6448{
6449 int i, rc;
6450
6451 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6452 rc = regulator_disable(vregs_tdisc[i]);
6453 if (rc < 0) {
6454 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6455 __func__, vregs_tdisc_name[i], rc);
6456 goto tdisc_reg_fail;
6457 }
6458 }
6459
6460 /* Disable the OE (output enable) gpio */
6461 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6462
6463 return 0;
6464
6465tdisc_reg_fail:
6466 while (i)
6467 regulator_enable(vregs_tdisc[--i]);
6468 return rc;
6469}
6470
6471static struct tdisc_abs_values tdisc_abs = {
6472 .x_max = 32,
6473 .y_max = 32,
6474 .x_min = -32,
6475 .y_min = -32,
6476 .pressure_max = 32,
6477 .pressure_min = 0,
6478};
6479
6480static struct tdisc_platform_data tdisc_data = {
6481 .tdisc_setup = tdisc_shinetsu_setup,
6482 .tdisc_release = tdisc_shinetsu_release,
6483 .tdisc_enable = tdisc_shinetsu_enable,
6484 .tdisc_disable = tdisc_shinetsu_disable,
6485 .tdisc_wakeup = 0,
6486 .tdisc_gpio = PMIC_GPIO_TDISC,
6487 .tdisc_report_keys = true,
6488 .tdisc_report_relative = true,
6489 .tdisc_report_absolute = false,
6490 .tdisc_report_wheel = false,
6491 .tdisc_reverse_x = false,
6492 .tdisc_reverse_y = true,
6493 .tdisc_abs = &tdisc_abs,
6494};
6495
6496static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6497 {
6498 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6499 .irq = TDISC_INT,
6500 .platform_data = &tdisc_data,
6501 },
6502};
6503#endif
6504
6505#define PM_GPIO_CDC_RST_N 20
6506#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6507
6508static struct regulator *vreg_timpani_1;
6509static struct regulator *vreg_timpani_2;
6510
6511static unsigned int msm_timpani_setup_power(void)
6512{
6513 int rc;
6514
6515 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6516 if (IS_ERR(vreg_timpani_1)) {
6517 pr_err("%s: Unable to get 8058_l0\n", __func__);
6518 return -ENODEV;
6519 }
6520
6521 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6522 if (IS_ERR(vreg_timpani_2)) {
6523 pr_err("%s: Unable to get 8058_s3\n", __func__);
6524 regulator_put(vreg_timpani_1);
6525 return -ENODEV;
6526 }
6527
6528 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6529 if (rc) {
6530 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6531 goto fail;
6532 }
6533
6534 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6535 if (rc) {
6536 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6537 goto fail;
6538 }
6539
6540 rc = regulator_enable(vreg_timpani_1);
6541 if (rc) {
6542 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6543 goto fail;
6544 }
6545
6546 /* The settings for LDO0 should be set such that
6547 * it doesn't require to reset the timpani. */
6548 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6549 if (rc < 0) {
6550 pr_err("Timpani regulator optimum mode setting failed\n");
6551 goto fail;
6552 }
6553
6554 rc = regulator_enable(vreg_timpani_2);
6555 if (rc) {
6556 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6557 regulator_disable(vreg_timpani_1);
6558 goto fail;
6559 }
6560
6561 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6562 if (rc) {
6563 pr_err("%s: GPIO Request %d failed\n", __func__,
6564 GPIO_CDC_RST_N);
6565 regulator_disable(vreg_timpani_1);
6566 regulator_disable(vreg_timpani_2);
6567 goto fail;
6568 } else {
6569 gpio_direction_output(GPIO_CDC_RST_N, 1);
6570 usleep_range(1000, 1050);
6571 gpio_direction_output(GPIO_CDC_RST_N, 0);
6572 usleep_range(1000, 1050);
6573 gpio_direction_output(GPIO_CDC_RST_N, 1);
6574 gpio_free(GPIO_CDC_RST_N);
6575 }
6576 return rc;
6577
6578fail:
6579 regulator_put(vreg_timpani_1);
6580 regulator_put(vreg_timpani_2);
6581 return rc;
6582}
6583
6584static void msm_timpani_shutdown_power(void)
6585{
6586 int rc;
6587
6588 rc = regulator_disable(vreg_timpani_1);
6589 if (rc)
6590 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6591
6592 regulator_put(vreg_timpani_1);
6593
6594 rc = regulator_disable(vreg_timpani_2);
6595 if (rc)
6596 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6597
6598 regulator_put(vreg_timpani_2);
6599}
6600
6601/* Power analog function of codec */
6602static struct regulator *vreg_timpani_cdc_apwr;
6603static int msm_timpani_codec_power(int vreg_on)
6604{
6605 int rc = 0;
6606
6607 if (!vreg_timpani_cdc_apwr) {
6608
6609 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6610
6611 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6612 pr_err("%s: vreg_get failed (%ld)\n",
6613 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6614 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6615 return rc;
6616 }
6617 }
6618
6619 if (vreg_on) {
6620
6621 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6622 2200000, 2200000);
6623 if (rc) {
6624 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6625 __func__);
6626 goto vreg_fail;
6627 }
6628
6629 rc = regulator_enable(vreg_timpani_cdc_apwr);
6630 if (rc) {
6631 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6632 goto vreg_fail;
6633 }
6634 } else {
6635 rc = regulator_disable(vreg_timpani_cdc_apwr);
6636 if (rc) {
6637 pr_err("%s: vreg_disable failed %d\n",
6638 __func__, rc);
6639 goto vreg_fail;
6640 }
6641 }
6642
6643 return 0;
6644
6645vreg_fail:
6646 regulator_put(vreg_timpani_cdc_apwr);
6647 vreg_timpani_cdc_apwr = NULL;
6648 return rc;
6649}
6650
6651static struct marimba_codec_platform_data timpani_codec_pdata = {
6652 .marimba_codec_power = msm_timpani_codec_power,
6653};
6654
6655#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6656#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6657
6658static struct marimba_platform_data timpani_pdata = {
6659 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6660 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6661 .marimba_setup = msm_timpani_setup_power,
6662 .marimba_shutdown = msm_timpani_shutdown_power,
6663 .codec = &timpani_codec_pdata,
6664 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6665};
6666
6667#define TIMPANI_I2C_SLAVE_ADDR 0xD
6668
6669static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6670 {
6671 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6672 .platform_data = &timpani_pdata,
6673 },
6674};
6675
Lei Zhou338cab82011-08-19 13:38:17 -04006676#ifdef CONFIG_SND_SOC_WM8903
6677static struct wm8903_platform_data wm8903_pdata = {
6678 .gpio_cfg[2] = 0x3A8,
6679};
6680
6681#define WM8903_I2C_SLAVE_ADDR 0x34
6682static struct i2c_board_info wm8903_codec_i2c_info[] = {
6683 {
6684 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6685 .platform_data = &wm8903_pdata,
6686 },
6687};
6688#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006689#ifdef CONFIG_PMIC8901
6690
6691#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006692/*
6693 * Consumer specific regulator names:
6694 * regulator name consumer dev_name
6695 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006696static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6697 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6698};
6699static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6700 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6701};
6702
6703#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306704 _always_on) \
6705 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006706 .init_data = { \
6707 .constraints = { \
6708 .valid_modes_mask = _modes, \
6709 .valid_ops_mask = _ops, \
6710 .min_uV = _min_uV, \
6711 .max_uV = _max_uV, \
6712 .input_uV = _min_uV, \
6713 .apply_uV = _apply_uV, \
6714 .always_on = _always_on, \
6715 }, \
6716 .consumer_supplies = vreg_consumers_8901_##_id, \
6717 .num_consumer_supplies = \
6718 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6719 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306720 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006721 }
6722
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006723#define PM8901_VREG_INIT_VS(_id) \
6724 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306725 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006726
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306727static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006728 PM8901_VREG_INIT_VS(USB_OTG),
6729 PM8901_VREG_INIT_VS(HDMI_MVS),
6730};
6731
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306732static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6733 .priority = 1,
6734};
6735
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306736static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6737 .irq_base = PM8901_IRQ_BASE,
6738 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6739 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6740};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006741
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306742static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6743 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006744};
6745
6746static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306747 .irq_pdata = &pm8901_irq_pdata,
6748 .mpp_pdata = &pm8901_mpp_pdata,
6749 .regulator_pdatas = pm8901_vreg_init,
6750 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306751 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006752};
6753
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306754static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6755 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6756 .slave = {
6757 .name = "pm8901-core",
6758 .platform_data = &pm8901_platform_data,
6759 },
6760};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006761#endif /* CONFIG_PMIC8901 */
6762
6763#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6764 || defined(CONFIG_GPIO_SX150X_MODULE))
6765
6766static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006767static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006768
6769struct bahama_config_register{
6770 u8 reg;
6771 u8 value;
6772 u8 mask;
6773};
6774
6775enum version{
6776 VER_1_0,
6777 VER_2_0,
6778 VER_UNSUPPORTED = 0xFF
6779};
6780
6781static u8 read_bahama_ver(void)
6782{
6783 int rc;
6784 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6785 u8 bahama_version;
6786
6787 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6788 if (rc < 0) {
6789 printk(KERN_ERR
6790 "%s: version read failed: %d\n",
6791 __func__, rc);
6792 return VER_UNSUPPORTED;
6793 } else {
6794 printk(KERN_INFO
6795 "%s: version read got: 0x%x\n",
6796 __func__, bahama_version);
6797 }
6798
6799 switch (bahama_version) {
6800 case 0x08: /* varient of bahama v1 */
6801 case 0x10:
6802 case 0x00:
6803 return VER_1_0;
6804 case 0x09: /* variant of bahama v2 */
6805 return VER_2_0;
6806 default:
6807 return VER_UNSUPPORTED;
6808 }
6809}
6810
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006811static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006812static unsigned int msm_bahama_setup_power(void)
6813{
6814 int rc = 0;
6815 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006816
6817 if (machine_is_msm8x60_dragon())
6818 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6819
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006820 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6821
6822 if (IS_ERR(vreg_bahama)) {
6823 rc = PTR_ERR(vreg_bahama);
6824 pr_err("%s: regulator_get %s = %d\n", __func__,
6825 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006826 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006827 }
6828
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006829 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6830 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006831 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6832 msm_bahama_regulator, rc);
6833 goto unget;
6834 }
6835
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006836 rc = regulator_enable(vreg_bahama);
6837 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006838 pr_err("%s: regulator_enable %s = %d\n", __func__,
6839 msm_bahama_regulator, rc);
6840 goto unget;
6841 }
6842
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006843 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6844 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006845 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006846 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006847 goto unenable;
6848 }
6849
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006850 gpio_direction_output(msm_bahama_sys_rst, 0);
6851 usleep_range(1000, 1050);
6852 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6853 usleep_range(1000, 1050);
6854 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006855 return rc;
6856
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006857unenable:
6858 regulator_disable(vreg_bahama);
6859unget:
6860 regulator_put(vreg_bahama);
6861 return rc;
6862};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006863
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006864static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006865{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006866 if (msm_bahama_setup_power_enable) {
6867 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6868 gpio_free(msm_bahama_sys_rst);
6869 regulator_disable(vreg_bahama);
6870 regulator_put(vreg_bahama);
6871 msm_bahama_setup_power_enable = 0;
6872 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006873
6874 return 0;
6875};
6876
6877static unsigned int msm_bahama_core_config(int type)
6878{
6879 int rc = 0;
6880
6881 if (type == BAHAMA_ID) {
6882
6883 int i;
6884 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6885
6886 const struct bahama_config_register v20_init[] = {
6887 /* reg, value, mask */
6888 { 0xF4, 0x84, 0xFF }, /* AREG */
6889 { 0xF0, 0x04, 0xFF } /* DREG */
6890 };
6891
6892 if (read_bahama_ver() == VER_2_0) {
6893 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6894 u8 value = v20_init[i].value;
6895 rc = marimba_write_bit_mask(&config,
6896 v20_init[i].reg,
6897 &value,
6898 sizeof(v20_init[i].value),
6899 v20_init[i].mask);
6900 if (rc < 0) {
6901 printk(KERN_ERR
6902 "%s: reg %d write failed: %d\n",
6903 __func__, v20_init[i].reg, rc);
6904 return rc;
6905 }
6906 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6907 " mask 0x%02x\n",
6908 __func__, v20_init[i].reg,
6909 v20_init[i].value, v20_init[i].mask);
6910 }
6911 }
6912 }
6913 printk(KERN_INFO "core type: %d\n", type);
6914
6915 return rc;
6916}
6917
6918static struct regulator *fm_regulator_s3;
6919static struct msm_xo_voter *fm_clock;
6920
6921static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6922{
6923 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306924 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006925 .direction = PM_GPIO_DIR_IN,
6926 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306927 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006928 .function = PM_GPIO_FUNC_NORMAL,
6929 .inv_int_pol = 0,
6930 };
6931
6932 if (!fm_regulator_s3) {
6933 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6934 if (IS_ERR(fm_regulator_s3)) {
6935 rc = PTR_ERR(fm_regulator_s3);
6936 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6937 __func__, rc);
6938 goto out;
6939 }
6940 }
6941
6942
6943 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6944 if (rc < 0) {
6945 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6946 __func__, rc);
6947 goto fm_fail_put;
6948 }
6949
6950 rc = regulator_enable(fm_regulator_s3);
6951 if (rc < 0) {
6952 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6953 __func__, rc);
6954 goto fm_fail_put;
6955 }
6956
6957 /*Vote for XO clock*/
6958 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6959
6960 if (IS_ERR(fm_clock)) {
6961 rc = PTR_ERR(fm_clock);
6962 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6963 __func__, rc);
6964 goto fm_fail_switch;
6965 }
6966
6967 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6968 if (rc < 0) {
6969 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6970 __func__, rc);
6971 goto fm_fail_vote;
6972 }
6973
6974 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306975 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006976 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306977 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006978 __func__, rc);
6979 goto fm_fail_clock;
6980 }
6981 goto out;
6982
6983fm_fail_clock:
6984 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6985fm_fail_vote:
6986 msm_xo_put(fm_clock);
6987fm_fail_switch:
6988 regulator_disable(fm_regulator_s3);
6989fm_fail_put:
6990 regulator_put(fm_regulator_s3);
6991out:
6992 return rc;
6993};
6994
6995static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
6996{
6997 int rc = 0;
6998 if (fm_regulator_s3 != NULL) {
6999 rc = regulator_disable(fm_regulator_s3);
7000 if (rc < 0) {
7001 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7002 __func__, rc);
7003 }
7004 regulator_put(fm_regulator_s3);
7005 fm_regulator_s3 = NULL;
7006 }
7007 printk(KERN_ERR "%s: Voting off for XO", __func__);
7008
7009 if (fm_clock != NULL) {
7010 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7011 if (rc < 0) {
7012 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7013 __func__, rc);
7014 }
7015 msm_xo_put(fm_clock);
7016 }
7017 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7018}
7019
7020/* Slave id address for FM/CDC/QMEMBIST
7021 * Values can be programmed using Marimba slave id 0
7022 * should there be a conflict with other I2C devices
7023 * */
7024#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7025#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7026
7027static struct marimba_fm_platform_data marimba_fm_pdata = {
7028 .fm_setup = fm_radio_setup,
7029 .fm_shutdown = fm_radio_shutdown,
7030 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7031 .is_fm_soc_i2s_master = false,
7032 .config_i2s_gpio = NULL,
7033};
7034
7035/*
7036Just initializing the BAHAMA related slave
7037*/
7038static struct marimba_platform_data marimba_pdata = {
7039 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7040 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7041 .bahama_setup = msm_bahama_setup_power,
7042 .bahama_shutdown = msm_bahama_shutdown_power,
7043 .bahama_core_config = msm_bahama_core_config,
7044 .fm = &marimba_fm_pdata,
7045 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7046};
7047
7048
7049static struct i2c_board_info msm_marimba_board_info[] = {
7050 {
7051 I2C_BOARD_INFO("marimba", 0xc),
7052 .platform_data = &marimba_pdata,
7053 }
7054};
7055#endif /* CONFIG_MAIMBA_CORE */
7056
7057#ifdef CONFIG_I2C
7058#define I2C_SURF 1
7059#define I2C_FFA (1 << 1)
7060#define I2C_RUMI (1 << 2)
7061#define I2C_SIM (1 << 3)
7062#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007063#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007064
7065struct i2c_registry {
7066 u8 machs;
7067 int bus;
7068 struct i2c_board_info *info;
7069 int len;
7070};
7071
7072static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007073#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7074 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007075 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007076 MSM_GSBI8_QUP_I2C_BUS_ID,
7077 core_expander_i2c_info,
7078 ARRAY_SIZE(core_expander_i2c_info),
7079 },
7080 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007081 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007082 MSM_GSBI8_QUP_I2C_BUS_ID,
7083 docking_expander_i2c_info,
7084 ARRAY_SIZE(docking_expander_i2c_info),
7085 },
7086 {
7087 I2C_SURF,
7088 MSM_GSBI8_QUP_I2C_BUS_ID,
7089 surf_expanders_i2c_info,
7090 ARRAY_SIZE(surf_expanders_i2c_info),
7091 },
7092 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007093 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007094 MSM_GSBI3_QUP_I2C_BUS_ID,
7095 fha_expanders_i2c_info,
7096 ARRAY_SIZE(fha_expanders_i2c_info),
7097 },
7098 {
7099 I2C_FLUID,
7100 MSM_GSBI3_QUP_I2C_BUS_ID,
7101 fluid_expanders_i2c_info,
7102 ARRAY_SIZE(fluid_expanders_i2c_info),
7103 },
7104 {
7105 I2C_FLUID,
7106 MSM_GSBI8_QUP_I2C_BUS_ID,
7107 fluid_core_expander_i2c_info,
7108 ARRAY_SIZE(fluid_core_expander_i2c_info),
7109 },
7110#endif
7111#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7112 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7113 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007114 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007115 MSM_GSBI3_QUP_I2C_BUS_ID,
7116 msm_i2c_gsbi3_tdisc_info,
7117 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7118 },
7119#endif
7120 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007121 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007122 MSM_GSBI3_QUP_I2C_BUS_ID,
7123 cy8ctmg200_board_info,
7124 ARRAY_SIZE(cy8ctmg200_board_info),
7125 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007126 {
7127 I2C_DRAGON,
7128 MSM_GSBI3_QUP_I2C_BUS_ID,
7129 cy8ctma340_dragon_board_info,
7130 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7131 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007132#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7133 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7134 {
7135 I2C_FLUID,
7136 MSM_GSBI3_QUP_I2C_BUS_ID,
7137 cyttsp_fluid_info,
7138 ARRAY_SIZE(cyttsp_fluid_info),
7139 },
7140 {
7141 I2C_FFA | I2C_SURF,
7142 MSM_GSBI3_QUP_I2C_BUS_ID,
7143 cyttsp_ffa_info,
7144 ARRAY_SIZE(cyttsp_ffa_info),
7145 },
7146#endif
7147#ifdef CONFIG_MSM_CAMERA
Jilai Wang971f97f2011-07-13 14:25:25 -04007148 {
7149 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007150 MSM_GSBI4_QUP_I2C_BUS_ID,
7151 msm_camera_boardinfo,
7152 ARRAY_SIZE(msm_camera_boardinfo),
7153 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007154 {
7155 I2C_DRAGON,
7156 MSM_GSBI4_QUP_I2C_BUS_ID,
7157 msm_camera_dragon_boardinfo,
7158 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7159 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007160#endif
7161 {
7162 I2C_SURF | I2C_FFA | I2C_FLUID,
7163 MSM_GSBI7_QUP_I2C_BUS_ID,
7164 msm_i2c_gsbi7_timpani_info,
7165 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7166 },
7167#if defined(CONFIG_MARIMBA_CORE)
7168 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007169 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007170 MSM_GSBI7_QUP_I2C_BUS_ID,
7171 msm_marimba_board_info,
7172 ARRAY_SIZE(msm_marimba_board_info),
7173 },
7174#endif /* CONFIG_MARIMBA_CORE */
7175#ifdef CONFIG_ISL9519_CHARGER
7176 {
7177 I2C_SURF | I2C_FFA,
7178 MSM_GSBI8_QUP_I2C_BUS_ID,
7179 isl_charger_i2c_info,
7180 ARRAY_SIZE(isl_charger_i2c_info),
7181 },
7182#endif
7183#if defined(CONFIG_HAPTIC_ISA1200) || \
7184 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7185 {
7186 I2C_FLUID,
7187 MSM_GSBI8_QUP_I2C_BUS_ID,
7188 msm_isa1200_board_info,
7189 ARRAY_SIZE(msm_isa1200_board_info),
7190 },
7191#endif
7192#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7193 {
7194 I2C_FLUID,
7195 MSM_GSBI8_QUP_I2C_BUS_ID,
7196 smb137b_charger_i2c_info,
7197 ARRAY_SIZE(smb137b_charger_i2c_info),
7198 },
7199#endif
7200#if defined(CONFIG_BATTERY_BQ27520) || \
7201 defined(CONFIG_BATTERY_BQ27520_MODULE)
7202 {
7203 I2C_FLUID,
7204 MSM_GSBI8_QUP_I2C_BUS_ID,
7205 msm_bq27520_board_info,
7206 ARRAY_SIZE(msm_bq27520_board_info),
7207 },
7208#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007209#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7210 {
7211 I2C_DRAGON,
7212 MSM_GSBI8_QUP_I2C_BUS_ID,
7213 wm8903_codec_i2c_info,
7214 ARRAY_SIZE(wm8903_codec_i2c_info),
7215 },
7216#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007217};
7218#endif /* CONFIG_I2C */
7219
7220static void fixup_i2c_configs(void)
7221{
7222#ifdef CONFIG_I2C
7223#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7224 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7225 sx150x_data[SX150X_CORE].irq_summary =
7226 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007227 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7228 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007229 sx150x_data[SX150X_CORE].irq_summary =
7230 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7231 else if (machine_is_msm8x60_fluid())
7232 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7233 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7234#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007235#endif
7236}
7237
7238static void register_i2c_devices(void)
7239{
7240#ifdef CONFIG_I2C
7241 u8 mach_mask = 0;
7242 int i;
7243
7244 /* Build the matching 'supported_machs' bitmask */
7245 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7246 mach_mask = I2C_SURF;
7247 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7248 mach_mask = I2C_FFA;
7249 else if (machine_is_msm8x60_rumi3())
7250 mach_mask = I2C_RUMI;
7251 else if (machine_is_msm8x60_sim())
7252 mach_mask = I2C_SIM;
7253 else if (machine_is_msm8x60_fluid())
7254 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007255 else if (machine_is_msm8x60_dragon())
7256 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007257 else
7258 pr_err("unmatched machine ID in register_i2c_devices\n");
7259
7260 /* Run the array and install devices as appropriate */
7261 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7262 if (msm8x60_i2c_devices[i].machs & mach_mask)
7263 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7264 msm8x60_i2c_devices[i].info,
7265 msm8x60_i2c_devices[i].len);
7266 }
7267#endif
7268}
7269
7270static void __init msm8x60_init_uart12dm(void)
7271{
7272#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7273 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7274 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7275
7276 if (!fpga_mem)
7277 pr_err("%s(): Error getting memory\n", __func__);
7278
7279 /* Advanced mode */
7280 writew(0xFFFF, fpga_mem + 0x15C);
7281 /* FPGA_UART_SEL */
7282 writew(0, fpga_mem + 0x172);
7283 /* FPGA_GPIO_CONFIG_117 */
7284 writew(1, fpga_mem + 0xEA);
7285 /* FPGA_GPIO_CONFIG_118 */
7286 writew(1, fpga_mem + 0xEC);
7287 mb();
7288 iounmap(fpga_mem);
7289#endif
7290}
7291
7292#define MSM_GSBI9_PHYS 0x19900000
7293#define GSBI_DUAL_MODE_CODE 0x60
7294
7295static void __init msm8x60_init_buses(void)
7296{
7297#ifdef CONFIG_I2C_QUP
7298 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7299 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7300 writel_relaxed(0x6 << 4, gsbi_mem);
7301 /* Ensure protocol code is written before proceeding further */
7302 mb();
7303 iounmap(gsbi_mem);
7304
7305 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7306 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7307 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7308 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7309
7310#ifdef CONFIG_MSM_GSBI9_UART
7311 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7312 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7313 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7314 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7315 iounmap(gsbi_mem);
7316 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7317 }
7318#endif
7319 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7320 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7321#endif
7322#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7323 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7324#endif
7325#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007326 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7327#endif
7328
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307329#ifdef CONFIG_MSM_SSBI
7330 msm_device_ssbi_pmic1.dev.platform_data =
7331 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307332 msm_device_ssbi_pmic2.dev.platform_data =
7333 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307334#endif
7335
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007336 if (machine_is_msm8x60_fluid()) {
7337#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7338 (defined(CONFIG_SMB137B_CHARGER) || \
7339 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7340 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7341#endif
7342#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7343 msm_gsbi10_qup_spi_device.dev.platform_data =
7344 &msm_gsbi10_qup_spi_pdata;
7345#endif
7346 }
7347
7348#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7349 /*
7350 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7351 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7352 * and ID notifications are available only on V2 surf and FFA
7353 * with a hardware workaround.
7354 */
7355 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7356 (machine_is_msm8x60_surf() ||
7357 (machine_is_msm8x60_ffa() &&
7358 pmic_id_notif_supported)))
7359 msm_otg_pdata.phy_can_powercollapse = 1;
7360 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7361#endif
7362
7363#ifdef CONFIG_USB_GADGET_MSM_72K
7364 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7365#endif
7366
7367#ifdef CONFIG_SERIAL_MSM_HS
7368 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7369 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7370#endif
7371#ifdef CONFIG_MSM_GSBI9_UART
7372 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7373 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7374 if (IS_ERR(msm_device_uart_gsbi9))
7375 pr_err("%s(): Failed to create uart gsbi9 device\n",
7376 __func__);
7377 }
7378#endif
7379
7380#ifdef CONFIG_MSM_BUS_SCALING
7381
7382 /* RPM calls are only enabled on V2 */
7383 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7384 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7385 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7386 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7387 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7388 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7389 }
7390
7391 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7392 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7393 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7394 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7395 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7396#endif
7397}
7398
7399static void __init msm8x60_map_io(void)
7400{
7401 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7402 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007403
7404 if (socinfo_init() < 0)
7405 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007406}
7407
7408/*
7409 * Most segments of the EBI2 bus are disabled by default.
7410 */
7411static void __init msm8x60_init_ebi2(void)
7412{
7413 uint32_t ebi2_cfg;
7414 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007415 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7416
7417 if (IS_ERR(mem_clk)) {
7418 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7419 "msm_ebi2", "mem_clk");
7420 return;
7421 }
7422 clk_enable(mem_clk);
7423 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007424
7425 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7426 if (ebi2_cfg_ptr != 0) {
7427 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7428
7429 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007430 machine_is_msm8x60_fluid() ||
7431 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007432 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7433 else if (machine_is_msm8x60_sim())
7434 ebi2_cfg |= (1 << 4); /* CS2 */
7435 else if (machine_is_msm8x60_rumi3())
7436 ebi2_cfg |= (1 << 5); /* CS3 */
7437
7438 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7439 iounmap(ebi2_cfg_ptr);
7440 }
7441
7442 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007443 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007444 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7445 if (ebi2_cfg_ptr != 0) {
7446 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7447 writel_relaxed(0UL, ebi2_cfg_ptr);
7448
7449 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7450 * LAN9221 Ethernet controller reads and writes.
7451 * The lowest 4 bits are the read delay, the next
7452 * 4 are the write delay. */
7453 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7454#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7455 /*
7456 * RECOVERY=5, HOLD_WR=1
7457 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7458 * WAIT_WR=1, WAIT_RD=2
7459 */
7460 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7461 /*
7462 * HOLD_RD=1
7463 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7464 */
7465 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7466#else
7467 /* EBI2 CS3 muxed address/data,
7468 * two cyc addr enable */
7469 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7470
7471#endif
7472 iounmap(ebi2_cfg_ptr);
7473 }
7474 }
7475}
7476
7477static void __init msm8x60_configure_smc91x(void)
7478{
7479 if (machine_is_msm8x60_sim()) {
7480
7481 smc91x_resources[0].start = 0x1b800300;
7482 smc91x_resources[0].end = 0x1b8003ff;
7483
7484 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7485 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7486
7487 } else if (machine_is_msm8x60_rumi3()) {
7488
7489 smc91x_resources[0].start = 0x1d000300;
7490 smc91x_resources[0].end = 0x1d0003ff;
7491
7492 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7493 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7494 }
7495}
7496
7497static void __init msm8x60_init_tlmm(void)
7498{
7499 if (machine_is_msm8x60_rumi3())
7500 msm_gpio_install_direct_irq(0, 0, 1);
7501}
7502
7503#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7504 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7505 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7506 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7507 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7508
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007509/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007510#define MAX_SDCC_CONTROLLER 5
7511
7512struct msm_sdcc_gpio {
7513 /* maximum 10 GPIOs per SDCC controller */
7514 s16 no;
7515 /* name of this GPIO */
7516 const char *name;
7517 bool always_on;
7518 bool is_enabled;
7519};
7520
7521#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7522static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7523 {159, "sdc1_dat_0"},
7524 {160, "sdc1_dat_1"},
7525 {161, "sdc1_dat_2"},
7526 {162, "sdc1_dat_3"},
7527#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7528 {163, "sdc1_dat_4"},
7529 {164, "sdc1_dat_5"},
7530 {165, "sdc1_dat_6"},
7531 {166, "sdc1_dat_7"},
7532#endif
7533 {167, "sdc1_clk"},
7534 {168, "sdc1_cmd"}
7535};
7536#endif
7537
7538#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7539static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7540 {143, "sdc2_dat_0"},
7541 {144, "sdc2_dat_1", 1},
7542 {145, "sdc2_dat_2"},
7543 {146, "sdc2_dat_3"},
7544#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7545 {147, "sdc2_dat_4"},
7546 {148, "sdc2_dat_5"},
7547 {149, "sdc2_dat_6"},
7548 {150, "sdc2_dat_7"},
7549#endif
7550 {151, "sdc2_cmd"},
7551 {152, "sdc2_clk", 1}
7552};
7553#endif
7554
7555#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7556static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7557 {95, "sdc5_cmd"},
7558 {96, "sdc5_dat_3"},
7559 {97, "sdc5_clk", 1},
7560 {98, "sdc5_dat_2"},
7561 {99, "sdc5_dat_1", 1},
7562 {100, "sdc5_dat_0"}
7563};
7564#endif
7565
7566struct msm_sdcc_pad_pull_cfg {
7567 enum msm_tlmm_pull_tgt pull;
7568 u32 pull_val;
7569};
7570
7571struct msm_sdcc_pad_drv_cfg {
7572 enum msm_tlmm_hdrive_tgt drv;
7573 u32 drv_val;
7574};
7575
7576#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7577static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7578 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7579 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7580 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7581};
7582
7583static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7584 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7585 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7586};
7587
7588static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7589 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7590 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7591 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7592};
7593
7594static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7595 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7596 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7597};
7598#endif
7599
7600#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7601static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7602 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7603 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7604 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7605};
7606
7607static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7608 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7609 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7610};
7611
7612static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7613 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7614 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7615 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7616};
7617
7618static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7619 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7620 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7621};
7622#endif
7623
7624struct msm_sdcc_pin_cfg {
7625 /*
7626 * = 1 if controller pins are using gpios
7627 * = 0 if controller has dedicated MSM pins
7628 */
7629 u8 is_gpio;
7630 u8 cfg_sts;
7631 u8 gpio_data_size;
7632 struct msm_sdcc_gpio *gpio_data;
7633 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7634 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7635 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7636 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7637 u8 pad_drv_data_size;
7638 u8 pad_pull_data_size;
7639 u8 sdio_lpm_gpio_cfg;
7640};
7641
7642
7643static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7644#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7645 [0] = {
7646 .is_gpio = 1,
7647 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7648 .gpio_data = sdc1_gpio_cfg
7649 },
7650#endif
7651#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7652 [1] = {
7653 .is_gpio = 1,
7654 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7655 .gpio_data = sdc2_gpio_cfg
7656 },
7657#endif
7658#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7659 [2] = {
7660 .is_gpio = 0,
7661 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7662 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7663 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7664 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7665 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7666 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7667 },
7668#endif
7669#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7670 [3] = {
7671 .is_gpio = 0,
7672 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7673 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7674 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7675 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7676 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7677 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7678 },
7679#endif
7680#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7681 [4] = {
7682 .is_gpio = 1,
7683 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7684 .gpio_data = sdc5_gpio_cfg
7685 }
7686#endif
7687};
7688
7689static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7690{
7691 int rc = 0;
7692 struct msm_sdcc_pin_cfg *curr;
7693 int n;
7694
7695 curr = &sdcc_pin_cfg_data[dev_id - 1];
7696 if (!curr->gpio_data)
7697 goto out;
7698
7699 for (n = 0; n < curr->gpio_data_size; n++) {
7700 if (enable) {
7701
7702 if (curr->gpio_data[n].always_on &&
7703 curr->gpio_data[n].is_enabled)
7704 continue;
7705 pr_debug("%s: enable: %s\n", __func__,
7706 curr->gpio_data[n].name);
7707 rc = gpio_request(curr->gpio_data[n].no,
7708 curr->gpio_data[n].name);
7709 if (rc) {
7710 pr_err("%s: gpio_request(%d, %s)"
7711 "failed", __func__,
7712 curr->gpio_data[n].no,
7713 curr->gpio_data[n].name);
7714 goto free_gpios;
7715 }
7716 /* set direction as output for all GPIOs */
7717 rc = gpio_direction_output(
7718 curr->gpio_data[n].no, 1);
7719 if (rc) {
7720 pr_err("%s: gpio_direction_output"
7721 "(%d, 1) failed\n", __func__,
7722 curr->gpio_data[n].no);
7723 goto free_gpios;
7724 }
7725 curr->gpio_data[n].is_enabled = 1;
7726 } else {
7727 /*
7728 * now free this GPIO which will put GPIO
7729 * in low power mode and will also put GPIO
7730 * in input mode
7731 */
7732 if (curr->gpio_data[n].always_on)
7733 continue;
7734 pr_debug("%s: disable: %s\n", __func__,
7735 curr->gpio_data[n].name);
7736 gpio_free(curr->gpio_data[n].no);
7737 curr->gpio_data[n].is_enabled = 0;
7738 }
7739 }
7740 curr->cfg_sts = enable;
7741 goto out;
7742
7743free_gpios:
7744 for (; n >= 0; n--)
7745 gpio_free(curr->gpio_data[n].no);
7746out:
7747 return rc;
7748}
7749
7750static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7751{
7752 int rc = 0;
7753 struct msm_sdcc_pin_cfg *curr;
7754 int n;
7755
7756 curr = &sdcc_pin_cfg_data[dev_id - 1];
7757 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7758 goto out;
7759
7760 if (enable) {
7761 /*
7762 * set up the normal driver strength and
7763 * pull config for pads
7764 */
7765 for (n = 0; n < curr->pad_drv_data_size; n++) {
7766 if (curr->sdio_lpm_gpio_cfg) {
7767 if (curr->pad_drv_on_data[n].drv ==
7768 TLMM_HDRV_SDC4_DATA)
7769 continue;
7770 }
7771 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7772 curr->pad_drv_on_data[n].drv_val);
7773 }
7774 for (n = 0; n < curr->pad_pull_data_size; n++) {
7775 if (curr->sdio_lpm_gpio_cfg) {
7776 if (curr->pad_pull_on_data[n].pull ==
7777 TLMM_PULL_SDC4_DATA)
7778 continue;
7779 }
7780 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7781 curr->pad_pull_on_data[n].pull_val);
7782 }
7783 } else {
7784 /* set the low power config for pads */
7785 for (n = 0; n < curr->pad_drv_data_size; n++) {
7786 if (curr->sdio_lpm_gpio_cfg) {
7787 if (curr->pad_drv_off_data[n].drv ==
7788 TLMM_HDRV_SDC4_DATA)
7789 continue;
7790 }
7791 msm_tlmm_set_hdrive(
7792 curr->pad_drv_off_data[n].drv,
7793 curr->pad_drv_off_data[n].drv_val);
7794 }
7795 for (n = 0; n < curr->pad_pull_data_size; n++) {
7796 if (curr->sdio_lpm_gpio_cfg) {
7797 if (curr->pad_pull_off_data[n].pull ==
7798 TLMM_PULL_SDC4_DATA)
7799 continue;
7800 }
7801 msm_tlmm_set_pull(
7802 curr->pad_pull_off_data[n].pull,
7803 curr->pad_pull_off_data[n].pull_val);
7804 }
7805 }
7806 curr->cfg_sts = enable;
7807out:
7808 return rc;
7809}
7810
7811struct sdcc_reg {
7812 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7813 const char *reg_name;
7814 /*
7815 * is set voltage supported for this regulator?
7816 * 0 = not supported, 1 = supported
7817 */
7818 unsigned char set_voltage_sup;
7819 /* voltage level to be set */
7820 unsigned int level;
7821 /* VDD/VCC/VCCQ voltage regulator handle */
7822 struct regulator *reg;
7823 /* is this regulator enabled? */
7824 bool enabled;
7825 /* is this regulator needs to be always on? */
7826 bool always_on;
7827 /* is operating power mode setting required for this regulator? */
7828 bool op_pwr_mode_sup;
7829 /* Load values for low power and high power mode */
7830 unsigned int lpm_uA;
7831 unsigned int hpm_uA;
7832};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007833/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007834static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7835/* only SDCC1 requires VCCQ voltage */
7836static struct sdcc_reg sdcc_vccq_reg_data[1];
7837/* all SDCC controllers may require voting for VDD PAD voltage */
7838static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7839
7840struct sdcc_reg_data {
7841 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7842 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7843 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7844 unsigned char sts; /* regulator enable/disable status */
7845};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007846/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007847static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7848
7849static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7850{
7851 int rc = 0;
7852
7853 /* Get the regulator handle */
7854 vreg->reg = regulator_get(NULL, vreg->reg_name);
7855 if (IS_ERR(vreg->reg)) {
7856 rc = PTR_ERR(vreg->reg);
7857 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7858 __func__, vreg->reg_name, rc);
7859 goto out;
7860 }
7861
7862 /* Set the voltage level if required */
7863 if (vreg->set_voltage_sup) {
7864 rc = regulator_set_voltage(vreg->reg, vreg->level,
7865 vreg->level);
7866 if (rc) {
7867 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7868 __func__, vreg->reg_name, rc);
7869 goto vreg_put;
7870 }
7871 }
7872 goto out;
7873
7874vreg_put:
7875 regulator_put(vreg->reg);
7876out:
7877 return rc;
7878}
7879
7880static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7881{
7882 regulator_put(vreg->reg);
7883}
7884
7885/* this init function should be called only once for each SDCC */
7886static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7887{
7888 int rc = 0;
7889 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7890 struct sdcc_reg_data *curr;
7891
7892 curr = &sdcc_vreg_data[dev_id - 1];
7893 curr_vdd_reg = curr->vdd_data;
7894 curr_vccq_reg = curr->vccq_data;
7895 curr_vddp_reg = curr->vddp_data;
7896
7897 if (init) {
7898 /*
7899 * get the regulator handle from voltage regulator framework
7900 * and then try to set the voltage level for the regulator
7901 */
7902 if (curr_vdd_reg) {
7903 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7904 if (rc)
7905 goto out;
7906 }
7907 if (curr_vccq_reg) {
7908 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7909 if (rc)
7910 goto vdd_reg_deinit;
7911 }
7912 if (curr_vddp_reg) {
7913 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7914 if (rc)
7915 goto vccq_reg_deinit;
7916 }
7917 goto out;
7918 } else
7919 /* deregister with all regulators from regulator framework */
7920 goto vddp_reg_deinit;
7921
7922vddp_reg_deinit:
7923 if (curr_vddp_reg)
7924 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7925vccq_reg_deinit:
7926 if (curr_vccq_reg)
7927 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7928vdd_reg_deinit:
7929 if (curr_vdd_reg)
7930 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7931out:
7932 return rc;
7933}
7934
7935static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7936{
7937 int rc;
7938
7939 if (!vreg->enabled) {
7940 rc = regulator_enable(vreg->reg);
7941 if (rc) {
7942 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7943 __func__, vreg->reg_name, rc);
7944 goto out;
7945 }
7946 vreg->enabled = 1;
7947 }
7948
7949 /* Put always_on regulator in HPM (high power mode) */
7950 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7951 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7952 if (rc < 0) {
7953 pr_err("%s: reg=%s: HPM setting failed"
7954 " hpm_uA=%d, rc=%d\n",
7955 __func__, vreg->reg_name,
7956 vreg->hpm_uA, rc);
7957 goto vreg_disable;
7958 }
7959 rc = 0;
7960 }
7961 goto out;
7962
7963vreg_disable:
7964 regulator_disable(vreg->reg);
7965 vreg->enabled = 0;
7966out:
7967 return rc;
7968}
7969
7970static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7971{
7972 int rc;
7973
7974 /* Never disable always_on regulator */
7975 if (!vreg->always_on) {
7976 rc = regulator_disable(vreg->reg);
7977 if (rc) {
7978 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7979 __func__, vreg->reg_name, rc);
7980 goto out;
7981 }
7982 vreg->enabled = 0;
7983 }
7984
7985 /* Put always_on regulator in LPM (low power mode) */
7986 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7987 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
7988 if (rc < 0) {
7989 pr_err("%s: reg=%s: LPM setting failed"
7990 " lpm_uA=%d, rc=%d\n",
7991 __func__,
7992 vreg->reg_name,
7993 vreg->lpm_uA, rc);
7994 goto out;
7995 }
7996 rc = 0;
7997 }
7998
7999out:
8000 return rc;
8001}
8002
8003static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8004{
8005 int rc = 0;
8006 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8007 struct sdcc_reg_data *curr;
8008
8009 curr = &sdcc_vreg_data[dev_id - 1];
8010 curr_vdd_reg = curr->vdd_data;
8011 curr_vccq_reg = curr->vccq_data;
8012 curr_vddp_reg = curr->vddp_data;
8013
8014 /* check if regulators are initialized or not? */
8015 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8016 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8017 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8018 /* initialize voltage regulators required for this SDCC */
8019 rc = msm_sdcc_vreg_init(dev_id, 1);
8020 if (rc) {
8021 pr_err("%s: regulator init failed = %d\n",
8022 __func__, rc);
8023 goto out;
8024 }
8025 }
8026
8027 if (curr->sts == enable)
8028 goto out;
8029
8030 if (curr_vdd_reg) {
8031 if (enable)
8032 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8033 else
8034 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8035 if (rc)
8036 goto out;
8037 }
8038
8039 if (curr_vccq_reg) {
8040 if (enable)
8041 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8042 else
8043 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8044 if (rc)
8045 goto out;
8046 }
8047
8048 if (curr_vddp_reg) {
8049 if (enable)
8050 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8051 else
8052 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8053 if (rc)
8054 goto out;
8055 }
8056 curr->sts = enable;
8057
8058out:
8059 return rc;
8060}
8061
8062static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8063{
8064 u32 rc_pin_cfg = 0;
8065 u32 rc_vreg_cfg = 0;
8066 u32 rc = 0;
8067 struct platform_device *pdev;
8068 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8069
8070 pdev = container_of(dv, struct platform_device, dev);
8071
8072 /* setup gpio/pad */
8073 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8074 if (curr_pin_cfg->cfg_sts == !!vdd)
8075 goto setup_vreg;
8076
8077 if (curr_pin_cfg->is_gpio)
8078 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8079 else
8080 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8081
8082setup_vreg:
8083 /* setup voltage regulators */
8084 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8085
8086 if (rc_pin_cfg || rc_vreg_cfg)
8087 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8088
8089 return rc;
8090}
8091
8092static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8093{
8094 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8095 struct platform_device *pdev;
8096
8097 pdev = container_of(dv, struct platform_device, dev);
8098 /* setup gpio/pad */
8099 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8100
8101 if (curr_pin_cfg->cfg_sts == active)
8102 return;
8103
8104 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8105 if (curr_pin_cfg->is_gpio)
8106 msm_sdcc_setup_gpio(pdev->id, active);
8107 else
8108 msm_sdcc_setup_pad(pdev->id, active);
8109 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8110}
8111
8112static int msm_sdc3_get_wpswitch(struct device *dev)
8113{
8114 struct platform_device *pdev;
8115 int status;
8116 pdev = container_of(dev, struct platform_device, dev);
8117
8118 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8119 if (status) {
8120 pr_err("%s:Failed to request GPIO %d\n",
8121 __func__, GPIO_SDC_WP);
8122 } else {
8123 status = gpio_direction_input(GPIO_SDC_WP);
8124 if (!status) {
8125 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8126 pr_info("%s: WP Status for Slot %d = %d\n",
8127 __func__, pdev->id, status);
8128 }
8129 gpio_free(GPIO_SDC_WP);
8130 }
8131 return status;
8132}
8133
8134#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8135int sdc5_register_status_notify(void (*callback)(int, void *),
8136 void *dev_id)
8137{
8138 sdc5_status_notify_cb = callback;
8139 sdc5_status_notify_cb_devid = dev_id;
8140 return 0;
8141}
8142#endif
8143
8144#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8145int sdc2_register_status_notify(void (*callback)(int, void *),
8146 void *dev_id)
8147{
8148 sdc2_status_notify_cb = callback;
8149 sdc2_status_notify_cb_devid = dev_id;
8150 return 0;
8151}
8152#endif
8153
8154/* Interrupt handler for SDC2 and SDC5 detection
8155 * This function uses dual-edge interrputs settings in order
8156 * to get SDIO detection when the GPIO is rising and SDIO removal
8157 * when the GPIO is falling */
8158static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8159{
8160 int status;
8161
8162 if (!machine_is_msm8x60_fusion() &&
8163 !machine_is_msm8x60_fusn_ffa())
8164 return IRQ_NONE;
8165
8166 status = gpio_get_value(MDM2AP_SYNC);
8167 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8168 __func__, status);
8169
8170#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8171 if (sdc2_status_notify_cb) {
8172 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8173 sdc2_status_notify_cb(status,
8174 sdc2_status_notify_cb_devid);
8175 }
8176#endif
8177
8178#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8179 if (sdc5_status_notify_cb) {
8180 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8181 sdc5_status_notify_cb(status,
8182 sdc5_status_notify_cb_devid);
8183 }
8184#endif
8185 return IRQ_HANDLED;
8186}
8187
8188static int msm8x60_multi_sdio_init(void)
8189{
8190 int ret, irq_num;
8191
8192 if (!machine_is_msm8x60_fusion() &&
8193 !machine_is_msm8x60_fusn_ffa())
8194 return 0;
8195
8196 ret = msm_gpiomux_get(MDM2AP_SYNC);
8197 if (ret) {
8198 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8199 __func__, MDM2AP_SYNC, ret);
8200 return ret;
8201 }
8202
8203 irq_num = gpio_to_irq(MDM2AP_SYNC);
8204
8205 ret = request_irq(irq_num,
8206 msm8x60_multi_sdio_slot_status_irq,
8207 IRQ_TYPE_EDGE_BOTH,
8208 "sdio_multidetection", NULL);
8209
8210 if (ret) {
8211 pr_err("%s:Failed to request irq, ret=%d\n",
8212 __func__, ret);
8213 return ret;
8214 }
8215
8216 return ret;
8217}
8218
8219#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8220#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8221static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8222{
8223 int status;
8224
8225 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8226 , "SD_HW_Detect");
8227 if (status) {
8228 pr_err("%s:Failed to request GPIO %d\n", __func__,
8229 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8230 } else {
8231 status = gpio_direction_input(
8232 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8233 if (!status)
8234 status = !(gpio_get_value_cansleep(
8235 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8236 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8237 }
8238 return (unsigned int) status;
8239}
8240#endif
8241#endif
8242
8243#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8244static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
8245{
8246 struct platform_device *pdev;
8247 enum msm_mpm_pin pin;
8248 int ret = 0;
8249
8250 pdev = container_of(dev, struct platform_device, dev);
8251
8252 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
8253 if (pdev->id == 4)
8254 pin = MSM_MPM_PIN_SDC4_DAT1;
8255 else
8256 return -EINVAL;
8257
8258 switch (mode) {
8259 case SDC_DAT1_DISABLE:
8260 ret = msm_mpm_enable_pin(pin, 0);
8261 break;
8262 case SDC_DAT1_ENABLE:
8263 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
8264 ret = msm_mpm_enable_pin(pin, 1);
8265 break;
8266 case SDC_DAT1_ENWAKE:
8267 ret = msm_mpm_set_pin_wake(pin, 1);
8268 break;
8269 case SDC_DAT1_DISWAKE:
8270 ret = msm_mpm_set_pin_wake(pin, 0);
8271 break;
8272 default:
8273 ret = -EINVAL;
8274 break;
8275 }
8276 return ret;
8277}
8278#endif
8279#endif
8280
8281#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8282static struct mmc_platform_data msm8x60_sdc1_data = {
8283 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8284 .translate_vdd = msm_sdcc_setup_power,
8285#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8286 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8287#else
8288 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8289#endif
8290 .msmsdcc_fmin = 400000,
8291 .msmsdcc_fmid = 24000000,
8292 .msmsdcc_fmax = 48000000,
8293 .nonremovable = 1,
8294 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008295};
8296#endif
8297
8298#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8299static struct mmc_platform_data msm8x60_sdc2_data = {
8300 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8301 .translate_vdd = msm_sdcc_setup_power,
8302 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8303 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8304 .msmsdcc_fmin = 400000,
8305 .msmsdcc_fmid = 24000000,
8306 .msmsdcc_fmax = 48000000,
8307 .nonremovable = 0,
8308 .pclk_src_dfab = 1,
8309 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008310#ifdef CONFIG_MSM_SDIO_AL
8311 .is_sdio_al_client = 1,
8312#endif
8313};
8314#endif
8315
8316#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8317static struct mmc_platform_data msm8x60_sdc3_data = {
8318 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8319 .translate_vdd = msm_sdcc_setup_power,
8320 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8321 .wpswitch = msm_sdc3_get_wpswitch,
8322#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8323 .status = msm8x60_sdcc_slot_status,
8324 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8325 PMIC_GPIO_SDC3_DET - 1),
8326 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8327#endif
8328 .msmsdcc_fmin = 400000,
8329 .msmsdcc_fmid = 24000000,
8330 .msmsdcc_fmax = 48000000,
8331 .nonremovable = 0,
8332 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008333};
8334#endif
8335
8336#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8337static struct mmc_platform_data msm8x60_sdc4_data = {
8338 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8339 .translate_vdd = msm_sdcc_setup_power,
8340 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8341 .msmsdcc_fmin = 400000,
8342 .msmsdcc_fmid = 24000000,
8343 .msmsdcc_fmax = 48000000,
8344 .nonremovable = 0,
8345 .pclk_src_dfab = 1,
8346 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008347};
8348#endif
8349
8350#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8351static struct mmc_platform_data msm8x60_sdc5_data = {
8352 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8353 .translate_vdd = msm_sdcc_setup_power,
8354 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8355 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8356 .msmsdcc_fmin = 400000,
8357 .msmsdcc_fmid = 24000000,
8358 .msmsdcc_fmax = 48000000,
8359 .nonremovable = 0,
8360 .pclk_src_dfab = 1,
8361 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008362#ifdef CONFIG_MSM_SDIO_AL
8363 .is_sdio_al_client = 1,
8364#endif
8365};
8366#endif
8367
8368static void __init msm8x60_init_mmc(void)
8369{
8370#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8371 /* SDCC1 : eMMC card connected */
8372 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8373 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8374 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8375 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308376 sdcc_vreg_data[0].vdd_data->always_on = 1;
8377 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8378 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8379 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008380
8381 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8382 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8383 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8384 sdcc_vreg_data[0].vccq_data->always_on = 1;
8385
8386 msm_add_sdcc(1, &msm8x60_sdc1_data);
8387#endif
8388#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8389 /*
8390 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8391 * and no card is connected on 8660 SURF/FFA/FLUID.
8392 */
8393 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8394 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8395 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8396 sdcc_vreg_data[1].vdd_data->level = 1800000;
8397
8398 sdcc_vreg_data[1].vccq_data = NULL;
8399
8400 if (machine_is_msm8x60_fusion())
8401 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8402 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8403#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8404 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8405 msm_sdcc_setup_gpio(2, 1);
8406#endif
8407 msm_add_sdcc(2, &msm8x60_sdc2_data);
8408 }
8409#endif
8410#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8411 /* SDCC3 : External card slot connected */
8412 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8413 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8414 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8415 sdcc_vreg_data[2].vdd_data->level = 2850000;
8416 sdcc_vreg_data[2].vdd_data->always_on = 1;
8417 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8418 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8419 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8420
8421 sdcc_vreg_data[2].vccq_data = NULL;
8422
8423 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8424 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8425 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8426 sdcc_vreg_data[2].vddp_data->level = 2850000;
8427 sdcc_vreg_data[2].vddp_data->always_on = 1;
8428 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8429 /* Sleep current required is ~300 uA. But min. RPM
8430 * vote can be in terms of mA (min. 1 mA).
8431 * So let's vote for 2 mA during sleep.
8432 */
8433 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8434 /* Max. Active current required is 16 mA */
8435 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8436
8437 if (machine_is_msm8x60_fluid())
8438 msm8x60_sdc3_data.wpswitch = NULL;
8439 msm_add_sdcc(3, &msm8x60_sdc3_data);
8440#endif
8441#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8442 /* SDCC4 : WLAN WCN1314 chip is connected */
8443 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8444 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8445 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8446 sdcc_vreg_data[3].vdd_data->level = 1800000;
8447
8448 sdcc_vreg_data[3].vccq_data = NULL;
8449
8450 msm_add_sdcc(4, &msm8x60_sdc4_data);
8451#endif
8452#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8453 /*
8454 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8455 * and no card is connected on 8660 SURF/FFA/FLUID.
8456 */
8457 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8458 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8459 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8460 sdcc_vreg_data[4].vdd_data->level = 1800000;
8461
8462 sdcc_vreg_data[4].vccq_data = NULL;
8463
8464 if (machine_is_msm8x60_fusion())
8465 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8466 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8467#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8468 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8469 msm_sdcc_setup_gpio(5, 1);
8470#endif
8471 msm_add_sdcc(5, &msm8x60_sdc5_data);
8472 }
8473#endif
8474}
8475
8476#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8477static inline void display_common_power(int on) {}
8478#else
8479
8480#define _GET_REGULATOR(var, name) do { \
8481 if (var == NULL) { \
8482 var = regulator_get(NULL, name); \
8483 if (IS_ERR(var)) { \
8484 pr_err("'%s' regulator not found, rc=%ld\n", \
8485 name, PTR_ERR(var)); \
8486 var = NULL; \
8487 } \
8488 } \
8489} while (0)
8490
8491static int dsub_regulator(int on)
8492{
8493 static struct regulator *dsub_reg;
8494 static struct regulator *mpp0_reg;
8495 static int dsub_reg_enabled;
8496 int rc = 0;
8497
8498 _GET_REGULATOR(dsub_reg, "8901_l3");
8499 if (IS_ERR(dsub_reg)) {
8500 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8501 __func__, PTR_ERR(dsub_reg));
8502 return PTR_ERR(dsub_reg);
8503 }
8504
8505 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8506 if (IS_ERR(mpp0_reg)) {
8507 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8508 __func__, PTR_ERR(mpp0_reg));
8509 return PTR_ERR(mpp0_reg);
8510 }
8511
8512 if (on && !dsub_reg_enabled) {
8513 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8514 if (rc) {
8515 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8516 " err=%d", __func__, rc);
8517 goto dsub_regulator_err;
8518 }
8519 rc = regulator_enable(dsub_reg);
8520 if (rc) {
8521 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8522 " err=%d", __func__, rc);
8523 goto dsub_regulator_err;
8524 }
8525 rc = regulator_enable(mpp0_reg);
8526 if (rc) {
8527 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8528 " err=%d", __func__, rc);
8529 goto dsub_regulator_err;
8530 }
8531 dsub_reg_enabled = 1;
8532 } else if (!on && dsub_reg_enabled) {
8533 rc = regulator_disable(dsub_reg);
8534 if (rc)
8535 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8536 " err=%d", __func__, rc);
8537 rc = regulator_disable(mpp0_reg);
8538 if (rc)
8539 printk(KERN_WARNING "%s: failed to disable reg "
8540 "8901_mpp0 err=%d", __func__, rc);
8541 dsub_reg_enabled = 0;
8542 }
8543
8544 return rc;
8545
8546dsub_regulator_err:
8547 regulator_put(mpp0_reg);
8548 regulator_put(dsub_reg);
8549 return rc;
8550}
8551
8552static int display_power_on;
8553static void setup_display_power(void)
8554{
8555 if (display_power_on)
8556 if (lcdc_vga_enabled) {
8557 dsub_regulator(1);
8558 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8559 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8560 if (machine_is_msm8x60_ffa() ||
8561 machine_is_msm8x60_fusn_ffa())
8562 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8563 } else {
8564 dsub_regulator(0);
8565 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8566 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8567 if (machine_is_msm8x60_ffa() ||
8568 machine_is_msm8x60_fusn_ffa())
8569 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8570 }
8571 else {
8572 dsub_regulator(0);
8573 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8574 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8575 /* BACKLIGHT */
8576 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8577 /* LVDS */
8578 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8579 }
8580}
8581
8582#define _GET_REGULATOR(var, name) do { \
8583 if (var == NULL) { \
8584 var = regulator_get(NULL, name); \
8585 if (IS_ERR(var)) { \
8586 pr_err("'%s' regulator not found, rc=%ld\n", \
8587 name, PTR_ERR(var)); \
8588 var = NULL; \
8589 } \
8590 } \
8591} while (0)
8592
8593#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8594
8595static void display_common_power(int on)
8596{
8597 int rc;
8598 static struct regulator *display_reg;
8599
8600 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8601 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8602 if (on) {
8603 /* LVDS */
8604 _GET_REGULATOR(display_reg, "8901_l2");
8605 if (!display_reg)
8606 return;
8607 rc = regulator_set_voltage(display_reg,
8608 3300000, 3300000);
8609 if (rc)
8610 goto out;
8611 rc = regulator_enable(display_reg);
8612 if (rc)
8613 goto out;
8614 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8615 "LVDS_STDN_OUT_N");
8616 if (rc) {
8617 printk(KERN_ERR "%s: LVDS gpio %d request"
8618 "failed\n", __func__,
8619 GPIO_LVDS_SHUTDOWN_N);
8620 goto out2;
8621 }
8622
8623 /* BACKLIGHT */
8624 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8625 if (rc) {
8626 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8627 "failed\n", __func__,
8628 GPIO_BACKLIGHT_EN);
8629 goto out3;
8630 }
8631
8632 if (machine_is_msm8x60_ffa() ||
8633 machine_is_msm8x60_fusn_ffa()) {
8634 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8635 "DONGLE_PWR_EN");
8636 if (rc) {
8637 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8638 " %d request failed\n", __func__,
8639 GPIO_DONGLE_PWR_EN);
8640 goto out4;
8641 }
8642 }
8643
8644 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8645 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8646 if (machine_is_msm8x60_ffa() ||
8647 machine_is_msm8x60_fusn_ffa())
8648 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8649 mdelay(20);
8650 display_power_on = 1;
8651 setup_display_power();
8652 } else {
8653 if (display_power_on) {
8654 display_power_on = 0;
8655 setup_display_power();
8656 mdelay(20);
8657 if (machine_is_msm8x60_ffa() ||
8658 machine_is_msm8x60_fusn_ffa())
8659 gpio_free(GPIO_DONGLE_PWR_EN);
8660 goto out4;
8661 }
8662 }
8663 }
8664#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8665 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8666 else if (machine_is_msm8x60_fluid()) {
8667 static struct regulator *fluid_reg;
8668 static struct regulator *fluid_reg2;
8669
8670 if (on) {
8671 _GET_REGULATOR(fluid_reg, "8901_l2");
8672 if (!fluid_reg)
8673 return;
8674 _GET_REGULATOR(fluid_reg2, "8058_s3");
8675 if (!fluid_reg2) {
8676 regulator_put(fluid_reg);
8677 return;
8678 }
8679 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8680 if (rc) {
8681 regulator_put(fluid_reg2);
8682 regulator_put(fluid_reg);
8683 return;
8684 }
8685 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8686 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8687 regulator_enable(fluid_reg);
8688 regulator_enable(fluid_reg2);
8689 msleep(20);
8690 gpio_direction_output(GPIO_RESX_N, 0);
8691 udelay(10);
8692 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8693 display_power_on = 1;
8694 setup_display_power();
8695 } else {
8696 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8697 gpio_free(GPIO_RESX_N);
8698 msleep(20);
8699 regulator_disable(fluid_reg2);
8700 regulator_disable(fluid_reg);
8701 regulator_put(fluid_reg2);
8702 regulator_put(fluid_reg);
8703 display_power_on = 0;
8704 setup_display_power();
8705 fluid_reg = NULL;
8706 fluid_reg2 = NULL;
8707 }
8708 }
8709#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008710#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8711 else if (machine_is_msm8x60_dragon()) {
8712 static struct regulator *dragon_reg;
8713 static struct regulator *dragon_reg2;
8714
8715 if (on) {
8716 _GET_REGULATOR(dragon_reg, "8901_l2");
8717 if (!dragon_reg)
8718 return;
8719 _GET_REGULATOR(dragon_reg2, "8058_l16");
8720 if (!dragon_reg2) {
8721 regulator_put(dragon_reg);
8722 dragon_reg = NULL;
8723 return;
8724 }
8725
8726 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8727 if (rc) {
8728 pr_err("%s: gpio %d request failed with rc=%d\n",
8729 __func__, GPIO_NT35582_BL_EN, rc);
8730 regulator_put(dragon_reg);
8731 regulator_put(dragon_reg2);
8732 dragon_reg = NULL;
8733 dragon_reg2 = NULL;
8734 return;
8735 }
8736
8737 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8738 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8739 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8740 pr_err("%s: config gpio '%d' failed!\n",
8741 __func__, GPIO_NT35582_RESET);
8742 gpio_free(GPIO_NT35582_BL_EN);
8743 regulator_put(dragon_reg);
8744 regulator_put(dragon_reg2);
8745 dragon_reg = NULL;
8746 dragon_reg2 = NULL;
8747 return;
8748 }
8749
8750 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8751 if (rc) {
8752 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8753 __func__, GPIO_NT35582_RESET, rc);
8754 gpio_free(GPIO_NT35582_BL_EN);
8755 regulator_put(dragon_reg);
8756 regulator_put(dragon_reg2);
8757 dragon_reg = NULL;
8758 dragon_reg2 = NULL;
8759 return;
8760 }
8761
8762 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8763 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8764 regulator_enable(dragon_reg);
8765 regulator_enable(dragon_reg2);
8766 msleep(20);
8767
8768 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8769 msleep(20);
8770 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8771 msleep(20);
8772 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8773 msleep(50);
8774
8775 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8776
8777 display_power_on = 1;
8778 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8779 gpio_free(GPIO_NT35582_RESET);
8780 gpio_free(GPIO_NT35582_BL_EN);
8781 regulator_disable(dragon_reg2);
8782 regulator_disable(dragon_reg);
8783 regulator_put(dragon_reg2);
8784 regulator_put(dragon_reg);
8785 display_power_on = 0;
8786 dragon_reg = NULL;
8787 dragon_reg2 = NULL;
8788 }
8789 }
8790#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008791 return;
8792
8793out4:
8794 gpio_free(GPIO_BACKLIGHT_EN);
8795out3:
8796 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8797out2:
8798 regulator_disable(display_reg);
8799out:
8800 regulator_put(display_reg);
8801 display_reg = NULL;
8802}
8803#undef _GET_REGULATOR
8804#endif
8805
8806static int mipi_dsi_panel_power(int on);
8807
8808#define LCDC_NUM_GPIO 28
8809#define LCDC_GPIO_START 0
8810
8811static void lcdc_samsung_panel_power(int on)
8812{
8813 int n, ret = 0;
8814
8815 display_common_power(on);
8816
8817 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8818 if (on) {
8819 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8820 if (unlikely(ret)) {
8821 pr_err("%s not able to get gpio\n", __func__);
8822 break;
8823 }
8824 } else
8825 gpio_free(LCDC_GPIO_START + n);
8826 }
8827
8828 if (ret) {
8829 for (n--; n >= 0; n--)
8830 gpio_free(LCDC_GPIO_START + n);
8831 }
8832
8833 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8834}
8835
8836#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8837#define _GET_REGULATOR(var, name) do { \
8838 var = regulator_get(NULL, name); \
8839 if (IS_ERR(var)) { \
8840 pr_err("'%s' regulator not found, rc=%ld\n", \
8841 name, IS_ERR(var)); \
8842 var = NULL; \
8843 return -ENODEV; \
8844 } \
8845} while (0)
8846
8847static int hdmi_enable_5v(int on)
8848{
8849 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8850 static struct regulator *reg_8901_mpp0; /* External 5V */
8851 static int prev_on;
8852 int rc;
8853
8854 if (on == prev_on)
8855 return 0;
8856
8857 if (!reg_8901_hdmi_mvs)
8858 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8859 if (!reg_8901_mpp0)
8860 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8861
8862 if (on) {
8863 rc = regulator_enable(reg_8901_mpp0);
8864 if (rc) {
8865 pr_err("'%s' regulator enable failed, rc=%d\n",
8866 "reg_8901_mpp0", rc);
8867 return rc;
8868 }
8869 rc = regulator_enable(reg_8901_hdmi_mvs);
8870 if (rc) {
8871 pr_err("'%s' regulator enable failed, rc=%d\n",
8872 "8901_hdmi_mvs", rc);
8873 return rc;
8874 }
8875 pr_info("%s(on): success\n", __func__);
8876 } else {
8877 rc = regulator_disable(reg_8901_hdmi_mvs);
8878 if (rc)
8879 pr_warning("'%s' regulator disable failed, rc=%d\n",
8880 "8901_hdmi_mvs", rc);
8881 rc = regulator_disable(reg_8901_mpp0);
8882 if (rc)
8883 pr_warning("'%s' regulator disable failed, rc=%d\n",
8884 "reg_8901_mpp0", rc);
8885 pr_info("%s(off): success\n", __func__);
8886 }
8887
8888 prev_on = on;
8889
8890 return 0;
8891}
8892
8893static int hdmi_core_power(int on, int show)
8894{
8895 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8896 static int prev_on;
8897 int rc;
8898
8899 if (on == prev_on)
8900 return 0;
8901
8902 if (!reg_8058_l16)
8903 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8904
8905 if (on) {
8906 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8907 if (!rc)
8908 rc = regulator_enable(reg_8058_l16);
8909 if (rc) {
8910 pr_err("'%s' regulator enable failed, rc=%d\n",
8911 "8058_l16", rc);
8912 return rc;
8913 }
8914 rc = gpio_request(170, "HDMI_DDC_CLK");
8915 if (rc) {
8916 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8917 "HDMI_DDC_CLK", 170, rc);
8918 goto error1;
8919 }
8920 rc = gpio_request(171, "HDMI_DDC_DATA");
8921 if (rc) {
8922 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8923 "HDMI_DDC_DATA", 171, rc);
8924 goto error2;
8925 }
8926 rc = gpio_request(172, "HDMI_HPD");
8927 if (rc) {
8928 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8929 "HDMI_HPD", 172, rc);
8930 goto error3;
8931 }
8932 pr_info("%s(on): success\n", __func__);
8933 } else {
8934 gpio_free(170);
8935 gpio_free(171);
8936 gpio_free(172);
8937 rc = regulator_disable(reg_8058_l16);
8938 if (rc)
8939 pr_warning("'%s' regulator disable failed, rc=%d\n",
8940 "8058_l16", rc);
8941 pr_info("%s(off): success\n", __func__);
8942 }
8943
8944 prev_on = on;
8945
8946 return 0;
8947
8948error3:
8949 gpio_free(171);
8950error2:
8951 gpio_free(170);
8952error1:
8953 regulator_disable(reg_8058_l16);
8954 return rc;
8955}
8956
8957static int hdmi_cec_power(int on)
8958{
8959 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8960 static int prev_on;
8961 int rc;
8962
8963 if (on == prev_on)
8964 return 0;
8965
8966 if (!reg_8901_l3)
8967 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8968
8969 if (on) {
8970 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8971 if (!rc)
8972 rc = regulator_enable(reg_8901_l3);
8973 if (rc) {
8974 pr_err("'%s' regulator enable failed, rc=%d\n",
8975 "8901_l3", rc);
8976 return rc;
8977 }
8978 rc = gpio_request(169, "HDMI_CEC_VAR");
8979 if (rc) {
8980 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8981 "HDMI_CEC_VAR", 169, rc);
8982 goto error;
8983 }
8984 pr_info("%s(on): success\n", __func__);
8985 } else {
8986 gpio_free(169);
8987 rc = regulator_disable(reg_8901_l3);
8988 if (rc)
8989 pr_warning("'%s' regulator disable failed, rc=%d\n",
8990 "8901_l3", rc);
8991 pr_info("%s(off): success\n", __func__);
8992 }
8993
8994 prev_on = on;
8995
8996 return 0;
8997error:
8998 regulator_disable(reg_8901_l3);
8999 return rc;
9000}
9001
9002#undef _GET_REGULATOR
9003
9004#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9005
9006static int lcdc_panel_power(int on)
9007{
9008 int flag_on = !!on;
9009 static int lcdc_power_save_on;
9010
9011 if (lcdc_power_save_on == flag_on)
9012 return 0;
9013
9014 lcdc_power_save_on = flag_on;
9015
9016 lcdc_samsung_panel_power(on);
9017
9018 return 0;
9019}
9020
9021#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009022
9023static struct msm_bus_vectors rotator_init_vectors[] = {
9024 {
9025 .src = MSM_BUS_MASTER_ROTATOR,
9026 .dst = MSM_BUS_SLAVE_SMI,
9027 .ab = 0,
9028 .ib = 0,
9029 },
9030 {
9031 .src = MSM_BUS_MASTER_ROTATOR,
9032 .dst = MSM_BUS_SLAVE_EBI_CH0,
9033 .ab = 0,
9034 .ib = 0,
9035 },
9036};
9037
9038static struct msm_bus_vectors rotator_ui_vectors[] = {
9039 {
9040 .src = MSM_BUS_MASTER_ROTATOR,
9041 .dst = MSM_BUS_SLAVE_SMI,
9042 .ab = 0,
9043 .ib = 0,
9044 },
9045 {
9046 .src = MSM_BUS_MASTER_ROTATOR,
9047 .dst = MSM_BUS_SLAVE_EBI_CH0,
9048 .ab = (1024 * 600 * 4 * 2 * 60),
9049 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9050 },
9051};
9052
9053static struct msm_bus_vectors rotator_vga_vectors[] = {
9054 {
9055 .src = MSM_BUS_MASTER_ROTATOR,
9056 .dst = MSM_BUS_SLAVE_SMI,
9057 .ab = (640 * 480 * 2 * 2 * 30),
9058 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9059 },
9060 {
9061 .src = MSM_BUS_MASTER_ROTATOR,
9062 .dst = MSM_BUS_SLAVE_EBI_CH0,
9063 .ab = (640 * 480 * 2 * 2 * 30),
9064 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9065 },
9066};
9067
9068static struct msm_bus_vectors rotator_720p_vectors[] = {
9069 {
9070 .src = MSM_BUS_MASTER_ROTATOR,
9071 .dst = MSM_BUS_SLAVE_SMI,
9072 .ab = (1280 * 736 * 2 * 2 * 30),
9073 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9074 },
9075 {
9076 .src = MSM_BUS_MASTER_ROTATOR,
9077 .dst = MSM_BUS_SLAVE_EBI_CH0,
9078 .ab = (1280 * 736 * 2 * 2 * 30),
9079 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9080 },
9081};
9082
9083static struct msm_bus_vectors rotator_1080p_vectors[] = {
9084 {
9085 .src = MSM_BUS_MASTER_ROTATOR,
9086 .dst = MSM_BUS_SLAVE_SMI,
9087 .ab = (1920 * 1088 * 2 * 2 * 30),
9088 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9089 },
9090 {
9091 .src = MSM_BUS_MASTER_ROTATOR,
9092 .dst = MSM_BUS_SLAVE_EBI_CH0,
9093 .ab = (1920 * 1088 * 2 * 2 * 30),
9094 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9095 },
9096};
9097
9098static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9099 {
9100 ARRAY_SIZE(rotator_init_vectors),
9101 rotator_init_vectors,
9102 },
9103 {
9104 ARRAY_SIZE(rotator_ui_vectors),
9105 rotator_ui_vectors,
9106 },
9107 {
9108 ARRAY_SIZE(rotator_vga_vectors),
9109 rotator_vga_vectors,
9110 },
9111 {
9112 ARRAY_SIZE(rotator_720p_vectors),
9113 rotator_720p_vectors,
9114 },
9115 {
9116 ARRAY_SIZE(rotator_1080p_vectors),
9117 rotator_1080p_vectors,
9118 },
9119};
9120
9121struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9122 rotator_bus_scale_usecases,
9123 ARRAY_SIZE(rotator_bus_scale_usecases),
9124 .name = "rotator",
9125};
9126
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009127static struct msm_bus_vectors mdp_init_vectors[] = {
9128 /* For now, 0th array entry is reserved.
9129 * Please leave 0 as is and don't use it
9130 */
9131 {
9132 .src = MSM_BUS_MASTER_MDP_PORT0,
9133 .dst = MSM_BUS_SLAVE_SMI,
9134 .ab = 0,
9135 .ib = 0,
9136 },
9137 /* Master and slaves can be from different fabrics */
9138 {
9139 .src = MSM_BUS_MASTER_MDP_PORT0,
9140 .dst = MSM_BUS_SLAVE_EBI_CH0,
9141 .ab = 0,
9142 .ib = 0,
9143 },
9144};
9145
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009146#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9147static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
9148 /* If HDMI is used as primary */
9149 {
9150 .src = MSM_BUS_MASTER_MDP_PORT0,
9151 .dst = MSM_BUS_SLAVE_SMI,
9152 .ab = 2000000000,
9153 .ib = 2000000000,
9154 },
9155 /* Master and slaves can be from different fabrics */
9156 {
9157 .src = MSM_BUS_MASTER_MDP_PORT0,
9158 .dst = MSM_BUS_SLAVE_EBI_CH0,
9159 .ab = 2000000000,
9160 .ib = 2000000000,
9161 },
9162};
9163
9164static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9165 {
9166 ARRAY_SIZE(mdp_init_vectors),
9167 mdp_init_vectors,
9168 },
9169 {
9170 ARRAY_SIZE(hdmi_as_primary_vectors),
9171 hdmi_as_primary_vectors,
9172 },
9173 {
9174 ARRAY_SIZE(hdmi_as_primary_vectors),
9175 hdmi_as_primary_vectors,
9176 },
9177 {
9178 ARRAY_SIZE(hdmi_as_primary_vectors),
9179 hdmi_as_primary_vectors,
9180 },
9181 {
9182 ARRAY_SIZE(hdmi_as_primary_vectors),
9183 hdmi_as_primary_vectors,
9184 },
9185 {
9186 ARRAY_SIZE(hdmi_as_primary_vectors),
9187 hdmi_as_primary_vectors,
9188 },
9189};
9190#else
9191#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009192static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9193 /* Default case static display/UI/2d/3d if FB SMI */
9194 {
9195 .src = MSM_BUS_MASTER_MDP_PORT0,
9196 .dst = MSM_BUS_SLAVE_SMI,
9197 .ab = 388800000,
9198 .ib = 486000000,
9199 },
9200 /* Master and slaves can be from different fabrics */
9201 {
9202 .src = MSM_BUS_MASTER_MDP_PORT0,
9203 .dst = MSM_BUS_SLAVE_EBI_CH0,
9204 .ab = 0,
9205 .ib = 0,
9206 },
9207};
9208
9209static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9210 /* Default case static display/UI/2d/3d if FB SMI */
9211 {
9212 .src = MSM_BUS_MASTER_MDP_PORT0,
9213 .dst = MSM_BUS_SLAVE_SMI,
9214 .ab = 0,
9215 .ib = 0,
9216 },
9217 /* Master and slaves can be from different fabrics */
9218 {
9219 .src = MSM_BUS_MASTER_MDP_PORT0,
9220 .dst = MSM_BUS_SLAVE_EBI_CH0,
9221 .ab = 388800000,
9222 .ib = 486000000 * 2,
9223 },
9224};
9225static struct msm_bus_vectors mdp_vga_vectors[] = {
9226 /* VGA and less video */
9227 {
9228 .src = MSM_BUS_MASTER_MDP_PORT0,
9229 .dst = MSM_BUS_SLAVE_SMI,
9230 .ab = 458092800,
9231 .ib = 572616000,
9232 },
9233 {
9234 .src = MSM_BUS_MASTER_MDP_PORT0,
9235 .dst = MSM_BUS_SLAVE_EBI_CH0,
9236 .ab = 458092800,
9237 .ib = 572616000 * 2,
9238 },
9239};
9240static struct msm_bus_vectors mdp_720p_vectors[] = {
9241 /* 720p and less video */
9242 {
9243 .src = MSM_BUS_MASTER_MDP_PORT0,
9244 .dst = MSM_BUS_SLAVE_SMI,
9245 .ab = 471744000,
9246 .ib = 589680000,
9247 },
9248 /* Master and slaves can be from different fabrics */
9249 {
9250 .src = MSM_BUS_MASTER_MDP_PORT0,
9251 .dst = MSM_BUS_SLAVE_EBI_CH0,
9252 .ab = 471744000,
9253 .ib = 589680000 * 2,
9254 },
9255};
9256
9257static struct msm_bus_vectors mdp_1080p_vectors[] = {
9258 /* 1080p and less video */
9259 {
9260 .src = MSM_BUS_MASTER_MDP_PORT0,
9261 .dst = MSM_BUS_SLAVE_SMI,
9262 .ab = 575424000,
9263 .ib = 719280000,
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 = 575424000,
9270 .ib = 719280000 * 2,
9271 },
9272};
9273
9274#else
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 = 175110000,
9281 .ib = 218887500,
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 = 216000000,
9305 .ib = 270000000 * 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 = 216000000,
9314 .ib = 270000000,
9315 },
9316 {
9317 .src = MSM_BUS_MASTER_MDP_PORT0,
9318 .dst = MSM_BUS_SLAVE_EBI_CH0,
9319 .ab = 216000000,
9320 .ib = 270000000 * 2,
9321 },
9322};
9323
9324static struct msm_bus_vectors mdp_720p_vectors[] = {
9325 /* 720p and less video */
9326 {
9327 .src = MSM_BUS_MASTER_MDP_PORT0,
9328 .dst = MSM_BUS_SLAVE_SMI,
9329 .ab = 230400000,
9330 .ib = 288000000,
9331 },
9332 /* Master and slaves can be from different fabrics */
9333 {
9334 .src = MSM_BUS_MASTER_MDP_PORT0,
9335 .dst = MSM_BUS_SLAVE_EBI_CH0,
9336 .ab = 230400000,
9337 .ib = 288000000 * 2,
9338 },
9339};
9340
9341static struct msm_bus_vectors mdp_1080p_vectors[] = {
9342 /* 1080p and less video */
9343 {
9344 .src = MSM_BUS_MASTER_MDP_PORT0,
9345 .dst = MSM_BUS_SLAVE_SMI,
9346 .ab = 334080000,
9347 .ib = 417600000,
9348 },
9349 /* Master and slaves can be from different fabrics */
9350 {
9351 .src = MSM_BUS_MASTER_MDP_PORT0,
9352 .dst = MSM_BUS_SLAVE_EBI_CH0,
9353 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009354 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009355 },
9356};
9357
9358#endif
9359static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9360 {
9361 ARRAY_SIZE(mdp_init_vectors),
9362 mdp_init_vectors,
9363 },
9364 {
9365 ARRAY_SIZE(mdp_sd_smi_vectors),
9366 mdp_sd_smi_vectors,
9367 },
9368 {
9369 ARRAY_SIZE(mdp_sd_ebi_vectors),
9370 mdp_sd_ebi_vectors,
9371 },
9372 {
9373 ARRAY_SIZE(mdp_vga_vectors),
9374 mdp_vga_vectors,
9375 },
9376 {
9377 ARRAY_SIZE(mdp_720p_vectors),
9378 mdp_720p_vectors,
9379 },
9380 {
9381 ARRAY_SIZE(mdp_1080p_vectors),
9382 mdp_1080p_vectors,
9383 },
9384};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009385#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009386static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9387 mdp_bus_scale_usecases,
9388 ARRAY_SIZE(mdp_bus_scale_usecases),
9389 .name = "mdp",
9390};
9391
9392#endif
9393#ifdef CONFIG_MSM_BUS_SCALING
9394static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9395 /* For now, 0th array entry is reserved.
9396 * Please leave 0 as is and don't use it
9397 */
9398 {
9399 .src = MSM_BUS_MASTER_MDP_PORT0,
9400 .dst = MSM_BUS_SLAVE_SMI,
9401 .ab = 0,
9402 .ib = 0,
9403 },
9404 /* Master and slaves can be from different fabrics */
9405 {
9406 .src = MSM_BUS_MASTER_MDP_PORT0,
9407 .dst = MSM_BUS_SLAVE_EBI_CH0,
9408 .ab = 0,
9409 .ib = 0,
9410 },
9411};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009412#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9413static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9414 /* For now, 0th array entry is reserved.
9415 * Please leave 0 as is and don't use it
9416 */
9417 {
9418 .src = MSM_BUS_MASTER_MDP_PORT0,
9419 .dst = MSM_BUS_SLAVE_SMI,
9420 .ab = 2000000000,
9421 .ib = 2000000000,
9422 },
9423 /* Master and slaves can be from different fabrics */
9424 {
9425 .src = MSM_BUS_MASTER_MDP_PORT0,
9426 .dst = MSM_BUS_SLAVE_EBI_CH0,
9427 .ab = 2000000000,
9428 .ib = 2000000000,
9429 },
9430};
9431#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009432static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9433 /* For now, 0th array entry is reserved.
9434 * Please leave 0 as is and don't use it
9435 */
9436 {
9437 .src = MSM_BUS_MASTER_MDP_PORT0,
9438 .dst = MSM_BUS_SLAVE_SMI,
9439 .ab = 566092800,
9440 .ib = 707616000,
9441 },
9442 /* Master and slaves can be from different fabrics */
9443 {
9444 .src = MSM_BUS_MASTER_MDP_PORT0,
9445 .dst = MSM_BUS_SLAVE_EBI_CH0,
9446 .ab = 566092800,
9447 .ib = 707616000,
9448 },
9449};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009450#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009451static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9452 {
9453 ARRAY_SIZE(dtv_bus_init_vectors),
9454 dtv_bus_init_vectors,
9455 },
9456 {
9457 ARRAY_SIZE(dtv_bus_def_vectors),
9458 dtv_bus_def_vectors,
9459 },
9460};
9461static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9462 dtv_bus_scale_usecases,
9463 ARRAY_SIZE(dtv_bus_scale_usecases),
9464 .name = "dtv",
9465};
9466
9467static struct lcdc_platform_data dtv_pdata = {
9468 .bus_scale_table = &dtv_bus_scale_pdata,
9469};
9470#endif
9471
9472
9473static struct lcdc_platform_data lcdc_pdata = {
9474 .lcdc_power_save = lcdc_panel_power,
9475};
9476
9477
9478#define MDP_VSYNC_GPIO 28
9479
9480/*
9481 * MIPI_DSI only use 8058_LDO0 which need always on
9482 * therefore it need to be put at low power mode if
9483 * it was not used instead of turn it off.
9484 */
9485static int mipi_dsi_panel_power(int on)
9486{
9487 int flag_on = !!on;
9488 static int mipi_dsi_power_save_on;
9489 static struct regulator *ldo0;
9490 int rc = 0;
9491
9492 if (mipi_dsi_power_save_on == flag_on)
9493 return 0;
9494
9495 mipi_dsi_power_save_on = flag_on;
9496
9497 if (ldo0 == NULL) { /* init */
9498 ldo0 = regulator_get(NULL, "8058_l0");
9499 if (IS_ERR(ldo0)) {
9500 pr_debug("%s: LDO0 failed\n", __func__);
9501 rc = PTR_ERR(ldo0);
9502 return rc;
9503 }
9504
9505 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9506 if (rc)
9507 goto out;
9508
9509 rc = regulator_enable(ldo0);
9510 if (rc)
9511 goto out;
9512 }
9513
9514 if (on) {
9515 /* set ldo0 to HPM */
9516 rc = regulator_set_optimum_mode(ldo0, 100000);
9517 if (rc < 0)
9518 goto out;
9519 } else {
9520 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309521 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009522 if (rc < 0)
9523 goto out;
9524 }
9525
9526 return 0;
9527out:
9528 regulator_disable(ldo0);
9529 regulator_put(ldo0);
9530 ldo0 = NULL;
9531 return rc;
9532}
9533
9534static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9535 .vsync_gpio = MDP_VSYNC_GPIO,
9536 .dsi_power_save = mipi_dsi_panel_power,
9537};
9538
9539#ifdef CONFIG_FB_MSM_TVOUT
9540static struct regulator *reg_8058_l13;
9541
9542static int atv_dac_power(int on)
9543{
9544 int rc = 0;
9545 #define _GET_REGULATOR(var, name) do { \
9546 var = regulator_get(NULL, name); \
9547 if (IS_ERR(var)) { \
9548 pr_info("'%s' regulator not found, rc=%ld\n", \
9549 name, IS_ERR(var)); \
9550 var = NULL; \
9551 return -ENODEV; \
9552 } \
9553 } while (0)
9554
9555 if (!reg_8058_l13)
9556 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9557 #undef _GET_REGULATOR
9558
9559 if (on) {
9560 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9561 if (rc) {
9562 pr_info("%s: '%s' regulator set voltage failed,\
9563 rc=%d\n", __func__, "8058_l13", rc);
9564 return rc;
9565 }
9566
9567 rc = regulator_enable(reg_8058_l13);
9568 if (rc) {
9569 pr_err("%s: '%s' regulator enable failed,\
9570 rc=%d\n", __func__, "8058_l13", rc);
9571 return rc;
9572 }
9573 } else {
9574 rc = regulator_force_disable(reg_8058_l13);
9575 if (rc)
9576 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9577 __func__, "8058_l13", rc);
9578 }
9579 return rc;
9580
9581}
9582#endif
9583
9584#ifdef CONFIG_FB_MSM_MIPI_DSI
9585int mdp_core_clk_rate_table[] = {
9586 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009587 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009588 160000000,
9589 200000000,
9590};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009591#elif defined(CONFIG_FB_MSM_HDMI_AS_PRIMARY)
9592int mdp_core_clk_rate_table[] = {
9593 200000000,
9594 200000000,
9595 200000000,
9596 200000000,
9597};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009598#else
9599int mdp_core_clk_rate_table[] = {
9600 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009601 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009602 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009603 200000000,
9604};
9605#endif
9606
9607static struct msm_panel_common_pdata mdp_pdata = {
9608 .gpio = MDP_VSYNC_GPIO,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009609#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9610 .mdp_core_clk_rate = 200000000,
9611#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009612 .mdp_core_clk_rate = 59080000,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009613#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009614 .mdp_core_clk_table = mdp_core_clk_rate_table,
9615 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9616#ifdef CONFIG_MSM_BUS_SCALING
9617 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9618#endif
9619 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009620#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
9621 .mem_hid = ION_CP_WB_HEAP_ID,
9622#else
9623 .mem_hid = MEMTYPE_EBI1,
9624#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009625};
9626
Huaibin Yanga5419422011-12-08 23:52:10 -08009627static void __init reserve_mdp_memory(void)
9628{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009629 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9630 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9631#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9632 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9633 mdp_pdata.ov0_wb_size;
9634 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9635 mdp_pdata.ov1_wb_size;
9636#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009637}
9638
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009639#ifdef CONFIG_FB_MSM_TVOUT
9640
9641#ifdef CONFIG_MSM_BUS_SCALING
9642static struct msm_bus_vectors atv_bus_init_vectors[] = {
9643 /* For now, 0th array entry is reserved.
9644 * Please leave 0 as is and don't use it
9645 */
9646 {
9647 .src = MSM_BUS_MASTER_MDP_PORT0,
9648 .dst = MSM_BUS_SLAVE_SMI,
9649 .ab = 0,
9650 .ib = 0,
9651 },
9652 /* Master and slaves can be from different fabrics */
9653 {
9654 .src = MSM_BUS_MASTER_MDP_PORT0,
9655 .dst = MSM_BUS_SLAVE_EBI_CH0,
9656 .ab = 0,
9657 .ib = 0,
9658 },
9659};
9660static struct msm_bus_vectors atv_bus_def_vectors[] = {
9661 /* For now, 0th array entry is reserved.
9662 * Please leave 0 as is and don't use it
9663 */
9664 {
9665 .src = MSM_BUS_MASTER_MDP_PORT0,
9666 .dst = MSM_BUS_SLAVE_SMI,
9667 .ab = 236390400,
9668 .ib = 265939200,
9669 },
9670 /* Master and slaves can be from different fabrics */
9671 {
9672 .src = MSM_BUS_MASTER_MDP_PORT0,
9673 .dst = MSM_BUS_SLAVE_EBI_CH0,
9674 .ab = 236390400,
9675 .ib = 265939200,
9676 },
9677};
9678static struct msm_bus_paths atv_bus_scale_usecases[] = {
9679 {
9680 ARRAY_SIZE(atv_bus_init_vectors),
9681 atv_bus_init_vectors,
9682 },
9683 {
9684 ARRAY_SIZE(atv_bus_def_vectors),
9685 atv_bus_def_vectors,
9686 },
9687};
9688static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9689 atv_bus_scale_usecases,
9690 ARRAY_SIZE(atv_bus_scale_usecases),
9691 .name = "atv",
9692};
9693#endif
9694
9695static struct tvenc_platform_data atv_pdata = {
9696 .poll = 0,
9697 .pm_vid_en = atv_dac_power,
9698#ifdef CONFIG_MSM_BUS_SCALING
9699 .bus_scale_table = &atv_bus_scale_pdata,
9700#endif
9701};
9702#endif
9703
9704static void __init msm_fb_add_devices(void)
9705{
9706#ifdef CONFIG_FB_MSM_LCDC_DSUB
9707 mdp_pdata.mdp_core_clk_table = NULL;
9708 mdp_pdata.num_mdp_clk = 0;
9709 mdp_pdata.mdp_core_clk_rate = 200000000;
9710#endif
9711 if (machine_is_msm8x60_rumi3())
9712 msm_fb_register_device("mdp", NULL);
9713 else
9714 msm_fb_register_device("mdp", &mdp_pdata);
9715
9716 msm_fb_register_device("lcdc", &lcdc_pdata);
9717 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9718#ifdef CONFIG_MSM_BUS_SCALING
9719 msm_fb_register_device("dtv", &dtv_pdata);
9720#endif
9721#ifdef CONFIG_FB_MSM_TVOUT
9722 msm_fb_register_device("tvenc", &atv_pdata);
9723 msm_fb_register_device("tvout_device", NULL);
9724#endif
9725}
9726
9727#if (defined(CONFIG_MARIMBA_CORE)) && \
9728 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9729
9730static const struct {
9731 char *name;
9732 int vmin;
9733 int vmax;
9734} bt_regs_info[] = {
9735 { "8058_s3", 1800000, 1800000 },
9736 { "8058_s2", 1300000, 1300000 },
9737 { "8058_l8", 2900000, 3050000 },
9738};
9739
9740static struct {
9741 bool enabled;
9742} bt_regs_status[] = {
9743 { false },
9744 { false },
9745 { false },
9746};
9747static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9748
9749static int bahama_bt(int on)
9750{
9751 int rc;
9752 int i;
9753 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9754
9755 struct bahama_variant_register {
9756 const size_t size;
9757 const struct bahama_config_register *set;
9758 };
9759
9760 const struct bahama_config_register *p;
9761
9762 u8 version;
9763
9764 const struct bahama_config_register v10_bt_on[] = {
9765 { 0xE9, 0x00, 0xFF },
9766 { 0xF4, 0x80, 0xFF },
9767 { 0xE4, 0x00, 0xFF },
9768 { 0xE5, 0x00, 0x0F },
9769#ifdef CONFIG_WLAN
9770 { 0xE6, 0x38, 0x7F },
9771 { 0xE7, 0x06, 0xFF },
9772#endif
9773 { 0xE9, 0x21, 0xFF },
9774 { 0x01, 0x0C, 0x1F },
9775 { 0x01, 0x08, 0x1F },
9776 };
9777
9778 const struct bahama_config_register v20_bt_on_fm_off[] = {
9779 { 0x11, 0x0C, 0xFF },
9780 { 0x13, 0x01, 0xFF },
9781 { 0xF4, 0x80, 0xFF },
9782 { 0xF0, 0x00, 0xFF },
9783 { 0xE9, 0x00, 0xFF },
9784#ifdef CONFIG_WLAN
9785 { 0x81, 0x00, 0x7F },
9786 { 0x82, 0x00, 0xFF },
9787 { 0xE6, 0x38, 0x7F },
9788 { 0xE7, 0x06, 0xFF },
9789#endif
9790 { 0xE9, 0x21, 0xFF },
9791 };
9792
9793 const struct bahama_config_register v20_bt_on_fm_on[] = {
9794 { 0x11, 0x0C, 0xFF },
9795 { 0x13, 0x01, 0xFF },
9796 { 0xF4, 0x86, 0xFF },
9797 { 0xF0, 0x06, 0xFF },
9798 { 0xE9, 0x00, 0xFF },
9799#ifdef CONFIG_WLAN
9800 { 0x81, 0x00, 0x7F },
9801 { 0x82, 0x00, 0xFF },
9802 { 0xE6, 0x38, 0x7F },
9803 { 0xE7, 0x06, 0xFF },
9804#endif
9805 { 0xE9, 0x21, 0xFF },
9806 };
9807
9808 const struct bahama_config_register v10_bt_off[] = {
9809 { 0xE9, 0x00, 0xFF },
9810 };
9811
9812 const struct bahama_config_register v20_bt_off_fm_off[] = {
9813 { 0xF4, 0x84, 0xFF },
9814 { 0xF0, 0x04, 0xFF },
9815 { 0xE9, 0x00, 0xFF }
9816 };
9817
9818 const struct bahama_config_register v20_bt_off_fm_on[] = {
9819 { 0xF4, 0x86, 0xFF },
9820 { 0xF0, 0x06, 0xFF },
9821 { 0xE9, 0x00, 0xFF }
9822 };
9823 const struct bahama_variant_register bt_bahama[2][3] = {
9824 {
9825 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9826 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9827 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9828 },
9829 {
9830 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9831 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9832 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9833 }
9834 };
9835
9836 u8 offset = 0; /* index into bahama configs */
9837
9838 on = on ? 1 : 0;
9839 version = read_bahama_ver();
9840
9841 if (version == VER_UNSUPPORTED) {
9842 dev_err(&msm_bt_power_device.dev,
9843 "%s: unsupported version\n",
9844 __func__);
9845 return -EIO;
9846 }
9847
9848 if (version == VER_2_0) {
9849 if (marimba_get_fm_status(&config))
9850 offset = 0x01;
9851 }
9852
9853 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9854 if (on && (version == VER_2_0)) {
9855 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9856 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9857 && (bt_regs_status[i].enabled == true)) {
9858 if (regulator_disable(bt_regs[i])) {
9859 dev_err(&msm_bt_power_device.dev,
9860 "%s: regulator disable failed",
9861 __func__);
9862 }
9863 bt_regs_status[i].enabled = false;
9864 break;
9865 }
9866 }
9867 }
9868
9869 p = bt_bahama[on][version + offset].set;
9870
9871 dev_info(&msm_bt_power_device.dev,
9872 "%s: found version %d\n", __func__, version);
9873
9874 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9875 u8 value = (p+i)->value;
9876 rc = marimba_write_bit_mask(&config,
9877 (p+i)->reg,
9878 &value,
9879 sizeof((p+i)->value),
9880 (p+i)->mask);
9881 if (rc < 0) {
9882 dev_err(&msm_bt_power_device.dev,
9883 "%s: reg %d write failed: %d\n",
9884 __func__, (p+i)->reg, rc);
9885 return rc;
9886 }
9887 dev_dbg(&msm_bt_power_device.dev,
9888 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9889 __func__, (p+i)->reg,
9890 value, (p+i)->mask);
9891 }
9892 /* Update BT Status */
9893 if (on)
9894 marimba_set_bt_status(&config, true);
9895 else
9896 marimba_set_bt_status(&config, false);
9897
9898 return 0;
9899}
9900
9901static int bluetooth_use_regulators(int on)
9902{
9903 int i, recover = -1, rc = 0;
9904
9905 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9906 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9907 bt_regs_info[i].name) :
9908 (regulator_put(bt_regs[i]), NULL);
9909 if (IS_ERR(bt_regs[i])) {
9910 rc = PTR_ERR(bt_regs[i]);
9911 dev_err(&msm_bt_power_device.dev,
9912 "regulator %s get failed (%d)\n",
9913 bt_regs_info[i].name, rc);
9914 recover = i - 1;
9915 bt_regs[i] = NULL;
9916 break;
9917 }
9918
9919 if (!on)
9920 continue;
9921
9922 rc = regulator_set_voltage(bt_regs[i],
9923 bt_regs_info[i].vmin,
9924 bt_regs_info[i].vmax);
9925 if (rc < 0) {
9926 dev_err(&msm_bt_power_device.dev,
9927 "regulator %s voltage set (%d)\n",
9928 bt_regs_info[i].name, rc);
9929 recover = i;
9930 break;
9931 }
9932 }
9933
9934 if (on && (recover > -1))
9935 for (i = recover; i >= 0; i--) {
9936 regulator_put(bt_regs[i]);
9937 bt_regs[i] = NULL;
9938 }
9939
9940 return rc;
9941}
9942
9943static int bluetooth_switch_regulators(int on)
9944{
9945 int i, rc = 0;
9946
9947 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9948 if (on && (bt_regs_status[i].enabled == false)) {
9949 rc = regulator_enable(bt_regs[i]);
9950 if (rc < 0) {
9951 dev_err(&msm_bt_power_device.dev,
9952 "regulator %s %s failed (%d)\n",
9953 bt_regs_info[i].name,
9954 "enable", rc);
9955 if (i > 0) {
9956 while (--i) {
9957 regulator_disable(bt_regs[i]);
9958 bt_regs_status[i].enabled
9959 = false;
9960 }
9961 break;
9962 }
9963 }
9964 bt_regs_status[i].enabled = true;
9965 } else if (!on && (bt_regs_status[i].enabled == true)) {
9966 rc = regulator_disable(bt_regs[i]);
9967 if (rc < 0) {
9968 dev_err(&msm_bt_power_device.dev,
9969 "regulator %s %s failed (%d)\n",
9970 bt_regs_info[i].name,
9971 "disable", rc);
9972 break;
9973 }
9974 bt_regs_status[i].enabled = false;
9975 }
9976 }
9977 return rc;
9978}
9979
9980static struct msm_xo_voter *bt_clock;
9981
9982static int bluetooth_power(int on)
9983{
9984 int rc = 0;
9985 int id;
9986
9987 /* In case probe function fails, cur_connv_type would be -1 */
9988 id = adie_get_detected_connectivity_type();
9989 if (id != BAHAMA_ID) {
9990 pr_err("%s: unexpected adie connectivity type: %d\n",
9991 __func__, id);
9992 return -ENODEV;
9993 }
9994
9995 if (on) {
9996
9997 rc = bluetooth_use_regulators(1);
9998 if (rc < 0)
9999 goto out;
10000
10001 rc = bluetooth_switch_regulators(1);
10002
10003 if (rc < 0)
10004 goto fail_put;
10005
10006 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10007
10008 if (IS_ERR(bt_clock)) {
10009 pr_err("Couldn't get TCXO_D0 voter\n");
10010 goto fail_switch;
10011 }
10012
10013 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10014
10015 if (rc < 0) {
10016 pr_err("Failed to vote for TCXO_DO ON\n");
10017 goto fail_vote;
10018 }
10019
10020 rc = bahama_bt(1);
10021
10022 if (rc < 0)
10023 goto fail_clock;
10024
10025 msleep(10);
10026
10027 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10028
10029 if (rc < 0) {
10030 pr_err("Failed to vote for TCXO_DO pin control\n");
10031 goto fail_vote;
10032 }
10033 } else {
10034 /* check for initial RFKILL block (power off) */
10035 /* some RFKILL versions/configurations rfkill_register */
10036 /* calls here for an initial set_block */
10037 /* avoid calling i2c and regulator before unblock (on) */
10038 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10039 dev_info(&msm_bt_power_device.dev,
10040 "%s: initialized OFF/blocked\n", __func__);
10041 goto out;
10042 }
10043
10044 bahama_bt(0);
10045
10046fail_clock:
10047 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10048fail_vote:
10049 msm_xo_put(bt_clock);
10050fail_switch:
10051 bluetooth_switch_regulators(0);
10052fail_put:
10053 bluetooth_use_regulators(0);
10054 }
10055
10056out:
10057 if (rc < 0)
10058 on = 0;
10059 dev_info(&msm_bt_power_device.dev,
10060 "Bluetooth power switch: state %d result %d\n", on, rc);
10061
10062 return rc;
10063}
10064
10065#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10066
10067static void __init msm8x60_cfg_smsc911x(void)
10068{
10069 smsc911x_resources[1].start =
10070 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10071 smsc911x_resources[1].end =
10072 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10073}
10074
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010075void msm_fusion_setup_pinctrl(void)
10076{
10077 struct msm_xo_voter *a1;
10078
10079 if (socinfo_get_platform_subtype() == 0x3) {
10080 /*
10081 * Vote for the A1 clock to be in pin control mode before
10082 * the external images are loaded.
10083 */
10084 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10085 BUG_ON(!a1);
10086 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10087 }
10088}
10089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010090struct msm_board_data {
10091 struct msm_gpiomux_configs *gpiomux_cfgs;
10092};
10093
10094static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10095 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10096};
10097
10098static struct msm_board_data msm8x60_sim_board_data __initdata = {
10099 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10100};
10101
10102static struct msm_board_data msm8x60_surf_board_data __initdata = {
10103 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10104};
10105
10106static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10107 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10108};
10109
10110static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10111 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10112};
10113
10114static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10115 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10116};
10117
10118static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10119 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10120};
10121
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010122static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10123 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10124};
10125
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010126static void __init msm8x60_init(struct msm_board_data *board_data)
10127{
10128 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010129#ifdef CONFIG_USB_EHCI_MSM_72K
10130 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10131 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10132 .level = PM8901_MPP_DIG_LEVEL_L5,
10133 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10134 };
10135#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010136 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010138 /*
10139 * Initialize RPM first as other drivers and devices may need
10140 * it for their initialization.
10141 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010142 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10143 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010144 if (msm_xo_init())
10145 pr_err("Failed to initialize XO votes\n");
10146
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010147 msm8x60_check_2d_hardware();
10148
10149 /* Change SPM handling of core 1 if PMM 8160 is present. */
10150 soc_platform_version = socinfo_get_platform_version();
10151 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10152 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10153 struct msm_spm_platform_data *spm_data;
10154
10155 spm_data = &msm_spm_data_v1[1];
10156 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10157 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10158
10159 spm_data = &msm_spm_data[1];
10160 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10161 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10162 }
10163
10164 /*
10165 * Initialize SPM before acpuclock as the latter calls into SPM
10166 * driver to set ACPU voltages.
10167 */
10168 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10169 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10170 else
10171 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10172
10173 /*
10174 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10175 * devices so that the RPM doesn't drop into a low power mode that an
10176 * un-reworked SURF cannot resume from.
10177 */
10178 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010179 int i;
10180
10181 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10182 if (rpm_regulator_init_data[i].id
10183 == RPM_VREG_ID_PM8901_L4
10184 || rpm_regulator_init_data[i].id
10185 == RPM_VREG_ID_PM8901_L6)
10186 rpm_regulator_init_data[i]
10187 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010188 }
10189
10190 /*
10191 * Disable regulator info printing so that regulator registration
10192 * messages do not enter the kmsg log.
10193 */
10194 regulator_suppress_info_printing();
10195
10196 /* Initialize regulators needed for clock_init. */
10197 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10198
Stephen Boydbb600ae2011-08-02 20:11:40 -070010199 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010200
10201 /* Buses need to be initialized before early-device registration
10202 * to get the platform data for fabrics.
10203 */
10204 msm8x60_init_buses();
10205 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10206 /* CPU frequency control is not supported on simulated targets. */
10207 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010208 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010209
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010210 /*
10211 * Enable EBI2 only for boards which make use of it. Leave
10212 * it disabled for all others for additional power savings.
10213 */
10214 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10215 machine_is_msm8x60_rumi3() ||
10216 machine_is_msm8x60_sim() ||
10217 machine_is_msm8x60_fluid() ||
10218 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010219 msm8x60_init_ebi2();
10220 msm8x60_init_tlmm();
10221 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10222 msm8x60_init_uart12dm();
10223 msm8x60_init_mmc();
10224
10225#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10226 msm8x60_init_pm8058_othc();
10227#endif
10228
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010229 if (machine_is_msm8x60_fluid())
10230 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10231 else if (machine_is_msm8x60_dragon())
10232 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10233 else
10234 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010235
Jilai Wang53d27a82011-07-13 14:32:58 -040010236 /* Specify reset pin for OV9726 */
10237 if (machine_is_msm8x60_dragon()) {
10238 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10239 ov9726_sensor_8660_info.mount_angle = 270;
10240 }
10241
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010242#ifdef CONFIG_BATTERY_MSM8X60
10243 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10244 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10245 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10246 platform_device_register(&msm_charger_device);
10247#endif
10248
10249 if (machine_is_msm8x60_dragon())
10250 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10251 if (!machine_is_msm8x60_fluid())
10252 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10253
10254 /* configure pmic leds */
10255 if (machine_is_msm8x60_fluid())
10256 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10257 else if (machine_is_msm8x60_dragon())
10258 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10259 else
10260 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10261
10262 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10263 machine_is_msm8x60_dragon()) {
10264 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10265 }
10266
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010267 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10268 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010269 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010270 msm8x60_cfg_smsc911x();
10271 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10272 platform_add_devices(msm_footswitch_devices,
10273 msm_num_footswitch_devices);
10274 platform_add_devices(surf_devices,
10275 ARRAY_SIZE(surf_devices));
10276
10277#ifdef CONFIG_MSM_DSPS
10278 if (machine_is_msm8x60_fluid()) {
10279 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10280 msm8x60_init_dsps();
10281 }
10282#endif
10283
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010284 pm8901_vreg_mpp0_init();
10285
10286 platform_device_register(&msm8x60_8901_mpp_vreg);
10287
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010288#ifdef CONFIG_USB_EHCI_MSM_72K
10289 /*
10290 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10291 * fluid
10292 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010293 if (machine_is_msm8x60_fluid())
10294 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10295 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010296#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010297
10298#ifdef CONFIG_SND_SOC_MSM8660_APQ
10299 if (machine_is_msm8x60_dragon())
10300 platform_add_devices(dragon_alsa_devices,
10301 ARRAY_SIZE(dragon_alsa_devices));
10302 else
10303#endif
10304 platform_add_devices(asoc_devices,
10305 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010306 } else {
10307 msm8x60_configure_smc91x();
10308 platform_add_devices(rumi_sim_devices,
10309 ARRAY_SIZE(rumi_sim_devices));
10310 }
10311#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010312 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10313 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010314 msm8x60_cfg_isp1763();
10315#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010316
10317 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10318 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10319
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010320
10321#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10322 if (machine_is_msm8x60_fluid())
10323 platform_device_register(&msm_gsbi10_qup_spi_device);
10324 else
10325 platform_device_register(&msm_gsbi1_qup_spi_device);
10326#endif
10327
10328#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10329 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10330 if (machine_is_msm8x60_fluid())
10331 cyttsp_set_params();
10332#endif
10333 if (!machine_is_msm8x60_sim())
10334 msm_fb_add_devices();
10335 fixup_i2c_configs();
10336 register_i2c_devices();
10337
Terence Hampson1c73fef2011-07-19 17:10:49 -040010338 if (machine_is_msm8x60_dragon())
10339 smsc911x_config.reset_gpio
10340 = GPIO_ETHERNET_RESET_N_DRAGON;
10341
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010342 platform_device_register(&smsc911x_device);
10343
10344#if (defined(CONFIG_SPI_QUP)) && \
10345 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010346 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10347 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010348
10349 if (machine_is_msm8x60_fluid()) {
10350#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10351 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10352 spi_register_board_info(lcdc_samsung_spi_board_info,
10353 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10354 } else
10355#endif
10356 {
10357#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10358 spi_register_board_info(lcdc_auo_spi_board_info,
10359 ARRAY_SIZE(lcdc_auo_spi_board_info));
10360#endif
10361 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010362#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10363 } else if (machine_is_msm8x60_dragon()) {
10364 spi_register_board_info(lcdc_nt35582_spi_board_info,
10365 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10366#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010367 }
10368#endif
10369
10370 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
10371 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
10372 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
10373 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010374 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010375
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010376 pm8058_gpios_init();
10377
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010378#ifdef CONFIG_SENSORS_MSM_ADC
10379 if (machine_is_msm8x60_fluid()) {
10380 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10381 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10382 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10383 msm_adc_pdata.gpio_config = APROC_CONFIG;
10384 else
10385 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10386 }
10387 msm_adc_pdata.target_hw = MSM_8x60;
10388#endif
10389#ifdef CONFIG_MSM8X60_AUDIO
10390 msm_snddev_init();
10391#endif
10392#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10393 if (machine_is_msm8x60_fluid())
10394 platform_device_register(&fluid_leds_gpio);
10395 else
10396 platform_device_register(&gpio_leds);
10397#endif
10398
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010399 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010400
10401 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10402 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010403}
10404
10405static void __init msm8x60_rumi3_init(void)
10406{
10407 msm8x60_init(&msm8x60_rumi3_board_data);
10408}
10409
10410static void __init msm8x60_sim_init(void)
10411{
10412 msm8x60_init(&msm8x60_sim_board_data);
10413}
10414
10415static void __init msm8x60_surf_init(void)
10416{
10417 msm8x60_init(&msm8x60_surf_board_data);
10418}
10419
10420static void __init msm8x60_ffa_init(void)
10421{
10422 msm8x60_init(&msm8x60_ffa_board_data);
10423}
10424
10425static void __init msm8x60_fluid_init(void)
10426{
10427 msm8x60_init(&msm8x60_fluid_board_data);
10428}
10429
10430static void __init msm8x60_charm_surf_init(void)
10431{
10432 msm8x60_init(&msm8x60_charm_surf_board_data);
10433}
10434
10435static void __init msm8x60_charm_ffa_init(void)
10436{
10437 msm8x60_init(&msm8x60_charm_ffa_board_data);
10438}
10439
10440static void __init msm8x60_charm_init_early(void)
10441{
10442 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010443}
10444
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010445static void __init msm8x60_dragon_init(void)
10446{
10447 msm8x60_init(&msm8x60_dragon_board_data);
10448}
10449
Steve Mucklea55df6e2010-01-07 12:43:24 -080010450MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10451 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010452 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010453 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010454 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010455 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010456 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010457 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010458MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010459
10460MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10461 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010462 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010463 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010464 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010465 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010466 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010467 .init_early = msm8x60_charm_init_early,
10468MACHINE_END
10469
10470MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10471 .map_io = msm8x60_map_io,
10472 .reserve = msm8x60_reserve,
10473 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010474 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010475 .init_machine = msm8x60_surf_init,
10476 .timer = &msm_timer,
10477 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010478MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010479
10480MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10481 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010482 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010483 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010484 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010485 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010486 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010487 .init_early = msm8x60_charm_init_early,
10488MACHINE_END
10489
10490MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10491 .map_io = msm8x60_map_io,
10492 .reserve = msm8x60_reserve,
10493 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010494 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010495 .init_machine = msm8x60_fluid_init,
10496 .timer = &msm_timer,
10497 .init_early = msm8x60_charm_init_early,
10498MACHINE_END
10499
10500MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10501 .map_io = msm8x60_map_io,
10502 .reserve = msm8x60_reserve,
10503 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010504 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010505 .init_machine = msm8x60_charm_surf_init,
10506 .timer = &msm_timer,
10507 .init_early = msm8x60_charm_init_early,
10508MACHINE_END
10509
10510MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10511 .map_io = msm8x60_map_io,
10512 .reserve = msm8x60_reserve,
10513 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010514 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010515 .init_machine = msm8x60_charm_ffa_init,
10516 .timer = &msm_timer,
10517 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010518MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010519
10520MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10521 .map_io = msm8x60_map_io,
10522 .reserve = msm8x60_reserve,
10523 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010524 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010525 .init_machine = msm8x60_dragon_init,
10526 .timer = &msm_timer,
10527 .init_early = msm8x60_charm_init_early,
10528MACHINE_END