blob: e3fc97f5c7eb686a6beeea099b0307ebfc030ebf [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
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302646#define MSM_FB_PRIM_BUF_SIZE \
2647 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002648#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302649#define MSM_FB_PRIM_BUF_SIZE \
2650 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002651#endif
2652
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002653#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302654#define MSM_FB_EXT_BUF_SIZE \
2655 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002656#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302657#define MSM_FB_EXT_BUF_SIZE \
2658 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002659#else
2660#define MSM_FB_EXT_BUFT_SIZE 0
2661#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002662
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002663#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2664/* 4 bpp x 2 page HDMI case */
2665#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
2666#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002667/* Note: must be multiple of 4096 */
2668#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002669 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002670#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002671
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002672#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2673#define MSM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
2674#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002675#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002676#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002677
Huaibin Yanga5419422011-12-08 23:52:10 -08002678#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2679#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2680#else
2681#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2682#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2683
2684#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2685#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2686#else
2687#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2688#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2689
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002690#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
2691#define MSM_PMEM_ADSP_SIZE 0x2000000
Ben Romberger09e462d2011-08-09 15:24:37 -07002692#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002693
2694#define MSM_SMI_BASE 0x38000000
2695#define MSM_SMI_SIZE 0x4000000
2696
2697#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002698#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002699
2700#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2701#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2702#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2703
Naseer Ahmed51860b02012-02-07 18:53:29 +05302704#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002705#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan42ebe712012-01-10 16:30:58 -08002706#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
2707#define MSM_ION_MM_SIZE 0x3600000 /* (54MB) */
Olav Hauganb5be7992011-11-18 14:29:02 -08002708#define MSM_ION_MFC_SIZE SZ_8K
2709#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Olav Haugan6ab47252012-02-15 14:46:49 -08002710#define MSM_ION_QSECOM_SIZE 0x300000 /* (3MB) */
Olav Haugan3a55e322012-01-23 14:24:01 -08002711#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002712
2713#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Olav Haugan6ab47252012-02-15 14:46:49 -08002714#define MSM_ION_HEAP_NUM 9
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002715#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002716#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002717#endif
2718
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002719static unsigned fb_size;
2720static int __init fb_size_setup(char *p)
2721{
2722 fb_size = memparse(p, NULL);
2723 return 0;
2724}
2725early_param("fb_size", fb_size_setup);
2726
2727static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2728static int __init pmem_kernel_ebi1_size_setup(char *p)
2729{
2730 pmem_kernel_ebi1_size = memparse(p, NULL);
2731 return 0;
2732}
2733early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2734
2735#ifdef CONFIG_ANDROID_PMEM
2736static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2737static int __init pmem_sf_size_setup(char *p)
2738{
2739 pmem_sf_size = memparse(p, NULL);
2740 return 0;
2741}
2742early_param("pmem_sf_size", pmem_sf_size_setup);
2743
2744static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2745
2746static int __init pmem_adsp_size_setup(char *p)
2747{
2748 pmem_adsp_size = memparse(p, NULL);
2749 return 0;
2750}
2751early_param("pmem_adsp_size", pmem_adsp_size_setup);
2752
2753static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2754
2755static int __init pmem_audio_size_setup(char *p)
2756{
2757 pmem_audio_size = memparse(p, NULL);
2758 return 0;
2759}
2760early_param("pmem_audio_size", pmem_audio_size_setup);
2761#endif
2762
2763static struct resource msm_fb_resources[] = {
2764 {
2765 .flags = IORESOURCE_DMA,
2766 }
2767};
2768
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002769static int msm_fb_detect_panel(const char *name)
2770{
2771 if (machine_is_msm8x60_fluid()) {
2772 uint32_t soc_platform_version = socinfo_get_platform_version();
2773 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2774#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2775 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002776 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2777 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002778 return 0;
2779#endif
2780 } else { /*P3 and up use AUO panel */
2781#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2782 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002783 strnlen(LCDC_AUO_PANEL_NAME,
2784 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002785 return 0;
2786#endif
2787 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002788#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2789 } else if machine_is_msm8x60_dragon() {
2790 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002791 strnlen(LCDC_NT35582_PANEL_NAME,
2792 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002793 return 0;
2794#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002795 } else {
2796 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002797 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2798 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002800
2801#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2802 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2803 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2804 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2805 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2806 PANEL_NAME_MAX_LEN)))
2807 return 0;
2808
2809 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2810 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2811 PANEL_NAME_MAX_LEN)))
2812 return 0;
2813
2814 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2815 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2816 PANEL_NAME_MAX_LEN)))
2817 return 0;
2818#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002819 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002820
2821 if (!strncmp(name, HDMI_PANEL_NAME,
2822 strnlen(HDMI_PANEL_NAME,
2823 PANEL_NAME_MAX_LEN)))
2824 return 0;
2825
2826 if (!strncmp(name, TVOUT_PANEL_NAME,
2827 strnlen(TVOUT_PANEL_NAME,
2828 PANEL_NAME_MAX_LEN)))
2829 return 0;
2830
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002831 pr_warning("%s: not supported '%s'", __func__, name);
2832 return -ENODEV;
2833}
2834
2835static struct msm_fb_platform_data msm_fb_pdata = {
2836 .detect_client = msm_fb_detect_panel,
2837};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002838
2839static struct platform_device msm_fb_device = {
2840 .name = "msm_fb",
2841 .id = 0,
2842 .num_resources = ARRAY_SIZE(msm_fb_resources),
2843 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002845};
2846
2847#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002848#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002849static struct android_pmem_platform_data android_pmem_pdata = {
2850 .name = "pmem",
2851 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2852 .cached = 1,
2853 .memory_type = MEMTYPE_EBI1,
2854};
2855
2856static struct platform_device android_pmem_device = {
2857 .name = "android_pmem",
2858 .id = 0,
2859 .dev = {.platform_data = &android_pmem_pdata},
2860};
2861
2862static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2863 .name = "pmem_adsp",
2864 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2865 .cached = 0,
2866 .memory_type = MEMTYPE_EBI1,
2867};
2868
2869static struct platform_device android_pmem_adsp_device = {
2870 .name = "android_pmem",
2871 .id = 2,
2872 .dev = { .platform_data = &android_pmem_adsp_pdata },
2873};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002874#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002875static struct android_pmem_platform_data android_pmem_audio_pdata = {
2876 .name = "pmem_audio",
2877 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2878 .cached = 0,
2879 .memory_type = MEMTYPE_EBI1,
2880};
2881
2882static struct platform_device android_pmem_audio_device = {
2883 .name = "android_pmem",
2884 .id = 4,
2885 .dev = { .platform_data = &android_pmem_audio_pdata },
2886};
2887
Laura Abbott1e36a022011-06-22 17:08:13 -07002888#define PMEM_BUS_WIDTH(_bw) \
2889 { \
2890 .vectors = &(struct msm_bus_vectors){ \
2891 .src = MSM_BUS_MASTER_AMPSS_M0, \
2892 .dst = MSM_BUS_SLAVE_SMI, \
2893 .ib = (_bw), \
2894 .ab = 0, \
2895 }, \
2896 .num_paths = 1, \
2897 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002898
2899static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002900 [0] = PMEM_BUS_WIDTH(0), /* Off */
2901 [1] = PMEM_BUS_WIDTH(1), /* On */
2902};
2903
2904static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002905 .usecase = mem_smi_table,
2906 .num_usecases = ARRAY_SIZE(mem_smi_table),
2907 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002908};
2909
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002910int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002911{
2912 int bus_id = (int) data;
2913
2914 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002915 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002916}
2917
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002918int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002919{
2920 int bus_id = (int) data;
2921
2922 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002923 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002924}
2925
Alex Bird199980e2011-10-21 11:29:27 -07002926void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002927{
2928 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2929}
Olav Hauganee0f7802011-12-19 13:28:57 -08002930#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2932 .name = "pmem_smipool",
2933 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2934 .cached = 0,
2935 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002936 .request_region = request_smi_region,
2937 .release_region = release_smi_region,
2938 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002939 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002940};
2941static struct platform_device android_pmem_smipool_device = {
2942 .name = "android_pmem",
2943 .id = 7,
2944 .dev = { .platform_data = &android_pmem_smipool_pdata },
2945};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002946#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002947#endif
2948
2949#define GPIO_DONGLE_PWR_EN 258
2950static void setup_display_power(void);
2951static int lcdc_vga_enabled;
2952static int vga_enable_request(int enable)
2953{
2954 if (enable)
2955 lcdc_vga_enabled = 1;
2956 else
2957 lcdc_vga_enabled = 0;
2958 setup_display_power();
2959
2960 return 0;
2961}
2962
2963#define GPIO_BACKLIGHT_PWM0 0
2964#define GPIO_BACKLIGHT_PWM1 1
2965
2966static int pmic_backlight_gpio[2]
2967 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2968static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2969 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2970 .vga_switch = vga_enable_request,
2971};
2972
2973static struct platform_device lcdc_samsung_panel_device = {
2974 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2975 .id = 0,
2976 .dev = {
2977 .platform_data = &lcdc_samsung_panel_data,
2978 }
2979};
2980#if (!defined(CONFIG_SPI_QUP)) && \
2981 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2982 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2983
2984static int lcdc_spi_gpio_array_num[] = {
2985 LCDC_SPI_GPIO_CLK,
2986 LCDC_SPI_GPIO_CS,
2987 LCDC_SPI_GPIO_MOSI,
2988};
2989
2990static uint32_t lcdc_spi_gpio_config_data[] = {
2991 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2992 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2993 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2994 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2995 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2996 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2997};
2998
2999static void lcdc_config_spi_gpios(int enable)
3000{
3001 int n;
3002 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
3003 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
3004}
3005#endif
3006
3007#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
3008#ifdef CONFIG_SPI_QUP
3009static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
3010 {
3011 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
3012 .mode = SPI_MODE_3,
3013 .bus_num = 1,
3014 .chip_select = 0,
3015 .max_speed_hz = 10800000,
3016 }
3017};
3018#endif /* CONFIG_SPI_QUP */
3019
3020static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
3021#ifndef CONFIG_SPI_QUP
3022 .panel_config_gpio = lcdc_config_spi_gpios,
3023 .gpio_num = lcdc_spi_gpio_array_num,
3024#endif
3025};
3026
3027static struct platform_device lcdc_samsung_oled_panel_device = {
3028 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
3029 .id = 0,
3030 .dev.platform_data = &lcdc_samsung_oled_panel_data,
3031};
3032#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3033
3034#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3035#ifdef CONFIG_SPI_QUP
3036static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3037 {
3038 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3039 .mode = SPI_MODE_3,
3040 .bus_num = 1,
3041 .chip_select = 0,
3042 .max_speed_hz = 10800000,
3043 }
3044};
3045#endif
3046
3047static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3048#ifndef CONFIG_SPI_QUP
3049 .panel_config_gpio = lcdc_config_spi_gpios,
3050 .gpio_num = lcdc_spi_gpio_array_num,
3051#endif
3052};
3053
3054static struct platform_device lcdc_auo_wvga_panel_device = {
3055 .name = LCDC_AUO_PANEL_NAME,
3056 .id = 0,
3057 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3058};
3059#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3060
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003061#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3062
3063#define GPIO_NT35582_RESET 94
3064#define GPIO_NT35582_BL_EN_HW_PIN 24
3065#define GPIO_NT35582_BL_EN \
3066 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3067
3068static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3069
3070static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3071 .gpio_num = lcdc_nt35582_pmic_gpio,
3072};
3073
3074static struct platform_device lcdc_nt35582_panel_device = {
3075 .name = LCDC_NT35582_PANEL_NAME,
3076 .id = 0,
3077 .dev = {
3078 .platform_data = &lcdc_nt35582_panel_data,
3079 }
3080};
3081
3082static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3083 {
3084 .modalias = "lcdc_nt35582_spi",
3085 .mode = SPI_MODE_0,
3086 .bus_num = 0,
3087 .chip_select = 0,
3088 .max_speed_hz = 1100000,
3089 }
3090};
3091#endif
3092
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003093#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3094static struct resource hdmi_msm_resources[] = {
3095 {
3096 .name = "hdmi_msm_qfprom_addr",
3097 .start = 0x00700000,
3098 .end = 0x007060FF,
3099 .flags = IORESOURCE_MEM,
3100 },
3101 {
3102 .name = "hdmi_msm_hdmi_addr",
3103 .start = 0x04A00000,
3104 .end = 0x04A00FFF,
3105 .flags = IORESOURCE_MEM,
3106 },
3107 {
3108 .name = "hdmi_msm_irq",
3109 .start = HDMI_IRQ,
3110 .end = HDMI_IRQ,
3111 .flags = IORESOURCE_IRQ,
3112 },
3113};
3114
3115static int hdmi_enable_5v(int on);
3116static int hdmi_core_power(int on, int show);
3117static int hdmi_cec_power(int on);
3118
3119static struct msm_hdmi_platform_data hdmi_msm_data = {
3120 .irq = HDMI_IRQ,
3121 .enable_5v = hdmi_enable_5v,
3122 .core_power = hdmi_core_power,
3123 .cec_power = hdmi_cec_power,
3124};
3125
3126static struct platform_device hdmi_msm_device = {
3127 .name = "hdmi_msm",
3128 .id = 0,
3129 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3130 .resource = hdmi_msm_resources,
3131 .dev.platform_data = &hdmi_msm_data,
3132};
3133#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3134
3135#ifdef CONFIG_FB_MSM_MIPI_DSI
3136static struct platform_device mipi_dsi_toshiba_panel_device = {
3137 .name = "mipi_toshiba",
3138 .id = 0,
3139};
3140
3141#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3142
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003143static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003144 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003145 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003146};
3147
3148static struct platform_device mipi_dsi_novatek_panel_device = {
3149 .name = "mipi_novatek",
3150 .id = 0,
3151 .dev = {
3152 .platform_data = &novatek_pdata,
3153 }
3154};
3155#endif
3156
3157static void __init msm8x60_allocate_memory_regions(void)
3158{
3159 void *addr;
3160 unsigned long size;
3161
3162 size = MSM_FB_SIZE;
3163 addr = alloc_bootmem_align(size, 0x1000);
3164 msm_fb_resources[0].start = __pa(addr);
3165 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3166 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3167 size, addr, __pa(addr));
3168
3169}
3170
3171#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3172 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3173/*virtual key support */
3174static ssize_t tma300_vkeys_show(struct kobject *kobj,
3175 struct kobj_attribute *attr, char *buf)
3176{
3177 return sprintf(buf,
3178 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3179 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3180 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3181 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3182 "\n");
3183}
3184
3185static struct kobj_attribute tma300_vkeys_attr = {
3186 .attr = {
3187 .mode = S_IRUGO,
3188 },
3189 .show = &tma300_vkeys_show,
3190};
3191
3192static struct attribute *tma300_properties_attrs[] = {
3193 &tma300_vkeys_attr.attr,
3194 NULL
3195};
3196
3197static struct attribute_group tma300_properties_attr_group = {
3198 .attrs = tma300_properties_attrs,
3199};
3200
3201static struct kobject *properties_kobj;
3202
3203
3204
3205#define CYTTSP_TS_GPIO_IRQ 61
3206static int cyttsp_platform_init(struct i2c_client *client)
3207{
3208 int rc = -EINVAL;
3209 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3210
3211 if (machine_is_msm8x60_fluid()) {
3212 pm8058_l5 = regulator_get(NULL, "8058_l5");
3213 if (IS_ERR(pm8058_l5)) {
3214 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3215 __func__, PTR_ERR(pm8058_l5));
3216 rc = PTR_ERR(pm8058_l5);
3217 return rc;
3218 }
3219 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3220 if (rc) {
3221 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3222 __func__, rc);
3223 goto reg_l5_put;
3224 }
3225
3226 rc = regulator_enable(pm8058_l5);
3227 if (rc) {
3228 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3229 __func__, rc);
3230 goto reg_l5_put;
3231 }
3232 }
3233 /* vote for s3 to enable i2c communication lines */
3234 pm8058_s3 = regulator_get(NULL, "8058_s3");
3235 if (IS_ERR(pm8058_s3)) {
3236 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3237 __func__, PTR_ERR(pm8058_s3));
3238 rc = PTR_ERR(pm8058_s3);
3239 goto reg_l5_disable;
3240 }
3241
3242 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3243 if (rc) {
3244 pr_err("%s: regulator_set_voltage() = %d\n",
3245 __func__, rc);
3246 goto reg_s3_put;
3247 }
3248
3249 rc = regulator_enable(pm8058_s3);
3250 if (rc) {
3251 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3252 __func__, rc);
3253 goto reg_s3_put;
3254 }
3255
3256 /* wait for vregs to stabilize */
3257 usleep_range(10000, 10000);
3258
3259 /* check this device active by reading first byte/register */
3260 rc = i2c_smbus_read_byte_data(client, 0x01);
3261 if (rc < 0) {
3262 pr_err("%s: i2c sanity check failed\n", __func__);
3263 goto reg_s3_disable;
3264 }
3265
3266 /* virtual keys */
3267 if (machine_is_msm8x60_fluid()) {
3268 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3269 properties_kobj = kobject_create_and_add("board_properties",
3270 NULL);
3271 if (properties_kobj)
3272 rc = sysfs_create_group(properties_kobj,
3273 &tma300_properties_attr_group);
3274 if (!properties_kobj || rc)
3275 pr_err("%s: failed to create board_properties\n",
3276 __func__);
3277 }
3278 return CY_OK;
3279
3280reg_s3_disable:
3281 regulator_disable(pm8058_s3);
3282reg_s3_put:
3283 regulator_put(pm8058_s3);
3284reg_l5_disable:
3285 if (machine_is_msm8x60_fluid())
3286 regulator_disable(pm8058_l5);
3287reg_l5_put:
3288 if (machine_is_msm8x60_fluid())
3289 regulator_put(pm8058_l5);
3290 return rc;
3291}
3292
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303293/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3294static int cyttsp_platform_suspend(struct i2c_client *client)
3295{
3296 msleep(20);
3297
3298 return CY_OK;
3299}
3300
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003301static int cyttsp_platform_resume(struct i2c_client *client)
3302{
3303 /* add any special code to strobe a wakeup pin or chip reset */
3304 msleep(10);
3305
3306 return CY_OK;
3307}
3308
3309static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3310 .flags = 0x04,
3311 .gen = CY_GEN3, /* or */
3312 .use_st = CY_USE_ST,
3313 .use_mt = CY_USE_MT,
3314 .use_hndshk = CY_SEND_HNDSHK,
3315 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303316 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003317 .use_gestures = CY_USE_GESTURES,
3318 /* activate up to 4 groups
3319 * and set active distance
3320 */
3321 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3322 CY_GEST_GRP3 | CY_GEST_GRP4 |
3323 CY_ACT_DIST,
3324 /* change act_intrvl to customize the Active power state
3325 * scanning/processing refresh interval for Operating mode
3326 */
3327 .act_intrvl = CY_ACT_INTRVL_DFLT,
3328 /* change tch_tmout to customize the touch timeout for the
3329 * Active power state for Operating mode
3330 */
3331 .tch_tmout = CY_TCH_TMOUT_DFLT,
3332 /* change lp_intrvl to customize the Low Power power state
3333 * scanning/processing refresh interval for Operating mode
3334 */
3335 .lp_intrvl = CY_LP_INTRVL_DFLT,
3336 .sleep_gpio = -1,
3337 .resout_gpio = -1,
3338 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3339 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303340 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003341 .init = cyttsp_platform_init,
3342};
3343
3344static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3345 .panel_maxx = 1083,
3346 .panel_maxy = 659,
3347 .disp_minx = 30,
3348 .disp_maxx = 1053,
3349 .disp_miny = 30,
3350 .disp_maxy = 629,
3351 .correct_fw_ver = 8,
3352 .fw_fname = "cyttsp_8660_ffa.hex",
3353 .flags = 0x00,
3354 .gen = CY_GEN2, /* or */
3355 .use_st = CY_USE_ST,
3356 .use_mt = CY_USE_MT,
3357 .use_hndshk = CY_SEND_HNDSHK,
3358 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303359 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003360 .use_gestures = CY_USE_GESTURES,
3361 /* activate up to 4 groups
3362 * and set active distance
3363 */
3364 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3365 CY_GEST_GRP3 | CY_GEST_GRP4 |
3366 CY_ACT_DIST,
3367 /* change act_intrvl to customize the Active power state
3368 * scanning/processing refresh interval for Operating mode
3369 */
3370 .act_intrvl = CY_ACT_INTRVL_DFLT,
3371 /* change tch_tmout to customize the touch timeout for the
3372 * Active power state for Operating mode
3373 */
3374 .tch_tmout = CY_TCH_TMOUT_DFLT,
3375 /* change lp_intrvl to customize the Low Power power state
3376 * scanning/processing refresh interval for Operating mode
3377 */
3378 .lp_intrvl = CY_LP_INTRVL_DFLT,
3379 .sleep_gpio = -1,
3380 .resout_gpio = -1,
3381 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3382 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303383 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303385 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003386};
3387static void cyttsp_set_params(void)
3388{
3389 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3390 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3391 cyttsp_fluid_pdata.panel_maxx = 539;
3392 cyttsp_fluid_pdata.panel_maxy = 994;
3393 cyttsp_fluid_pdata.disp_minx = 30;
3394 cyttsp_fluid_pdata.disp_maxx = 509;
3395 cyttsp_fluid_pdata.disp_miny = 60;
3396 cyttsp_fluid_pdata.disp_maxy = 859;
3397 cyttsp_fluid_pdata.correct_fw_ver = 4;
3398 } else {
3399 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3400 cyttsp_fluid_pdata.panel_maxx = 550;
3401 cyttsp_fluid_pdata.panel_maxy = 1013;
3402 cyttsp_fluid_pdata.disp_minx = 35;
3403 cyttsp_fluid_pdata.disp_maxx = 515;
3404 cyttsp_fluid_pdata.disp_miny = 69;
3405 cyttsp_fluid_pdata.disp_maxy = 869;
3406 cyttsp_fluid_pdata.correct_fw_ver = 5;
3407 }
3408
3409}
3410
3411static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3412 {
3413 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3414 .platform_data = &cyttsp_fluid_pdata,
3415#ifndef CY_USE_TIMER
3416 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3417#endif /* CY_USE_TIMER */
3418 },
3419};
3420
3421static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3422 {
3423 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3424 .platform_data = &cyttsp_tmg240_pdata,
3425#ifndef CY_USE_TIMER
3426 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3427#endif /* CY_USE_TIMER */
3428 },
3429};
3430#endif
3431
3432static struct regulator *vreg_tmg200;
3433
3434#define TS_PEN_IRQ_GPIO 61
3435static int tmg200_power(int vreg_on)
3436{
3437 int rc = -EINVAL;
3438
3439 if (!vreg_tmg200) {
3440 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3441 __func__, rc);
3442 return rc;
3443 }
3444
3445 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3446 regulator_disable(vreg_tmg200);
3447 if (rc < 0)
3448 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3449 __func__, vreg_on ? "enable" : "disable", rc);
3450
3451 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003452 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003453
3454 return rc;
3455}
3456
3457static int tmg200_dev_setup(bool enable)
3458{
3459 int rc;
3460
3461 if (enable) {
3462 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3463 if (IS_ERR(vreg_tmg200)) {
3464 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3465 __func__, PTR_ERR(vreg_tmg200));
3466 rc = PTR_ERR(vreg_tmg200);
3467 return rc;
3468 }
3469
3470 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3471 if (rc) {
3472 pr_err("%s: regulator_set_voltage() = %d\n",
3473 __func__, rc);
3474 goto reg_put;
3475 }
3476 } else {
3477 /* put voltage sources */
3478 regulator_put(vreg_tmg200);
3479 }
3480 return 0;
3481reg_put:
3482 regulator_put(vreg_tmg200);
3483 return rc;
3484}
3485
3486static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3487 .ts_name = "msm_tmg200_ts",
3488 .dis_min_x = 0,
3489 .dis_max_x = 1023,
3490 .dis_min_y = 0,
3491 .dis_max_y = 599,
3492 .min_tid = 0,
3493 .max_tid = 255,
3494 .min_touch = 0,
3495 .max_touch = 255,
3496 .min_width = 0,
3497 .max_width = 255,
3498 .power_on = tmg200_power,
3499 .dev_setup = tmg200_dev_setup,
3500 .nfingers = 2,
3501 .irq_gpio = TS_PEN_IRQ_GPIO,
3502 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3503};
3504
3505static struct i2c_board_info cy8ctmg200_board_info[] = {
3506 {
3507 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3508 .platform_data = &cy8ctmg200_pdata,
3509 }
3510};
3511
Zhang Chang Ken211df572011-07-05 19:16:39 -04003512static struct regulator *vreg_tma340;
3513
3514static int tma340_power(int vreg_on)
3515{
3516 int rc = -EINVAL;
3517
3518 if (!vreg_tma340) {
3519 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3520 __func__, rc);
3521 return rc;
3522 }
3523
3524 rc = vreg_on ? regulator_enable(vreg_tma340) :
3525 regulator_disable(vreg_tma340);
3526 if (rc < 0)
3527 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3528 __func__, vreg_on ? "enable" : "disable", rc);
3529
3530 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003531 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003532
3533 return rc;
3534}
3535
3536static struct kobject *tma340_prop_kobj;
3537
3538static int tma340_dragon_dev_setup(bool enable)
3539{
3540 int rc;
3541
3542 if (enable) {
3543 vreg_tma340 = regulator_get(NULL, "8901_l2");
3544 if (IS_ERR(vreg_tma340)) {
3545 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3546 __func__, PTR_ERR(vreg_tma340));
3547 rc = PTR_ERR(vreg_tma340);
3548 return rc;
3549 }
3550
3551 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3552 if (rc) {
3553 pr_err("%s: regulator_set_voltage() = %d\n",
3554 __func__, rc);
3555 goto reg_put;
3556 }
3557 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3558 tma340_prop_kobj = kobject_create_and_add("board_properties",
3559 NULL);
3560 if (tma340_prop_kobj) {
3561 rc = sysfs_create_group(tma340_prop_kobj,
3562 &tma300_properties_attr_group);
3563 if (rc) {
3564 kobject_put(tma340_prop_kobj);
3565 pr_err("%s: failed to create board_properties\n",
3566 __func__);
3567 goto reg_put;
3568 }
3569 }
3570
3571 } else {
3572 /* put voltage sources */
3573 regulator_put(vreg_tma340);
3574 /* destroy virtual keys */
3575 if (tma340_prop_kobj) {
3576 sysfs_remove_group(tma340_prop_kobj,
3577 &tma300_properties_attr_group);
3578 kobject_put(tma340_prop_kobj);
3579 }
3580 }
3581 return 0;
3582reg_put:
3583 regulator_put(vreg_tma340);
3584 return rc;
3585}
3586
3587
3588static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3589 .ts_name = "cy8ctma340",
3590 .dis_min_x = 0,
3591 .dis_max_x = 479,
3592 .dis_min_y = 0,
3593 .dis_max_y = 799,
3594 .min_tid = 0,
3595 .max_tid = 255,
3596 .min_touch = 0,
3597 .max_touch = 255,
3598 .min_width = 0,
3599 .max_width = 255,
3600 .power_on = tma340_power,
3601 .dev_setup = tma340_dragon_dev_setup,
3602 .nfingers = 2,
3603 .irq_gpio = TS_PEN_IRQ_GPIO,
3604 .resout_gpio = -1,
3605};
3606
3607static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3608 {
3609 I2C_BOARD_INFO("cy8ctma340", 0x24),
3610 .platform_data = &cy8ctma340_dragon_pdata,
3611 }
3612};
3613
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003614#ifdef CONFIG_SERIAL_MSM_HS
3615static int configure_uart_gpios(int on)
3616{
3617 int ret = 0, i;
3618 int uart_gpios[] = {53, 54, 55, 56};
3619 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3620 if (on) {
3621 ret = msm_gpiomux_get(uart_gpios[i]);
3622 if (unlikely(ret))
3623 break;
3624 } else {
3625 ret = msm_gpiomux_put(uart_gpios[i]);
3626 if (unlikely(ret))
3627 return ret;
3628 }
3629 }
3630 if (ret)
3631 for (; i >= 0; i--)
3632 msm_gpiomux_put(uart_gpios[i]);
3633 return ret;
3634}
3635static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3636 .inject_rx_on_wakeup = 1,
3637 .rx_to_inject = 0xFD,
3638 .gpio_config = configure_uart_gpios,
3639};
3640#endif
3641
3642
3643#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3644
3645static struct gpio_led gpio_exp_leds_config[] = {
3646 {
3647 .name = "left_led1:green",
3648 .gpio = GPIO_LEFT_LED_1,
3649 .active_low = 1,
3650 .retain_state_suspended = 0,
3651 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3652 },
3653 {
3654 .name = "left_led2:red",
3655 .gpio = GPIO_LEFT_LED_2,
3656 .active_low = 1,
3657 .retain_state_suspended = 0,
3658 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3659 },
3660 {
3661 .name = "left_led3:green",
3662 .gpio = GPIO_LEFT_LED_3,
3663 .active_low = 1,
3664 .retain_state_suspended = 0,
3665 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3666 },
3667 {
3668 .name = "wlan_led:orange",
3669 .gpio = GPIO_LEFT_LED_WLAN,
3670 .active_low = 1,
3671 .retain_state_suspended = 0,
3672 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3673 },
3674 {
3675 .name = "left_led5:green",
3676 .gpio = GPIO_LEFT_LED_5,
3677 .active_low = 1,
3678 .retain_state_suspended = 0,
3679 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3680 },
3681 {
3682 .name = "right_led1:green",
3683 .gpio = GPIO_RIGHT_LED_1,
3684 .active_low = 1,
3685 .retain_state_suspended = 0,
3686 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3687 },
3688 {
3689 .name = "right_led2:red",
3690 .gpio = GPIO_RIGHT_LED_2,
3691 .active_low = 1,
3692 .retain_state_suspended = 0,
3693 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3694 },
3695 {
3696 .name = "right_led3:green",
3697 .gpio = GPIO_RIGHT_LED_3,
3698 .active_low = 1,
3699 .retain_state_suspended = 0,
3700 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3701 },
3702 {
3703 .name = "bt_led:blue",
3704 .gpio = GPIO_RIGHT_LED_BT,
3705 .active_low = 1,
3706 .retain_state_suspended = 0,
3707 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3708 },
3709 {
3710 .name = "right_led5:green",
3711 .gpio = GPIO_RIGHT_LED_5,
3712 .active_low = 1,
3713 .retain_state_suspended = 0,
3714 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3715 },
3716};
3717
3718static struct gpio_led_platform_data gpio_leds_pdata = {
3719 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3720 .leds = gpio_exp_leds_config,
3721};
3722
3723static struct platform_device gpio_leds = {
3724 .name = "leds-gpio",
3725 .id = -1,
3726 .dev = {
3727 .platform_data = &gpio_leds_pdata,
3728 },
3729};
3730
3731static struct gpio_led fluid_gpio_leds[] = {
3732 {
3733 .name = "dual_led:green",
3734 .gpio = GPIO_LED1_GREEN_N,
3735 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3736 .active_low = 1,
3737 .retain_state_suspended = 0,
3738 },
3739 {
3740 .name = "dual_led:red",
3741 .gpio = GPIO_LED2_RED_N,
3742 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3743 .active_low = 1,
3744 .retain_state_suspended = 0,
3745 },
3746};
3747
3748static struct gpio_led_platform_data gpio_led_pdata = {
3749 .leds = fluid_gpio_leds,
3750 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3751};
3752
3753static struct platform_device fluid_leds_gpio = {
3754 .name = "leds-gpio",
3755 .id = -1,
3756 .dev = {
3757 .platform_data = &gpio_led_pdata,
3758 },
3759};
3760
3761#endif
3762
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003763#ifdef CONFIG_BATTERY_MSM8X60
3764static struct msm_charger_platform_data msm_charger_data = {
3765 .safety_time = 180,
3766 .update_time = 1,
3767 .max_voltage = 4200,
3768 .min_voltage = 3200,
3769};
3770
3771static struct platform_device msm_charger_device = {
3772 .name = "msm-charger",
3773 .id = -1,
3774 .dev = {
3775 .platform_data = &msm_charger_data,
3776 }
3777};
3778#endif
3779
3780/*
3781 * Consumer specific regulator names:
3782 * regulator name consumer dev_name
3783 */
3784static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3785 REGULATOR_SUPPLY("8058_l0", NULL),
3786};
3787static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3788 REGULATOR_SUPPLY("8058_l1", NULL),
3789};
3790static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3791 REGULATOR_SUPPLY("8058_l2", NULL),
3792};
3793static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3794 REGULATOR_SUPPLY("8058_l3", NULL),
3795};
3796static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3797 REGULATOR_SUPPLY("8058_l4", NULL),
3798};
3799static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3800 REGULATOR_SUPPLY("8058_l5", NULL),
3801};
3802static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3803 REGULATOR_SUPPLY("8058_l6", NULL),
3804};
3805static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3806 REGULATOR_SUPPLY("8058_l7", NULL),
3807};
3808static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3809 REGULATOR_SUPPLY("8058_l8", NULL),
3810};
3811static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3812 REGULATOR_SUPPLY("8058_l9", NULL),
3813};
3814static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3815 REGULATOR_SUPPLY("8058_l10", NULL),
3816};
3817static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3818 REGULATOR_SUPPLY("8058_l11", NULL),
3819};
3820static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3821 REGULATOR_SUPPLY("8058_l12", NULL),
3822};
3823static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3824 REGULATOR_SUPPLY("8058_l13", NULL),
3825};
3826static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3827 REGULATOR_SUPPLY("8058_l14", NULL),
3828};
3829static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3830 REGULATOR_SUPPLY("8058_l15", NULL),
3831};
3832static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3833 REGULATOR_SUPPLY("8058_l16", NULL),
3834};
3835static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3836 REGULATOR_SUPPLY("8058_l17", NULL),
3837};
3838static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3839 REGULATOR_SUPPLY("8058_l18", NULL),
3840};
3841static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3842 REGULATOR_SUPPLY("8058_l19", NULL),
3843};
3844static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3845 REGULATOR_SUPPLY("8058_l20", NULL),
3846};
3847static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3848 REGULATOR_SUPPLY("8058_l21", NULL),
3849};
3850static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3851 REGULATOR_SUPPLY("8058_l22", NULL),
3852};
3853static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3854 REGULATOR_SUPPLY("8058_l23", NULL),
3855};
3856static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3857 REGULATOR_SUPPLY("8058_l24", NULL),
3858};
3859static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3860 REGULATOR_SUPPLY("8058_l25", NULL),
3861};
3862static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3863 REGULATOR_SUPPLY("8058_s0", NULL),
3864};
3865static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3866 REGULATOR_SUPPLY("8058_s1", NULL),
3867};
3868static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3869 REGULATOR_SUPPLY("8058_s2", NULL),
3870};
3871static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3872 REGULATOR_SUPPLY("8058_s3", NULL),
3873};
3874static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3875 REGULATOR_SUPPLY("8058_s4", NULL),
3876};
3877static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3878 REGULATOR_SUPPLY("8058_lvs0", NULL),
3879};
3880static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3881 REGULATOR_SUPPLY("8058_lvs1", NULL),
3882};
3883static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3884 REGULATOR_SUPPLY("8058_ncp", NULL),
3885};
3886
3887static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3888 REGULATOR_SUPPLY("8901_l0", NULL),
3889};
3890static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3891 REGULATOR_SUPPLY("8901_l1", NULL),
3892};
3893static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3894 REGULATOR_SUPPLY("8901_l2", NULL),
3895};
3896static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3897 REGULATOR_SUPPLY("8901_l3", NULL),
3898};
3899static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3900 REGULATOR_SUPPLY("8901_l4", NULL),
3901};
3902static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3903 REGULATOR_SUPPLY("8901_l5", NULL),
3904};
3905static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3906 REGULATOR_SUPPLY("8901_l6", NULL),
3907};
3908static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3909 REGULATOR_SUPPLY("8901_s2", NULL),
3910};
3911static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3912 REGULATOR_SUPPLY("8901_s3", NULL),
3913};
3914static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3915 REGULATOR_SUPPLY("8901_s4", NULL),
3916};
3917static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3918 REGULATOR_SUPPLY("8901_lvs0", NULL),
3919};
3920static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3921 REGULATOR_SUPPLY("8901_lvs1", NULL),
3922};
3923static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3924 REGULATOR_SUPPLY("8901_lvs2", NULL),
3925};
3926static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3927 REGULATOR_SUPPLY("8901_lvs3", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3930 REGULATOR_SUPPLY("8901_mvs0", NULL),
3931};
3932
David Collins6f032ba2011-08-31 14:08:15 -07003933/* Pin control regulators */
3934static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3935 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3936};
3937static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3938 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3939};
3940static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3941 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3942};
3943static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3944 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3945};
3946static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3947 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3948};
3949static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3950 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3951};
3952
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003953#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3954 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins6f032ba2011-08-31 14:08:15 -07003955 _freq, _pin_fn, _force_mode, _state, _sleep_selectable, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003956 _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003957 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003958 .init_data = { \
3959 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003960 .valid_modes_mask = _modes, \
3961 .valid_ops_mask = _ops, \
3962 .min_uV = _min_uV, \
3963 .max_uV = _max_uV, \
3964 .input_uV = _min_uV, \
3965 .apply_uV = _apply_uV, \
3966 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003967 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003968 .consumer_supplies = vreg_consumers_##_id, \
3969 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003970 ARRAY_SIZE(vreg_consumers_##_id), \
3971 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003972 .id = RPM_VREG_ID_##_id, \
3973 .default_uV = _default_uV, \
3974 .peak_uA = _peak_uA, \
3975 .avg_uA = _avg_uA, \
3976 .pull_down_enable = _pull_down, \
3977 .pin_ctrl = _pin_ctrl, \
3978 .freq = RPM_VREG_FREQ_##_freq, \
3979 .pin_fn = _pin_fn, \
3980 .force_mode = _force_mode, \
3981 .state = _state, \
3982 .sleep_selectable = _sleep_selectable, \
3983 }
3984
3985/* Pin control initialization */
3986#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3987 { \
3988 .init_data = { \
3989 .constraints = { \
3990 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3991 .always_on = _always_on, \
3992 }, \
3993 .num_consumer_supplies = \
3994 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3995 .consumer_supplies = vreg_consumers_##_id##_PC, \
3996 }, \
3997 .id = RPM_VREG_ID_##_id##_PC, \
3998 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003999 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004000 }
4001
4002/*
4003 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4004 * via the peak_uA value specified in the table below. If the value is less
4005 * than the high power min threshold for the regulator, then the regulator will
4006 * be set to LPM. Otherwise, it will be set to HPM.
4007 *
4008 * This value can be further overridden by specifying an initial mode via
4009 * .init_data.constraints.initial_mode.
4010 */
4011
David Collins6f032ba2011-08-31 14:08:15 -07004012#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4013 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004014 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4015 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4016 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4017 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4018 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004019 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4020 RPM_VREG_PIN_FN_8660_ENABLE, \
4021 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004022 _sleep_selectable, _always_on)
4023
David Collins6f032ba2011-08-31 14:08:15 -07004024#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4025 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004026 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4027 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4028 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4029 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4030 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004031 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4032 RPM_VREG_PIN_FN_8660_ENABLE, \
4033 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4034 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004035
David Collins6f032ba2011-08-31 14:08:15 -07004036#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004037 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4038 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004039 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4040 RPM_VREG_PIN_FN_8660_ENABLE, \
4041 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4042 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004043
David Collins6f032ba2011-08-31 14:08:15 -07004044#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4046 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004047 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4048 RPM_VREG_PIN_FN_8660_ENABLE, \
4049 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4050 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004051
David Collins6f032ba2011-08-31 14:08:15 -07004052#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4053#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4054#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4055#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4056#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004057
David Collins6f032ba2011-08-31 14:08:15 -07004058/* RPM early regulator constraints */
4059static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4060 /* ID a_on pd ss min_uV max_uV init_ip freq */
4061 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
4062 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004063};
4064
David Collins6f032ba2011-08-31 14:08:15 -07004065/* RPM regulator constraints */
4066static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4067 /* ID a_on pd ss min_uV max_uV init_ip */
4068 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4069 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4070 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4071 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4072 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4073 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4074 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4075 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4076 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4077 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4078 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4079 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4080 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4081 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4082 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4083 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4084 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4085 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4086 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4087 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4088 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4089 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4090 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4091 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4092 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4093 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004094
David Collins6f032ba2011-08-31 14:08:15 -07004095 /* ID a_on pd ss min_uV max_uV init_ip freq */
4096 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4097 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4098 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4099
4100 /* ID a_on pd ss */
4101 RPM_VS(PM8058_LVS0, 0, 1, 0),
4102 RPM_VS(PM8058_LVS1, 0, 1, 0),
4103
4104 /* ID a_on pd ss min_uV max_uV */
4105 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4106
4107 /* ID a_on pd ss min_uV max_uV init_ip */
4108 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4109 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4110 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4111 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4112 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4113 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4114 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4115
4116 /* ID a_on pd ss min_uV max_uV init_ip freq */
4117 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4118 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4119 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4120
4121 /* ID a_on pd ss */
4122 RPM_VS(PM8901_LVS0, 1, 1, 0),
4123 RPM_VS(PM8901_LVS1, 0, 1, 0),
4124 RPM_VS(PM8901_LVS2, 0, 1, 0),
4125 RPM_VS(PM8901_LVS3, 0, 1, 0),
4126 RPM_VS(PM8901_MVS0, 0, 1, 0),
4127
4128 /* ID a_on pin_func pin_ctrl */
4129 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4130 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4131 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4132 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4133 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4134 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4135};
4136
4137static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4138 .init_data = rpm_regulator_early_init_data,
4139 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4140 .version = RPM_VREG_VERSION_8660,
4141 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4142 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4143};
4144
4145static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4146 .init_data = rpm_regulator_init_data,
4147 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4148 .version = RPM_VREG_VERSION_8660,
4149};
4150
4151static struct platform_device rpm_regulator_early_device = {
4152 .name = "rpm-regulator",
4153 .id = 0,
4154 .dev = {
4155 .platform_data = &rpm_regulator_early_pdata,
4156 },
4157};
4158
4159static struct platform_device rpm_regulator_device = {
4160 .name = "rpm-regulator",
4161 .id = 1,
4162 .dev = {
4163 .platform_data = &rpm_regulator_pdata,
4164 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004165};
4166
4167static struct platform_device *early_regulators[] __initdata = {
4168 &msm_device_saw_s0,
4169 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004170 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004171};
4172
4173static struct platform_device *early_devices[] __initdata = {
4174#ifdef CONFIG_MSM_BUS_SCALING
4175 &msm_bus_apps_fabric,
4176 &msm_bus_sys_fabric,
4177 &msm_bus_mm_fabric,
4178 &msm_bus_sys_fpb,
4179 &msm_bus_cpss_fpb,
4180#endif
4181 &msm_device_dmov_adm0,
4182 &msm_device_dmov_adm1,
4183};
4184
4185#if (defined(CONFIG_MARIMBA_CORE)) && \
4186 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4187
4188static int bluetooth_power(int);
4189static struct platform_device msm_bt_power_device = {
4190 .name = "bt_power",
4191 .id = -1,
4192 .dev = {
4193 .platform_data = &bluetooth_power,
4194 },
4195};
4196#endif
4197
4198static struct platform_device msm_tsens_device = {
4199 .name = "tsens-tm",
4200 .id = -1,
4201};
4202
4203static struct platform_device *rumi_sim_devices[] __initdata = {
4204 &smc91x_device,
4205 &msm_device_uart_dm12,
4206#ifdef CONFIG_I2C_QUP
4207 &msm_gsbi3_qup_i2c_device,
4208 &msm_gsbi4_qup_i2c_device,
4209 &msm_gsbi7_qup_i2c_device,
4210 &msm_gsbi8_qup_i2c_device,
4211 &msm_gsbi9_qup_i2c_device,
4212 &msm_gsbi12_qup_i2c_device,
4213#endif
4214#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004215 &msm_device_ssbi3,
4216#endif
4217#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004218#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004219 &android_pmem_device,
4220 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004221 &android_pmem_smipool_device,
4222#endif
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004223 &android_pmem_audio_device,
4224#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004225#ifdef CONFIG_MSM_ROTATOR
4226 &msm_rotator_device,
4227#endif
4228 &msm_fb_device,
4229 &msm_kgsl_3d0,
4230 &msm_kgsl_2d0,
4231 &msm_kgsl_2d1,
4232 &lcdc_samsung_panel_device,
4233#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4234 &hdmi_msm_device,
4235#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4236#ifdef CONFIG_MSM_CAMERA
4237#ifdef CONFIG_MT9E013
4238 &msm_camera_sensor_mt9e013,
4239#endif
4240#ifdef CONFIG_IMX074
4241 &msm_camera_sensor_imx074,
4242#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004243#ifdef CONFIG_VX6953
4244 &msm_camera_sensor_vx6953,
4245#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004246#ifdef CONFIG_WEBCAM_OV7692
4247 &msm_camera_sensor_webcam_ov7692,
4248#endif
4249#ifdef CONFIG_WEBCAM_OV9726
4250 &msm_camera_sensor_webcam_ov9726,
4251#endif
4252#ifdef CONFIG_QS_S5K4E1
4253 &msm_camera_sensor_qs_s5k4e1,
4254#endif
4255#endif
4256#ifdef CONFIG_MSM_GEMINI
4257 &msm_gemini_device,
4258#endif
4259#ifdef CONFIG_MSM_VPE
4260 &msm_vpe_device,
4261#endif
4262 &msm_device_vidc,
4263};
4264
4265#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4266enum {
4267 SX150X_CORE,
4268 SX150X_DOCKING,
4269 SX150X_SURF,
4270 SX150X_LEFT_FHA,
4271 SX150X_RIGHT_FHA,
4272 SX150X_SOUTH,
4273 SX150X_NORTH,
4274 SX150X_CORE_FLUID,
4275};
4276
4277static struct sx150x_platform_data sx150x_data[] __initdata = {
4278 [SX150X_CORE] = {
4279 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4280 .oscio_is_gpo = false,
4281 .io_pullup_ena = 0x0c08,
4282 .io_pulldn_ena = 0x4060,
4283 .io_open_drain_ena = 0x000c,
4284 .io_polarity = 0,
4285 .irq_summary = -1, /* see fixup_i2c_configs() */
4286 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4287 },
4288 [SX150X_DOCKING] = {
4289 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4290 .oscio_is_gpo = false,
4291 .io_pullup_ena = 0x5e06,
4292 .io_pulldn_ena = 0x81b8,
4293 .io_open_drain_ena = 0,
4294 .io_polarity = 0,
4295 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4296 UI_INT2_N),
4297 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4298 GPIO_DOCKING_EXPANDER_BASE -
4299 GPIO_EXPANDER_GPIO_BASE,
4300 },
4301 [SX150X_SURF] = {
4302 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4303 .oscio_is_gpo = false,
4304 .io_pullup_ena = 0,
4305 .io_pulldn_ena = 0,
4306 .io_open_drain_ena = 0,
4307 .io_polarity = 0,
4308 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4309 UI_INT1_N),
4310 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4311 GPIO_SURF_EXPANDER_BASE -
4312 GPIO_EXPANDER_GPIO_BASE,
4313 },
4314 [SX150X_LEFT_FHA] = {
4315 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4316 .oscio_is_gpo = false,
4317 .io_pullup_ena = 0,
4318 .io_pulldn_ena = 0x40,
4319 .io_open_drain_ena = 0,
4320 .io_polarity = 0,
4321 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4322 UI_INT3_N),
4323 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4324 GPIO_LEFT_KB_EXPANDER_BASE -
4325 GPIO_EXPANDER_GPIO_BASE,
4326 },
4327 [SX150X_RIGHT_FHA] = {
4328 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4329 .oscio_is_gpo = true,
4330 .io_pullup_ena = 0,
4331 .io_pulldn_ena = 0,
4332 .io_open_drain_ena = 0,
4333 .io_polarity = 0,
4334 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4335 UI_INT3_N),
4336 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4337 GPIO_RIGHT_KB_EXPANDER_BASE -
4338 GPIO_EXPANDER_GPIO_BASE,
4339 },
4340 [SX150X_SOUTH] = {
4341 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4342 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4343 GPIO_SOUTH_EXPANDER_BASE -
4344 GPIO_EXPANDER_GPIO_BASE,
4345 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4346 },
4347 [SX150X_NORTH] = {
4348 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4349 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4350 GPIO_NORTH_EXPANDER_BASE -
4351 GPIO_EXPANDER_GPIO_BASE,
4352 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4353 .oscio_is_gpo = true,
4354 .io_open_drain_ena = 0x30,
4355 },
4356 [SX150X_CORE_FLUID] = {
4357 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4358 .oscio_is_gpo = false,
4359 .io_pullup_ena = 0x0408,
4360 .io_pulldn_ena = 0x4060,
4361 .io_open_drain_ena = 0x0008,
4362 .io_polarity = 0,
4363 .irq_summary = -1, /* see fixup_i2c_configs() */
4364 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4365 },
4366};
4367
4368#ifdef CONFIG_SENSORS_MSM_ADC
4369/* Configuration of EPM expander is done when client
4370 * request an adc read
4371 */
4372static struct sx150x_platform_data sx150x_epmdata = {
4373 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4374 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4375 GPIO_EPM_EXPANDER_BASE -
4376 GPIO_EXPANDER_GPIO_BASE,
4377 .irq_summary = -1,
4378};
4379#endif
4380
4381/* sx150x_low_power_cfg
4382 *
4383 * This data and init function are used to put unused gpio-expander output
4384 * lines into their low-power states at boot. The init
4385 * function must be deferred until a later init stage because the i2c
4386 * gpio expander drivers do not probe until after they are registered
4387 * (see register_i2c_devices) and the work-queues for those registrations
4388 * are processed. Because these lines are unused, there is no risk of
4389 * competing with a device driver for the gpio.
4390 *
4391 * gpio lines whose low-power states are input are naturally in their low-
4392 * power configurations once probed, see the platform data structures above.
4393 */
4394struct sx150x_low_power_cfg {
4395 unsigned gpio;
4396 unsigned val;
4397};
4398
4399static struct sx150x_low_power_cfg
4400common_sx150x_lp_cfgs[] __initdata = {
4401 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4402 {GPIO_EXT_GPS_LNA_EN, 0},
4403 {GPIO_MSM_WAKES_BT, 0},
4404 {GPIO_USB_UICC_EN, 0},
4405 {GPIO_BATT_GAUGE_EN, 0},
4406};
4407
4408static struct sx150x_low_power_cfg
4409surf_ffa_sx150x_lp_cfgs[] __initdata = {
4410 {GPIO_MIPI_DSI_RST_N, 0},
4411 {GPIO_DONGLE_PWR_EN, 0},
4412 {GPIO_CAP_TS_SLEEP, 1},
4413 {GPIO_WEB_CAMIF_RESET_N, 0},
4414};
4415
4416static void __init
4417cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4418{
4419 unsigned n;
4420 int rc;
4421
4422 for (n = 0; n < nelems; ++n) {
4423 rc = gpio_request(cfgs[n].gpio, NULL);
4424 if (!rc) {
4425 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4426 gpio_free(cfgs[n].gpio);
4427 }
4428
4429 if (rc) {
4430 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4431 __func__, cfgs[n].gpio, rc);
4432 }
Steve Muckle9161d302010-02-11 11:50:40 -08004433 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004434}
4435
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004437{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004438 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4439 ARRAY_SIZE(common_sx150x_lp_cfgs));
4440 if (!machine_is_msm8x60_fluid())
4441 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4442 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4443 return 0;
4444}
4445module_init(cfg_sx150xs_low_power);
4446
4447#ifdef CONFIG_I2C
4448static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4449 {
4450 I2C_BOARD_INFO("sx1509q", 0x3e),
4451 .platform_data = &sx150x_data[SX150X_CORE]
4452 },
4453};
4454
4455static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4456 {
4457 I2C_BOARD_INFO("sx1509q", 0x3f),
4458 .platform_data = &sx150x_data[SX150X_DOCKING]
4459 },
4460};
4461
4462static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4463 {
4464 I2C_BOARD_INFO("sx1509q", 0x70),
4465 .platform_data = &sx150x_data[SX150X_SURF]
4466 }
4467};
4468
4469static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4470 {
4471 I2C_BOARD_INFO("sx1508q", 0x21),
4472 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4473 },
4474 {
4475 I2C_BOARD_INFO("sx1508q", 0x22),
4476 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4477 }
4478};
4479
4480static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4481 {
4482 I2C_BOARD_INFO("sx1508q", 0x23),
4483 .platform_data = &sx150x_data[SX150X_SOUTH]
4484 },
4485 {
4486 I2C_BOARD_INFO("sx1508q", 0x20),
4487 .platform_data = &sx150x_data[SX150X_NORTH]
4488 }
4489};
4490
4491static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4492 {
4493 I2C_BOARD_INFO("sx1509q", 0x3e),
4494 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4495 },
4496};
4497
4498#ifdef CONFIG_SENSORS_MSM_ADC
4499static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4500 {
4501 I2C_BOARD_INFO("sx1509q", 0x3e),
4502 .platform_data = &sx150x_epmdata
4503 },
4504};
4505#endif
4506#endif
4507#endif
4508
4509#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004510
4511static struct adc_access_fn xoadc_fn = {
4512 pm8058_xoadc_select_chan_and_start_conv,
4513 pm8058_xoadc_read_adc_code,
4514 pm8058_xoadc_get_properties,
4515 pm8058_xoadc_slot_request,
4516 pm8058_xoadc_restore_slot,
4517 pm8058_xoadc_calibrate,
4518};
4519
4520#if defined(CONFIG_I2C) && \
4521 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4522static struct regulator *vreg_adc_epm1;
4523
4524static struct i2c_client *epm_expander_i2c_register_board(void)
4525
4526{
4527 struct i2c_adapter *i2c_adap;
4528 struct i2c_client *client = NULL;
4529 i2c_adap = i2c_get_adapter(0x0);
4530
4531 if (i2c_adap == NULL)
4532 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4533
4534 if (i2c_adap != NULL)
4535 client = i2c_new_device(i2c_adap,
4536 &fluid_expanders_i2c_epm_info[0]);
4537 return client;
4538
4539}
4540
4541static unsigned int msm_adc_gpio_configure_expander_enable(void)
4542{
4543 int rc = 0;
4544 static struct i2c_client *epm_i2c_client;
4545
4546 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4547
4548 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4549
4550 if (IS_ERR(vreg_adc_epm1)) {
4551 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4552 return 0;
4553 }
4554
4555 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4556 if (rc)
4557 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4558 "regulator set voltage failed\n");
4559
4560 rc = regulator_enable(vreg_adc_epm1);
4561 if (rc) {
4562 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4563 "Error while enabling regulator for epm s3 %d\n", rc);
4564 return rc;
4565 }
4566
4567 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4568 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4569
4570 msleep(1000);
4571
4572 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4573 if (!rc) {
4574 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4575 "Configure 5v boost\n");
4576 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4577 } else {
4578 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4579 "Error for epm 5v boost en\n");
4580 goto exit_vreg_epm;
4581 }
4582
4583 msleep(500);
4584
4585 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4586 if (!rc) {
4587 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4588 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4589 "Configure epm 3.3v\n");
4590 } else {
4591 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4592 "Error for gpio 3.3ven\n");
4593 goto exit_vreg_epm;
4594 }
4595 msleep(500);
4596
4597 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4598 "Trying to request EPM LVLSFT_EN\n");
4599 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4600 if (!rc) {
4601 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4602 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4603 "Configure the lvlsft\n");
4604 } else {
4605 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4606 "Error for epm lvlsft_en\n");
4607 goto exit_vreg_epm;
4608 }
4609
4610 msleep(500);
4611
4612 if (!epm_i2c_client)
4613 epm_i2c_client = epm_expander_i2c_register_board();
4614
4615 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4616 if (!rc)
4617 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4618 if (rc) {
4619 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4620 ": GPIO PWR MON Enable issue\n");
4621 goto exit_vreg_epm;
4622 }
4623
4624 msleep(1000);
4625
4626 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4627 if (!rc) {
4628 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4629 if (rc) {
4630 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4631 ": ADC1_PWDN error direction out\n");
4632 goto exit_vreg_epm;
4633 }
4634 }
4635
4636 msleep(100);
4637
4638 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4639 if (!rc) {
4640 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4641 if (rc) {
4642 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4643 ": ADC2_PWD error direction out\n");
4644 goto exit_vreg_epm;
4645 }
4646 }
4647
4648 msleep(1000);
4649
4650 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4651 if (!rc) {
4652 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4653 if (rc) {
4654 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4655 "Gpio request problem %d\n", rc);
4656 goto exit_vreg_epm;
4657 }
4658 }
4659
4660 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4661 if (!rc) {
4662 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4663 if (rc) {
4664 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4665 ": EPM_SPI_ADC1_CS_N error\n");
4666 goto exit_vreg_epm;
4667 }
4668 }
4669
4670 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4671 if (!rc) {
4672 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4673 if (rc) {
4674 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4675 ": EPM_SPI_ADC2_Cs_N error\n");
4676 goto exit_vreg_epm;
4677 }
4678 }
4679
4680 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4681 "the power monitor reset for epm\n");
4682
4683 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4684 if (!rc) {
4685 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4686 if (rc) {
4687 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4688 ": Error in the power mon reset\n");
4689 goto exit_vreg_epm;
4690 }
4691 }
4692
4693 msleep(1000);
4694
4695 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4696
4697 msleep(500);
4698
4699 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4700
4701 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4702
4703 return rc;
4704
4705exit_vreg_epm:
4706 regulator_disable(vreg_adc_epm1);
4707
4708 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4709 " rc = %d.\n", rc);
4710 return rc;
4711};
4712
4713static unsigned int msm_adc_gpio_configure_expander_disable(void)
4714{
4715 int rc = 0;
4716
4717 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4718 gpio_free(GPIO_PWR_MON_RESET_N);
4719
4720 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4721 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4722
4723 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4724 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4725
4726 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4727 gpio_free(GPIO_PWR_MON_START);
4728
4729 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4730 gpio_free(GPIO_ADC1_PWDN_N);
4731
4732 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4733 gpio_free(GPIO_ADC2_PWDN_N);
4734
4735 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4736 gpio_free(GPIO_PWR_MON_ENABLE);
4737
4738 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4739 gpio_free(GPIO_EPM_LVLSFT_EN);
4740
4741 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4742 gpio_free(GPIO_EPM_5V_BOOST_EN);
4743
4744 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4745 gpio_free(GPIO_EPM_3_3V_EN);
4746
4747 rc = regulator_disable(vreg_adc_epm1);
4748 if (rc)
4749 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4750 "Error while enabling regulator for epm s3 %d\n", rc);
4751 regulator_put(vreg_adc_epm1);
4752
4753 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4754 return rc;
4755};
4756
4757unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4758{
4759 int rc = 0;
4760
4761 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4762 cs_enable);
4763
4764 if (cs_enable < 16) {
4765 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4766 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4767 } else {
4768 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4769 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4770 }
4771 return rc;
4772};
4773
4774unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4775{
4776 int rc = 0;
4777
4778 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4779
4780 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4781
4782 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4783
4784 return rc;
4785};
4786#endif
4787
4788static struct msm_adc_channels msm_adc_channels_data[] = {
4789 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4790 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4791 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4792 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4793 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4794 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4795 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4796 CHAN_PATH_TYPE4,
4797 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4798 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4799 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4800 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4801 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4802 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4803 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4804 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4805 CHAN_PATH_TYPE12,
4806 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4807 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4808 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4809 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4810 CHAN_PATH_TYPE_NONE,
4811 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4812 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4813 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4814 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4815 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4816 scale_xtern_chgr_cur},
4817 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4818 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4819 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4820 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4821 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4822 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4823 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4824 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4825 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4826 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4827 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4828 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4829};
4830
4831static char *msm_adc_fluid_device_names[] = {
4832 "ADS_ADC1",
4833 "ADS_ADC2",
4834};
4835
4836static struct msm_adc_platform_data msm_adc_pdata = {
4837 .channel = msm_adc_channels_data,
4838 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4839#if defined(CONFIG_I2C) && \
4840 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4841 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4842 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4843 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4844 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4845#endif
4846};
4847
4848static struct platform_device msm_adc_device = {
4849 .name = "msm_adc",
4850 .id = -1,
4851 .dev = {
4852 .platform_data = &msm_adc_pdata,
4853 },
4854};
4855
4856static void pmic8058_xoadc_mpp_config(void)
4857{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304858 int rc, i;
4859 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304860 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304861 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304862 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304863 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304864 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304865 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304866 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304867 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304868 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304869 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304870 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4871 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304872 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004873
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304874 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4875 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4876 &xoadc_mpps[i].config);
4877 if (rc) {
4878 pr_err("%s: Config MPP %d of PM8058 failed\n",
4879 __func__, xoadc_mpps[i].mpp);
4880 }
4881 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004882}
4883
4884static struct regulator *vreg_ldo18_adc;
4885
4886static int pmic8058_xoadc_vreg_config(int on)
4887{
4888 int rc;
4889
4890 if (on) {
4891 rc = regulator_enable(vreg_ldo18_adc);
4892 if (rc)
4893 pr_err("%s: Enable of regulator ldo18_adc "
4894 "failed\n", __func__);
4895 } else {
4896 rc = regulator_disable(vreg_ldo18_adc);
4897 if (rc)
4898 pr_err("%s: Disable of regulator ldo18_adc "
4899 "failed\n", __func__);
4900 }
4901
4902 return rc;
4903}
4904
4905static int pmic8058_xoadc_vreg_setup(void)
4906{
4907 int rc;
4908
4909 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4910 if (IS_ERR(vreg_ldo18_adc)) {
4911 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4912 __func__, PTR_ERR(vreg_ldo18_adc));
4913 rc = PTR_ERR(vreg_ldo18_adc);
4914 goto fail;
4915 }
4916
4917 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4918 if (rc) {
4919 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4920 goto fail;
4921 }
4922
4923 return rc;
4924fail:
4925 regulator_put(vreg_ldo18_adc);
4926 return rc;
4927}
4928
4929static void pmic8058_xoadc_vreg_shutdown(void)
4930{
4931 regulator_put(vreg_ldo18_adc);
4932}
4933
4934/* usec. For this ADC,
4935 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4936 * Each channel has different configuration, thus at the time of starting
4937 * the conversion, xoadc will return actual conversion time
4938 * */
4939static struct adc_properties pm8058_xoadc_data = {
4940 .adc_reference = 2200, /* milli-voltage for this adc */
4941 .bitresolution = 15,
4942 .bipolar = 0,
4943 .conversiontime = 54,
4944};
4945
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304946static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004947 .xoadc_prop = &pm8058_xoadc_data,
4948 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4949 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4950 .xoadc_num = XOADC_PMIC_0,
4951 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4952 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4953};
4954#endif
4955
4956#ifdef CONFIG_MSM_SDIO_AL
4957
4958static unsigned mdm2ap_status = 140;
4959
4960static int configure_mdm2ap_status(int on)
4961{
4962 int ret = 0;
4963 if (on)
4964 ret = msm_gpiomux_get(mdm2ap_status);
4965 else
4966 ret = msm_gpiomux_put(mdm2ap_status);
4967
4968 if (ret)
4969 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4970 on);
4971
4972 return ret;
4973}
4974
4975
4976static int get_mdm2ap_status(void)
4977{
4978 return gpio_get_value(mdm2ap_status);
4979}
4980
4981static struct sdio_al_platform_data sdio_al_pdata = {
4982 .config_mdm2ap_status = configure_mdm2ap_status,
4983 .get_mdm2ap_status = get_mdm2ap_status,
4984 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004985 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004986 .peer_sdioc_version_major = 0x0004,
4987 .peer_sdioc_boot_version_minor = 0x0001,
4988 .peer_sdioc_boot_version_major = 0x0003
4989};
4990
4991struct platform_device msm_device_sdio_al = {
4992 .name = "msm_sdio_al",
4993 .id = -1,
4994 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004995 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004996 .platform_data = &sdio_al_pdata,
4997 },
4998};
4999
5000#endif /* CONFIG_MSM_SDIO_AL */
5001
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305002#define GPIO_VREG_ID_EXT_5V 0
5003
5004static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5005 REGULATOR_SUPPLY("ext_5v", NULL),
5006 REGULATOR_SUPPLY("8901_mpp0", NULL),
5007};
5008
5009#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5010 [GPIO_VREG_ID_##_id] = { \
5011 .init_data = { \
5012 .constraints = { \
5013 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5014 }, \
5015 .num_consumer_supplies = \
5016 ARRAY_SIZE(vreg_consumers_##_id), \
5017 .consumer_supplies = vreg_consumers_##_id, \
5018 }, \
5019 .regulator_name = _reg_name, \
5020 .active_low = _active_low, \
5021 .gpio_label = _gpio_label, \
5022 .gpio = _gpio, \
5023 }
5024
5025/* GPIO regulator constraints */
5026static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5027 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5028 PM8901_MPP_PM_TO_SYS(0), 0),
5029};
5030
5031/* GPIO regulator */
5032static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5033 .name = GPIO_REGULATOR_DEV_NAME,
5034 .id = PM8901_MPP_PM_TO_SYS(0),
5035 .dev = {
5036 .platform_data =
5037 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5038 },
5039};
5040
5041static void __init pm8901_vreg_mpp0_init(void)
5042{
5043 int rc;
5044
5045 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5046 .mpp = PM8901_MPP_PM_TO_SYS(0),
5047 .config = {
5048 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5049 .level = PM8901_MPP_DIG_LEVEL_VPH,
5050 },
5051 };
5052
5053 /*
5054 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5055 * implies that the regulator connected to MPP0 is enabled when
5056 * MPP0 is low.
5057 */
5058 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5059 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5060 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5061 } else {
5062 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5063 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5064 }
5065
5066 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5067 if (rc)
5068 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5069}
5070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005071static struct platform_device *charm_devices[] __initdata = {
5072 &msm_charm_modem,
5073#ifdef CONFIG_MSM_SDIO_AL
5074 &msm_device_sdio_al,
5075#endif
5076};
5077
Lei Zhou338cab82011-08-19 13:38:17 -04005078#ifdef CONFIG_SND_SOC_MSM8660_APQ
5079static struct platform_device *dragon_alsa_devices[] __initdata = {
5080 &msm_pcm,
5081 &msm_pcm_routing,
5082 &msm_cpudai0,
5083 &msm_cpudai1,
5084 &msm_cpudai_hdmi_rx,
5085 &msm_cpudai_bt_rx,
5086 &msm_cpudai_bt_tx,
5087 &msm_cpudai_fm_rx,
5088 &msm_cpudai_fm_tx,
5089 &msm_cpu_fe,
5090 &msm_stub_codec,
5091 &msm_lpa_pcm,
5092};
5093#endif
5094
5095static struct platform_device *asoc_devices[] __initdata = {
5096 &asoc_msm_pcm,
5097 &asoc_msm_dai0,
5098 &asoc_msm_dai1,
5099};
5100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005101static struct platform_device *surf_devices[] __initdata = {
5102 &msm_device_smd,
5103 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005104 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005105 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005106 &msm_pil_tzapps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005107#ifdef CONFIG_I2C_QUP
5108 &msm_gsbi3_qup_i2c_device,
5109 &msm_gsbi4_qup_i2c_device,
5110 &msm_gsbi7_qup_i2c_device,
5111 &msm_gsbi8_qup_i2c_device,
5112 &msm_gsbi9_qup_i2c_device,
5113 &msm_gsbi12_qup_i2c_device,
5114#endif
5115#ifdef CONFIG_SERIAL_MSM_HS
5116 &msm_device_uart_dm1,
5117#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305118#ifdef CONFIG_MSM_SSBI
5119 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305120 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305121#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005122#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005123 &msm_device_ssbi3,
5124#endif
5125#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5126 &isp1763_device,
5127#endif
5128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005129#if defined (CONFIG_MSM_8x60_VOIP)
5130 &asoc_msm_mvs,
5131 &asoc_mvs_dai0,
5132 &asoc_mvs_dai1,
5133#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005134
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005135#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
5136 &msm_device_otg,
5137#endif
5138#ifdef CONFIG_USB_GADGET_MSM_72K
5139 &msm_device_gadget_peripheral,
5140#endif
5141#ifdef CONFIG_USB_G_ANDROID
5142 &android_usb_device,
5143#endif
5144#ifdef CONFIG_BATTERY_MSM
5145 &msm_batt_device,
5146#endif
5147#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005148#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005149 &android_pmem_device,
5150 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151 &android_pmem_smipool_device,
5152#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005153 &android_pmem_audio_device,
5154#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005155#ifdef CONFIG_MSM_ROTATOR
5156 &msm_rotator_device,
5157#endif
5158 &msm_fb_device,
5159 &msm_kgsl_3d0,
5160 &msm_kgsl_2d0,
5161 &msm_kgsl_2d1,
5162 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005163#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5164 &lcdc_nt35582_panel_device,
5165#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005166#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5167 &lcdc_samsung_oled_panel_device,
5168#endif
5169#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5170 &lcdc_auo_wvga_panel_device,
5171#endif
5172#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5173 &hdmi_msm_device,
5174#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5175#ifdef CONFIG_FB_MSM_MIPI_DSI
5176 &mipi_dsi_toshiba_panel_device,
5177 &mipi_dsi_novatek_panel_device,
5178#endif
5179#ifdef CONFIG_MSM_CAMERA
5180#ifdef CONFIG_MT9E013
5181 &msm_camera_sensor_mt9e013,
5182#endif
5183#ifdef CONFIG_IMX074
5184 &msm_camera_sensor_imx074,
5185#endif
5186#ifdef CONFIG_WEBCAM_OV7692
5187 &msm_camera_sensor_webcam_ov7692,
5188#endif
5189#ifdef CONFIG_WEBCAM_OV9726
5190 &msm_camera_sensor_webcam_ov9726,
5191#endif
5192#ifdef CONFIG_QS_S5K4E1
5193 &msm_camera_sensor_qs_s5k4e1,
5194#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005195#ifdef CONFIG_VX6953
5196 &msm_camera_sensor_vx6953,
5197#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005198#endif
5199#ifdef CONFIG_MSM_GEMINI
5200 &msm_gemini_device,
5201#endif
5202#ifdef CONFIG_MSM_VPE
5203 &msm_vpe_device,
5204#endif
5205
5206#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005207 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005208#endif
5209#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005210 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211#endif
5212 &msm_device_vidc,
5213#if (defined(CONFIG_MARIMBA_CORE)) && \
5214 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5215 &msm_bt_power_device,
5216#endif
5217#ifdef CONFIG_SENSORS_MSM_ADC
5218 &msm_adc_device,
5219#endif
David Collins6f032ba2011-08-31 14:08:15 -07005220 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005221
5222#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5223 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5224 &qcrypto_device,
5225#endif
5226
5227#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5228 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5229 &qcedev_device,
5230#endif
5231
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005232
5233#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5234#ifdef CONFIG_MSM_USE_TSIF1
5235 &msm_device_tsif[1],
5236#else
5237 &msm_device_tsif[0],
5238#endif /* CONFIG_MSM_USE_TSIF1 */
5239#endif /* CONFIG_TSIF */
5240
5241#ifdef CONFIG_HW_RANDOM_MSM
5242 &msm_device_rng,
5243#endif
5244
5245 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005246 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005247#ifdef CONFIG_ION_MSM
5248 &ion_dev,
5249#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005250 &msm8660_device_watchdog,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005251};
5252
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005253#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005254#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5255static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5256 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan42ebe712012-01-10 16:30:58 -08005257 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005258 .request_region = request_smi_region,
5259 .release_region = release_smi_region,
5260 .setup_region = setup_smi_region,
5261};
5262
5263static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5264 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005265 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005266 .request_region = request_smi_region,
5267 .release_region = release_smi_region,
5268 .setup_region = setup_smi_region,
5269};
5270
5271static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5272 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005273 .align = PAGE_SIZE,
5274};
5275
5276static struct ion_co_heap_pdata fw_co_ion_pdata = {
5277 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5278 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005279};
5280
5281static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005282 .adjacent_mem_id = INVALID_HEAP_ID,
5283 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005284};
5285#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005286
5287/**
5288 * These heaps are listed in the order they will be allocated. Due to
5289 * video hardware restrictions and content protection the FW heap has to
5290 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5291 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5292 * away from the base address of the FW heap.
5293 * However, the order of FW heap and MM heap doesn't matter since these
5294 * two heaps are taken care of by separate code to ensure they are adjacent
5295 * to each other.
5296 * Don't swap the order unless you know what you are doing!
5297 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005298static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005299 .nr = MSM_ION_HEAP_NUM,
5300 .heaps = {
5301 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005302 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005303 .type = ION_HEAP_TYPE_SYSTEM,
5304 .name = ION_VMALLOC_HEAP_NAME,
5305 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005306#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5307 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005308 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005309 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005310 .name = ION_MM_HEAP_NAME,
5311 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005312 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005313 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005314 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005315 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005316 .id = ION_MM_FIRMWARE_HEAP_ID,
5317 .type = ION_HEAP_TYPE_CARVEOUT,
5318 .name = ION_MM_FIRMWARE_HEAP_NAME,
5319 .size = MSM_ION_MM_FW_SIZE,
5320 .memory_type = ION_SMI_TYPE,
5321 .extra_data = (void *) &fw_co_ion_pdata,
5322 },
5323 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005324 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005325 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005326 .name = ION_MFC_HEAP_NAME,
5327 .size = MSM_ION_MFC_SIZE,
5328 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005329 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005330 },
5331 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005332 .id = ION_SF_HEAP_ID,
5333 .type = ION_HEAP_TYPE_CARVEOUT,
5334 .name = ION_SF_HEAP_NAME,
5335 .size = MSM_ION_SF_SIZE,
5336 .memory_type = ION_EBI_TYPE,
5337 .extra_data = (void *)&co_ion_pdata,
5338 },
5339 {
5340 .id = ION_CAMERA_HEAP_ID,
5341 .type = ION_HEAP_TYPE_CARVEOUT,
5342 .name = ION_CAMERA_HEAP_NAME,
5343 .size = MSM_ION_CAMERA_SIZE,
5344 .memory_type = ION_EBI_TYPE,
5345 .extra_data = &co_ion_pdata,
5346 },
5347 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005348 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005349 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005350 .name = ION_WB_HEAP_NAME,
5351 .size = MSM_ION_WB_SIZE,
5352 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005353 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005354 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005355 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005356 .id = ION_QSECOM_HEAP_ID,
5357 .type = ION_HEAP_TYPE_CARVEOUT,
5358 .name = ION_QSECOM_HEAP_NAME,
5359 .size = MSM_ION_QSECOM_SIZE,
5360 .memory_type = ION_EBI_TYPE,
5361 .extra_data = (void *) &co_ion_pdata,
5362 },
5363 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005364 .id = ION_AUDIO_HEAP_ID,
5365 .type = ION_HEAP_TYPE_CARVEOUT,
5366 .name = ION_AUDIO_HEAP_NAME,
5367 .size = MSM_ION_AUDIO_SIZE,
5368 .memory_type = ION_EBI_TYPE,
5369 .extra_data = (void *)&co_ion_pdata,
5370 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005371#endif
5372 }
5373};
5374
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005375static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005376 .name = "ion-msm",
5377 .id = 1,
5378 .dev = { .platform_data = &ion_pdata },
5379};
5380#endif
5381
5382
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005383static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5384 /* Kernel SMI memory pool for video core, used for firmware */
5385 /* and encoder, decoder scratch buffers */
5386 /* Kernel SMI memory pool should always precede the user space */
5387 /* SMI memory pool, as the video core will use offset address */
5388 /* from the Firmware base */
5389 [MEMTYPE_SMI_KERNEL] = {
5390 .start = KERNEL_SMI_BASE,
5391 .limit = KERNEL_SMI_SIZE,
5392 .size = KERNEL_SMI_SIZE,
5393 .flags = MEMTYPE_FLAGS_FIXED,
5394 },
5395 /* User space SMI memory pool for video core */
5396 /* used for encoder, decoder input & output buffers */
5397 [MEMTYPE_SMI] = {
5398 .start = USER_SMI_BASE,
5399 .limit = USER_SMI_SIZE,
5400 .flags = MEMTYPE_FLAGS_FIXED,
5401 },
5402 [MEMTYPE_EBI0] = {
5403 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5404 },
5405 [MEMTYPE_EBI1] = {
5406 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5407 },
5408};
5409
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005410static void reserve_ion_memory(void)
5411{
5412#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Olav Hauganb5be7992011-11-18 14:29:02 -08005413 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
Olav Haugan42ebe712012-01-10 16:30:58 -08005414 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005415 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5416 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5417 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5418 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005419 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005420#endif
5421}
5422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005423static void __init size_pmem_devices(void)
5424{
5425#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005426#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005427 android_pmem_adsp_pdata.size = pmem_adsp_size;
5428 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005429 android_pmem_pdata.size = pmem_sf_size;
5430#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005431 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
5432#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005433}
5434
5435static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5436{
5437 msm8x60_reserve_table[p->memory_type].size += p->size;
5438}
5439
5440static void __init reserve_pmem_memory(void)
5441{
5442#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005443#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005444 reserve_memory_for(&android_pmem_adsp_pdata);
5445 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005446 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005447#endif
5448 reserve_memory_for(&android_pmem_audio_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005449 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
5450#endif
5451}
5452
Huaibin Yanga5419422011-12-08 23:52:10 -08005453static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005454
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455static void __init msm8x60_calculate_reserve_sizes(void)
5456{
5457 size_pmem_devices();
5458 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005459 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005460 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005461}
5462
5463static int msm8x60_paddr_to_memtype(unsigned int paddr)
5464{
5465 if (paddr >= 0x40000000 && paddr < 0x60000000)
5466 return MEMTYPE_EBI1;
5467 if (paddr >= 0x38000000 && paddr < 0x40000000)
5468 return MEMTYPE_SMI;
5469 return MEMTYPE_NONE;
5470}
5471
5472static struct reserve_info msm8x60_reserve_info __initdata = {
5473 .memtype_reserve_table = msm8x60_reserve_table,
5474 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5475 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5476};
5477
5478static void __init msm8x60_reserve(void)
5479{
5480 reserve_info = &msm8x60_reserve_info;
5481 msm_reserve();
5482}
5483
5484#define EXT_CHG_VALID_MPP 10
5485#define EXT_CHG_VALID_MPP_2 11
5486
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305487static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305488 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305489 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305490 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305491 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5492};
5493
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005494#ifdef CONFIG_ISL9519_CHARGER
5495static int isl_detection_setup(void)
5496{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305497 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005498
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305499 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5500 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5501 &isl_mpp[i].config);
5502 if (ret) {
5503 pr_err("%s: Config MPP %d of PM8058 failed\n",
5504 __func__, isl_mpp[i].mpp);
5505 return ret;
5506 }
5507 }
5508
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005509 return ret;
5510}
5511
5512static struct isl_platform_data isl_data __initdata = {
5513 .chgcurrent = 700,
5514 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5515 .chg_detection_config = isl_detection_setup,
5516 .max_system_voltage = 4200,
5517 .min_system_voltage = 3200,
5518 .term_current = 120,
5519 .input_current = 2048,
5520};
5521
5522static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5523 {
5524 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305525 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005526 .platform_data = &isl_data,
5527 },
5528};
5529#endif
5530
5531#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5532static int smb137b_detection_setup(void)
5533{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305534 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005535
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305536 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5537 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5538 &isl_mpp[i].config);
5539 if (ret) {
5540 pr_err("%s: Config MPP %d of PM8058 failed\n",
5541 __func__, isl_mpp[i].mpp);
5542 return ret;
5543 }
5544 }
5545
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005546 return ret;
5547}
5548
5549static struct smb137b_platform_data smb137b_data __initdata = {
5550 .chg_detection_config = smb137b_detection_setup,
5551 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5552 .batt_mah_rating = 950,
5553};
5554
5555static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5556 {
5557 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305558 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005559 .platform_data = &smb137b_data,
5560 },
5561};
5562#endif
5563
5564#ifdef CONFIG_PMIC8058
5565#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305566#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005567
5568static int pm8058_gpios_init(void)
5569{
5570 int i;
5571 int rc;
5572 struct pm8058_gpio_cfg {
5573 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305574 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005575 };
5576
5577 struct pm8058_gpio_cfg gpio_cfgs[] = {
5578 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305579 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005580 {
5581 .direction = PM_GPIO_DIR_IN,
5582 .pull = PM_GPIO_PULL_DN,
5583 .vin_sel = 2,
5584 .function = PM_GPIO_FUNC_NORMAL,
5585 .inv_int_pol = 0,
5586 },
5587 },
5588#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5589 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305590 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005591 {
5592 .direction = PM_GPIO_DIR_IN,
5593 .pull = PM_GPIO_PULL_UP_30,
5594 .vin_sel = 2,
5595 .function = PM_GPIO_FUNC_NORMAL,
5596 .inv_int_pol = 0,
5597 },
5598 },
5599#endif
5600 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305601 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602 {
5603 .direction = PM_GPIO_DIR_IN,
5604 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305605 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005606 .function = PM_GPIO_FUNC_NORMAL,
5607 .inv_int_pol = 0,
5608 },
5609 },
5610 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305611 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005612 {
5613 .direction = PM_GPIO_DIR_IN,
5614 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305615 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616 .function = PM_GPIO_FUNC_NORMAL,
5617 .inv_int_pol = 0,
5618 },
5619 },
5620 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305621 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005622 {
5623 .direction = PM_GPIO_DIR_IN,
5624 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305625 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005626 .function = PM_GPIO_FUNC_NORMAL,
5627 .inv_int_pol = 0,
5628 },
5629 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005630 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305631 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005632 {
5633 .direction = PM_GPIO_DIR_OUT,
5634 .output_value = 1,
5635 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5636 .pull = PM_GPIO_PULL_DN,
5637 .out_strength = PM_GPIO_STRENGTH_HIGH,
5638 .function = PM_GPIO_FUNC_NORMAL,
5639 .vin_sel = 2,
5640 .inv_int_pol = 0,
5641 }
5642 },
5643 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305644 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645 {
5646 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305647 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005648 .function = PM_GPIO_FUNC_NORMAL,
5649 .vin_sel = 2,
5650 .inv_int_pol = 0,
5651 }
5652 },
5653 };
5654
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305655#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5656 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305657 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305658 .direction = PM_GPIO_DIR_IN,
5659 .pull = PM_GPIO_PULL_UP_1P5,
5660 .vin_sel = 2,
5661 .function = PM_GPIO_FUNC_NORMAL,
5662 };
5663#endif
5664
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005665#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305666 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305667 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305668 .direction = PM_GPIO_DIR_OUT,
5669 .pull = PM_GPIO_PULL_NO,
5670 .out_strength = PM_GPIO_STRENGTH_HIGH,
5671 .function = PM_GPIO_FUNC_NORMAL,
5672 .inv_int_pol = 0,
5673 .vin_sel = 2,
5674 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5675 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005676 };
5677#endif
5678
5679#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5680 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305681 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005682 {
5683 .direction = PM_GPIO_DIR_IN,
5684 .pull = PM_GPIO_PULL_UP_1P5,
5685 .vin_sel = 2,
5686 .function = PM_GPIO_FUNC_NORMAL,
5687 .inv_int_pol = 0,
5688 }
5689 };
5690#endif
5691
5692#if defined(CONFIG_QS_S5K4E1)
5693 {
5694 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305695 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005696 {
5697 .direction = PM_GPIO_DIR_OUT,
5698 .output_value = 0,
5699 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5700 .pull = PM_GPIO_PULL_DN,
5701 .out_strength = PM_GPIO_STRENGTH_HIGH,
5702 .function = PM_GPIO_FUNC_NORMAL,
5703 .vin_sel = 2,
5704 .inv_int_pol = 0,
5705 }
5706 };
5707#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005708#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5709 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305710 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005711 {
5712 .direction = PM_GPIO_DIR_OUT,
5713 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5714 .output_value = 1,
5715 .pull = PM_GPIO_PULL_UP_30,
5716 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305717 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005718 .out_strength = PM_GPIO_STRENGTH_HIGH,
5719 .function = PM_GPIO_FUNC_NORMAL,
5720 .inv_int_pol = 0,
5721 }
5722 };
5723#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005724#if defined(CONFIG_HAPTIC_ISA1200) || \
5725 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5726 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305727 rc = pm8xxx_gpio_config(
5728 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5729 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005730 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305731 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005732 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305733 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305734 rc = pm8xxx_gpio_config(
5735 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5736 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305737 if (rc < 0) {
5738 pr_err("%s: pmic haptics ldo gpio config failed\n",
5739 __func__);
5740 }
5741
5742 }
5743#endif
5744
5745#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5746 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5747 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5748 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305749 rc = pm8xxx_gpio_config(
5750 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5751 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305752 if (rc < 0) {
5753 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5754 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005755 }
5756 }
5757#endif
5758
5759#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5760 /* Line_in only for 8660 ffa & surf */
5761 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005762 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005763 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305764 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005765 &line_in_gpio_cfg.cfg);
5766 if (rc < 0) {
5767 pr_err("%s pmic line_in gpio config failed\n",
5768 __func__);
5769 return rc;
5770 }
5771 }
5772#endif
5773
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005774#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5775 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305776 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005777 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5778 if (rc < 0) {
5779 pr_err("%s pmic gpio config failed\n", __func__);
5780 return rc;
5781 }
5782 }
5783#endif
5784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005785#if defined(CONFIG_QS_S5K4E1)
5786 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5787 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305788 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 &qs_hc37_cam_pd_gpio_cfg.cfg);
5790 if (rc < 0) {
5791 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5792 __func__);
5793 return rc;
5794 }
5795 }
5796 }
5797#endif
5798
5799 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305800 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005801 &gpio_cfgs[i].cfg);
5802 if (rc < 0) {
5803 pr_err("%s pmic gpio config failed\n",
5804 __func__);
5805 return rc;
5806 }
5807 }
5808
5809 return 0;
5810}
5811
5812static const unsigned int ffa_keymap[] = {
5813 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5814 KEY(0, 1, KEY_UP), /* NAV - UP */
5815 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5816 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5817
5818 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5819 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5820 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5821 KEY(1, 3, KEY_VOLUMEDOWN),
5822
5823 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5824
5825 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5826 KEY(4, 1, KEY_UP), /* USER_UP */
5827 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5828 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5829 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5830
5831 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5832 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5833 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5834 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5835 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5836};
5837
Zhang Chang Ken683be172011-08-10 17:45:34 -04005838static const unsigned int dragon_keymap[] = {
5839 KEY(0, 0, KEY_MENU),
5840 KEY(0, 2, KEY_1),
5841 KEY(0, 3, KEY_4),
5842 KEY(0, 4, KEY_7),
5843
5844 KEY(1, 0, KEY_UP),
5845 KEY(1, 1, KEY_LEFT),
5846 KEY(1, 2, KEY_DOWN),
5847 KEY(1, 3, KEY_5),
5848 KEY(1, 4, KEY_8),
5849
5850 KEY(2, 0, KEY_HOME),
5851 KEY(2, 1, KEY_REPLY),
5852 KEY(2, 2, KEY_2),
5853 KEY(2, 3, KEY_6),
5854 KEY(2, 4, KEY_0),
5855
5856 KEY(3, 0, KEY_VOLUMEUP),
5857 KEY(3, 1, KEY_RIGHT),
5858 KEY(3, 2, KEY_3),
5859 KEY(3, 3, KEY_9),
5860 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5861
5862 KEY(4, 0, KEY_VOLUMEDOWN),
5863 KEY(4, 1, KEY_BACK),
5864 KEY(4, 2, KEY_CAMERA),
5865 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5866};
5867
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005868static struct matrix_keymap_data ffa_keymap_data = {
5869 .keymap_size = ARRAY_SIZE(ffa_keymap),
5870 .keymap = ffa_keymap,
5871};
5872
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305873static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005874 .input_name = "ffa-keypad",
5875 .input_phys_device = "ffa-keypad/input0",
5876 .num_rows = 6,
5877 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305878 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5879 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5880 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005881 .scan_delay_ms = 32,
5882 .row_hold_ns = 91500,
5883 .wakeup = 1,
5884 .keymap_data = &ffa_keymap_data,
5885};
5886
Zhang Chang Ken683be172011-08-10 17:45:34 -04005887static struct matrix_keymap_data dragon_keymap_data = {
5888 .keymap_size = ARRAY_SIZE(dragon_keymap),
5889 .keymap = dragon_keymap,
5890};
5891
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305892static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005893 .input_name = "dragon-keypad",
5894 .input_phys_device = "dragon-keypad/input0",
5895 .num_rows = 6,
5896 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305897 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5898 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5899 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005900 .scan_delay_ms = 32,
5901 .row_hold_ns = 91500,
5902 .wakeup = 1,
5903 .keymap_data = &dragon_keymap_data,
5904};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305905
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005906static const unsigned int fluid_keymap[] = {
5907 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5908 KEY(0, 1, KEY_UP), /* NAV - UP */
5909 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5910 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5911
5912 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5913 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5914 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5915 KEY(1, 3, KEY_VOLUMEUP),
5916
5917 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5918
5919 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5920 KEY(4, 1, KEY_UP), /* USER_UP */
5921 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5922 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5923 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5924
Jilai Wang9a895102011-07-12 14:00:35 -04005925 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005926 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5927 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5928 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5929 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5930};
5931
5932static struct matrix_keymap_data fluid_keymap_data = {
5933 .keymap_size = ARRAY_SIZE(fluid_keymap),
5934 .keymap = fluid_keymap,
5935};
5936
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305937static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005938 .input_name = "fluid-keypad",
5939 .input_phys_device = "fluid-keypad/input0",
5940 .num_rows = 6,
5941 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305942 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5943 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5944 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005945 .scan_delay_ms = 32,
5946 .row_hold_ns = 91500,
5947 .wakeup = 1,
5948 .keymap_data = &fluid_keymap_data,
5949};
5950
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305951static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005952 .initial_vibrate_ms = 500,
5953 .level_mV = 3000,
5954 .max_timeout_ms = 15000,
5955};
5956
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305957static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
5958 .rtc_write_enable = false,
5959 .rtc_alarm_powerup = false,
5960};
5961
5962static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
5963 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08005964 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305965 .wakeup = 1,
5966};
5967
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005968#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5969
5970static struct othc_accessory_info othc_accessories[] = {
5971 {
5972 .accessory = OTHC_SVIDEO_OUT,
5973 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5974 | OTHC_ADC_DETECT,
5975 .key_code = SW_VIDEOOUT_INSERT,
5976 .enabled = false,
5977 .adc_thres = {
5978 .min_threshold = 20,
5979 .max_threshold = 40,
5980 },
5981 },
5982 {
5983 .accessory = OTHC_ANC_HEADPHONE,
5984 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5985 OTHC_SWITCH_DETECT,
5986 .gpio = PM8058_LINE_IN_DET_GPIO,
5987 .active_low = 1,
5988 .key_code = SW_HEADPHONE_INSERT,
5989 .enabled = true,
5990 },
5991 {
5992 .accessory = OTHC_ANC_HEADSET,
5993 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5994 .gpio = PM8058_LINE_IN_DET_GPIO,
5995 .active_low = 1,
5996 .key_code = SW_HEADPHONE_INSERT,
5997 .enabled = true,
5998 },
5999 {
6000 .accessory = OTHC_HEADPHONE,
6001 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6002 .key_code = SW_HEADPHONE_INSERT,
6003 .enabled = true,
6004 },
6005 {
6006 .accessory = OTHC_MICROPHONE,
6007 .detect_flags = OTHC_GPIO_DETECT,
6008 .gpio = PM8058_LINE_IN_DET_GPIO,
6009 .active_low = 1,
6010 .key_code = SW_MICROPHONE_INSERT,
6011 .enabled = true,
6012 },
6013 {
6014 .accessory = OTHC_HEADSET,
6015 .detect_flags = OTHC_MICBIAS_DETECT,
6016 .key_code = SW_HEADPHONE_INSERT,
6017 .enabled = true,
6018 },
6019};
6020
6021static struct othc_switch_info switch_info[] = {
6022 {
6023 .min_adc_threshold = 0,
6024 .max_adc_threshold = 100,
6025 .key_code = KEY_PLAYPAUSE,
6026 },
6027 {
6028 .min_adc_threshold = 100,
6029 .max_adc_threshold = 200,
6030 .key_code = KEY_REWIND,
6031 },
6032 {
6033 .min_adc_threshold = 200,
6034 .max_adc_threshold = 500,
6035 .key_code = KEY_FASTFORWARD,
6036 },
6037};
6038
6039static struct othc_n_switch_config switch_config = {
6040 .voltage_settling_time_ms = 0,
6041 .num_adc_samples = 3,
6042 .adc_channel = CHANNEL_ADC_HDSET,
6043 .switch_info = switch_info,
6044 .num_keys = ARRAY_SIZE(switch_info),
6045 .default_sw_en = true,
6046 .default_sw_idx = 0,
6047};
6048
6049static struct hsed_bias_config hsed_bias_config = {
6050 /* HSED mic bias config info */
6051 .othc_headset = OTHC_HEADSET_NO,
6052 .othc_lowcurr_thresh_uA = 100,
6053 .othc_highcurr_thresh_uA = 600,
6054 .othc_hyst_prediv_us = 7800,
6055 .othc_period_clkdiv_us = 62500,
6056 .othc_hyst_clk_us = 121000,
6057 .othc_period_clk_us = 312500,
6058 .othc_wakeup = 1,
6059};
6060
6061static struct othc_hsed_config hsed_config_1 = {
6062 .hsed_bias_config = &hsed_bias_config,
6063 /*
6064 * The detection delay and switch reporting delay are
6065 * required to encounter a hardware bug (spurious switch
6066 * interrupts on slow insertion/removal of the headset).
6067 * This will introduce a delay in reporting the accessory
6068 * insertion and removal to the userspace.
6069 */
6070 .detection_delay_ms = 1500,
6071 /* Switch info */
6072 .switch_debounce_ms = 1500,
6073 .othc_support_n_switch = false,
6074 .switch_config = &switch_config,
6075 .ir_gpio = -1,
6076 /* Accessory info */
6077 .accessories_support = true,
6078 .accessories = othc_accessories,
6079 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6080};
6081
6082static struct othc_regulator_config othc_reg = {
6083 .regulator = "8058_l5",
6084 .max_uV = 2850000,
6085 .min_uV = 2850000,
6086};
6087
6088/* MIC_BIAS0 is configured as normal MIC BIAS */
6089static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6090 .micbias_select = OTHC_MICBIAS_0,
6091 .micbias_capability = OTHC_MICBIAS,
6092 .micbias_enable = OTHC_SIGNAL_OFF,
6093 .micbias_regulator = &othc_reg,
6094};
6095
6096/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6097static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6098 .micbias_select = OTHC_MICBIAS_1,
6099 .micbias_capability = OTHC_MICBIAS_HSED,
6100 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6101 .micbias_regulator = &othc_reg,
6102 .hsed_config = &hsed_config_1,
6103 .hsed_name = "8660_handset",
6104};
6105
6106/* MIC_BIAS2 is configured as normal MIC BIAS */
6107static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6108 .micbias_select = OTHC_MICBIAS_2,
6109 .micbias_capability = OTHC_MICBIAS,
6110 .micbias_enable = OTHC_SIGNAL_OFF,
6111 .micbias_regulator = &othc_reg,
6112};
6113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006114
6115static void __init msm8x60_init_pm8058_othc(void)
6116{
6117 int i;
6118
6119 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6120 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6121 machine_is_msm8x60_fusn_ffa()) {
6122 /* 3-switch headset supported only by V2 FFA and FLUID */
6123 hsed_config_1.accessories_adc_support = true,
6124 /* ADC based accessory detection works only on V2 and FLUID */
6125 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6126 hsed_config_1.othc_support_n_switch = true;
6127 }
6128
6129 /* IR GPIO is absent on FLUID */
6130 if (machine_is_msm8x60_fluid())
6131 hsed_config_1.ir_gpio = -1;
6132
6133 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6134 if (machine_is_msm8x60_fluid()) {
6135 switch (othc_accessories[i].accessory) {
6136 case OTHC_ANC_HEADPHONE:
6137 case OTHC_ANC_HEADSET:
6138 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6139 break;
6140 case OTHC_MICROPHONE:
6141 othc_accessories[i].enabled = false;
6142 break;
6143 case OTHC_SVIDEO_OUT:
6144 othc_accessories[i].enabled = true;
6145 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6146 break;
6147 }
6148 }
6149 }
6150}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006151
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006152
6153static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6154{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306155 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006156 .direction = PM_GPIO_DIR_OUT,
6157 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6158 .output_value = 0,
6159 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306160 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006161 .out_strength = PM_GPIO_STRENGTH_HIGH,
6162 .function = PM_GPIO_FUNC_2,
6163 };
6164
6165 int rc = -EINVAL;
6166 int id, mode, max_mA;
6167
6168 id = mode = max_mA = 0;
6169 switch (ch) {
6170 case 0:
6171 case 1:
6172 case 2:
6173 if (on) {
6174 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306175 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6176 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006177 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306178 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006179 __func__, id, rc);
6180 }
6181 break;
6182
6183 case 6:
6184 id = PM_PWM_LED_FLASH;
6185 mode = PM_PWM_CONF_PWM1;
6186 max_mA = 300;
6187 break;
6188
6189 case 7:
6190 id = PM_PWM_LED_FLASH1;
6191 mode = PM_PWM_CONF_PWM1;
6192 max_mA = 300;
6193 break;
6194
6195 default:
6196 break;
6197 }
6198
6199 if (ch >= 6 && ch <= 7) {
6200 if (!on) {
6201 mode = PM_PWM_CONF_NONE;
6202 max_mA = 0;
6203 }
6204 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6205 if (rc)
6206 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6207 __func__, ch, rc);
6208 }
6209 return rc;
6210
6211}
6212
6213static struct pm8058_pwm_pdata pm8058_pwm_data = {
6214 .config = pm8058_pwm_config,
6215};
6216
6217#define PM8058_GPIO_INT 88
6218
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006219static struct pmic8058_led pmic8058_flash_leds[] = {
6220 [0] = {
6221 .name = "camera:flash0",
6222 .max_brightness = 15,
6223 .id = PMIC8058_ID_FLASH_LED_0,
6224 },
6225 [1] = {
6226 .name = "camera:flash1",
6227 .max_brightness = 15,
6228 .id = PMIC8058_ID_FLASH_LED_1,
6229 },
6230};
6231
6232static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6233 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6234 .leds = pmic8058_flash_leds,
6235};
6236
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006237static struct pmic8058_led pmic8058_dragon_leds[] = {
6238 [0] = {
6239 /* RED */
6240 .name = "led_drv0",
6241 .max_brightness = 15,
6242 .id = PMIC8058_ID_LED_0,
6243 },/* 300 mA flash led0 drv sink */
6244 [1] = {
6245 /* Yellow */
6246 .name = "led_drv1",
6247 .max_brightness = 15,
6248 .id = PMIC8058_ID_LED_1,
6249 },/* 300 mA flash led0 drv sink */
6250 [2] = {
6251 /* Green */
6252 .name = "led_drv2",
6253 .max_brightness = 15,
6254 .id = PMIC8058_ID_LED_2,
6255 },/* 300 mA flash led0 drv sink */
6256 [3] = {
6257 .name = "led_psensor",
6258 .max_brightness = 15,
6259 .id = PMIC8058_ID_LED_KB_LIGHT,
6260 },/* 300 mA flash led0 drv sink */
6261};
6262
6263static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6264 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6265 .leds = pmic8058_dragon_leds,
6266};
6267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6269 [0] = {
6270 .name = "led:drv0",
6271 .max_brightness = 15,
6272 .id = PMIC8058_ID_FLASH_LED_0,
6273 },/* 300 mA flash led0 drv sink */
6274 [1] = {
6275 .name = "led:drv1",
6276 .max_brightness = 15,
6277 .id = PMIC8058_ID_FLASH_LED_1,
6278 },/* 300 mA flash led1 sink */
6279 [2] = {
6280 .name = "led:drv2",
6281 .max_brightness = 20,
6282 .id = PMIC8058_ID_LED_0,
6283 },/* 40 mA led0 sink */
6284 [3] = {
6285 .name = "keypad:drv",
6286 .max_brightness = 15,
6287 .id = PMIC8058_ID_LED_KB_LIGHT,
6288 },/* 300 mA keypad drv sink */
6289};
6290
6291static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6292 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6293 .leds = pmic8058_fluid_flash_leds,
6294};
6295
Terence Hampson90508a92011-08-09 10:40:08 -04006296static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306297 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006298 .max_source_current = 1800,
6299 .charger_type = CHG_TYPE_AC,
6300};
6301
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306302static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6303 .charger_data_valid = false,
6304};
6305
6306static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6307 .priority = 0,
6308};
6309
6310static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6311 .irq_base = PM8058_IRQ_BASE,
6312 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6313 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6314};
6315
6316static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6317 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6318};
6319
6320static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6321 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006322};
6323
6324static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306325 .irq_pdata = &pm8058_irq_pdata,
6326 .gpio_pdata = &pm8058_gpio_pdata,
6327 .mpp_pdata = &pm8058_mpp_pdata,
6328 .rtc_pdata = &pm8058_rtc_pdata,
6329 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6330 .othc0_pdata = &othc_config_pdata_0,
6331 .othc1_pdata = &othc_config_pdata_1,
6332 .othc2_pdata = &othc_config_pdata_2,
6333 .pwm_pdata = &pm8058_pwm_data,
6334 .misc_pdata = &pm8058_misc_pdata,
6335#ifdef CONFIG_SENSORS_MSM_ADC
6336 .xoadc_pdata = &pm8058_xoadc_pdata,
6337#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006338};
6339
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306340#ifdef CONFIG_MSM_SSBI
6341static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6342 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6343 .slave = {
6344 .name = "pm8058-core",
6345 .platform_data = &pm8058_platform_data,
6346 },
6347};
6348#endif
6349#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006350
6351#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6352 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6353#define TDISC_I2C_SLAVE_ADDR 0x67
6354#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6355#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6356
6357static const char *vregs_tdisc_name[] = {
6358 "8058_l5",
6359 "8058_s3",
6360};
6361
6362static const int vregs_tdisc_val[] = {
6363 2850000,/* uV */
6364 1800000,
6365};
6366static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6367
6368static int tdisc_shinetsu_setup(void)
6369{
6370 int rc, i;
6371
6372 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6373 if (rc) {
6374 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6375 __func__);
6376 return rc;
6377 }
6378
6379 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6380 if (rc) {
6381 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6382 __func__);
6383 goto fail_gpio_oe;
6384 }
6385
6386 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6387 if (rc) {
6388 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6389 __func__);
6390 gpio_free(GPIO_JOYSTICK_EN);
6391 goto fail_gpio_oe;
6392 }
6393
6394 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6395 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6396 if (IS_ERR(vregs_tdisc[i])) {
6397 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6398 __func__, vregs_tdisc_name[i],
6399 PTR_ERR(vregs_tdisc[i]));
6400 rc = PTR_ERR(vregs_tdisc[i]);
6401 goto vreg_get_fail;
6402 }
6403
6404 rc = regulator_set_voltage(vregs_tdisc[i],
6405 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6406 if (rc) {
6407 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6408 __func__, rc);
6409 goto vreg_set_voltage_fail;
6410 }
6411 }
6412
6413 return rc;
6414vreg_set_voltage_fail:
6415 i++;
6416vreg_get_fail:
6417 while (i)
6418 regulator_put(vregs_tdisc[--i]);
6419fail_gpio_oe:
6420 gpio_free(PMIC_GPIO_TDISC);
6421 return rc;
6422}
6423
6424static void tdisc_shinetsu_release(void)
6425{
6426 int i;
6427
6428 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6429 regulator_put(vregs_tdisc[i]);
6430
6431 gpio_free(PMIC_GPIO_TDISC);
6432 gpio_free(GPIO_JOYSTICK_EN);
6433}
6434
6435static int tdisc_shinetsu_enable(void)
6436{
6437 int i, rc = -EINVAL;
6438
6439 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6440 rc = regulator_enable(vregs_tdisc[i]);
6441 if (rc < 0) {
6442 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6443 __func__, vregs_tdisc_name[i], rc);
6444 goto vreg_fail;
6445 }
6446 }
6447
6448 /* Enable the OE (output enable) gpio */
6449 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6450 /* voltage and gpio stabilization delay */
6451 msleep(50);
6452
6453 return 0;
6454vreg_fail:
6455 while (i)
6456 regulator_disable(vregs_tdisc[--i]);
6457 return rc;
6458}
6459
6460static int tdisc_shinetsu_disable(void)
6461{
6462 int i, rc;
6463
6464 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6465 rc = regulator_disable(vregs_tdisc[i]);
6466 if (rc < 0) {
6467 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6468 __func__, vregs_tdisc_name[i], rc);
6469 goto tdisc_reg_fail;
6470 }
6471 }
6472
6473 /* Disable the OE (output enable) gpio */
6474 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6475
6476 return 0;
6477
6478tdisc_reg_fail:
6479 while (i)
6480 regulator_enable(vregs_tdisc[--i]);
6481 return rc;
6482}
6483
6484static struct tdisc_abs_values tdisc_abs = {
6485 .x_max = 32,
6486 .y_max = 32,
6487 .x_min = -32,
6488 .y_min = -32,
6489 .pressure_max = 32,
6490 .pressure_min = 0,
6491};
6492
6493static struct tdisc_platform_data tdisc_data = {
6494 .tdisc_setup = tdisc_shinetsu_setup,
6495 .tdisc_release = tdisc_shinetsu_release,
6496 .tdisc_enable = tdisc_shinetsu_enable,
6497 .tdisc_disable = tdisc_shinetsu_disable,
6498 .tdisc_wakeup = 0,
6499 .tdisc_gpio = PMIC_GPIO_TDISC,
6500 .tdisc_report_keys = true,
6501 .tdisc_report_relative = true,
6502 .tdisc_report_absolute = false,
6503 .tdisc_report_wheel = false,
6504 .tdisc_reverse_x = false,
6505 .tdisc_reverse_y = true,
6506 .tdisc_abs = &tdisc_abs,
6507};
6508
6509static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6510 {
6511 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6512 .irq = TDISC_INT,
6513 .platform_data = &tdisc_data,
6514 },
6515};
6516#endif
6517
6518#define PM_GPIO_CDC_RST_N 20
6519#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6520
6521static struct regulator *vreg_timpani_1;
6522static struct regulator *vreg_timpani_2;
6523
6524static unsigned int msm_timpani_setup_power(void)
6525{
6526 int rc;
6527
6528 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6529 if (IS_ERR(vreg_timpani_1)) {
6530 pr_err("%s: Unable to get 8058_l0\n", __func__);
6531 return -ENODEV;
6532 }
6533
6534 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6535 if (IS_ERR(vreg_timpani_2)) {
6536 pr_err("%s: Unable to get 8058_s3\n", __func__);
6537 regulator_put(vreg_timpani_1);
6538 return -ENODEV;
6539 }
6540
6541 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6542 if (rc) {
6543 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6544 goto fail;
6545 }
6546
6547 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6548 if (rc) {
6549 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6550 goto fail;
6551 }
6552
6553 rc = regulator_enable(vreg_timpani_1);
6554 if (rc) {
6555 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6556 goto fail;
6557 }
6558
6559 /* The settings for LDO0 should be set such that
6560 * it doesn't require to reset the timpani. */
6561 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6562 if (rc < 0) {
6563 pr_err("Timpani regulator optimum mode setting failed\n");
6564 goto fail;
6565 }
6566
6567 rc = regulator_enable(vreg_timpani_2);
6568 if (rc) {
6569 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6570 regulator_disable(vreg_timpani_1);
6571 goto fail;
6572 }
6573
6574 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6575 if (rc) {
6576 pr_err("%s: GPIO Request %d failed\n", __func__,
6577 GPIO_CDC_RST_N);
6578 regulator_disable(vreg_timpani_1);
6579 regulator_disable(vreg_timpani_2);
6580 goto fail;
6581 } else {
6582 gpio_direction_output(GPIO_CDC_RST_N, 1);
6583 usleep_range(1000, 1050);
6584 gpio_direction_output(GPIO_CDC_RST_N, 0);
6585 usleep_range(1000, 1050);
6586 gpio_direction_output(GPIO_CDC_RST_N, 1);
6587 gpio_free(GPIO_CDC_RST_N);
6588 }
6589 return rc;
6590
6591fail:
6592 regulator_put(vreg_timpani_1);
6593 regulator_put(vreg_timpani_2);
6594 return rc;
6595}
6596
6597static void msm_timpani_shutdown_power(void)
6598{
6599 int rc;
6600
6601 rc = regulator_disable(vreg_timpani_1);
6602 if (rc)
6603 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6604
6605 regulator_put(vreg_timpani_1);
6606
6607 rc = regulator_disable(vreg_timpani_2);
6608 if (rc)
6609 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6610
6611 regulator_put(vreg_timpani_2);
6612}
6613
6614/* Power analog function of codec */
6615static struct regulator *vreg_timpani_cdc_apwr;
6616static int msm_timpani_codec_power(int vreg_on)
6617{
6618 int rc = 0;
6619
6620 if (!vreg_timpani_cdc_apwr) {
6621
6622 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6623
6624 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6625 pr_err("%s: vreg_get failed (%ld)\n",
6626 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6627 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6628 return rc;
6629 }
6630 }
6631
6632 if (vreg_on) {
6633
6634 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6635 2200000, 2200000);
6636 if (rc) {
6637 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6638 __func__);
6639 goto vreg_fail;
6640 }
6641
6642 rc = regulator_enable(vreg_timpani_cdc_apwr);
6643 if (rc) {
6644 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6645 goto vreg_fail;
6646 }
6647 } else {
6648 rc = regulator_disable(vreg_timpani_cdc_apwr);
6649 if (rc) {
6650 pr_err("%s: vreg_disable failed %d\n",
6651 __func__, rc);
6652 goto vreg_fail;
6653 }
6654 }
6655
6656 return 0;
6657
6658vreg_fail:
6659 regulator_put(vreg_timpani_cdc_apwr);
6660 vreg_timpani_cdc_apwr = NULL;
6661 return rc;
6662}
6663
6664static struct marimba_codec_platform_data timpani_codec_pdata = {
6665 .marimba_codec_power = msm_timpani_codec_power,
6666};
6667
6668#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6669#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6670
6671static struct marimba_platform_data timpani_pdata = {
6672 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6673 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6674 .marimba_setup = msm_timpani_setup_power,
6675 .marimba_shutdown = msm_timpani_shutdown_power,
6676 .codec = &timpani_codec_pdata,
6677 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6678};
6679
6680#define TIMPANI_I2C_SLAVE_ADDR 0xD
6681
6682static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6683 {
6684 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6685 .platform_data = &timpani_pdata,
6686 },
6687};
6688
Lei Zhou338cab82011-08-19 13:38:17 -04006689#ifdef CONFIG_SND_SOC_WM8903
6690static struct wm8903_platform_data wm8903_pdata = {
6691 .gpio_cfg[2] = 0x3A8,
6692};
6693
6694#define WM8903_I2C_SLAVE_ADDR 0x34
6695static struct i2c_board_info wm8903_codec_i2c_info[] = {
6696 {
6697 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6698 .platform_data = &wm8903_pdata,
6699 },
6700};
6701#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006702#ifdef CONFIG_PMIC8901
6703
6704#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006705/*
6706 * Consumer specific regulator names:
6707 * regulator name consumer dev_name
6708 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006709static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6710 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6711};
6712static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6713 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6714};
6715
6716#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306717 _always_on) \
6718 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006719 .init_data = { \
6720 .constraints = { \
6721 .valid_modes_mask = _modes, \
6722 .valid_ops_mask = _ops, \
6723 .min_uV = _min_uV, \
6724 .max_uV = _max_uV, \
6725 .input_uV = _min_uV, \
6726 .apply_uV = _apply_uV, \
6727 .always_on = _always_on, \
6728 }, \
6729 .consumer_supplies = vreg_consumers_8901_##_id, \
6730 .num_consumer_supplies = \
6731 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6732 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306733 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006734 }
6735
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006736#define PM8901_VREG_INIT_VS(_id) \
6737 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306738 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006739
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306740static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006741 PM8901_VREG_INIT_VS(USB_OTG),
6742 PM8901_VREG_INIT_VS(HDMI_MVS),
6743};
6744
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306745static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6746 .priority = 1,
6747};
6748
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306749static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6750 .irq_base = PM8901_IRQ_BASE,
6751 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6752 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6753};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006754
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306755static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6756 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006757};
6758
6759static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306760 .irq_pdata = &pm8901_irq_pdata,
6761 .mpp_pdata = &pm8901_mpp_pdata,
6762 .regulator_pdatas = pm8901_vreg_init,
6763 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306764 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006765};
6766
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306767static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6768 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6769 .slave = {
6770 .name = "pm8901-core",
6771 .platform_data = &pm8901_platform_data,
6772 },
6773};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006774#endif /* CONFIG_PMIC8901 */
6775
6776#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6777 || defined(CONFIG_GPIO_SX150X_MODULE))
6778
6779static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006780static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006781
6782struct bahama_config_register{
6783 u8 reg;
6784 u8 value;
6785 u8 mask;
6786};
6787
6788enum version{
6789 VER_1_0,
6790 VER_2_0,
6791 VER_UNSUPPORTED = 0xFF
6792};
6793
6794static u8 read_bahama_ver(void)
6795{
6796 int rc;
6797 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6798 u8 bahama_version;
6799
6800 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6801 if (rc < 0) {
6802 printk(KERN_ERR
6803 "%s: version read failed: %d\n",
6804 __func__, rc);
6805 return VER_UNSUPPORTED;
6806 } else {
6807 printk(KERN_INFO
6808 "%s: version read got: 0x%x\n",
6809 __func__, bahama_version);
6810 }
6811
6812 switch (bahama_version) {
6813 case 0x08: /* varient of bahama v1 */
6814 case 0x10:
6815 case 0x00:
6816 return VER_1_0;
6817 case 0x09: /* variant of bahama v2 */
6818 return VER_2_0;
6819 default:
6820 return VER_UNSUPPORTED;
6821 }
6822}
6823
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006824static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006825static unsigned int msm_bahama_setup_power(void)
6826{
6827 int rc = 0;
6828 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006829
6830 if (machine_is_msm8x60_dragon())
6831 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6832
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6834
6835 if (IS_ERR(vreg_bahama)) {
6836 rc = PTR_ERR(vreg_bahama);
6837 pr_err("%s: regulator_get %s = %d\n", __func__,
6838 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006839 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006840 }
6841
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006842 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6843 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006844 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6845 msm_bahama_regulator, rc);
6846 goto unget;
6847 }
6848
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006849 rc = regulator_enable(vreg_bahama);
6850 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006851 pr_err("%s: regulator_enable %s = %d\n", __func__,
6852 msm_bahama_regulator, rc);
6853 goto unget;
6854 }
6855
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006856 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6857 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006858 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006859 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006860 goto unenable;
6861 }
6862
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006863 gpio_direction_output(msm_bahama_sys_rst, 0);
6864 usleep_range(1000, 1050);
6865 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6866 usleep_range(1000, 1050);
6867 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006868 return rc;
6869
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006870unenable:
6871 regulator_disable(vreg_bahama);
6872unget:
6873 regulator_put(vreg_bahama);
6874 return rc;
6875};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006876
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006877static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006878{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006879 if (msm_bahama_setup_power_enable) {
6880 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6881 gpio_free(msm_bahama_sys_rst);
6882 regulator_disable(vreg_bahama);
6883 regulator_put(vreg_bahama);
6884 msm_bahama_setup_power_enable = 0;
6885 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006886
6887 return 0;
6888};
6889
6890static unsigned int msm_bahama_core_config(int type)
6891{
6892 int rc = 0;
6893
6894 if (type == BAHAMA_ID) {
6895
6896 int i;
6897 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6898
6899 const struct bahama_config_register v20_init[] = {
6900 /* reg, value, mask */
6901 { 0xF4, 0x84, 0xFF }, /* AREG */
6902 { 0xF0, 0x04, 0xFF } /* DREG */
6903 };
6904
6905 if (read_bahama_ver() == VER_2_0) {
6906 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6907 u8 value = v20_init[i].value;
6908 rc = marimba_write_bit_mask(&config,
6909 v20_init[i].reg,
6910 &value,
6911 sizeof(v20_init[i].value),
6912 v20_init[i].mask);
6913 if (rc < 0) {
6914 printk(KERN_ERR
6915 "%s: reg %d write failed: %d\n",
6916 __func__, v20_init[i].reg, rc);
6917 return rc;
6918 }
6919 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6920 " mask 0x%02x\n",
6921 __func__, v20_init[i].reg,
6922 v20_init[i].value, v20_init[i].mask);
6923 }
6924 }
6925 }
6926 printk(KERN_INFO "core type: %d\n", type);
6927
6928 return rc;
6929}
6930
6931static struct regulator *fm_regulator_s3;
6932static struct msm_xo_voter *fm_clock;
6933
6934static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6935{
6936 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306937 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006938 .direction = PM_GPIO_DIR_IN,
6939 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306940 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006941 .function = PM_GPIO_FUNC_NORMAL,
6942 .inv_int_pol = 0,
6943 };
6944
6945 if (!fm_regulator_s3) {
6946 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6947 if (IS_ERR(fm_regulator_s3)) {
6948 rc = PTR_ERR(fm_regulator_s3);
6949 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6950 __func__, rc);
6951 goto out;
6952 }
6953 }
6954
6955
6956 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6957 if (rc < 0) {
6958 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6959 __func__, rc);
6960 goto fm_fail_put;
6961 }
6962
6963 rc = regulator_enable(fm_regulator_s3);
6964 if (rc < 0) {
6965 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6966 __func__, rc);
6967 goto fm_fail_put;
6968 }
6969
6970 /*Vote for XO clock*/
6971 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6972
6973 if (IS_ERR(fm_clock)) {
6974 rc = PTR_ERR(fm_clock);
6975 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6976 __func__, rc);
6977 goto fm_fail_switch;
6978 }
6979
6980 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6981 if (rc < 0) {
6982 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6983 __func__, rc);
6984 goto fm_fail_vote;
6985 }
6986
6987 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306988 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006989 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306990 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006991 __func__, rc);
6992 goto fm_fail_clock;
6993 }
6994 goto out;
6995
6996fm_fail_clock:
6997 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6998fm_fail_vote:
6999 msm_xo_put(fm_clock);
7000fm_fail_switch:
7001 regulator_disable(fm_regulator_s3);
7002fm_fail_put:
7003 regulator_put(fm_regulator_s3);
7004out:
7005 return rc;
7006};
7007
7008static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7009{
7010 int rc = 0;
7011 if (fm_regulator_s3 != NULL) {
7012 rc = regulator_disable(fm_regulator_s3);
7013 if (rc < 0) {
7014 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7015 __func__, rc);
7016 }
7017 regulator_put(fm_regulator_s3);
7018 fm_regulator_s3 = NULL;
7019 }
7020 printk(KERN_ERR "%s: Voting off for XO", __func__);
7021
7022 if (fm_clock != NULL) {
7023 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7024 if (rc < 0) {
7025 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7026 __func__, rc);
7027 }
7028 msm_xo_put(fm_clock);
7029 }
7030 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7031}
7032
7033/* Slave id address for FM/CDC/QMEMBIST
7034 * Values can be programmed using Marimba slave id 0
7035 * should there be a conflict with other I2C devices
7036 * */
7037#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7038#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7039
7040static struct marimba_fm_platform_data marimba_fm_pdata = {
7041 .fm_setup = fm_radio_setup,
7042 .fm_shutdown = fm_radio_shutdown,
7043 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7044 .is_fm_soc_i2s_master = false,
7045 .config_i2s_gpio = NULL,
7046};
7047
7048/*
7049Just initializing the BAHAMA related slave
7050*/
7051static struct marimba_platform_data marimba_pdata = {
7052 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7053 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7054 .bahama_setup = msm_bahama_setup_power,
7055 .bahama_shutdown = msm_bahama_shutdown_power,
7056 .bahama_core_config = msm_bahama_core_config,
7057 .fm = &marimba_fm_pdata,
7058 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7059};
7060
7061
7062static struct i2c_board_info msm_marimba_board_info[] = {
7063 {
7064 I2C_BOARD_INFO("marimba", 0xc),
7065 .platform_data = &marimba_pdata,
7066 }
7067};
7068#endif /* CONFIG_MAIMBA_CORE */
7069
7070#ifdef CONFIG_I2C
7071#define I2C_SURF 1
7072#define I2C_FFA (1 << 1)
7073#define I2C_RUMI (1 << 2)
7074#define I2C_SIM (1 << 3)
7075#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007076#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007077
7078struct i2c_registry {
7079 u8 machs;
7080 int bus;
7081 struct i2c_board_info *info;
7082 int len;
7083};
7084
7085static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007086#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7087 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007088 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007089 MSM_GSBI8_QUP_I2C_BUS_ID,
7090 core_expander_i2c_info,
7091 ARRAY_SIZE(core_expander_i2c_info),
7092 },
7093 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007094 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007095 MSM_GSBI8_QUP_I2C_BUS_ID,
7096 docking_expander_i2c_info,
7097 ARRAY_SIZE(docking_expander_i2c_info),
7098 },
7099 {
7100 I2C_SURF,
7101 MSM_GSBI8_QUP_I2C_BUS_ID,
7102 surf_expanders_i2c_info,
7103 ARRAY_SIZE(surf_expanders_i2c_info),
7104 },
7105 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007106 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007107 MSM_GSBI3_QUP_I2C_BUS_ID,
7108 fha_expanders_i2c_info,
7109 ARRAY_SIZE(fha_expanders_i2c_info),
7110 },
7111 {
7112 I2C_FLUID,
7113 MSM_GSBI3_QUP_I2C_BUS_ID,
7114 fluid_expanders_i2c_info,
7115 ARRAY_SIZE(fluid_expanders_i2c_info),
7116 },
7117 {
7118 I2C_FLUID,
7119 MSM_GSBI8_QUP_I2C_BUS_ID,
7120 fluid_core_expander_i2c_info,
7121 ARRAY_SIZE(fluid_core_expander_i2c_info),
7122 },
7123#endif
7124#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7125 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7126 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007127 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007128 MSM_GSBI3_QUP_I2C_BUS_ID,
7129 msm_i2c_gsbi3_tdisc_info,
7130 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7131 },
7132#endif
7133 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007134 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007135 MSM_GSBI3_QUP_I2C_BUS_ID,
7136 cy8ctmg200_board_info,
7137 ARRAY_SIZE(cy8ctmg200_board_info),
7138 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007139 {
7140 I2C_DRAGON,
7141 MSM_GSBI3_QUP_I2C_BUS_ID,
7142 cy8ctma340_dragon_board_info,
7143 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7144 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007145#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7146 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7147 {
7148 I2C_FLUID,
7149 MSM_GSBI3_QUP_I2C_BUS_ID,
7150 cyttsp_fluid_info,
7151 ARRAY_SIZE(cyttsp_fluid_info),
7152 },
7153 {
7154 I2C_FFA | I2C_SURF,
7155 MSM_GSBI3_QUP_I2C_BUS_ID,
7156 cyttsp_ffa_info,
7157 ARRAY_SIZE(cyttsp_ffa_info),
7158 },
7159#endif
7160#ifdef CONFIG_MSM_CAMERA
Jilai Wang971f97f2011-07-13 14:25:25 -04007161 {
7162 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007163 MSM_GSBI4_QUP_I2C_BUS_ID,
7164 msm_camera_boardinfo,
7165 ARRAY_SIZE(msm_camera_boardinfo),
7166 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007167 {
7168 I2C_DRAGON,
7169 MSM_GSBI4_QUP_I2C_BUS_ID,
7170 msm_camera_dragon_boardinfo,
7171 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7172 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007173#endif
7174 {
7175 I2C_SURF | I2C_FFA | I2C_FLUID,
7176 MSM_GSBI7_QUP_I2C_BUS_ID,
7177 msm_i2c_gsbi7_timpani_info,
7178 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7179 },
7180#if defined(CONFIG_MARIMBA_CORE)
7181 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007182 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007183 MSM_GSBI7_QUP_I2C_BUS_ID,
7184 msm_marimba_board_info,
7185 ARRAY_SIZE(msm_marimba_board_info),
7186 },
7187#endif /* CONFIG_MARIMBA_CORE */
7188#ifdef CONFIG_ISL9519_CHARGER
7189 {
7190 I2C_SURF | I2C_FFA,
7191 MSM_GSBI8_QUP_I2C_BUS_ID,
7192 isl_charger_i2c_info,
7193 ARRAY_SIZE(isl_charger_i2c_info),
7194 },
7195#endif
7196#if defined(CONFIG_HAPTIC_ISA1200) || \
7197 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7198 {
7199 I2C_FLUID,
7200 MSM_GSBI8_QUP_I2C_BUS_ID,
7201 msm_isa1200_board_info,
7202 ARRAY_SIZE(msm_isa1200_board_info),
7203 },
7204#endif
7205#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7206 {
7207 I2C_FLUID,
7208 MSM_GSBI8_QUP_I2C_BUS_ID,
7209 smb137b_charger_i2c_info,
7210 ARRAY_SIZE(smb137b_charger_i2c_info),
7211 },
7212#endif
7213#if defined(CONFIG_BATTERY_BQ27520) || \
7214 defined(CONFIG_BATTERY_BQ27520_MODULE)
7215 {
7216 I2C_FLUID,
7217 MSM_GSBI8_QUP_I2C_BUS_ID,
7218 msm_bq27520_board_info,
7219 ARRAY_SIZE(msm_bq27520_board_info),
7220 },
7221#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007222#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7223 {
7224 I2C_DRAGON,
7225 MSM_GSBI8_QUP_I2C_BUS_ID,
7226 wm8903_codec_i2c_info,
7227 ARRAY_SIZE(wm8903_codec_i2c_info),
7228 },
7229#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007230};
7231#endif /* CONFIG_I2C */
7232
7233static void fixup_i2c_configs(void)
7234{
7235#ifdef CONFIG_I2C
7236#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7237 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7238 sx150x_data[SX150X_CORE].irq_summary =
7239 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007240 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7241 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007242 sx150x_data[SX150X_CORE].irq_summary =
7243 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7244 else if (machine_is_msm8x60_fluid())
7245 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7246 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7247#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007248#endif
7249}
7250
7251static void register_i2c_devices(void)
7252{
7253#ifdef CONFIG_I2C
7254 u8 mach_mask = 0;
7255 int i;
7256
7257 /* Build the matching 'supported_machs' bitmask */
7258 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7259 mach_mask = I2C_SURF;
7260 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7261 mach_mask = I2C_FFA;
7262 else if (machine_is_msm8x60_rumi3())
7263 mach_mask = I2C_RUMI;
7264 else if (machine_is_msm8x60_sim())
7265 mach_mask = I2C_SIM;
7266 else if (machine_is_msm8x60_fluid())
7267 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007268 else if (machine_is_msm8x60_dragon())
7269 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007270 else
7271 pr_err("unmatched machine ID in register_i2c_devices\n");
7272
7273 /* Run the array and install devices as appropriate */
7274 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7275 if (msm8x60_i2c_devices[i].machs & mach_mask)
7276 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7277 msm8x60_i2c_devices[i].info,
7278 msm8x60_i2c_devices[i].len);
7279 }
7280#endif
7281}
7282
7283static void __init msm8x60_init_uart12dm(void)
7284{
7285#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7286 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7287 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7288
7289 if (!fpga_mem)
7290 pr_err("%s(): Error getting memory\n", __func__);
7291
7292 /* Advanced mode */
7293 writew(0xFFFF, fpga_mem + 0x15C);
7294 /* FPGA_UART_SEL */
7295 writew(0, fpga_mem + 0x172);
7296 /* FPGA_GPIO_CONFIG_117 */
7297 writew(1, fpga_mem + 0xEA);
7298 /* FPGA_GPIO_CONFIG_118 */
7299 writew(1, fpga_mem + 0xEC);
7300 mb();
7301 iounmap(fpga_mem);
7302#endif
7303}
7304
7305#define MSM_GSBI9_PHYS 0x19900000
7306#define GSBI_DUAL_MODE_CODE 0x60
7307
7308static void __init msm8x60_init_buses(void)
7309{
7310#ifdef CONFIG_I2C_QUP
7311 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7312 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7313 writel_relaxed(0x6 << 4, gsbi_mem);
7314 /* Ensure protocol code is written before proceeding further */
7315 mb();
7316 iounmap(gsbi_mem);
7317
7318 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7319 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7320 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7321 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7322
7323#ifdef CONFIG_MSM_GSBI9_UART
7324 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7325 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7326 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7327 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7328 iounmap(gsbi_mem);
7329 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7330 }
7331#endif
7332 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7333 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7334#endif
7335#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7336 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7337#endif
7338#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007339 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7340#endif
7341
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307342#ifdef CONFIG_MSM_SSBI
7343 msm_device_ssbi_pmic1.dev.platform_data =
7344 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307345 msm_device_ssbi_pmic2.dev.platform_data =
7346 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307347#endif
7348
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007349 if (machine_is_msm8x60_fluid()) {
7350#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7351 (defined(CONFIG_SMB137B_CHARGER) || \
7352 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7353 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7354#endif
7355#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7356 msm_gsbi10_qup_spi_device.dev.platform_data =
7357 &msm_gsbi10_qup_spi_pdata;
7358#endif
7359 }
7360
7361#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7362 /*
7363 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7364 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7365 * and ID notifications are available only on V2 surf and FFA
7366 * with a hardware workaround.
7367 */
7368 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7369 (machine_is_msm8x60_surf() ||
7370 (machine_is_msm8x60_ffa() &&
7371 pmic_id_notif_supported)))
7372 msm_otg_pdata.phy_can_powercollapse = 1;
7373 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7374#endif
7375
7376#ifdef CONFIG_USB_GADGET_MSM_72K
7377 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7378#endif
7379
7380#ifdef CONFIG_SERIAL_MSM_HS
7381 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7382 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7383#endif
7384#ifdef CONFIG_MSM_GSBI9_UART
7385 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7386 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7387 if (IS_ERR(msm_device_uart_gsbi9))
7388 pr_err("%s(): Failed to create uart gsbi9 device\n",
7389 __func__);
7390 }
7391#endif
7392
7393#ifdef CONFIG_MSM_BUS_SCALING
7394
7395 /* RPM calls are only enabled on V2 */
7396 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7397 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7398 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7399 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7400 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7401 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7402 }
7403
7404 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7405 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7406 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7407 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7408 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7409#endif
7410}
7411
7412static void __init msm8x60_map_io(void)
7413{
7414 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7415 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007416
7417 if (socinfo_init() < 0)
7418 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007419}
7420
7421/*
7422 * Most segments of the EBI2 bus are disabled by default.
7423 */
7424static void __init msm8x60_init_ebi2(void)
7425{
7426 uint32_t ebi2_cfg;
7427 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007428 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7429
7430 if (IS_ERR(mem_clk)) {
7431 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7432 "msm_ebi2", "mem_clk");
7433 return;
7434 }
7435 clk_enable(mem_clk);
7436 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007437
7438 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7439 if (ebi2_cfg_ptr != 0) {
7440 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7441
7442 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007443 machine_is_msm8x60_fluid() ||
7444 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007445 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7446 else if (machine_is_msm8x60_sim())
7447 ebi2_cfg |= (1 << 4); /* CS2 */
7448 else if (machine_is_msm8x60_rumi3())
7449 ebi2_cfg |= (1 << 5); /* CS3 */
7450
7451 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7452 iounmap(ebi2_cfg_ptr);
7453 }
7454
7455 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007456 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007457 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7458 if (ebi2_cfg_ptr != 0) {
7459 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7460 writel_relaxed(0UL, ebi2_cfg_ptr);
7461
7462 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7463 * LAN9221 Ethernet controller reads and writes.
7464 * The lowest 4 bits are the read delay, the next
7465 * 4 are the write delay. */
7466 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7467#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7468 /*
7469 * RECOVERY=5, HOLD_WR=1
7470 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7471 * WAIT_WR=1, WAIT_RD=2
7472 */
7473 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7474 /*
7475 * HOLD_RD=1
7476 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7477 */
7478 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7479#else
7480 /* EBI2 CS3 muxed address/data,
7481 * two cyc addr enable */
7482 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7483
7484#endif
7485 iounmap(ebi2_cfg_ptr);
7486 }
7487 }
7488}
7489
7490static void __init msm8x60_configure_smc91x(void)
7491{
7492 if (machine_is_msm8x60_sim()) {
7493
7494 smc91x_resources[0].start = 0x1b800300;
7495 smc91x_resources[0].end = 0x1b8003ff;
7496
7497 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7498 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7499
7500 } else if (machine_is_msm8x60_rumi3()) {
7501
7502 smc91x_resources[0].start = 0x1d000300;
7503 smc91x_resources[0].end = 0x1d0003ff;
7504
7505 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7506 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7507 }
7508}
7509
7510static void __init msm8x60_init_tlmm(void)
7511{
7512 if (machine_is_msm8x60_rumi3())
7513 msm_gpio_install_direct_irq(0, 0, 1);
7514}
7515
7516#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7517 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7518 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7519 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7520 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7521
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007522/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007523#define MAX_SDCC_CONTROLLER 5
7524
7525struct msm_sdcc_gpio {
7526 /* maximum 10 GPIOs per SDCC controller */
7527 s16 no;
7528 /* name of this GPIO */
7529 const char *name;
7530 bool always_on;
7531 bool is_enabled;
7532};
7533
7534#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7535static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7536 {159, "sdc1_dat_0"},
7537 {160, "sdc1_dat_1"},
7538 {161, "sdc1_dat_2"},
7539 {162, "sdc1_dat_3"},
7540#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7541 {163, "sdc1_dat_4"},
7542 {164, "sdc1_dat_5"},
7543 {165, "sdc1_dat_6"},
7544 {166, "sdc1_dat_7"},
7545#endif
7546 {167, "sdc1_clk"},
7547 {168, "sdc1_cmd"}
7548};
7549#endif
7550
7551#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7552static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7553 {143, "sdc2_dat_0"},
7554 {144, "sdc2_dat_1", 1},
7555 {145, "sdc2_dat_2"},
7556 {146, "sdc2_dat_3"},
7557#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7558 {147, "sdc2_dat_4"},
7559 {148, "sdc2_dat_5"},
7560 {149, "sdc2_dat_6"},
7561 {150, "sdc2_dat_7"},
7562#endif
7563 {151, "sdc2_cmd"},
7564 {152, "sdc2_clk", 1}
7565};
7566#endif
7567
7568#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7569static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7570 {95, "sdc5_cmd"},
7571 {96, "sdc5_dat_3"},
7572 {97, "sdc5_clk", 1},
7573 {98, "sdc5_dat_2"},
7574 {99, "sdc5_dat_1", 1},
7575 {100, "sdc5_dat_0"}
7576};
7577#endif
7578
7579struct msm_sdcc_pad_pull_cfg {
7580 enum msm_tlmm_pull_tgt pull;
7581 u32 pull_val;
7582};
7583
7584struct msm_sdcc_pad_drv_cfg {
7585 enum msm_tlmm_hdrive_tgt drv;
7586 u32 drv_val;
7587};
7588
7589#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7590static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7591 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7592 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7593 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7594};
7595
7596static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7597 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7598 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7599};
7600
7601static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7602 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7603 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7604 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7605};
7606
7607static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7608 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7609 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7610};
7611#endif
7612
7613#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7614static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7615 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7616 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7617 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7618};
7619
7620static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7621 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7622 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7623};
7624
7625static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7626 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7627 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7628 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7629};
7630
7631static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7632 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7633 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7634};
7635#endif
7636
7637struct msm_sdcc_pin_cfg {
7638 /*
7639 * = 1 if controller pins are using gpios
7640 * = 0 if controller has dedicated MSM pins
7641 */
7642 u8 is_gpio;
7643 u8 cfg_sts;
7644 u8 gpio_data_size;
7645 struct msm_sdcc_gpio *gpio_data;
7646 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7647 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7648 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7649 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7650 u8 pad_drv_data_size;
7651 u8 pad_pull_data_size;
7652 u8 sdio_lpm_gpio_cfg;
7653};
7654
7655
7656static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7657#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7658 [0] = {
7659 .is_gpio = 1,
7660 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7661 .gpio_data = sdc1_gpio_cfg
7662 },
7663#endif
7664#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7665 [1] = {
7666 .is_gpio = 1,
7667 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7668 .gpio_data = sdc2_gpio_cfg
7669 },
7670#endif
7671#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7672 [2] = {
7673 .is_gpio = 0,
7674 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7675 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7676 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7677 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7678 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7679 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7680 },
7681#endif
7682#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7683 [3] = {
7684 .is_gpio = 0,
7685 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7686 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7687 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7688 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7689 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7690 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7691 },
7692#endif
7693#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7694 [4] = {
7695 .is_gpio = 1,
7696 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7697 .gpio_data = sdc5_gpio_cfg
7698 }
7699#endif
7700};
7701
7702static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7703{
7704 int rc = 0;
7705 struct msm_sdcc_pin_cfg *curr;
7706 int n;
7707
7708 curr = &sdcc_pin_cfg_data[dev_id - 1];
7709 if (!curr->gpio_data)
7710 goto out;
7711
7712 for (n = 0; n < curr->gpio_data_size; n++) {
7713 if (enable) {
7714
7715 if (curr->gpio_data[n].always_on &&
7716 curr->gpio_data[n].is_enabled)
7717 continue;
7718 pr_debug("%s: enable: %s\n", __func__,
7719 curr->gpio_data[n].name);
7720 rc = gpio_request(curr->gpio_data[n].no,
7721 curr->gpio_data[n].name);
7722 if (rc) {
7723 pr_err("%s: gpio_request(%d, %s)"
7724 "failed", __func__,
7725 curr->gpio_data[n].no,
7726 curr->gpio_data[n].name);
7727 goto free_gpios;
7728 }
7729 /* set direction as output for all GPIOs */
7730 rc = gpio_direction_output(
7731 curr->gpio_data[n].no, 1);
7732 if (rc) {
7733 pr_err("%s: gpio_direction_output"
7734 "(%d, 1) failed\n", __func__,
7735 curr->gpio_data[n].no);
7736 goto free_gpios;
7737 }
7738 curr->gpio_data[n].is_enabled = 1;
7739 } else {
7740 /*
7741 * now free this GPIO which will put GPIO
7742 * in low power mode and will also put GPIO
7743 * in input mode
7744 */
7745 if (curr->gpio_data[n].always_on)
7746 continue;
7747 pr_debug("%s: disable: %s\n", __func__,
7748 curr->gpio_data[n].name);
7749 gpio_free(curr->gpio_data[n].no);
7750 curr->gpio_data[n].is_enabled = 0;
7751 }
7752 }
7753 curr->cfg_sts = enable;
7754 goto out;
7755
7756free_gpios:
7757 for (; n >= 0; n--)
7758 gpio_free(curr->gpio_data[n].no);
7759out:
7760 return rc;
7761}
7762
7763static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7764{
7765 int rc = 0;
7766 struct msm_sdcc_pin_cfg *curr;
7767 int n;
7768
7769 curr = &sdcc_pin_cfg_data[dev_id - 1];
7770 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7771 goto out;
7772
7773 if (enable) {
7774 /*
7775 * set up the normal driver strength and
7776 * pull config for pads
7777 */
7778 for (n = 0; n < curr->pad_drv_data_size; n++) {
7779 if (curr->sdio_lpm_gpio_cfg) {
7780 if (curr->pad_drv_on_data[n].drv ==
7781 TLMM_HDRV_SDC4_DATA)
7782 continue;
7783 }
7784 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7785 curr->pad_drv_on_data[n].drv_val);
7786 }
7787 for (n = 0; n < curr->pad_pull_data_size; n++) {
7788 if (curr->sdio_lpm_gpio_cfg) {
7789 if (curr->pad_pull_on_data[n].pull ==
7790 TLMM_PULL_SDC4_DATA)
7791 continue;
7792 }
7793 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7794 curr->pad_pull_on_data[n].pull_val);
7795 }
7796 } else {
7797 /* set the low power config for pads */
7798 for (n = 0; n < curr->pad_drv_data_size; n++) {
7799 if (curr->sdio_lpm_gpio_cfg) {
7800 if (curr->pad_drv_off_data[n].drv ==
7801 TLMM_HDRV_SDC4_DATA)
7802 continue;
7803 }
7804 msm_tlmm_set_hdrive(
7805 curr->pad_drv_off_data[n].drv,
7806 curr->pad_drv_off_data[n].drv_val);
7807 }
7808 for (n = 0; n < curr->pad_pull_data_size; n++) {
7809 if (curr->sdio_lpm_gpio_cfg) {
7810 if (curr->pad_pull_off_data[n].pull ==
7811 TLMM_PULL_SDC4_DATA)
7812 continue;
7813 }
7814 msm_tlmm_set_pull(
7815 curr->pad_pull_off_data[n].pull,
7816 curr->pad_pull_off_data[n].pull_val);
7817 }
7818 }
7819 curr->cfg_sts = enable;
7820out:
7821 return rc;
7822}
7823
7824struct sdcc_reg {
7825 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7826 const char *reg_name;
7827 /*
7828 * is set voltage supported for this regulator?
7829 * 0 = not supported, 1 = supported
7830 */
7831 unsigned char set_voltage_sup;
7832 /* voltage level to be set */
7833 unsigned int level;
7834 /* VDD/VCC/VCCQ voltage regulator handle */
7835 struct regulator *reg;
7836 /* is this regulator enabled? */
7837 bool enabled;
7838 /* is this regulator needs to be always on? */
7839 bool always_on;
7840 /* is operating power mode setting required for this regulator? */
7841 bool op_pwr_mode_sup;
7842 /* Load values for low power and high power mode */
7843 unsigned int lpm_uA;
7844 unsigned int hpm_uA;
7845};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007846/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007847static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7848/* only SDCC1 requires VCCQ voltage */
7849static struct sdcc_reg sdcc_vccq_reg_data[1];
7850/* all SDCC controllers may require voting for VDD PAD voltage */
7851static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7852
7853struct sdcc_reg_data {
7854 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7855 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7856 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7857 unsigned char sts; /* regulator enable/disable status */
7858};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007859/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007860static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7861
7862static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7863{
7864 int rc = 0;
7865
7866 /* Get the regulator handle */
7867 vreg->reg = regulator_get(NULL, vreg->reg_name);
7868 if (IS_ERR(vreg->reg)) {
7869 rc = PTR_ERR(vreg->reg);
7870 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7871 __func__, vreg->reg_name, rc);
7872 goto out;
7873 }
7874
7875 /* Set the voltage level if required */
7876 if (vreg->set_voltage_sup) {
7877 rc = regulator_set_voltage(vreg->reg, vreg->level,
7878 vreg->level);
7879 if (rc) {
7880 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7881 __func__, vreg->reg_name, rc);
7882 goto vreg_put;
7883 }
7884 }
7885 goto out;
7886
7887vreg_put:
7888 regulator_put(vreg->reg);
7889out:
7890 return rc;
7891}
7892
7893static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7894{
7895 regulator_put(vreg->reg);
7896}
7897
7898/* this init function should be called only once for each SDCC */
7899static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7900{
7901 int rc = 0;
7902 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7903 struct sdcc_reg_data *curr;
7904
7905 curr = &sdcc_vreg_data[dev_id - 1];
7906 curr_vdd_reg = curr->vdd_data;
7907 curr_vccq_reg = curr->vccq_data;
7908 curr_vddp_reg = curr->vddp_data;
7909
7910 if (init) {
7911 /*
7912 * get the regulator handle from voltage regulator framework
7913 * and then try to set the voltage level for the regulator
7914 */
7915 if (curr_vdd_reg) {
7916 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7917 if (rc)
7918 goto out;
7919 }
7920 if (curr_vccq_reg) {
7921 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7922 if (rc)
7923 goto vdd_reg_deinit;
7924 }
7925 if (curr_vddp_reg) {
7926 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7927 if (rc)
7928 goto vccq_reg_deinit;
7929 }
7930 goto out;
7931 } else
7932 /* deregister with all regulators from regulator framework */
7933 goto vddp_reg_deinit;
7934
7935vddp_reg_deinit:
7936 if (curr_vddp_reg)
7937 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7938vccq_reg_deinit:
7939 if (curr_vccq_reg)
7940 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7941vdd_reg_deinit:
7942 if (curr_vdd_reg)
7943 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7944out:
7945 return rc;
7946}
7947
7948static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7949{
7950 int rc;
7951
7952 if (!vreg->enabled) {
7953 rc = regulator_enable(vreg->reg);
7954 if (rc) {
7955 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7956 __func__, vreg->reg_name, rc);
7957 goto out;
7958 }
7959 vreg->enabled = 1;
7960 }
7961
7962 /* Put always_on regulator in HPM (high power mode) */
7963 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7964 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7965 if (rc < 0) {
7966 pr_err("%s: reg=%s: HPM setting failed"
7967 " hpm_uA=%d, rc=%d\n",
7968 __func__, vreg->reg_name,
7969 vreg->hpm_uA, rc);
7970 goto vreg_disable;
7971 }
7972 rc = 0;
7973 }
7974 goto out;
7975
7976vreg_disable:
7977 regulator_disable(vreg->reg);
7978 vreg->enabled = 0;
7979out:
7980 return rc;
7981}
7982
7983static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7984{
7985 int rc;
7986
7987 /* Never disable always_on regulator */
7988 if (!vreg->always_on) {
7989 rc = regulator_disable(vreg->reg);
7990 if (rc) {
7991 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7992 __func__, vreg->reg_name, rc);
7993 goto out;
7994 }
7995 vreg->enabled = 0;
7996 }
7997
7998 /* Put always_on regulator in LPM (low power mode) */
7999 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8000 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8001 if (rc < 0) {
8002 pr_err("%s: reg=%s: LPM setting failed"
8003 " lpm_uA=%d, rc=%d\n",
8004 __func__,
8005 vreg->reg_name,
8006 vreg->lpm_uA, rc);
8007 goto out;
8008 }
8009 rc = 0;
8010 }
8011
8012out:
8013 return rc;
8014}
8015
8016static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8017{
8018 int rc = 0;
8019 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8020 struct sdcc_reg_data *curr;
8021
8022 curr = &sdcc_vreg_data[dev_id - 1];
8023 curr_vdd_reg = curr->vdd_data;
8024 curr_vccq_reg = curr->vccq_data;
8025 curr_vddp_reg = curr->vddp_data;
8026
8027 /* check if regulators are initialized or not? */
8028 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8029 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8030 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8031 /* initialize voltage regulators required for this SDCC */
8032 rc = msm_sdcc_vreg_init(dev_id, 1);
8033 if (rc) {
8034 pr_err("%s: regulator init failed = %d\n",
8035 __func__, rc);
8036 goto out;
8037 }
8038 }
8039
8040 if (curr->sts == enable)
8041 goto out;
8042
8043 if (curr_vdd_reg) {
8044 if (enable)
8045 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8046 else
8047 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8048 if (rc)
8049 goto out;
8050 }
8051
8052 if (curr_vccq_reg) {
8053 if (enable)
8054 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8055 else
8056 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8057 if (rc)
8058 goto out;
8059 }
8060
8061 if (curr_vddp_reg) {
8062 if (enable)
8063 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8064 else
8065 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8066 if (rc)
8067 goto out;
8068 }
8069 curr->sts = enable;
8070
8071out:
8072 return rc;
8073}
8074
8075static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8076{
8077 u32 rc_pin_cfg = 0;
8078 u32 rc_vreg_cfg = 0;
8079 u32 rc = 0;
8080 struct platform_device *pdev;
8081 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8082
8083 pdev = container_of(dv, struct platform_device, dev);
8084
8085 /* setup gpio/pad */
8086 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8087 if (curr_pin_cfg->cfg_sts == !!vdd)
8088 goto setup_vreg;
8089
8090 if (curr_pin_cfg->is_gpio)
8091 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8092 else
8093 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8094
8095setup_vreg:
8096 /* setup voltage regulators */
8097 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8098
8099 if (rc_pin_cfg || rc_vreg_cfg)
8100 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8101
8102 return rc;
8103}
8104
8105static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8106{
8107 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8108 struct platform_device *pdev;
8109
8110 pdev = container_of(dv, struct platform_device, dev);
8111 /* setup gpio/pad */
8112 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8113
8114 if (curr_pin_cfg->cfg_sts == active)
8115 return;
8116
8117 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8118 if (curr_pin_cfg->is_gpio)
8119 msm_sdcc_setup_gpio(pdev->id, active);
8120 else
8121 msm_sdcc_setup_pad(pdev->id, active);
8122 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8123}
8124
8125static int msm_sdc3_get_wpswitch(struct device *dev)
8126{
8127 struct platform_device *pdev;
8128 int status;
8129 pdev = container_of(dev, struct platform_device, dev);
8130
8131 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8132 if (status) {
8133 pr_err("%s:Failed to request GPIO %d\n",
8134 __func__, GPIO_SDC_WP);
8135 } else {
8136 status = gpio_direction_input(GPIO_SDC_WP);
8137 if (!status) {
8138 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8139 pr_info("%s: WP Status for Slot %d = %d\n",
8140 __func__, pdev->id, status);
8141 }
8142 gpio_free(GPIO_SDC_WP);
8143 }
8144 return status;
8145}
8146
8147#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8148int sdc5_register_status_notify(void (*callback)(int, void *),
8149 void *dev_id)
8150{
8151 sdc5_status_notify_cb = callback;
8152 sdc5_status_notify_cb_devid = dev_id;
8153 return 0;
8154}
8155#endif
8156
8157#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8158int sdc2_register_status_notify(void (*callback)(int, void *),
8159 void *dev_id)
8160{
8161 sdc2_status_notify_cb = callback;
8162 sdc2_status_notify_cb_devid = dev_id;
8163 return 0;
8164}
8165#endif
8166
8167/* Interrupt handler for SDC2 and SDC5 detection
8168 * This function uses dual-edge interrputs settings in order
8169 * to get SDIO detection when the GPIO is rising and SDIO removal
8170 * when the GPIO is falling */
8171static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8172{
8173 int status;
8174
8175 if (!machine_is_msm8x60_fusion() &&
8176 !machine_is_msm8x60_fusn_ffa())
8177 return IRQ_NONE;
8178
8179 status = gpio_get_value(MDM2AP_SYNC);
8180 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8181 __func__, status);
8182
8183#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8184 if (sdc2_status_notify_cb) {
8185 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8186 sdc2_status_notify_cb(status,
8187 sdc2_status_notify_cb_devid);
8188 }
8189#endif
8190
8191#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8192 if (sdc5_status_notify_cb) {
8193 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8194 sdc5_status_notify_cb(status,
8195 sdc5_status_notify_cb_devid);
8196 }
8197#endif
8198 return IRQ_HANDLED;
8199}
8200
8201static int msm8x60_multi_sdio_init(void)
8202{
8203 int ret, irq_num;
8204
8205 if (!machine_is_msm8x60_fusion() &&
8206 !machine_is_msm8x60_fusn_ffa())
8207 return 0;
8208
8209 ret = msm_gpiomux_get(MDM2AP_SYNC);
8210 if (ret) {
8211 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8212 __func__, MDM2AP_SYNC, ret);
8213 return ret;
8214 }
8215
8216 irq_num = gpio_to_irq(MDM2AP_SYNC);
8217
8218 ret = request_irq(irq_num,
8219 msm8x60_multi_sdio_slot_status_irq,
8220 IRQ_TYPE_EDGE_BOTH,
8221 "sdio_multidetection", NULL);
8222
8223 if (ret) {
8224 pr_err("%s:Failed to request irq, ret=%d\n",
8225 __func__, ret);
8226 return ret;
8227 }
8228
8229 return ret;
8230}
8231
8232#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8233#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8234static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8235{
8236 int status;
8237
8238 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8239 , "SD_HW_Detect");
8240 if (status) {
8241 pr_err("%s:Failed to request GPIO %d\n", __func__,
8242 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8243 } else {
8244 status = gpio_direction_input(
8245 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8246 if (!status)
8247 status = !(gpio_get_value_cansleep(
8248 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8249 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8250 }
8251 return (unsigned int) status;
8252}
8253#endif
8254#endif
8255
8256#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8257static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
8258{
8259 struct platform_device *pdev;
8260 enum msm_mpm_pin pin;
8261 int ret = 0;
8262
8263 pdev = container_of(dev, struct platform_device, dev);
8264
8265 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
8266 if (pdev->id == 4)
8267 pin = MSM_MPM_PIN_SDC4_DAT1;
8268 else
8269 return -EINVAL;
8270
8271 switch (mode) {
8272 case SDC_DAT1_DISABLE:
8273 ret = msm_mpm_enable_pin(pin, 0);
8274 break;
8275 case SDC_DAT1_ENABLE:
8276 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
8277 ret = msm_mpm_enable_pin(pin, 1);
8278 break;
8279 case SDC_DAT1_ENWAKE:
8280 ret = msm_mpm_set_pin_wake(pin, 1);
8281 break;
8282 case SDC_DAT1_DISWAKE:
8283 ret = msm_mpm_set_pin_wake(pin, 0);
8284 break;
8285 default:
8286 ret = -EINVAL;
8287 break;
8288 }
8289 return ret;
8290}
8291#endif
8292#endif
8293
8294#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8295static struct mmc_platform_data msm8x60_sdc1_data = {
8296 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8297 .translate_vdd = msm_sdcc_setup_power,
8298#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8299 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8300#else
8301 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8302#endif
8303 .msmsdcc_fmin = 400000,
8304 .msmsdcc_fmid = 24000000,
8305 .msmsdcc_fmax = 48000000,
8306 .nonremovable = 1,
8307 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008308};
8309#endif
8310
8311#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8312static struct mmc_platform_data msm8x60_sdc2_data = {
8313 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8314 .translate_vdd = msm_sdcc_setup_power,
8315 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8316 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8317 .msmsdcc_fmin = 400000,
8318 .msmsdcc_fmid = 24000000,
8319 .msmsdcc_fmax = 48000000,
8320 .nonremovable = 0,
8321 .pclk_src_dfab = 1,
8322 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008323#ifdef CONFIG_MSM_SDIO_AL
8324 .is_sdio_al_client = 1,
8325#endif
8326};
8327#endif
8328
8329#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8330static struct mmc_platform_data msm8x60_sdc3_data = {
8331 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8332 .translate_vdd = msm_sdcc_setup_power,
8333 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8334 .wpswitch = msm_sdc3_get_wpswitch,
8335#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8336 .status = msm8x60_sdcc_slot_status,
8337 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8338 PMIC_GPIO_SDC3_DET - 1),
8339 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8340#endif
8341 .msmsdcc_fmin = 400000,
8342 .msmsdcc_fmid = 24000000,
8343 .msmsdcc_fmax = 48000000,
8344 .nonremovable = 0,
8345 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008346};
8347#endif
8348
8349#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8350static struct mmc_platform_data msm8x60_sdc4_data = {
8351 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8352 .translate_vdd = msm_sdcc_setup_power,
8353 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8354 .msmsdcc_fmin = 400000,
8355 .msmsdcc_fmid = 24000000,
8356 .msmsdcc_fmax = 48000000,
8357 .nonremovable = 0,
8358 .pclk_src_dfab = 1,
8359 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008360};
8361#endif
8362
8363#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8364static struct mmc_platform_data msm8x60_sdc5_data = {
8365 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8366 .translate_vdd = msm_sdcc_setup_power,
8367 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8368 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8369 .msmsdcc_fmin = 400000,
8370 .msmsdcc_fmid = 24000000,
8371 .msmsdcc_fmax = 48000000,
8372 .nonremovable = 0,
8373 .pclk_src_dfab = 1,
8374 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008375#ifdef CONFIG_MSM_SDIO_AL
8376 .is_sdio_al_client = 1,
8377#endif
8378};
8379#endif
8380
8381static void __init msm8x60_init_mmc(void)
8382{
8383#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8384 /* SDCC1 : eMMC card connected */
8385 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8386 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8387 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8388 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308389 sdcc_vreg_data[0].vdd_data->always_on = 1;
8390 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8391 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8392 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008393
8394 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8395 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8396 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8397 sdcc_vreg_data[0].vccq_data->always_on = 1;
8398
8399 msm_add_sdcc(1, &msm8x60_sdc1_data);
8400#endif
8401#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8402 /*
8403 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8404 * and no card is connected on 8660 SURF/FFA/FLUID.
8405 */
8406 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8407 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8408 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8409 sdcc_vreg_data[1].vdd_data->level = 1800000;
8410
8411 sdcc_vreg_data[1].vccq_data = NULL;
8412
8413 if (machine_is_msm8x60_fusion())
8414 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8415 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8416#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8417 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8418 msm_sdcc_setup_gpio(2, 1);
8419#endif
8420 msm_add_sdcc(2, &msm8x60_sdc2_data);
8421 }
8422#endif
8423#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8424 /* SDCC3 : External card slot connected */
8425 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8426 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8427 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8428 sdcc_vreg_data[2].vdd_data->level = 2850000;
8429 sdcc_vreg_data[2].vdd_data->always_on = 1;
8430 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8431 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8432 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8433
8434 sdcc_vreg_data[2].vccq_data = NULL;
8435
8436 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8437 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8438 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8439 sdcc_vreg_data[2].vddp_data->level = 2850000;
8440 sdcc_vreg_data[2].vddp_data->always_on = 1;
8441 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8442 /* Sleep current required is ~300 uA. But min. RPM
8443 * vote can be in terms of mA (min. 1 mA).
8444 * So let's vote for 2 mA during sleep.
8445 */
8446 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8447 /* Max. Active current required is 16 mA */
8448 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8449
8450 if (machine_is_msm8x60_fluid())
8451 msm8x60_sdc3_data.wpswitch = NULL;
8452 msm_add_sdcc(3, &msm8x60_sdc3_data);
8453#endif
8454#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8455 /* SDCC4 : WLAN WCN1314 chip is connected */
8456 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8457 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8458 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8459 sdcc_vreg_data[3].vdd_data->level = 1800000;
8460
8461 sdcc_vreg_data[3].vccq_data = NULL;
8462
8463 msm_add_sdcc(4, &msm8x60_sdc4_data);
8464#endif
8465#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8466 /*
8467 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8468 * and no card is connected on 8660 SURF/FFA/FLUID.
8469 */
8470 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8471 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8472 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8473 sdcc_vreg_data[4].vdd_data->level = 1800000;
8474
8475 sdcc_vreg_data[4].vccq_data = NULL;
8476
8477 if (machine_is_msm8x60_fusion())
8478 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8479 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8480#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8481 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8482 msm_sdcc_setup_gpio(5, 1);
8483#endif
8484 msm_add_sdcc(5, &msm8x60_sdc5_data);
8485 }
8486#endif
8487}
8488
8489#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8490static inline void display_common_power(int on) {}
8491#else
8492
8493#define _GET_REGULATOR(var, name) do { \
8494 if (var == NULL) { \
8495 var = regulator_get(NULL, name); \
8496 if (IS_ERR(var)) { \
8497 pr_err("'%s' regulator not found, rc=%ld\n", \
8498 name, PTR_ERR(var)); \
8499 var = NULL; \
8500 } \
8501 } \
8502} while (0)
8503
8504static int dsub_regulator(int on)
8505{
8506 static struct regulator *dsub_reg;
8507 static struct regulator *mpp0_reg;
8508 static int dsub_reg_enabled;
8509 int rc = 0;
8510
8511 _GET_REGULATOR(dsub_reg, "8901_l3");
8512 if (IS_ERR(dsub_reg)) {
8513 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8514 __func__, PTR_ERR(dsub_reg));
8515 return PTR_ERR(dsub_reg);
8516 }
8517
8518 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8519 if (IS_ERR(mpp0_reg)) {
8520 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8521 __func__, PTR_ERR(mpp0_reg));
8522 return PTR_ERR(mpp0_reg);
8523 }
8524
8525 if (on && !dsub_reg_enabled) {
8526 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8527 if (rc) {
8528 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8529 " err=%d", __func__, rc);
8530 goto dsub_regulator_err;
8531 }
8532 rc = regulator_enable(dsub_reg);
8533 if (rc) {
8534 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8535 " err=%d", __func__, rc);
8536 goto dsub_regulator_err;
8537 }
8538 rc = regulator_enable(mpp0_reg);
8539 if (rc) {
8540 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8541 " err=%d", __func__, rc);
8542 goto dsub_regulator_err;
8543 }
8544 dsub_reg_enabled = 1;
8545 } else if (!on && dsub_reg_enabled) {
8546 rc = regulator_disable(dsub_reg);
8547 if (rc)
8548 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8549 " err=%d", __func__, rc);
8550 rc = regulator_disable(mpp0_reg);
8551 if (rc)
8552 printk(KERN_WARNING "%s: failed to disable reg "
8553 "8901_mpp0 err=%d", __func__, rc);
8554 dsub_reg_enabled = 0;
8555 }
8556
8557 return rc;
8558
8559dsub_regulator_err:
8560 regulator_put(mpp0_reg);
8561 regulator_put(dsub_reg);
8562 return rc;
8563}
8564
8565static int display_power_on;
8566static void setup_display_power(void)
8567{
8568 if (display_power_on)
8569 if (lcdc_vga_enabled) {
8570 dsub_regulator(1);
8571 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8572 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8573 if (machine_is_msm8x60_ffa() ||
8574 machine_is_msm8x60_fusn_ffa())
8575 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8576 } else {
8577 dsub_regulator(0);
8578 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8579 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8580 if (machine_is_msm8x60_ffa() ||
8581 machine_is_msm8x60_fusn_ffa())
8582 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8583 }
8584 else {
8585 dsub_regulator(0);
8586 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8587 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8588 /* BACKLIGHT */
8589 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8590 /* LVDS */
8591 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8592 }
8593}
8594
8595#define _GET_REGULATOR(var, name) do { \
8596 if (var == NULL) { \
8597 var = regulator_get(NULL, name); \
8598 if (IS_ERR(var)) { \
8599 pr_err("'%s' regulator not found, rc=%ld\n", \
8600 name, PTR_ERR(var)); \
8601 var = NULL; \
8602 } \
8603 } \
8604} while (0)
8605
8606#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8607
8608static void display_common_power(int on)
8609{
8610 int rc;
8611 static struct regulator *display_reg;
8612
8613 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8614 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8615 if (on) {
8616 /* LVDS */
8617 _GET_REGULATOR(display_reg, "8901_l2");
8618 if (!display_reg)
8619 return;
8620 rc = regulator_set_voltage(display_reg,
8621 3300000, 3300000);
8622 if (rc)
8623 goto out;
8624 rc = regulator_enable(display_reg);
8625 if (rc)
8626 goto out;
8627 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8628 "LVDS_STDN_OUT_N");
8629 if (rc) {
8630 printk(KERN_ERR "%s: LVDS gpio %d request"
8631 "failed\n", __func__,
8632 GPIO_LVDS_SHUTDOWN_N);
8633 goto out2;
8634 }
8635
8636 /* BACKLIGHT */
8637 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8638 if (rc) {
8639 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8640 "failed\n", __func__,
8641 GPIO_BACKLIGHT_EN);
8642 goto out3;
8643 }
8644
8645 if (machine_is_msm8x60_ffa() ||
8646 machine_is_msm8x60_fusn_ffa()) {
8647 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8648 "DONGLE_PWR_EN");
8649 if (rc) {
8650 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8651 " %d request failed\n", __func__,
8652 GPIO_DONGLE_PWR_EN);
8653 goto out4;
8654 }
8655 }
8656
8657 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8658 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8659 if (machine_is_msm8x60_ffa() ||
8660 machine_is_msm8x60_fusn_ffa())
8661 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8662 mdelay(20);
8663 display_power_on = 1;
8664 setup_display_power();
8665 } else {
8666 if (display_power_on) {
8667 display_power_on = 0;
8668 setup_display_power();
8669 mdelay(20);
8670 if (machine_is_msm8x60_ffa() ||
8671 machine_is_msm8x60_fusn_ffa())
8672 gpio_free(GPIO_DONGLE_PWR_EN);
8673 goto out4;
8674 }
8675 }
8676 }
8677#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8678 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8679 else if (machine_is_msm8x60_fluid()) {
8680 static struct regulator *fluid_reg;
8681 static struct regulator *fluid_reg2;
8682
8683 if (on) {
8684 _GET_REGULATOR(fluid_reg, "8901_l2");
8685 if (!fluid_reg)
8686 return;
8687 _GET_REGULATOR(fluid_reg2, "8058_s3");
8688 if (!fluid_reg2) {
8689 regulator_put(fluid_reg);
8690 return;
8691 }
8692 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8693 if (rc) {
8694 regulator_put(fluid_reg2);
8695 regulator_put(fluid_reg);
8696 return;
8697 }
8698 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8699 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8700 regulator_enable(fluid_reg);
8701 regulator_enable(fluid_reg2);
8702 msleep(20);
8703 gpio_direction_output(GPIO_RESX_N, 0);
8704 udelay(10);
8705 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8706 display_power_on = 1;
8707 setup_display_power();
8708 } else {
8709 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8710 gpio_free(GPIO_RESX_N);
8711 msleep(20);
8712 regulator_disable(fluid_reg2);
8713 regulator_disable(fluid_reg);
8714 regulator_put(fluid_reg2);
8715 regulator_put(fluid_reg);
8716 display_power_on = 0;
8717 setup_display_power();
8718 fluid_reg = NULL;
8719 fluid_reg2 = NULL;
8720 }
8721 }
8722#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008723#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8724 else if (machine_is_msm8x60_dragon()) {
8725 static struct regulator *dragon_reg;
8726 static struct regulator *dragon_reg2;
8727
8728 if (on) {
8729 _GET_REGULATOR(dragon_reg, "8901_l2");
8730 if (!dragon_reg)
8731 return;
8732 _GET_REGULATOR(dragon_reg2, "8058_l16");
8733 if (!dragon_reg2) {
8734 regulator_put(dragon_reg);
8735 dragon_reg = NULL;
8736 return;
8737 }
8738
8739 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8740 if (rc) {
8741 pr_err("%s: gpio %d request failed with rc=%d\n",
8742 __func__, GPIO_NT35582_BL_EN, rc);
8743 regulator_put(dragon_reg);
8744 regulator_put(dragon_reg2);
8745 dragon_reg = NULL;
8746 dragon_reg2 = NULL;
8747 return;
8748 }
8749
8750 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8751 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8752 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8753 pr_err("%s: config gpio '%d' failed!\n",
8754 __func__, GPIO_NT35582_RESET);
8755 gpio_free(GPIO_NT35582_BL_EN);
8756 regulator_put(dragon_reg);
8757 regulator_put(dragon_reg2);
8758 dragon_reg = NULL;
8759 dragon_reg2 = NULL;
8760 return;
8761 }
8762
8763 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8764 if (rc) {
8765 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8766 __func__, GPIO_NT35582_RESET, rc);
8767 gpio_free(GPIO_NT35582_BL_EN);
8768 regulator_put(dragon_reg);
8769 regulator_put(dragon_reg2);
8770 dragon_reg = NULL;
8771 dragon_reg2 = NULL;
8772 return;
8773 }
8774
8775 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8776 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8777 regulator_enable(dragon_reg);
8778 regulator_enable(dragon_reg2);
8779 msleep(20);
8780
8781 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8782 msleep(20);
8783 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8784 msleep(20);
8785 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8786 msleep(50);
8787
8788 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8789
8790 display_power_on = 1;
8791 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8792 gpio_free(GPIO_NT35582_RESET);
8793 gpio_free(GPIO_NT35582_BL_EN);
8794 regulator_disable(dragon_reg2);
8795 regulator_disable(dragon_reg);
8796 regulator_put(dragon_reg2);
8797 regulator_put(dragon_reg);
8798 display_power_on = 0;
8799 dragon_reg = NULL;
8800 dragon_reg2 = NULL;
8801 }
8802 }
8803#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008804 return;
8805
8806out4:
8807 gpio_free(GPIO_BACKLIGHT_EN);
8808out3:
8809 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8810out2:
8811 regulator_disable(display_reg);
8812out:
8813 regulator_put(display_reg);
8814 display_reg = NULL;
8815}
8816#undef _GET_REGULATOR
8817#endif
8818
8819static int mipi_dsi_panel_power(int on);
8820
8821#define LCDC_NUM_GPIO 28
8822#define LCDC_GPIO_START 0
8823
8824static void lcdc_samsung_panel_power(int on)
8825{
8826 int n, ret = 0;
8827
8828 display_common_power(on);
8829
8830 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8831 if (on) {
8832 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8833 if (unlikely(ret)) {
8834 pr_err("%s not able to get gpio\n", __func__);
8835 break;
8836 }
8837 } else
8838 gpio_free(LCDC_GPIO_START + n);
8839 }
8840
8841 if (ret) {
8842 for (n--; n >= 0; n--)
8843 gpio_free(LCDC_GPIO_START + n);
8844 }
8845
8846 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8847}
8848
8849#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8850#define _GET_REGULATOR(var, name) do { \
8851 var = regulator_get(NULL, name); \
8852 if (IS_ERR(var)) { \
8853 pr_err("'%s' regulator not found, rc=%ld\n", \
8854 name, IS_ERR(var)); \
8855 var = NULL; \
8856 return -ENODEV; \
8857 } \
8858} while (0)
8859
8860static int hdmi_enable_5v(int on)
8861{
8862 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8863 static struct regulator *reg_8901_mpp0; /* External 5V */
8864 static int prev_on;
8865 int rc;
8866
8867 if (on == prev_on)
8868 return 0;
8869
8870 if (!reg_8901_hdmi_mvs)
8871 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8872 if (!reg_8901_mpp0)
8873 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8874
8875 if (on) {
8876 rc = regulator_enable(reg_8901_mpp0);
8877 if (rc) {
8878 pr_err("'%s' regulator enable failed, rc=%d\n",
8879 "reg_8901_mpp0", rc);
8880 return rc;
8881 }
8882 rc = regulator_enable(reg_8901_hdmi_mvs);
8883 if (rc) {
8884 pr_err("'%s' regulator enable failed, rc=%d\n",
8885 "8901_hdmi_mvs", rc);
8886 return rc;
8887 }
8888 pr_info("%s(on): success\n", __func__);
8889 } else {
8890 rc = regulator_disable(reg_8901_hdmi_mvs);
8891 if (rc)
8892 pr_warning("'%s' regulator disable failed, rc=%d\n",
8893 "8901_hdmi_mvs", rc);
8894 rc = regulator_disable(reg_8901_mpp0);
8895 if (rc)
8896 pr_warning("'%s' regulator disable failed, rc=%d\n",
8897 "reg_8901_mpp0", rc);
8898 pr_info("%s(off): success\n", __func__);
8899 }
8900
8901 prev_on = on;
8902
8903 return 0;
8904}
8905
8906static int hdmi_core_power(int on, int show)
8907{
8908 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8909 static int prev_on;
8910 int rc;
8911
8912 if (on == prev_on)
8913 return 0;
8914
8915 if (!reg_8058_l16)
8916 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8917
8918 if (on) {
8919 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8920 if (!rc)
8921 rc = regulator_enable(reg_8058_l16);
8922 if (rc) {
8923 pr_err("'%s' regulator enable failed, rc=%d\n",
8924 "8058_l16", rc);
8925 return rc;
8926 }
8927 rc = gpio_request(170, "HDMI_DDC_CLK");
8928 if (rc) {
8929 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8930 "HDMI_DDC_CLK", 170, rc);
8931 goto error1;
8932 }
8933 rc = gpio_request(171, "HDMI_DDC_DATA");
8934 if (rc) {
8935 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8936 "HDMI_DDC_DATA", 171, rc);
8937 goto error2;
8938 }
8939 rc = gpio_request(172, "HDMI_HPD");
8940 if (rc) {
8941 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8942 "HDMI_HPD", 172, rc);
8943 goto error3;
8944 }
8945 pr_info("%s(on): success\n", __func__);
8946 } else {
8947 gpio_free(170);
8948 gpio_free(171);
8949 gpio_free(172);
8950 rc = regulator_disable(reg_8058_l16);
8951 if (rc)
8952 pr_warning("'%s' regulator disable failed, rc=%d\n",
8953 "8058_l16", rc);
8954 pr_info("%s(off): success\n", __func__);
8955 }
8956
8957 prev_on = on;
8958
8959 return 0;
8960
8961error3:
8962 gpio_free(171);
8963error2:
8964 gpio_free(170);
8965error1:
8966 regulator_disable(reg_8058_l16);
8967 return rc;
8968}
8969
8970static int hdmi_cec_power(int on)
8971{
8972 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8973 static int prev_on;
8974 int rc;
8975
8976 if (on == prev_on)
8977 return 0;
8978
8979 if (!reg_8901_l3)
8980 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8981
8982 if (on) {
8983 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8984 if (!rc)
8985 rc = regulator_enable(reg_8901_l3);
8986 if (rc) {
8987 pr_err("'%s' regulator enable failed, rc=%d\n",
8988 "8901_l3", rc);
8989 return rc;
8990 }
8991 rc = gpio_request(169, "HDMI_CEC_VAR");
8992 if (rc) {
8993 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8994 "HDMI_CEC_VAR", 169, rc);
8995 goto error;
8996 }
8997 pr_info("%s(on): success\n", __func__);
8998 } else {
8999 gpio_free(169);
9000 rc = regulator_disable(reg_8901_l3);
9001 if (rc)
9002 pr_warning("'%s' regulator disable failed, rc=%d\n",
9003 "8901_l3", rc);
9004 pr_info("%s(off): success\n", __func__);
9005 }
9006
9007 prev_on = on;
9008
9009 return 0;
9010error:
9011 regulator_disable(reg_8901_l3);
9012 return rc;
9013}
9014
9015#undef _GET_REGULATOR
9016
9017#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9018
9019static int lcdc_panel_power(int on)
9020{
9021 int flag_on = !!on;
9022 static int lcdc_power_save_on;
9023
9024 if (lcdc_power_save_on == flag_on)
9025 return 0;
9026
9027 lcdc_power_save_on = flag_on;
9028
9029 lcdc_samsung_panel_power(on);
9030
9031 return 0;
9032}
9033
9034#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009035
9036static struct msm_bus_vectors rotator_init_vectors[] = {
9037 {
9038 .src = MSM_BUS_MASTER_ROTATOR,
9039 .dst = MSM_BUS_SLAVE_SMI,
9040 .ab = 0,
9041 .ib = 0,
9042 },
9043 {
9044 .src = MSM_BUS_MASTER_ROTATOR,
9045 .dst = MSM_BUS_SLAVE_EBI_CH0,
9046 .ab = 0,
9047 .ib = 0,
9048 },
9049};
9050
9051static struct msm_bus_vectors rotator_ui_vectors[] = {
9052 {
9053 .src = MSM_BUS_MASTER_ROTATOR,
9054 .dst = MSM_BUS_SLAVE_SMI,
9055 .ab = 0,
9056 .ib = 0,
9057 },
9058 {
9059 .src = MSM_BUS_MASTER_ROTATOR,
9060 .dst = MSM_BUS_SLAVE_EBI_CH0,
9061 .ab = (1024 * 600 * 4 * 2 * 60),
9062 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9063 },
9064};
9065
9066static struct msm_bus_vectors rotator_vga_vectors[] = {
9067 {
9068 .src = MSM_BUS_MASTER_ROTATOR,
9069 .dst = MSM_BUS_SLAVE_SMI,
9070 .ab = (640 * 480 * 2 * 2 * 30),
9071 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9072 },
9073 {
9074 .src = MSM_BUS_MASTER_ROTATOR,
9075 .dst = MSM_BUS_SLAVE_EBI_CH0,
9076 .ab = (640 * 480 * 2 * 2 * 30),
9077 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9078 },
9079};
9080
9081static struct msm_bus_vectors rotator_720p_vectors[] = {
9082 {
9083 .src = MSM_BUS_MASTER_ROTATOR,
9084 .dst = MSM_BUS_SLAVE_SMI,
9085 .ab = (1280 * 736 * 2 * 2 * 30),
9086 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9087 },
9088 {
9089 .src = MSM_BUS_MASTER_ROTATOR,
9090 .dst = MSM_BUS_SLAVE_EBI_CH0,
9091 .ab = (1280 * 736 * 2 * 2 * 30),
9092 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9093 },
9094};
9095
9096static struct msm_bus_vectors rotator_1080p_vectors[] = {
9097 {
9098 .src = MSM_BUS_MASTER_ROTATOR,
9099 .dst = MSM_BUS_SLAVE_SMI,
9100 .ab = (1920 * 1088 * 2 * 2 * 30),
9101 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9102 },
9103 {
9104 .src = MSM_BUS_MASTER_ROTATOR,
9105 .dst = MSM_BUS_SLAVE_EBI_CH0,
9106 .ab = (1920 * 1088 * 2 * 2 * 30),
9107 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9108 },
9109};
9110
9111static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9112 {
9113 ARRAY_SIZE(rotator_init_vectors),
9114 rotator_init_vectors,
9115 },
9116 {
9117 ARRAY_SIZE(rotator_ui_vectors),
9118 rotator_ui_vectors,
9119 },
9120 {
9121 ARRAY_SIZE(rotator_vga_vectors),
9122 rotator_vga_vectors,
9123 },
9124 {
9125 ARRAY_SIZE(rotator_720p_vectors),
9126 rotator_720p_vectors,
9127 },
9128 {
9129 ARRAY_SIZE(rotator_1080p_vectors),
9130 rotator_1080p_vectors,
9131 },
9132};
9133
9134struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9135 rotator_bus_scale_usecases,
9136 ARRAY_SIZE(rotator_bus_scale_usecases),
9137 .name = "rotator",
9138};
9139
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009140static struct msm_bus_vectors mdp_init_vectors[] = {
9141 /* For now, 0th array entry is reserved.
9142 * Please leave 0 as is and don't use it
9143 */
9144 {
9145 .src = MSM_BUS_MASTER_MDP_PORT0,
9146 .dst = MSM_BUS_SLAVE_SMI,
9147 .ab = 0,
9148 .ib = 0,
9149 },
9150 /* Master and slaves can be from different fabrics */
9151 {
9152 .src = MSM_BUS_MASTER_MDP_PORT0,
9153 .dst = MSM_BUS_SLAVE_EBI_CH0,
9154 .ab = 0,
9155 .ib = 0,
9156 },
9157};
9158
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009159#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9160static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
9161 /* If HDMI is used as primary */
9162 {
9163 .src = MSM_BUS_MASTER_MDP_PORT0,
9164 .dst = MSM_BUS_SLAVE_SMI,
9165 .ab = 2000000000,
9166 .ib = 2000000000,
9167 },
9168 /* Master and slaves can be from different fabrics */
9169 {
9170 .src = MSM_BUS_MASTER_MDP_PORT0,
9171 .dst = MSM_BUS_SLAVE_EBI_CH0,
9172 .ab = 2000000000,
9173 .ib = 2000000000,
9174 },
9175};
9176
9177static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9178 {
9179 ARRAY_SIZE(mdp_init_vectors),
9180 mdp_init_vectors,
9181 },
9182 {
9183 ARRAY_SIZE(hdmi_as_primary_vectors),
9184 hdmi_as_primary_vectors,
9185 },
9186 {
9187 ARRAY_SIZE(hdmi_as_primary_vectors),
9188 hdmi_as_primary_vectors,
9189 },
9190 {
9191 ARRAY_SIZE(hdmi_as_primary_vectors),
9192 hdmi_as_primary_vectors,
9193 },
9194 {
9195 ARRAY_SIZE(hdmi_as_primary_vectors),
9196 hdmi_as_primary_vectors,
9197 },
9198 {
9199 ARRAY_SIZE(hdmi_as_primary_vectors),
9200 hdmi_as_primary_vectors,
9201 },
9202};
9203#else
9204#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009205static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9206 /* Default case static display/UI/2d/3d if FB SMI */
9207 {
9208 .src = MSM_BUS_MASTER_MDP_PORT0,
9209 .dst = MSM_BUS_SLAVE_SMI,
9210 .ab = 388800000,
9211 .ib = 486000000,
9212 },
9213 /* Master and slaves can be from different fabrics */
9214 {
9215 .src = MSM_BUS_MASTER_MDP_PORT0,
9216 .dst = MSM_BUS_SLAVE_EBI_CH0,
9217 .ab = 0,
9218 .ib = 0,
9219 },
9220};
9221
9222static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9223 /* Default case static display/UI/2d/3d if FB SMI */
9224 {
9225 .src = MSM_BUS_MASTER_MDP_PORT0,
9226 .dst = MSM_BUS_SLAVE_SMI,
9227 .ab = 0,
9228 .ib = 0,
9229 },
9230 /* Master and slaves can be from different fabrics */
9231 {
9232 .src = MSM_BUS_MASTER_MDP_PORT0,
9233 .dst = MSM_BUS_SLAVE_EBI_CH0,
9234 .ab = 388800000,
9235 .ib = 486000000 * 2,
9236 },
9237};
9238static struct msm_bus_vectors mdp_vga_vectors[] = {
9239 /* VGA and less video */
9240 {
9241 .src = MSM_BUS_MASTER_MDP_PORT0,
9242 .dst = MSM_BUS_SLAVE_SMI,
9243 .ab = 458092800,
9244 .ib = 572616000,
9245 },
9246 {
9247 .src = MSM_BUS_MASTER_MDP_PORT0,
9248 .dst = MSM_BUS_SLAVE_EBI_CH0,
9249 .ab = 458092800,
9250 .ib = 572616000 * 2,
9251 },
9252};
9253static struct msm_bus_vectors mdp_720p_vectors[] = {
9254 /* 720p and less video */
9255 {
9256 .src = MSM_BUS_MASTER_MDP_PORT0,
9257 .dst = MSM_BUS_SLAVE_SMI,
9258 .ab = 471744000,
9259 .ib = 589680000,
9260 },
9261 /* Master and slaves can be from different fabrics */
9262 {
9263 .src = MSM_BUS_MASTER_MDP_PORT0,
9264 .dst = MSM_BUS_SLAVE_EBI_CH0,
9265 .ab = 471744000,
9266 .ib = 589680000 * 2,
9267 },
9268};
9269
9270static struct msm_bus_vectors mdp_1080p_vectors[] = {
9271 /* 1080p and less video */
9272 {
9273 .src = MSM_BUS_MASTER_MDP_PORT0,
9274 .dst = MSM_BUS_SLAVE_SMI,
9275 .ab = 575424000,
9276 .ib = 719280000,
9277 },
9278 /* Master and slaves can be from different fabrics */
9279 {
9280 .src = MSM_BUS_MASTER_MDP_PORT0,
9281 .dst = MSM_BUS_SLAVE_EBI_CH0,
9282 .ab = 575424000,
9283 .ib = 719280000 * 2,
9284 },
9285};
9286
9287#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009288static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9289 /* Default case static display/UI/2d/3d if FB SMI */
9290 {
9291 .src = MSM_BUS_MASTER_MDP_PORT0,
9292 .dst = MSM_BUS_SLAVE_SMI,
9293 .ab = 175110000,
9294 .ib = 218887500,
9295 },
9296 /* Master and slaves can be from different fabrics */
9297 {
9298 .src = MSM_BUS_MASTER_MDP_PORT0,
9299 .dst = MSM_BUS_SLAVE_EBI_CH0,
9300 .ab = 0,
9301 .ib = 0,
9302 },
9303};
9304
9305static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9306 /* Default case static display/UI/2d/3d if FB SMI */
9307 {
9308 .src = MSM_BUS_MASTER_MDP_PORT0,
9309 .dst = MSM_BUS_SLAVE_SMI,
9310 .ab = 0,
9311 .ib = 0,
9312 },
9313 /* Master and slaves can be from different fabrics */
9314 {
9315 .src = MSM_BUS_MASTER_MDP_PORT0,
9316 .dst = MSM_BUS_SLAVE_EBI_CH0,
9317 .ab = 216000000,
9318 .ib = 270000000 * 2,
9319 },
9320};
9321static struct msm_bus_vectors mdp_vga_vectors[] = {
9322 /* VGA and less video */
9323 {
9324 .src = MSM_BUS_MASTER_MDP_PORT0,
9325 .dst = MSM_BUS_SLAVE_SMI,
9326 .ab = 216000000,
9327 .ib = 270000000,
9328 },
9329 {
9330 .src = MSM_BUS_MASTER_MDP_PORT0,
9331 .dst = MSM_BUS_SLAVE_EBI_CH0,
9332 .ab = 216000000,
9333 .ib = 270000000 * 2,
9334 },
9335};
9336
9337static struct msm_bus_vectors mdp_720p_vectors[] = {
9338 /* 720p and less video */
9339 {
9340 .src = MSM_BUS_MASTER_MDP_PORT0,
9341 .dst = MSM_BUS_SLAVE_SMI,
9342 .ab = 230400000,
9343 .ib = 288000000,
9344 },
9345 /* Master and slaves can be from different fabrics */
9346 {
9347 .src = MSM_BUS_MASTER_MDP_PORT0,
9348 .dst = MSM_BUS_SLAVE_EBI_CH0,
9349 .ab = 230400000,
9350 .ib = 288000000 * 2,
9351 },
9352};
9353
9354static struct msm_bus_vectors mdp_1080p_vectors[] = {
9355 /* 1080p and less video */
9356 {
9357 .src = MSM_BUS_MASTER_MDP_PORT0,
9358 .dst = MSM_BUS_SLAVE_SMI,
9359 .ab = 334080000,
9360 .ib = 417600000,
9361 },
9362 /* Master and slaves can be from different fabrics */
9363 {
9364 .src = MSM_BUS_MASTER_MDP_PORT0,
9365 .dst = MSM_BUS_SLAVE_EBI_CH0,
9366 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009367 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009368 },
9369};
9370
9371#endif
9372static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9373 {
9374 ARRAY_SIZE(mdp_init_vectors),
9375 mdp_init_vectors,
9376 },
9377 {
9378 ARRAY_SIZE(mdp_sd_smi_vectors),
9379 mdp_sd_smi_vectors,
9380 },
9381 {
9382 ARRAY_SIZE(mdp_sd_ebi_vectors),
9383 mdp_sd_ebi_vectors,
9384 },
9385 {
9386 ARRAY_SIZE(mdp_vga_vectors),
9387 mdp_vga_vectors,
9388 },
9389 {
9390 ARRAY_SIZE(mdp_720p_vectors),
9391 mdp_720p_vectors,
9392 },
9393 {
9394 ARRAY_SIZE(mdp_1080p_vectors),
9395 mdp_1080p_vectors,
9396 },
9397};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009398#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009399static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9400 mdp_bus_scale_usecases,
9401 ARRAY_SIZE(mdp_bus_scale_usecases),
9402 .name = "mdp",
9403};
9404
9405#endif
9406#ifdef CONFIG_MSM_BUS_SCALING
9407static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9408 /* For now, 0th array entry is reserved.
9409 * Please leave 0 as is and don't use it
9410 */
9411 {
9412 .src = MSM_BUS_MASTER_MDP_PORT0,
9413 .dst = MSM_BUS_SLAVE_SMI,
9414 .ab = 0,
9415 .ib = 0,
9416 },
9417 /* Master and slaves can be from different fabrics */
9418 {
9419 .src = MSM_BUS_MASTER_MDP_PORT0,
9420 .dst = MSM_BUS_SLAVE_EBI_CH0,
9421 .ab = 0,
9422 .ib = 0,
9423 },
9424};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009425#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9426static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9427 /* For now, 0th array entry is reserved.
9428 * Please leave 0 as is and don't use it
9429 */
9430 {
9431 .src = MSM_BUS_MASTER_MDP_PORT0,
9432 .dst = MSM_BUS_SLAVE_SMI,
9433 .ab = 2000000000,
9434 .ib = 2000000000,
9435 },
9436 /* Master and slaves can be from different fabrics */
9437 {
9438 .src = MSM_BUS_MASTER_MDP_PORT0,
9439 .dst = MSM_BUS_SLAVE_EBI_CH0,
9440 .ab = 2000000000,
9441 .ib = 2000000000,
9442 },
9443};
9444#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009445static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9446 /* For now, 0th array entry is reserved.
9447 * Please leave 0 as is and don't use it
9448 */
9449 {
9450 .src = MSM_BUS_MASTER_MDP_PORT0,
9451 .dst = MSM_BUS_SLAVE_SMI,
9452 .ab = 566092800,
9453 .ib = 707616000,
9454 },
9455 /* Master and slaves can be from different fabrics */
9456 {
9457 .src = MSM_BUS_MASTER_MDP_PORT0,
9458 .dst = MSM_BUS_SLAVE_EBI_CH0,
9459 .ab = 566092800,
9460 .ib = 707616000,
9461 },
9462};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009463#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009464static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9465 {
9466 ARRAY_SIZE(dtv_bus_init_vectors),
9467 dtv_bus_init_vectors,
9468 },
9469 {
9470 ARRAY_SIZE(dtv_bus_def_vectors),
9471 dtv_bus_def_vectors,
9472 },
9473};
9474static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9475 dtv_bus_scale_usecases,
9476 ARRAY_SIZE(dtv_bus_scale_usecases),
9477 .name = "dtv",
9478};
9479
9480static struct lcdc_platform_data dtv_pdata = {
9481 .bus_scale_table = &dtv_bus_scale_pdata,
9482};
9483#endif
9484
9485
9486static struct lcdc_platform_data lcdc_pdata = {
9487 .lcdc_power_save = lcdc_panel_power,
9488};
9489
9490
9491#define MDP_VSYNC_GPIO 28
9492
9493/*
9494 * MIPI_DSI only use 8058_LDO0 which need always on
9495 * therefore it need to be put at low power mode if
9496 * it was not used instead of turn it off.
9497 */
9498static int mipi_dsi_panel_power(int on)
9499{
9500 int flag_on = !!on;
9501 static int mipi_dsi_power_save_on;
9502 static struct regulator *ldo0;
9503 int rc = 0;
9504
9505 if (mipi_dsi_power_save_on == flag_on)
9506 return 0;
9507
9508 mipi_dsi_power_save_on = flag_on;
9509
9510 if (ldo0 == NULL) { /* init */
9511 ldo0 = regulator_get(NULL, "8058_l0");
9512 if (IS_ERR(ldo0)) {
9513 pr_debug("%s: LDO0 failed\n", __func__);
9514 rc = PTR_ERR(ldo0);
9515 return rc;
9516 }
9517
9518 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9519 if (rc)
9520 goto out;
9521
9522 rc = regulator_enable(ldo0);
9523 if (rc)
9524 goto out;
9525 }
9526
9527 if (on) {
9528 /* set ldo0 to HPM */
9529 rc = regulator_set_optimum_mode(ldo0, 100000);
9530 if (rc < 0)
9531 goto out;
9532 } else {
9533 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309534 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009535 if (rc < 0)
9536 goto out;
9537 }
9538
9539 return 0;
9540out:
9541 regulator_disable(ldo0);
9542 regulator_put(ldo0);
9543 ldo0 = NULL;
9544 return rc;
9545}
9546
9547static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9548 .vsync_gpio = MDP_VSYNC_GPIO,
9549 .dsi_power_save = mipi_dsi_panel_power,
9550};
9551
9552#ifdef CONFIG_FB_MSM_TVOUT
9553static struct regulator *reg_8058_l13;
9554
9555static int atv_dac_power(int on)
9556{
9557 int rc = 0;
9558 #define _GET_REGULATOR(var, name) do { \
9559 var = regulator_get(NULL, name); \
9560 if (IS_ERR(var)) { \
9561 pr_info("'%s' regulator not found, rc=%ld\n", \
9562 name, IS_ERR(var)); \
9563 var = NULL; \
9564 return -ENODEV; \
9565 } \
9566 } while (0)
9567
9568 if (!reg_8058_l13)
9569 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9570 #undef _GET_REGULATOR
9571
9572 if (on) {
9573 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9574 if (rc) {
9575 pr_info("%s: '%s' regulator set voltage failed,\
9576 rc=%d\n", __func__, "8058_l13", rc);
9577 return rc;
9578 }
9579
9580 rc = regulator_enable(reg_8058_l13);
9581 if (rc) {
9582 pr_err("%s: '%s' regulator enable failed,\
9583 rc=%d\n", __func__, "8058_l13", rc);
9584 return rc;
9585 }
9586 } else {
9587 rc = regulator_force_disable(reg_8058_l13);
9588 if (rc)
9589 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9590 __func__, "8058_l13", rc);
9591 }
9592 return rc;
9593
9594}
9595#endif
9596
9597#ifdef CONFIG_FB_MSM_MIPI_DSI
9598int mdp_core_clk_rate_table[] = {
9599 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009600 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009601 160000000,
9602 200000000,
9603};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009604#elif defined(CONFIG_FB_MSM_HDMI_AS_PRIMARY)
9605int mdp_core_clk_rate_table[] = {
9606 200000000,
9607 200000000,
9608 200000000,
9609 200000000,
9610};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009611#else
9612int mdp_core_clk_rate_table[] = {
9613 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009614 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009615 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009616 200000000,
9617};
9618#endif
9619
9620static struct msm_panel_common_pdata mdp_pdata = {
9621 .gpio = MDP_VSYNC_GPIO,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009622#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9623 .mdp_core_clk_rate = 200000000,
9624#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009625 .mdp_core_clk_rate = 59080000,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009626#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009627 .mdp_core_clk_table = mdp_core_clk_rate_table,
9628 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9629#ifdef CONFIG_MSM_BUS_SCALING
9630 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9631#endif
9632 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009633#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
9634 .mem_hid = ION_CP_WB_HEAP_ID,
9635#else
9636 .mem_hid = MEMTYPE_EBI1,
9637#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009638};
9639
Huaibin Yanga5419422011-12-08 23:52:10 -08009640static void __init reserve_mdp_memory(void)
9641{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009642 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9643 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9644#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9645 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9646 mdp_pdata.ov0_wb_size;
9647 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9648 mdp_pdata.ov1_wb_size;
9649#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009650}
9651
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009652#ifdef CONFIG_FB_MSM_TVOUT
9653
9654#ifdef CONFIG_MSM_BUS_SCALING
9655static struct msm_bus_vectors atv_bus_init_vectors[] = {
9656 /* For now, 0th array entry is reserved.
9657 * Please leave 0 as is and don't use it
9658 */
9659 {
9660 .src = MSM_BUS_MASTER_MDP_PORT0,
9661 .dst = MSM_BUS_SLAVE_SMI,
9662 .ab = 0,
9663 .ib = 0,
9664 },
9665 /* Master and slaves can be from different fabrics */
9666 {
9667 .src = MSM_BUS_MASTER_MDP_PORT0,
9668 .dst = MSM_BUS_SLAVE_EBI_CH0,
9669 .ab = 0,
9670 .ib = 0,
9671 },
9672};
9673static struct msm_bus_vectors atv_bus_def_vectors[] = {
9674 /* For now, 0th array entry is reserved.
9675 * Please leave 0 as is and don't use it
9676 */
9677 {
9678 .src = MSM_BUS_MASTER_MDP_PORT0,
9679 .dst = MSM_BUS_SLAVE_SMI,
9680 .ab = 236390400,
9681 .ib = 265939200,
9682 },
9683 /* Master and slaves can be from different fabrics */
9684 {
9685 .src = MSM_BUS_MASTER_MDP_PORT0,
9686 .dst = MSM_BUS_SLAVE_EBI_CH0,
9687 .ab = 236390400,
9688 .ib = 265939200,
9689 },
9690};
9691static struct msm_bus_paths atv_bus_scale_usecases[] = {
9692 {
9693 ARRAY_SIZE(atv_bus_init_vectors),
9694 atv_bus_init_vectors,
9695 },
9696 {
9697 ARRAY_SIZE(atv_bus_def_vectors),
9698 atv_bus_def_vectors,
9699 },
9700};
9701static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9702 atv_bus_scale_usecases,
9703 ARRAY_SIZE(atv_bus_scale_usecases),
9704 .name = "atv",
9705};
9706#endif
9707
9708static struct tvenc_platform_data atv_pdata = {
9709 .poll = 0,
9710 .pm_vid_en = atv_dac_power,
9711#ifdef CONFIG_MSM_BUS_SCALING
9712 .bus_scale_table = &atv_bus_scale_pdata,
9713#endif
9714};
9715#endif
9716
9717static void __init msm_fb_add_devices(void)
9718{
9719#ifdef CONFIG_FB_MSM_LCDC_DSUB
9720 mdp_pdata.mdp_core_clk_table = NULL;
9721 mdp_pdata.num_mdp_clk = 0;
9722 mdp_pdata.mdp_core_clk_rate = 200000000;
9723#endif
9724 if (machine_is_msm8x60_rumi3())
9725 msm_fb_register_device("mdp", NULL);
9726 else
9727 msm_fb_register_device("mdp", &mdp_pdata);
9728
9729 msm_fb_register_device("lcdc", &lcdc_pdata);
9730 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9731#ifdef CONFIG_MSM_BUS_SCALING
9732 msm_fb_register_device("dtv", &dtv_pdata);
9733#endif
9734#ifdef CONFIG_FB_MSM_TVOUT
9735 msm_fb_register_device("tvenc", &atv_pdata);
9736 msm_fb_register_device("tvout_device", NULL);
9737#endif
9738}
9739
9740#if (defined(CONFIG_MARIMBA_CORE)) && \
9741 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9742
9743static const struct {
9744 char *name;
9745 int vmin;
9746 int vmax;
9747} bt_regs_info[] = {
9748 { "8058_s3", 1800000, 1800000 },
9749 { "8058_s2", 1300000, 1300000 },
9750 { "8058_l8", 2900000, 3050000 },
9751};
9752
9753static struct {
9754 bool enabled;
9755} bt_regs_status[] = {
9756 { false },
9757 { false },
9758 { false },
9759};
9760static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9761
9762static int bahama_bt(int on)
9763{
9764 int rc;
9765 int i;
9766 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9767
9768 struct bahama_variant_register {
9769 const size_t size;
9770 const struct bahama_config_register *set;
9771 };
9772
9773 const struct bahama_config_register *p;
9774
9775 u8 version;
9776
9777 const struct bahama_config_register v10_bt_on[] = {
9778 { 0xE9, 0x00, 0xFF },
9779 { 0xF4, 0x80, 0xFF },
9780 { 0xE4, 0x00, 0xFF },
9781 { 0xE5, 0x00, 0x0F },
9782#ifdef CONFIG_WLAN
9783 { 0xE6, 0x38, 0x7F },
9784 { 0xE7, 0x06, 0xFF },
9785#endif
9786 { 0xE9, 0x21, 0xFF },
9787 { 0x01, 0x0C, 0x1F },
9788 { 0x01, 0x08, 0x1F },
9789 };
9790
9791 const struct bahama_config_register v20_bt_on_fm_off[] = {
9792 { 0x11, 0x0C, 0xFF },
9793 { 0x13, 0x01, 0xFF },
9794 { 0xF4, 0x80, 0xFF },
9795 { 0xF0, 0x00, 0xFF },
9796 { 0xE9, 0x00, 0xFF },
9797#ifdef CONFIG_WLAN
9798 { 0x81, 0x00, 0x7F },
9799 { 0x82, 0x00, 0xFF },
9800 { 0xE6, 0x38, 0x7F },
9801 { 0xE7, 0x06, 0xFF },
9802#endif
9803 { 0xE9, 0x21, 0xFF },
9804 };
9805
9806 const struct bahama_config_register v20_bt_on_fm_on[] = {
9807 { 0x11, 0x0C, 0xFF },
9808 { 0x13, 0x01, 0xFF },
9809 { 0xF4, 0x86, 0xFF },
9810 { 0xF0, 0x06, 0xFF },
9811 { 0xE9, 0x00, 0xFF },
9812#ifdef CONFIG_WLAN
9813 { 0x81, 0x00, 0x7F },
9814 { 0x82, 0x00, 0xFF },
9815 { 0xE6, 0x38, 0x7F },
9816 { 0xE7, 0x06, 0xFF },
9817#endif
9818 { 0xE9, 0x21, 0xFF },
9819 };
9820
9821 const struct bahama_config_register v10_bt_off[] = {
9822 { 0xE9, 0x00, 0xFF },
9823 };
9824
9825 const struct bahama_config_register v20_bt_off_fm_off[] = {
9826 { 0xF4, 0x84, 0xFF },
9827 { 0xF0, 0x04, 0xFF },
9828 { 0xE9, 0x00, 0xFF }
9829 };
9830
9831 const struct bahama_config_register v20_bt_off_fm_on[] = {
9832 { 0xF4, 0x86, 0xFF },
9833 { 0xF0, 0x06, 0xFF },
9834 { 0xE9, 0x00, 0xFF }
9835 };
9836 const struct bahama_variant_register bt_bahama[2][3] = {
9837 {
9838 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9839 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9840 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9841 },
9842 {
9843 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9844 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9845 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9846 }
9847 };
9848
9849 u8 offset = 0; /* index into bahama configs */
9850
9851 on = on ? 1 : 0;
9852 version = read_bahama_ver();
9853
9854 if (version == VER_UNSUPPORTED) {
9855 dev_err(&msm_bt_power_device.dev,
9856 "%s: unsupported version\n",
9857 __func__);
9858 return -EIO;
9859 }
9860
9861 if (version == VER_2_0) {
9862 if (marimba_get_fm_status(&config))
9863 offset = 0x01;
9864 }
9865
9866 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9867 if (on && (version == VER_2_0)) {
9868 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9869 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9870 && (bt_regs_status[i].enabled == true)) {
9871 if (regulator_disable(bt_regs[i])) {
9872 dev_err(&msm_bt_power_device.dev,
9873 "%s: regulator disable failed",
9874 __func__);
9875 }
9876 bt_regs_status[i].enabled = false;
9877 break;
9878 }
9879 }
9880 }
9881
9882 p = bt_bahama[on][version + offset].set;
9883
9884 dev_info(&msm_bt_power_device.dev,
9885 "%s: found version %d\n", __func__, version);
9886
9887 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9888 u8 value = (p+i)->value;
9889 rc = marimba_write_bit_mask(&config,
9890 (p+i)->reg,
9891 &value,
9892 sizeof((p+i)->value),
9893 (p+i)->mask);
9894 if (rc < 0) {
9895 dev_err(&msm_bt_power_device.dev,
9896 "%s: reg %d write failed: %d\n",
9897 __func__, (p+i)->reg, rc);
9898 return rc;
9899 }
9900 dev_dbg(&msm_bt_power_device.dev,
9901 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9902 __func__, (p+i)->reg,
9903 value, (p+i)->mask);
9904 }
9905 /* Update BT Status */
9906 if (on)
9907 marimba_set_bt_status(&config, true);
9908 else
9909 marimba_set_bt_status(&config, false);
9910
9911 return 0;
9912}
9913
9914static int bluetooth_use_regulators(int on)
9915{
9916 int i, recover = -1, rc = 0;
9917
9918 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9919 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9920 bt_regs_info[i].name) :
9921 (regulator_put(bt_regs[i]), NULL);
9922 if (IS_ERR(bt_regs[i])) {
9923 rc = PTR_ERR(bt_regs[i]);
9924 dev_err(&msm_bt_power_device.dev,
9925 "regulator %s get failed (%d)\n",
9926 bt_regs_info[i].name, rc);
9927 recover = i - 1;
9928 bt_regs[i] = NULL;
9929 break;
9930 }
9931
9932 if (!on)
9933 continue;
9934
9935 rc = regulator_set_voltage(bt_regs[i],
9936 bt_regs_info[i].vmin,
9937 bt_regs_info[i].vmax);
9938 if (rc < 0) {
9939 dev_err(&msm_bt_power_device.dev,
9940 "regulator %s voltage set (%d)\n",
9941 bt_regs_info[i].name, rc);
9942 recover = i;
9943 break;
9944 }
9945 }
9946
9947 if (on && (recover > -1))
9948 for (i = recover; i >= 0; i--) {
9949 regulator_put(bt_regs[i]);
9950 bt_regs[i] = NULL;
9951 }
9952
9953 return rc;
9954}
9955
9956static int bluetooth_switch_regulators(int on)
9957{
9958 int i, rc = 0;
9959
9960 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9961 if (on && (bt_regs_status[i].enabled == false)) {
9962 rc = regulator_enable(bt_regs[i]);
9963 if (rc < 0) {
9964 dev_err(&msm_bt_power_device.dev,
9965 "regulator %s %s failed (%d)\n",
9966 bt_regs_info[i].name,
9967 "enable", rc);
9968 if (i > 0) {
9969 while (--i) {
9970 regulator_disable(bt_regs[i]);
9971 bt_regs_status[i].enabled
9972 = false;
9973 }
9974 break;
9975 }
9976 }
9977 bt_regs_status[i].enabled = true;
9978 } else if (!on && (bt_regs_status[i].enabled == true)) {
9979 rc = regulator_disable(bt_regs[i]);
9980 if (rc < 0) {
9981 dev_err(&msm_bt_power_device.dev,
9982 "regulator %s %s failed (%d)\n",
9983 bt_regs_info[i].name,
9984 "disable", rc);
9985 break;
9986 }
9987 bt_regs_status[i].enabled = false;
9988 }
9989 }
9990 return rc;
9991}
9992
9993static struct msm_xo_voter *bt_clock;
9994
9995static int bluetooth_power(int on)
9996{
9997 int rc = 0;
9998 int id;
9999
10000 /* In case probe function fails, cur_connv_type would be -1 */
10001 id = adie_get_detected_connectivity_type();
10002 if (id != BAHAMA_ID) {
10003 pr_err("%s: unexpected adie connectivity type: %d\n",
10004 __func__, id);
10005 return -ENODEV;
10006 }
10007
10008 if (on) {
10009
10010 rc = bluetooth_use_regulators(1);
10011 if (rc < 0)
10012 goto out;
10013
10014 rc = bluetooth_switch_regulators(1);
10015
10016 if (rc < 0)
10017 goto fail_put;
10018
10019 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10020
10021 if (IS_ERR(bt_clock)) {
10022 pr_err("Couldn't get TCXO_D0 voter\n");
10023 goto fail_switch;
10024 }
10025
10026 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10027
10028 if (rc < 0) {
10029 pr_err("Failed to vote for TCXO_DO ON\n");
10030 goto fail_vote;
10031 }
10032
10033 rc = bahama_bt(1);
10034
10035 if (rc < 0)
10036 goto fail_clock;
10037
10038 msleep(10);
10039
10040 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10041
10042 if (rc < 0) {
10043 pr_err("Failed to vote for TCXO_DO pin control\n");
10044 goto fail_vote;
10045 }
10046 } else {
10047 /* check for initial RFKILL block (power off) */
10048 /* some RFKILL versions/configurations rfkill_register */
10049 /* calls here for an initial set_block */
10050 /* avoid calling i2c and regulator before unblock (on) */
10051 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10052 dev_info(&msm_bt_power_device.dev,
10053 "%s: initialized OFF/blocked\n", __func__);
10054 goto out;
10055 }
10056
10057 bahama_bt(0);
10058
10059fail_clock:
10060 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10061fail_vote:
10062 msm_xo_put(bt_clock);
10063fail_switch:
10064 bluetooth_switch_regulators(0);
10065fail_put:
10066 bluetooth_use_regulators(0);
10067 }
10068
10069out:
10070 if (rc < 0)
10071 on = 0;
10072 dev_info(&msm_bt_power_device.dev,
10073 "Bluetooth power switch: state %d result %d\n", on, rc);
10074
10075 return rc;
10076}
10077
10078#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10079
10080static void __init msm8x60_cfg_smsc911x(void)
10081{
10082 smsc911x_resources[1].start =
10083 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10084 smsc911x_resources[1].end =
10085 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10086}
10087
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010088void msm_fusion_setup_pinctrl(void)
10089{
10090 struct msm_xo_voter *a1;
10091
10092 if (socinfo_get_platform_subtype() == 0x3) {
10093 /*
10094 * Vote for the A1 clock to be in pin control mode before
10095 * the external images are loaded.
10096 */
10097 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10098 BUG_ON(!a1);
10099 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10100 }
10101}
10102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010103struct msm_board_data {
10104 struct msm_gpiomux_configs *gpiomux_cfgs;
10105};
10106
10107static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10108 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10109};
10110
10111static struct msm_board_data msm8x60_sim_board_data __initdata = {
10112 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10113};
10114
10115static struct msm_board_data msm8x60_surf_board_data __initdata = {
10116 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10117};
10118
10119static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10120 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10121};
10122
10123static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10124 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10125};
10126
10127static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10128 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10129};
10130
10131static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10132 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10133};
10134
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010135static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10136 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10137};
10138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010139static void __init msm8x60_init(struct msm_board_data *board_data)
10140{
10141 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010142#ifdef CONFIG_USB_EHCI_MSM_72K
10143 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10144 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10145 .level = PM8901_MPP_DIG_LEVEL_L5,
10146 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10147 };
10148#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010149 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010150
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010151 /*
10152 * Initialize RPM first as other drivers and devices may need
10153 * it for their initialization.
10154 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010155 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10156 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010157 if (msm_xo_init())
10158 pr_err("Failed to initialize XO votes\n");
10159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010160 msm8x60_check_2d_hardware();
10161
10162 /* Change SPM handling of core 1 if PMM 8160 is present. */
10163 soc_platform_version = socinfo_get_platform_version();
10164 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10165 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10166 struct msm_spm_platform_data *spm_data;
10167
10168 spm_data = &msm_spm_data_v1[1];
10169 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10170 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10171
10172 spm_data = &msm_spm_data[1];
10173 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10174 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10175 }
10176
10177 /*
10178 * Initialize SPM before acpuclock as the latter calls into SPM
10179 * driver to set ACPU voltages.
10180 */
10181 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10182 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10183 else
10184 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10185
10186 /*
10187 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10188 * devices so that the RPM doesn't drop into a low power mode that an
10189 * un-reworked SURF cannot resume from.
10190 */
10191 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010192 int i;
10193
10194 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10195 if (rpm_regulator_init_data[i].id
10196 == RPM_VREG_ID_PM8901_L4
10197 || rpm_regulator_init_data[i].id
10198 == RPM_VREG_ID_PM8901_L6)
10199 rpm_regulator_init_data[i]
10200 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010201 }
10202
10203 /*
10204 * Disable regulator info printing so that regulator registration
10205 * messages do not enter the kmsg log.
10206 */
10207 regulator_suppress_info_printing();
10208
10209 /* Initialize regulators needed for clock_init. */
10210 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10211
Stephen Boydbb600ae2011-08-02 20:11:40 -070010212 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010213
10214 /* Buses need to be initialized before early-device registration
10215 * to get the platform data for fabrics.
10216 */
10217 msm8x60_init_buses();
10218 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10219 /* CPU frequency control is not supported on simulated targets. */
10220 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010221 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010222
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010223 /*
10224 * Enable EBI2 only for boards which make use of it. Leave
10225 * it disabled for all others for additional power savings.
10226 */
10227 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10228 machine_is_msm8x60_rumi3() ||
10229 machine_is_msm8x60_sim() ||
10230 machine_is_msm8x60_fluid() ||
10231 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010232 msm8x60_init_ebi2();
10233 msm8x60_init_tlmm();
10234 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10235 msm8x60_init_uart12dm();
10236 msm8x60_init_mmc();
10237
10238#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10239 msm8x60_init_pm8058_othc();
10240#endif
10241
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010242 if (machine_is_msm8x60_fluid())
10243 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10244 else if (machine_is_msm8x60_dragon())
10245 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10246 else
10247 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010248
Jilai Wang53d27a82011-07-13 14:32:58 -040010249 /* Specify reset pin for OV9726 */
10250 if (machine_is_msm8x60_dragon()) {
10251 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10252 ov9726_sensor_8660_info.mount_angle = 270;
10253 }
10254
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010255#ifdef CONFIG_BATTERY_MSM8X60
10256 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10257 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10258 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10259 platform_device_register(&msm_charger_device);
10260#endif
10261
10262 if (machine_is_msm8x60_dragon())
10263 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10264 if (!machine_is_msm8x60_fluid())
10265 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10266
10267 /* configure pmic leds */
10268 if (machine_is_msm8x60_fluid())
10269 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10270 else if (machine_is_msm8x60_dragon())
10271 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10272 else
10273 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10274
10275 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10276 machine_is_msm8x60_dragon()) {
10277 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10278 }
10279
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010280 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10281 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010282 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010283 msm8x60_cfg_smsc911x();
10284 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10285 platform_add_devices(msm_footswitch_devices,
10286 msm_num_footswitch_devices);
10287 platform_add_devices(surf_devices,
10288 ARRAY_SIZE(surf_devices));
10289
10290#ifdef CONFIG_MSM_DSPS
10291 if (machine_is_msm8x60_fluid()) {
10292 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10293 msm8x60_init_dsps();
10294 }
10295#endif
10296
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010297 pm8901_vreg_mpp0_init();
10298
10299 platform_device_register(&msm8x60_8901_mpp_vreg);
10300
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010301#ifdef CONFIG_USB_EHCI_MSM_72K
10302 /*
10303 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10304 * fluid
10305 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010306 if (machine_is_msm8x60_fluid())
10307 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10308 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010309#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010310
10311#ifdef CONFIG_SND_SOC_MSM8660_APQ
10312 if (machine_is_msm8x60_dragon())
10313 platform_add_devices(dragon_alsa_devices,
10314 ARRAY_SIZE(dragon_alsa_devices));
10315 else
10316#endif
10317 platform_add_devices(asoc_devices,
10318 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010319 } else {
10320 msm8x60_configure_smc91x();
10321 platform_add_devices(rumi_sim_devices,
10322 ARRAY_SIZE(rumi_sim_devices));
10323 }
10324#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010325 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10326 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010327 msm8x60_cfg_isp1763();
10328#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010329
10330 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10331 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10332
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010333
10334#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10335 if (machine_is_msm8x60_fluid())
10336 platform_device_register(&msm_gsbi10_qup_spi_device);
10337 else
10338 platform_device_register(&msm_gsbi1_qup_spi_device);
10339#endif
10340
10341#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10342 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10343 if (machine_is_msm8x60_fluid())
10344 cyttsp_set_params();
10345#endif
10346 if (!machine_is_msm8x60_sim())
10347 msm_fb_add_devices();
10348 fixup_i2c_configs();
10349 register_i2c_devices();
10350
Terence Hampson1c73fef2011-07-19 17:10:49 -040010351 if (machine_is_msm8x60_dragon())
10352 smsc911x_config.reset_gpio
10353 = GPIO_ETHERNET_RESET_N_DRAGON;
10354
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010355 platform_device_register(&smsc911x_device);
10356
10357#if (defined(CONFIG_SPI_QUP)) && \
10358 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010359 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10360 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010361
10362 if (machine_is_msm8x60_fluid()) {
10363#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10364 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10365 spi_register_board_info(lcdc_samsung_spi_board_info,
10366 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10367 } else
10368#endif
10369 {
10370#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10371 spi_register_board_info(lcdc_auo_spi_board_info,
10372 ARRAY_SIZE(lcdc_auo_spi_board_info));
10373#endif
10374 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010375#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10376 } else if (machine_is_msm8x60_dragon()) {
10377 spi_register_board_info(lcdc_nt35582_spi_board_info,
10378 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10379#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010380 }
10381#endif
10382
10383 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
10384 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
10385 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
10386 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010387 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010388
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010389 pm8058_gpios_init();
10390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010391#ifdef CONFIG_SENSORS_MSM_ADC
10392 if (machine_is_msm8x60_fluid()) {
10393 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10394 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10395 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10396 msm_adc_pdata.gpio_config = APROC_CONFIG;
10397 else
10398 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10399 }
10400 msm_adc_pdata.target_hw = MSM_8x60;
10401#endif
10402#ifdef CONFIG_MSM8X60_AUDIO
10403 msm_snddev_init();
10404#endif
10405#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10406 if (machine_is_msm8x60_fluid())
10407 platform_device_register(&fluid_leds_gpio);
10408 else
10409 platform_device_register(&gpio_leds);
10410#endif
10411
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010412 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010413
10414 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10415 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010416}
10417
10418static void __init msm8x60_rumi3_init(void)
10419{
10420 msm8x60_init(&msm8x60_rumi3_board_data);
10421}
10422
10423static void __init msm8x60_sim_init(void)
10424{
10425 msm8x60_init(&msm8x60_sim_board_data);
10426}
10427
10428static void __init msm8x60_surf_init(void)
10429{
10430 msm8x60_init(&msm8x60_surf_board_data);
10431}
10432
10433static void __init msm8x60_ffa_init(void)
10434{
10435 msm8x60_init(&msm8x60_ffa_board_data);
10436}
10437
10438static void __init msm8x60_fluid_init(void)
10439{
10440 msm8x60_init(&msm8x60_fluid_board_data);
10441}
10442
10443static void __init msm8x60_charm_surf_init(void)
10444{
10445 msm8x60_init(&msm8x60_charm_surf_board_data);
10446}
10447
10448static void __init msm8x60_charm_ffa_init(void)
10449{
10450 msm8x60_init(&msm8x60_charm_ffa_board_data);
10451}
10452
10453static void __init msm8x60_charm_init_early(void)
10454{
10455 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010456}
10457
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010458static void __init msm8x60_dragon_init(void)
10459{
10460 msm8x60_init(&msm8x60_dragon_board_data);
10461}
10462
Steve Mucklea55df6e2010-01-07 12:43:24 -080010463MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10464 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010465 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010466 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010467 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010468 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010469 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010470 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010471MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010472
10473MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10474 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010475 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010476 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010477 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010478 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010479 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010480 .init_early = msm8x60_charm_init_early,
10481MACHINE_END
10482
10483MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10484 .map_io = msm8x60_map_io,
10485 .reserve = msm8x60_reserve,
10486 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010487 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010488 .init_machine = msm8x60_surf_init,
10489 .timer = &msm_timer,
10490 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010491MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010492
10493MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10494 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010495 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010496 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010497 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010498 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010499 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010500 .init_early = msm8x60_charm_init_early,
10501MACHINE_END
10502
10503MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10504 .map_io = msm8x60_map_io,
10505 .reserve = msm8x60_reserve,
10506 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010507 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010508 .init_machine = msm8x60_fluid_init,
10509 .timer = &msm_timer,
10510 .init_early = msm8x60_charm_init_early,
10511MACHINE_END
10512
10513MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10514 .map_io = msm8x60_map_io,
10515 .reserve = msm8x60_reserve,
10516 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010517 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010518 .init_machine = msm8x60_charm_surf_init,
10519 .timer = &msm_timer,
10520 .init_early = msm8x60_charm_init_early,
10521MACHINE_END
10522
10523MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10524 .map_io = msm8x60_map_io,
10525 .reserve = msm8x60_reserve,
10526 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010527 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010528 .init_machine = msm8x60_charm_ffa_init,
10529 .timer = &msm_timer,
10530 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010531MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010532
10533MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10534 .map_io = msm8x60_map_io,
10535 .reserve = msm8x60_reserve,
10536 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010537 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010538 .init_machine = msm8x60_dragon_init,
10539 .timer = &msm_timer,
10540 .init_early = msm8x60_charm_init_early,
10541MACHINE_END