blob: b5c583771abd4ccaacb57071c8bcc874fb19398d [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>
92#include <mach/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
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600921static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
922 .mode = MSM_PM_BOOT_CONFIG_TZ,
923};
924
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700925#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
926
927#define ISP1763_INT_GPIO 117
928#define ISP1763_RST_GPIO 152
929static struct resource isp1763_resources[] = {
930 [0] = {
931 .flags = IORESOURCE_MEM,
932 .start = 0x1D000000,
933 .end = 0x1D005FFF, /* 24KB */
934 },
935 [1] = {
936 .flags = IORESOURCE_IRQ,
937 },
938};
939static void __init msm8x60_cfg_isp1763(void)
940{
941 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
942 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
943}
944
945static int isp1763_setup_gpio(int enable)
946{
947 int status = 0;
948
949 if (enable) {
950 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
951 if (status) {
952 pr_err("%s:Failed to request GPIO %d\n",
953 __func__, ISP1763_INT_GPIO);
954 return status;
955 }
956 status = gpio_direction_input(ISP1763_INT_GPIO);
957 if (status) {
958 pr_err("%s:Failed to configure GPIO %d\n",
959 __func__, ISP1763_INT_GPIO);
960 goto gpio_free_int;
961 }
962 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
963 if (status) {
964 pr_err("%s:Failed to request GPIO %d\n",
965 __func__, ISP1763_RST_GPIO);
966 goto gpio_free_int;
967 }
968 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
969 if (status) {
970 pr_err("%s:Failed to configure GPIO %d\n",
971 __func__, ISP1763_RST_GPIO);
972 goto gpio_free_rst;
973 }
974 pr_debug("\nISP GPIO configuration done\n");
975 return status;
976 }
977
978gpio_free_rst:
979 gpio_free(ISP1763_RST_GPIO);
980gpio_free_int:
981 gpio_free(ISP1763_INT_GPIO);
982
983 return status;
984}
985static struct isp1763_platform_data isp1763_pdata = {
986 .reset_gpio = ISP1763_RST_GPIO,
987 .setup_gpio = isp1763_setup_gpio
988};
989
990static struct platform_device isp1763_device = {
991 .name = "isp1763_usb",
992 .num_resources = ARRAY_SIZE(isp1763_resources),
993 .resource = isp1763_resources,
994 .dev = {
995 .platform_data = &isp1763_pdata
996 }
997};
998#endif
999
1000#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301001static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001002static struct regulator *ldo6_3p3;
1003static struct regulator *ldo7_1p8;
1004static struct regulator *vdd_cx;
1005#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +05301006#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007notify_vbus_state notify_vbus_state_func_ptr;
1008static int usb_phy_susp_dig_vol = 750000;
1009static int pmic_id_notif_supported;
1010
1011#ifdef CONFIG_USB_EHCI_MSM_72K
1012#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
1013struct delayed_work pmic_id_det;
1014
1015static int __init usb_id_pin_rework_setup(char *support)
1016{
1017 if (strncmp(support, "true", 4) == 0)
1018 pmic_id_notif_supported = 1;
1019
1020 return 1;
1021}
1022__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
1023
1024static void pmic_id_detect(struct work_struct *w)
1025{
1026 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
1027 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
1028
1029 if (notify_vbus_state_func_ptr)
1030 (*notify_vbus_state_func_ptr) (val);
1031}
1032
1033static irqreturn_t pmic_id_on_irq(int irq, void *data)
1034{
1035 /*
1036 * Spurious interrupts are observed on pmic gpio line
1037 * even though there is no state change on USB ID. Schedule the
1038 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001039 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001040 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001041
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001042 return IRQ_HANDLED;
1043}
1044
Anji jonnalaae745e92011-11-14 18:34:31 +05301045static int msm_hsusb_phy_id_setup_init(int init)
1046{
1047 unsigned ret;
1048
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301049 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1050 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1051 .level = PM8901_MPP_DIG_LEVEL_L5,
1052 };
1053
Anji jonnalaae745e92011-11-14 18:34:31 +05301054 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301055 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1056 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1057 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301058 if (ret < 0)
1059 pr_err("%s:MPP2 configuration failed\n", __func__);
1060 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301061 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1062 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1063 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301064 if (ret < 0)
1065 pr_err("%s:MPP2 un config failed\n", __func__);
1066 }
1067 return ret;
1068}
1069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1071{
1072 unsigned ret = -ENODEV;
1073
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301074 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301075 .direction = PM_GPIO_DIR_IN,
1076 .pull = PM_GPIO_PULL_UP_1P5,
1077 .function = PM_GPIO_FUNC_NORMAL,
1078 .vin_sel = 2,
1079 .inv_int_pol = 0,
1080 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301081 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301082 .direction = PM_GPIO_DIR_IN,
1083 .pull = PM_GPIO_PULL_NO,
1084 .function = PM_GPIO_FUNC_NORMAL,
1085 .vin_sel = 2,
1086 .inv_int_pol = 0,
1087 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001088 if (!callback)
1089 return -EINVAL;
1090
1091 if (machine_is_msm8x60_fluid())
1092 return -ENOTSUPP;
1093
1094 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1095 pr_debug("%s: USB_ID pin is not routed to PMIC"
1096 "on V1 surf/ffa\n", __func__);
1097 return -ENOTSUPP;
1098 }
1099
Manu Gautam62158eb2011-11-24 16:20:46 +05301100 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1101 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001102 pr_debug("%s: USB_ID is not routed to PMIC"
1103 "on V2 ffa\n", __func__);
1104 return -ENOTSUPP;
1105 }
1106
1107 usb_phy_susp_dig_vol = 500000;
1108
1109 if (init) {
1110 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301111 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301112 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1113 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301114 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301115 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301116 __func__, ret);
1117 return ret;
1118 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001119 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1120 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1121 "msm_otg_id", NULL);
1122 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001123 pr_err("%s:pmic_usb_id interrupt registration failed",
1124 __func__);
1125 return ret;
1126 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301127 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001128 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301129 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001130 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301131 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1132 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301133 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301134 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301135 __func__, ret);
1136 return ret;
1137 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301138 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001139 cancel_delayed_work_sync(&pmic_id_det);
1140 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001141 }
1142 return 0;
1143}
1144#endif
1145
1146#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1147#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1148static int msm_hsusb_init_vddcx(int init)
1149{
1150 int ret = 0;
1151
1152 if (init) {
1153 vdd_cx = regulator_get(NULL, "8058_s1");
1154 if (IS_ERR(vdd_cx)) {
1155 return PTR_ERR(vdd_cx);
1156 }
1157
1158 ret = regulator_set_voltage(vdd_cx,
1159 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1160 USB_PHY_MAX_VDD_DIG_VOL);
1161 if (ret) {
1162 pr_err("%s: unable to set the voltage for regulator"
1163 "vdd_cx\n", __func__);
1164 regulator_put(vdd_cx);
1165 return ret;
1166 }
1167
1168 ret = regulator_enable(vdd_cx);
1169 if (ret) {
1170 pr_err("%s: unable to enable regulator"
1171 "vdd_cx\n", __func__);
1172 regulator_put(vdd_cx);
1173 }
1174 } else {
1175 ret = regulator_disable(vdd_cx);
1176 if (ret) {
1177 pr_err("%s: Unable to disable the regulator:"
1178 "vdd_cx\n", __func__);
1179 return ret;
1180 }
1181
1182 regulator_put(vdd_cx);
1183 }
1184
1185 return ret;
1186}
1187
1188static int msm_hsusb_config_vddcx(int high)
1189{
1190 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1191 int min_vol;
1192 int ret;
1193
1194 if (high)
1195 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1196 else
1197 min_vol = usb_phy_susp_dig_vol;
1198
1199 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1200 if (ret) {
1201 pr_err("%s: unable to set the voltage for regulator"
1202 "vdd_cx\n", __func__);
1203 return ret;
1204 }
1205
1206 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1207
1208 return ret;
1209}
1210
1211#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1212#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1213#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1214#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1215
1216#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1217#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1218#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1219#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1220static int msm_hsusb_ldo_init(int init)
1221{
1222 int rc = 0;
1223
1224 if (init) {
1225 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1226 if (IS_ERR(ldo6_3p3))
1227 return PTR_ERR(ldo6_3p3);
1228
1229 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1230 if (IS_ERR(ldo7_1p8)) {
1231 rc = PTR_ERR(ldo7_1p8);
1232 goto put_3p3;
1233 }
1234
1235 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1236 USB_PHY_3P3_VOL_MAX);
1237 if (rc) {
1238 pr_err("%s: Unable to set voltage level for"
1239 "ldo6_3p3 regulator\n", __func__);
1240 goto put_1p8;
1241 }
1242 rc = regulator_enable(ldo6_3p3);
1243 if (rc) {
1244 pr_err("%s: Unable to enable the regulator:"
1245 "ldo6_3p3\n", __func__);
1246 goto put_1p8;
1247 }
1248 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1249 USB_PHY_1P8_VOL_MAX);
1250 if (rc) {
1251 pr_err("%s: Unable to set voltage level for"
1252 "ldo7_1p8 regulator\n", __func__);
1253 goto disable_3p3;
1254 }
1255 rc = regulator_enable(ldo7_1p8);
1256 if (rc) {
1257 pr_err("%s: Unable to enable the regulator:"
1258 "ldo7_1p8\n", __func__);
1259 goto disable_3p3;
1260 }
1261
1262 return 0;
1263 }
1264
1265 regulator_disable(ldo7_1p8);
1266disable_3p3:
1267 regulator_disable(ldo6_3p3);
1268put_1p8:
1269 regulator_put(ldo7_1p8);
1270put_3p3:
1271 regulator_put(ldo6_3p3);
1272 return rc;
1273}
1274
1275static int msm_hsusb_ldo_enable(int on)
1276{
1277 int ret = 0;
1278
1279 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1280 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1281 return -ENODEV;
1282 }
1283
1284 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1285 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1286 return -ENODEV;
1287 }
1288
1289 if (on) {
1290 ret = regulator_set_optimum_mode(ldo7_1p8,
1291 USB_PHY_1P8_HPM_LOAD);
1292 if (ret < 0) {
1293 pr_err("%s: Unable to set HPM of the regulator:"
1294 "ldo7_1p8\n", __func__);
1295 return ret;
1296 }
1297 ret = regulator_set_optimum_mode(ldo6_3p3,
1298 USB_PHY_3P3_HPM_LOAD);
1299 if (ret < 0) {
1300 pr_err("%s: Unable to set HPM of the regulator:"
1301 "ldo6_3p3\n", __func__);
1302 regulator_set_optimum_mode(ldo7_1p8,
1303 USB_PHY_1P8_LPM_LOAD);
1304 return ret;
1305 }
1306 } else {
1307 ret = regulator_set_optimum_mode(ldo7_1p8,
1308 USB_PHY_1P8_LPM_LOAD);
1309 if (ret < 0)
1310 pr_err("%s: Unable to set LPM of the regulator:"
1311 "ldo7_1p8\n", __func__);
1312 ret = regulator_set_optimum_mode(ldo6_3p3,
1313 USB_PHY_3P3_LPM_LOAD);
1314 if (ret < 0)
1315 pr_err("%s: Unable to set LPM of the regulator:"
1316 "ldo6_3p3\n", __func__);
1317 }
1318
1319 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1320 return ret < 0 ? ret : 0;
1321 }
1322#endif
1323#ifdef CONFIG_USB_EHCI_MSM_72K
1324#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1325static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1326{
1327 static int vbus_is_on;
1328
1329 /* If VBUS is already on (or off), do nothing. */
1330 if (on == vbus_is_on)
1331 return;
1332 smb137b_otg_power(on);
1333 vbus_is_on = on;
1334}
1335#endif
1336static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1337{
1338 static struct regulator *votg_5v_switch;
1339 static struct regulator *ext_5v_reg;
1340 static int vbus_is_on;
1341
1342 /* If VBUS is already on (or off), do nothing. */
1343 if (on == vbus_is_on)
1344 return;
1345
1346 if (!votg_5v_switch) {
1347 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1348 if (IS_ERR(votg_5v_switch)) {
1349 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1350 return;
1351 }
1352 }
1353 if (!ext_5v_reg) {
1354 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1355 if (IS_ERR(ext_5v_reg)) {
1356 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1357 return;
1358 }
1359 }
1360 if (on) {
1361 if (regulator_enable(ext_5v_reg)) {
1362 pr_err("%s: Unable to enable the regulator:"
1363 " ext_5v_reg\n", __func__);
1364 return;
1365 }
1366 if (regulator_enable(votg_5v_switch)) {
1367 pr_err("%s: Unable to enable the regulator:"
1368 " votg_5v_switch\n", __func__);
1369 return;
1370 }
1371 } else {
1372 if (regulator_disable(votg_5v_switch))
1373 pr_err("%s: Unable to enable the regulator:"
1374 " votg_5v_switch\n", __func__);
1375 if (regulator_disable(ext_5v_reg))
1376 pr_err("%s: Unable to enable the regulator:"
1377 " ext_5v_reg\n", __func__);
1378 }
1379
1380 vbus_is_on = on;
1381}
1382
1383static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1384 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1385 .power_budget = 390,
1386};
1387#endif
1388
1389#ifdef CONFIG_BATTERY_MSM8X60
1390static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1391 int init)
1392{
1393 int ret = -ENOTSUPP;
1394
1395#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1396 if (machine_is_msm8x60_fluid()) {
1397 if (init)
1398 msm_charger_register_vbus_sn(callback);
1399 else
1400 msm_charger_unregister_vbus_sn(callback);
1401 return 0;
1402 }
1403#endif
1404 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1405 * hence, irrespective of either peripheral only mode or
1406 * OTG (host and peripheral) modes, can depend on pmic for
1407 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001408 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001409 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1410 && (machine_is_msm8x60_surf() ||
1411 pmic_id_notif_supported)) {
1412 if (init)
1413 ret = msm_charger_register_vbus_sn(callback);
1414 else {
1415 msm_charger_unregister_vbus_sn(callback);
1416 ret = 0;
1417 }
1418 } else {
1419#if !defined(CONFIG_USB_EHCI_MSM_72K)
1420 if (init)
1421 ret = msm_charger_register_vbus_sn(callback);
1422 else {
1423 msm_charger_unregister_vbus_sn(callback);
1424 ret = 0;
1425 }
1426#endif
1427 }
1428 return ret;
1429}
1430#endif
1431
1432#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
1433static struct msm_otg_platform_data msm_otg_pdata = {
1434 /* if usb link is in sps there is no need for
1435 * usb pclk as dayatona fabric clock will be
1436 * used instead
1437 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001438 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1439 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1440 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301441 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001442#ifdef CONFIG_USB_EHCI_MSM_72K
1443 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301444 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001445#endif
1446#ifdef CONFIG_USB_EHCI_MSM_72K
1447 .vbus_power = msm_hsusb_vbus_power,
1448#endif
1449#ifdef CONFIG_BATTERY_MSM8X60
1450 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1451#endif
1452 .ldo_init = msm_hsusb_ldo_init,
1453 .ldo_enable = msm_hsusb_ldo_enable,
1454 .config_vddcx = msm_hsusb_config_vddcx,
1455 .init_vddcx = msm_hsusb_init_vddcx,
1456#ifdef CONFIG_BATTERY_MSM8X60
1457 .chg_vbus_draw = msm_charger_vbus_draw,
1458#endif
1459};
1460#endif
1461
1462#ifdef CONFIG_USB_GADGET_MSM_72K
1463static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1464 .is_phy_status_timer_on = 1,
1465};
1466#endif
1467
1468#ifdef CONFIG_USB_G_ANDROID
1469
1470#define PID_MAGIC_ID 0x71432909
1471#define SERIAL_NUM_MAGIC_ID 0x61945374
1472#define SERIAL_NUMBER_LENGTH 127
1473#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1474
1475struct magic_num_struct {
1476 uint32_t pid;
1477 uint32_t serial_num;
1478};
1479
1480struct dload_struct {
1481 uint32_t reserved1;
1482 uint32_t reserved2;
1483 uint32_t reserved3;
1484 uint16_t reserved4;
1485 uint16_t pid;
1486 char serial_number[SERIAL_NUMBER_LENGTH];
1487 uint16_t reserved5;
1488 struct magic_num_struct
1489 magic_struct;
1490};
1491
1492static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1493{
1494 struct dload_struct __iomem *dload = 0;
1495
1496 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1497 if (!dload) {
1498 pr_err("%s: cannot remap I/O memory region: %08x\n",
1499 __func__, DLOAD_USB_BASE_ADD);
1500 return -ENXIO;
1501 }
1502
1503 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1504 __func__, dload, pid, snum);
1505 /* update pid */
1506 dload->magic_struct.pid = PID_MAGIC_ID;
1507 dload->pid = pid;
1508
1509 /* update serial number */
1510 dload->magic_struct.serial_num = 0;
1511 if (!snum)
1512 return 0;
1513
1514 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1515 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1516 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1517
1518 iounmap(dload);
1519
1520 return 0;
1521}
1522
1523static struct android_usb_platform_data android_usb_pdata = {
1524 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1525};
1526
1527static struct platform_device android_usb_device = {
1528 .name = "android_usb",
1529 .id = -1,
1530 .dev = {
1531 .platform_data = &android_usb_pdata,
1532 },
1533};
1534
1535
1536#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001537
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001538#ifdef CONFIG_MSM_VPE
1539static struct resource msm_vpe_resources[] = {
1540 {
1541 .start = 0x05300000,
1542 .end = 0x05300000 + SZ_1M - 1,
1543 .flags = IORESOURCE_MEM,
1544 },
1545 {
1546 .start = INT_VPE,
1547 .end = INT_VPE,
1548 .flags = IORESOURCE_IRQ,
1549 },
1550};
1551
1552static struct platform_device msm_vpe_device = {
1553 .name = "msm_vpe",
1554 .id = 0,
1555 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1556 .resource = msm_vpe_resources,
1557};
1558#endif
1559
1560#ifdef CONFIG_MSM_CAMERA
1561#ifdef CONFIG_MSM_CAMERA_FLASH
1562#define VFE_CAMIF_TIMER1_GPIO 29
1563#define VFE_CAMIF_TIMER2_GPIO 30
1564#define VFE_CAMIF_TIMER3_GPIO_INT 31
1565#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1566static struct msm_camera_sensor_flash_src msm_flash_src = {
1567 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1568 ._fsrc.pmic_src.num_of_src = 2,
1569 ._fsrc.pmic_src.low_current = 100,
1570 ._fsrc.pmic_src.high_current = 300,
1571 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1572 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1573 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1574};
1575#ifdef CONFIG_IMX074
1576static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1577 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1578 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1579 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1580 .flash_recharge_duration = 50000,
1581 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1582};
1583#endif
1584#endif
1585
1586int msm_cam_gpio_tbl[] = {
1587 32,/*CAMIF_MCLK*/
1588 47,/*CAMIF_I2C_DATA*/
1589 48,/*CAMIF_I2C_CLK*/
1590 105,/*STANDBY*/
1591};
1592
1593enum msm_cam_stat{
1594 MSM_CAM_OFF,
1595 MSM_CAM_ON,
1596};
1597
1598static int config_gpio_table(enum msm_cam_stat stat)
1599{
1600 int rc = 0, i = 0;
1601 if (stat == MSM_CAM_ON) {
1602 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1603 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1604 if (unlikely(rc < 0)) {
1605 pr_err("%s not able to get gpio\n", __func__);
1606 for (i--; i >= 0; i--)
1607 gpio_free(msm_cam_gpio_tbl[i]);
1608 break;
1609 }
1610 }
1611 } else {
1612 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1613 gpio_free(msm_cam_gpio_tbl[i]);
1614 }
1615 return rc;
1616}
1617
1618static struct msm_camera_sensor_platform_info sensor_board_info = {
1619 .mount_angle = 0
1620};
1621
1622/*external regulator VREG_5V*/
1623static struct regulator *reg_flash_5V;
1624
1625static int config_camera_on_gpios_fluid(void)
1626{
1627 int rc = 0;
1628
1629 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1630 if (IS_ERR(reg_flash_5V)) {
1631 pr_err("'%s' regulator not found, rc=%ld\n",
1632 "8901_mpp0", IS_ERR(reg_flash_5V));
1633 return -ENODEV;
1634 }
1635
1636 rc = regulator_enable(reg_flash_5V);
1637 if (rc) {
1638 pr_err("'%s' regulator enable failed, rc=%d\n",
1639 "8901_mpp0", rc);
1640 regulator_put(reg_flash_5V);
1641 return rc;
1642 }
1643
1644#ifdef CONFIG_IMX074
1645 sensor_board_info.mount_angle = 90;
1646#endif
1647 rc = config_gpio_table(MSM_CAM_ON);
1648 if (rc < 0) {
1649 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1650 "failed\n", __func__);
1651 return rc;
1652 }
1653
1654 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1655 if (rc < 0) {
1656 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1657 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1658 regulator_disable(reg_flash_5V);
1659 regulator_put(reg_flash_5V);
1660 return rc;
1661 }
1662 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1663 msleep(20);
1664 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1665
1666
1667 /*Enable LED_FLASH_EN*/
1668 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1669 if (rc < 0) {
1670 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1671 "failed\n", __func__, GPIO_LED_FLASH_EN);
1672
1673 regulator_disable(reg_flash_5V);
1674 regulator_put(reg_flash_5V);
1675 config_gpio_table(MSM_CAM_OFF);
1676 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1677 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1678 return rc;
1679 }
1680 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1681 msleep(20);
1682 return rc;
1683}
1684
1685
1686static void config_camera_off_gpios_fluid(void)
1687{
1688 regulator_disable(reg_flash_5V);
1689 regulator_put(reg_flash_5V);
1690
1691 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1692 gpio_free(GPIO_LED_FLASH_EN);
1693
1694 config_gpio_table(MSM_CAM_OFF);
1695
1696 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1697 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1698}
1699static int config_camera_on_gpios(void)
1700{
1701 int rc = 0;
1702
1703 if (machine_is_msm8x60_fluid())
1704 return config_camera_on_gpios_fluid();
1705
1706 rc = config_gpio_table(MSM_CAM_ON);
1707 if (rc < 0) {
1708 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1709 "failed\n", __func__);
1710 return rc;
1711 }
1712
Jilai Wang971f97f2011-07-13 14:25:25 -04001713 if (!machine_is_msm8x60_dragon()) {
1714 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1715 if (rc < 0) {
1716 config_gpio_table(MSM_CAM_OFF);
1717 pr_err("%s: CAMSENSOR gpio %d request"
1718 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1719 return rc;
1720 }
1721 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1722 msleep(20);
1723 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001724 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001725
1726#ifdef CONFIG_MSM_CAMERA_FLASH
1727#ifdef CONFIG_IMX074
1728 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1729 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1730#endif
1731#endif
1732 return rc;
1733}
1734
1735static void config_camera_off_gpios(void)
1736{
1737 if (machine_is_msm8x60_fluid())
1738 return config_camera_off_gpios_fluid();
1739
1740
1741 config_gpio_table(MSM_CAM_OFF);
1742
Jilai Wang971f97f2011-07-13 14:25:25 -04001743 if (!machine_is_msm8x60_dragon()) {
1744 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1745 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1746 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001747}
1748
1749#ifdef CONFIG_QS_S5K4E1
1750
1751#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1752
1753static int config_camera_on_gpios_qs_cam_fluid(void)
1754{
1755 int rc = 0;
1756
1757 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1758 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1759 if (rc < 0) {
1760 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1761 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1762 return rc;
1763 }
1764 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1765 msleep(20);
1766 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1767 msleep(20);
1768
1769 /*
1770 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1771 * to enable 2.7V power to Camera
1772 */
1773 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1774 if (rc < 0) {
1775 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1776 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1777 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1778 gpio_free(QS_CAM_HC37_CAM_PD);
1779 return rc;
1780 }
1781 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1782 msleep(20);
1783 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1784 msleep(20);
1785
1786 rc = config_camera_on_gpios_fluid();
1787 if (rc < 0) {
1788 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1789 " failed\n", __func__);
1790 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1791 gpio_free(QS_CAM_HC37_CAM_PD);
1792 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1793 gpio_free(GPIO_AUX_CAM_2P7_EN);
1794 return rc;
1795 }
1796 return rc;
1797}
1798
1799static void config_camera_off_gpios_qs_cam_fluid(void)
1800{
1801 /*
1802 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1803 * to disable 2.7V power to Camera
1804 */
1805 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1806 gpio_free(GPIO_AUX_CAM_2P7_EN);
1807
1808 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1809 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1810 gpio_free(QS_CAM_HC37_CAM_PD);
1811
1812 config_camera_off_gpios_fluid();
1813 return;
1814}
1815
1816static int config_camera_on_gpios_qs_cam(void)
1817{
1818 int rc = 0;
1819
1820 if (machine_is_msm8x60_fluid())
1821 return config_camera_on_gpios_qs_cam_fluid();
1822
1823 rc = config_camera_on_gpios();
1824 return rc;
1825}
1826
1827static void config_camera_off_gpios_qs_cam(void)
1828{
1829 if (machine_is_msm8x60_fluid())
1830 return config_camera_off_gpios_qs_cam_fluid();
1831
1832 config_camera_off_gpios();
1833 return;
1834}
1835#endif
1836
1837static int config_camera_on_gpios_web_cam(void)
1838{
1839 int rc = 0;
1840 rc = config_gpio_table(MSM_CAM_ON);
1841 if (rc < 0) {
1842 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1843 "failed\n", __func__);
1844 return rc;
1845 }
1846
Jilai Wang53d27a82011-07-13 14:32:58 -04001847 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001848 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1849 if (rc < 0) {
1850 config_gpio_table(MSM_CAM_OFF);
1851 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1852 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1853 return rc;
1854 }
1855 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1856 }
1857 return rc;
1858}
1859
1860static void config_camera_off_gpios_web_cam(void)
1861{
1862 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001863 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001864 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1865 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1866 }
1867 return;
1868}
1869
1870#ifdef CONFIG_MSM_BUS_SCALING
1871static struct msm_bus_vectors cam_init_vectors[] = {
1872 {
1873 .src = MSM_BUS_MASTER_VFE,
1874 .dst = MSM_BUS_SLAVE_SMI,
1875 .ab = 0,
1876 .ib = 0,
1877 },
1878 {
1879 .src = MSM_BUS_MASTER_VFE,
1880 .dst = MSM_BUS_SLAVE_EBI_CH0,
1881 .ab = 0,
1882 .ib = 0,
1883 },
1884 {
1885 .src = MSM_BUS_MASTER_VPE,
1886 .dst = MSM_BUS_SLAVE_SMI,
1887 .ab = 0,
1888 .ib = 0,
1889 },
1890 {
1891 .src = MSM_BUS_MASTER_VPE,
1892 .dst = MSM_BUS_SLAVE_EBI_CH0,
1893 .ab = 0,
1894 .ib = 0,
1895 },
1896 {
1897 .src = MSM_BUS_MASTER_JPEG_ENC,
1898 .dst = MSM_BUS_SLAVE_SMI,
1899 .ab = 0,
1900 .ib = 0,
1901 },
1902 {
1903 .src = MSM_BUS_MASTER_JPEG_ENC,
1904 .dst = MSM_BUS_SLAVE_EBI_CH0,
1905 .ab = 0,
1906 .ib = 0,
1907 },
1908};
1909
1910static struct msm_bus_vectors cam_preview_vectors[] = {
1911 {
1912 .src = MSM_BUS_MASTER_VFE,
1913 .dst = MSM_BUS_SLAVE_SMI,
1914 .ab = 0,
1915 .ib = 0,
1916 },
1917 {
1918 .src = MSM_BUS_MASTER_VFE,
1919 .dst = MSM_BUS_SLAVE_EBI_CH0,
1920 .ab = 283115520,
1921 .ib = 452984832,
1922 },
1923 {
1924 .src = MSM_BUS_MASTER_VPE,
1925 .dst = MSM_BUS_SLAVE_SMI,
1926 .ab = 0,
1927 .ib = 0,
1928 },
1929 {
1930 .src = MSM_BUS_MASTER_VPE,
1931 .dst = MSM_BUS_SLAVE_EBI_CH0,
1932 .ab = 0,
1933 .ib = 0,
1934 },
1935 {
1936 .src = MSM_BUS_MASTER_JPEG_ENC,
1937 .dst = MSM_BUS_SLAVE_SMI,
1938 .ab = 0,
1939 .ib = 0,
1940 },
1941 {
1942 .src = MSM_BUS_MASTER_JPEG_ENC,
1943 .dst = MSM_BUS_SLAVE_EBI_CH0,
1944 .ab = 0,
1945 .ib = 0,
1946 },
1947};
1948
1949static struct msm_bus_vectors cam_video_vectors[] = {
1950 {
1951 .src = MSM_BUS_MASTER_VFE,
1952 .dst = MSM_BUS_SLAVE_SMI,
1953 .ab = 283115520,
1954 .ib = 452984832,
1955 },
1956 {
1957 .src = MSM_BUS_MASTER_VFE,
1958 .dst = MSM_BUS_SLAVE_EBI_CH0,
1959 .ab = 283115520,
1960 .ib = 452984832,
1961 },
1962 {
1963 .src = MSM_BUS_MASTER_VPE,
1964 .dst = MSM_BUS_SLAVE_SMI,
1965 .ab = 319610880,
1966 .ib = 511377408,
1967 },
1968 {
1969 .src = MSM_BUS_MASTER_VPE,
1970 .dst = MSM_BUS_SLAVE_EBI_CH0,
1971 .ab = 0,
1972 .ib = 0,
1973 },
1974 {
1975 .src = MSM_BUS_MASTER_JPEG_ENC,
1976 .dst = MSM_BUS_SLAVE_SMI,
1977 .ab = 0,
1978 .ib = 0,
1979 },
1980 {
1981 .src = MSM_BUS_MASTER_JPEG_ENC,
1982 .dst = MSM_BUS_SLAVE_EBI_CH0,
1983 .ab = 0,
1984 .ib = 0,
1985 },
1986};
1987
1988static struct msm_bus_vectors cam_snapshot_vectors[] = {
1989 {
1990 .src = MSM_BUS_MASTER_VFE,
1991 .dst = MSM_BUS_SLAVE_SMI,
1992 .ab = 566231040,
1993 .ib = 905969664,
1994 },
1995 {
1996 .src = MSM_BUS_MASTER_VFE,
1997 .dst = MSM_BUS_SLAVE_EBI_CH0,
1998 .ab = 69984000,
1999 .ib = 111974400,
2000 },
2001 {
2002 .src = MSM_BUS_MASTER_VPE,
2003 .dst = MSM_BUS_SLAVE_SMI,
2004 .ab = 0,
2005 .ib = 0,
2006 },
2007 {
2008 .src = MSM_BUS_MASTER_VPE,
2009 .dst = MSM_BUS_SLAVE_EBI_CH0,
2010 .ab = 0,
2011 .ib = 0,
2012 },
2013 {
2014 .src = MSM_BUS_MASTER_JPEG_ENC,
2015 .dst = MSM_BUS_SLAVE_SMI,
2016 .ab = 320864256,
2017 .ib = 513382810,
2018 },
2019 {
2020 .src = MSM_BUS_MASTER_JPEG_ENC,
2021 .dst = MSM_BUS_SLAVE_EBI_CH0,
2022 .ab = 320864256,
2023 .ib = 513382810,
2024 },
2025};
2026
2027static struct msm_bus_vectors cam_zsl_vectors[] = {
2028 {
2029 .src = MSM_BUS_MASTER_VFE,
2030 .dst = MSM_BUS_SLAVE_SMI,
2031 .ab = 566231040,
2032 .ib = 905969664,
2033 },
2034 {
2035 .src = MSM_BUS_MASTER_VFE,
2036 .dst = MSM_BUS_SLAVE_EBI_CH0,
2037 .ab = 706199040,
2038 .ib = 1129918464,
2039 },
2040 {
2041 .src = MSM_BUS_MASTER_VPE,
2042 .dst = MSM_BUS_SLAVE_SMI,
2043 .ab = 0,
2044 .ib = 0,
2045 },
2046 {
2047 .src = MSM_BUS_MASTER_VPE,
2048 .dst = MSM_BUS_SLAVE_EBI_CH0,
2049 .ab = 0,
2050 .ib = 0,
2051 },
2052 {
2053 .src = MSM_BUS_MASTER_JPEG_ENC,
2054 .dst = MSM_BUS_SLAVE_SMI,
2055 .ab = 320864256,
2056 .ib = 513382810,
2057 },
2058 {
2059 .src = MSM_BUS_MASTER_JPEG_ENC,
2060 .dst = MSM_BUS_SLAVE_EBI_CH0,
2061 .ab = 320864256,
2062 .ib = 513382810,
2063 },
2064};
2065
2066static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2067 {
2068 .src = MSM_BUS_MASTER_VFE,
2069 .dst = MSM_BUS_SLAVE_SMI,
2070 .ab = 212336640,
2071 .ib = 339738624,
2072 },
2073 {
2074 .src = MSM_BUS_MASTER_VFE,
2075 .dst = MSM_BUS_SLAVE_EBI_CH0,
2076 .ab = 25090560,
2077 .ib = 40144896,
2078 },
2079 {
2080 .src = MSM_BUS_MASTER_VPE,
2081 .dst = MSM_BUS_SLAVE_SMI,
2082 .ab = 239708160,
2083 .ib = 383533056,
2084 },
2085 {
2086 .src = MSM_BUS_MASTER_VPE,
2087 .dst = MSM_BUS_SLAVE_EBI_CH0,
2088 .ab = 79902720,
2089 .ib = 127844352,
2090 },
2091 {
2092 .src = MSM_BUS_MASTER_JPEG_ENC,
2093 .dst = MSM_BUS_SLAVE_SMI,
2094 .ab = 0,
2095 .ib = 0,
2096 },
2097 {
2098 .src = MSM_BUS_MASTER_JPEG_ENC,
2099 .dst = MSM_BUS_SLAVE_EBI_CH0,
2100 .ab = 0,
2101 .ib = 0,
2102 },
2103};
2104
2105static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2106 {
2107 .src = MSM_BUS_MASTER_VFE,
2108 .dst = MSM_BUS_SLAVE_SMI,
2109 .ab = 0,
2110 .ib = 0,
2111 },
2112 {
2113 .src = MSM_BUS_MASTER_VFE,
2114 .dst = MSM_BUS_SLAVE_EBI_CH0,
2115 .ab = 300902400,
2116 .ib = 481443840,
2117 },
2118 {
2119 .src = MSM_BUS_MASTER_VPE,
2120 .dst = MSM_BUS_SLAVE_SMI,
2121 .ab = 230307840,
2122 .ib = 368492544,
2123 },
2124 {
2125 .src = MSM_BUS_MASTER_VPE,
2126 .dst = MSM_BUS_SLAVE_EBI_CH0,
2127 .ab = 245113344,
2128 .ib = 392181351,
2129 },
2130 {
2131 .src = MSM_BUS_MASTER_JPEG_ENC,
2132 .dst = MSM_BUS_SLAVE_SMI,
2133 .ab = 106536960,
2134 .ib = 170459136,
2135 },
2136 {
2137 .src = MSM_BUS_MASTER_JPEG_ENC,
2138 .dst = MSM_BUS_SLAVE_EBI_CH0,
2139 .ab = 106536960,
2140 .ib = 170459136,
2141 },
2142};
2143
2144static struct msm_bus_paths cam_bus_client_config[] = {
2145 {
2146 ARRAY_SIZE(cam_init_vectors),
2147 cam_init_vectors,
2148 },
2149 {
2150 ARRAY_SIZE(cam_preview_vectors),
2151 cam_preview_vectors,
2152 },
2153 {
2154 ARRAY_SIZE(cam_video_vectors),
2155 cam_video_vectors,
2156 },
2157 {
2158 ARRAY_SIZE(cam_snapshot_vectors),
2159 cam_snapshot_vectors,
2160 },
2161 {
2162 ARRAY_SIZE(cam_zsl_vectors),
2163 cam_zsl_vectors,
2164 },
2165 {
2166 ARRAY_SIZE(cam_stereo_video_vectors),
2167 cam_stereo_video_vectors,
2168 },
2169 {
2170 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2171 cam_stereo_snapshot_vectors,
2172 },
2173};
2174
2175static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2176 cam_bus_client_config,
2177 ARRAY_SIZE(cam_bus_client_config),
2178 .name = "msm_camera",
2179};
2180#endif
2181
2182struct msm_camera_device_platform_data msm_camera_device_data = {
2183 .camera_gpio_on = config_camera_on_gpios,
2184 .camera_gpio_off = config_camera_off_gpios,
2185 .ioext.csiphy = 0x04800000,
2186 .ioext.csisz = 0x00000400,
2187 .ioext.csiirq = CSI_0_IRQ,
2188 .ioclk.mclk_clk_rate = 24000000,
2189 .ioclk.vfe_clk_rate = 228570000,
2190#ifdef CONFIG_MSM_BUS_SCALING
2191 .cam_bus_scale_table = &cam_bus_client_pdata,
2192#endif
2193};
2194
2195#ifdef CONFIG_QS_S5K4E1
2196struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2197 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2198 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2199 .ioext.csiphy = 0x04800000,
2200 .ioext.csisz = 0x00000400,
2201 .ioext.csiirq = CSI_0_IRQ,
2202 .ioclk.mclk_clk_rate = 24000000,
2203 .ioclk.vfe_clk_rate = 228570000,
2204#ifdef CONFIG_MSM_BUS_SCALING
2205 .cam_bus_scale_table = &cam_bus_client_pdata,
2206#endif
2207};
2208#endif
2209
2210struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2211 .camera_gpio_on = config_camera_on_gpios_web_cam,
2212 .camera_gpio_off = config_camera_off_gpios_web_cam,
2213 .ioext.csiphy = 0x04900000,
2214 .ioext.csisz = 0x00000400,
2215 .ioext.csiirq = CSI_1_IRQ,
2216 .ioclk.mclk_clk_rate = 24000000,
2217 .ioclk.vfe_clk_rate = 228570000,
2218#ifdef CONFIG_MSM_BUS_SCALING
2219 .cam_bus_scale_table = &cam_bus_client_pdata,
2220#endif
2221};
2222
2223struct resource msm_camera_resources[] = {
2224 {
2225 .start = 0x04500000,
2226 .end = 0x04500000 + SZ_1M - 1,
2227 .flags = IORESOURCE_MEM,
2228 },
2229 {
2230 .start = VFE_IRQ,
2231 .end = VFE_IRQ,
2232 .flags = IORESOURCE_IRQ,
2233 },
2234};
2235#ifdef CONFIG_MT9E013
2236static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2237 .mount_angle = 0
2238};
2239
2240static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2241 .flash_type = MSM_CAMERA_FLASH_LED,
2242 .flash_src = &msm_flash_src
2243};
2244
2245static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2246 .sensor_name = "mt9e013",
2247 .sensor_reset = 106,
2248 .sensor_pwd = 85,
2249 .vcm_pwd = 1,
2250 .vcm_enable = 0,
2251 .pdata = &msm_camera_device_data,
2252 .resource = msm_camera_resources,
2253 .num_resources = ARRAY_SIZE(msm_camera_resources),
2254 .flash_data = &flash_mt9e013,
2255 .strobe_flash_data = &strobe_flash_xenon,
2256 .sensor_platform_info = &mt9e013_sensor_8660_info,
2257 .csi_if = 1
2258};
2259struct platform_device msm_camera_sensor_mt9e013 = {
2260 .name = "msm_camera_mt9e013",
2261 .dev = {
2262 .platform_data = &msm_camera_sensor_mt9e013_data,
2263 },
2264};
2265#endif
2266
2267#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302268static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2269 .mount_angle = 180
2270};
2271
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002272static struct msm_camera_sensor_flash_data flash_imx074 = {
2273 .flash_type = MSM_CAMERA_FLASH_LED,
2274 .flash_src = &msm_flash_src
2275};
2276
2277static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2278 .sensor_name = "imx074",
2279 .sensor_reset = 106,
2280 .sensor_pwd = 85,
2281 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2282 .vcm_enable = 1,
2283 .pdata = &msm_camera_device_data,
2284 .resource = msm_camera_resources,
2285 .num_resources = ARRAY_SIZE(msm_camera_resources),
2286 .flash_data = &flash_imx074,
2287 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302288 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002289 .csi_if = 1
2290};
2291struct platform_device msm_camera_sensor_imx074 = {
2292 .name = "msm_camera_imx074",
2293 .dev = {
2294 .platform_data = &msm_camera_sensor_imx074_data,
2295 },
2296};
2297#endif
2298#ifdef CONFIG_WEBCAM_OV9726
2299
2300static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2301 .mount_angle = 0
2302};
2303
2304static struct msm_camera_sensor_flash_data flash_ov9726 = {
2305 .flash_type = MSM_CAMERA_FLASH_LED,
2306 .flash_src = &msm_flash_src
2307};
2308static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2309 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002310 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002311 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2312 .sensor_pwd = 85,
2313 .vcm_pwd = 1,
2314 .vcm_enable = 0,
2315 .pdata = &msm_camera_device_data_web_cam,
2316 .resource = msm_camera_resources,
2317 .num_resources = ARRAY_SIZE(msm_camera_resources),
2318 .flash_data = &flash_ov9726,
2319 .sensor_platform_info = &ov9726_sensor_8660_info,
2320 .csi_if = 1
2321};
2322struct platform_device msm_camera_sensor_webcam_ov9726 = {
2323 .name = "msm_camera_ov9726",
2324 .dev = {
2325 .platform_data = &msm_camera_sensor_ov9726_data,
2326 },
2327};
2328#endif
2329#ifdef CONFIG_WEBCAM_OV7692
2330static struct msm_camera_sensor_flash_data flash_ov7692 = {
2331 .flash_type = MSM_CAMERA_FLASH_LED,
2332 .flash_src = &msm_flash_src
2333};
2334static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2335 .sensor_name = "ov7692",
2336 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2337 .sensor_pwd = 85,
2338 .vcm_pwd = 1,
2339 .vcm_enable = 0,
2340 .pdata = &msm_camera_device_data_web_cam,
2341 .resource = msm_camera_resources,
2342 .num_resources = ARRAY_SIZE(msm_camera_resources),
2343 .flash_data = &flash_ov7692,
2344 .csi_if = 1
2345};
2346
2347static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2348 .name = "msm_camera_ov7692",
2349 .dev = {
2350 .platform_data = &msm_camera_sensor_ov7692_data,
2351 },
2352};
2353#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002354#ifdef CONFIG_VX6953
2355static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2356 .mount_angle = 270
2357};
2358
2359static struct msm_camera_sensor_flash_data flash_vx6953 = {
2360 .flash_type = MSM_CAMERA_FLASH_NONE,
2361 .flash_src = &msm_flash_src
2362};
2363
2364static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2365 .sensor_name = "vx6953",
2366 .sensor_reset = 63,
2367 .sensor_pwd = 63,
2368 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2369 .vcm_enable = 1,
2370 .pdata = &msm_camera_device_data,
2371 .resource = msm_camera_resources,
2372 .num_resources = ARRAY_SIZE(msm_camera_resources),
2373 .flash_data = &flash_vx6953,
2374 .sensor_platform_info = &vx6953_sensor_8660_info,
2375 .csi_if = 1
2376};
2377struct platform_device msm_camera_sensor_vx6953 = {
2378 .name = "msm_camera_vx6953",
2379 .dev = {
2380 .platform_data = &msm_camera_sensor_vx6953_data,
2381 },
2382};
2383#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002384#ifdef CONFIG_QS_S5K4E1
2385
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302386static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2387#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2388 .mount_angle = 90
2389#else
2390 .mount_angle = 0
2391#endif
2392};
2393
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002394static char eeprom_data[864];
2395static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2396 .flash_type = MSM_CAMERA_FLASH_LED,
2397 .flash_src = &msm_flash_src
2398};
2399
2400static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2401 .sensor_name = "qs_s5k4e1",
2402 .sensor_reset = 106,
2403 .sensor_pwd = 85,
2404 .vcm_pwd = 1,
2405 .vcm_enable = 0,
2406 .pdata = &msm_camera_device_data_qs_cam,
2407 .resource = msm_camera_resources,
2408 .num_resources = ARRAY_SIZE(msm_camera_resources),
2409 .flash_data = &flash_qs_s5k4e1,
2410 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302411 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002412 .csi_if = 1,
2413 .eeprom_data = eeprom_data,
2414};
2415struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2416 .name = "msm_camera_qs_s5k4e1",
2417 .dev = {
2418 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2419 },
2420};
2421#endif
2422static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2423 #ifdef CONFIG_MT9E013
2424 {
2425 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2426 },
2427 #endif
2428 #ifdef CONFIG_IMX074
2429 {
2430 I2C_BOARD_INFO("imx074", 0x1A),
2431 },
2432 #endif
2433 #ifdef CONFIG_WEBCAM_OV7692
2434 {
2435 I2C_BOARD_INFO("ov7692", 0x78),
2436 },
2437 #endif
2438 #ifdef CONFIG_WEBCAM_OV9726
2439 {
2440 I2C_BOARD_INFO("ov9726", 0x10),
2441 },
2442 #endif
2443 #ifdef CONFIG_QS_S5K4E1
2444 {
2445 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2446 },
2447 #endif
2448};
Jilai Wang971f97f2011-07-13 14:25:25 -04002449
2450static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002451 #ifdef CONFIG_WEBCAM_OV9726
2452 {
2453 I2C_BOARD_INFO("ov9726", 0x10),
2454 },
2455 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002456 #ifdef CONFIG_VX6953
2457 {
2458 I2C_BOARD_INFO("vx6953", 0x20),
2459 },
2460 #endif
2461};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002462#endif
2463
2464#ifdef CONFIG_MSM_GEMINI
2465static struct resource msm_gemini_resources[] = {
2466 {
2467 .start = 0x04600000,
2468 .end = 0x04600000 + SZ_1M - 1,
2469 .flags = IORESOURCE_MEM,
2470 },
2471 {
2472 .start = INT_JPEG,
2473 .end = INT_JPEG,
2474 .flags = IORESOURCE_IRQ,
2475 },
2476};
2477
2478static struct platform_device msm_gemini_device = {
2479 .name = "msm_gemini",
2480 .resource = msm_gemini_resources,
2481 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2482};
2483#endif
2484
2485#ifdef CONFIG_I2C_QUP
2486static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2487{
2488}
2489
2490static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2491 .clk_freq = 384000,
2492 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002493 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2494};
2495
2496static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2497 .clk_freq = 100000,
2498 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002499 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2500};
2501
2502static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2503 .clk_freq = 100000,
2504 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002505 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2506};
2507
2508static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2509 .clk_freq = 100000,
2510 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002511 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2512};
2513
2514static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2515 .clk_freq = 100000,
2516 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002517 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2518};
2519
2520static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2521 .clk_freq = 100000,
2522 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002523 .use_gsbi_shared_mode = 1,
2524 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2525};
2526#endif
2527
2528#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2529static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2530 .max_clock_speed = 24000000,
2531};
2532
2533static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2534 .max_clock_speed = 24000000,
2535};
2536#endif
2537
2538#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002539/* CODEC/TSSC SSBI */
2540static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2541 .controller_type = MSM_SBI_CTRL_SSBI,
2542};
2543#endif
2544
2545#ifdef CONFIG_BATTERY_MSM
2546/* Use basic value for fake MSM battery */
2547static struct msm_psy_batt_pdata msm_psy_batt_data = {
2548 .avail_chg_sources = AC_CHG,
2549};
2550
2551static struct platform_device msm_batt_device = {
2552 .name = "msm-battery",
2553 .id = -1,
2554 .dev.platform_data = &msm_psy_batt_data,
2555};
2556#endif
2557
2558#ifdef CONFIG_FB_MSM_LCDC_DSUB
2559/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2560 prim = 1024 x 600 x 4(bpp) x 2(pages)
2561 This is the difference. */
2562#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2563#else
2564#define MSM_FB_DSUB_PMEM_ADDER (0)
2565#endif
2566
2567/* Sensors DSPS platform data */
2568#ifdef CONFIG_MSM_DSPS
2569
2570static struct dsps_gpio_info dsps_surf_gpios[] = {
2571 {
2572 .name = "compass_rst_n",
2573 .num = GPIO_COMPASS_RST_N,
2574 .on_val = 1, /* device not in reset */
2575 .off_val = 0, /* device in reset */
2576 },
2577 {
2578 .name = "gpio_r_altimeter_reset_n",
2579 .num = GPIO_R_ALTIMETER_RESET_N,
2580 .on_val = 1, /* device not in reset */
2581 .off_val = 0, /* device in reset */
2582 }
2583};
2584
2585static struct dsps_gpio_info dsps_fluid_gpios[] = {
2586 {
2587 .name = "gpio_n_altimeter_reset_n",
2588 .num = GPIO_N_ALTIMETER_RESET_N,
2589 .on_val = 1, /* device not in reset */
2590 .off_val = 0, /* device in reset */
2591 }
2592};
2593
2594static void __init msm8x60_init_dsps(void)
2595{
2596 struct msm_dsps_platform_data *pdata =
2597 msm_dsps_device.dev.platform_data;
2598 /*
2599 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2600 * to the power supply and not controled via GPIOs. Fluid uses a
2601 * different IO-Expender (north) than used on surf/ffa.
2602 */
2603 if (machine_is_msm8x60_fluid()) {
2604 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002605 pdata->pil_name = DSPS_PIL_FLUID_NAME;
2606 pdata->gpios = dsps_fluid_gpios;
2607 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2608 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002609 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2610 pdata->gpios = dsps_surf_gpios;
2611 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2612 }
2613
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002614 platform_device_register(&msm_dsps_device);
2615}
2616#endif /* CONFIG_MSM_DSPS */
2617
2618#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002619#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002620#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002621#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002622#endif
2623
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002624#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2625#define MSM_FB_EXT_BUF_SIZE (1920 * 1080 * 2 * 1) /* 2 bpp x 1 page */
2626#elif defined(CONFIG_FB_MSM_TVOUT)
2627#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
2628#else
2629#define MSM_FB_EXT_BUFT_SIZE 0
2630#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002631
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002632#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2633/* 4 bpp x 2 page HDMI case */
2634#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
2635#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002636/* Note: must be multiple of 4096 */
2637#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002638 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002639#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002640
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002641#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2642#define MSM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
2643#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002644#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002645#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002646
Huaibin Yanga5419422011-12-08 23:52:10 -08002647#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2648#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2649#else
2650#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2651#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2652
2653#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2654#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2655#else
2656#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2657#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2658
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002659#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
2660#define MSM_PMEM_ADSP_SIZE 0x2000000
Ben Romberger09e462d2011-08-09 15:24:37 -07002661#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002662
2663#define MSM_SMI_BASE 0x38000000
2664#define MSM_SMI_SIZE 0x4000000
2665
2666#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002667#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002668
2669#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2670#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2671#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2672
Olav Hauganb5be7992011-11-18 14:29:02 -08002673#define MSM_ION_SF_SIZE 0x1800000 /* 24MB */
2674#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
2675#define MSM_ION_MM_SIZE 0x3800000 /* 56MB */
2676#define MSM_ION_MFC_SIZE SZ_8K
2677#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002678
2679#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Olav Hauganb5be7992011-11-18 14:29:02 -08002680#define MSM_ION_HEAP_NUM 6
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002681#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002682#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002683#endif
2684
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002685static unsigned fb_size;
2686static int __init fb_size_setup(char *p)
2687{
2688 fb_size = memparse(p, NULL);
2689 return 0;
2690}
2691early_param("fb_size", fb_size_setup);
2692
2693static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2694static int __init pmem_kernel_ebi1_size_setup(char *p)
2695{
2696 pmem_kernel_ebi1_size = memparse(p, NULL);
2697 return 0;
2698}
2699early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2700
2701#ifdef CONFIG_ANDROID_PMEM
2702static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2703static int __init pmem_sf_size_setup(char *p)
2704{
2705 pmem_sf_size = memparse(p, NULL);
2706 return 0;
2707}
2708early_param("pmem_sf_size", pmem_sf_size_setup);
2709
2710static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2711
2712static int __init pmem_adsp_size_setup(char *p)
2713{
2714 pmem_adsp_size = memparse(p, NULL);
2715 return 0;
2716}
2717early_param("pmem_adsp_size", pmem_adsp_size_setup);
2718
2719static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2720
2721static int __init pmem_audio_size_setup(char *p)
2722{
2723 pmem_audio_size = memparse(p, NULL);
2724 return 0;
2725}
2726early_param("pmem_audio_size", pmem_audio_size_setup);
2727#endif
2728
2729static struct resource msm_fb_resources[] = {
2730 {
2731 .flags = IORESOURCE_DMA,
2732 }
2733};
2734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002735static int msm_fb_detect_panel(const char *name)
2736{
2737 if (machine_is_msm8x60_fluid()) {
2738 uint32_t soc_platform_version = socinfo_get_platform_version();
2739 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2740#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2741 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002742 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2743 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744 return 0;
2745#endif
2746 } else { /*P3 and up use AUO panel */
2747#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2748 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002749 strnlen(LCDC_AUO_PANEL_NAME,
2750 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002751 return 0;
2752#endif
2753 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002754#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2755 } else if machine_is_msm8x60_dragon() {
2756 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002757 strnlen(LCDC_NT35582_PANEL_NAME,
2758 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002759 return 0;
2760#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002761 } else {
2762 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002763 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2764 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002765 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002766
2767#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2768 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2769 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2770 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2771 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2772 PANEL_NAME_MAX_LEN)))
2773 return 0;
2774
2775 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2776 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2777 PANEL_NAME_MAX_LEN)))
2778 return 0;
2779
2780 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2781 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2782 PANEL_NAME_MAX_LEN)))
2783 return 0;
2784#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002785 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002786
2787 if (!strncmp(name, HDMI_PANEL_NAME,
2788 strnlen(HDMI_PANEL_NAME,
2789 PANEL_NAME_MAX_LEN)))
2790 return 0;
2791
2792 if (!strncmp(name, TVOUT_PANEL_NAME,
2793 strnlen(TVOUT_PANEL_NAME,
2794 PANEL_NAME_MAX_LEN)))
2795 return 0;
2796
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002797 pr_warning("%s: not supported '%s'", __func__, name);
2798 return -ENODEV;
2799}
2800
2801static struct msm_fb_platform_data msm_fb_pdata = {
2802 .detect_client = msm_fb_detect_panel,
2803};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002804
2805static struct platform_device msm_fb_device = {
2806 .name = "msm_fb",
2807 .id = 0,
2808 .num_resources = ARRAY_SIZE(msm_fb_resources),
2809 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002811};
2812
2813#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002814#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002815static struct android_pmem_platform_data android_pmem_pdata = {
2816 .name = "pmem",
2817 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2818 .cached = 1,
2819 .memory_type = MEMTYPE_EBI1,
2820};
2821
2822static struct platform_device android_pmem_device = {
2823 .name = "android_pmem",
2824 .id = 0,
2825 .dev = {.platform_data = &android_pmem_pdata},
2826};
2827
2828static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2829 .name = "pmem_adsp",
2830 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2831 .cached = 0,
2832 .memory_type = MEMTYPE_EBI1,
2833};
2834
2835static struct platform_device android_pmem_adsp_device = {
2836 .name = "android_pmem",
2837 .id = 2,
2838 .dev = { .platform_data = &android_pmem_adsp_pdata },
2839};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002840#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002841static struct android_pmem_platform_data android_pmem_audio_pdata = {
2842 .name = "pmem_audio",
2843 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2844 .cached = 0,
2845 .memory_type = MEMTYPE_EBI1,
2846};
2847
2848static struct platform_device android_pmem_audio_device = {
2849 .name = "android_pmem",
2850 .id = 4,
2851 .dev = { .platform_data = &android_pmem_audio_pdata },
2852};
2853
Laura Abbott1e36a022011-06-22 17:08:13 -07002854#define PMEM_BUS_WIDTH(_bw) \
2855 { \
2856 .vectors = &(struct msm_bus_vectors){ \
2857 .src = MSM_BUS_MASTER_AMPSS_M0, \
2858 .dst = MSM_BUS_SLAVE_SMI, \
2859 .ib = (_bw), \
2860 .ab = 0, \
2861 }, \
2862 .num_paths = 1, \
2863 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002864
2865static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002866 [0] = PMEM_BUS_WIDTH(0), /* Off */
2867 [1] = PMEM_BUS_WIDTH(1), /* On */
2868};
2869
2870static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002871 .usecase = mem_smi_table,
2872 .num_usecases = ARRAY_SIZE(mem_smi_table),
2873 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002874};
2875
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002876int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002877{
2878 int bus_id = (int) data;
2879
2880 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002881 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002882}
2883
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002884int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002885{
2886 int bus_id = (int) data;
2887
2888 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002889 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002890}
2891
Alex Bird199980e2011-10-21 11:29:27 -07002892void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002893{
2894 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2895}
Olav Hauganee0f7802011-12-19 13:28:57 -08002896#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002897static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2898 .name = "pmem_smipool",
2899 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2900 .cached = 0,
2901 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002902 .request_region = request_smi_region,
2903 .release_region = release_smi_region,
2904 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002905 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002906};
2907static struct platform_device android_pmem_smipool_device = {
2908 .name = "android_pmem",
2909 .id = 7,
2910 .dev = { .platform_data = &android_pmem_smipool_pdata },
2911};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002912#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002913#endif
2914
2915#define GPIO_DONGLE_PWR_EN 258
2916static void setup_display_power(void);
2917static int lcdc_vga_enabled;
2918static int vga_enable_request(int enable)
2919{
2920 if (enable)
2921 lcdc_vga_enabled = 1;
2922 else
2923 lcdc_vga_enabled = 0;
2924 setup_display_power();
2925
2926 return 0;
2927}
2928
2929#define GPIO_BACKLIGHT_PWM0 0
2930#define GPIO_BACKLIGHT_PWM1 1
2931
2932static int pmic_backlight_gpio[2]
2933 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2934static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2935 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2936 .vga_switch = vga_enable_request,
2937};
2938
2939static struct platform_device lcdc_samsung_panel_device = {
2940 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2941 .id = 0,
2942 .dev = {
2943 .platform_data = &lcdc_samsung_panel_data,
2944 }
2945};
2946#if (!defined(CONFIG_SPI_QUP)) && \
2947 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2948 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2949
2950static int lcdc_spi_gpio_array_num[] = {
2951 LCDC_SPI_GPIO_CLK,
2952 LCDC_SPI_GPIO_CS,
2953 LCDC_SPI_GPIO_MOSI,
2954};
2955
2956static uint32_t lcdc_spi_gpio_config_data[] = {
2957 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2958 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2959 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2960 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2961 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2962 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2963};
2964
2965static void lcdc_config_spi_gpios(int enable)
2966{
2967 int n;
2968 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2969 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2970}
2971#endif
2972
2973#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2974#ifdef CONFIG_SPI_QUP
2975static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2976 {
2977 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2978 .mode = SPI_MODE_3,
2979 .bus_num = 1,
2980 .chip_select = 0,
2981 .max_speed_hz = 10800000,
2982 }
2983};
2984#endif /* CONFIG_SPI_QUP */
2985
2986static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2987#ifndef CONFIG_SPI_QUP
2988 .panel_config_gpio = lcdc_config_spi_gpios,
2989 .gpio_num = lcdc_spi_gpio_array_num,
2990#endif
2991};
2992
2993static struct platform_device lcdc_samsung_oled_panel_device = {
2994 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2995 .id = 0,
2996 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2997};
2998#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2999
3000#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3001#ifdef CONFIG_SPI_QUP
3002static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3003 {
3004 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3005 .mode = SPI_MODE_3,
3006 .bus_num = 1,
3007 .chip_select = 0,
3008 .max_speed_hz = 10800000,
3009 }
3010};
3011#endif
3012
3013static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3014#ifndef CONFIG_SPI_QUP
3015 .panel_config_gpio = lcdc_config_spi_gpios,
3016 .gpio_num = lcdc_spi_gpio_array_num,
3017#endif
3018};
3019
3020static struct platform_device lcdc_auo_wvga_panel_device = {
3021 .name = LCDC_AUO_PANEL_NAME,
3022 .id = 0,
3023 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3024};
3025#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3026
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003027#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3028
3029#define GPIO_NT35582_RESET 94
3030#define GPIO_NT35582_BL_EN_HW_PIN 24
3031#define GPIO_NT35582_BL_EN \
3032 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3033
3034static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3035
3036static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3037 .gpio_num = lcdc_nt35582_pmic_gpio,
3038};
3039
3040static struct platform_device lcdc_nt35582_panel_device = {
3041 .name = LCDC_NT35582_PANEL_NAME,
3042 .id = 0,
3043 .dev = {
3044 .platform_data = &lcdc_nt35582_panel_data,
3045 }
3046};
3047
3048static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3049 {
3050 .modalias = "lcdc_nt35582_spi",
3051 .mode = SPI_MODE_0,
3052 .bus_num = 0,
3053 .chip_select = 0,
3054 .max_speed_hz = 1100000,
3055 }
3056};
3057#endif
3058
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003059#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3060static struct resource hdmi_msm_resources[] = {
3061 {
3062 .name = "hdmi_msm_qfprom_addr",
3063 .start = 0x00700000,
3064 .end = 0x007060FF,
3065 .flags = IORESOURCE_MEM,
3066 },
3067 {
3068 .name = "hdmi_msm_hdmi_addr",
3069 .start = 0x04A00000,
3070 .end = 0x04A00FFF,
3071 .flags = IORESOURCE_MEM,
3072 },
3073 {
3074 .name = "hdmi_msm_irq",
3075 .start = HDMI_IRQ,
3076 .end = HDMI_IRQ,
3077 .flags = IORESOURCE_IRQ,
3078 },
3079};
3080
3081static int hdmi_enable_5v(int on);
3082static int hdmi_core_power(int on, int show);
3083static int hdmi_cec_power(int on);
3084
3085static struct msm_hdmi_platform_data hdmi_msm_data = {
3086 .irq = HDMI_IRQ,
3087 .enable_5v = hdmi_enable_5v,
3088 .core_power = hdmi_core_power,
3089 .cec_power = hdmi_cec_power,
3090};
3091
3092static struct platform_device hdmi_msm_device = {
3093 .name = "hdmi_msm",
3094 .id = 0,
3095 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3096 .resource = hdmi_msm_resources,
3097 .dev.platform_data = &hdmi_msm_data,
3098};
3099#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3100
3101#ifdef CONFIG_FB_MSM_MIPI_DSI
3102static struct platform_device mipi_dsi_toshiba_panel_device = {
3103 .name = "mipi_toshiba",
3104 .id = 0,
3105};
3106
3107#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3108
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003109static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003110 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003111 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003112};
3113
3114static struct platform_device mipi_dsi_novatek_panel_device = {
3115 .name = "mipi_novatek",
3116 .id = 0,
3117 .dev = {
3118 .platform_data = &novatek_pdata,
3119 }
3120};
3121#endif
3122
3123static void __init msm8x60_allocate_memory_regions(void)
3124{
3125 void *addr;
3126 unsigned long size;
3127
3128 size = MSM_FB_SIZE;
3129 addr = alloc_bootmem_align(size, 0x1000);
3130 msm_fb_resources[0].start = __pa(addr);
3131 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3132 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3133 size, addr, __pa(addr));
3134
3135}
3136
3137#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3138 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3139/*virtual key support */
3140static ssize_t tma300_vkeys_show(struct kobject *kobj,
3141 struct kobj_attribute *attr, char *buf)
3142{
3143 return sprintf(buf,
3144 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3145 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3146 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3147 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3148 "\n");
3149}
3150
3151static struct kobj_attribute tma300_vkeys_attr = {
3152 .attr = {
3153 .mode = S_IRUGO,
3154 },
3155 .show = &tma300_vkeys_show,
3156};
3157
3158static struct attribute *tma300_properties_attrs[] = {
3159 &tma300_vkeys_attr.attr,
3160 NULL
3161};
3162
3163static struct attribute_group tma300_properties_attr_group = {
3164 .attrs = tma300_properties_attrs,
3165};
3166
3167static struct kobject *properties_kobj;
3168
3169
3170
3171#define CYTTSP_TS_GPIO_IRQ 61
3172static int cyttsp_platform_init(struct i2c_client *client)
3173{
3174 int rc = -EINVAL;
3175 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3176
3177 if (machine_is_msm8x60_fluid()) {
3178 pm8058_l5 = regulator_get(NULL, "8058_l5");
3179 if (IS_ERR(pm8058_l5)) {
3180 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3181 __func__, PTR_ERR(pm8058_l5));
3182 rc = PTR_ERR(pm8058_l5);
3183 return rc;
3184 }
3185 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3186 if (rc) {
3187 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3188 __func__, rc);
3189 goto reg_l5_put;
3190 }
3191
3192 rc = regulator_enable(pm8058_l5);
3193 if (rc) {
3194 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3195 __func__, rc);
3196 goto reg_l5_put;
3197 }
3198 }
3199 /* vote for s3 to enable i2c communication lines */
3200 pm8058_s3 = regulator_get(NULL, "8058_s3");
3201 if (IS_ERR(pm8058_s3)) {
3202 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3203 __func__, PTR_ERR(pm8058_s3));
3204 rc = PTR_ERR(pm8058_s3);
3205 goto reg_l5_disable;
3206 }
3207
3208 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3209 if (rc) {
3210 pr_err("%s: regulator_set_voltage() = %d\n",
3211 __func__, rc);
3212 goto reg_s3_put;
3213 }
3214
3215 rc = regulator_enable(pm8058_s3);
3216 if (rc) {
3217 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3218 __func__, rc);
3219 goto reg_s3_put;
3220 }
3221
3222 /* wait for vregs to stabilize */
3223 usleep_range(10000, 10000);
3224
3225 /* check this device active by reading first byte/register */
3226 rc = i2c_smbus_read_byte_data(client, 0x01);
3227 if (rc < 0) {
3228 pr_err("%s: i2c sanity check failed\n", __func__);
3229 goto reg_s3_disable;
3230 }
3231
3232 /* virtual keys */
3233 if (machine_is_msm8x60_fluid()) {
3234 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3235 properties_kobj = kobject_create_and_add("board_properties",
3236 NULL);
3237 if (properties_kobj)
3238 rc = sysfs_create_group(properties_kobj,
3239 &tma300_properties_attr_group);
3240 if (!properties_kobj || rc)
3241 pr_err("%s: failed to create board_properties\n",
3242 __func__);
3243 }
3244 return CY_OK;
3245
3246reg_s3_disable:
3247 regulator_disable(pm8058_s3);
3248reg_s3_put:
3249 regulator_put(pm8058_s3);
3250reg_l5_disable:
3251 if (machine_is_msm8x60_fluid())
3252 regulator_disable(pm8058_l5);
3253reg_l5_put:
3254 if (machine_is_msm8x60_fluid())
3255 regulator_put(pm8058_l5);
3256 return rc;
3257}
3258
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303259/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3260static int cyttsp_platform_suspend(struct i2c_client *client)
3261{
3262 msleep(20);
3263
3264 return CY_OK;
3265}
3266
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003267static int cyttsp_platform_resume(struct i2c_client *client)
3268{
3269 /* add any special code to strobe a wakeup pin or chip reset */
3270 msleep(10);
3271
3272 return CY_OK;
3273}
3274
3275static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3276 .flags = 0x04,
3277 .gen = CY_GEN3, /* or */
3278 .use_st = CY_USE_ST,
3279 .use_mt = CY_USE_MT,
3280 .use_hndshk = CY_SEND_HNDSHK,
3281 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303282 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003283 .use_gestures = CY_USE_GESTURES,
3284 /* activate up to 4 groups
3285 * and set active distance
3286 */
3287 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3288 CY_GEST_GRP3 | CY_GEST_GRP4 |
3289 CY_ACT_DIST,
3290 /* change act_intrvl to customize the Active power state
3291 * scanning/processing refresh interval for Operating mode
3292 */
3293 .act_intrvl = CY_ACT_INTRVL_DFLT,
3294 /* change tch_tmout to customize the touch timeout for the
3295 * Active power state for Operating mode
3296 */
3297 .tch_tmout = CY_TCH_TMOUT_DFLT,
3298 /* change lp_intrvl to customize the Low Power power state
3299 * scanning/processing refresh interval for Operating mode
3300 */
3301 .lp_intrvl = CY_LP_INTRVL_DFLT,
3302 .sleep_gpio = -1,
3303 .resout_gpio = -1,
3304 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3305 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303306 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003307 .init = cyttsp_platform_init,
3308};
3309
3310static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3311 .panel_maxx = 1083,
3312 .panel_maxy = 659,
3313 .disp_minx = 30,
3314 .disp_maxx = 1053,
3315 .disp_miny = 30,
3316 .disp_maxy = 629,
3317 .correct_fw_ver = 8,
3318 .fw_fname = "cyttsp_8660_ffa.hex",
3319 .flags = 0x00,
3320 .gen = CY_GEN2, /* or */
3321 .use_st = CY_USE_ST,
3322 .use_mt = CY_USE_MT,
3323 .use_hndshk = CY_SEND_HNDSHK,
3324 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303325 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003326 .use_gestures = CY_USE_GESTURES,
3327 /* activate up to 4 groups
3328 * and set active distance
3329 */
3330 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3331 CY_GEST_GRP3 | CY_GEST_GRP4 |
3332 CY_ACT_DIST,
3333 /* change act_intrvl to customize the Active power state
3334 * scanning/processing refresh interval for Operating mode
3335 */
3336 .act_intrvl = CY_ACT_INTRVL_DFLT,
3337 /* change tch_tmout to customize the touch timeout for the
3338 * Active power state for Operating mode
3339 */
3340 .tch_tmout = CY_TCH_TMOUT_DFLT,
3341 /* change lp_intrvl to customize the Low Power power state
3342 * scanning/processing refresh interval for Operating mode
3343 */
3344 .lp_intrvl = CY_LP_INTRVL_DFLT,
3345 .sleep_gpio = -1,
3346 .resout_gpio = -1,
3347 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3348 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303349 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003350 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303351 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003352};
3353static void cyttsp_set_params(void)
3354{
3355 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3356 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3357 cyttsp_fluid_pdata.panel_maxx = 539;
3358 cyttsp_fluid_pdata.panel_maxy = 994;
3359 cyttsp_fluid_pdata.disp_minx = 30;
3360 cyttsp_fluid_pdata.disp_maxx = 509;
3361 cyttsp_fluid_pdata.disp_miny = 60;
3362 cyttsp_fluid_pdata.disp_maxy = 859;
3363 cyttsp_fluid_pdata.correct_fw_ver = 4;
3364 } else {
3365 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3366 cyttsp_fluid_pdata.panel_maxx = 550;
3367 cyttsp_fluid_pdata.panel_maxy = 1013;
3368 cyttsp_fluid_pdata.disp_minx = 35;
3369 cyttsp_fluid_pdata.disp_maxx = 515;
3370 cyttsp_fluid_pdata.disp_miny = 69;
3371 cyttsp_fluid_pdata.disp_maxy = 869;
3372 cyttsp_fluid_pdata.correct_fw_ver = 5;
3373 }
3374
3375}
3376
3377static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3378 {
3379 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3380 .platform_data = &cyttsp_fluid_pdata,
3381#ifndef CY_USE_TIMER
3382 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3383#endif /* CY_USE_TIMER */
3384 },
3385};
3386
3387static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3388 {
3389 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3390 .platform_data = &cyttsp_tmg240_pdata,
3391#ifndef CY_USE_TIMER
3392 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3393#endif /* CY_USE_TIMER */
3394 },
3395};
3396#endif
3397
3398static struct regulator *vreg_tmg200;
3399
3400#define TS_PEN_IRQ_GPIO 61
3401static int tmg200_power(int vreg_on)
3402{
3403 int rc = -EINVAL;
3404
3405 if (!vreg_tmg200) {
3406 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3407 __func__, rc);
3408 return rc;
3409 }
3410
3411 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3412 regulator_disable(vreg_tmg200);
3413 if (rc < 0)
3414 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3415 __func__, vreg_on ? "enable" : "disable", rc);
3416
3417 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003418 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003419
3420 return rc;
3421}
3422
3423static int tmg200_dev_setup(bool enable)
3424{
3425 int rc;
3426
3427 if (enable) {
3428 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3429 if (IS_ERR(vreg_tmg200)) {
3430 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3431 __func__, PTR_ERR(vreg_tmg200));
3432 rc = PTR_ERR(vreg_tmg200);
3433 return rc;
3434 }
3435
3436 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3437 if (rc) {
3438 pr_err("%s: regulator_set_voltage() = %d\n",
3439 __func__, rc);
3440 goto reg_put;
3441 }
3442 } else {
3443 /* put voltage sources */
3444 regulator_put(vreg_tmg200);
3445 }
3446 return 0;
3447reg_put:
3448 regulator_put(vreg_tmg200);
3449 return rc;
3450}
3451
3452static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3453 .ts_name = "msm_tmg200_ts",
3454 .dis_min_x = 0,
3455 .dis_max_x = 1023,
3456 .dis_min_y = 0,
3457 .dis_max_y = 599,
3458 .min_tid = 0,
3459 .max_tid = 255,
3460 .min_touch = 0,
3461 .max_touch = 255,
3462 .min_width = 0,
3463 .max_width = 255,
3464 .power_on = tmg200_power,
3465 .dev_setup = tmg200_dev_setup,
3466 .nfingers = 2,
3467 .irq_gpio = TS_PEN_IRQ_GPIO,
3468 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3469};
3470
3471static struct i2c_board_info cy8ctmg200_board_info[] = {
3472 {
3473 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3474 .platform_data = &cy8ctmg200_pdata,
3475 }
3476};
3477
Zhang Chang Ken211df572011-07-05 19:16:39 -04003478static struct regulator *vreg_tma340;
3479
3480static int tma340_power(int vreg_on)
3481{
3482 int rc = -EINVAL;
3483
3484 if (!vreg_tma340) {
3485 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3486 __func__, rc);
3487 return rc;
3488 }
3489
3490 rc = vreg_on ? regulator_enable(vreg_tma340) :
3491 regulator_disable(vreg_tma340);
3492 if (rc < 0)
3493 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3494 __func__, vreg_on ? "enable" : "disable", rc);
3495
3496 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003497 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003498
3499 return rc;
3500}
3501
3502static struct kobject *tma340_prop_kobj;
3503
3504static int tma340_dragon_dev_setup(bool enable)
3505{
3506 int rc;
3507
3508 if (enable) {
3509 vreg_tma340 = regulator_get(NULL, "8901_l2");
3510 if (IS_ERR(vreg_tma340)) {
3511 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3512 __func__, PTR_ERR(vreg_tma340));
3513 rc = PTR_ERR(vreg_tma340);
3514 return rc;
3515 }
3516
3517 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3518 if (rc) {
3519 pr_err("%s: regulator_set_voltage() = %d\n",
3520 __func__, rc);
3521 goto reg_put;
3522 }
3523 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3524 tma340_prop_kobj = kobject_create_and_add("board_properties",
3525 NULL);
3526 if (tma340_prop_kobj) {
3527 rc = sysfs_create_group(tma340_prop_kobj,
3528 &tma300_properties_attr_group);
3529 if (rc) {
3530 kobject_put(tma340_prop_kobj);
3531 pr_err("%s: failed to create board_properties\n",
3532 __func__);
3533 goto reg_put;
3534 }
3535 }
3536
3537 } else {
3538 /* put voltage sources */
3539 regulator_put(vreg_tma340);
3540 /* destroy virtual keys */
3541 if (tma340_prop_kobj) {
3542 sysfs_remove_group(tma340_prop_kobj,
3543 &tma300_properties_attr_group);
3544 kobject_put(tma340_prop_kobj);
3545 }
3546 }
3547 return 0;
3548reg_put:
3549 regulator_put(vreg_tma340);
3550 return rc;
3551}
3552
3553
3554static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3555 .ts_name = "cy8ctma340",
3556 .dis_min_x = 0,
3557 .dis_max_x = 479,
3558 .dis_min_y = 0,
3559 .dis_max_y = 799,
3560 .min_tid = 0,
3561 .max_tid = 255,
3562 .min_touch = 0,
3563 .max_touch = 255,
3564 .min_width = 0,
3565 .max_width = 255,
3566 .power_on = tma340_power,
3567 .dev_setup = tma340_dragon_dev_setup,
3568 .nfingers = 2,
3569 .irq_gpio = TS_PEN_IRQ_GPIO,
3570 .resout_gpio = -1,
3571};
3572
3573static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3574 {
3575 I2C_BOARD_INFO("cy8ctma340", 0x24),
3576 .platform_data = &cy8ctma340_dragon_pdata,
3577 }
3578};
3579
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003580#ifdef CONFIG_SERIAL_MSM_HS
3581static int configure_uart_gpios(int on)
3582{
3583 int ret = 0, i;
3584 int uart_gpios[] = {53, 54, 55, 56};
3585 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3586 if (on) {
3587 ret = msm_gpiomux_get(uart_gpios[i]);
3588 if (unlikely(ret))
3589 break;
3590 } else {
3591 ret = msm_gpiomux_put(uart_gpios[i]);
3592 if (unlikely(ret))
3593 return ret;
3594 }
3595 }
3596 if (ret)
3597 for (; i >= 0; i--)
3598 msm_gpiomux_put(uart_gpios[i]);
3599 return ret;
3600}
3601static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3602 .inject_rx_on_wakeup = 1,
3603 .rx_to_inject = 0xFD,
3604 .gpio_config = configure_uart_gpios,
3605};
3606#endif
3607
3608
3609#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3610
3611static struct gpio_led gpio_exp_leds_config[] = {
3612 {
3613 .name = "left_led1:green",
3614 .gpio = GPIO_LEFT_LED_1,
3615 .active_low = 1,
3616 .retain_state_suspended = 0,
3617 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3618 },
3619 {
3620 .name = "left_led2:red",
3621 .gpio = GPIO_LEFT_LED_2,
3622 .active_low = 1,
3623 .retain_state_suspended = 0,
3624 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3625 },
3626 {
3627 .name = "left_led3:green",
3628 .gpio = GPIO_LEFT_LED_3,
3629 .active_low = 1,
3630 .retain_state_suspended = 0,
3631 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3632 },
3633 {
3634 .name = "wlan_led:orange",
3635 .gpio = GPIO_LEFT_LED_WLAN,
3636 .active_low = 1,
3637 .retain_state_suspended = 0,
3638 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3639 },
3640 {
3641 .name = "left_led5:green",
3642 .gpio = GPIO_LEFT_LED_5,
3643 .active_low = 1,
3644 .retain_state_suspended = 0,
3645 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3646 },
3647 {
3648 .name = "right_led1:green",
3649 .gpio = GPIO_RIGHT_LED_1,
3650 .active_low = 1,
3651 .retain_state_suspended = 0,
3652 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3653 },
3654 {
3655 .name = "right_led2:red",
3656 .gpio = GPIO_RIGHT_LED_2,
3657 .active_low = 1,
3658 .retain_state_suspended = 0,
3659 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3660 },
3661 {
3662 .name = "right_led3:green",
3663 .gpio = GPIO_RIGHT_LED_3,
3664 .active_low = 1,
3665 .retain_state_suspended = 0,
3666 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3667 },
3668 {
3669 .name = "bt_led:blue",
3670 .gpio = GPIO_RIGHT_LED_BT,
3671 .active_low = 1,
3672 .retain_state_suspended = 0,
3673 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3674 },
3675 {
3676 .name = "right_led5:green",
3677 .gpio = GPIO_RIGHT_LED_5,
3678 .active_low = 1,
3679 .retain_state_suspended = 0,
3680 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3681 },
3682};
3683
3684static struct gpio_led_platform_data gpio_leds_pdata = {
3685 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3686 .leds = gpio_exp_leds_config,
3687};
3688
3689static struct platform_device gpio_leds = {
3690 .name = "leds-gpio",
3691 .id = -1,
3692 .dev = {
3693 .platform_data = &gpio_leds_pdata,
3694 },
3695};
3696
3697static struct gpio_led fluid_gpio_leds[] = {
3698 {
3699 .name = "dual_led:green",
3700 .gpio = GPIO_LED1_GREEN_N,
3701 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3702 .active_low = 1,
3703 .retain_state_suspended = 0,
3704 },
3705 {
3706 .name = "dual_led:red",
3707 .gpio = GPIO_LED2_RED_N,
3708 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3709 .active_low = 1,
3710 .retain_state_suspended = 0,
3711 },
3712};
3713
3714static struct gpio_led_platform_data gpio_led_pdata = {
3715 .leds = fluid_gpio_leds,
3716 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3717};
3718
3719static struct platform_device fluid_leds_gpio = {
3720 .name = "leds-gpio",
3721 .id = -1,
3722 .dev = {
3723 .platform_data = &gpio_led_pdata,
3724 },
3725};
3726
3727#endif
3728
3729#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
3730
3731static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
3732 .phys_addr_base = 0x00106000,
3733 .reg_offsets = {
3734 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000C80,
3735 [MSM_RPM_LOG_PAGE_BUFFER] = 0x00000CA0,
3736 },
3737 .phys_size = SZ_8K,
3738 .log_len = 4096, /* log's buffer length in bytes */
3739 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3740};
3741
3742static struct platform_device msm_rpm_log_device = {
3743 .name = "msm_rpm_log",
3744 .id = -1,
3745 .dev = {
3746 .platform_data = &msm_rpm_log_pdata,
3747 },
3748};
3749#endif
3750
3751#ifdef CONFIG_BATTERY_MSM8X60
3752static struct msm_charger_platform_data msm_charger_data = {
3753 .safety_time = 180,
3754 .update_time = 1,
3755 .max_voltage = 4200,
3756 .min_voltage = 3200,
3757};
3758
3759static struct platform_device msm_charger_device = {
3760 .name = "msm-charger",
3761 .id = -1,
3762 .dev = {
3763 .platform_data = &msm_charger_data,
3764 }
3765};
3766#endif
3767
3768/*
3769 * Consumer specific regulator names:
3770 * regulator name consumer dev_name
3771 */
3772static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3773 REGULATOR_SUPPLY("8058_l0", NULL),
3774};
3775static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3776 REGULATOR_SUPPLY("8058_l1", NULL),
3777};
3778static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3779 REGULATOR_SUPPLY("8058_l2", NULL),
3780};
3781static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3782 REGULATOR_SUPPLY("8058_l3", NULL),
3783};
3784static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3785 REGULATOR_SUPPLY("8058_l4", NULL),
3786};
3787static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3788 REGULATOR_SUPPLY("8058_l5", NULL),
3789};
3790static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3791 REGULATOR_SUPPLY("8058_l6", NULL),
3792};
3793static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3794 REGULATOR_SUPPLY("8058_l7", NULL),
3795};
3796static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3797 REGULATOR_SUPPLY("8058_l8", NULL),
3798};
3799static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3800 REGULATOR_SUPPLY("8058_l9", NULL),
3801};
3802static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3803 REGULATOR_SUPPLY("8058_l10", NULL),
3804};
3805static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3806 REGULATOR_SUPPLY("8058_l11", NULL),
3807};
3808static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3809 REGULATOR_SUPPLY("8058_l12", NULL),
3810};
3811static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3812 REGULATOR_SUPPLY("8058_l13", NULL),
3813};
3814static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3815 REGULATOR_SUPPLY("8058_l14", NULL),
3816};
3817static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3818 REGULATOR_SUPPLY("8058_l15", NULL),
3819};
3820static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3821 REGULATOR_SUPPLY("8058_l16", NULL),
3822};
3823static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3824 REGULATOR_SUPPLY("8058_l17", NULL),
3825};
3826static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3827 REGULATOR_SUPPLY("8058_l18", NULL),
3828};
3829static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3830 REGULATOR_SUPPLY("8058_l19", NULL),
3831};
3832static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3833 REGULATOR_SUPPLY("8058_l20", NULL),
3834};
3835static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3836 REGULATOR_SUPPLY("8058_l21", NULL),
3837};
3838static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3839 REGULATOR_SUPPLY("8058_l22", NULL),
3840};
3841static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3842 REGULATOR_SUPPLY("8058_l23", NULL),
3843};
3844static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3845 REGULATOR_SUPPLY("8058_l24", NULL),
3846};
3847static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3848 REGULATOR_SUPPLY("8058_l25", NULL),
3849};
3850static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3851 REGULATOR_SUPPLY("8058_s0", NULL),
3852};
3853static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3854 REGULATOR_SUPPLY("8058_s1", NULL),
3855};
3856static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3857 REGULATOR_SUPPLY("8058_s2", NULL),
3858};
3859static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3860 REGULATOR_SUPPLY("8058_s3", NULL),
3861};
3862static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3863 REGULATOR_SUPPLY("8058_s4", NULL),
3864};
3865static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3866 REGULATOR_SUPPLY("8058_lvs0", NULL),
3867};
3868static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3869 REGULATOR_SUPPLY("8058_lvs1", NULL),
3870};
3871static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3872 REGULATOR_SUPPLY("8058_ncp", NULL),
3873};
3874
3875static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3876 REGULATOR_SUPPLY("8901_l0", NULL),
3877};
3878static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3879 REGULATOR_SUPPLY("8901_l1", NULL),
3880};
3881static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3882 REGULATOR_SUPPLY("8901_l2", NULL),
3883};
3884static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3885 REGULATOR_SUPPLY("8901_l3", NULL),
3886};
3887static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3888 REGULATOR_SUPPLY("8901_l4", NULL),
3889};
3890static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3891 REGULATOR_SUPPLY("8901_l5", NULL),
3892};
3893static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3894 REGULATOR_SUPPLY("8901_l6", NULL),
3895};
3896static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3897 REGULATOR_SUPPLY("8901_s2", NULL),
3898};
3899static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3900 REGULATOR_SUPPLY("8901_s3", NULL),
3901};
3902static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3903 REGULATOR_SUPPLY("8901_s4", NULL),
3904};
3905static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3906 REGULATOR_SUPPLY("8901_lvs0", NULL),
3907};
3908static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3909 REGULATOR_SUPPLY("8901_lvs1", NULL),
3910};
3911static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3912 REGULATOR_SUPPLY("8901_lvs2", NULL),
3913};
3914static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3915 REGULATOR_SUPPLY("8901_lvs3", NULL),
3916};
3917static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3918 REGULATOR_SUPPLY("8901_mvs0", NULL),
3919};
3920
David Collins6f032ba2011-08-31 14:08:15 -07003921/* Pin control regulators */
3922static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3923 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3924};
3925static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3926 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3927};
3928static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3929 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3930};
3931static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3932 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3933};
3934static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3935 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3936};
3937static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3938 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3939};
3940
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003941#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3942 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins6f032ba2011-08-31 14:08:15 -07003943 _freq, _pin_fn, _force_mode, _state, _sleep_selectable, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003944 _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003945 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003946 .init_data = { \
3947 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003948 .valid_modes_mask = _modes, \
3949 .valid_ops_mask = _ops, \
3950 .min_uV = _min_uV, \
3951 .max_uV = _max_uV, \
3952 .input_uV = _min_uV, \
3953 .apply_uV = _apply_uV, \
3954 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003955 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003956 .consumer_supplies = vreg_consumers_##_id, \
3957 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003958 ARRAY_SIZE(vreg_consumers_##_id), \
3959 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003960 .id = RPM_VREG_ID_##_id, \
3961 .default_uV = _default_uV, \
3962 .peak_uA = _peak_uA, \
3963 .avg_uA = _avg_uA, \
3964 .pull_down_enable = _pull_down, \
3965 .pin_ctrl = _pin_ctrl, \
3966 .freq = RPM_VREG_FREQ_##_freq, \
3967 .pin_fn = _pin_fn, \
3968 .force_mode = _force_mode, \
3969 .state = _state, \
3970 .sleep_selectable = _sleep_selectable, \
3971 }
3972
3973/* Pin control initialization */
3974#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3975 { \
3976 .init_data = { \
3977 .constraints = { \
3978 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3979 .always_on = _always_on, \
3980 }, \
3981 .num_consumer_supplies = \
3982 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3983 .consumer_supplies = vreg_consumers_##_id##_PC, \
3984 }, \
3985 .id = RPM_VREG_ID_##_id##_PC, \
3986 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003987 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003988 }
3989
3990/*
3991 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3992 * via the peak_uA value specified in the table below. If the value is less
3993 * than the high power min threshold for the regulator, then the regulator will
3994 * be set to LPM. Otherwise, it will be set to HPM.
3995 *
3996 * This value can be further overridden by specifying an initial mode via
3997 * .init_data.constraints.initial_mode.
3998 */
3999
David Collins6f032ba2011-08-31 14:08:15 -07004000#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4001 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004002 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4003 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4004 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4005 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4006 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004007 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4008 RPM_VREG_PIN_FN_8660_ENABLE, \
4009 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004010 _sleep_selectable, _always_on)
4011
David Collins6f032ba2011-08-31 14:08:15 -07004012#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4013 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004014 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4015 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4016 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4017 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4018 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004019 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4020 RPM_VREG_PIN_FN_8660_ENABLE, \
4021 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4022 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004023
David Collins6f032ba2011-08-31 14:08:15 -07004024#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004025 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4026 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004027 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4028 RPM_VREG_PIN_FN_8660_ENABLE, \
4029 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4030 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004031
David Collins6f032ba2011-08-31 14:08:15 -07004032#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004033 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4034 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004035 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4036 RPM_VREG_PIN_FN_8660_ENABLE, \
4037 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4038 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004039
David Collins6f032ba2011-08-31 14:08:15 -07004040#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4041#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4042#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4043#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4044#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045
David Collins6f032ba2011-08-31 14:08:15 -07004046/* RPM early regulator constraints */
4047static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4048 /* ID a_on pd ss min_uV max_uV init_ip freq */
4049 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
4050 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004051};
4052
David Collins6f032ba2011-08-31 14:08:15 -07004053/* RPM regulator constraints */
4054static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4055 /* ID a_on pd ss min_uV max_uV init_ip */
4056 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4057 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4058 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4059 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4060 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4061 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4062 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4063 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4064 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4065 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4066 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4067 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4068 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4069 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4070 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4071 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4072 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4073 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4074 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4075 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4076 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4077 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4078 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4079 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4080 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4081 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004082
David Collins6f032ba2011-08-31 14:08:15 -07004083 /* ID a_on pd ss min_uV max_uV init_ip freq */
4084 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4085 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4086 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4087
4088 /* ID a_on pd ss */
4089 RPM_VS(PM8058_LVS0, 0, 1, 0),
4090 RPM_VS(PM8058_LVS1, 0, 1, 0),
4091
4092 /* ID a_on pd ss min_uV max_uV */
4093 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4094
4095 /* ID a_on pd ss min_uV max_uV init_ip */
4096 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4097 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4098 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4099 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4100 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4101 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4102 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4103
4104 /* ID a_on pd ss min_uV max_uV init_ip freq */
4105 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4106 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4107 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4108
4109 /* ID a_on pd ss */
4110 RPM_VS(PM8901_LVS0, 1, 1, 0),
4111 RPM_VS(PM8901_LVS1, 0, 1, 0),
4112 RPM_VS(PM8901_LVS2, 0, 1, 0),
4113 RPM_VS(PM8901_LVS3, 0, 1, 0),
4114 RPM_VS(PM8901_MVS0, 0, 1, 0),
4115
4116 /* ID a_on pin_func pin_ctrl */
4117 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4118 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4119 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4120 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4121 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4122 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4123};
4124
4125static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4126 .init_data = rpm_regulator_early_init_data,
4127 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4128 .version = RPM_VREG_VERSION_8660,
4129 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4130 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4131};
4132
4133static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4134 .init_data = rpm_regulator_init_data,
4135 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4136 .version = RPM_VREG_VERSION_8660,
4137};
4138
4139static struct platform_device rpm_regulator_early_device = {
4140 .name = "rpm-regulator",
4141 .id = 0,
4142 .dev = {
4143 .platform_data = &rpm_regulator_early_pdata,
4144 },
4145};
4146
4147static struct platform_device rpm_regulator_device = {
4148 .name = "rpm-regulator",
4149 .id = 1,
4150 .dev = {
4151 .platform_data = &rpm_regulator_pdata,
4152 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004153};
4154
4155static struct platform_device *early_regulators[] __initdata = {
4156 &msm_device_saw_s0,
4157 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004158 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004159};
4160
4161static struct platform_device *early_devices[] __initdata = {
4162#ifdef CONFIG_MSM_BUS_SCALING
4163 &msm_bus_apps_fabric,
4164 &msm_bus_sys_fabric,
4165 &msm_bus_mm_fabric,
4166 &msm_bus_sys_fpb,
4167 &msm_bus_cpss_fpb,
4168#endif
4169 &msm_device_dmov_adm0,
4170 &msm_device_dmov_adm1,
4171};
4172
4173#if (defined(CONFIG_MARIMBA_CORE)) && \
4174 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4175
4176static int bluetooth_power(int);
4177static struct platform_device msm_bt_power_device = {
4178 .name = "bt_power",
4179 .id = -1,
4180 .dev = {
4181 .platform_data = &bluetooth_power,
4182 },
4183};
4184#endif
4185
4186static struct platform_device msm_tsens_device = {
4187 .name = "tsens-tm",
4188 .id = -1,
4189};
4190
4191static struct platform_device *rumi_sim_devices[] __initdata = {
4192 &smc91x_device,
4193 &msm_device_uart_dm12,
4194#ifdef CONFIG_I2C_QUP
4195 &msm_gsbi3_qup_i2c_device,
4196 &msm_gsbi4_qup_i2c_device,
4197 &msm_gsbi7_qup_i2c_device,
4198 &msm_gsbi8_qup_i2c_device,
4199 &msm_gsbi9_qup_i2c_device,
4200 &msm_gsbi12_qup_i2c_device,
4201#endif
4202#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004203 &msm_device_ssbi3,
4204#endif
4205#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004206#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004207 &android_pmem_device,
4208 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004209 &android_pmem_smipool_device,
4210#endif
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004211 &android_pmem_audio_device,
4212#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004213#ifdef CONFIG_MSM_ROTATOR
4214 &msm_rotator_device,
4215#endif
4216 &msm_fb_device,
4217 &msm_kgsl_3d0,
4218 &msm_kgsl_2d0,
4219 &msm_kgsl_2d1,
4220 &lcdc_samsung_panel_device,
4221#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4222 &hdmi_msm_device,
4223#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4224#ifdef CONFIG_MSM_CAMERA
4225#ifdef CONFIG_MT9E013
4226 &msm_camera_sensor_mt9e013,
4227#endif
4228#ifdef CONFIG_IMX074
4229 &msm_camera_sensor_imx074,
4230#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004231#ifdef CONFIG_VX6953
4232 &msm_camera_sensor_vx6953,
4233#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004234#ifdef CONFIG_WEBCAM_OV7692
4235 &msm_camera_sensor_webcam_ov7692,
4236#endif
4237#ifdef CONFIG_WEBCAM_OV9726
4238 &msm_camera_sensor_webcam_ov9726,
4239#endif
4240#ifdef CONFIG_QS_S5K4E1
4241 &msm_camera_sensor_qs_s5k4e1,
4242#endif
4243#endif
4244#ifdef CONFIG_MSM_GEMINI
4245 &msm_gemini_device,
4246#endif
4247#ifdef CONFIG_MSM_VPE
4248 &msm_vpe_device,
4249#endif
4250 &msm_device_vidc,
4251};
4252
4253#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4254enum {
4255 SX150X_CORE,
4256 SX150X_DOCKING,
4257 SX150X_SURF,
4258 SX150X_LEFT_FHA,
4259 SX150X_RIGHT_FHA,
4260 SX150X_SOUTH,
4261 SX150X_NORTH,
4262 SX150X_CORE_FLUID,
4263};
4264
4265static struct sx150x_platform_data sx150x_data[] __initdata = {
4266 [SX150X_CORE] = {
4267 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4268 .oscio_is_gpo = false,
4269 .io_pullup_ena = 0x0c08,
4270 .io_pulldn_ena = 0x4060,
4271 .io_open_drain_ena = 0x000c,
4272 .io_polarity = 0,
4273 .irq_summary = -1, /* see fixup_i2c_configs() */
4274 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4275 },
4276 [SX150X_DOCKING] = {
4277 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4278 .oscio_is_gpo = false,
4279 .io_pullup_ena = 0x5e06,
4280 .io_pulldn_ena = 0x81b8,
4281 .io_open_drain_ena = 0,
4282 .io_polarity = 0,
4283 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4284 UI_INT2_N),
4285 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4286 GPIO_DOCKING_EXPANDER_BASE -
4287 GPIO_EXPANDER_GPIO_BASE,
4288 },
4289 [SX150X_SURF] = {
4290 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4291 .oscio_is_gpo = false,
4292 .io_pullup_ena = 0,
4293 .io_pulldn_ena = 0,
4294 .io_open_drain_ena = 0,
4295 .io_polarity = 0,
4296 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4297 UI_INT1_N),
4298 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4299 GPIO_SURF_EXPANDER_BASE -
4300 GPIO_EXPANDER_GPIO_BASE,
4301 },
4302 [SX150X_LEFT_FHA] = {
4303 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4304 .oscio_is_gpo = false,
4305 .io_pullup_ena = 0,
4306 .io_pulldn_ena = 0x40,
4307 .io_open_drain_ena = 0,
4308 .io_polarity = 0,
4309 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4310 UI_INT3_N),
4311 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4312 GPIO_LEFT_KB_EXPANDER_BASE -
4313 GPIO_EXPANDER_GPIO_BASE,
4314 },
4315 [SX150X_RIGHT_FHA] = {
4316 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4317 .oscio_is_gpo = true,
4318 .io_pullup_ena = 0,
4319 .io_pulldn_ena = 0,
4320 .io_open_drain_ena = 0,
4321 .io_polarity = 0,
4322 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4323 UI_INT3_N),
4324 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4325 GPIO_RIGHT_KB_EXPANDER_BASE -
4326 GPIO_EXPANDER_GPIO_BASE,
4327 },
4328 [SX150X_SOUTH] = {
4329 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4330 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4331 GPIO_SOUTH_EXPANDER_BASE -
4332 GPIO_EXPANDER_GPIO_BASE,
4333 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4334 },
4335 [SX150X_NORTH] = {
4336 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4337 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4338 GPIO_NORTH_EXPANDER_BASE -
4339 GPIO_EXPANDER_GPIO_BASE,
4340 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4341 .oscio_is_gpo = true,
4342 .io_open_drain_ena = 0x30,
4343 },
4344 [SX150X_CORE_FLUID] = {
4345 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4346 .oscio_is_gpo = false,
4347 .io_pullup_ena = 0x0408,
4348 .io_pulldn_ena = 0x4060,
4349 .io_open_drain_ena = 0x0008,
4350 .io_polarity = 0,
4351 .irq_summary = -1, /* see fixup_i2c_configs() */
4352 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4353 },
4354};
4355
4356#ifdef CONFIG_SENSORS_MSM_ADC
4357/* Configuration of EPM expander is done when client
4358 * request an adc read
4359 */
4360static struct sx150x_platform_data sx150x_epmdata = {
4361 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4362 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4363 GPIO_EPM_EXPANDER_BASE -
4364 GPIO_EXPANDER_GPIO_BASE,
4365 .irq_summary = -1,
4366};
4367#endif
4368
4369/* sx150x_low_power_cfg
4370 *
4371 * This data and init function are used to put unused gpio-expander output
4372 * lines into their low-power states at boot. The init
4373 * function must be deferred until a later init stage because the i2c
4374 * gpio expander drivers do not probe until after they are registered
4375 * (see register_i2c_devices) and the work-queues for those registrations
4376 * are processed. Because these lines are unused, there is no risk of
4377 * competing with a device driver for the gpio.
4378 *
4379 * gpio lines whose low-power states are input are naturally in their low-
4380 * power configurations once probed, see the platform data structures above.
4381 */
4382struct sx150x_low_power_cfg {
4383 unsigned gpio;
4384 unsigned val;
4385};
4386
4387static struct sx150x_low_power_cfg
4388common_sx150x_lp_cfgs[] __initdata = {
4389 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4390 {GPIO_EXT_GPS_LNA_EN, 0},
4391 {GPIO_MSM_WAKES_BT, 0},
4392 {GPIO_USB_UICC_EN, 0},
4393 {GPIO_BATT_GAUGE_EN, 0},
4394};
4395
4396static struct sx150x_low_power_cfg
4397surf_ffa_sx150x_lp_cfgs[] __initdata = {
4398 {GPIO_MIPI_DSI_RST_N, 0},
4399 {GPIO_DONGLE_PWR_EN, 0},
4400 {GPIO_CAP_TS_SLEEP, 1},
4401 {GPIO_WEB_CAMIF_RESET_N, 0},
4402};
4403
4404static void __init
4405cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4406{
4407 unsigned n;
4408 int rc;
4409
4410 for (n = 0; n < nelems; ++n) {
4411 rc = gpio_request(cfgs[n].gpio, NULL);
4412 if (!rc) {
4413 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4414 gpio_free(cfgs[n].gpio);
4415 }
4416
4417 if (rc) {
4418 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4419 __func__, cfgs[n].gpio, rc);
4420 }
Steve Muckle9161d302010-02-11 11:50:40 -08004421 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004422}
4423
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004424static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004425{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004426 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4427 ARRAY_SIZE(common_sx150x_lp_cfgs));
4428 if (!machine_is_msm8x60_fluid())
4429 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4430 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4431 return 0;
4432}
4433module_init(cfg_sx150xs_low_power);
4434
4435#ifdef CONFIG_I2C
4436static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4437 {
4438 I2C_BOARD_INFO("sx1509q", 0x3e),
4439 .platform_data = &sx150x_data[SX150X_CORE]
4440 },
4441};
4442
4443static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4444 {
4445 I2C_BOARD_INFO("sx1509q", 0x3f),
4446 .platform_data = &sx150x_data[SX150X_DOCKING]
4447 },
4448};
4449
4450static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4451 {
4452 I2C_BOARD_INFO("sx1509q", 0x70),
4453 .platform_data = &sx150x_data[SX150X_SURF]
4454 }
4455};
4456
4457static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4458 {
4459 I2C_BOARD_INFO("sx1508q", 0x21),
4460 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4461 },
4462 {
4463 I2C_BOARD_INFO("sx1508q", 0x22),
4464 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4465 }
4466};
4467
4468static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4469 {
4470 I2C_BOARD_INFO("sx1508q", 0x23),
4471 .platform_data = &sx150x_data[SX150X_SOUTH]
4472 },
4473 {
4474 I2C_BOARD_INFO("sx1508q", 0x20),
4475 .platform_data = &sx150x_data[SX150X_NORTH]
4476 }
4477};
4478
4479static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4480 {
4481 I2C_BOARD_INFO("sx1509q", 0x3e),
4482 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4483 },
4484};
4485
4486#ifdef CONFIG_SENSORS_MSM_ADC
4487static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4488 {
4489 I2C_BOARD_INFO("sx1509q", 0x3e),
4490 .platform_data = &sx150x_epmdata
4491 },
4492};
4493#endif
4494#endif
4495#endif
4496
4497#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004498
4499static struct adc_access_fn xoadc_fn = {
4500 pm8058_xoadc_select_chan_and_start_conv,
4501 pm8058_xoadc_read_adc_code,
4502 pm8058_xoadc_get_properties,
4503 pm8058_xoadc_slot_request,
4504 pm8058_xoadc_restore_slot,
4505 pm8058_xoadc_calibrate,
4506};
4507
4508#if defined(CONFIG_I2C) && \
4509 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4510static struct regulator *vreg_adc_epm1;
4511
4512static struct i2c_client *epm_expander_i2c_register_board(void)
4513
4514{
4515 struct i2c_adapter *i2c_adap;
4516 struct i2c_client *client = NULL;
4517 i2c_adap = i2c_get_adapter(0x0);
4518
4519 if (i2c_adap == NULL)
4520 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4521
4522 if (i2c_adap != NULL)
4523 client = i2c_new_device(i2c_adap,
4524 &fluid_expanders_i2c_epm_info[0]);
4525 return client;
4526
4527}
4528
4529static unsigned int msm_adc_gpio_configure_expander_enable(void)
4530{
4531 int rc = 0;
4532 static struct i2c_client *epm_i2c_client;
4533
4534 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4535
4536 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4537
4538 if (IS_ERR(vreg_adc_epm1)) {
4539 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4540 return 0;
4541 }
4542
4543 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4544 if (rc)
4545 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4546 "regulator set voltage failed\n");
4547
4548 rc = regulator_enable(vreg_adc_epm1);
4549 if (rc) {
4550 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4551 "Error while enabling regulator for epm s3 %d\n", rc);
4552 return rc;
4553 }
4554
4555 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4556 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4557
4558 msleep(1000);
4559
4560 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4561 if (!rc) {
4562 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4563 "Configure 5v boost\n");
4564 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4565 } else {
4566 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4567 "Error for epm 5v boost en\n");
4568 goto exit_vreg_epm;
4569 }
4570
4571 msleep(500);
4572
4573 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4574 if (!rc) {
4575 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4576 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4577 "Configure epm 3.3v\n");
4578 } else {
4579 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4580 "Error for gpio 3.3ven\n");
4581 goto exit_vreg_epm;
4582 }
4583 msleep(500);
4584
4585 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4586 "Trying to request EPM LVLSFT_EN\n");
4587 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4588 if (!rc) {
4589 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4590 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4591 "Configure the lvlsft\n");
4592 } else {
4593 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4594 "Error for epm lvlsft_en\n");
4595 goto exit_vreg_epm;
4596 }
4597
4598 msleep(500);
4599
4600 if (!epm_i2c_client)
4601 epm_i2c_client = epm_expander_i2c_register_board();
4602
4603 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4604 if (!rc)
4605 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4606 if (rc) {
4607 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4608 ": GPIO PWR MON Enable issue\n");
4609 goto exit_vreg_epm;
4610 }
4611
4612 msleep(1000);
4613
4614 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4615 if (!rc) {
4616 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4617 if (rc) {
4618 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4619 ": ADC1_PWDN error direction out\n");
4620 goto exit_vreg_epm;
4621 }
4622 }
4623
4624 msleep(100);
4625
4626 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4627 if (!rc) {
4628 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4629 if (rc) {
4630 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4631 ": ADC2_PWD error direction out\n");
4632 goto exit_vreg_epm;
4633 }
4634 }
4635
4636 msleep(1000);
4637
4638 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4639 if (!rc) {
4640 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4641 if (rc) {
4642 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4643 "Gpio request problem %d\n", rc);
4644 goto exit_vreg_epm;
4645 }
4646 }
4647
4648 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4649 if (!rc) {
4650 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4651 if (rc) {
4652 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4653 ": EPM_SPI_ADC1_CS_N error\n");
4654 goto exit_vreg_epm;
4655 }
4656 }
4657
4658 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4659 if (!rc) {
4660 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4661 if (rc) {
4662 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4663 ": EPM_SPI_ADC2_Cs_N error\n");
4664 goto exit_vreg_epm;
4665 }
4666 }
4667
4668 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4669 "the power monitor reset for epm\n");
4670
4671 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4672 if (!rc) {
4673 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4674 if (rc) {
4675 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4676 ": Error in the power mon reset\n");
4677 goto exit_vreg_epm;
4678 }
4679 }
4680
4681 msleep(1000);
4682
4683 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4684
4685 msleep(500);
4686
4687 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4688
4689 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4690
4691 return rc;
4692
4693exit_vreg_epm:
4694 regulator_disable(vreg_adc_epm1);
4695
4696 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4697 " rc = %d.\n", rc);
4698 return rc;
4699};
4700
4701static unsigned int msm_adc_gpio_configure_expander_disable(void)
4702{
4703 int rc = 0;
4704
4705 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4706 gpio_free(GPIO_PWR_MON_RESET_N);
4707
4708 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4709 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4710
4711 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4712 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4713
4714 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4715 gpio_free(GPIO_PWR_MON_START);
4716
4717 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4718 gpio_free(GPIO_ADC1_PWDN_N);
4719
4720 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4721 gpio_free(GPIO_ADC2_PWDN_N);
4722
4723 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4724 gpio_free(GPIO_PWR_MON_ENABLE);
4725
4726 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4727 gpio_free(GPIO_EPM_LVLSFT_EN);
4728
4729 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4730 gpio_free(GPIO_EPM_5V_BOOST_EN);
4731
4732 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4733 gpio_free(GPIO_EPM_3_3V_EN);
4734
4735 rc = regulator_disable(vreg_adc_epm1);
4736 if (rc)
4737 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4738 "Error while enabling regulator for epm s3 %d\n", rc);
4739 regulator_put(vreg_adc_epm1);
4740
4741 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4742 return rc;
4743};
4744
4745unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4746{
4747 int rc = 0;
4748
4749 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4750 cs_enable);
4751
4752 if (cs_enable < 16) {
4753 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4754 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4755 } else {
4756 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4757 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4758 }
4759 return rc;
4760};
4761
4762unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4763{
4764 int rc = 0;
4765
4766 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4767
4768 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4769
4770 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4771
4772 return rc;
4773};
4774#endif
4775
4776static struct msm_adc_channels msm_adc_channels_data[] = {
4777 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4778 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4779 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4780 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4781 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4782 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4783 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4784 CHAN_PATH_TYPE4,
4785 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4786 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4787 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4788 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4789 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4790 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4791 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4792 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4793 CHAN_PATH_TYPE12,
4794 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4795 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4796 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4797 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4798 CHAN_PATH_TYPE_NONE,
4799 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4800 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4801 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4802 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4803 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4804 scale_xtern_chgr_cur},
4805 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4806 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4807 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4808 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4809 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4810 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4811 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4812 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4813 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4814 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4815 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4816 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4817};
4818
4819static char *msm_adc_fluid_device_names[] = {
4820 "ADS_ADC1",
4821 "ADS_ADC2",
4822};
4823
4824static struct msm_adc_platform_data msm_adc_pdata = {
4825 .channel = msm_adc_channels_data,
4826 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4827#if defined(CONFIG_I2C) && \
4828 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4829 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4830 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4831 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4832 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4833#endif
4834};
4835
4836static struct platform_device msm_adc_device = {
4837 .name = "msm_adc",
4838 .id = -1,
4839 .dev = {
4840 .platform_data = &msm_adc_pdata,
4841 },
4842};
4843
4844static void pmic8058_xoadc_mpp_config(void)
4845{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304846 int rc, i;
4847 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304848 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304849 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304850 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304851 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304852 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304853 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304854 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304855 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304856 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304857 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304858 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4859 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304860 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004861
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304862 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4863 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4864 &xoadc_mpps[i].config);
4865 if (rc) {
4866 pr_err("%s: Config MPP %d of PM8058 failed\n",
4867 __func__, xoadc_mpps[i].mpp);
4868 }
4869 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004870}
4871
4872static struct regulator *vreg_ldo18_adc;
4873
4874static int pmic8058_xoadc_vreg_config(int on)
4875{
4876 int rc;
4877
4878 if (on) {
4879 rc = regulator_enable(vreg_ldo18_adc);
4880 if (rc)
4881 pr_err("%s: Enable of regulator ldo18_adc "
4882 "failed\n", __func__);
4883 } else {
4884 rc = regulator_disable(vreg_ldo18_adc);
4885 if (rc)
4886 pr_err("%s: Disable of regulator ldo18_adc "
4887 "failed\n", __func__);
4888 }
4889
4890 return rc;
4891}
4892
4893static int pmic8058_xoadc_vreg_setup(void)
4894{
4895 int rc;
4896
4897 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4898 if (IS_ERR(vreg_ldo18_adc)) {
4899 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4900 __func__, PTR_ERR(vreg_ldo18_adc));
4901 rc = PTR_ERR(vreg_ldo18_adc);
4902 goto fail;
4903 }
4904
4905 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4906 if (rc) {
4907 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4908 goto fail;
4909 }
4910
4911 return rc;
4912fail:
4913 regulator_put(vreg_ldo18_adc);
4914 return rc;
4915}
4916
4917static void pmic8058_xoadc_vreg_shutdown(void)
4918{
4919 regulator_put(vreg_ldo18_adc);
4920}
4921
4922/* usec. For this ADC,
4923 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4924 * Each channel has different configuration, thus at the time of starting
4925 * the conversion, xoadc will return actual conversion time
4926 * */
4927static struct adc_properties pm8058_xoadc_data = {
4928 .adc_reference = 2200, /* milli-voltage for this adc */
4929 .bitresolution = 15,
4930 .bipolar = 0,
4931 .conversiontime = 54,
4932};
4933
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304934static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004935 .xoadc_prop = &pm8058_xoadc_data,
4936 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4937 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4938 .xoadc_num = XOADC_PMIC_0,
4939 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4940 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4941};
4942#endif
4943
4944#ifdef CONFIG_MSM_SDIO_AL
4945
4946static unsigned mdm2ap_status = 140;
4947
4948static int configure_mdm2ap_status(int on)
4949{
4950 int ret = 0;
4951 if (on)
4952 ret = msm_gpiomux_get(mdm2ap_status);
4953 else
4954 ret = msm_gpiomux_put(mdm2ap_status);
4955
4956 if (ret)
4957 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4958 on);
4959
4960 return ret;
4961}
4962
4963
4964static int get_mdm2ap_status(void)
4965{
4966 return gpio_get_value(mdm2ap_status);
4967}
4968
4969static struct sdio_al_platform_data sdio_al_pdata = {
4970 .config_mdm2ap_status = configure_mdm2ap_status,
4971 .get_mdm2ap_status = get_mdm2ap_status,
4972 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004973 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004974 .peer_sdioc_version_major = 0x0004,
4975 .peer_sdioc_boot_version_minor = 0x0001,
4976 .peer_sdioc_boot_version_major = 0x0003
4977};
4978
4979struct platform_device msm_device_sdio_al = {
4980 .name = "msm_sdio_al",
4981 .id = -1,
4982 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004983 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004984 .platform_data = &sdio_al_pdata,
4985 },
4986};
4987
4988#endif /* CONFIG_MSM_SDIO_AL */
4989
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304990#define GPIO_VREG_ID_EXT_5V 0
4991
4992static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4993 REGULATOR_SUPPLY("ext_5v", NULL),
4994 REGULATOR_SUPPLY("8901_mpp0", NULL),
4995};
4996
4997#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4998 [GPIO_VREG_ID_##_id] = { \
4999 .init_data = { \
5000 .constraints = { \
5001 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5002 }, \
5003 .num_consumer_supplies = \
5004 ARRAY_SIZE(vreg_consumers_##_id), \
5005 .consumer_supplies = vreg_consumers_##_id, \
5006 }, \
5007 .regulator_name = _reg_name, \
5008 .active_low = _active_low, \
5009 .gpio_label = _gpio_label, \
5010 .gpio = _gpio, \
5011 }
5012
5013/* GPIO regulator constraints */
5014static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5015 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5016 PM8901_MPP_PM_TO_SYS(0), 0),
5017};
5018
5019/* GPIO regulator */
5020static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5021 .name = GPIO_REGULATOR_DEV_NAME,
5022 .id = PM8901_MPP_PM_TO_SYS(0),
5023 .dev = {
5024 .platform_data =
5025 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5026 },
5027};
5028
5029static void __init pm8901_vreg_mpp0_init(void)
5030{
5031 int rc;
5032
5033 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5034 .mpp = PM8901_MPP_PM_TO_SYS(0),
5035 .config = {
5036 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5037 .level = PM8901_MPP_DIG_LEVEL_VPH,
5038 },
5039 };
5040
5041 /*
5042 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5043 * implies that the regulator connected to MPP0 is enabled when
5044 * MPP0 is low.
5045 */
5046 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5047 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5048 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5049 } else {
5050 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5051 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5052 }
5053
5054 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5055 if (rc)
5056 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5057}
5058
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005059static struct platform_device *charm_devices[] __initdata = {
5060 &msm_charm_modem,
5061#ifdef CONFIG_MSM_SDIO_AL
5062 &msm_device_sdio_al,
5063#endif
5064};
5065
Lei Zhou338cab82011-08-19 13:38:17 -04005066#ifdef CONFIG_SND_SOC_MSM8660_APQ
5067static struct platform_device *dragon_alsa_devices[] __initdata = {
5068 &msm_pcm,
5069 &msm_pcm_routing,
5070 &msm_cpudai0,
5071 &msm_cpudai1,
5072 &msm_cpudai_hdmi_rx,
5073 &msm_cpudai_bt_rx,
5074 &msm_cpudai_bt_tx,
5075 &msm_cpudai_fm_rx,
5076 &msm_cpudai_fm_tx,
5077 &msm_cpu_fe,
5078 &msm_stub_codec,
5079 &msm_lpa_pcm,
5080};
5081#endif
5082
5083static struct platform_device *asoc_devices[] __initdata = {
5084 &asoc_msm_pcm,
5085 &asoc_msm_dai0,
5086 &asoc_msm_dai1,
5087};
5088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005089static struct platform_device *surf_devices[] __initdata = {
5090 &msm_device_smd,
5091 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005092 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005093 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005094 &msm_pil_tzapps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005095#ifdef CONFIG_I2C_QUP
5096 &msm_gsbi3_qup_i2c_device,
5097 &msm_gsbi4_qup_i2c_device,
5098 &msm_gsbi7_qup_i2c_device,
5099 &msm_gsbi8_qup_i2c_device,
5100 &msm_gsbi9_qup_i2c_device,
5101 &msm_gsbi12_qup_i2c_device,
5102#endif
5103#ifdef CONFIG_SERIAL_MSM_HS
5104 &msm_device_uart_dm1,
5105#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305106#ifdef CONFIG_MSM_SSBI
5107 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305108 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305109#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005110#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005111 &msm_device_ssbi3,
5112#endif
5113#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5114 &isp1763_device,
5115#endif
5116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005117#if defined (CONFIG_MSM_8x60_VOIP)
5118 &asoc_msm_mvs,
5119 &asoc_mvs_dai0,
5120 &asoc_mvs_dai1,
5121#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005123#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
5124 &msm_device_otg,
5125#endif
5126#ifdef CONFIG_USB_GADGET_MSM_72K
5127 &msm_device_gadget_peripheral,
5128#endif
5129#ifdef CONFIG_USB_G_ANDROID
5130 &android_usb_device,
5131#endif
5132#ifdef CONFIG_BATTERY_MSM
5133 &msm_batt_device,
5134#endif
5135#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005136#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005137 &android_pmem_device,
5138 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005139 &android_pmem_smipool_device,
5140#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005141 &android_pmem_audio_device,
5142#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005143#ifdef CONFIG_MSM_ROTATOR
5144 &msm_rotator_device,
5145#endif
5146 &msm_fb_device,
5147 &msm_kgsl_3d0,
5148 &msm_kgsl_2d0,
5149 &msm_kgsl_2d1,
5150 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005151#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5152 &lcdc_nt35582_panel_device,
5153#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005154#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5155 &lcdc_samsung_oled_panel_device,
5156#endif
5157#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5158 &lcdc_auo_wvga_panel_device,
5159#endif
5160#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5161 &hdmi_msm_device,
5162#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5163#ifdef CONFIG_FB_MSM_MIPI_DSI
5164 &mipi_dsi_toshiba_panel_device,
5165 &mipi_dsi_novatek_panel_device,
5166#endif
5167#ifdef CONFIG_MSM_CAMERA
5168#ifdef CONFIG_MT9E013
5169 &msm_camera_sensor_mt9e013,
5170#endif
5171#ifdef CONFIG_IMX074
5172 &msm_camera_sensor_imx074,
5173#endif
5174#ifdef CONFIG_WEBCAM_OV7692
5175 &msm_camera_sensor_webcam_ov7692,
5176#endif
5177#ifdef CONFIG_WEBCAM_OV9726
5178 &msm_camera_sensor_webcam_ov9726,
5179#endif
5180#ifdef CONFIG_QS_S5K4E1
5181 &msm_camera_sensor_qs_s5k4e1,
5182#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005183#ifdef CONFIG_VX6953
5184 &msm_camera_sensor_vx6953,
5185#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005186#endif
5187#ifdef CONFIG_MSM_GEMINI
5188 &msm_gemini_device,
5189#endif
5190#ifdef CONFIG_MSM_VPE
5191 &msm_vpe_device,
5192#endif
5193
5194#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
5195 &msm_rpm_log_device,
5196#endif
5197#if defined(CONFIG_MSM_RPM_STATS_LOG)
5198 &msm_rpm_stat_device,
5199#endif
5200 &msm_device_vidc,
5201#if (defined(CONFIG_MARIMBA_CORE)) && \
5202 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5203 &msm_bt_power_device,
5204#endif
5205#ifdef CONFIG_SENSORS_MSM_ADC
5206 &msm_adc_device,
5207#endif
David Collins6f032ba2011-08-31 14:08:15 -07005208 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005209
5210#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5211 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5212 &qcrypto_device,
5213#endif
5214
5215#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5216 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5217 &qcedev_device,
5218#endif
5219
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005220
5221#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5222#ifdef CONFIG_MSM_USE_TSIF1
5223 &msm_device_tsif[1],
5224#else
5225 &msm_device_tsif[0],
5226#endif /* CONFIG_MSM_USE_TSIF1 */
5227#endif /* CONFIG_TSIF */
5228
5229#ifdef CONFIG_HW_RANDOM_MSM
5230 &msm_device_rng,
5231#endif
5232
5233 &msm_tsens_device,
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06005234 &msm_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005235#ifdef CONFIG_ION_MSM
5236 &ion_dev,
5237#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005238 &msm8660_device_watchdog,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005239};
5240
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005241#ifdef CONFIG_ION_MSM
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005242static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005243 .nr = MSM_ION_HEAP_NUM,
5244 .heaps = {
5245 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005246 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005247 .type = ION_HEAP_TYPE_SYSTEM,
5248 .name = ION_VMALLOC_HEAP_NAME,
5249 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005250#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5251 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005252 .id = ION_SF_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005253 .type = ION_HEAP_TYPE_CARVEOUT,
Olav Hauganb5be7992011-11-18 14:29:02 -08005254 .name = ION_SF_HEAP_NAME,
5255 .size = MSM_ION_SF_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005256 .memory_type = ION_EBI_TYPE,
5257 },
5258 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005259 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005260 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005261 .name = ION_MM_HEAP_NAME,
5262 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005263 .memory_type = ION_SMI_TYPE,
Olav Hauganee0f7802011-12-19 13:28:57 -08005264 .request_region = request_smi_region,
5265 .release_region = release_smi_region,
5266 .setup_region = setup_smi_region,
Olav Haugan0a852512012-01-09 10:20:55 -08005267 .permission_type = IPT_TYPE_MM_CARVEOUT,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005268 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005269 {
5270 .id = ION_CAMERA_HEAP_ID,
5271 .type = ION_HEAP_TYPE_CARVEOUT,
5272 .name = ION_CAMERA_HEAP_NAME,
5273 .size = MSM_ION_CAMERA_SIZE,
5274 .memory_type = ION_EBI_TYPE,
5275 },
5276 {
5277 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005278 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005279 .name = ION_MFC_HEAP_NAME,
5280 .size = MSM_ION_MFC_SIZE,
5281 .memory_type = ION_SMI_TYPE,
5282 .request_region = request_smi_region,
5283 .release_region = release_smi_region,
5284 .setup_region = setup_smi_region,
Olav Haugan0a852512012-01-09 10:20:55 -08005285 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Hauganb5be7992011-11-18 14:29:02 -08005286 },
5287 {
5288 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005289 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005290 .name = ION_WB_HEAP_NAME,
5291 .size = MSM_ION_WB_SIZE,
5292 .memory_type = ION_EBI_TYPE,
Olav Haugan0a852512012-01-09 10:20:55 -08005293 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Hauganb5be7992011-11-18 14:29:02 -08005294 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005295#endif
5296 }
5297};
5298
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005299static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005300 .name = "ion-msm",
5301 .id = 1,
5302 .dev = { .platform_data = &ion_pdata },
5303};
5304#endif
5305
5306
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005307static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5308 /* Kernel SMI memory pool for video core, used for firmware */
5309 /* and encoder, decoder scratch buffers */
5310 /* Kernel SMI memory pool should always precede the user space */
5311 /* SMI memory pool, as the video core will use offset address */
5312 /* from the Firmware base */
5313 [MEMTYPE_SMI_KERNEL] = {
5314 .start = KERNEL_SMI_BASE,
5315 .limit = KERNEL_SMI_SIZE,
5316 .size = KERNEL_SMI_SIZE,
5317 .flags = MEMTYPE_FLAGS_FIXED,
5318 },
5319 /* User space SMI memory pool for video core */
5320 /* used for encoder, decoder input & output buffers */
5321 [MEMTYPE_SMI] = {
5322 .start = USER_SMI_BASE,
5323 .limit = USER_SMI_SIZE,
5324 .flags = MEMTYPE_FLAGS_FIXED,
5325 },
5326 [MEMTYPE_EBI0] = {
5327 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5328 },
5329 [MEMTYPE_EBI1] = {
5330 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5331 },
5332};
5333
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005334static void reserve_ion_memory(void)
5335{
5336#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Olav Hauganb5be7992011-11-18 14:29:02 -08005337 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
5338 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5339 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5340 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5341 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005342#endif
5343}
5344
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005345static void __init size_pmem_devices(void)
5346{
5347#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005348#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005349 android_pmem_adsp_pdata.size = pmem_adsp_size;
5350 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005351 android_pmem_pdata.size = pmem_sf_size;
5352#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005353 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
5354#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005355}
5356
5357static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5358{
5359 msm8x60_reserve_table[p->memory_type].size += p->size;
5360}
5361
5362static void __init reserve_pmem_memory(void)
5363{
5364#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005365#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005366 reserve_memory_for(&android_pmem_adsp_pdata);
5367 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005368 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005369#endif
5370 reserve_memory_for(&android_pmem_audio_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005371 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
5372#endif
5373}
5374
Huaibin Yanga5419422011-12-08 23:52:10 -08005375static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005376
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005377static void __init msm8x60_calculate_reserve_sizes(void)
5378{
5379 size_pmem_devices();
5380 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005381 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005382 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005383}
5384
5385static int msm8x60_paddr_to_memtype(unsigned int paddr)
5386{
5387 if (paddr >= 0x40000000 && paddr < 0x60000000)
5388 return MEMTYPE_EBI1;
5389 if (paddr >= 0x38000000 && paddr < 0x40000000)
5390 return MEMTYPE_SMI;
5391 return MEMTYPE_NONE;
5392}
5393
5394static struct reserve_info msm8x60_reserve_info __initdata = {
5395 .memtype_reserve_table = msm8x60_reserve_table,
5396 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5397 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5398};
5399
5400static void __init msm8x60_reserve(void)
5401{
5402 reserve_info = &msm8x60_reserve_info;
5403 msm_reserve();
5404}
5405
5406#define EXT_CHG_VALID_MPP 10
5407#define EXT_CHG_VALID_MPP_2 11
5408
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305409static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305410 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305411 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305412 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305413 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5414};
5415
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005416#ifdef CONFIG_ISL9519_CHARGER
5417static int isl_detection_setup(void)
5418{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305419 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005420
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305421 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5422 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5423 &isl_mpp[i].config);
5424 if (ret) {
5425 pr_err("%s: Config MPP %d of PM8058 failed\n",
5426 __func__, isl_mpp[i].mpp);
5427 return ret;
5428 }
5429 }
5430
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005431 return ret;
5432}
5433
5434static struct isl_platform_data isl_data __initdata = {
5435 .chgcurrent = 700,
5436 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5437 .chg_detection_config = isl_detection_setup,
5438 .max_system_voltage = 4200,
5439 .min_system_voltage = 3200,
5440 .term_current = 120,
5441 .input_current = 2048,
5442};
5443
5444static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5445 {
5446 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305447 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005448 .platform_data = &isl_data,
5449 },
5450};
5451#endif
5452
5453#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5454static int smb137b_detection_setup(void)
5455{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305456 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005457
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305458 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5459 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5460 &isl_mpp[i].config);
5461 if (ret) {
5462 pr_err("%s: Config MPP %d of PM8058 failed\n",
5463 __func__, isl_mpp[i].mpp);
5464 return ret;
5465 }
5466 }
5467
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005468 return ret;
5469}
5470
5471static struct smb137b_platform_data smb137b_data __initdata = {
5472 .chg_detection_config = smb137b_detection_setup,
5473 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5474 .batt_mah_rating = 950,
5475};
5476
5477static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5478 {
5479 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305480 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005481 .platform_data = &smb137b_data,
5482 },
5483};
5484#endif
5485
5486#ifdef CONFIG_PMIC8058
5487#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305488#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005489
5490static int pm8058_gpios_init(void)
5491{
5492 int i;
5493 int rc;
5494 struct pm8058_gpio_cfg {
5495 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305496 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 };
5498
5499 struct pm8058_gpio_cfg gpio_cfgs[] = {
5500 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305501 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005502 {
5503 .direction = PM_GPIO_DIR_IN,
5504 .pull = PM_GPIO_PULL_DN,
5505 .vin_sel = 2,
5506 .function = PM_GPIO_FUNC_NORMAL,
5507 .inv_int_pol = 0,
5508 },
5509 },
5510#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5511 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305512 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005513 {
5514 .direction = PM_GPIO_DIR_IN,
5515 .pull = PM_GPIO_PULL_UP_30,
5516 .vin_sel = 2,
5517 .function = PM_GPIO_FUNC_NORMAL,
5518 .inv_int_pol = 0,
5519 },
5520 },
5521#endif
5522 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305523 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005524 {
5525 .direction = PM_GPIO_DIR_IN,
5526 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305527 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005528 .function = PM_GPIO_FUNC_NORMAL,
5529 .inv_int_pol = 0,
5530 },
5531 },
5532 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305533 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005534 {
5535 .direction = PM_GPIO_DIR_IN,
5536 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305537 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005538 .function = PM_GPIO_FUNC_NORMAL,
5539 .inv_int_pol = 0,
5540 },
5541 },
5542 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305543 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005544 {
5545 .direction = PM_GPIO_DIR_IN,
5546 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305547 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005548 .function = PM_GPIO_FUNC_NORMAL,
5549 .inv_int_pol = 0,
5550 },
5551 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005552 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305553 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005554 {
5555 .direction = PM_GPIO_DIR_OUT,
5556 .output_value = 1,
5557 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5558 .pull = PM_GPIO_PULL_DN,
5559 .out_strength = PM_GPIO_STRENGTH_HIGH,
5560 .function = PM_GPIO_FUNC_NORMAL,
5561 .vin_sel = 2,
5562 .inv_int_pol = 0,
5563 }
5564 },
5565 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305566 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005567 {
5568 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305569 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005570 .function = PM_GPIO_FUNC_NORMAL,
5571 .vin_sel = 2,
5572 .inv_int_pol = 0,
5573 }
5574 },
5575 };
5576
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305577#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5578 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305579 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305580 .direction = PM_GPIO_DIR_IN,
5581 .pull = PM_GPIO_PULL_UP_1P5,
5582 .vin_sel = 2,
5583 .function = PM_GPIO_FUNC_NORMAL,
5584 };
5585#endif
5586
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305588 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305589 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305590 .direction = PM_GPIO_DIR_OUT,
5591 .pull = PM_GPIO_PULL_NO,
5592 .out_strength = PM_GPIO_STRENGTH_HIGH,
5593 .function = PM_GPIO_FUNC_NORMAL,
5594 .inv_int_pol = 0,
5595 .vin_sel = 2,
5596 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5597 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005598 };
5599#endif
5600
5601#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5602 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305603 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 {
5605 .direction = PM_GPIO_DIR_IN,
5606 .pull = PM_GPIO_PULL_UP_1P5,
5607 .vin_sel = 2,
5608 .function = PM_GPIO_FUNC_NORMAL,
5609 .inv_int_pol = 0,
5610 }
5611 };
5612#endif
5613
5614#if defined(CONFIG_QS_S5K4E1)
5615 {
5616 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305617 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005618 {
5619 .direction = PM_GPIO_DIR_OUT,
5620 .output_value = 0,
5621 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5622 .pull = PM_GPIO_PULL_DN,
5623 .out_strength = PM_GPIO_STRENGTH_HIGH,
5624 .function = PM_GPIO_FUNC_NORMAL,
5625 .vin_sel = 2,
5626 .inv_int_pol = 0,
5627 }
5628 };
5629#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005630#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5631 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305632 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005633 {
5634 .direction = PM_GPIO_DIR_OUT,
5635 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5636 .output_value = 1,
5637 .pull = PM_GPIO_PULL_UP_30,
5638 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305639 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005640 .out_strength = PM_GPIO_STRENGTH_HIGH,
5641 .function = PM_GPIO_FUNC_NORMAL,
5642 .inv_int_pol = 0,
5643 }
5644 };
5645#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005646#if defined(CONFIG_HAPTIC_ISA1200) || \
5647 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5648 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305649 rc = pm8xxx_gpio_config(
5650 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5651 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005652 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305653 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005654 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305655 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305656 rc = pm8xxx_gpio_config(
5657 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5658 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305659 if (rc < 0) {
5660 pr_err("%s: pmic haptics ldo gpio config failed\n",
5661 __func__);
5662 }
5663
5664 }
5665#endif
5666
5667#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5668 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5669 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5670 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305671 rc = pm8xxx_gpio_config(
5672 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5673 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305674 if (rc < 0) {
5675 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5676 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005677 }
5678 }
5679#endif
5680
5681#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5682 /* Line_in only for 8660 ffa & surf */
5683 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005684 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005685 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305686 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005687 &line_in_gpio_cfg.cfg);
5688 if (rc < 0) {
5689 pr_err("%s pmic line_in gpio config failed\n",
5690 __func__);
5691 return rc;
5692 }
5693 }
5694#endif
5695
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005696#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5697 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305698 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005699 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5700 if (rc < 0) {
5701 pr_err("%s pmic gpio config failed\n", __func__);
5702 return rc;
5703 }
5704 }
5705#endif
5706
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005707#if defined(CONFIG_QS_S5K4E1)
5708 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5709 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305710 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005711 &qs_hc37_cam_pd_gpio_cfg.cfg);
5712 if (rc < 0) {
5713 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5714 __func__);
5715 return rc;
5716 }
5717 }
5718 }
5719#endif
5720
5721 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305722 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005723 &gpio_cfgs[i].cfg);
5724 if (rc < 0) {
5725 pr_err("%s pmic gpio config failed\n",
5726 __func__);
5727 return rc;
5728 }
5729 }
5730
5731 return 0;
5732}
5733
5734static const unsigned int ffa_keymap[] = {
5735 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5736 KEY(0, 1, KEY_UP), /* NAV - UP */
5737 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5738 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5739
5740 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5741 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5742 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5743 KEY(1, 3, KEY_VOLUMEDOWN),
5744
5745 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5746
5747 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5748 KEY(4, 1, KEY_UP), /* USER_UP */
5749 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5750 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5751 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5752
5753 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5754 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5755 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5756 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5757 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5758};
5759
Zhang Chang Ken683be172011-08-10 17:45:34 -04005760static const unsigned int dragon_keymap[] = {
5761 KEY(0, 0, KEY_MENU),
5762 KEY(0, 2, KEY_1),
5763 KEY(0, 3, KEY_4),
5764 KEY(0, 4, KEY_7),
5765
5766 KEY(1, 0, KEY_UP),
5767 KEY(1, 1, KEY_LEFT),
5768 KEY(1, 2, KEY_DOWN),
5769 KEY(1, 3, KEY_5),
5770 KEY(1, 4, KEY_8),
5771
5772 KEY(2, 0, KEY_HOME),
5773 KEY(2, 1, KEY_REPLY),
5774 KEY(2, 2, KEY_2),
5775 KEY(2, 3, KEY_6),
5776 KEY(2, 4, KEY_0),
5777
5778 KEY(3, 0, KEY_VOLUMEUP),
5779 KEY(3, 1, KEY_RIGHT),
5780 KEY(3, 2, KEY_3),
5781 KEY(3, 3, KEY_9),
5782 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5783
5784 KEY(4, 0, KEY_VOLUMEDOWN),
5785 KEY(4, 1, KEY_BACK),
5786 KEY(4, 2, KEY_CAMERA),
5787 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5788};
5789
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005790static struct matrix_keymap_data ffa_keymap_data = {
5791 .keymap_size = ARRAY_SIZE(ffa_keymap),
5792 .keymap = ffa_keymap,
5793};
5794
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305795static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005796 .input_name = "ffa-keypad",
5797 .input_phys_device = "ffa-keypad/input0",
5798 .num_rows = 6,
5799 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305800 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5801 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5802 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005803 .scan_delay_ms = 32,
5804 .row_hold_ns = 91500,
5805 .wakeup = 1,
5806 .keymap_data = &ffa_keymap_data,
5807};
5808
Zhang Chang Ken683be172011-08-10 17:45:34 -04005809static struct matrix_keymap_data dragon_keymap_data = {
5810 .keymap_size = ARRAY_SIZE(dragon_keymap),
5811 .keymap = dragon_keymap,
5812};
5813
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305814static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005815 .input_name = "dragon-keypad",
5816 .input_phys_device = "dragon-keypad/input0",
5817 .num_rows = 6,
5818 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305819 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5820 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5821 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005822 .scan_delay_ms = 32,
5823 .row_hold_ns = 91500,
5824 .wakeup = 1,
5825 .keymap_data = &dragon_keymap_data,
5826};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305827
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005828static const unsigned int fluid_keymap[] = {
5829 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5830 KEY(0, 1, KEY_UP), /* NAV - UP */
5831 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5832 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5833
5834 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5835 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5836 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5837 KEY(1, 3, KEY_VOLUMEUP),
5838
5839 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5840
5841 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5842 KEY(4, 1, KEY_UP), /* USER_UP */
5843 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5844 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5845 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5846
Jilai Wang9a895102011-07-12 14:00:35 -04005847 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005848 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5849 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5850 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5851 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5852};
5853
5854static struct matrix_keymap_data fluid_keymap_data = {
5855 .keymap_size = ARRAY_SIZE(fluid_keymap),
5856 .keymap = fluid_keymap,
5857};
5858
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305859static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005860 .input_name = "fluid-keypad",
5861 .input_phys_device = "fluid-keypad/input0",
5862 .num_rows = 6,
5863 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305864 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5865 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5866 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005867 .scan_delay_ms = 32,
5868 .row_hold_ns = 91500,
5869 .wakeup = 1,
5870 .keymap_data = &fluid_keymap_data,
5871};
5872
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305873static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005874 .initial_vibrate_ms = 500,
5875 .level_mV = 3000,
5876 .max_timeout_ms = 15000,
5877};
5878
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305879static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
5880 .rtc_write_enable = false,
5881 .rtc_alarm_powerup = false,
5882};
5883
5884static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
5885 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08005886 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305887 .wakeup = 1,
5888};
5889
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005890#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5891
5892static struct othc_accessory_info othc_accessories[] = {
5893 {
5894 .accessory = OTHC_SVIDEO_OUT,
5895 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5896 | OTHC_ADC_DETECT,
5897 .key_code = SW_VIDEOOUT_INSERT,
5898 .enabled = false,
5899 .adc_thres = {
5900 .min_threshold = 20,
5901 .max_threshold = 40,
5902 },
5903 },
5904 {
5905 .accessory = OTHC_ANC_HEADPHONE,
5906 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5907 OTHC_SWITCH_DETECT,
5908 .gpio = PM8058_LINE_IN_DET_GPIO,
5909 .active_low = 1,
5910 .key_code = SW_HEADPHONE_INSERT,
5911 .enabled = true,
5912 },
5913 {
5914 .accessory = OTHC_ANC_HEADSET,
5915 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5916 .gpio = PM8058_LINE_IN_DET_GPIO,
5917 .active_low = 1,
5918 .key_code = SW_HEADPHONE_INSERT,
5919 .enabled = true,
5920 },
5921 {
5922 .accessory = OTHC_HEADPHONE,
5923 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
5924 .key_code = SW_HEADPHONE_INSERT,
5925 .enabled = true,
5926 },
5927 {
5928 .accessory = OTHC_MICROPHONE,
5929 .detect_flags = OTHC_GPIO_DETECT,
5930 .gpio = PM8058_LINE_IN_DET_GPIO,
5931 .active_low = 1,
5932 .key_code = SW_MICROPHONE_INSERT,
5933 .enabled = true,
5934 },
5935 {
5936 .accessory = OTHC_HEADSET,
5937 .detect_flags = OTHC_MICBIAS_DETECT,
5938 .key_code = SW_HEADPHONE_INSERT,
5939 .enabled = true,
5940 },
5941};
5942
5943static struct othc_switch_info switch_info[] = {
5944 {
5945 .min_adc_threshold = 0,
5946 .max_adc_threshold = 100,
5947 .key_code = KEY_PLAYPAUSE,
5948 },
5949 {
5950 .min_adc_threshold = 100,
5951 .max_adc_threshold = 200,
5952 .key_code = KEY_REWIND,
5953 },
5954 {
5955 .min_adc_threshold = 200,
5956 .max_adc_threshold = 500,
5957 .key_code = KEY_FASTFORWARD,
5958 },
5959};
5960
5961static struct othc_n_switch_config switch_config = {
5962 .voltage_settling_time_ms = 0,
5963 .num_adc_samples = 3,
5964 .adc_channel = CHANNEL_ADC_HDSET,
5965 .switch_info = switch_info,
5966 .num_keys = ARRAY_SIZE(switch_info),
5967 .default_sw_en = true,
5968 .default_sw_idx = 0,
5969};
5970
5971static struct hsed_bias_config hsed_bias_config = {
5972 /* HSED mic bias config info */
5973 .othc_headset = OTHC_HEADSET_NO,
5974 .othc_lowcurr_thresh_uA = 100,
5975 .othc_highcurr_thresh_uA = 600,
5976 .othc_hyst_prediv_us = 7800,
5977 .othc_period_clkdiv_us = 62500,
5978 .othc_hyst_clk_us = 121000,
5979 .othc_period_clk_us = 312500,
5980 .othc_wakeup = 1,
5981};
5982
5983static struct othc_hsed_config hsed_config_1 = {
5984 .hsed_bias_config = &hsed_bias_config,
5985 /*
5986 * The detection delay and switch reporting delay are
5987 * required to encounter a hardware bug (spurious switch
5988 * interrupts on slow insertion/removal of the headset).
5989 * This will introduce a delay in reporting the accessory
5990 * insertion and removal to the userspace.
5991 */
5992 .detection_delay_ms = 1500,
5993 /* Switch info */
5994 .switch_debounce_ms = 1500,
5995 .othc_support_n_switch = false,
5996 .switch_config = &switch_config,
5997 .ir_gpio = -1,
5998 /* Accessory info */
5999 .accessories_support = true,
6000 .accessories = othc_accessories,
6001 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6002};
6003
6004static struct othc_regulator_config othc_reg = {
6005 .regulator = "8058_l5",
6006 .max_uV = 2850000,
6007 .min_uV = 2850000,
6008};
6009
6010/* MIC_BIAS0 is configured as normal MIC BIAS */
6011static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6012 .micbias_select = OTHC_MICBIAS_0,
6013 .micbias_capability = OTHC_MICBIAS,
6014 .micbias_enable = OTHC_SIGNAL_OFF,
6015 .micbias_regulator = &othc_reg,
6016};
6017
6018/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6019static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6020 .micbias_select = OTHC_MICBIAS_1,
6021 .micbias_capability = OTHC_MICBIAS_HSED,
6022 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6023 .micbias_regulator = &othc_reg,
6024 .hsed_config = &hsed_config_1,
6025 .hsed_name = "8660_handset",
6026};
6027
6028/* MIC_BIAS2 is configured as normal MIC BIAS */
6029static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6030 .micbias_select = OTHC_MICBIAS_2,
6031 .micbias_capability = OTHC_MICBIAS,
6032 .micbias_enable = OTHC_SIGNAL_OFF,
6033 .micbias_regulator = &othc_reg,
6034};
6035
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006036
6037static void __init msm8x60_init_pm8058_othc(void)
6038{
6039 int i;
6040
6041 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6042 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6043 machine_is_msm8x60_fusn_ffa()) {
6044 /* 3-switch headset supported only by V2 FFA and FLUID */
6045 hsed_config_1.accessories_adc_support = true,
6046 /* ADC based accessory detection works only on V2 and FLUID */
6047 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6048 hsed_config_1.othc_support_n_switch = true;
6049 }
6050
6051 /* IR GPIO is absent on FLUID */
6052 if (machine_is_msm8x60_fluid())
6053 hsed_config_1.ir_gpio = -1;
6054
6055 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6056 if (machine_is_msm8x60_fluid()) {
6057 switch (othc_accessories[i].accessory) {
6058 case OTHC_ANC_HEADPHONE:
6059 case OTHC_ANC_HEADSET:
6060 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6061 break;
6062 case OTHC_MICROPHONE:
6063 othc_accessories[i].enabled = false;
6064 break;
6065 case OTHC_SVIDEO_OUT:
6066 othc_accessories[i].enabled = true;
6067 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6068 break;
6069 }
6070 }
6071 }
6072}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006074
6075static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6076{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306077 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006078 .direction = PM_GPIO_DIR_OUT,
6079 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6080 .output_value = 0,
6081 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306082 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006083 .out_strength = PM_GPIO_STRENGTH_HIGH,
6084 .function = PM_GPIO_FUNC_2,
6085 };
6086
6087 int rc = -EINVAL;
6088 int id, mode, max_mA;
6089
6090 id = mode = max_mA = 0;
6091 switch (ch) {
6092 case 0:
6093 case 1:
6094 case 2:
6095 if (on) {
6096 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306097 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6098 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006099 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306100 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006101 __func__, id, rc);
6102 }
6103 break;
6104
6105 case 6:
6106 id = PM_PWM_LED_FLASH;
6107 mode = PM_PWM_CONF_PWM1;
6108 max_mA = 300;
6109 break;
6110
6111 case 7:
6112 id = PM_PWM_LED_FLASH1;
6113 mode = PM_PWM_CONF_PWM1;
6114 max_mA = 300;
6115 break;
6116
6117 default:
6118 break;
6119 }
6120
6121 if (ch >= 6 && ch <= 7) {
6122 if (!on) {
6123 mode = PM_PWM_CONF_NONE;
6124 max_mA = 0;
6125 }
6126 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6127 if (rc)
6128 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6129 __func__, ch, rc);
6130 }
6131 return rc;
6132
6133}
6134
6135static struct pm8058_pwm_pdata pm8058_pwm_data = {
6136 .config = pm8058_pwm_config,
6137};
6138
6139#define PM8058_GPIO_INT 88
6140
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006141static struct pmic8058_led pmic8058_flash_leds[] = {
6142 [0] = {
6143 .name = "camera:flash0",
6144 .max_brightness = 15,
6145 .id = PMIC8058_ID_FLASH_LED_0,
6146 },
6147 [1] = {
6148 .name = "camera:flash1",
6149 .max_brightness = 15,
6150 .id = PMIC8058_ID_FLASH_LED_1,
6151 },
6152};
6153
6154static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6155 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6156 .leds = pmic8058_flash_leds,
6157};
6158
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006159static struct pmic8058_led pmic8058_dragon_leds[] = {
6160 [0] = {
6161 /* RED */
6162 .name = "led_drv0",
6163 .max_brightness = 15,
6164 .id = PMIC8058_ID_LED_0,
6165 },/* 300 mA flash led0 drv sink */
6166 [1] = {
6167 /* Yellow */
6168 .name = "led_drv1",
6169 .max_brightness = 15,
6170 .id = PMIC8058_ID_LED_1,
6171 },/* 300 mA flash led0 drv sink */
6172 [2] = {
6173 /* Green */
6174 .name = "led_drv2",
6175 .max_brightness = 15,
6176 .id = PMIC8058_ID_LED_2,
6177 },/* 300 mA flash led0 drv sink */
6178 [3] = {
6179 .name = "led_psensor",
6180 .max_brightness = 15,
6181 .id = PMIC8058_ID_LED_KB_LIGHT,
6182 },/* 300 mA flash led0 drv sink */
6183};
6184
6185static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6186 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6187 .leds = pmic8058_dragon_leds,
6188};
6189
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006190static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6191 [0] = {
6192 .name = "led:drv0",
6193 .max_brightness = 15,
6194 .id = PMIC8058_ID_FLASH_LED_0,
6195 },/* 300 mA flash led0 drv sink */
6196 [1] = {
6197 .name = "led:drv1",
6198 .max_brightness = 15,
6199 .id = PMIC8058_ID_FLASH_LED_1,
6200 },/* 300 mA flash led1 sink */
6201 [2] = {
6202 .name = "led:drv2",
6203 .max_brightness = 20,
6204 .id = PMIC8058_ID_LED_0,
6205 },/* 40 mA led0 sink */
6206 [3] = {
6207 .name = "keypad:drv",
6208 .max_brightness = 15,
6209 .id = PMIC8058_ID_LED_KB_LIGHT,
6210 },/* 300 mA keypad drv sink */
6211};
6212
6213static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6214 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6215 .leds = pmic8058_fluid_flash_leds,
6216};
6217
Terence Hampson90508a92011-08-09 10:40:08 -04006218static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306219 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006220 .max_source_current = 1800,
6221 .charger_type = CHG_TYPE_AC,
6222};
6223
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306224static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6225 .charger_data_valid = false,
6226};
6227
6228static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6229 .priority = 0,
6230};
6231
6232static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6233 .irq_base = PM8058_IRQ_BASE,
6234 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6235 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6236};
6237
6238static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6239 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6240};
6241
6242static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6243 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006244};
6245
6246static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306247 .irq_pdata = &pm8058_irq_pdata,
6248 .gpio_pdata = &pm8058_gpio_pdata,
6249 .mpp_pdata = &pm8058_mpp_pdata,
6250 .rtc_pdata = &pm8058_rtc_pdata,
6251 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6252 .othc0_pdata = &othc_config_pdata_0,
6253 .othc1_pdata = &othc_config_pdata_1,
6254 .othc2_pdata = &othc_config_pdata_2,
6255 .pwm_pdata = &pm8058_pwm_data,
6256 .misc_pdata = &pm8058_misc_pdata,
6257#ifdef CONFIG_SENSORS_MSM_ADC
6258 .xoadc_pdata = &pm8058_xoadc_pdata,
6259#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006260};
6261
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306262#ifdef CONFIG_MSM_SSBI
6263static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6264 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6265 .slave = {
6266 .name = "pm8058-core",
6267 .platform_data = &pm8058_platform_data,
6268 },
6269};
6270#endif
6271#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006272
6273#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6274 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6275#define TDISC_I2C_SLAVE_ADDR 0x67
6276#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6277#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6278
6279static const char *vregs_tdisc_name[] = {
6280 "8058_l5",
6281 "8058_s3",
6282};
6283
6284static const int vregs_tdisc_val[] = {
6285 2850000,/* uV */
6286 1800000,
6287};
6288static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6289
6290static int tdisc_shinetsu_setup(void)
6291{
6292 int rc, i;
6293
6294 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6295 if (rc) {
6296 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6297 __func__);
6298 return rc;
6299 }
6300
6301 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6302 if (rc) {
6303 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6304 __func__);
6305 goto fail_gpio_oe;
6306 }
6307
6308 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6309 if (rc) {
6310 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6311 __func__);
6312 gpio_free(GPIO_JOYSTICK_EN);
6313 goto fail_gpio_oe;
6314 }
6315
6316 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6317 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6318 if (IS_ERR(vregs_tdisc[i])) {
6319 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6320 __func__, vregs_tdisc_name[i],
6321 PTR_ERR(vregs_tdisc[i]));
6322 rc = PTR_ERR(vregs_tdisc[i]);
6323 goto vreg_get_fail;
6324 }
6325
6326 rc = regulator_set_voltage(vregs_tdisc[i],
6327 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6328 if (rc) {
6329 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6330 __func__, rc);
6331 goto vreg_set_voltage_fail;
6332 }
6333 }
6334
6335 return rc;
6336vreg_set_voltage_fail:
6337 i++;
6338vreg_get_fail:
6339 while (i)
6340 regulator_put(vregs_tdisc[--i]);
6341fail_gpio_oe:
6342 gpio_free(PMIC_GPIO_TDISC);
6343 return rc;
6344}
6345
6346static void tdisc_shinetsu_release(void)
6347{
6348 int i;
6349
6350 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6351 regulator_put(vregs_tdisc[i]);
6352
6353 gpio_free(PMIC_GPIO_TDISC);
6354 gpio_free(GPIO_JOYSTICK_EN);
6355}
6356
6357static int tdisc_shinetsu_enable(void)
6358{
6359 int i, rc = -EINVAL;
6360
6361 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6362 rc = regulator_enable(vregs_tdisc[i]);
6363 if (rc < 0) {
6364 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6365 __func__, vregs_tdisc_name[i], rc);
6366 goto vreg_fail;
6367 }
6368 }
6369
6370 /* Enable the OE (output enable) gpio */
6371 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6372 /* voltage and gpio stabilization delay */
6373 msleep(50);
6374
6375 return 0;
6376vreg_fail:
6377 while (i)
6378 regulator_disable(vregs_tdisc[--i]);
6379 return rc;
6380}
6381
6382static int tdisc_shinetsu_disable(void)
6383{
6384 int i, rc;
6385
6386 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6387 rc = regulator_disable(vregs_tdisc[i]);
6388 if (rc < 0) {
6389 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6390 __func__, vregs_tdisc_name[i], rc);
6391 goto tdisc_reg_fail;
6392 }
6393 }
6394
6395 /* Disable the OE (output enable) gpio */
6396 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6397
6398 return 0;
6399
6400tdisc_reg_fail:
6401 while (i)
6402 regulator_enable(vregs_tdisc[--i]);
6403 return rc;
6404}
6405
6406static struct tdisc_abs_values tdisc_abs = {
6407 .x_max = 32,
6408 .y_max = 32,
6409 .x_min = -32,
6410 .y_min = -32,
6411 .pressure_max = 32,
6412 .pressure_min = 0,
6413};
6414
6415static struct tdisc_platform_data tdisc_data = {
6416 .tdisc_setup = tdisc_shinetsu_setup,
6417 .tdisc_release = tdisc_shinetsu_release,
6418 .tdisc_enable = tdisc_shinetsu_enable,
6419 .tdisc_disable = tdisc_shinetsu_disable,
6420 .tdisc_wakeup = 0,
6421 .tdisc_gpio = PMIC_GPIO_TDISC,
6422 .tdisc_report_keys = true,
6423 .tdisc_report_relative = true,
6424 .tdisc_report_absolute = false,
6425 .tdisc_report_wheel = false,
6426 .tdisc_reverse_x = false,
6427 .tdisc_reverse_y = true,
6428 .tdisc_abs = &tdisc_abs,
6429};
6430
6431static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6432 {
6433 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6434 .irq = TDISC_INT,
6435 .platform_data = &tdisc_data,
6436 },
6437};
6438#endif
6439
6440#define PM_GPIO_CDC_RST_N 20
6441#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6442
6443static struct regulator *vreg_timpani_1;
6444static struct regulator *vreg_timpani_2;
6445
6446static unsigned int msm_timpani_setup_power(void)
6447{
6448 int rc;
6449
6450 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6451 if (IS_ERR(vreg_timpani_1)) {
6452 pr_err("%s: Unable to get 8058_l0\n", __func__);
6453 return -ENODEV;
6454 }
6455
6456 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6457 if (IS_ERR(vreg_timpani_2)) {
6458 pr_err("%s: Unable to get 8058_s3\n", __func__);
6459 regulator_put(vreg_timpani_1);
6460 return -ENODEV;
6461 }
6462
6463 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6464 if (rc) {
6465 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6466 goto fail;
6467 }
6468
6469 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6470 if (rc) {
6471 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6472 goto fail;
6473 }
6474
6475 rc = regulator_enable(vreg_timpani_1);
6476 if (rc) {
6477 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6478 goto fail;
6479 }
6480
6481 /* The settings for LDO0 should be set such that
6482 * it doesn't require to reset the timpani. */
6483 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6484 if (rc < 0) {
6485 pr_err("Timpani regulator optimum mode setting failed\n");
6486 goto fail;
6487 }
6488
6489 rc = regulator_enable(vreg_timpani_2);
6490 if (rc) {
6491 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6492 regulator_disable(vreg_timpani_1);
6493 goto fail;
6494 }
6495
6496 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6497 if (rc) {
6498 pr_err("%s: GPIO Request %d failed\n", __func__,
6499 GPIO_CDC_RST_N);
6500 regulator_disable(vreg_timpani_1);
6501 regulator_disable(vreg_timpani_2);
6502 goto fail;
6503 } else {
6504 gpio_direction_output(GPIO_CDC_RST_N, 1);
6505 usleep_range(1000, 1050);
6506 gpio_direction_output(GPIO_CDC_RST_N, 0);
6507 usleep_range(1000, 1050);
6508 gpio_direction_output(GPIO_CDC_RST_N, 1);
6509 gpio_free(GPIO_CDC_RST_N);
6510 }
6511 return rc;
6512
6513fail:
6514 regulator_put(vreg_timpani_1);
6515 regulator_put(vreg_timpani_2);
6516 return rc;
6517}
6518
6519static void msm_timpani_shutdown_power(void)
6520{
6521 int rc;
6522
6523 rc = regulator_disable(vreg_timpani_1);
6524 if (rc)
6525 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6526
6527 regulator_put(vreg_timpani_1);
6528
6529 rc = regulator_disable(vreg_timpani_2);
6530 if (rc)
6531 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6532
6533 regulator_put(vreg_timpani_2);
6534}
6535
6536/* Power analog function of codec */
6537static struct regulator *vreg_timpani_cdc_apwr;
6538static int msm_timpani_codec_power(int vreg_on)
6539{
6540 int rc = 0;
6541
6542 if (!vreg_timpani_cdc_apwr) {
6543
6544 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6545
6546 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6547 pr_err("%s: vreg_get failed (%ld)\n",
6548 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6549 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6550 return rc;
6551 }
6552 }
6553
6554 if (vreg_on) {
6555
6556 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6557 2200000, 2200000);
6558 if (rc) {
6559 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6560 __func__);
6561 goto vreg_fail;
6562 }
6563
6564 rc = regulator_enable(vreg_timpani_cdc_apwr);
6565 if (rc) {
6566 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6567 goto vreg_fail;
6568 }
6569 } else {
6570 rc = regulator_disable(vreg_timpani_cdc_apwr);
6571 if (rc) {
6572 pr_err("%s: vreg_disable failed %d\n",
6573 __func__, rc);
6574 goto vreg_fail;
6575 }
6576 }
6577
6578 return 0;
6579
6580vreg_fail:
6581 regulator_put(vreg_timpani_cdc_apwr);
6582 vreg_timpani_cdc_apwr = NULL;
6583 return rc;
6584}
6585
6586static struct marimba_codec_platform_data timpani_codec_pdata = {
6587 .marimba_codec_power = msm_timpani_codec_power,
6588};
6589
6590#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6591#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6592
6593static struct marimba_platform_data timpani_pdata = {
6594 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6595 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6596 .marimba_setup = msm_timpani_setup_power,
6597 .marimba_shutdown = msm_timpani_shutdown_power,
6598 .codec = &timpani_codec_pdata,
6599 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6600};
6601
6602#define TIMPANI_I2C_SLAVE_ADDR 0xD
6603
6604static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6605 {
6606 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6607 .platform_data = &timpani_pdata,
6608 },
6609};
6610
Lei Zhou338cab82011-08-19 13:38:17 -04006611#ifdef CONFIG_SND_SOC_WM8903
6612static struct wm8903_platform_data wm8903_pdata = {
6613 .gpio_cfg[2] = 0x3A8,
6614};
6615
6616#define WM8903_I2C_SLAVE_ADDR 0x34
6617static struct i2c_board_info wm8903_codec_i2c_info[] = {
6618 {
6619 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6620 .platform_data = &wm8903_pdata,
6621 },
6622};
6623#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006624#ifdef CONFIG_PMIC8901
6625
6626#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006627/*
6628 * Consumer specific regulator names:
6629 * regulator name consumer dev_name
6630 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006631static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6632 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6633};
6634static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6635 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6636};
6637
6638#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306639 _always_on) \
6640 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006641 .init_data = { \
6642 .constraints = { \
6643 .valid_modes_mask = _modes, \
6644 .valid_ops_mask = _ops, \
6645 .min_uV = _min_uV, \
6646 .max_uV = _max_uV, \
6647 .input_uV = _min_uV, \
6648 .apply_uV = _apply_uV, \
6649 .always_on = _always_on, \
6650 }, \
6651 .consumer_supplies = vreg_consumers_8901_##_id, \
6652 .num_consumer_supplies = \
6653 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6654 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306655 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006656 }
6657
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006658#define PM8901_VREG_INIT_VS(_id) \
6659 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306660 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006661
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306662static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006663 PM8901_VREG_INIT_VS(USB_OTG),
6664 PM8901_VREG_INIT_VS(HDMI_MVS),
6665};
6666
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306667static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6668 .priority = 1,
6669};
6670
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306671static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6672 .irq_base = PM8901_IRQ_BASE,
6673 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6674 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6675};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006676
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306677static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6678 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006679};
6680
6681static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306682 .irq_pdata = &pm8901_irq_pdata,
6683 .mpp_pdata = &pm8901_mpp_pdata,
6684 .regulator_pdatas = pm8901_vreg_init,
6685 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306686 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006687};
6688
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306689static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6690 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6691 .slave = {
6692 .name = "pm8901-core",
6693 .platform_data = &pm8901_platform_data,
6694 },
6695};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006696#endif /* CONFIG_PMIC8901 */
6697
6698#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6699 || defined(CONFIG_GPIO_SX150X_MODULE))
6700
6701static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006702static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006703
6704struct bahama_config_register{
6705 u8 reg;
6706 u8 value;
6707 u8 mask;
6708};
6709
6710enum version{
6711 VER_1_0,
6712 VER_2_0,
6713 VER_UNSUPPORTED = 0xFF
6714};
6715
6716static u8 read_bahama_ver(void)
6717{
6718 int rc;
6719 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6720 u8 bahama_version;
6721
6722 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6723 if (rc < 0) {
6724 printk(KERN_ERR
6725 "%s: version read failed: %d\n",
6726 __func__, rc);
6727 return VER_UNSUPPORTED;
6728 } else {
6729 printk(KERN_INFO
6730 "%s: version read got: 0x%x\n",
6731 __func__, bahama_version);
6732 }
6733
6734 switch (bahama_version) {
6735 case 0x08: /* varient of bahama v1 */
6736 case 0x10:
6737 case 0x00:
6738 return VER_1_0;
6739 case 0x09: /* variant of bahama v2 */
6740 return VER_2_0;
6741 default:
6742 return VER_UNSUPPORTED;
6743 }
6744}
6745
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006746static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006747static unsigned int msm_bahama_setup_power(void)
6748{
6749 int rc = 0;
6750 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006751
6752 if (machine_is_msm8x60_dragon())
6753 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6754
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006755 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6756
6757 if (IS_ERR(vreg_bahama)) {
6758 rc = PTR_ERR(vreg_bahama);
6759 pr_err("%s: regulator_get %s = %d\n", __func__,
6760 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006761 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006762 }
6763
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006764 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6765 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006766 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6767 msm_bahama_regulator, rc);
6768 goto unget;
6769 }
6770
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006771 rc = regulator_enable(vreg_bahama);
6772 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006773 pr_err("%s: regulator_enable %s = %d\n", __func__,
6774 msm_bahama_regulator, rc);
6775 goto unget;
6776 }
6777
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006778 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6779 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006780 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006781 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006782 goto unenable;
6783 }
6784
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006785 gpio_direction_output(msm_bahama_sys_rst, 0);
6786 usleep_range(1000, 1050);
6787 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6788 usleep_range(1000, 1050);
6789 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006790 return rc;
6791
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006792unenable:
6793 regulator_disable(vreg_bahama);
6794unget:
6795 regulator_put(vreg_bahama);
6796 return rc;
6797};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006798
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006799static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006800{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006801 if (msm_bahama_setup_power_enable) {
6802 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6803 gpio_free(msm_bahama_sys_rst);
6804 regulator_disable(vreg_bahama);
6805 regulator_put(vreg_bahama);
6806 msm_bahama_setup_power_enable = 0;
6807 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006808
6809 return 0;
6810};
6811
6812static unsigned int msm_bahama_core_config(int type)
6813{
6814 int rc = 0;
6815
6816 if (type == BAHAMA_ID) {
6817
6818 int i;
6819 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6820
6821 const struct bahama_config_register v20_init[] = {
6822 /* reg, value, mask */
6823 { 0xF4, 0x84, 0xFF }, /* AREG */
6824 { 0xF0, 0x04, 0xFF } /* DREG */
6825 };
6826
6827 if (read_bahama_ver() == VER_2_0) {
6828 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6829 u8 value = v20_init[i].value;
6830 rc = marimba_write_bit_mask(&config,
6831 v20_init[i].reg,
6832 &value,
6833 sizeof(v20_init[i].value),
6834 v20_init[i].mask);
6835 if (rc < 0) {
6836 printk(KERN_ERR
6837 "%s: reg %d write failed: %d\n",
6838 __func__, v20_init[i].reg, rc);
6839 return rc;
6840 }
6841 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6842 " mask 0x%02x\n",
6843 __func__, v20_init[i].reg,
6844 v20_init[i].value, v20_init[i].mask);
6845 }
6846 }
6847 }
6848 printk(KERN_INFO "core type: %d\n", type);
6849
6850 return rc;
6851}
6852
6853static struct regulator *fm_regulator_s3;
6854static struct msm_xo_voter *fm_clock;
6855
6856static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6857{
6858 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306859 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006860 .direction = PM_GPIO_DIR_IN,
6861 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306862 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006863 .function = PM_GPIO_FUNC_NORMAL,
6864 .inv_int_pol = 0,
6865 };
6866
6867 if (!fm_regulator_s3) {
6868 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6869 if (IS_ERR(fm_regulator_s3)) {
6870 rc = PTR_ERR(fm_regulator_s3);
6871 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6872 __func__, rc);
6873 goto out;
6874 }
6875 }
6876
6877
6878 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6879 if (rc < 0) {
6880 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6881 __func__, rc);
6882 goto fm_fail_put;
6883 }
6884
6885 rc = regulator_enable(fm_regulator_s3);
6886 if (rc < 0) {
6887 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6888 __func__, rc);
6889 goto fm_fail_put;
6890 }
6891
6892 /*Vote for XO clock*/
6893 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6894
6895 if (IS_ERR(fm_clock)) {
6896 rc = PTR_ERR(fm_clock);
6897 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6898 __func__, rc);
6899 goto fm_fail_switch;
6900 }
6901
6902 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6903 if (rc < 0) {
6904 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6905 __func__, rc);
6906 goto fm_fail_vote;
6907 }
6908
6909 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306910 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006911 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306912 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006913 __func__, rc);
6914 goto fm_fail_clock;
6915 }
6916 goto out;
6917
6918fm_fail_clock:
6919 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6920fm_fail_vote:
6921 msm_xo_put(fm_clock);
6922fm_fail_switch:
6923 regulator_disable(fm_regulator_s3);
6924fm_fail_put:
6925 regulator_put(fm_regulator_s3);
6926out:
6927 return rc;
6928};
6929
6930static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
6931{
6932 int rc = 0;
6933 if (fm_regulator_s3 != NULL) {
6934 rc = regulator_disable(fm_regulator_s3);
6935 if (rc < 0) {
6936 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
6937 __func__, rc);
6938 }
6939 regulator_put(fm_regulator_s3);
6940 fm_regulator_s3 = NULL;
6941 }
6942 printk(KERN_ERR "%s: Voting off for XO", __func__);
6943
6944 if (fm_clock != NULL) {
6945 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6946 if (rc < 0) {
6947 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
6948 __func__, rc);
6949 }
6950 msm_xo_put(fm_clock);
6951 }
6952 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
6953}
6954
6955/* Slave id address for FM/CDC/QMEMBIST
6956 * Values can be programmed using Marimba slave id 0
6957 * should there be a conflict with other I2C devices
6958 * */
6959#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
6960#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
6961
6962static struct marimba_fm_platform_data marimba_fm_pdata = {
6963 .fm_setup = fm_radio_setup,
6964 .fm_shutdown = fm_radio_shutdown,
6965 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
6966 .is_fm_soc_i2s_master = false,
6967 .config_i2s_gpio = NULL,
6968};
6969
6970/*
6971Just initializing the BAHAMA related slave
6972*/
6973static struct marimba_platform_data marimba_pdata = {
6974 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
6975 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
6976 .bahama_setup = msm_bahama_setup_power,
6977 .bahama_shutdown = msm_bahama_shutdown_power,
6978 .bahama_core_config = msm_bahama_core_config,
6979 .fm = &marimba_fm_pdata,
6980 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6981};
6982
6983
6984static struct i2c_board_info msm_marimba_board_info[] = {
6985 {
6986 I2C_BOARD_INFO("marimba", 0xc),
6987 .platform_data = &marimba_pdata,
6988 }
6989};
6990#endif /* CONFIG_MAIMBA_CORE */
6991
6992#ifdef CONFIG_I2C
6993#define I2C_SURF 1
6994#define I2C_FFA (1 << 1)
6995#define I2C_RUMI (1 << 2)
6996#define I2C_SIM (1 << 3)
6997#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006998#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006999
7000struct i2c_registry {
7001 u8 machs;
7002 int bus;
7003 struct i2c_board_info *info;
7004 int len;
7005};
7006
7007static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007008#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7009 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007010 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007011 MSM_GSBI8_QUP_I2C_BUS_ID,
7012 core_expander_i2c_info,
7013 ARRAY_SIZE(core_expander_i2c_info),
7014 },
7015 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007016 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007017 MSM_GSBI8_QUP_I2C_BUS_ID,
7018 docking_expander_i2c_info,
7019 ARRAY_SIZE(docking_expander_i2c_info),
7020 },
7021 {
7022 I2C_SURF,
7023 MSM_GSBI8_QUP_I2C_BUS_ID,
7024 surf_expanders_i2c_info,
7025 ARRAY_SIZE(surf_expanders_i2c_info),
7026 },
7027 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007028 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007029 MSM_GSBI3_QUP_I2C_BUS_ID,
7030 fha_expanders_i2c_info,
7031 ARRAY_SIZE(fha_expanders_i2c_info),
7032 },
7033 {
7034 I2C_FLUID,
7035 MSM_GSBI3_QUP_I2C_BUS_ID,
7036 fluid_expanders_i2c_info,
7037 ARRAY_SIZE(fluid_expanders_i2c_info),
7038 },
7039 {
7040 I2C_FLUID,
7041 MSM_GSBI8_QUP_I2C_BUS_ID,
7042 fluid_core_expander_i2c_info,
7043 ARRAY_SIZE(fluid_core_expander_i2c_info),
7044 },
7045#endif
7046#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7047 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7048 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007049 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007050 MSM_GSBI3_QUP_I2C_BUS_ID,
7051 msm_i2c_gsbi3_tdisc_info,
7052 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7053 },
7054#endif
7055 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007056 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007057 MSM_GSBI3_QUP_I2C_BUS_ID,
7058 cy8ctmg200_board_info,
7059 ARRAY_SIZE(cy8ctmg200_board_info),
7060 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007061 {
7062 I2C_DRAGON,
7063 MSM_GSBI3_QUP_I2C_BUS_ID,
7064 cy8ctma340_dragon_board_info,
7065 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7066 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007067#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7068 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7069 {
7070 I2C_FLUID,
7071 MSM_GSBI3_QUP_I2C_BUS_ID,
7072 cyttsp_fluid_info,
7073 ARRAY_SIZE(cyttsp_fluid_info),
7074 },
7075 {
7076 I2C_FFA | I2C_SURF,
7077 MSM_GSBI3_QUP_I2C_BUS_ID,
7078 cyttsp_ffa_info,
7079 ARRAY_SIZE(cyttsp_ffa_info),
7080 },
7081#endif
7082#ifdef CONFIG_MSM_CAMERA
Jilai Wang971f97f2011-07-13 14:25:25 -04007083 {
7084 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007085 MSM_GSBI4_QUP_I2C_BUS_ID,
7086 msm_camera_boardinfo,
7087 ARRAY_SIZE(msm_camera_boardinfo),
7088 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007089 {
7090 I2C_DRAGON,
7091 MSM_GSBI4_QUP_I2C_BUS_ID,
7092 msm_camera_dragon_boardinfo,
7093 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7094 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007095#endif
7096 {
7097 I2C_SURF | I2C_FFA | I2C_FLUID,
7098 MSM_GSBI7_QUP_I2C_BUS_ID,
7099 msm_i2c_gsbi7_timpani_info,
7100 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7101 },
7102#if defined(CONFIG_MARIMBA_CORE)
7103 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007104 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007105 MSM_GSBI7_QUP_I2C_BUS_ID,
7106 msm_marimba_board_info,
7107 ARRAY_SIZE(msm_marimba_board_info),
7108 },
7109#endif /* CONFIG_MARIMBA_CORE */
7110#ifdef CONFIG_ISL9519_CHARGER
7111 {
7112 I2C_SURF | I2C_FFA,
7113 MSM_GSBI8_QUP_I2C_BUS_ID,
7114 isl_charger_i2c_info,
7115 ARRAY_SIZE(isl_charger_i2c_info),
7116 },
7117#endif
7118#if defined(CONFIG_HAPTIC_ISA1200) || \
7119 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7120 {
7121 I2C_FLUID,
7122 MSM_GSBI8_QUP_I2C_BUS_ID,
7123 msm_isa1200_board_info,
7124 ARRAY_SIZE(msm_isa1200_board_info),
7125 },
7126#endif
7127#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7128 {
7129 I2C_FLUID,
7130 MSM_GSBI8_QUP_I2C_BUS_ID,
7131 smb137b_charger_i2c_info,
7132 ARRAY_SIZE(smb137b_charger_i2c_info),
7133 },
7134#endif
7135#if defined(CONFIG_BATTERY_BQ27520) || \
7136 defined(CONFIG_BATTERY_BQ27520_MODULE)
7137 {
7138 I2C_FLUID,
7139 MSM_GSBI8_QUP_I2C_BUS_ID,
7140 msm_bq27520_board_info,
7141 ARRAY_SIZE(msm_bq27520_board_info),
7142 },
7143#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007144#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7145 {
7146 I2C_DRAGON,
7147 MSM_GSBI8_QUP_I2C_BUS_ID,
7148 wm8903_codec_i2c_info,
7149 ARRAY_SIZE(wm8903_codec_i2c_info),
7150 },
7151#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007152};
7153#endif /* CONFIG_I2C */
7154
7155static void fixup_i2c_configs(void)
7156{
7157#ifdef CONFIG_I2C
7158#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7159 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7160 sx150x_data[SX150X_CORE].irq_summary =
7161 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007162 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7163 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007164 sx150x_data[SX150X_CORE].irq_summary =
7165 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7166 else if (machine_is_msm8x60_fluid())
7167 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7168 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7169#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007170#endif
7171}
7172
7173static void register_i2c_devices(void)
7174{
7175#ifdef CONFIG_I2C
7176 u8 mach_mask = 0;
7177 int i;
7178
7179 /* Build the matching 'supported_machs' bitmask */
7180 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7181 mach_mask = I2C_SURF;
7182 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7183 mach_mask = I2C_FFA;
7184 else if (machine_is_msm8x60_rumi3())
7185 mach_mask = I2C_RUMI;
7186 else if (machine_is_msm8x60_sim())
7187 mach_mask = I2C_SIM;
7188 else if (machine_is_msm8x60_fluid())
7189 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007190 else if (machine_is_msm8x60_dragon())
7191 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007192 else
7193 pr_err("unmatched machine ID in register_i2c_devices\n");
7194
7195 /* Run the array and install devices as appropriate */
7196 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7197 if (msm8x60_i2c_devices[i].machs & mach_mask)
7198 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7199 msm8x60_i2c_devices[i].info,
7200 msm8x60_i2c_devices[i].len);
7201 }
7202#endif
7203}
7204
7205static void __init msm8x60_init_uart12dm(void)
7206{
7207#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7208 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7209 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7210
7211 if (!fpga_mem)
7212 pr_err("%s(): Error getting memory\n", __func__);
7213
7214 /* Advanced mode */
7215 writew(0xFFFF, fpga_mem + 0x15C);
7216 /* FPGA_UART_SEL */
7217 writew(0, fpga_mem + 0x172);
7218 /* FPGA_GPIO_CONFIG_117 */
7219 writew(1, fpga_mem + 0xEA);
7220 /* FPGA_GPIO_CONFIG_118 */
7221 writew(1, fpga_mem + 0xEC);
7222 mb();
7223 iounmap(fpga_mem);
7224#endif
7225}
7226
7227#define MSM_GSBI9_PHYS 0x19900000
7228#define GSBI_DUAL_MODE_CODE 0x60
7229
7230static void __init msm8x60_init_buses(void)
7231{
7232#ifdef CONFIG_I2C_QUP
7233 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7234 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7235 writel_relaxed(0x6 << 4, gsbi_mem);
7236 /* Ensure protocol code is written before proceeding further */
7237 mb();
7238 iounmap(gsbi_mem);
7239
7240 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7241 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7242 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7243 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7244
7245#ifdef CONFIG_MSM_GSBI9_UART
7246 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7247 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7248 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7249 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7250 iounmap(gsbi_mem);
7251 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7252 }
7253#endif
7254 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7255 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7256#endif
7257#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7258 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7259#endif
7260#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007261 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7262#endif
7263
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307264#ifdef CONFIG_MSM_SSBI
7265 msm_device_ssbi_pmic1.dev.platform_data =
7266 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307267 msm_device_ssbi_pmic2.dev.platform_data =
7268 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307269#endif
7270
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007271 if (machine_is_msm8x60_fluid()) {
7272#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7273 (defined(CONFIG_SMB137B_CHARGER) || \
7274 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7275 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7276#endif
7277#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7278 msm_gsbi10_qup_spi_device.dev.platform_data =
7279 &msm_gsbi10_qup_spi_pdata;
7280#endif
7281 }
7282
7283#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7284 /*
7285 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7286 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7287 * and ID notifications are available only on V2 surf and FFA
7288 * with a hardware workaround.
7289 */
7290 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7291 (machine_is_msm8x60_surf() ||
7292 (machine_is_msm8x60_ffa() &&
7293 pmic_id_notif_supported)))
7294 msm_otg_pdata.phy_can_powercollapse = 1;
7295 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7296#endif
7297
7298#ifdef CONFIG_USB_GADGET_MSM_72K
7299 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7300#endif
7301
7302#ifdef CONFIG_SERIAL_MSM_HS
7303 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7304 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7305#endif
7306#ifdef CONFIG_MSM_GSBI9_UART
7307 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7308 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7309 if (IS_ERR(msm_device_uart_gsbi9))
7310 pr_err("%s(): Failed to create uart gsbi9 device\n",
7311 __func__);
7312 }
7313#endif
7314
7315#ifdef CONFIG_MSM_BUS_SCALING
7316
7317 /* RPM calls are only enabled on V2 */
7318 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7319 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7320 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7321 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7322 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7323 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7324 }
7325
7326 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7327 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7328 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7329 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7330 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7331#endif
7332}
7333
7334static void __init msm8x60_map_io(void)
7335{
7336 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7337 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007338
7339 if (socinfo_init() < 0)
7340 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007341}
7342
7343/*
7344 * Most segments of the EBI2 bus are disabled by default.
7345 */
7346static void __init msm8x60_init_ebi2(void)
7347{
7348 uint32_t ebi2_cfg;
7349 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007350 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7351
7352 if (IS_ERR(mem_clk)) {
7353 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7354 "msm_ebi2", "mem_clk");
7355 return;
7356 }
7357 clk_enable(mem_clk);
7358 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007359
7360 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7361 if (ebi2_cfg_ptr != 0) {
7362 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7363
7364 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007365 machine_is_msm8x60_fluid() ||
7366 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007367 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7368 else if (machine_is_msm8x60_sim())
7369 ebi2_cfg |= (1 << 4); /* CS2 */
7370 else if (machine_is_msm8x60_rumi3())
7371 ebi2_cfg |= (1 << 5); /* CS3 */
7372
7373 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7374 iounmap(ebi2_cfg_ptr);
7375 }
7376
7377 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007378 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007379 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7380 if (ebi2_cfg_ptr != 0) {
7381 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7382 writel_relaxed(0UL, ebi2_cfg_ptr);
7383
7384 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7385 * LAN9221 Ethernet controller reads and writes.
7386 * The lowest 4 bits are the read delay, the next
7387 * 4 are the write delay. */
7388 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7389#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7390 /*
7391 * RECOVERY=5, HOLD_WR=1
7392 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7393 * WAIT_WR=1, WAIT_RD=2
7394 */
7395 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7396 /*
7397 * HOLD_RD=1
7398 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7399 */
7400 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7401#else
7402 /* EBI2 CS3 muxed address/data,
7403 * two cyc addr enable */
7404 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7405
7406#endif
7407 iounmap(ebi2_cfg_ptr);
7408 }
7409 }
7410}
7411
7412static void __init msm8x60_configure_smc91x(void)
7413{
7414 if (machine_is_msm8x60_sim()) {
7415
7416 smc91x_resources[0].start = 0x1b800300;
7417 smc91x_resources[0].end = 0x1b8003ff;
7418
7419 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7420 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7421
7422 } else if (machine_is_msm8x60_rumi3()) {
7423
7424 smc91x_resources[0].start = 0x1d000300;
7425 smc91x_resources[0].end = 0x1d0003ff;
7426
7427 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7428 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7429 }
7430}
7431
7432static void __init msm8x60_init_tlmm(void)
7433{
7434 if (machine_is_msm8x60_rumi3())
7435 msm_gpio_install_direct_irq(0, 0, 1);
7436}
7437
7438#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7439 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7440 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7441 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7442 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7443
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007444/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007445#define MAX_SDCC_CONTROLLER 5
7446
7447struct msm_sdcc_gpio {
7448 /* maximum 10 GPIOs per SDCC controller */
7449 s16 no;
7450 /* name of this GPIO */
7451 const char *name;
7452 bool always_on;
7453 bool is_enabled;
7454};
7455
7456#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7457static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7458 {159, "sdc1_dat_0"},
7459 {160, "sdc1_dat_1"},
7460 {161, "sdc1_dat_2"},
7461 {162, "sdc1_dat_3"},
7462#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7463 {163, "sdc1_dat_4"},
7464 {164, "sdc1_dat_5"},
7465 {165, "sdc1_dat_6"},
7466 {166, "sdc1_dat_7"},
7467#endif
7468 {167, "sdc1_clk"},
7469 {168, "sdc1_cmd"}
7470};
7471#endif
7472
7473#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7474static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7475 {143, "sdc2_dat_0"},
7476 {144, "sdc2_dat_1", 1},
7477 {145, "sdc2_dat_2"},
7478 {146, "sdc2_dat_3"},
7479#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7480 {147, "sdc2_dat_4"},
7481 {148, "sdc2_dat_5"},
7482 {149, "sdc2_dat_6"},
7483 {150, "sdc2_dat_7"},
7484#endif
7485 {151, "sdc2_cmd"},
7486 {152, "sdc2_clk", 1}
7487};
7488#endif
7489
7490#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7491static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7492 {95, "sdc5_cmd"},
7493 {96, "sdc5_dat_3"},
7494 {97, "sdc5_clk", 1},
7495 {98, "sdc5_dat_2"},
7496 {99, "sdc5_dat_1", 1},
7497 {100, "sdc5_dat_0"}
7498};
7499#endif
7500
7501struct msm_sdcc_pad_pull_cfg {
7502 enum msm_tlmm_pull_tgt pull;
7503 u32 pull_val;
7504};
7505
7506struct msm_sdcc_pad_drv_cfg {
7507 enum msm_tlmm_hdrive_tgt drv;
7508 u32 drv_val;
7509};
7510
7511#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7512static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7513 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7514 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7515 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7516};
7517
7518static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7519 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7520 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7521};
7522
7523static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7524 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7525 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7526 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7527};
7528
7529static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7530 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7531 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7532};
7533#endif
7534
7535#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7536static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7537 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7538 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7539 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7540};
7541
7542static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7543 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7544 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7545};
7546
7547static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7548 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7549 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7550 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7551};
7552
7553static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7554 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7555 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7556};
7557#endif
7558
7559struct msm_sdcc_pin_cfg {
7560 /*
7561 * = 1 if controller pins are using gpios
7562 * = 0 if controller has dedicated MSM pins
7563 */
7564 u8 is_gpio;
7565 u8 cfg_sts;
7566 u8 gpio_data_size;
7567 struct msm_sdcc_gpio *gpio_data;
7568 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7569 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7570 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7571 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7572 u8 pad_drv_data_size;
7573 u8 pad_pull_data_size;
7574 u8 sdio_lpm_gpio_cfg;
7575};
7576
7577
7578static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7579#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7580 [0] = {
7581 .is_gpio = 1,
7582 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7583 .gpio_data = sdc1_gpio_cfg
7584 },
7585#endif
7586#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7587 [1] = {
7588 .is_gpio = 1,
7589 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7590 .gpio_data = sdc2_gpio_cfg
7591 },
7592#endif
7593#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7594 [2] = {
7595 .is_gpio = 0,
7596 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7597 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7598 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7599 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7600 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7601 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7602 },
7603#endif
7604#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7605 [3] = {
7606 .is_gpio = 0,
7607 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7608 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7609 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7610 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7611 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7612 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7613 },
7614#endif
7615#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7616 [4] = {
7617 .is_gpio = 1,
7618 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7619 .gpio_data = sdc5_gpio_cfg
7620 }
7621#endif
7622};
7623
7624static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7625{
7626 int rc = 0;
7627 struct msm_sdcc_pin_cfg *curr;
7628 int n;
7629
7630 curr = &sdcc_pin_cfg_data[dev_id - 1];
7631 if (!curr->gpio_data)
7632 goto out;
7633
7634 for (n = 0; n < curr->gpio_data_size; n++) {
7635 if (enable) {
7636
7637 if (curr->gpio_data[n].always_on &&
7638 curr->gpio_data[n].is_enabled)
7639 continue;
7640 pr_debug("%s: enable: %s\n", __func__,
7641 curr->gpio_data[n].name);
7642 rc = gpio_request(curr->gpio_data[n].no,
7643 curr->gpio_data[n].name);
7644 if (rc) {
7645 pr_err("%s: gpio_request(%d, %s)"
7646 "failed", __func__,
7647 curr->gpio_data[n].no,
7648 curr->gpio_data[n].name);
7649 goto free_gpios;
7650 }
7651 /* set direction as output for all GPIOs */
7652 rc = gpio_direction_output(
7653 curr->gpio_data[n].no, 1);
7654 if (rc) {
7655 pr_err("%s: gpio_direction_output"
7656 "(%d, 1) failed\n", __func__,
7657 curr->gpio_data[n].no);
7658 goto free_gpios;
7659 }
7660 curr->gpio_data[n].is_enabled = 1;
7661 } else {
7662 /*
7663 * now free this GPIO which will put GPIO
7664 * in low power mode and will also put GPIO
7665 * in input mode
7666 */
7667 if (curr->gpio_data[n].always_on)
7668 continue;
7669 pr_debug("%s: disable: %s\n", __func__,
7670 curr->gpio_data[n].name);
7671 gpio_free(curr->gpio_data[n].no);
7672 curr->gpio_data[n].is_enabled = 0;
7673 }
7674 }
7675 curr->cfg_sts = enable;
7676 goto out;
7677
7678free_gpios:
7679 for (; n >= 0; n--)
7680 gpio_free(curr->gpio_data[n].no);
7681out:
7682 return rc;
7683}
7684
7685static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7686{
7687 int rc = 0;
7688 struct msm_sdcc_pin_cfg *curr;
7689 int n;
7690
7691 curr = &sdcc_pin_cfg_data[dev_id - 1];
7692 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7693 goto out;
7694
7695 if (enable) {
7696 /*
7697 * set up the normal driver strength and
7698 * pull config for pads
7699 */
7700 for (n = 0; n < curr->pad_drv_data_size; n++) {
7701 if (curr->sdio_lpm_gpio_cfg) {
7702 if (curr->pad_drv_on_data[n].drv ==
7703 TLMM_HDRV_SDC4_DATA)
7704 continue;
7705 }
7706 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7707 curr->pad_drv_on_data[n].drv_val);
7708 }
7709 for (n = 0; n < curr->pad_pull_data_size; n++) {
7710 if (curr->sdio_lpm_gpio_cfg) {
7711 if (curr->pad_pull_on_data[n].pull ==
7712 TLMM_PULL_SDC4_DATA)
7713 continue;
7714 }
7715 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7716 curr->pad_pull_on_data[n].pull_val);
7717 }
7718 } else {
7719 /* set the low power config for pads */
7720 for (n = 0; n < curr->pad_drv_data_size; n++) {
7721 if (curr->sdio_lpm_gpio_cfg) {
7722 if (curr->pad_drv_off_data[n].drv ==
7723 TLMM_HDRV_SDC4_DATA)
7724 continue;
7725 }
7726 msm_tlmm_set_hdrive(
7727 curr->pad_drv_off_data[n].drv,
7728 curr->pad_drv_off_data[n].drv_val);
7729 }
7730 for (n = 0; n < curr->pad_pull_data_size; n++) {
7731 if (curr->sdio_lpm_gpio_cfg) {
7732 if (curr->pad_pull_off_data[n].pull ==
7733 TLMM_PULL_SDC4_DATA)
7734 continue;
7735 }
7736 msm_tlmm_set_pull(
7737 curr->pad_pull_off_data[n].pull,
7738 curr->pad_pull_off_data[n].pull_val);
7739 }
7740 }
7741 curr->cfg_sts = enable;
7742out:
7743 return rc;
7744}
7745
7746struct sdcc_reg {
7747 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7748 const char *reg_name;
7749 /*
7750 * is set voltage supported for this regulator?
7751 * 0 = not supported, 1 = supported
7752 */
7753 unsigned char set_voltage_sup;
7754 /* voltage level to be set */
7755 unsigned int level;
7756 /* VDD/VCC/VCCQ voltage regulator handle */
7757 struct regulator *reg;
7758 /* is this regulator enabled? */
7759 bool enabled;
7760 /* is this regulator needs to be always on? */
7761 bool always_on;
7762 /* is operating power mode setting required for this regulator? */
7763 bool op_pwr_mode_sup;
7764 /* Load values for low power and high power mode */
7765 unsigned int lpm_uA;
7766 unsigned int hpm_uA;
7767};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007768/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007769static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7770/* only SDCC1 requires VCCQ voltage */
7771static struct sdcc_reg sdcc_vccq_reg_data[1];
7772/* all SDCC controllers may require voting for VDD PAD voltage */
7773static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7774
7775struct sdcc_reg_data {
7776 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7777 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7778 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7779 unsigned char sts; /* regulator enable/disable status */
7780};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007781/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007782static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7783
7784static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7785{
7786 int rc = 0;
7787
7788 /* Get the regulator handle */
7789 vreg->reg = regulator_get(NULL, vreg->reg_name);
7790 if (IS_ERR(vreg->reg)) {
7791 rc = PTR_ERR(vreg->reg);
7792 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7793 __func__, vreg->reg_name, rc);
7794 goto out;
7795 }
7796
7797 /* Set the voltage level if required */
7798 if (vreg->set_voltage_sup) {
7799 rc = regulator_set_voltage(vreg->reg, vreg->level,
7800 vreg->level);
7801 if (rc) {
7802 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7803 __func__, vreg->reg_name, rc);
7804 goto vreg_put;
7805 }
7806 }
7807 goto out;
7808
7809vreg_put:
7810 regulator_put(vreg->reg);
7811out:
7812 return rc;
7813}
7814
7815static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7816{
7817 regulator_put(vreg->reg);
7818}
7819
7820/* this init function should be called only once for each SDCC */
7821static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7822{
7823 int rc = 0;
7824 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7825 struct sdcc_reg_data *curr;
7826
7827 curr = &sdcc_vreg_data[dev_id - 1];
7828 curr_vdd_reg = curr->vdd_data;
7829 curr_vccq_reg = curr->vccq_data;
7830 curr_vddp_reg = curr->vddp_data;
7831
7832 if (init) {
7833 /*
7834 * get the regulator handle from voltage regulator framework
7835 * and then try to set the voltage level for the regulator
7836 */
7837 if (curr_vdd_reg) {
7838 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7839 if (rc)
7840 goto out;
7841 }
7842 if (curr_vccq_reg) {
7843 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7844 if (rc)
7845 goto vdd_reg_deinit;
7846 }
7847 if (curr_vddp_reg) {
7848 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7849 if (rc)
7850 goto vccq_reg_deinit;
7851 }
7852 goto out;
7853 } else
7854 /* deregister with all regulators from regulator framework */
7855 goto vddp_reg_deinit;
7856
7857vddp_reg_deinit:
7858 if (curr_vddp_reg)
7859 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7860vccq_reg_deinit:
7861 if (curr_vccq_reg)
7862 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7863vdd_reg_deinit:
7864 if (curr_vdd_reg)
7865 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7866out:
7867 return rc;
7868}
7869
7870static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7871{
7872 int rc;
7873
7874 if (!vreg->enabled) {
7875 rc = regulator_enable(vreg->reg);
7876 if (rc) {
7877 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7878 __func__, vreg->reg_name, rc);
7879 goto out;
7880 }
7881 vreg->enabled = 1;
7882 }
7883
7884 /* Put always_on regulator in HPM (high power mode) */
7885 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7886 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7887 if (rc < 0) {
7888 pr_err("%s: reg=%s: HPM setting failed"
7889 " hpm_uA=%d, rc=%d\n",
7890 __func__, vreg->reg_name,
7891 vreg->hpm_uA, rc);
7892 goto vreg_disable;
7893 }
7894 rc = 0;
7895 }
7896 goto out;
7897
7898vreg_disable:
7899 regulator_disable(vreg->reg);
7900 vreg->enabled = 0;
7901out:
7902 return rc;
7903}
7904
7905static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7906{
7907 int rc;
7908
7909 /* Never disable always_on regulator */
7910 if (!vreg->always_on) {
7911 rc = regulator_disable(vreg->reg);
7912 if (rc) {
7913 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7914 __func__, vreg->reg_name, rc);
7915 goto out;
7916 }
7917 vreg->enabled = 0;
7918 }
7919
7920 /* Put always_on regulator in LPM (low power mode) */
7921 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7922 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
7923 if (rc < 0) {
7924 pr_err("%s: reg=%s: LPM setting failed"
7925 " lpm_uA=%d, rc=%d\n",
7926 __func__,
7927 vreg->reg_name,
7928 vreg->lpm_uA, rc);
7929 goto out;
7930 }
7931 rc = 0;
7932 }
7933
7934out:
7935 return rc;
7936}
7937
7938static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
7939{
7940 int rc = 0;
7941 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7942 struct sdcc_reg_data *curr;
7943
7944 curr = &sdcc_vreg_data[dev_id - 1];
7945 curr_vdd_reg = curr->vdd_data;
7946 curr_vccq_reg = curr->vccq_data;
7947 curr_vddp_reg = curr->vddp_data;
7948
7949 /* check if regulators are initialized or not? */
7950 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
7951 (curr_vccq_reg && !curr_vccq_reg->reg) ||
7952 (curr_vddp_reg && !curr_vddp_reg->reg)) {
7953 /* initialize voltage regulators required for this SDCC */
7954 rc = msm_sdcc_vreg_init(dev_id, 1);
7955 if (rc) {
7956 pr_err("%s: regulator init failed = %d\n",
7957 __func__, rc);
7958 goto out;
7959 }
7960 }
7961
7962 if (curr->sts == enable)
7963 goto out;
7964
7965 if (curr_vdd_reg) {
7966 if (enable)
7967 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
7968 else
7969 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
7970 if (rc)
7971 goto out;
7972 }
7973
7974 if (curr_vccq_reg) {
7975 if (enable)
7976 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
7977 else
7978 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
7979 if (rc)
7980 goto out;
7981 }
7982
7983 if (curr_vddp_reg) {
7984 if (enable)
7985 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
7986 else
7987 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
7988 if (rc)
7989 goto out;
7990 }
7991 curr->sts = enable;
7992
7993out:
7994 return rc;
7995}
7996
7997static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
7998{
7999 u32 rc_pin_cfg = 0;
8000 u32 rc_vreg_cfg = 0;
8001 u32 rc = 0;
8002 struct platform_device *pdev;
8003 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8004
8005 pdev = container_of(dv, struct platform_device, dev);
8006
8007 /* setup gpio/pad */
8008 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8009 if (curr_pin_cfg->cfg_sts == !!vdd)
8010 goto setup_vreg;
8011
8012 if (curr_pin_cfg->is_gpio)
8013 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8014 else
8015 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8016
8017setup_vreg:
8018 /* setup voltage regulators */
8019 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8020
8021 if (rc_pin_cfg || rc_vreg_cfg)
8022 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8023
8024 return rc;
8025}
8026
8027static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8028{
8029 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8030 struct platform_device *pdev;
8031
8032 pdev = container_of(dv, struct platform_device, dev);
8033 /* setup gpio/pad */
8034 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8035
8036 if (curr_pin_cfg->cfg_sts == active)
8037 return;
8038
8039 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8040 if (curr_pin_cfg->is_gpio)
8041 msm_sdcc_setup_gpio(pdev->id, active);
8042 else
8043 msm_sdcc_setup_pad(pdev->id, active);
8044 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8045}
8046
8047static int msm_sdc3_get_wpswitch(struct device *dev)
8048{
8049 struct platform_device *pdev;
8050 int status;
8051 pdev = container_of(dev, struct platform_device, dev);
8052
8053 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8054 if (status) {
8055 pr_err("%s:Failed to request GPIO %d\n",
8056 __func__, GPIO_SDC_WP);
8057 } else {
8058 status = gpio_direction_input(GPIO_SDC_WP);
8059 if (!status) {
8060 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8061 pr_info("%s: WP Status for Slot %d = %d\n",
8062 __func__, pdev->id, status);
8063 }
8064 gpio_free(GPIO_SDC_WP);
8065 }
8066 return status;
8067}
8068
8069#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8070int sdc5_register_status_notify(void (*callback)(int, void *),
8071 void *dev_id)
8072{
8073 sdc5_status_notify_cb = callback;
8074 sdc5_status_notify_cb_devid = dev_id;
8075 return 0;
8076}
8077#endif
8078
8079#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8080int sdc2_register_status_notify(void (*callback)(int, void *),
8081 void *dev_id)
8082{
8083 sdc2_status_notify_cb = callback;
8084 sdc2_status_notify_cb_devid = dev_id;
8085 return 0;
8086}
8087#endif
8088
8089/* Interrupt handler for SDC2 and SDC5 detection
8090 * This function uses dual-edge interrputs settings in order
8091 * to get SDIO detection when the GPIO is rising and SDIO removal
8092 * when the GPIO is falling */
8093static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8094{
8095 int status;
8096
8097 if (!machine_is_msm8x60_fusion() &&
8098 !machine_is_msm8x60_fusn_ffa())
8099 return IRQ_NONE;
8100
8101 status = gpio_get_value(MDM2AP_SYNC);
8102 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8103 __func__, status);
8104
8105#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8106 if (sdc2_status_notify_cb) {
8107 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8108 sdc2_status_notify_cb(status,
8109 sdc2_status_notify_cb_devid);
8110 }
8111#endif
8112
8113#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8114 if (sdc5_status_notify_cb) {
8115 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8116 sdc5_status_notify_cb(status,
8117 sdc5_status_notify_cb_devid);
8118 }
8119#endif
8120 return IRQ_HANDLED;
8121}
8122
8123static int msm8x60_multi_sdio_init(void)
8124{
8125 int ret, irq_num;
8126
8127 if (!machine_is_msm8x60_fusion() &&
8128 !machine_is_msm8x60_fusn_ffa())
8129 return 0;
8130
8131 ret = msm_gpiomux_get(MDM2AP_SYNC);
8132 if (ret) {
8133 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8134 __func__, MDM2AP_SYNC, ret);
8135 return ret;
8136 }
8137
8138 irq_num = gpio_to_irq(MDM2AP_SYNC);
8139
8140 ret = request_irq(irq_num,
8141 msm8x60_multi_sdio_slot_status_irq,
8142 IRQ_TYPE_EDGE_BOTH,
8143 "sdio_multidetection", NULL);
8144
8145 if (ret) {
8146 pr_err("%s:Failed to request irq, ret=%d\n",
8147 __func__, ret);
8148 return ret;
8149 }
8150
8151 return ret;
8152}
8153
8154#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8155#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8156static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8157{
8158 int status;
8159
8160 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8161 , "SD_HW_Detect");
8162 if (status) {
8163 pr_err("%s:Failed to request GPIO %d\n", __func__,
8164 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8165 } else {
8166 status = gpio_direction_input(
8167 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8168 if (!status)
8169 status = !(gpio_get_value_cansleep(
8170 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8171 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8172 }
8173 return (unsigned int) status;
8174}
8175#endif
8176#endif
8177
8178#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8179static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
8180{
8181 struct platform_device *pdev;
8182 enum msm_mpm_pin pin;
8183 int ret = 0;
8184
8185 pdev = container_of(dev, struct platform_device, dev);
8186
8187 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
8188 if (pdev->id == 4)
8189 pin = MSM_MPM_PIN_SDC4_DAT1;
8190 else
8191 return -EINVAL;
8192
8193 switch (mode) {
8194 case SDC_DAT1_DISABLE:
8195 ret = msm_mpm_enable_pin(pin, 0);
8196 break;
8197 case SDC_DAT1_ENABLE:
8198 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
8199 ret = msm_mpm_enable_pin(pin, 1);
8200 break;
8201 case SDC_DAT1_ENWAKE:
8202 ret = msm_mpm_set_pin_wake(pin, 1);
8203 break;
8204 case SDC_DAT1_DISWAKE:
8205 ret = msm_mpm_set_pin_wake(pin, 0);
8206 break;
8207 default:
8208 ret = -EINVAL;
8209 break;
8210 }
8211 return ret;
8212}
8213#endif
8214#endif
8215
8216#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8217static struct mmc_platform_data msm8x60_sdc1_data = {
8218 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8219 .translate_vdd = msm_sdcc_setup_power,
8220#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8221 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8222#else
8223 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8224#endif
8225 .msmsdcc_fmin = 400000,
8226 .msmsdcc_fmid = 24000000,
8227 .msmsdcc_fmax = 48000000,
8228 .nonremovable = 1,
8229 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008230};
8231#endif
8232
8233#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8234static struct mmc_platform_data msm8x60_sdc2_data = {
8235 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8236 .translate_vdd = msm_sdcc_setup_power,
8237 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8238 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8239 .msmsdcc_fmin = 400000,
8240 .msmsdcc_fmid = 24000000,
8241 .msmsdcc_fmax = 48000000,
8242 .nonremovable = 0,
8243 .pclk_src_dfab = 1,
8244 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008245#ifdef CONFIG_MSM_SDIO_AL
8246 .is_sdio_al_client = 1,
8247#endif
8248};
8249#endif
8250
8251#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8252static struct mmc_platform_data msm8x60_sdc3_data = {
8253 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8254 .translate_vdd = msm_sdcc_setup_power,
8255 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8256 .wpswitch = msm_sdc3_get_wpswitch,
8257#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8258 .status = msm8x60_sdcc_slot_status,
8259 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8260 PMIC_GPIO_SDC3_DET - 1),
8261 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8262#endif
8263 .msmsdcc_fmin = 400000,
8264 .msmsdcc_fmid = 24000000,
8265 .msmsdcc_fmax = 48000000,
8266 .nonremovable = 0,
8267 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008268};
8269#endif
8270
8271#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8272static struct mmc_platform_data msm8x60_sdc4_data = {
8273 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8274 .translate_vdd = msm_sdcc_setup_power,
8275 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8276 .msmsdcc_fmin = 400000,
8277 .msmsdcc_fmid = 24000000,
8278 .msmsdcc_fmax = 48000000,
8279 .nonremovable = 0,
8280 .pclk_src_dfab = 1,
8281 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008282};
8283#endif
8284
8285#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8286static struct mmc_platform_data msm8x60_sdc5_data = {
8287 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8288 .translate_vdd = msm_sdcc_setup_power,
8289 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8290 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8291 .msmsdcc_fmin = 400000,
8292 .msmsdcc_fmid = 24000000,
8293 .msmsdcc_fmax = 48000000,
8294 .nonremovable = 0,
8295 .pclk_src_dfab = 1,
8296 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008297#ifdef CONFIG_MSM_SDIO_AL
8298 .is_sdio_al_client = 1,
8299#endif
8300};
8301#endif
8302
8303static void __init msm8x60_init_mmc(void)
8304{
8305#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8306 /* SDCC1 : eMMC card connected */
8307 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8308 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8309 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8310 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308311 sdcc_vreg_data[0].vdd_data->always_on = 1;
8312 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8313 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8314 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008315
8316 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8317 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8318 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8319 sdcc_vreg_data[0].vccq_data->always_on = 1;
8320
8321 msm_add_sdcc(1, &msm8x60_sdc1_data);
8322#endif
8323#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8324 /*
8325 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8326 * and no card is connected on 8660 SURF/FFA/FLUID.
8327 */
8328 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8329 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8330 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8331 sdcc_vreg_data[1].vdd_data->level = 1800000;
8332
8333 sdcc_vreg_data[1].vccq_data = NULL;
8334
8335 if (machine_is_msm8x60_fusion())
8336 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8337 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8338#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8339 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8340 msm_sdcc_setup_gpio(2, 1);
8341#endif
8342 msm_add_sdcc(2, &msm8x60_sdc2_data);
8343 }
8344#endif
8345#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8346 /* SDCC3 : External card slot connected */
8347 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8348 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8349 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8350 sdcc_vreg_data[2].vdd_data->level = 2850000;
8351 sdcc_vreg_data[2].vdd_data->always_on = 1;
8352 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8353 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8354 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8355
8356 sdcc_vreg_data[2].vccq_data = NULL;
8357
8358 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8359 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8360 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8361 sdcc_vreg_data[2].vddp_data->level = 2850000;
8362 sdcc_vreg_data[2].vddp_data->always_on = 1;
8363 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8364 /* Sleep current required is ~300 uA. But min. RPM
8365 * vote can be in terms of mA (min. 1 mA).
8366 * So let's vote for 2 mA during sleep.
8367 */
8368 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8369 /* Max. Active current required is 16 mA */
8370 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8371
8372 if (machine_is_msm8x60_fluid())
8373 msm8x60_sdc3_data.wpswitch = NULL;
8374 msm_add_sdcc(3, &msm8x60_sdc3_data);
8375#endif
8376#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8377 /* SDCC4 : WLAN WCN1314 chip is connected */
8378 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8379 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8380 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8381 sdcc_vreg_data[3].vdd_data->level = 1800000;
8382
8383 sdcc_vreg_data[3].vccq_data = NULL;
8384
8385 msm_add_sdcc(4, &msm8x60_sdc4_data);
8386#endif
8387#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8388 /*
8389 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8390 * and no card is connected on 8660 SURF/FFA/FLUID.
8391 */
8392 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8393 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8394 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8395 sdcc_vreg_data[4].vdd_data->level = 1800000;
8396
8397 sdcc_vreg_data[4].vccq_data = NULL;
8398
8399 if (machine_is_msm8x60_fusion())
8400 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8401 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8402#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8403 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8404 msm_sdcc_setup_gpio(5, 1);
8405#endif
8406 msm_add_sdcc(5, &msm8x60_sdc5_data);
8407 }
8408#endif
8409}
8410
8411#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8412static inline void display_common_power(int on) {}
8413#else
8414
8415#define _GET_REGULATOR(var, name) do { \
8416 if (var == NULL) { \
8417 var = regulator_get(NULL, name); \
8418 if (IS_ERR(var)) { \
8419 pr_err("'%s' regulator not found, rc=%ld\n", \
8420 name, PTR_ERR(var)); \
8421 var = NULL; \
8422 } \
8423 } \
8424} while (0)
8425
8426static int dsub_regulator(int on)
8427{
8428 static struct regulator *dsub_reg;
8429 static struct regulator *mpp0_reg;
8430 static int dsub_reg_enabled;
8431 int rc = 0;
8432
8433 _GET_REGULATOR(dsub_reg, "8901_l3");
8434 if (IS_ERR(dsub_reg)) {
8435 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8436 __func__, PTR_ERR(dsub_reg));
8437 return PTR_ERR(dsub_reg);
8438 }
8439
8440 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8441 if (IS_ERR(mpp0_reg)) {
8442 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8443 __func__, PTR_ERR(mpp0_reg));
8444 return PTR_ERR(mpp0_reg);
8445 }
8446
8447 if (on && !dsub_reg_enabled) {
8448 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8449 if (rc) {
8450 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8451 " err=%d", __func__, rc);
8452 goto dsub_regulator_err;
8453 }
8454 rc = regulator_enable(dsub_reg);
8455 if (rc) {
8456 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8457 " err=%d", __func__, rc);
8458 goto dsub_regulator_err;
8459 }
8460 rc = regulator_enable(mpp0_reg);
8461 if (rc) {
8462 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8463 " err=%d", __func__, rc);
8464 goto dsub_regulator_err;
8465 }
8466 dsub_reg_enabled = 1;
8467 } else if (!on && dsub_reg_enabled) {
8468 rc = regulator_disable(dsub_reg);
8469 if (rc)
8470 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8471 " err=%d", __func__, rc);
8472 rc = regulator_disable(mpp0_reg);
8473 if (rc)
8474 printk(KERN_WARNING "%s: failed to disable reg "
8475 "8901_mpp0 err=%d", __func__, rc);
8476 dsub_reg_enabled = 0;
8477 }
8478
8479 return rc;
8480
8481dsub_regulator_err:
8482 regulator_put(mpp0_reg);
8483 regulator_put(dsub_reg);
8484 return rc;
8485}
8486
8487static int display_power_on;
8488static void setup_display_power(void)
8489{
8490 if (display_power_on)
8491 if (lcdc_vga_enabled) {
8492 dsub_regulator(1);
8493 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8494 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8495 if (machine_is_msm8x60_ffa() ||
8496 machine_is_msm8x60_fusn_ffa())
8497 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8498 } else {
8499 dsub_regulator(0);
8500 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8501 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8502 if (machine_is_msm8x60_ffa() ||
8503 machine_is_msm8x60_fusn_ffa())
8504 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8505 }
8506 else {
8507 dsub_regulator(0);
8508 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8509 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8510 /* BACKLIGHT */
8511 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8512 /* LVDS */
8513 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8514 }
8515}
8516
8517#define _GET_REGULATOR(var, name) do { \
8518 if (var == NULL) { \
8519 var = regulator_get(NULL, name); \
8520 if (IS_ERR(var)) { \
8521 pr_err("'%s' regulator not found, rc=%ld\n", \
8522 name, PTR_ERR(var)); \
8523 var = NULL; \
8524 } \
8525 } \
8526} while (0)
8527
8528#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8529
8530static void display_common_power(int on)
8531{
8532 int rc;
8533 static struct regulator *display_reg;
8534
8535 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8536 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8537 if (on) {
8538 /* LVDS */
8539 _GET_REGULATOR(display_reg, "8901_l2");
8540 if (!display_reg)
8541 return;
8542 rc = regulator_set_voltage(display_reg,
8543 3300000, 3300000);
8544 if (rc)
8545 goto out;
8546 rc = regulator_enable(display_reg);
8547 if (rc)
8548 goto out;
8549 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8550 "LVDS_STDN_OUT_N");
8551 if (rc) {
8552 printk(KERN_ERR "%s: LVDS gpio %d request"
8553 "failed\n", __func__,
8554 GPIO_LVDS_SHUTDOWN_N);
8555 goto out2;
8556 }
8557
8558 /* BACKLIGHT */
8559 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8560 if (rc) {
8561 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8562 "failed\n", __func__,
8563 GPIO_BACKLIGHT_EN);
8564 goto out3;
8565 }
8566
8567 if (machine_is_msm8x60_ffa() ||
8568 machine_is_msm8x60_fusn_ffa()) {
8569 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8570 "DONGLE_PWR_EN");
8571 if (rc) {
8572 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8573 " %d request failed\n", __func__,
8574 GPIO_DONGLE_PWR_EN);
8575 goto out4;
8576 }
8577 }
8578
8579 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8580 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8581 if (machine_is_msm8x60_ffa() ||
8582 machine_is_msm8x60_fusn_ffa())
8583 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8584 mdelay(20);
8585 display_power_on = 1;
8586 setup_display_power();
8587 } else {
8588 if (display_power_on) {
8589 display_power_on = 0;
8590 setup_display_power();
8591 mdelay(20);
8592 if (machine_is_msm8x60_ffa() ||
8593 machine_is_msm8x60_fusn_ffa())
8594 gpio_free(GPIO_DONGLE_PWR_EN);
8595 goto out4;
8596 }
8597 }
8598 }
8599#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8600 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8601 else if (machine_is_msm8x60_fluid()) {
8602 static struct regulator *fluid_reg;
8603 static struct regulator *fluid_reg2;
8604
8605 if (on) {
8606 _GET_REGULATOR(fluid_reg, "8901_l2");
8607 if (!fluid_reg)
8608 return;
8609 _GET_REGULATOR(fluid_reg2, "8058_s3");
8610 if (!fluid_reg2) {
8611 regulator_put(fluid_reg);
8612 return;
8613 }
8614 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8615 if (rc) {
8616 regulator_put(fluid_reg2);
8617 regulator_put(fluid_reg);
8618 return;
8619 }
8620 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8621 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8622 regulator_enable(fluid_reg);
8623 regulator_enable(fluid_reg2);
8624 msleep(20);
8625 gpio_direction_output(GPIO_RESX_N, 0);
8626 udelay(10);
8627 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8628 display_power_on = 1;
8629 setup_display_power();
8630 } else {
8631 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8632 gpio_free(GPIO_RESX_N);
8633 msleep(20);
8634 regulator_disable(fluid_reg2);
8635 regulator_disable(fluid_reg);
8636 regulator_put(fluid_reg2);
8637 regulator_put(fluid_reg);
8638 display_power_on = 0;
8639 setup_display_power();
8640 fluid_reg = NULL;
8641 fluid_reg2 = NULL;
8642 }
8643 }
8644#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008645#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8646 else if (machine_is_msm8x60_dragon()) {
8647 static struct regulator *dragon_reg;
8648 static struct regulator *dragon_reg2;
8649
8650 if (on) {
8651 _GET_REGULATOR(dragon_reg, "8901_l2");
8652 if (!dragon_reg)
8653 return;
8654 _GET_REGULATOR(dragon_reg2, "8058_l16");
8655 if (!dragon_reg2) {
8656 regulator_put(dragon_reg);
8657 dragon_reg = NULL;
8658 return;
8659 }
8660
8661 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8662 if (rc) {
8663 pr_err("%s: gpio %d request failed with rc=%d\n",
8664 __func__, GPIO_NT35582_BL_EN, rc);
8665 regulator_put(dragon_reg);
8666 regulator_put(dragon_reg2);
8667 dragon_reg = NULL;
8668 dragon_reg2 = NULL;
8669 return;
8670 }
8671
8672 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8673 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8674 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8675 pr_err("%s: config gpio '%d' failed!\n",
8676 __func__, GPIO_NT35582_RESET);
8677 gpio_free(GPIO_NT35582_BL_EN);
8678 regulator_put(dragon_reg);
8679 regulator_put(dragon_reg2);
8680 dragon_reg = NULL;
8681 dragon_reg2 = NULL;
8682 return;
8683 }
8684
8685 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8686 if (rc) {
8687 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8688 __func__, GPIO_NT35582_RESET, rc);
8689 gpio_free(GPIO_NT35582_BL_EN);
8690 regulator_put(dragon_reg);
8691 regulator_put(dragon_reg2);
8692 dragon_reg = NULL;
8693 dragon_reg2 = NULL;
8694 return;
8695 }
8696
8697 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8698 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8699 regulator_enable(dragon_reg);
8700 regulator_enable(dragon_reg2);
8701 msleep(20);
8702
8703 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8704 msleep(20);
8705 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8706 msleep(20);
8707 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8708 msleep(50);
8709
8710 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8711
8712 display_power_on = 1;
8713 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8714 gpio_free(GPIO_NT35582_RESET);
8715 gpio_free(GPIO_NT35582_BL_EN);
8716 regulator_disable(dragon_reg2);
8717 regulator_disable(dragon_reg);
8718 regulator_put(dragon_reg2);
8719 regulator_put(dragon_reg);
8720 display_power_on = 0;
8721 dragon_reg = NULL;
8722 dragon_reg2 = NULL;
8723 }
8724 }
8725#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008726 return;
8727
8728out4:
8729 gpio_free(GPIO_BACKLIGHT_EN);
8730out3:
8731 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8732out2:
8733 regulator_disable(display_reg);
8734out:
8735 regulator_put(display_reg);
8736 display_reg = NULL;
8737}
8738#undef _GET_REGULATOR
8739#endif
8740
8741static int mipi_dsi_panel_power(int on);
8742
8743#define LCDC_NUM_GPIO 28
8744#define LCDC_GPIO_START 0
8745
8746static void lcdc_samsung_panel_power(int on)
8747{
8748 int n, ret = 0;
8749
8750 display_common_power(on);
8751
8752 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8753 if (on) {
8754 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8755 if (unlikely(ret)) {
8756 pr_err("%s not able to get gpio\n", __func__);
8757 break;
8758 }
8759 } else
8760 gpio_free(LCDC_GPIO_START + n);
8761 }
8762
8763 if (ret) {
8764 for (n--; n >= 0; n--)
8765 gpio_free(LCDC_GPIO_START + n);
8766 }
8767
8768 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8769}
8770
8771#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8772#define _GET_REGULATOR(var, name) do { \
8773 var = regulator_get(NULL, name); \
8774 if (IS_ERR(var)) { \
8775 pr_err("'%s' regulator not found, rc=%ld\n", \
8776 name, IS_ERR(var)); \
8777 var = NULL; \
8778 return -ENODEV; \
8779 } \
8780} while (0)
8781
8782static int hdmi_enable_5v(int on)
8783{
8784 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8785 static struct regulator *reg_8901_mpp0; /* External 5V */
8786 static int prev_on;
8787 int rc;
8788
8789 if (on == prev_on)
8790 return 0;
8791
8792 if (!reg_8901_hdmi_mvs)
8793 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8794 if (!reg_8901_mpp0)
8795 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8796
8797 if (on) {
8798 rc = regulator_enable(reg_8901_mpp0);
8799 if (rc) {
8800 pr_err("'%s' regulator enable failed, rc=%d\n",
8801 "reg_8901_mpp0", rc);
8802 return rc;
8803 }
8804 rc = regulator_enable(reg_8901_hdmi_mvs);
8805 if (rc) {
8806 pr_err("'%s' regulator enable failed, rc=%d\n",
8807 "8901_hdmi_mvs", rc);
8808 return rc;
8809 }
8810 pr_info("%s(on): success\n", __func__);
8811 } else {
8812 rc = regulator_disable(reg_8901_hdmi_mvs);
8813 if (rc)
8814 pr_warning("'%s' regulator disable failed, rc=%d\n",
8815 "8901_hdmi_mvs", rc);
8816 rc = regulator_disable(reg_8901_mpp0);
8817 if (rc)
8818 pr_warning("'%s' regulator disable failed, rc=%d\n",
8819 "reg_8901_mpp0", rc);
8820 pr_info("%s(off): success\n", __func__);
8821 }
8822
8823 prev_on = on;
8824
8825 return 0;
8826}
8827
8828static int hdmi_core_power(int on, int show)
8829{
8830 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8831 static int prev_on;
8832 int rc;
8833
8834 if (on == prev_on)
8835 return 0;
8836
8837 if (!reg_8058_l16)
8838 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8839
8840 if (on) {
8841 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8842 if (!rc)
8843 rc = regulator_enable(reg_8058_l16);
8844 if (rc) {
8845 pr_err("'%s' regulator enable failed, rc=%d\n",
8846 "8058_l16", rc);
8847 return rc;
8848 }
8849 rc = gpio_request(170, "HDMI_DDC_CLK");
8850 if (rc) {
8851 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8852 "HDMI_DDC_CLK", 170, rc);
8853 goto error1;
8854 }
8855 rc = gpio_request(171, "HDMI_DDC_DATA");
8856 if (rc) {
8857 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8858 "HDMI_DDC_DATA", 171, rc);
8859 goto error2;
8860 }
8861 rc = gpio_request(172, "HDMI_HPD");
8862 if (rc) {
8863 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8864 "HDMI_HPD", 172, rc);
8865 goto error3;
8866 }
8867 pr_info("%s(on): success\n", __func__);
8868 } else {
8869 gpio_free(170);
8870 gpio_free(171);
8871 gpio_free(172);
8872 rc = regulator_disable(reg_8058_l16);
8873 if (rc)
8874 pr_warning("'%s' regulator disable failed, rc=%d\n",
8875 "8058_l16", rc);
8876 pr_info("%s(off): success\n", __func__);
8877 }
8878
8879 prev_on = on;
8880
8881 return 0;
8882
8883error3:
8884 gpio_free(171);
8885error2:
8886 gpio_free(170);
8887error1:
8888 regulator_disable(reg_8058_l16);
8889 return rc;
8890}
8891
8892static int hdmi_cec_power(int on)
8893{
8894 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8895 static int prev_on;
8896 int rc;
8897
8898 if (on == prev_on)
8899 return 0;
8900
8901 if (!reg_8901_l3)
8902 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8903
8904 if (on) {
8905 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8906 if (!rc)
8907 rc = regulator_enable(reg_8901_l3);
8908 if (rc) {
8909 pr_err("'%s' regulator enable failed, rc=%d\n",
8910 "8901_l3", rc);
8911 return rc;
8912 }
8913 rc = gpio_request(169, "HDMI_CEC_VAR");
8914 if (rc) {
8915 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8916 "HDMI_CEC_VAR", 169, rc);
8917 goto error;
8918 }
8919 pr_info("%s(on): success\n", __func__);
8920 } else {
8921 gpio_free(169);
8922 rc = regulator_disable(reg_8901_l3);
8923 if (rc)
8924 pr_warning("'%s' regulator disable failed, rc=%d\n",
8925 "8901_l3", rc);
8926 pr_info("%s(off): success\n", __func__);
8927 }
8928
8929 prev_on = on;
8930
8931 return 0;
8932error:
8933 regulator_disable(reg_8901_l3);
8934 return rc;
8935}
8936
8937#undef _GET_REGULATOR
8938
8939#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
8940
8941static int lcdc_panel_power(int on)
8942{
8943 int flag_on = !!on;
8944 static int lcdc_power_save_on;
8945
8946 if (lcdc_power_save_on == flag_on)
8947 return 0;
8948
8949 lcdc_power_save_on = flag_on;
8950
8951 lcdc_samsung_panel_power(on);
8952
8953 return 0;
8954}
8955
8956#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08008957
8958static struct msm_bus_vectors rotator_init_vectors[] = {
8959 {
8960 .src = MSM_BUS_MASTER_ROTATOR,
8961 .dst = MSM_BUS_SLAVE_SMI,
8962 .ab = 0,
8963 .ib = 0,
8964 },
8965 {
8966 .src = MSM_BUS_MASTER_ROTATOR,
8967 .dst = MSM_BUS_SLAVE_EBI_CH0,
8968 .ab = 0,
8969 .ib = 0,
8970 },
8971};
8972
8973static struct msm_bus_vectors rotator_ui_vectors[] = {
8974 {
8975 .src = MSM_BUS_MASTER_ROTATOR,
8976 .dst = MSM_BUS_SLAVE_SMI,
8977 .ab = 0,
8978 .ib = 0,
8979 },
8980 {
8981 .src = MSM_BUS_MASTER_ROTATOR,
8982 .dst = MSM_BUS_SLAVE_EBI_CH0,
8983 .ab = (1024 * 600 * 4 * 2 * 60),
8984 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
8985 },
8986};
8987
8988static struct msm_bus_vectors rotator_vga_vectors[] = {
8989 {
8990 .src = MSM_BUS_MASTER_ROTATOR,
8991 .dst = MSM_BUS_SLAVE_SMI,
8992 .ab = (640 * 480 * 2 * 2 * 30),
8993 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
8994 },
8995 {
8996 .src = MSM_BUS_MASTER_ROTATOR,
8997 .dst = MSM_BUS_SLAVE_EBI_CH0,
8998 .ab = (640 * 480 * 2 * 2 * 30),
8999 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9000 },
9001};
9002
9003static struct msm_bus_vectors rotator_720p_vectors[] = {
9004 {
9005 .src = MSM_BUS_MASTER_ROTATOR,
9006 .dst = MSM_BUS_SLAVE_SMI,
9007 .ab = (1280 * 736 * 2 * 2 * 30),
9008 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9009 },
9010 {
9011 .src = MSM_BUS_MASTER_ROTATOR,
9012 .dst = MSM_BUS_SLAVE_EBI_CH0,
9013 .ab = (1280 * 736 * 2 * 2 * 30),
9014 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9015 },
9016};
9017
9018static struct msm_bus_vectors rotator_1080p_vectors[] = {
9019 {
9020 .src = MSM_BUS_MASTER_ROTATOR,
9021 .dst = MSM_BUS_SLAVE_SMI,
9022 .ab = (1920 * 1088 * 2 * 2 * 30),
9023 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9024 },
9025 {
9026 .src = MSM_BUS_MASTER_ROTATOR,
9027 .dst = MSM_BUS_SLAVE_EBI_CH0,
9028 .ab = (1920 * 1088 * 2 * 2 * 30),
9029 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9030 },
9031};
9032
9033static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9034 {
9035 ARRAY_SIZE(rotator_init_vectors),
9036 rotator_init_vectors,
9037 },
9038 {
9039 ARRAY_SIZE(rotator_ui_vectors),
9040 rotator_ui_vectors,
9041 },
9042 {
9043 ARRAY_SIZE(rotator_vga_vectors),
9044 rotator_vga_vectors,
9045 },
9046 {
9047 ARRAY_SIZE(rotator_720p_vectors),
9048 rotator_720p_vectors,
9049 },
9050 {
9051 ARRAY_SIZE(rotator_1080p_vectors),
9052 rotator_1080p_vectors,
9053 },
9054};
9055
9056struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9057 rotator_bus_scale_usecases,
9058 ARRAY_SIZE(rotator_bus_scale_usecases),
9059 .name = "rotator",
9060};
9061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009062static struct msm_bus_vectors mdp_init_vectors[] = {
9063 /* For now, 0th array entry is reserved.
9064 * Please leave 0 as is and don't use it
9065 */
9066 {
9067 .src = MSM_BUS_MASTER_MDP_PORT0,
9068 .dst = MSM_BUS_SLAVE_SMI,
9069 .ab = 0,
9070 .ib = 0,
9071 },
9072 /* Master and slaves can be from different fabrics */
9073 {
9074 .src = MSM_BUS_MASTER_MDP_PORT0,
9075 .dst = MSM_BUS_SLAVE_EBI_CH0,
9076 .ab = 0,
9077 .ib = 0,
9078 },
9079};
9080
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009081#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9082static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
9083 /* If HDMI is used as primary */
9084 {
9085 .src = MSM_BUS_MASTER_MDP_PORT0,
9086 .dst = MSM_BUS_SLAVE_SMI,
9087 .ab = 2000000000,
9088 .ib = 2000000000,
9089 },
9090 /* Master and slaves can be from different fabrics */
9091 {
9092 .src = MSM_BUS_MASTER_MDP_PORT0,
9093 .dst = MSM_BUS_SLAVE_EBI_CH0,
9094 .ab = 2000000000,
9095 .ib = 2000000000,
9096 },
9097};
9098
9099static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9100 {
9101 ARRAY_SIZE(mdp_init_vectors),
9102 mdp_init_vectors,
9103 },
9104 {
9105 ARRAY_SIZE(hdmi_as_primary_vectors),
9106 hdmi_as_primary_vectors,
9107 },
9108 {
9109 ARRAY_SIZE(hdmi_as_primary_vectors),
9110 hdmi_as_primary_vectors,
9111 },
9112 {
9113 ARRAY_SIZE(hdmi_as_primary_vectors),
9114 hdmi_as_primary_vectors,
9115 },
9116 {
9117 ARRAY_SIZE(hdmi_as_primary_vectors),
9118 hdmi_as_primary_vectors,
9119 },
9120 {
9121 ARRAY_SIZE(hdmi_as_primary_vectors),
9122 hdmi_as_primary_vectors,
9123 },
9124};
9125#else
9126#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009127static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9128 /* Default case static display/UI/2d/3d if FB SMI */
9129 {
9130 .src = MSM_BUS_MASTER_MDP_PORT0,
9131 .dst = MSM_BUS_SLAVE_SMI,
9132 .ab = 388800000,
9133 .ib = 486000000,
9134 },
9135 /* Master and slaves can be from different fabrics */
9136 {
9137 .src = MSM_BUS_MASTER_MDP_PORT0,
9138 .dst = MSM_BUS_SLAVE_EBI_CH0,
9139 .ab = 0,
9140 .ib = 0,
9141 },
9142};
9143
9144static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9145 /* Default case static display/UI/2d/3d if FB SMI */
9146 {
9147 .src = MSM_BUS_MASTER_MDP_PORT0,
9148 .dst = MSM_BUS_SLAVE_SMI,
9149 .ab = 0,
9150 .ib = 0,
9151 },
9152 /* Master and slaves can be from different fabrics */
9153 {
9154 .src = MSM_BUS_MASTER_MDP_PORT0,
9155 .dst = MSM_BUS_SLAVE_EBI_CH0,
9156 .ab = 388800000,
9157 .ib = 486000000 * 2,
9158 },
9159};
9160static struct msm_bus_vectors mdp_vga_vectors[] = {
9161 /* VGA and less video */
9162 {
9163 .src = MSM_BUS_MASTER_MDP_PORT0,
9164 .dst = MSM_BUS_SLAVE_SMI,
9165 .ab = 458092800,
9166 .ib = 572616000,
9167 },
9168 {
9169 .src = MSM_BUS_MASTER_MDP_PORT0,
9170 .dst = MSM_BUS_SLAVE_EBI_CH0,
9171 .ab = 458092800,
9172 .ib = 572616000 * 2,
9173 },
9174};
9175static struct msm_bus_vectors mdp_720p_vectors[] = {
9176 /* 720p and less video */
9177 {
9178 .src = MSM_BUS_MASTER_MDP_PORT0,
9179 .dst = MSM_BUS_SLAVE_SMI,
9180 .ab = 471744000,
9181 .ib = 589680000,
9182 },
9183 /* Master and slaves can be from different fabrics */
9184 {
9185 .src = MSM_BUS_MASTER_MDP_PORT0,
9186 .dst = MSM_BUS_SLAVE_EBI_CH0,
9187 .ab = 471744000,
9188 .ib = 589680000 * 2,
9189 },
9190};
9191
9192static struct msm_bus_vectors mdp_1080p_vectors[] = {
9193 /* 1080p and less video */
9194 {
9195 .src = MSM_BUS_MASTER_MDP_PORT0,
9196 .dst = MSM_BUS_SLAVE_SMI,
9197 .ab = 575424000,
9198 .ib = 719280000,
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 = 575424000,
9205 .ib = 719280000 * 2,
9206 },
9207};
9208
9209#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009210static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9211 /* Default case static display/UI/2d/3d if FB SMI */
9212 {
9213 .src = MSM_BUS_MASTER_MDP_PORT0,
9214 .dst = MSM_BUS_SLAVE_SMI,
9215 .ab = 175110000,
9216 .ib = 218887500,
9217 },
9218 /* Master and slaves can be from different fabrics */
9219 {
9220 .src = MSM_BUS_MASTER_MDP_PORT0,
9221 .dst = MSM_BUS_SLAVE_EBI_CH0,
9222 .ab = 0,
9223 .ib = 0,
9224 },
9225};
9226
9227static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9228 /* Default case static display/UI/2d/3d if FB SMI */
9229 {
9230 .src = MSM_BUS_MASTER_MDP_PORT0,
9231 .dst = MSM_BUS_SLAVE_SMI,
9232 .ab = 0,
9233 .ib = 0,
9234 },
9235 /* Master and slaves can be from different fabrics */
9236 {
9237 .src = MSM_BUS_MASTER_MDP_PORT0,
9238 .dst = MSM_BUS_SLAVE_EBI_CH0,
9239 .ab = 216000000,
9240 .ib = 270000000 * 2,
9241 },
9242};
9243static struct msm_bus_vectors mdp_vga_vectors[] = {
9244 /* VGA and less video */
9245 {
9246 .src = MSM_BUS_MASTER_MDP_PORT0,
9247 .dst = MSM_BUS_SLAVE_SMI,
9248 .ab = 216000000,
9249 .ib = 270000000,
9250 },
9251 {
9252 .src = MSM_BUS_MASTER_MDP_PORT0,
9253 .dst = MSM_BUS_SLAVE_EBI_CH0,
9254 .ab = 216000000,
9255 .ib = 270000000 * 2,
9256 },
9257};
9258
9259static struct msm_bus_vectors mdp_720p_vectors[] = {
9260 /* 720p and less video */
9261 {
9262 .src = MSM_BUS_MASTER_MDP_PORT0,
9263 .dst = MSM_BUS_SLAVE_SMI,
9264 .ab = 230400000,
9265 .ib = 288000000,
9266 },
9267 /* Master and slaves can be from different fabrics */
9268 {
9269 .src = MSM_BUS_MASTER_MDP_PORT0,
9270 .dst = MSM_BUS_SLAVE_EBI_CH0,
9271 .ab = 230400000,
9272 .ib = 288000000 * 2,
9273 },
9274};
9275
9276static struct msm_bus_vectors mdp_1080p_vectors[] = {
9277 /* 1080p and less video */
9278 {
9279 .src = MSM_BUS_MASTER_MDP_PORT0,
9280 .dst = MSM_BUS_SLAVE_SMI,
9281 .ab = 334080000,
9282 .ib = 417600000,
9283 },
9284 /* Master and slaves can be from different fabrics */
9285 {
9286 .src = MSM_BUS_MASTER_MDP_PORT0,
9287 .dst = MSM_BUS_SLAVE_EBI_CH0,
9288 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009289 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009290 },
9291};
9292
9293#endif
9294static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9295 {
9296 ARRAY_SIZE(mdp_init_vectors),
9297 mdp_init_vectors,
9298 },
9299 {
9300 ARRAY_SIZE(mdp_sd_smi_vectors),
9301 mdp_sd_smi_vectors,
9302 },
9303 {
9304 ARRAY_SIZE(mdp_sd_ebi_vectors),
9305 mdp_sd_ebi_vectors,
9306 },
9307 {
9308 ARRAY_SIZE(mdp_vga_vectors),
9309 mdp_vga_vectors,
9310 },
9311 {
9312 ARRAY_SIZE(mdp_720p_vectors),
9313 mdp_720p_vectors,
9314 },
9315 {
9316 ARRAY_SIZE(mdp_1080p_vectors),
9317 mdp_1080p_vectors,
9318 },
9319};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009320#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009321static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9322 mdp_bus_scale_usecases,
9323 ARRAY_SIZE(mdp_bus_scale_usecases),
9324 .name = "mdp",
9325};
9326
9327#endif
9328#ifdef CONFIG_MSM_BUS_SCALING
9329static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9330 /* For now, 0th array entry is reserved.
9331 * Please leave 0 as is and don't use it
9332 */
9333 {
9334 .src = MSM_BUS_MASTER_MDP_PORT0,
9335 .dst = MSM_BUS_SLAVE_SMI,
9336 .ab = 0,
9337 .ib = 0,
9338 },
9339 /* Master and slaves can be from different fabrics */
9340 {
9341 .src = MSM_BUS_MASTER_MDP_PORT0,
9342 .dst = MSM_BUS_SLAVE_EBI_CH0,
9343 .ab = 0,
9344 .ib = 0,
9345 },
9346};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009347#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9348static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9349 /* For now, 0th array entry is reserved.
9350 * Please leave 0 as is and don't use it
9351 */
9352 {
9353 .src = MSM_BUS_MASTER_MDP_PORT0,
9354 .dst = MSM_BUS_SLAVE_SMI,
9355 .ab = 2000000000,
9356 .ib = 2000000000,
9357 },
9358 /* Master and slaves can be from different fabrics */
9359 {
9360 .src = MSM_BUS_MASTER_MDP_PORT0,
9361 .dst = MSM_BUS_SLAVE_EBI_CH0,
9362 .ab = 2000000000,
9363 .ib = 2000000000,
9364 },
9365};
9366#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009367static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9368 /* For now, 0th array entry is reserved.
9369 * Please leave 0 as is and don't use it
9370 */
9371 {
9372 .src = MSM_BUS_MASTER_MDP_PORT0,
9373 .dst = MSM_BUS_SLAVE_SMI,
9374 .ab = 566092800,
9375 .ib = 707616000,
9376 },
9377 /* Master and slaves can be from different fabrics */
9378 {
9379 .src = MSM_BUS_MASTER_MDP_PORT0,
9380 .dst = MSM_BUS_SLAVE_EBI_CH0,
9381 .ab = 566092800,
9382 .ib = 707616000,
9383 },
9384};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009385#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009386static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9387 {
9388 ARRAY_SIZE(dtv_bus_init_vectors),
9389 dtv_bus_init_vectors,
9390 },
9391 {
9392 ARRAY_SIZE(dtv_bus_def_vectors),
9393 dtv_bus_def_vectors,
9394 },
9395};
9396static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9397 dtv_bus_scale_usecases,
9398 ARRAY_SIZE(dtv_bus_scale_usecases),
9399 .name = "dtv",
9400};
9401
9402static struct lcdc_platform_data dtv_pdata = {
9403 .bus_scale_table = &dtv_bus_scale_pdata,
9404};
9405#endif
9406
9407
9408static struct lcdc_platform_data lcdc_pdata = {
9409 .lcdc_power_save = lcdc_panel_power,
9410};
9411
9412
9413#define MDP_VSYNC_GPIO 28
9414
9415/*
9416 * MIPI_DSI only use 8058_LDO0 which need always on
9417 * therefore it need to be put at low power mode if
9418 * it was not used instead of turn it off.
9419 */
9420static int mipi_dsi_panel_power(int on)
9421{
9422 int flag_on = !!on;
9423 static int mipi_dsi_power_save_on;
9424 static struct regulator *ldo0;
9425 int rc = 0;
9426
9427 if (mipi_dsi_power_save_on == flag_on)
9428 return 0;
9429
9430 mipi_dsi_power_save_on = flag_on;
9431
9432 if (ldo0 == NULL) { /* init */
9433 ldo0 = regulator_get(NULL, "8058_l0");
9434 if (IS_ERR(ldo0)) {
9435 pr_debug("%s: LDO0 failed\n", __func__);
9436 rc = PTR_ERR(ldo0);
9437 return rc;
9438 }
9439
9440 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9441 if (rc)
9442 goto out;
9443
9444 rc = regulator_enable(ldo0);
9445 if (rc)
9446 goto out;
9447 }
9448
9449 if (on) {
9450 /* set ldo0 to HPM */
9451 rc = regulator_set_optimum_mode(ldo0, 100000);
9452 if (rc < 0)
9453 goto out;
9454 } else {
9455 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309456 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009457 if (rc < 0)
9458 goto out;
9459 }
9460
9461 return 0;
9462out:
9463 regulator_disable(ldo0);
9464 regulator_put(ldo0);
9465 ldo0 = NULL;
9466 return rc;
9467}
9468
9469static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9470 .vsync_gpio = MDP_VSYNC_GPIO,
9471 .dsi_power_save = mipi_dsi_panel_power,
9472};
9473
9474#ifdef CONFIG_FB_MSM_TVOUT
9475static struct regulator *reg_8058_l13;
9476
9477static int atv_dac_power(int on)
9478{
9479 int rc = 0;
9480 #define _GET_REGULATOR(var, name) do { \
9481 var = regulator_get(NULL, name); \
9482 if (IS_ERR(var)) { \
9483 pr_info("'%s' regulator not found, rc=%ld\n", \
9484 name, IS_ERR(var)); \
9485 var = NULL; \
9486 return -ENODEV; \
9487 } \
9488 } while (0)
9489
9490 if (!reg_8058_l13)
9491 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9492 #undef _GET_REGULATOR
9493
9494 if (on) {
9495 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9496 if (rc) {
9497 pr_info("%s: '%s' regulator set voltage failed,\
9498 rc=%d\n", __func__, "8058_l13", rc);
9499 return rc;
9500 }
9501
9502 rc = regulator_enable(reg_8058_l13);
9503 if (rc) {
9504 pr_err("%s: '%s' regulator enable failed,\
9505 rc=%d\n", __func__, "8058_l13", rc);
9506 return rc;
9507 }
9508 } else {
9509 rc = regulator_force_disable(reg_8058_l13);
9510 if (rc)
9511 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9512 __func__, "8058_l13", rc);
9513 }
9514 return rc;
9515
9516}
9517#endif
9518
9519#ifdef CONFIG_FB_MSM_MIPI_DSI
9520int mdp_core_clk_rate_table[] = {
9521 85330000,
9522 85330000,
9523 160000000,
9524 200000000,
9525};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009526#elif defined(CONFIG_FB_MSM_HDMI_AS_PRIMARY)
9527int mdp_core_clk_rate_table[] = {
9528 200000000,
9529 200000000,
9530 200000000,
9531 200000000,
9532};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009533#else
9534int mdp_core_clk_rate_table[] = {
9535 59080000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009536 85330000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009537 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009538 200000000,
9539};
9540#endif
9541
9542static struct msm_panel_common_pdata mdp_pdata = {
9543 .gpio = MDP_VSYNC_GPIO,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009544#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9545 .mdp_core_clk_rate = 200000000,
9546#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009547 .mdp_core_clk_rate = 59080000,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009548#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009549 .mdp_core_clk_table = mdp_core_clk_rate_table,
9550 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9551#ifdef CONFIG_MSM_BUS_SCALING
9552 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9553#endif
9554 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009555#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
9556 .mem_hid = ION_CP_WB_HEAP_ID,
9557#else
9558 .mem_hid = MEMTYPE_EBI1,
9559#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009560};
9561
Huaibin Yanga5419422011-12-08 23:52:10 -08009562static void __init reserve_mdp_memory(void)
9563{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009564 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9565 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9566#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9567 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9568 mdp_pdata.ov0_wb_size;
9569 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9570 mdp_pdata.ov1_wb_size;
9571#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009572}
9573
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009574#ifdef CONFIG_FB_MSM_TVOUT
9575
9576#ifdef CONFIG_MSM_BUS_SCALING
9577static struct msm_bus_vectors atv_bus_init_vectors[] = {
9578 /* For now, 0th array entry is reserved.
9579 * Please leave 0 as is and don't use it
9580 */
9581 {
9582 .src = MSM_BUS_MASTER_MDP_PORT0,
9583 .dst = MSM_BUS_SLAVE_SMI,
9584 .ab = 0,
9585 .ib = 0,
9586 },
9587 /* Master and slaves can be from different fabrics */
9588 {
9589 .src = MSM_BUS_MASTER_MDP_PORT0,
9590 .dst = MSM_BUS_SLAVE_EBI_CH0,
9591 .ab = 0,
9592 .ib = 0,
9593 },
9594};
9595static struct msm_bus_vectors atv_bus_def_vectors[] = {
9596 /* For now, 0th array entry is reserved.
9597 * Please leave 0 as is and don't use it
9598 */
9599 {
9600 .src = MSM_BUS_MASTER_MDP_PORT0,
9601 .dst = MSM_BUS_SLAVE_SMI,
9602 .ab = 236390400,
9603 .ib = 265939200,
9604 },
9605 /* Master and slaves can be from different fabrics */
9606 {
9607 .src = MSM_BUS_MASTER_MDP_PORT0,
9608 .dst = MSM_BUS_SLAVE_EBI_CH0,
9609 .ab = 236390400,
9610 .ib = 265939200,
9611 },
9612};
9613static struct msm_bus_paths atv_bus_scale_usecases[] = {
9614 {
9615 ARRAY_SIZE(atv_bus_init_vectors),
9616 atv_bus_init_vectors,
9617 },
9618 {
9619 ARRAY_SIZE(atv_bus_def_vectors),
9620 atv_bus_def_vectors,
9621 },
9622};
9623static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9624 atv_bus_scale_usecases,
9625 ARRAY_SIZE(atv_bus_scale_usecases),
9626 .name = "atv",
9627};
9628#endif
9629
9630static struct tvenc_platform_data atv_pdata = {
9631 .poll = 0,
9632 .pm_vid_en = atv_dac_power,
9633#ifdef CONFIG_MSM_BUS_SCALING
9634 .bus_scale_table = &atv_bus_scale_pdata,
9635#endif
9636};
9637#endif
9638
9639static void __init msm_fb_add_devices(void)
9640{
9641#ifdef CONFIG_FB_MSM_LCDC_DSUB
9642 mdp_pdata.mdp_core_clk_table = NULL;
9643 mdp_pdata.num_mdp_clk = 0;
9644 mdp_pdata.mdp_core_clk_rate = 200000000;
9645#endif
9646 if (machine_is_msm8x60_rumi3())
9647 msm_fb_register_device("mdp", NULL);
9648 else
9649 msm_fb_register_device("mdp", &mdp_pdata);
9650
9651 msm_fb_register_device("lcdc", &lcdc_pdata);
9652 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9653#ifdef CONFIG_MSM_BUS_SCALING
9654 msm_fb_register_device("dtv", &dtv_pdata);
9655#endif
9656#ifdef CONFIG_FB_MSM_TVOUT
9657 msm_fb_register_device("tvenc", &atv_pdata);
9658 msm_fb_register_device("tvout_device", NULL);
9659#endif
9660}
9661
9662#if (defined(CONFIG_MARIMBA_CORE)) && \
9663 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9664
9665static const struct {
9666 char *name;
9667 int vmin;
9668 int vmax;
9669} bt_regs_info[] = {
9670 { "8058_s3", 1800000, 1800000 },
9671 { "8058_s2", 1300000, 1300000 },
9672 { "8058_l8", 2900000, 3050000 },
9673};
9674
9675static struct {
9676 bool enabled;
9677} bt_regs_status[] = {
9678 { false },
9679 { false },
9680 { false },
9681};
9682static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9683
9684static int bahama_bt(int on)
9685{
9686 int rc;
9687 int i;
9688 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9689
9690 struct bahama_variant_register {
9691 const size_t size;
9692 const struct bahama_config_register *set;
9693 };
9694
9695 const struct bahama_config_register *p;
9696
9697 u8 version;
9698
9699 const struct bahama_config_register v10_bt_on[] = {
9700 { 0xE9, 0x00, 0xFF },
9701 { 0xF4, 0x80, 0xFF },
9702 { 0xE4, 0x00, 0xFF },
9703 { 0xE5, 0x00, 0x0F },
9704#ifdef CONFIG_WLAN
9705 { 0xE6, 0x38, 0x7F },
9706 { 0xE7, 0x06, 0xFF },
9707#endif
9708 { 0xE9, 0x21, 0xFF },
9709 { 0x01, 0x0C, 0x1F },
9710 { 0x01, 0x08, 0x1F },
9711 };
9712
9713 const struct bahama_config_register v20_bt_on_fm_off[] = {
9714 { 0x11, 0x0C, 0xFF },
9715 { 0x13, 0x01, 0xFF },
9716 { 0xF4, 0x80, 0xFF },
9717 { 0xF0, 0x00, 0xFF },
9718 { 0xE9, 0x00, 0xFF },
9719#ifdef CONFIG_WLAN
9720 { 0x81, 0x00, 0x7F },
9721 { 0x82, 0x00, 0xFF },
9722 { 0xE6, 0x38, 0x7F },
9723 { 0xE7, 0x06, 0xFF },
9724#endif
9725 { 0xE9, 0x21, 0xFF },
9726 };
9727
9728 const struct bahama_config_register v20_bt_on_fm_on[] = {
9729 { 0x11, 0x0C, 0xFF },
9730 { 0x13, 0x01, 0xFF },
9731 { 0xF4, 0x86, 0xFF },
9732 { 0xF0, 0x06, 0xFF },
9733 { 0xE9, 0x00, 0xFF },
9734#ifdef CONFIG_WLAN
9735 { 0x81, 0x00, 0x7F },
9736 { 0x82, 0x00, 0xFF },
9737 { 0xE6, 0x38, 0x7F },
9738 { 0xE7, 0x06, 0xFF },
9739#endif
9740 { 0xE9, 0x21, 0xFF },
9741 };
9742
9743 const struct bahama_config_register v10_bt_off[] = {
9744 { 0xE9, 0x00, 0xFF },
9745 };
9746
9747 const struct bahama_config_register v20_bt_off_fm_off[] = {
9748 { 0xF4, 0x84, 0xFF },
9749 { 0xF0, 0x04, 0xFF },
9750 { 0xE9, 0x00, 0xFF }
9751 };
9752
9753 const struct bahama_config_register v20_bt_off_fm_on[] = {
9754 { 0xF4, 0x86, 0xFF },
9755 { 0xF0, 0x06, 0xFF },
9756 { 0xE9, 0x00, 0xFF }
9757 };
9758 const struct bahama_variant_register bt_bahama[2][3] = {
9759 {
9760 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9761 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9762 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9763 },
9764 {
9765 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9766 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9767 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9768 }
9769 };
9770
9771 u8 offset = 0; /* index into bahama configs */
9772
9773 on = on ? 1 : 0;
9774 version = read_bahama_ver();
9775
9776 if (version == VER_UNSUPPORTED) {
9777 dev_err(&msm_bt_power_device.dev,
9778 "%s: unsupported version\n",
9779 __func__);
9780 return -EIO;
9781 }
9782
9783 if (version == VER_2_0) {
9784 if (marimba_get_fm_status(&config))
9785 offset = 0x01;
9786 }
9787
9788 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9789 if (on && (version == VER_2_0)) {
9790 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9791 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9792 && (bt_regs_status[i].enabled == true)) {
9793 if (regulator_disable(bt_regs[i])) {
9794 dev_err(&msm_bt_power_device.dev,
9795 "%s: regulator disable failed",
9796 __func__);
9797 }
9798 bt_regs_status[i].enabled = false;
9799 break;
9800 }
9801 }
9802 }
9803
9804 p = bt_bahama[on][version + offset].set;
9805
9806 dev_info(&msm_bt_power_device.dev,
9807 "%s: found version %d\n", __func__, version);
9808
9809 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9810 u8 value = (p+i)->value;
9811 rc = marimba_write_bit_mask(&config,
9812 (p+i)->reg,
9813 &value,
9814 sizeof((p+i)->value),
9815 (p+i)->mask);
9816 if (rc < 0) {
9817 dev_err(&msm_bt_power_device.dev,
9818 "%s: reg %d write failed: %d\n",
9819 __func__, (p+i)->reg, rc);
9820 return rc;
9821 }
9822 dev_dbg(&msm_bt_power_device.dev,
9823 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9824 __func__, (p+i)->reg,
9825 value, (p+i)->mask);
9826 }
9827 /* Update BT Status */
9828 if (on)
9829 marimba_set_bt_status(&config, true);
9830 else
9831 marimba_set_bt_status(&config, false);
9832
9833 return 0;
9834}
9835
9836static int bluetooth_use_regulators(int on)
9837{
9838 int i, recover = -1, rc = 0;
9839
9840 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9841 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9842 bt_regs_info[i].name) :
9843 (regulator_put(bt_regs[i]), NULL);
9844 if (IS_ERR(bt_regs[i])) {
9845 rc = PTR_ERR(bt_regs[i]);
9846 dev_err(&msm_bt_power_device.dev,
9847 "regulator %s get failed (%d)\n",
9848 bt_regs_info[i].name, rc);
9849 recover = i - 1;
9850 bt_regs[i] = NULL;
9851 break;
9852 }
9853
9854 if (!on)
9855 continue;
9856
9857 rc = regulator_set_voltage(bt_regs[i],
9858 bt_regs_info[i].vmin,
9859 bt_regs_info[i].vmax);
9860 if (rc < 0) {
9861 dev_err(&msm_bt_power_device.dev,
9862 "regulator %s voltage set (%d)\n",
9863 bt_regs_info[i].name, rc);
9864 recover = i;
9865 break;
9866 }
9867 }
9868
9869 if (on && (recover > -1))
9870 for (i = recover; i >= 0; i--) {
9871 regulator_put(bt_regs[i]);
9872 bt_regs[i] = NULL;
9873 }
9874
9875 return rc;
9876}
9877
9878static int bluetooth_switch_regulators(int on)
9879{
9880 int i, rc = 0;
9881
9882 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9883 if (on && (bt_regs_status[i].enabled == false)) {
9884 rc = regulator_enable(bt_regs[i]);
9885 if (rc < 0) {
9886 dev_err(&msm_bt_power_device.dev,
9887 "regulator %s %s failed (%d)\n",
9888 bt_regs_info[i].name,
9889 "enable", rc);
9890 if (i > 0) {
9891 while (--i) {
9892 regulator_disable(bt_regs[i]);
9893 bt_regs_status[i].enabled
9894 = false;
9895 }
9896 break;
9897 }
9898 }
9899 bt_regs_status[i].enabled = true;
9900 } else if (!on && (bt_regs_status[i].enabled == true)) {
9901 rc = regulator_disable(bt_regs[i]);
9902 if (rc < 0) {
9903 dev_err(&msm_bt_power_device.dev,
9904 "regulator %s %s failed (%d)\n",
9905 bt_regs_info[i].name,
9906 "disable", rc);
9907 break;
9908 }
9909 bt_regs_status[i].enabled = false;
9910 }
9911 }
9912 return rc;
9913}
9914
9915static struct msm_xo_voter *bt_clock;
9916
9917static int bluetooth_power(int on)
9918{
9919 int rc = 0;
9920 int id;
9921
9922 /* In case probe function fails, cur_connv_type would be -1 */
9923 id = adie_get_detected_connectivity_type();
9924 if (id != BAHAMA_ID) {
9925 pr_err("%s: unexpected adie connectivity type: %d\n",
9926 __func__, id);
9927 return -ENODEV;
9928 }
9929
9930 if (on) {
9931
9932 rc = bluetooth_use_regulators(1);
9933 if (rc < 0)
9934 goto out;
9935
9936 rc = bluetooth_switch_regulators(1);
9937
9938 if (rc < 0)
9939 goto fail_put;
9940
9941 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
9942
9943 if (IS_ERR(bt_clock)) {
9944 pr_err("Couldn't get TCXO_D0 voter\n");
9945 goto fail_switch;
9946 }
9947
9948 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
9949
9950 if (rc < 0) {
9951 pr_err("Failed to vote for TCXO_DO ON\n");
9952 goto fail_vote;
9953 }
9954
9955 rc = bahama_bt(1);
9956
9957 if (rc < 0)
9958 goto fail_clock;
9959
9960 msleep(10);
9961
9962 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
9963
9964 if (rc < 0) {
9965 pr_err("Failed to vote for TCXO_DO pin control\n");
9966 goto fail_vote;
9967 }
9968 } else {
9969 /* check for initial RFKILL block (power off) */
9970 /* some RFKILL versions/configurations rfkill_register */
9971 /* calls here for an initial set_block */
9972 /* avoid calling i2c and regulator before unblock (on) */
9973 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
9974 dev_info(&msm_bt_power_device.dev,
9975 "%s: initialized OFF/blocked\n", __func__);
9976 goto out;
9977 }
9978
9979 bahama_bt(0);
9980
9981fail_clock:
9982 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
9983fail_vote:
9984 msm_xo_put(bt_clock);
9985fail_switch:
9986 bluetooth_switch_regulators(0);
9987fail_put:
9988 bluetooth_use_regulators(0);
9989 }
9990
9991out:
9992 if (rc < 0)
9993 on = 0;
9994 dev_info(&msm_bt_power_device.dev,
9995 "Bluetooth power switch: state %d result %d\n", on, rc);
9996
9997 return rc;
9998}
9999
10000#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10001
10002static void __init msm8x60_cfg_smsc911x(void)
10003{
10004 smsc911x_resources[1].start =
10005 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10006 smsc911x_resources[1].end =
10007 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10008}
10009
10010#ifdef CONFIG_MSM_RPM
10011static struct msm_rpm_platform_data msm_rpm_data = {
10012 .reg_base_addrs = {
10013 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
10014 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
10015 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
10016 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
10017 },
10018
10019 .irq_ack = RPM_SCSS_CPU0_GP_HIGH_IRQ,
10020 .irq_err = RPM_SCSS_CPU0_GP_LOW_IRQ,
10021 .irq_vmpm = RPM_SCSS_CPU0_GP_MEDIUM_IRQ,
10022 .msm_apps_ipc_rpm_reg = MSM_GCC_BASE + 0x008,
10023 .msm_apps_ipc_rpm_val = 4,
10024};
10025#endif
10026
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010027void msm_fusion_setup_pinctrl(void)
10028{
10029 struct msm_xo_voter *a1;
10030
10031 if (socinfo_get_platform_subtype() == 0x3) {
10032 /*
10033 * Vote for the A1 clock to be in pin control mode before
10034 * the external images are loaded.
10035 */
10036 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10037 BUG_ON(!a1);
10038 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10039 }
10040}
10041
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010042struct msm_board_data {
10043 struct msm_gpiomux_configs *gpiomux_cfgs;
10044};
10045
10046static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10047 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10048};
10049
10050static struct msm_board_data msm8x60_sim_board_data __initdata = {
10051 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10052};
10053
10054static struct msm_board_data msm8x60_surf_board_data __initdata = {
10055 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10056};
10057
10058static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10059 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10060};
10061
10062static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10063 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10064};
10065
10066static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10067 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10068};
10069
10070static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10071 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10072};
10073
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010074static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10075 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10076};
10077
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010078static void __init msm8x60_init(struct msm_board_data *board_data)
10079{
10080 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010081#ifdef CONFIG_USB_EHCI_MSM_72K
10082 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10083 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10084 .level = PM8901_MPP_DIG_LEVEL_L5,
10085 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10086 };
10087#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010088 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010090 /*
10091 * Initialize RPM first as other drivers and devices may need
10092 * it for their initialization.
10093 */
10094#ifdef CONFIG_MSM_RPM
10095 BUG_ON(msm_rpm_init(&msm_rpm_data));
10096#endif
10097 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
10098 ARRAY_SIZE(msm_rpmrs_levels)));
10099 if (msm_xo_init())
10100 pr_err("Failed to initialize XO votes\n");
10101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010102 msm8x60_check_2d_hardware();
10103
10104 /* Change SPM handling of core 1 if PMM 8160 is present. */
10105 soc_platform_version = socinfo_get_platform_version();
10106 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10107 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10108 struct msm_spm_platform_data *spm_data;
10109
10110 spm_data = &msm_spm_data_v1[1];
10111 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10112 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10113
10114 spm_data = &msm_spm_data[1];
10115 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10116 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10117 }
10118
10119 /*
10120 * Initialize SPM before acpuclock as the latter calls into SPM
10121 * driver to set ACPU voltages.
10122 */
10123 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10124 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10125 else
10126 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10127
10128 /*
10129 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10130 * devices so that the RPM doesn't drop into a low power mode that an
10131 * un-reworked SURF cannot resume from.
10132 */
10133 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010134 int i;
10135
10136 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10137 if (rpm_regulator_init_data[i].id
10138 == RPM_VREG_ID_PM8901_L4
10139 || rpm_regulator_init_data[i].id
10140 == RPM_VREG_ID_PM8901_L6)
10141 rpm_regulator_init_data[i]
10142 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010143 }
10144
10145 /*
10146 * Disable regulator info printing so that regulator registration
10147 * messages do not enter the kmsg log.
10148 */
10149 regulator_suppress_info_printing();
10150
10151 /* Initialize regulators needed for clock_init. */
10152 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10153
Stephen Boydbb600ae2011-08-02 20:11:40 -070010154 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010155
10156 /* Buses need to be initialized before early-device registration
10157 * to get the platform data for fabrics.
10158 */
10159 msm8x60_init_buses();
10160 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10161 /* CPU frequency control is not supported on simulated targets. */
10162 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010163 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010164
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010165 /*
10166 * Enable EBI2 only for boards which make use of it. Leave
10167 * it disabled for all others for additional power savings.
10168 */
10169 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10170 machine_is_msm8x60_rumi3() ||
10171 machine_is_msm8x60_sim() ||
10172 machine_is_msm8x60_fluid() ||
10173 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010174 msm8x60_init_ebi2();
10175 msm8x60_init_tlmm();
10176 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10177 msm8x60_init_uart12dm();
10178 msm8x60_init_mmc();
10179
10180#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10181 msm8x60_init_pm8058_othc();
10182#endif
10183
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010184 if (machine_is_msm8x60_fluid())
10185 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10186 else if (machine_is_msm8x60_dragon())
10187 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10188 else
10189 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010190
Jilai Wang53d27a82011-07-13 14:32:58 -040010191 /* Specify reset pin for OV9726 */
10192 if (machine_is_msm8x60_dragon()) {
10193 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10194 ov9726_sensor_8660_info.mount_angle = 270;
10195 }
10196
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010197#ifdef CONFIG_BATTERY_MSM8X60
10198 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10199 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10200 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10201 platform_device_register(&msm_charger_device);
10202#endif
10203
10204 if (machine_is_msm8x60_dragon())
10205 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10206 if (!machine_is_msm8x60_fluid())
10207 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10208
10209 /* configure pmic leds */
10210 if (machine_is_msm8x60_fluid())
10211 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10212 else if (machine_is_msm8x60_dragon())
10213 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10214 else
10215 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10216
10217 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10218 machine_is_msm8x60_dragon()) {
10219 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10220 }
10221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010222 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10223 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010224 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010225 msm8x60_cfg_smsc911x();
10226 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10227 platform_add_devices(msm_footswitch_devices,
10228 msm_num_footswitch_devices);
10229 platform_add_devices(surf_devices,
10230 ARRAY_SIZE(surf_devices));
10231
10232#ifdef CONFIG_MSM_DSPS
10233 if (machine_is_msm8x60_fluid()) {
10234 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10235 msm8x60_init_dsps();
10236 }
10237#endif
10238
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010239 pm8901_vreg_mpp0_init();
10240
10241 platform_device_register(&msm8x60_8901_mpp_vreg);
10242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010243#ifdef CONFIG_USB_EHCI_MSM_72K
10244 /*
10245 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10246 * fluid
10247 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010248 if (machine_is_msm8x60_fluid())
10249 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10250 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010251#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010252
10253#ifdef CONFIG_SND_SOC_MSM8660_APQ
10254 if (machine_is_msm8x60_dragon())
10255 platform_add_devices(dragon_alsa_devices,
10256 ARRAY_SIZE(dragon_alsa_devices));
10257 else
10258#endif
10259 platform_add_devices(asoc_devices,
10260 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010261 } else {
10262 msm8x60_configure_smc91x();
10263 platform_add_devices(rumi_sim_devices,
10264 ARRAY_SIZE(rumi_sim_devices));
10265 }
10266#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010267 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10268 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010269 msm8x60_cfg_isp1763();
10270#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010271
10272 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10273 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10274
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010275
10276#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10277 if (machine_is_msm8x60_fluid())
10278 platform_device_register(&msm_gsbi10_qup_spi_device);
10279 else
10280 platform_device_register(&msm_gsbi1_qup_spi_device);
10281#endif
10282
10283#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10284 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10285 if (machine_is_msm8x60_fluid())
10286 cyttsp_set_params();
10287#endif
10288 if (!machine_is_msm8x60_sim())
10289 msm_fb_add_devices();
10290 fixup_i2c_configs();
10291 register_i2c_devices();
10292
Terence Hampson1c73fef2011-07-19 17:10:49 -040010293 if (machine_is_msm8x60_dragon())
10294 smsc911x_config.reset_gpio
10295 = GPIO_ETHERNET_RESET_N_DRAGON;
10296
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010297 platform_device_register(&smsc911x_device);
10298
10299#if (defined(CONFIG_SPI_QUP)) && \
10300 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010301 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10302 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010303
10304 if (machine_is_msm8x60_fluid()) {
10305#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10306 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10307 spi_register_board_info(lcdc_samsung_spi_board_info,
10308 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10309 } else
10310#endif
10311 {
10312#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10313 spi_register_board_info(lcdc_auo_spi_board_info,
10314 ARRAY_SIZE(lcdc_auo_spi_board_info));
10315#endif
10316 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010317#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10318 } else if (machine_is_msm8x60_dragon()) {
10319 spi_register_board_info(lcdc_nt35582_spi_board_info,
10320 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10321#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010322 }
10323#endif
10324
10325 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
10326 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
10327 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
10328 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010329 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010330
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010331 pm8058_gpios_init();
10332
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010333#ifdef CONFIG_SENSORS_MSM_ADC
10334 if (machine_is_msm8x60_fluid()) {
10335 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10336 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10337 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10338 msm_adc_pdata.gpio_config = APROC_CONFIG;
10339 else
10340 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10341 }
10342 msm_adc_pdata.target_hw = MSM_8x60;
10343#endif
10344#ifdef CONFIG_MSM8X60_AUDIO
10345 msm_snddev_init();
10346#endif
10347#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10348 if (machine_is_msm8x60_fluid())
10349 platform_device_register(&fluid_leds_gpio);
10350 else
10351 platform_device_register(&gpio_leds);
10352#endif
10353
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010354 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010355
10356 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10357 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010358}
10359
10360static void __init msm8x60_rumi3_init(void)
10361{
10362 msm8x60_init(&msm8x60_rumi3_board_data);
10363}
10364
10365static void __init msm8x60_sim_init(void)
10366{
10367 msm8x60_init(&msm8x60_sim_board_data);
10368}
10369
10370static void __init msm8x60_surf_init(void)
10371{
10372 msm8x60_init(&msm8x60_surf_board_data);
10373}
10374
10375static void __init msm8x60_ffa_init(void)
10376{
10377 msm8x60_init(&msm8x60_ffa_board_data);
10378}
10379
10380static void __init msm8x60_fluid_init(void)
10381{
10382 msm8x60_init(&msm8x60_fluid_board_data);
10383}
10384
10385static void __init msm8x60_charm_surf_init(void)
10386{
10387 msm8x60_init(&msm8x60_charm_surf_board_data);
10388}
10389
10390static void __init msm8x60_charm_ffa_init(void)
10391{
10392 msm8x60_init(&msm8x60_charm_ffa_board_data);
10393}
10394
10395static void __init msm8x60_charm_init_early(void)
10396{
10397 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010398}
10399
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010400static void __init msm8x60_dragon_init(void)
10401{
10402 msm8x60_init(&msm8x60_dragon_board_data);
10403}
10404
Steve Mucklea55df6e2010-01-07 12:43:24 -080010405MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10406 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010407 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010408 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010409 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010410 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010411 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010412 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010413MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010414
10415MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10416 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010417 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010418 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010419 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010420 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010421 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010422 .init_early = msm8x60_charm_init_early,
10423MACHINE_END
10424
10425MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10426 .map_io = msm8x60_map_io,
10427 .reserve = msm8x60_reserve,
10428 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010429 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010430 .init_machine = msm8x60_surf_init,
10431 .timer = &msm_timer,
10432 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010433MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010434
10435MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10436 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010437 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010438 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010439 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010440 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010441 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010442 .init_early = msm8x60_charm_init_early,
10443MACHINE_END
10444
10445MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10446 .map_io = msm8x60_map_io,
10447 .reserve = msm8x60_reserve,
10448 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010449 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010450 .init_machine = msm8x60_fluid_init,
10451 .timer = &msm_timer,
10452 .init_early = msm8x60_charm_init_early,
10453MACHINE_END
10454
10455MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10456 .map_io = msm8x60_map_io,
10457 .reserve = msm8x60_reserve,
10458 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010459 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010460 .init_machine = msm8x60_charm_surf_init,
10461 .timer = &msm_timer,
10462 .init_early = msm8x60_charm_init_early,
10463MACHINE_END
10464
10465MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10466 .map_io = msm8x60_map_io,
10467 .reserve = msm8x60_reserve,
10468 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010469 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010470 .init_machine = msm8x60_charm_ffa_init,
10471 .timer = &msm_timer,
10472 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010473MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010474
10475MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10476 .map_io = msm8x60_map_io,
10477 .reserve = msm8x60_reserve,
10478 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010479 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010480 .init_machine = msm8x60_dragon_init,
10481 .timer = &msm_timer,
10482 .init_early = msm8x60_charm_init_early,
10483MACHINE_END