blob: 477b17dbbdd505725f231cbc350ea612cfa1388a [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"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053093#include <mach/mpm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094#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,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700436 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700437 },
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,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700447 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700448 },
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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
803 {
804 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
805 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
806 true,
807 1, 8000, 100000, 1,
808 },
809
810 {
811 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
812 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
813 true,
814 1500, 5000, 60100000, 3000,
815 },
816
817 {
818 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
819 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
820 false,
821 1800, 5000, 60350000, 3500,
822 },
823 {
824 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
825 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
826 false,
827 3800, 4500, 65350000, 5500,
828 },
829
830 {
831 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
832 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
833 false,
834 2800, 2500, 66850000, 4800,
835 },
836
837 {
838 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
839 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
840 false,
841 4800, 2000, 71850000, 6800,
842 },
843
844 {
845 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
846 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
847 false,
848 6800, 500, 75850000, 8800,
849 },
850
851 {
852 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
853 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
854 false,
855 7800, 0, 76350000, 9800,
856 },
857};
858
Praveen Chidambaram78499012011-11-01 17:15:17 -0600859static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
860 .levels = &msm_rpmrs_levels[0],
861 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
862 .vdd_mem_levels = {
863 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
864 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
865 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700866 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600867 },
868 .vdd_dig_levels = {
869 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
870 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
871 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
872 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
873 },
874 .vdd_mask = 0xFFF,
875 .rpmrs_target_id = {
876 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
877 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
878 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
879 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
880 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
881 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
882 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
883 },
884};
885
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600886static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
887 .mode = MSM_PM_BOOT_CONFIG_TZ,
888};
889
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700890#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
891
892#define ISP1763_INT_GPIO 117
893#define ISP1763_RST_GPIO 152
894static struct resource isp1763_resources[] = {
895 [0] = {
896 .flags = IORESOURCE_MEM,
897 .start = 0x1D000000,
898 .end = 0x1D005FFF, /* 24KB */
899 },
900 [1] = {
901 .flags = IORESOURCE_IRQ,
902 },
903};
904static void __init msm8x60_cfg_isp1763(void)
905{
906 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
907 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
908}
909
910static int isp1763_setup_gpio(int enable)
911{
912 int status = 0;
913
914 if (enable) {
915 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
916 if (status) {
917 pr_err("%s:Failed to request GPIO %d\n",
918 __func__, ISP1763_INT_GPIO);
919 return status;
920 }
921 status = gpio_direction_input(ISP1763_INT_GPIO);
922 if (status) {
923 pr_err("%s:Failed to configure GPIO %d\n",
924 __func__, ISP1763_INT_GPIO);
925 goto gpio_free_int;
926 }
927 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
928 if (status) {
929 pr_err("%s:Failed to request GPIO %d\n",
930 __func__, ISP1763_RST_GPIO);
931 goto gpio_free_int;
932 }
933 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
934 if (status) {
935 pr_err("%s:Failed to configure GPIO %d\n",
936 __func__, ISP1763_RST_GPIO);
937 goto gpio_free_rst;
938 }
939 pr_debug("\nISP GPIO configuration done\n");
940 return status;
941 }
942
943gpio_free_rst:
944 gpio_free(ISP1763_RST_GPIO);
945gpio_free_int:
946 gpio_free(ISP1763_INT_GPIO);
947
948 return status;
949}
950static struct isp1763_platform_data isp1763_pdata = {
951 .reset_gpio = ISP1763_RST_GPIO,
952 .setup_gpio = isp1763_setup_gpio
953};
954
955static struct platform_device isp1763_device = {
956 .name = "isp1763_usb",
957 .num_resources = ARRAY_SIZE(isp1763_resources),
958 .resource = isp1763_resources,
959 .dev = {
960 .platform_data = &isp1763_pdata
961 }
962};
963#endif
964
Lena Salman57d167e2012-03-21 19:46:38 +0200965#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530966static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700967static struct regulator *ldo6_3p3;
968static struct regulator *ldo7_1p8;
969static struct regulator *vdd_cx;
970#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530971#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700972notify_vbus_state notify_vbus_state_func_ptr;
973static int usb_phy_susp_dig_vol = 750000;
974static int pmic_id_notif_supported;
975
976#ifdef CONFIG_USB_EHCI_MSM_72K
977#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
978struct delayed_work pmic_id_det;
979
980static int __init usb_id_pin_rework_setup(char *support)
981{
982 if (strncmp(support, "true", 4) == 0)
983 pmic_id_notif_supported = 1;
984
985 return 1;
986}
987__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
988
989static void pmic_id_detect(struct work_struct *w)
990{
991 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
992 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
993
994 if (notify_vbus_state_func_ptr)
995 (*notify_vbus_state_func_ptr) (val);
996}
997
998static irqreturn_t pmic_id_on_irq(int irq, void *data)
999{
1000 /*
1001 * Spurious interrupts are observed on pmic gpio line
1002 * even though there is no state change on USB ID. Schedule the
1003 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001004 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001005 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001006
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007 return IRQ_HANDLED;
1008}
1009
Anji jonnalaae745e92011-11-14 18:34:31 +05301010static int msm_hsusb_phy_id_setup_init(int init)
1011{
1012 unsigned ret;
1013
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301014 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1015 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1016 .level = PM8901_MPP_DIG_LEVEL_L5,
1017 };
1018
Anji jonnalaae745e92011-11-14 18:34:31 +05301019 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301020 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1021 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1022 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301023 if (ret < 0)
1024 pr_err("%s:MPP2 configuration failed\n", __func__);
1025 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301026 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1027 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1028 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301029 if (ret < 0)
1030 pr_err("%s:MPP2 un config failed\n", __func__);
1031 }
1032 return ret;
1033}
1034
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001035static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1036{
1037 unsigned ret = -ENODEV;
1038
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301039 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301040 .direction = PM_GPIO_DIR_IN,
1041 .pull = PM_GPIO_PULL_UP_1P5,
1042 .function = PM_GPIO_FUNC_NORMAL,
1043 .vin_sel = 2,
1044 .inv_int_pol = 0,
1045 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301046 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301047 .direction = PM_GPIO_DIR_IN,
1048 .pull = PM_GPIO_PULL_NO,
1049 .function = PM_GPIO_FUNC_NORMAL,
1050 .vin_sel = 2,
1051 .inv_int_pol = 0,
1052 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001053 if (!callback)
1054 return -EINVAL;
1055
1056 if (machine_is_msm8x60_fluid())
1057 return -ENOTSUPP;
1058
1059 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1060 pr_debug("%s: USB_ID pin is not routed to PMIC"
1061 "on V1 surf/ffa\n", __func__);
1062 return -ENOTSUPP;
1063 }
1064
Manu Gautam62158eb2011-11-24 16:20:46 +05301065 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1066 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001067 pr_debug("%s: USB_ID is not routed to PMIC"
1068 "on V2 ffa\n", __func__);
1069 return -ENOTSUPP;
1070 }
1071
1072 usb_phy_susp_dig_vol = 500000;
1073
1074 if (init) {
1075 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301076 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301077 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1078 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301079 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301080 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301081 __func__, ret);
1082 return ret;
1083 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001084 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1085 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1086 "msm_otg_id", NULL);
1087 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001088 pr_err("%s:pmic_usb_id interrupt registration failed",
1089 __func__);
1090 return ret;
1091 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301092 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001093 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301094 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001095 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301096 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1097 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301098 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301099 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301100 __func__, ret);
1101 return ret;
1102 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301103 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001104 cancel_delayed_work_sync(&pmic_id_det);
1105 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001106 }
1107 return 0;
1108}
1109#endif
1110
1111#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1112#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1113static int msm_hsusb_init_vddcx(int init)
1114{
1115 int ret = 0;
1116
1117 if (init) {
1118 vdd_cx = regulator_get(NULL, "8058_s1");
1119 if (IS_ERR(vdd_cx)) {
1120 return PTR_ERR(vdd_cx);
1121 }
1122
1123 ret = regulator_set_voltage(vdd_cx,
1124 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1125 USB_PHY_MAX_VDD_DIG_VOL);
1126 if (ret) {
1127 pr_err("%s: unable to set the voltage for regulator"
1128 "vdd_cx\n", __func__);
1129 regulator_put(vdd_cx);
1130 return ret;
1131 }
1132
1133 ret = regulator_enable(vdd_cx);
1134 if (ret) {
1135 pr_err("%s: unable to enable regulator"
1136 "vdd_cx\n", __func__);
1137 regulator_put(vdd_cx);
1138 }
1139 } else {
1140 ret = regulator_disable(vdd_cx);
1141 if (ret) {
1142 pr_err("%s: Unable to disable the regulator:"
1143 "vdd_cx\n", __func__);
1144 return ret;
1145 }
1146
1147 regulator_put(vdd_cx);
1148 }
1149
1150 return ret;
1151}
1152
1153static int msm_hsusb_config_vddcx(int high)
1154{
1155 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1156 int min_vol;
1157 int ret;
1158
1159 if (high)
1160 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1161 else
1162 min_vol = usb_phy_susp_dig_vol;
1163
1164 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1165 if (ret) {
1166 pr_err("%s: unable to set the voltage for regulator"
1167 "vdd_cx\n", __func__);
1168 return ret;
1169 }
1170
1171 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1172
1173 return ret;
1174}
1175
1176#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1177#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1178#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1179#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1180
1181#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1182#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1183#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1184#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1185static int msm_hsusb_ldo_init(int init)
1186{
1187 int rc = 0;
1188
1189 if (init) {
1190 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1191 if (IS_ERR(ldo6_3p3))
1192 return PTR_ERR(ldo6_3p3);
1193
1194 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1195 if (IS_ERR(ldo7_1p8)) {
1196 rc = PTR_ERR(ldo7_1p8);
1197 goto put_3p3;
1198 }
1199
1200 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1201 USB_PHY_3P3_VOL_MAX);
1202 if (rc) {
1203 pr_err("%s: Unable to set voltage level for"
1204 "ldo6_3p3 regulator\n", __func__);
1205 goto put_1p8;
1206 }
1207 rc = regulator_enable(ldo6_3p3);
1208 if (rc) {
1209 pr_err("%s: Unable to enable the regulator:"
1210 "ldo6_3p3\n", __func__);
1211 goto put_1p8;
1212 }
1213 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1214 USB_PHY_1P8_VOL_MAX);
1215 if (rc) {
1216 pr_err("%s: Unable to set voltage level for"
1217 "ldo7_1p8 regulator\n", __func__);
1218 goto disable_3p3;
1219 }
1220 rc = regulator_enable(ldo7_1p8);
1221 if (rc) {
1222 pr_err("%s: Unable to enable the regulator:"
1223 "ldo7_1p8\n", __func__);
1224 goto disable_3p3;
1225 }
1226
1227 return 0;
1228 }
1229
1230 regulator_disable(ldo7_1p8);
1231disable_3p3:
1232 regulator_disable(ldo6_3p3);
1233put_1p8:
1234 regulator_put(ldo7_1p8);
1235put_3p3:
1236 regulator_put(ldo6_3p3);
1237 return rc;
1238}
1239
1240static int msm_hsusb_ldo_enable(int on)
1241{
1242 int ret = 0;
1243
1244 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1245 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1246 return -ENODEV;
1247 }
1248
1249 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1250 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1251 return -ENODEV;
1252 }
1253
1254 if (on) {
1255 ret = regulator_set_optimum_mode(ldo7_1p8,
1256 USB_PHY_1P8_HPM_LOAD);
1257 if (ret < 0) {
1258 pr_err("%s: Unable to set HPM of the regulator:"
1259 "ldo7_1p8\n", __func__);
1260 return ret;
1261 }
1262 ret = regulator_set_optimum_mode(ldo6_3p3,
1263 USB_PHY_3P3_HPM_LOAD);
1264 if (ret < 0) {
1265 pr_err("%s: Unable to set HPM of the regulator:"
1266 "ldo6_3p3\n", __func__);
1267 regulator_set_optimum_mode(ldo7_1p8,
1268 USB_PHY_1P8_LPM_LOAD);
1269 return ret;
1270 }
1271 } else {
1272 ret = regulator_set_optimum_mode(ldo7_1p8,
1273 USB_PHY_1P8_LPM_LOAD);
1274 if (ret < 0)
1275 pr_err("%s: Unable to set LPM of the regulator:"
1276 "ldo7_1p8\n", __func__);
1277 ret = regulator_set_optimum_mode(ldo6_3p3,
1278 USB_PHY_3P3_LPM_LOAD);
1279 if (ret < 0)
1280 pr_err("%s: Unable to set LPM of the regulator:"
1281 "ldo6_3p3\n", __func__);
1282 }
1283
1284 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1285 return ret < 0 ? ret : 0;
1286 }
1287#endif
1288#ifdef CONFIG_USB_EHCI_MSM_72K
1289#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1290static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1291{
1292 static int vbus_is_on;
1293
1294 /* If VBUS is already on (or off), do nothing. */
1295 if (on == vbus_is_on)
1296 return;
1297 smb137b_otg_power(on);
1298 vbus_is_on = on;
1299}
1300#endif
1301static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1302{
1303 static struct regulator *votg_5v_switch;
1304 static struct regulator *ext_5v_reg;
1305 static int vbus_is_on;
1306
1307 /* If VBUS is already on (or off), do nothing. */
1308 if (on == vbus_is_on)
1309 return;
1310
1311 if (!votg_5v_switch) {
1312 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1313 if (IS_ERR(votg_5v_switch)) {
1314 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1315 return;
1316 }
1317 }
1318 if (!ext_5v_reg) {
1319 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1320 if (IS_ERR(ext_5v_reg)) {
1321 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1322 return;
1323 }
1324 }
1325 if (on) {
1326 if (regulator_enable(ext_5v_reg)) {
1327 pr_err("%s: Unable to enable the regulator:"
1328 " ext_5v_reg\n", __func__);
1329 return;
1330 }
1331 if (regulator_enable(votg_5v_switch)) {
1332 pr_err("%s: Unable to enable the regulator:"
1333 " votg_5v_switch\n", __func__);
1334 return;
1335 }
1336 } else {
1337 if (regulator_disable(votg_5v_switch))
1338 pr_err("%s: Unable to enable the regulator:"
1339 " votg_5v_switch\n", __func__);
1340 if (regulator_disable(ext_5v_reg))
1341 pr_err("%s: Unable to enable the regulator:"
1342 " ext_5v_reg\n", __func__);
1343 }
1344
1345 vbus_is_on = on;
1346}
1347
1348static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1349 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1350 .power_budget = 390,
1351};
1352#endif
1353
1354#ifdef CONFIG_BATTERY_MSM8X60
1355static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1356 int init)
1357{
1358 int ret = -ENOTSUPP;
1359
1360#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1361 if (machine_is_msm8x60_fluid()) {
1362 if (init)
1363 msm_charger_register_vbus_sn(callback);
1364 else
1365 msm_charger_unregister_vbus_sn(callback);
1366 return 0;
1367 }
1368#endif
1369 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1370 * hence, irrespective of either peripheral only mode or
1371 * OTG (host and peripheral) modes, can depend on pmic for
1372 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001373 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001374 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1375 && (machine_is_msm8x60_surf() ||
1376 pmic_id_notif_supported)) {
1377 if (init)
1378 ret = msm_charger_register_vbus_sn(callback);
1379 else {
1380 msm_charger_unregister_vbus_sn(callback);
1381 ret = 0;
1382 }
1383 } else {
1384#if !defined(CONFIG_USB_EHCI_MSM_72K)
1385 if (init)
1386 ret = msm_charger_register_vbus_sn(callback);
1387 else {
1388 msm_charger_unregister_vbus_sn(callback);
1389 ret = 0;
1390 }
1391#endif
1392 }
1393 return ret;
1394}
1395#endif
1396
Lena Salman57d167e2012-03-21 19:46:38 +02001397#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001398static struct msm_otg_platform_data msm_otg_pdata = {
1399 /* if usb link is in sps there is no need for
1400 * usb pclk as dayatona fabric clock will be
1401 * used instead
1402 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001403 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1404 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1405 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301406 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001407#ifdef CONFIG_USB_EHCI_MSM_72K
1408 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301409 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410#endif
1411#ifdef CONFIG_USB_EHCI_MSM_72K
1412 .vbus_power = msm_hsusb_vbus_power,
1413#endif
1414#ifdef CONFIG_BATTERY_MSM8X60
1415 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1416#endif
1417 .ldo_init = msm_hsusb_ldo_init,
1418 .ldo_enable = msm_hsusb_ldo_enable,
1419 .config_vddcx = msm_hsusb_config_vddcx,
1420 .init_vddcx = msm_hsusb_init_vddcx,
1421#ifdef CONFIG_BATTERY_MSM8X60
1422 .chg_vbus_draw = msm_charger_vbus_draw,
1423#endif
1424};
1425#endif
1426
Lena Salman57d167e2012-03-21 19:46:38 +02001427#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001428static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1429 .is_phy_status_timer_on = 1,
1430};
1431#endif
1432
1433#ifdef CONFIG_USB_G_ANDROID
1434
1435#define PID_MAGIC_ID 0x71432909
1436#define SERIAL_NUM_MAGIC_ID 0x61945374
1437#define SERIAL_NUMBER_LENGTH 127
1438#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1439
1440struct magic_num_struct {
1441 uint32_t pid;
1442 uint32_t serial_num;
1443};
1444
1445struct dload_struct {
1446 uint32_t reserved1;
1447 uint32_t reserved2;
1448 uint32_t reserved3;
1449 uint16_t reserved4;
1450 uint16_t pid;
1451 char serial_number[SERIAL_NUMBER_LENGTH];
1452 uint16_t reserved5;
1453 struct magic_num_struct
1454 magic_struct;
1455};
1456
1457static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1458{
1459 struct dload_struct __iomem *dload = 0;
1460
1461 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1462 if (!dload) {
1463 pr_err("%s: cannot remap I/O memory region: %08x\n",
1464 __func__, DLOAD_USB_BASE_ADD);
1465 return -ENXIO;
1466 }
1467
1468 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1469 __func__, dload, pid, snum);
1470 /* update pid */
1471 dload->magic_struct.pid = PID_MAGIC_ID;
1472 dload->pid = pid;
1473
1474 /* update serial number */
1475 dload->magic_struct.serial_num = 0;
1476 if (!snum)
1477 return 0;
1478
1479 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1480 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1481 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1482
1483 iounmap(dload);
1484
1485 return 0;
1486}
1487
1488static struct android_usb_platform_data android_usb_pdata = {
1489 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1490};
1491
1492static struct platform_device android_usb_device = {
1493 .name = "android_usb",
1494 .id = -1,
1495 .dev = {
1496 .platform_data = &android_usb_pdata,
1497 },
1498};
1499
1500
1501#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001502
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001503#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001504#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001505static struct resource msm_vpe_resources[] = {
1506 {
1507 .start = 0x05300000,
1508 .end = 0x05300000 + SZ_1M - 1,
1509 .flags = IORESOURCE_MEM,
1510 },
1511 {
1512 .start = INT_VPE,
1513 .end = INT_VPE,
1514 .flags = IORESOURCE_IRQ,
1515 },
1516};
1517
1518static struct platform_device msm_vpe_device = {
1519 .name = "msm_vpe",
1520 .id = 0,
1521 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1522 .resource = msm_vpe_resources,
1523};
1524#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001525#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001526
1527#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001528#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001529#ifdef CONFIG_MSM_CAMERA_FLASH
1530#define VFE_CAMIF_TIMER1_GPIO 29
1531#define VFE_CAMIF_TIMER2_GPIO 30
1532#define VFE_CAMIF_TIMER3_GPIO_INT 31
1533#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1534static struct msm_camera_sensor_flash_src msm_flash_src = {
1535 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1536 ._fsrc.pmic_src.num_of_src = 2,
1537 ._fsrc.pmic_src.low_current = 100,
1538 ._fsrc.pmic_src.high_current = 300,
1539 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1540 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1541 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1542};
1543#ifdef CONFIG_IMX074
1544static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1545 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1546 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1547 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1548 .flash_recharge_duration = 50000,
1549 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1550};
1551#endif
1552#endif
1553
1554int msm_cam_gpio_tbl[] = {
1555 32,/*CAMIF_MCLK*/
1556 47,/*CAMIF_I2C_DATA*/
1557 48,/*CAMIF_I2C_CLK*/
1558 105,/*STANDBY*/
1559};
1560
1561enum msm_cam_stat{
1562 MSM_CAM_OFF,
1563 MSM_CAM_ON,
1564};
1565
1566static int config_gpio_table(enum msm_cam_stat stat)
1567{
1568 int rc = 0, i = 0;
1569 if (stat == MSM_CAM_ON) {
1570 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1571 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1572 if (unlikely(rc < 0)) {
1573 pr_err("%s not able to get gpio\n", __func__);
1574 for (i--; i >= 0; i--)
1575 gpio_free(msm_cam_gpio_tbl[i]);
1576 break;
1577 }
1578 }
1579 } else {
1580 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1581 gpio_free(msm_cam_gpio_tbl[i]);
1582 }
1583 return rc;
1584}
1585
1586static struct msm_camera_sensor_platform_info sensor_board_info = {
1587 .mount_angle = 0
1588};
1589
1590/*external regulator VREG_5V*/
1591static struct regulator *reg_flash_5V;
1592
1593static int config_camera_on_gpios_fluid(void)
1594{
1595 int rc = 0;
1596
1597 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1598 if (IS_ERR(reg_flash_5V)) {
1599 pr_err("'%s' regulator not found, rc=%ld\n",
1600 "8901_mpp0", IS_ERR(reg_flash_5V));
1601 return -ENODEV;
1602 }
1603
1604 rc = regulator_enable(reg_flash_5V);
1605 if (rc) {
1606 pr_err("'%s' regulator enable failed, rc=%d\n",
1607 "8901_mpp0", rc);
1608 regulator_put(reg_flash_5V);
1609 return rc;
1610 }
1611
1612#ifdef CONFIG_IMX074
1613 sensor_board_info.mount_angle = 90;
1614#endif
1615 rc = config_gpio_table(MSM_CAM_ON);
1616 if (rc < 0) {
1617 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1618 "failed\n", __func__);
1619 return rc;
1620 }
1621
1622 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1623 if (rc < 0) {
1624 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1625 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1626 regulator_disable(reg_flash_5V);
1627 regulator_put(reg_flash_5V);
1628 return rc;
1629 }
1630 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1631 msleep(20);
1632 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1633
1634
1635 /*Enable LED_FLASH_EN*/
1636 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1637 if (rc < 0) {
1638 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1639 "failed\n", __func__, GPIO_LED_FLASH_EN);
1640
1641 regulator_disable(reg_flash_5V);
1642 regulator_put(reg_flash_5V);
1643 config_gpio_table(MSM_CAM_OFF);
1644 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1645 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1646 return rc;
1647 }
1648 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1649 msleep(20);
1650 return rc;
1651}
1652
1653
1654static void config_camera_off_gpios_fluid(void)
1655{
1656 regulator_disable(reg_flash_5V);
1657 regulator_put(reg_flash_5V);
1658
1659 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1660 gpio_free(GPIO_LED_FLASH_EN);
1661
1662 config_gpio_table(MSM_CAM_OFF);
1663
1664 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1665 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1666}
1667static int config_camera_on_gpios(void)
1668{
1669 int rc = 0;
1670
1671 if (machine_is_msm8x60_fluid())
1672 return config_camera_on_gpios_fluid();
1673
1674 rc = config_gpio_table(MSM_CAM_ON);
1675 if (rc < 0) {
1676 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1677 "failed\n", __func__);
1678 return rc;
1679 }
1680
Jilai Wang971f97f2011-07-13 14:25:25 -04001681 if (!machine_is_msm8x60_dragon()) {
1682 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1683 if (rc < 0) {
1684 config_gpio_table(MSM_CAM_OFF);
1685 pr_err("%s: CAMSENSOR gpio %d request"
1686 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1687 return rc;
1688 }
1689 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1690 msleep(20);
1691 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001692 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001693
1694#ifdef CONFIG_MSM_CAMERA_FLASH
1695#ifdef CONFIG_IMX074
1696 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1697 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1698#endif
1699#endif
1700 return rc;
1701}
1702
1703static void config_camera_off_gpios(void)
1704{
1705 if (machine_is_msm8x60_fluid())
1706 return config_camera_off_gpios_fluid();
1707
1708
1709 config_gpio_table(MSM_CAM_OFF);
1710
Jilai Wang971f97f2011-07-13 14:25:25 -04001711 if (!machine_is_msm8x60_dragon()) {
1712 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1713 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1714 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001715}
1716
1717#ifdef CONFIG_QS_S5K4E1
1718
1719#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1720
1721static int config_camera_on_gpios_qs_cam_fluid(void)
1722{
1723 int rc = 0;
1724
1725 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1726 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1727 if (rc < 0) {
1728 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1729 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1730 return rc;
1731 }
1732 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1733 msleep(20);
1734 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1735 msleep(20);
1736
1737 /*
1738 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1739 * to enable 2.7V power to Camera
1740 */
1741 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1742 if (rc < 0) {
1743 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1744 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1745 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1746 gpio_free(QS_CAM_HC37_CAM_PD);
1747 return rc;
1748 }
1749 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1750 msleep(20);
1751 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1752 msleep(20);
1753
1754 rc = config_camera_on_gpios_fluid();
1755 if (rc < 0) {
1756 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1757 " failed\n", __func__);
1758 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1759 gpio_free(QS_CAM_HC37_CAM_PD);
1760 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1761 gpio_free(GPIO_AUX_CAM_2P7_EN);
1762 return rc;
1763 }
1764 return rc;
1765}
1766
1767static void config_camera_off_gpios_qs_cam_fluid(void)
1768{
1769 /*
1770 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1771 * to disable 2.7V power to Camera
1772 */
1773 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1774 gpio_free(GPIO_AUX_CAM_2P7_EN);
1775
1776 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1777 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1778 gpio_free(QS_CAM_HC37_CAM_PD);
1779
1780 config_camera_off_gpios_fluid();
1781 return;
1782}
1783
1784static int config_camera_on_gpios_qs_cam(void)
1785{
1786 int rc = 0;
1787
1788 if (machine_is_msm8x60_fluid())
1789 return config_camera_on_gpios_qs_cam_fluid();
1790
1791 rc = config_camera_on_gpios();
1792 return rc;
1793}
1794
1795static void config_camera_off_gpios_qs_cam(void)
1796{
1797 if (machine_is_msm8x60_fluid())
1798 return config_camera_off_gpios_qs_cam_fluid();
1799
1800 config_camera_off_gpios();
1801 return;
1802}
1803#endif
1804
1805static int config_camera_on_gpios_web_cam(void)
1806{
1807 int rc = 0;
1808 rc = config_gpio_table(MSM_CAM_ON);
1809 if (rc < 0) {
1810 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1811 "failed\n", __func__);
1812 return rc;
1813 }
1814
Jilai Wang53d27a82011-07-13 14:32:58 -04001815 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001816 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1817 if (rc < 0) {
1818 config_gpio_table(MSM_CAM_OFF);
1819 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1820 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1821 return rc;
1822 }
1823 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1824 }
1825 return rc;
1826}
1827
1828static void config_camera_off_gpios_web_cam(void)
1829{
1830 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001831 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001832 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1833 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1834 }
1835 return;
1836}
1837
1838#ifdef CONFIG_MSM_BUS_SCALING
1839static struct msm_bus_vectors cam_init_vectors[] = {
1840 {
1841 .src = MSM_BUS_MASTER_VFE,
1842 .dst = MSM_BUS_SLAVE_SMI,
1843 .ab = 0,
1844 .ib = 0,
1845 },
1846 {
1847 .src = MSM_BUS_MASTER_VFE,
1848 .dst = MSM_BUS_SLAVE_EBI_CH0,
1849 .ab = 0,
1850 .ib = 0,
1851 },
1852 {
1853 .src = MSM_BUS_MASTER_VPE,
1854 .dst = MSM_BUS_SLAVE_SMI,
1855 .ab = 0,
1856 .ib = 0,
1857 },
1858 {
1859 .src = MSM_BUS_MASTER_VPE,
1860 .dst = MSM_BUS_SLAVE_EBI_CH0,
1861 .ab = 0,
1862 .ib = 0,
1863 },
1864 {
1865 .src = MSM_BUS_MASTER_JPEG_ENC,
1866 .dst = MSM_BUS_SLAVE_SMI,
1867 .ab = 0,
1868 .ib = 0,
1869 },
1870 {
1871 .src = MSM_BUS_MASTER_JPEG_ENC,
1872 .dst = MSM_BUS_SLAVE_EBI_CH0,
1873 .ab = 0,
1874 .ib = 0,
1875 },
1876};
1877
1878static struct msm_bus_vectors cam_preview_vectors[] = {
1879 {
1880 .src = MSM_BUS_MASTER_VFE,
1881 .dst = MSM_BUS_SLAVE_SMI,
1882 .ab = 0,
1883 .ib = 0,
1884 },
1885 {
1886 .src = MSM_BUS_MASTER_VFE,
1887 .dst = MSM_BUS_SLAVE_EBI_CH0,
1888 .ab = 283115520,
1889 .ib = 452984832,
1890 },
1891 {
1892 .src = MSM_BUS_MASTER_VPE,
1893 .dst = MSM_BUS_SLAVE_SMI,
1894 .ab = 0,
1895 .ib = 0,
1896 },
1897 {
1898 .src = MSM_BUS_MASTER_VPE,
1899 .dst = MSM_BUS_SLAVE_EBI_CH0,
1900 .ab = 0,
1901 .ib = 0,
1902 },
1903 {
1904 .src = MSM_BUS_MASTER_JPEG_ENC,
1905 .dst = MSM_BUS_SLAVE_SMI,
1906 .ab = 0,
1907 .ib = 0,
1908 },
1909 {
1910 .src = MSM_BUS_MASTER_JPEG_ENC,
1911 .dst = MSM_BUS_SLAVE_EBI_CH0,
1912 .ab = 0,
1913 .ib = 0,
1914 },
1915};
1916
1917static struct msm_bus_vectors cam_video_vectors[] = {
1918 {
1919 .src = MSM_BUS_MASTER_VFE,
1920 .dst = MSM_BUS_SLAVE_SMI,
1921 .ab = 283115520,
1922 .ib = 452984832,
1923 },
1924 {
1925 .src = MSM_BUS_MASTER_VFE,
1926 .dst = MSM_BUS_SLAVE_EBI_CH0,
1927 .ab = 283115520,
1928 .ib = 452984832,
1929 },
1930 {
1931 .src = MSM_BUS_MASTER_VPE,
1932 .dst = MSM_BUS_SLAVE_SMI,
1933 .ab = 319610880,
1934 .ib = 511377408,
1935 },
1936 {
1937 .src = MSM_BUS_MASTER_VPE,
1938 .dst = MSM_BUS_SLAVE_EBI_CH0,
1939 .ab = 0,
1940 .ib = 0,
1941 },
1942 {
1943 .src = MSM_BUS_MASTER_JPEG_ENC,
1944 .dst = MSM_BUS_SLAVE_SMI,
1945 .ab = 0,
1946 .ib = 0,
1947 },
1948 {
1949 .src = MSM_BUS_MASTER_JPEG_ENC,
1950 .dst = MSM_BUS_SLAVE_EBI_CH0,
1951 .ab = 0,
1952 .ib = 0,
1953 },
1954};
1955
1956static struct msm_bus_vectors cam_snapshot_vectors[] = {
1957 {
1958 .src = MSM_BUS_MASTER_VFE,
1959 .dst = MSM_BUS_SLAVE_SMI,
1960 .ab = 566231040,
1961 .ib = 905969664,
1962 },
1963 {
1964 .src = MSM_BUS_MASTER_VFE,
1965 .dst = MSM_BUS_SLAVE_EBI_CH0,
1966 .ab = 69984000,
1967 .ib = 111974400,
1968 },
1969 {
1970 .src = MSM_BUS_MASTER_VPE,
1971 .dst = MSM_BUS_SLAVE_SMI,
1972 .ab = 0,
1973 .ib = 0,
1974 },
1975 {
1976 .src = MSM_BUS_MASTER_VPE,
1977 .dst = MSM_BUS_SLAVE_EBI_CH0,
1978 .ab = 0,
1979 .ib = 0,
1980 },
1981 {
1982 .src = MSM_BUS_MASTER_JPEG_ENC,
1983 .dst = MSM_BUS_SLAVE_SMI,
1984 .ab = 320864256,
1985 .ib = 513382810,
1986 },
1987 {
1988 .src = MSM_BUS_MASTER_JPEG_ENC,
1989 .dst = MSM_BUS_SLAVE_EBI_CH0,
1990 .ab = 320864256,
1991 .ib = 513382810,
1992 },
1993};
1994
1995static struct msm_bus_vectors cam_zsl_vectors[] = {
1996 {
1997 .src = MSM_BUS_MASTER_VFE,
1998 .dst = MSM_BUS_SLAVE_SMI,
1999 .ab = 566231040,
2000 .ib = 905969664,
2001 },
2002 {
2003 .src = MSM_BUS_MASTER_VFE,
2004 .dst = MSM_BUS_SLAVE_EBI_CH0,
2005 .ab = 706199040,
2006 .ib = 1129918464,
2007 },
2008 {
2009 .src = MSM_BUS_MASTER_VPE,
2010 .dst = MSM_BUS_SLAVE_SMI,
2011 .ab = 0,
2012 .ib = 0,
2013 },
2014 {
2015 .src = MSM_BUS_MASTER_VPE,
2016 .dst = MSM_BUS_SLAVE_EBI_CH0,
2017 .ab = 0,
2018 .ib = 0,
2019 },
2020 {
2021 .src = MSM_BUS_MASTER_JPEG_ENC,
2022 .dst = MSM_BUS_SLAVE_SMI,
2023 .ab = 320864256,
2024 .ib = 513382810,
2025 },
2026 {
2027 .src = MSM_BUS_MASTER_JPEG_ENC,
2028 .dst = MSM_BUS_SLAVE_EBI_CH0,
2029 .ab = 320864256,
2030 .ib = 513382810,
2031 },
2032};
2033
2034static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2035 {
2036 .src = MSM_BUS_MASTER_VFE,
2037 .dst = MSM_BUS_SLAVE_SMI,
2038 .ab = 212336640,
2039 .ib = 339738624,
2040 },
2041 {
2042 .src = MSM_BUS_MASTER_VFE,
2043 .dst = MSM_BUS_SLAVE_EBI_CH0,
2044 .ab = 25090560,
2045 .ib = 40144896,
2046 },
2047 {
2048 .src = MSM_BUS_MASTER_VPE,
2049 .dst = MSM_BUS_SLAVE_SMI,
2050 .ab = 239708160,
2051 .ib = 383533056,
2052 },
2053 {
2054 .src = MSM_BUS_MASTER_VPE,
2055 .dst = MSM_BUS_SLAVE_EBI_CH0,
2056 .ab = 79902720,
2057 .ib = 127844352,
2058 },
2059 {
2060 .src = MSM_BUS_MASTER_JPEG_ENC,
2061 .dst = MSM_BUS_SLAVE_SMI,
2062 .ab = 0,
2063 .ib = 0,
2064 },
2065 {
2066 .src = MSM_BUS_MASTER_JPEG_ENC,
2067 .dst = MSM_BUS_SLAVE_EBI_CH0,
2068 .ab = 0,
2069 .ib = 0,
2070 },
2071};
2072
2073static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2074 {
2075 .src = MSM_BUS_MASTER_VFE,
2076 .dst = MSM_BUS_SLAVE_SMI,
2077 .ab = 0,
2078 .ib = 0,
2079 },
2080 {
2081 .src = MSM_BUS_MASTER_VFE,
2082 .dst = MSM_BUS_SLAVE_EBI_CH0,
2083 .ab = 300902400,
2084 .ib = 481443840,
2085 },
2086 {
2087 .src = MSM_BUS_MASTER_VPE,
2088 .dst = MSM_BUS_SLAVE_SMI,
2089 .ab = 230307840,
2090 .ib = 368492544,
2091 },
2092 {
2093 .src = MSM_BUS_MASTER_VPE,
2094 .dst = MSM_BUS_SLAVE_EBI_CH0,
2095 .ab = 245113344,
2096 .ib = 392181351,
2097 },
2098 {
2099 .src = MSM_BUS_MASTER_JPEG_ENC,
2100 .dst = MSM_BUS_SLAVE_SMI,
2101 .ab = 106536960,
2102 .ib = 170459136,
2103 },
2104 {
2105 .src = MSM_BUS_MASTER_JPEG_ENC,
2106 .dst = MSM_BUS_SLAVE_EBI_CH0,
2107 .ab = 106536960,
2108 .ib = 170459136,
2109 },
2110};
2111
2112static struct msm_bus_paths cam_bus_client_config[] = {
2113 {
2114 ARRAY_SIZE(cam_init_vectors),
2115 cam_init_vectors,
2116 },
2117 {
2118 ARRAY_SIZE(cam_preview_vectors),
2119 cam_preview_vectors,
2120 },
2121 {
2122 ARRAY_SIZE(cam_video_vectors),
2123 cam_video_vectors,
2124 },
2125 {
2126 ARRAY_SIZE(cam_snapshot_vectors),
2127 cam_snapshot_vectors,
2128 },
2129 {
2130 ARRAY_SIZE(cam_zsl_vectors),
2131 cam_zsl_vectors,
2132 },
2133 {
2134 ARRAY_SIZE(cam_stereo_video_vectors),
2135 cam_stereo_video_vectors,
2136 },
2137 {
2138 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2139 cam_stereo_snapshot_vectors,
2140 },
2141};
2142
2143static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2144 cam_bus_client_config,
2145 ARRAY_SIZE(cam_bus_client_config),
2146 .name = "msm_camera",
2147};
2148#endif
2149
2150struct msm_camera_device_platform_data msm_camera_device_data = {
2151 .camera_gpio_on = config_camera_on_gpios,
2152 .camera_gpio_off = config_camera_off_gpios,
2153 .ioext.csiphy = 0x04800000,
2154 .ioext.csisz = 0x00000400,
2155 .ioext.csiirq = CSI_0_IRQ,
2156 .ioclk.mclk_clk_rate = 24000000,
2157 .ioclk.vfe_clk_rate = 228570000,
2158#ifdef CONFIG_MSM_BUS_SCALING
2159 .cam_bus_scale_table = &cam_bus_client_pdata,
2160#endif
2161};
2162
2163#ifdef CONFIG_QS_S5K4E1
2164struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2165 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2166 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2167 .ioext.csiphy = 0x04800000,
2168 .ioext.csisz = 0x00000400,
2169 .ioext.csiirq = CSI_0_IRQ,
2170 .ioclk.mclk_clk_rate = 24000000,
2171 .ioclk.vfe_clk_rate = 228570000,
2172#ifdef CONFIG_MSM_BUS_SCALING
2173 .cam_bus_scale_table = &cam_bus_client_pdata,
2174#endif
2175};
2176#endif
2177
2178struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2179 .camera_gpio_on = config_camera_on_gpios_web_cam,
2180 .camera_gpio_off = config_camera_off_gpios_web_cam,
2181 .ioext.csiphy = 0x04900000,
2182 .ioext.csisz = 0x00000400,
2183 .ioext.csiirq = CSI_1_IRQ,
2184 .ioclk.mclk_clk_rate = 24000000,
2185 .ioclk.vfe_clk_rate = 228570000,
2186#ifdef CONFIG_MSM_BUS_SCALING
2187 .cam_bus_scale_table = &cam_bus_client_pdata,
2188#endif
2189};
2190
2191struct resource msm_camera_resources[] = {
2192 {
2193 .start = 0x04500000,
2194 .end = 0x04500000 + SZ_1M - 1,
2195 .flags = IORESOURCE_MEM,
2196 },
2197 {
2198 .start = VFE_IRQ,
2199 .end = VFE_IRQ,
2200 .flags = IORESOURCE_IRQ,
2201 },
2202};
2203#ifdef CONFIG_MT9E013
2204static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2205 .mount_angle = 0
2206};
2207
2208static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2209 .flash_type = MSM_CAMERA_FLASH_LED,
2210 .flash_src = &msm_flash_src
2211};
2212
2213static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2214 .sensor_name = "mt9e013",
2215 .sensor_reset = 106,
2216 .sensor_pwd = 85,
2217 .vcm_pwd = 1,
2218 .vcm_enable = 0,
2219 .pdata = &msm_camera_device_data,
2220 .resource = msm_camera_resources,
2221 .num_resources = ARRAY_SIZE(msm_camera_resources),
2222 .flash_data = &flash_mt9e013,
2223 .strobe_flash_data = &strobe_flash_xenon,
2224 .sensor_platform_info = &mt9e013_sensor_8660_info,
2225 .csi_if = 1
2226};
2227struct platform_device msm_camera_sensor_mt9e013 = {
2228 .name = "msm_camera_mt9e013",
2229 .dev = {
2230 .platform_data = &msm_camera_sensor_mt9e013_data,
2231 },
2232};
2233#endif
2234
2235#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302236static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2237 .mount_angle = 180
2238};
2239
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002240static struct msm_camera_sensor_flash_data flash_imx074 = {
2241 .flash_type = MSM_CAMERA_FLASH_LED,
2242 .flash_src = &msm_flash_src
2243};
2244
2245static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2246 .sensor_name = "imx074",
2247 .sensor_reset = 106,
2248 .sensor_pwd = 85,
2249 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2250 .vcm_enable = 1,
2251 .pdata = &msm_camera_device_data,
2252 .resource = msm_camera_resources,
2253 .num_resources = ARRAY_SIZE(msm_camera_resources),
2254 .flash_data = &flash_imx074,
2255 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302256 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002257 .csi_if = 1
2258};
2259struct platform_device msm_camera_sensor_imx074 = {
2260 .name = "msm_camera_imx074",
2261 .dev = {
2262 .platform_data = &msm_camera_sensor_imx074_data,
2263 },
2264};
2265#endif
2266#ifdef CONFIG_WEBCAM_OV9726
2267
2268static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2269 .mount_angle = 0
2270};
2271
2272static struct msm_camera_sensor_flash_data flash_ov9726 = {
2273 .flash_type = MSM_CAMERA_FLASH_LED,
2274 .flash_src = &msm_flash_src
2275};
2276static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2277 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002278 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002279 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2280 .sensor_pwd = 85,
2281 .vcm_pwd = 1,
2282 .vcm_enable = 0,
2283 .pdata = &msm_camera_device_data_web_cam,
2284 .resource = msm_camera_resources,
2285 .num_resources = ARRAY_SIZE(msm_camera_resources),
2286 .flash_data = &flash_ov9726,
2287 .sensor_platform_info = &ov9726_sensor_8660_info,
2288 .csi_if = 1
2289};
2290struct platform_device msm_camera_sensor_webcam_ov9726 = {
2291 .name = "msm_camera_ov9726",
2292 .dev = {
2293 .platform_data = &msm_camera_sensor_ov9726_data,
2294 },
2295};
2296#endif
2297#ifdef CONFIG_WEBCAM_OV7692
2298static struct msm_camera_sensor_flash_data flash_ov7692 = {
2299 .flash_type = MSM_CAMERA_FLASH_LED,
2300 .flash_src = &msm_flash_src
2301};
2302static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2303 .sensor_name = "ov7692",
2304 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2305 .sensor_pwd = 85,
2306 .vcm_pwd = 1,
2307 .vcm_enable = 0,
2308 .pdata = &msm_camera_device_data_web_cam,
2309 .resource = msm_camera_resources,
2310 .num_resources = ARRAY_SIZE(msm_camera_resources),
2311 .flash_data = &flash_ov7692,
2312 .csi_if = 1
2313};
2314
2315static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2316 .name = "msm_camera_ov7692",
2317 .dev = {
2318 .platform_data = &msm_camera_sensor_ov7692_data,
2319 },
2320};
2321#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002322#ifdef CONFIG_VX6953
2323static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2324 .mount_angle = 270
2325};
2326
2327static struct msm_camera_sensor_flash_data flash_vx6953 = {
2328 .flash_type = MSM_CAMERA_FLASH_NONE,
2329 .flash_src = &msm_flash_src
2330};
2331
2332static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2333 .sensor_name = "vx6953",
2334 .sensor_reset = 63,
2335 .sensor_pwd = 63,
2336 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2337 .vcm_enable = 1,
2338 .pdata = &msm_camera_device_data,
2339 .resource = msm_camera_resources,
2340 .num_resources = ARRAY_SIZE(msm_camera_resources),
2341 .flash_data = &flash_vx6953,
2342 .sensor_platform_info = &vx6953_sensor_8660_info,
2343 .csi_if = 1
2344};
2345struct platform_device msm_camera_sensor_vx6953 = {
2346 .name = "msm_camera_vx6953",
2347 .dev = {
2348 .platform_data = &msm_camera_sensor_vx6953_data,
2349 },
2350};
2351#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002352#ifdef CONFIG_QS_S5K4E1
2353
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302354static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2355#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2356 .mount_angle = 90
2357#else
2358 .mount_angle = 0
2359#endif
2360};
2361
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002362static char eeprom_data[864];
2363static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2364 .flash_type = MSM_CAMERA_FLASH_LED,
2365 .flash_src = &msm_flash_src
2366};
2367
2368static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2369 .sensor_name = "qs_s5k4e1",
2370 .sensor_reset = 106,
2371 .sensor_pwd = 85,
2372 .vcm_pwd = 1,
2373 .vcm_enable = 0,
2374 .pdata = &msm_camera_device_data_qs_cam,
2375 .resource = msm_camera_resources,
2376 .num_resources = ARRAY_SIZE(msm_camera_resources),
2377 .flash_data = &flash_qs_s5k4e1,
2378 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302379 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002380 .csi_if = 1,
2381 .eeprom_data = eeprom_data,
2382};
2383struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2384 .name = "msm_camera_qs_s5k4e1",
2385 .dev = {
2386 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2387 },
2388};
2389#endif
2390static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2391 #ifdef CONFIG_MT9E013
2392 {
2393 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2394 },
2395 #endif
2396 #ifdef CONFIG_IMX074
2397 {
2398 I2C_BOARD_INFO("imx074", 0x1A),
2399 },
2400 #endif
2401 #ifdef CONFIG_WEBCAM_OV7692
2402 {
2403 I2C_BOARD_INFO("ov7692", 0x78),
2404 },
2405 #endif
2406 #ifdef CONFIG_WEBCAM_OV9726
2407 {
2408 I2C_BOARD_INFO("ov9726", 0x10),
2409 },
2410 #endif
2411 #ifdef CONFIG_QS_S5K4E1
2412 {
2413 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2414 },
2415 #endif
2416};
Jilai Wang971f97f2011-07-13 14:25:25 -04002417
2418static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002419 #ifdef CONFIG_WEBCAM_OV9726
2420 {
2421 I2C_BOARD_INFO("ov9726", 0x10),
2422 },
2423 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002424 #ifdef CONFIG_VX6953
2425 {
2426 I2C_BOARD_INFO("vx6953", 0x20),
2427 },
2428 #endif
2429};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002430#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002431#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002432
2433#ifdef CONFIG_MSM_GEMINI
2434static struct resource msm_gemini_resources[] = {
2435 {
2436 .start = 0x04600000,
2437 .end = 0x04600000 + SZ_1M - 1,
2438 .flags = IORESOURCE_MEM,
2439 },
2440 {
2441 .start = INT_JPEG,
2442 .end = INT_JPEG,
2443 .flags = IORESOURCE_IRQ,
2444 },
2445};
2446
2447static struct platform_device msm_gemini_device = {
2448 .name = "msm_gemini",
2449 .resource = msm_gemini_resources,
2450 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2451};
2452#endif
2453
2454#ifdef CONFIG_I2C_QUP
2455static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2456{
2457}
2458
2459static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2460 .clk_freq = 384000,
2461 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002462 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2463};
2464
2465static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2466 .clk_freq = 100000,
2467 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002468 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2469};
2470
2471static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2472 .clk_freq = 100000,
2473 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002474 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2475};
2476
2477static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2478 .clk_freq = 100000,
2479 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002480 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2481};
2482
2483static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2484 .clk_freq = 100000,
2485 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002486 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2487};
2488
2489static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2490 .clk_freq = 100000,
2491 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002492 .use_gsbi_shared_mode = 1,
2493 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2494};
2495#endif
2496
2497#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2498static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2499 .max_clock_speed = 24000000,
2500};
2501
2502static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2503 .max_clock_speed = 24000000,
2504};
2505#endif
2506
2507#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002508/* CODEC/TSSC SSBI */
2509static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2510 .controller_type = MSM_SBI_CTRL_SSBI,
2511};
2512#endif
2513
2514#ifdef CONFIG_BATTERY_MSM
2515/* Use basic value for fake MSM battery */
2516static struct msm_psy_batt_pdata msm_psy_batt_data = {
2517 .avail_chg_sources = AC_CHG,
2518};
2519
2520static struct platform_device msm_batt_device = {
2521 .name = "msm-battery",
2522 .id = -1,
2523 .dev.platform_data = &msm_psy_batt_data,
2524};
2525#endif
2526
2527#ifdef CONFIG_FB_MSM_LCDC_DSUB
2528/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2529 prim = 1024 x 600 x 4(bpp) x 2(pages)
2530 This is the difference. */
2531#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2532#else
2533#define MSM_FB_DSUB_PMEM_ADDER (0)
2534#endif
2535
2536/* Sensors DSPS platform data */
2537#ifdef CONFIG_MSM_DSPS
2538
2539static struct dsps_gpio_info dsps_surf_gpios[] = {
2540 {
2541 .name = "compass_rst_n",
2542 .num = GPIO_COMPASS_RST_N,
2543 .on_val = 1, /* device not in reset */
2544 .off_val = 0, /* device in reset */
2545 },
2546 {
2547 .name = "gpio_r_altimeter_reset_n",
2548 .num = GPIO_R_ALTIMETER_RESET_N,
2549 .on_val = 1, /* device not in reset */
2550 .off_val = 0, /* device in reset */
2551 }
2552};
2553
2554static struct dsps_gpio_info dsps_fluid_gpios[] = {
2555 {
2556 .name = "gpio_n_altimeter_reset_n",
2557 .num = GPIO_N_ALTIMETER_RESET_N,
2558 .on_val = 1, /* device not in reset */
2559 .off_val = 0, /* device in reset */
2560 }
2561};
2562
2563static void __init msm8x60_init_dsps(void)
2564{
2565 struct msm_dsps_platform_data *pdata =
2566 msm_dsps_device.dev.platform_data;
2567 /*
2568 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2569 * to the power supply and not controled via GPIOs. Fluid uses a
2570 * different IO-Expender (north) than used on surf/ffa.
2571 */
2572 if (machine_is_msm8x60_fluid()) {
2573 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002574 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002575 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002576 pdata->gpios = dsps_fluid_gpios;
2577 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2578 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002579 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002580 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002581 pdata->gpios = dsps_surf_gpios;
2582 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2583 }
2584
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002585 platform_device_register(&msm_dsps_device);
2586}
2587#endif /* CONFIG_MSM_DSPS */
2588
2589#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302590#define MSM_FB_PRIM_BUF_SIZE \
2591 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002592#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302593#define MSM_FB_PRIM_BUF_SIZE \
2594 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002595#endif
2596
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002597#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302598#define MSM_FB_EXT_BUF_SIZE \
2599 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002600#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302601#define MSM_FB_EXT_BUF_SIZE \
2602 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002603#else
2604#define MSM_FB_EXT_BUFT_SIZE 0
2605#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002606
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002607/* Note: must be multiple of 4096 */
2608#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002609 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002610
2611#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302612#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002613
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002614#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002615unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002616#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002617unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002618#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002619
Huaibin Yanga5419422011-12-08 23:52:10 -08002620#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2621#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2622#else
2623#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2624#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2625
2626#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2627#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2628#else
2629#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2630#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2631
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302632#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002633#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302634#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002635
2636#define MSM_SMI_BASE 0x38000000
2637#define MSM_SMI_SIZE 0x4000000
2638
2639#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002640#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002641
2642#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2643#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2644#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2645
Naseer Ahmed51860b02012-02-07 18:53:29 +05302646#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002647#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan42ebe712012-01-10 16:30:58 -08002648#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
2649#define MSM_ION_MM_SIZE 0x3600000 /* (54MB) */
Olav Hauganb5be7992011-11-18 14:29:02 -08002650#define MSM_ION_MFC_SIZE SZ_8K
Mayank Choprac22ace32012-03-03 00:45:04 +05302651#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2652#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2653#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002654#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302655#endif
2656
Olav Haugan424ff492012-03-13 11:41:23 -07002657#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002658
2659#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302660#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002661#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002662#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2663static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002664#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002665#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002666#endif
2667
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002668static unsigned fb_size;
2669static int __init fb_size_setup(char *p)
2670{
2671 fb_size = memparse(p, NULL);
2672 return 0;
2673}
2674early_param("fb_size", fb_size_setup);
2675
2676static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2677static int __init pmem_kernel_ebi1_size_setup(char *p)
2678{
2679 pmem_kernel_ebi1_size = memparse(p, NULL);
2680 return 0;
2681}
2682early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2683
2684#ifdef CONFIG_ANDROID_PMEM
2685static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2686static int __init pmem_sf_size_setup(char *p)
2687{
2688 pmem_sf_size = memparse(p, NULL);
2689 return 0;
2690}
2691early_param("pmem_sf_size", pmem_sf_size_setup);
2692
2693static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2694
2695static int __init pmem_adsp_size_setup(char *p)
2696{
2697 pmem_adsp_size = memparse(p, NULL);
2698 return 0;
2699}
2700early_param("pmem_adsp_size", pmem_adsp_size_setup);
2701
2702static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2703
2704static int __init pmem_audio_size_setup(char *p)
2705{
2706 pmem_audio_size = memparse(p, NULL);
2707 return 0;
2708}
2709early_param("pmem_audio_size", pmem_audio_size_setup);
2710#endif
2711
2712static struct resource msm_fb_resources[] = {
2713 {
2714 .flags = IORESOURCE_DMA,
2715 }
2716};
2717
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002718static void set_mdp_clocks_for_wuxga(void);
2719
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002720static int msm_fb_detect_panel(const char *name)
2721{
2722 if (machine_is_msm8x60_fluid()) {
2723 uint32_t soc_platform_version = socinfo_get_platform_version();
2724 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2725#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2726 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002727 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2728 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002729 return 0;
2730#endif
2731 } else { /*P3 and up use AUO panel */
2732#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2733 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002734 strnlen(LCDC_AUO_PANEL_NAME,
2735 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736 return 0;
2737#endif
2738 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002739#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2740 } else if machine_is_msm8x60_dragon() {
2741 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002742 strnlen(LCDC_NT35582_PANEL_NAME,
2743 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002744 return 0;
2745#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002746 } else {
2747 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002748 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2749 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002750 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002751
2752#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2753 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2754 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2755 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2756 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2757 PANEL_NAME_MAX_LEN)))
2758 return 0;
2759
2760 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2761 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2762 PANEL_NAME_MAX_LEN)))
2763 return 0;
2764
2765 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2766 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2767 PANEL_NAME_MAX_LEN)))
2768 return 0;
2769#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002770 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002771
2772 if (!strncmp(name, HDMI_PANEL_NAME,
2773 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002774 PANEL_NAME_MAX_LEN))) {
2775 if (hdmi_is_primary)
2776 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002777 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002778 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002779
2780 if (!strncmp(name, TVOUT_PANEL_NAME,
2781 strnlen(TVOUT_PANEL_NAME,
2782 PANEL_NAME_MAX_LEN)))
2783 return 0;
2784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002785 pr_warning("%s: not supported '%s'", __func__, name);
2786 return -ENODEV;
2787}
2788
2789static struct msm_fb_platform_data msm_fb_pdata = {
2790 .detect_client = msm_fb_detect_panel,
2791};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002792
2793static struct platform_device msm_fb_device = {
2794 .name = "msm_fb",
2795 .id = 0,
2796 .num_resources = ARRAY_SIZE(msm_fb_resources),
2797 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002798 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799};
2800
2801#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002802#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002803static struct android_pmem_platform_data android_pmem_pdata = {
2804 .name = "pmem",
2805 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2806 .cached = 1,
2807 .memory_type = MEMTYPE_EBI1,
2808};
2809
2810static struct platform_device android_pmem_device = {
2811 .name = "android_pmem",
2812 .id = 0,
2813 .dev = {.platform_data = &android_pmem_pdata},
2814};
2815
2816static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2817 .name = "pmem_adsp",
2818 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2819 .cached = 0,
2820 .memory_type = MEMTYPE_EBI1,
2821};
2822
2823static struct platform_device android_pmem_adsp_device = {
2824 .name = "android_pmem",
2825 .id = 2,
2826 .dev = { .platform_data = &android_pmem_adsp_pdata },
2827};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302828
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002829static struct android_pmem_platform_data android_pmem_audio_pdata = {
2830 .name = "pmem_audio",
2831 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2832 .cached = 0,
2833 .memory_type = MEMTYPE_EBI1,
2834};
2835
2836static struct platform_device android_pmem_audio_device = {
2837 .name = "android_pmem",
2838 .id = 4,
2839 .dev = { .platform_data = &android_pmem_audio_pdata },
2840};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302841#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002842#define PMEM_BUS_WIDTH(_bw) \
2843 { \
2844 .vectors = &(struct msm_bus_vectors){ \
2845 .src = MSM_BUS_MASTER_AMPSS_M0, \
2846 .dst = MSM_BUS_SLAVE_SMI, \
2847 .ib = (_bw), \
2848 .ab = 0, \
2849 }, \
2850 .num_paths = 1, \
2851 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002852
2853static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002854 [0] = PMEM_BUS_WIDTH(0), /* Off */
2855 [1] = PMEM_BUS_WIDTH(1), /* On */
2856};
2857
2858static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002859 .usecase = mem_smi_table,
2860 .num_usecases = ARRAY_SIZE(mem_smi_table),
2861 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002862};
2863
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002864int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002865{
2866 int bus_id = (int) data;
2867
2868 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002869 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002870}
2871
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002872int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002873{
2874 int bus_id = (int) data;
2875
2876 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002877 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002878}
2879
Alex Bird199980e2011-10-21 11:29:27 -07002880void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002881{
2882 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2883}
Olav Hauganee0f7802011-12-19 13:28:57 -08002884#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002885static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2886 .name = "pmem_smipool",
2887 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2888 .cached = 0,
2889 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002890 .request_region = request_smi_region,
2891 .release_region = release_smi_region,
2892 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002893 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002894};
2895static struct platform_device android_pmem_smipool_device = {
2896 .name = "android_pmem",
2897 .id = 7,
2898 .dev = { .platform_data = &android_pmem_smipool_pdata },
2899};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302900#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2901#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002902
2903#define GPIO_DONGLE_PWR_EN 258
2904static void setup_display_power(void);
2905static int lcdc_vga_enabled;
2906static int vga_enable_request(int enable)
2907{
2908 if (enable)
2909 lcdc_vga_enabled = 1;
2910 else
2911 lcdc_vga_enabled = 0;
2912 setup_display_power();
2913
2914 return 0;
2915}
2916
2917#define GPIO_BACKLIGHT_PWM0 0
2918#define GPIO_BACKLIGHT_PWM1 1
2919
2920static int pmic_backlight_gpio[2]
2921 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2922static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2923 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2924 .vga_switch = vga_enable_request,
2925};
2926
2927static struct platform_device lcdc_samsung_panel_device = {
2928 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2929 .id = 0,
2930 .dev = {
2931 .platform_data = &lcdc_samsung_panel_data,
2932 }
2933};
2934#if (!defined(CONFIG_SPI_QUP)) && \
2935 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2936 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2937
2938static int lcdc_spi_gpio_array_num[] = {
2939 LCDC_SPI_GPIO_CLK,
2940 LCDC_SPI_GPIO_CS,
2941 LCDC_SPI_GPIO_MOSI,
2942};
2943
2944static uint32_t lcdc_spi_gpio_config_data[] = {
2945 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2946 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2947 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2948 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2949 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2950 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2951};
2952
2953static void lcdc_config_spi_gpios(int enable)
2954{
2955 int n;
2956 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2957 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2958}
2959#endif
2960
2961#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2962#ifdef CONFIG_SPI_QUP
2963static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2964 {
2965 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2966 .mode = SPI_MODE_3,
2967 .bus_num = 1,
2968 .chip_select = 0,
2969 .max_speed_hz = 10800000,
2970 }
2971};
2972#endif /* CONFIG_SPI_QUP */
2973
2974static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2975#ifndef CONFIG_SPI_QUP
2976 .panel_config_gpio = lcdc_config_spi_gpios,
2977 .gpio_num = lcdc_spi_gpio_array_num,
2978#endif
2979};
2980
2981static struct platform_device lcdc_samsung_oled_panel_device = {
2982 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2983 .id = 0,
2984 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2985};
2986#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2987
2988#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2989#ifdef CONFIG_SPI_QUP
2990static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
2991 {
2992 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
2993 .mode = SPI_MODE_3,
2994 .bus_num = 1,
2995 .chip_select = 0,
2996 .max_speed_hz = 10800000,
2997 }
2998};
2999#endif
3000
3001static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3002#ifndef CONFIG_SPI_QUP
3003 .panel_config_gpio = lcdc_config_spi_gpios,
3004 .gpio_num = lcdc_spi_gpio_array_num,
3005#endif
3006};
3007
3008static struct platform_device lcdc_auo_wvga_panel_device = {
3009 .name = LCDC_AUO_PANEL_NAME,
3010 .id = 0,
3011 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3012};
3013#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3014
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003015#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3016
3017#define GPIO_NT35582_RESET 94
3018#define GPIO_NT35582_BL_EN_HW_PIN 24
3019#define GPIO_NT35582_BL_EN \
3020 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3021
3022static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3023
3024static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3025 .gpio_num = lcdc_nt35582_pmic_gpio,
3026};
3027
3028static struct platform_device lcdc_nt35582_panel_device = {
3029 .name = LCDC_NT35582_PANEL_NAME,
3030 .id = 0,
3031 .dev = {
3032 .platform_data = &lcdc_nt35582_panel_data,
3033 }
3034};
3035
3036static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3037 {
3038 .modalias = "lcdc_nt35582_spi",
3039 .mode = SPI_MODE_0,
3040 .bus_num = 0,
3041 .chip_select = 0,
3042 .max_speed_hz = 1100000,
3043 }
3044};
3045#endif
3046
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003047#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3048static struct resource hdmi_msm_resources[] = {
3049 {
3050 .name = "hdmi_msm_qfprom_addr",
3051 .start = 0x00700000,
3052 .end = 0x007060FF,
3053 .flags = IORESOURCE_MEM,
3054 },
3055 {
3056 .name = "hdmi_msm_hdmi_addr",
3057 .start = 0x04A00000,
3058 .end = 0x04A00FFF,
3059 .flags = IORESOURCE_MEM,
3060 },
3061 {
3062 .name = "hdmi_msm_irq",
3063 .start = HDMI_IRQ,
3064 .end = HDMI_IRQ,
3065 .flags = IORESOURCE_IRQ,
3066 },
3067};
3068
3069static int hdmi_enable_5v(int on);
3070static int hdmi_core_power(int on, int show);
3071static int hdmi_cec_power(int on);
3072
3073static struct msm_hdmi_platform_data hdmi_msm_data = {
3074 .irq = HDMI_IRQ,
3075 .enable_5v = hdmi_enable_5v,
3076 .core_power = hdmi_core_power,
3077 .cec_power = hdmi_cec_power,
3078};
3079
3080static struct platform_device hdmi_msm_device = {
3081 .name = "hdmi_msm",
3082 .id = 0,
3083 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3084 .resource = hdmi_msm_resources,
3085 .dev.platform_data = &hdmi_msm_data,
3086};
3087#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3088
3089#ifdef CONFIG_FB_MSM_MIPI_DSI
3090static struct platform_device mipi_dsi_toshiba_panel_device = {
3091 .name = "mipi_toshiba",
3092 .id = 0,
3093};
3094
3095#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3096
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003097static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003098 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003099 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003100};
3101
3102static struct platform_device mipi_dsi_novatek_panel_device = {
3103 .name = "mipi_novatek",
3104 .id = 0,
3105 .dev = {
3106 .platform_data = &novatek_pdata,
3107 }
3108};
3109#endif
3110
3111static void __init msm8x60_allocate_memory_regions(void)
3112{
3113 void *addr;
3114 unsigned long size;
3115
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003116 if (hdmi_is_primary)
3117 size = roundup((1920 * 1088 * 4 * 2), 4096);
3118 else
3119 size = MSM_FB_SIZE;
3120
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003121 addr = alloc_bootmem_align(size, 0x1000);
3122 msm_fb_resources[0].start = __pa(addr);
3123 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3124 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3125 size, addr, __pa(addr));
3126
3127}
3128
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003129void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3130{
3131 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3132 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3133 PANEL_NAME_MAX_LEN);
3134 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3135 msm_fb_pdata.prim_panel_name);
3136
3137 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3138 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3139 PANEL_NAME_MAX_LEN))) {
3140 pr_debug("HDMI is the primary display by"
3141 " boot parameter\n");
3142 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003143 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003144 }
3145 }
3146 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3147 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3148 PANEL_NAME_MAX_LEN);
3149 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3150 msm_fb_pdata.ext_panel_name);
3151 }
3152}
3153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003154#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3155 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3156/*virtual key support */
3157static ssize_t tma300_vkeys_show(struct kobject *kobj,
3158 struct kobj_attribute *attr, char *buf)
3159{
3160 return sprintf(buf,
3161 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3162 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3163 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3164 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3165 "\n");
3166}
3167
3168static struct kobj_attribute tma300_vkeys_attr = {
3169 .attr = {
3170 .mode = S_IRUGO,
3171 },
3172 .show = &tma300_vkeys_show,
3173};
3174
3175static struct attribute *tma300_properties_attrs[] = {
3176 &tma300_vkeys_attr.attr,
3177 NULL
3178};
3179
3180static struct attribute_group tma300_properties_attr_group = {
3181 .attrs = tma300_properties_attrs,
3182};
3183
3184static struct kobject *properties_kobj;
3185
3186
3187
3188#define CYTTSP_TS_GPIO_IRQ 61
3189static int cyttsp_platform_init(struct i2c_client *client)
3190{
3191 int rc = -EINVAL;
3192 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3193
3194 if (machine_is_msm8x60_fluid()) {
3195 pm8058_l5 = regulator_get(NULL, "8058_l5");
3196 if (IS_ERR(pm8058_l5)) {
3197 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3198 __func__, PTR_ERR(pm8058_l5));
3199 rc = PTR_ERR(pm8058_l5);
3200 return rc;
3201 }
3202 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3203 if (rc) {
3204 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3205 __func__, rc);
3206 goto reg_l5_put;
3207 }
3208
3209 rc = regulator_enable(pm8058_l5);
3210 if (rc) {
3211 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3212 __func__, rc);
3213 goto reg_l5_put;
3214 }
3215 }
3216 /* vote for s3 to enable i2c communication lines */
3217 pm8058_s3 = regulator_get(NULL, "8058_s3");
3218 if (IS_ERR(pm8058_s3)) {
3219 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3220 __func__, PTR_ERR(pm8058_s3));
3221 rc = PTR_ERR(pm8058_s3);
3222 goto reg_l5_disable;
3223 }
3224
3225 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3226 if (rc) {
3227 pr_err("%s: regulator_set_voltage() = %d\n",
3228 __func__, rc);
3229 goto reg_s3_put;
3230 }
3231
3232 rc = regulator_enable(pm8058_s3);
3233 if (rc) {
3234 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3235 __func__, rc);
3236 goto reg_s3_put;
3237 }
3238
3239 /* wait for vregs to stabilize */
3240 usleep_range(10000, 10000);
3241
3242 /* check this device active by reading first byte/register */
3243 rc = i2c_smbus_read_byte_data(client, 0x01);
3244 if (rc < 0) {
3245 pr_err("%s: i2c sanity check failed\n", __func__);
3246 goto reg_s3_disable;
3247 }
3248
3249 /* virtual keys */
3250 if (machine_is_msm8x60_fluid()) {
3251 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3252 properties_kobj = kobject_create_and_add("board_properties",
3253 NULL);
3254 if (properties_kobj)
3255 rc = sysfs_create_group(properties_kobj,
3256 &tma300_properties_attr_group);
3257 if (!properties_kobj || rc)
3258 pr_err("%s: failed to create board_properties\n",
3259 __func__);
3260 }
3261 return CY_OK;
3262
3263reg_s3_disable:
3264 regulator_disable(pm8058_s3);
3265reg_s3_put:
3266 regulator_put(pm8058_s3);
3267reg_l5_disable:
3268 if (machine_is_msm8x60_fluid())
3269 regulator_disable(pm8058_l5);
3270reg_l5_put:
3271 if (machine_is_msm8x60_fluid())
3272 regulator_put(pm8058_l5);
3273 return rc;
3274}
3275
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303276/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3277static int cyttsp_platform_suspend(struct i2c_client *client)
3278{
3279 msleep(20);
3280
3281 return CY_OK;
3282}
3283
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003284static int cyttsp_platform_resume(struct i2c_client *client)
3285{
3286 /* add any special code to strobe a wakeup pin or chip reset */
3287 msleep(10);
3288
3289 return CY_OK;
3290}
3291
3292static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3293 .flags = 0x04,
3294 .gen = CY_GEN3, /* or */
3295 .use_st = CY_USE_ST,
3296 .use_mt = CY_USE_MT,
3297 .use_hndshk = CY_SEND_HNDSHK,
3298 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303299 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003300 .use_gestures = CY_USE_GESTURES,
3301 /* activate up to 4 groups
3302 * and set active distance
3303 */
3304 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3305 CY_GEST_GRP3 | CY_GEST_GRP4 |
3306 CY_ACT_DIST,
3307 /* change act_intrvl to customize the Active power state
3308 * scanning/processing refresh interval for Operating mode
3309 */
3310 .act_intrvl = CY_ACT_INTRVL_DFLT,
3311 /* change tch_tmout to customize the touch timeout for the
3312 * Active power state for Operating mode
3313 */
3314 .tch_tmout = CY_TCH_TMOUT_DFLT,
3315 /* change lp_intrvl to customize the Low Power power state
3316 * scanning/processing refresh interval for Operating mode
3317 */
3318 .lp_intrvl = CY_LP_INTRVL_DFLT,
3319 .sleep_gpio = -1,
3320 .resout_gpio = -1,
3321 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3322 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303323 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003324 .init = cyttsp_platform_init,
3325};
3326
3327static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3328 .panel_maxx = 1083,
3329 .panel_maxy = 659,
3330 .disp_minx = 30,
3331 .disp_maxx = 1053,
3332 .disp_miny = 30,
3333 .disp_maxy = 629,
3334 .correct_fw_ver = 8,
3335 .fw_fname = "cyttsp_8660_ffa.hex",
3336 .flags = 0x00,
3337 .gen = CY_GEN2, /* or */
3338 .use_st = CY_USE_ST,
3339 .use_mt = CY_USE_MT,
3340 .use_hndshk = CY_SEND_HNDSHK,
3341 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303342 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003343 .use_gestures = CY_USE_GESTURES,
3344 /* activate up to 4 groups
3345 * and set active distance
3346 */
3347 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3348 CY_GEST_GRP3 | CY_GEST_GRP4 |
3349 CY_ACT_DIST,
3350 /* change act_intrvl to customize the Active power state
3351 * scanning/processing refresh interval for Operating mode
3352 */
3353 .act_intrvl = CY_ACT_INTRVL_DFLT,
3354 /* change tch_tmout to customize the touch timeout for the
3355 * Active power state for Operating mode
3356 */
3357 .tch_tmout = CY_TCH_TMOUT_DFLT,
3358 /* change lp_intrvl to customize the Low Power power state
3359 * scanning/processing refresh interval for Operating mode
3360 */
3361 .lp_intrvl = CY_LP_INTRVL_DFLT,
3362 .sleep_gpio = -1,
3363 .resout_gpio = -1,
3364 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3365 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303366 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003367 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303368 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003369};
3370static void cyttsp_set_params(void)
3371{
3372 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3373 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3374 cyttsp_fluid_pdata.panel_maxx = 539;
3375 cyttsp_fluid_pdata.panel_maxy = 994;
3376 cyttsp_fluid_pdata.disp_minx = 30;
3377 cyttsp_fluid_pdata.disp_maxx = 509;
3378 cyttsp_fluid_pdata.disp_miny = 60;
3379 cyttsp_fluid_pdata.disp_maxy = 859;
3380 cyttsp_fluid_pdata.correct_fw_ver = 4;
3381 } else {
3382 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3383 cyttsp_fluid_pdata.panel_maxx = 550;
3384 cyttsp_fluid_pdata.panel_maxy = 1013;
3385 cyttsp_fluid_pdata.disp_minx = 35;
3386 cyttsp_fluid_pdata.disp_maxx = 515;
3387 cyttsp_fluid_pdata.disp_miny = 69;
3388 cyttsp_fluid_pdata.disp_maxy = 869;
3389 cyttsp_fluid_pdata.correct_fw_ver = 5;
3390 }
3391
3392}
3393
3394static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3395 {
3396 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3397 .platform_data = &cyttsp_fluid_pdata,
3398#ifndef CY_USE_TIMER
3399 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3400#endif /* CY_USE_TIMER */
3401 },
3402};
3403
3404static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3405 {
3406 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3407 .platform_data = &cyttsp_tmg240_pdata,
3408#ifndef CY_USE_TIMER
3409 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3410#endif /* CY_USE_TIMER */
3411 },
3412};
3413#endif
3414
3415static struct regulator *vreg_tmg200;
3416
3417#define TS_PEN_IRQ_GPIO 61
3418static int tmg200_power(int vreg_on)
3419{
3420 int rc = -EINVAL;
3421
3422 if (!vreg_tmg200) {
3423 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3424 __func__, rc);
3425 return rc;
3426 }
3427
3428 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3429 regulator_disable(vreg_tmg200);
3430 if (rc < 0)
3431 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3432 __func__, vreg_on ? "enable" : "disable", rc);
3433
3434 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003435 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003436
3437 return rc;
3438}
3439
3440static int tmg200_dev_setup(bool enable)
3441{
3442 int rc;
3443
3444 if (enable) {
3445 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3446 if (IS_ERR(vreg_tmg200)) {
3447 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3448 __func__, PTR_ERR(vreg_tmg200));
3449 rc = PTR_ERR(vreg_tmg200);
3450 return rc;
3451 }
3452
3453 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3454 if (rc) {
3455 pr_err("%s: regulator_set_voltage() = %d\n",
3456 __func__, rc);
3457 goto reg_put;
3458 }
3459 } else {
3460 /* put voltage sources */
3461 regulator_put(vreg_tmg200);
3462 }
3463 return 0;
3464reg_put:
3465 regulator_put(vreg_tmg200);
3466 return rc;
3467}
3468
3469static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3470 .ts_name = "msm_tmg200_ts",
3471 .dis_min_x = 0,
3472 .dis_max_x = 1023,
3473 .dis_min_y = 0,
3474 .dis_max_y = 599,
3475 .min_tid = 0,
3476 .max_tid = 255,
3477 .min_touch = 0,
3478 .max_touch = 255,
3479 .min_width = 0,
3480 .max_width = 255,
3481 .power_on = tmg200_power,
3482 .dev_setup = tmg200_dev_setup,
3483 .nfingers = 2,
3484 .irq_gpio = TS_PEN_IRQ_GPIO,
3485 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3486};
3487
3488static struct i2c_board_info cy8ctmg200_board_info[] = {
3489 {
3490 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3491 .platform_data = &cy8ctmg200_pdata,
3492 }
3493};
3494
Zhang Chang Ken211df572011-07-05 19:16:39 -04003495static struct regulator *vreg_tma340;
3496
3497static int tma340_power(int vreg_on)
3498{
3499 int rc = -EINVAL;
3500
3501 if (!vreg_tma340) {
3502 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3503 __func__, rc);
3504 return rc;
3505 }
3506
3507 rc = vreg_on ? regulator_enable(vreg_tma340) :
3508 regulator_disable(vreg_tma340);
3509 if (rc < 0)
3510 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3511 __func__, vreg_on ? "enable" : "disable", rc);
3512
3513 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003514 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003515
3516 return rc;
3517}
3518
3519static struct kobject *tma340_prop_kobj;
3520
3521static int tma340_dragon_dev_setup(bool enable)
3522{
3523 int rc;
3524
3525 if (enable) {
3526 vreg_tma340 = regulator_get(NULL, "8901_l2");
3527 if (IS_ERR(vreg_tma340)) {
3528 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3529 __func__, PTR_ERR(vreg_tma340));
3530 rc = PTR_ERR(vreg_tma340);
3531 return rc;
3532 }
3533
3534 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3535 if (rc) {
3536 pr_err("%s: regulator_set_voltage() = %d\n",
3537 __func__, rc);
3538 goto reg_put;
3539 }
3540 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3541 tma340_prop_kobj = kobject_create_and_add("board_properties",
3542 NULL);
3543 if (tma340_prop_kobj) {
3544 rc = sysfs_create_group(tma340_prop_kobj,
3545 &tma300_properties_attr_group);
3546 if (rc) {
3547 kobject_put(tma340_prop_kobj);
3548 pr_err("%s: failed to create board_properties\n",
3549 __func__);
3550 goto reg_put;
3551 }
3552 }
3553
3554 } else {
3555 /* put voltage sources */
3556 regulator_put(vreg_tma340);
3557 /* destroy virtual keys */
3558 if (tma340_prop_kobj) {
3559 sysfs_remove_group(tma340_prop_kobj,
3560 &tma300_properties_attr_group);
3561 kobject_put(tma340_prop_kobj);
3562 }
3563 }
3564 return 0;
3565reg_put:
3566 regulator_put(vreg_tma340);
3567 return rc;
3568}
3569
3570
3571static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3572 .ts_name = "cy8ctma340",
3573 .dis_min_x = 0,
3574 .dis_max_x = 479,
3575 .dis_min_y = 0,
3576 .dis_max_y = 799,
3577 .min_tid = 0,
3578 .max_tid = 255,
3579 .min_touch = 0,
3580 .max_touch = 255,
3581 .min_width = 0,
3582 .max_width = 255,
3583 .power_on = tma340_power,
3584 .dev_setup = tma340_dragon_dev_setup,
3585 .nfingers = 2,
3586 .irq_gpio = TS_PEN_IRQ_GPIO,
3587 .resout_gpio = -1,
3588};
3589
3590static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3591 {
3592 I2C_BOARD_INFO("cy8ctma340", 0x24),
3593 .platform_data = &cy8ctma340_dragon_pdata,
3594 }
3595};
3596
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003597#ifdef CONFIG_SERIAL_MSM_HS
3598static int configure_uart_gpios(int on)
3599{
3600 int ret = 0, i;
3601 int uart_gpios[] = {53, 54, 55, 56};
3602 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3603 if (on) {
3604 ret = msm_gpiomux_get(uart_gpios[i]);
3605 if (unlikely(ret))
3606 break;
3607 } else {
3608 ret = msm_gpiomux_put(uart_gpios[i]);
3609 if (unlikely(ret))
3610 return ret;
3611 }
3612 }
3613 if (ret)
3614 for (; i >= 0; i--)
3615 msm_gpiomux_put(uart_gpios[i]);
3616 return ret;
3617}
3618static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3619 .inject_rx_on_wakeup = 1,
3620 .rx_to_inject = 0xFD,
3621 .gpio_config = configure_uart_gpios,
3622};
3623#endif
3624
3625
3626#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3627
3628static struct gpio_led gpio_exp_leds_config[] = {
3629 {
3630 .name = "left_led1:green",
3631 .gpio = GPIO_LEFT_LED_1,
3632 .active_low = 1,
3633 .retain_state_suspended = 0,
3634 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3635 },
3636 {
3637 .name = "left_led2:red",
3638 .gpio = GPIO_LEFT_LED_2,
3639 .active_low = 1,
3640 .retain_state_suspended = 0,
3641 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3642 },
3643 {
3644 .name = "left_led3:green",
3645 .gpio = GPIO_LEFT_LED_3,
3646 .active_low = 1,
3647 .retain_state_suspended = 0,
3648 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3649 },
3650 {
3651 .name = "wlan_led:orange",
3652 .gpio = GPIO_LEFT_LED_WLAN,
3653 .active_low = 1,
3654 .retain_state_suspended = 0,
3655 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3656 },
3657 {
3658 .name = "left_led5:green",
3659 .gpio = GPIO_LEFT_LED_5,
3660 .active_low = 1,
3661 .retain_state_suspended = 0,
3662 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3663 },
3664 {
3665 .name = "right_led1:green",
3666 .gpio = GPIO_RIGHT_LED_1,
3667 .active_low = 1,
3668 .retain_state_suspended = 0,
3669 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3670 },
3671 {
3672 .name = "right_led2:red",
3673 .gpio = GPIO_RIGHT_LED_2,
3674 .active_low = 1,
3675 .retain_state_suspended = 0,
3676 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3677 },
3678 {
3679 .name = "right_led3:green",
3680 .gpio = GPIO_RIGHT_LED_3,
3681 .active_low = 1,
3682 .retain_state_suspended = 0,
3683 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3684 },
3685 {
3686 .name = "bt_led:blue",
3687 .gpio = GPIO_RIGHT_LED_BT,
3688 .active_low = 1,
3689 .retain_state_suspended = 0,
3690 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3691 },
3692 {
3693 .name = "right_led5:green",
3694 .gpio = GPIO_RIGHT_LED_5,
3695 .active_low = 1,
3696 .retain_state_suspended = 0,
3697 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3698 },
3699};
3700
3701static struct gpio_led_platform_data gpio_leds_pdata = {
3702 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3703 .leds = gpio_exp_leds_config,
3704};
3705
3706static struct platform_device gpio_leds = {
3707 .name = "leds-gpio",
3708 .id = -1,
3709 .dev = {
3710 .platform_data = &gpio_leds_pdata,
3711 },
3712};
3713
3714static struct gpio_led fluid_gpio_leds[] = {
3715 {
3716 .name = "dual_led:green",
3717 .gpio = GPIO_LED1_GREEN_N,
3718 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3719 .active_low = 1,
3720 .retain_state_suspended = 0,
3721 },
3722 {
3723 .name = "dual_led:red",
3724 .gpio = GPIO_LED2_RED_N,
3725 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3726 .active_low = 1,
3727 .retain_state_suspended = 0,
3728 },
3729};
3730
3731static struct gpio_led_platform_data gpio_led_pdata = {
3732 .leds = fluid_gpio_leds,
3733 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3734};
3735
3736static struct platform_device fluid_leds_gpio = {
3737 .name = "leds-gpio",
3738 .id = -1,
3739 .dev = {
3740 .platform_data = &gpio_led_pdata,
3741 },
3742};
3743
3744#endif
3745
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003746#ifdef CONFIG_BATTERY_MSM8X60
3747static struct msm_charger_platform_data msm_charger_data = {
3748 .safety_time = 180,
3749 .update_time = 1,
3750 .max_voltage = 4200,
3751 .min_voltage = 3200,
3752};
3753
3754static struct platform_device msm_charger_device = {
3755 .name = "msm-charger",
3756 .id = -1,
3757 .dev = {
3758 .platform_data = &msm_charger_data,
3759 }
3760};
3761#endif
3762
3763/*
3764 * Consumer specific regulator names:
3765 * regulator name consumer dev_name
3766 */
3767static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3768 REGULATOR_SUPPLY("8058_l0", NULL),
3769};
3770static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3771 REGULATOR_SUPPLY("8058_l1", NULL),
3772};
3773static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3774 REGULATOR_SUPPLY("8058_l2", NULL),
3775};
3776static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3777 REGULATOR_SUPPLY("8058_l3", NULL),
3778};
3779static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3780 REGULATOR_SUPPLY("8058_l4", NULL),
3781};
3782static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3783 REGULATOR_SUPPLY("8058_l5", NULL),
3784};
3785static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3786 REGULATOR_SUPPLY("8058_l6", NULL),
3787};
3788static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3789 REGULATOR_SUPPLY("8058_l7", NULL),
3790};
3791static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3792 REGULATOR_SUPPLY("8058_l8", NULL),
3793};
3794static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3795 REGULATOR_SUPPLY("8058_l9", NULL),
3796};
3797static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3798 REGULATOR_SUPPLY("8058_l10", NULL),
3799};
3800static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3801 REGULATOR_SUPPLY("8058_l11", NULL),
3802};
3803static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3804 REGULATOR_SUPPLY("8058_l12", NULL),
3805};
3806static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3807 REGULATOR_SUPPLY("8058_l13", NULL),
3808};
3809static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3810 REGULATOR_SUPPLY("8058_l14", NULL),
3811};
3812static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3813 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003814 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003815 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003816 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003817};
3818static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3819 REGULATOR_SUPPLY("8058_l16", NULL),
3820};
3821static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3822 REGULATOR_SUPPLY("8058_l17", NULL),
3823};
3824static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3825 REGULATOR_SUPPLY("8058_l18", NULL),
3826};
3827static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3828 REGULATOR_SUPPLY("8058_l19", NULL),
3829};
3830static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3831 REGULATOR_SUPPLY("8058_l20", NULL),
3832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3834 REGULATOR_SUPPLY("8058_l21", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3837 REGULATOR_SUPPLY("8058_l22", NULL),
3838};
3839static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3840 REGULATOR_SUPPLY("8058_l23", NULL),
3841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3843 REGULATOR_SUPPLY("8058_l24", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3846 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003847 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003848 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003849 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3852 REGULATOR_SUPPLY("8058_s0", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3855 REGULATOR_SUPPLY("8058_s1", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3858 REGULATOR_SUPPLY("8058_s2", NULL),
3859};
3860static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3861 REGULATOR_SUPPLY("8058_s3", NULL),
3862};
3863static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3864 REGULATOR_SUPPLY("8058_s4", NULL),
3865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3867 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003868 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003869 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003870 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003871};
3872static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3873 REGULATOR_SUPPLY("8058_lvs1", NULL),
3874};
3875static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3876 REGULATOR_SUPPLY("8058_ncp", NULL),
3877};
3878
3879static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3880 REGULATOR_SUPPLY("8901_l0", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3883 REGULATOR_SUPPLY("8901_l1", NULL),
3884};
3885static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3886 REGULATOR_SUPPLY("8901_l2", NULL),
3887};
3888static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3889 REGULATOR_SUPPLY("8901_l3", NULL),
3890};
3891static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3892 REGULATOR_SUPPLY("8901_l4", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3895 REGULATOR_SUPPLY("8901_l5", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3898 REGULATOR_SUPPLY("8901_l6", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3901 REGULATOR_SUPPLY("8901_s2", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3904 REGULATOR_SUPPLY("8901_s3", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3907 REGULATOR_SUPPLY("8901_s4", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3910 REGULATOR_SUPPLY("8901_lvs0", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3913 REGULATOR_SUPPLY("8901_lvs1", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3916 REGULATOR_SUPPLY("8901_lvs2", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3919 REGULATOR_SUPPLY("8901_lvs3", NULL),
3920};
3921static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3922 REGULATOR_SUPPLY("8901_mvs0", NULL),
3923};
3924
David Collins6f032ba2011-08-31 14:08:15 -07003925/* Pin control regulators */
3926static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3927 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3930 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3933 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3934};
3935static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3936 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3937};
3938static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3939 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3940};
3941static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3942 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3943};
3944
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003945#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3946 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003947 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3948 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003949 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003950 .init_data = { \
3951 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003952 .valid_modes_mask = _modes, \
3953 .valid_ops_mask = _ops, \
3954 .min_uV = _min_uV, \
3955 .max_uV = _max_uV, \
3956 .input_uV = _min_uV, \
3957 .apply_uV = _apply_uV, \
3958 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003960 .consumer_supplies = vreg_consumers_##_id, \
3961 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003962 ARRAY_SIZE(vreg_consumers_##_id), \
3963 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003964 .id = RPM_VREG_ID_##_id, \
3965 .default_uV = _default_uV, \
3966 .peak_uA = _peak_uA, \
3967 .avg_uA = _avg_uA, \
3968 .pull_down_enable = _pull_down, \
3969 .pin_ctrl = _pin_ctrl, \
3970 .freq = RPM_VREG_FREQ_##_freq, \
3971 .pin_fn = _pin_fn, \
3972 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003973 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003974 .state = _state, \
3975 .sleep_selectable = _sleep_selectable, \
3976 }
3977
3978/* Pin control initialization */
3979#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3980 { \
3981 .init_data = { \
3982 .constraints = { \
3983 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3984 .always_on = _always_on, \
3985 }, \
3986 .num_consumer_supplies = \
3987 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3988 .consumer_supplies = vreg_consumers_##_id##_PC, \
3989 }, \
3990 .id = RPM_VREG_ID_##_id##_PC, \
3991 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003992 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003993 }
3994
3995/*
3996 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3997 * via the peak_uA value specified in the table below. If the value is less
3998 * than the high power min threshold for the regulator, then the regulator will
3999 * be set to LPM. Otherwise, it will be set to HPM.
4000 *
4001 * This value can be further overridden by specifying an initial mode via
4002 * .init_data.constraints.initial_mode.
4003 */
4004
David Collins6f032ba2011-08-31 14:08:15 -07004005#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4006 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004007 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4008 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4009 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4010 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4011 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004012 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4013 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004014 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004015 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004016 _sleep_selectable, _always_on)
4017
David Collins6f032ba2011-08-31 14:08:15 -07004018#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4019 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004020 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4021 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4022 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4023 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4024 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004025 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4026 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004027 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004028 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4029 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030
David Collins6f032ba2011-08-31 14:08:15 -07004031#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004032 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4033 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004034 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4035 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004036 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004037 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4038 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004039
David Collins6f032ba2011-08-31 14:08:15 -07004040#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4042 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004043 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4044 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004045 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004046 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4047 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004048
David Collins6f032ba2011-08-31 14:08:15 -07004049#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4050#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4051#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4052#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4053#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004054
David Collins6f032ba2011-08-31 14:08:15 -07004055/* RPM early regulator constraints */
4056static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4057 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004058 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004059 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004060};
4061
David Collins6f032ba2011-08-31 14:08:15 -07004062/* RPM regulator constraints */
4063static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4064 /* ID a_on pd ss min_uV max_uV init_ip */
4065 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4066 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4067 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4068 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4069 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4070 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4071 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4072 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4073 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4074 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4075 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4076 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4077 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4078 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4079 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4080 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4081 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4082 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4083 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4084 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4085 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4086 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4087 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4088 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4089 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4090 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004091
David Collins6f032ba2011-08-31 14:08:15 -07004092 /* ID a_on pd ss min_uV max_uV init_ip freq */
4093 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4094 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4095 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4096
4097 /* ID a_on pd ss */
4098 RPM_VS(PM8058_LVS0, 0, 1, 0),
4099 RPM_VS(PM8058_LVS1, 0, 1, 0),
4100
4101 /* ID a_on pd ss min_uV max_uV */
4102 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4103
4104 /* ID a_on pd ss min_uV max_uV init_ip */
4105 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4106 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4107 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4108 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4109 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4110 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4111 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4112
4113 /* ID a_on pd ss min_uV max_uV init_ip freq */
4114 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4115 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4116 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4117
4118 /* ID a_on pd ss */
4119 RPM_VS(PM8901_LVS0, 1, 1, 0),
4120 RPM_VS(PM8901_LVS1, 0, 1, 0),
4121 RPM_VS(PM8901_LVS2, 0, 1, 0),
4122 RPM_VS(PM8901_LVS3, 0, 1, 0),
4123 RPM_VS(PM8901_MVS0, 0, 1, 0),
4124
4125 /* ID a_on pin_func pin_ctrl */
4126 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4127 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4128 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4129 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4130 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4131 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4132};
4133
4134static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4135 .init_data = rpm_regulator_early_init_data,
4136 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4137 .version = RPM_VREG_VERSION_8660,
4138 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4139 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4140};
4141
4142static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4143 .init_data = rpm_regulator_init_data,
4144 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4145 .version = RPM_VREG_VERSION_8660,
4146};
4147
4148static struct platform_device rpm_regulator_early_device = {
4149 .name = "rpm-regulator",
4150 .id = 0,
4151 .dev = {
4152 .platform_data = &rpm_regulator_early_pdata,
4153 },
4154};
4155
4156static struct platform_device rpm_regulator_device = {
4157 .name = "rpm-regulator",
4158 .id = 1,
4159 .dev = {
4160 .platform_data = &rpm_regulator_pdata,
4161 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162};
4163
4164static struct platform_device *early_regulators[] __initdata = {
4165 &msm_device_saw_s0,
4166 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004167 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168};
4169
4170static struct platform_device *early_devices[] __initdata = {
4171#ifdef CONFIG_MSM_BUS_SCALING
4172 &msm_bus_apps_fabric,
4173 &msm_bus_sys_fabric,
4174 &msm_bus_mm_fabric,
4175 &msm_bus_sys_fpb,
4176 &msm_bus_cpss_fpb,
4177#endif
4178 &msm_device_dmov_adm0,
4179 &msm_device_dmov_adm1,
4180};
4181
4182#if (defined(CONFIG_MARIMBA_CORE)) && \
4183 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4184
4185static int bluetooth_power(int);
4186static struct platform_device msm_bt_power_device = {
4187 .name = "bt_power",
4188 .id = -1,
4189 .dev = {
4190 .platform_data = &bluetooth_power,
4191 },
4192};
4193#endif
4194
4195static struct platform_device msm_tsens_device = {
4196 .name = "tsens-tm",
4197 .id = -1,
4198};
4199
4200static struct platform_device *rumi_sim_devices[] __initdata = {
4201 &smc91x_device,
4202 &msm_device_uart_dm12,
4203#ifdef CONFIG_I2C_QUP
4204 &msm_gsbi3_qup_i2c_device,
4205 &msm_gsbi4_qup_i2c_device,
4206 &msm_gsbi7_qup_i2c_device,
4207 &msm_gsbi8_qup_i2c_device,
4208 &msm_gsbi9_qup_i2c_device,
4209 &msm_gsbi12_qup_i2c_device,
4210#endif
4211#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004212 &msm_device_ssbi3,
4213#endif
4214#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004215#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004216 &android_pmem_device,
4217 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004218 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004219 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304220#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4221#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004222#ifdef CONFIG_MSM_ROTATOR
4223 &msm_rotator_device,
4224#endif
4225 &msm_fb_device,
4226 &msm_kgsl_3d0,
4227 &msm_kgsl_2d0,
4228 &msm_kgsl_2d1,
4229 &lcdc_samsung_panel_device,
4230#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4231 &hdmi_msm_device,
4232#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4233#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004234#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004235#ifdef CONFIG_MT9E013
4236 &msm_camera_sensor_mt9e013,
4237#endif
4238#ifdef CONFIG_IMX074
4239 &msm_camera_sensor_imx074,
4240#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004241#ifdef CONFIG_VX6953
4242 &msm_camera_sensor_vx6953,
4243#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004244#ifdef CONFIG_WEBCAM_OV7692
4245 &msm_camera_sensor_webcam_ov7692,
4246#endif
4247#ifdef CONFIG_WEBCAM_OV9726
4248 &msm_camera_sensor_webcam_ov9726,
4249#endif
4250#ifdef CONFIG_QS_S5K4E1
4251 &msm_camera_sensor_qs_s5k4e1,
4252#endif
4253#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004254#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004255#ifdef CONFIG_MSM_GEMINI
4256 &msm_gemini_device,
4257#endif
4258#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004259#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004260 &msm_vpe_device,
4261#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004262#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004263 &msm_device_vidc,
4264};
4265
4266#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4267enum {
4268 SX150X_CORE,
4269 SX150X_DOCKING,
4270 SX150X_SURF,
4271 SX150X_LEFT_FHA,
4272 SX150X_RIGHT_FHA,
4273 SX150X_SOUTH,
4274 SX150X_NORTH,
4275 SX150X_CORE_FLUID,
4276};
4277
4278static struct sx150x_platform_data sx150x_data[] __initdata = {
4279 [SX150X_CORE] = {
4280 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4281 .oscio_is_gpo = false,
4282 .io_pullup_ena = 0x0c08,
4283 .io_pulldn_ena = 0x4060,
4284 .io_open_drain_ena = 0x000c,
4285 .io_polarity = 0,
4286 .irq_summary = -1, /* see fixup_i2c_configs() */
4287 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4288 },
4289 [SX150X_DOCKING] = {
4290 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4291 .oscio_is_gpo = false,
4292 .io_pullup_ena = 0x5e06,
4293 .io_pulldn_ena = 0x81b8,
4294 .io_open_drain_ena = 0,
4295 .io_polarity = 0,
4296 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4297 UI_INT2_N),
4298 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4299 GPIO_DOCKING_EXPANDER_BASE -
4300 GPIO_EXPANDER_GPIO_BASE,
4301 },
4302 [SX150X_SURF] = {
4303 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4304 .oscio_is_gpo = false,
4305 .io_pullup_ena = 0,
4306 .io_pulldn_ena = 0,
4307 .io_open_drain_ena = 0,
4308 .io_polarity = 0,
4309 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4310 UI_INT1_N),
4311 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4312 GPIO_SURF_EXPANDER_BASE -
4313 GPIO_EXPANDER_GPIO_BASE,
4314 },
4315 [SX150X_LEFT_FHA] = {
4316 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4317 .oscio_is_gpo = false,
4318 .io_pullup_ena = 0,
4319 .io_pulldn_ena = 0x40,
4320 .io_open_drain_ena = 0,
4321 .io_polarity = 0,
4322 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4323 UI_INT3_N),
4324 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4325 GPIO_LEFT_KB_EXPANDER_BASE -
4326 GPIO_EXPANDER_GPIO_BASE,
4327 },
4328 [SX150X_RIGHT_FHA] = {
4329 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4330 .oscio_is_gpo = true,
4331 .io_pullup_ena = 0,
4332 .io_pulldn_ena = 0,
4333 .io_open_drain_ena = 0,
4334 .io_polarity = 0,
4335 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4336 UI_INT3_N),
4337 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4338 GPIO_RIGHT_KB_EXPANDER_BASE -
4339 GPIO_EXPANDER_GPIO_BASE,
4340 },
4341 [SX150X_SOUTH] = {
4342 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4343 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4344 GPIO_SOUTH_EXPANDER_BASE -
4345 GPIO_EXPANDER_GPIO_BASE,
4346 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4347 },
4348 [SX150X_NORTH] = {
4349 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4350 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4351 GPIO_NORTH_EXPANDER_BASE -
4352 GPIO_EXPANDER_GPIO_BASE,
4353 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4354 .oscio_is_gpo = true,
4355 .io_open_drain_ena = 0x30,
4356 },
4357 [SX150X_CORE_FLUID] = {
4358 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4359 .oscio_is_gpo = false,
4360 .io_pullup_ena = 0x0408,
4361 .io_pulldn_ena = 0x4060,
4362 .io_open_drain_ena = 0x0008,
4363 .io_polarity = 0,
4364 .irq_summary = -1, /* see fixup_i2c_configs() */
4365 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4366 },
4367};
4368
4369#ifdef CONFIG_SENSORS_MSM_ADC
4370/* Configuration of EPM expander is done when client
4371 * request an adc read
4372 */
4373static struct sx150x_platform_data sx150x_epmdata = {
4374 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4375 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4376 GPIO_EPM_EXPANDER_BASE -
4377 GPIO_EXPANDER_GPIO_BASE,
4378 .irq_summary = -1,
4379};
4380#endif
4381
4382/* sx150x_low_power_cfg
4383 *
4384 * This data and init function are used to put unused gpio-expander output
4385 * lines into their low-power states at boot. The init
4386 * function must be deferred until a later init stage because the i2c
4387 * gpio expander drivers do not probe until after they are registered
4388 * (see register_i2c_devices) and the work-queues for those registrations
4389 * are processed. Because these lines are unused, there is no risk of
4390 * competing with a device driver for the gpio.
4391 *
4392 * gpio lines whose low-power states are input are naturally in their low-
4393 * power configurations once probed, see the platform data structures above.
4394 */
4395struct sx150x_low_power_cfg {
4396 unsigned gpio;
4397 unsigned val;
4398};
4399
4400static struct sx150x_low_power_cfg
4401common_sx150x_lp_cfgs[] __initdata = {
4402 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4403 {GPIO_EXT_GPS_LNA_EN, 0},
4404 {GPIO_MSM_WAKES_BT, 0},
4405 {GPIO_USB_UICC_EN, 0},
4406 {GPIO_BATT_GAUGE_EN, 0},
4407};
4408
4409static struct sx150x_low_power_cfg
4410surf_ffa_sx150x_lp_cfgs[] __initdata = {
4411 {GPIO_MIPI_DSI_RST_N, 0},
4412 {GPIO_DONGLE_PWR_EN, 0},
4413 {GPIO_CAP_TS_SLEEP, 1},
4414 {GPIO_WEB_CAMIF_RESET_N, 0},
4415};
4416
4417static void __init
4418cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4419{
4420 unsigned n;
4421 int rc;
4422
4423 for (n = 0; n < nelems; ++n) {
4424 rc = gpio_request(cfgs[n].gpio, NULL);
4425 if (!rc) {
4426 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4427 gpio_free(cfgs[n].gpio);
4428 }
4429
4430 if (rc) {
4431 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4432 __func__, cfgs[n].gpio, rc);
4433 }
Steve Muckle9161d302010-02-11 11:50:40 -08004434 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004435}
4436
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004437static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004438{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004439 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4440 ARRAY_SIZE(common_sx150x_lp_cfgs));
4441 if (!machine_is_msm8x60_fluid())
4442 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4443 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4444 return 0;
4445}
4446module_init(cfg_sx150xs_low_power);
4447
4448#ifdef CONFIG_I2C
4449static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4450 {
4451 I2C_BOARD_INFO("sx1509q", 0x3e),
4452 .platform_data = &sx150x_data[SX150X_CORE]
4453 },
4454};
4455
4456static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4457 {
4458 I2C_BOARD_INFO("sx1509q", 0x3f),
4459 .platform_data = &sx150x_data[SX150X_DOCKING]
4460 },
4461};
4462
4463static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4464 {
4465 I2C_BOARD_INFO("sx1509q", 0x70),
4466 .platform_data = &sx150x_data[SX150X_SURF]
4467 }
4468};
4469
4470static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4471 {
4472 I2C_BOARD_INFO("sx1508q", 0x21),
4473 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4474 },
4475 {
4476 I2C_BOARD_INFO("sx1508q", 0x22),
4477 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4478 }
4479};
4480
4481static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4482 {
4483 I2C_BOARD_INFO("sx1508q", 0x23),
4484 .platform_data = &sx150x_data[SX150X_SOUTH]
4485 },
4486 {
4487 I2C_BOARD_INFO("sx1508q", 0x20),
4488 .platform_data = &sx150x_data[SX150X_NORTH]
4489 }
4490};
4491
4492static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4493 {
4494 I2C_BOARD_INFO("sx1509q", 0x3e),
4495 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4496 },
4497};
4498
4499#ifdef CONFIG_SENSORS_MSM_ADC
4500static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4501 {
4502 I2C_BOARD_INFO("sx1509q", 0x3e),
4503 .platform_data = &sx150x_epmdata
4504 },
4505};
4506#endif
4507#endif
4508#endif
4509
4510#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004511
4512static struct adc_access_fn xoadc_fn = {
4513 pm8058_xoadc_select_chan_and_start_conv,
4514 pm8058_xoadc_read_adc_code,
4515 pm8058_xoadc_get_properties,
4516 pm8058_xoadc_slot_request,
4517 pm8058_xoadc_restore_slot,
4518 pm8058_xoadc_calibrate,
4519};
4520
4521#if defined(CONFIG_I2C) && \
4522 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4523static struct regulator *vreg_adc_epm1;
4524
4525static struct i2c_client *epm_expander_i2c_register_board(void)
4526
4527{
4528 struct i2c_adapter *i2c_adap;
4529 struct i2c_client *client = NULL;
4530 i2c_adap = i2c_get_adapter(0x0);
4531
4532 if (i2c_adap == NULL)
4533 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4534
4535 if (i2c_adap != NULL)
4536 client = i2c_new_device(i2c_adap,
4537 &fluid_expanders_i2c_epm_info[0]);
4538 return client;
4539
4540}
4541
4542static unsigned int msm_adc_gpio_configure_expander_enable(void)
4543{
4544 int rc = 0;
4545 static struct i2c_client *epm_i2c_client;
4546
4547 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4548
4549 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4550
4551 if (IS_ERR(vreg_adc_epm1)) {
4552 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4553 return 0;
4554 }
4555
4556 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4557 if (rc)
4558 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4559 "regulator set voltage failed\n");
4560
4561 rc = regulator_enable(vreg_adc_epm1);
4562 if (rc) {
4563 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4564 "Error while enabling regulator for epm s3 %d\n", rc);
4565 return rc;
4566 }
4567
4568 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4569 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4570
4571 msleep(1000);
4572
4573 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4574 if (!rc) {
4575 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4576 "Configure 5v boost\n");
4577 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4578 } else {
4579 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4580 "Error for epm 5v boost en\n");
4581 goto exit_vreg_epm;
4582 }
4583
4584 msleep(500);
4585
4586 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4587 if (!rc) {
4588 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4589 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4590 "Configure epm 3.3v\n");
4591 } else {
4592 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4593 "Error for gpio 3.3ven\n");
4594 goto exit_vreg_epm;
4595 }
4596 msleep(500);
4597
4598 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4599 "Trying to request EPM LVLSFT_EN\n");
4600 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4601 if (!rc) {
4602 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4603 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4604 "Configure the lvlsft\n");
4605 } else {
4606 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4607 "Error for epm lvlsft_en\n");
4608 goto exit_vreg_epm;
4609 }
4610
4611 msleep(500);
4612
4613 if (!epm_i2c_client)
4614 epm_i2c_client = epm_expander_i2c_register_board();
4615
4616 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4617 if (!rc)
4618 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4619 if (rc) {
4620 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4621 ": GPIO PWR MON Enable issue\n");
4622 goto exit_vreg_epm;
4623 }
4624
4625 msleep(1000);
4626
4627 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4628 if (!rc) {
4629 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4630 if (rc) {
4631 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4632 ": ADC1_PWDN error direction out\n");
4633 goto exit_vreg_epm;
4634 }
4635 }
4636
4637 msleep(100);
4638
4639 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4640 if (!rc) {
4641 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4642 if (rc) {
4643 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4644 ": ADC2_PWD error direction out\n");
4645 goto exit_vreg_epm;
4646 }
4647 }
4648
4649 msleep(1000);
4650
4651 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4652 if (!rc) {
4653 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4654 if (rc) {
4655 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4656 "Gpio request problem %d\n", rc);
4657 goto exit_vreg_epm;
4658 }
4659 }
4660
4661 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4662 if (!rc) {
4663 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4664 if (rc) {
4665 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4666 ": EPM_SPI_ADC1_CS_N error\n");
4667 goto exit_vreg_epm;
4668 }
4669 }
4670
4671 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4672 if (!rc) {
4673 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4674 if (rc) {
4675 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4676 ": EPM_SPI_ADC2_Cs_N error\n");
4677 goto exit_vreg_epm;
4678 }
4679 }
4680
4681 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4682 "the power monitor reset for epm\n");
4683
4684 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4685 if (!rc) {
4686 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4687 if (rc) {
4688 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4689 ": Error in the power mon reset\n");
4690 goto exit_vreg_epm;
4691 }
4692 }
4693
4694 msleep(1000);
4695
4696 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4697
4698 msleep(500);
4699
4700 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4701
4702 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4703
4704 return rc;
4705
4706exit_vreg_epm:
4707 regulator_disable(vreg_adc_epm1);
4708
4709 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4710 " rc = %d.\n", rc);
4711 return rc;
4712};
4713
4714static unsigned int msm_adc_gpio_configure_expander_disable(void)
4715{
4716 int rc = 0;
4717
4718 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4719 gpio_free(GPIO_PWR_MON_RESET_N);
4720
4721 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4722 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4723
4724 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4725 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4726
4727 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4728 gpio_free(GPIO_PWR_MON_START);
4729
4730 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4731 gpio_free(GPIO_ADC1_PWDN_N);
4732
4733 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4734 gpio_free(GPIO_ADC2_PWDN_N);
4735
4736 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4737 gpio_free(GPIO_PWR_MON_ENABLE);
4738
4739 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4740 gpio_free(GPIO_EPM_LVLSFT_EN);
4741
4742 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4743 gpio_free(GPIO_EPM_5V_BOOST_EN);
4744
4745 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4746 gpio_free(GPIO_EPM_3_3V_EN);
4747
4748 rc = regulator_disable(vreg_adc_epm1);
4749 if (rc)
4750 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4751 "Error while enabling regulator for epm s3 %d\n", rc);
4752 regulator_put(vreg_adc_epm1);
4753
4754 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4755 return rc;
4756};
4757
4758unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4759{
4760 int rc = 0;
4761
4762 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4763 cs_enable);
4764
4765 if (cs_enable < 16) {
4766 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4767 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4768 } else {
4769 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4770 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4771 }
4772 return rc;
4773};
4774
4775unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4776{
4777 int rc = 0;
4778
4779 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4780
4781 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4782
4783 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4784
4785 return rc;
4786};
4787#endif
4788
4789static struct msm_adc_channels msm_adc_channels_data[] = {
4790 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4791 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4792 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4793 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4794 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4795 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4796 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4797 CHAN_PATH_TYPE4,
4798 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4799 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4800 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4801 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4802 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4803 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4804 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4805 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4806 CHAN_PATH_TYPE12,
4807 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4808 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4809 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4810 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4811 CHAN_PATH_TYPE_NONE,
4812 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4813 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4814 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4815 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4816 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4817 scale_xtern_chgr_cur},
4818 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4819 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4820 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4822 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4823 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4824 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4825 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4826 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4827 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4828 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4829 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4830};
4831
4832static char *msm_adc_fluid_device_names[] = {
4833 "ADS_ADC1",
4834 "ADS_ADC2",
4835};
4836
4837static struct msm_adc_platform_data msm_adc_pdata = {
4838 .channel = msm_adc_channels_data,
4839 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4840#if defined(CONFIG_I2C) && \
4841 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4842 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4843 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4844 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4845 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4846#endif
4847};
4848
4849static struct platform_device msm_adc_device = {
4850 .name = "msm_adc",
4851 .id = -1,
4852 .dev = {
4853 .platform_data = &msm_adc_pdata,
4854 },
4855};
4856
4857static void pmic8058_xoadc_mpp_config(void)
4858{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304859 int rc, i;
4860 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304861 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304862 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304863 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304864 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304865 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304866 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304867 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304868 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304869 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304870 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304871 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4872 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304873 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004874
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304875 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4876 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4877 &xoadc_mpps[i].config);
4878 if (rc) {
4879 pr_err("%s: Config MPP %d of PM8058 failed\n",
4880 __func__, xoadc_mpps[i].mpp);
4881 }
4882 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004883}
4884
4885static struct regulator *vreg_ldo18_adc;
4886
4887static int pmic8058_xoadc_vreg_config(int on)
4888{
4889 int rc;
4890
4891 if (on) {
4892 rc = regulator_enable(vreg_ldo18_adc);
4893 if (rc)
4894 pr_err("%s: Enable of regulator ldo18_adc "
4895 "failed\n", __func__);
4896 } else {
4897 rc = regulator_disable(vreg_ldo18_adc);
4898 if (rc)
4899 pr_err("%s: Disable of regulator ldo18_adc "
4900 "failed\n", __func__);
4901 }
4902
4903 return rc;
4904}
4905
4906static int pmic8058_xoadc_vreg_setup(void)
4907{
4908 int rc;
4909
4910 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4911 if (IS_ERR(vreg_ldo18_adc)) {
4912 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4913 __func__, PTR_ERR(vreg_ldo18_adc));
4914 rc = PTR_ERR(vreg_ldo18_adc);
4915 goto fail;
4916 }
4917
4918 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4919 if (rc) {
4920 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4921 goto fail;
4922 }
4923
4924 return rc;
4925fail:
4926 regulator_put(vreg_ldo18_adc);
4927 return rc;
4928}
4929
4930static void pmic8058_xoadc_vreg_shutdown(void)
4931{
4932 regulator_put(vreg_ldo18_adc);
4933}
4934
4935/* usec. For this ADC,
4936 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4937 * Each channel has different configuration, thus at the time of starting
4938 * the conversion, xoadc will return actual conversion time
4939 * */
4940static struct adc_properties pm8058_xoadc_data = {
4941 .adc_reference = 2200, /* milli-voltage for this adc */
4942 .bitresolution = 15,
4943 .bipolar = 0,
4944 .conversiontime = 54,
4945};
4946
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304947static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004948 .xoadc_prop = &pm8058_xoadc_data,
4949 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4950 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4951 .xoadc_num = XOADC_PMIC_0,
4952 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4953 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4954};
4955#endif
4956
4957#ifdef CONFIG_MSM_SDIO_AL
4958
4959static unsigned mdm2ap_status = 140;
4960
4961static int configure_mdm2ap_status(int on)
4962{
4963 int ret = 0;
4964 if (on)
4965 ret = msm_gpiomux_get(mdm2ap_status);
4966 else
4967 ret = msm_gpiomux_put(mdm2ap_status);
4968
4969 if (ret)
4970 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4971 on);
4972
4973 return ret;
4974}
4975
4976
4977static int get_mdm2ap_status(void)
4978{
4979 return gpio_get_value(mdm2ap_status);
4980}
4981
4982static struct sdio_al_platform_data sdio_al_pdata = {
4983 .config_mdm2ap_status = configure_mdm2ap_status,
4984 .get_mdm2ap_status = get_mdm2ap_status,
4985 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004986 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004987 .peer_sdioc_version_major = 0x0004,
4988 .peer_sdioc_boot_version_minor = 0x0001,
4989 .peer_sdioc_boot_version_major = 0x0003
4990};
4991
4992struct platform_device msm_device_sdio_al = {
4993 .name = "msm_sdio_al",
4994 .id = -1,
4995 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004996 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004997 .platform_data = &sdio_al_pdata,
4998 },
4999};
5000
5001#endif /* CONFIG_MSM_SDIO_AL */
5002
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305003#define GPIO_VREG_ID_EXT_5V 0
5004
5005static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5006 REGULATOR_SUPPLY("ext_5v", NULL),
5007 REGULATOR_SUPPLY("8901_mpp0", NULL),
5008};
5009
5010#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5011 [GPIO_VREG_ID_##_id] = { \
5012 .init_data = { \
5013 .constraints = { \
5014 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5015 }, \
5016 .num_consumer_supplies = \
5017 ARRAY_SIZE(vreg_consumers_##_id), \
5018 .consumer_supplies = vreg_consumers_##_id, \
5019 }, \
5020 .regulator_name = _reg_name, \
5021 .active_low = _active_low, \
5022 .gpio_label = _gpio_label, \
5023 .gpio = _gpio, \
5024 }
5025
5026/* GPIO regulator constraints */
5027static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5028 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5029 PM8901_MPP_PM_TO_SYS(0), 0),
5030};
5031
5032/* GPIO regulator */
5033static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5034 .name = GPIO_REGULATOR_DEV_NAME,
5035 .id = PM8901_MPP_PM_TO_SYS(0),
5036 .dev = {
5037 .platform_data =
5038 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5039 },
5040};
5041
5042static void __init pm8901_vreg_mpp0_init(void)
5043{
5044 int rc;
5045
5046 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5047 .mpp = PM8901_MPP_PM_TO_SYS(0),
5048 .config = {
5049 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5050 .level = PM8901_MPP_DIG_LEVEL_VPH,
5051 },
5052 };
5053
5054 /*
5055 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5056 * implies that the regulator connected to MPP0 is enabled when
5057 * MPP0 is low.
5058 */
5059 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5060 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5061 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5062 } else {
5063 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5064 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5065 }
5066
5067 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5068 if (rc)
5069 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5070}
5071
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005072static struct platform_device *charm_devices[] __initdata = {
5073 &msm_charm_modem,
5074#ifdef CONFIG_MSM_SDIO_AL
5075 &msm_device_sdio_al,
5076#endif
5077};
5078
Lei Zhou338cab82011-08-19 13:38:17 -04005079#ifdef CONFIG_SND_SOC_MSM8660_APQ
5080static struct platform_device *dragon_alsa_devices[] __initdata = {
5081 &msm_pcm,
5082 &msm_pcm_routing,
5083 &msm_cpudai0,
5084 &msm_cpudai1,
5085 &msm_cpudai_hdmi_rx,
5086 &msm_cpudai_bt_rx,
5087 &msm_cpudai_bt_tx,
5088 &msm_cpudai_fm_rx,
5089 &msm_cpudai_fm_tx,
5090 &msm_cpu_fe,
5091 &msm_stub_codec,
5092 &msm_lpa_pcm,
5093};
5094#endif
5095
5096static struct platform_device *asoc_devices[] __initdata = {
5097 &asoc_msm_pcm,
5098 &asoc_msm_dai0,
5099 &asoc_msm_dai1,
5100};
5101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005102static struct platform_device *surf_devices[] __initdata = {
5103 &msm_device_smd,
5104 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005105 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005106 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005107 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005108 &msm_pil_dsps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005109#ifdef CONFIG_I2C_QUP
5110 &msm_gsbi3_qup_i2c_device,
5111 &msm_gsbi4_qup_i2c_device,
5112 &msm_gsbi7_qup_i2c_device,
5113 &msm_gsbi8_qup_i2c_device,
5114 &msm_gsbi9_qup_i2c_device,
5115 &msm_gsbi12_qup_i2c_device,
5116#endif
5117#ifdef CONFIG_SERIAL_MSM_HS
5118 &msm_device_uart_dm1,
5119#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305120#ifdef CONFIG_MSM_SSBI
5121 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305122 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305123#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005124#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005125 &msm_device_ssbi3,
5126#endif
5127#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5128 &isp1763_device,
5129#endif
5130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005131#if defined (CONFIG_MSM_8x60_VOIP)
5132 &asoc_msm_mvs,
5133 &asoc_mvs_dai0,
5134 &asoc_mvs_dai1,
5135#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005136
Lena Salman57d167e2012-03-21 19:46:38 +02005137#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005138 &msm_device_otg,
5139#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005140#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005141 &msm_device_gadget_peripheral,
5142#endif
5143#ifdef CONFIG_USB_G_ANDROID
5144 &android_usb_device,
5145#endif
5146#ifdef CONFIG_BATTERY_MSM
5147 &msm_batt_device,
5148#endif
5149#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005150#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151 &android_pmem_device,
5152 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005153 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005154 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305155#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5156#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157#ifdef CONFIG_MSM_ROTATOR
5158 &msm_rotator_device,
5159#endif
5160 &msm_fb_device,
5161 &msm_kgsl_3d0,
5162 &msm_kgsl_2d0,
5163 &msm_kgsl_2d1,
5164 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005165#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5166 &lcdc_nt35582_panel_device,
5167#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005168#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5169 &lcdc_samsung_oled_panel_device,
5170#endif
5171#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5172 &lcdc_auo_wvga_panel_device,
5173#endif
5174#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5175 &hdmi_msm_device,
5176#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5177#ifdef CONFIG_FB_MSM_MIPI_DSI
5178 &mipi_dsi_toshiba_panel_device,
5179 &mipi_dsi_novatek_panel_device,
5180#endif
5181#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005182#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005183#ifdef CONFIG_MT9E013
5184 &msm_camera_sensor_mt9e013,
5185#endif
5186#ifdef CONFIG_IMX074
5187 &msm_camera_sensor_imx074,
5188#endif
5189#ifdef CONFIG_WEBCAM_OV7692
5190 &msm_camera_sensor_webcam_ov7692,
5191#endif
5192#ifdef CONFIG_WEBCAM_OV9726
5193 &msm_camera_sensor_webcam_ov9726,
5194#endif
5195#ifdef CONFIG_QS_S5K4E1
5196 &msm_camera_sensor_qs_s5k4e1,
5197#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005198#ifdef CONFIG_VX6953
5199 &msm_camera_sensor_vx6953,
5200#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005201#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005202#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203#ifdef CONFIG_MSM_GEMINI
5204 &msm_gemini_device,
5205#endif
5206#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005207#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005208 &msm_vpe_device,
5209#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005210#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211
5212#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005213 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005214#endif
5215#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005216 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005217#endif
5218 &msm_device_vidc,
5219#if (defined(CONFIG_MARIMBA_CORE)) && \
5220 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5221 &msm_bt_power_device,
5222#endif
5223#ifdef CONFIG_SENSORS_MSM_ADC
5224 &msm_adc_device,
5225#endif
David Collins6f032ba2011-08-31 14:08:15 -07005226 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005227
5228#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5229 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5230 &qcrypto_device,
5231#endif
5232
5233#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5234 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5235 &qcedev_device,
5236#endif
5237
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005238
5239#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5240#ifdef CONFIG_MSM_USE_TSIF1
5241 &msm_device_tsif[1],
5242#else
5243 &msm_device_tsif[0],
5244#endif /* CONFIG_MSM_USE_TSIF1 */
5245#endif /* CONFIG_TSIF */
5246
5247#ifdef CONFIG_HW_RANDOM_MSM
5248 &msm_device_rng,
5249#endif
5250
5251 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005252 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005253#ifdef CONFIG_ION_MSM
5254 &ion_dev,
5255#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005256 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005257 &msm_device_tz_log,
5258
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005259};
5260
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005261#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005262#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5263static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5264 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan42ebe712012-01-10 16:30:58 -08005265 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005266 .request_region = request_smi_region,
5267 .release_region = release_smi_region,
5268 .setup_region = setup_smi_region,
5269};
5270
5271static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5272 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005273 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005274 .request_region = request_smi_region,
5275 .release_region = release_smi_region,
5276 .setup_region = setup_smi_region,
5277};
5278
5279static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5280 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005281 .align = PAGE_SIZE,
5282};
5283
5284static struct ion_co_heap_pdata fw_co_ion_pdata = {
5285 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5286 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005287};
5288
5289static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005290 .adjacent_mem_id = INVALID_HEAP_ID,
5291 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005292};
5293#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005294
5295/**
5296 * These heaps are listed in the order they will be allocated. Due to
5297 * video hardware restrictions and content protection the FW heap has to
5298 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5299 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5300 * away from the base address of the FW heap.
5301 * However, the order of FW heap and MM heap doesn't matter since these
5302 * two heaps are taken care of by separate code to ensure they are adjacent
5303 * to each other.
5304 * Don't swap the order unless you know what you are doing!
5305 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005306static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005307 .nr = MSM_ION_HEAP_NUM,
5308 .heaps = {
5309 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005310 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005311 .type = ION_HEAP_TYPE_SYSTEM,
5312 .name = ION_VMALLOC_HEAP_NAME,
5313 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005314#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5315 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005316 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005317 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005318 .name = ION_MM_HEAP_NAME,
5319 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005320 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005321 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005322 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005323 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005324 .id = ION_MM_FIRMWARE_HEAP_ID,
5325 .type = ION_HEAP_TYPE_CARVEOUT,
5326 .name = ION_MM_FIRMWARE_HEAP_NAME,
5327 .size = MSM_ION_MM_FW_SIZE,
5328 .memory_type = ION_SMI_TYPE,
5329 .extra_data = (void *) &fw_co_ion_pdata,
5330 },
5331 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005332 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005333 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005334 .name = ION_MFC_HEAP_NAME,
5335 .size = MSM_ION_MFC_SIZE,
5336 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005337 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005338 },
5339 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005340 .id = ION_SF_HEAP_ID,
5341 .type = ION_HEAP_TYPE_CARVEOUT,
5342 .name = ION_SF_HEAP_NAME,
5343 .size = MSM_ION_SF_SIZE,
5344 .memory_type = ION_EBI_TYPE,
5345 .extra_data = (void *)&co_ion_pdata,
5346 },
5347 {
5348 .id = ION_CAMERA_HEAP_ID,
5349 .type = ION_HEAP_TYPE_CARVEOUT,
5350 .name = ION_CAMERA_HEAP_NAME,
5351 .size = MSM_ION_CAMERA_SIZE,
5352 .memory_type = ION_EBI_TYPE,
5353 .extra_data = &co_ion_pdata,
5354 },
5355 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005356 .id = ION_CP_WB_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_WB_HEAP_NAME,
5359 .size = MSM_ION_WB_SIZE,
5360 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005361 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005362 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005363 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005364 .id = ION_QSECOM_HEAP_ID,
5365 .type = ION_HEAP_TYPE_CARVEOUT,
5366 .name = ION_QSECOM_HEAP_NAME,
5367 .size = MSM_ION_QSECOM_SIZE,
5368 .memory_type = ION_EBI_TYPE,
5369 .extra_data = (void *) &co_ion_pdata,
5370 },
5371 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005372 .id = ION_AUDIO_HEAP_ID,
5373 .type = ION_HEAP_TYPE_CARVEOUT,
5374 .name = ION_AUDIO_HEAP_NAME,
5375 .size = MSM_ION_AUDIO_SIZE,
5376 .memory_type = ION_EBI_TYPE,
5377 .extra_data = (void *)&co_ion_pdata,
5378 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005379#endif
5380 }
5381};
5382
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005383static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005384 .name = "ion-msm",
5385 .id = 1,
5386 .dev = { .platform_data = &ion_pdata },
5387};
5388#endif
5389
5390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005391static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5392 /* Kernel SMI memory pool for video core, used for firmware */
5393 /* and encoder, decoder scratch buffers */
5394 /* Kernel SMI memory pool should always precede the user space */
5395 /* SMI memory pool, as the video core will use offset address */
5396 /* from the Firmware base */
5397 [MEMTYPE_SMI_KERNEL] = {
5398 .start = KERNEL_SMI_BASE,
5399 .limit = KERNEL_SMI_SIZE,
5400 .size = KERNEL_SMI_SIZE,
5401 .flags = MEMTYPE_FLAGS_FIXED,
5402 },
5403 /* User space SMI memory pool for video core */
5404 /* used for encoder, decoder input & output buffers */
5405 [MEMTYPE_SMI] = {
5406 .start = USER_SMI_BASE,
5407 .limit = USER_SMI_SIZE,
5408 .flags = MEMTYPE_FLAGS_FIXED,
5409 },
5410 [MEMTYPE_EBI0] = {
5411 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5412 },
5413 [MEMTYPE_EBI1] = {
5414 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5415 },
5416};
5417
Stephen Boyd668d7652012-04-25 11:31:01 -07005418static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005419{
5420#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005421 unsigned int i;
5422
5423 if (hdmi_is_primary) {
5424 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5425 for (i = 0; i < ion_pdata.nr; i++) {
5426 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5427 ion_pdata.heaps[i].size = msm_ion_sf_size;
5428 pr_debug("msm_ion_sf_size 0x%x\n",
5429 msm_ion_sf_size);
5430 break;
5431 }
5432 }
5433 }
5434
5435 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Haugan42ebe712012-01-10 16:30:58 -08005436 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005437 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5438 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5439 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5440 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005441 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005442 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005443#endif
5444}
5445
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005446static void __init size_pmem_devices(void)
5447{
5448#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005449#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005450 android_pmem_adsp_pdata.size = pmem_adsp_size;
5451 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005452
5453 if (hdmi_is_primary)
5454 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005456 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305457#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5458#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005459}
5460
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305461#ifdef CONFIG_ANDROID_PMEM
5462#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005463static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5464{
5465 msm8x60_reserve_table[p->memory_type].size += p->size;
5466}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305467#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5468#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005469
5470static void __init reserve_pmem_memory(void)
5471{
5472#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005473#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005474 reserve_memory_for(&android_pmem_adsp_pdata);
5475 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005476 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005477 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305478#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005479 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305480#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005481}
5482
Huaibin Yanga5419422011-12-08 23:52:10 -08005483static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005484
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005485static void __init msm8x60_calculate_reserve_sizes(void)
5486{
5487 size_pmem_devices();
5488 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005489 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005490 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005491}
5492
5493static int msm8x60_paddr_to_memtype(unsigned int paddr)
5494{
5495 if (paddr >= 0x40000000 && paddr < 0x60000000)
5496 return MEMTYPE_EBI1;
5497 if (paddr >= 0x38000000 && paddr < 0x40000000)
5498 return MEMTYPE_SMI;
5499 return MEMTYPE_NONE;
5500}
5501
5502static struct reserve_info msm8x60_reserve_info __initdata = {
5503 .memtype_reserve_table = msm8x60_reserve_table,
5504 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5505 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5506};
5507
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005508static char prim_panel_name[PANEL_NAME_MAX_LEN];
5509static char ext_panel_name[PANEL_NAME_MAX_LEN];
5510static int __init prim_display_setup(char *param)
5511{
5512 if (strnlen(param, PANEL_NAME_MAX_LEN))
5513 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5514 return 0;
5515}
5516early_param("prim_display", prim_display_setup);
5517
5518static int __init ext_display_setup(char *param)
5519{
5520 if (strnlen(param, PANEL_NAME_MAX_LEN))
5521 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5522 return 0;
5523}
5524early_param("ext_display", ext_display_setup);
5525
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005526static void __init msm8x60_reserve(void)
5527{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005528 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005529 reserve_info = &msm8x60_reserve_info;
5530 msm_reserve();
5531}
5532
5533#define EXT_CHG_VALID_MPP 10
5534#define EXT_CHG_VALID_MPP_2 11
5535
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305536static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305537 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305538 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305539 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305540 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5541};
5542
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005543#ifdef CONFIG_ISL9519_CHARGER
5544static int isl_detection_setup(void)
5545{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305546 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005547
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305548 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5549 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5550 &isl_mpp[i].config);
5551 if (ret) {
5552 pr_err("%s: Config MPP %d of PM8058 failed\n",
5553 __func__, isl_mpp[i].mpp);
5554 return ret;
5555 }
5556 }
5557
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005558 return ret;
5559}
5560
5561static struct isl_platform_data isl_data __initdata = {
5562 .chgcurrent = 700,
5563 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5564 .chg_detection_config = isl_detection_setup,
5565 .max_system_voltage = 4200,
5566 .min_system_voltage = 3200,
5567 .term_current = 120,
5568 .input_current = 2048,
5569};
5570
5571static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5572 {
5573 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305574 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005575 .platform_data = &isl_data,
5576 },
5577};
5578#endif
5579
5580#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5581static int smb137b_detection_setup(void)
5582{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305583 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005584
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305585 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5586 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5587 &isl_mpp[i].config);
5588 if (ret) {
5589 pr_err("%s: Config MPP %d of PM8058 failed\n",
5590 __func__, isl_mpp[i].mpp);
5591 return ret;
5592 }
5593 }
5594
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005595 return ret;
5596}
5597
5598static struct smb137b_platform_data smb137b_data __initdata = {
5599 .chg_detection_config = smb137b_detection_setup,
5600 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5601 .batt_mah_rating = 950,
5602};
5603
5604static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5605 {
5606 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305607 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608 .platform_data = &smb137b_data,
5609 },
5610};
5611#endif
5612
5613#ifdef CONFIG_PMIC8058
5614#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305615#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616
5617static int pm8058_gpios_init(void)
5618{
5619 int i;
5620 int rc;
5621 struct pm8058_gpio_cfg {
5622 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305623 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005624 };
5625
5626 struct pm8058_gpio_cfg gpio_cfgs[] = {
5627 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305628 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005629 {
5630 .direction = PM_GPIO_DIR_IN,
5631 .pull = PM_GPIO_PULL_DN,
5632 .vin_sel = 2,
5633 .function = PM_GPIO_FUNC_NORMAL,
5634 .inv_int_pol = 0,
5635 },
5636 },
5637#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5638 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305639 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005640 {
5641 .direction = PM_GPIO_DIR_IN,
5642 .pull = PM_GPIO_PULL_UP_30,
5643 .vin_sel = 2,
5644 .function = PM_GPIO_FUNC_NORMAL,
5645 .inv_int_pol = 0,
5646 },
5647 },
5648#endif
5649 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305650 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005651 {
5652 .direction = PM_GPIO_DIR_IN,
5653 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305654 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005655 .function = PM_GPIO_FUNC_NORMAL,
5656 .inv_int_pol = 0,
5657 },
5658 },
5659 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305660 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005661 {
5662 .direction = PM_GPIO_DIR_IN,
5663 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305664 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005665 .function = PM_GPIO_FUNC_NORMAL,
5666 .inv_int_pol = 0,
5667 },
5668 },
5669 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305670 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005671 {
5672 .direction = PM_GPIO_DIR_IN,
5673 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305674 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005675 .function = PM_GPIO_FUNC_NORMAL,
5676 .inv_int_pol = 0,
5677 },
5678 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005679 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305680 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005681 {
5682 .direction = PM_GPIO_DIR_OUT,
5683 .output_value = 1,
5684 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5685 .pull = PM_GPIO_PULL_DN,
5686 .out_strength = PM_GPIO_STRENGTH_HIGH,
5687 .function = PM_GPIO_FUNC_NORMAL,
5688 .vin_sel = 2,
5689 .inv_int_pol = 0,
5690 }
5691 },
5692 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305693 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005694 {
5695 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305696 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005697 .function = PM_GPIO_FUNC_NORMAL,
5698 .vin_sel = 2,
5699 .inv_int_pol = 0,
5700 }
5701 },
5702 };
5703
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305704#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5705 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305706 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305707 .direction = PM_GPIO_DIR_IN,
5708 .pull = PM_GPIO_PULL_UP_1P5,
5709 .vin_sel = 2,
5710 .function = PM_GPIO_FUNC_NORMAL,
5711 };
5712#endif
5713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005714#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305715 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305716 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305717 .direction = PM_GPIO_DIR_OUT,
5718 .pull = PM_GPIO_PULL_NO,
5719 .out_strength = PM_GPIO_STRENGTH_HIGH,
5720 .function = PM_GPIO_FUNC_NORMAL,
5721 .inv_int_pol = 0,
5722 .vin_sel = 2,
5723 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5724 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725 };
5726#endif
5727
5728#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5729 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305730 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005731 {
5732 .direction = PM_GPIO_DIR_IN,
5733 .pull = PM_GPIO_PULL_UP_1P5,
5734 .vin_sel = 2,
5735 .function = PM_GPIO_FUNC_NORMAL,
5736 .inv_int_pol = 0,
5737 }
5738 };
5739#endif
5740
5741#if defined(CONFIG_QS_S5K4E1)
5742 {
5743 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305744 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005745 {
5746 .direction = PM_GPIO_DIR_OUT,
5747 .output_value = 0,
5748 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5749 .pull = PM_GPIO_PULL_DN,
5750 .out_strength = PM_GPIO_STRENGTH_HIGH,
5751 .function = PM_GPIO_FUNC_NORMAL,
5752 .vin_sel = 2,
5753 .inv_int_pol = 0,
5754 }
5755 };
5756#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005757#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5758 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305759 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005760 {
5761 .direction = PM_GPIO_DIR_OUT,
5762 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5763 .output_value = 1,
5764 .pull = PM_GPIO_PULL_UP_30,
5765 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305766 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005767 .out_strength = PM_GPIO_STRENGTH_HIGH,
5768 .function = PM_GPIO_FUNC_NORMAL,
5769 .inv_int_pol = 0,
5770 }
5771 };
5772#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005773#if defined(CONFIG_HAPTIC_ISA1200) || \
5774 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5775 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305776 rc = pm8xxx_gpio_config(
5777 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5778 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005779 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305780 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305782 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305783 rc = pm8xxx_gpio_config(
5784 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5785 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305786 if (rc < 0) {
5787 pr_err("%s: pmic haptics ldo gpio config failed\n",
5788 __func__);
5789 }
5790
5791 }
5792#endif
5793
5794#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5795 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5796 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5797 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305798 rc = pm8xxx_gpio_config(
5799 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5800 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305801 if (rc < 0) {
5802 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5803 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005804 }
5805 }
5806#endif
5807
5808#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5809 /* Line_in only for 8660 ffa & surf */
5810 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005811 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005812 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305813 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005814 &line_in_gpio_cfg.cfg);
5815 if (rc < 0) {
5816 pr_err("%s pmic line_in gpio config failed\n",
5817 __func__);
5818 return rc;
5819 }
5820 }
5821#endif
5822
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005823#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5824 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305825 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005826 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5827 if (rc < 0) {
5828 pr_err("%s pmic gpio config failed\n", __func__);
5829 return rc;
5830 }
5831 }
5832#endif
5833
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005834#if defined(CONFIG_QS_S5K4E1)
5835 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5836 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305837 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005838 &qs_hc37_cam_pd_gpio_cfg.cfg);
5839 if (rc < 0) {
5840 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5841 __func__);
5842 return rc;
5843 }
5844 }
5845 }
5846#endif
5847
5848 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305849 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005850 &gpio_cfgs[i].cfg);
5851 if (rc < 0) {
5852 pr_err("%s pmic gpio config failed\n",
5853 __func__);
5854 return rc;
5855 }
5856 }
5857
5858 return 0;
5859}
5860
5861static const unsigned int ffa_keymap[] = {
5862 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5863 KEY(0, 1, KEY_UP), /* NAV - UP */
5864 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5865 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5866
5867 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5868 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5869 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5870 KEY(1, 3, KEY_VOLUMEDOWN),
5871
5872 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5873
5874 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5875 KEY(4, 1, KEY_UP), /* USER_UP */
5876 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5877 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5878 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5879
5880 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5881 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5882 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5883 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5884 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5885};
5886
Zhang Chang Ken683be172011-08-10 17:45:34 -04005887static const unsigned int dragon_keymap[] = {
5888 KEY(0, 0, KEY_MENU),
5889 KEY(0, 2, KEY_1),
5890 KEY(0, 3, KEY_4),
5891 KEY(0, 4, KEY_7),
5892
5893 KEY(1, 0, KEY_UP),
5894 KEY(1, 1, KEY_LEFT),
5895 KEY(1, 2, KEY_DOWN),
5896 KEY(1, 3, KEY_5),
5897 KEY(1, 4, KEY_8),
5898
5899 KEY(2, 0, KEY_HOME),
5900 KEY(2, 1, KEY_REPLY),
5901 KEY(2, 2, KEY_2),
5902 KEY(2, 3, KEY_6),
5903 KEY(2, 4, KEY_0),
5904
5905 KEY(3, 0, KEY_VOLUMEUP),
5906 KEY(3, 1, KEY_RIGHT),
5907 KEY(3, 2, KEY_3),
5908 KEY(3, 3, KEY_9),
5909 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5910
5911 KEY(4, 0, KEY_VOLUMEDOWN),
5912 KEY(4, 1, KEY_BACK),
5913 KEY(4, 2, KEY_CAMERA),
5914 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5915};
5916
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005917static struct matrix_keymap_data ffa_keymap_data = {
5918 .keymap_size = ARRAY_SIZE(ffa_keymap),
5919 .keymap = ffa_keymap,
5920};
5921
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305922static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005923 .input_name = "ffa-keypad",
5924 .input_phys_device = "ffa-keypad/input0",
5925 .num_rows = 6,
5926 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305927 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5928 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5929 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005930 .scan_delay_ms = 32,
5931 .row_hold_ns = 91500,
5932 .wakeup = 1,
5933 .keymap_data = &ffa_keymap_data,
5934};
5935
Zhang Chang Ken683be172011-08-10 17:45:34 -04005936static struct matrix_keymap_data dragon_keymap_data = {
5937 .keymap_size = ARRAY_SIZE(dragon_keymap),
5938 .keymap = dragon_keymap,
5939};
5940
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305941static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005942 .input_name = "dragon-keypad",
5943 .input_phys_device = "dragon-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,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005949 .scan_delay_ms = 32,
5950 .row_hold_ns = 91500,
5951 .wakeup = 1,
5952 .keymap_data = &dragon_keymap_data,
5953};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305954
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005955static const unsigned int fluid_keymap[] = {
5956 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5957 KEY(0, 1, KEY_UP), /* NAV - UP */
5958 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5959 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5960
5961 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5962 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5963 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5964 KEY(1, 3, KEY_VOLUMEUP),
5965
5966 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5967
5968 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5969 KEY(4, 1, KEY_UP), /* USER_UP */
5970 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5971 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5972 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5973
Jilai Wang9a895102011-07-12 14:00:35 -04005974 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005975 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5976 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5977 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5978 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5979};
5980
5981static struct matrix_keymap_data fluid_keymap_data = {
5982 .keymap_size = ARRAY_SIZE(fluid_keymap),
5983 .keymap = fluid_keymap,
5984};
5985
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305986static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005987 .input_name = "fluid-keypad",
5988 .input_phys_device = "fluid-keypad/input0",
5989 .num_rows = 6,
5990 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305991 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5992 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5993 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005994 .scan_delay_ms = 32,
5995 .row_hold_ns = 91500,
5996 .wakeup = 1,
5997 .keymap_data = &fluid_keymap_data,
5998};
5999
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306000static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006001 .initial_vibrate_ms = 500,
6002 .level_mV = 3000,
6003 .max_timeout_ms = 15000,
6004};
6005
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306006static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6007 .rtc_write_enable = false,
6008 .rtc_alarm_powerup = false,
6009};
6010
6011static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6012 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006013 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306014 .wakeup = 1,
6015};
6016
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006017#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6018
6019static struct othc_accessory_info othc_accessories[] = {
6020 {
6021 .accessory = OTHC_SVIDEO_OUT,
6022 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6023 | OTHC_ADC_DETECT,
6024 .key_code = SW_VIDEOOUT_INSERT,
6025 .enabled = false,
6026 .adc_thres = {
6027 .min_threshold = 20,
6028 .max_threshold = 40,
6029 },
6030 },
6031 {
6032 .accessory = OTHC_ANC_HEADPHONE,
6033 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6034 OTHC_SWITCH_DETECT,
6035 .gpio = PM8058_LINE_IN_DET_GPIO,
6036 .active_low = 1,
6037 .key_code = SW_HEADPHONE_INSERT,
6038 .enabled = true,
6039 },
6040 {
6041 .accessory = OTHC_ANC_HEADSET,
6042 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6043 .gpio = PM8058_LINE_IN_DET_GPIO,
6044 .active_low = 1,
6045 .key_code = SW_HEADPHONE_INSERT,
6046 .enabled = true,
6047 },
6048 {
6049 .accessory = OTHC_HEADPHONE,
6050 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6051 .key_code = SW_HEADPHONE_INSERT,
6052 .enabled = true,
6053 },
6054 {
6055 .accessory = OTHC_MICROPHONE,
6056 .detect_flags = OTHC_GPIO_DETECT,
6057 .gpio = PM8058_LINE_IN_DET_GPIO,
6058 .active_low = 1,
6059 .key_code = SW_MICROPHONE_INSERT,
6060 .enabled = true,
6061 },
6062 {
6063 .accessory = OTHC_HEADSET,
6064 .detect_flags = OTHC_MICBIAS_DETECT,
6065 .key_code = SW_HEADPHONE_INSERT,
6066 .enabled = true,
6067 },
6068};
6069
6070static struct othc_switch_info switch_info[] = {
6071 {
6072 .min_adc_threshold = 0,
6073 .max_adc_threshold = 100,
6074 .key_code = KEY_PLAYPAUSE,
6075 },
6076 {
6077 .min_adc_threshold = 100,
6078 .max_adc_threshold = 200,
6079 .key_code = KEY_REWIND,
6080 },
6081 {
6082 .min_adc_threshold = 200,
6083 .max_adc_threshold = 500,
6084 .key_code = KEY_FASTFORWARD,
6085 },
6086};
6087
6088static struct othc_n_switch_config switch_config = {
6089 .voltage_settling_time_ms = 0,
6090 .num_adc_samples = 3,
6091 .adc_channel = CHANNEL_ADC_HDSET,
6092 .switch_info = switch_info,
6093 .num_keys = ARRAY_SIZE(switch_info),
6094 .default_sw_en = true,
6095 .default_sw_idx = 0,
6096};
6097
6098static struct hsed_bias_config hsed_bias_config = {
6099 /* HSED mic bias config info */
6100 .othc_headset = OTHC_HEADSET_NO,
6101 .othc_lowcurr_thresh_uA = 100,
6102 .othc_highcurr_thresh_uA = 600,
6103 .othc_hyst_prediv_us = 7800,
6104 .othc_period_clkdiv_us = 62500,
6105 .othc_hyst_clk_us = 121000,
6106 .othc_period_clk_us = 312500,
6107 .othc_wakeup = 1,
6108};
6109
6110static struct othc_hsed_config hsed_config_1 = {
6111 .hsed_bias_config = &hsed_bias_config,
6112 /*
6113 * The detection delay and switch reporting delay are
6114 * required to encounter a hardware bug (spurious switch
6115 * interrupts on slow insertion/removal of the headset).
6116 * This will introduce a delay in reporting the accessory
6117 * insertion and removal to the userspace.
6118 */
6119 .detection_delay_ms = 1500,
6120 /* Switch info */
6121 .switch_debounce_ms = 1500,
6122 .othc_support_n_switch = false,
6123 .switch_config = &switch_config,
6124 .ir_gpio = -1,
6125 /* Accessory info */
6126 .accessories_support = true,
6127 .accessories = othc_accessories,
6128 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6129};
6130
6131static struct othc_regulator_config othc_reg = {
6132 .regulator = "8058_l5",
6133 .max_uV = 2850000,
6134 .min_uV = 2850000,
6135};
6136
6137/* MIC_BIAS0 is configured as normal MIC BIAS */
6138static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6139 .micbias_select = OTHC_MICBIAS_0,
6140 .micbias_capability = OTHC_MICBIAS,
6141 .micbias_enable = OTHC_SIGNAL_OFF,
6142 .micbias_regulator = &othc_reg,
6143};
6144
6145/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6146static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6147 .micbias_select = OTHC_MICBIAS_1,
6148 .micbias_capability = OTHC_MICBIAS_HSED,
6149 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6150 .micbias_regulator = &othc_reg,
6151 .hsed_config = &hsed_config_1,
6152 .hsed_name = "8660_handset",
6153};
6154
6155/* MIC_BIAS2 is configured as normal MIC BIAS */
6156static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6157 .micbias_select = OTHC_MICBIAS_2,
6158 .micbias_capability = OTHC_MICBIAS,
6159 .micbias_enable = OTHC_SIGNAL_OFF,
6160 .micbias_regulator = &othc_reg,
6161};
6162
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006163
6164static void __init msm8x60_init_pm8058_othc(void)
6165{
6166 int i;
6167
6168 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6169 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6170 machine_is_msm8x60_fusn_ffa()) {
6171 /* 3-switch headset supported only by V2 FFA and FLUID */
6172 hsed_config_1.accessories_adc_support = true,
6173 /* ADC based accessory detection works only on V2 and FLUID */
6174 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6175 hsed_config_1.othc_support_n_switch = true;
6176 }
6177
6178 /* IR GPIO is absent on FLUID */
6179 if (machine_is_msm8x60_fluid())
6180 hsed_config_1.ir_gpio = -1;
6181
6182 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6183 if (machine_is_msm8x60_fluid()) {
6184 switch (othc_accessories[i].accessory) {
6185 case OTHC_ANC_HEADPHONE:
6186 case OTHC_ANC_HEADSET:
6187 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6188 break;
6189 case OTHC_MICROPHONE:
6190 othc_accessories[i].enabled = false;
6191 break;
6192 case OTHC_SVIDEO_OUT:
6193 othc_accessories[i].enabled = true;
6194 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6195 break;
6196 }
6197 }
6198 }
6199}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006201
6202static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6203{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306204 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006205 .direction = PM_GPIO_DIR_OUT,
6206 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6207 .output_value = 0,
6208 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306209 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006210 .out_strength = PM_GPIO_STRENGTH_HIGH,
6211 .function = PM_GPIO_FUNC_2,
6212 };
6213
6214 int rc = -EINVAL;
6215 int id, mode, max_mA;
6216
6217 id = mode = max_mA = 0;
6218 switch (ch) {
6219 case 0:
6220 case 1:
6221 case 2:
6222 if (on) {
6223 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306224 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6225 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006226 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306227 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006228 __func__, id, rc);
6229 }
6230 break;
6231
6232 case 6:
6233 id = PM_PWM_LED_FLASH;
6234 mode = PM_PWM_CONF_PWM1;
6235 max_mA = 300;
6236 break;
6237
6238 case 7:
6239 id = PM_PWM_LED_FLASH1;
6240 mode = PM_PWM_CONF_PWM1;
6241 max_mA = 300;
6242 break;
6243
6244 default:
6245 break;
6246 }
6247
6248 if (ch >= 6 && ch <= 7) {
6249 if (!on) {
6250 mode = PM_PWM_CONF_NONE;
6251 max_mA = 0;
6252 }
6253 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6254 if (rc)
6255 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6256 __func__, ch, rc);
6257 }
6258 return rc;
6259
6260}
6261
6262static struct pm8058_pwm_pdata pm8058_pwm_data = {
6263 .config = pm8058_pwm_config,
6264};
6265
6266#define PM8058_GPIO_INT 88
6267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268static struct pmic8058_led pmic8058_flash_leds[] = {
6269 [0] = {
6270 .name = "camera:flash0",
6271 .max_brightness = 15,
6272 .id = PMIC8058_ID_FLASH_LED_0,
6273 },
6274 [1] = {
6275 .name = "camera:flash1",
6276 .max_brightness = 15,
6277 .id = PMIC8058_ID_FLASH_LED_1,
6278 },
6279};
6280
6281static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6282 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6283 .leds = pmic8058_flash_leds,
6284};
6285
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006286static struct pmic8058_led pmic8058_dragon_leds[] = {
6287 [0] = {
6288 /* RED */
6289 .name = "led_drv0",
6290 .max_brightness = 15,
6291 .id = PMIC8058_ID_LED_0,
6292 },/* 300 mA flash led0 drv sink */
6293 [1] = {
6294 /* Yellow */
6295 .name = "led_drv1",
6296 .max_brightness = 15,
6297 .id = PMIC8058_ID_LED_1,
6298 },/* 300 mA flash led0 drv sink */
6299 [2] = {
6300 /* Green */
6301 .name = "led_drv2",
6302 .max_brightness = 15,
6303 .id = PMIC8058_ID_LED_2,
6304 },/* 300 mA flash led0 drv sink */
6305 [3] = {
6306 .name = "led_psensor",
6307 .max_brightness = 15,
6308 .id = PMIC8058_ID_LED_KB_LIGHT,
6309 },/* 300 mA flash led0 drv sink */
6310};
6311
6312static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6313 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6314 .leds = pmic8058_dragon_leds,
6315};
6316
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006317static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6318 [0] = {
6319 .name = "led:drv0",
6320 .max_brightness = 15,
6321 .id = PMIC8058_ID_FLASH_LED_0,
6322 },/* 300 mA flash led0 drv sink */
6323 [1] = {
6324 .name = "led:drv1",
6325 .max_brightness = 15,
6326 .id = PMIC8058_ID_FLASH_LED_1,
6327 },/* 300 mA flash led1 sink */
6328 [2] = {
6329 .name = "led:drv2",
6330 .max_brightness = 20,
6331 .id = PMIC8058_ID_LED_0,
6332 },/* 40 mA led0 sink */
6333 [3] = {
6334 .name = "keypad:drv",
6335 .max_brightness = 15,
6336 .id = PMIC8058_ID_LED_KB_LIGHT,
6337 },/* 300 mA keypad drv sink */
6338};
6339
6340static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6341 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6342 .leds = pmic8058_fluid_flash_leds,
6343};
6344
Terence Hampson90508a92011-08-09 10:40:08 -04006345static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306346 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006347 .max_source_current = 1800,
6348 .charger_type = CHG_TYPE_AC,
6349};
6350
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306351static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6352 .charger_data_valid = false,
6353};
6354
6355static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6356 .priority = 0,
6357};
6358
6359static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6360 .irq_base = PM8058_IRQ_BASE,
6361 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6362 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6363};
6364
6365static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6366 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6367};
6368
6369static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6370 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006371};
6372
6373static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306374 .irq_pdata = &pm8058_irq_pdata,
6375 .gpio_pdata = &pm8058_gpio_pdata,
6376 .mpp_pdata = &pm8058_mpp_pdata,
6377 .rtc_pdata = &pm8058_rtc_pdata,
6378 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6379 .othc0_pdata = &othc_config_pdata_0,
6380 .othc1_pdata = &othc_config_pdata_1,
6381 .othc2_pdata = &othc_config_pdata_2,
6382 .pwm_pdata = &pm8058_pwm_data,
6383 .misc_pdata = &pm8058_misc_pdata,
6384#ifdef CONFIG_SENSORS_MSM_ADC
6385 .xoadc_pdata = &pm8058_xoadc_pdata,
6386#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006387};
6388
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306389#ifdef CONFIG_MSM_SSBI
6390static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6391 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6392 .slave = {
6393 .name = "pm8058-core",
6394 .platform_data = &pm8058_platform_data,
6395 },
6396};
6397#endif
6398#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006399
6400#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6401 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6402#define TDISC_I2C_SLAVE_ADDR 0x67
6403#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6404#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6405
6406static const char *vregs_tdisc_name[] = {
6407 "8058_l5",
6408 "8058_s3",
6409};
6410
6411static const int vregs_tdisc_val[] = {
6412 2850000,/* uV */
6413 1800000,
6414};
6415static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6416
6417static int tdisc_shinetsu_setup(void)
6418{
6419 int rc, i;
6420
6421 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6422 if (rc) {
6423 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6424 __func__);
6425 return rc;
6426 }
6427
6428 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6429 if (rc) {
6430 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6431 __func__);
6432 goto fail_gpio_oe;
6433 }
6434
6435 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6436 if (rc) {
6437 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6438 __func__);
6439 gpio_free(GPIO_JOYSTICK_EN);
6440 goto fail_gpio_oe;
6441 }
6442
6443 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6444 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6445 if (IS_ERR(vregs_tdisc[i])) {
6446 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6447 __func__, vregs_tdisc_name[i],
6448 PTR_ERR(vregs_tdisc[i]));
6449 rc = PTR_ERR(vregs_tdisc[i]);
6450 goto vreg_get_fail;
6451 }
6452
6453 rc = regulator_set_voltage(vregs_tdisc[i],
6454 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6455 if (rc) {
6456 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6457 __func__, rc);
6458 goto vreg_set_voltage_fail;
6459 }
6460 }
6461
6462 return rc;
6463vreg_set_voltage_fail:
6464 i++;
6465vreg_get_fail:
6466 while (i)
6467 regulator_put(vregs_tdisc[--i]);
6468fail_gpio_oe:
6469 gpio_free(PMIC_GPIO_TDISC);
6470 return rc;
6471}
6472
6473static void tdisc_shinetsu_release(void)
6474{
6475 int i;
6476
6477 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6478 regulator_put(vregs_tdisc[i]);
6479
6480 gpio_free(PMIC_GPIO_TDISC);
6481 gpio_free(GPIO_JOYSTICK_EN);
6482}
6483
6484static int tdisc_shinetsu_enable(void)
6485{
6486 int i, rc = -EINVAL;
6487
6488 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6489 rc = regulator_enable(vregs_tdisc[i]);
6490 if (rc < 0) {
6491 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6492 __func__, vregs_tdisc_name[i], rc);
6493 goto vreg_fail;
6494 }
6495 }
6496
6497 /* Enable the OE (output enable) gpio */
6498 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6499 /* voltage and gpio stabilization delay */
6500 msleep(50);
6501
6502 return 0;
6503vreg_fail:
6504 while (i)
6505 regulator_disable(vregs_tdisc[--i]);
6506 return rc;
6507}
6508
6509static int tdisc_shinetsu_disable(void)
6510{
6511 int i, rc;
6512
6513 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6514 rc = regulator_disable(vregs_tdisc[i]);
6515 if (rc < 0) {
6516 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6517 __func__, vregs_tdisc_name[i], rc);
6518 goto tdisc_reg_fail;
6519 }
6520 }
6521
6522 /* Disable the OE (output enable) gpio */
6523 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6524
6525 return 0;
6526
6527tdisc_reg_fail:
6528 while (i)
6529 regulator_enable(vregs_tdisc[--i]);
6530 return rc;
6531}
6532
6533static struct tdisc_abs_values tdisc_abs = {
6534 .x_max = 32,
6535 .y_max = 32,
6536 .x_min = -32,
6537 .y_min = -32,
6538 .pressure_max = 32,
6539 .pressure_min = 0,
6540};
6541
6542static struct tdisc_platform_data tdisc_data = {
6543 .tdisc_setup = tdisc_shinetsu_setup,
6544 .tdisc_release = tdisc_shinetsu_release,
6545 .tdisc_enable = tdisc_shinetsu_enable,
6546 .tdisc_disable = tdisc_shinetsu_disable,
6547 .tdisc_wakeup = 0,
6548 .tdisc_gpio = PMIC_GPIO_TDISC,
6549 .tdisc_report_keys = true,
6550 .tdisc_report_relative = true,
6551 .tdisc_report_absolute = false,
6552 .tdisc_report_wheel = false,
6553 .tdisc_reverse_x = false,
6554 .tdisc_reverse_y = true,
6555 .tdisc_abs = &tdisc_abs,
6556};
6557
6558static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6559 {
6560 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6561 .irq = TDISC_INT,
6562 .platform_data = &tdisc_data,
6563 },
6564};
6565#endif
6566
6567#define PM_GPIO_CDC_RST_N 20
6568#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6569
6570static struct regulator *vreg_timpani_1;
6571static struct regulator *vreg_timpani_2;
6572
6573static unsigned int msm_timpani_setup_power(void)
6574{
6575 int rc;
6576
6577 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6578 if (IS_ERR(vreg_timpani_1)) {
6579 pr_err("%s: Unable to get 8058_l0\n", __func__);
6580 return -ENODEV;
6581 }
6582
6583 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6584 if (IS_ERR(vreg_timpani_2)) {
6585 pr_err("%s: Unable to get 8058_s3\n", __func__);
6586 regulator_put(vreg_timpani_1);
6587 return -ENODEV;
6588 }
6589
6590 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6591 if (rc) {
6592 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6593 goto fail;
6594 }
6595
6596 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6597 if (rc) {
6598 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6599 goto fail;
6600 }
6601
6602 rc = regulator_enable(vreg_timpani_1);
6603 if (rc) {
6604 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6605 goto fail;
6606 }
6607
6608 /* The settings for LDO0 should be set such that
6609 * it doesn't require to reset the timpani. */
6610 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6611 if (rc < 0) {
6612 pr_err("Timpani regulator optimum mode setting failed\n");
6613 goto fail;
6614 }
6615
6616 rc = regulator_enable(vreg_timpani_2);
6617 if (rc) {
6618 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6619 regulator_disable(vreg_timpani_1);
6620 goto fail;
6621 }
6622
6623 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6624 if (rc) {
6625 pr_err("%s: GPIO Request %d failed\n", __func__,
6626 GPIO_CDC_RST_N);
6627 regulator_disable(vreg_timpani_1);
6628 regulator_disable(vreg_timpani_2);
6629 goto fail;
6630 } else {
6631 gpio_direction_output(GPIO_CDC_RST_N, 1);
6632 usleep_range(1000, 1050);
6633 gpio_direction_output(GPIO_CDC_RST_N, 0);
6634 usleep_range(1000, 1050);
6635 gpio_direction_output(GPIO_CDC_RST_N, 1);
6636 gpio_free(GPIO_CDC_RST_N);
6637 }
6638 return rc;
6639
6640fail:
6641 regulator_put(vreg_timpani_1);
6642 regulator_put(vreg_timpani_2);
6643 return rc;
6644}
6645
6646static void msm_timpani_shutdown_power(void)
6647{
6648 int rc;
6649
6650 rc = regulator_disable(vreg_timpani_1);
6651 if (rc)
6652 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6653
6654 regulator_put(vreg_timpani_1);
6655
6656 rc = regulator_disable(vreg_timpani_2);
6657 if (rc)
6658 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6659
6660 regulator_put(vreg_timpani_2);
6661}
6662
6663/* Power analog function of codec */
6664static struct regulator *vreg_timpani_cdc_apwr;
6665static int msm_timpani_codec_power(int vreg_on)
6666{
6667 int rc = 0;
6668
6669 if (!vreg_timpani_cdc_apwr) {
6670
6671 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6672
6673 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6674 pr_err("%s: vreg_get failed (%ld)\n",
6675 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6676 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6677 return rc;
6678 }
6679 }
6680
6681 if (vreg_on) {
6682
6683 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6684 2200000, 2200000);
6685 if (rc) {
6686 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6687 __func__);
6688 goto vreg_fail;
6689 }
6690
6691 rc = regulator_enable(vreg_timpani_cdc_apwr);
6692 if (rc) {
6693 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6694 goto vreg_fail;
6695 }
6696 } else {
6697 rc = regulator_disable(vreg_timpani_cdc_apwr);
6698 if (rc) {
6699 pr_err("%s: vreg_disable failed %d\n",
6700 __func__, rc);
6701 goto vreg_fail;
6702 }
6703 }
6704
6705 return 0;
6706
6707vreg_fail:
6708 regulator_put(vreg_timpani_cdc_apwr);
6709 vreg_timpani_cdc_apwr = NULL;
6710 return rc;
6711}
6712
6713static struct marimba_codec_platform_data timpani_codec_pdata = {
6714 .marimba_codec_power = msm_timpani_codec_power,
6715};
6716
6717#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6718#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6719
6720static struct marimba_platform_data timpani_pdata = {
6721 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6722 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6723 .marimba_setup = msm_timpani_setup_power,
6724 .marimba_shutdown = msm_timpani_shutdown_power,
6725 .codec = &timpani_codec_pdata,
6726 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6727};
6728
6729#define TIMPANI_I2C_SLAVE_ADDR 0xD
6730
6731static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6732 {
6733 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6734 .platform_data = &timpani_pdata,
6735 },
6736};
6737
Lei Zhou338cab82011-08-19 13:38:17 -04006738#ifdef CONFIG_SND_SOC_WM8903
6739static struct wm8903_platform_data wm8903_pdata = {
6740 .gpio_cfg[2] = 0x3A8,
6741};
6742
6743#define WM8903_I2C_SLAVE_ADDR 0x34
6744static struct i2c_board_info wm8903_codec_i2c_info[] = {
6745 {
6746 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6747 .platform_data = &wm8903_pdata,
6748 },
6749};
6750#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006751#ifdef CONFIG_PMIC8901
6752
6753#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006754/*
6755 * Consumer specific regulator names:
6756 * regulator name consumer dev_name
6757 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006758static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6759 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6760};
6761static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6762 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6763};
6764
6765#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306766 _always_on) \
6767 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006768 .init_data = { \
6769 .constraints = { \
6770 .valid_modes_mask = _modes, \
6771 .valid_ops_mask = _ops, \
6772 .min_uV = _min_uV, \
6773 .max_uV = _max_uV, \
6774 .input_uV = _min_uV, \
6775 .apply_uV = _apply_uV, \
6776 .always_on = _always_on, \
6777 }, \
6778 .consumer_supplies = vreg_consumers_8901_##_id, \
6779 .num_consumer_supplies = \
6780 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6781 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306782 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006783 }
6784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006785#define PM8901_VREG_INIT_VS(_id) \
6786 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306787 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006788
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306789static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006790 PM8901_VREG_INIT_VS(USB_OTG),
6791 PM8901_VREG_INIT_VS(HDMI_MVS),
6792};
6793
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306794static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6795 .priority = 1,
6796};
6797
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306798static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6799 .irq_base = PM8901_IRQ_BASE,
6800 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6801 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6802};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006803
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306804static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6805 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006806};
6807
6808static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306809 .irq_pdata = &pm8901_irq_pdata,
6810 .mpp_pdata = &pm8901_mpp_pdata,
6811 .regulator_pdatas = pm8901_vreg_init,
6812 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306813 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006814};
6815
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306816static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6817 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6818 .slave = {
6819 .name = "pm8901-core",
6820 .platform_data = &pm8901_platform_data,
6821 },
6822};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006823#endif /* CONFIG_PMIC8901 */
6824
6825#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6826 || defined(CONFIG_GPIO_SX150X_MODULE))
6827
6828static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006829static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006830
6831struct bahama_config_register{
6832 u8 reg;
6833 u8 value;
6834 u8 mask;
6835};
6836
6837enum version{
6838 VER_1_0,
6839 VER_2_0,
6840 VER_UNSUPPORTED = 0xFF
6841};
6842
6843static u8 read_bahama_ver(void)
6844{
6845 int rc;
6846 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6847 u8 bahama_version;
6848
6849 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6850 if (rc < 0) {
6851 printk(KERN_ERR
6852 "%s: version read failed: %d\n",
6853 __func__, rc);
6854 return VER_UNSUPPORTED;
6855 } else {
6856 printk(KERN_INFO
6857 "%s: version read got: 0x%x\n",
6858 __func__, bahama_version);
6859 }
6860
6861 switch (bahama_version) {
6862 case 0x08: /* varient of bahama v1 */
6863 case 0x10:
6864 case 0x00:
6865 return VER_1_0;
6866 case 0x09: /* variant of bahama v2 */
6867 return VER_2_0;
6868 default:
6869 return VER_UNSUPPORTED;
6870 }
6871}
6872
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006873static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006874static unsigned int msm_bahama_setup_power(void)
6875{
6876 int rc = 0;
6877 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006878
6879 if (machine_is_msm8x60_dragon())
6880 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6881
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006882 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6883
6884 if (IS_ERR(vreg_bahama)) {
6885 rc = PTR_ERR(vreg_bahama);
6886 pr_err("%s: regulator_get %s = %d\n", __func__,
6887 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006888 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006889 }
6890
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006891 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6892 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006893 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6894 msm_bahama_regulator, rc);
6895 goto unget;
6896 }
6897
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006898 rc = regulator_enable(vreg_bahama);
6899 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006900 pr_err("%s: regulator_enable %s = %d\n", __func__,
6901 msm_bahama_regulator, rc);
6902 goto unget;
6903 }
6904
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006905 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6906 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006907 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006908 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006909 goto unenable;
6910 }
6911
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006912 gpio_direction_output(msm_bahama_sys_rst, 0);
6913 usleep_range(1000, 1050);
6914 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6915 usleep_range(1000, 1050);
6916 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006917 return rc;
6918
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006919unenable:
6920 regulator_disable(vreg_bahama);
6921unget:
6922 regulator_put(vreg_bahama);
6923 return rc;
6924};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006925
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006926static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006927{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006928 if (msm_bahama_setup_power_enable) {
6929 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6930 gpio_free(msm_bahama_sys_rst);
6931 regulator_disable(vreg_bahama);
6932 regulator_put(vreg_bahama);
6933 msm_bahama_setup_power_enable = 0;
6934 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006935
6936 return 0;
6937};
6938
6939static unsigned int msm_bahama_core_config(int type)
6940{
6941 int rc = 0;
6942
6943 if (type == BAHAMA_ID) {
6944
6945 int i;
6946 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6947
6948 const struct bahama_config_register v20_init[] = {
6949 /* reg, value, mask */
6950 { 0xF4, 0x84, 0xFF }, /* AREG */
6951 { 0xF0, 0x04, 0xFF } /* DREG */
6952 };
6953
6954 if (read_bahama_ver() == VER_2_0) {
6955 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6956 u8 value = v20_init[i].value;
6957 rc = marimba_write_bit_mask(&config,
6958 v20_init[i].reg,
6959 &value,
6960 sizeof(v20_init[i].value),
6961 v20_init[i].mask);
6962 if (rc < 0) {
6963 printk(KERN_ERR
6964 "%s: reg %d write failed: %d\n",
6965 __func__, v20_init[i].reg, rc);
6966 return rc;
6967 }
6968 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6969 " mask 0x%02x\n",
6970 __func__, v20_init[i].reg,
6971 v20_init[i].value, v20_init[i].mask);
6972 }
6973 }
6974 }
6975 printk(KERN_INFO "core type: %d\n", type);
6976
6977 return rc;
6978}
6979
6980static struct regulator *fm_regulator_s3;
6981static struct msm_xo_voter *fm_clock;
6982
6983static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6984{
6985 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306986 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006987 .direction = PM_GPIO_DIR_IN,
6988 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306989 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006990 .function = PM_GPIO_FUNC_NORMAL,
6991 .inv_int_pol = 0,
6992 };
6993
6994 if (!fm_regulator_s3) {
6995 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6996 if (IS_ERR(fm_regulator_s3)) {
6997 rc = PTR_ERR(fm_regulator_s3);
6998 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6999 __func__, rc);
7000 goto out;
7001 }
7002 }
7003
7004
7005 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7006 if (rc < 0) {
7007 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7008 __func__, rc);
7009 goto fm_fail_put;
7010 }
7011
7012 rc = regulator_enable(fm_regulator_s3);
7013 if (rc < 0) {
7014 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7015 __func__, rc);
7016 goto fm_fail_put;
7017 }
7018
7019 /*Vote for XO clock*/
7020 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7021
7022 if (IS_ERR(fm_clock)) {
7023 rc = PTR_ERR(fm_clock);
7024 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7025 __func__, rc);
7026 goto fm_fail_switch;
7027 }
7028
7029 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7030 if (rc < 0) {
7031 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7032 __func__, rc);
7033 goto fm_fail_vote;
7034 }
7035
7036 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307037 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007038 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307039 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007040 __func__, rc);
7041 goto fm_fail_clock;
7042 }
7043 goto out;
7044
7045fm_fail_clock:
7046 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7047fm_fail_vote:
7048 msm_xo_put(fm_clock);
7049fm_fail_switch:
7050 regulator_disable(fm_regulator_s3);
7051fm_fail_put:
7052 regulator_put(fm_regulator_s3);
7053out:
7054 return rc;
7055};
7056
7057static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7058{
7059 int rc = 0;
7060 if (fm_regulator_s3 != NULL) {
7061 rc = regulator_disable(fm_regulator_s3);
7062 if (rc < 0) {
7063 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7064 __func__, rc);
7065 }
7066 regulator_put(fm_regulator_s3);
7067 fm_regulator_s3 = NULL;
7068 }
7069 printk(KERN_ERR "%s: Voting off for XO", __func__);
7070
7071 if (fm_clock != NULL) {
7072 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7073 if (rc < 0) {
7074 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7075 __func__, rc);
7076 }
7077 msm_xo_put(fm_clock);
7078 }
7079 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7080}
7081
7082/* Slave id address for FM/CDC/QMEMBIST
7083 * Values can be programmed using Marimba slave id 0
7084 * should there be a conflict with other I2C devices
7085 * */
7086#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7087#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7088
7089static struct marimba_fm_platform_data marimba_fm_pdata = {
7090 .fm_setup = fm_radio_setup,
7091 .fm_shutdown = fm_radio_shutdown,
7092 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7093 .is_fm_soc_i2s_master = false,
7094 .config_i2s_gpio = NULL,
7095};
7096
7097/*
7098Just initializing the BAHAMA related slave
7099*/
7100static struct marimba_platform_data marimba_pdata = {
7101 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7102 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7103 .bahama_setup = msm_bahama_setup_power,
7104 .bahama_shutdown = msm_bahama_shutdown_power,
7105 .bahama_core_config = msm_bahama_core_config,
7106 .fm = &marimba_fm_pdata,
7107 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7108};
7109
7110
7111static struct i2c_board_info msm_marimba_board_info[] = {
7112 {
7113 I2C_BOARD_INFO("marimba", 0xc),
7114 .platform_data = &marimba_pdata,
7115 }
7116};
7117#endif /* CONFIG_MAIMBA_CORE */
7118
7119#ifdef CONFIG_I2C
7120#define I2C_SURF 1
7121#define I2C_FFA (1 << 1)
7122#define I2C_RUMI (1 << 2)
7123#define I2C_SIM (1 << 3)
7124#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007125#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007126
7127struct i2c_registry {
7128 u8 machs;
7129 int bus;
7130 struct i2c_board_info *info;
7131 int len;
7132};
7133
7134static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007135#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7136 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007137 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007138 MSM_GSBI8_QUP_I2C_BUS_ID,
7139 core_expander_i2c_info,
7140 ARRAY_SIZE(core_expander_i2c_info),
7141 },
7142 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007143 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007144 MSM_GSBI8_QUP_I2C_BUS_ID,
7145 docking_expander_i2c_info,
7146 ARRAY_SIZE(docking_expander_i2c_info),
7147 },
7148 {
7149 I2C_SURF,
7150 MSM_GSBI8_QUP_I2C_BUS_ID,
7151 surf_expanders_i2c_info,
7152 ARRAY_SIZE(surf_expanders_i2c_info),
7153 },
7154 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007155 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007156 MSM_GSBI3_QUP_I2C_BUS_ID,
7157 fha_expanders_i2c_info,
7158 ARRAY_SIZE(fha_expanders_i2c_info),
7159 },
7160 {
7161 I2C_FLUID,
7162 MSM_GSBI3_QUP_I2C_BUS_ID,
7163 fluid_expanders_i2c_info,
7164 ARRAY_SIZE(fluid_expanders_i2c_info),
7165 },
7166 {
7167 I2C_FLUID,
7168 MSM_GSBI8_QUP_I2C_BUS_ID,
7169 fluid_core_expander_i2c_info,
7170 ARRAY_SIZE(fluid_core_expander_i2c_info),
7171 },
7172#endif
7173#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7174 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7175 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007176 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007177 MSM_GSBI3_QUP_I2C_BUS_ID,
7178 msm_i2c_gsbi3_tdisc_info,
7179 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7180 },
7181#endif
7182 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007183 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007184 MSM_GSBI3_QUP_I2C_BUS_ID,
7185 cy8ctmg200_board_info,
7186 ARRAY_SIZE(cy8ctmg200_board_info),
7187 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007188 {
7189 I2C_DRAGON,
7190 MSM_GSBI3_QUP_I2C_BUS_ID,
7191 cy8ctma340_dragon_board_info,
7192 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7193 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007194#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7195 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7196 {
7197 I2C_FLUID,
7198 MSM_GSBI3_QUP_I2C_BUS_ID,
7199 cyttsp_fluid_info,
7200 ARRAY_SIZE(cyttsp_fluid_info),
7201 },
7202 {
7203 I2C_FFA | I2C_SURF,
7204 MSM_GSBI3_QUP_I2C_BUS_ID,
7205 cyttsp_ffa_info,
7206 ARRAY_SIZE(cyttsp_ffa_info),
7207 },
7208#endif
7209#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007210#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007211 {
7212 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007213 MSM_GSBI4_QUP_I2C_BUS_ID,
7214 msm_camera_boardinfo,
7215 ARRAY_SIZE(msm_camera_boardinfo),
7216 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007217 {
7218 I2C_DRAGON,
7219 MSM_GSBI4_QUP_I2C_BUS_ID,
7220 msm_camera_dragon_boardinfo,
7221 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7222 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007223#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007224#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007225 {
7226 I2C_SURF | I2C_FFA | I2C_FLUID,
7227 MSM_GSBI7_QUP_I2C_BUS_ID,
7228 msm_i2c_gsbi7_timpani_info,
7229 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7230 },
7231#if defined(CONFIG_MARIMBA_CORE)
7232 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007233 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007234 MSM_GSBI7_QUP_I2C_BUS_ID,
7235 msm_marimba_board_info,
7236 ARRAY_SIZE(msm_marimba_board_info),
7237 },
7238#endif /* CONFIG_MARIMBA_CORE */
7239#ifdef CONFIG_ISL9519_CHARGER
7240 {
7241 I2C_SURF | I2C_FFA,
7242 MSM_GSBI8_QUP_I2C_BUS_ID,
7243 isl_charger_i2c_info,
7244 ARRAY_SIZE(isl_charger_i2c_info),
7245 },
7246#endif
7247#if defined(CONFIG_HAPTIC_ISA1200) || \
7248 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7249 {
7250 I2C_FLUID,
7251 MSM_GSBI8_QUP_I2C_BUS_ID,
7252 msm_isa1200_board_info,
7253 ARRAY_SIZE(msm_isa1200_board_info),
7254 },
7255#endif
7256#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7257 {
7258 I2C_FLUID,
7259 MSM_GSBI8_QUP_I2C_BUS_ID,
7260 smb137b_charger_i2c_info,
7261 ARRAY_SIZE(smb137b_charger_i2c_info),
7262 },
7263#endif
7264#if defined(CONFIG_BATTERY_BQ27520) || \
7265 defined(CONFIG_BATTERY_BQ27520_MODULE)
7266 {
7267 I2C_FLUID,
7268 MSM_GSBI8_QUP_I2C_BUS_ID,
7269 msm_bq27520_board_info,
7270 ARRAY_SIZE(msm_bq27520_board_info),
7271 },
7272#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007273#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7274 {
7275 I2C_DRAGON,
7276 MSM_GSBI8_QUP_I2C_BUS_ID,
7277 wm8903_codec_i2c_info,
7278 ARRAY_SIZE(wm8903_codec_i2c_info),
7279 },
7280#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007281};
7282#endif /* CONFIG_I2C */
7283
Stephen Boyd668d7652012-04-25 11:31:01 -07007284static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007285{
7286#ifdef CONFIG_I2C
7287#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7288 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7289 sx150x_data[SX150X_CORE].irq_summary =
7290 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007291 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7292 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007293 sx150x_data[SX150X_CORE].irq_summary =
7294 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7295 else if (machine_is_msm8x60_fluid())
7296 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7297 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7298#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007299#endif
7300}
7301
Stephen Boyd668d7652012-04-25 11:31:01 -07007302static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007303{
7304#ifdef CONFIG_I2C
7305 u8 mach_mask = 0;
7306 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007307#ifdef CONFIG_MSM_CAMERA_V4L2
7308 struct i2c_registry msm8x60_camera_i2c_devices = {
7309 I2C_SURF | I2C_FFA | I2C_FLUID,
7310 MSM_GSBI4_QUP_I2C_BUS_ID,
7311 msm8x60_camera_board_info.board_info,
7312 msm8x60_camera_board_info.num_i2c_board_info,
7313 };
7314#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007315
7316 /* Build the matching 'supported_machs' bitmask */
7317 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7318 mach_mask = I2C_SURF;
7319 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7320 mach_mask = I2C_FFA;
7321 else if (machine_is_msm8x60_rumi3())
7322 mach_mask = I2C_RUMI;
7323 else if (machine_is_msm8x60_sim())
7324 mach_mask = I2C_SIM;
7325 else if (machine_is_msm8x60_fluid())
7326 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007327 else if (machine_is_msm8x60_dragon())
7328 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007329 else
7330 pr_err("unmatched machine ID in register_i2c_devices\n");
7331
7332 /* Run the array and install devices as appropriate */
7333 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7334 if (msm8x60_i2c_devices[i].machs & mach_mask)
7335 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7336 msm8x60_i2c_devices[i].info,
7337 msm8x60_i2c_devices[i].len);
7338 }
Kevin Chan3be11612012-03-22 20:05:40 -07007339#ifdef CONFIG_MSM_CAMERA_V4L2
7340 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7341 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7342 msm8x60_camera_i2c_devices.info,
7343 msm8x60_camera_i2c_devices.len);
7344#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007345#endif
7346}
7347
7348static void __init msm8x60_init_uart12dm(void)
7349{
7350#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7351 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7352 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7353
7354 if (!fpga_mem)
7355 pr_err("%s(): Error getting memory\n", __func__);
7356
7357 /* Advanced mode */
7358 writew(0xFFFF, fpga_mem + 0x15C);
7359 /* FPGA_UART_SEL */
7360 writew(0, fpga_mem + 0x172);
7361 /* FPGA_GPIO_CONFIG_117 */
7362 writew(1, fpga_mem + 0xEA);
7363 /* FPGA_GPIO_CONFIG_118 */
7364 writew(1, fpga_mem + 0xEC);
7365 mb();
7366 iounmap(fpga_mem);
7367#endif
7368}
7369
7370#define MSM_GSBI9_PHYS 0x19900000
7371#define GSBI_DUAL_MODE_CODE 0x60
7372
7373static void __init msm8x60_init_buses(void)
7374{
7375#ifdef CONFIG_I2C_QUP
7376 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7377 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7378 writel_relaxed(0x6 << 4, gsbi_mem);
7379 /* Ensure protocol code is written before proceeding further */
7380 mb();
7381 iounmap(gsbi_mem);
7382
7383 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7384 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7385 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7386 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7387
7388#ifdef CONFIG_MSM_GSBI9_UART
7389 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7390 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7391 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7392 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7393 iounmap(gsbi_mem);
7394 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7395 }
7396#endif
7397 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7398 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7399#endif
7400#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7401 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7402#endif
7403#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007404 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7405#endif
7406
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307407#ifdef CONFIG_MSM_SSBI
7408 msm_device_ssbi_pmic1.dev.platform_data =
7409 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307410 msm_device_ssbi_pmic2.dev.platform_data =
7411 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307412#endif
7413
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007414 if (machine_is_msm8x60_fluid()) {
7415#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7416 (defined(CONFIG_SMB137B_CHARGER) || \
7417 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7418 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7419#endif
7420#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7421 msm_gsbi10_qup_spi_device.dev.platform_data =
7422 &msm_gsbi10_qup_spi_pdata;
7423#endif
7424 }
7425
Lena Salman57d167e2012-03-21 19:46:38 +02007426#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007427 /*
7428 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7429 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7430 * and ID notifications are available only on V2 surf and FFA
7431 * with a hardware workaround.
7432 */
7433 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7434 (machine_is_msm8x60_surf() ||
7435 (machine_is_msm8x60_ffa() &&
7436 pmic_id_notif_supported)))
7437 msm_otg_pdata.phy_can_powercollapse = 1;
7438 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7439#endif
7440
Lena Salman57d167e2012-03-21 19:46:38 +02007441#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007442 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7443#endif
7444
7445#ifdef CONFIG_SERIAL_MSM_HS
7446 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7447 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7448#endif
7449#ifdef CONFIG_MSM_GSBI9_UART
7450 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7451 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7452 if (IS_ERR(msm_device_uart_gsbi9))
7453 pr_err("%s(): Failed to create uart gsbi9 device\n",
7454 __func__);
7455 }
7456#endif
7457
7458#ifdef CONFIG_MSM_BUS_SCALING
7459
7460 /* RPM calls are only enabled on V2 */
7461 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7462 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7463 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7464 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7465 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7466 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7467 }
7468
7469 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7470 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7471 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7472 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7473 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7474#endif
7475}
7476
7477static void __init msm8x60_map_io(void)
7478{
7479 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7480 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007481
7482 if (socinfo_init() < 0)
7483 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007484}
7485
7486/*
7487 * Most segments of the EBI2 bus are disabled by default.
7488 */
7489static void __init msm8x60_init_ebi2(void)
7490{
7491 uint32_t ebi2_cfg;
7492 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007493 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7494
7495 if (IS_ERR(mem_clk)) {
7496 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7497 "msm_ebi2", "mem_clk");
7498 return;
7499 }
7500 clk_enable(mem_clk);
7501 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007502
7503 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7504 if (ebi2_cfg_ptr != 0) {
7505 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7506
7507 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007508 machine_is_msm8x60_fluid() ||
7509 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007510 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7511 else if (machine_is_msm8x60_sim())
7512 ebi2_cfg |= (1 << 4); /* CS2 */
7513 else if (machine_is_msm8x60_rumi3())
7514 ebi2_cfg |= (1 << 5); /* CS3 */
7515
7516 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7517 iounmap(ebi2_cfg_ptr);
7518 }
7519
7520 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007521 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007522 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7523 if (ebi2_cfg_ptr != 0) {
7524 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7525 writel_relaxed(0UL, ebi2_cfg_ptr);
7526
7527 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7528 * LAN9221 Ethernet controller reads and writes.
7529 * The lowest 4 bits are the read delay, the next
7530 * 4 are the write delay. */
7531 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7532#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7533 /*
7534 * RECOVERY=5, HOLD_WR=1
7535 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7536 * WAIT_WR=1, WAIT_RD=2
7537 */
7538 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7539 /*
7540 * HOLD_RD=1
7541 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7542 */
7543 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7544#else
7545 /* EBI2 CS3 muxed address/data,
7546 * two cyc addr enable */
7547 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7548
7549#endif
7550 iounmap(ebi2_cfg_ptr);
7551 }
7552 }
7553}
7554
7555static void __init msm8x60_configure_smc91x(void)
7556{
7557 if (machine_is_msm8x60_sim()) {
7558
7559 smc91x_resources[0].start = 0x1b800300;
7560 smc91x_resources[0].end = 0x1b8003ff;
7561
7562 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7563 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7564
7565 } else if (machine_is_msm8x60_rumi3()) {
7566
7567 smc91x_resources[0].start = 0x1d000300;
7568 smc91x_resources[0].end = 0x1d0003ff;
7569
7570 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7571 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7572 }
7573}
7574
7575static void __init msm8x60_init_tlmm(void)
7576{
7577 if (machine_is_msm8x60_rumi3())
7578 msm_gpio_install_direct_irq(0, 0, 1);
7579}
7580
7581#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7582 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7583 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7584 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7585 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7586
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007587/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007588#define MAX_SDCC_CONTROLLER 5
7589
7590struct msm_sdcc_gpio {
7591 /* maximum 10 GPIOs per SDCC controller */
7592 s16 no;
7593 /* name of this GPIO */
7594 const char *name;
7595 bool always_on;
7596 bool is_enabled;
7597};
7598
7599#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7600static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7601 {159, "sdc1_dat_0"},
7602 {160, "sdc1_dat_1"},
7603 {161, "sdc1_dat_2"},
7604 {162, "sdc1_dat_3"},
7605#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7606 {163, "sdc1_dat_4"},
7607 {164, "sdc1_dat_5"},
7608 {165, "sdc1_dat_6"},
7609 {166, "sdc1_dat_7"},
7610#endif
7611 {167, "sdc1_clk"},
7612 {168, "sdc1_cmd"}
7613};
7614#endif
7615
7616#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7617static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7618 {143, "sdc2_dat_0"},
7619 {144, "sdc2_dat_1", 1},
7620 {145, "sdc2_dat_2"},
7621 {146, "sdc2_dat_3"},
7622#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7623 {147, "sdc2_dat_4"},
7624 {148, "sdc2_dat_5"},
7625 {149, "sdc2_dat_6"},
7626 {150, "sdc2_dat_7"},
7627#endif
7628 {151, "sdc2_cmd"},
7629 {152, "sdc2_clk", 1}
7630};
7631#endif
7632
7633#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7634static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7635 {95, "sdc5_cmd"},
7636 {96, "sdc5_dat_3"},
7637 {97, "sdc5_clk", 1},
7638 {98, "sdc5_dat_2"},
7639 {99, "sdc5_dat_1", 1},
7640 {100, "sdc5_dat_0"}
7641};
7642#endif
7643
7644struct msm_sdcc_pad_pull_cfg {
7645 enum msm_tlmm_pull_tgt pull;
7646 u32 pull_val;
7647};
7648
7649struct msm_sdcc_pad_drv_cfg {
7650 enum msm_tlmm_hdrive_tgt drv;
7651 u32 drv_val;
7652};
7653
7654#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7655static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7656 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7657 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7658 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7659};
7660
7661static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7662 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7663 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7664};
7665
7666static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7667 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7668 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7669 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7670};
7671
7672static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7673 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7674 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7675};
7676#endif
7677
7678#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7679static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7680 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7681 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7682 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7683};
7684
7685static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7686 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7687 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7688};
7689
7690static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7691 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7692 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7693 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7694};
7695
7696static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7697 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7698 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7699};
7700#endif
7701
7702struct msm_sdcc_pin_cfg {
7703 /*
7704 * = 1 if controller pins are using gpios
7705 * = 0 if controller has dedicated MSM pins
7706 */
7707 u8 is_gpio;
7708 u8 cfg_sts;
7709 u8 gpio_data_size;
7710 struct msm_sdcc_gpio *gpio_data;
7711 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7712 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7713 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7714 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7715 u8 pad_drv_data_size;
7716 u8 pad_pull_data_size;
7717 u8 sdio_lpm_gpio_cfg;
7718};
7719
7720
7721static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7722#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7723 [0] = {
7724 .is_gpio = 1,
7725 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7726 .gpio_data = sdc1_gpio_cfg
7727 },
7728#endif
7729#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7730 [1] = {
7731 .is_gpio = 1,
7732 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7733 .gpio_data = sdc2_gpio_cfg
7734 },
7735#endif
7736#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7737 [2] = {
7738 .is_gpio = 0,
7739 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7740 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7741 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7742 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7743 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7744 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7745 },
7746#endif
7747#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7748 [3] = {
7749 .is_gpio = 0,
7750 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7751 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7752 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7753 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7754 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7755 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7756 },
7757#endif
7758#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7759 [4] = {
7760 .is_gpio = 1,
7761 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7762 .gpio_data = sdc5_gpio_cfg
7763 }
7764#endif
7765};
7766
7767static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7768{
7769 int rc = 0;
7770 struct msm_sdcc_pin_cfg *curr;
7771 int n;
7772
7773 curr = &sdcc_pin_cfg_data[dev_id - 1];
7774 if (!curr->gpio_data)
7775 goto out;
7776
7777 for (n = 0; n < curr->gpio_data_size; n++) {
7778 if (enable) {
7779
7780 if (curr->gpio_data[n].always_on &&
7781 curr->gpio_data[n].is_enabled)
7782 continue;
7783 pr_debug("%s: enable: %s\n", __func__,
7784 curr->gpio_data[n].name);
7785 rc = gpio_request(curr->gpio_data[n].no,
7786 curr->gpio_data[n].name);
7787 if (rc) {
7788 pr_err("%s: gpio_request(%d, %s)"
7789 "failed", __func__,
7790 curr->gpio_data[n].no,
7791 curr->gpio_data[n].name);
7792 goto free_gpios;
7793 }
7794 /* set direction as output for all GPIOs */
7795 rc = gpio_direction_output(
7796 curr->gpio_data[n].no, 1);
7797 if (rc) {
7798 pr_err("%s: gpio_direction_output"
7799 "(%d, 1) failed\n", __func__,
7800 curr->gpio_data[n].no);
7801 goto free_gpios;
7802 }
7803 curr->gpio_data[n].is_enabled = 1;
7804 } else {
7805 /*
7806 * now free this GPIO which will put GPIO
7807 * in low power mode and will also put GPIO
7808 * in input mode
7809 */
7810 if (curr->gpio_data[n].always_on)
7811 continue;
7812 pr_debug("%s: disable: %s\n", __func__,
7813 curr->gpio_data[n].name);
7814 gpio_free(curr->gpio_data[n].no);
7815 curr->gpio_data[n].is_enabled = 0;
7816 }
7817 }
7818 curr->cfg_sts = enable;
7819 goto out;
7820
7821free_gpios:
7822 for (; n >= 0; n--)
7823 gpio_free(curr->gpio_data[n].no);
7824out:
7825 return rc;
7826}
7827
7828static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7829{
7830 int rc = 0;
7831 struct msm_sdcc_pin_cfg *curr;
7832 int n;
7833
7834 curr = &sdcc_pin_cfg_data[dev_id - 1];
7835 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7836 goto out;
7837
7838 if (enable) {
7839 /*
7840 * set up the normal driver strength and
7841 * pull config for pads
7842 */
7843 for (n = 0; n < curr->pad_drv_data_size; n++) {
7844 if (curr->sdio_lpm_gpio_cfg) {
7845 if (curr->pad_drv_on_data[n].drv ==
7846 TLMM_HDRV_SDC4_DATA)
7847 continue;
7848 }
7849 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7850 curr->pad_drv_on_data[n].drv_val);
7851 }
7852 for (n = 0; n < curr->pad_pull_data_size; n++) {
7853 if (curr->sdio_lpm_gpio_cfg) {
7854 if (curr->pad_pull_on_data[n].pull ==
7855 TLMM_PULL_SDC4_DATA)
7856 continue;
7857 }
7858 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7859 curr->pad_pull_on_data[n].pull_val);
7860 }
7861 } else {
7862 /* set the low power config for pads */
7863 for (n = 0; n < curr->pad_drv_data_size; n++) {
7864 if (curr->sdio_lpm_gpio_cfg) {
7865 if (curr->pad_drv_off_data[n].drv ==
7866 TLMM_HDRV_SDC4_DATA)
7867 continue;
7868 }
7869 msm_tlmm_set_hdrive(
7870 curr->pad_drv_off_data[n].drv,
7871 curr->pad_drv_off_data[n].drv_val);
7872 }
7873 for (n = 0; n < curr->pad_pull_data_size; n++) {
7874 if (curr->sdio_lpm_gpio_cfg) {
7875 if (curr->pad_pull_off_data[n].pull ==
7876 TLMM_PULL_SDC4_DATA)
7877 continue;
7878 }
7879 msm_tlmm_set_pull(
7880 curr->pad_pull_off_data[n].pull,
7881 curr->pad_pull_off_data[n].pull_val);
7882 }
7883 }
7884 curr->cfg_sts = enable;
7885out:
7886 return rc;
7887}
7888
7889struct sdcc_reg {
7890 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7891 const char *reg_name;
7892 /*
7893 * is set voltage supported for this regulator?
7894 * 0 = not supported, 1 = supported
7895 */
7896 unsigned char set_voltage_sup;
7897 /* voltage level to be set */
7898 unsigned int level;
7899 /* VDD/VCC/VCCQ voltage regulator handle */
7900 struct regulator *reg;
7901 /* is this regulator enabled? */
7902 bool enabled;
7903 /* is this regulator needs to be always on? */
7904 bool always_on;
7905 /* is operating power mode setting required for this regulator? */
7906 bool op_pwr_mode_sup;
7907 /* Load values for low power and high power mode */
7908 unsigned int lpm_uA;
7909 unsigned int hpm_uA;
7910};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007911/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007912static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7913/* only SDCC1 requires VCCQ voltage */
7914static struct sdcc_reg sdcc_vccq_reg_data[1];
7915/* all SDCC controllers may require voting for VDD PAD voltage */
7916static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7917
7918struct sdcc_reg_data {
7919 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7920 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7921 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7922 unsigned char sts; /* regulator enable/disable status */
7923};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007924/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007925static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7926
7927static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7928{
7929 int rc = 0;
7930
7931 /* Get the regulator handle */
7932 vreg->reg = regulator_get(NULL, vreg->reg_name);
7933 if (IS_ERR(vreg->reg)) {
7934 rc = PTR_ERR(vreg->reg);
7935 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7936 __func__, vreg->reg_name, rc);
7937 goto out;
7938 }
7939
7940 /* Set the voltage level if required */
7941 if (vreg->set_voltage_sup) {
7942 rc = regulator_set_voltage(vreg->reg, vreg->level,
7943 vreg->level);
7944 if (rc) {
7945 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7946 __func__, vreg->reg_name, rc);
7947 goto vreg_put;
7948 }
7949 }
7950 goto out;
7951
7952vreg_put:
7953 regulator_put(vreg->reg);
7954out:
7955 return rc;
7956}
7957
7958static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7959{
7960 regulator_put(vreg->reg);
7961}
7962
7963/* this init function should be called only once for each SDCC */
7964static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7965{
7966 int rc = 0;
7967 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7968 struct sdcc_reg_data *curr;
7969
7970 curr = &sdcc_vreg_data[dev_id - 1];
7971 curr_vdd_reg = curr->vdd_data;
7972 curr_vccq_reg = curr->vccq_data;
7973 curr_vddp_reg = curr->vddp_data;
7974
7975 if (init) {
7976 /*
7977 * get the regulator handle from voltage regulator framework
7978 * and then try to set the voltage level for the regulator
7979 */
7980 if (curr_vdd_reg) {
7981 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7982 if (rc)
7983 goto out;
7984 }
7985 if (curr_vccq_reg) {
7986 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7987 if (rc)
7988 goto vdd_reg_deinit;
7989 }
7990 if (curr_vddp_reg) {
7991 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7992 if (rc)
7993 goto vccq_reg_deinit;
7994 }
7995 goto out;
7996 } else
7997 /* deregister with all regulators from regulator framework */
7998 goto vddp_reg_deinit;
7999
8000vddp_reg_deinit:
8001 if (curr_vddp_reg)
8002 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8003vccq_reg_deinit:
8004 if (curr_vccq_reg)
8005 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8006vdd_reg_deinit:
8007 if (curr_vdd_reg)
8008 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8009out:
8010 return rc;
8011}
8012
8013static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8014{
8015 int rc;
8016
8017 if (!vreg->enabled) {
8018 rc = regulator_enable(vreg->reg);
8019 if (rc) {
8020 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8021 __func__, vreg->reg_name, rc);
8022 goto out;
8023 }
8024 vreg->enabled = 1;
8025 }
8026
8027 /* Put always_on regulator in HPM (high power mode) */
8028 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8029 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8030 if (rc < 0) {
8031 pr_err("%s: reg=%s: HPM setting failed"
8032 " hpm_uA=%d, rc=%d\n",
8033 __func__, vreg->reg_name,
8034 vreg->hpm_uA, rc);
8035 goto vreg_disable;
8036 }
8037 rc = 0;
8038 }
8039 goto out;
8040
8041vreg_disable:
8042 regulator_disable(vreg->reg);
8043 vreg->enabled = 0;
8044out:
8045 return rc;
8046}
8047
8048static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8049{
8050 int rc;
8051
8052 /* Never disable always_on regulator */
8053 if (!vreg->always_on) {
8054 rc = regulator_disable(vreg->reg);
8055 if (rc) {
8056 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8057 __func__, vreg->reg_name, rc);
8058 goto out;
8059 }
8060 vreg->enabled = 0;
8061 }
8062
8063 /* Put always_on regulator in LPM (low power mode) */
8064 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8065 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8066 if (rc < 0) {
8067 pr_err("%s: reg=%s: LPM setting failed"
8068 " lpm_uA=%d, rc=%d\n",
8069 __func__,
8070 vreg->reg_name,
8071 vreg->lpm_uA, rc);
8072 goto out;
8073 }
8074 rc = 0;
8075 }
8076
8077out:
8078 return rc;
8079}
8080
8081static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8082{
8083 int rc = 0;
8084 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8085 struct sdcc_reg_data *curr;
8086
8087 curr = &sdcc_vreg_data[dev_id - 1];
8088 curr_vdd_reg = curr->vdd_data;
8089 curr_vccq_reg = curr->vccq_data;
8090 curr_vddp_reg = curr->vddp_data;
8091
8092 /* check if regulators are initialized or not? */
8093 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8094 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8095 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8096 /* initialize voltage regulators required for this SDCC */
8097 rc = msm_sdcc_vreg_init(dev_id, 1);
8098 if (rc) {
8099 pr_err("%s: regulator init failed = %d\n",
8100 __func__, rc);
8101 goto out;
8102 }
8103 }
8104
8105 if (curr->sts == enable)
8106 goto out;
8107
8108 if (curr_vdd_reg) {
8109 if (enable)
8110 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8111 else
8112 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8113 if (rc)
8114 goto out;
8115 }
8116
8117 if (curr_vccq_reg) {
8118 if (enable)
8119 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8120 else
8121 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8122 if (rc)
8123 goto out;
8124 }
8125
8126 if (curr_vddp_reg) {
8127 if (enable)
8128 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8129 else
8130 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8131 if (rc)
8132 goto out;
8133 }
8134 curr->sts = enable;
8135
8136out:
8137 return rc;
8138}
8139
8140static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8141{
8142 u32 rc_pin_cfg = 0;
8143 u32 rc_vreg_cfg = 0;
8144 u32 rc = 0;
8145 struct platform_device *pdev;
8146 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8147
8148 pdev = container_of(dv, struct platform_device, dev);
8149
8150 /* setup gpio/pad */
8151 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8152 if (curr_pin_cfg->cfg_sts == !!vdd)
8153 goto setup_vreg;
8154
8155 if (curr_pin_cfg->is_gpio)
8156 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8157 else
8158 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8159
8160setup_vreg:
8161 /* setup voltage regulators */
8162 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8163
8164 if (rc_pin_cfg || rc_vreg_cfg)
8165 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8166
8167 return rc;
8168}
8169
8170static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8171{
8172 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8173 struct platform_device *pdev;
8174
8175 pdev = container_of(dv, struct platform_device, dev);
8176 /* setup gpio/pad */
8177 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8178
8179 if (curr_pin_cfg->cfg_sts == active)
8180 return;
8181
8182 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8183 if (curr_pin_cfg->is_gpio)
8184 msm_sdcc_setup_gpio(pdev->id, active);
8185 else
8186 msm_sdcc_setup_pad(pdev->id, active);
8187 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8188}
8189
8190static int msm_sdc3_get_wpswitch(struct device *dev)
8191{
8192 struct platform_device *pdev;
8193 int status;
8194 pdev = container_of(dev, struct platform_device, dev);
8195
8196 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8197 if (status) {
8198 pr_err("%s:Failed to request GPIO %d\n",
8199 __func__, GPIO_SDC_WP);
8200 } else {
8201 status = gpio_direction_input(GPIO_SDC_WP);
8202 if (!status) {
8203 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8204 pr_info("%s: WP Status for Slot %d = %d\n",
8205 __func__, pdev->id, status);
8206 }
8207 gpio_free(GPIO_SDC_WP);
8208 }
8209 return status;
8210}
8211
8212#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8213int sdc5_register_status_notify(void (*callback)(int, void *),
8214 void *dev_id)
8215{
8216 sdc5_status_notify_cb = callback;
8217 sdc5_status_notify_cb_devid = dev_id;
8218 return 0;
8219}
8220#endif
8221
8222#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8223int sdc2_register_status_notify(void (*callback)(int, void *),
8224 void *dev_id)
8225{
8226 sdc2_status_notify_cb = callback;
8227 sdc2_status_notify_cb_devid = dev_id;
8228 return 0;
8229}
8230#endif
8231
8232/* Interrupt handler for SDC2 and SDC5 detection
8233 * This function uses dual-edge interrputs settings in order
8234 * to get SDIO detection when the GPIO is rising and SDIO removal
8235 * when the GPIO is falling */
8236static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8237{
8238 int status;
8239
8240 if (!machine_is_msm8x60_fusion() &&
8241 !machine_is_msm8x60_fusn_ffa())
8242 return IRQ_NONE;
8243
8244 status = gpio_get_value(MDM2AP_SYNC);
8245 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8246 __func__, status);
8247
8248#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8249 if (sdc2_status_notify_cb) {
8250 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8251 sdc2_status_notify_cb(status,
8252 sdc2_status_notify_cb_devid);
8253 }
8254#endif
8255
8256#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8257 if (sdc5_status_notify_cb) {
8258 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8259 sdc5_status_notify_cb(status,
8260 sdc5_status_notify_cb_devid);
8261 }
8262#endif
8263 return IRQ_HANDLED;
8264}
8265
8266static int msm8x60_multi_sdio_init(void)
8267{
8268 int ret, irq_num;
8269
8270 if (!machine_is_msm8x60_fusion() &&
8271 !machine_is_msm8x60_fusn_ffa())
8272 return 0;
8273
8274 ret = msm_gpiomux_get(MDM2AP_SYNC);
8275 if (ret) {
8276 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8277 __func__, MDM2AP_SYNC, ret);
8278 return ret;
8279 }
8280
8281 irq_num = gpio_to_irq(MDM2AP_SYNC);
8282
8283 ret = request_irq(irq_num,
8284 msm8x60_multi_sdio_slot_status_irq,
8285 IRQ_TYPE_EDGE_BOTH,
8286 "sdio_multidetection", NULL);
8287
8288 if (ret) {
8289 pr_err("%s:Failed to request irq, ret=%d\n",
8290 __func__, ret);
8291 return ret;
8292 }
8293
8294 return ret;
8295}
8296
8297#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8298#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8299static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8300{
8301 int status;
8302
8303 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8304 , "SD_HW_Detect");
8305 if (status) {
8306 pr_err("%s:Failed to request GPIO %d\n", __func__,
8307 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8308 } else {
8309 status = gpio_direction_input(
8310 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8311 if (!status)
8312 status = !(gpio_get_value_cansleep(
8313 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8314 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8315 }
8316 return (unsigned int) status;
8317}
8318#endif
8319#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308320#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008321
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308322#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308323#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008324
8325#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8326static struct mmc_platform_data msm8x60_sdc1_data = {
8327 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8328 .translate_vdd = msm_sdcc_setup_power,
8329#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8330 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8331#else
8332 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8333#endif
8334 .msmsdcc_fmin = 400000,
8335 .msmsdcc_fmid = 24000000,
8336 .msmsdcc_fmax = 48000000,
8337 .nonremovable = 1,
8338 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008339};
8340#endif
8341
8342#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8343static struct mmc_platform_data msm8x60_sdc2_data = {
8344 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8345 .translate_vdd = msm_sdcc_setup_power,
8346 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8347 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8348 .msmsdcc_fmin = 400000,
8349 .msmsdcc_fmid = 24000000,
8350 .msmsdcc_fmax = 48000000,
8351 .nonremovable = 0,
8352 .pclk_src_dfab = 1,
8353 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008354#ifdef CONFIG_MSM_SDIO_AL
8355 .is_sdio_al_client = 1,
8356#endif
8357};
8358#endif
8359
8360#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8361static struct mmc_platform_data msm8x60_sdc3_data = {
8362 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8363 .translate_vdd = msm_sdcc_setup_power,
8364 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8365 .wpswitch = msm_sdc3_get_wpswitch,
8366#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8367 .status = msm8x60_sdcc_slot_status,
8368 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8369 PMIC_GPIO_SDC3_DET - 1),
8370 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8371#endif
8372 .msmsdcc_fmin = 400000,
8373 .msmsdcc_fmid = 24000000,
8374 .msmsdcc_fmax = 48000000,
8375 .nonremovable = 0,
8376 .pclk_src_dfab = 1,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308377 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008378};
8379#endif
8380
8381#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8382static struct mmc_platform_data msm8x60_sdc4_data = {
8383 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8384 .translate_vdd = msm_sdcc_setup_power,
8385 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8386 .msmsdcc_fmin = 400000,
8387 .msmsdcc_fmid = 24000000,
8388 .msmsdcc_fmax = 48000000,
8389 .nonremovable = 0,
8390 .pclk_src_dfab = 1,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308391 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008392};
8393#endif
8394
8395#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8396static struct mmc_platform_data msm8x60_sdc5_data = {
8397 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8398 .translate_vdd = msm_sdcc_setup_power,
8399 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8400 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8401 .msmsdcc_fmin = 400000,
8402 .msmsdcc_fmid = 24000000,
8403 .msmsdcc_fmax = 48000000,
8404 .nonremovable = 0,
8405 .pclk_src_dfab = 1,
8406 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008407#ifdef CONFIG_MSM_SDIO_AL
8408 .is_sdio_al_client = 1,
8409#endif
8410};
8411#endif
8412
8413static void __init msm8x60_init_mmc(void)
8414{
8415#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8416 /* SDCC1 : eMMC card connected */
8417 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8418 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8419 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8420 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308421 sdcc_vreg_data[0].vdd_data->always_on = 1;
8422 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8423 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8424 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008425
8426 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8427 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8428 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8429 sdcc_vreg_data[0].vccq_data->always_on = 1;
8430
8431 msm_add_sdcc(1, &msm8x60_sdc1_data);
8432#endif
8433#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8434 /*
8435 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8436 * and no card is connected on 8660 SURF/FFA/FLUID.
8437 */
8438 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8439 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8440 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8441 sdcc_vreg_data[1].vdd_data->level = 1800000;
8442
8443 sdcc_vreg_data[1].vccq_data = NULL;
8444
8445 if (machine_is_msm8x60_fusion())
8446 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8447 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008448 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8449 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008450 msm_add_sdcc(2, &msm8x60_sdc2_data);
8451 }
8452#endif
8453#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8454 /* SDCC3 : External card slot connected */
8455 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8456 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8457 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8458 sdcc_vreg_data[2].vdd_data->level = 2850000;
8459 sdcc_vreg_data[2].vdd_data->always_on = 1;
8460 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8461 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8462 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8463
8464 sdcc_vreg_data[2].vccq_data = NULL;
8465
8466 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8467 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8468 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8469 sdcc_vreg_data[2].vddp_data->level = 2850000;
8470 sdcc_vreg_data[2].vddp_data->always_on = 1;
8471 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8472 /* Sleep current required is ~300 uA. But min. RPM
8473 * vote can be in terms of mA (min. 1 mA).
8474 * So let's vote for 2 mA during sleep.
8475 */
8476 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8477 /* Max. Active current required is 16 mA */
8478 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8479
8480 if (machine_is_msm8x60_fluid())
8481 msm8x60_sdc3_data.wpswitch = NULL;
8482 msm_add_sdcc(3, &msm8x60_sdc3_data);
8483#endif
8484#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8485 /* SDCC4 : WLAN WCN1314 chip is connected */
8486 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8487 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8488 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8489 sdcc_vreg_data[3].vdd_data->level = 1800000;
8490
8491 sdcc_vreg_data[3].vccq_data = NULL;
8492
8493 msm_add_sdcc(4, &msm8x60_sdc4_data);
8494#endif
8495#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8496 /*
8497 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8498 * and no card is connected on 8660 SURF/FFA/FLUID.
8499 */
8500 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8501 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8502 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8503 sdcc_vreg_data[4].vdd_data->level = 1800000;
8504
8505 sdcc_vreg_data[4].vccq_data = NULL;
8506
8507 if (machine_is_msm8x60_fusion())
8508 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8509 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008510 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8511 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008512 msm_add_sdcc(5, &msm8x60_sdc5_data);
8513 }
8514#endif
8515}
8516
8517#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8518static inline void display_common_power(int on) {}
8519#else
8520
8521#define _GET_REGULATOR(var, name) do { \
8522 if (var == NULL) { \
8523 var = regulator_get(NULL, name); \
8524 if (IS_ERR(var)) { \
8525 pr_err("'%s' regulator not found, rc=%ld\n", \
8526 name, PTR_ERR(var)); \
8527 var = NULL; \
8528 } \
8529 } \
8530} while (0)
8531
8532static int dsub_regulator(int on)
8533{
8534 static struct regulator *dsub_reg;
8535 static struct regulator *mpp0_reg;
8536 static int dsub_reg_enabled;
8537 int rc = 0;
8538
8539 _GET_REGULATOR(dsub_reg, "8901_l3");
8540 if (IS_ERR(dsub_reg)) {
8541 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8542 __func__, PTR_ERR(dsub_reg));
8543 return PTR_ERR(dsub_reg);
8544 }
8545
8546 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8547 if (IS_ERR(mpp0_reg)) {
8548 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8549 __func__, PTR_ERR(mpp0_reg));
8550 return PTR_ERR(mpp0_reg);
8551 }
8552
8553 if (on && !dsub_reg_enabled) {
8554 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8555 if (rc) {
8556 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8557 " err=%d", __func__, rc);
8558 goto dsub_regulator_err;
8559 }
8560 rc = regulator_enable(dsub_reg);
8561 if (rc) {
8562 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8563 " err=%d", __func__, rc);
8564 goto dsub_regulator_err;
8565 }
8566 rc = regulator_enable(mpp0_reg);
8567 if (rc) {
8568 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8569 " err=%d", __func__, rc);
8570 goto dsub_regulator_err;
8571 }
8572 dsub_reg_enabled = 1;
8573 } else if (!on && dsub_reg_enabled) {
8574 rc = regulator_disable(dsub_reg);
8575 if (rc)
8576 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8577 " err=%d", __func__, rc);
8578 rc = regulator_disable(mpp0_reg);
8579 if (rc)
8580 printk(KERN_WARNING "%s: failed to disable reg "
8581 "8901_mpp0 err=%d", __func__, rc);
8582 dsub_reg_enabled = 0;
8583 }
8584
8585 return rc;
8586
8587dsub_regulator_err:
8588 regulator_put(mpp0_reg);
8589 regulator_put(dsub_reg);
8590 return rc;
8591}
8592
8593static int display_power_on;
8594static void setup_display_power(void)
8595{
8596 if (display_power_on)
8597 if (lcdc_vga_enabled) {
8598 dsub_regulator(1);
8599 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8600 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8601 if (machine_is_msm8x60_ffa() ||
8602 machine_is_msm8x60_fusn_ffa())
8603 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8604 } else {
8605 dsub_regulator(0);
8606 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8607 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8608 if (machine_is_msm8x60_ffa() ||
8609 machine_is_msm8x60_fusn_ffa())
8610 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8611 }
8612 else {
8613 dsub_regulator(0);
8614 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8615 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8616 /* BACKLIGHT */
8617 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8618 /* LVDS */
8619 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8620 }
8621}
8622
8623#define _GET_REGULATOR(var, name) do { \
8624 if (var == NULL) { \
8625 var = regulator_get(NULL, name); \
8626 if (IS_ERR(var)) { \
8627 pr_err("'%s' regulator not found, rc=%ld\n", \
8628 name, PTR_ERR(var)); \
8629 var = NULL; \
8630 } \
8631 } \
8632} while (0)
8633
8634#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8635
8636static void display_common_power(int on)
8637{
8638 int rc;
8639 static struct regulator *display_reg;
8640
8641 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8642 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8643 if (on) {
8644 /* LVDS */
8645 _GET_REGULATOR(display_reg, "8901_l2");
8646 if (!display_reg)
8647 return;
8648 rc = regulator_set_voltage(display_reg,
8649 3300000, 3300000);
8650 if (rc)
8651 goto out;
8652 rc = regulator_enable(display_reg);
8653 if (rc)
8654 goto out;
8655 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8656 "LVDS_STDN_OUT_N");
8657 if (rc) {
8658 printk(KERN_ERR "%s: LVDS gpio %d request"
8659 "failed\n", __func__,
8660 GPIO_LVDS_SHUTDOWN_N);
8661 goto out2;
8662 }
8663
8664 /* BACKLIGHT */
8665 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8666 if (rc) {
8667 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8668 "failed\n", __func__,
8669 GPIO_BACKLIGHT_EN);
8670 goto out3;
8671 }
8672
8673 if (machine_is_msm8x60_ffa() ||
8674 machine_is_msm8x60_fusn_ffa()) {
8675 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8676 "DONGLE_PWR_EN");
8677 if (rc) {
8678 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8679 " %d request failed\n", __func__,
8680 GPIO_DONGLE_PWR_EN);
8681 goto out4;
8682 }
8683 }
8684
8685 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8686 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8687 if (machine_is_msm8x60_ffa() ||
8688 machine_is_msm8x60_fusn_ffa())
8689 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8690 mdelay(20);
8691 display_power_on = 1;
8692 setup_display_power();
8693 } else {
8694 if (display_power_on) {
8695 display_power_on = 0;
8696 setup_display_power();
8697 mdelay(20);
8698 if (machine_is_msm8x60_ffa() ||
8699 machine_is_msm8x60_fusn_ffa())
8700 gpio_free(GPIO_DONGLE_PWR_EN);
8701 goto out4;
8702 }
8703 }
8704 }
8705#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8706 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8707 else if (machine_is_msm8x60_fluid()) {
8708 static struct regulator *fluid_reg;
8709 static struct regulator *fluid_reg2;
8710
8711 if (on) {
8712 _GET_REGULATOR(fluid_reg, "8901_l2");
8713 if (!fluid_reg)
8714 return;
8715 _GET_REGULATOR(fluid_reg2, "8058_s3");
8716 if (!fluid_reg2) {
8717 regulator_put(fluid_reg);
8718 return;
8719 }
8720 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8721 if (rc) {
8722 regulator_put(fluid_reg2);
8723 regulator_put(fluid_reg);
8724 return;
8725 }
8726 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8727 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8728 regulator_enable(fluid_reg);
8729 regulator_enable(fluid_reg2);
8730 msleep(20);
8731 gpio_direction_output(GPIO_RESX_N, 0);
8732 udelay(10);
8733 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8734 display_power_on = 1;
8735 setup_display_power();
8736 } else {
8737 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8738 gpio_free(GPIO_RESX_N);
8739 msleep(20);
8740 regulator_disable(fluid_reg2);
8741 regulator_disable(fluid_reg);
8742 regulator_put(fluid_reg2);
8743 regulator_put(fluid_reg);
8744 display_power_on = 0;
8745 setup_display_power();
8746 fluid_reg = NULL;
8747 fluid_reg2 = NULL;
8748 }
8749 }
8750#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008751#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8752 else if (machine_is_msm8x60_dragon()) {
8753 static struct regulator *dragon_reg;
8754 static struct regulator *dragon_reg2;
8755
8756 if (on) {
8757 _GET_REGULATOR(dragon_reg, "8901_l2");
8758 if (!dragon_reg)
8759 return;
8760 _GET_REGULATOR(dragon_reg2, "8058_l16");
8761 if (!dragon_reg2) {
8762 regulator_put(dragon_reg);
8763 dragon_reg = NULL;
8764 return;
8765 }
8766
8767 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8768 if (rc) {
8769 pr_err("%s: gpio %d request failed with rc=%d\n",
8770 __func__, GPIO_NT35582_BL_EN, rc);
8771 regulator_put(dragon_reg);
8772 regulator_put(dragon_reg2);
8773 dragon_reg = NULL;
8774 dragon_reg2 = NULL;
8775 return;
8776 }
8777
8778 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8779 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8780 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8781 pr_err("%s: config gpio '%d' failed!\n",
8782 __func__, GPIO_NT35582_RESET);
8783 gpio_free(GPIO_NT35582_BL_EN);
8784 regulator_put(dragon_reg);
8785 regulator_put(dragon_reg2);
8786 dragon_reg = NULL;
8787 dragon_reg2 = NULL;
8788 return;
8789 }
8790
8791 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8792 if (rc) {
8793 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8794 __func__, GPIO_NT35582_RESET, rc);
8795 gpio_free(GPIO_NT35582_BL_EN);
8796 regulator_put(dragon_reg);
8797 regulator_put(dragon_reg2);
8798 dragon_reg = NULL;
8799 dragon_reg2 = NULL;
8800 return;
8801 }
8802
8803 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8804 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8805 regulator_enable(dragon_reg);
8806 regulator_enable(dragon_reg2);
8807 msleep(20);
8808
8809 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8810 msleep(20);
8811 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8812 msleep(20);
8813 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8814 msleep(50);
8815
8816 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8817
8818 display_power_on = 1;
8819 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8820 gpio_free(GPIO_NT35582_RESET);
8821 gpio_free(GPIO_NT35582_BL_EN);
8822 regulator_disable(dragon_reg2);
8823 regulator_disable(dragon_reg);
8824 regulator_put(dragon_reg2);
8825 regulator_put(dragon_reg);
8826 display_power_on = 0;
8827 dragon_reg = NULL;
8828 dragon_reg2 = NULL;
8829 }
8830 }
8831#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008832 return;
8833
8834out4:
8835 gpio_free(GPIO_BACKLIGHT_EN);
8836out3:
8837 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8838out2:
8839 regulator_disable(display_reg);
8840out:
8841 regulator_put(display_reg);
8842 display_reg = NULL;
8843}
8844#undef _GET_REGULATOR
8845#endif
8846
8847static int mipi_dsi_panel_power(int on);
8848
8849#define LCDC_NUM_GPIO 28
8850#define LCDC_GPIO_START 0
8851
8852static void lcdc_samsung_panel_power(int on)
8853{
8854 int n, ret = 0;
8855
8856 display_common_power(on);
8857
8858 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8859 if (on) {
8860 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8861 if (unlikely(ret)) {
8862 pr_err("%s not able to get gpio\n", __func__);
8863 break;
8864 }
8865 } else
8866 gpio_free(LCDC_GPIO_START + n);
8867 }
8868
8869 if (ret) {
8870 for (n--; n >= 0; n--)
8871 gpio_free(LCDC_GPIO_START + n);
8872 }
8873
8874 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8875}
8876
8877#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8878#define _GET_REGULATOR(var, name) do { \
8879 var = regulator_get(NULL, name); \
8880 if (IS_ERR(var)) { \
8881 pr_err("'%s' regulator not found, rc=%ld\n", \
8882 name, IS_ERR(var)); \
8883 var = NULL; \
8884 return -ENODEV; \
8885 } \
8886} while (0)
8887
8888static int hdmi_enable_5v(int on)
8889{
8890 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8891 static struct regulator *reg_8901_mpp0; /* External 5V */
8892 static int prev_on;
8893 int rc;
8894
8895 if (on == prev_on)
8896 return 0;
8897
8898 if (!reg_8901_hdmi_mvs)
8899 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8900 if (!reg_8901_mpp0)
8901 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8902
8903 if (on) {
8904 rc = regulator_enable(reg_8901_mpp0);
8905 if (rc) {
8906 pr_err("'%s' regulator enable failed, rc=%d\n",
8907 "reg_8901_mpp0", rc);
8908 return rc;
8909 }
8910 rc = regulator_enable(reg_8901_hdmi_mvs);
8911 if (rc) {
8912 pr_err("'%s' regulator enable failed, rc=%d\n",
8913 "8901_hdmi_mvs", rc);
8914 return rc;
8915 }
8916 pr_info("%s(on): success\n", __func__);
8917 } else {
8918 rc = regulator_disable(reg_8901_hdmi_mvs);
8919 if (rc)
8920 pr_warning("'%s' regulator disable failed, rc=%d\n",
8921 "8901_hdmi_mvs", rc);
8922 rc = regulator_disable(reg_8901_mpp0);
8923 if (rc)
8924 pr_warning("'%s' regulator disable failed, rc=%d\n",
8925 "reg_8901_mpp0", rc);
8926 pr_info("%s(off): success\n", __func__);
8927 }
8928
8929 prev_on = on;
8930
8931 return 0;
8932}
8933
8934static int hdmi_core_power(int on, int show)
8935{
8936 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8937 static int prev_on;
8938 int rc;
8939
8940 if (on == prev_on)
8941 return 0;
8942
8943 if (!reg_8058_l16)
8944 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8945
8946 if (on) {
8947 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8948 if (!rc)
8949 rc = regulator_enable(reg_8058_l16);
8950 if (rc) {
8951 pr_err("'%s' regulator enable failed, rc=%d\n",
8952 "8058_l16", rc);
8953 return rc;
8954 }
8955 rc = gpio_request(170, "HDMI_DDC_CLK");
8956 if (rc) {
8957 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8958 "HDMI_DDC_CLK", 170, rc);
8959 goto error1;
8960 }
8961 rc = gpio_request(171, "HDMI_DDC_DATA");
8962 if (rc) {
8963 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8964 "HDMI_DDC_DATA", 171, rc);
8965 goto error2;
8966 }
8967 rc = gpio_request(172, "HDMI_HPD");
8968 if (rc) {
8969 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8970 "HDMI_HPD", 172, rc);
8971 goto error3;
8972 }
8973 pr_info("%s(on): success\n", __func__);
8974 } else {
8975 gpio_free(170);
8976 gpio_free(171);
8977 gpio_free(172);
8978 rc = regulator_disable(reg_8058_l16);
8979 if (rc)
8980 pr_warning("'%s' regulator disable failed, rc=%d\n",
8981 "8058_l16", rc);
8982 pr_info("%s(off): success\n", __func__);
8983 }
8984
8985 prev_on = on;
8986
8987 return 0;
8988
8989error3:
8990 gpio_free(171);
8991error2:
8992 gpio_free(170);
8993error1:
8994 regulator_disable(reg_8058_l16);
8995 return rc;
8996}
8997
8998static int hdmi_cec_power(int on)
8999{
9000 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9001 static int prev_on;
9002 int rc;
9003
9004 if (on == prev_on)
9005 return 0;
9006
9007 if (!reg_8901_l3)
9008 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9009
9010 if (on) {
9011 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9012 if (!rc)
9013 rc = regulator_enable(reg_8901_l3);
9014 if (rc) {
9015 pr_err("'%s' regulator enable failed, rc=%d\n",
9016 "8901_l3", rc);
9017 return rc;
9018 }
9019 rc = gpio_request(169, "HDMI_CEC_VAR");
9020 if (rc) {
9021 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9022 "HDMI_CEC_VAR", 169, rc);
9023 goto error;
9024 }
9025 pr_info("%s(on): success\n", __func__);
9026 } else {
9027 gpio_free(169);
9028 rc = regulator_disable(reg_8901_l3);
9029 if (rc)
9030 pr_warning("'%s' regulator disable failed, rc=%d\n",
9031 "8901_l3", rc);
9032 pr_info("%s(off): success\n", __func__);
9033 }
9034
9035 prev_on = on;
9036
9037 return 0;
9038error:
9039 regulator_disable(reg_8901_l3);
9040 return rc;
9041}
9042
9043#undef _GET_REGULATOR
9044
9045#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9046
9047static int lcdc_panel_power(int on)
9048{
9049 int flag_on = !!on;
9050 static int lcdc_power_save_on;
9051
9052 if (lcdc_power_save_on == flag_on)
9053 return 0;
9054
9055 lcdc_power_save_on = flag_on;
9056
9057 lcdc_samsung_panel_power(on);
9058
9059 return 0;
9060}
9061
9062#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009063
9064static struct msm_bus_vectors rotator_init_vectors[] = {
9065 {
9066 .src = MSM_BUS_MASTER_ROTATOR,
9067 .dst = MSM_BUS_SLAVE_SMI,
9068 .ab = 0,
9069 .ib = 0,
9070 },
9071 {
9072 .src = MSM_BUS_MASTER_ROTATOR,
9073 .dst = MSM_BUS_SLAVE_EBI_CH0,
9074 .ab = 0,
9075 .ib = 0,
9076 },
9077};
9078
9079static struct msm_bus_vectors rotator_ui_vectors[] = {
9080 {
9081 .src = MSM_BUS_MASTER_ROTATOR,
9082 .dst = MSM_BUS_SLAVE_SMI,
9083 .ab = 0,
9084 .ib = 0,
9085 },
9086 {
9087 .src = MSM_BUS_MASTER_ROTATOR,
9088 .dst = MSM_BUS_SLAVE_EBI_CH0,
9089 .ab = (1024 * 600 * 4 * 2 * 60),
9090 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9091 },
9092};
9093
9094static struct msm_bus_vectors rotator_vga_vectors[] = {
9095 {
9096 .src = MSM_BUS_MASTER_ROTATOR,
9097 .dst = MSM_BUS_SLAVE_SMI,
9098 .ab = (640 * 480 * 2 * 2 * 30),
9099 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9100 },
9101 {
9102 .src = MSM_BUS_MASTER_ROTATOR,
9103 .dst = MSM_BUS_SLAVE_EBI_CH0,
9104 .ab = (640 * 480 * 2 * 2 * 30),
9105 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9106 },
9107};
9108
9109static struct msm_bus_vectors rotator_720p_vectors[] = {
9110 {
9111 .src = MSM_BUS_MASTER_ROTATOR,
9112 .dst = MSM_BUS_SLAVE_SMI,
9113 .ab = (1280 * 736 * 2 * 2 * 30),
9114 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9115 },
9116 {
9117 .src = MSM_BUS_MASTER_ROTATOR,
9118 .dst = MSM_BUS_SLAVE_EBI_CH0,
9119 .ab = (1280 * 736 * 2 * 2 * 30),
9120 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9121 },
9122};
9123
9124static struct msm_bus_vectors rotator_1080p_vectors[] = {
9125 {
9126 .src = MSM_BUS_MASTER_ROTATOR,
9127 .dst = MSM_BUS_SLAVE_SMI,
9128 .ab = (1920 * 1088 * 2 * 2 * 30),
9129 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9130 },
9131 {
9132 .src = MSM_BUS_MASTER_ROTATOR,
9133 .dst = MSM_BUS_SLAVE_EBI_CH0,
9134 .ab = (1920 * 1088 * 2 * 2 * 30),
9135 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9136 },
9137};
9138
9139static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9140 {
9141 ARRAY_SIZE(rotator_init_vectors),
9142 rotator_init_vectors,
9143 },
9144 {
9145 ARRAY_SIZE(rotator_ui_vectors),
9146 rotator_ui_vectors,
9147 },
9148 {
9149 ARRAY_SIZE(rotator_vga_vectors),
9150 rotator_vga_vectors,
9151 },
9152 {
9153 ARRAY_SIZE(rotator_720p_vectors),
9154 rotator_720p_vectors,
9155 },
9156 {
9157 ARRAY_SIZE(rotator_1080p_vectors),
9158 rotator_1080p_vectors,
9159 },
9160};
9161
9162struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9163 rotator_bus_scale_usecases,
9164 ARRAY_SIZE(rotator_bus_scale_usecases),
9165 .name = "rotator",
9166};
9167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009168static struct msm_bus_vectors mdp_init_vectors[] = {
9169 /* For now, 0th array entry is reserved.
9170 * Please leave 0 as is and don't use it
9171 */
9172 {
9173 .src = MSM_BUS_MASTER_MDP_PORT0,
9174 .dst = MSM_BUS_SLAVE_SMI,
9175 .ab = 0,
9176 .ib = 0,
9177 },
9178 /* Master and slaves can be from different fabrics */
9179 {
9180 .src = MSM_BUS_MASTER_MDP_PORT0,
9181 .dst = MSM_BUS_SLAVE_EBI_CH0,
9182 .ab = 0,
9183 .ib = 0,
9184 },
9185};
9186
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009187#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009188static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9189 /* Default case static display/UI/2d/3d if FB SMI */
9190 {
9191 .src = MSM_BUS_MASTER_MDP_PORT0,
9192 .dst = MSM_BUS_SLAVE_SMI,
9193 .ab = 388800000,
9194 .ib = 486000000,
9195 },
9196 /* Master and slaves can be from different fabrics */
9197 {
9198 .src = MSM_BUS_MASTER_MDP_PORT0,
9199 .dst = MSM_BUS_SLAVE_EBI_CH0,
9200 .ab = 0,
9201 .ib = 0,
9202 },
9203};
9204
9205static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9206 /* Default case static display/UI/2d/3d if FB SMI */
9207 {
9208 .src = MSM_BUS_MASTER_MDP_PORT0,
9209 .dst = MSM_BUS_SLAVE_SMI,
9210 .ab = 0,
9211 .ib = 0,
9212 },
9213 /* Master and slaves can be from different fabrics */
9214 {
9215 .src = MSM_BUS_MASTER_MDP_PORT0,
9216 .dst = MSM_BUS_SLAVE_EBI_CH0,
9217 .ab = 388800000,
9218 .ib = 486000000 * 2,
9219 },
9220};
9221static struct msm_bus_vectors mdp_vga_vectors[] = {
9222 /* VGA and less video */
9223 {
9224 .src = MSM_BUS_MASTER_MDP_PORT0,
9225 .dst = MSM_BUS_SLAVE_SMI,
9226 .ab = 458092800,
9227 .ib = 572616000,
9228 },
9229 {
9230 .src = MSM_BUS_MASTER_MDP_PORT0,
9231 .dst = MSM_BUS_SLAVE_EBI_CH0,
9232 .ab = 458092800,
9233 .ib = 572616000 * 2,
9234 },
9235};
9236static struct msm_bus_vectors mdp_720p_vectors[] = {
9237 /* 720p and less video */
9238 {
9239 .src = MSM_BUS_MASTER_MDP_PORT0,
9240 .dst = MSM_BUS_SLAVE_SMI,
9241 .ab = 471744000,
9242 .ib = 589680000,
9243 },
9244 /* Master and slaves can be from different fabrics */
9245 {
9246 .src = MSM_BUS_MASTER_MDP_PORT0,
9247 .dst = MSM_BUS_SLAVE_EBI_CH0,
9248 .ab = 471744000,
9249 .ib = 589680000 * 2,
9250 },
9251};
9252
9253static struct msm_bus_vectors mdp_1080p_vectors[] = {
9254 /* 1080p and less video */
9255 {
9256 .src = MSM_BUS_MASTER_MDP_PORT0,
9257 .dst = MSM_BUS_SLAVE_SMI,
9258 .ab = 575424000,
9259 .ib = 719280000,
9260 },
9261 /* Master and slaves can be from different fabrics */
9262 {
9263 .src = MSM_BUS_MASTER_MDP_PORT0,
9264 .dst = MSM_BUS_SLAVE_EBI_CH0,
9265 .ab = 575424000,
9266 .ib = 719280000 * 2,
9267 },
9268};
9269
9270#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009271static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9272 /* Default case static display/UI/2d/3d if FB SMI */
9273 {
9274 .src = MSM_BUS_MASTER_MDP_PORT0,
9275 .dst = MSM_BUS_SLAVE_SMI,
9276 .ab = 175110000,
9277 .ib = 218887500,
9278 },
9279 /* Master and slaves can be from different fabrics */
9280 {
9281 .src = MSM_BUS_MASTER_MDP_PORT0,
9282 .dst = MSM_BUS_SLAVE_EBI_CH0,
9283 .ab = 0,
9284 .ib = 0,
9285 },
9286};
9287
9288static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9289 /* Default case static display/UI/2d/3d if FB SMI */
9290 {
9291 .src = MSM_BUS_MASTER_MDP_PORT0,
9292 .dst = MSM_BUS_SLAVE_SMI,
9293 .ab = 0,
9294 .ib = 0,
9295 },
9296 /* Master and slaves can be from different fabrics */
9297 {
9298 .src = MSM_BUS_MASTER_MDP_PORT0,
9299 .dst = MSM_BUS_SLAVE_EBI_CH0,
9300 .ab = 216000000,
9301 .ib = 270000000 * 2,
9302 },
9303};
9304static struct msm_bus_vectors mdp_vga_vectors[] = {
9305 /* VGA and less video */
9306 {
9307 .src = MSM_BUS_MASTER_MDP_PORT0,
9308 .dst = MSM_BUS_SLAVE_SMI,
9309 .ab = 216000000,
9310 .ib = 270000000,
9311 },
9312 {
9313 .src = MSM_BUS_MASTER_MDP_PORT0,
9314 .dst = MSM_BUS_SLAVE_EBI_CH0,
9315 .ab = 216000000,
9316 .ib = 270000000 * 2,
9317 },
9318};
9319
9320static struct msm_bus_vectors mdp_720p_vectors[] = {
9321 /* 720p and less video */
9322 {
9323 .src = MSM_BUS_MASTER_MDP_PORT0,
9324 .dst = MSM_BUS_SLAVE_SMI,
9325 .ab = 230400000,
9326 .ib = 288000000,
9327 },
9328 /* Master and slaves can be from different fabrics */
9329 {
9330 .src = MSM_BUS_MASTER_MDP_PORT0,
9331 .dst = MSM_BUS_SLAVE_EBI_CH0,
9332 .ab = 230400000,
9333 .ib = 288000000 * 2,
9334 },
9335};
9336
9337static struct msm_bus_vectors mdp_1080p_vectors[] = {
9338 /* 1080p and less video */
9339 {
9340 .src = MSM_BUS_MASTER_MDP_PORT0,
9341 .dst = MSM_BUS_SLAVE_SMI,
9342 .ab = 334080000,
9343 .ib = 417600000,
9344 },
9345 /* Master and slaves can be from different fabrics */
9346 {
9347 .src = MSM_BUS_MASTER_MDP_PORT0,
9348 .dst = MSM_BUS_SLAVE_EBI_CH0,
9349 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009350 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009351 },
9352};
9353
9354#endif
9355static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9356 {
9357 ARRAY_SIZE(mdp_init_vectors),
9358 mdp_init_vectors,
9359 },
9360 {
9361 ARRAY_SIZE(mdp_sd_smi_vectors),
9362 mdp_sd_smi_vectors,
9363 },
9364 {
9365 ARRAY_SIZE(mdp_sd_ebi_vectors),
9366 mdp_sd_ebi_vectors,
9367 },
9368 {
9369 ARRAY_SIZE(mdp_vga_vectors),
9370 mdp_vga_vectors,
9371 },
9372 {
9373 ARRAY_SIZE(mdp_720p_vectors),
9374 mdp_720p_vectors,
9375 },
9376 {
9377 ARRAY_SIZE(mdp_1080p_vectors),
9378 mdp_1080p_vectors,
9379 },
9380};
9381static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9382 mdp_bus_scale_usecases,
9383 ARRAY_SIZE(mdp_bus_scale_usecases),
9384 .name = "mdp",
9385};
9386
9387#endif
9388#ifdef CONFIG_MSM_BUS_SCALING
9389static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9390 /* For now, 0th array entry is reserved.
9391 * Please leave 0 as is and don't use it
9392 */
9393 {
9394 .src = MSM_BUS_MASTER_MDP_PORT0,
9395 .dst = MSM_BUS_SLAVE_SMI,
9396 .ab = 0,
9397 .ib = 0,
9398 },
9399 /* Master and slaves can be from different fabrics */
9400 {
9401 .src = MSM_BUS_MASTER_MDP_PORT0,
9402 .dst = MSM_BUS_SLAVE_EBI_CH0,
9403 .ab = 0,
9404 .ib = 0,
9405 },
9406};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009407
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009408static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9409 /* For now, 0th array entry is reserved.
9410 * Please leave 0 as is and don't use it
9411 */
9412 {
9413 .src = MSM_BUS_MASTER_MDP_PORT0,
9414 .dst = MSM_BUS_SLAVE_SMI,
9415 .ab = 566092800,
9416 .ib = 707616000,
9417 },
9418 /* Master and slaves can be from different fabrics */
9419 {
9420 .src = MSM_BUS_MASTER_MDP_PORT0,
9421 .dst = MSM_BUS_SLAVE_EBI_CH0,
9422 .ab = 566092800,
9423 .ib = 707616000,
9424 },
9425};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009426
9427static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9428 /* For now, 0th array entry is reserved.
9429 * Please leave 0 as is and don't use it
9430 */
9431 {
9432 .src = MSM_BUS_MASTER_MDP_PORT0,
9433 .dst = MSM_BUS_SLAVE_SMI,
9434 .ab = 2000000000,
9435 .ib = 2000000000,
9436 },
9437 /* Master and slaves can be from different fabrics */
9438 {
9439 .src = MSM_BUS_MASTER_MDP_PORT0,
9440 .dst = MSM_BUS_SLAVE_EBI_CH0,
9441 .ab = 2000000000,
9442 .ib = 2000000000,
9443 },
9444};
9445
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009446static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9447 {
9448 ARRAY_SIZE(dtv_bus_init_vectors),
9449 dtv_bus_init_vectors,
9450 },
9451 {
9452 ARRAY_SIZE(dtv_bus_def_vectors),
9453 dtv_bus_def_vectors,
9454 },
9455};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009456
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009457static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9458 dtv_bus_scale_usecases,
9459 ARRAY_SIZE(dtv_bus_scale_usecases),
9460 .name = "dtv",
9461};
9462
9463static struct lcdc_platform_data dtv_pdata = {
9464 .bus_scale_table = &dtv_bus_scale_pdata,
9465};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009466
9467static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9468 {
9469 ARRAY_SIZE(dtv_bus_init_vectors),
9470 dtv_bus_init_vectors,
9471 },
9472 {
9473 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9474 dtv_bus_hdmi_prim_vectors,
9475 },
9476};
9477
9478static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9479 dtv_hdmi_prim_bus_scale_usecases,
9480 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9481 .name = "dtv",
9482};
9483
9484static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9485 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9486};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009487#endif
9488
9489
9490static struct lcdc_platform_data lcdc_pdata = {
9491 .lcdc_power_save = lcdc_panel_power,
9492};
9493
9494
9495#define MDP_VSYNC_GPIO 28
9496
9497/*
9498 * MIPI_DSI only use 8058_LDO0 which need always on
9499 * therefore it need to be put at low power mode if
9500 * it was not used instead of turn it off.
9501 */
9502static int mipi_dsi_panel_power(int on)
9503{
9504 int flag_on = !!on;
9505 static int mipi_dsi_power_save_on;
9506 static struct regulator *ldo0;
9507 int rc = 0;
9508
9509 if (mipi_dsi_power_save_on == flag_on)
9510 return 0;
9511
9512 mipi_dsi_power_save_on = flag_on;
9513
9514 if (ldo0 == NULL) { /* init */
9515 ldo0 = regulator_get(NULL, "8058_l0");
9516 if (IS_ERR(ldo0)) {
9517 pr_debug("%s: LDO0 failed\n", __func__);
9518 rc = PTR_ERR(ldo0);
9519 return rc;
9520 }
9521
9522 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9523 if (rc)
9524 goto out;
9525
9526 rc = regulator_enable(ldo0);
9527 if (rc)
9528 goto out;
9529 }
9530
9531 if (on) {
9532 /* set ldo0 to HPM */
9533 rc = regulator_set_optimum_mode(ldo0, 100000);
9534 if (rc < 0)
9535 goto out;
9536 } else {
9537 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309538 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009539 if (rc < 0)
9540 goto out;
9541 }
9542
9543 return 0;
9544out:
9545 regulator_disable(ldo0);
9546 regulator_put(ldo0);
9547 ldo0 = NULL;
9548 return rc;
9549}
9550
9551static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9552 .vsync_gpio = MDP_VSYNC_GPIO,
9553 .dsi_power_save = mipi_dsi_panel_power,
9554};
9555
9556#ifdef CONFIG_FB_MSM_TVOUT
9557static struct regulator *reg_8058_l13;
9558
9559static int atv_dac_power(int on)
9560{
9561 int rc = 0;
9562 #define _GET_REGULATOR(var, name) do { \
9563 var = regulator_get(NULL, name); \
9564 if (IS_ERR(var)) { \
9565 pr_info("'%s' regulator not found, rc=%ld\n", \
9566 name, IS_ERR(var)); \
9567 var = NULL; \
9568 return -ENODEV; \
9569 } \
9570 } while (0)
9571
9572 if (!reg_8058_l13)
9573 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9574 #undef _GET_REGULATOR
9575
9576 if (on) {
9577 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9578 if (rc) {
9579 pr_info("%s: '%s' regulator set voltage failed,\
9580 rc=%d\n", __func__, "8058_l13", rc);
9581 return rc;
9582 }
9583
9584 rc = regulator_enable(reg_8058_l13);
9585 if (rc) {
9586 pr_err("%s: '%s' regulator enable failed,\
9587 rc=%d\n", __func__, "8058_l13", rc);
9588 return rc;
9589 }
9590 } else {
9591 rc = regulator_force_disable(reg_8058_l13);
9592 if (rc)
9593 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9594 __func__, "8058_l13", rc);
9595 }
9596 return rc;
9597
9598}
9599#endif
9600
9601#ifdef CONFIG_FB_MSM_MIPI_DSI
9602int mdp_core_clk_rate_table[] = {
9603 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009604 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009605 160000000,
9606 200000000,
9607};
9608#else
9609int mdp_core_clk_rate_table[] = {
9610 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009611 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009612 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009613 200000000,
9614};
9615#endif
9616
9617static struct msm_panel_common_pdata mdp_pdata = {
9618 .gpio = MDP_VSYNC_GPIO,
9619 .mdp_core_clk_rate = 59080000,
9620 .mdp_core_clk_table = mdp_core_clk_rate_table,
9621 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9622#ifdef CONFIG_MSM_BUS_SCALING
9623 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9624#endif
9625 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009626#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009627 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009628#else
9629 .mem_hid = MEMTYPE_EBI1,
9630#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009631};
9632
Huaibin Yanga5419422011-12-08 23:52:10 -08009633static void __init reserve_mdp_memory(void)
9634{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009635 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9636 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9637#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9638 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9639 mdp_pdata.ov0_wb_size;
9640 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9641 mdp_pdata.ov1_wb_size;
9642#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009643}
9644
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009645#ifdef CONFIG_FB_MSM_TVOUT
9646
9647#ifdef CONFIG_MSM_BUS_SCALING
9648static struct msm_bus_vectors atv_bus_init_vectors[] = {
9649 /* For now, 0th array entry is reserved.
9650 * Please leave 0 as is and don't use it
9651 */
9652 {
9653 .src = MSM_BUS_MASTER_MDP_PORT0,
9654 .dst = MSM_BUS_SLAVE_SMI,
9655 .ab = 0,
9656 .ib = 0,
9657 },
9658 /* Master and slaves can be from different fabrics */
9659 {
9660 .src = MSM_BUS_MASTER_MDP_PORT0,
9661 .dst = MSM_BUS_SLAVE_EBI_CH0,
9662 .ab = 0,
9663 .ib = 0,
9664 },
9665};
9666static struct msm_bus_vectors atv_bus_def_vectors[] = {
9667 /* For now, 0th array entry is reserved.
9668 * Please leave 0 as is and don't use it
9669 */
9670 {
9671 .src = MSM_BUS_MASTER_MDP_PORT0,
9672 .dst = MSM_BUS_SLAVE_SMI,
9673 .ab = 236390400,
9674 .ib = 265939200,
9675 },
9676 /* Master and slaves can be from different fabrics */
9677 {
9678 .src = MSM_BUS_MASTER_MDP_PORT0,
9679 .dst = MSM_BUS_SLAVE_EBI_CH0,
9680 .ab = 236390400,
9681 .ib = 265939200,
9682 },
9683};
9684static struct msm_bus_paths atv_bus_scale_usecases[] = {
9685 {
9686 ARRAY_SIZE(atv_bus_init_vectors),
9687 atv_bus_init_vectors,
9688 },
9689 {
9690 ARRAY_SIZE(atv_bus_def_vectors),
9691 atv_bus_def_vectors,
9692 },
9693};
9694static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9695 atv_bus_scale_usecases,
9696 ARRAY_SIZE(atv_bus_scale_usecases),
9697 .name = "atv",
9698};
9699#endif
9700
9701static struct tvenc_platform_data atv_pdata = {
9702 .poll = 0,
9703 .pm_vid_en = atv_dac_power,
9704#ifdef CONFIG_MSM_BUS_SCALING
9705 .bus_scale_table = &atv_bus_scale_pdata,
9706#endif
9707};
9708#endif
9709
9710static void __init msm_fb_add_devices(void)
9711{
9712#ifdef CONFIG_FB_MSM_LCDC_DSUB
9713 mdp_pdata.mdp_core_clk_table = NULL;
9714 mdp_pdata.num_mdp_clk = 0;
9715 mdp_pdata.mdp_core_clk_rate = 200000000;
9716#endif
9717 if (machine_is_msm8x60_rumi3())
9718 msm_fb_register_device("mdp", NULL);
9719 else
9720 msm_fb_register_device("mdp", &mdp_pdata);
9721
9722 msm_fb_register_device("lcdc", &lcdc_pdata);
9723 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9724#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009725 if (hdmi_is_primary)
9726 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9727 else
9728 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009729#endif
9730#ifdef CONFIG_FB_MSM_TVOUT
9731 msm_fb_register_device("tvenc", &atv_pdata);
9732 msm_fb_register_device("tvout_device", NULL);
9733#endif
9734}
9735
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009736/**
9737 * Set MDP clocks to high frequency to avoid underflow when
9738 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9739 */
9740static void set_mdp_clocks_for_wuxga(void)
9741{
9742 int i;
9743
9744 mdp_sd_smi_vectors[0].ab = 2000000000;
9745 mdp_sd_smi_vectors[0].ib = 2000000000;
9746 mdp_sd_smi_vectors[1].ab = 2000000000;
9747 mdp_sd_smi_vectors[1].ib = 2000000000;
9748
9749 mdp_sd_ebi_vectors[0].ab = 2000000000;
9750 mdp_sd_ebi_vectors[0].ib = 2000000000;
9751 mdp_sd_ebi_vectors[1].ab = 2000000000;
9752 mdp_sd_ebi_vectors[1].ib = 2000000000;
9753
9754 mdp_vga_vectors[0].ab = 2000000000;
9755 mdp_vga_vectors[0].ib = 2000000000;
9756 mdp_vga_vectors[1].ab = 2000000000;
9757 mdp_vga_vectors[1].ib = 2000000000;
9758
9759 mdp_720p_vectors[0].ab = 2000000000;
9760 mdp_720p_vectors[0].ib = 2000000000;
9761 mdp_720p_vectors[1].ab = 2000000000;
9762 mdp_720p_vectors[1].ib = 2000000000;
9763
9764 mdp_1080p_vectors[0].ab = 2000000000;
9765 mdp_1080p_vectors[0].ib = 2000000000;
9766 mdp_1080p_vectors[1].ab = 2000000000;
9767 mdp_1080p_vectors[1].ib = 2000000000;
9768
9769 mdp_pdata.mdp_core_clk_rate = 200000000;
9770
9771 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9772 mdp_core_clk_rate_table[i] = 200000000;
9773}
9774
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009775#if (defined(CONFIG_MARIMBA_CORE)) && \
9776 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9777
9778static const struct {
9779 char *name;
9780 int vmin;
9781 int vmax;
9782} bt_regs_info[] = {
9783 { "8058_s3", 1800000, 1800000 },
9784 { "8058_s2", 1300000, 1300000 },
9785 { "8058_l8", 2900000, 3050000 },
9786};
9787
9788static struct {
9789 bool enabled;
9790} bt_regs_status[] = {
9791 { false },
9792 { false },
9793 { false },
9794};
9795static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9796
9797static int bahama_bt(int on)
9798{
9799 int rc;
9800 int i;
9801 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9802
9803 struct bahama_variant_register {
9804 const size_t size;
9805 const struct bahama_config_register *set;
9806 };
9807
9808 const struct bahama_config_register *p;
9809
9810 u8 version;
9811
9812 const struct bahama_config_register v10_bt_on[] = {
9813 { 0xE9, 0x00, 0xFF },
9814 { 0xF4, 0x80, 0xFF },
9815 { 0xE4, 0x00, 0xFF },
9816 { 0xE5, 0x00, 0x0F },
9817#ifdef CONFIG_WLAN
9818 { 0xE6, 0x38, 0x7F },
9819 { 0xE7, 0x06, 0xFF },
9820#endif
9821 { 0xE9, 0x21, 0xFF },
9822 { 0x01, 0x0C, 0x1F },
9823 { 0x01, 0x08, 0x1F },
9824 };
9825
9826 const struct bahama_config_register v20_bt_on_fm_off[] = {
9827 { 0x11, 0x0C, 0xFF },
9828 { 0x13, 0x01, 0xFF },
9829 { 0xF4, 0x80, 0xFF },
9830 { 0xF0, 0x00, 0xFF },
9831 { 0xE9, 0x00, 0xFF },
9832#ifdef CONFIG_WLAN
9833 { 0x81, 0x00, 0x7F },
9834 { 0x82, 0x00, 0xFF },
9835 { 0xE6, 0x38, 0x7F },
9836 { 0xE7, 0x06, 0xFF },
9837#endif
9838 { 0xE9, 0x21, 0xFF },
9839 };
9840
9841 const struct bahama_config_register v20_bt_on_fm_on[] = {
9842 { 0x11, 0x0C, 0xFF },
9843 { 0x13, 0x01, 0xFF },
9844 { 0xF4, 0x86, 0xFF },
9845 { 0xF0, 0x06, 0xFF },
9846 { 0xE9, 0x00, 0xFF },
9847#ifdef CONFIG_WLAN
9848 { 0x81, 0x00, 0x7F },
9849 { 0x82, 0x00, 0xFF },
9850 { 0xE6, 0x38, 0x7F },
9851 { 0xE7, 0x06, 0xFF },
9852#endif
9853 { 0xE9, 0x21, 0xFF },
9854 };
9855
9856 const struct bahama_config_register v10_bt_off[] = {
9857 { 0xE9, 0x00, 0xFF },
9858 };
9859
9860 const struct bahama_config_register v20_bt_off_fm_off[] = {
9861 { 0xF4, 0x84, 0xFF },
9862 { 0xF0, 0x04, 0xFF },
9863 { 0xE9, 0x00, 0xFF }
9864 };
9865
9866 const struct bahama_config_register v20_bt_off_fm_on[] = {
9867 { 0xF4, 0x86, 0xFF },
9868 { 0xF0, 0x06, 0xFF },
9869 { 0xE9, 0x00, 0xFF }
9870 };
9871 const struct bahama_variant_register bt_bahama[2][3] = {
9872 {
9873 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9874 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9875 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9876 },
9877 {
9878 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9879 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9880 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9881 }
9882 };
9883
9884 u8 offset = 0; /* index into bahama configs */
9885
9886 on = on ? 1 : 0;
9887 version = read_bahama_ver();
9888
9889 if (version == VER_UNSUPPORTED) {
9890 dev_err(&msm_bt_power_device.dev,
9891 "%s: unsupported version\n",
9892 __func__);
9893 return -EIO;
9894 }
9895
9896 if (version == VER_2_0) {
9897 if (marimba_get_fm_status(&config))
9898 offset = 0x01;
9899 }
9900
9901 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9902 if (on && (version == VER_2_0)) {
9903 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9904 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9905 && (bt_regs_status[i].enabled == true)) {
9906 if (regulator_disable(bt_regs[i])) {
9907 dev_err(&msm_bt_power_device.dev,
9908 "%s: regulator disable failed",
9909 __func__);
9910 }
9911 bt_regs_status[i].enabled = false;
9912 break;
9913 }
9914 }
9915 }
9916
9917 p = bt_bahama[on][version + offset].set;
9918
9919 dev_info(&msm_bt_power_device.dev,
9920 "%s: found version %d\n", __func__, version);
9921
9922 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9923 u8 value = (p+i)->value;
9924 rc = marimba_write_bit_mask(&config,
9925 (p+i)->reg,
9926 &value,
9927 sizeof((p+i)->value),
9928 (p+i)->mask);
9929 if (rc < 0) {
9930 dev_err(&msm_bt_power_device.dev,
9931 "%s: reg %d write failed: %d\n",
9932 __func__, (p+i)->reg, rc);
9933 return rc;
9934 }
9935 dev_dbg(&msm_bt_power_device.dev,
9936 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9937 __func__, (p+i)->reg,
9938 value, (p+i)->mask);
9939 }
9940 /* Update BT Status */
9941 if (on)
9942 marimba_set_bt_status(&config, true);
9943 else
9944 marimba_set_bt_status(&config, false);
9945
9946 return 0;
9947}
9948
9949static int bluetooth_use_regulators(int on)
9950{
9951 int i, recover = -1, rc = 0;
9952
9953 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9954 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9955 bt_regs_info[i].name) :
9956 (regulator_put(bt_regs[i]), NULL);
9957 if (IS_ERR(bt_regs[i])) {
9958 rc = PTR_ERR(bt_regs[i]);
9959 dev_err(&msm_bt_power_device.dev,
9960 "regulator %s get failed (%d)\n",
9961 bt_regs_info[i].name, rc);
9962 recover = i - 1;
9963 bt_regs[i] = NULL;
9964 break;
9965 }
9966
9967 if (!on)
9968 continue;
9969
9970 rc = regulator_set_voltage(bt_regs[i],
9971 bt_regs_info[i].vmin,
9972 bt_regs_info[i].vmax);
9973 if (rc < 0) {
9974 dev_err(&msm_bt_power_device.dev,
9975 "regulator %s voltage set (%d)\n",
9976 bt_regs_info[i].name, rc);
9977 recover = i;
9978 break;
9979 }
9980 }
9981
9982 if (on && (recover > -1))
9983 for (i = recover; i >= 0; i--) {
9984 regulator_put(bt_regs[i]);
9985 bt_regs[i] = NULL;
9986 }
9987
9988 return rc;
9989}
9990
9991static int bluetooth_switch_regulators(int on)
9992{
9993 int i, rc = 0;
9994
9995 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9996 if (on && (bt_regs_status[i].enabled == false)) {
9997 rc = regulator_enable(bt_regs[i]);
9998 if (rc < 0) {
9999 dev_err(&msm_bt_power_device.dev,
10000 "regulator %s %s failed (%d)\n",
10001 bt_regs_info[i].name,
10002 "enable", rc);
10003 if (i > 0) {
10004 while (--i) {
10005 regulator_disable(bt_regs[i]);
10006 bt_regs_status[i].enabled
10007 = false;
10008 }
10009 break;
10010 }
10011 }
10012 bt_regs_status[i].enabled = true;
10013 } else if (!on && (bt_regs_status[i].enabled == true)) {
10014 rc = regulator_disable(bt_regs[i]);
10015 if (rc < 0) {
10016 dev_err(&msm_bt_power_device.dev,
10017 "regulator %s %s failed (%d)\n",
10018 bt_regs_info[i].name,
10019 "disable", rc);
10020 break;
10021 }
10022 bt_regs_status[i].enabled = false;
10023 }
10024 }
10025 return rc;
10026}
10027
10028static struct msm_xo_voter *bt_clock;
10029
10030static int bluetooth_power(int on)
10031{
10032 int rc = 0;
10033 int id;
10034
10035 /* In case probe function fails, cur_connv_type would be -1 */
10036 id = adie_get_detected_connectivity_type();
10037 if (id != BAHAMA_ID) {
10038 pr_err("%s: unexpected adie connectivity type: %d\n",
10039 __func__, id);
10040 return -ENODEV;
10041 }
10042
10043 if (on) {
10044
10045 rc = bluetooth_use_regulators(1);
10046 if (rc < 0)
10047 goto out;
10048
10049 rc = bluetooth_switch_regulators(1);
10050
10051 if (rc < 0)
10052 goto fail_put;
10053
10054 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10055
10056 if (IS_ERR(bt_clock)) {
10057 pr_err("Couldn't get TCXO_D0 voter\n");
10058 goto fail_switch;
10059 }
10060
10061 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10062
10063 if (rc < 0) {
10064 pr_err("Failed to vote for TCXO_DO ON\n");
10065 goto fail_vote;
10066 }
10067
10068 rc = bahama_bt(1);
10069
10070 if (rc < 0)
10071 goto fail_clock;
10072
10073 msleep(10);
10074
10075 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10076
10077 if (rc < 0) {
10078 pr_err("Failed to vote for TCXO_DO pin control\n");
10079 goto fail_vote;
10080 }
10081 } else {
10082 /* check for initial RFKILL block (power off) */
10083 /* some RFKILL versions/configurations rfkill_register */
10084 /* calls here for an initial set_block */
10085 /* avoid calling i2c and regulator before unblock (on) */
10086 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10087 dev_info(&msm_bt_power_device.dev,
10088 "%s: initialized OFF/blocked\n", __func__);
10089 goto out;
10090 }
10091
10092 bahama_bt(0);
10093
10094fail_clock:
10095 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10096fail_vote:
10097 msm_xo_put(bt_clock);
10098fail_switch:
10099 bluetooth_switch_regulators(0);
10100fail_put:
10101 bluetooth_use_regulators(0);
10102 }
10103
10104out:
10105 if (rc < 0)
10106 on = 0;
10107 dev_info(&msm_bt_power_device.dev,
10108 "Bluetooth power switch: state %d result %d\n", on, rc);
10109
10110 return rc;
10111}
10112
10113#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10114
10115static void __init msm8x60_cfg_smsc911x(void)
10116{
10117 smsc911x_resources[1].start =
10118 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10119 smsc911x_resources[1].end =
10120 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10121}
10122
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010123void msm_fusion_setup_pinctrl(void)
10124{
10125 struct msm_xo_voter *a1;
10126
10127 if (socinfo_get_platform_subtype() == 0x3) {
10128 /*
10129 * Vote for the A1 clock to be in pin control mode before
10130 * the external images are loaded.
10131 */
10132 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10133 BUG_ON(!a1);
10134 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10135 }
10136}
10137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010138struct msm_board_data {
10139 struct msm_gpiomux_configs *gpiomux_cfgs;
10140};
10141
10142static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10143 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10144};
10145
10146static struct msm_board_data msm8x60_sim_board_data __initdata = {
10147 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10148};
10149
10150static struct msm_board_data msm8x60_surf_board_data __initdata = {
10151 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10152};
10153
10154static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10155 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10156};
10157
10158static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10159 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10160};
10161
10162static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10163 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10164};
10165
10166static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10167 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10168};
10169
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010170static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10171 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10172};
10173
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010174static void __init msm8x60_init(struct msm_board_data *board_data)
10175{
10176 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010177#ifdef CONFIG_USB_EHCI_MSM_72K
10178 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10179 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10180 .level = PM8901_MPP_DIG_LEVEL_L5,
10181 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10182 };
10183#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010184 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010185
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010186 /*
10187 * Initialize RPM first as other drivers and devices may need
10188 * it for their initialization.
10189 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010190 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10191 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010192 if (msm_xo_init())
10193 pr_err("Failed to initialize XO votes\n");
10194
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010195 msm8x60_check_2d_hardware();
10196
10197 /* Change SPM handling of core 1 if PMM 8160 is present. */
10198 soc_platform_version = socinfo_get_platform_version();
10199 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10200 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10201 struct msm_spm_platform_data *spm_data;
10202
10203 spm_data = &msm_spm_data_v1[1];
10204 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10205 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10206
10207 spm_data = &msm_spm_data[1];
10208 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10209 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10210 }
10211
10212 /*
10213 * Initialize SPM before acpuclock as the latter calls into SPM
10214 * driver to set ACPU voltages.
10215 */
10216 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10217 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10218 else
10219 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10220
10221 /*
10222 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10223 * devices so that the RPM doesn't drop into a low power mode that an
10224 * un-reworked SURF cannot resume from.
10225 */
10226 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010227 int i;
10228
10229 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10230 if (rpm_regulator_init_data[i].id
10231 == RPM_VREG_ID_PM8901_L4
10232 || rpm_regulator_init_data[i].id
10233 == RPM_VREG_ID_PM8901_L6)
10234 rpm_regulator_init_data[i]
10235 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010236 }
10237
10238 /*
10239 * Disable regulator info printing so that regulator registration
10240 * messages do not enter the kmsg log.
10241 */
10242 regulator_suppress_info_printing();
10243
10244 /* Initialize regulators needed for clock_init. */
10245 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10246
Stephen Boydbb600ae2011-08-02 20:11:40 -070010247 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010248
10249 /* Buses need to be initialized before early-device registration
10250 * to get the platform data for fabrics.
10251 */
10252 msm8x60_init_buses();
10253 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10254 /* CPU frequency control is not supported on simulated targets. */
10255 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010256 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010257
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010258 /*
10259 * Enable EBI2 only for boards which make use of it. Leave
10260 * it disabled for all others for additional power savings.
10261 */
10262 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10263 machine_is_msm8x60_rumi3() ||
10264 machine_is_msm8x60_sim() ||
10265 machine_is_msm8x60_fluid() ||
10266 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010267 msm8x60_init_ebi2();
10268 msm8x60_init_tlmm();
10269 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10270 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010271#ifdef CONFIG_MSM_CAMERA_V4L2
10272 msm8x60_init_cam();
10273#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010274 msm8x60_init_mmc();
10275
Kevin Chan3be11612012-03-22 20:05:40 -070010276
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010277#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10278 msm8x60_init_pm8058_othc();
10279#endif
10280
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010281 if (machine_is_msm8x60_fluid())
10282 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10283 else if (machine_is_msm8x60_dragon())
10284 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10285 else
10286 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Kevin Chan3be11612012-03-22 20:05:40 -070010287#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang53d27a82011-07-13 14:32:58 -040010288 /* Specify reset pin for OV9726 */
10289 if (machine_is_msm8x60_dragon()) {
10290 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10291 ov9726_sensor_8660_info.mount_angle = 270;
10292 }
Kevin Chan3be11612012-03-22 20:05:40 -070010293#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010294#ifdef CONFIG_BATTERY_MSM8X60
10295 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10296 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10297 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10298 platform_device_register(&msm_charger_device);
10299#endif
10300
10301 if (machine_is_msm8x60_dragon())
10302 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10303 if (!machine_is_msm8x60_fluid())
10304 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10305
10306 /* configure pmic leds */
10307 if (machine_is_msm8x60_fluid())
10308 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10309 else if (machine_is_msm8x60_dragon())
10310 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10311 else
10312 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10313
10314 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10315 machine_is_msm8x60_dragon()) {
10316 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10317 }
10318
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010319 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10320 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010321 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010322 msm8x60_cfg_smsc911x();
10323 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010324 platform_add_devices(msm8660_footswitch,
10325 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010326 platform_add_devices(surf_devices,
10327 ARRAY_SIZE(surf_devices));
10328
10329#ifdef CONFIG_MSM_DSPS
10330 if (machine_is_msm8x60_fluid()) {
10331 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10332 msm8x60_init_dsps();
10333 }
10334#endif
10335
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010336 pm8901_vreg_mpp0_init();
10337
10338 platform_device_register(&msm8x60_8901_mpp_vreg);
10339
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010340#ifdef CONFIG_USB_EHCI_MSM_72K
10341 /*
10342 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10343 * fluid
10344 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010345 if (machine_is_msm8x60_fluid())
10346 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10347 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010348#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010349
10350#ifdef CONFIG_SND_SOC_MSM8660_APQ
10351 if (machine_is_msm8x60_dragon())
10352 platform_add_devices(dragon_alsa_devices,
10353 ARRAY_SIZE(dragon_alsa_devices));
10354 else
10355#endif
10356 platform_add_devices(asoc_devices,
10357 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010358 } else {
10359 msm8x60_configure_smc91x();
10360 platform_add_devices(rumi_sim_devices,
10361 ARRAY_SIZE(rumi_sim_devices));
10362 }
10363#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010364 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10365 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010366 msm8x60_cfg_isp1763();
10367#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010368
10369 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10370 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10371
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010372
10373#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10374 if (machine_is_msm8x60_fluid())
10375 platform_device_register(&msm_gsbi10_qup_spi_device);
10376 else
10377 platform_device_register(&msm_gsbi1_qup_spi_device);
10378#endif
10379
10380#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10381 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10382 if (machine_is_msm8x60_fluid())
10383 cyttsp_set_params();
10384#endif
10385 if (!machine_is_msm8x60_sim())
10386 msm_fb_add_devices();
10387 fixup_i2c_configs();
10388 register_i2c_devices();
10389
Terence Hampson1c73fef2011-07-19 17:10:49 -040010390 if (machine_is_msm8x60_dragon())
10391 smsc911x_config.reset_gpio
10392 = GPIO_ETHERNET_RESET_N_DRAGON;
10393
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010394 platform_device_register(&smsc911x_device);
10395
10396#if (defined(CONFIG_SPI_QUP)) && \
10397 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010398 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10399 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010400
10401 if (machine_is_msm8x60_fluid()) {
10402#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10403 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10404 spi_register_board_info(lcdc_samsung_spi_board_info,
10405 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10406 } else
10407#endif
10408 {
10409#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10410 spi_register_board_info(lcdc_auo_spi_board_info,
10411 ARRAY_SIZE(lcdc_auo_spi_board_info));
10412#endif
10413 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010414#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10415 } else if (machine_is_msm8x60_dragon()) {
10416 spi_register_board_info(lcdc_nt35582_spi_board_info,
10417 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10418#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010419 }
10420#endif
10421
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010422 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010423
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010424 pm8058_gpios_init();
10425
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010426#ifdef CONFIG_SENSORS_MSM_ADC
10427 if (machine_is_msm8x60_fluid()) {
10428 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10429 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10430 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10431 msm_adc_pdata.gpio_config = APROC_CONFIG;
10432 else
10433 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10434 }
10435 msm_adc_pdata.target_hw = MSM_8x60;
10436#endif
10437#ifdef CONFIG_MSM8X60_AUDIO
10438 msm_snddev_init();
10439#endif
10440#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10441 if (machine_is_msm8x60_fluid())
10442 platform_device_register(&fluid_leds_gpio);
10443 else
10444 platform_device_register(&gpio_leds);
10445#endif
10446
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010447 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010448
10449 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10450 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010451}
10452
10453static void __init msm8x60_rumi3_init(void)
10454{
10455 msm8x60_init(&msm8x60_rumi3_board_data);
10456}
10457
10458static void __init msm8x60_sim_init(void)
10459{
10460 msm8x60_init(&msm8x60_sim_board_data);
10461}
10462
10463static void __init msm8x60_surf_init(void)
10464{
10465 msm8x60_init(&msm8x60_surf_board_data);
10466}
10467
10468static void __init msm8x60_ffa_init(void)
10469{
10470 msm8x60_init(&msm8x60_ffa_board_data);
10471}
10472
10473static void __init msm8x60_fluid_init(void)
10474{
10475 msm8x60_init(&msm8x60_fluid_board_data);
10476}
10477
10478static void __init msm8x60_charm_surf_init(void)
10479{
10480 msm8x60_init(&msm8x60_charm_surf_board_data);
10481}
10482
10483static void __init msm8x60_charm_ffa_init(void)
10484{
10485 msm8x60_init(&msm8x60_charm_ffa_board_data);
10486}
10487
10488static void __init msm8x60_charm_init_early(void)
10489{
10490 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010491}
10492
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010493static void __init msm8x60_dragon_init(void)
10494{
10495 msm8x60_init(&msm8x60_dragon_board_data);
10496}
10497
Steve Mucklea55df6e2010-01-07 12:43:24 -080010498MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10499 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010500 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010501 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010502 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010503 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010504 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010505 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010506MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010507
10508MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10509 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010510 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010511 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010512 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010513 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010514 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010515 .init_early = msm8x60_charm_init_early,
10516MACHINE_END
10517
10518MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10519 .map_io = msm8x60_map_io,
10520 .reserve = msm8x60_reserve,
10521 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010522 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010523 .init_machine = msm8x60_surf_init,
10524 .timer = &msm_timer,
10525 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010526MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010527
10528MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10529 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010530 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010531 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010532 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010533 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010534 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010535 .init_early = msm8x60_charm_init_early,
10536MACHINE_END
10537
10538MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10539 .map_io = msm8x60_map_io,
10540 .reserve = msm8x60_reserve,
10541 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010542 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010543 .init_machine = msm8x60_fluid_init,
10544 .timer = &msm_timer,
10545 .init_early = msm8x60_charm_init_early,
10546MACHINE_END
10547
10548MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10549 .map_io = msm8x60_map_io,
10550 .reserve = msm8x60_reserve,
10551 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010552 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010553 .init_machine = msm8x60_charm_surf_init,
10554 .timer = &msm_timer,
10555 .init_early = msm8x60_charm_init_early,
10556MACHINE_END
10557
10558MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10559 .map_io = msm8x60_map_io,
10560 .reserve = msm8x60_reserve,
10561 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010562 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010563 .init_machine = msm8x60_charm_ffa_init,
10564 .timer = &msm_timer,
10565 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010566MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010567
10568MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10569 .map_io = msm8x60_map_io,
10570 .reserve = msm8x60_reserve,
10571 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010572 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010573 .init_machine = msm8x60_dragon_init,
10574 .timer = &msm_timer,
10575 .init_early = msm8x60_charm_init_early,
10576MACHINE_END