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