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