blob: 5fc17dfd5f3ae0602ac405bf697743bc346eac25 [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"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003815};
3816static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3817 REGULATOR_SUPPLY("8058_l16", NULL),
3818};
3819static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3820 REGULATOR_SUPPLY("8058_l17", NULL),
3821};
3822static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3823 REGULATOR_SUPPLY("8058_l18", NULL),
3824};
3825static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3826 REGULATOR_SUPPLY("8058_l19", NULL),
3827};
3828static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3829 REGULATOR_SUPPLY("8058_l20", NULL),
3830};
3831static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3832 REGULATOR_SUPPLY("8058_l21", NULL),
3833};
3834static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3835 REGULATOR_SUPPLY("8058_l22", NULL),
3836};
3837static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3838 REGULATOR_SUPPLY("8058_l23", NULL),
3839};
3840static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3841 REGULATOR_SUPPLY("8058_l24", NULL),
3842};
3843static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3844 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003845 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003846};
3847static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3848 REGULATOR_SUPPLY("8058_s0", NULL),
3849};
3850static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3851 REGULATOR_SUPPLY("8058_s1", NULL),
3852};
3853static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3854 REGULATOR_SUPPLY("8058_s2", NULL),
3855};
3856static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3857 REGULATOR_SUPPLY("8058_s3", NULL),
3858};
3859static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3860 REGULATOR_SUPPLY("8058_s4", NULL),
3861};
3862static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3863 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003864 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3867 REGULATOR_SUPPLY("8058_lvs1", NULL),
3868};
3869static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3870 REGULATOR_SUPPLY("8058_ncp", NULL),
3871};
3872
3873static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3874 REGULATOR_SUPPLY("8901_l0", NULL),
3875};
3876static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3877 REGULATOR_SUPPLY("8901_l1", NULL),
3878};
3879static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3880 REGULATOR_SUPPLY("8901_l2", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3883 REGULATOR_SUPPLY("8901_l3", NULL),
3884};
3885static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3886 REGULATOR_SUPPLY("8901_l4", NULL),
3887};
3888static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3889 REGULATOR_SUPPLY("8901_l5", NULL),
3890};
3891static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3892 REGULATOR_SUPPLY("8901_l6", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3895 REGULATOR_SUPPLY("8901_s2", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3898 REGULATOR_SUPPLY("8901_s3", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3901 REGULATOR_SUPPLY("8901_s4", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3904 REGULATOR_SUPPLY("8901_lvs0", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3907 REGULATOR_SUPPLY("8901_lvs1", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3910 REGULATOR_SUPPLY("8901_lvs2", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3913 REGULATOR_SUPPLY("8901_lvs3", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3916 REGULATOR_SUPPLY("8901_mvs0", NULL),
3917};
3918
David Collins6f032ba2011-08-31 14:08:15 -07003919/* Pin control regulators */
3920static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3921 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3922};
3923static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3924 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3925};
3926static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3927 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3930 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3933 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3934};
3935static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3936 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3937};
3938
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003939#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3940 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003941 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3942 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003943 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003944 .init_data = { \
3945 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003946 .valid_modes_mask = _modes, \
3947 .valid_ops_mask = _ops, \
3948 .min_uV = _min_uV, \
3949 .max_uV = _max_uV, \
3950 .input_uV = _min_uV, \
3951 .apply_uV = _apply_uV, \
3952 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003953 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003954 .consumer_supplies = vreg_consumers_##_id, \
3955 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003956 ARRAY_SIZE(vreg_consumers_##_id), \
3957 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003958 .id = RPM_VREG_ID_##_id, \
3959 .default_uV = _default_uV, \
3960 .peak_uA = _peak_uA, \
3961 .avg_uA = _avg_uA, \
3962 .pull_down_enable = _pull_down, \
3963 .pin_ctrl = _pin_ctrl, \
3964 .freq = RPM_VREG_FREQ_##_freq, \
3965 .pin_fn = _pin_fn, \
3966 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003967 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003968 .state = _state, \
3969 .sleep_selectable = _sleep_selectable, \
3970 }
3971
3972/* Pin control initialization */
3973#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3974 { \
3975 .init_data = { \
3976 .constraints = { \
3977 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3978 .always_on = _always_on, \
3979 }, \
3980 .num_consumer_supplies = \
3981 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3982 .consumer_supplies = vreg_consumers_##_id##_PC, \
3983 }, \
3984 .id = RPM_VREG_ID_##_id##_PC, \
3985 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003986 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003987 }
3988
3989/*
3990 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3991 * via the peak_uA value specified in the table below. If the value is less
3992 * than the high power min threshold for the regulator, then the regulator will
3993 * be set to LPM. Otherwise, it will be set to HPM.
3994 *
3995 * This value can be further overridden by specifying an initial mode via
3996 * .init_data.constraints.initial_mode.
3997 */
3998
David Collins6f032ba2011-08-31 14:08:15 -07003999#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4000 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004001 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4002 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4003 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4004 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4005 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004006 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4007 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004008 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004009 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004010 _sleep_selectable, _always_on)
4011
David Collins6f032ba2011-08-31 14:08:15 -07004012#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4013 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004014 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4015 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4016 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4017 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4018 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004019 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4020 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004021 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004022 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4023 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004024
David Collins6f032ba2011-08-31 14:08:15 -07004025#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004026 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4027 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004028 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4029 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004030 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004031 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4032 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004033
David Collins6f032ba2011-08-31 14:08:15 -07004034#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004035 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4036 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004037 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4038 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004039 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004040 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4041 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004042
David Collins6f032ba2011-08-31 14:08:15 -07004043#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4044#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4045#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4046#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4047#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004048
David Collins6f032ba2011-08-31 14:08:15 -07004049/* RPM early regulator constraints */
4050static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4051 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004052 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004053 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004054};
4055
David Collins6f032ba2011-08-31 14:08:15 -07004056/* RPM regulator constraints */
4057static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4058 /* ID a_on pd ss min_uV max_uV init_ip */
4059 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4060 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4061 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4062 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4063 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4064 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4065 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4066 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4067 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4068 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4069 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4070 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4071 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4072 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4073 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4074 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4075 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4076 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4077 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4078 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4079 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4080 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4081 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4082 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4083 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4084 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004085
David Collins6f032ba2011-08-31 14:08:15 -07004086 /* ID a_on pd ss min_uV max_uV init_ip freq */
4087 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4088 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4089 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4090
4091 /* ID a_on pd ss */
4092 RPM_VS(PM8058_LVS0, 0, 1, 0),
4093 RPM_VS(PM8058_LVS1, 0, 1, 0),
4094
4095 /* ID a_on pd ss min_uV max_uV */
4096 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4097
4098 /* ID a_on pd ss min_uV max_uV init_ip */
4099 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4100 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4101 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4102 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4103 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4104 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4105 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4106
4107 /* ID a_on pd ss min_uV max_uV init_ip freq */
4108 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4109 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4110 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4111
4112 /* ID a_on pd ss */
4113 RPM_VS(PM8901_LVS0, 1, 1, 0),
4114 RPM_VS(PM8901_LVS1, 0, 1, 0),
4115 RPM_VS(PM8901_LVS2, 0, 1, 0),
4116 RPM_VS(PM8901_LVS3, 0, 1, 0),
4117 RPM_VS(PM8901_MVS0, 0, 1, 0),
4118
4119 /* ID a_on pin_func pin_ctrl */
4120 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4121 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4122 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4123 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4124 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4125 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4126};
4127
4128static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4129 .init_data = rpm_regulator_early_init_data,
4130 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4131 .version = RPM_VREG_VERSION_8660,
4132 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4133 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4134};
4135
4136static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4137 .init_data = rpm_regulator_init_data,
4138 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4139 .version = RPM_VREG_VERSION_8660,
4140};
4141
4142static struct platform_device rpm_regulator_early_device = {
4143 .name = "rpm-regulator",
4144 .id = 0,
4145 .dev = {
4146 .platform_data = &rpm_regulator_early_pdata,
4147 },
4148};
4149
4150static struct platform_device rpm_regulator_device = {
4151 .name = "rpm-regulator",
4152 .id = 1,
4153 .dev = {
4154 .platform_data = &rpm_regulator_pdata,
4155 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004156};
4157
4158static struct platform_device *early_regulators[] __initdata = {
4159 &msm_device_saw_s0,
4160 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004161 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162};
4163
4164static struct platform_device *early_devices[] __initdata = {
4165#ifdef CONFIG_MSM_BUS_SCALING
4166 &msm_bus_apps_fabric,
4167 &msm_bus_sys_fabric,
4168 &msm_bus_mm_fabric,
4169 &msm_bus_sys_fpb,
4170 &msm_bus_cpss_fpb,
4171#endif
4172 &msm_device_dmov_adm0,
4173 &msm_device_dmov_adm1,
4174};
4175
4176#if (defined(CONFIG_MARIMBA_CORE)) && \
4177 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4178
4179static int bluetooth_power(int);
4180static struct platform_device msm_bt_power_device = {
4181 .name = "bt_power",
4182 .id = -1,
4183 .dev = {
4184 .platform_data = &bluetooth_power,
4185 },
4186};
4187#endif
4188
4189static struct platform_device msm_tsens_device = {
4190 .name = "tsens-tm",
4191 .id = -1,
4192};
4193
4194static struct platform_device *rumi_sim_devices[] __initdata = {
4195 &smc91x_device,
4196 &msm_device_uart_dm12,
4197#ifdef CONFIG_I2C_QUP
4198 &msm_gsbi3_qup_i2c_device,
4199 &msm_gsbi4_qup_i2c_device,
4200 &msm_gsbi7_qup_i2c_device,
4201 &msm_gsbi8_qup_i2c_device,
4202 &msm_gsbi9_qup_i2c_device,
4203 &msm_gsbi12_qup_i2c_device,
4204#endif
4205#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004206 &msm_device_ssbi3,
4207#endif
4208#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004209#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004210 &android_pmem_device,
4211 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004212 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004213 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304214#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4215#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004216#ifdef CONFIG_MSM_ROTATOR
4217 &msm_rotator_device,
4218#endif
4219 &msm_fb_device,
4220 &msm_kgsl_3d0,
4221 &msm_kgsl_2d0,
4222 &msm_kgsl_2d1,
4223 &lcdc_samsung_panel_device,
4224#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4225 &hdmi_msm_device,
4226#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4227#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004228#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004229#ifdef CONFIG_MT9E013
4230 &msm_camera_sensor_mt9e013,
4231#endif
4232#ifdef CONFIG_IMX074
4233 &msm_camera_sensor_imx074,
4234#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004235#ifdef CONFIG_VX6953
4236 &msm_camera_sensor_vx6953,
4237#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004238#ifdef CONFIG_WEBCAM_OV7692
4239 &msm_camera_sensor_webcam_ov7692,
4240#endif
4241#ifdef CONFIG_WEBCAM_OV9726
4242 &msm_camera_sensor_webcam_ov9726,
4243#endif
4244#ifdef CONFIG_QS_S5K4E1
4245 &msm_camera_sensor_qs_s5k4e1,
4246#endif
4247#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004248#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004249#ifdef CONFIG_MSM_GEMINI
4250 &msm_gemini_device,
4251#endif
4252#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004253#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004254 &msm_vpe_device,
4255#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004256#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004257 &msm_device_vidc,
4258};
4259
4260#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4261enum {
4262 SX150X_CORE,
4263 SX150X_DOCKING,
4264 SX150X_SURF,
4265 SX150X_LEFT_FHA,
4266 SX150X_RIGHT_FHA,
4267 SX150X_SOUTH,
4268 SX150X_NORTH,
4269 SX150X_CORE_FLUID,
4270};
4271
4272static struct sx150x_platform_data sx150x_data[] __initdata = {
4273 [SX150X_CORE] = {
4274 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4275 .oscio_is_gpo = false,
4276 .io_pullup_ena = 0x0c08,
4277 .io_pulldn_ena = 0x4060,
4278 .io_open_drain_ena = 0x000c,
4279 .io_polarity = 0,
4280 .irq_summary = -1, /* see fixup_i2c_configs() */
4281 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4282 },
4283 [SX150X_DOCKING] = {
4284 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4285 .oscio_is_gpo = false,
4286 .io_pullup_ena = 0x5e06,
4287 .io_pulldn_ena = 0x81b8,
4288 .io_open_drain_ena = 0,
4289 .io_polarity = 0,
4290 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4291 UI_INT2_N),
4292 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4293 GPIO_DOCKING_EXPANDER_BASE -
4294 GPIO_EXPANDER_GPIO_BASE,
4295 },
4296 [SX150X_SURF] = {
4297 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4298 .oscio_is_gpo = false,
4299 .io_pullup_ena = 0,
4300 .io_pulldn_ena = 0,
4301 .io_open_drain_ena = 0,
4302 .io_polarity = 0,
4303 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4304 UI_INT1_N),
4305 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4306 GPIO_SURF_EXPANDER_BASE -
4307 GPIO_EXPANDER_GPIO_BASE,
4308 },
4309 [SX150X_LEFT_FHA] = {
4310 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4311 .oscio_is_gpo = false,
4312 .io_pullup_ena = 0,
4313 .io_pulldn_ena = 0x40,
4314 .io_open_drain_ena = 0,
4315 .io_polarity = 0,
4316 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4317 UI_INT3_N),
4318 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4319 GPIO_LEFT_KB_EXPANDER_BASE -
4320 GPIO_EXPANDER_GPIO_BASE,
4321 },
4322 [SX150X_RIGHT_FHA] = {
4323 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4324 .oscio_is_gpo = true,
4325 .io_pullup_ena = 0,
4326 .io_pulldn_ena = 0,
4327 .io_open_drain_ena = 0,
4328 .io_polarity = 0,
4329 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4330 UI_INT3_N),
4331 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4332 GPIO_RIGHT_KB_EXPANDER_BASE -
4333 GPIO_EXPANDER_GPIO_BASE,
4334 },
4335 [SX150X_SOUTH] = {
4336 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4337 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4338 GPIO_SOUTH_EXPANDER_BASE -
4339 GPIO_EXPANDER_GPIO_BASE,
4340 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4341 },
4342 [SX150X_NORTH] = {
4343 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4344 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4345 GPIO_NORTH_EXPANDER_BASE -
4346 GPIO_EXPANDER_GPIO_BASE,
4347 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4348 .oscio_is_gpo = true,
4349 .io_open_drain_ena = 0x30,
4350 },
4351 [SX150X_CORE_FLUID] = {
4352 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4353 .oscio_is_gpo = false,
4354 .io_pullup_ena = 0x0408,
4355 .io_pulldn_ena = 0x4060,
4356 .io_open_drain_ena = 0x0008,
4357 .io_polarity = 0,
4358 .irq_summary = -1, /* see fixup_i2c_configs() */
4359 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4360 },
4361};
4362
4363#ifdef CONFIG_SENSORS_MSM_ADC
4364/* Configuration of EPM expander is done when client
4365 * request an adc read
4366 */
4367static struct sx150x_platform_data sx150x_epmdata = {
4368 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4369 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4370 GPIO_EPM_EXPANDER_BASE -
4371 GPIO_EXPANDER_GPIO_BASE,
4372 .irq_summary = -1,
4373};
4374#endif
4375
4376/* sx150x_low_power_cfg
4377 *
4378 * This data and init function are used to put unused gpio-expander output
4379 * lines into their low-power states at boot. The init
4380 * function must be deferred until a later init stage because the i2c
4381 * gpio expander drivers do not probe until after they are registered
4382 * (see register_i2c_devices) and the work-queues for those registrations
4383 * are processed. Because these lines are unused, there is no risk of
4384 * competing with a device driver for the gpio.
4385 *
4386 * gpio lines whose low-power states are input are naturally in their low-
4387 * power configurations once probed, see the platform data structures above.
4388 */
4389struct sx150x_low_power_cfg {
4390 unsigned gpio;
4391 unsigned val;
4392};
4393
4394static struct sx150x_low_power_cfg
4395common_sx150x_lp_cfgs[] __initdata = {
4396 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4397 {GPIO_EXT_GPS_LNA_EN, 0},
4398 {GPIO_MSM_WAKES_BT, 0},
4399 {GPIO_USB_UICC_EN, 0},
4400 {GPIO_BATT_GAUGE_EN, 0},
4401};
4402
4403static struct sx150x_low_power_cfg
4404surf_ffa_sx150x_lp_cfgs[] __initdata = {
4405 {GPIO_MIPI_DSI_RST_N, 0},
4406 {GPIO_DONGLE_PWR_EN, 0},
4407 {GPIO_CAP_TS_SLEEP, 1},
4408 {GPIO_WEB_CAMIF_RESET_N, 0},
4409};
4410
4411static void __init
4412cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4413{
4414 unsigned n;
4415 int rc;
4416
4417 for (n = 0; n < nelems; ++n) {
4418 rc = gpio_request(cfgs[n].gpio, NULL);
4419 if (!rc) {
4420 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4421 gpio_free(cfgs[n].gpio);
4422 }
4423
4424 if (rc) {
4425 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4426 __func__, cfgs[n].gpio, rc);
4427 }
Steve Muckle9161d302010-02-11 11:50:40 -08004428 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004429}
4430
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004431static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004432{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004433 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4434 ARRAY_SIZE(common_sx150x_lp_cfgs));
4435 if (!machine_is_msm8x60_fluid())
4436 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4437 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4438 return 0;
4439}
4440module_init(cfg_sx150xs_low_power);
4441
4442#ifdef CONFIG_I2C
4443static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4444 {
4445 I2C_BOARD_INFO("sx1509q", 0x3e),
4446 .platform_data = &sx150x_data[SX150X_CORE]
4447 },
4448};
4449
4450static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4451 {
4452 I2C_BOARD_INFO("sx1509q", 0x3f),
4453 .platform_data = &sx150x_data[SX150X_DOCKING]
4454 },
4455};
4456
4457static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4458 {
4459 I2C_BOARD_INFO("sx1509q", 0x70),
4460 .platform_data = &sx150x_data[SX150X_SURF]
4461 }
4462};
4463
4464static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4465 {
4466 I2C_BOARD_INFO("sx1508q", 0x21),
4467 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4468 },
4469 {
4470 I2C_BOARD_INFO("sx1508q", 0x22),
4471 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4472 }
4473};
4474
4475static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4476 {
4477 I2C_BOARD_INFO("sx1508q", 0x23),
4478 .platform_data = &sx150x_data[SX150X_SOUTH]
4479 },
4480 {
4481 I2C_BOARD_INFO("sx1508q", 0x20),
4482 .platform_data = &sx150x_data[SX150X_NORTH]
4483 }
4484};
4485
4486static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4487 {
4488 I2C_BOARD_INFO("sx1509q", 0x3e),
4489 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4490 },
4491};
4492
4493#ifdef CONFIG_SENSORS_MSM_ADC
4494static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4495 {
4496 I2C_BOARD_INFO("sx1509q", 0x3e),
4497 .platform_data = &sx150x_epmdata
4498 },
4499};
4500#endif
4501#endif
4502#endif
4503
4504#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004505
4506static struct adc_access_fn xoadc_fn = {
4507 pm8058_xoadc_select_chan_and_start_conv,
4508 pm8058_xoadc_read_adc_code,
4509 pm8058_xoadc_get_properties,
4510 pm8058_xoadc_slot_request,
4511 pm8058_xoadc_restore_slot,
4512 pm8058_xoadc_calibrate,
4513};
4514
4515#if defined(CONFIG_I2C) && \
4516 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4517static struct regulator *vreg_adc_epm1;
4518
4519static struct i2c_client *epm_expander_i2c_register_board(void)
4520
4521{
4522 struct i2c_adapter *i2c_adap;
4523 struct i2c_client *client = NULL;
4524 i2c_adap = i2c_get_adapter(0x0);
4525
4526 if (i2c_adap == NULL)
4527 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4528
4529 if (i2c_adap != NULL)
4530 client = i2c_new_device(i2c_adap,
4531 &fluid_expanders_i2c_epm_info[0]);
4532 return client;
4533
4534}
4535
4536static unsigned int msm_adc_gpio_configure_expander_enable(void)
4537{
4538 int rc = 0;
4539 static struct i2c_client *epm_i2c_client;
4540
4541 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4542
4543 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4544
4545 if (IS_ERR(vreg_adc_epm1)) {
4546 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4547 return 0;
4548 }
4549
4550 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4551 if (rc)
4552 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4553 "regulator set voltage failed\n");
4554
4555 rc = regulator_enable(vreg_adc_epm1);
4556 if (rc) {
4557 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4558 "Error while enabling regulator for epm s3 %d\n", rc);
4559 return rc;
4560 }
4561
4562 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4563 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4564
4565 msleep(1000);
4566
4567 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4568 if (!rc) {
4569 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4570 "Configure 5v boost\n");
4571 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4572 } else {
4573 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4574 "Error for epm 5v boost en\n");
4575 goto exit_vreg_epm;
4576 }
4577
4578 msleep(500);
4579
4580 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4581 if (!rc) {
4582 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4583 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4584 "Configure epm 3.3v\n");
4585 } else {
4586 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4587 "Error for gpio 3.3ven\n");
4588 goto exit_vreg_epm;
4589 }
4590 msleep(500);
4591
4592 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4593 "Trying to request EPM LVLSFT_EN\n");
4594 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4595 if (!rc) {
4596 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4597 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4598 "Configure the lvlsft\n");
4599 } else {
4600 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4601 "Error for epm lvlsft_en\n");
4602 goto exit_vreg_epm;
4603 }
4604
4605 msleep(500);
4606
4607 if (!epm_i2c_client)
4608 epm_i2c_client = epm_expander_i2c_register_board();
4609
4610 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4611 if (!rc)
4612 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4613 if (rc) {
4614 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4615 ": GPIO PWR MON Enable issue\n");
4616 goto exit_vreg_epm;
4617 }
4618
4619 msleep(1000);
4620
4621 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4622 if (!rc) {
4623 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4624 if (rc) {
4625 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4626 ": ADC1_PWDN error direction out\n");
4627 goto exit_vreg_epm;
4628 }
4629 }
4630
4631 msleep(100);
4632
4633 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4634 if (!rc) {
4635 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4636 if (rc) {
4637 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4638 ": ADC2_PWD error direction out\n");
4639 goto exit_vreg_epm;
4640 }
4641 }
4642
4643 msleep(1000);
4644
4645 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4646 if (!rc) {
4647 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4648 if (rc) {
4649 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4650 "Gpio request problem %d\n", rc);
4651 goto exit_vreg_epm;
4652 }
4653 }
4654
4655 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4656 if (!rc) {
4657 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4658 if (rc) {
4659 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4660 ": EPM_SPI_ADC1_CS_N error\n");
4661 goto exit_vreg_epm;
4662 }
4663 }
4664
4665 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4666 if (!rc) {
4667 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4668 if (rc) {
4669 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4670 ": EPM_SPI_ADC2_Cs_N error\n");
4671 goto exit_vreg_epm;
4672 }
4673 }
4674
4675 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4676 "the power monitor reset for epm\n");
4677
4678 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4679 if (!rc) {
4680 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4681 if (rc) {
4682 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4683 ": Error in the power mon reset\n");
4684 goto exit_vreg_epm;
4685 }
4686 }
4687
4688 msleep(1000);
4689
4690 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4691
4692 msleep(500);
4693
4694 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4695
4696 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4697
4698 return rc;
4699
4700exit_vreg_epm:
4701 regulator_disable(vreg_adc_epm1);
4702
4703 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4704 " rc = %d.\n", rc);
4705 return rc;
4706};
4707
4708static unsigned int msm_adc_gpio_configure_expander_disable(void)
4709{
4710 int rc = 0;
4711
4712 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4713 gpio_free(GPIO_PWR_MON_RESET_N);
4714
4715 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4716 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4717
4718 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4719 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4720
4721 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4722 gpio_free(GPIO_PWR_MON_START);
4723
4724 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4725 gpio_free(GPIO_ADC1_PWDN_N);
4726
4727 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4728 gpio_free(GPIO_ADC2_PWDN_N);
4729
4730 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4731 gpio_free(GPIO_PWR_MON_ENABLE);
4732
4733 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4734 gpio_free(GPIO_EPM_LVLSFT_EN);
4735
4736 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4737 gpio_free(GPIO_EPM_5V_BOOST_EN);
4738
4739 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4740 gpio_free(GPIO_EPM_3_3V_EN);
4741
4742 rc = regulator_disable(vreg_adc_epm1);
4743 if (rc)
4744 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4745 "Error while enabling regulator for epm s3 %d\n", rc);
4746 regulator_put(vreg_adc_epm1);
4747
4748 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4749 return rc;
4750};
4751
4752unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4753{
4754 int rc = 0;
4755
4756 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4757 cs_enable);
4758
4759 if (cs_enable < 16) {
4760 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4761 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4762 } else {
4763 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4764 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4765 }
4766 return rc;
4767};
4768
4769unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4770{
4771 int rc = 0;
4772
4773 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4774
4775 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4776
4777 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4778
4779 return rc;
4780};
4781#endif
4782
4783static struct msm_adc_channels msm_adc_channels_data[] = {
4784 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4785 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4786 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4787 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4788 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4789 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4790 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4791 CHAN_PATH_TYPE4,
4792 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4793 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4794 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4795 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4796 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4797 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4798 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4799 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4800 CHAN_PATH_TYPE12,
4801 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4802 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4803 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4804 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4805 CHAN_PATH_TYPE_NONE,
4806 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4807 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4808 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4809 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4810 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4811 scale_xtern_chgr_cur},
4812 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4813 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4814 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4815 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4816 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4817 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4818 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4819 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4820 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4822 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4823 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4824};
4825
4826static char *msm_adc_fluid_device_names[] = {
4827 "ADS_ADC1",
4828 "ADS_ADC2",
4829};
4830
4831static struct msm_adc_platform_data msm_adc_pdata = {
4832 .channel = msm_adc_channels_data,
4833 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4834#if defined(CONFIG_I2C) && \
4835 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4836 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4837 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4838 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4839 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4840#endif
4841};
4842
4843static struct platform_device msm_adc_device = {
4844 .name = "msm_adc",
4845 .id = -1,
4846 .dev = {
4847 .platform_data = &msm_adc_pdata,
4848 },
4849};
4850
4851static void pmic8058_xoadc_mpp_config(void)
4852{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304853 int rc, i;
4854 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304855 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304856 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304857 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304858 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304859 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304860 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304861 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304862 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304863 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304864 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304865 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4866 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304867 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004868
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304869 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4870 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4871 &xoadc_mpps[i].config);
4872 if (rc) {
4873 pr_err("%s: Config MPP %d of PM8058 failed\n",
4874 __func__, xoadc_mpps[i].mpp);
4875 }
4876 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004877}
4878
4879static struct regulator *vreg_ldo18_adc;
4880
4881static int pmic8058_xoadc_vreg_config(int on)
4882{
4883 int rc;
4884
4885 if (on) {
4886 rc = regulator_enable(vreg_ldo18_adc);
4887 if (rc)
4888 pr_err("%s: Enable of regulator ldo18_adc "
4889 "failed\n", __func__);
4890 } else {
4891 rc = regulator_disable(vreg_ldo18_adc);
4892 if (rc)
4893 pr_err("%s: Disable of regulator ldo18_adc "
4894 "failed\n", __func__);
4895 }
4896
4897 return rc;
4898}
4899
4900static int pmic8058_xoadc_vreg_setup(void)
4901{
4902 int rc;
4903
4904 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4905 if (IS_ERR(vreg_ldo18_adc)) {
4906 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4907 __func__, PTR_ERR(vreg_ldo18_adc));
4908 rc = PTR_ERR(vreg_ldo18_adc);
4909 goto fail;
4910 }
4911
4912 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4913 if (rc) {
4914 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4915 goto fail;
4916 }
4917
4918 return rc;
4919fail:
4920 regulator_put(vreg_ldo18_adc);
4921 return rc;
4922}
4923
4924static void pmic8058_xoadc_vreg_shutdown(void)
4925{
4926 regulator_put(vreg_ldo18_adc);
4927}
4928
4929/* usec. For this ADC,
4930 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4931 * Each channel has different configuration, thus at the time of starting
4932 * the conversion, xoadc will return actual conversion time
4933 * */
4934static struct adc_properties pm8058_xoadc_data = {
4935 .adc_reference = 2200, /* milli-voltage for this adc */
4936 .bitresolution = 15,
4937 .bipolar = 0,
4938 .conversiontime = 54,
4939};
4940
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304941static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004942 .xoadc_prop = &pm8058_xoadc_data,
4943 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4944 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4945 .xoadc_num = XOADC_PMIC_0,
4946 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4947 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4948};
4949#endif
4950
4951#ifdef CONFIG_MSM_SDIO_AL
4952
4953static unsigned mdm2ap_status = 140;
4954
4955static int configure_mdm2ap_status(int on)
4956{
4957 int ret = 0;
4958 if (on)
4959 ret = msm_gpiomux_get(mdm2ap_status);
4960 else
4961 ret = msm_gpiomux_put(mdm2ap_status);
4962
4963 if (ret)
4964 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4965 on);
4966
4967 return ret;
4968}
4969
4970
4971static int get_mdm2ap_status(void)
4972{
4973 return gpio_get_value(mdm2ap_status);
4974}
4975
4976static struct sdio_al_platform_data sdio_al_pdata = {
4977 .config_mdm2ap_status = configure_mdm2ap_status,
4978 .get_mdm2ap_status = get_mdm2ap_status,
4979 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004980 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004981 .peer_sdioc_version_major = 0x0004,
4982 .peer_sdioc_boot_version_minor = 0x0001,
4983 .peer_sdioc_boot_version_major = 0x0003
4984};
4985
4986struct platform_device msm_device_sdio_al = {
4987 .name = "msm_sdio_al",
4988 .id = -1,
4989 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004990 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004991 .platform_data = &sdio_al_pdata,
4992 },
4993};
4994
4995#endif /* CONFIG_MSM_SDIO_AL */
4996
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304997#define GPIO_VREG_ID_EXT_5V 0
4998
4999static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5000 REGULATOR_SUPPLY("ext_5v", NULL),
5001 REGULATOR_SUPPLY("8901_mpp0", NULL),
5002};
5003
5004#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5005 [GPIO_VREG_ID_##_id] = { \
5006 .init_data = { \
5007 .constraints = { \
5008 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5009 }, \
5010 .num_consumer_supplies = \
5011 ARRAY_SIZE(vreg_consumers_##_id), \
5012 .consumer_supplies = vreg_consumers_##_id, \
5013 }, \
5014 .regulator_name = _reg_name, \
5015 .active_low = _active_low, \
5016 .gpio_label = _gpio_label, \
5017 .gpio = _gpio, \
5018 }
5019
5020/* GPIO regulator constraints */
5021static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5022 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5023 PM8901_MPP_PM_TO_SYS(0), 0),
5024};
5025
5026/* GPIO regulator */
5027static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5028 .name = GPIO_REGULATOR_DEV_NAME,
5029 .id = PM8901_MPP_PM_TO_SYS(0),
5030 .dev = {
5031 .platform_data =
5032 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5033 },
5034};
5035
5036static void __init pm8901_vreg_mpp0_init(void)
5037{
5038 int rc;
5039
5040 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5041 .mpp = PM8901_MPP_PM_TO_SYS(0),
5042 .config = {
5043 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5044 .level = PM8901_MPP_DIG_LEVEL_VPH,
5045 },
5046 };
5047
5048 /*
5049 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5050 * implies that the regulator connected to MPP0 is enabled when
5051 * MPP0 is low.
5052 */
5053 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5054 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5055 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5056 } else {
5057 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5058 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5059 }
5060
5061 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5062 if (rc)
5063 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5064}
5065
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005066static struct platform_device *charm_devices[] __initdata = {
5067 &msm_charm_modem,
5068#ifdef CONFIG_MSM_SDIO_AL
5069 &msm_device_sdio_al,
5070#endif
5071};
5072
Lei Zhou338cab82011-08-19 13:38:17 -04005073#ifdef CONFIG_SND_SOC_MSM8660_APQ
5074static struct platform_device *dragon_alsa_devices[] __initdata = {
5075 &msm_pcm,
5076 &msm_pcm_routing,
5077 &msm_cpudai0,
5078 &msm_cpudai1,
5079 &msm_cpudai_hdmi_rx,
5080 &msm_cpudai_bt_rx,
5081 &msm_cpudai_bt_tx,
5082 &msm_cpudai_fm_rx,
5083 &msm_cpudai_fm_tx,
5084 &msm_cpu_fe,
5085 &msm_stub_codec,
5086 &msm_lpa_pcm,
5087};
5088#endif
5089
5090static struct platform_device *asoc_devices[] __initdata = {
5091 &asoc_msm_pcm,
5092 &asoc_msm_dai0,
5093 &asoc_msm_dai1,
5094};
5095
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005096static struct platform_device *surf_devices[] __initdata = {
5097 &msm_device_smd,
5098 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005099 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005100 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005101 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005102 &msm_pil_dsps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005103#ifdef CONFIG_I2C_QUP
5104 &msm_gsbi3_qup_i2c_device,
5105 &msm_gsbi4_qup_i2c_device,
5106 &msm_gsbi7_qup_i2c_device,
5107 &msm_gsbi8_qup_i2c_device,
5108 &msm_gsbi9_qup_i2c_device,
5109 &msm_gsbi12_qup_i2c_device,
5110#endif
5111#ifdef CONFIG_SERIAL_MSM_HS
5112 &msm_device_uart_dm1,
5113#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305114#ifdef CONFIG_MSM_SSBI
5115 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305116 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305117#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005118#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005119 &msm_device_ssbi3,
5120#endif
5121#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5122 &isp1763_device,
5123#endif
5124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005125#if defined (CONFIG_MSM_8x60_VOIP)
5126 &asoc_msm_mvs,
5127 &asoc_mvs_dai0,
5128 &asoc_mvs_dai1,
5129#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005130
Lena Salman57d167e2012-03-21 19:46:38 +02005131#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005132 &msm_device_otg,
5133#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005134#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005135 &msm_device_gadget_peripheral,
5136#endif
5137#ifdef CONFIG_USB_G_ANDROID
5138 &android_usb_device,
5139#endif
5140#ifdef CONFIG_BATTERY_MSM
5141 &msm_batt_device,
5142#endif
5143#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005144#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005145 &android_pmem_device,
5146 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005147 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005148 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305149#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5150#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151#ifdef CONFIG_MSM_ROTATOR
5152 &msm_rotator_device,
5153#endif
5154 &msm_fb_device,
5155 &msm_kgsl_3d0,
5156 &msm_kgsl_2d0,
5157 &msm_kgsl_2d1,
5158 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005159#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5160 &lcdc_nt35582_panel_device,
5161#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005162#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5163 &lcdc_samsung_oled_panel_device,
5164#endif
5165#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5166 &lcdc_auo_wvga_panel_device,
5167#endif
5168#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5169 &hdmi_msm_device,
5170#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5171#ifdef CONFIG_FB_MSM_MIPI_DSI
5172 &mipi_dsi_toshiba_panel_device,
5173 &mipi_dsi_novatek_panel_device,
5174#endif
5175#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005176#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177#ifdef CONFIG_MT9E013
5178 &msm_camera_sensor_mt9e013,
5179#endif
5180#ifdef CONFIG_IMX074
5181 &msm_camera_sensor_imx074,
5182#endif
5183#ifdef CONFIG_WEBCAM_OV7692
5184 &msm_camera_sensor_webcam_ov7692,
5185#endif
5186#ifdef CONFIG_WEBCAM_OV9726
5187 &msm_camera_sensor_webcam_ov9726,
5188#endif
5189#ifdef CONFIG_QS_S5K4E1
5190 &msm_camera_sensor_qs_s5k4e1,
5191#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005192#ifdef CONFIG_VX6953
5193 &msm_camera_sensor_vx6953,
5194#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005195#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005196#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005197#ifdef CONFIG_MSM_GEMINI
5198 &msm_gemini_device,
5199#endif
5200#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005201#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005202 &msm_vpe_device,
5203#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005204#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005205
5206#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005207 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005208#endif
5209#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005210 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211#endif
5212 &msm_device_vidc,
5213#if (defined(CONFIG_MARIMBA_CORE)) && \
5214 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5215 &msm_bt_power_device,
5216#endif
5217#ifdef CONFIG_SENSORS_MSM_ADC
5218 &msm_adc_device,
5219#endif
David Collins6f032ba2011-08-31 14:08:15 -07005220 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005221
5222#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5223 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5224 &qcrypto_device,
5225#endif
5226
5227#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5228 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5229 &qcedev_device,
5230#endif
5231
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005232
5233#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5234#ifdef CONFIG_MSM_USE_TSIF1
5235 &msm_device_tsif[1],
5236#else
5237 &msm_device_tsif[0],
5238#endif /* CONFIG_MSM_USE_TSIF1 */
5239#endif /* CONFIG_TSIF */
5240
5241#ifdef CONFIG_HW_RANDOM_MSM
5242 &msm_device_rng,
5243#endif
5244
5245 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005246 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005247#ifdef CONFIG_ION_MSM
5248 &ion_dev,
5249#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005250 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005251 &msm_device_tz_log,
5252
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253};
5254
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005255#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005256#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5257static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5258 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan42ebe712012-01-10 16:30:58 -08005259 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005260 .request_region = request_smi_region,
5261 .release_region = release_smi_region,
5262 .setup_region = setup_smi_region,
5263};
5264
5265static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5266 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005267 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005268 .request_region = request_smi_region,
5269 .release_region = release_smi_region,
5270 .setup_region = setup_smi_region,
5271};
5272
5273static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5274 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005275 .align = PAGE_SIZE,
5276};
5277
5278static struct ion_co_heap_pdata fw_co_ion_pdata = {
5279 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5280 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005281};
5282
5283static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005284 .adjacent_mem_id = INVALID_HEAP_ID,
5285 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005286};
5287#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005288
5289/**
5290 * These heaps are listed in the order they will be allocated. Due to
5291 * video hardware restrictions and content protection the FW heap has to
5292 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5293 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5294 * away from the base address of the FW heap.
5295 * However, the order of FW heap and MM heap doesn't matter since these
5296 * two heaps are taken care of by separate code to ensure they are adjacent
5297 * to each other.
5298 * Don't swap the order unless you know what you are doing!
5299 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005300static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005301 .nr = MSM_ION_HEAP_NUM,
5302 .heaps = {
5303 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005304 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005305 .type = ION_HEAP_TYPE_SYSTEM,
5306 .name = ION_VMALLOC_HEAP_NAME,
5307 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005308#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5309 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005310 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005311 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005312 .name = ION_MM_HEAP_NAME,
5313 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005314 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005315 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005316 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005317 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005318 .id = ION_MM_FIRMWARE_HEAP_ID,
5319 .type = ION_HEAP_TYPE_CARVEOUT,
5320 .name = ION_MM_FIRMWARE_HEAP_NAME,
5321 .size = MSM_ION_MM_FW_SIZE,
5322 .memory_type = ION_SMI_TYPE,
5323 .extra_data = (void *) &fw_co_ion_pdata,
5324 },
5325 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005326 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005327 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005328 .name = ION_MFC_HEAP_NAME,
5329 .size = MSM_ION_MFC_SIZE,
5330 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005331 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005332 },
5333 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005334 .id = ION_SF_HEAP_ID,
5335 .type = ION_HEAP_TYPE_CARVEOUT,
5336 .name = ION_SF_HEAP_NAME,
5337 .size = MSM_ION_SF_SIZE,
5338 .memory_type = ION_EBI_TYPE,
5339 .extra_data = (void *)&co_ion_pdata,
5340 },
5341 {
5342 .id = ION_CAMERA_HEAP_ID,
5343 .type = ION_HEAP_TYPE_CARVEOUT,
5344 .name = ION_CAMERA_HEAP_NAME,
5345 .size = MSM_ION_CAMERA_SIZE,
5346 .memory_type = ION_EBI_TYPE,
5347 .extra_data = &co_ion_pdata,
5348 },
5349 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005350 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005351 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005352 .name = ION_WB_HEAP_NAME,
5353 .size = MSM_ION_WB_SIZE,
5354 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005355 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005356 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005357 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005358 .id = ION_QSECOM_HEAP_ID,
5359 .type = ION_HEAP_TYPE_CARVEOUT,
5360 .name = ION_QSECOM_HEAP_NAME,
5361 .size = MSM_ION_QSECOM_SIZE,
5362 .memory_type = ION_EBI_TYPE,
5363 .extra_data = (void *) &co_ion_pdata,
5364 },
5365 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005366 .id = ION_AUDIO_HEAP_ID,
5367 .type = ION_HEAP_TYPE_CARVEOUT,
5368 .name = ION_AUDIO_HEAP_NAME,
5369 .size = MSM_ION_AUDIO_SIZE,
5370 .memory_type = ION_EBI_TYPE,
5371 .extra_data = (void *)&co_ion_pdata,
5372 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005373#endif
5374 }
5375};
5376
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005377static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005378 .name = "ion-msm",
5379 .id = 1,
5380 .dev = { .platform_data = &ion_pdata },
5381};
5382#endif
5383
5384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005385static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5386 /* Kernel SMI memory pool for video core, used for firmware */
5387 /* and encoder, decoder scratch buffers */
5388 /* Kernel SMI memory pool should always precede the user space */
5389 /* SMI memory pool, as the video core will use offset address */
5390 /* from the Firmware base */
5391 [MEMTYPE_SMI_KERNEL] = {
5392 .start = KERNEL_SMI_BASE,
5393 .limit = KERNEL_SMI_SIZE,
5394 .size = KERNEL_SMI_SIZE,
5395 .flags = MEMTYPE_FLAGS_FIXED,
5396 },
5397 /* User space SMI memory pool for video core */
5398 /* used for encoder, decoder input & output buffers */
5399 [MEMTYPE_SMI] = {
5400 .start = USER_SMI_BASE,
5401 .limit = USER_SMI_SIZE,
5402 .flags = MEMTYPE_FLAGS_FIXED,
5403 },
5404 [MEMTYPE_EBI0] = {
5405 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5406 },
5407 [MEMTYPE_EBI1] = {
5408 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5409 },
5410};
5411
Stephen Boyd668d7652012-04-25 11:31:01 -07005412static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005413{
5414#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005415 unsigned int i;
5416
5417 if (hdmi_is_primary) {
5418 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5419 for (i = 0; i < ion_pdata.nr; i++) {
5420 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5421 ion_pdata.heaps[i].size = msm_ion_sf_size;
5422 pr_debug("msm_ion_sf_size 0x%x\n",
5423 msm_ion_sf_size);
5424 break;
5425 }
5426 }
5427 }
5428
5429 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Haugan42ebe712012-01-10 16:30:58 -08005430 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005431 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5432 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5433 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5434 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005435 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005436 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005437#endif
5438}
5439
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005440static void __init size_pmem_devices(void)
5441{
5442#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005443#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005444 android_pmem_adsp_pdata.size = pmem_adsp_size;
5445 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005446
5447 if (hdmi_is_primary)
5448 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005449 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005450 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305451#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5452#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005453}
5454
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305455#ifdef CONFIG_ANDROID_PMEM
5456#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005457static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5458{
5459 msm8x60_reserve_table[p->memory_type].size += p->size;
5460}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305461#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5462#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005463
5464static void __init reserve_pmem_memory(void)
5465{
5466#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005467#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005468 reserve_memory_for(&android_pmem_adsp_pdata);
5469 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005470 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005471 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305472#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005473 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305474#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005475}
5476
Huaibin Yanga5419422011-12-08 23:52:10 -08005477static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005478
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005479static void __init msm8x60_calculate_reserve_sizes(void)
5480{
5481 size_pmem_devices();
5482 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005483 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005484 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005485}
5486
5487static int msm8x60_paddr_to_memtype(unsigned int paddr)
5488{
5489 if (paddr >= 0x40000000 && paddr < 0x60000000)
5490 return MEMTYPE_EBI1;
5491 if (paddr >= 0x38000000 && paddr < 0x40000000)
5492 return MEMTYPE_SMI;
5493 return MEMTYPE_NONE;
5494}
5495
5496static struct reserve_info msm8x60_reserve_info __initdata = {
5497 .memtype_reserve_table = msm8x60_reserve_table,
5498 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5499 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5500};
5501
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005502static char prim_panel_name[PANEL_NAME_MAX_LEN];
5503static char ext_panel_name[PANEL_NAME_MAX_LEN];
5504static int __init prim_display_setup(char *param)
5505{
5506 if (strnlen(param, PANEL_NAME_MAX_LEN))
5507 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5508 return 0;
5509}
5510early_param("prim_display", prim_display_setup);
5511
5512static int __init ext_display_setup(char *param)
5513{
5514 if (strnlen(param, PANEL_NAME_MAX_LEN))
5515 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5516 return 0;
5517}
5518early_param("ext_display", ext_display_setup);
5519
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005520static void __init msm8x60_reserve(void)
5521{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005522 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523 reserve_info = &msm8x60_reserve_info;
5524 msm_reserve();
5525}
5526
5527#define EXT_CHG_VALID_MPP 10
5528#define EXT_CHG_VALID_MPP_2 11
5529
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305530static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305531 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305532 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305533 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305534 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5535};
5536
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005537#ifdef CONFIG_ISL9519_CHARGER
5538static int isl_detection_setup(void)
5539{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305540 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005541
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305542 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5543 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5544 &isl_mpp[i].config);
5545 if (ret) {
5546 pr_err("%s: Config MPP %d of PM8058 failed\n",
5547 __func__, isl_mpp[i].mpp);
5548 return ret;
5549 }
5550 }
5551
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005552 return ret;
5553}
5554
5555static struct isl_platform_data isl_data __initdata = {
5556 .chgcurrent = 700,
5557 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5558 .chg_detection_config = isl_detection_setup,
5559 .max_system_voltage = 4200,
5560 .min_system_voltage = 3200,
5561 .term_current = 120,
5562 .input_current = 2048,
5563};
5564
5565static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5566 {
5567 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305568 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005569 .platform_data = &isl_data,
5570 },
5571};
5572#endif
5573
5574#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5575static int smb137b_detection_setup(void)
5576{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305577 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005578
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305579 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5580 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5581 &isl_mpp[i].config);
5582 if (ret) {
5583 pr_err("%s: Config MPP %d of PM8058 failed\n",
5584 __func__, isl_mpp[i].mpp);
5585 return ret;
5586 }
5587 }
5588
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005589 return ret;
5590}
5591
5592static struct smb137b_platform_data smb137b_data __initdata = {
5593 .chg_detection_config = smb137b_detection_setup,
5594 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5595 .batt_mah_rating = 950,
5596};
5597
5598static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5599 {
5600 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305601 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602 .platform_data = &smb137b_data,
5603 },
5604};
5605#endif
5606
5607#ifdef CONFIG_PMIC8058
5608#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305609#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005610
5611static int pm8058_gpios_init(void)
5612{
5613 int i;
5614 int rc;
5615 struct pm8058_gpio_cfg {
5616 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305617 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005618 };
5619
5620 struct pm8058_gpio_cfg gpio_cfgs[] = {
5621 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305622 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005623 {
5624 .direction = PM_GPIO_DIR_IN,
5625 .pull = PM_GPIO_PULL_DN,
5626 .vin_sel = 2,
5627 .function = PM_GPIO_FUNC_NORMAL,
5628 .inv_int_pol = 0,
5629 },
5630 },
5631#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5632 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305633 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005634 {
5635 .direction = PM_GPIO_DIR_IN,
5636 .pull = PM_GPIO_PULL_UP_30,
5637 .vin_sel = 2,
5638 .function = PM_GPIO_FUNC_NORMAL,
5639 .inv_int_pol = 0,
5640 },
5641 },
5642#endif
5643 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305644 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645 {
5646 .direction = PM_GPIO_DIR_IN,
5647 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305648 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005649 .function = PM_GPIO_FUNC_NORMAL,
5650 .inv_int_pol = 0,
5651 },
5652 },
5653 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305654 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005655 {
5656 .direction = PM_GPIO_DIR_IN,
5657 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305658 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005659 .function = PM_GPIO_FUNC_NORMAL,
5660 .inv_int_pol = 0,
5661 },
5662 },
5663 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305664 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005665 {
5666 .direction = PM_GPIO_DIR_IN,
5667 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305668 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005669 .function = PM_GPIO_FUNC_NORMAL,
5670 .inv_int_pol = 0,
5671 },
5672 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005673 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305674 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005675 {
5676 .direction = PM_GPIO_DIR_OUT,
5677 .output_value = 1,
5678 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5679 .pull = PM_GPIO_PULL_DN,
5680 .out_strength = PM_GPIO_STRENGTH_HIGH,
5681 .function = PM_GPIO_FUNC_NORMAL,
5682 .vin_sel = 2,
5683 .inv_int_pol = 0,
5684 }
5685 },
5686 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305687 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005688 {
5689 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305690 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005691 .function = PM_GPIO_FUNC_NORMAL,
5692 .vin_sel = 2,
5693 .inv_int_pol = 0,
5694 }
5695 },
5696 };
5697
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305698#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5699 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305700 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305701 .direction = PM_GPIO_DIR_IN,
5702 .pull = PM_GPIO_PULL_UP_1P5,
5703 .vin_sel = 2,
5704 .function = PM_GPIO_FUNC_NORMAL,
5705 };
5706#endif
5707
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005708#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305709 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305710 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305711 .direction = PM_GPIO_DIR_OUT,
5712 .pull = PM_GPIO_PULL_NO,
5713 .out_strength = PM_GPIO_STRENGTH_HIGH,
5714 .function = PM_GPIO_FUNC_NORMAL,
5715 .inv_int_pol = 0,
5716 .vin_sel = 2,
5717 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5718 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 };
5720#endif
5721
5722#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5723 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305724 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725 {
5726 .direction = PM_GPIO_DIR_IN,
5727 .pull = PM_GPIO_PULL_UP_1P5,
5728 .vin_sel = 2,
5729 .function = PM_GPIO_FUNC_NORMAL,
5730 .inv_int_pol = 0,
5731 }
5732 };
5733#endif
5734
5735#if defined(CONFIG_QS_S5K4E1)
5736 {
5737 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305738 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005739 {
5740 .direction = PM_GPIO_DIR_OUT,
5741 .output_value = 0,
5742 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5743 .pull = PM_GPIO_PULL_DN,
5744 .out_strength = PM_GPIO_STRENGTH_HIGH,
5745 .function = PM_GPIO_FUNC_NORMAL,
5746 .vin_sel = 2,
5747 .inv_int_pol = 0,
5748 }
5749 };
5750#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005751#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5752 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305753 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005754 {
5755 .direction = PM_GPIO_DIR_OUT,
5756 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5757 .output_value = 1,
5758 .pull = PM_GPIO_PULL_UP_30,
5759 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305760 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005761 .out_strength = PM_GPIO_STRENGTH_HIGH,
5762 .function = PM_GPIO_FUNC_NORMAL,
5763 .inv_int_pol = 0,
5764 }
5765 };
5766#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005767#if defined(CONFIG_HAPTIC_ISA1200) || \
5768 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5769 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305770 rc = pm8xxx_gpio_config(
5771 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5772 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005773 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305774 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005775 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305776 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305777 rc = pm8xxx_gpio_config(
5778 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5779 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305780 if (rc < 0) {
5781 pr_err("%s: pmic haptics ldo gpio config failed\n",
5782 __func__);
5783 }
5784
5785 }
5786#endif
5787
5788#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5789 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5790 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5791 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305792 rc = pm8xxx_gpio_config(
5793 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5794 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305795 if (rc < 0) {
5796 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5797 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 }
5799 }
5800#endif
5801
5802#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5803 /* Line_in only for 8660 ffa & surf */
5804 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005805 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005806 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305807 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005808 &line_in_gpio_cfg.cfg);
5809 if (rc < 0) {
5810 pr_err("%s pmic line_in gpio config failed\n",
5811 __func__);
5812 return rc;
5813 }
5814 }
5815#endif
5816
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005817#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5818 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305819 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005820 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5821 if (rc < 0) {
5822 pr_err("%s pmic gpio config failed\n", __func__);
5823 return rc;
5824 }
5825 }
5826#endif
5827
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005828#if defined(CONFIG_QS_S5K4E1)
5829 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5830 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305831 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005832 &qs_hc37_cam_pd_gpio_cfg.cfg);
5833 if (rc < 0) {
5834 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5835 __func__);
5836 return rc;
5837 }
5838 }
5839 }
5840#endif
5841
5842 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305843 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005844 &gpio_cfgs[i].cfg);
5845 if (rc < 0) {
5846 pr_err("%s pmic gpio config failed\n",
5847 __func__);
5848 return rc;
5849 }
5850 }
5851
5852 return 0;
5853}
5854
5855static const unsigned int ffa_keymap[] = {
5856 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5857 KEY(0, 1, KEY_UP), /* NAV - UP */
5858 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5859 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5860
5861 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5862 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5863 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5864 KEY(1, 3, KEY_VOLUMEDOWN),
5865
5866 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5867
5868 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5869 KEY(4, 1, KEY_UP), /* USER_UP */
5870 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5871 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5872 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5873
5874 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5875 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5876 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5877 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5878 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5879};
5880
Zhang Chang Ken683be172011-08-10 17:45:34 -04005881static const unsigned int dragon_keymap[] = {
5882 KEY(0, 0, KEY_MENU),
5883 KEY(0, 2, KEY_1),
5884 KEY(0, 3, KEY_4),
5885 KEY(0, 4, KEY_7),
5886
5887 KEY(1, 0, KEY_UP),
5888 KEY(1, 1, KEY_LEFT),
5889 KEY(1, 2, KEY_DOWN),
5890 KEY(1, 3, KEY_5),
5891 KEY(1, 4, KEY_8),
5892
5893 KEY(2, 0, KEY_HOME),
5894 KEY(2, 1, KEY_REPLY),
5895 KEY(2, 2, KEY_2),
5896 KEY(2, 3, KEY_6),
5897 KEY(2, 4, KEY_0),
5898
5899 KEY(3, 0, KEY_VOLUMEUP),
5900 KEY(3, 1, KEY_RIGHT),
5901 KEY(3, 2, KEY_3),
5902 KEY(3, 3, KEY_9),
5903 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5904
5905 KEY(4, 0, KEY_VOLUMEDOWN),
5906 KEY(4, 1, KEY_BACK),
5907 KEY(4, 2, KEY_CAMERA),
5908 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5909};
5910
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005911static struct matrix_keymap_data ffa_keymap_data = {
5912 .keymap_size = ARRAY_SIZE(ffa_keymap),
5913 .keymap = ffa_keymap,
5914};
5915
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305916static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005917 .input_name = "ffa-keypad",
5918 .input_phys_device = "ffa-keypad/input0",
5919 .num_rows = 6,
5920 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305921 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5922 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5923 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005924 .scan_delay_ms = 32,
5925 .row_hold_ns = 91500,
5926 .wakeup = 1,
5927 .keymap_data = &ffa_keymap_data,
5928};
5929
Zhang Chang Ken683be172011-08-10 17:45:34 -04005930static struct matrix_keymap_data dragon_keymap_data = {
5931 .keymap_size = ARRAY_SIZE(dragon_keymap),
5932 .keymap = dragon_keymap,
5933};
5934
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305935static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005936 .input_name = "dragon-keypad",
5937 .input_phys_device = "dragon-keypad/input0",
5938 .num_rows = 6,
5939 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305940 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5941 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5942 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005943 .scan_delay_ms = 32,
5944 .row_hold_ns = 91500,
5945 .wakeup = 1,
5946 .keymap_data = &dragon_keymap_data,
5947};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305948
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005949static const unsigned int fluid_keymap[] = {
5950 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5951 KEY(0, 1, KEY_UP), /* NAV - UP */
5952 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5953 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5954
5955 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5956 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5957 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5958 KEY(1, 3, KEY_VOLUMEUP),
5959
5960 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5961
5962 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5963 KEY(4, 1, KEY_UP), /* USER_UP */
5964 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5965 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5966 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5967
Jilai Wang9a895102011-07-12 14:00:35 -04005968 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005969 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5970 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5971 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5972 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5973};
5974
5975static struct matrix_keymap_data fluid_keymap_data = {
5976 .keymap_size = ARRAY_SIZE(fluid_keymap),
5977 .keymap = fluid_keymap,
5978};
5979
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305980static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005981 .input_name = "fluid-keypad",
5982 .input_phys_device = "fluid-keypad/input0",
5983 .num_rows = 6,
5984 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305985 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5986 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5987 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005988 .scan_delay_ms = 32,
5989 .row_hold_ns = 91500,
5990 .wakeup = 1,
5991 .keymap_data = &fluid_keymap_data,
5992};
5993
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305994static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005995 .initial_vibrate_ms = 500,
5996 .level_mV = 3000,
5997 .max_timeout_ms = 15000,
5998};
5999
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306000static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6001 .rtc_write_enable = false,
6002 .rtc_alarm_powerup = false,
6003};
6004
6005static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6006 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006007 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306008 .wakeup = 1,
6009};
6010
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006011#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6012
6013static struct othc_accessory_info othc_accessories[] = {
6014 {
6015 .accessory = OTHC_SVIDEO_OUT,
6016 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6017 | OTHC_ADC_DETECT,
6018 .key_code = SW_VIDEOOUT_INSERT,
6019 .enabled = false,
6020 .adc_thres = {
6021 .min_threshold = 20,
6022 .max_threshold = 40,
6023 },
6024 },
6025 {
6026 .accessory = OTHC_ANC_HEADPHONE,
6027 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6028 OTHC_SWITCH_DETECT,
6029 .gpio = PM8058_LINE_IN_DET_GPIO,
6030 .active_low = 1,
6031 .key_code = SW_HEADPHONE_INSERT,
6032 .enabled = true,
6033 },
6034 {
6035 .accessory = OTHC_ANC_HEADSET,
6036 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6037 .gpio = PM8058_LINE_IN_DET_GPIO,
6038 .active_low = 1,
6039 .key_code = SW_HEADPHONE_INSERT,
6040 .enabled = true,
6041 },
6042 {
6043 .accessory = OTHC_HEADPHONE,
6044 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6045 .key_code = SW_HEADPHONE_INSERT,
6046 .enabled = true,
6047 },
6048 {
6049 .accessory = OTHC_MICROPHONE,
6050 .detect_flags = OTHC_GPIO_DETECT,
6051 .gpio = PM8058_LINE_IN_DET_GPIO,
6052 .active_low = 1,
6053 .key_code = SW_MICROPHONE_INSERT,
6054 .enabled = true,
6055 },
6056 {
6057 .accessory = OTHC_HEADSET,
6058 .detect_flags = OTHC_MICBIAS_DETECT,
6059 .key_code = SW_HEADPHONE_INSERT,
6060 .enabled = true,
6061 },
6062};
6063
6064static struct othc_switch_info switch_info[] = {
6065 {
6066 .min_adc_threshold = 0,
6067 .max_adc_threshold = 100,
6068 .key_code = KEY_PLAYPAUSE,
6069 },
6070 {
6071 .min_adc_threshold = 100,
6072 .max_adc_threshold = 200,
6073 .key_code = KEY_REWIND,
6074 },
6075 {
6076 .min_adc_threshold = 200,
6077 .max_adc_threshold = 500,
6078 .key_code = KEY_FASTFORWARD,
6079 },
6080};
6081
6082static struct othc_n_switch_config switch_config = {
6083 .voltage_settling_time_ms = 0,
6084 .num_adc_samples = 3,
6085 .adc_channel = CHANNEL_ADC_HDSET,
6086 .switch_info = switch_info,
6087 .num_keys = ARRAY_SIZE(switch_info),
6088 .default_sw_en = true,
6089 .default_sw_idx = 0,
6090};
6091
6092static struct hsed_bias_config hsed_bias_config = {
6093 /* HSED mic bias config info */
6094 .othc_headset = OTHC_HEADSET_NO,
6095 .othc_lowcurr_thresh_uA = 100,
6096 .othc_highcurr_thresh_uA = 600,
6097 .othc_hyst_prediv_us = 7800,
6098 .othc_period_clkdiv_us = 62500,
6099 .othc_hyst_clk_us = 121000,
6100 .othc_period_clk_us = 312500,
6101 .othc_wakeup = 1,
6102};
6103
6104static struct othc_hsed_config hsed_config_1 = {
6105 .hsed_bias_config = &hsed_bias_config,
6106 /*
6107 * The detection delay and switch reporting delay are
6108 * required to encounter a hardware bug (spurious switch
6109 * interrupts on slow insertion/removal of the headset).
6110 * This will introduce a delay in reporting the accessory
6111 * insertion and removal to the userspace.
6112 */
6113 .detection_delay_ms = 1500,
6114 /* Switch info */
6115 .switch_debounce_ms = 1500,
6116 .othc_support_n_switch = false,
6117 .switch_config = &switch_config,
6118 .ir_gpio = -1,
6119 /* Accessory info */
6120 .accessories_support = true,
6121 .accessories = othc_accessories,
6122 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6123};
6124
6125static struct othc_regulator_config othc_reg = {
6126 .regulator = "8058_l5",
6127 .max_uV = 2850000,
6128 .min_uV = 2850000,
6129};
6130
6131/* MIC_BIAS0 is configured as normal MIC BIAS */
6132static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6133 .micbias_select = OTHC_MICBIAS_0,
6134 .micbias_capability = OTHC_MICBIAS,
6135 .micbias_enable = OTHC_SIGNAL_OFF,
6136 .micbias_regulator = &othc_reg,
6137};
6138
6139/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6140static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6141 .micbias_select = OTHC_MICBIAS_1,
6142 .micbias_capability = OTHC_MICBIAS_HSED,
6143 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6144 .micbias_regulator = &othc_reg,
6145 .hsed_config = &hsed_config_1,
6146 .hsed_name = "8660_handset",
6147};
6148
6149/* MIC_BIAS2 is configured as normal MIC BIAS */
6150static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6151 .micbias_select = OTHC_MICBIAS_2,
6152 .micbias_capability = OTHC_MICBIAS,
6153 .micbias_enable = OTHC_SIGNAL_OFF,
6154 .micbias_regulator = &othc_reg,
6155};
6156
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006157
6158static void __init msm8x60_init_pm8058_othc(void)
6159{
6160 int i;
6161
6162 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6163 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6164 machine_is_msm8x60_fusn_ffa()) {
6165 /* 3-switch headset supported only by V2 FFA and FLUID */
6166 hsed_config_1.accessories_adc_support = true,
6167 /* ADC based accessory detection works only on V2 and FLUID */
6168 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6169 hsed_config_1.othc_support_n_switch = true;
6170 }
6171
6172 /* IR GPIO is absent on FLUID */
6173 if (machine_is_msm8x60_fluid())
6174 hsed_config_1.ir_gpio = -1;
6175
6176 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6177 if (machine_is_msm8x60_fluid()) {
6178 switch (othc_accessories[i].accessory) {
6179 case OTHC_ANC_HEADPHONE:
6180 case OTHC_ANC_HEADSET:
6181 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6182 break;
6183 case OTHC_MICROPHONE:
6184 othc_accessories[i].enabled = false;
6185 break;
6186 case OTHC_SVIDEO_OUT:
6187 othc_accessories[i].enabled = true;
6188 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6189 break;
6190 }
6191 }
6192 }
6193}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006194
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006195
6196static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6197{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306198 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006199 .direction = PM_GPIO_DIR_OUT,
6200 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6201 .output_value = 0,
6202 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306203 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006204 .out_strength = PM_GPIO_STRENGTH_HIGH,
6205 .function = PM_GPIO_FUNC_2,
6206 };
6207
6208 int rc = -EINVAL;
6209 int id, mode, max_mA;
6210
6211 id = mode = max_mA = 0;
6212 switch (ch) {
6213 case 0:
6214 case 1:
6215 case 2:
6216 if (on) {
6217 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306218 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6219 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006220 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306221 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006222 __func__, id, rc);
6223 }
6224 break;
6225
6226 case 6:
6227 id = PM_PWM_LED_FLASH;
6228 mode = PM_PWM_CONF_PWM1;
6229 max_mA = 300;
6230 break;
6231
6232 case 7:
6233 id = PM_PWM_LED_FLASH1;
6234 mode = PM_PWM_CONF_PWM1;
6235 max_mA = 300;
6236 break;
6237
6238 default:
6239 break;
6240 }
6241
6242 if (ch >= 6 && ch <= 7) {
6243 if (!on) {
6244 mode = PM_PWM_CONF_NONE;
6245 max_mA = 0;
6246 }
6247 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6248 if (rc)
6249 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6250 __func__, ch, rc);
6251 }
6252 return rc;
6253
6254}
6255
6256static struct pm8058_pwm_pdata pm8058_pwm_data = {
6257 .config = pm8058_pwm_config,
6258};
6259
6260#define PM8058_GPIO_INT 88
6261
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006262static struct pmic8058_led pmic8058_flash_leds[] = {
6263 [0] = {
6264 .name = "camera:flash0",
6265 .max_brightness = 15,
6266 .id = PMIC8058_ID_FLASH_LED_0,
6267 },
6268 [1] = {
6269 .name = "camera:flash1",
6270 .max_brightness = 15,
6271 .id = PMIC8058_ID_FLASH_LED_1,
6272 },
6273};
6274
6275static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6276 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6277 .leds = pmic8058_flash_leds,
6278};
6279
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006280static struct pmic8058_led pmic8058_dragon_leds[] = {
6281 [0] = {
6282 /* RED */
6283 .name = "led_drv0",
6284 .max_brightness = 15,
6285 .id = PMIC8058_ID_LED_0,
6286 },/* 300 mA flash led0 drv sink */
6287 [1] = {
6288 /* Yellow */
6289 .name = "led_drv1",
6290 .max_brightness = 15,
6291 .id = PMIC8058_ID_LED_1,
6292 },/* 300 mA flash led0 drv sink */
6293 [2] = {
6294 /* Green */
6295 .name = "led_drv2",
6296 .max_brightness = 15,
6297 .id = PMIC8058_ID_LED_2,
6298 },/* 300 mA flash led0 drv sink */
6299 [3] = {
6300 .name = "led_psensor",
6301 .max_brightness = 15,
6302 .id = PMIC8058_ID_LED_KB_LIGHT,
6303 },/* 300 mA flash led0 drv sink */
6304};
6305
6306static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6307 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6308 .leds = pmic8058_dragon_leds,
6309};
6310
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006311static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6312 [0] = {
6313 .name = "led:drv0",
6314 .max_brightness = 15,
6315 .id = PMIC8058_ID_FLASH_LED_0,
6316 },/* 300 mA flash led0 drv sink */
6317 [1] = {
6318 .name = "led:drv1",
6319 .max_brightness = 15,
6320 .id = PMIC8058_ID_FLASH_LED_1,
6321 },/* 300 mA flash led1 sink */
6322 [2] = {
6323 .name = "led:drv2",
6324 .max_brightness = 20,
6325 .id = PMIC8058_ID_LED_0,
6326 },/* 40 mA led0 sink */
6327 [3] = {
6328 .name = "keypad:drv",
6329 .max_brightness = 15,
6330 .id = PMIC8058_ID_LED_KB_LIGHT,
6331 },/* 300 mA keypad drv sink */
6332};
6333
6334static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6335 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6336 .leds = pmic8058_fluid_flash_leds,
6337};
6338
Terence Hampson90508a92011-08-09 10:40:08 -04006339static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306340 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006341 .max_source_current = 1800,
6342 .charger_type = CHG_TYPE_AC,
6343};
6344
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306345static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6346 .charger_data_valid = false,
6347};
6348
6349static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6350 .priority = 0,
6351};
6352
6353static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6354 .irq_base = PM8058_IRQ_BASE,
6355 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6356 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6357};
6358
6359static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6360 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6361};
6362
6363static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6364 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006365};
6366
6367static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306368 .irq_pdata = &pm8058_irq_pdata,
6369 .gpio_pdata = &pm8058_gpio_pdata,
6370 .mpp_pdata = &pm8058_mpp_pdata,
6371 .rtc_pdata = &pm8058_rtc_pdata,
6372 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6373 .othc0_pdata = &othc_config_pdata_0,
6374 .othc1_pdata = &othc_config_pdata_1,
6375 .othc2_pdata = &othc_config_pdata_2,
6376 .pwm_pdata = &pm8058_pwm_data,
6377 .misc_pdata = &pm8058_misc_pdata,
6378#ifdef CONFIG_SENSORS_MSM_ADC
6379 .xoadc_pdata = &pm8058_xoadc_pdata,
6380#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006381};
6382
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306383#ifdef CONFIG_MSM_SSBI
6384static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6385 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6386 .slave = {
6387 .name = "pm8058-core",
6388 .platform_data = &pm8058_platform_data,
6389 },
6390};
6391#endif
6392#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006393
6394#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6395 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6396#define TDISC_I2C_SLAVE_ADDR 0x67
6397#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6398#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6399
6400static const char *vregs_tdisc_name[] = {
6401 "8058_l5",
6402 "8058_s3",
6403};
6404
6405static const int vregs_tdisc_val[] = {
6406 2850000,/* uV */
6407 1800000,
6408};
6409static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6410
6411static int tdisc_shinetsu_setup(void)
6412{
6413 int rc, i;
6414
6415 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6416 if (rc) {
6417 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6418 __func__);
6419 return rc;
6420 }
6421
6422 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6423 if (rc) {
6424 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6425 __func__);
6426 goto fail_gpio_oe;
6427 }
6428
6429 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6430 if (rc) {
6431 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6432 __func__);
6433 gpio_free(GPIO_JOYSTICK_EN);
6434 goto fail_gpio_oe;
6435 }
6436
6437 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6438 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6439 if (IS_ERR(vregs_tdisc[i])) {
6440 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6441 __func__, vregs_tdisc_name[i],
6442 PTR_ERR(vregs_tdisc[i]));
6443 rc = PTR_ERR(vregs_tdisc[i]);
6444 goto vreg_get_fail;
6445 }
6446
6447 rc = regulator_set_voltage(vregs_tdisc[i],
6448 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6449 if (rc) {
6450 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6451 __func__, rc);
6452 goto vreg_set_voltage_fail;
6453 }
6454 }
6455
6456 return rc;
6457vreg_set_voltage_fail:
6458 i++;
6459vreg_get_fail:
6460 while (i)
6461 regulator_put(vregs_tdisc[--i]);
6462fail_gpio_oe:
6463 gpio_free(PMIC_GPIO_TDISC);
6464 return rc;
6465}
6466
6467static void tdisc_shinetsu_release(void)
6468{
6469 int i;
6470
6471 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6472 regulator_put(vregs_tdisc[i]);
6473
6474 gpio_free(PMIC_GPIO_TDISC);
6475 gpio_free(GPIO_JOYSTICK_EN);
6476}
6477
6478static int tdisc_shinetsu_enable(void)
6479{
6480 int i, rc = -EINVAL;
6481
6482 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6483 rc = regulator_enable(vregs_tdisc[i]);
6484 if (rc < 0) {
6485 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6486 __func__, vregs_tdisc_name[i], rc);
6487 goto vreg_fail;
6488 }
6489 }
6490
6491 /* Enable the OE (output enable) gpio */
6492 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6493 /* voltage and gpio stabilization delay */
6494 msleep(50);
6495
6496 return 0;
6497vreg_fail:
6498 while (i)
6499 regulator_disable(vregs_tdisc[--i]);
6500 return rc;
6501}
6502
6503static int tdisc_shinetsu_disable(void)
6504{
6505 int i, rc;
6506
6507 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6508 rc = regulator_disable(vregs_tdisc[i]);
6509 if (rc < 0) {
6510 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6511 __func__, vregs_tdisc_name[i], rc);
6512 goto tdisc_reg_fail;
6513 }
6514 }
6515
6516 /* Disable the OE (output enable) gpio */
6517 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6518
6519 return 0;
6520
6521tdisc_reg_fail:
6522 while (i)
6523 regulator_enable(vregs_tdisc[--i]);
6524 return rc;
6525}
6526
6527static struct tdisc_abs_values tdisc_abs = {
6528 .x_max = 32,
6529 .y_max = 32,
6530 .x_min = -32,
6531 .y_min = -32,
6532 .pressure_max = 32,
6533 .pressure_min = 0,
6534};
6535
6536static struct tdisc_platform_data tdisc_data = {
6537 .tdisc_setup = tdisc_shinetsu_setup,
6538 .tdisc_release = tdisc_shinetsu_release,
6539 .tdisc_enable = tdisc_shinetsu_enable,
6540 .tdisc_disable = tdisc_shinetsu_disable,
6541 .tdisc_wakeup = 0,
6542 .tdisc_gpio = PMIC_GPIO_TDISC,
6543 .tdisc_report_keys = true,
6544 .tdisc_report_relative = true,
6545 .tdisc_report_absolute = false,
6546 .tdisc_report_wheel = false,
6547 .tdisc_reverse_x = false,
6548 .tdisc_reverse_y = true,
6549 .tdisc_abs = &tdisc_abs,
6550};
6551
6552static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6553 {
6554 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6555 .irq = TDISC_INT,
6556 .platform_data = &tdisc_data,
6557 },
6558};
6559#endif
6560
6561#define PM_GPIO_CDC_RST_N 20
6562#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6563
6564static struct regulator *vreg_timpani_1;
6565static struct regulator *vreg_timpani_2;
6566
6567static unsigned int msm_timpani_setup_power(void)
6568{
6569 int rc;
6570
6571 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6572 if (IS_ERR(vreg_timpani_1)) {
6573 pr_err("%s: Unable to get 8058_l0\n", __func__);
6574 return -ENODEV;
6575 }
6576
6577 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6578 if (IS_ERR(vreg_timpani_2)) {
6579 pr_err("%s: Unable to get 8058_s3\n", __func__);
6580 regulator_put(vreg_timpani_1);
6581 return -ENODEV;
6582 }
6583
6584 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6585 if (rc) {
6586 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6587 goto fail;
6588 }
6589
6590 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6591 if (rc) {
6592 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6593 goto fail;
6594 }
6595
6596 rc = regulator_enable(vreg_timpani_1);
6597 if (rc) {
6598 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6599 goto fail;
6600 }
6601
6602 /* The settings for LDO0 should be set such that
6603 * it doesn't require to reset the timpani. */
6604 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6605 if (rc < 0) {
6606 pr_err("Timpani regulator optimum mode setting failed\n");
6607 goto fail;
6608 }
6609
6610 rc = regulator_enable(vreg_timpani_2);
6611 if (rc) {
6612 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6613 regulator_disable(vreg_timpani_1);
6614 goto fail;
6615 }
6616
6617 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6618 if (rc) {
6619 pr_err("%s: GPIO Request %d failed\n", __func__,
6620 GPIO_CDC_RST_N);
6621 regulator_disable(vreg_timpani_1);
6622 regulator_disable(vreg_timpani_2);
6623 goto fail;
6624 } else {
6625 gpio_direction_output(GPIO_CDC_RST_N, 1);
6626 usleep_range(1000, 1050);
6627 gpio_direction_output(GPIO_CDC_RST_N, 0);
6628 usleep_range(1000, 1050);
6629 gpio_direction_output(GPIO_CDC_RST_N, 1);
6630 gpio_free(GPIO_CDC_RST_N);
6631 }
6632 return rc;
6633
6634fail:
6635 regulator_put(vreg_timpani_1);
6636 regulator_put(vreg_timpani_2);
6637 return rc;
6638}
6639
6640static void msm_timpani_shutdown_power(void)
6641{
6642 int rc;
6643
6644 rc = regulator_disable(vreg_timpani_1);
6645 if (rc)
6646 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6647
6648 regulator_put(vreg_timpani_1);
6649
6650 rc = regulator_disable(vreg_timpani_2);
6651 if (rc)
6652 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6653
6654 regulator_put(vreg_timpani_2);
6655}
6656
6657/* Power analog function of codec */
6658static struct regulator *vreg_timpani_cdc_apwr;
6659static int msm_timpani_codec_power(int vreg_on)
6660{
6661 int rc = 0;
6662
6663 if (!vreg_timpani_cdc_apwr) {
6664
6665 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6666
6667 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6668 pr_err("%s: vreg_get failed (%ld)\n",
6669 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6670 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6671 return rc;
6672 }
6673 }
6674
6675 if (vreg_on) {
6676
6677 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6678 2200000, 2200000);
6679 if (rc) {
6680 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6681 __func__);
6682 goto vreg_fail;
6683 }
6684
6685 rc = regulator_enable(vreg_timpani_cdc_apwr);
6686 if (rc) {
6687 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6688 goto vreg_fail;
6689 }
6690 } else {
6691 rc = regulator_disable(vreg_timpani_cdc_apwr);
6692 if (rc) {
6693 pr_err("%s: vreg_disable failed %d\n",
6694 __func__, rc);
6695 goto vreg_fail;
6696 }
6697 }
6698
6699 return 0;
6700
6701vreg_fail:
6702 regulator_put(vreg_timpani_cdc_apwr);
6703 vreg_timpani_cdc_apwr = NULL;
6704 return rc;
6705}
6706
6707static struct marimba_codec_platform_data timpani_codec_pdata = {
6708 .marimba_codec_power = msm_timpani_codec_power,
6709};
6710
6711#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6712#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6713
6714static struct marimba_platform_data timpani_pdata = {
6715 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6716 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6717 .marimba_setup = msm_timpani_setup_power,
6718 .marimba_shutdown = msm_timpani_shutdown_power,
6719 .codec = &timpani_codec_pdata,
6720 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6721};
6722
6723#define TIMPANI_I2C_SLAVE_ADDR 0xD
6724
6725static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6726 {
6727 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6728 .platform_data = &timpani_pdata,
6729 },
6730};
6731
Lei Zhou338cab82011-08-19 13:38:17 -04006732#ifdef CONFIG_SND_SOC_WM8903
6733static struct wm8903_platform_data wm8903_pdata = {
6734 .gpio_cfg[2] = 0x3A8,
6735};
6736
6737#define WM8903_I2C_SLAVE_ADDR 0x34
6738static struct i2c_board_info wm8903_codec_i2c_info[] = {
6739 {
6740 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6741 .platform_data = &wm8903_pdata,
6742 },
6743};
6744#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006745#ifdef CONFIG_PMIC8901
6746
6747#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006748/*
6749 * Consumer specific regulator names:
6750 * regulator name consumer dev_name
6751 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006752static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6753 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6754};
6755static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6756 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6757};
6758
6759#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306760 _always_on) \
6761 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006762 .init_data = { \
6763 .constraints = { \
6764 .valid_modes_mask = _modes, \
6765 .valid_ops_mask = _ops, \
6766 .min_uV = _min_uV, \
6767 .max_uV = _max_uV, \
6768 .input_uV = _min_uV, \
6769 .apply_uV = _apply_uV, \
6770 .always_on = _always_on, \
6771 }, \
6772 .consumer_supplies = vreg_consumers_8901_##_id, \
6773 .num_consumer_supplies = \
6774 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6775 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306776 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006777 }
6778
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006779#define PM8901_VREG_INIT_VS(_id) \
6780 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306781 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006782
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306783static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006784 PM8901_VREG_INIT_VS(USB_OTG),
6785 PM8901_VREG_INIT_VS(HDMI_MVS),
6786};
6787
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306788static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6789 .priority = 1,
6790};
6791
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306792static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6793 .irq_base = PM8901_IRQ_BASE,
6794 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6795 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6796};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006797
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306798static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6799 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006800};
6801
6802static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306803 .irq_pdata = &pm8901_irq_pdata,
6804 .mpp_pdata = &pm8901_mpp_pdata,
6805 .regulator_pdatas = pm8901_vreg_init,
6806 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306807 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006808};
6809
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306810static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6811 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6812 .slave = {
6813 .name = "pm8901-core",
6814 .platform_data = &pm8901_platform_data,
6815 },
6816};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006817#endif /* CONFIG_PMIC8901 */
6818
6819#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6820 || defined(CONFIG_GPIO_SX150X_MODULE))
6821
6822static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006823static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006824
6825struct bahama_config_register{
6826 u8 reg;
6827 u8 value;
6828 u8 mask;
6829};
6830
6831enum version{
6832 VER_1_0,
6833 VER_2_0,
6834 VER_UNSUPPORTED = 0xFF
6835};
6836
6837static u8 read_bahama_ver(void)
6838{
6839 int rc;
6840 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6841 u8 bahama_version;
6842
6843 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6844 if (rc < 0) {
6845 printk(KERN_ERR
6846 "%s: version read failed: %d\n",
6847 __func__, rc);
6848 return VER_UNSUPPORTED;
6849 } else {
6850 printk(KERN_INFO
6851 "%s: version read got: 0x%x\n",
6852 __func__, bahama_version);
6853 }
6854
6855 switch (bahama_version) {
6856 case 0x08: /* varient of bahama v1 */
6857 case 0x10:
6858 case 0x00:
6859 return VER_1_0;
6860 case 0x09: /* variant of bahama v2 */
6861 return VER_2_0;
6862 default:
6863 return VER_UNSUPPORTED;
6864 }
6865}
6866
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006867static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006868static unsigned int msm_bahama_setup_power(void)
6869{
6870 int rc = 0;
6871 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006872
6873 if (machine_is_msm8x60_dragon())
6874 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6875
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006876 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6877
6878 if (IS_ERR(vreg_bahama)) {
6879 rc = PTR_ERR(vreg_bahama);
6880 pr_err("%s: regulator_get %s = %d\n", __func__,
6881 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006882 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006883 }
6884
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006885 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6886 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006887 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6888 msm_bahama_regulator, rc);
6889 goto unget;
6890 }
6891
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006892 rc = regulator_enable(vreg_bahama);
6893 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006894 pr_err("%s: regulator_enable %s = %d\n", __func__,
6895 msm_bahama_regulator, rc);
6896 goto unget;
6897 }
6898
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006899 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6900 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006901 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006902 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006903 goto unenable;
6904 }
6905
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006906 gpio_direction_output(msm_bahama_sys_rst, 0);
6907 usleep_range(1000, 1050);
6908 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6909 usleep_range(1000, 1050);
6910 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006911 return rc;
6912
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006913unenable:
6914 regulator_disable(vreg_bahama);
6915unget:
6916 regulator_put(vreg_bahama);
6917 return rc;
6918};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006919
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006920static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006921{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006922 if (msm_bahama_setup_power_enable) {
6923 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6924 gpio_free(msm_bahama_sys_rst);
6925 regulator_disable(vreg_bahama);
6926 regulator_put(vreg_bahama);
6927 msm_bahama_setup_power_enable = 0;
6928 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006929
6930 return 0;
6931};
6932
6933static unsigned int msm_bahama_core_config(int type)
6934{
6935 int rc = 0;
6936
6937 if (type == BAHAMA_ID) {
6938
6939 int i;
6940 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6941
6942 const struct bahama_config_register v20_init[] = {
6943 /* reg, value, mask */
6944 { 0xF4, 0x84, 0xFF }, /* AREG */
6945 { 0xF0, 0x04, 0xFF } /* DREG */
6946 };
6947
6948 if (read_bahama_ver() == VER_2_0) {
6949 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6950 u8 value = v20_init[i].value;
6951 rc = marimba_write_bit_mask(&config,
6952 v20_init[i].reg,
6953 &value,
6954 sizeof(v20_init[i].value),
6955 v20_init[i].mask);
6956 if (rc < 0) {
6957 printk(KERN_ERR
6958 "%s: reg %d write failed: %d\n",
6959 __func__, v20_init[i].reg, rc);
6960 return rc;
6961 }
6962 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6963 " mask 0x%02x\n",
6964 __func__, v20_init[i].reg,
6965 v20_init[i].value, v20_init[i].mask);
6966 }
6967 }
6968 }
6969 printk(KERN_INFO "core type: %d\n", type);
6970
6971 return rc;
6972}
6973
6974static struct regulator *fm_regulator_s3;
6975static struct msm_xo_voter *fm_clock;
6976
6977static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6978{
6979 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306980 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006981 .direction = PM_GPIO_DIR_IN,
6982 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306983 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984 .function = PM_GPIO_FUNC_NORMAL,
6985 .inv_int_pol = 0,
6986 };
6987
6988 if (!fm_regulator_s3) {
6989 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6990 if (IS_ERR(fm_regulator_s3)) {
6991 rc = PTR_ERR(fm_regulator_s3);
6992 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6993 __func__, rc);
6994 goto out;
6995 }
6996 }
6997
6998
6999 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7000 if (rc < 0) {
7001 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7002 __func__, rc);
7003 goto fm_fail_put;
7004 }
7005
7006 rc = regulator_enable(fm_regulator_s3);
7007 if (rc < 0) {
7008 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7009 __func__, rc);
7010 goto fm_fail_put;
7011 }
7012
7013 /*Vote for XO clock*/
7014 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7015
7016 if (IS_ERR(fm_clock)) {
7017 rc = PTR_ERR(fm_clock);
7018 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7019 __func__, rc);
7020 goto fm_fail_switch;
7021 }
7022
7023 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7024 if (rc < 0) {
7025 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7026 __func__, rc);
7027 goto fm_fail_vote;
7028 }
7029
7030 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307031 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007032 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307033 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007034 __func__, rc);
7035 goto fm_fail_clock;
7036 }
7037 goto out;
7038
7039fm_fail_clock:
7040 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7041fm_fail_vote:
7042 msm_xo_put(fm_clock);
7043fm_fail_switch:
7044 regulator_disable(fm_regulator_s3);
7045fm_fail_put:
7046 regulator_put(fm_regulator_s3);
7047out:
7048 return rc;
7049};
7050
7051static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7052{
7053 int rc = 0;
7054 if (fm_regulator_s3 != NULL) {
7055 rc = regulator_disable(fm_regulator_s3);
7056 if (rc < 0) {
7057 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7058 __func__, rc);
7059 }
7060 regulator_put(fm_regulator_s3);
7061 fm_regulator_s3 = NULL;
7062 }
7063 printk(KERN_ERR "%s: Voting off for XO", __func__);
7064
7065 if (fm_clock != NULL) {
7066 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7067 if (rc < 0) {
7068 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7069 __func__, rc);
7070 }
7071 msm_xo_put(fm_clock);
7072 }
7073 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7074}
7075
7076/* Slave id address for FM/CDC/QMEMBIST
7077 * Values can be programmed using Marimba slave id 0
7078 * should there be a conflict with other I2C devices
7079 * */
7080#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7081#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7082
7083static struct marimba_fm_platform_data marimba_fm_pdata = {
7084 .fm_setup = fm_radio_setup,
7085 .fm_shutdown = fm_radio_shutdown,
7086 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7087 .is_fm_soc_i2s_master = false,
7088 .config_i2s_gpio = NULL,
7089};
7090
7091/*
7092Just initializing the BAHAMA related slave
7093*/
7094static struct marimba_platform_data marimba_pdata = {
7095 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7096 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7097 .bahama_setup = msm_bahama_setup_power,
7098 .bahama_shutdown = msm_bahama_shutdown_power,
7099 .bahama_core_config = msm_bahama_core_config,
7100 .fm = &marimba_fm_pdata,
7101 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7102};
7103
7104
7105static struct i2c_board_info msm_marimba_board_info[] = {
7106 {
7107 I2C_BOARD_INFO("marimba", 0xc),
7108 .platform_data = &marimba_pdata,
7109 }
7110};
7111#endif /* CONFIG_MAIMBA_CORE */
7112
7113#ifdef CONFIG_I2C
7114#define I2C_SURF 1
7115#define I2C_FFA (1 << 1)
7116#define I2C_RUMI (1 << 2)
7117#define I2C_SIM (1 << 3)
7118#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007119#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007120
7121struct i2c_registry {
7122 u8 machs;
7123 int bus;
7124 struct i2c_board_info *info;
7125 int len;
7126};
7127
7128static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007129#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7130 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007131 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007132 MSM_GSBI8_QUP_I2C_BUS_ID,
7133 core_expander_i2c_info,
7134 ARRAY_SIZE(core_expander_i2c_info),
7135 },
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 docking_expander_i2c_info,
7140 ARRAY_SIZE(docking_expander_i2c_info),
7141 },
7142 {
7143 I2C_SURF,
7144 MSM_GSBI8_QUP_I2C_BUS_ID,
7145 surf_expanders_i2c_info,
7146 ARRAY_SIZE(surf_expanders_i2c_info),
7147 },
7148 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007149 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007150 MSM_GSBI3_QUP_I2C_BUS_ID,
7151 fha_expanders_i2c_info,
7152 ARRAY_SIZE(fha_expanders_i2c_info),
7153 },
7154 {
7155 I2C_FLUID,
7156 MSM_GSBI3_QUP_I2C_BUS_ID,
7157 fluid_expanders_i2c_info,
7158 ARRAY_SIZE(fluid_expanders_i2c_info),
7159 },
7160 {
7161 I2C_FLUID,
7162 MSM_GSBI8_QUP_I2C_BUS_ID,
7163 fluid_core_expander_i2c_info,
7164 ARRAY_SIZE(fluid_core_expander_i2c_info),
7165 },
7166#endif
7167#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7168 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7169 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007170 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007171 MSM_GSBI3_QUP_I2C_BUS_ID,
7172 msm_i2c_gsbi3_tdisc_info,
7173 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7174 },
7175#endif
7176 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007177 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007178 MSM_GSBI3_QUP_I2C_BUS_ID,
7179 cy8ctmg200_board_info,
7180 ARRAY_SIZE(cy8ctmg200_board_info),
7181 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007182 {
7183 I2C_DRAGON,
7184 MSM_GSBI3_QUP_I2C_BUS_ID,
7185 cy8ctma340_dragon_board_info,
7186 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7187 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007188#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7189 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7190 {
7191 I2C_FLUID,
7192 MSM_GSBI3_QUP_I2C_BUS_ID,
7193 cyttsp_fluid_info,
7194 ARRAY_SIZE(cyttsp_fluid_info),
7195 },
7196 {
7197 I2C_FFA | I2C_SURF,
7198 MSM_GSBI3_QUP_I2C_BUS_ID,
7199 cyttsp_ffa_info,
7200 ARRAY_SIZE(cyttsp_ffa_info),
7201 },
7202#endif
7203#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007204#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007205 {
7206 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007207 MSM_GSBI4_QUP_I2C_BUS_ID,
7208 msm_camera_boardinfo,
7209 ARRAY_SIZE(msm_camera_boardinfo),
7210 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007211 {
7212 I2C_DRAGON,
7213 MSM_GSBI4_QUP_I2C_BUS_ID,
7214 msm_camera_dragon_boardinfo,
7215 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7216 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007217#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007218#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007219 {
7220 I2C_SURF | I2C_FFA | I2C_FLUID,
7221 MSM_GSBI7_QUP_I2C_BUS_ID,
7222 msm_i2c_gsbi7_timpani_info,
7223 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7224 },
7225#if defined(CONFIG_MARIMBA_CORE)
7226 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007227 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007228 MSM_GSBI7_QUP_I2C_BUS_ID,
7229 msm_marimba_board_info,
7230 ARRAY_SIZE(msm_marimba_board_info),
7231 },
7232#endif /* CONFIG_MARIMBA_CORE */
7233#ifdef CONFIG_ISL9519_CHARGER
7234 {
7235 I2C_SURF | I2C_FFA,
7236 MSM_GSBI8_QUP_I2C_BUS_ID,
7237 isl_charger_i2c_info,
7238 ARRAY_SIZE(isl_charger_i2c_info),
7239 },
7240#endif
7241#if defined(CONFIG_HAPTIC_ISA1200) || \
7242 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7243 {
7244 I2C_FLUID,
7245 MSM_GSBI8_QUP_I2C_BUS_ID,
7246 msm_isa1200_board_info,
7247 ARRAY_SIZE(msm_isa1200_board_info),
7248 },
7249#endif
7250#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7251 {
7252 I2C_FLUID,
7253 MSM_GSBI8_QUP_I2C_BUS_ID,
7254 smb137b_charger_i2c_info,
7255 ARRAY_SIZE(smb137b_charger_i2c_info),
7256 },
7257#endif
7258#if defined(CONFIG_BATTERY_BQ27520) || \
7259 defined(CONFIG_BATTERY_BQ27520_MODULE)
7260 {
7261 I2C_FLUID,
7262 MSM_GSBI8_QUP_I2C_BUS_ID,
7263 msm_bq27520_board_info,
7264 ARRAY_SIZE(msm_bq27520_board_info),
7265 },
7266#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007267#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7268 {
7269 I2C_DRAGON,
7270 MSM_GSBI8_QUP_I2C_BUS_ID,
7271 wm8903_codec_i2c_info,
7272 ARRAY_SIZE(wm8903_codec_i2c_info),
7273 },
7274#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007275};
7276#endif /* CONFIG_I2C */
7277
Stephen Boyd668d7652012-04-25 11:31:01 -07007278static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007279{
7280#ifdef CONFIG_I2C
7281#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7282 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7283 sx150x_data[SX150X_CORE].irq_summary =
7284 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007285 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7286 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007287 sx150x_data[SX150X_CORE].irq_summary =
7288 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7289 else if (machine_is_msm8x60_fluid())
7290 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7291 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7292#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007293#endif
7294}
7295
Stephen Boyd668d7652012-04-25 11:31:01 -07007296static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007297{
7298#ifdef CONFIG_I2C
7299 u8 mach_mask = 0;
7300 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007301#ifdef CONFIG_MSM_CAMERA_V4L2
7302 struct i2c_registry msm8x60_camera_i2c_devices = {
7303 I2C_SURF | I2C_FFA | I2C_FLUID,
7304 MSM_GSBI4_QUP_I2C_BUS_ID,
7305 msm8x60_camera_board_info.board_info,
7306 msm8x60_camera_board_info.num_i2c_board_info,
7307 };
7308#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007309
7310 /* Build the matching 'supported_machs' bitmask */
7311 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7312 mach_mask = I2C_SURF;
7313 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7314 mach_mask = I2C_FFA;
7315 else if (machine_is_msm8x60_rumi3())
7316 mach_mask = I2C_RUMI;
7317 else if (machine_is_msm8x60_sim())
7318 mach_mask = I2C_SIM;
7319 else if (machine_is_msm8x60_fluid())
7320 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007321 else if (machine_is_msm8x60_dragon())
7322 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007323 else
7324 pr_err("unmatched machine ID in register_i2c_devices\n");
7325
7326 /* Run the array and install devices as appropriate */
7327 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7328 if (msm8x60_i2c_devices[i].machs & mach_mask)
7329 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7330 msm8x60_i2c_devices[i].info,
7331 msm8x60_i2c_devices[i].len);
7332 }
Kevin Chan3be11612012-03-22 20:05:40 -07007333#ifdef CONFIG_MSM_CAMERA_V4L2
7334 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7335 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7336 msm8x60_camera_i2c_devices.info,
7337 msm8x60_camera_i2c_devices.len);
7338#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007339#endif
7340}
7341
7342static void __init msm8x60_init_uart12dm(void)
7343{
7344#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7345 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7346 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7347
7348 if (!fpga_mem)
7349 pr_err("%s(): Error getting memory\n", __func__);
7350
7351 /* Advanced mode */
7352 writew(0xFFFF, fpga_mem + 0x15C);
7353 /* FPGA_UART_SEL */
7354 writew(0, fpga_mem + 0x172);
7355 /* FPGA_GPIO_CONFIG_117 */
7356 writew(1, fpga_mem + 0xEA);
7357 /* FPGA_GPIO_CONFIG_118 */
7358 writew(1, fpga_mem + 0xEC);
7359 mb();
7360 iounmap(fpga_mem);
7361#endif
7362}
7363
7364#define MSM_GSBI9_PHYS 0x19900000
7365#define GSBI_DUAL_MODE_CODE 0x60
7366
7367static void __init msm8x60_init_buses(void)
7368{
7369#ifdef CONFIG_I2C_QUP
7370 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7371 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7372 writel_relaxed(0x6 << 4, gsbi_mem);
7373 /* Ensure protocol code is written before proceeding further */
7374 mb();
7375 iounmap(gsbi_mem);
7376
7377 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7378 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7379 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7380 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7381
7382#ifdef CONFIG_MSM_GSBI9_UART
7383 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7384 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7385 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7386 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7387 iounmap(gsbi_mem);
7388 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7389 }
7390#endif
7391 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7392 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7393#endif
7394#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7395 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7396#endif
7397#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007398 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7399#endif
7400
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307401#ifdef CONFIG_MSM_SSBI
7402 msm_device_ssbi_pmic1.dev.platform_data =
7403 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307404 msm_device_ssbi_pmic2.dev.platform_data =
7405 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307406#endif
7407
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007408 if (machine_is_msm8x60_fluid()) {
7409#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7410 (defined(CONFIG_SMB137B_CHARGER) || \
7411 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7412 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7413#endif
7414#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7415 msm_gsbi10_qup_spi_device.dev.platform_data =
7416 &msm_gsbi10_qup_spi_pdata;
7417#endif
7418 }
7419
Lena Salman57d167e2012-03-21 19:46:38 +02007420#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007421 /*
7422 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7423 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7424 * and ID notifications are available only on V2 surf and FFA
7425 * with a hardware workaround.
7426 */
7427 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7428 (machine_is_msm8x60_surf() ||
7429 (machine_is_msm8x60_ffa() &&
7430 pmic_id_notif_supported)))
7431 msm_otg_pdata.phy_can_powercollapse = 1;
7432 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7433#endif
7434
Lena Salman57d167e2012-03-21 19:46:38 +02007435#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007436 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7437#endif
7438
7439#ifdef CONFIG_SERIAL_MSM_HS
7440 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7441 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7442#endif
7443#ifdef CONFIG_MSM_GSBI9_UART
7444 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7445 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7446 if (IS_ERR(msm_device_uart_gsbi9))
7447 pr_err("%s(): Failed to create uart gsbi9 device\n",
7448 __func__);
7449 }
7450#endif
7451
7452#ifdef CONFIG_MSM_BUS_SCALING
7453
7454 /* RPM calls are only enabled on V2 */
7455 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7456 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7457 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7458 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7459 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7460 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7461 }
7462
7463 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7464 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7465 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7466 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7467 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7468#endif
7469}
7470
7471static void __init msm8x60_map_io(void)
7472{
7473 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7474 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007475
7476 if (socinfo_init() < 0)
7477 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007478}
7479
7480/*
7481 * Most segments of the EBI2 bus are disabled by default.
7482 */
7483static void __init msm8x60_init_ebi2(void)
7484{
7485 uint32_t ebi2_cfg;
7486 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007487 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7488
7489 if (IS_ERR(mem_clk)) {
7490 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7491 "msm_ebi2", "mem_clk");
7492 return;
7493 }
7494 clk_enable(mem_clk);
7495 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007496
7497 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7498 if (ebi2_cfg_ptr != 0) {
7499 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7500
7501 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007502 machine_is_msm8x60_fluid() ||
7503 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007504 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7505 else if (machine_is_msm8x60_sim())
7506 ebi2_cfg |= (1 << 4); /* CS2 */
7507 else if (machine_is_msm8x60_rumi3())
7508 ebi2_cfg |= (1 << 5); /* CS3 */
7509
7510 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7511 iounmap(ebi2_cfg_ptr);
7512 }
7513
7514 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007515 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007516 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7517 if (ebi2_cfg_ptr != 0) {
7518 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7519 writel_relaxed(0UL, ebi2_cfg_ptr);
7520
7521 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7522 * LAN9221 Ethernet controller reads and writes.
7523 * The lowest 4 bits are the read delay, the next
7524 * 4 are the write delay. */
7525 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7526#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7527 /*
7528 * RECOVERY=5, HOLD_WR=1
7529 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7530 * WAIT_WR=1, WAIT_RD=2
7531 */
7532 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7533 /*
7534 * HOLD_RD=1
7535 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7536 */
7537 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7538#else
7539 /* EBI2 CS3 muxed address/data,
7540 * two cyc addr enable */
7541 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7542
7543#endif
7544 iounmap(ebi2_cfg_ptr);
7545 }
7546 }
7547}
7548
7549static void __init msm8x60_configure_smc91x(void)
7550{
7551 if (machine_is_msm8x60_sim()) {
7552
7553 smc91x_resources[0].start = 0x1b800300;
7554 smc91x_resources[0].end = 0x1b8003ff;
7555
7556 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7557 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7558
7559 } else if (machine_is_msm8x60_rumi3()) {
7560
7561 smc91x_resources[0].start = 0x1d000300;
7562 smc91x_resources[0].end = 0x1d0003ff;
7563
7564 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7565 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7566 }
7567}
7568
7569static void __init msm8x60_init_tlmm(void)
7570{
7571 if (machine_is_msm8x60_rumi3())
7572 msm_gpio_install_direct_irq(0, 0, 1);
7573}
7574
7575#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7576 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7577 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7578 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7579 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7580
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007581/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007582#define MAX_SDCC_CONTROLLER 5
7583
7584struct msm_sdcc_gpio {
7585 /* maximum 10 GPIOs per SDCC controller */
7586 s16 no;
7587 /* name of this GPIO */
7588 const char *name;
7589 bool always_on;
7590 bool is_enabled;
7591};
7592
7593#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7594static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7595 {159, "sdc1_dat_0"},
7596 {160, "sdc1_dat_1"},
7597 {161, "sdc1_dat_2"},
7598 {162, "sdc1_dat_3"},
7599#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7600 {163, "sdc1_dat_4"},
7601 {164, "sdc1_dat_5"},
7602 {165, "sdc1_dat_6"},
7603 {166, "sdc1_dat_7"},
7604#endif
7605 {167, "sdc1_clk"},
7606 {168, "sdc1_cmd"}
7607};
7608#endif
7609
7610#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7611static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7612 {143, "sdc2_dat_0"},
7613 {144, "sdc2_dat_1", 1},
7614 {145, "sdc2_dat_2"},
7615 {146, "sdc2_dat_3"},
7616#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7617 {147, "sdc2_dat_4"},
7618 {148, "sdc2_dat_5"},
7619 {149, "sdc2_dat_6"},
7620 {150, "sdc2_dat_7"},
7621#endif
7622 {151, "sdc2_cmd"},
7623 {152, "sdc2_clk", 1}
7624};
7625#endif
7626
7627#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7628static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7629 {95, "sdc5_cmd"},
7630 {96, "sdc5_dat_3"},
7631 {97, "sdc5_clk", 1},
7632 {98, "sdc5_dat_2"},
7633 {99, "sdc5_dat_1", 1},
7634 {100, "sdc5_dat_0"}
7635};
7636#endif
7637
7638struct msm_sdcc_pad_pull_cfg {
7639 enum msm_tlmm_pull_tgt pull;
7640 u32 pull_val;
7641};
7642
7643struct msm_sdcc_pad_drv_cfg {
7644 enum msm_tlmm_hdrive_tgt drv;
7645 u32 drv_val;
7646};
7647
7648#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7649static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7650 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7651 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7652 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7653};
7654
7655static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7656 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7657 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7658};
7659
7660static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7661 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7662 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7663 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7664};
7665
7666static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7667 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7668 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7669};
7670#endif
7671
7672#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7673static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7674 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7675 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7676 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7677};
7678
7679static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7680 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7681 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7682};
7683
7684static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7685 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7686 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7687 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7688};
7689
7690static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7691 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7692 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7693};
7694#endif
7695
7696struct msm_sdcc_pin_cfg {
7697 /*
7698 * = 1 if controller pins are using gpios
7699 * = 0 if controller has dedicated MSM pins
7700 */
7701 u8 is_gpio;
7702 u8 cfg_sts;
7703 u8 gpio_data_size;
7704 struct msm_sdcc_gpio *gpio_data;
7705 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7706 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7707 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7708 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7709 u8 pad_drv_data_size;
7710 u8 pad_pull_data_size;
7711 u8 sdio_lpm_gpio_cfg;
7712};
7713
7714
7715static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7716#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7717 [0] = {
7718 .is_gpio = 1,
7719 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7720 .gpio_data = sdc1_gpio_cfg
7721 },
7722#endif
7723#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7724 [1] = {
7725 .is_gpio = 1,
7726 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7727 .gpio_data = sdc2_gpio_cfg
7728 },
7729#endif
7730#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7731 [2] = {
7732 .is_gpio = 0,
7733 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7734 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7735 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7736 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7737 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7738 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7739 },
7740#endif
7741#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7742 [3] = {
7743 .is_gpio = 0,
7744 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7745 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7746 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7747 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7748 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7749 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7750 },
7751#endif
7752#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7753 [4] = {
7754 .is_gpio = 1,
7755 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7756 .gpio_data = sdc5_gpio_cfg
7757 }
7758#endif
7759};
7760
7761static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7762{
7763 int rc = 0;
7764 struct msm_sdcc_pin_cfg *curr;
7765 int n;
7766
7767 curr = &sdcc_pin_cfg_data[dev_id - 1];
7768 if (!curr->gpio_data)
7769 goto out;
7770
7771 for (n = 0; n < curr->gpio_data_size; n++) {
7772 if (enable) {
7773
7774 if (curr->gpio_data[n].always_on &&
7775 curr->gpio_data[n].is_enabled)
7776 continue;
7777 pr_debug("%s: enable: %s\n", __func__,
7778 curr->gpio_data[n].name);
7779 rc = gpio_request(curr->gpio_data[n].no,
7780 curr->gpio_data[n].name);
7781 if (rc) {
7782 pr_err("%s: gpio_request(%d, %s)"
7783 "failed", __func__,
7784 curr->gpio_data[n].no,
7785 curr->gpio_data[n].name);
7786 goto free_gpios;
7787 }
7788 /* set direction as output for all GPIOs */
7789 rc = gpio_direction_output(
7790 curr->gpio_data[n].no, 1);
7791 if (rc) {
7792 pr_err("%s: gpio_direction_output"
7793 "(%d, 1) failed\n", __func__,
7794 curr->gpio_data[n].no);
7795 goto free_gpios;
7796 }
7797 curr->gpio_data[n].is_enabled = 1;
7798 } else {
7799 /*
7800 * now free this GPIO which will put GPIO
7801 * in low power mode and will also put GPIO
7802 * in input mode
7803 */
7804 if (curr->gpio_data[n].always_on)
7805 continue;
7806 pr_debug("%s: disable: %s\n", __func__,
7807 curr->gpio_data[n].name);
7808 gpio_free(curr->gpio_data[n].no);
7809 curr->gpio_data[n].is_enabled = 0;
7810 }
7811 }
7812 curr->cfg_sts = enable;
7813 goto out;
7814
7815free_gpios:
7816 for (; n >= 0; n--)
7817 gpio_free(curr->gpio_data[n].no);
7818out:
7819 return rc;
7820}
7821
7822static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7823{
7824 int rc = 0;
7825 struct msm_sdcc_pin_cfg *curr;
7826 int n;
7827
7828 curr = &sdcc_pin_cfg_data[dev_id - 1];
7829 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7830 goto out;
7831
7832 if (enable) {
7833 /*
7834 * set up the normal driver strength and
7835 * pull config for pads
7836 */
7837 for (n = 0; n < curr->pad_drv_data_size; n++) {
7838 if (curr->sdio_lpm_gpio_cfg) {
7839 if (curr->pad_drv_on_data[n].drv ==
7840 TLMM_HDRV_SDC4_DATA)
7841 continue;
7842 }
7843 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7844 curr->pad_drv_on_data[n].drv_val);
7845 }
7846 for (n = 0; n < curr->pad_pull_data_size; n++) {
7847 if (curr->sdio_lpm_gpio_cfg) {
7848 if (curr->pad_pull_on_data[n].pull ==
7849 TLMM_PULL_SDC4_DATA)
7850 continue;
7851 }
7852 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7853 curr->pad_pull_on_data[n].pull_val);
7854 }
7855 } else {
7856 /* set the low power config for pads */
7857 for (n = 0; n < curr->pad_drv_data_size; n++) {
7858 if (curr->sdio_lpm_gpio_cfg) {
7859 if (curr->pad_drv_off_data[n].drv ==
7860 TLMM_HDRV_SDC4_DATA)
7861 continue;
7862 }
7863 msm_tlmm_set_hdrive(
7864 curr->pad_drv_off_data[n].drv,
7865 curr->pad_drv_off_data[n].drv_val);
7866 }
7867 for (n = 0; n < curr->pad_pull_data_size; n++) {
7868 if (curr->sdio_lpm_gpio_cfg) {
7869 if (curr->pad_pull_off_data[n].pull ==
7870 TLMM_PULL_SDC4_DATA)
7871 continue;
7872 }
7873 msm_tlmm_set_pull(
7874 curr->pad_pull_off_data[n].pull,
7875 curr->pad_pull_off_data[n].pull_val);
7876 }
7877 }
7878 curr->cfg_sts = enable;
7879out:
7880 return rc;
7881}
7882
7883struct sdcc_reg {
7884 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7885 const char *reg_name;
7886 /*
7887 * is set voltage supported for this regulator?
7888 * 0 = not supported, 1 = supported
7889 */
7890 unsigned char set_voltage_sup;
7891 /* voltage level to be set */
7892 unsigned int level;
7893 /* VDD/VCC/VCCQ voltage regulator handle */
7894 struct regulator *reg;
7895 /* is this regulator enabled? */
7896 bool enabled;
7897 /* is this regulator needs to be always on? */
7898 bool always_on;
7899 /* is operating power mode setting required for this regulator? */
7900 bool op_pwr_mode_sup;
7901 /* Load values for low power and high power mode */
7902 unsigned int lpm_uA;
7903 unsigned int hpm_uA;
7904};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007905/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007906static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7907/* only SDCC1 requires VCCQ voltage */
7908static struct sdcc_reg sdcc_vccq_reg_data[1];
7909/* all SDCC controllers may require voting for VDD PAD voltage */
7910static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7911
7912struct sdcc_reg_data {
7913 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7914 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7915 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7916 unsigned char sts; /* regulator enable/disable status */
7917};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007918/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007919static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7920
7921static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7922{
7923 int rc = 0;
7924
7925 /* Get the regulator handle */
7926 vreg->reg = regulator_get(NULL, vreg->reg_name);
7927 if (IS_ERR(vreg->reg)) {
7928 rc = PTR_ERR(vreg->reg);
7929 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7930 __func__, vreg->reg_name, rc);
7931 goto out;
7932 }
7933
7934 /* Set the voltage level if required */
7935 if (vreg->set_voltage_sup) {
7936 rc = regulator_set_voltage(vreg->reg, vreg->level,
7937 vreg->level);
7938 if (rc) {
7939 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7940 __func__, vreg->reg_name, rc);
7941 goto vreg_put;
7942 }
7943 }
7944 goto out;
7945
7946vreg_put:
7947 regulator_put(vreg->reg);
7948out:
7949 return rc;
7950}
7951
7952static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7953{
7954 regulator_put(vreg->reg);
7955}
7956
7957/* this init function should be called only once for each SDCC */
7958static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7959{
7960 int rc = 0;
7961 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7962 struct sdcc_reg_data *curr;
7963
7964 curr = &sdcc_vreg_data[dev_id - 1];
7965 curr_vdd_reg = curr->vdd_data;
7966 curr_vccq_reg = curr->vccq_data;
7967 curr_vddp_reg = curr->vddp_data;
7968
7969 if (init) {
7970 /*
7971 * get the regulator handle from voltage regulator framework
7972 * and then try to set the voltage level for the regulator
7973 */
7974 if (curr_vdd_reg) {
7975 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7976 if (rc)
7977 goto out;
7978 }
7979 if (curr_vccq_reg) {
7980 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7981 if (rc)
7982 goto vdd_reg_deinit;
7983 }
7984 if (curr_vddp_reg) {
7985 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7986 if (rc)
7987 goto vccq_reg_deinit;
7988 }
7989 goto out;
7990 } else
7991 /* deregister with all regulators from regulator framework */
7992 goto vddp_reg_deinit;
7993
7994vddp_reg_deinit:
7995 if (curr_vddp_reg)
7996 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7997vccq_reg_deinit:
7998 if (curr_vccq_reg)
7999 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8000vdd_reg_deinit:
8001 if (curr_vdd_reg)
8002 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8003out:
8004 return rc;
8005}
8006
8007static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8008{
8009 int rc;
8010
8011 if (!vreg->enabled) {
8012 rc = regulator_enable(vreg->reg);
8013 if (rc) {
8014 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8015 __func__, vreg->reg_name, rc);
8016 goto out;
8017 }
8018 vreg->enabled = 1;
8019 }
8020
8021 /* Put always_on regulator in HPM (high power mode) */
8022 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8023 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8024 if (rc < 0) {
8025 pr_err("%s: reg=%s: HPM setting failed"
8026 " hpm_uA=%d, rc=%d\n",
8027 __func__, vreg->reg_name,
8028 vreg->hpm_uA, rc);
8029 goto vreg_disable;
8030 }
8031 rc = 0;
8032 }
8033 goto out;
8034
8035vreg_disable:
8036 regulator_disable(vreg->reg);
8037 vreg->enabled = 0;
8038out:
8039 return rc;
8040}
8041
8042static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8043{
8044 int rc;
8045
8046 /* Never disable always_on regulator */
8047 if (!vreg->always_on) {
8048 rc = regulator_disable(vreg->reg);
8049 if (rc) {
8050 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8051 __func__, vreg->reg_name, rc);
8052 goto out;
8053 }
8054 vreg->enabled = 0;
8055 }
8056
8057 /* Put always_on regulator in LPM (low power mode) */
8058 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8059 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8060 if (rc < 0) {
8061 pr_err("%s: reg=%s: LPM setting failed"
8062 " lpm_uA=%d, rc=%d\n",
8063 __func__,
8064 vreg->reg_name,
8065 vreg->lpm_uA, rc);
8066 goto out;
8067 }
8068 rc = 0;
8069 }
8070
8071out:
8072 return rc;
8073}
8074
8075static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8076{
8077 int rc = 0;
8078 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8079 struct sdcc_reg_data *curr;
8080
8081 curr = &sdcc_vreg_data[dev_id - 1];
8082 curr_vdd_reg = curr->vdd_data;
8083 curr_vccq_reg = curr->vccq_data;
8084 curr_vddp_reg = curr->vddp_data;
8085
8086 /* check if regulators are initialized or not? */
8087 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8088 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8089 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8090 /* initialize voltage regulators required for this SDCC */
8091 rc = msm_sdcc_vreg_init(dev_id, 1);
8092 if (rc) {
8093 pr_err("%s: regulator init failed = %d\n",
8094 __func__, rc);
8095 goto out;
8096 }
8097 }
8098
8099 if (curr->sts == enable)
8100 goto out;
8101
8102 if (curr_vdd_reg) {
8103 if (enable)
8104 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8105 else
8106 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8107 if (rc)
8108 goto out;
8109 }
8110
8111 if (curr_vccq_reg) {
8112 if (enable)
8113 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8114 else
8115 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8116 if (rc)
8117 goto out;
8118 }
8119
8120 if (curr_vddp_reg) {
8121 if (enable)
8122 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8123 else
8124 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8125 if (rc)
8126 goto out;
8127 }
8128 curr->sts = enable;
8129
8130out:
8131 return rc;
8132}
8133
8134static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8135{
8136 u32 rc_pin_cfg = 0;
8137 u32 rc_vreg_cfg = 0;
8138 u32 rc = 0;
8139 struct platform_device *pdev;
8140 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8141
8142 pdev = container_of(dv, struct platform_device, dev);
8143
8144 /* setup gpio/pad */
8145 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8146 if (curr_pin_cfg->cfg_sts == !!vdd)
8147 goto setup_vreg;
8148
8149 if (curr_pin_cfg->is_gpio)
8150 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8151 else
8152 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8153
8154setup_vreg:
8155 /* setup voltage regulators */
8156 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8157
8158 if (rc_pin_cfg || rc_vreg_cfg)
8159 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8160
8161 return rc;
8162}
8163
8164static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8165{
8166 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8167 struct platform_device *pdev;
8168
8169 pdev = container_of(dv, struct platform_device, dev);
8170 /* setup gpio/pad */
8171 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8172
8173 if (curr_pin_cfg->cfg_sts == active)
8174 return;
8175
8176 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8177 if (curr_pin_cfg->is_gpio)
8178 msm_sdcc_setup_gpio(pdev->id, active);
8179 else
8180 msm_sdcc_setup_pad(pdev->id, active);
8181 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8182}
8183
8184static int msm_sdc3_get_wpswitch(struct device *dev)
8185{
8186 struct platform_device *pdev;
8187 int status;
8188 pdev = container_of(dev, struct platform_device, dev);
8189
8190 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8191 if (status) {
8192 pr_err("%s:Failed to request GPIO %d\n",
8193 __func__, GPIO_SDC_WP);
8194 } else {
8195 status = gpio_direction_input(GPIO_SDC_WP);
8196 if (!status) {
8197 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8198 pr_info("%s: WP Status for Slot %d = %d\n",
8199 __func__, pdev->id, status);
8200 }
8201 gpio_free(GPIO_SDC_WP);
8202 }
8203 return status;
8204}
8205
8206#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8207int sdc5_register_status_notify(void (*callback)(int, void *),
8208 void *dev_id)
8209{
8210 sdc5_status_notify_cb = callback;
8211 sdc5_status_notify_cb_devid = dev_id;
8212 return 0;
8213}
8214#endif
8215
8216#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8217int sdc2_register_status_notify(void (*callback)(int, void *),
8218 void *dev_id)
8219{
8220 sdc2_status_notify_cb = callback;
8221 sdc2_status_notify_cb_devid = dev_id;
8222 return 0;
8223}
8224#endif
8225
8226/* Interrupt handler for SDC2 and SDC5 detection
8227 * This function uses dual-edge interrputs settings in order
8228 * to get SDIO detection when the GPIO is rising and SDIO removal
8229 * when the GPIO is falling */
8230static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8231{
8232 int status;
8233
8234 if (!machine_is_msm8x60_fusion() &&
8235 !machine_is_msm8x60_fusn_ffa())
8236 return IRQ_NONE;
8237
8238 status = gpio_get_value(MDM2AP_SYNC);
8239 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8240 __func__, status);
8241
8242#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8243 if (sdc2_status_notify_cb) {
8244 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8245 sdc2_status_notify_cb(status,
8246 sdc2_status_notify_cb_devid);
8247 }
8248#endif
8249
8250#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8251 if (sdc5_status_notify_cb) {
8252 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8253 sdc5_status_notify_cb(status,
8254 sdc5_status_notify_cb_devid);
8255 }
8256#endif
8257 return IRQ_HANDLED;
8258}
8259
8260static int msm8x60_multi_sdio_init(void)
8261{
8262 int ret, irq_num;
8263
8264 if (!machine_is_msm8x60_fusion() &&
8265 !machine_is_msm8x60_fusn_ffa())
8266 return 0;
8267
8268 ret = msm_gpiomux_get(MDM2AP_SYNC);
8269 if (ret) {
8270 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8271 __func__, MDM2AP_SYNC, ret);
8272 return ret;
8273 }
8274
8275 irq_num = gpio_to_irq(MDM2AP_SYNC);
8276
8277 ret = request_irq(irq_num,
8278 msm8x60_multi_sdio_slot_status_irq,
8279 IRQ_TYPE_EDGE_BOTH,
8280 "sdio_multidetection", NULL);
8281
8282 if (ret) {
8283 pr_err("%s:Failed to request irq, ret=%d\n",
8284 __func__, ret);
8285 return ret;
8286 }
8287
8288 return ret;
8289}
8290
8291#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8292#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8293static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8294{
8295 int status;
8296
8297 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8298 , "SD_HW_Detect");
8299 if (status) {
8300 pr_err("%s:Failed to request GPIO %d\n", __func__,
8301 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8302 } else {
8303 status = gpio_direction_input(
8304 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8305 if (!status)
8306 status = !(gpio_get_value_cansleep(
8307 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8308 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8309 }
8310 return (unsigned int) status;
8311}
8312#endif
8313#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308314#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008315
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308316#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308317#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008318
8319#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8320static struct mmc_platform_data msm8x60_sdc1_data = {
8321 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8322 .translate_vdd = msm_sdcc_setup_power,
8323#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8324 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8325#else
8326 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8327#endif
8328 .msmsdcc_fmin = 400000,
8329 .msmsdcc_fmid = 24000000,
8330 .msmsdcc_fmax = 48000000,
8331 .nonremovable = 1,
8332 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008333};
8334#endif
8335
8336#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8337static struct mmc_platform_data msm8x60_sdc2_data = {
8338 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8339 .translate_vdd = msm_sdcc_setup_power,
8340 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8341 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8342 .msmsdcc_fmin = 400000,
8343 .msmsdcc_fmid = 24000000,
8344 .msmsdcc_fmax = 48000000,
8345 .nonremovable = 0,
8346 .pclk_src_dfab = 1,
8347 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008348#ifdef CONFIG_MSM_SDIO_AL
8349 .is_sdio_al_client = 1,
8350#endif
8351};
8352#endif
8353
8354#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8355static struct mmc_platform_data msm8x60_sdc3_data = {
8356 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8357 .translate_vdd = msm_sdcc_setup_power,
8358 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8359 .wpswitch = msm_sdc3_get_wpswitch,
8360#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8361 .status = msm8x60_sdcc_slot_status,
8362 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8363 PMIC_GPIO_SDC3_DET - 1),
8364 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8365#endif
8366 .msmsdcc_fmin = 400000,
8367 .msmsdcc_fmid = 24000000,
8368 .msmsdcc_fmax = 48000000,
8369 .nonremovable = 0,
8370 .pclk_src_dfab = 1,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308371 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008372};
8373#endif
8374
8375#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8376static struct mmc_platform_data msm8x60_sdc4_data = {
8377 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8378 .translate_vdd = msm_sdcc_setup_power,
8379 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8380 .msmsdcc_fmin = 400000,
8381 .msmsdcc_fmid = 24000000,
8382 .msmsdcc_fmax = 48000000,
8383 .nonremovable = 0,
8384 .pclk_src_dfab = 1,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308385 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008386};
8387#endif
8388
8389#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8390static struct mmc_platform_data msm8x60_sdc5_data = {
8391 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8392 .translate_vdd = msm_sdcc_setup_power,
8393 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8394 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8395 .msmsdcc_fmin = 400000,
8396 .msmsdcc_fmid = 24000000,
8397 .msmsdcc_fmax = 48000000,
8398 .nonremovable = 0,
8399 .pclk_src_dfab = 1,
8400 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008401#ifdef CONFIG_MSM_SDIO_AL
8402 .is_sdio_al_client = 1,
8403#endif
8404};
8405#endif
8406
8407static void __init msm8x60_init_mmc(void)
8408{
8409#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8410 /* SDCC1 : eMMC card connected */
8411 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8412 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8413 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8414 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308415 sdcc_vreg_data[0].vdd_data->always_on = 1;
8416 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8417 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8418 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008419
8420 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8421 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8422 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8423 sdcc_vreg_data[0].vccq_data->always_on = 1;
8424
8425 msm_add_sdcc(1, &msm8x60_sdc1_data);
8426#endif
8427#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8428 /*
8429 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8430 * and no card is connected on 8660 SURF/FFA/FLUID.
8431 */
8432 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8433 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8434 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8435 sdcc_vreg_data[1].vdd_data->level = 1800000;
8436
8437 sdcc_vreg_data[1].vccq_data = NULL;
8438
8439 if (machine_is_msm8x60_fusion())
8440 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8441 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008442 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8443 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008444 msm_add_sdcc(2, &msm8x60_sdc2_data);
8445 }
8446#endif
8447#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8448 /* SDCC3 : External card slot connected */
8449 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8450 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8451 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8452 sdcc_vreg_data[2].vdd_data->level = 2850000;
8453 sdcc_vreg_data[2].vdd_data->always_on = 1;
8454 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8455 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8456 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8457
8458 sdcc_vreg_data[2].vccq_data = NULL;
8459
8460 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8461 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8462 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8463 sdcc_vreg_data[2].vddp_data->level = 2850000;
8464 sdcc_vreg_data[2].vddp_data->always_on = 1;
8465 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8466 /* Sleep current required is ~300 uA. But min. RPM
8467 * vote can be in terms of mA (min. 1 mA).
8468 * So let's vote for 2 mA during sleep.
8469 */
8470 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8471 /* Max. Active current required is 16 mA */
8472 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8473
8474 if (machine_is_msm8x60_fluid())
8475 msm8x60_sdc3_data.wpswitch = NULL;
8476 msm_add_sdcc(3, &msm8x60_sdc3_data);
8477#endif
8478#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8479 /* SDCC4 : WLAN WCN1314 chip is connected */
8480 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8481 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8482 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8483 sdcc_vreg_data[3].vdd_data->level = 1800000;
8484
8485 sdcc_vreg_data[3].vccq_data = NULL;
8486
8487 msm_add_sdcc(4, &msm8x60_sdc4_data);
8488#endif
8489#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8490 /*
8491 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8492 * and no card is connected on 8660 SURF/FFA/FLUID.
8493 */
8494 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8495 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8496 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8497 sdcc_vreg_data[4].vdd_data->level = 1800000;
8498
8499 sdcc_vreg_data[4].vccq_data = NULL;
8500
8501 if (machine_is_msm8x60_fusion())
8502 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8503 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008504 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8505 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008506 msm_add_sdcc(5, &msm8x60_sdc5_data);
8507 }
8508#endif
8509}
8510
8511#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8512static inline void display_common_power(int on) {}
8513#else
8514
8515#define _GET_REGULATOR(var, name) do { \
8516 if (var == NULL) { \
8517 var = regulator_get(NULL, name); \
8518 if (IS_ERR(var)) { \
8519 pr_err("'%s' regulator not found, rc=%ld\n", \
8520 name, PTR_ERR(var)); \
8521 var = NULL; \
8522 } \
8523 } \
8524} while (0)
8525
8526static int dsub_regulator(int on)
8527{
8528 static struct regulator *dsub_reg;
8529 static struct regulator *mpp0_reg;
8530 static int dsub_reg_enabled;
8531 int rc = 0;
8532
8533 _GET_REGULATOR(dsub_reg, "8901_l3");
8534 if (IS_ERR(dsub_reg)) {
8535 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8536 __func__, PTR_ERR(dsub_reg));
8537 return PTR_ERR(dsub_reg);
8538 }
8539
8540 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8541 if (IS_ERR(mpp0_reg)) {
8542 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8543 __func__, PTR_ERR(mpp0_reg));
8544 return PTR_ERR(mpp0_reg);
8545 }
8546
8547 if (on && !dsub_reg_enabled) {
8548 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8549 if (rc) {
8550 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8551 " err=%d", __func__, rc);
8552 goto dsub_regulator_err;
8553 }
8554 rc = regulator_enable(dsub_reg);
8555 if (rc) {
8556 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8557 " err=%d", __func__, rc);
8558 goto dsub_regulator_err;
8559 }
8560 rc = regulator_enable(mpp0_reg);
8561 if (rc) {
8562 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8563 " err=%d", __func__, rc);
8564 goto dsub_regulator_err;
8565 }
8566 dsub_reg_enabled = 1;
8567 } else if (!on && dsub_reg_enabled) {
8568 rc = regulator_disable(dsub_reg);
8569 if (rc)
8570 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8571 " err=%d", __func__, rc);
8572 rc = regulator_disable(mpp0_reg);
8573 if (rc)
8574 printk(KERN_WARNING "%s: failed to disable reg "
8575 "8901_mpp0 err=%d", __func__, rc);
8576 dsub_reg_enabled = 0;
8577 }
8578
8579 return rc;
8580
8581dsub_regulator_err:
8582 regulator_put(mpp0_reg);
8583 regulator_put(dsub_reg);
8584 return rc;
8585}
8586
8587static int display_power_on;
8588static void setup_display_power(void)
8589{
8590 if (display_power_on)
8591 if (lcdc_vga_enabled) {
8592 dsub_regulator(1);
8593 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8594 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8595 if (machine_is_msm8x60_ffa() ||
8596 machine_is_msm8x60_fusn_ffa())
8597 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8598 } else {
8599 dsub_regulator(0);
8600 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8601 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8602 if (machine_is_msm8x60_ffa() ||
8603 machine_is_msm8x60_fusn_ffa())
8604 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8605 }
8606 else {
8607 dsub_regulator(0);
8608 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8609 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8610 /* BACKLIGHT */
8611 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8612 /* LVDS */
8613 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8614 }
8615}
8616
8617#define _GET_REGULATOR(var, name) do { \
8618 if (var == NULL) { \
8619 var = regulator_get(NULL, name); \
8620 if (IS_ERR(var)) { \
8621 pr_err("'%s' regulator not found, rc=%ld\n", \
8622 name, PTR_ERR(var)); \
8623 var = NULL; \
8624 } \
8625 } \
8626} while (0)
8627
8628#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8629
8630static void display_common_power(int on)
8631{
8632 int rc;
8633 static struct regulator *display_reg;
8634
8635 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8636 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8637 if (on) {
8638 /* LVDS */
8639 _GET_REGULATOR(display_reg, "8901_l2");
8640 if (!display_reg)
8641 return;
8642 rc = regulator_set_voltage(display_reg,
8643 3300000, 3300000);
8644 if (rc)
8645 goto out;
8646 rc = regulator_enable(display_reg);
8647 if (rc)
8648 goto out;
8649 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8650 "LVDS_STDN_OUT_N");
8651 if (rc) {
8652 printk(KERN_ERR "%s: LVDS gpio %d request"
8653 "failed\n", __func__,
8654 GPIO_LVDS_SHUTDOWN_N);
8655 goto out2;
8656 }
8657
8658 /* BACKLIGHT */
8659 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8660 if (rc) {
8661 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8662 "failed\n", __func__,
8663 GPIO_BACKLIGHT_EN);
8664 goto out3;
8665 }
8666
8667 if (machine_is_msm8x60_ffa() ||
8668 machine_is_msm8x60_fusn_ffa()) {
8669 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8670 "DONGLE_PWR_EN");
8671 if (rc) {
8672 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8673 " %d request failed\n", __func__,
8674 GPIO_DONGLE_PWR_EN);
8675 goto out4;
8676 }
8677 }
8678
8679 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8680 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8681 if (machine_is_msm8x60_ffa() ||
8682 machine_is_msm8x60_fusn_ffa())
8683 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8684 mdelay(20);
8685 display_power_on = 1;
8686 setup_display_power();
8687 } else {
8688 if (display_power_on) {
8689 display_power_on = 0;
8690 setup_display_power();
8691 mdelay(20);
8692 if (machine_is_msm8x60_ffa() ||
8693 machine_is_msm8x60_fusn_ffa())
8694 gpio_free(GPIO_DONGLE_PWR_EN);
8695 goto out4;
8696 }
8697 }
8698 }
8699#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8700 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8701 else if (machine_is_msm8x60_fluid()) {
8702 static struct regulator *fluid_reg;
8703 static struct regulator *fluid_reg2;
8704
8705 if (on) {
8706 _GET_REGULATOR(fluid_reg, "8901_l2");
8707 if (!fluid_reg)
8708 return;
8709 _GET_REGULATOR(fluid_reg2, "8058_s3");
8710 if (!fluid_reg2) {
8711 regulator_put(fluid_reg);
8712 return;
8713 }
8714 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8715 if (rc) {
8716 regulator_put(fluid_reg2);
8717 regulator_put(fluid_reg);
8718 return;
8719 }
8720 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8721 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8722 regulator_enable(fluid_reg);
8723 regulator_enable(fluid_reg2);
8724 msleep(20);
8725 gpio_direction_output(GPIO_RESX_N, 0);
8726 udelay(10);
8727 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8728 display_power_on = 1;
8729 setup_display_power();
8730 } else {
8731 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8732 gpio_free(GPIO_RESX_N);
8733 msleep(20);
8734 regulator_disable(fluid_reg2);
8735 regulator_disable(fluid_reg);
8736 regulator_put(fluid_reg2);
8737 regulator_put(fluid_reg);
8738 display_power_on = 0;
8739 setup_display_power();
8740 fluid_reg = NULL;
8741 fluid_reg2 = NULL;
8742 }
8743 }
8744#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008745#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8746 else if (machine_is_msm8x60_dragon()) {
8747 static struct regulator *dragon_reg;
8748 static struct regulator *dragon_reg2;
8749
8750 if (on) {
8751 _GET_REGULATOR(dragon_reg, "8901_l2");
8752 if (!dragon_reg)
8753 return;
8754 _GET_REGULATOR(dragon_reg2, "8058_l16");
8755 if (!dragon_reg2) {
8756 regulator_put(dragon_reg);
8757 dragon_reg = NULL;
8758 return;
8759 }
8760
8761 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8762 if (rc) {
8763 pr_err("%s: gpio %d request failed with rc=%d\n",
8764 __func__, GPIO_NT35582_BL_EN, rc);
8765 regulator_put(dragon_reg);
8766 regulator_put(dragon_reg2);
8767 dragon_reg = NULL;
8768 dragon_reg2 = NULL;
8769 return;
8770 }
8771
8772 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8773 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8774 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8775 pr_err("%s: config gpio '%d' failed!\n",
8776 __func__, GPIO_NT35582_RESET);
8777 gpio_free(GPIO_NT35582_BL_EN);
8778 regulator_put(dragon_reg);
8779 regulator_put(dragon_reg2);
8780 dragon_reg = NULL;
8781 dragon_reg2 = NULL;
8782 return;
8783 }
8784
8785 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8786 if (rc) {
8787 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8788 __func__, GPIO_NT35582_RESET, rc);
8789 gpio_free(GPIO_NT35582_BL_EN);
8790 regulator_put(dragon_reg);
8791 regulator_put(dragon_reg2);
8792 dragon_reg = NULL;
8793 dragon_reg2 = NULL;
8794 return;
8795 }
8796
8797 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8798 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8799 regulator_enable(dragon_reg);
8800 regulator_enable(dragon_reg2);
8801 msleep(20);
8802
8803 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8804 msleep(20);
8805 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8806 msleep(20);
8807 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8808 msleep(50);
8809
8810 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8811
8812 display_power_on = 1;
8813 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8814 gpio_free(GPIO_NT35582_RESET);
8815 gpio_free(GPIO_NT35582_BL_EN);
8816 regulator_disable(dragon_reg2);
8817 regulator_disable(dragon_reg);
8818 regulator_put(dragon_reg2);
8819 regulator_put(dragon_reg);
8820 display_power_on = 0;
8821 dragon_reg = NULL;
8822 dragon_reg2 = NULL;
8823 }
8824 }
8825#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008826 return;
8827
8828out4:
8829 gpio_free(GPIO_BACKLIGHT_EN);
8830out3:
8831 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8832out2:
8833 regulator_disable(display_reg);
8834out:
8835 regulator_put(display_reg);
8836 display_reg = NULL;
8837}
8838#undef _GET_REGULATOR
8839#endif
8840
8841static int mipi_dsi_panel_power(int on);
8842
8843#define LCDC_NUM_GPIO 28
8844#define LCDC_GPIO_START 0
8845
8846static void lcdc_samsung_panel_power(int on)
8847{
8848 int n, ret = 0;
8849
8850 display_common_power(on);
8851
8852 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8853 if (on) {
8854 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8855 if (unlikely(ret)) {
8856 pr_err("%s not able to get gpio\n", __func__);
8857 break;
8858 }
8859 } else
8860 gpio_free(LCDC_GPIO_START + n);
8861 }
8862
8863 if (ret) {
8864 for (n--; n >= 0; n--)
8865 gpio_free(LCDC_GPIO_START + n);
8866 }
8867
8868 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8869}
8870
8871#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8872#define _GET_REGULATOR(var, name) do { \
8873 var = regulator_get(NULL, name); \
8874 if (IS_ERR(var)) { \
8875 pr_err("'%s' regulator not found, rc=%ld\n", \
8876 name, IS_ERR(var)); \
8877 var = NULL; \
8878 return -ENODEV; \
8879 } \
8880} while (0)
8881
8882static int hdmi_enable_5v(int on)
8883{
8884 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8885 static struct regulator *reg_8901_mpp0; /* External 5V */
8886 static int prev_on;
8887 int rc;
8888
8889 if (on == prev_on)
8890 return 0;
8891
8892 if (!reg_8901_hdmi_mvs)
8893 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8894 if (!reg_8901_mpp0)
8895 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8896
8897 if (on) {
8898 rc = regulator_enable(reg_8901_mpp0);
8899 if (rc) {
8900 pr_err("'%s' regulator enable failed, rc=%d\n",
8901 "reg_8901_mpp0", rc);
8902 return rc;
8903 }
8904 rc = regulator_enable(reg_8901_hdmi_mvs);
8905 if (rc) {
8906 pr_err("'%s' regulator enable failed, rc=%d\n",
8907 "8901_hdmi_mvs", rc);
8908 return rc;
8909 }
8910 pr_info("%s(on): success\n", __func__);
8911 } else {
8912 rc = regulator_disable(reg_8901_hdmi_mvs);
8913 if (rc)
8914 pr_warning("'%s' regulator disable failed, rc=%d\n",
8915 "8901_hdmi_mvs", rc);
8916 rc = regulator_disable(reg_8901_mpp0);
8917 if (rc)
8918 pr_warning("'%s' regulator disable failed, rc=%d\n",
8919 "reg_8901_mpp0", rc);
8920 pr_info("%s(off): success\n", __func__);
8921 }
8922
8923 prev_on = on;
8924
8925 return 0;
8926}
8927
8928static int hdmi_core_power(int on, int show)
8929{
8930 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8931 static int prev_on;
8932 int rc;
8933
8934 if (on == prev_on)
8935 return 0;
8936
8937 if (!reg_8058_l16)
8938 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8939
8940 if (on) {
8941 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8942 if (!rc)
8943 rc = regulator_enable(reg_8058_l16);
8944 if (rc) {
8945 pr_err("'%s' regulator enable failed, rc=%d\n",
8946 "8058_l16", rc);
8947 return rc;
8948 }
8949 rc = gpio_request(170, "HDMI_DDC_CLK");
8950 if (rc) {
8951 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8952 "HDMI_DDC_CLK", 170, rc);
8953 goto error1;
8954 }
8955 rc = gpio_request(171, "HDMI_DDC_DATA");
8956 if (rc) {
8957 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8958 "HDMI_DDC_DATA", 171, rc);
8959 goto error2;
8960 }
8961 rc = gpio_request(172, "HDMI_HPD");
8962 if (rc) {
8963 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8964 "HDMI_HPD", 172, rc);
8965 goto error3;
8966 }
8967 pr_info("%s(on): success\n", __func__);
8968 } else {
8969 gpio_free(170);
8970 gpio_free(171);
8971 gpio_free(172);
8972 rc = regulator_disable(reg_8058_l16);
8973 if (rc)
8974 pr_warning("'%s' regulator disable failed, rc=%d\n",
8975 "8058_l16", rc);
8976 pr_info("%s(off): success\n", __func__);
8977 }
8978
8979 prev_on = on;
8980
8981 return 0;
8982
8983error3:
8984 gpio_free(171);
8985error2:
8986 gpio_free(170);
8987error1:
8988 regulator_disable(reg_8058_l16);
8989 return rc;
8990}
8991
8992static int hdmi_cec_power(int on)
8993{
8994 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8995 static int prev_on;
8996 int rc;
8997
8998 if (on == prev_on)
8999 return 0;
9000
9001 if (!reg_8901_l3)
9002 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9003
9004 if (on) {
9005 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9006 if (!rc)
9007 rc = regulator_enable(reg_8901_l3);
9008 if (rc) {
9009 pr_err("'%s' regulator enable failed, rc=%d\n",
9010 "8901_l3", rc);
9011 return rc;
9012 }
9013 rc = gpio_request(169, "HDMI_CEC_VAR");
9014 if (rc) {
9015 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9016 "HDMI_CEC_VAR", 169, rc);
9017 goto error;
9018 }
9019 pr_info("%s(on): success\n", __func__);
9020 } else {
9021 gpio_free(169);
9022 rc = regulator_disable(reg_8901_l3);
9023 if (rc)
9024 pr_warning("'%s' regulator disable failed, rc=%d\n",
9025 "8901_l3", rc);
9026 pr_info("%s(off): success\n", __func__);
9027 }
9028
9029 prev_on = on;
9030
9031 return 0;
9032error:
9033 regulator_disable(reg_8901_l3);
9034 return rc;
9035}
9036
9037#undef _GET_REGULATOR
9038
9039#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9040
9041static int lcdc_panel_power(int on)
9042{
9043 int flag_on = !!on;
9044 static int lcdc_power_save_on;
9045
9046 if (lcdc_power_save_on == flag_on)
9047 return 0;
9048
9049 lcdc_power_save_on = flag_on;
9050
9051 lcdc_samsung_panel_power(on);
9052
9053 return 0;
9054}
9055
9056#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009057
9058static struct msm_bus_vectors rotator_init_vectors[] = {
9059 {
9060 .src = MSM_BUS_MASTER_ROTATOR,
9061 .dst = MSM_BUS_SLAVE_SMI,
9062 .ab = 0,
9063 .ib = 0,
9064 },
9065 {
9066 .src = MSM_BUS_MASTER_ROTATOR,
9067 .dst = MSM_BUS_SLAVE_EBI_CH0,
9068 .ab = 0,
9069 .ib = 0,
9070 },
9071};
9072
9073static struct msm_bus_vectors rotator_ui_vectors[] = {
9074 {
9075 .src = MSM_BUS_MASTER_ROTATOR,
9076 .dst = MSM_BUS_SLAVE_SMI,
9077 .ab = 0,
9078 .ib = 0,
9079 },
9080 {
9081 .src = MSM_BUS_MASTER_ROTATOR,
9082 .dst = MSM_BUS_SLAVE_EBI_CH0,
9083 .ab = (1024 * 600 * 4 * 2 * 60),
9084 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9085 },
9086};
9087
9088static struct msm_bus_vectors rotator_vga_vectors[] = {
9089 {
9090 .src = MSM_BUS_MASTER_ROTATOR,
9091 .dst = MSM_BUS_SLAVE_SMI,
9092 .ab = (640 * 480 * 2 * 2 * 30),
9093 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9094 },
9095 {
9096 .src = MSM_BUS_MASTER_ROTATOR,
9097 .dst = MSM_BUS_SLAVE_EBI_CH0,
9098 .ab = (640 * 480 * 2 * 2 * 30),
9099 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9100 },
9101};
9102
9103static struct msm_bus_vectors rotator_720p_vectors[] = {
9104 {
9105 .src = MSM_BUS_MASTER_ROTATOR,
9106 .dst = MSM_BUS_SLAVE_SMI,
9107 .ab = (1280 * 736 * 2 * 2 * 30),
9108 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9109 },
9110 {
9111 .src = MSM_BUS_MASTER_ROTATOR,
9112 .dst = MSM_BUS_SLAVE_EBI_CH0,
9113 .ab = (1280 * 736 * 2 * 2 * 30),
9114 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9115 },
9116};
9117
9118static struct msm_bus_vectors rotator_1080p_vectors[] = {
9119 {
9120 .src = MSM_BUS_MASTER_ROTATOR,
9121 .dst = MSM_BUS_SLAVE_SMI,
9122 .ab = (1920 * 1088 * 2 * 2 * 30),
9123 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9124 },
9125 {
9126 .src = MSM_BUS_MASTER_ROTATOR,
9127 .dst = MSM_BUS_SLAVE_EBI_CH0,
9128 .ab = (1920 * 1088 * 2 * 2 * 30),
9129 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9130 },
9131};
9132
9133static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9134 {
9135 ARRAY_SIZE(rotator_init_vectors),
9136 rotator_init_vectors,
9137 },
9138 {
9139 ARRAY_SIZE(rotator_ui_vectors),
9140 rotator_ui_vectors,
9141 },
9142 {
9143 ARRAY_SIZE(rotator_vga_vectors),
9144 rotator_vga_vectors,
9145 },
9146 {
9147 ARRAY_SIZE(rotator_720p_vectors),
9148 rotator_720p_vectors,
9149 },
9150 {
9151 ARRAY_SIZE(rotator_1080p_vectors),
9152 rotator_1080p_vectors,
9153 },
9154};
9155
9156struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9157 rotator_bus_scale_usecases,
9158 ARRAY_SIZE(rotator_bus_scale_usecases),
9159 .name = "rotator",
9160};
9161
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009162static struct msm_bus_vectors mdp_init_vectors[] = {
9163 /* For now, 0th array entry is reserved.
9164 * Please leave 0 as is and don't use it
9165 */
9166 {
9167 .src = MSM_BUS_MASTER_MDP_PORT0,
9168 .dst = MSM_BUS_SLAVE_SMI,
9169 .ab = 0,
9170 .ib = 0,
9171 },
9172 /* Master and slaves can be from different fabrics */
9173 {
9174 .src = MSM_BUS_MASTER_MDP_PORT0,
9175 .dst = MSM_BUS_SLAVE_EBI_CH0,
9176 .ab = 0,
9177 .ib = 0,
9178 },
9179};
9180
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009181#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009182static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9183 /* Default case static display/UI/2d/3d if FB SMI */
9184 {
9185 .src = MSM_BUS_MASTER_MDP_PORT0,
9186 .dst = MSM_BUS_SLAVE_SMI,
9187 .ab = 388800000,
9188 .ib = 486000000,
9189 },
9190 /* Master and slaves can be from different fabrics */
9191 {
9192 .src = MSM_BUS_MASTER_MDP_PORT0,
9193 .dst = MSM_BUS_SLAVE_EBI_CH0,
9194 .ab = 0,
9195 .ib = 0,
9196 },
9197};
9198
9199static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9200 /* Default case static display/UI/2d/3d if FB SMI */
9201 {
9202 .src = MSM_BUS_MASTER_MDP_PORT0,
9203 .dst = MSM_BUS_SLAVE_SMI,
9204 .ab = 0,
9205 .ib = 0,
9206 },
9207 /* Master and slaves can be from different fabrics */
9208 {
9209 .src = MSM_BUS_MASTER_MDP_PORT0,
9210 .dst = MSM_BUS_SLAVE_EBI_CH0,
9211 .ab = 388800000,
9212 .ib = 486000000 * 2,
9213 },
9214};
9215static struct msm_bus_vectors mdp_vga_vectors[] = {
9216 /* VGA and less video */
9217 {
9218 .src = MSM_BUS_MASTER_MDP_PORT0,
9219 .dst = MSM_BUS_SLAVE_SMI,
9220 .ab = 458092800,
9221 .ib = 572616000,
9222 },
9223 {
9224 .src = MSM_BUS_MASTER_MDP_PORT0,
9225 .dst = MSM_BUS_SLAVE_EBI_CH0,
9226 .ab = 458092800,
9227 .ib = 572616000 * 2,
9228 },
9229};
9230static struct msm_bus_vectors mdp_720p_vectors[] = {
9231 /* 720p and less video */
9232 {
9233 .src = MSM_BUS_MASTER_MDP_PORT0,
9234 .dst = MSM_BUS_SLAVE_SMI,
9235 .ab = 471744000,
9236 .ib = 589680000,
9237 },
9238 /* Master and slaves can be from different fabrics */
9239 {
9240 .src = MSM_BUS_MASTER_MDP_PORT0,
9241 .dst = MSM_BUS_SLAVE_EBI_CH0,
9242 .ab = 471744000,
9243 .ib = 589680000 * 2,
9244 },
9245};
9246
9247static struct msm_bus_vectors mdp_1080p_vectors[] = {
9248 /* 1080p and less video */
9249 {
9250 .src = MSM_BUS_MASTER_MDP_PORT0,
9251 .dst = MSM_BUS_SLAVE_SMI,
9252 .ab = 575424000,
9253 .ib = 719280000,
9254 },
9255 /* Master and slaves can be from different fabrics */
9256 {
9257 .src = MSM_BUS_MASTER_MDP_PORT0,
9258 .dst = MSM_BUS_SLAVE_EBI_CH0,
9259 .ab = 575424000,
9260 .ib = 719280000 * 2,
9261 },
9262};
9263
9264#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009265static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9266 /* Default case static display/UI/2d/3d if FB SMI */
9267 {
9268 .src = MSM_BUS_MASTER_MDP_PORT0,
9269 .dst = MSM_BUS_SLAVE_SMI,
9270 .ab = 175110000,
9271 .ib = 218887500,
9272 },
9273 /* Master and slaves can be from different fabrics */
9274 {
9275 .src = MSM_BUS_MASTER_MDP_PORT0,
9276 .dst = MSM_BUS_SLAVE_EBI_CH0,
9277 .ab = 0,
9278 .ib = 0,
9279 },
9280};
9281
9282static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9283 /* Default case static display/UI/2d/3d if FB SMI */
9284 {
9285 .src = MSM_BUS_MASTER_MDP_PORT0,
9286 .dst = MSM_BUS_SLAVE_SMI,
9287 .ab = 0,
9288 .ib = 0,
9289 },
9290 /* Master and slaves can be from different fabrics */
9291 {
9292 .src = MSM_BUS_MASTER_MDP_PORT0,
9293 .dst = MSM_BUS_SLAVE_EBI_CH0,
9294 .ab = 216000000,
9295 .ib = 270000000 * 2,
9296 },
9297};
9298static struct msm_bus_vectors mdp_vga_vectors[] = {
9299 /* VGA and less video */
9300 {
9301 .src = MSM_BUS_MASTER_MDP_PORT0,
9302 .dst = MSM_BUS_SLAVE_SMI,
9303 .ab = 216000000,
9304 .ib = 270000000,
9305 },
9306 {
9307 .src = MSM_BUS_MASTER_MDP_PORT0,
9308 .dst = MSM_BUS_SLAVE_EBI_CH0,
9309 .ab = 216000000,
9310 .ib = 270000000 * 2,
9311 },
9312};
9313
9314static struct msm_bus_vectors mdp_720p_vectors[] = {
9315 /* 720p and less video */
9316 {
9317 .src = MSM_BUS_MASTER_MDP_PORT0,
9318 .dst = MSM_BUS_SLAVE_SMI,
9319 .ab = 230400000,
9320 .ib = 288000000,
9321 },
9322 /* Master and slaves can be from different fabrics */
9323 {
9324 .src = MSM_BUS_MASTER_MDP_PORT0,
9325 .dst = MSM_BUS_SLAVE_EBI_CH0,
9326 .ab = 230400000,
9327 .ib = 288000000 * 2,
9328 },
9329};
9330
9331static struct msm_bus_vectors mdp_1080p_vectors[] = {
9332 /* 1080p and less video */
9333 {
9334 .src = MSM_BUS_MASTER_MDP_PORT0,
9335 .dst = MSM_BUS_SLAVE_SMI,
9336 .ab = 334080000,
9337 .ib = 417600000,
9338 },
9339 /* Master and slaves can be from different fabrics */
9340 {
9341 .src = MSM_BUS_MASTER_MDP_PORT0,
9342 .dst = MSM_BUS_SLAVE_EBI_CH0,
9343 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009344 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009345 },
9346};
9347
9348#endif
9349static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9350 {
9351 ARRAY_SIZE(mdp_init_vectors),
9352 mdp_init_vectors,
9353 },
9354 {
9355 ARRAY_SIZE(mdp_sd_smi_vectors),
9356 mdp_sd_smi_vectors,
9357 },
9358 {
9359 ARRAY_SIZE(mdp_sd_ebi_vectors),
9360 mdp_sd_ebi_vectors,
9361 },
9362 {
9363 ARRAY_SIZE(mdp_vga_vectors),
9364 mdp_vga_vectors,
9365 },
9366 {
9367 ARRAY_SIZE(mdp_720p_vectors),
9368 mdp_720p_vectors,
9369 },
9370 {
9371 ARRAY_SIZE(mdp_1080p_vectors),
9372 mdp_1080p_vectors,
9373 },
9374};
9375static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9376 mdp_bus_scale_usecases,
9377 ARRAY_SIZE(mdp_bus_scale_usecases),
9378 .name = "mdp",
9379};
9380
9381#endif
9382#ifdef CONFIG_MSM_BUS_SCALING
9383static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9384 /* For now, 0th array entry is reserved.
9385 * Please leave 0 as is and don't use it
9386 */
9387 {
9388 .src = MSM_BUS_MASTER_MDP_PORT0,
9389 .dst = MSM_BUS_SLAVE_SMI,
9390 .ab = 0,
9391 .ib = 0,
9392 },
9393 /* Master and slaves can be from different fabrics */
9394 {
9395 .src = MSM_BUS_MASTER_MDP_PORT0,
9396 .dst = MSM_BUS_SLAVE_EBI_CH0,
9397 .ab = 0,
9398 .ib = 0,
9399 },
9400};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009401
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009402static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9403 /* For now, 0th array entry is reserved.
9404 * Please leave 0 as is and don't use it
9405 */
9406 {
9407 .src = MSM_BUS_MASTER_MDP_PORT0,
9408 .dst = MSM_BUS_SLAVE_SMI,
9409 .ab = 566092800,
9410 .ib = 707616000,
9411 },
9412 /* Master and slaves can be from different fabrics */
9413 {
9414 .src = MSM_BUS_MASTER_MDP_PORT0,
9415 .dst = MSM_BUS_SLAVE_EBI_CH0,
9416 .ab = 566092800,
9417 .ib = 707616000,
9418 },
9419};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009420
9421static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9422 /* For now, 0th array entry is reserved.
9423 * Please leave 0 as is and don't use it
9424 */
9425 {
9426 .src = MSM_BUS_MASTER_MDP_PORT0,
9427 .dst = MSM_BUS_SLAVE_SMI,
9428 .ab = 2000000000,
9429 .ib = 2000000000,
9430 },
9431 /* Master and slaves can be from different fabrics */
9432 {
9433 .src = MSM_BUS_MASTER_MDP_PORT0,
9434 .dst = MSM_BUS_SLAVE_EBI_CH0,
9435 .ab = 2000000000,
9436 .ib = 2000000000,
9437 },
9438};
9439
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009440static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9441 {
9442 ARRAY_SIZE(dtv_bus_init_vectors),
9443 dtv_bus_init_vectors,
9444 },
9445 {
9446 ARRAY_SIZE(dtv_bus_def_vectors),
9447 dtv_bus_def_vectors,
9448 },
9449};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009450
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009451static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9452 dtv_bus_scale_usecases,
9453 ARRAY_SIZE(dtv_bus_scale_usecases),
9454 .name = "dtv",
9455};
9456
9457static struct lcdc_platform_data dtv_pdata = {
9458 .bus_scale_table = &dtv_bus_scale_pdata,
9459};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009460
9461static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9462 {
9463 ARRAY_SIZE(dtv_bus_init_vectors),
9464 dtv_bus_init_vectors,
9465 },
9466 {
9467 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9468 dtv_bus_hdmi_prim_vectors,
9469 },
9470};
9471
9472static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9473 dtv_hdmi_prim_bus_scale_usecases,
9474 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9475 .name = "dtv",
9476};
9477
9478static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9479 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9480};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009481#endif
9482
9483
9484static struct lcdc_platform_data lcdc_pdata = {
9485 .lcdc_power_save = lcdc_panel_power,
9486};
9487
9488
9489#define MDP_VSYNC_GPIO 28
9490
9491/*
9492 * MIPI_DSI only use 8058_LDO0 which need always on
9493 * therefore it need to be put at low power mode if
9494 * it was not used instead of turn it off.
9495 */
9496static int mipi_dsi_panel_power(int on)
9497{
9498 int flag_on = !!on;
9499 static int mipi_dsi_power_save_on;
9500 static struct regulator *ldo0;
9501 int rc = 0;
9502
9503 if (mipi_dsi_power_save_on == flag_on)
9504 return 0;
9505
9506 mipi_dsi_power_save_on = flag_on;
9507
9508 if (ldo0 == NULL) { /* init */
9509 ldo0 = regulator_get(NULL, "8058_l0");
9510 if (IS_ERR(ldo0)) {
9511 pr_debug("%s: LDO0 failed\n", __func__);
9512 rc = PTR_ERR(ldo0);
9513 return rc;
9514 }
9515
9516 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9517 if (rc)
9518 goto out;
9519
9520 rc = regulator_enable(ldo0);
9521 if (rc)
9522 goto out;
9523 }
9524
9525 if (on) {
9526 /* set ldo0 to HPM */
9527 rc = regulator_set_optimum_mode(ldo0, 100000);
9528 if (rc < 0)
9529 goto out;
9530 } else {
9531 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309532 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009533 if (rc < 0)
9534 goto out;
9535 }
9536
9537 return 0;
9538out:
9539 regulator_disable(ldo0);
9540 regulator_put(ldo0);
9541 ldo0 = NULL;
9542 return rc;
9543}
9544
9545static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9546 .vsync_gpio = MDP_VSYNC_GPIO,
9547 .dsi_power_save = mipi_dsi_panel_power,
9548};
9549
9550#ifdef CONFIG_FB_MSM_TVOUT
9551static struct regulator *reg_8058_l13;
9552
9553static int atv_dac_power(int on)
9554{
9555 int rc = 0;
9556 #define _GET_REGULATOR(var, name) do { \
9557 var = regulator_get(NULL, name); \
9558 if (IS_ERR(var)) { \
9559 pr_info("'%s' regulator not found, rc=%ld\n", \
9560 name, IS_ERR(var)); \
9561 var = NULL; \
9562 return -ENODEV; \
9563 } \
9564 } while (0)
9565
9566 if (!reg_8058_l13)
9567 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9568 #undef _GET_REGULATOR
9569
9570 if (on) {
9571 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9572 if (rc) {
9573 pr_info("%s: '%s' regulator set voltage failed,\
9574 rc=%d\n", __func__, "8058_l13", rc);
9575 return rc;
9576 }
9577
9578 rc = regulator_enable(reg_8058_l13);
9579 if (rc) {
9580 pr_err("%s: '%s' regulator enable failed,\
9581 rc=%d\n", __func__, "8058_l13", rc);
9582 return rc;
9583 }
9584 } else {
9585 rc = regulator_force_disable(reg_8058_l13);
9586 if (rc)
9587 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9588 __func__, "8058_l13", rc);
9589 }
9590 return rc;
9591
9592}
9593#endif
9594
9595#ifdef CONFIG_FB_MSM_MIPI_DSI
9596int mdp_core_clk_rate_table[] = {
9597 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009598 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009599 160000000,
9600 200000000,
9601};
9602#else
9603int mdp_core_clk_rate_table[] = {
9604 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009605 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009606 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009607 200000000,
9608};
9609#endif
9610
9611static struct msm_panel_common_pdata mdp_pdata = {
9612 .gpio = MDP_VSYNC_GPIO,
9613 .mdp_core_clk_rate = 59080000,
9614 .mdp_core_clk_table = mdp_core_clk_rate_table,
9615 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9616#ifdef CONFIG_MSM_BUS_SCALING
9617 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9618#endif
9619 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009620#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009621 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009622#else
9623 .mem_hid = MEMTYPE_EBI1,
9624#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009625};
9626
Huaibin Yanga5419422011-12-08 23:52:10 -08009627static void __init reserve_mdp_memory(void)
9628{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009629 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9630 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9631#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9632 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9633 mdp_pdata.ov0_wb_size;
9634 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9635 mdp_pdata.ov1_wb_size;
9636#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009637}
9638
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009639#ifdef CONFIG_FB_MSM_TVOUT
9640
9641#ifdef CONFIG_MSM_BUS_SCALING
9642static struct msm_bus_vectors atv_bus_init_vectors[] = {
9643 /* For now, 0th array entry is reserved.
9644 * Please leave 0 as is and don't use it
9645 */
9646 {
9647 .src = MSM_BUS_MASTER_MDP_PORT0,
9648 .dst = MSM_BUS_SLAVE_SMI,
9649 .ab = 0,
9650 .ib = 0,
9651 },
9652 /* Master and slaves can be from different fabrics */
9653 {
9654 .src = MSM_BUS_MASTER_MDP_PORT0,
9655 .dst = MSM_BUS_SLAVE_EBI_CH0,
9656 .ab = 0,
9657 .ib = 0,
9658 },
9659};
9660static struct msm_bus_vectors atv_bus_def_vectors[] = {
9661 /* For now, 0th array entry is reserved.
9662 * Please leave 0 as is and don't use it
9663 */
9664 {
9665 .src = MSM_BUS_MASTER_MDP_PORT0,
9666 .dst = MSM_BUS_SLAVE_SMI,
9667 .ab = 236390400,
9668 .ib = 265939200,
9669 },
9670 /* Master and slaves can be from different fabrics */
9671 {
9672 .src = MSM_BUS_MASTER_MDP_PORT0,
9673 .dst = MSM_BUS_SLAVE_EBI_CH0,
9674 .ab = 236390400,
9675 .ib = 265939200,
9676 },
9677};
9678static struct msm_bus_paths atv_bus_scale_usecases[] = {
9679 {
9680 ARRAY_SIZE(atv_bus_init_vectors),
9681 atv_bus_init_vectors,
9682 },
9683 {
9684 ARRAY_SIZE(atv_bus_def_vectors),
9685 atv_bus_def_vectors,
9686 },
9687};
9688static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9689 atv_bus_scale_usecases,
9690 ARRAY_SIZE(atv_bus_scale_usecases),
9691 .name = "atv",
9692};
9693#endif
9694
9695static struct tvenc_platform_data atv_pdata = {
9696 .poll = 0,
9697 .pm_vid_en = atv_dac_power,
9698#ifdef CONFIG_MSM_BUS_SCALING
9699 .bus_scale_table = &atv_bus_scale_pdata,
9700#endif
9701};
9702#endif
9703
9704static void __init msm_fb_add_devices(void)
9705{
9706#ifdef CONFIG_FB_MSM_LCDC_DSUB
9707 mdp_pdata.mdp_core_clk_table = NULL;
9708 mdp_pdata.num_mdp_clk = 0;
9709 mdp_pdata.mdp_core_clk_rate = 200000000;
9710#endif
9711 if (machine_is_msm8x60_rumi3())
9712 msm_fb_register_device("mdp", NULL);
9713 else
9714 msm_fb_register_device("mdp", &mdp_pdata);
9715
9716 msm_fb_register_device("lcdc", &lcdc_pdata);
9717 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9718#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009719 if (hdmi_is_primary)
9720 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9721 else
9722 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009723#endif
9724#ifdef CONFIG_FB_MSM_TVOUT
9725 msm_fb_register_device("tvenc", &atv_pdata);
9726 msm_fb_register_device("tvout_device", NULL);
9727#endif
9728}
9729
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009730/**
9731 * Set MDP clocks to high frequency to avoid underflow when
9732 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9733 */
9734static void set_mdp_clocks_for_wuxga(void)
9735{
9736 int i;
9737
9738 mdp_sd_smi_vectors[0].ab = 2000000000;
9739 mdp_sd_smi_vectors[0].ib = 2000000000;
9740 mdp_sd_smi_vectors[1].ab = 2000000000;
9741 mdp_sd_smi_vectors[1].ib = 2000000000;
9742
9743 mdp_sd_ebi_vectors[0].ab = 2000000000;
9744 mdp_sd_ebi_vectors[0].ib = 2000000000;
9745 mdp_sd_ebi_vectors[1].ab = 2000000000;
9746 mdp_sd_ebi_vectors[1].ib = 2000000000;
9747
9748 mdp_vga_vectors[0].ab = 2000000000;
9749 mdp_vga_vectors[0].ib = 2000000000;
9750 mdp_vga_vectors[1].ab = 2000000000;
9751 mdp_vga_vectors[1].ib = 2000000000;
9752
9753 mdp_720p_vectors[0].ab = 2000000000;
9754 mdp_720p_vectors[0].ib = 2000000000;
9755 mdp_720p_vectors[1].ab = 2000000000;
9756 mdp_720p_vectors[1].ib = 2000000000;
9757
9758 mdp_1080p_vectors[0].ab = 2000000000;
9759 mdp_1080p_vectors[0].ib = 2000000000;
9760 mdp_1080p_vectors[1].ab = 2000000000;
9761 mdp_1080p_vectors[1].ib = 2000000000;
9762
9763 mdp_pdata.mdp_core_clk_rate = 200000000;
9764
9765 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9766 mdp_core_clk_rate_table[i] = 200000000;
9767}
9768
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009769#if (defined(CONFIG_MARIMBA_CORE)) && \
9770 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9771
9772static const struct {
9773 char *name;
9774 int vmin;
9775 int vmax;
9776} bt_regs_info[] = {
9777 { "8058_s3", 1800000, 1800000 },
9778 { "8058_s2", 1300000, 1300000 },
9779 { "8058_l8", 2900000, 3050000 },
9780};
9781
9782static struct {
9783 bool enabled;
9784} bt_regs_status[] = {
9785 { false },
9786 { false },
9787 { false },
9788};
9789static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9790
9791static int bahama_bt(int on)
9792{
9793 int rc;
9794 int i;
9795 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9796
9797 struct bahama_variant_register {
9798 const size_t size;
9799 const struct bahama_config_register *set;
9800 };
9801
9802 const struct bahama_config_register *p;
9803
9804 u8 version;
9805
9806 const struct bahama_config_register v10_bt_on[] = {
9807 { 0xE9, 0x00, 0xFF },
9808 { 0xF4, 0x80, 0xFF },
9809 { 0xE4, 0x00, 0xFF },
9810 { 0xE5, 0x00, 0x0F },
9811#ifdef CONFIG_WLAN
9812 { 0xE6, 0x38, 0x7F },
9813 { 0xE7, 0x06, 0xFF },
9814#endif
9815 { 0xE9, 0x21, 0xFF },
9816 { 0x01, 0x0C, 0x1F },
9817 { 0x01, 0x08, 0x1F },
9818 };
9819
9820 const struct bahama_config_register v20_bt_on_fm_off[] = {
9821 { 0x11, 0x0C, 0xFF },
9822 { 0x13, 0x01, 0xFF },
9823 { 0xF4, 0x80, 0xFF },
9824 { 0xF0, 0x00, 0xFF },
9825 { 0xE9, 0x00, 0xFF },
9826#ifdef CONFIG_WLAN
9827 { 0x81, 0x00, 0x7F },
9828 { 0x82, 0x00, 0xFF },
9829 { 0xE6, 0x38, 0x7F },
9830 { 0xE7, 0x06, 0xFF },
9831#endif
9832 { 0xE9, 0x21, 0xFF },
9833 };
9834
9835 const struct bahama_config_register v20_bt_on_fm_on[] = {
9836 { 0x11, 0x0C, 0xFF },
9837 { 0x13, 0x01, 0xFF },
9838 { 0xF4, 0x86, 0xFF },
9839 { 0xF0, 0x06, 0xFF },
9840 { 0xE9, 0x00, 0xFF },
9841#ifdef CONFIG_WLAN
9842 { 0x81, 0x00, 0x7F },
9843 { 0x82, 0x00, 0xFF },
9844 { 0xE6, 0x38, 0x7F },
9845 { 0xE7, 0x06, 0xFF },
9846#endif
9847 { 0xE9, 0x21, 0xFF },
9848 };
9849
9850 const struct bahama_config_register v10_bt_off[] = {
9851 { 0xE9, 0x00, 0xFF },
9852 };
9853
9854 const struct bahama_config_register v20_bt_off_fm_off[] = {
9855 { 0xF4, 0x84, 0xFF },
9856 { 0xF0, 0x04, 0xFF },
9857 { 0xE9, 0x00, 0xFF }
9858 };
9859
9860 const struct bahama_config_register v20_bt_off_fm_on[] = {
9861 { 0xF4, 0x86, 0xFF },
9862 { 0xF0, 0x06, 0xFF },
9863 { 0xE9, 0x00, 0xFF }
9864 };
9865 const struct bahama_variant_register bt_bahama[2][3] = {
9866 {
9867 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9868 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9869 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9870 },
9871 {
9872 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9873 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9874 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9875 }
9876 };
9877
9878 u8 offset = 0; /* index into bahama configs */
9879
9880 on = on ? 1 : 0;
9881 version = read_bahama_ver();
9882
9883 if (version == VER_UNSUPPORTED) {
9884 dev_err(&msm_bt_power_device.dev,
9885 "%s: unsupported version\n",
9886 __func__);
9887 return -EIO;
9888 }
9889
9890 if (version == VER_2_0) {
9891 if (marimba_get_fm_status(&config))
9892 offset = 0x01;
9893 }
9894
9895 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9896 if (on && (version == VER_2_0)) {
9897 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9898 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9899 && (bt_regs_status[i].enabled == true)) {
9900 if (regulator_disable(bt_regs[i])) {
9901 dev_err(&msm_bt_power_device.dev,
9902 "%s: regulator disable failed",
9903 __func__);
9904 }
9905 bt_regs_status[i].enabled = false;
9906 break;
9907 }
9908 }
9909 }
9910
9911 p = bt_bahama[on][version + offset].set;
9912
9913 dev_info(&msm_bt_power_device.dev,
9914 "%s: found version %d\n", __func__, version);
9915
9916 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9917 u8 value = (p+i)->value;
9918 rc = marimba_write_bit_mask(&config,
9919 (p+i)->reg,
9920 &value,
9921 sizeof((p+i)->value),
9922 (p+i)->mask);
9923 if (rc < 0) {
9924 dev_err(&msm_bt_power_device.dev,
9925 "%s: reg %d write failed: %d\n",
9926 __func__, (p+i)->reg, rc);
9927 return rc;
9928 }
9929 dev_dbg(&msm_bt_power_device.dev,
9930 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9931 __func__, (p+i)->reg,
9932 value, (p+i)->mask);
9933 }
9934 /* Update BT Status */
9935 if (on)
9936 marimba_set_bt_status(&config, true);
9937 else
9938 marimba_set_bt_status(&config, false);
9939
9940 return 0;
9941}
9942
9943static int bluetooth_use_regulators(int on)
9944{
9945 int i, recover = -1, rc = 0;
9946
9947 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9948 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9949 bt_regs_info[i].name) :
9950 (regulator_put(bt_regs[i]), NULL);
9951 if (IS_ERR(bt_regs[i])) {
9952 rc = PTR_ERR(bt_regs[i]);
9953 dev_err(&msm_bt_power_device.dev,
9954 "regulator %s get failed (%d)\n",
9955 bt_regs_info[i].name, rc);
9956 recover = i - 1;
9957 bt_regs[i] = NULL;
9958 break;
9959 }
9960
9961 if (!on)
9962 continue;
9963
9964 rc = regulator_set_voltage(bt_regs[i],
9965 bt_regs_info[i].vmin,
9966 bt_regs_info[i].vmax);
9967 if (rc < 0) {
9968 dev_err(&msm_bt_power_device.dev,
9969 "regulator %s voltage set (%d)\n",
9970 bt_regs_info[i].name, rc);
9971 recover = i;
9972 break;
9973 }
9974 }
9975
9976 if (on && (recover > -1))
9977 for (i = recover; i >= 0; i--) {
9978 regulator_put(bt_regs[i]);
9979 bt_regs[i] = NULL;
9980 }
9981
9982 return rc;
9983}
9984
9985static int bluetooth_switch_regulators(int on)
9986{
9987 int i, rc = 0;
9988
9989 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9990 if (on && (bt_regs_status[i].enabled == false)) {
9991 rc = regulator_enable(bt_regs[i]);
9992 if (rc < 0) {
9993 dev_err(&msm_bt_power_device.dev,
9994 "regulator %s %s failed (%d)\n",
9995 bt_regs_info[i].name,
9996 "enable", rc);
9997 if (i > 0) {
9998 while (--i) {
9999 regulator_disable(bt_regs[i]);
10000 bt_regs_status[i].enabled
10001 = false;
10002 }
10003 break;
10004 }
10005 }
10006 bt_regs_status[i].enabled = true;
10007 } else if (!on && (bt_regs_status[i].enabled == true)) {
10008 rc = regulator_disable(bt_regs[i]);
10009 if (rc < 0) {
10010 dev_err(&msm_bt_power_device.dev,
10011 "regulator %s %s failed (%d)\n",
10012 bt_regs_info[i].name,
10013 "disable", rc);
10014 break;
10015 }
10016 bt_regs_status[i].enabled = false;
10017 }
10018 }
10019 return rc;
10020}
10021
10022static struct msm_xo_voter *bt_clock;
10023
10024static int bluetooth_power(int on)
10025{
10026 int rc = 0;
10027 int id;
10028
10029 /* In case probe function fails, cur_connv_type would be -1 */
10030 id = adie_get_detected_connectivity_type();
10031 if (id != BAHAMA_ID) {
10032 pr_err("%s: unexpected adie connectivity type: %d\n",
10033 __func__, id);
10034 return -ENODEV;
10035 }
10036
10037 if (on) {
10038
10039 rc = bluetooth_use_regulators(1);
10040 if (rc < 0)
10041 goto out;
10042
10043 rc = bluetooth_switch_regulators(1);
10044
10045 if (rc < 0)
10046 goto fail_put;
10047
10048 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10049
10050 if (IS_ERR(bt_clock)) {
10051 pr_err("Couldn't get TCXO_D0 voter\n");
10052 goto fail_switch;
10053 }
10054
10055 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10056
10057 if (rc < 0) {
10058 pr_err("Failed to vote for TCXO_DO ON\n");
10059 goto fail_vote;
10060 }
10061
10062 rc = bahama_bt(1);
10063
10064 if (rc < 0)
10065 goto fail_clock;
10066
10067 msleep(10);
10068
10069 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10070
10071 if (rc < 0) {
10072 pr_err("Failed to vote for TCXO_DO pin control\n");
10073 goto fail_vote;
10074 }
10075 } else {
10076 /* check for initial RFKILL block (power off) */
10077 /* some RFKILL versions/configurations rfkill_register */
10078 /* calls here for an initial set_block */
10079 /* avoid calling i2c and regulator before unblock (on) */
10080 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10081 dev_info(&msm_bt_power_device.dev,
10082 "%s: initialized OFF/blocked\n", __func__);
10083 goto out;
10084 }
10085
10086 bahama_bt(0);
10087
10088fail_clock:
10089 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10090fail_vote:
10091 msm_xo_put(bt_clock);
10092fail_switch:
10093 bluetooth_switch_regulators(0);
10094fail_put:
10095 bluetooth_use_regulators(0);
10096 }
10097
10098out:
10099 if (rc < 0)
10100 on = 0;
10101 dev_info(&msm_bt_power_device.dev,
10102 "Bluetooth power switch: state %d result %d\n", on, rc);
10103
10104 return rc;
10105}
10106
10107#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10108
10109static void __init msm8x60_cfg_smsc911x(void)
10110{
10111 smsc911x_resources[1].start =
10112 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10113 smsc911x_resources[1].end =
10114 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10115}
10116
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010117void msm_fusion_setup_pinctrl(void)
10118{
10119 struct msm_xo_voter *a1;
10120
10121 if (socinfo_get_platform_subtype() == 0x3) {
10122 /*
10123 * Vote for the A1 clock to be in pin control mode before
10124 * the external images are loaded.
10125 */
10126 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10127 BUG_ON(!a1);
10128 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10129 }
10130}
10131
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010132struct msm_board_data {
10133 struct msm_gpiomux_configs *gpiomux_cfgs;
10134};
10135
10136static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10137 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10138};
10139
10140static struct msm_board_data msm8x60_sim_board_data __initdata = {
10141 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10142};
10143
10144static struct msm_board_data msm8x60_surf_board_data __initdata = {
10145 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10146};
10147
10148static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10149 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10150};
10151
10152static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10153 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10154};
10155
10156static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10157 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10158};
10159
10160static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10161 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10162};
10163
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010164static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10165 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10166};
10167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010168static void __init msm8x60_init(struct msm_board_data *board_data)
10169{
10170 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010171#ifdef CONFIG_USB_EHCI_MSM_72K
10172 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10173 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10174 .level = PM8901_MPP_DIG_LEVEL_L5,
10175 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10176 };
10177#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010178 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010179
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010180 /*
10181 * Initialize RPM first as other drivers and devices may need
10182 * it for their initialization.
10183 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010184 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10185 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010186 if (msm_xo_init())
10187 pr_err("Failed to initialize XO votes\n");
10188
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010189 msm8x60_check_2d_hardware();
10190
10191 /* Change SPM handling of core 1 if PMM 8160 is present. */
10192 soc_platform_version = socinfo_get_platform_version();
10193 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10194 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10195 struct msm_spm_platform_data *spm_data;
10196
10197 spm_data = &msm_spm_data_v1[1];
10198 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10199 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10200
10201 spm_data = &msm_spm_data[1];
10202 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10203 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10204 }
10205
10206 /*
10207 * Initialize SPM before acpuclock as the latter calls into SPM
10208 * driver to set ACPU voltages.
10209 */
10210 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10211 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10212 else
10213 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10214
10215 /*
10216 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10217 * devices so that the RPM doesn't drop into a low power mode that an
10218 * un-reworked SURF cannot resume from.
10219 */
10220 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010221 int i;
10222
10223 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10224 if (rpm_regulator_init_data[i].id
10225 == RPM_VREG_ID_PM8901_L4
10226 || rpm_regulator_init_data[i].id
10227 == RPM_VREG_ID_PM8901_L6)
10228 rpm_regulator_init_data[i]
10229 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010230 }
10231
10232 /*
10233 * Disable regulator info printing so that regulator registration
10234 * messages do not enter the kmsg log.
10235 */
10236 regulator_suppress_info_printing();
10237
10238 /* Initialize regulators needed for clock_init. */
10239 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10240
Stephen Boydbb600ae2011-08-02 20:11:40 -070010241 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010242
10243 /* Buses need to be initialized before early-device registration
10244 * to get the platform data for fabrics.
10245 */
10246 msm8x60_init_buses();
10247 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10248 /* CPU frequency control is not supported on simulated targets. */
10249 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010250 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010251
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010252 /*
10253 * Enable EBI2 only for boards which make use of it. Leave
10254 * it disabled for all others for additional power savings.
10255 */
10256 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10257 machine_is_msm8x60_rumi3() ||
10258 machine_is_msm8x60_sim() ||
10259 machine_is_msm8x60_fluid() ||
10260 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010261 msm8x60_init_ebi2();
10262 msm8x60_init_tlmm();
10263 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10264 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010265#ifdef CONFIG_MSM_CAMERA_V4L2
10266 msm8x60_init_cam();
10267#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010268 msm8x60_init_mmc();
10269
Kevin Chan3be11612012-03-22 20:05:40 -070010270
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010271#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10272 msm8x60_init_pm8058_othc();
10273#endif
10274
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010275 if (machine_is_msm8x60_fluid())
10276 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10277 else if (machine_is_msm8x60_dragon())
10278 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10279 else
10280 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Kevin Chan3be11612012-03-22 20:05:40 -070010281#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang53d27a82011-07-13 14:32:58 -040010282 /* Specify reset pin for OV9726 */
10283 if (machine_is_msm8x60_dragon()) {
10284 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10285 ov9726_sensor_8660_info.mount_angle = 270;
10286 }
Kevin Chan3be11612012-03-22 20:05:40 -070010287#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010288#ifdef CONFIG_BATTERY_MSM8X60
10289 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10290 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10291 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10292 platform_device_register(&msm_charger_device);
10293#endif
10294
10295 if (machine_is_msm8x60_dragon())
10296 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10297 if (!machine_is_msm8x60_fluid())
10298 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10299
10300 /* configure pmic leds */
10301 if (machine_is_msm8x60_fluid())
10302 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10303 else if (machine_is_msm8x60_dragon())
10304 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10305 else
10306 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10307
10308 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10309 machine_is_msm8x60_dragon()) {
10310 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10311 }
10312
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010313 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10314 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010315 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010316 msm8x60_cfg_smsc911x();
10317 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10318 platform_add_devices(msm_footswitch_devices,
10319 msm_num_footswitch_devices);
10320 platform_add_devices(surf_devices,
10321 ARRAY_SIZE(surf_devices));
10322
10323#ifdef CONFIG_MSM_DSPS
10324 if (machine_is_msm8x60_fluid()) {
10325 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10326 msm8x60_init_dsps();
10327 }
10328#endif
10329
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010330 pm8901_vreg_mpp0_init();
10331
10332 platform_device_register(&msm8x60_8901_mpp_vreg);
10333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010334#ifdef CONFIG_USB_EHCI_MSM_72K
10335 /*
10336 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10337 * fluid
10338 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010339 if (machine_is_msm8x60_fluid())
10340 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10341 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010342#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010343
10344#ifdef CONFIG_SND_SOC_MSM8660_APQ
10345 if (machine_is_msm8x60_dragon())
10346 platform_add_devices(dragon_alsa_devices,
10347 ARRAY_SIZE(dragon_alsa_devices));
10348 else
10349#endif
10350 platform_add_devices(asoc_devices,
10351 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010352 } else {
10353 msm8x60_configure_smc91x();
10354 platform_add_devices(rumi_sim_devices,
10355 ARRAY_SIZE(rumi_sim_devices));
10356 }
10357#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010358 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10359 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010360 msm8x60_cfg_isp1763();
10361#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010362
10363 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10364 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010366
10367#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10368 if (machine_is_msm8x60_fluid())
10369 platform_device_register(&msm_gsbi10_qup_spi_device);
10370 else
10371 platform_device_register(&msm_gsbi1_qup_spi_device);
10372#endif
10373
10374#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10375 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10376 if (machine_is_msm8x60_fluid())
10377 cyttsp_set_params();
10378#endif
10379 if (!machine_is_msm8x60_sim())
10380 msm_fb_add_devices();
10381 fixup_i2c_configs();
10382 register_i2c_devices();
10383
Terence Hampson1c73fef2011-07-19 17:10:49 -040010384 if (machine_is_msm8x60_dragon())
10385 smsc911x_config.reset_gpio
10386 = GPIO_ETHERNET_RESET_N_DRAGON;
10387
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010388 platform_device_register(&smsc911x_device);
10389
10390#if (defined(CONFIG_SPI_QUP)) && \
10391 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010392 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10393 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010394
10395 if (machine_is_msm8x60_fluid()) {
10396#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10397 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10398 spi_register_board_info(lcdc_samsung_spi_board_info,
10399 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10400 } else
10401#endif
10402 {
10403#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10404 spi_register_board_info(lcdc_auo_spi_board_info,
10405 ARRAY_SIZE(lcdc_auo_spi_board_info));
10406#endif
10407 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010408#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10409 } else if (machine_is_msm8x60_dragon()) {
10410 spi_register_board_info(lcdc_nt35582_spi_board_info,
10411 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10412#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010413 }
10414#endif
10415
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010416 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010417
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010418 pm8058_gpios_init();
10419
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010420#ifdef CONFIG_SENSORS_MSM_ADC
10421 if (machine_is_msm8x60_fluid()) {
10422 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10423 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10424 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10425 msm_adc_pdata.gpio_config = APROC_CONFIG;
10426 else
10427 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10428 }
10429 msm_adc_pdata.target_hw = MSM_8x60;
10430#endif
10431#ifdef CONFIG_MSM8X60_AUDIO
10432 msm_snddev_init();
10433#endif
10434#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10435 if (machine_is_msm8x60_fluid())
10436 platform_device_register(&fluid_leds_gpio);
10437 else
10438 platform_device_register(&gpio_leds);
10439#endif
10440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010441 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010442
10443 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10444 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010445}
10446
10447static void __init msm8x60_rumi3_init(void)
10448{
10449 msm8x60_init(&msm8x60_rumi3_board_data);
10450}
10451
10452static void __init msm8x60_sim_init(void)
10453{
10454 msm8x60_init(&msm8x60_sim_board_data);
10455}
10456
10457static void __init msm8x60_surf_init(void)
10458{
10459 msm8x60_init(&msm8x60_surf_board_data);
10460}
10461
10462static void __init msm8x60_ffa_init(void)
10463{
10464 msm8x60_init(&msm8x60_ffa_board_data);
10465}
10466
10467static void __init msm8x60_fluid_init(void)
10468{
10469 msm8x60_init(&msm8x60_fluid_board_data);
10470}
10471
10472static void __init msm8x60_charm_surf_init(void)
10473{
10474 msm8x60_init(&msm8x60_charm_surf_board_data);
10475}
10476
10477static void __init msm8x60_charm_ffa_init(void)
10478{
10479 msm8x60_init(&msm8x60_charm_ffa_board_data);
10480}
10481
10482static void __init msm8x60_charm_init_early(void)
10483{
10484 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010485}
10486
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010487static void __init msm8x60_dragon_init(void)
10488{
10489 msm8x60_init(&msm8x60_dragon_board_data);
10490}
10491
Steve Mucklea55df6e2010-01-07 12:43:24 -080010492MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10493 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010494 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010495 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010496 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010497 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010498 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010499 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010500MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010501
10502MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10503 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010504 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010505 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010506 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010507 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010508 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010509 .init_early = msm8x60_charm_init_early,
10510MACHINE_END
10511
10512MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10513 .map_io = msm8x60_map_io,
10514 .reserve = msm8x60_reserve,
10515 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010516 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010517 .init_machine = msm8x60_surf_init,
10518 .timer = &msm_timer,
10519 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010520MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010521
10522MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10523 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010524 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010525 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010526 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010527 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010528 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010529 .init_early = msm8x60_charm_init_early,
10530MACHINE_END
10531
10532MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10533 .map_io = msm8x60_map_io,
10534 .reserve = msm8x60_reserve,
10535 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010536 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010537 .init_machine = msm8x60_fluid_init,
10538 .timer = &msm_timer,
10539 .init_early = msm8x60_charm_init_early,
10540MACHINE_END
10541
10542MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10543 .map_io = msm8x60_map_io,
10544 .reserve = msm8x60_reserve,
10545 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010546 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010547 .init_machine = msm8x60_charm_surf_init,
10548 .timer = &msm_timer,
10549 .init_early = msm8x60_charm_init_early,
10550MACHINE_END
10551
10552MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10553 .map_io = msm8x60_map_io,
10554 .reserve = msm8x60_reserve,
10555 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010556 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010557 .init_machine = msm8x60_charm_ffa_init,
10558 .timer = &msm_timer,
10559 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010560MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010561
10562MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10563 .map_io = msm8x60_map_io,
10564 .reserve = msm8x60_reserve,
10565 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010566 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010567 .init_machine = msm8x60_dragon_init,
10568 .timer = &msm_timer,
10569 .init_early = msm8x60_charm_init_early,
10570MACHINE_END