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