blob: 50b1ac564c52b329244a6d56448fd910b23d67e4 [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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070025#include <linux/regulator/msm-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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070038#include <linux/cyttsp-qc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039#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>
Stephen Boyd9e775ad2011-08-12 00:14:28 +010055#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"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600103#include "pm-boot.h"
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530104#include "board-storage-common-a.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700105
106#include <linux/ion.h>
107#include <mach/ion.h>
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +0530108#include <mach/msm_rtb.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700109
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111#define MDM2AP_SYNC 129
112
Terence Hampson1c73fef2011-07-19 17:10:49 -0400113#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define LCDC_SPI_GPIO_CLK 73
115#define LCDC_SPI_GPIO_CS 72
116#define LCDC_SPI_GPIO_MOSI 70
117#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
118#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
119#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
120#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
121#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400122#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700123
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700124#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
125#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
126#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
127#define HDMI_PANEL_NAME "hdmi_msm"
128#define TVOUT_PANEL_NAME "tvout_msm"
129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700130#define DSPS_PIL_GENERIC_NAME "dsps"
131#define DSPS_PIL_FLUID_NAME "dsps_fluid"
132
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800133#ifdef CONFIG_ION_MSM
134static struct platform_device ion_dev;
135#endif
136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700137enum {
138 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530139 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700140 /* CORE expander */
141 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
142 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
143 GPIO_WLAN_DEEP_SLEEP_N,
144 GPIO_LVDS_SHUTDOWN_N,
145 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
146 GPIO_MS_SYS_RESET_N,
147 GPIO_CAP_TS_RESOUT_N,
148 GPIO_CAP_GAUGE_BI_TOUT,
149 GPIO_ETHERNET_PME,
150 GPIO_EXT_GPS_LNA_EN,
151 GPIO_MSM_WAKES_BT,
152 GPIO_ETHERNET_RESET_N,
153 GPIO_HEADSET_DET_N,
154 GPIO_USB_UICC_EN,
155 GPIO_BACKLIGHT_EN,
156 GPIO_EXT_CAMIF_PWR_EN,
157 GPIO_BATT_GAUGE_INT_N,
158 GPIO_BATT_GAUGE_EN,
159 /* DOCKING expander */
160 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
161 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
162 GPIO_AUX_JTAG_DET_N,
163 GPIO_DONGLE_DET_N,
164 GPIO_SVIDEO_LOAD_DET,
165 GPIO_SVID_AMP_SHUTDOWN1_N,
166 GPIO_SVID_AMP_SHUTDOWN0_N,
167 GPIO_SDC_WP,
168 GPIO_IRDA_PWDN,
169 GPIO_IRDA_RESET_N,
170 GPIO_DONGLE_GPIO0,
171 GPIO_DONGLE_GPIO1,
172 GPIO_DONGLE_GPIO2,
173 GPIO_DONGLE_GPIO3,
174 GPIO_DONGLE_PWR_EN,
175 GPIO_EMMC_RESET_N,
176 GPIO_TP_EXP2_IO15,
177 /* SURF expander */
178 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
179 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
180 GPIO_SD_CARD_DET_2,
181 GPIO_SD_CARD_DET_4,
182 GPIO_SD_CARD_DET_5,
183 GPIO_UIM3_RST,
184 GPIO_SURF_EXPANDER_IO5,
185 GPIO_SURF_EXPANDER_IO6,
186 GPIO_ADC_I2C_EN,
187 GPIO_SURF_EXPANDER_IO8,
188 GPIO_SURF_EXPANDER_IO9,
189 GPIO_SURF_EXPANDER_IO10,
190 GPIO_SURF_EXPANDER_IO11,
191 GPIO_SURF_EXPANDER_IO12,
192 GPIO_SURF_EXPANDER_IO13,
193 GPIO_SURF_EXPANDER_IO14,
194 GPIO_SURF_EXPANDER_IO15,
195 /* LEFT KB IO expander */
196 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
197 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
198 GPIO_LEFT_LED_2,
199 GPIO_LEFT_LED_3,
200 GPIO_LEFT_LED_WLAN,
201 GPIO_JOYSTICK_EN,
202 GPIO_CAP_TS_SLEEP,
203 GPIO_LEFT_KB_IO6,
204 GPIO_LEFT_LED_5,
205 /* RIGHT KB IO expander */
206 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
207 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
208 GPIO_RIGHT_LED_2,
209 GPIO_RIGHT_LED_3,
210 GPIO_RIGHT_LED_BT,
211 GPIO_WEB_CAMIF_STANDBY,
212 GPIO_COMPASS_RST_N,
213 GPIO_WEB_CAMIF_RESET_N,
214 GPIO_RIGHT_LED_5,
215 GPIO_R_ALTIMETER_RESET_N,
216 /* FLUID S IO expander */
217 GPIO_SOUTH_EXPANDER_BASE,
218 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
219 GPIO_MIC1_ANCL_SEL,
220 GPIO_HS_MIC4_SEL,
221 GPIO_FML_MIC3_SEL,
222 GPIO_FMR_MIC5_SEL,
223 GPIO_TS_SLEEP,
224 GPIO_HAP_SHIFT_LVL_OE,
225 GPIO_HS_SW_DIR,
226 /* FLUID N IO expander */
227 GPIO_NORTH_EXPANDER_BASE,
228 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
229 GPIO_EPM_5V_BOOST_EN,
230 GPIO_AUX_CAM_2P7_EN,
231 GPIO_LED_FLASH_EN,
232 GPIO_LED1_GREEN_N,
233 GPIO_LED2_RED_N,
234 GPIO_FRONT_CAM_RESET_N,
235 GPIO_EPM_LVLSFT_EN,
236 GPIO_N_ALTIMETER_RESET_N,
237 /* EPM expander */
238 GPIO_EPM_EXPANDER_BASE,
239 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
240 GPIO_PWR_MON_RESET_N,
241 GPIO_ADC1_PWDN_N,
242 GPIO_ADC2_PWDN_N,
243 GPIO_EPM_EXPANDER_IO4,
244 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
245 GPIO_ADC2_MUX_SPI_INT_N,
246 GPIO_EPM_EXPANDER_IO7,
247 GPIO_PWR_MON_ENABLE,
248 GPIO_EPM_SPI_ADC1_CS_N,
249 GPIO_EPM_SPI_ADC2_CS_N,
250 GPIO_EPM_EXPANDER_IO11,
251 GPIO_EPM_EXPANDER_IO12,
252 GPIO_EPM_EXPANDER_IO13,
253 GPIO_EPM_EXPANDER_IO14,
254 GPIO_EPM_EXPANDER_IO15,
255};
256
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530257struct pm8xxx_mpp_init_info {
258 unsigned mpp;
259 struct pm8xxx_mpp_config_data config;
260};
261
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530262#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530263{ \
264 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
265 .config = { \
266 .type = PM8XXX_MPP_TYPE_##_type, \
267 .level = _level, \
268 .control = PM8XXX_MPP_##_control, \
269 } \
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100270}
271
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530272#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
273{ \
274 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
275 .config = { \
276 .type = PM8XXX_MPP_TYPE_##_type, \
277 .level = _level, \
278 .control = PM8XXX_MPP_##_control, \
279 } \
280}
281
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282/*
283 * The UI_INTx_N lines are pmic gpio lines which connect i2c
284 * gpio expanders to the pm8058.
285 */
286#define UI_INT1_N 25
287#define UI_INT2_N 34
288#define UI_INT3_N 14
289/*
290FM GPIO is GPIO 18 on PMIC 8058.
291As the index starts from 0 in the PMIC driver, and hence 17
292corresponds to GPIO 18 on PMIC 8058.
293*/
294#define FM_GPIO 17
295
296#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
297static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
298static void *sdc2_status_notify_cb_devid;
299#endif
300
301#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
302static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
303static void *sdc5_status_notify_cb_devid;
304#endif
305
306static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
307 [0] = {
308 .reg_base_addr = MSM_SAW0_BASE,
309
310#ifdef CONFIG_MSM_AVS_HW
311 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
312#endif
313 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
314 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
315 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
316 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
317
318 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
319 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
320 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
321
322 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
323 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
324 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
325
326 .awake_vlevel = 0x94,
327 .retention_vlevel = 0x81,
328 .collapse_vlevel = 0x20,
329 .retention_mid_vlevel = 0x94,
330 .collapse_mid_vlevel = 0x8C,
331
332 .vctl_timeout_us = 50,
333 },
334
335 [1] = {
336 .reg_base_addr = MSM_SAW1_BASE,
337
338#ifdef CONFIG_MSM_AVS_HW
339 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
340#endif
341 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
342 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
343 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
344 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
345
346 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
347 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
348 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
349
350 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
351 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
352 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
353
354 .awake_vlevel = 0x94,
355 .retention_vlevel = 0x81,
356 .collapse_vlevel = 0x20,
357 .retention_mid_vlevel = 0x94,
358 .collapse_mid_vlevel = 0x8C,
359
360 .vctl_timeout_us = 50,
361 },
362};
363
364static struct msm_spm_platform_data msm_spm_data[] __initdata = {
365 [0] = {
366 .reg_base_addr = MSM_SAW0_BASE,
367
368#ifdef CONFIG_MSM_AVS_HW
369 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
370#endif
371 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
372 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
373 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
374 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
375
376 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
377 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
378 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
379
380 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
381 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
382 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
383
384 .awake_vlevel = 0xA0,
385 .retention_vlevel = 0x89,
386 .collapse_vlevel = 0x20,
387 .retention_mid_vlevel = 0x89,
388 .collapse_mid_vlevel = 0x89,
389
390 .vctl_timeout_us = 50,
391 },
392
393 [1] = {
394 .reg_base_addr = MSM_SAW1_BASE,
395
396#ifdef CONFIG_MSM_AVS_HW
397 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
398#endif
399 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
400 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
401 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
402 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
403
404 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
405 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
406 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
407
408 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
409 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
410 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
411
412 .awake_vlevel = 0xA0,
413 .retention_vlevel = 0x89,
414 .collapse_vlevel = 0x20,
415 .retention_mid_vlevel = 0x89,
416 .collapse_mid_vlevel = 0x89,
417
418 .vctl_timeout_us = 50,
419 },
420};
421
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700422/*
423 * Consumer specific regulator names:
424 * regulator name consumer dev_name
425 */
426static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
427 REGULATOR_SUPPLY("8901_s0", NULL),
428};
429static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
430 REGULATOR_SUPPLY("8901_s1", NULL),
431};
432
433static struct regulator_init_data saw_s0_init_data = {
434 .constraints = {
435 .name = "8901_s0",
436 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700437 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700438 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700439 },
440 .consumer_supplies = vreg_consumers_8901_S0,
441 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
442};
443
444static struct regulator_init_data saw_s1_init_data = {
445 .constraints = {
446 .name = "8901_s1",
447 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700448 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700449 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700450 },
451 .consumer_supplies = vreg_consumers_8901_S1,
452 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
453};
454
455static struct platform_device msm_device_saw_s0 = {
456 .name = "saw-regulator",
457 .id = 0,
458 .dev = {
459 .platform_data = &saw_s0_init_data,
460 },
461};
462
463static struct platform_device msm_device_saw_s1 = {
464 .name = "saw-regulator",
465 .id = 1,
466 .dev = {
467 .platform_data = &saw_s1_init_data,
468 },
469};
470
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700471static struct resource smsc911x_resources[] = {
472 [0] = {
473 .flags = IORESOURCE_MEM,
474 .start = 0x1b800000,
475 .end = 0x1b8000ff
476 },
477 [1] = {
478 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
479 },
480};
481
482static struct smsc911x_platform_config smsc911x_config = {
483 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
484 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
485 .flags = SMSC911X_USE_16BIT,
486 .has_reset_gpio = 1,
487 .reset_gpio = GPIO_ETHERNET_RESET_N
488};
489
490static struct platform_device smsc911x_device = {
491 .name = "smsc911x",
492 .id = 0,
493 .num_resources = ARRAY_SIZE(smsc911x_resources),
494 .resource = smsc911x_resources,
495 .dev = {
496 .platform_data = &smsc911x_config
497 }
498};
499
500#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
501 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
502 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
503 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
504
505#define QCE_SIZE 0x10000
506#define QCE_0_BASE 0x18500000
507
508#define QCE_HW_KEY_SUPPORT 0
509#define QCE_SHA_HMAC_SUPPORT 0
510#define QCE_SHARE_CE_RESOURCE 2
511#define QCE_CE_SHARED 1
512
513static struct resource qcrypto_resources[] = {
514 [0] = {
515 .start = QCE_0_BASE,
516 .end = QCE_0_BASE + QCE_SIZE - 1,
517 .flags = IORESOURCE_MEM,
518 },
519 [1] = {
520 .name = "crypto_channels",
521 .start = DMOV_CE_IN_CHAN,
522 .end = DMOV_CE_OUT_CHAN,
523 .flags = IORESOURCE_DMA,
524 },
525 [2] = {
526 .name = "crypto_crci_in",
527 .start = DMOV_CE_IN_CRCI,
528 .end = DMOV_CE_IN_CRCI,
529 .flags = IORESOURCE_DMA,
530 },
531 [3] = {
532 .name = "crypto_crci_out",
533 .start = DMOV_CE_OUT_CRCI,
534 .end = DMOV_CE_OUT_CRCI,
535 .flags = IORESOURCE_DMA,
536 },
537 [4] = {
538 .name = "crypto_crci_hash",
539 .start = DMOV_CE_HASH_CRCI,
540 .end = DMOV_CE_HASH_CRCI,
541 .flags = IORESOURCE_DMA,
542 },
543};
544
545static struct resource qcedev_resources[] = {
546 [0] = {
547 .start = QCE_0_BASE,
548 .end = QCE_0_BASE + QCE_SIZE - 1,
549 .flags = IORESOURCE_MEM,
550 },
551 [1] = {
552 .name = "crypto_channels",
553 .start = DMOV_CE_IN_CHAN,
554 .end = DMOV_CE_OUT_CHAN,
555 .flags = IORESOURCE_DMA,
556 },
557 [2] = {
558 .name = "crypto_crci_in",
559 .start = DMOV_CE_IN_CRCI,
560 .end = DMOV_CE_IN_CRCI,
561 .flags = IORESOURCE_DMA,
562 },
563 [3] = {
564 .name = "crypto_crci_out",
565 .start = DMOV_CE_OUT_CRCI,
566 .end = DMOV_CE_OUT_CRCI,
567 .flags = IORESOURCE_DMA,
568 },
569 [4] = {
570 .name = "crypto_crci_hash",
571 .start = DMOV_CE_HASH_CRCI,
572 .end = DMOV_CE_HASH_CRCI,
573 .flags = IORESOURCE_DMA,
574 },
575};
576
577#endif
578
579#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
580 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
581
582static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
583 .ce_shared = QCE_CE_SHARED,
584 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
585 .hw_key_support = QCE_HW_KEY_SUPPORT,
586 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800587 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700588};
589
590static struct platform_device qcrypto_device = {
591 .name = "qcrypto",
592 .id = 0,
593 .num_resources = ARRAY_SIZE(qcrypto_resources),
594 .resource = qcrypto_resources,
595 .dev = {
596 .coherent_dma_mask = DMA_BIT_MASK(32),
597 .platform_data = &qcrypto_ce_hw_suppport,
598 },
599};
600#endif
601
602#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
603 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
604
605static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
606 .ce_shared = QCE_CE_SHARED,
607 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
608 .hw_key_support = QCE_HW_KEY_SUPPORT,
609 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800610 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700611};
612
613static struct platform_device qcedev_device = {
614 .name = "qce",
615 .id = 0,
616 .num_resources = ARRAY_SIZE(qcedev_resources),
617 .resource = qcedev_resources,
618 .dev = {
619 .coherent_dma_mask = DMA_BIT_MASK(32),
620 .platform_data = &qcedev_ce_hw_suppport,
621 },
622};
623#endif
624
625#if defined(CONFIG_HAPTIC_ISA1200) || \
626 defined(CONFIG_HAPTIC_ISA1200_MODULE)
627
628static const char *vregs_isa1200_name[] = {
629 "8058_s3",
630 "8901_l4",
631};
632
633static const int vregs_isa1200_val[] = {
634 1800000,/* uV */
635 2600000,
636};
637static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
638static struct msm_xo_voter *xo_handle_a1;
639
640static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800641{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700642 int i, rc = 0;
643
644 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
645 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
646 regulator_disable(vregs_isa1200[i]);
647 if (rc < 0) {
648 pr_err("%s: vreg %s %s failed (%d)\n",
649 __func__, vregs_isa1200_name[i],
650 vreg_on ? "enable" : "disable", rc);
651 goto vreg_fail;
652 }
653 }
654
655 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
656 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
657 if (rc < 0) {
658 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
659 __func__, vreg_on ? "" : "de-", rc);
660 goto vreg_fail;
661 }
662 return 0;
663
664vreg_fail:
665 while (i--)
666 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
667 regulator_disable(vregs_isa1200[i]);
668 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800669}
670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700671static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800672{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700673 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800674
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700675 if (enable == true) {
676 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
677 vregs_isa1200[i] = regulator_get(NULL,
678 vregs_isa1200_name[i]);
679 if (IS_ERR(vregs_isa1200[i])) {
680 pr_err("%s: regulator get of %s failed (%ld)\n",
681 __func__, vregs_isa1200_name[i],
682 PTR_ERR(vregs_isa1200[i]));
683 rc = PTR_ERR(vregs_isa1200[i]);
684 goto vreg_get_fail;
685 }
686 rc = regulator_set_voltage(vregs_isa1200[i],
687 vregs_isa1200_val[i], vregs_isa1200_val[i]);
688 if (rc) {
689 pr_err("%s: regulator_set_voltage(%s) failed\n",
690 __func__, vregs_isa1200_name[i]);
691 goto vreg_get_fail;
692 }
693 }
Steve Muckle9161d302010-02-11 11:50:40 -0800694
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700695 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
696 if (rc) {
697 pr_err("%s: unable to request gpio %d (%d)\n",
698 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
699 goto vreg_get_fail;
700 }
Steve Muckle9161d302010-02-11 11:50:40 -0800701
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700702 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
703 if (rc) {
704 pr_err("%s: Unable to set direction\n", __func__);;
705 goto free_gpio;
706 }
707
708 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
709 if (IS_ERR(xo_handle_a1)) {
710 rc = PTR_ERR(xo_handle_a1);
711 pr_err("%s: failed to get the handle for A1(%d)\n",
712 __func__, rc);
713 goto gpio_set_dir;
714 }
715 } else {
716 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
717 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
718
719 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
720 regulator_put(vregs_isa1200[i]);
721
722 msm_xo_put(xo_handle_a1);
723 }
724
725 return 0;
726gpio_set_dir:
727 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
728free_gpio:
729 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
730vreg_get_fail:
731 while (i)
732 regulator_put(vregs_isa1200[--i]);
733 return rc;
734}
735
736#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530737#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738static struct isa1200_platform_data isa1200_1_pdata = {
739 .name = "vibrator",
740 .power_on = isa1200_power,
741 .dev_setup = isa1200_dev_setup,
742 /*gpio to enable haptic*/
743 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530744 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700745 .max_timeout = 15000,
746 .mode_ctrl = PWM_GEN_MODE,
747 .pwm_fd = {
748 .pwm_div = 256,
749 },
750 .is_erm = false,
751 .smart_en = true,
752 .ext_clk_en = true,
753 .chip_en = 1,
754};
755
756static struct i2c_board_info msm_isa1200_board_info[] = {
757 {
758 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
759 .platform_data = &isa1200_1_pdata,
760 },
761};
762#endif
763
764#if defined(CONFIG_BATTERY_BQ27520) || \
765 defined(CONFIG_BATTERY_BQ27520_MODULE)
766static struct bq27520_platform_data bq27520_pdata = {
767 .name = "fuel-gauge",
768 .vreg_name = "8058_s3",
769 .vreg_value = 1800000,
770 .soc_int = GPIO_BATT_GAUGE_INT_N,
771 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
772 .chip_en = GPIO_BATT_GAUGE_EN,
773 .enable_dlog = 0, /* if enable coulomb counter logger */
774};
775
776static struct i2c_board_info msm_bq27520_board_info[] = {
777 {
778 I2C_BOARD_INFO("bq27520", 0xaa>>1),
779 .platform_data = &bq27520_pdata,
780 },
781};
782#endif
783
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700784static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
785 {
786 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
787 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
788 true,
789 1, 8000, 100000, 1,
790 },
791
792 {
793 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
794 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
795 true,
796 1500, 5000, 60100000, 3000,
797 },
798
799 {
800 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
801 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
802 false,
803 1800, 5000, 60350000, 3500,
804 },
805 {
806 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
807 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
808 false,
809 3800, 4500, 65350000, 5500,
810 },
811
812 {
813 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
814 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
815 false,
816 2800, 2500, 66850000, 4800,
817 },
818
819 {
820 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
821 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
822 false,
823 4800, 2000, 71850000, 6800,
824 },
825
826 {
827 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
828 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
829 false,
830 6800, 500, 75850000, 8800,
831 },
832
833 {
834 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
835 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
836 false,
837 7800, 0, 76350000, 9800,
838 },
839};
840
Praveen Chidambaram78499012011-11-01 17:15:17 -0600841static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
842 .levels = &msm_rpmrs_levels[0],
843 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
844 .vdd_mem_levels = {
845 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
846 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
847 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700848 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600849 },
850 .vdd_dig_levels = {
851 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
852 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
853 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
854 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
855 },
856 .vdd_mask = 0xFFF,
857 .rpmrs_target_id = {
858 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
859 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
860 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
861 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
862 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
863 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
864 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
865 },
866};
867
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600868static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
869 .mode = MSM_PM_BOOT_CONFIG_TZ,
870};
871
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700872#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
873
874#define ISP1763_INT_GPIO 117
875#define ISP1763_RST_GPIO 152
876static struct resource isp1763_resources[] = {
877 [0] = {
878 .flags = IORESOURCE_MEM,
879 .start = 0x1D000000,
880 .end = 0x1D005FFF, /* 24KB */
881 },
882 [1] = {
883 .flags = IORESOURCE_IRQ,
884 },
885};
886static void __init msm8x60_cfg_isp1763(void)
887{
888 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
889 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
890}
891
892static int isp1763_setup_gpio(int enable)
893{
894 int status = 0;
895
896 if (enable) {
897 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
898 if (status) {
899 pr_err("%s:Failed to request GPIO %d\n",
900 __func__, ISP1763_INT_GPIO);
901 return status;
902 }
903 status = gpio_direction_input(ISP1763_INT_GPIO);
904 if (status) {
905 pr_err("%s:Failed to configure GPIO %d\n",
906 __func__, ISP1763_INT_GPIO);
907 goto gpio_free_int;
908 }
909 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
910 if (status) {
911 pr_err("%s:Failed to request GPIO %d\n",
912 __func__, ISP1763_RST_GPIO);
913 goto gpio_free_int;
914 }
915 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
916 if (status) {
917 pr_err("%s:Failed to configure GPIO %d\n",
918 __func__, ISP1763_RST_GPIO);
919 goto gpio_free_rst;
920 }
921 pr_debug("\nISP GPIO configuration done\n");
922 return status;
923 }
924
925gpio_free_rst:
926 gpio_free(ISP1763_RST_GPIO);
927gpio_free_int:
928 gpio_free(ISP1763_INT_GPIO);
929
930 return status;
931}
932static struct isp1763_platform_data isp1763_pdata = {
933 .reset_gpio = ISP1763_RST_GPIO,
934 .setup_gpio = isp1763_setup_gpio
935};
936
937static struct platform_device isp1763_device = {
938 .name = "isp1763_usb",
939 .num_resources = ARRAY_SIZE(isp1763_resources),
940 .resource = isp1763_resources,
941 .dev = {
942 .platform_data = &isp1763_pdata
943 }
944};
945#endif
946
Lena Salman57d167e2012-03-21 19:46:38 +0200947#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530948static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700949static struct regulator *ldo6_3p3;
950static struct regulator *ldo7_1p8;
951static struct regulator *vdd_cx;
952#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530953#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700954notify_vbus_state notify_vbus_state_func_ptr;
955static int usb_phy_susp_dig_vol = 750000;
956static int pmic_id_notif_supported;
957
958#ifdef CONFIG_USB_EHCI_MSM_72K
959#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
960struct delayed_work pmic_id_det;
961
962static int __init usb_id_pin_rework_setup(char *support)
963{
964 if (strncmp(support, "true", 4) == 0)
965 pmic_id_notif_supported = 1;
966
967 return 1;
968}
969__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
970
971static void pmic_id_detect(struct work_struct *w)
972{
973 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
974 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
975
976 if (notify_vbus_state_func_ptr)
977 (*notify_vbus_state_func_ptr) (val);
978}
979
980static irqreturn_t pmic_id_on_irq(int irq, void *data)
981{
982 /*
983 * Spurious interrupts are observed on pmic gpio line
984 * even though there is no state change on USB ID. Schedule the
985 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -0800986 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700987 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -0800988
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700989 return IRQ_HANDLED;
990}
991
Anji jonnalaae745e92011-11-14 18:34:31 +0530992static int msm_hsusb_phy_id_setup_init(int init)
993{
994 unsigned ret;
995
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530996 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
997 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
998 .level = PM8901_MPP_DIG_LEVEL_L5,
999 };
1000
Anji jonnalaae745e92011-11-14 18:34:31 +05301001 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301002 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1003 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1004 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301005 if (ret < 0)
1006 pr_err("%s:MPP2 configuration failed\n", __func__);
1007 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301008 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1009 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1010 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301011 if (ret < 0)
1012 pr_err("%s:MPP2 un config failed\n", __func__);
1013 }
1014 return ret;
1015}
1016
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001017static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1018{
1019 unsigned ret = -ENODEV;
1020
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301021 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301022 .direction = PM_GPIO_DIR_IN,
1023 .pull = PM_GPIO_PULL_UP_1P5,
1024 .function = PM_GPIO_FUNC_NORMAL,
1025 .vin_sel = 2,
1026 .inv_int_pol = 0,
1027 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301028 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301029 .direction = PM_GPIO_DIR_IN,
1030 .pull = PM_GPIO_PULL_NO,
1031 .function = PM_GPIO_FUNC_NORMAL,
1032 .vin_sel = 2,
1033 .inv_int_pol = 0,
1034 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001035 if (!callback)
1036 return -EINVAL;
1037
1038 if (machine_is_msm8x60_fluid())
1039 return -ENOTSUPP;
1040
1041 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1042 pr_debug("%s: USB_ID pin is not routed to PMIC"
1043 "on V1 surf/ffa\n", __func__);
1044 return -ENOTSUPP;
1045 }
1046
Manu Gautam62158eb2011-11-24 16:20:46 +05301047 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1048 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001049 pr_debug("%s: USB_ID is not routed to PMIC"
1050 "on V2 ffa\n", __func__);
1051 return -ENOTSUPP;
1052 }
1053
1054 usb_phy_susp_dig_vol = 500000;
1055
1056 if (init) {
1057 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301058 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301059 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1060 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301061 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301062 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301063 __func__, ret);
1064 return ret;
1065 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001066 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1067 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1068 "msm_otg_id", NULL);
1069 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070 pr_err("%s:pmic_usb_id interrupt registration failed",
1071 __func__);
1072 return ret;
1073 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301074 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001075 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301076 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001077 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301078 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1079 &pmic_id_uncfg);
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 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301085 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001086 cancel_delayed_work_sync(&pmic_id_det);
1087 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001088 }
1089 return 0;
1090}
1091#endif
1092
1093#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1094#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1095static int msm_hsusb_init_vddcx(int init)
1096{
1097 int ret = 0;
1098
1099 if (init) {
1100 vdd_cx = regulator_get(NULL, "8058_s1");
1101 if (IS_ERR(vdd_cx)) {
1102 return PTR_ERR(vdd_cx);
1103 }
1104
1105 ret = regulator_set_voltage(vdd_cx,
1106 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1107 USB_PHY_MAX_VDD_DIG_VOL);
1108 if (ret) {
1109 pr_err("%s: unable to set the voltage for regulator"
1110 "vdd_cx\n", __func__);
1111 regulator_put(vdd_cx);
1112 return ret;
1113 }
1114
1115 ret = regulator_enable(vdd_cx);
1116 if (ret) {
1117 pr_err("%s: unable to enable regulator"
1118 "vdd_cx\n", __func__);
1119 regulator_put(vdd_cx);
1120 }
1121 } else {
1122 ret = regulator_disable(vdd_cx);
1123 if (ret) {
1124 pr_err("%s: Unable to disable the regulator:"
1125 "vdd_cx\n", __func__);
1126 return ret;
1127 }
1128
1129 regulator_put(vdd_cx);
1130 }
1131
1132 return ret;
1133}
1134
1135static int msm_hsusb_config_vddcx(int high)
1136{
1137 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1138 int min_vol;
1139 int ret;
1140
1141 if (high)
1142 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1143 else
1144 min_vol = usb_phy_susp_dig_vol;
1145
1146 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1147 if (ret) {
1148 pr_err("%s: unable to set the voltage for regulator"
1149 "vdd_cx\n", __func__);
1150 return ret;
1151 }
1152
1153 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1154
1155 return ret;
1156}
1157
1158#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1159#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1160#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1161#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1162
1163#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1164#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1165#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1166#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1167static int msm_hsusb_ldo_init(int init)
1168{
1169 int rc = 0;
1170
1171 if (init) {
1172 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1173 if (IS_ERR(ldo6_3p3))
1174 return PTR_ERR(ldo6_3p3);
1175
1176 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1177 if (IS_ERR(ldo7_1p8)) {
1178 rc = PTR_ERR(ldo7_1p8);
1179 goto put_3p3;
1180 }
1181
1182 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1183 USB_PHY_3P3_VOL_MAX);
1184 if (rc) {
1185 pr_err("%s: Unable to set voltage level for"
1186 "ldo6_3p3 regulator\n", __func__);
1187 goto put_1p8;
1188 }
1189 rc = regulator_enable(ldo6_3p3);
1190 if (rc) {
1191 pr_err("%s: Unable to enable the regulator:"
1192 "ldo6_3p3\n", __func__);
1193 goto put_1p8;
1194 }
1195 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1196 USB_PHY_1P8_VOL_MAX);
1197 if (rc) {
1198 pr_err("%s: Unable to set voltage level for"
1199 "ldo7_1p8 regulator\n", __func__);
1200 goto disable_3p3;
1201 }
1202 rc = regulator_enable(ldo7_1p8);
1203 if (rc) {
1204 pr_err("%s: Unable to enable the regulator:"
1205 "ldo7_1p8\n", __func__);
1206 goto disable_3p3;
1207 }
1208
1209 return 0;
1210 }
1211
1212 regulator_disable(ldo7_1p8);
1213disable_3p3:
1214 regulator_disable(ldo6_3p3);
1215put_1p8:
1216 regulator_put(ldo7_1p8);
1217put_3p3:
1218 regulator_put(ldo6_3p3);
1219 return rc;
1220}
1221
1222static int msm_hsusb_ldo_enable(int on)
1223{
1224 int ret = 0;
1225
1226 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1227 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1228 return -ENODEV;
1229 }
1230
1231 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1232 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1233 return -ENODEV;
1234 }
1235
1236 if (on) {
1237 ret = regulator_set_optimum_mode(ldo7_1p8,
1238 USB_PHY_1P8_HPM_LOAD);
1239 if (ret < 0) {
1240 pr_err("%s: Unable to set HPM of the regulator:"
1241 "ldo7_1p8\n", __func__);
1242 return ret;
1243 }
1244 ret = regulator_set_optimum_mode(ldo6_3p3,
1245 USB_PHY_3P3_HPM_LOAD);
1246 if (ret < 0) {
1247 pr_err("%s: Unable to set HPM of the regulator:"
1248 "ldo6_3p3\n", __func__);
1249 regulator_set_optimum_mode(ldo7_1p8,
1250 USB_PHY_1P8_LPM_LOAD);
1251 return ret;
1252 }
1253 } else {
1254 ret = regulator_set_optimum_mode(ldo7_1p8,
1255 USB_PHY_1P8_LPM_LOAD);
1256 if (ret < 0)
1257 pr_err("%s: Unable to set LPM of the regulator:"
1258 "ldo7_1p8\n", __func__);
1259 ret = regulator_set_optimum_mode(ldo6_3p3,
1260 USB_PHY_3P3_LPM_LOAD);
1261 if (ret < 0)
1262 pr_err("%s: Unable to set LPM of the regulator:"
1263 "ldo6_3p3\n", __func__);
1264 }
1265
1266 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1267 return ret < 0 ? ret : 0;
1268 }
1269#endif
1270#ifdef CONFIG_USB_EHCI_MSM_72K
1271#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1272static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1273{
1274 static int vbus_is_on;
1275
1276 /* If VBUS is already on (or off), do nothing. */
1277 if (on == vbus_is_on)
1278 return;
1279 smb137b_otg_power(on);
1280 vbus_is_on = on;
1281}
1282#endif
1283static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1284{
1285 static struct regulator *votg_5v_switch;
1286 static struct regulator *ext_5v_reg;
1287 static int vbus_is_on;
1288
1289 /* If VBUS is already on (or off), do nothing. */
1290 if (on == vbus_is_on)
1291 return;
1292
1293 if (!votg_5v_switch) {
1294 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1295 if (IS_ERR(votg_5v_switch)) {
1296 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1297 return;
1298 }
1299 }
1300 if (!ext_5v_reg) {
1301 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1302 if (IS_ERR(ext_5v_reg)) {
1303 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1304 return;
1305 }
1306 }
1307 if (on) {
1308 if (regulator_enable(ext_5v_reg)) {
1309 pr_err("%s: Unable to enable the regulator:"
1310 " ext_5v_reg\n", __func__);
1311 return;
1312 }
1313 if (regulator_enable(votg_5v_switch)) {
1314 pr_err("%s: Unable to enable the regulator:"
1315 " votg_5v_switch\n", __func__);
1316 return;
1317 }
1318 } else {
1319 if (regulator_disable(votg_5v_switch))
1320 pr_err("%s: Unable to enable the regulator:"
1321 " votg_5v_switch\n", __func__);
1322 if (regulator_disable(ext_5v_reg))
1323 pr_err("%s: Unable to enable the regulator:"
1324 " ext_5v_reg\n", __func__);
1325 }
1326
1327 vbus_is_on = on;
1328}
1329
1330static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1331 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1332 .power_budget = 390,
1333};
1334#endif
1335
1336#ifdef CONFIG_BATTERY_MSM8X60
1337static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1338 int init)
1339{
1340 int ret = -ENOTSUPP;
1341
1342#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1343 if (machine_is_msm8x60_fluid()) {
1344 if (init)
1345 msm_charger_register_vbus_sn(callback);
1346 else
1347 msm_charger_unregister_vbus_sn(callback);
1348 return 0;
1349 }
1350#endif
1351 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1352 * hence, irrespective of either peripheral only mode or
1353 * OTG (host and peripheral) modes, can depend on pmic for
1354 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001355 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001356 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1357 && (machine_is_msm8x60_surf() ||
1358 pmic_id_notif_supported)) {
1359 if (init)
1360 ret = msm_charger_register_vbus_sn(callback);
1361 else {
1362 msm_charger_unregister_vbus_sn(callback);
1363 ret = 0;
1364 }
1365 } else {
1366#if !defined(CONFIG_USB_EHCI_MSM_72K)
1367 if (init)
1368 ret = msm_charger_register_vbus_sn(callback);
1369 else {
1370 msm_charger_unregister_vbus_sn(callback);
1371 ret = 0;
1372 }
1373#endif
1374 }
1375 return ret;
1376}
1377#endif
1378
Lena Salman57d167e2012-03-21 19:46:38 +02001379#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001380static struct msm_otg_platform_data msm_otg_pdata = {
1381 /* if usb link is in sps there is no need for
1382 * usb pclk as dayatona fabric clock will be
1383 * used instead
1384 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001385 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1386 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1387 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301388 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001389#ifdef CONFIG_USB_EHCI_MSM_72K
1390 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301391 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001392#endif
1393#ifdef CONFIG_USB_EHCI_MSM_72K
1394 .vbus_power = msm_hsusb_vbus_power,
1395#endif
1396#ifdef CONFIG_BATTERY_MSM8X60
1397 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1398#endif
1399 .ldo_init = msm_hsusb_ldo_init,
1400 .ldo_enable = msm_hsusb_ldo_enable,
1401 .config_vddcx = msm_hsusb_config_vddcx,
1402 .init_vddcx = msm_hsusb_init_vddcx,
1403#ifdef CONFIG_BATTERY_MSM8X60
1404 .chg_vbus_draw = msm_charger_vbus_draw,
1405#endif
1406};
1407#endif
1408
Lena Salman57d167e2012-03-21 19:46:38 +02001409#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1411 .is_phy_status_timer_on = 1,
1412};
1413#endif
1414
1415#ifdef CONFIG_USB_G_ANDROID
1416
1417#define PID_MAGIC_ID 0x71432909
1418#define SERIAL_NUM_MAGIC_ID 0x61945374
1419#define SERIAL_NUMBER_LENGTH 127
1420#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1421
1422struct magic_num_struct {
1423 uint32_t pid;
1424 uint32_t serial_num;
1425};
1426
1427struct dload_struct {
1428 uint32_t reserved1;
1429 uint32_t reserved2;
1430 uint32_t reserved3;
1431 uint16_t reserved4;
1432 uint16_t pid;
1433 char serial_number[SERIAL_NUMBER_LENGTH];
1434 uint16_t reserved5;
1435 struct magic_num_struct
1436 magic_struct;
1437};
1438
1439static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1440{
1441 struct dload_struct __iomem *dload = 0;
1442
1443 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1444 if (!dload) {
1445 pr_err("%s: cannot remap I/O memory region: %08x\n",
1446 __func__, DLOAD_USB_BASE_ADD);
1447 return -ENXIO;
1448 }
1449
1450 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1451 __func__, dload, pid, snum);
1452 /* update pid */
1453 dload->magic_struct.pid = PID_MAGIC_ID;
1454 dload->pid = pid;
1455
1456 /* update serial number */
1457 dload->magic_struct.serial_num = 0;
1458 if (!snum)
1459 return 0;
1460
1461 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1462 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1463 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1464
1465 iounmap(dload);
1466
1467 return 0;
1468}
1469
1470static struct android_usb_platform_data android_usb_pdata = {
1471 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1472};
1473
1474static struct platform_device android_usb_device = {
1475 .name = "android_usb",
1476 .id = -1,
1477 .dev = {
1478 .platform_data = &android_usb_pdata,
1479 },
1480};
1481
1482
1483#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001484
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001485#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001486#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001487static struct resource msm_vpe_resources[] = {
1488 {
1489 .start = 0x05300000,
1490 .end = 0x05300000 + SZ_1M - 1,
1491 .flags = IORESOURCE_MEM,
1492 },
1493 {
1494 .start = INT_VPE,
1495 .end = INT_VPE,
1496 .flags = IORESOURCE_IRQ,
1497 },
1498};
1499
1500static struct platform_device msm_vpe_device = {
1501 .name = "msm_vpe",
1502 .id = 0,
1503 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1504 .resource = msm_vpe_resources,
1505};
1506#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001507#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001508
1509#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001510#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001511#ifdef CONFIG_MSM_CAMERA_FLASH
1512#define VFE_CAMIF_TIMER1_GPIO 29
1513#define VFE_CAMIF_TIMER2_GPIO 30
1514#define VFE_CAMIF_TIMER3_GPIO_INT 31
1515#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1516static struct msm_camera_sensor_flash_src msm_flash_src = {
1517 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1518 ._fsrc.pmic_src.num_of_src = 2,
1519 ._fsrc.pmic_src.low_current = 100,
1520 ._fsrc.pmic_src.high_current = 300,
1521 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1522 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1523 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1524};
1525#ifdef CONFIG_IMX074
1526static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1527 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1528 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1529 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1530 .flash_recharge_duration = 50000,
1531 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1532};
1533#endif
1534#endif
1535
1536int msm_cam_gpio_tbl[] = {
1537 32,/*CAMIF_MCLK*/
1538 47,/*CAMIF_I2C_DATA*/
1539 48,/*CAMIF_I2C_CLK*/
1540 105,/*STANDBY*/
1541};
1542
1543enum msm_cam_stat{
1544 MSM_CAM_OFF,
1545 MSM_CAM_ON,
1546};
1547
1548static int config_gpio_table(enum msm_cam_stat stat)
1549{
1550 int rc = 0, i = 0;
1551 if (stat == MSM_CAM_ON) {
1552 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1553 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1554 if (unlikely(rc < 0)) {
1555 pr_err("%s not able to get gpio\n", __func__);
1556 for (i--; i >= 0; i--)
1557 gpio_free(msm_cam_gpio_tbl[i]);
1558 break;
1559 }
1560 }
1561 } else {
1562 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1563 gpio_free(msm_cam_gpio_tbl[i]);
1564 }
1565 return rc;
1566}
1567
1568static struct msm_camera_sensor_platform_info sensor_board_info = {
1569 .mount_angle = 0
1570};
1571
1572/*external regulator VREG_5V*/
1573static struct regulator *reg_flash_5V;
1574
1575static int config_camera_on_gpios_fluid(void)
1576{
1577 int rc = 0;
1578
1579 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1580 if (IS_ERR(reg_flash_5V)) {
1581 pr_err("'%s' regulator not found, rc=%ld\n",
1582 "8901_mpp0", IS_ERR(reg_flash_5V));
1583 return -ENODEV;
1584 }
1585
1586 rc = regulator_enable(reg_flash_5V);
1587 if (rc) {
1588 pr_err("'%s' regulator enable failed, rc=%d\n",
1589 "8901_mpp0", rc);
1590 regulator_put(reg_flash_5V);
1591 return rc;
1592 }
1593
1594#ifdef CONFIG_IMX074
1595 sensor_board_info.mount_angle = 90;
1596#endif
1597 rc = config_gpio_table(MSM_CAM_ON);
1598 if (rc < 0) {
1599 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1600 "failed\n", __func__);
1601 return rc;
1602 }
1603
1604 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1605 if (rc < 0) {
1606 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1607 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1608 regulator_disable(reg_flash_5V);
1609 regulator_put(reg_flash_5V);
1610 return rc;
1611 }
1612 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1613 msleep(20);
1614 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1615
1616
1617 /*Enable LED_FLASH_EN*/
1618 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1619 if (rc < 0) {
1620 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1621 "failed\n", __func__, GPIO_LED_FLASH_EN);
1622
1623 regulator_disable(reg_flash_5V);
1624 regulator_put(reg_flash_5V);
1625 config_gpio_table(MSM_CAM_OFF);
1626 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1627 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1628 return rc;
1629 }
1630 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1631 msleep(20);
1632 return rc;
1633}
1634
1635
1636static void config_camera_off_gpios_fluid(void)
1637{
1638 regulator_disable(reg_flash_5V);
1639 regulator_put(reg_flash_5V);
1640
1641 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1642 gpio_free(GPIO_LED_FLASH_EN);
1643
1644 config_gpio_table(MSM_CAM_OFF);
1645
1646 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1647 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1648}
1649static int config_camera_on_gpios(void)
1650{
1651 int rc = 0;
1652
1653 if (machine_is_msm8x60_fluid())
1654 return config_camera_on_gpios_fluid();
1655
1656 rc = config_gpio_table(MSM_CAM_ON);
1657 if (rc < 0) {
1658 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1659 "failed\n", __func__);
1660 return rc;
1661 }
1662
Jilai Wang971f97f2011-07-13 14:25:25 -04001663 if (!machine_is_msm8x60_dragon()) {
1664 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1665 if (rc < 0) {
1666 config_gpio_table(MSM_CAM_OFF);
1667 pr_err("%s: CAMSENSOR gpio %d request"
1668 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1669 return rc;
1670 }
1671 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1672 msleep(20);
1673 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001674 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675
1676#ifdef CONFIG_MSM_CAMERA_FLASH
1677#ifdef CONFIG_IMX074
1678 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1679 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1680#endif
1681#endif
1682 return rc;
1683}
1684
1685static void config_camera_off_gpios(void)
1686{
1687 if (machine_is_msm8x60_fluid())
1688 return config_camera_off_gpios_fluid();
1689
1690
1691 config_gpio_table(MSM_CAM_OFF);
1692
Jilai Wang971f97f2011-07-13 14:25:25 -04001693 if (!machine_is_msm8x60_dragon()) {
1694 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1695 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1696 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001697}
1698
1699#ifdef CONFIG_QS_S5K4E1
1700
1701#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1702
1703static int config_camera_on_gpios_qs_cam_fluid(void)
1704{
1705 int rc = 0;
1706
1707 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1708 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1709 if (rc < 0) {
1710 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1711 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1712 return rc;
1713 }
1714 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1715 msleep(20);
1716 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1717 msleep(20);
1718
1719 /*
1720 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1721 * to enable 2.7V power to Camera
1722 */
1723 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1724 if (rc < 0) {
1725 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1726 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1727 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1728 gpio_free(QS_CAM_HC37_CAM_PD);
1729 return rc;
1730 }
1731 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1732 msleep(20);
1733 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1734 msleep(20);
1735
1736 rc = config_camera_on_gpios_fluid();
1737 if (rc < 0) {
1738 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1739 " failed\n", __func__);
1740 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1741 gpio_free(QS_CAM_HC37_CAM_PD);
1742 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1743 gpio_free(GPIO_AUX_CAM_2P7_EN);
1744 return rc;
1745 }
1746 return rc;
1747}
1748
1749static void config_camera_off_gpios_qs_cam_fluid(void)
1750{
1751 /*
1752 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1753 * to disable 2.7V power to Camera
1754 */
1755 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1756 gpio_free(GPIO_AUX_CAM_2P7_EN);
1757
1758 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1759 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1760 gpio_free(QS_CAM_HC37_CAM_PD);
1761
1762 config_camera_off_gpios_fluid();
1763 return;
1764}
1765
1766static int config_camera_on_gpios_qs_cam(void)
1767{
1768 int rc = 0;
1769
1770 if (machine_is_msm8x60_fluid())
1771 return config_camera_on_gpios_qs_cam_fluid();
1772
1773 rc = config_camera_on_gpios();
1774 return rc;
1775}
1776
1777static void config_camera_off_gpios_qs_cam(void)
1778{
1779 if (machine_is_msm8x60_fluid())
1780 return config_camera_off_gpios_qs_cam_fluid();
1781
1782 config_camera_off_gpios();
1783 return;
1784}
1785#endif
1786
1787static int config_camera_on_gpios_web_cam(void)
1788{
1789 int rc = 0;
1790 rc = config_gpio_table(MSM_CAM_ON);
1791 if (rc < 0) {
1792 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1793 "failed\n", __func__);
1794 return rc;
1795 }
1796
Jilai Wang53d27a82011-07-13 14:32:58 -04001797 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1799 if (rc < 0) {
1800 config_gpio_table(MSM_CAM_OFF);
1801 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1802 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1803 return rc;
1804 }
1805 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1806 }
1807 return rc;
1808}
1809
1810static void config_camera_off_gpios_web_cam(void)
1811{
1812 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001813 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001814 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1815 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1816 }
1817 return;
1818}
1819
1820#ifdef CONFIG_MSM_BUS_SCALING
1821static struct msm_bus_vectors cam_init_vectors[] = {
1822 {
1823 .src = MSM_BUS_MASTER_VFE,
1824 .dst = MSM_BUS_SLAVE_SMI,
1825 .ab = 0,
1826 .ib = 0,
1827 },
1828 {
1829 .src = MSM_BUS_MASTER_VFE,
1830 .dst = MSM_BUS_SLAVE_EBI_CH0,
1831 .ab = 0,
1832 .ib = 0,
1833 },
1834 {
1835 .src = MSM_BUS_MASTER_VPE,
1836 .dst = MSM_BUS_SLAVE_SMI,
1837 .ab = 0,
1838 .ib = 0,
1839 },
1840 {
1841 .src = MSM_BUS_MASTER_VPE,
1842 .dst = MSM_BUS_SLAVE_EBI_CH0,
1843 .ab = 0,
1844 .ib = 0,
1845 },
1846 {
1847 .src = MSM_BUS_MASTER_JPEG_ENC,
1848 .dst = MSM_BUS_SLAVE_SMI,
1849 .ab = 0,
1850 .ib = 0,
1851 },
1852 {
1853 .src = MSM_BUS_MASTER_JPEG_ENC,
1854 .dst = MSM_BUS_SLAVE_EBI_CH0,
1855 .ab = 0,
1856 .ib = 0,
1857 },
1858};
1859
1860static struct msm_bus_vectors cam_preview_vectors[] = {
1861 {
1862 .src = MSM_BUS_MASTER_VFE,
1863 .dst = MSM_BUS_SLAVE_SMI,
1864 .ab = 0,
1865 .ib = 0,
1866 },
1867 {
1868 .src = MSM_BUS_MASTER_VFE,
1869 .dst = MSM_BUS_SLAVE_EBI_CH0,
1870 .ab = 283115520,
1871 .ib = 452984832,
1872 },
1873 {
1874 .src = MSM_BUS_MASTER_VPE,
1875 .dst = MSM_BUS_SLAVE_SMI,
1876 .ab = 0,
1877 .ib = 0,
1878 },
1879 {
1880 .src = MSM_BUS_MASTER_VPE,
1881 .dst = MSM_BUS_SLAVE_EBI_CH0,
1882 .ab = 0,
1883 .ib = 0,
1884 },
1885 {
1886 .src = MSM_BUS_MASTER_JPEG_ENC,
1887 .dst = MSM_BUS_SLAVE_SMI,
1888 .ab = 0,
1889 .ib = 0,
1890 },
1891 {
1892 .src = MSM_BUS_MASTER_JPEG_ENC,
1893 .dst = MSM_BUS_SLAVE_EBI_CH0,
1894 .ab = 0,
1895 .ib = 0,
1896 },
1897};
1898
1899static struct msm_bus_vectors cam_video_vectors[] = {
1900 {
1901 .src = MSM_BUS_MASTER_VFE,
1902 .dst = MSM_BUS_SLAVE_SMI,
1903 .ab = 283115520,
1904 .ib = 452984832,
1905 },
1906 {
1907 .src = MSM_BUS_MASTER_VFE,
1908 .dst = MSM_BUS_SLAVE_EBI_CH0,
1909 .ab = 283115520,
1910 .ib = 452984832,
1911 },
1912 {
1913 .src = MSM_BUS_MASTER_VPE,
1914 .dst = MSM_BUS_SLAVE_SMI,
1915 .ab = 319610880,
1916 .ib = 511377408,
1917 },
1918 {
1919 .src = MSM_BUS_MASTER_VPE,
1920 .dst = MSM_BUS_SLAVE_EBI_CH0,
1921 .ab = 0,
1922 .ib = 0,
1923 },
1924 {
1925 .src = MSM_BUS_MASTER_JPEG_ENC,
1926 .dst = MSM_BUS_SLAVE_SMI,
1927 .ab = 0,
1928 .ib = 0,
1929 },
1930 {
1931 .src = MSM_BUS_MASTER_JPEG_ENC,
1932 .dst = MSM_BUS_SLAVE_EBI_CH0,
1933 .ab = 0,
1934 .ib = 0,
1935 },
1936};
1937
1938static struct msm_bus_vectors cam_snapshot_vectors[] = {
1939 {
1940 .src = MSM_BUS_MASTER_VFE,
1941 .dst = MSM_BUS_SLAVE_SMI,
1942 .ab = 566231040,
1943 .ib = 905969664,
1944 },
1945 {
1946 .src = MSM_BUS_MASTER_VFE,
1947 .dst = MSM_BUS_SLAVE_EBI_CH0,
1948 .ab = 69984000,
1949 .ib = 111974400,
1950 },
1951 {
1952 .src = MSM_BUS_MASTER_VPE,
1953 .dst = MSM_BUS_SLAVE_SMI,
1954 .ab = 0,
1955 .ib = 0,
1956 },
1957 {
1958 .src = MSM_BUS_MASTER_VPE,
1959 .dst = MSM_BUS_SLAVE_EBI_CH0,
1960 .ab = 0,
1961 .ib = 0,
1962 },
1963 {
1964 .src = MSM_BUS_MASTER_JPEG_ENC,
1965 .dst = MSM_BUS_SLAVE_SMI,
1966 .ab = 320864256,
1967 .ib = 513382810,
1968 },
1969 {
1970 .src = MSM_BUS_MASTER_JPEG_ENC,
1971 .dst = MSM_BUS_SLAVE_EBI_CH0,
1972 .ab = 320864256,
1973 .ib = 513382810,
1974 },
1975};
1976
1977static struct msm_bus_vectors cam_zsl_vectors[] = {
1978 {
1979 .src = MSM_BUS_MASTER_VFE,
1980 .dst = MSM_BUS_SLAVE_SMI,
1981 .ab = 566231040,
1982 .ib = 905969664,
1983 },
1984 {
1985 .src = MSM_BUS_MASTER_VFE,
1986 .dst = MSM_BUS_SLAVE_EBI_CH0,
1987 .ab = 706199040,
1988 .ib = 1129918464,
1989 },
1990 {
1991 .src = MSM_BUS_MASTER_VPE,
1992 .dst = MSM_BUS_SLAVE_SMI,
1993 .ab = 0,
1994 .ib = 0,
1995 },
1996 {
1997 .src = MSM_BUS_MASTER_VPE,
1998 .dst = MSM_BUS_SLAVE_EBI_CH0,
1999 .ab = 0,
2000 .ib = 0,
2001 },
2002 {
2003 .src = MSM_BUS_MASTER_JPEG_ENC,
2004 .dst = MSM_BUS_SLAVE_SMI,
2005 .ab = 320864256,
2006 .ib = 513382810,
2007 },
2008 {
2009 .src = MSM_BUS_MASTER_JPEG_ENC,
2010 .dst = MSM_BUS_SLAVE_EBI_CH0,
2011 .ab = 320864256,
2012 .ib = 513382810,
2013 },
2014};
2015
2016static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2017 {
2018 .src = MSM_BUS_MASTER_VFE,
2019 .dst = MSM_BUS_SLAVE_SMI,
2020 .ab = 212336640,
2021 .ib = 339738624,
2022 },
2023 {
2024 .src = MSM_BUS_MASTER_VFE,
2025 .dst = MSM_BUS_SLAVE_EBI_CH0,
2026 .ab = 25090560,
2027 .ib = 40144896,
2028 },
2029 {
2030 .src = MSM_BUS_MASTER_VPE,
2031 .dst = MSM_BUS_SLAVE_SMI,
2032 .ab = 239708160,
2033 .ib = 383533056,
2034 },
2035 {
2036 .src = MSM_BUS_MASTER_VPE,
2037 .dst = MSM_BUS_SLAVE_EBI_CH0,
2038 .ab = 79902720,
2039 .ib = 127844352,
2040 },
2041 {
2042 .src = MSM_BUS_MASTER_JPEG_ENC,
2043 .dst = MSM_BUS_SLAVE_SMI,
2044 .ab = 0,
2045 .ib = 0,
2046 },
2047 {
2048 .src = MSM_BUS_MASTER_JPEG_ENC,
2049 .dst = MSM_BUS_SLAVE_EBI_CH0,
2050 .ab = 0,
2051 .ib = 0,
2052 },
2053};
2054
2055static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2056 {
2057 .src = MSM_BUS_MASTER_VFE,
2058 .dst = MSM_BUS_SLAVE_SMI,
2059 .ab = 0,
2060 .ib = 0,
2061 },
2062 {
2063 .src = MSM_BUS_MASTER_VFE,
2064 .dst = MSM_BUS_SLAVE_EBI_CH0,
2065 .ab = 300902400,
2066 .ib = 481443840,
2067 },
2068 {
2069 .src = MSM_BUS_MASTER_VPE,
2070 .dst = MSM_BUS_SLAVE_SMI,
2071 .ab = 230307840,
2072 .ib = 368492544,
2073 },
2074 {
2075 .src = MSM_BUS_MASTER_VPE,
2076 .dst = MSM_BUS_SLAVE_EBI_CH0,
2077 .ab = 245113344,
2078 .ib = 392181351,
2079 },
2080 {
2081 .src = MSM_BUS_MASTER_JPEG_ENC,
2082 .dst = MSM_BUS_SLAVE_SMI,
2083 .ab = 106536960,
2084 .ib = 170459136,
2085 },
2086 {
2087 .src = MSM_BUS_MASTER_JPEG_ENC,
2088 .dst = MSM_BUS_SLAVE_EBI_CH0,
2089 .ab = 106536960,
2090 .ib = 170459136,
2091 },
2092};
2093
2094static struct msm_bus_paths cam_bus_client_config[] = {
2095 {
2096 ARRAY_SIZE(cam_init_vectors),
2097 cam_init_vectors,
2098 },
2099 {
2100 ARRAY_SIZE(cam_preview_vectors),
2101 cam_preview_vectors,
2102 },
2103 {
2104 ARRAY_SIZE(cam_video_vectors),
2105 cam_video_vectors,
2106 },
2107 {
2108 ARRAY_SIZE(cam_snapshot_vectors),
2109 cam_snapshot_vectors,
2110 },
2111 {
2112 ARRAY_SIZE(cam_zsl_vectors),
2113 cam_zsl_vectors,
2114 },
2115 {
2116 ARRAY_SIZE(cam_stereo_video_vectors),
2117 cam_stereo_video_vectors,
2118 },
2119 {
2120 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2121 cam_stereo_snapshot_vectors,
2122 },
2123};
2124
2125static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2126 cam_bus_client_config,
2127 ARRAY_SIZE(cam_bus_client_config),
2128 .name = "msm_camera",
2129};
2130#endif
2131
2132struct msm_camera_device_platform_data msm_camera_device_data = {
2133 .camera_gpio_on = config_camera_on_gpios,
2134 .camera_gpio_off = config_camera_off_gpios,
2135 .ioext.csiphy = 0x04800000,
2136 .ioext.csisz = 0x00000400,
2137 .ioext.csiirq = CSI_0_IRQ,
2138 .ioclk.mclk_clk_rate = 24000000,
2139 .ioclk.vfe_clk_rate = 228570000,
2140#ifdef CONFIG_MSM_BUS_SCALING
2141 .cam_bus_scale_table = &cam_bus_client_pdata,
2142#endif
2143};
2144
2145#ifdef CONFIG_QS_S5K4E1
2146struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2147 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2148 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2149 .ioext.csiphy = 0x04800000,
2150 .ioext.csisz = 0x00000400,
2151 .ioext.csiirq = CSI_0_IRQ,
2152 .ioclk.mclk_clk_rate = 24000000,
2153 .ioclk.vfe_clk_rate = 228570000,
2154#ifdef CONFIG_MSM_BUS_SCALING
2155 .cam_bus_scale_table = &cam_bus_client_pdata,
2156#endif
2157};
2158#endif
2159
2160struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2161 .camera_gpio_on = config_camera_on_gpios_web_cam,
2162 .camera_gpio_off = config_camera_off_gpios_web_cam,
2163 .ioext.csiphy = 0x04900000,
2164 .ioext.csisz = 0x00000400,
2165 .ioext.csiirq = CSI_1_IRQ,
2166 .ioclk.mclk_clk_rate = 24000000,
2167 .ioclk.vfe_clk_rate = 228570000,
2168#ifdef CONFIG_MSM_BUS_SCALING
2169 .cam_bus_scale_table = &cam_bus_client_pdata,
2170#endif
2171};
2172
2173struct resource msm_camera_resources[] = {
2174 {
2175 .start = 0x04500000,
2176 .end = 0x04500000 + SZ_1M - 1,
2177 .flags = IORESOURCE_MEM,
2178 },
2179 {
2180 .start = VFE_IRQ,
2181 .end = VFE_IRQ,
2182 .flags = IORESOURCE_IRQ,
2183 },
2184};
2185#ifdef CONFIG_MT9E013
2186static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2187 .mount_angle = 0
2188};
2189
2190static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2191 .flash_type = MSM_CAMERA_FLASH_LED,
2192 .flash_src = &msm_flash_src
2193};
2194
2195static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2196 .sensor_name = "mt9e013",
2197 .sensor_reset = 106,
2198 .sensor_pwd = 85,
2199 .vcm_pwd = 1,
2200 .vcm_enable = 0,
2201 .pdata = &msm_camera_device_data,
2202 .resource = msm_camera_resources,
2203 .num_resources = ARRAY_SIZE(msm_camera_resources),
2204 .flash_data = &flash_mt9e013,
2205 .strobe_flash_data = &strobe_flash_xenon,
2206 .sensor_platform_info = &mt9e013_sensor_8660_info,
2207 .csi_if = 1
2208};
2209struct platform_device msm_camera_sensor_mt9e013 = {
2210 .name = "msm_camera_mt9e013",
2211 .dev = {
2212 .platform_data = &msm_camera_sensor_mt9e013_data,
2213 },
2214};
2215#endif
2216
2217#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302218static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2219 .mount_angle = 180
2220};
2221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002222static struct msm_camera_sensor_flash_data flash_imx074 = {
2223 .flash_type = MSM_CAMERA_FLASH_LED,
2224 .flash_src = &msm_flash_src
2225};
2226
2227static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2228 .sensor_name = "imx074",
2229 .sensor_reset = 106,
2230 .sensor_pwd = 85,
2231 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2232 .vcm_enable = 1,
2233 .pdata = &msm_camera_device_data,
2234 .resource = msm_camera_resources,
2235 .num_resources = ARRAY_SIZE(msm_camera_resources),
2236 .flash_data = &flash_imx074,
2237 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302238 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002239 .csi_if = 1
2240};
2241struct platform_device msm_camera_sensor_imx074 = {
2242 .name = "msm_camera_imx074",
2243 .dev = {
2244 .platform_data = &msm_camera_sensor_imx074_data,
2245 },
2246};
2247#endif
2248#ifdef CONFIG_WEBCAM_OV9726
2249
2250static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2251 .mount_angle = 0
2252};
2253
2254static struct msm_camera_sensor_flash_data flash_ov9726 = {
2255 .flash_type = MSM_CAMERA_FLASH_LED,
2256 .flash_src = &msm_flash_src
2257};
2258static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2259 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002260 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002261 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2262 .sensor_pwd = 85,
2263 .vcm_pwd = 1,
2264 .vcm_enable = 0,
2265 .pdata = &msm_camera_device_data_web_cam,
2266 .resource = msm_camera_resources,
2267 .num_resources = ARRAY_SIZE(msm_camera_resources),
2268 .flash_data = &flash_ov9726,
2269 .sensor_platform_info = &ov9726_sensor_8660_info,
2270 .csi_if = 1
2271};
2272struct platform_device msm_camera_sensor_webcam_ov9726 = {
2273 .name = "msm_camera_ov9726",
2274 .dev = {
2275 .platform_data = &msm_camera_sensor_ov9726_data,
2276 },
2277};
2278#endif
2279#ifdef CONFIG_WEBCAM_OV7692
2280static struct msm_camera_sensor_flash_data flash_ov7692 = {
2281 .flash_type = MSM_CAMERA_FLASH_LED,
2282 .flash_src = &msm_flash_src
2283};
2284static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2285 .sensor_name = "ov7692",
2286 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2287 .sensor_pwd = 85,
2288 .vcm_pwd = 1,
2289 .vcm_enable = 0,
2290 .pdata = &msm_camera_device_data_web_cam,
2291 .resource = msm_camera_resources,
2292 .num_resources = ARRAY_SIZE(msm_camera_resources),
2293 .flash_data = &flash_ov7692,
2294 .csi_if = 1
2295};
2296
2297static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2298 .name = "msm_camera_ov7692",
2299 .dev = {
2300 .platform_data = &msm_camera_sensor_ov7692_data,
2301 },
2302};
2303#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002304#ifdef CONFIG_VX6953
2305static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2306 .mount_angle = 270
2307};
2308
2309static struct msm_camera_sensor_flash_data flash_vx6953 = {
2310 .flash_type = MSM_CAMERA_FLASH_NONE,
2311 .flash_src = &msm_flash_src
2312};
2313
2314static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2315 .sensor_name = "vx6953",
2316 .sensor_reset = 63,
2317 .sensor_pwd = 63,
2318 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2319 .vcm_enable = 1,
2320 .pdata = &msm_camera_device_data,
2321 .resource = msm_camera_resources,
2322 .num_resources = ARRAY_SIZE(msm_camera_resources),
2323 .flash_data = &flash_vx6953,
2324 .sensor_platform_info = &vx6953_sensor_8660_info,
2325 .csi_if = 1
2326};
2327struct platform_device msm_camera_sensor_vx6953 = {
2328 .name = "msm_camera_vx6953",
2329 .dev = {
2330 .platform_data = &msm_camera_sensor_vx6953_data,
2331 },
2332};
2333#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002334#ifdef CONFIG_QS_S5K4E1
2335
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302336static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2337#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2338 .mount_angle = 90
2339#else
2340 .mount_angle = 0
2341#endif
2342};
2343
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002344static char eeprom_data[864];
2345static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2346 .flash_type = MSM_CAMERA_FLASH_LED,
2347 .flash_src = &msm_flash_src
2348};
2349
2350static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2351 .sensor_name = "qs_s5k4e1",
2352 .sensor_reset = 106,
2353 .sensor_pwd = 85,
2354 .vcm_pwd = 1,
2355 .vcm_enable = 0,
2356 .pdata = &msm_camera_device_data_qs_cam,
2357 .resource = msm_camera_resources,
2358 .num_resources = ARRAY_SIZE(msm_camera_resources),
2359 .flash_data = &flash_qs_s5k4e1,
2360 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302361 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002362 .csi_if = 1,
2363 .eeprom_data = eeprom_data,
2364};
2365struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2366 .name = "msm_camera_qs_s5k4e1",
2367 .dev = {
2368 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2369 },
2370};
2371#endif
2372static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2373 #ifdef CONFIG_MT9E013
2374 {
2375 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2376 },
2377 #endif
2378 #ifdef CONFIG_IMX074
2379 {
2380 I2C_BOARD_INFO("imx074", 0x1A),
2381 },
2382 #endif
2383 #ifdef CONFIG_WEBCAM_OV7692
2384 {
2385 I2C_BOARD_INFO("ov7692", 0x78),
2386 },
2387 #endif
2388 #ifdef CONFIG_WEBCAM_OV9726
2389 {
2390 I2C_BOARD_INFO("ov9726", 0x10),
2391 },
2392 #endif
2393 #ifdef CONFIG_QS_S5K4E1
2394 {
2395 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2396 },
2397 #endif
2398};
Jilai Wang971f97f2011-07-13 14:25:25 -04002399
2400static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002401 #ifdef CONFIG_WEBCAM_OV9726
2402 {
2403 I2C_BOARD_INFO("ov9726", 0x10),
2404 },
2405 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002406 #ifdef CONFIG_VX6953
2407 {
2408 I2C_BOARD_INFO("vx6953", 0x20),
2409 },
2410 #endif
2411};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002412#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002413#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002414
2415#ifdef CONFIG_MSM_GEMINI
2416static struct resource msm_gemini_resources[] = {
2417 {
2418 .start = 0x04600000,
2419 .end = 0x04600000 + SZ_1M - 1,
2420 .flags = IORESOURCE_MEM,
2421 },
2422 {
2423 .start = INT_JPEG,
2424 .end = INT_JPEG,
2425 .flags = IORESOURCE_IRQ,
2426 },
2427};
2428
2429static struct platform_device msm_gemini_device = {
2430 .name = "msm_gemini",
2431 .resource = msm_gemini_resources,
2432 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2433};
2434#endif
2435
2436#ifdef CONFIG_I2C_QUP
2437static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2438{
2439}
2440
2441static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2442 .clk_freq = 384000,
2443 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002444 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2445};
2446
2447static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2448 .clk_freq = 100000,
2449 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002450 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2451};
2452
2453static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2454 .clk_freq = 100000,
2455 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002456 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2457};
2458
2459static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2460 .clk_freq = 100000,
2461 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002462 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2463};
2464
2465static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2466 .clk_freq = 100000,
2467 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002468 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2469};
2470
2471static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2472 .clk_freq = 100000,
2473 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002474 .use_gsbi_shared_mode = 1,
2475 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2476};
2477#endif
2478
2479#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2480static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2481 .max_clock_speed = 24000000,
2482};
2483
2484static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2485 .max_clock_speed = 24000000,
2486};
2487#endif
2488
2489#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002490/* CODEC/TSSC SSBI */
2491static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2492 .controller_type = MSM_SBI_CTRL_SSBI,
2493};
2494#endif
2495
2496#ifdef CONFIG_BATTERY_MSM
2497/* Use basic value for fake MSM battery */
2498static struct msm_psy_batt_pdata msm_psy_batt_data = {
2499 .avail_chg_sources = AC_CHG,
2500};
2501
2502static struct platform_device msm_batt_device = {
2503 .name = "msm-battery",
2504 .id = -1,
2505 .dev.platform_data = &msm_psy_batt_data,
2506};
2507#endif
2508
2509#ifdef CONFIG_FB_MSM_LCDC_DSUB
2510/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2511 prim = 1024 x 600 x 4(bpp) x 2(pages)
2512 This is the difference. */
2513#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2514#else
2515#define MSM_FB_DSUB_PMEM_ADDER (0)
2516#endif
2517
2518/* Sensors DSPS platform data */
2519#ifdef CONFIG_MSM_DSPS
2520
2521static struct dsps_gpio_info dsps_surf_gpios[] = {
2522 {
2523 .name = "compass_rst_n",
2524 .num = GPIO_COMPASS_RST_N,
2525 .on_val = 1, /* device not in reset */
2526 .off_val = 0, /* device in reset */
2527 },
2528 {
2529 .name = "gpio_r_altimeter_reset_n",
2530 .num = GPIO_R_ALTIMETER_RESET_N,
2531 .on_val = 1, /* device not in reset */
2532 .off_val = 0, /* device in reset */
2533 }
2534};
2535
2536static struct dsps_gpio_info dsps_fluid_gpios[] = {
2537 {
2538 .name = "gpio_n_altimeter_reset_n",
2539 .num = GPIO_N_ALTIMETER_RESET_N,
2540 .on_val = 1, /* device not in reset */
2541 .off_val = 0, /* device in reset */
2542 }
2543};
2544
2545static void __init msm8x60_init_dsps(void)
2546{
2547 struct msm_dsps_platform_data *pdata =
2548 msm_dsps_device.dev.platform_data;
2549 /*
2550 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2551 * to the power supply and not controled via GPIOs. Fluid uses a
2552 * different IO-Expender (north) than used on surf/ffa.
2553 */
2554 if (machine_is_msm8x60_fluid()) {
2555 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002556 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002557 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002558 pdata->gpios = dsps_fluid_gpios;
2559 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2560 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002561 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002562 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002563 pdata->gpios = dsps_surf_gpios;
2564 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2565 }
2566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002567 platform_device_register(&msm_dsps_device);
2568}
2569#endif /* CONFIG_MSM_DSPS */
2570
2571#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302572#define MSM_FB_PRIM_BUF_SIZE \
2573 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002574#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302575#define MSM_FB_PRIM_BUF_SIZE \
2576 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002577#endif
2578
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002579#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302580#define MSM_FB_EXT_BUF_SIZE \
2581 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002582#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302583#define MSM_FB_EXT_BUF_SIZE \
2584 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002585#else
Ajay Singh Parmardf694562012-06-05 15:06:21 +05302586#define MSM_FB_EXT_BUF_SIZE 0
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002587#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002588
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002589/* Note: must be multiple of 4096 */
2590#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002591 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002592
2593#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302594#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002595
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002596#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002597unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002598#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002599unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002600#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002601
Huaibin Yanga5419422011-12-08 23:52:10 -08002602#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2603#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2604#else
2605#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2606#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2607
2608#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2609#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2610#else
2611#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2612#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2613
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302614#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002615#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302616#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002617
2618#define MSM_SMI_BASE 0x38000000
2619#define MSM_SMI_SIZE 0x4000000
2620
2621#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302622#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2623#define KERNEL_SMI_SIZE 0x000000
2624#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002625#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302626#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002627
2628#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2629#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2630#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2631
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302632#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
2633#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2634#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2635#define MSM_ION_MFC_SIZE SZ_8K
2636
2637#define MSM_MM_FW_BASE MSM_SMI_BASE
2638#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2639#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2640#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2641
Naseer Ahmed51860b02012-02-07 18:53:29 +05302642#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002643#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302644
Mayank Choprac22ace32012-03-03 00:45:04 +05302645#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2646#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2647#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002648#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302649#endif
2650
Olav Haugan424ff492012-03-13 11:41:23 -07002651#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002652
2653#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302654#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002655#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002656#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2657static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002658#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002659#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002660#endif
2661
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002662static unsigned fb_size;
2663static int __init fb_size_setup(char *p)
2664{
2665 fb_size = memparse(p, NULL);
2666 return 0;
2667}
2668early_param("fb_size", fb_size_setup);
2669
2670static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2671static int __init pmem_kernel_ebi1_size_setup(char *p)
2672{
2673 pmem_kernel_ebi1_size = memparse(p, NULL);
2674 return 0;
2675}
2676early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2677
2678#ifdef CONFIG_ANDROID_PMEM
2679static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2680static int __init pmem_sf_size_setup(char *p)
2681{
2682 pmem_sf_size = memparse(p, NULL);
2683 return 0;
2684}
2685early_param("pmem_sf_size", pmem_sf_size_setup);
2686
2687static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2688
2689static int __init pmem_adsp_size_setup(char *p)
2690{
2691 pmem_adsp_size = memparse(p, NULL);
2692 return 0;
2693}
2694early_param("pmem_adsp_size", pmem_adsp_size_setup);
2695
2696static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2697
2698static int __init pmem_audio_size_setup(char *p)
2699{
2700 pmem_audio_size = memparse(p, NULL);
2701 return 0;
2702}
2703early_param("pmem_audio_size", pmem_audio_size_setup);
2704#endif
2705
2706static struct resource msm_fb_resources[] = {
2707 {
2708 .flags = IORESOURCE_DMA,
2709 }
2710};
2711
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002712static void set_mdp_clocks_for_wuxga(void);
2713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002714static int msm_fb_detect_panel(const char *name)
2715{
2716 if (machine_is_msm8x60_fluid()) {
2717 uint32_t soc_platform_version = socinfo_get_platform_version();
2718 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2719#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2720 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002721 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2722 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002723 return 0;
2724#endif
2725 } else { /*P3 and up use AUO panel */
2726#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2727 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002728 strnlen(LCDC_AUO_PANEL_NAME,
2729 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002730 return 0;
2731#endif
2732 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002733#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2734 } else if machine_is_msm8x60_dragon() {
2735 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002736 strnlen(LCDC_NT35582_PANEL_NAME,
2737 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002738 return 0;
2739#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002740 } else {
2741 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002742 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2743 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002745
2746#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2747 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2748 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2749 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2750 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2751 PANEL_NAME_MAX_LEN)))
2752 return 0;
2753
2754 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2755 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2756 PANEL_NAME_MAX_LEN)))
2757 return 0;
2758
2759 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2760 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2761 PANEL_NAME_MAX_LEN)))
2762 return 0;
2763#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002764 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002765
2766 if (!strncmp(name, HDMI_PANEL_NAME,
2767 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002768 PANEL_NAME_MAX_LEN))) {
2769 if (hdmi_is_primary)
2770 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002771 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002772 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002773
2774 if (!strncmp(name, TVOUT_PANEL_NAME,
2775 strnlen(TVOUT_PANEL_NAME,
2776 PANEL_NAME_MAX_LEN)))
2777 return 0;
2778
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002779 pr_warning("%s: not supported '%s'", __func__, name);
2780 return -ENODEV;
2781}
2782
2783static struct msm_fb_platform_data msm_fb_pdata = {
2784 .detect_client = msm_fb_detect_panel,
2785};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002786
2787static struct platform_device msm_fb_device = {
2788 .name = "msm_fb",
2789 .id = 0,
2790 .num_resources = ARRAY_SIZE(msm_fb_resources),
2791 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002792 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002793};
2794
2795#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002796#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002797static struct android_pmem_platform_data android_pmem_pdata = {
2798 .name = "pmem",
2799 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2800 .cached = 1,
2801 .memory_type = MEMTYPE_EBI1,
2802};
2803
2804static struct platform_device android_pmem_device = {
2805 .name = "android_pmem",
2806 .id = 0,
2807 .dev = {.platform_data = &android_pmem_pdata},
2808};
2809
2810static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2811 .name = "pmem_adsp",
2812 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2813 .cached = 0,
2814 .memory_type = MEMTYPE_EBI1,
2815};
2816
2817static struct platform_device android_pmem_adsp_device = {
2818 .name = "android_pmem",
2819 .id = 2,
2820 .dev = { .platform_data = &android_pmem_adsp_pdata },
2821};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002823static struct android_pmem_platform_data android_pmem_audio_pdata = {
2824 .name = "pmem_audio",
2825 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2826 .cached = 0,
2827 .memory_type = MEMTYPE_EBI1,
2828};
2829
2830static struct platform_device android_pmem_audio_device = {
2831 .name = "android_pmem",
2832 .id = 4,
2833 .dev = { .platform_data = &android_pmem_audio_pdata },
2834};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302835#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002836#define PMEM_BUS_WIDTH(_bw) \
2837 { \
2838 .vectors = &(struct msm_bus_vectors){ \
2839 .src = MSM_BUS_MASTER_AMPSS_M0, \
2840 .dst = MSM_BUS_SLAVE_SMI, \
2841 .ib = (_bw), \
2842 .ab = 0, \
2843 }, \
2844 .num_paths = 1, \
2845 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002846
2847static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002848 [0] = PMEM_BUS_WIDTH(0), /* Off */
2849 [1] = PMEM_BUS_WIDTH(1), /* On */
2850};
2851
2852static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002853 .usecase = mem_smi_table,
2854 .num_usecases = ARRAY_SIZE(mem_smi_table),
2855 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002856};
2857
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002858int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002859{
2860 int bus_id = (int) data;
2861
2862 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002863 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002864}
2865
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002866int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002867{
2868 int bus_id = (int) data;
2869
2870 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002871 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002872}
2873
Alex Bird199980e2011-10-21 11:29:27 -07002874void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002875{
2876 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2877}
Olav Hauganee0f7802011-12-19 13:28:57 -08002878#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002879static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2880 .name = "pmem_smipool",
2881 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2882 .cached = 0,
2883 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002884 .request_region = request_smi_region,
2885 .release_region = release_smi_region,
2886 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002887 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002888};
2889static struct platform_device android_pmem_smipool_device = {
2890 .name = "android_pmem",
2891 .id = 7,
2892 .dev = { .platform_data = &android_pmem_smipool_pdata },
2893};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302894#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2895#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002896
2897#define GPIO_DONGLE_PWR_EN 258
2898static void setup_display_power(void);
2899static int lcdc_vga_enabled;
2900static int vga_enable_request(int enable)
2901{
2902 if (enable)
2903 lcdc_vga_enabled = 1;
2904 else
2905 lcdc_vga_enabled = 0;
2906 setup_display_power();
2907
2908 return 0;
2909}
2910
2911#define GPIO_BACKLIGHT_PWM0 0
2912#define GPIO_BACKLIGHT_PWM1 1
2913
2914static int pmic_backlight_gpio[2]
2915 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2916static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2917 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2918 .vga_switch = vga_enable_request,
2919};
2920
2921static struct platform_device lcdc_samsung_panel_device = {
2922 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2923 .id = 0,
2924 .dev = {
2925 .platform_data = &lcdc_samsung_panel_data,
2926 }
2927};
2928#if (!defined(CONFIG_SPI_QUP)) && \
2929 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2930 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2931
2932static int lcdc_spi_gpio_array_num[] = {
2933 LCDC_SPI_GPIO_CLK,
2934 LCDC_SPI_GPIO_CS,
2935 LCDC_SPI_GPIO_MOSI,
2936};
2937
2938static uint32_t lcdc_spi_gpio_config_data[] = {
2939 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2940 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2941 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2942 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2943 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2944 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2945};
2946
2947static void lcdc_config_spi_gpios(int enable)
2948{
2949 int n;
2950 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2951 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2952}
2953#endif
2954
2955#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2956#ifdef CONFIG_SPI_QUP
2957static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2958 {
2959 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2960 .mode = SPI_MODE_3,
2961 .bus_num = 1,
2962 .chip_select = 0,
2963 .max_speed_hz = 10800000,
2964 }
2965};
2966#endif /* CONFIG_SPI_QUP */
2967
2968static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2969#ifndef CONFIG_SPI_QUP
2970 .panel_config_gpio = lcdc_config_spi_gpios,
2971 .gpio_num = lcdc_spi_gpio_array_num,
2972#endif
2973};
2974
2975static struct platform_device lcdc_samsung_oled_panel_device = {
2976 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2977 .id = 0,
2978 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2979};
2980#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2981
2982#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2983#ifdef CONFIG_SPI_QUP
2984static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
2985 {
2986 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
2987 .mode = SPI_MODE_3,
2988 .bus_num = 1,
2989 .chip_select = 0,
2990 .max_speed_hz = 10800000,
2991 }
2992};
2993#endif
2994
2995static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
2996#ifndef CONFIG_SPI_QUP
2997 .panel_config_gpio = lcdc_config_spi_gpios,
2998 .gpio_num = lcdc_spi_gpio_array_num,
2999#endif
3000};
3001
3002static struct platform_device lcdc_auo_wvga_panel_device = {
3003 .name = LCDC_AUO_PANEL_NAME,
3004 .id = 0,
3005 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3006};
3007#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3008
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003009#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3010
3011#define GPIO_NT35582_RESET 94
3012#define GPIO_NT35582_BL_EN_HW_PIN 24
3013#define GPIO_NT35582_BL_EN \
3014 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3015
3016static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3017
3018static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3019 .gpio_num = lcdc_nt35582_pmic_gpio,
3020};
3021
3022static struct platform_device lcdc_nt35582_panel_device = {
3023 .name = LCDC_NT35582_PANEL_NAME,
3024 .id = 0,
3025 .dev = {
3026 .platform_data = &lcdc_nt35582_panel_data,
3027 }
3028};
3029
3030static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3031 {
3032 .modalias = "lcdc_nt35582_spi",
3033 .mode = SPI_MODE_0,
3034 .bus_num = 0,
3035 .chip_select = 0,
3036 .max_speed_hz = 1100000,
3037 }
3038};
3039#endif
3040
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003041#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3042static struct resource hdmi_msm_resources[] = {
3043 {
3044 .name = "hdmi_msm_qfprom_addr",
3045 .start = 0x00700000,
3046 .end = 0x007060FF,
3047 .flags = IORESOURCE_MEM,
3048 },
3049 {
3050 .name = "hdmi_msm_hdmi_addr",
3051 .start = 0x04A00000,
3052 .end = 0x04A00FFF,
3053 .flags = IORESOURCE_MEM,
3054 },
3055 {
3056 .name = "hdmi_msm_irq",
3057 .start = HDMI_IRQ,
3058 .end = HDMI_IRQ,
3059 .flags = IORESOURCE_IRQ,
3060 },
3061};
3062
3063static int hdmi_enable_5v(int on);
3064static int hdmi_core_power(int on, int show);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303065static int hdmi_gpio_config(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003066static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303067static int hdmi_panel_power(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003068
3069static struct msm_hdmi_platform_data hdmi_msm_data = {
3070 .irq = HDMI_IRQ,
3071 .enable_5v = hdmi_enable_5v,
3072 .core_power = hdmi_core_power,
3073 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303074 .panel_power = hdmi_panel_power,
3075 .gpio_config = hdmi_gpio_config,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003076};
3077
3078static struct platform_device hdmi_msm_device = {
3079 .name = "hdmi_msm",
3080 .id = 0,
3081 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3082 .resource = hdmi_msm_resources,
3083 .dev.platform_data = &hdmi_msm_data,
3084};
3085#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3086
3087#ifdef CONFIG_FB_MSM_MIPI_DSI
3088static struct platform_device mipi_dsi_toshiba_panel_device = {
3089 .name = "mipi_toshiba",
3090 .id = 0,
3091};
3092
3093#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3094
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003095static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003096 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003097 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003098};
3099
3100static struct platform_device mipi_dsi_novatek_panel_device = {
3101 .name = "mipi_novatek",
3102 .id = 0,
3103 .dev = {
3104 .platform_data = &novatek_pdata,
3105 }
3106};
3107#endif
3108
3109static void __init msm8x60_allocate_memory_regions(void)
3110{
3111 void *addr;
3112 unsigned long size;
3113
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003114 if (hdmi_is_primary)
3115 size = roundup((1920 * 1088 * 4 * 2), 4096);
3116 else
3117 size = MSM_FB_SIZE;
3118
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003119 addr = alloc_bootmem_align(size, 0x1000);
3120 msm_fb_resources[0].start = __pa(addr);
3121 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3122 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3123 size, addr, __pa(addr));
3124
3125}
3126
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003127void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3128{
3129 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3130 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3131 PANEL_NAME_MAX_LEN);
3132 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3133 msm_fb_pdata.prim_panel_name);
3134
3135 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3136 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3137 PANEL_NAME_MAX_LEN))) {
3138 pr_debug("HDMI is the primary display by"
3139 " boot parameter\n");
3140 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003141 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003142 }
3143 }
3144 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3145 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3146 PANEL_NAME_MAX_LEN);
3147 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3148 msm_fb_pdata.ext_panel_name);
3149 }
3150}
3151
Steve Mucklef132c6c2012-06-06 18:30:57 -07003152#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3153 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003154/*virtual key support */
3155static ssize_t tma300_vkeys_show(struct kobject *kobj,
3156 struct kobj_attribute *attr, char *buf)
3157{
3158 return sprintf(buf,
3159 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3160 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3161 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3162 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3163 "\n");
3164}
3165
3166static struct kobj_attribute tma300_vkeys_attr = {
3167 .attr = {
3168 .mode = S_IRUGO,
3169 },
3170 .show = &tma300_vkeys_show,
3171};
3172
3173static struct attribute *tma300_properties_attrs[] = {
3174 &tma300_vkeys_attr.attr,
3175 NULL
3176};
3177
3178static struct attribute_group tma300_properties_attr_group = {
3179 .attrs = tma300_properties_attrs,
3180};
3181
3182static struct kobject *properties_kobj;
3183
3184
3185
3186#define CYTTSP_TS_GPIO_IRQ 61
3187static int cyttsp_platform_init(struct i2c_client *client)
3188{
3189 int rc = -EINVAL;
3190 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3191
3192 if (machine_is_msm8x60_fluid()) {
3193 pm8058_l5 = regulator_get(NULL, "8058_l5");
3194 if (IS_ERR(pm8058_l5)) {
3195 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3196 __func__, PTR_ERR(pm8058_l5));
3197 rc = PTR_ERR(pm8058_l5);
3198 return rc;
3199 }
3200 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3201 if (rc) {
3202 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3203 __func__, rc);
3204 goto reg_l5_put;
3205 }
3206
3207 rc = regulator_enable(pm8058_l5);
3208 if (rc) {
3209 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3210 __func__, rc);
3211 goto reg_l5_put;
3212 }
3213 }
3214 /* vote for s3 to enable i2c communication lines */
3215 pm8058_s3 = regulator_get(NULL, "8058_s3");
3216 if (IS_ERR(pm8058_s3)) {
3217 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3218 __func__, PTR_ERR(pm8058_s3));
3219 rc = PTR_ERR(pm8058_s3);
3220 goto reg_l5_disable;
3221 }
3222
3223 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3224 if (rc) {
3225 pr_err("%s: regulator_set_voltage() = %d\n",
3226 __func__, rc);
3227 goto reg_s3_put;
3228 }
3229
3230 rc = regulator_enable(pm8058_s3);
3231 if (rc) {
3232 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3233 __func__, rc);
3234 goto reg_s3_put;
3235 }
3236
3237 /* wait for vregs to stabilize */
3238 usleep_range(10000, 10000);
3239
3240 /* check this device active by reading first byte/register */
3241 rc = i2c_smbus_read_byte_data(client, 0x01);
3242 if (rc < 0) {
3243 pr_err("%s: i2c sanity check failed\n", __func__);
3244 goto reg_s3_disable;
3245 }
3246
3247 /* virtual keys */
3248 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003249 properties_kobj = kobject_create_and_add("board_properties",
3250 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003251 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003252 if (!properties_kobj || rc)
3253 pr_err("%s: failed to create board_properties\n",
3254 __func__);
3255 }
3256 return CY_OK;
3257
3258reg_s3_disable:
3259 regulator_disable(pm8058_s3);
3260reg_s3_put:
3261 regulator_put(pm8058_s3);
3262reg_l5_disable:
3263 if (machine_is_msm8x60_fluid())
3264 regulator_disable(pm8058_l5);
3265reg_l5_put:
3266 if (machine_is_msm8x60_fluid())
3267 regulator_put(pm8058_l5);
3268 return rc;
3269}
3270
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303271/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3272static int cyttsp_platform_suspend(struct i2c_client *client)
3273{
3274 msleep(20);
3275
3276 return CY_OK;
3277}
3278
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003279static int cyttsp_platform_resume(struct i2c_client *client)
3280{
3281 /* add any special code to strobe a wakeup pin or chip reset */
3282 msleep(10);
3283
3284 return CY_OK;
3285}
3286
3287static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3288 .flags = 0x04,
3289 .gen = CY_GEN3, /* or */
3290 .use_st = CY_USE_ST,
3291 .use_mt = CY_USE_MT,
3292 .use_hndshk = CY_SEND_HNDSHK,
3293 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303294 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003295 .use_gestures = CY_USE_GESTURES,
3296 /* activate up to 4 groups
3297 * and set active distance
3298 */
3299 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3300 CY_GEST_GRP3 | CY_GEST_GRP4 |
3301 CY_ACT_DIST,
3302 /* change act_intrvl to customize the Active power state
3303 * scanning/processing refresh interval for Operating mode
3304 */
3305 .act_intrvl = CY_ACT_INTRVL_DFLT,
3306 /* change tch_tmout to customize the touch timeout for the
3307 * Active power state for Operating mode
3308 */
3309 .tch_tmout = CY_TCH_TMOUT_DFLT,
3310 /* change lp_intrvl to customize the Low Power power state
3311 * scanning/processing refresh interval for Operating mode
3312 */
3313 .lp_intrvl = CY_LP_INTRVL_DFLT,
3314 .sleep_gpio = -1,
3315 .resout_gpio = -1,
3316 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3317 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303318 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003319 .init = cyttsp_platform_init,
3320};
3321
3322static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3323 .panel_maxx = 1083,
3324 .panel_maxy = 659,
3325 .disp_minx = 30,
3326 .disp_maxx = 1053,
3327 .disp_miny = 30,
3328 .disp_maxy = 629,
3329 .correct_fw_ver = 8,
3330 .fw_fname = "cyttsp_8660_ffa.hex",
3331 .flags = 0x00,
3332 .gen = CY_GEN2, /* or */
3333 .use_st = CY_USE_ST,
3334 .use_mt = CY_USE_MT,
3335 .use_hndshk = CY_SEND_HNDSHK,
3336 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303337 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003338 .use_gestures = CY_USE_GESTURES,
3339 /* activate up to 4 groups
3340 * and set active distance
3341 */
3342 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3343 CY_GEST_GRP3 | CY_GEST_GRP4 |
3344 CY_ACT_DIST,
3345 /* change act_intrvl to customize the Active power state
3346 * scanning/processing refresh interval for Operating mode
3347 */
3348 .act_intrvl = CY_ACT_INTRVL_DFLT,
3349 /* change tch_tmout to customize the touch timeout for the
3350 * Active power state for Operating mode
3351 */
3352 .tch_tmout = CY_TCH_TMOUT_DFLT,
3353 /* change lp_intrvl to customize the Low Power power state
3354 * scanning/processing refresh interval for Operating mode
3355 */
3356 .lp_intrvl = CY_LP_INTRVL_DFLT,
3357 .sleep_gpio = -1,
3358 .resout_gpio = -1,
3359 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3360 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303361 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003362 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303363 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364};
3365static void cyttsp_set_params(void)
3366{
3367 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3368 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3369 cyttsp_fluid_pdata.panel_maxx = 539;
3370 cyttsp_fluid_pdata.panel_maxy = 994;
3371 cyttsp_fluid_pdata.disp_minx = 30;
3372 cyttsp_fluid_pdata.disp_maxx = 509;
3373 cyttsp_fluid_pdata.disp_miny = 60;
3374 cyttsp_fluid_pdata.disp_maxy = 859;
3375 cyttsp_fluid_pdata.correct_fw_ver = 4;
3376 } else {
3377 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3378 cyttsp_fluid_pdata.panel_maxx = 550;
3379 cyttsp_fluid_pdata.panel_maxy = 1013;
3380 cyttsp_fluid_pdata.disp_minx = 35;
3381 cyttsp_fluid_pdata.disp_maxx = 515;
3382 cyttsp_fluid_pdata.disp_miny = 69;
3383 cyttsp_fluid_pdata.disp_maxy = 869;
3384 cyttsp_fluid_pdata.correct_fw_ver = 5;
3385 }
3386
3387}
3388
3389static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3390 {
3391 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3392 .platform_data = &cyttsp_fluid_pdata,
3393#ifndef CY_USE_TIMER
3394 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3395#endif /* CY_USE_TIMER */
3396 },
3397};
3398
3399static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3400 {
3401 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3402 .platform_data = &cyttsp_tmg240_pdata,
3403#ifndef CY_USE_TIMER
3404 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3405#endif /* CY_USE_TIMER */
3406 },
3407};
3408#endif
3409
3410static struct regulator *vreg_tmg200;
3411
3412#define TS_PEN_IRQ_GPIO 61
3413static int tmg200_power(int vreg_on)
3414{
3415 int rc = -EINVAL;
3416
3417 if (!vreg_tmg200) {
3418 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3419 __func__, rc);
3420 return rc;
3421 }
3422
3423 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3424 regulator_disable(vreg_tmg200);
3425 if (rc < 0)
3426 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3427 __func__, vreg_on ? "enable" : "disable", rc);
3428
3429 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003430 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431
3432 return rc;
3433}
3434
3435static int tmg200_dev_setup(bool enable)
3436{
3437 int rc;
3438
3439 if (enable) {
3440 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3441 if (IS_ERR(vreg_tmg200)) {
3442 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3443 __func__, PTR_ERR(vreg_tmg200));
3444 rc = PTR_ERR(vreg_tmg200);
3445 return rc;
3446 }
3447
3448 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3449 if (rc) {
3450 pr_err("%s: regulator_set_voltage() = %d\n",
3451 __func__, rc);
3452 goto reg_put;
3453 }
3454 } else {
3455 /* put voltage sources */
3456 regulator_put(vreg_tmg200);
3457 }
3458 return 0;
3459reg_put:
3460 regulator_put(vreg_tmg200);
3461 return rc;
3462}
3463
3464static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3465 .ts_name = "msm_tmg200_ts",
3466 .dis_min_x = 0,
3467 .dis_max_x = 1023,
3468 .dis_min_y = 0,
3469 .dis_max_y = 599,
3470 .min_tid = 0,
3471 .max_tid = 255,
3472 .min_touch = 0,
3473 .max_touch = 255,
3474 .min_width = 0,
3475 .max_width = 255,
3476 .power_on = tmg200_power,
3477 .dev_setup = tmg200_dev_setup,
3478 .nfingers = 2,
3479 .irq_gpio = TS_PEN_IRQ_GPIO,
3480 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3481};
3482
3483static struct i2c_board_info cy8ctmg200_board_info[] = {
3484 {
3485 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3486 .platform_data = &cy8ctmg200_pdata,
3487 }
3488};
3489
Zhang Chang Ken211df572011-07-05 19:16:39 -04003490static struct regulator *vreg_tma340;
3491
3492static int tma340_power(int vreg_on)
3493{
3494 int rc = -EINVAL;
3495
3496 if (!vreg_tma340) {
3497 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3498 __func__, rc);
3499 return rc;
3500 }
3501
3502 rc = vreg_on ? regulator_enable(vreg_tma340) :
3503 regulator_disable(vreg_tma340);
3504 if (rc < 0)
3505 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3506 __func__, vreg_on ? "enable" : "disable", rc);
3507
3508 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003509 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003510
3511 return rc;
3512}
3513
3514static struct kobject *tma340_prop_kobj;
3515
3516static int tma340_dragon_dev_setup(bool enable)
3517{
3518 int rc;
3519
3520 if (enable) {
3521 vreg_tma340 = regulator_get(NULL, "8901_l2");
3522 if (IS_ERR(vreg_tma340)) {
3523 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3524 __func__, PTR_ERR(vreg_tma340));
3525 rc = PTR_ERR(vreg_tma340);
3526 return rc;
3527 }
3528
3529 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3530 if (rc) {
3531 pr_err("%s: regulator_set_voltage() = %d\n",
3532 __func__, rc);
3533 goto reg_put;
3534 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003535 tma340_prop_kobj = kobject_create_and_add("board_properties",
3536 NULL);
3537 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003538 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003539 if (rc) {
3540 kobject_put(tma340_prop_kobj);
3541 pr_err("%s: failed to create board_properties\n",
3542 __func__);
3543 goto reg_put;
3544 }
3545 }
3546
3547 } else {
3548 /* put voltage sources */
3549 regulator_put(vreg_tma340);
3550 /* destroy virtual keys */
3551 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003552 kobject_put(tma340_prop_kobj);
3553 }
3554 }
3555 return 0;
3556reg_put:
3557 regulator_put(vreg_tma340);
3558 return rc;
3559}
3560
3561
3562static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3563 .ts_name = "cy8ctma340",
3564 .dis_min_x = 0,
3565 .dis_max_x = 479,
3566 .dis_min_y = 0,
3567 .dis_max_y = 799,
3568 .min_tid = 0,
3569 .max_tid = 255,
3570 .min_touch = 0,
3571 .max_touch = 255,
3572 .min_width = 0,
3573 .max_width = 255,
3574 .power_on = tma340_power,
3575 .dev_setup = tma340_dragon_dev_setup,
3576 .nfingers = 2,
3577 .irq_gpio = TS_PEN_IRQ_GPIO,
3578 .resout_gpio = -1,
3579};
3580
3581static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3582 {
3583 I2C_BOARD_INFO("cy8ctma340", 0x24),
3584 .platform_data = &cy8ctma340_dragon_pdata,
3585 }
3586};
3587
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003588#ifdef CONFIG_SERIAL_MSM_HS
3589static int configure_uart_gpios(int on)
3590{
3591 int ret = 0, i;
3592 int uart_gpios[] = {53, 54, 55, 56};
3593 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3594 if (on) {
3595 ret = msm_gpiomux_get(uart_gpios[i]);
3596 if (unlikely(ret))
3597 break;
3598 } else {
3599 ret = msm_gpiomux_put(uart_gpios[i]);
3600 if (unlikely(ret))
3601 return ret;
3602 }
3603 }
3604 if (ret)
3605 for (; i >= 0; i--)
3606 msm_gpiomux_put(uart_gpios[i]);
3607 return ret;
3608}
3609static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3610 .inject_rx_on_wakeup = 1,
3611 .rx_to_inject = 0xFD,
3612 .gpio_config = configure_uart_gpios,
3613};
3614#endif
3615
3616
3617#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3618
3619static struct gpio_led gpio_exp_leds_config[] = {
3620 {
3621 .name = "left_led1:green",
3622 .gpio = GPIO_LEFT_LED_1,
3623 .active_low = 1,
3624 .retain_state_suspended = 0,
3625 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3626 },
3627 {
3628 .name = "left_led2:red",
3629 .gpio = GPIO_LEFT_LED_2,
3630 .active_low = 1,
3631 .retain_state_suspended = 0,
3632 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3633 },
3634 {
3635 .name = "left_led3:green",
3636 .gpio = GPIO_LEFT_LED_3,
3637 .active_low = 1,
3638 .retain_state_suspended = 0,
3639 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3640 },
3641 {
3642 .name = "wlan_led:orange",
3643 .gpio = GPIO_LEFT_LED_WLAN,
3644 .active_low = 1,
3645 .retain_state_suspended = 0,
3646 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3647 },
3648 {
3649 .name = "left_led5:green",
3650 .gpio = GPIO_LEFT_LED_5,
3651 .active_low = 1,
3652 .retain_state_suspended = 0,
3653 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3654 },
3655 {
3656 .name = "right_led1:green",
3657 .gpio = GPIO_RIGHT_LED_1,
3658 .active_low = 1,
3659 .retain_state_suspended = 0,
3660 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3661 },
3662 {
3663 .name = "right_led2:red",
3664 .gpio = GPIO_RIGHT_LED_2,
3665 .active_low = 1,
3666 .retain_state_suspended = 0,
3667 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3668 },
3669 {
3670 .name = "right_led3:green",
3671 .gpio = GPIO_RIGHT_LED_3,
3672 .active_low = 1,
3673 .retain_state_suspended = 0,
3674 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3675 },
3676 {
3677 .name = "bt_led:blue",
3678 .gpio = GPIO_RIGHT_LED_BT,
3679 .active_low = 1,
3680 .retain_state_suspended = 0,
3681 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3682 },
3683 {
3684 .name = "right_led5:green",
3685 .gpio = GPIO_RIGHT_LED_5,
3686 .active_low = 1,
3687 .retain_state_suspended = 0,
3688 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3689 },
3690};
3691
3692static struct gpio_led_platform_data gpio_leds_pdata = {
3693 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3694 .leds = gpio_exp_leds_config,
3695};
3696
3697static struct platform_device gpio_leds = {
3698 .name = "leds-gpio",
3699 .id = -1,
3700 .dev = {
3701 .platform_data = &gpio_leds_pdata,
3702 },
3703};
3704
3705static struct gpio_led fluid_gpio_leds[] = {
3706 {
3707 .name = "dual_led:green",
3708 .gpio = GPIO_LED1_GREEN_N,
3709 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3710 .active_low = 1,
3711 .retain_state_suspended = 0,
3712 },
3713 {
3714 .name = "dual_led:red",
3715 .gpio = GPIO_LED2_RED_N,
3716 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3717 .active_low = 1,
3718 .retain_state_suspended = 0,
3719 },
3720};
3721
3722static struct gpio_led_platform_data gpio_led_pdata = {
3723 .leds = fluid_gpio_leds,
3724 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3725};
3726
3727static struct platform_device fluid_leds_gpio = {
3728 .name = "leds-gpio",
3729 .id = -1,
3730 .dev = {
3731 .platform_data = &gpio_led_pdata,
3732 },
3733};
3734
3735#endif
3736
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003737#ifdef CONFIG_BATTERY_MSM8X60
3738static struct msm_charger_platform_data msm_charger_data = {
3739 .safety_time = 180,
3740 .update_time = 1,
3741 .max_voltage = 4200,
3742 .min_voltage = 3200,
3743};
3744
3745static struct platform_device msm_charger_device = {
3746 .name = "msm-charger",
3747 .id = -1,
3748 .dev = {
3749 .platform_data = &msm_charger_data,
3750 }
3751};
3752#endif
3753
3754/*
3755 * Consumer specific regulator names:
3756 * regulator name consumer dev_name
3757 */
3758static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3759 REGULATOR_SUPPLY("8058_l0", NULL),
3760};
3761static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3762 REGULATOR_SUPPLY("8058_l1", NULL),
3763};
3764static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3765 REGULATOR_SUPPLY("8058_l2", NULL),
3766};
3767static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3768 REGULATOR_SUPPLY("8058_l3", NULL),
3769};
3770static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3771 REGULATOR_SUPPLY("8058_l4", NULL),
3772};
3773static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3774 REGULATOR_SUPPLY("8058_l5", NULL),
3775};
3776static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3777 REGULATOR_SUPPLY("8058_l6", NULL),
3778};
3779static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3780 REGULATOR_SUPPLY("8058_l7", NULL),
3781};
3782static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3783 REGULATOR_SUPPLY("8058_l8", NULL),
3784};
3785static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3786 REGULATOR_SUPPLY("8058_l9", NULL),
3787};
3788static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3789 REGULATOR_SUPPLY("8058_l10", NULL),
3790};
3791static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3792 REGULATOR_SUPPLY("8058_l11", NULL),
3793};
3794static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3795 REGULATOR_SUPPLY("8058_l12", NULL),
3796};
3797static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3798 REGULATOR_SUPPLY("8058_l13", NULL),
3799};
3800static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3801 REGULATOR_SUPPLY("8058_l14", NULL),
3802};
3803static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3804 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003805 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003806 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003807 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003808};
3809static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3810 REGULATOR_SUPPLY("8058_l16", NULL),
3811};
3812static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3813 REGULATOR_SUPPLY("8058_l17", NULL),
3814};
3815static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3816 REGULATOR_SUPPLY("8058_l18", NULL),
3817};
3818static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3819 REGULATOR_SUPPLY("8058_l19", NULL),
3820};
3821static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3822 REGULATOR_SUPPLY("8058_l20", NULL),
3823};
3824static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3825 REGULATOR_SUPPLY("8058_l21", NULL),
3826};
3827static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3828 REGULATOR_SUPPLY("8058_l22", NULL),
3829};
3830static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3831 REGULATOR_SUPPLY("8058_l23", NULL),
3832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3834 REGULATOR_SUPPLY("8058_l24", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3837 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003838 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003839 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003840 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3843 REGULATOR_SUPPLY("8058_s0", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3846 REGULATOR_SUPPLY("8058_s1", NULL),
3847};
3848static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3849 REGULATOR_SUPPLY("8058_s2", NULL),
3850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3852 REGULATOR_SUPPLY("8058_s3", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3855 REGULATOR_SUPPLY("8058_s4", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3858 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003859 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003860 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003861 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003862};
3863static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3864 REGULATOR_SUPPLY("8058_lvs1", NULL),
3865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3867 REGULATOR_SUPPLY("8058_ncp", NULL),
3868};
3869
3870static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3871 REGULATOR_SUPPLY("8901_l0", NULL),
3872};
3873static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3874 REGULATOR_SUPPLY("8901_l1", NULL),
3875};
3876static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3877 REGULATOR_SUPPLY("8901_l2", NULL),
3878};
3879static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3880 REGULATOR_SUPPLY("8901_l3", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3883 REGULATOR_SUPPLY("8901_l4", NULL),
3884};
3885static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3886 REGULATOR_SUPPLY("8901_l5", NULL),
3887};
3888static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3889 REGULATOR_SUPPLY("8901_l6", NULL),
3890};
3891static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3892 REGULATOR_SUPPLY("8901_s2", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3895 REGULATOR_SUPPLY("8901_s3", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3898 REGULATOR_SUPPLY("8901_s4", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3901 REGULATOR_SUPPLY("8901_lvs0", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3904 REGULATOR_SUPPLY("8901_lvs1", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3907 REGULATOR_SUPPLY("8901_lvs2", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3910 REGULATOR_SUPPLY("8901_lvs3", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3913 REGULATOR_SUPPLY("8901_mvs0", NULL),
3914};
3915
David Collins6f032ba2011-08-31 14:08:15 -07003916/* Pin control regulators */
3917static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3918 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3919};
3920static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3921 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3922};
3923static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3924 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3925};
3926static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3927 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3930 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3933 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3934};
3935
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003936#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3937 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003938 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3939 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003940 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003941 .init_data = { \
3942 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003943 .valid_modes_mask = _modes, \
3944 .valid_ops_mask = _ops, \
3945 .min_uV = _min_uV, \
3946 .max_uV = _max_uV, \
3947 .input_uV = _min_uV, \
3948 .apply_uV = _apply_uV, \
3949 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003950 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003951 .consumer_supplies = vreg_consumers_##_id, \
3952 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003953 ARRAY_SIZE(vreg_consumers_##_id), \
3954 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003955 .id = RPM_VREG_ID_##_id, \
3956 .default_uV = _default_uV, \
3957 .peak_uA = _peak_uA, \
3958 .avg_uA = _avg_uA, \
3959 .pull_down_enable = _pull_down, \
3960 .pin_ctrl = _pin_ctrl, \
3961 .freq = RPM_VREG_FREQ_##_freq, \
3962 .pin_fn = _pin_fn, \
3963 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003964 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003965 .state = _state, \
3966 .sleep_selectable = _sleep_selectable, \
3967 }
3968
3969/* Pin control initialization */
3970#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3971 { \
3972 .init_data = { \
3973 .constraints = { \
3974 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3975 .always_on = _always_on, \
3976 }, \
3977 .num_consumer_supplies = \
3978 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3979 .consumer_supplies = vreg_consumers_##_id##_PC, \
3980 }, \
3981 .id = RPM_VREG_ID_##_id##_PC, \
3982 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003983 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003984 }
3985
3986/*
3987 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3988 * via the peak_uA value specified in the table below. If the value is less
3989 * than the high power min threshold for the regulator, then the regulator will
3990 * be set to LPM. Otherwise, it will be set to HPM.
3991 *
3992 * This value can be further overridden by specifying an initial mode via
3993 * .init_data.constraints.initial_mode.
3994 */
3995
David Collins6f032ba2011-08-31 14:08:15 -07003996#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
3997 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003998 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
3999 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4000 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4001 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4002 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004003 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4004 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004005 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004006 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004007 _sleep_selectable, _always_on)
4008
David Collins6f032ba2011-08-31 14:08:15 -07004009#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4010 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004011 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4012 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4013 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4014 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4015 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004016 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4017 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004018 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004019 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4020 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004021
David Collins6f032ba2011-08-31 14:08:15 -07004022#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004023 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4024 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004025 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4026 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004027 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004028 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4029 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030
David Collins6f032ba2011-08-31 14:08:15 -07004031#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004032 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4033 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004034 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4035 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004036 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004037 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4038 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004039
David Collins6f032ba2011-08-31 14:08:15 -07004040#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4041#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4042#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4043#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4044#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045
David Collins6f032ba2011-08-31 14:08:15 -07004046/* RPM early regulator constraints */
4047static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4048 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004049 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004050 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004051};
4052
David Collins6f032ba2011-08-31 14:08:15 -07004053/* RPM regulator constraints */
4054static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4055 /* ID a_on pd ss min_uV max_uV init_ip */
4056 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4057 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4058 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4059 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4060 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4061 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4062 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4063 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4064 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4065 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4066 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4067 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4068 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4069 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4070 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4071 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4072 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4073 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4074 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4075 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4076 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4077 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4078 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4079 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4080 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4081 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004082
David Collins6f032ba2011-08-31 14:08:15 -07004083 /* ID a_on pd ss min_uV max_uV init_ip freq */
4084 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4085 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4086 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4087
4088 /* ID a_on pd ss */
4089 RPM_VS(PM8058_LVS0, 0, 1, 0),
4090 RPM_VS(PM8058_LVS1, 0, 1, 0),
4091
4092 /* ID a_on pd ss min_uV max_uV */
4093 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4094
4095 /* ID a_on pd ss min_uV max_uV init_ip */
4096 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4097 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4098 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4099 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4100 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4101 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4102 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4103
4104 /* ID a_on pd ss min_uV max_uV init_ip freq */
4105 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4106 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4107 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4108
4109 /* ID a_on pd ss */
4110 RPM_VS(PM8901_LVS0, 1, 1, 0),
4111 RPM_VS(PM8901_LVS1, 0, 1, 0),
4112 RPM_VS(PM8901_LVS2, 0, 1, 0),
4113 RPM_VS(PM8901_LVS3, 0, 1, 0),
4114 RPM_VS(PM8901_MVS0, 0, 1, 0),
4115
4116 /* ID a_on pin_func pin_ctrl */
4117 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4118 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4119 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4120 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4121 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4122 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4123};
4124
4125static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4126 .init_data = rpm_regulator_early_init_data,
4127 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4128 .version = RPM_VREG_VERSION_8660,
4129 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4130 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4131};
4132
4133static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4134 .init_data = rpm_regulator_init_data,
4135 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4136 .version = RPM_VREG_VERSION_8660,
4137};
4138
4139static struct platform_device rpm_regulator_early_device = {
4140 .name = "rpm-regulator",
4141 .id = 0,
4142 .dev = {
4143 .platform_data = &rpm_regulator_early_pdata,
4144 },
4145};
4146
4147static struct platform_device rpm_regulator_device = {
4148 .name = "rpm-regulator",
4149 .id = 1,
4150 .dev = {
4151 .platform_data = &rpm_regulator_pdata,
4152 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004153};
4154
4155static struct platform_device *early_regulators[] __initdata = {
4156 &msm_device_saw_s0,
4157 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004158 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004159};
4160
4161static struct platform_device *early_devices[] __initdata = {
4162#ifdef CONFIG_MSM_BUS_SCALING
4163 &msm_bus_apps_fabric,
4164 &msm_bus_sys_fabric,
4165 &msm_bus_mm_fabric,
4166 &msm_bus_sys_fpb,
4167 &msm_bus_cpss_fpb,
4168#endif
4169 &msm_device_dmov_adm0,
4170 &msm_device_dmov_adm1,
4171};
4172
4173#if (defined(CONFIG_MARIMBA_CORE)) && \
4174 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4175
4176static int bluetooth_power(int);
4177static struct platform_device msm_bt_power_device = {
4178 .name = "bt_power",
4179 .id = -1,
4180 .dev = {
4181 .platform_data = &bluetooth_power,
4182 },
4183};
4184#endif
4185
4186static struct platform_device msm_tsens_device = {
4187 .name = "tsens-tm",
4188 .id = -1,
4189};
4190
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004191#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4192enum {
4193 SX150X_CORE,
4194 SX150X_DOCKING,
4195 SX150X_SURF,
4196 SX150X_LEFT_FHA,
4197 SX150X_RIGHT_FHA,
4198 SX150X_SOUTH,
4199 SX150X_NORTH,
4200 SX150X_CORE_FLUID,
4201};
4202
4203static struct sx150x_platform_data sx150x_data[] __initdata = {
4204 [SX150X_CORE] = {
4205 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4206 .oscio_is_gpo = false,
4207 .io_pullup_ena = 0x0c08,
4208 .io_pulldn_ena = 0x4060,
4209 .io_open_drain_ena = 0x000c,
4210 .io_polarity = 0,
4211 .irq_summary = -1, /* see fixup_i2c_configs() */
4212 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4213 },
4214 [SX150X_DOCKING] = {
4215 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4216 .oscio_is_gpo = false,
4217 .io_pullup_ena = 0x5e06,
4218 .io_pulldn_ena = 0x81b8,
4219 .io_open_drain_ena = 0,
4220 .io_polarity = 0,
4221 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4222 UI_INT2_N),
4223 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4224 GPIO_DOCKING_EXPANDER_BASE -
4225 GPIO_EXPANDER_GPIO_BASE,
4226 },
4227 [SX150X_SURF] = {
4228 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4229 .oscio_is_gpo = false,
4230 .io_pullup_ena = 0,
4231 .io_pulldn_ena = 0,
4232 .io_open_drain_ena = 0,
4233 .io_polarity = 0,
4234 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4235 UI_INT1_N),
4236 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4237 GPIO_SURF_EXPANDER_BASE -
4238 GPIO_EXPANDER_GPIO_BASE,
4239 },
4240 [SX150X_LEFT_FHA] = {
4241 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4242 .oscio_is_gpo = false,
4243 .io_pullup_ena = 0,
4244 .io_pulldn_ena = 0x40,
4245 .io_open_drain_ena = 0,
4246 .io_polarity = 0,
4247 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4248 UI_INT3_N),
4249 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4250 GPIO_LEFT_KB_EXPANDER_BASE -
4251 GPIO_EXPANDER_GPIO_BASE,
4252 },
4253 [SX150X_RIGHT_FHA] = {
4254 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4255 .oscio_is_gpo = true,
4256 .io_pullup_ena = 0,
4257 .io_pulldn_ena = 0,
4258 .io_open_drain_ena = 0,
4259 .io_polarity = 0,
4260 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4261 UI_INT3_N),
4262 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4263 GPIO_RIGHT_KB_EXPANDER_BASE -
4264 GPIO_EXPANDER_GPIO_BASE,
4265 },
4266 [SX150X_SOUTH] = {
4267 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4268 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4269 GPIO_SOUTH_EXPANDER_BASE -
4270 GPIO_EXPANDER_GPIO_BASE,
4271 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4272 },
4273 [SX150X_NORTH] = {
4274 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4275 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4276 GPIO_NORTH_EXPANDER_BASE -
4277 GPIO_EXPANDER_GPIO_BASE,
4278 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4279 .oscio_is_gpo = true,
4280 .io_open_drain_ena = 0x30,
4281 },
4282 [SX150X_CORE_FLUID] = {
4283 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4284 .oscio_is_gpo = false,
4285 .io_pullup_ena = 0x0408,
4286 .io_pulldn_ena = 0x4060,
4287 .io_open_drain_ena = 0x0008,
4288 .io_polarity = 0,
4289 .irq_summary = -1, /* see fixup_i2c_configs() */
4290 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4291 },
4292};
4293
4294#ifdef CONFIG_SENSORS_MSM_ADC
4295/* Configuration of EPM expander is done when client
4296 * request an adc read
4297 */
4298static struct sx150x_platform_data sx150x_epmdata = {
4299 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4300 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4301 GPIO_EPM_EXPANDER_BASE -
4302 GPIO_EXPANDER_GPIO_BASE,
4303 .irq_summary = -1,
4304};
4305#endif
4306
4307/* sx150x_low_power_cfg
4308 *
4309 * This data and init function are used to put unused gpio-expander output
4310 * lines into their low-power states at boot. The init
4311 * function must be deferred until a later init stage because the i2c
4312 * gpio expander drivers do not probe until after they are registered
4313 * (see register_i2c_devices) and the work-queues for those registrations
4314 * are processed. Because these lines are unused, there is no risk of
4315 * competing with a device driver for the gpio.
4316 *
4317 * gpio lines whose low-power states are input are naturally in their low-
4318 * power configurations once probed, see the platform data structures above.
4319 */
4320struct sx150x_low_power_cfg {
4321 unsigned gpio;
4322 unsigned val;
4323};
4324
4325static struct sx150x_low_power_cfg
4326common_sx150x_lp_cfgs[] __initdata = {
4327 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4328 {GPIO_EXT_GPS_LNA_EN, 0},
4329 {GPIO_MSM_WAKES_BT, 0},
4330 {GPIO_USB_UICC_EN, 0},
4331 {GPIO_BATT_GAUGE_EN, 0},
4332};
4333
4334static struct sx150x_low_power_cfg
4335surf_ffa_sx150x_lp_cfgs[] __initdata = {
4336 {GPIO_MIPI_DSI_RST_N, 0},
4337 {GPIO_DONGLE_PWR_EN, 0},
4338 {GPIO_CAP_TS_SLEEP, 1},
4339 {GPIO_WEB_CAMIF_RESET_N, 0},
4340};
4341
4342static void __init
4343cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4344{
4345 unsigned n;
4346 int rc;
4347
4348 for (n = 0; n < nelems; ++n) {
4349 rc = gpio_request(cfgs[n].gpio, NULL);
4350 if (!rc) {
4351 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4352 gpio_free(cfgs[n].gpio);
4353 }
4354
4355 if (rc) {
4356 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4357 __func__, cfgs[n].gpio, rc);
4358 }
Steve Muckle9161d302010-02-11 11:50:40 -08004359 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004360}
4361
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004363{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004364 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4365 ARRAY_SIZE(common_sx150x_lp_cfgs));
4366 if (!machine_is_msm8x60_fluid())
4367 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4368 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4369 return 0;
4370}
4371module_init(cfg_sx150xs_low_power);
4372
4373#ifdef CONFIG_I2C
4374static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4375 {
4376 I2C_BOARD_INFO("sx1509q", 0x3e),
4377 .platform_data = &sx150x_data[SX150X_CORE]
4378 },
4379};
4380
4381static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4382 {
4383 I2C_BOARD_INFO("sx1509q", 0x3f),
4384 .platform_data = &sx150x_data[SX150X_DOCKING]
4385 },
4386};
4387
4388static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4389 {
4390 I2C_BOARD_INFO("sx1509q", 0x70),
4391 .platform_data = &sx150x_data[SX150X_SURF]
4392 }
4393};
4394
4395static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4396 {
4397 I2C_BOARD_INFO("sx1508q", 0x21),
4398 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4399 },
4400 {
4401 I2C_BOARD_INFO("sx1508q", 0x22),
4402 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4403 }
4404};
4405
4406static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4407 {
4408 I2C_BOARD_INFO("sx1508q", 0x23),
4409 .platform_data = &sx150x_data[SX150X_SOUTH]
4410 },
4411 {
4412 I2C_BOARD_INFO("sx1508q", 0x20),
4413 .platform_data = &sx150x_data[SX150X_NORTH]
4414 }
4415};
4416
4417static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4418 {
4419 I2C_BOARD_INFO("sx1509q", 0x3e),
4420 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4421 },
4422};
4423
4424#ifdef CONFIG_SENSORS_MSM_ADC
4425static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4426 {
4427 I2C_BOARD_INFO("sx1509q", 0x3e),
4428 .platform_data = &sx150x_epmdata
4429 },
4430};
4431#endif
4432#endif
4433#endif
4434
4435#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436
4437static struct adc_access_fn xoadc_fn = {
4438 pm8058_xoadc_select_chan_and_start_conv,
4439 pm8058_xoadc_read_adc_code,
4440 pm8058_xoadc_get_properties,
4441 pm8058_xoadc_slot_request,
4442 pm8058_xoadc_restore_slot,
4443 pm8058_xoadc_calibrate,
4444};
4445
4446#if defined(CONFIG_I2C) && \
4447 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4448static struct regulator *vreg_adc_epm1;
4449
4450static struct i2c_client *epm_expander_i2c_register_board(void)
4451
4452{
4453 struct i2c_adapter *i2c_adap;
4454 struct i2c_client *client = NULL;
4455 i2c_adap = i2c_get_adapter(0x0);
4456
4457 if (i2c_adap == NULL)
4458 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4459
4460 if (i2c_adap != NULL)
4461 client = i2c_new_device(i2c_adap,
4462 &fluid_expanders_i2c_epm_info[0]);
4463 return client;
4464
4465}
4466
4467static unsigned int msm_adc_gpio_configure_expander_enable(void)
4468{
4469 int rc = 0;
4470 static struct i2c_client *epm_i2c_client;
4471
4472 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4473
4474 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4475
4476 if (IS_ERR(vreg_adc_epm1)) {
4477 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4478 return 0;
4479 }
4480
4481 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4482 if (rc)
4483 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4484 "regulator set voltage failed\n");
4485
4486 rc = regulator_enable(vreg_adc_epm1);
4487 if (rc) {
4488 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4489 "Error while enabling regulator for epm s3 %d\n", rc);
4490 return rc;
4491 }
4492
4493 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4494 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4495
4496 msleep(1000);
4497
4498 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4499 if (!rc) {
4500 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4501 "Configure 5v boost\n");
4502 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4503 } else {
4504 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4505 "Error for epm 5v boost en\n");
4506 goto exit_vreg_epm;
4507 }
4508
4509 msleep(500);
4510
4511 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4512 if (!rc) {
4513 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4514 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4515 "Configure epm 3.3v\n");
4516 } else {
4517 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4518 "Error for gpio 3.3ven\n");
4519 goto exit_vreg_epm;
4520 }
4521 msleep(500);
4522
4523 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4524 "Trying to request EPM LVLSFT_EN\n");
4525 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4526 if (!rc) {
4527 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4528 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4529 "Configure the lvlsft\n");
4530 } else {
4531 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4532 "Error for epm lvlsft_en\n");
4533 goto exit_vreg_epm;
4534 }
4535
4536 msleep(500);
4537
4538 if (!epm_i2c_client)
4539 epm_i2c_client = epm_expander_i2c_register_board();
4540
4541 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4542 if (!rc)
4543 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4544 if (rc) {
4545 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4546 ": GPIO PWR MON Enable issue\n");
4547 goto exit_vreg_epm;
4548 }
4549
4550 msleep(1000);
4551
4552 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4553 if (!rc) {
4554 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4555 if (rc) {
4556 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4557 ": ADC1_PWDN error direction out\n");
4558 goto exit_vreg_epm;
4559 }
4560 }
4561
4562 msleep(100);
4563
4564 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4565 if (!rc) {
4566 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4567 if (rc) {
4568 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4569 ": ADC2_PWD error direction out\n");
4570 goto exit_vreg_epm;
4571 }
4572 }
4573
4574 msleep(1000);
4575
4576 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4577 if (!rc) {
4578 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4579 if (rc) {
4580 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4581 "Gpio request problem %d\n", rc);
4582 goto exit_vreg_epm;
4583 }
4584 }
4585
4586 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4587 if (!rc) {
4588 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4589 if (rc) {
4590 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4591 ": EPM_SPI_ADC1_CS_N error\n");
4592 goto exit_vreg_epm;
4593 }
4594 }
4595
4596 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4597 if (!rc) {
4598 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4599 if (rc) {
4600 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4601 ": EPM_SPI_ADC2_Cs_N error\n");
4602 goto exit_vreg_epm;
4603 }
4604 }
4605
4606 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4607 "the power monitor reset for epm\n");
4608
4609 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4610 if (!rc) {
4611 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4612 if (rc) {
4613 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4614 ": Error in the power mon reset\n");
4615 goto exit_vreg_epm;
4616 }
4617 }
4618
4619 msleep(1000);
4620
4621 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4622
4623 msleep(500);
4624
4625 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4626
4627 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4628
4629 return rc;
4630
4631exit_vreg_epm:
4632 regulator_disable(vreg_adc_epm1);
4633
4634 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4635 " rc = %d.\n", rc);
4636 return rc;
4637};
4638
4639static unsigned int msm_adc_gpio_configure_expander_disable(void)
4640{
4641 int rc = 0;
4642
4643 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4644 gpio_free(GPIO_PWR_MON_RESET_N);
4645
4646 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4647 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4648
4649 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4650 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4651
4652 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4653 gpio_free(GPIO_PWR_MON_START);
4654
4655 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4656 gpio_free(GPIO_ADC1_PWDN_N);
4657
4658 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4659 gpio_free(GPIO_ADC2_PWDN_N);
4660
4661 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4662 gpio_free(GPIO_PWR_MON_ENABLE);
4663
4664 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4665 gpio_free(GPIO_EPM_LVLSFT_EN);
4666
4667 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4668 gpio_free(GPIO_EPM_5V_BOOST_EN);
4669
4670 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4671 gpio_free(GPIO_EPM_3_3V_EN);
4672
4673 rc = regulator_disable(vreg_adc_epm1);
4674 if (rc)
4675 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4676 "Error while enabling regulator for epm s3 %d\n", rc);
4677 regulator_put(vreg_adc_epm1);
4678
4679 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4680 return rc;
4681};
4682
4683unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4684{
4685 int rc = 0;
4686
4687 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4688 cs_enable);
4689
4690 if (cs_enable < 16) {
4691 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4692 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4693 } else {
4694 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4695 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4696 }
4697 return rc;
4698};
4699
4700unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4701{
4702 int rc = 0;
4703
4704 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4705
4706 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4707
4708 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4709
4710 return rc;
4711};
4712#endif
4713
4714static struct msm_adc_channels msm_adc_channels_data[] = {
4715 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4716 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4717 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4718 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4719 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4720 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4721 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4722 CHAN_PATH_TYPE4,
4723 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4724 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4725 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4726 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4727 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4728 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4729 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4730 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4731 CHAN_PATH_TYPE12,
4732 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4733 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4734 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4735 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4736 CHAN_PATH_TYPE_NONE,
4737 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4738 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4739 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4740 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4741 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4742 scale_xtern_chgr_cur},
4743 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4744 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4745 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4746 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4747 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4748 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4749 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4750 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4751 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4752 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4753 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4754 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4755};
4756
4757static char *msm_adc_fluid_device_names[] = {
4758 "ADS_ADC1",
4759 "ADS_ADC2",
4760};
4761
4762static struct msm_adc_platform_data msm_adc_pdata = {
4763 .channel = msm_adc_channels_data,
4764 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4765#if defined(CONFIG_I2C) && \
4766 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4767 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4768 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4769 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4770 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4771#endif
4772};
4773
4774static struct platform_device msm_adc_device = {
4775 .name = "msm_adc",
4776 .id = -1,
4777 .dev = {
4778 .platform_data = &msm_adc_pdata,
4779 },
4780};
4781
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304782static struct msm_rtb_platform_data msm_rtb_pdata = {
4783 .size = SZ_1M,
4784};
4785
4786static int __init msm_rtb_set_buffer_size(char *p)
4787{
4788 int s;
4789
4790 s = memparse(p, NULL);
4791 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4792 return 0;
4793}
4794early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4795
4796
4797static struct platform_device msm_rtb_device = {
4798 .name = "msm_rtb",
4799 .id = -1,
4800 .dev = {
4801 .platform_data = &msm_rtb_pdata,
4802 },
4803};
4804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004805static void pmic8058_xoadc_mpp_config(void)
4806{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304807 int rc, i;
4808 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304809 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304810 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304811 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304812 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304813 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304814 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304815 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304816 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304817 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304818 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304819 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4820 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304821 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004822
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304823 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4824 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4825 &xoadc_mpps[i].config);
4826 if (rc) {
4827 pr_err("%s: Config MPP %d of PM8058 failed\n",
4828 __func__, xoadc_mpps[i].mpp);
4829 }
4830 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004831}
4832
4833static struct regulator *vreg_ldo18_adc;
4834
4835static int pmic8058_xoadc_vreg_config(int on)
4836{
4837 int rc;
4838
4839 if (on) {
4840 rc = regulator_enable(vreg_ldo18_adc);
4841 if (rc)
4842 pr_err("%s: Enable of regulator ldo18_adc "
4843 "failed\n", __func__);
4844 } else {
4845 rc = regulator_disable(vreg_ldo18_adc);
4846 if (rc)
4847 pr_err("%s: Disable of regulator ldo18_adc "
4848 "failed\n", __func__);
4849 }
4850
4851 return rc;
4852}
4853
4854static int pmic8058_xoadc_vreg_setup(void)
4855{
4856 int rc;
4857
4858 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4859 if (IS_ERR(vreg_ldo18_adc)) {
4860 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4861 __func__, PTR_ERR(vreg_ldo18_adc));
4862 rc = PTR_ERR(vreg_ldo18_adc);
4863 goto fail;
4864 }
4865
4866 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4867 if (rc) {
4868 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4869 goto fail;
4870 }
4871
4872 return rc;
4873fail:
4874 regulator_put(vreg_ldo18_adc);
4875 return rc;
4876}
4877
4878static void pmic8058_xoadc_vreg_shutdown(void)
4879{
4880 regulator_put(vreg_ldo18_adc);
4881}
4882
4883/* usec. For this ADC,
4884 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4885 * Each channel has different configuration, thus at the time of starting
4886 * the conversion, xoadc will return actual conversion time
4887 * */
4888static struct adc_properties pm8058_xoadc_data = {
4889 .adc_reference = 2200, /* milli-voltage for this adc */
4890 .bitresolution = 15,
4891 .bipolar = 0,
4892 .conversiontime = 54,
4893};
4894
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304895static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004896 .xoadc_prop = &pm8058_xoadc_data,
4897 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4898 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4899 .xoadc_num = XOADC_PMIC_0,
4900 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4901 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4902};
4903#endif
4904
4905#ifdef CONFIG_MSM_SDIO_AL
4906
4907static unsigned mdm2ap_status = 140;
4908
4909static int configure_mdm2ap_status(int on)
4910{
4911 int ret = 0;
4912 if (on)
4913 ret = msm_gpiomux_get(mdm2ap_status);
4914 else
4915 ret = msm_gpiomux_put(mdm2ap_status);
4916
4917 if (ret)
4918 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4919 on);
4920
4921 return ret;
4922}
4923
4924
4925static int get_mdm2ap_status(void)
4926{
4927 return gpio_get_value(mdm2ap_status);
4928}
4929
4930static struct sdio_al_platform_data sdio_al_pdata = {
4931 .config_mdm2ap_status = configure_mdm2ap_status,
4932 .get_mdm2ap_status = get_mdm2ap_status,
4933 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004934 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004935 .peer_sdioc_version_major = 0x0004,
4936 .peer_sdioc_boot_version_minor = 0x0001,
4937 .peer_sdioc_boot_version_major = 0x0003
4938};
4939
4940struct platform_device msm_device_sdio_al = {
4941 .name = "msm_sdio_al",
4942 .id = -1,
4943 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004944 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004945 .platform_data = &sdio_al_pdata,
4946 },
4947};
4948
4949#endif /* CONFIG_MSM_SDIO_AL */
4950
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304951#define GPIO_VREG_ID_EXT_5V 0
4952
4953static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4954 REGULATOR_SUPPLY("ext_5v", NULL),
4955 REGULATOR_SUPPLY("8901_mpp0", NULL),
4956};
4957
4958#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4959 [GPIO_VREG_ID_##_id] = { \
4960 .init_data = { \
4961 .constraints = { \
4962 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
4963 }, \
4964 .num_consumer_supplies = \
4965 ARRAY_SIZE(vreg_consumers_##_id), \
4966 .consumer_supplies = vreg_consumers_##_id, \
4967 }, \
4968 .regulator_name = _reg_name, \
4969 .active_low = _active_low, \
4970 .gpio_label = _gpio_label, \
4971 .gpio = _gpio, \
4972 }
4973
4974/* GPIO regulator constraints */
4975static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
4976 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
4977 PM8901_MPP_PM_TO_SYS(0), 0),
4978};
4979
4980/* GPIO regulator */
4981static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
4982 .name = GPIO_REGULATOR_DEV_NAME,
4983 .id = PM8901_MPP_PM_TO_SYS(0),
4984 .dev = {
4985 .platform_data =
4986 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
4987 },
4988};
4989
4990static void __init pm8901_vreg_mpp0_init(void)
4991{
4992 int rc;
4993
4994 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
4995 .mpp = PM8901_MPP_PM_TO_SYS(0),
4996 .config = {
4997 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
4998 .level = PM8901_MPP_DIG_LEVEL_VPH,
4999 },
5000 };
5001
5002 /*
5003 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5004 * implies that the regulator connected to MPP0 is enabled when
5005 * MPP0 is low.
5006 */
5007 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5008 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5009 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5010 } else {
5011 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5012 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5013 }
5014
5015 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5016 if (rc)
5017 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5018}
5019
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005020static struct platform_device *charm_devices[] __initdata = {
5021 &msm_charm_modem,
5022#ifdef CONFIG_MSM_SDIO_AL
5023 &msm_device_sdio_al,
5024#endif
5025};
5026
Lei Zhou338cab82011-08-19 13:38:17 -04005027#ifdef CONFIG_SND_SOC_MSM8660_APQ
5028static struct platform_device *dragon_alsa_devices[] __initdata = {
5029 &msm_pcm,
5030 &msm_pcm_routing,
5031 &msm_cpudai0,
5032 &msm_cpudai1,
5033 &msm_cpudai_hdmi_rx,
5034 &msm_cpudai_bt_rx,
5035 &msm_cpudai_bt_tx,
5036 &msm_cpudai_fm_rx,
5037 &msm_cpudai_fm_tx,
5038 &msm_cpu_fe,
5039 &msm_stub_codec,
5040 &msm_lpa_pcm,
5041};
5042#endif
5043
5044static struct platform_device *asoc_devices[] __initdata = {
5045 &asoc_msm_pcm,
5046 &asoc_msm_dai0,
5047 &asoc_msm_dai1,
5048};
5049
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305050/* qseecom bus scaling */
5051static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
5052 {
5053 .src = MSM_BUS_MASTER_SPS,
5054 .dst = MSM_BUS_SLAVE_EBI_CH0,
5055 .ib = 0,
5056 .ab = 0,
5057 },
5058 {
5059 .src = MSM_BUS_MASTER_SPDM,
5060 .dst = MSM_BUS_SLAVE_SPDM,
5061 .ib = 0,
5062 .ab = 0,
5063 },
5064};
5065
5066static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
5067 {
5068 .src = MSM_BUS_MASTER_SPS,
5069 .dst = MSM_BUS_SLAVE_EBI_CH0,
5070 .ib = (492 * 8) * 1000000UL,
5071 .ab = (492 * 8) * 100000UL,
5072 },
5073 {
5074 .src = MSM_BUS_MASTER_SPDM,
5075 .dst = MSM_BUS_SLAVE_SPDM,
5076 .ib = 0,
5077 .ab = 0,
5078 },
5079};
5080
5081static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
5082 {
5083 .src = MSM_BUS_MASTER_SPS,
5084 .dst = MSM_BUS_SLAVE_EBI_CH0,
5085 .ib = 0,
5086 .ab = 0,
5087 },
5088 {
5089 .src = MSM_BUS_MASTER_SPDM,
5090 .dst = MSM_BUS_SLAVE_SPDM,
5091 .ib = (64 * 8) * 1000000UL,
5092 .ab = (64 * 8) * 100000UL,
5093 },
5094};
5095
5096static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
5097 {
5098 ARRAY_SIZE(qseecom_clks_init_vectors),
5099 qseecom_clks_init_vectors,
5100 },
5101 {
5102 ARRAY_SIZE(qseecom_enable_dfab_vectors),
5103 qseecom_enable_sfpb_vectors,
5104 },
5105 {
5106 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
5107 qseecom_enable_sfpb_vectors,
5108 },
5109};
5110
5111static struct msm_bus_scale_pdata qseecom_bus_pdata = {
5112 .usecase = qseecom_hw_bus_scale_usecases,
5113 .num_usecases = ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
5114 .name = "qsee",
5115};
5116
5117static struct platform_device qseecom_device = {
5118 .name = "qseecom",
5119 .id = -1,
5120 .dev = {
5121 .platform_data = &qseecom_bus_pdata,
5122 },
5123};
5124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005125static struct platform_device *surf_devices[] __initdata = {
Matt Wagantallbf430eb2012-03-22 11:45:49 -07005126 &msm8x60_device_acpuclk,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005127 &msm_device_smd,
5128 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005129 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005130 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005131 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005132 &msm_pil_dsps,
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05305133 &msm_pil_vidc,
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305134 &qseecom_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005135#ifdef CONFIG_I2C_QUP
5136 &msm_gsbi3_qup_i2c_device,
5137 &msm_gsbi4_qup_i2c_device,
5138 &msm_gsbi7_qup_i2c_device,
5139 &msm_gsbi8_qup_i2c_device,
5140 &msm_gsbi9_qup_i2c_device,
5141 &msm_gsbi12_qup_i2c_device,
5142#endif
5143#ifdef CONFIG_SERIAL_MSM_HS
5144 &msm_device_uart_dm1,
5145#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305146#ifdef CONFIG_MSM_SSBI
5147 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305148 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305149#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005150#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151 &msm_device_ssbi3,
5152#endif
5153#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5154 &isp1763_device,
5155#endif
5156
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157#if defined (CONFIG_MSM_8x60_VOIP)
5158 &asoc_msm_mvs,
5159 &asoc_mvs_dai0,
5160 &asoc_mvs_dai1,
5161#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005162
Lena Salman57d167e2012-03-21 19:46:38 +02005163#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005164 &msm_device_otg,
5165#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005166#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005167 &msm_device_gadget_peripheral,
5168#endif
5169#ifdef CONFIG_USB_G_ANDROID
5170 &android_usb_device,
5171#endif
5172#ifdef CONFIG_BATTERY_MSM
5173 &msm_batt_device,
5174#endif
5175#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005176#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177 &android_pmem_device,
5178 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005179 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005180 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305181#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5182#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005183#ifdef CONFIG_MSM_ROTATOR
5184 &msm_rotator_device,
5185#endif
5186 &msm_fb_device,
5187 &msm_kgsl_3d0,
5188 &msm_kgsl_2d0,
5189 &msm_kgsl_2d1,
5190 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005191#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5192 &lcdc_nt35582_panel_device,
5193#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005194#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5195 &lcdc_samsung_oled_panel_device,
5196#endif
5197#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5198 &lcdc_auo_wvga_panel_device,
5199#endif
5200#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5201 &hdmi_msm_device,
5202#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5203#ifdef CONFIG_FB_MSM_MIPI_DSI
5204 &mipi_dsi_toshiba_panel_device,
5205 &mipi_dsi_novatek_panel_device,
5206#endif
5207#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005208#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005209#ifdef CONFIG_MT9E013
5210 &msm_camera_sensor_mt9e013,
5211#endif
5212#ifdef CONFIG_IMX074
5213 &msm_camera_sensor_imx074,
5214#endif
5215#ifdef CONFIG_WEBCAM_OV7692
5216 &msm_camera_sensor_webcam_ov7692,
5217#endif
5218#ifdef CONFIG_WEBCAM_OV9726
5219 &msm_camera_sensor_webcam_ov9726,
5220#endif
5221#ifdef CONFIG_QS_S5K4E1
5222 &msm_camera_sensor_qs_s5k4e1,
5223#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005224#ifdef CONFIG_VX6953
5225 &msm_camera_sensor_vx6953,
5226#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005227#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005228#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005229#ifdef CONFIG_MSM_GEMINI
5230 &msm_gemini_device,
5231#endif
5232#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005233#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005234 &msm_vpe_device,
5235#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005236#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005237
5238#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005239 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240#endif
5241#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005242 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005243#endif
5244 &msm_device_vidc,
5245#if (defined(CONFIG_MARIMBA_CORE)) && \
5246 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5247 &msm_bt_power_device,
5248#endif
5249#ifdef CONFIG_SENSORS_MSM_ADC
5250 &msm_adc_device,
5251#endif
David Collins6f032ba2011-08-31 14:08:15 -07005252 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253
5254#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5255 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5256 &qcrypto_device,
5257#endif
5258
5259#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5260 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5261 &qcedev_device,
5262#endif
5263
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005264
5265#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5266#ifdef CONFIG_MSM_USE_TSIF1
5267 &msm_device_tsif[1],
5268#else
5269 &msm_device_tsif[0],
5270#endif /* CONFIG_MSM_USE_TSIF1 */
5271#endif /* CONFIG_TSIF */
5272
5273#ifdef CONFIG_HW_RANDOM_MSM
5274 &msm_device_rng,
5275#endif
5276
5277 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005278 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005279#ifdef CONFIG_ION_MSM
5280 &ion_dev,
5281#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005282 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005283 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305284 &msm_rtb_device,
Laura Abbottd92be422012-06-04 15:11:09 -07005285 &msm8660_iommu_domain_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005286};
5287
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005288#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005289#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5290static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5291 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005292 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005293 .request_region = request_smi_region,
5294 .release_region = release_smi_region,
5295 .setup_region = setup_smi_region,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305296 .secure_base = MSM_ION_HOLE_BASE,
5297 .secure_size = MSM_ION_HOLE_SIZE + MSM_ION_MM_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005298 .iommu_map_all = 1,
5299 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005300};
5301
5302static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5303 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005304 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005305 .request_region = request_smi_region,
5306 .release_region = release_smi_region,
5307 .setup_region = setup_smi_region,
5308};
5309
5310static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5311 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005312 .align = PAGE_SIZE,
5313};
5314
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305315static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005316 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005317};
5318
5319static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005320 .adjacent_mem_id = INVALID_HEAP_ID,
5321 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005322};
5323#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005324
5325/**
5326 * These heaps are listed in the order they will be allocated. Due to
5327 * video hardware restrictions and content protection the FW heap has to
5328 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5329 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5330 * away from the base address of the FW heap.
5331 * However, the order of FW heap and MM heap doesn't matter since these
5332 * two heaps are taken care of by separate code to ensure they are adjacent
5333 * to each other.
5334 * Don't swap the order unless you know what you are doing!
5335 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005336static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005337 .nr = MSM_ION_HEAP_NUM,
5338 .heaps = {
5339 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005340 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005341 .type = ION_HEAP_TYPE_SYSTEM,
5342 .name = ION_VMALLOC_HEAP_NAME,
5343 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005344#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5345 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005346 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005347 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005348 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305349 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005350 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005351 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005352 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005353 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005354 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005355 .id = ION_MM_FIRMWARE_HEAP_ID,
5356 .type = ION_HEAP_TYPE_CARVEOUT,
5357 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305358 .base = MSM_MM_FW_BASE,
5359 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005360 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305361 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005362 },
5363 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005364 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005365 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005366 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305367 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005368 .size = MSM_ION_MFC_SIZE,
5369 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005370 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005371 },
5372 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005373 .id = ION_SF_HEAP_ID,
5374 .type = ION_HEAP_TYPE_CARVEOUT,
5375 .name = ION_SF_HEAP_NAME,
5376 .size = MSM_ION_SF_SIZE,
5377 .memory_type = ION_EBI_TYPE,
5378 .extra_data = (void *)&co_ion_pdata,
5379 },
5380 {
5381 .id = ION_CAMERA_HEAP_ID,
5382 .type = ION_HEAP_TYPE_CARVEOUT,
5383 .name = ION_CAMERA_HEAP_NAME,
5384 .size = MSM_ION_CAMERA_SIZE,
5385 .memory_type = ION_EBI_TYPE,
5386 .extra_data = &co_ion_pdata,
5387 },
5388 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005389 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005390 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005391 .name = ION_WB_HEAP_NAME,
5392 .size = MSM_ION_WB_SIZE,
5393 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005394 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005395 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005396 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005397 .id = ION_QSECOM_HEAP_ID,
5398 .type = ION_HEAP_TYPE_CARVEOUT,
5399 .name = ION_QSECOM_HEAP_NAME,
5400 .size = MSM_ION_QSECOM_SIZE,
5401 .memory_type = ION_EBI_TYPE,
5402 .extra_data = (void *) &co_ion_pdata,
5403 },
5404 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005405 .id = ION_AUDIO_HEAP_ID,
5406 .type = ION_HEAP_TYPE_CARVEOUT,
5407 .name = ION_AUDIO_HEAP_NAME,
5408 .size = MSM_ION_AUDIO_SIZE,
5409 .memory_type = ION_EBI_TYPE,
5410 .extra_data = (void *)&co_ion_pdata,
5411 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005412#endif
5413 }
5414};
5415
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005416static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005417 .name = "ion-msm",
5418 .id = 1,
5419 .dev = { .platform_data = &ion_pdata },
5420};
5421#endif
5422
5423
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005424static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5425 /* Kernel SMI memory pool for video core, used for firmware */
5426 /* and encoder, decoder scratch buffers */
5427 /* Kernel SMI memory pool should always precede the user space */
5428 /* SMI memory pool, as the video core will use offset address */
5429 /* from the Firmware base */
5430 [MEMTYPE_SMI_KERNEL] = {
5431 .start = KERNEL_SMI_BASE,
5432 .limit = KERNEL_SMI_SIZE,
5433 .size = KERNEL_SMI_SIZE,
5434 .flags = MEMTYPE_FLAGS_FIXED,
5435 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005436 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005437 },
5438 [MEMTYPE_EBI0] = {
5439 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5440 },
5441 [MEMTYPE_EBI1] = {
5442 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5443 },
5444};
5445
Stephen Boyd668d7652012-04-25 11:31:01 -07005446static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005447{
5448#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005449 unsigned int i;
5450
5451 if (hdmi_is_primary) {
5452 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5453 for (i = 0; i < ion_pdata.nr; i++) {
5454 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5455 ion_pdata.heaps[i].size = msm_ion_sf_size;
5456 pr_debug("msm_ion_sf_size 0x%x\n",
5457 msm_ion_sf_size);
5458 break;
5459 }
5460 }
5461 }
5462
Olav Haugan8726caf2012-05-10 15:11:35 -07005463 /* Verify size of heap is a multiple of 64K */
5464 for (i = 0; i < ion_pdata.nr; i++) {
5465 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5466
5467 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5468 int map_all = ((struct ion_cp_heap_pdata *)
5469 heap->extra_data)->iommu_map_all;
5470
5471 if (map_all && (heap->size & (SZ_64K-1))) {
5472 heap->size = ALIGN(heap->size, SZ_64K);
5473 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5474 heap->name, heap->size);
5475
5476 }
5477 }
5478 }
5479
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005480 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005481 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5482 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005483 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005484 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005485#endif
5486}
5487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005488static void __init size_pmem_devices(void)
5489{
5490#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005491#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005492 android_pmem_adsp_pdata.size = pmem_adsp_size;
5493 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005494
5495 if (hdmi_is_primary)
5496 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005498 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305499#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5500#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005501}
5502
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305503#ifdef CONFIG_ANDROID_PMEM
5504#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005505static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5506{
5507 msm8x60_reserve_table[p->memory_type].size += p->size;
5508}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305509#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5510#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005511
5512static void __init reserve_pmem_memory(void)
5513{
5514#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005515#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005516 reserve_memory_for(&android_pmem_adsp_pdata);
5517 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005518 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005519 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305520#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005521 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305522#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523}
5524
Huaibin Yanga5419422011-12-08 23:52:10 -08005525static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005526
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305527static void __init reserve_rtb_memory(void)
5528{
5529#if defined(CONFIG_MSM_RTB)
5530 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5531#endif
5532}
5533
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005534static void __init msm8x60_calculate_reserve_sizes(void)
5535{
5536 size_pmem_devices();
5537 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005538 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005539 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305540 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005541}
5542
5543static int msm8x60_paddr_to_memtype(unsigned int paddr)
5544{
5545 if (paddr >= 0x40000000 && paddr < 0x60000000)
5546 return MEMTYPE_EBI1;
5547 if (paddr >= 0x38000000 && paddr < 0x40000000)
5548 return MEMTYPE_SMI;
5549 return MEMTYPE_NONE;
5550}
5551
5552static struct reserve_info msm8x60_reserve_info __initdata = {
5553 .memtype_reserve_table = msm8x60_reserve_table,
5554 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5555 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5556};
5557
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005558static char prim_panel_name[PANEL_NAME_MAX_LEN];
5559static char ext_panel_name[PANEL_NAME_MAX_LEN];
5560static int __init prim_display_setup(char *param)
5561{
5562 if (strnlen(param, PANEL_NAME_MAX_LEN))
5563 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5564 return 0;
5565}
5566early_param("prim_display", prim_display_setup);
5567
5568static int __init ext_display_setup(char *param)
5569{
5570 if (strnlen(param, PANEL_NAME_MAX_LEN))
5571 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5572 return 0;
5573}
5574early_param("ext_display", ext_display_setup);
5575
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005576static void __init msm8x60_reserve(void)
5577{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005578 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005579 reserve_info = &msm8x60_reserve_info;
5580 msm_reserve();
5581}
5582
5583#define EXT_CHG_VALID_MPP 10
5584#define EXT_CHG_VALID_MPP_2 11
5585
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305586static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305587 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305588 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305589 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305590 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5591};
5592
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593#ifdef CONFIG_ISL9519_CHARGER
5594static int isl_detection_setup(void)
5595{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305596 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005597
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305598 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5599 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5600 &isl_mpp[i].config);
5601 if (ret) {
5602 pr_err("%s: Config MPP %d of PM8058 failed\n",
5603 __func__, isl_mpp[i].mpp);
5604 return ret;
5605 }
5606 }
5607
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608 return ret;
5609}
5610
5611static struct isl_platform_data isl_data __initdata = {
5612 .chgcurrent = 700,
5613 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5614 .chg_detection_config = isl_detection_setup,
5615 .max_system_voltage = 4200,
5616 .min_system_voltage = 3200,
5617 .term_current = 120,
5618 .input_current = 2048,
5619};
5620
5621static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5622 {
5623 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305624 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005625 .platform_data = &isl_data,
5626 },
5627};
5628#endif
5629
5630#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5631static int smb137b_detection_setup(void)
5632{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305633 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005634
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305635 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5636 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5637 &isl_mpp[i].config);
5638 if (ret) {
5639 pr_err("%s: Config MPP %d of PM8058 failed\n",
5640 __func__, isl_mpp[i].mpp);
5641 return ret;
5642 }
5643 }
5644
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645 return ret;
5646}
5647
5648static struct smb137b_platform_data smb137b_data __initdata = {
5649 .chg_detection_config = smb137b_detection_setup,
5650 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5651 .batt_mah_rating = 950,
5652};
5653
5654static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5655 {
5656 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305657 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005658 .platform_data = &smb137b_data,
5659 },
5660};
5661#endif
5662
5663#ifdef CONFIG_PMIC8058
5664#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305665#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005666
5667static int pm8058_gpios_init(void)
5668{
5669 int i;
5670 int rc;
5671 struct pm8058_gpio_cfg {
5672 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305673 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005674 };
5675
5676 struct pm8058_gpio_cfg gpio_cfgs[] = {
5677 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305678 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005679 {
5680 .direction = PM_GPIO_DIR_IN,
5681 .pull = PM_GPIO_PULL_DN,
5682 .vin_sel = 2,
5683 .function = PM_GPIO_FUNC_NORMAL,
5684 .inv_int_pol = 0,
5685 },
5686 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005687 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305688 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005689 {
5690 .direction = PM_GPIO_DIR_IN,
5691 .pull = PM_GPIO_PULL_UP_30,
5692 .vin_sel = 2,
5693 .function = PM_GPIO_FUNC_NORMAL,
5694 .inv_int_pol = 0,
5695 },
5696 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005697 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305698 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005699 {
5700 .direction = PM_GPIO_DIR_IN,
5701 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305702 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005703 .function = PM_GPIO_FUNC_NORMAL,
5704 .inv_int_pol = 0,
5705 },
5706 },
5707 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305708 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005709 {
5710 .direction = PM_GPIO_DIR_IN,
5711 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305712 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005713 .function = PM_GPIO_FUNC_NORMAL,
5714 .inv_int_pol = 0,
5715 },
5716 },
5717 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305718 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 {
5720 .direction = PM_GPIO_DIR_IN,
5721 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305722 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005723 .function = PM_GPIO_FUNC_NORMAL,
5724 .inv_int_pol = 0,
5725 },
5726 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005727 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305728 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005729 {
5730 .direction = PM_GPIO_DIR_OUT,
5731 .output_value = 1,
5732 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5733 .pull = PM_GPIO_PULL_DN,
5734 .out_strength = PM_GPIO_STRENGTH_HIGH,
5735 .function = PM_GPIO_FUNC_NORMAL,
5736 .vin_sel = 2,
5737 .inv_int_pol = 0,
5738 }
5739 },
5740 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305741 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005742 {
5743 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305744 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005745 .function = PM_GPIO_FUNC_NORMAL,
5746 .vin_sel = 2,
5747 .inv_int_pol = 0,
5748 }
5749 },
5750 };
5751
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305752#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5753 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305754 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305755 .direction = PM_GPIO_DIR_IN,
5756 .pull = PM_GPIO_PULL_UP_1P5,
5757 .vin_sel = 2,
5758 .function = PM_GPIO_FUNC_NORMAL,
5759 };
5760#endif
5761
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005762#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305763 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305764 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305765 .direction = PM_GPIO_DIR_OUT,
5766 .pull = PM_GPIO_PULL_NO,
5767 .out_strength = PM_GPIO_STRENGTH_HIGH,
5768 .function = PM_GPIO_FUNC_NORMAL,
5769 .inv_int_pol = 0,
5770 .vin_sel = 2,
5771 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5772 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005773 };
5774#endif
5775
5776#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5777 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305778 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005779 {
5780 .direction = PM_GPIO_DIR_IN,
5781 .pull = PM_GPIO_PULL_UP_1P5,
5782 .vin_sel = 2,
5783 .function = PM_GPIO_FUNC_NORMAL,
5784 .inv_int_pol = 0,
5785 }
5786 };
5787#endif
5788
5789#if defined(CONFIG_QS_S5K4E1)
5790 {
5791 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305792 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005793 {
5794 .direction = PM_GPIO_DIR_OUT,
5795 .output_value = 0,
5796 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5797 .pull = PM_GPIO_PULL_DN,
5798 .out_strength = PM_GPIO_STRENGTH_HIGH,
5799 .function = PM_GPIO_FUNC_NORMAL,
5800 .vin_sel = 2,
5801 .inv_int_pol = 0,
5802 }
5803 };
5804#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005805#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5806 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305807 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005808 {
5809 .direction = PM_GPIO_DIR_OUT,
5810 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5811 .output_value = 1,
5812 .pull = PM_GPIO_PULL_UP_30,
5813 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305814 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005815 .out_strength = PM_GPIO_STRENGTH_HIGH,
5816 .function = PM_GPIO_FUNC_NORMAL,
5817 .inv_int_pol = 0,
5818 }
5819 };
5820#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005821#if defined(CONFIG_HAPTIC_ISA1200) || \
5822 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5823 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305824 rc = pm8xxx_gpio_config(
5825 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5826 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005827 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305828 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005829 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305830 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305831 rc = pm8xxx_gpio_config(
5832 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5833 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305834 if (rc < 0) {
5835 pr_err("%s: pmic haptics ldo gpio config failed\n",
5836 __func__);
5837 }
5838
5839 }
5840#endif
5841
5842#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5843 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5844 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5845 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305846 rc = pm8xxx_gpio_config(
5847 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5848 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305849 if (rc < 0) {
5850 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5851 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005852 }
5853 }
5854#endif
5855
5856#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5857 /* Line_in only for 8660 ffa & surf */
5858 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005859 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005860 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305861 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005862 &line_in_gpio_cfg.cfg);
5863 if (rc < 0) {
5864 pr_err("%s pmic line_in gpio config failed\n",
5865 __func__);
5866 return rc;
5867 }
5868 }
5869#endif
5870
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005871#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5872 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305873 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005874 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5875 if (rc < 0) {
5876 pr_err("%s pmic gpio config failed\n", __func__);
5877 return rc;
5878 }
5879 }
5880#endif
5881
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005882#if defined(CONFIG_QS_S5K4E1)
5883 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5884 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305885 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005886 &qs_hc37_cam_pd_gpio_cfg.cfg);
5887 if (rc < 0) {
5888 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5889 __func__);
5890 return rc;
5891 }
5892 }
5893 }
5894#endif
5895
5896 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305897 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005898 &gpio_cfgs[i].cfg);
5899 if (rc < 0) {
5900 pr_err("%s pmic gpio config failed\n",
5901 __func__);
5902 return rc;
5903 }
5904 }
5905
5906 return 0;
5907}
5908
5909static const unsigned int ffa_keymap[] = {
5910 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5911 KEY(0, 1, KEY_UP), /* NAV - UP */
5912 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5913 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5914
5915 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5916 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5917 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5918 KEY(1, 3, KEY_VOLUMEDOWN),
5919
5920 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5921
5922 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5923 KEY(4, 1, KEY_UP), /* USER_UP */
5924 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5925 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5926 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5927
5928 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5929 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5930 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5931 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5932 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5933};
5934
Zhang Chang Ken683be172011-08-10 17:45:34 -04005935static const unsigned int dragon_keymap[] = {
5936 KEY(0, 0, KEY_MENU),
5937 KEY(0, 2, KEY_1),
5938 KEY(0, 3, KEY_4),
5939 KEY(0, 4, KEY_7),
5940
5941 KEY(1, 0, KEY_UP),
5942 KEY(1, 1, KEY_LEFT),
5943 KEY(1, 2, KEY_DOWN),
5944 KEY(1, 3, KEY_5),
5945 KEY(1, 4, KEY_8),
5946
5947 KEY(2, 0, KEY_HOME),
5948 KEY(2, 1, KEY_REPLY),
5949 KEY(2, 2, KEY_2),
5950 KEY(2, 3, KEY_6),
5951 KEY(2, 4, KEY_0),
5952
5953 KEY(3, 0, KEY_VOLUMEUP),
5954 KEY(3, 1, KEY_RIGHT),
5955 KEY(3, 2, KEY_3),
5956 KEY(3, 3, KEY_9),
5957 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5958
5959 KEY(4, 0, KEY_VOLUMEDOWN),
5960 KEY(4, 1, KEY_BACK),
5961 KEY(4, 2, KEY_CAMERA),
5962 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5963};
5964
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005965static struct matrix_keymap_data ffa_keymap_data = {
5966 .keymap_size = ARRAY_SIZE(ffa_keymap),
5967 .keymap = ffa_keymap,
5968};
5969
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305970static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005971 .input_name = "ffa-keypad",
5972 .input_phys_device = "ffa-keypad/input0",
5973 .num_rows = 6,
5974 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305975 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5976 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5977 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005978 .scan_delay_ms = 32,
5979 .row_hold_ns = 91500,
5980 .wakeup = 1,
5981 .keymap_data = &ffa_keymap_data,
5982};
5983
Zhang Chang Ken683be172011-08-10 17:45:34 -04005984static struct matrix_keymap_data dragon_keymap_data = {
5985 .keymap_size = ARRAY_SIZE(dragon_keymap),
5986 .keymap = dragon_keymap,
5987};
5988
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305989static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005990 .input_name = "dragon-keypad",
5991 .input_phys_device = "dragon-keypad/input0",
5992 .num_rows = 6,
5993 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305994 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5995 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5996 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005997 .scan_delay_ms = 32,
5998 .row_hold_ns = 91500,
5999 .wakeup = 1,
6000 .keymap_data = &dragon_keymap_data,
6001};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306002
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006003static const unsigned int fluid_keymap[] = {
6004 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6005 KEY(0, 1, KEY_UP), /* NAV - UP */
6006 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6007 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6008
6009 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6010 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6011 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6012 KEY(1, 3, KEY_VOLUMEUP),
6013
6014 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6015
6016 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6017 KEY(4, 1, KEY_UP), /* USER_UP */
6018 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6019 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6020 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6021
Jilai Wang9a895102011-07-12 14:00:35 -04006022 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006023 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6024 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6025 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6026 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6027};
6028
6029static struct matrix_keymap_data fluid_keymap_data = {
6030 .keymap_size = ARRAY_SIZE(fluid_keymap),
6031 .keymap = fluid_keymap,
6032};
6033
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306034static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006035 .input_name = "fluid-keypad",
6036 .input_phys_device = "fluid-keypad/input0",
6037 .num_rows = 6,
6038 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306039 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6040 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6041 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006042 .scan_delay_ms = 32,
6043 .row_hold_ns = 91500,
6044 .wakeup = 1,
6045 .keymap_data = &fluid_keymap_data,
6046};
6047
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306048static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006049 .initial_vibrate_ms = 500,
6050 .level_mV = 3000,
6051 .max_timeout_ms = 15000,
6052};
6053
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306054static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6055 .rtc_write_enable = false,
6056 .rtc_alarm_powerup = false,
6057};
6058
6059static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6060 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006061 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306062 .wakeup = 1,
6063};
6064
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006065#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6066
6067static struct othc_accessory_info othc_accessories[] = {
6068 {
6069 .accessory = OTHC_SVIDEO_OUT,
6070 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6071 | OTHC_ADC_DETECT,
6072 .key_code = SW_VIDEOOUT_INSERT,
6073 .enabled = false,
6074 .adc_thres = {
6075 .min_threshold = 20,
6076 .max_threshold = 40,
6077 },
6078 },
6079 {
6080 .accessory = OTHC_ANC_HEADPHONE,
6081 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6082 OTHC_SWITCH_DETECT,
6083 .gpio = PM8058_LINE_IN_DET_GPIO,
6084 .active_low = 1,
6085 .key_code = SW_HEADPHONE_INSERT,
6086 .enabled = true,
6087 },
6088 {
6089 .accessory = OTHC_ANC_HEADSET,
6090 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6091 .gpio = PM8058_LINE_IN_DET_GPIO,
6092 .active_low = 1,
6093 .key_code = SW_HEADPHONE_INSERT,
6094 .enabled = true,
6095 },
6096 {
6097 .accessory = OTHC_HEADPHONE,
6098 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6099 .key_code = SW_HEADPHONE_INSERT,
6100 .enabled = true,
6101 },
6102 {
6103 .accessory = OTHC_MICROPHONE,
6104 .detect_flags = OTHC_GPIO_DETECT,
6105 .gpio = PM8058_LINE_IN_DET_GPIO,
6106 .active_low = 1,
6107 .key_code = SW_MICROPHONE_INSERT,
6108 .enabled = true,
6109 },
6110 {
6111 .accessory = OTHC_HEADSET,
6112 .detect_flags = OTHC_MICBIAS_DETECT,
6113 .key_code = SW_HEADPHONE_INSERT,
6114 .enabled = true,
6115 },
6116};
6117
6118static struct othc_switch_info switch_info[] = {
6119 {
6120 .min_adc_threshold = 0,
6121 .max_adc_threshold = 100,
6122 .key_code = KEY_PLAYPAUSE,
6123 },
6124 {
6125 .min_adc_threshold = 100,
6126 .max_adc_threshold = 200,
6127 .key_code = KEY_REWIND,
6128 },
6129 {
6130 .min_adc_threshold = 200,
6131 .max_adc_threshold = 500,
6132 .key_code = KEY_FASTFORWARD,
6133 },
6134};
6135
6136static struct othc_n_switch_config switch_config = {
6137 .voltage_settling_time_ms = 0,
6138 .num_adc_samples = 3,
6139 .adc_channel = CHANNEL_ADC_HDSET,
6140 .switch_info = switch_info,
6141 .num_keys = ARRAY_SIZE(switch_info),
6142 .default_sw_en = true,
6143 .default_sw_idx = 0,
6144};
6145
6146static struct hsed_bias_config hsed_bias_config = {
6147 /* HSED mic bias config info */
6148 .othc_headset = OTHC_HEADSET_NO,
6149 .othc_lowcurr_thresh_uA = 100,
6150 .othc_highcurr_thresh_uA = 600,
6151 .othc_hyst_prediv_us = 7800,
6152 .othc_period_clkdiv_us = 62500,
6153 .othc_hyst_clk_us = 121000,
6154 .othc_period_clk_us = 312500,
6155 .othc_wakeup = 1,
6156};
6157
6158static struct othc_hsed_config hsed_config_1 = {
6159 .hsed_bias_config = &hsed_bias_config,
6160 /*
6161 * The detection delay and switch reporting delay are
6162 * required to encounter a hardware bug (spurious switch
6163 * interrupts on slow insertion/removal of the headset).
6164 * This will introduce a delay in reporting the accessory
6165 * insertion and removal to the userspace.
6166 */
6167 .detection_delay_ms = 1500,
6168 /* Switch info */
6169 .switch_debounce_ms = 1500,
6170 .othc_support_n_switch = false,
6171 .switch_config = &switch_config,
6172 .ir_gpio = -1,
6173 /* Accessory info */
6174 .accessories_support = true,
6175 .accessories = othc_accessories,
6176 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6177};
6178
6179static struct othc_regulator_config othc_reg = {
6180 .regulator = "8058_l5",
6181 .max_uV = 2850000,
6182 .min_uV = 2850000,
6183};
6184
6185/* MIC_BIAS0 is configured as normal MIC BIAS */
6186static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6187 .micbias_select = OTHC_MICBIAS_0,
6188 .micbias_capability = OTHC_MICBIAS,
6189 .micbias_enable = OTHC_SIGNAL_OFF,
6190 .micbias_regulator = &othc_reg,
6191};
6192
6193/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6194static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6195 .micbias_select = OTHC_MICBIAS_1,
6196 .micbias_capability = OTHC_MICBIAS_HSED,
6197 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6198 .micbias_regulator = &othc_reg,
6199 .hsed_config = &hsed_config_1,
6200 .hsed_name = "8660_handset",
6201};
6202
6203/* MIC_BIAS2 is configured as normal MIC BIAS */
6204static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6205 .micbias_select = OTHC_MICBIAS_2,
6206 .micbias_capability = OTHC_MICBIAS,
6207 .micbias_enable = OTHC_SIGNAL_OFF,
6208 .micbias_regulator = &othc_reg,
6209};
6210
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006211
6212static void __init msm8x60_init_pm8058_othc(void)
6213{
6214 int i;
6215
6216 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6217 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6218 machine_is_msm8x60_fusn_ffa()) {
6219 /* 3-switch headset supported only by V2 FFA and FLUID */
6220 hsed_config_1.accessories_adc_support = true,
6221 /* ADC based accessory detection works only on V2 and FLUID */
6222 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6223 hsed_config_1.othc_support_n_switch = true;
6224 }
6225
6226 /* IR GPIO is absent on FLUID */
6227 if (machine_is_msm8x60_fluid())
6228 hsed_config_1.ir_gpio = -1;
6229
6230 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6231 if (machine_is_msm8x60_fluid()) {
6232 switch (othc_accessories[i].accessory) {
6233 case OTHC_ANC_HEADPHONE:
6234 case OTHC_ANC_HEADSET:
6235 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6236 break;
6237 case OTHC_MICROPHONE:
6238 othc_accessories[i].enabled = false;
6239 break;
6240 case OTHC_SVIDEO_OUT:
6241 othc_accessories[i].enabled = true;
6242 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6243 break;
6244 }
6245 }
6246 }
6247}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006248
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006249
6250static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6251{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306252 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006253 .direction = PM_GPIO_DIR_OUT,
6254 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6255 .output_value = 0,
6256 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306257 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006258 .out_strength = PM_GPIO_STRENGTH_HIGH,
6259 .function = PM_GPIO_FUNC_2,
6260 };
6261
6262 int rc = -EINVAL;
6263 int id, mode, max_mA;
6264
6265 id = mode = max_mA = 0;
6266 switch (ch) {
6267 case 0:
6268 case 1:
6269 case 2:
6270 if (on) {
6271 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306272 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6273 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006274 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306275 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006276 __func__, id, rc);
6277 }
6278 break;
6279
6280 case 6:
6281 id = PM_PWM_LED_FLASH;
6282 mode = PM_PWM_CONF_PWM1;
6283 max_mA = 300;
6284 break;
6285
6286 case 7:
6287 id = PM_PWM_LED_FLASH1;
6288 mode = PM_PWM_CONF_PWM1;
6289 max_mA = 300;
6290 break;
6291
6292 default:
6293 break;
6294 }
6295
6296 if (ch >= 6 && ch <= 7) {
6297 if (!on) {
6298 mode = PM_PWM_CONF_NONE;
6299 max_mA = 0;
6300 }
6301 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6302 if (rc)
6303 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6304 __func__, ch, rc);
6305 }
6306 return rc;
6307
6308}
6309
6310static struct pm8058_pwm_pdata pm8058_pwm_data = {
6311 .config = pm8058_pwm_config,
6312};
6313
6314#define PM8058_GPIO_INT 88
6315
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006316static struct pmic8058_led pmic8058_flash_leds[] = {
6317 [0] = {
6318 .name = "camera:flash0",
6319 .max_brightness = 15,
6320 .id = PMIC8058_ID_FLASH_LED_0,
6321 },
6322 [1] = {
6323 .name = "camera:flash1",
6324 .max_brightness = 15,
6325 .id = PMIC8058_ID_FLASH_LED_1,
6326 },
6327};
6328
6329static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6330 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6331 .leds = pmic8058_flash_leds,
6332};
6333
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006334static struct pmic8058_led pmic8058_dragon_leds[] = {
6335 [0] = {
6336 /* RED */
6337 .name = "led_drv0",
6338 .max_brightness = 15,
6339 .id = PMIC8058_ID_LED_0,
6340 },/* 300 mA flash led0 drv sink */
6341 [1] = {
6342 /* Yellow */
6343 .name = "led_drv1",
6344 .max_brightness = 15,
6345 .id = PMIC8058_ID_LED_1,
6346 },/* 300 mA flash led0 drv sink */
6347 [2] = {
6348 /* Green */
6349 .name = "led_drv2",
6350 .max_brightness = 15,
6351 .id = PMIC8058_ID_LED_2,
6352 },/* 300 mA flash led0 drv sink */
6353 [3] = {
6354 .name = "led_psensor",
6355 .max_brightness = 15,
6356 .id = PMIC8058_ID_LED_KB_LIGHT,
6357 },/* 300 mA flash led0 drv sink */
6358};
6359
6360static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6361 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6362 .leds = pmic8058_dragon_leds,
6363};
6364
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006365static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6366 [0] = {
6367 .name = "led:drv0",
6368 .max_brightness = 15,
6369 .id = PMIC8058_ID_FLASH_LED_0,
6370 },/* 300 mA flash led0 drv sink */
6371 [1] = {
6372 .name = "led:drv1",
6373 .max_brightness = 15,
6374 .id = PMIC8058_ID_FLASH_LED_1,
6375 },/* 300 mA flash led1 sink */
6376 [2] = {
6377 .name = "led:drv2",
6378 .max_brightness = 20,
6379 .id = PMIC8058_ID_LED_0,
6380 },/* 40 mA led0 sink */
6381 [3] = {
6382 .name = "keypad:drv",
6383 .max_brightness = 15,
6384 .id = PMIC8058_ID_LED_KB_LIGHT,
6385 },/* 300 mA keypad drv sink */
6386};
6387
6388static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6389 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6390 .leds = pmic8058_fluid_flash_leds,
6391};
6392
Terence Hampson90508a92011-08-09 10:40:08 -04006393static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306394 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006395 .max_source_current = 1800,
6396 .charger_type = CHG_TYPE_AC,
6397};
6398
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306399static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6400 .charger_data_valid = false,
6401};
6402
6403static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6404 .priority = 0,
6405};
6406
6407static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6408 .irq_base = PM8058_IRQ_BASE,
6409 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6410 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6411};
6412
6413static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6414 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6415};
6416
6417static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6418 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006419};
6420
6421static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306422 .irq_pdata = &pm8058_irq_pdata,
6423 .gpio_pdata = &pm8058_gpio_pdata,
6424 .mpp_pdata = &pm8058_mpp_pdata,
6425 .rtc_pdata = &pm8058_rtc_pdata,
6426 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6427 .othc0_pdata = &othc_config_pdata_0,
6428 .othc1_pdata = &othc_config_pdata_1,
6429 .othc2_pdata = &othc_config_pdata_2,
6430 .pwm_pdata = &pm8058_pwm_data,
6431 .misc_pdata = &pm8058_misc_pdata,
6432#ifdef CONFIG_SENSORS_MSM_ADC
6433 .xoadc_pdata = &pm8058_xoadc_pdata,
6434#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006435};
6436
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306437#ifdef CONFIG_MSM_SSBI
6438static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6439 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6440 .slave = {
6441 .name = "pm8058-core",
6442 .platform_data = &pm8058_platform_data,
6443 },
6444};
6445#endif
6446#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006447
6448#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6449 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6450#define TDISC_I2C_SLAVE_ADDR 0x67
6451#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6452#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6453
6454static const char *vregs_tdisc_name[] = {
6455 "8058_l5",
6456 "8058_s3",
6457};
6458
6459static const int vregs_tdisc_val[] = {
6460 2850000,/* uV */
6461 1800000,
6462};
6463static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6464
6465static int tdisc_shinetsu_setup(void)
6466{
6467 int rc, i;
6468
6469 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6470 if (rc) {
6471 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6472 __func__);
6473 return rc;
6474 }
6475
6476 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6477 if (rc) {
6478 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6479 __func__);
6480 goto fail_gpio_oe;
6481 }
6482
6483 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6484 if (rc) {
6485 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6486 __func__);
6487 gpio_free(GPIO_JOYSTICK_EN);
6488 goto fail_gpio_oe;
6489 }
6490
6491 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6492 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6493 if (IS_ERR(vregs_tdisc[i])) {
6494 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6495 __func__, vregs_tdisc_name[i],
6496 PTR_ERR(vregs_tdisc[i]));
6497 rc = PTR_ERR(vregs_tdisc[i]);
6498 goto vreg_get_fail;
6499 }
6500
6501 rc = regulator_set_voltage(vregs_tdisc[i],
6502 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6503 if (rc) {
6504 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6505 __func__, rc);
6506 goto vreg_set_voltage_fail;
6507 }
6508 }
6509
6510 return rc;
6511vreg_set_voltage_fail:
6512 i++;
6513vreg_get_fail:
6514 while (i)
6515 regulator_put(vregs_tdisc[--i]);
6516fail_gpio_oe:
6517 gpio_free(PMIC_GPIO_TDISC);
6518 return rc;
6519}
6520
6521static void tdisc_shinetsu_release(void)
6522{
6523 int i;
6524
6525 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6526 regulator_put(vregs_tdisc[i]);
6527
6528 gpio_free(PMIC_GPIO_TDISC);
6529 gpio_free(GPIO_JOYSTICK_EN);
6530}
6531
6532static int tdisc_shinetsu_enable(void)
6533{
6534 int i, rc = -EINVAL;
6535
6536 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6537 rc = regulator_enable(vregs_tdisc[i]);
6538 if (rc < 0) {
6539 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6540 __func__, vregs_tdisc_name[i], rc);
6541 goto vreg_fail;
6542 }
6543 }
6544
6545 /* Enable the OE (output enable) gpio */
6546 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6547 /* voltage and gpio stabilization delay */
6548 msleep(50);
6549
6550 return 0;
6551vreg_fail:
6552 while (i)
6553 regulator_disable(vregs_tdisc[--i]);
6554 return rc;
6555}
6556
6557static int tdisc_shinetsu_disable(void)
6558{
6559 int i, rc;
6560
6561 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6562 rc = regulator_disable(vregs_tdisc[i]);
6563 if (rc < 0) {
6564 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6565 __func__, vregs_tdisc_name[i], rc);
6566 goto tdisc_reg_fail;
6567 }
6568 }
6569
6570 /* Disable the OE (output enable) gpio */
6571 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6572
6573 return 0;
6574
6575tdisc_reg_fail:
6576 while (i)
6577 regulator_enable(vregs_tdisc[--i]);
6578 return rc;
6579}
6580
6581static struct tdisc_abs_values tdisc_abs = {
6582 .x_max = 32,
6583 .y_max = 32,
6584 .x_min = -32,
6585 .y_min = -32,
6586 .pressure_max = 32,
6587 .pressure_min = 0,
6588};
6589
6590static struct tdisc_platform_data tdisc_data = {
6591 .tdisc_setup = tdisc_shinetsu_setup,
6592 .tdisc_release = tdisc_shinetsu_release,
6593 .tdisc_enable = tdisc_shinetsu_enable,
6594 .tdisc_disable = tdisc_shinetsu_disable,
6595 .tdisc_wakeup = 0,
6596 .tdisc_gpio = PMIC_GPIO_TDISC,
6597 .tdisc_report_keys = true,
6598 .tdisc_report_relative = true,
6599 .tdisc_report_absolute = false,
6600 .tdisc_report_wheel = false,
6601 .tdisc_reverse_x = false,
6602 .tdisc_reverse_y = true,
6603 .tdisc_abs = &tdisc_abs,
6604};
6605
6606static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6607 {
6608 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6609 .irq = TDISC_INT,
6610 .platform_data = &tdisc_data,
6611 },
6612};
6613#endif
6614
6615#define PM_GPIO_CDC_RST_N 20
6616#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6617
6618static struct regulator *vreg_timpani_1;
6619static struct regulator *vreg_timpani_2;
6620
6621static unsigned int msm_timpani_setup_power(void)
6622{
6623 int rc;
6624
6625 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6626 if (IS_ERR(vreg_timpani_1)) {
6627 pr_err("%s: Unable to get 8058_l0\n", __func__);
6628 return -ENODEV;
6629 }
6630
6631 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6632 if (IS_ERR(vreg_timpani_2)) {
6633 pr_err("%s: Unable to get 8058_s3\n", __func__);
6634 regulator_put(vreg_timpani_1);
6635 return -ENODEV;
6636 }
6637
6638 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6639 if (rc) {
6640 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6641 goto fail;
6642 }
6643
6644 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6645 if (rc) {
6646 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6647 goto fail;
6648 }
6649
6650 rc = regulator_enable(vreg_timpani_1);
6651 if (rc) {
6652 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6653 goto fail;
6654 }
6655
6656 /* The settings for LDO0 should be set such that
6657 * it doesn't require to reset the timpani. */
6658 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6659 if (rc < 0) {
6660 pr_err("Timpani regulator optimum mode setting failed\n");
6661 goto fail;
6662 }
6663
6664 rc = regulator_enable(vreg_timpani_2);
6665 if (rc) {
6666 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6667 regulator_disable(vreg_timpani_1);
6668 goto fail;
6669 }
6670
6671 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6672 if (rc) {
6673 pr_err("%s: GPIO Request %d failed\n", __func__,
6674 GPIO_CDC_RST_N);
6675 regulator_disable(vreg_timpani_1);
6676 regulator_disable(vreg_timpani_2);
6677 goto fail;
6678 } else {
6679 gpio_direction_output(GPIO_CDC_RST_N, 1);
6680 usleep_range(1000, 1050);
6681 gpio_direction_output(GPIO_CDC_RST_N, 0);
6682 usleep_range(1000, 1050);
6683 gpio_direction_output(GPIO_CDC_RST_N, 1);
6684 gpio_free(GPIO_CDC_RST_N);
6685 }
6686 return rc;
6687
6688fail:
6689 regulator_put(vreg_timpani_1);
6690 regulator_put(vreg_timpani_2);
6691 return rc;
6692}
6693
6694static void msm_timpani_shutdown_power(void)
6695{
6696 int rc;
6697
6698 rc = regulator_disable(vreg_timpani_1);
6699 if (rc)
6700 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6701
6702 regulator_put(vreg_timpani_1);
6703
6704 rc = regulator_disable(vreg_timpani_2);
6705 if (rc)
6706 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6707
6708 regulator_put(vreg_timpani_2);
6709}
6710
6711/* Power analog function of codec */
6712static struct regulator *vreg_timpani_cdc_apwr;
6713static int msm_timpani_codec_power(int vreg_on)
6714{
6715 int rc = 0;
6716
6717 if (!vreg_timpani_cdc_apwr) {
6718
6719 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6720
6721 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6722 pr_err("%s: vreg_get failed (%ld)\n",
6723 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6724 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6725 return rc;
6726 }
6727 }
6728
6729 if (vreg_on) {
6730
6731 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6732 2200000, 2200000);
6733 if (rc) {
6734 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6735 __func__);
6736 goto vreg_fail;
6737 }
6738
6739 rc = regulator_enable(vreg_timpani_cdc_apwr);
6740 if (rc) {
6741 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6742 goto vreg_fail;
6743 }
6744 } else {
6745 rc = regulator_disable(vreg_timpani_cdc_apwr);
6746 if (rc) {
6747 pr_err("%s: vreg_disable failed %d\n",
6748 __func__, rc);
6749 goto vreg_fail;
6750 }
6751 }
6752
6753 return 0;
6754
6755vreg_fail:
6756 regulator_put(vreg_timpani_cdc_apwr);
6757 vreg_timpani_cdc_apwr = NULL;
6758 return rc;
6759}
6760
6761static struct marimba_codec_platform_data timpani_codec_pdata = {
6762 .marimba_codec_power = msm_timpani_codec_power,
6763};
6764
6765#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6766#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6767
6768static struct marimba_platform_data timpani_pdata = {
6769 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6770 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6771 .marimba_setup = msm_timpani_setup_power,
6772 .marimba_shutdown = msm_timpani_shutdown_power,
6773 .codec = &timpani_codec_pdata,
6774 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6775};
6776
6777#define TIMPANI_I2C_SLAVE_ADDR 0xD
6778
6779static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6780 {
6781 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6782 .platform_data = &timpani_pdata,
6783 },
6784};
6785
Lei Zhou338cab82011-08-19 13:38:17 -04006786#ifdef CONFIG_SND_SOC_WM8903
6787static struct wm8903_platform_data wm8903_pdata = {
6788 .gpio_cfg[2] = 0x3A8,
6789};
6790
6791#define WM8903_I2C_SLAVE_ADDR 0x34
6792static struct i2c_board_info wm8903_codec_i2c_info[] = {
6793 {
6794 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6795 .platform_data = &wm8903_pdata,
6796 },
6797};
6798#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006799#ifdef CONFIG_PMIC8901
6800
6801#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006802/*
6803 * Consumer specific regulator names:
6804 * regulator name consumer dev_name
6805 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006806static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6807 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6808};
6809static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6810 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6811};
6812
6813#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306814 _always_on) \
6815 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006816 .init_data = { \
6817 .constraints = { \
6818 .valid_modes_mask = _modes, \
6819 .valid_ops_mask = _ops, \
6820 .min_uV = _min_uV, \
6821 .max_uV = _max_uV, \
6822 .input_uV = _min_uV, \
6823 .apply_uV = _apply_uV, \
6824 .always_on = _always_on, \
6825 }, \
6826 .consumer_supplies = vreg_consumers_8901_##_id, \
6827 .num_consumer_supplies = \
6828 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6829 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306830 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006831 }
6832
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833#define PM8901_VREG_INIT_VS(_id) \
6834 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306835 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006836
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306837static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006838 PM8901_VREG_INIT_VS(USB_OTG),
6839 PM8901_VREG_INIT_VS(HDMI_MVS),
6840};
6841
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306842static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6843 .priority = 1,
6844};
6845
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306846static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6847 .irq_base = PM8901_IRQ_BASE,
6848 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6849 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6850};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006851
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306852static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6853 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006854};
6855
6856static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306857 .irq_pdata = &pm8901_irq_pdata,
6858 .mpp_pdata = &pm8901_mpp_pdata,
6859 .regulator_pdatas = pm8901_vreg_init,
6860 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306861 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006862};
6863
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306864static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6865 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6866 .slave = {
6867 .name = "pm8901-core",
6868 .platform_data = &pm8901_platform_data,
6869 },
6870};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006871#endif /* CONFIG_PMIC8901 */
6872
6873#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6874 || defined(CONFIG_GPIO_SX150X_MODULE))
6875
6876static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006877static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006878
6879struct bahama_config_register{
6880 u8 reg;
6881 u8 value;
6882 u8 mask;
6883};
6884
6885enum version{
6886 VER_1_0,
6887 VER_2_0,
6888 VER_UNSUPPORTED = 0xFF
6889};
6890
6891static u8 read_bahama_ver(void)
6892{
6893 int rc;
6894 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6895 u8 bahama_version;
6896
6897 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6898 if (rc < 0) {
6899 printk(KERN_ERR
6900 "%s: version read failed: %d\n",
6901 __func__, rc);
6902 return VER_UNSUPPORTED;
6903 } else {
6904 printk(KERN_INFO
6905 "%s: version read got: 0x%x\n",
6906 __func__, bahama_version);
6907 }
6908
6909 switch (bahama_version) {
6910 case 0x08: /* varient of bahama v1 */
6911 case 0x10:
6912 case 0x00:
6913 return VER_1_0;
6914 case 0x09: /* variant of bahama v2 */
6915 return VER_2_0;
6916 default:
6917 return VER_UNSUPPORTED;
6918 }
6919}
6920
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006921static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006922static unsigned int msm_bahama_setup_power(void)
6923{
6924 int rc = 0;
6925 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006926
6927 if (machine_is_msm8x60_dragon())
6928 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6929
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006930 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6931
6932 if (IS_ERR(vreg_bahama)) {
6933 rc = PTR_ERR(vreg_bahama);
6934 pr_err("%s: regulator_get %s = %d\n", __func__,
6935 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006936 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006937 }
6938
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006939 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6940 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006941 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6942 msm_bahama_regulator, rc);
6943 goto unget;
6944 }
6945
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006946 rc = regulator_enable(vreg_bahama);
6947 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006948 pr_err("%s: regulator_enable %s = %d\n", __func__,
6949 msm_bahama_regulator, rc);
6950 goto unget;
6951 }
6952
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006953 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6954 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006955 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006956 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 goto unenable;
6958 }
6959
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006960 gpio_direction_output(msm_bahama_sys_rst, 0);
6961 usleep_range(1000, 1050);
6962 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6963 usleep_range(1000, 1050);
6964 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006965 return rc;
6966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006967unenable:
6968 regulator_disable(vreg_bahama);
6969unget:
6970 regulator_put(vreg_bahama);
6971 return rc;
6972};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006973
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006974static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006975{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006976 if (msm_bahama_setup_power_enable) {
6977 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6978 gpio_free(msm_bahama_sys_rst);
6979 regulator_disable(vreg_bahama);
6980 regulator_put(vreg_bahama);
6981 msm_bahama_setup_power_enable = 0;
6982 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006983
6984 return 0;
6985};
6986
6987static unsigned int msm_bahama_core_config(int type)
6988{
6989 int rc = 0;
6990
6991 if (type == BAHAMA_ID) {
6992
6993 int i;
6994 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6995
6996 const struct bahama_config_register v20_init[] = {
6997 /* reg, value, mask */
6998 { 0xF4, 0x84, 0xFF }, /* AREG */
6999 { 0xF0, 0x04, 0xFF } /* DREG */
7000 };
7001
7002 if (read_bahama_ver() == VER_2_0) {
7003 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7004 u8 value = v20_init[i].value;
7005 rc = marimba_write_bit_mask(&config,
7006 v20_init[i].reg,
7007 &value,
7008 sizeof(v20_init[i].value),
7009 v20_init[i].mask);
7010 if (rc < 0) {
7011 printk(KERN_ERR
7012 "%s: reg %d write failed: %d\n",
7013 __func__, v20_init[i].reg, rc);
7014 return rc;
7015 }
7016 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7017 " mask 0x%02x\n",
7018 __func__, v20_init[i].reg,
7019 v20_init[i].value, v20_init[i].mask);
7020 }
7021 }
7022 }
7023 printk(KERN_INFO "core type: %d\n", type);
7024
7025 return rc;
7026}
7027
7028static struct regulator *fm_regulator_s3;
7029static struct msm_xo_voter *fm_clock;
7030
7031static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7032{
7033 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307034 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007035 .direction = PM_GPIO_DIR_IN,
7036 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307037 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007038 .function = PM_GPIO_FUNC_NORMAL,
7039 .inv_int_pol = 0,
7040 };
7041
7042 if (!fm_regulator_s3) {
7043 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7044 if (IS_ERR(fm_regulator_s3)) {
7045 rc = PTR_ERR(fm_regulator_s3);
7046 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7047 __func__, rc);
7048 goto out;
7049 }
7050 }
7051
7052
7053 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7054 if (rc < 0) {
7055 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7056 __func__, rc);
7057 goto fm_fail_put;
7058 }
7059
7060 rc = regulator_enable(fm_regulator_s3);
7061 if (rc < 0) {
7062 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7063 __func__, rc);
7064 goto fm_fail_put;
7065 }
7066
7067 /*Vote for XO clock*/
7068 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7069
7070 if (IS_ERR(fm_clock)) {
7071 rc = PTR_ERR(fm_clock);
7072 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7073 __func__, rc);
7074 goto fm_fail_switch;
7075 }
7076
7077 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7078 if (rc < 0) {
7079 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7080 __func__, rc);
7081 goto fm_fail_vote;
7082 }
7083
7084 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307085 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007086 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307087 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007088 __func__, rc);
7089 goto fm_fail_clock;
7090 }
7091 goto out;
7092
7093fm_fail_clock:
7094 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7095fm_fail_vote:
7096 msm_xo_put(fm_clock);
7097fm_fail_switch:
7098 regulator_disable(fm_regulator_s3);
7099fm_fail_put:
7100 regulator_put(fm_regulator_s3);
7101out:
7102 return rc;
7103};
7104
7105static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7106{
7107 int rc = 0;
7108 if (fm_regulator_s3 != NULL) {
7109 rc = regulator_disable(fm_regulator_s3);
7110 if (rc < 0) {
7111 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7112 __func__, rc);
7113 }
7114 regulator_put(fm_regulator_s3);
7115 fm_regulator_s3 = NULL;
7116 }
7117 printk(KERN_ERR "%s: Voting off for XO", __func__);
7118
7119 if (fm_clock != NULL) {
7120 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7121 if (rc < 0) {
7122 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7123 __func__, rc);
7124 }
7125 msm_xo_put(fm_clock);
7126 }
7127 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7128}
7129
7130/* Slave id address for FM/CDC/QMEMBIST
7131 * Values can be programmed using Marimba slave id 0
7132 * should there be a conflict with other I2C devices
7133 * */
7134#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7135#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7136
7137static struct marimba_fm_platform_data marimba_fm_pdata = {
7138 .fm_setup = fm_radio_setup,
7139 .fm_shutdown = fm_radio_shutdown,
7140 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7141 .is_fm_soc_i2s_master = false,
7142 .config_i2s_gpio = NULL,
7143};
7144
7145/*
7146Just initializing the BAHAMA related slave
7147*/
7148static struct marimba_platform_data marimba_pdata = {
7149 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7150 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7151 .bahama_setup = msm_bahama_setup_power,
7152 .bahama_shutdown = msm_bahama_shutdown_power,
7153 .bahama_core_config = msm_bahama_core_config,
7154 .fm = &marimba_fm_pdata,
7155 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7156};
7157
7158
7159static struct i2c_board_info msm_marimba_board_info[] = {
7160 {
7161 I2C_BOARD_INFO("marimba", 0xc),
7162 .platform_data = &marimba_pdata,
7163 }
7164};
7165#endif /* CONFIG_MAIMBA_CORE */
7166
7167#ifdef CONFIG_I2C
7168#define I2C_SURF 1
7169#define I2C_FFA (1 << 1)
7170#define I2C_RUMI (1 << 2)
7171#define I2C_SIM (1 << 3)
7172#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007173#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007174
7175struct i2c_registry {
7176 u8 machs;
7177 int bus;
7178 struct i2c_board_info *info;
7179 int len;
7180};
7181
7182static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007183#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7184 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007185 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007186 MSM_GSBI8_QUP_I2C_BUS_ID,
7187 core_expander_i2c_info,
7188 ARRAY_SIZE(core_expander_i2c_info),
7189 },
7190 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007191 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007192 MSM_GSBI8_QUP_I2C_BUS_ID,
7193 docking_expander_i2c_info,
7194 ARRAY_SIZE(docking_expander_i2c_info),
7195 },
7196 {
7197 I2C_SURF,
7198 MSM_GSBI8_QUP_I2C_BUS_ID,
7199 surf_expanders_i2c_info,
7200 ARRAY_SIZE(surf_expanders_i2c_info),
7201 },
7202 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007203 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007204 MSM_GSBI3_QUP_I2C_BUS_ID,
7205 fha_expanders_i2c_info,
7206 ARRAY_SIZE(fha_expanders_i2c_info),
7207 },
7208 {
7209 I2C_FLUID,
7210 MSM_GSBI3_QUP_I2C_BUS_ID,
7211 fluid_expanders_i2c_info,
7212 ARRAY_SIZE(fluid_expanders_i2c_info),
7213 },
7214 {
7215 I2C_FLUID,
7216 MSM_GSBI8_QUP_I2C_BUS_ID,
7217 fluid_core_expander_i2c_info,
7218 ARRAY_SIZE(fluid_core_expander_i2c_info),
7219 },
7220#endif
7221#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7222 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7223 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007224 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007225 MSM_GSBI3_QUP_I2C_BUS_ID,
7226 msm_i2c_gsbi3_tdisc_info,
7227 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7228 },
7229#endif
7230 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007231 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007232 MSM_GSBI3_QUP_I2C_BUS_ID,
7233 cy8ctmg200_board_info,
7234 ARRAY_SIZE(cy8ctmg200_board_info),
7235 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007236 {
7237 I2C_DRAGON,
7238 MSM_GSBI3_QUP_I2C_BUS_ID,
7239 cy8ctma340_dragon_board_info,
7240 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7241 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007242#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7243 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007244 {
7245 I2C_FLUID,
7246 MSM_GSBI3_QUP_I2C_BUS_ID,
7247 cyttsp_fluid_info,
7248 ARRAY_SIZE(cyttsp_fluid_info),
7249 },
7250 {
7251 I2C_FFA | I2C_SURF,
7252 MSM_GSBI3_QUP_I2C_BUS_ID,
7253 cyttsp_ffa_info,
7254 ARRAY_SIZE(cyttsp_ffa_info),
7255 },
7256#endif
7257#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007258#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007259 {
7260 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007261 MSM_GSBI4_QUP_I2C_BUS_ID,
7262 msm_camera_boardinfo,
7263 ARRAY_SIZE(msm_camera_boardinfo),
7264 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007265 {
7266 I2C_DRAGON,
7267 MSM_GSBI4_QUP_I2C_BUS_ID,
7268 msm_camera_dragon_boardinfo,
7269 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7270 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007271#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007272#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007273 {
7274 I2C_SURF | I2C_FFA | I2C_FLUID,
7275 MSM_GSBI7_QUP_I2C_BUS_ID,
7276 msm_i2c_gsbi7_timpani_info,
7277 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7278 },
7279#if defined(CONFIG_MARIMBA_CORE)
7280 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007281 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007282 MSM_GSBI7_QUP_I2C_BUS_ID,
7283 msm_marimba_board_info,
7284 ARRAY_SIZE(msm_marimba_board_info),
7285 },
7286#endif /* CONFIG_MARIMBA_CORE */
7287#ifdef CONFIG_ISL9519_CHARGER
7288 {
7289 I2C_SURF | I2C_FFA,
7290 MSM_GSBI8_QUP_I2C_BUS_ID,
7291 isl_charger_i2c_info,
7292 ARRAY_SIZE(isl_charger_i2c_info),
7293 },
7294#endif
7295#if defined(CONFIG_HAPTIC_ISA1200) || \
7296 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7297 {
7298 I2C_FLUID,
7299 MSM_GSBI8_QUP_I2C_BUS_ID,
7300 msm_isa1200_board_info,
7301 ARRAY_SIZE(msm_isa1200_board_info),
7302 },
7303#endif
7304#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7305 {
7306 I2C_FLUID,
7307 MSM_GSBI8_QUP_I2C_BUS_ID,
7308 smb137b_charger_i2c_info,
7309 ARRAY_SIZE(smb137b_charger_i2c_info),
7310 },
7311#endif
7312#if defined(CONFIG_BATTERY_BQ27520) || \
7313 defined(CONFIG_BATTERY_BQ27520_MODULE)
7314 {
7315 I2C_FLUID,
7316 MSM_GSBI8_QUP_I2C_BUS_ID,
7317 msm_bq27520_board_info,
7318 ARRAY_SIZE(msm_bq27520_board_info),
7319 },
7320#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007321#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7322 {
7323 I2C_DRAGON,
7324 MSM_GSBI8_QUP_I2C_BUS_ID,
7325 wm8903_codec_i2c_info,
7326 ARRAY_SIZE(wm8903_codec_i2c_info),
7327 },
7328#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007329};
7330#endif /* CONFIG_I2C */
7331
Stephen Boyd668d7652012-04-25 11:31:01 -07007332static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007333{
7334#ifdef CONFIG_I2C
7335#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7336 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7337 sx150x_data[SX150X_CORE].irq_summary =
7338 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007339 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7340 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007341 sx150x_data[SX150X_CORE].irq_summary =
7342 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7343 else if (machine_is_msm8x60_fluid())
7344 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7345 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7346#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007347#endif
7348}
7349
Stephen Boyd668d7652012-04-25 11:31:01 -07007350static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007351{
7352#ifdef CONFIG_I2C
7353 u8 mach_mask = 0;
7354 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007355#ifdef CONFIG_MSM_CAMERA_V4L2
7356 struct i2c_registry msm8x60_camera_i2c_devices = {
7357 I2C_SURF | I2C_FFA | I2C_FLUID,
7358 MSM_GSBI4_QUP_I2C_BUS_ID,
7359 msm8x60_camera_board_info.board_info,
7360 msm8x60_camera_board_info.num_i2c_board_info,
7361 };
7362#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007363
7364 /* Build the matching 'supported_machs' bitmask */
7365 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7366 mach_mask = I2C_SURF;
7367 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7368 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007369 else if (machine_is_msm8x60_fluid())
7370 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007371 else if (machine_is_msm8x60_dragon())
7372 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007373 else
7374 pr_err("unmatched machine ID in register_i2c_devices\n");
7375
7376 /* Run the array and install devices as appropriate */
7377 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7378 if (msm8x60_i2c_devices[i].machs & mach_mask)
7379 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7380 msm8x60_i2c_devices[i].info,
7381 msm8x60_i2c_devices[i].len);
7382 }
Kevin Chan3be11612012-03-22 20:05:40 -07007383#ifdef CONFIG_MSM_CAMERA_V4L2
7384 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7385 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7386 msm8x60_camera_i2c_devices.info,
7387 msm8x60_camera_i2c_devices.len);
7388#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007389#endif
7390}
7391
7392static void __init msm8x60_init_uart12dm(void)
7393{
7394#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7395 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7396 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7397
7398 if (!fpga_mem)
7399 pr_err("%s(): Error getting memory\n", __func__);
7400
7401 /* Advanced mode */
7402 writew(0xFFFF, fpga_mem + 0x15C);
7403 /* FPGA_UART_SEL */
7404 writew(0, fpga_mem + 0x172);
7405 /* FPGA_GPIO_CONFIG_117 */
7406 writew(1, fpga_mem + 0xEA);
7407 /* FPGA_GPIO_CONFIG_118 */
7408 writew(1, fpga_mem + 0xEC);
7409 mb();
7410 iounmap(fpga_mem);
7411#endif
7412}
7413
7414#define MSM_GSBI9_PHYS 0x19900000
7415#define GSBI_DUAL_MODE_CODE 0x60
7416
7417static void __init msm8x60_init_buses(void)
7418{
7419#ifdef CONFIG_I2C_QUP
7420 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7421 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7422 writel_relaxed(0x6 << 4, gsbi_mem);
7423 /* Ensure protocol code is written before proceeding further */
7424 mb();
7425 iounmap(gsbi_mem);
7426
7427 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7428 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7429 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7430 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7431
7432#ifdef CONFIG_MSM_GSBI9_UART
7433 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7434 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7435 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7436 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7437 iounmap(gsbi_mem);
7438 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7439 }
7440#endif
7441 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7442 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7443#endif
7444#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7445 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7446#endif
7447#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007448 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7449#endif
7450
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307451#ifdef CONFIG_MSM_SSBI
7452 msm_device_ssbi_pmic1.dev.platform_data =
7453 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307454 msm_device_ssbi_pmic2.dev.platform_data =
7455 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307456#endif
7457
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007458 if (machine_is_msm8x60_fluid()) {
7459#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7460 (defined(CONFIG_SMB137B_CHARGER) || \
7461 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7462 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7463#endif
7464#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7465 msm_gsbi10_qup_spi_device.dev.platform_data =
7466 &msm_gsbi10_qup_spi_pdata;
7467#endif
7468 }
7469
Lena Salman57d167e2012-03-21 19:46:38 +02007470#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007471 /*
7472 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7473 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7474 * and ID notifications are available only on V2 surf and FFA
7475 * with a hardware workaround.
7476 */
7477 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7478 (machine_is_msm8x60_surf() ||
7479 (machine_is_msm8x60_ffa() &&
7480 pmic_id_notif_supported)))
7481 msm_otg_pdata.phy_can_powercollapse = 1;
7482 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7483#endif
7484
Lena Salman57d167e2012-03-21 19:46:38 +02007485#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007486 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7487#endif
7488
7489#ifdef CONFIG_SERIAL_MSM_HS
7490 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7491 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7492#endif
7493#ifdef CONFIG_MSM_GSBI9_UART
7494 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7495 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7496 if (IS_ERR(msm_device_uart_gsbi9))
7497 pr_err("%s(): Failed to create uart gsbi9 device\n",
7498 __func__);
7499 }
7500#endif
7501
7502#ifdef CONFIG_MSM_BUS_SCALING
7503
7504 /* RPM calls are only enabled on V2 */
7505 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7506 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7507 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7508 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7509 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7510 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7511 }
7512
7513 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7514 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7515 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7516 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7517 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7518#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007519}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007520
7521static void __init msm8x60_map_io(void)
7522{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007523 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007524 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007525
7526 if (socinfo_init() < 0)
7527 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007528}
7529
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007530/*
7531 * Most segments of the EBI2 bus are disabled by default.
7532 */
7533static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007534{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007535 uint32_t ebi2_cfg;
7536 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007537 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007538
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007539 if (IS_ERR(mem_clk)) {
7540 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7541 "msm_ebi2", "mem_clk");
7542 return;
7543 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007544 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007545 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007546
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007547 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7548 if (ebi2_cfg_ptr != 0) {
7549 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007550
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007551 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007552 machine_is_msm8x60_fluid() ||
7553 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007554 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007555
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007556 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7557 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007558 }
7559
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007560 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007561 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007562 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7563 if (ebi2_cfg_ptr != 0) {
7564 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7565 writel_relaxed(0UL, ebi2_cfg_ptr);
7566
7567 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7568 * LAN9221 Ethernet controller reads and writes.
7569 * The lowest 4 bits are the read delay, the next
7570 * 4 are the write delay. */
7571 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7572#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7573 /*
7574 * RECOVERY=5, HOLD_WR=1
7575 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7576 * WAIT_WR=1, WAIT_RD=2
7577 */
7578 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7579 /*
7580 * HOLD_RD=1
7581 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7582 */
7583 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7584#else
7585 /* EBI2 CS3 muxed address/data,
7586 * two cyc addr enable */
7587 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7588
7589#endif
7590 iounmap(ebi2_cfg_ptr);
7591 }
7592 }
David Brown56e2d8a2011-08-04 02:01:02 -07007593}
7594
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007595#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7596 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7597 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7598 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7599 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7600
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007601/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007602#define MAX_SDCC_CONTROLLER 5
7603
7604struct msm_sdcc_gpio {
7605 /* maximum 10 GPIOs per SDCC controller */
7606 s16 no;
7607 /* name of this GPIO */
7608 const char *name;
7609 bool always_on;
7610 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007611};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007612
7613#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7614static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7615 {159, "sdc1_dat_0"},
7616 {160, "sdc1_dat_1"},
7617 {161, "sdc1_dat_2"},
7618 {162, "sdc1_dat_3"},
7619#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7620 {163, "sdc1_dat_4"},
7621 {164, "sdc1_dat_5"},
7622 {165, "sdc1_dat_6"},
7623 {166, "sdc1_dat_7"},
7624#endif
7625 {167, "sdc1_clk"},
7626 {168, "sdc1_cmd"}
7627};
7628#endif
7629
7630#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7631static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7632 {143, "sdc2_dat_0"},
7633 {144, "sdc2_dat_1", 1},
7634 {145, "sdc2_dat_2"},
7635 {146, "sdc2_dat_3"},
7636#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7637 {147, "sdc2_dat_4"},
7638 {148, "sdc2_dat_5"},
7639 {149, "sdc2_dat_6"},
7640 {150, "sdc2_dat_7"},
7641#endif
7642 {151, "sdc2_cmd"},
7643 {152, "sdc2_clk", 1}
7644};
7645#endif
7646
7647#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7648static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7649 {95, "sdc5_cmd"},
7650 {96, "sdc5_dat_3"},
7651 {97, "sdc5_clk", 1},
7652 {98, "sdc5_dat_2"},
7653 {99, "sdc5_dat_1", 1},
7654 {100, "sdc5_dat_0"}
7655};
7656#endif
7657
7658struct msm_sdcc_pad_pull_cfg {
7659 enum msm_tlmm_pull_tgt pull;
7660 u32 pull_val;
7661};
7662
7663struct msm_sdcc_pad_drv_cfg {
7664 enum msm_tlmm_hdrive_tgt drv;
7665 u32 drv_val;
7666};
7667
7668#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7669static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7670 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7671 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7672 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7673};
7674
7675static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7676 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7677 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7678};
7679
7680static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7681 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7682 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7683 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7684};
7685
7686static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7687 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7688 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7689};
7690#endif
7691
7692#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7693static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7694 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7695 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7696 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7697};
7698
7699static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7700 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7701 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7702};
7703
7704static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7705 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7706 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7707 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7708};
7709
7710static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7711 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7712 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7713};
7714#endif
7715
7716struct msm_sdcc_pin_cfg {
7717 /*
7718 * = 1 if controller pins are using gpios
7719 * = 0 if controller has dedicated MSM pins
7720 */
7721 u8 is_gpio;
7722 u8 cfg_sts;
7723 u8 gpio_data_size;
7724 struct msm_sdcc_gpio *gpio_data;
7725 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7726 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7727 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7728 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7729 u8 pad_drv_data_size;
7730 u8 pad_pull_data_size;
7731 u8 sdio_lpm_gpio_cfg;
7732};
7733
7734
7735static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7736#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7737 [0] = {
7738 .is_gpio = 1,
7739 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7740 .gpio_data = sdc1_gpio_cfg
7741 },
7742#endif
7743#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7744 [1] = {
7745 .is_gpio = 1,
7746 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7747 .gpio_data = sdc2_gpio_cfg
7748 },
7749#endif
7750#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7751 [2] = {
7752 .is_gpio = 0,
7753 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7754 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7755 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7756 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7757 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7758 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7759 },
7760#endif
7761#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7762 [3] = {
7763 .is_gpio = 0,
7764 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7765 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7766 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7767 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7768 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7769 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7770 },
7771#endif
7772#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7773 [4] = {
7774 .is_gpio = 1,
7775 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7776 .gpio_data = sdc5_gpio_cfg
7777 }
7778#endif
7779};
7780
7781static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7782{
7783 int rc = 0;
7784 struct msm_sdcc_pin_cfg *curr;
7785 int n;
7786
7787 curr = &sdcc_pin_cfg_data[dev_id - 1];
7788 if (!curr->gpio_data)
7789 goto out;
7790
7791 for (n = 0; n < curr->gpio_data_size; n++) {
7792 if (enable) {
7793
7794 if (curr->gpio_data[n].always_on &&
7795 curr->gpio_data[n].is_enabled)
7796 continue;
7797 pr_debug("%s: enable: %s\n", __func__,
7798 curr->gpio_data[n].name);
7799 rc = gpio_request(curr->gpio_data[n].no,
7800 curr->gpio_data[n].name);
7801 if (rc) {
7802 pr_err("%s: gpio_request(%d, %s)"
7803 "failed", __func__,
7804 curr->gpio_data[n].no,
7805 curr->gpio_data[n].name);
7806 goto free_gpios;
7807 }
7808 /* set direction as output for all GPIOs */
7809 rc = gpio_direction_output(
7810 curr->gpio_data[n].no, 1);
7811 if (rc) {
7812 pr_err("%s: gpio_direction_output"
7813 "(%d, 1) failed\n", __func__,
7814 curr->gpio_data[n].no);
7815 goto free_gpios;
7816 }
7817 curr->gpio_data[n].is_enabled = 1;
7818 } else {
7819 /*
7820 * now free this GPIO which will put GPIO
7821 * in low power mode and will also put GPIO
7822 * in input mode
7823 */
7824 if (curr->gpio_data[n].always_on)
7825 continue;
7826 pr_debug("%s: disable: %s\n", __func__,
7827 curr->gpio_data[n].name);
7828 gpio_free(curr->gpio_data[n].no);
7829 curr->gpio_data[n].is_enabled = 0;
7830 }
7831 }
7832 curr->cfg_sts = enable;
7833 goto out;
7834
7835free_gpios:
7836 for (; n >= 0; n--)
7837 gpio_free(curr->gpio_data[n].no);
7838out:
7839 return rc;
7840}
7841
7842static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7843{
7844 int rc = 0;
7845 struct msm_sdcc_pin_cfg *curr;
7846 int n;
7847
7848 curr = &sdcc_pin_cfg_data[dev_id - 1];
7849 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7850 goto out;
7851
7852 if (enable) {
7853 /*
7854 * set up the normal driver strength and
7855 * pull config for pads
7856 */
7857 for (n = 0; n < curr->pad_drv_data_size; n++) {
7858 if (curr->sdio_lpm_gpio_cfg) {
7859 if (curr->pad_drv_on_data[n].drv ==
7860 TLMM_HDRV_SDC4_DATA)
7861 continue;
7862 }
7863 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7864 curr->pad_drv_on_data[n].drv_val);
7865 }
7866 for (n = 0; n < curr->pad_pull_data_size; n++) {
7867 if (curr->sdio_lpm_gpio_cfg) {
7868 if (curr->pad_pull_on_data[n].pull ==
7869 TLMM_PULL_SDC4_DATA)
7870 continue;
7871 }
7872 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7873 curr->pad_pull_on_data[n].pull_val);
7874 }
7875 } else {
7876 /* set the low power config for pads */
7877 for (n = 0; n < curr->pad_drv_data_size; n++) {
7878 if (curr->sdio_lpm_gpio_cfg) {
7879 if (curr->pad_drv_off_data[n].drv ==
7880 TLMM_HDRV_SDC4_DATA)
7881 continue;
7882 }
7883 msm_tlmm_set_hdrive(
7884 curr->pad_drv_off_data[n].drv,
7885 curr->pad_drv_off_data[n].drv_val);
7886 }
7887 for (n = 0; n < curr->pad_pull_data_size; n++) {
7888 if (curr->sdio_lpm_gpio_cfg) {
7889 if (curr->pad_pull_off_data[n].pull ==
7890 TLMM_PULL_SDC4_DATA)
7891 continue;
7892 }
7893 msm_tlmm_set_pull(
7894 curr->pad_pull_off_data[n].pull,
7895 curr->pad_pull_off_data[n].pull_val);
7896 }
7897 }
7898 curr->cfg_sts = enable;
7899out:
7900 return rc;
7901}
7902
7903struct sdcc_reg {
7904 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7905 const char *reg_name;
7906 /*
7907 * is set voltage supported for this regulator?
7908 * 0 = not supported, 1 = supported
7909 */
7910 unsigned char set_voltage_sup;
7911 /* voltage level to be set */
7912 unsigned int level;
7913 /* VDD/VCC/VCCQ voltage regulator handle */
7914 struct regulator *reg;
7915 /* is this regulator enabled? */
7916 bool enabled;
7917 /* is this regulator needs to be always on? */
7918 bool always_on;
7919 /* is operating power mode setting required for this regulator? */
7920 bool op_pwr_mode_sup;
7921 /* Load values for low power and high power mode */
7922 unsigned int lpm_uA;
7923 unsigned int hpm_uA;
7924};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007925/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007926static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7927/* only SDCC1 requires VCCQ voltage */
7928static struct sdcc_reg sdcc_vccq_reg_data[1];
7929/* all SDCC controllers may require voting for VDD PAD voltage */
7930static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7931
7932struct sdcc_reg_data {
7933 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7934 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7935 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7936 unsigned char sts; /* regulator enable/disable status */
7937};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007938/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007939static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7940
7941static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7942{
7943 int rc = 0;
7944
7945 /* Get the regulator handle */
7946 vreg->reg = regulator_get(NULL, vreg->reg_name);
7947 if (IS_ERR(vreg->reg)) {
7948 rc = PTR_ERR(vreg->reg);
7949 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7950 __func__, vreg->reg_name, rc);
7951 goto out;
7952 }
7953
7954 /* Set the voltage level if required */
7955 if (vreg->set_voltage_sup) {
7956 rc = regulator_set_voltage(vreg->reg, vreg->level,
7957 vreg->level);
7958 if (rc) {
7959 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7960 __func__, vreg->reg_name, rc);
7961 goto vreg_put;
7962 }
7963 }
7964 goto out;
7965
7966vreg_put:
7967 regulator_put(vreg->reg);
7968out:
7969 return rc;
7970}
7971
7972static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7973{
7974 regulator_put(vreg->reg);
7975}
7976
7977/* this init function should be called only once for each SDCC */
7978static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7979{
7980 int rc = 0;
7981 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7982 struct sdcc_reg_data *curr;
7983
7984 curr = &sdcc_vreg_data[dev_id - 1];
7985 curr_vdd_reg = curr->vdd_data;
7986 curr_vccq_reg = curr->vccq_data;
7987 curr_vddp_reg = curr->vddp_data;
7988
7989 if (init) {
7990 /*
7991 * get the regulator handle from voltage regulator framework
7992 * and then try to set the voltage level for the regulator
7993 */
7994 if (curr_vdd_reg) {
7995 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7996 if (rc)
7997 goto out;
7998 }
7999 if (curr_vccq_reg) {
8000 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8001 if (rc)
8002 goto vdd_reg_deinit;
8003 }
8004 if (curr_vddp_reg) {
8005 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8006 if (rc)
8007 goto vccq_reg_deinit;
8008 }
8009 goto out;
8010 } else
8011 /* deregister with all regulators from regulator framework */
8012 goto vddp_reg_deinit;
8013
8014vddp_reg_deinit:
8015 if (curr_vddp_reg)
8016 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8017vccq_reg_deinit:
8018 if (curr_vccq_reg)
8019 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8020vdd_reg_deinit:
8021 if (curr_vdd_reg)
8022 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8023out:
8024 return rc;
8025}
8026
8027static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8028{
8029 int rc;
8030
8031 if (!vreg->enabled) {
8032 rc = regulator_enable(vreg->reg);
8033 if (rc) {
8034 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8035 __func__, vreg->reg_name, rc);
8036 goto out;
8037 }
8038 vreg->enabled = 1;
8039 }
8040
8041 /* Put always_on regulator in HPM (high power mode) */
8042 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8043 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8044 if (rc < 0) {
8045 pr_err("%s: reg=%s: HPM setting failed"
8046 " hpm_uA=%d, rc=%d\n",
8047 __func__, vreg->reg_name,
8048 vreg->hpm_uA, rc);
8049 goto vreg_disable;
8050 }
8051 rc = 0;
8052 }
8053 goto out;
8054
8055vreg_disable:
8056 regulator_disable(vreg->reg);
8057 vreg->enabled = 0;
8058out:
8059 return rc;
8060}
8061
8062static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8063{
8064 int rc;
8065
8066 /* Never disable always_on regulator */
8067 if (!vreg->always_on) {
8068 rc = regulator_disable(vreg->reg);
8069 if (rc) {
8070 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8071 __func__, vreg->reg_name, rc);
8072 goto out;
8073 }
8074 vreg->enabled = 0;
8075 }
8076
8077 /* Put always_on regulator in LPM (low power mode) */
8078 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8079 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8080 if (rc < 0) {
8081 pr_err("%s: reg=%s: LPM setting failed"
8082 " lpm_uA=%d, rc=%d\n",
8083 __func__,
8084 vreg->reg_name,
8085 vreg->lpm_uA, rc);
8086 goto out;
8087 }
8088 rc = 0;
8089 }
8090
8091out:
8092 return rc;
8093}
8094
8095static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8096{
8097 int rc = 0;
8098 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8099 struct sdcc_reg_data *curr;
8100
8101 curr = &sdcc_vreg_data[dev_id - 1];
8102 curr_vdd_reg = curr->vdd_data;
8103 curr_vccq_reg = curr->vccq_data;
8104 curr_vddp_reg = curr->vddp_data;
8105
8106 /* check if regulators are initialized or not? */
8107 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8108 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8109 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8110 /* initialize voltage regulators required for this SDCC */
8111 rc = msm_sdcc_vreg_init(dev_id, 1);
8112 if (rc) {
8113 pr_err("%s: regulator init failed = %d\n",
8114 __func__, rc);
8115 goto out;
8116 }
8117 }
8118
8119 if (curr->sts == enable)
8120 goto out;
8121
8122 if (curr_vdd_reg) {
8123 if (enable)
8124 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8125 else
8126 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8127 if (rc)
8128 goto out;
8129 }
8130
8131 if (curr_vccq_reg) {
8132 if (enable)
8133 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8134 else
8135 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8136 if (rc)
8137 goto out;
8138 }
8139
8140 if (curr_vddp_reg) {
8141 if (enable)
8142 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8143 else
8144 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8145 if (rc)
8146 goto out;
8147 }
8148 curr->sts = enable;
8149
8150out:
8151 return rc;
8152}
8153
8154static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8155{
8156 u32 rc_pin_cfg = 0;
8157 u32 rc_vreg_cfg = 0;
8158 u32 rc = 0;
8159 struct platform_device *pdev;
8160 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8161
8162 pdev = container_of(dv, struct platform_device, dev);
8163
8164 /* setup gpio/pad */
8165 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8166 if (curr_pin_cfg->cfg_sts == !!vdd)
8167 goto setup_vreg;
8168
8169 if (curr_pin_cfg->is_gpio)
8170 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8171 else
8172 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8173
8174setup_vreg:
8175 /* setup voltage regulators */
8176 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8177
8178 if (rc_pin_cfg || rc_vreg_cfg)
8179 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8180
8181 return rc;
8182}
8183
8184static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8185{
8186 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8187 struct platform_device *pdev;
8188
8189 pdev = container_of(dv, struct platform_device, dev);
8190 /* setup gpio/pad */
8191 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8192
8193 if (curr_pin_cfg->cfg_sts == active)
8194 return;
8195
8196 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8197 if (curr_pin_cfg->is_gpio)
8198 msm_sdcc_setup_gpio(pdev->id, active);
8199 else
8200 msm_sdcc_setup_pad(pdev->id, active);
8201 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8202}
8203
8204static int msm_sdc3_get_wpswitch(struct device *dev)
8205{
8206 struct platform_device *pdev;
8207 int status;
8208 pdev = container_of(dev, struct platform_device, dev);
8209
8210 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8211 if (status) {
8212 pr_err("%s:Failed to request GPIO %d\n",
8213 __func__, GPIO_SDC_WP);
8214 } else {
8215 status = gpio_direction_input(GPIO_SDC_WP);
8216 if (!status) {
8217 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8218 pr_info("%s: WP Status for Slot %d = %d\n",
8219 __func__, pdev->id, status);
8220 }
8221 gpio_free(GPIO_SDC_WP);
8222 }
8223 return status;
8224}
8225
8226#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8227int sdc5_register_status_notify(void (*callback)(int, void *),
8228 void *dev_id)
8229{
8230 sdc5_status_notify_cb = callback;
8231 sdc5_status_notify_cb_devid = dev_id;
8232 return 0;
8233}
8234#endif
8235
8236#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8237int sdc2_register_status_notify(void (*callback)(int, void *),
8238 void *dev_id)
8239{
8240 sdc2_status_notify_cb = callback;
8241 sdc2_status_notify_cb_devid = dev_id;
8242 return 0;
8243}
8244#endif
8245
8246/* Interrupt handler for SDC2 and SDC5 detection
8247 * This function uses dual-edge interrputs settings in order
8248 * to get SDIO detection when the GPIO is rising and SDIO removal
8249 * when the GPIO is falling */
8250static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8251{
8252 int status;
8253
8254 if (!machine_is_msm8x60_fusion() &&
8255 !machine_is_msm8x60_fusn_ffa())
8256 return IRQ_NONE;
8257
8258 status = gpio_get_value(MDM2AP_SYNC);
8259 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8260 __func__, status);
8261
8262#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8263 if (sdc2_status_notify_cb) {
8264 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8265 sdc2_status_notify_cb(status,
8266 sdc2_status_notify_cb_devid);
8267 }
8268#endif
8269
8270#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8271 if (sdc5_status_notify_cb) {
8272 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8273 sdc5_status_notify_cb(status,
8274 sdc5_status_notify_cb_devid);
8275 }
8276#endif
8277 return IRQ_HANDLED;
8278}
8279
8280static int msm8x60_multi_sdio_init(void)
8281{
8282 int ret, irq_num;
8283
8284 if (!machine_is_msm8x60_fusion() &&
8285 !machine_is_msm8x60_fusn_ffa())
8286 return 0;
8287
8288 ret = msm_gpiomux_get(MDM2AP_SYNC);
8289 if (ret) {
8290 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8291 __func__, MDM2AP_SYNC, ret);
8292 return ret;
8293 }
8294
8295 irq_num = gpio_to_irq(MDM2AP_SYNC);
8296
8297 ret = request_irq(irq_num,
8298 msm8x60_multi_sdio_slot_status_irq,
8299 IRQ_TYPE_EDGE_BOTH,
8300 "sdio_multidetection", NULL);
8301
8302 if (ret) {
8303 pr_err("%s:Failed to request irq, ret=%d\n",
8304 __func__, ret);
8305 return ret;
8306 }
8307
8308 return ret;
8309}
8310
8311#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008312static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8313{
8314 int status;
8315
8316 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8317 , "SD_HW_Detect");
8318 if (status) {
8319 pr_err("%s:Failed to request GPIO %d\n", __func__,
8320 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8321 } else {
8322 status = gpio_direction_input(
8323 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8324 if (!status)
8325 status = !(gpio_get_value_cansleep(
8326 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8327 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8328 }
8329 return (unsigned int) status;
8330}
8331#endif
8332#endif
8333
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308334#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308335#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008336
8337#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8338static struct mmc_platform_data msm8x60_sdc1_data = {
8339 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8340 .translate_vdd = msm_sdcc_setup_power,
8341#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8342 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8343#else
8344 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8345#endif
8346 .msmsdcc_fmin = 400000,
8347 .msmsdcc_fmid = 24000000,
8348 .msmsdcc_fmax = 48000000,
8349 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308350 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008351};
8352#endif
8353
8354#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8355static struct mmc_platform_data msm8x60_sdc2_data = {
8356 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8357 .translate_vdd = msm_sdcc_setup_power,
8358 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8359 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8360 .msmsdcc_fmin = 400000,
8361 .msmsdcc_fmid = 24000000,
8362 .msmsdcc_fmax = 48000000,
8363 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008364 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008365#ifdef CONFIG_MSM_SDIO_AL
8366 .is_sdio_al_client = 1,
8367#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308368 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008369};
8370#endif
8371
8372#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8373static struct mmc_platform_data msm8x60_sdc3_data = {
8374 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8375 .translate_vdd = msm_sdcc_setup_power,
8376 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8377 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008378 .status = msm8x60_sdcc_slot_status,
8379 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8380 PMIC_GPIO_SDC3_DET - 1),
8381 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008382 .msmsdcc_fmin = 400000,
8383 .msmsdcc_fmid = 24000000,
8384 .msmsdcc_fmax = 48000000,
8385 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308386 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308387 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008388};
8389#endif
8390
8391#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8392static struct mmc_platform_data msm8x60_sdc4_data = {
8393 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8394 .translate_vdd = msm_sdcc_setup_power,
8395 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8396 .msmsdcc_fmin = 400000,
8397 .msmsdcc_fmid = 24000000,
8398 .msmsdcc_fmax = 48000000,
8399 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308400 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308401 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008402};
8403#endif
8404
8405#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8406static struct mmc_platform_data msm8x60_sdc5_data = {
8407 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8408 .translate_vdd = msm_sdcc_setup_power,
8409 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8410 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8411 .msmsdcc_fmin = 400000,
8412 .msmsdcc_fmid = 24000000,
8413 .msmsdcc_fmax = 48000000,
8414 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008415 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008416#ifdef CONFIG_MSM_SDIO_AL
8417 .is_sdio_al_client = 1,
8418#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308419 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008420};
8421#endif
8422
8423static void __init msm8x60_init_mmc(void)
8424{
8425#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8426 /* SDCC1 : eMMC card connected */
8427 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8428 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8429 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8430 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308431 sdcc_vreg_data[0].vdd_data->always_on = 1;
8432 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8433 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8434 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008435
8436 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8437 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8438 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8439 sdcc_vreg_data[0].vccq_data->always_on = 1;
8440
8441 msm_add_sdcc(1, &msm8x60_sdc1_data);
8442#endif
8443#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8444 /*
8445 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8446 * and no card is connected on 8660 SURF/FFA/FLUID.
8447 */
8448 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8449 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8450 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8451 sdcc_vreg_data[1].vdd_data->level = 1800000;
8452
8453 sdcc_vreg_data[1].vccq_data = NULL;
8454
8455 if (machine_is_msm8x60_fusion())
8456 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8457 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008458 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8459 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008460 msm_add_sdcc(2, &msm8x60_sdc2_data);
8461 }
8462#endif
8463#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8464 /* SDCC3 : External card slot connected */
8465 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8466 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8467 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8468 sdcc_vreg_data[2].vdd_data->level = 2850000;
8469 sdcc_vreg_data[2].vdd_data->always_on = 1;
8470 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8471 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8472 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8473
8474 sdcc_vreg_data[2].vccq_data = NULL;
8475
8476 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8477 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8478 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8479 sdcc_vreg_data[2].vddp_data->level = 2850000;
8480 sdcc_vreg_data[2].vddp_data->always_on = 1;
8481 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8482 /* Sleep current required is ~300 uA. But min. RPM
8483 * vote can be in terms of mA (min. 1 mA).
8484 * So let's vote for 2 mA during sleep.
8485 */
8486 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8487 /* Max. Active current required is 16 mA */
8488 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8489
8490 if (machine_is_msm8x60_fluid())
8491 msm8x60_sdc3_data.wpswitch = NULL;
8492 msm_add_sdcc(3, &msm8x60_sdc3_data);
8493#endif
8494#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8495 /* SDCC4 : WLAN WCN1314 chip is connected */
8496 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8497 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8498 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8499 sdcc_vreg_data[3].vdd_data->level = 1800000;
8500
8501 sdcc_vreg_data[3].vccq_data = NULL;
8502
8503 msm_add_sdcc(4, &msm8x60_sdc4_data);
8504#endif
8505#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8506 /*
8507 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8508 * and no card is connected on 8660 SURF/FFA/FLUID.
8509 */
8510 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8511 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8512 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8513 sdcc_vreg_data[4].vdd_data->level = 1800000;
8514
8515 sdcc_vreg_data[4].vccq_data = NULL;
8516
8517 if (machine_is_msm8x60_fusion())
8518 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8519 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008520 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8521 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008522 msm_add_sdcc(5, &msm8x60_sdc5_data);
8523 }
8524#endif
8525}
8526
8527#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8528static inline void display_common_power(int on) {}
8529#else
8530
8531#define _GET_REGULATOR(var, name) do { \
8532 if (var == NULL) { \
8533 var = regulator_get(NULL, name); \
8534 if (IS_ERR(var)) { \
8535 pr_err("'%s' regulator not found, rc=%ld\n", \
8536 name, PTR_ERR(var)); \
8537 var = NULL; \
8538 } \
8539 } \
8540} while (0)
8541
8542static int dsub_regulator(int on)
8543{
8544 static struct regulator *dsub_reg;
8545 static struct regulator *mpp0_reg;
8546 static int dsub_reg_enabled;
8547 int rc = 0;
8548
8549 _GET_REGULATOR(dsub_reg, "8901_l3");
8550 if (IS_ERR(dsub_reg)) {
8551 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8552 __func__, PTR_ERR(dsub_reg));
8553 return PTR_ERR(dsub_reg);
8554 }
8555
8556 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8557 if (IS_ERR(mpp0_reg)) {
8558 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8559 __func__, PTR_ERR(mpp0_reg));
8560 return PTR_ERR(mpp0_reg);
8561 }
8562
8563 if (on && !dsub_reg_enabled) {
8564 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8565 if (rc) {
8566 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8567 " err=%d", __func__, rc);
8568 goto dsub_regulator_err;
8569 }
8570 rc = regulator_enable(dsub_reg);
8571 if (rc) {
8572 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8573 " err=%d", __func__, rc);
8574 goto dsub_regulator_err;
8575 }
8576 rc = regulator_enable(mpp0_reg);
8577 if (rc) {
8578 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8579 " err=%d", __func__, rc);
8580 goto dsub_regulator_err;
8581 }
8582 dsub_reg_enabled = 1;
8583 } else if (!on && dsub_reg_enabled) {
8584 rc = regulator_disable(dsub_reg);
8585 if (rc)
8586 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8587 " err=%d", __func__, rc);
8588 rc = regulator_disable(mpp0_reg);
8589 if (rc)
8590 printk(KERN_WARNING "%s: failed to disable reg "
8591 "8901_mpp0 err=%d", __func__, rc);
8592 dsub_reg_enabled = 0;
8593 }
8594
8595 return rc;
8596
8597dsub_regulator_err:
8598 regulator_put(mpp0_reg);
8599 regulator_put(dsub_reg);
8600 return rc;
8601}
8602
8603static int display_power_on;
8604static void setup_display_power(void)
8605{
8606 if (display_power_on)
8607 if (lcdc_vga_enabled) {
8608 dsub_regulator(1);
8609 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8610 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8611 if (machine_is_msm8x60_ffa() ||
8612 machine_is_msm8x60_fusn_ffa())
8613 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8614 } else {
8615 dsub_regulator(0);
8616 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8617 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8618 if (machine_is_msm8x60_ffa() ||
8619 machine_is_msm8x60_fusn_ffa())
8620 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8621 }
8622 else {
8623 dsub_regulator(0);
8624 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8625 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8626 /* BACKLIGHT */
8627 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8628 /* LVDS */
8629 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8630 }
8631}
8632
8633#define _GET_REGULATOR(var, name) do { \
8634 if (var == NULL) { \
8635 var = regulator_get(NULL, name); \
8636 if (IS_ERR(var)) { \
8637 pr_err("'%s' regulator not found, rc=%ld\n", \
8638 name, PTR_ERR(var)); \
8639 var = NULL; \
8640 } \
8641 } \
8642} while (0)
8643
8644#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8645
8646static void display_common_power(int on)
8647{
8648 int rc;
8649 static struct regulator *display_reg;
8650
8651 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8652 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8653 if (on) {
8654 /* LVDS */
8655 _GET_REGULATOR(display_reg, "8901_l2");
8656 if (!display_reg)
8657 return;
8658 rc = regulator_set_voltage(display_reg,
8659 3300000, 3300000);
8660 if (rc)
8661 goto out;
8662 rc = regulator_enable(display_reg);
8663 if (rc)
8664 goto out;
8665 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8666 "LVDS_STDN_OUT_N");
8667 if (rc) {
8668 printk(KERN_ERR "%s: LVDS gpio %d request"
8669 "failed\n", __func__,
8670 GPIO_LVDS_SHUTDOWN_N);
8671 goto out2;
8672 }
8673
8674 /* BACKLIGHT */
8675 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8676 if (rc) {
8677 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8678 "failed\n", __func__,
8679 GPIO_BACKLIGHT_EN);
8680 goto out3;
8681 }
8682
8683 if (machine_is_msm8x60_ffa() ||
8684 machine_is_msm8x60_fusn_ffa()) {
8685 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8686 "DONGLE_PWR_EN");
8687 if (rc) {
8688 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8689 " %d request failed\n", __func__,
8690 GPIO_DONGLE_PWR_EN);
8691 goto out4;
8692 }
8693 }
8694
8695 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8696 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8697 if (machine_is_msm8x60_ffa() ||
8698 machine_is_msm8x60_fusn_ffa())
8699 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8700 mdelay(20);
8701 display_power_on = 1;
8702 setup_display_power();
8703 } else {
8704 if (display_power_on) {
8705 display_power_on = 0;
8706 setup_display_power();
8707 mdelay(20);
8708 if (machine_is_msm8x60_ffa() ||
8709 machine_is_msm8x60_fusn_ffa())
8710 gpio_free(GPIO_DONGLE_PWR_EN);
8711 goto out4;
8712 }
8713 }
8714 }
8715#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8716 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8717 else if (machine_is_msm8x60_fluid()) {
8718 static struct regulator *fluid_reg;
8719 static struct regulator *fluid_reg2;
8720
8721 if (on) {
8722 _GET_REGULATOR(fluid_reg, "8901_l2");
8723 if (!fluid_reg)
8724 return;
8725 _GET_REGULATOR(fluid_reg2, "8058_s3");
8726 if (!fluid_reg2) {
8727 regulator_put(fluid_reg);
8728 return;
8729 }
8730 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8731 if (rc) {
8732 regulator_put(fluid_reg2);
8733 regulator_put(fluid_reg);
8734 return;
8735 }
8736 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8737 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8738 regulator_enable(fluid_reg);
8739 regulator_enable(fluid_reg2);
8740 msleep(20);
8741 gpio_direction_output(GPIO_RESX_N, 0);
8742 udelay(10);
8743 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8744 display_power_on = 1;
8745 setup_display_power();
8746 } else {
8747 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8748 gpio_free(GPIO_RESX_N);
8749 msleep(20);
8750 regulator_disable(fluid_reg2);
8751 regulator_disable(fluid_reg);
8752 regulator_put(fluid_reg2);
8753 regulator_put(fluid_reg);
8754 display_power_on = 0;
8755 setup_display_power();
8756 fluid_reg = NULL;
8757 fluid_reg2 = NULL;
8758 }
8759 }
8760#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008761#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8762 else if (machine_is_msm8x60_dragon()) {
8763 static struct regulator *dragon_reg;
8764 static struct regulator *dragon_reg2;
8765
8766 if (on) {
8767 _GET_REGULATOR(dragon_reg, "8901_l2");
8768 if (!dragon_reg)
8769 return;
8770 _GET_REGULATOR(dragon_reg2, "8058_l16");
8771 if (!dragon_reg2) {
8772 regulator_put(dragon_reg);
8773 dragon_reg = NULL;
8774 return;
8775 }
8776
8777 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8778 if (rc) {
8779 pr_err("%s: gpio %d request failed with rc=%d\n",
8780 __func__, GPIO_NT35582_BL_EN, rc);
8781 regulator_put(dragon_reg);
8782 regulator_put(dragon_reg2);
8783 dragon_reg = NULL;
8784 dragon_reg2 = NULL;
8785 return;
8786 }
8787
8788 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8789 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8790 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8791 pr_err("%s: config gpio '%d' failed!\n",
8792 __func__, GPIO_NT35582_RESET);
8793 gpio_free(GPIO_NT35582_BL_EN);
8794 regulator_put(dragon_reg);
8795 regulator_put(dragon_reg2);
8796 dragon_reg = NULL;
8797 dragon_reg2 = NULL;
8798 return;
8799 }
8800
8801 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8802 if (rc) {
8803 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8804 __func__, GPIO_NT35582_RESET, rc);
8805 gpio_free(GPIO_NT35582_BL_EN);
8806 regulator_put(dragon_reg);
8807 regulator_put(dragon_reg2);
8808 dragon_reg = NULL;
8809 dragon_reg2 = NULL;
8810 return;
8811 }
8812
8813 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8814 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8815 regulator_enable(dragon_reg);
8816 regulator_enable(dragon_reg2);
8817 msleep(20);
8818
8819 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8820 msleep(20);
8821 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8822 msleep(20);
8823 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8824 msleep(50);
8825
8826 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8827
8828 display_power_on = 1;
8829 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8830 gpio_free(GPIO_NT35582_RESET);
8831 gpio_free(GPIO_NT35582_BL_EN);
8832 regulator_disable(dragon_reg2);
8833 regulator_disable(dragon_reg);
8834 regulator_put(dragon_reg2);
8835 regulator_put(dragon_reg);
8836 display_power_on = 0;
8837 dragon_reg = NULL;
8838 dragon_reg2 = NULL;
8839 }
8840 }
8841#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008842 return;
8843
8844out4:
8845 gpio_free(GPIO_BACKLIGHT_EN);
8846out3:
8847 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8848out2:
8849 regulator_disable(display_reg);
8850out:
8851 regulator_put(display_reg);
8852 display_reg = NULL;
8853}
8854#undef _GET_REGULATOR
8855#endif
8856
8857static int mipi_dsi_panel_power(int on);
8858
8859#define LCDC_NUM_GPIO 28
8860#define LCDC_GPIO_START 0
8861
8862static void lcdc_samsung_panel_power(int on)
8863{
8864 int n, ret = 0;
8865
8866 display_common_power(on);
8867
8868 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8869 if (on) {
8870 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8871 if (unlikely(ret)) {
8872 pr_err("%s not able to get gpio\n", __func__);
8873 break;
8874 }
8875 } else
8876 gpio_free(LCDC_GPIO_START + n);
8877 }
8878
8879 if (ret) {
8880 for (n--; n >= 0; n--)
8881 gpio_free(LCDC_GPIO_START + n);
8882 }
8883
8884 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8885}
8886
8887#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8888#define _GET_REGULATOR(var, name) do { \
8889 var = regulator_get(NULL, name); \
8890 if (IS_ERR(var)) { \
8891 pr_err("'%s' regulator not found, rc=%ld\n", \
8892 name, IS_ERR(var)); \
8893 var = NULL; \
8894 return -ENODEV; \
8895 } \
8896} while (0)
8897
8898static int hdmi_enable_5v(int on)
8899{
8900 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8901 static struct regulator *reg_8901_mpp0; /* External 5V */
8902 static int prev_on;
8903 int rc;
8904
8905 if (on == prev_on)
8906 return 0;
8907
8908 if (!reg_8901_hdmi_mvs)
8909 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8910 if (!reg_8901_mpp0)
8911 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8912
8913 if (on) {
8914 rc = regulator_enable(reg_8901_mpp0);
8915 if (rc) {
8916 pr_err("'%s' regulator enable failed, rc=%d\n",
8917 "reg_8901_mpp0", rc);
8918 return rc;
8919 }
8920 rc = regulator_enable(reg_8901_hdmi_mvs);
8921 if (rc) {
8922 pr_err("'%s' regulator enable failed, rc=%d\n",
8923 "8901_hdmi_mvs", rc);
8924 return rc;
8925 }
8926 pr_info("%s(on): success\n", __func__);
8927 } else {
8928 rc = regulator_disable(reg_8901_hdmi_mvs);
8929 if (rc)
8930 pr_warning("'%s' regulator disable failed, rc=%d\n",
8931 "8901_hdmi_mvs", rc);
8932 rc = regulator_disable(reg_8901_mpp0);
8933 if (rc)
8934 pr_warning("'%s' regulator disable failed, rc=%d\n",
8935 "reg_8901_mpp0", rc);
8936 pr_info("%s(off): success\n", __func__);
8937 }
8938
8939 prev_on = on;
8940
8941 return 0;
8942}
8943
8944static int hdmi_core_power(int on, int show)
8945{
8946 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8947 static int prev_on;
8948 int rc;
8949
8950 if (on == prev_on)
8951 return 0;
8952
8953 if (!reg_8058_l16)
8954 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8955
8956 if (on) {
8957 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8958 if (!rc)
8959 rc = regulator_enable(reg_8058_l16);
8960 if (rc) {
8961 pr_err("'%s' regulator enable failed, rc=%d\n",
8962 "8058_l16", rc);
8963 return rc;
8964 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05308965 pr_debug("%s(on): success\n", __func__);
8966 } else {
8967 rc = regulator_disable(reg_8058_l16);
8968 if (rc)
8969 pr_warning("'%s' regulator disable failed, rc=%d\n",
8970 "8058_l16", rc);
8971 pr_debug("%s(off): success\n", __func__);
8972 }
8973
8974 prev_on = on;
8975
8976 return 0;
8977}
8978
8979static int hdmi_gpio_config(int on)
8980{
8981 int rc = 0;
8982 static int prev_on;
8983
8984 if (on == prev_on)
8985 return 0;
8986
8987 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008988 rc = gpio_request(170, "HDMI_DDC_CLK");
8989 if (rc) {
8990 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8991 "HDMI_DDC_CLK", 170, rc);
8992 goto error1;
8993 }
8994 rc = gpio_request(171, "HDMI_DDC_DATA");
8995 if (rc) {
8996 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8997 "HDMI_DDC_DATA", 171, rc);
8998 goto error2;
8999 }
9000 rc = gpio_request(172, "HDMI_HPD");
9001 if (rc) {
9002 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9003 "HDMI_HPD", 172, rc);
9004 goto error3;
9005 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309006 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009007 } else {
9008 gpio_free(170);
9009 gpio_free(171);
9010 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309011 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009012 }
9013
9014 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009015 return 0;
9016
9017error3:
9018 gpio_free(171);
9019error2:
9020 gpio_free(170);
9021error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009022 return rc;
9023}
9024
9025static int hdmi_cec_power(int on)
9026{
9027 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9028 static int prev_on;
9029 int rc;
9030
9031 if (on == prev_on)
9032 return 0;
9033
9034 if (!reg_8901_l3)
9035 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9036
9037 if (on) {
9038 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9039 if (!rc)
9040 rc = regulator_enable(reg_8901_l3);
9041 if (rc) {
9042 pr_err("'%s' regulator enable failed, rc=%d\n",
9043 "8901_l3", rc);
9044 return rc;
9045 }
9046 rc = gpio_request(169, "HDMI_CEC_VAR");
9047 if (rc) {
9048 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9049 "HDMI_CEC_VAR", 169, rc);
9050 goto error;
9051 }
9052 pr_info("%s(on): success\n", __func__);
9053 } else {
9054 gpio_free(169);
9055 rc = regulator_disable(reg_8901_l3);
9056 if (rc)
9057 pr_warning("'%s' regulator disable failed, rc=%d\n",
9058 "8901_l3", rc);
9059 pr_info("%s(off): success\n", __func__);
9060 }
9061
9062 prev_on = on;
9063
9064 return 0;
9065error:
9066 regulator_disable(reg_8901_l3);
9067 return rc;
9068}
9069
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309070static int hdmi_panel_power(int on)
9071{
9072 int rc;
9073
9074 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9075 rc = hdmi_core_power(on, 1);
9076 if (rc)
9077 rc = hdmi_cec_power(on);
9078
9079 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9080 return rc;
9081}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009082#undef _GET_REGULATOR
9083
9084#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9085
9086static int lcdc_panel_power(int on)
9087{
9088 int flag_on = !!on;
9089 static int lcdc_power_save_on;
9090
9091 if (lcdc_power_save_on == flag_on)
9092 return 0;
9093
9094 lcdc_power_save_on = flag_on;
9095
9096 lcdc_samsung_panel_power(on);
9097
9098 return 0;
9099}
9100
9101#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009102
9103static struct msm_bus_vectors rotator_init_vectors[] = {
9104 {
9105 .src = MSM_BUS_MASTER_ROTATOR,
9106 .dst = MSM_BUS_SLAVE_SMI,
9107 .ab = 0,
9108 .ib = 0,
9109 },
9110 {
9111 .src = MSM_BUS_MASTER_ROTATOR,
9112 .dst = MSM_BUS_SLAVE_EBI_CH0,
9113 .ab = 0,
9114 .ib = 0,
9115 },
9116};
9117
9118static struct msm_bus_vectors rotator_ui_vectors[] = {
9119 {
9120 .src = MSM_BUS_MASTER_ROTATOR,
9121 .dst = MSM_BUS_SLAVE_SMI,
9122 .ab = 0,
9123 .ib = 0,
9124 },
9125 {
9126 .src = MSM_BUS_MASTER_ROTATOR,
9127 .dst = MSM_BUS_SLAVE_EBI_CH0,
9128 .ab = (1024 * 600 * 4 * 2 * 60),
9129 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9130 },
9131};
9132
9133static struct msm_bus_vectors rotator_vga_vectors[] = {
9134 {
9135 .src = MSM_BUS_MASTER_ROTATOR,
9136 .dst = MSM_BUS_SLAVE_SMI,
9137 .ab = (640 * 480 * 2 * 2 * 30),
9138 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9139 },
9140 {
9141 .src = MSM_BUS_MASTER_ROTATOR,
9142 .dst = MSM_BUS_SLAVE_EBI_CH0,
9143 .ab = (640 * 480 * 2 * 2 * 30),
9144 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9145 },
9146};
9147
9148static struct msm_bus_vectors rotator_720p_vectors[] = {
9149 {
9150 .src = MSM_BUS_MASTER_ROTATOR,
9151 .dst = MSM_BUS_SLAVE_SMI,
9152 .ab = (1280 * 736 * 2 * 2 * 30),
9153 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9154 },
9155 {
9156 .src = MSM_BUS_MASTER_ROTATOR,
9157 .dst = MSM_BUS_SLAVE_EBI_CH0,
9158 .ab = (1280 * 736 * 2 * 2 * 30),
9159 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9160 },
9161};
9162
9163static struct msm_bus_vectors rotator_1080p_vectors[] = {
9164 {
9165 .src = MSM_BUS_MASTER_ROTATOR,
9166 .dst = MSM_BUS_SLAVE_SMI,
9167 .ab = (1920 * 1088 * 2 * 2 * 30),
9168 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9169 },
9170 {
9171 .src = MSM_BUS_MASTER_ROTATOR,
9172 .dst = MSM_BUS_SLAVE_EBI_CH0,
9173 .ab = (1920 * 1088 * 2 * 2 * 30),
9174 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9175 },
9176};
9177
9178static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9179 {
9180 ARRAY_SIZE(rotator_init_vectors),
9181 rotator_init_vectors,
9182 },
9183 {
9184 ARRAY_SIZE(rotator_ui_vectors),
9185 rotator_ui_vectors,
9186 },
9187 {
9188 ARRAY_SIZE(rotator_vga_vectors),
9189 rotator_vga_vectors,
9190 },
9191 {
9192 ARRAY_SIZE(rotator_720p_vectors),
9193 rotator_720p_vectors,
9194 },
9195 {
9196 ARRAY_SIZE(rotator_1080p_vectors),
9197 rotator_1080p_vectors,
9198 },
9199};
9200
9201struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9202 rotator_bus_scale_usecases,
9203 ARRAY_SIZE(rotator_bus_scale_usecases),
9204 .name = "rotator",
9205};
9206
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009207static struct msm_bus_vectors mdp_init_vectors[] = {
9208 /* For now, 0th array entry is reserved.
9209 * Please leave 0 as is and don't use it
9210 */
9211 {
9212 .src = MSM_BUS_MASTER_MDP_PORT0,
9213 .dst = MSM_BUS_SLAVE_SMI,
9214 .ab = 0,
9215 .ib = 0,
9216 },
9217 /* Master and slaves can be from different fabrics */
9218 {
9219 .src = MSM_BUS_MASTER_MDP_PORT0,
9220 .dst = MSM_BUS_SLAVE_EBI_CH0,
9221 .ab = 0,
9222 .ib = 0,
9223 },
9224};
9225
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009226#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009227static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9228 /* Default case static display/UI/2d/3d if FB SMI */
9229 {
9230 .src = MSM_BUS_MASTER_MDP_PORT0,
9231 .dst = MSM_BUS_SLAVE_SMI,
9232 .ab = 388800000,
9233 .ib = 486000000,
9234 },
9235 /* Master and slaves can be from different fabrics */
9236 {
9237 .src = MSM_BUS_MASTER_MDP_PORT0,
9238 .dst = MSM_BUS_SLAVE_EBI_CH0,
9239 .ab = 0,
9240 .ib = 0,
9241 },
9242};
9243
9244static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9245 /* Default case static display/UI/2d/3d if FB SMI */
9246 {
9247 .src = MSM_BUS_MASTER_MDP_PORT0,
9248 .dst = MSM_BUS_SLAVE_SMI,
9249 .ab = 0,
9250 .ib = 0,
9251 },
9252 /* Master and slaves can be from different fabrics */
9253 {
9254 .src = MSM_BUS_MASTER_MDP_PORT0,
9255 .dst = MSM_BUS_SLAVE_EBI_CH0,
9256 .ab = 388800000,
9257 .ib = 486000000 * 2,
9258 },
9259};
9260static struct msm_bus_vectors mdp_vga_vectors[] = {
9261 /* VGA and less video */
9262 {
9263 .src = MSM_BUS_MASTER_MDP_PORT0,
9264 .dst = MSM_BUS_SLAVE_SMI,
9265 .ab = 458092800,
9266 .ib = 572616000,
9267 },
9268 {
9269 .src = MSM_BUS_MASTER_MDP_PORT0,
9270 .dst = MSM_BUS_SLAVE_EBI_CH0,
9271 .ab = 458092800,
9272 .ib = 572616000 * 2,
9273 },
9274};
9275static struct msm_bus_vectors mdp_720p_vectors[] = {
9276 /* 720p and less video */
9277 {
9278 .src = MSM_BUS_MASTER_MDP_PORT0,
9279 .dst = MSM_BUS_SLAVE_SMI,
9280 .ab = 471744000,
9281 .ib = 589680000,
9282 },
9283 /* Master and slaves can be from different fabrics */
9284 {
9285 .src = MSM_BUS_MASTER_MDP_PORT0,
9286 .dst = MSM_BUS_SLAVE_EBI_CH0,
9287 .ab = 471744000,
9288 .ib = 589680000 * 2,
9289 },
9290};
9291
9292static struct msm_bus_vectors mdp_1080p_vectors[] = {
9293 /* 1080p and less video */
9294 {
9295 .src = MSM_BUS_MASTER_MDP_PORT0,
9296 .dst = MSM_BUS_SLAVE_SMI,
9297 .ab = 575424000,
9298 .ib = 719280000,
9299 },
9300 /* Master and slaves can be from different fabrics */
9301 {
9302 .src = MSM_BUS_MASTER_MDP_PORT0,
9303 .dst = MSM_BUS_SLAVE_EBI_CH0,
9304 .ab = 575424000,
9305 .ib = 719280000 * 2,
9306 },
9307};
9308
9309#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009310static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9311 /* Default case static display/UI/2d/3d if FB SMI */
9312 {
9313 .src = MSM_BUS_MASTER_MDP_PORT0,
9314 .dst = MSM_BUS_SLAVE_SMI,
9315 .ab = 175110000,
9316 .ib = 218887500,
9317 },
9318 /* Master and slaves can be from different fabrics */
9319 {
9320 .src = MSM_BUS_MASTER_MDP_PORT0,
9321 .dst = MSM_BUS_SLAVE_EBI_CH0,
9322 .ab = 0,
9323 .ib = 0,
9324 },
9325};
9326
9327static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9328 /* Default case static display/UI/2d/3d if FB SMI */
9329 {
9330 .src = MSM_BUS_MASTER_MDP_PORT0,
9331 .dst = MSM_BUS_SLAVE_SMI,
9332 .ab = 0,
9333 .ib = 0,
9334 },
9335 /* Master and slaves can be from different fabrics */
9336 {
9337 .src = MSM_BUS_MASTER_MDP_PORT0,
9338 .dst = MSM_BUS_SLAVE_EBI_CH0,
9339 .ab = 216000000,
9340 .ib = 270000000 * 2,
9341 },
9342};
9343static struct msm_bus_vectors mdp_vga_vectors[] = {
9344 /* VGA and less video */
9345 {
9346 .src = MSM_BUS_MASTER_MDP_PORT0,
9347 .dst = MSM_BUS_SLAVE_SMI,
9348 .ab = 216000000,
9349 .ib = 270000000,
9350 },
9351 {
9352 .src = MSM_BUS_MASTER_MDP_PORT0,
9353 .dst = MSM_BUS_SLAVE_EBI_CH0,
9354 .ab = 216000000,
9355 .ib = 270000000 * 2,
9356 },
9357};
9358
9359static struct msm_bus_vectors mdp_720p_vectors[] = {
9360 /* 720p and less video */
9361 {
9362 .src = MSM_BUS_MASTER_MDP_PORT0,
9363 .dst = MSM_BUS_SLAVE_SMI,
9364 .ab = 230400000,
9365 .ib = 288000000,
9366 },
9367 /* Master and slaves can be from different fabrics */
9368 {
9369 .src = MSM_BUS_MASTER_MDP_PORT0,
9370 .dst = MSM_BUS_SLAVE_EBI_CH0,
9371 .ab = 230400000,
9372 .ib = 288000000 * 2,
9373 },
9374};
9375
9376static struct msm_bus_vectors mdp_1080p_vectors[] = {
9377 /* 1080p and less video */
9378 {
9379 .src = MSM_BUS_MASTER_MDP_PORT0,
9380 .dst = MSM_BUS_SLAVE_SMI,
9381 .ab = 334080000,
9382 .ib = 417600000,
9383 },
9384 /* Master and slaves can be from different fabrics */
9385 {
9386 .src = MSM_BUS_MASTER_MDP_PORT0,
9387 .dst = MSM_BUS_SLAVE_EBI_CH0,
9388 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009389 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009390 },
9391};
9392
9393#endif
9394static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9395 {
9396 ARRAY_SIZE(mdp_init_vectors),
9397 mdp_init_vectors,
9398 },
9399 {
9400 ARRAY_SIZE(mdp_sd_smi_vectors),
9401 mdp_sd_smi_vectors,
9402 },
9403 {
9404 ARRAY_SIZE(mdp_sd_ebi_vectors),
9405 mdp_sd_ebi_vectors,
9406 },
9407 {
9408 ARRAY_SIZE(mdp_vga_vectors),
9409 mdp_vga_vectors,
9410 },
9411 {
9412 ARRAY_SIZE(mdp_720p_vectors),
9413 mdp_720p_vectors,
9414 },
9415 {
9416 ARRAY_SIZE(mdp_1080p_vectors),
9417 mdp_1080p_vectors,
9418 },
9419};
9420static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9421 mdp_bus_scale_usecases,
9422 ARRAY_SIZE(mdp_bus_scale_usecases),
9423 .name = "mdp",
9424};
9425
9426#endif
9427#ifdef CONFIG_MSM_BUS_SCALING
9428static struct msm_bus_vectors dtv_bus_init_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 = 0,
9436 .ib = 0,
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 = 0,
9443 .ib = 0,
9444 },
9445};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009446
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009447static struct msm_bus_vectors dtv_bus_def_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 = 566092800,
9455 .ib = 707616000,
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 = 566092800,
9462 .ib = 707616000,
9463 },
9464};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009465
9466static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9467 /* For now, 0th array entry is reserved.
9468 * Please leave 0 as is and don't use it
9469 */
9470 {
9471 .src = MSM_BUS_MASTER_MDP_PORT0,
9472 .dst = MSM_BUS_SLAVE_SMI,
9473 .ab = 2000000000,
9474 .ib = 2000000000,
9475 },
9476 /* Master and slaves can be from different fabrics */
9477 {
9478 .src = MSM_BUS_MASTER_MDP_PORT0,
9479 .dst = MSM_BUS_SLAVE_EBI_CH0,
9480 .ab = 2000000000,
9481 .ib = 2000000000,
9482 },
9483};
9484
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009485static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9486 {
9487 ARRAY_SIZE(dtv_bus_init_vectors),
9488 dtv_bus_init_vectors,
9489 },
9490 {
9491 ARRAY_SIZE(dtv_bus_def_vectors),
9492 dtv_bus_def_vectors,
9493 },
9494};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009495
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009496static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9497 dtv_bus_scale_usecases,
9498 ARRAY_SIZE(dtv_bus_scale_usecases),
9499 .name = "dtv",
9500};
9501
9502static struct lcdc_platform_data dtv_pdata = {
9503 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309504 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009505};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009506
9507static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9508 {
9509 ARRAY_SIZE(dtv_bus_init_vectors),
9510 dtv_bus_init_vectors,
9511 },
9512 {
9513 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9514 dtv_bus_hdmi_prim_vectors,
9515 },
9516};
9517
9518static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9519 dtv_hdmi_prim_bus_scale_usecases,
9520 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9521 .name = "dtv",
9522};
9523
9524static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9525 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9526};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009527#endif
9528
9529
9530static struct lcdc_platform_data lcdc_pdata = {
9531 .lcdc_power_save = lcdc_panel_power,
9532};
9533
9534
9535#define MDP_VSYNC_GPIO 28
9536
9537/*
9538 * MIPI_DSI only use 8058_LDO0 which need always on
9539 * therefore it need to be put at low power mode if
9540 * it was not used instead of turn it off.
9541 */
9542static int mipi_dsi_panel_power(int on)
9543{
9544 int flag_on = !!on;
9545 static int mipi_dsi_power_save_on;
9546 static struct regulator *ldo0;
9547 int rc = 0;
9548
9549 if (mipi_dsi_power_save_on == flag_on)
9550 return 0;
9551
9552 mipi_dsi_power_save_on = flag_on;
9553
9554 if (ldo0 == NULL) { /* init */
9555 ldo0 = regulator_get(NULL, "8058_l0");
9556 if (IS_ERR(ldo0)) {
9557 pr_debug("%s: LDO0 failed\n", __func__);
9558 rc = PTR_ERR(ldo0);
9559 return rc;
9560 }
9561
9562 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9563 if (rc)
9564 goto out;
9565
9566 rc = regulator_enable(ldo0);
9567 if (rc)
9568 goto out;
9569 }
9570
9571 if (on) {
9572 /* set ldo0 to HPM */
9573 rc = regulator_set_optimum_mode(ldo0, 100000);
9574 if (rc < 0)
9575 goto out;
9576 } else {
9577 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309578 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009579 if (rc < 0)
9580 goto out;
9581 }
9582
9583 return 0;
9584out:
9585 regulator_disable(ldo0);
9586 regulator_put(ldo0);
9587 ldo0 = NULL;
9588 return rc;
9589}
9590
9591static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9592 .vsync_gpio = MDP_VSYNC_GPIO,
9593 .dsi_power_save = mipi_dsi_panel_power,
9594};
9595
9596#ifdef CONFIG_FB_MSM_TVOUT
9597static struct regulator *reg_8058_l13;
9598
9599static int atv_dac_power(int on)
9600{
9601 int rc = 0;
9602 #define _GET_REGULATOR(var, name) do { \
9603 var = regulator_get(NULL, name); \
9604 if (IS_ERR(var)) { \
9605 pr_info("'%s' regulator not found, rc=%ld\n", \
9606 name, IS_ERR(var)); \
9607 var = NULL; \
9608 return -ENODEV; \
9609 } \
9610 } while (0)
9611
9612 if (!reg_8058_l13)
9613 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9614 #undef _GET_REGULATOR
9615
9616 if (on) {
9617 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9618 if (rc) {
9619 pr_info("%s: '%s' regulator set voltage failed,\
9620 rc=%d\n", __func__, "8058_l13", rc);
9621 return rc;
9622 }
9623
9624 rc = regulator_enable(reg_8058_l13);
9625 if (rc) {
9626 pr_err("%s: '%s' regulator enable failed,\
9627 rc=%d\n", __func__, "8058_l13", rc);
9628 return rc;
9629 }
9630 } else {
9631 rc = regulator_force_disable(reg_8058_l13);
9632 if (rc)
9633 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9634 __func__, "8058_l13", rc);
9635 }
9636 return rc;
9637
9638}
9639#endif
9640
9641#ifdef CONFIG_FB_MSM_MIPI_DSI
9642int mdp_core_clk_rate_table[] = {
9643 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009644 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009645 160000000,
9646 200000000,
9647};
9648#else
9649int mdp_core_clk_rate_table[] = {
9650 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009651 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009652 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009653 200000000,
9654};
9655#endif
9656
9657static struct msm_panel_common_pdata mdp_pdata = {
9658 .gpio = MDP_VSYNC_GPIO,
9659 .mdp_core_clk_rate = 59080000,
9660 .mdp_core_clk_table = mdp_core_clk_rate_table,
9661 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9662#ifdef CONFIG_MSM_BUS_SCALING
9663 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9664#endif
9665 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009666#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009667 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009668#else
9669 .mem_hid = MEMTYPE_EBI1,
9670#endif
Olav Hauganef95ae32012-05-15 09:50:30 -07009671 .mdp_iommu_split_domain = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009672};
9673
Huaibin Yanga5419422011-12-08 23:52:10 -08009674static void __init reserve_mdp_memory(void)
9675{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009676 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9677 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9678#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9679 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9680 mdp_pdata.ov0_wb_size;
9681 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9682 mdp_pdata.ov1_wb_size;
9683#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009684}
9685
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009686#ifdef CONFIG_FB_MSM_TVOUT
9687
9688#ifdef CONFIG_MSM_BUS_SCALING
9689static struct msm_bus_vectors atv_bus_init_vectors[] = {
9690 /* For now, 0th array entry is reserved.
9691 * Please leave 0 as is and don't use it
9692 */
9693 {
9694 .src = MSM_BUS_MASTER_MDP_PORT0,
9695 .dst = MSM_BUS_SLAVE_SMI,
9696 .ab = 0,
9697 .ib = 0,
9698 },
9699 /* Master and slaves can be from different fabrics */
9700 {
9701 .src = MSM_BUS_MASTER_MDP_PORT0,
9702 .dst = MSM_BUS_SLAVE_EBI_CH0,
9703 .ab = 0,
9704 .ib = 0,
9705 },
9706};
9707static struct msm_bus_vectors atv_bus_def_vectors[] = {
9708 /* For now, 0th array entry is reserved.
9709 * Please leave 0 as is and don't use it
9710 */
9711 {
9712 .src = MSM_BUS_MASTER_MDP_PORT0,
9713 .dst = MSM_BUS_SLAVE_SMI,
9714 .ab = 236390400,
9715 .ib = 265939200,
9716 },
9717 /* Master and slaves can be from different fabrics */
9718 {
9719 .src = MSM_BUS_MASTER_MDP_PORT0,
9720 .dst = MSM_BUS_SLAVE_EBI_CH0,
9721 .ab = 236390400,
9722 .ib = 265939200,
9723 },
9724};
9725static struct msm_bus_paths atv_bus_scale_usecases[] = {
9726 {
9727 ARRAY_SIZE(atv_bus_init_vectors),
9728 atv_bus_init_vectors,
9729 },
9730 {
9731 ARRAY_SIZE(atv_bus_def_vectors),
9732 atv_bus_def_vectors,
9733 },
9734};
9735static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9736 atv_bus_scale_usecases,
9737 ARRAY_SIZE(atv_bus_scale_usecases),
9738 .name = "atv",
9739};
9740#endif
9741
9742static struct tvenc_platform_data atv_pdata = {
9743 .poll = 0,
9744 .pm_vid_en = atv_dac_power,
9745#ifdef CONFIG_MSM_BUS_SCALING
9746 .bus_scale_table = &atv_bus_scale_pdata,
9747#endif
9748};
9749#endif
9750
9751static void __init msm_fb_add_devices(void)
9752{
9753#ifdef CONFIG_FB_MSM_LCDC_DSUB
9754 mdp_pdata.mdp_core_clk_table = NULL;
9755 mdp_pdata.num_mdp_clk = 0;
9756 mdp_pdata.mdp_core_clk_rate = 200000000;
9757#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -07009758 msm_fb_register_device("mdp", &mdp_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009759
9760 msm_fb_register_device("lcdc", &lcdc_pdata);
9761 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9762#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009763 if (hdmi_is_primary)
9764 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9765 else
9766 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009767#endif
9768#ifdef CONFIG_FB_MSM_TVOUT
9769 msm_fb_register_device("tvenc", &atv_pdata);
9770 msm_fb_register_device("tvout_device", NULL);
9771#endif
9772}
9773
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009774/**
9775 * Set MDP clocks to high frequency to avoid underflow when
9776 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9777 */
9778static void set_mdp_clocks_for_wuxga(void)
9779{
9780 int i;
9781
9782 mdp_sd_smi_vectors[0].ab = 2000000000;
9783 mdp_sd_smi_vectors[0].ib = 2000000000;
9784 mdp_sd_smi_vectors[1].ab = 2000000000;
9785 mdp_sd_smi_vectors[1].ib = 2000000000;
9786
9787 mdp_sd_ebi_vectors[0].ab = 2000000000;
9788 mdp_sd_ebi_vectors[0].ib = 2000000000;
9789 mdp_sd_ebi_vectors[1].ab = 2000000000;
9790 mdp_sd_ebi_vectors[1].ib = 2000000000;
9791
9792 mdp_vga_vectors[0].ab = 2000000000;
9793 mdp_vga_vectors[0].ib = 2000000000;
9794 mdp_vga_vectors[1].ab = 2000000000;
9795 mdp_vga_vectors[1].ib = 2000000000;
9796
9797 mdp_720p_vectors[0].ab = 2000000000;
9798 mdp_720p_vectors[0].ib = 2000000000;
9799 mdp_720p_vectors[1].ab = 2000000000;
9800 mdp_720p_vectors[1].ib = 2000000000;
9801
9802 mdp_1080p_vectors[0].ab = 2000000000;
9803 mdp_1080p_vectors[0].ib = 2000000000;
9804 mdp_1080p_vectors[1].ab = 2000000000;
9805 mdp_1080p_vectors[1].ib = 2000000000;
9806
9807 mdp_pdata.mdp_core_clk_rate = 200000000;
9808
9809 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9810 mdp_core_clk_rate_table[i] = 200000000;
9811}
9812
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009813#if (defined(CONFIG_MARIMBA_CORE)) && \
9814 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9815
9816static const struct {
9817 char *name;
9818 int vmin;
9819 int vmax;
9820} bt_regs_info[] = {
9821 { "8058_s3", 1800000, 1800000 },
9822 { "8058_s2", 1300000, 1300000 },
9823 { "8058_l8", 2900000, 3050000 },
9824};
9825
9826static struct {
9827 bool enabled;
9828} bt_regs_status[] = {
9829 { false },
9830 { false },
9831 { false },
9832};
9833static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9834
9835static int bahama_bt(int on)
9836{
9837 int rc;
9838 int i;
9839 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9840
9841 struct bahama_variant_register {
9842 const size_t size;
9843 const struct bahama_config_register *set;
9844 };
9845
9846 const struct bahama_config_register *p;
9847
9848 u8 version;
9849
9850 const struct bahama_config_register v10_bt_on[] = {
9851 { 0xE9, 0x00, 0xFF },
9852 { 0xF4, 0x80, 0xFF },
9853 { 0xE4, 0x00, 0xFF },
9854 { 0xE5, 0x00, 0x0F },
9855#ifdef CONFIG_WLAN
9856 { 0xE6, 0x38, 0x7F },
9857 { 0xE7, 0x06, 0xFF },
9858#endif
9859 { 0xE9, 0x21, 0xFF },
9860 { 0x01, 0x0C, 0x1F },
9861 { 0x01, 0x08, 0x1F },
9862 };
9863
9864 const struct bahama_config_register v20_bt_on_fm_off[] = {
9865 { 0x11, 0x0C, 0xFF },
9866 { 0x13, 0x01, 0xFF },
9867 { 0xF4, 0x80, 0xFF },
9868 { 0xF0, 0x00, 0xFF },
9869 { 0xE9, 0x00, 0xFF },
9870#ifdef CONFIG_WLAN
9871 { 0x81, 0x00, 0x7F },
9872 { 0x82, 0x00, 0xFF },
9873 { 0xE6, 0x38, 0x7F },
9874 { 0xE7, 0x06, 0xFF },
9875#endif
9876 { 0xE9, 0x21, 0xFF },
9877 };
9878
9879 const struct bahama_config_register v20_bt_on_fm_on[] = {
9880 { 0x11, 0x0C, 0xFF },
9881 { 0x13, 0x01, 0xFF },
9882 { 0xF4, 0x86, 0xFF },
9883 { 0xF0, 0x06, 0xFF },
9884 { 0xE9, 0x00, 0xFF },
9885#ifdef CONFIG_WLAN
9886 { 0x81, 0x00, 0x7F },
9887 { 0x82, 0x00, 0xFF },
9888 { 0xE6, 0x38, 0x7F },
9889 { 0xE7, 0x06, 0xFF },
9890#endif
9891 { 0xE9, 0x21, 0xFF },
9892 };
9893
9894 const struct bahama_config_register v10_bt_off[] = {
9895 { 0xE9, 0x00, 0xFF },
9896 };
9897
9898 const struct bahama_config_register v20_bt_off_fm_off[] = {
9899 { 0xF4, 0x84, 0xFF },
9900 { 0xF0, 0x04, 0xFF },
9901 { 0xE9, 0x00, 0xFF }
9902 };
9903
9904 const struct bahama_config_register v20_bt_off_fm_on[] = {
9905 { 0xF4, 0x86, 0xFF },
9906 { 0xF0, 0x06, 0xFF },
9907 { 0xE9, 0x00, 0xFF }
9908 };
9909 const struct bahama_variant_register bt_bahama[2][3] = {
9910 {
9911 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9912 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9913 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9914 },
9915 {
9916 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9917 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9918 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9919 }
9920 };
9921
9922 u8 offset = 0; /* index into bahama configs */
9923
9924 on = on ? 1 : 0;
9925 version = read_bahama_ver();
9926
9927 if (version == VER_UNSUPPORTED) {
9928 dev_err(&msm_bt_power_device.dev,
9929 "%s: unsupported version\n",
9930 __func__);
9931 return -EIO;
9932 }
9933
9934 if (version == VER_2_0) {
9935 if (marimba_get_fm_status(&config))
9936 offset = 0x01;
9937 }
9938
9939 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9940 if (on && (version == VER_2_0)) {
9941 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9942 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9943 && (bt_regs_status[i].enabled == true)) {
9944 if (regulator_disable(bt_regs[i])) {
9945 dev_err(&msm_bt_power_device.dev,
9946 "%s: regulator disable failed",
9947 __func__);
9948 }
9949 bt_regs_status[i].enabled = false;
9950 break;
9951 }
9952 }
9953 }
9954
9955 p = bt_bahama[on][version + offset].set;
9956
9957 dev_info(&msm_bt_power_device.dev,
9958 "%s: found version %d\n", __func__, version);
9959
9960 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9961 u8 value = (p+i)->value;
9962 rc = marimba_write_bit_mask(&config,
9963 (p+i)->reg,
9964 &value,
9965 sizeof((p+i)->value),
9966 (p+i)->mask);
9967 if (rc < 0) {
9968 dev_err(&msm_bt_power_device.dev,
9969 "%s: reg %d write failed: %d\n",
9970 __func__, (p+i)->reg, rc);
9971 return rc;
9972 }
9973 dev_dbg(&msm_bt_power_device.dev,
9974 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9975 __func__, (p+i)->reg,
9976 value, (p+i)->mask);
9977 }
9978 /* Update BT Status */
9979 if (on)
9980 marimba_set_bt_status(&config, true);
9981 else
9982 marimba_set_bt_status(&config, false);
9983
9984 return 0;
9985}
9986
9987static int bluetooth_use_regulators(int on)
9988{
9989 int i, recover = -1, rc = 0;
9990
9991 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9992 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9993 bt_regs_info[i].name) :
9994 (regulator_put(bt_regs[i]), NULL);
9995 if (IS_ERR(bt_regs[i])) {
9996 rc = PTR_ERR(bt_regs[i]);
9997 dev_err(&msm_bt_power_device.dev,
9998 "regulator %s get failed (%d)\n",
9999 bt_regs_info[i].name, rc);
10000 recover = i - 1;
10001 bt_regs[i] = NULL;
10002 break;
10003 }
10004
10005 if (!on)
10006 continue;
10007
10008 rc = regulator_set_voltage(bt_regs[i],
10009 bt_regs_info[i].vmin,
10010 bt_regs_info[i].vmax);
10011 if (rc < 0) {
10012 dev_err(&msm_bt_power_device.dev,
10013 "regulator %s voltage set (%d)\n",
10014 bt_regs_info[i].name, rc);
10015 recover = i;
10016 break;
10017 }
10018 }
10019
10020 if (on && (recover > -1))
10021 for (i = recover; i >= 0; i--) {
10022 regulator_put(bt_regs[i]);
10023 bt_regs[i] = NULL;
10024 }
10025
10026 return rc;
10027}
10028
10029static int bluetooth_switch_regulators(int on)
10030{
10031 int i, rc = 0;
10032
10033 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10034 if (on && (bt_regs_status[i].enabled == false)) {
10035 rc = regulator_enable(bt_regs[i]);
10036 if (rc < 0) {
10037 dev_err(&msm_bt_power_device.dev,
10038 "regulator %s %s failed (%d)\n",
10039 bt_regs_info[i].name,
10040 "enable", rc);
10041 if (i > 0) {
10042 while (--i) {
10043 regulator_disable(bt_regs[i]);
10044 bt_regs_status[i].enabled
10045 = false;
10046 }
10047 break;
10048 }
10049 }
10050 bt_regs_status[i].enabled = true;
10051 } else if (!on && (bt_regs_status[i].enabled == true)) {
10052 rc = regulator_disable(bt_regs[i]);
10053 if (rc < 0) {
10054 dev_err(&msm_bt_power_device.dev,
10055 "regulator %s %s failed (%d)\n",
10056 bt_regs_info[i].name,
10057 "disable", rc);
10058 break;
10059 }
10060 bt_regs_status[i].enabled = false;
10061 }
10062 }
10063 return rc;
10064}
10065
10066static struct msm_xo_voter *bt_clock;
10067
10068static int bluetooth_power(int on)
10069{
10070 int rc = 0;
10071 int id;
10072
10073 /* In case probe function fails, cur_connv_type would be -1 */
10074 id = adie_get_detected_connectivity_type();
10075 if (id != BAHAMA_ID) {
10076 pr_err("%s: unexpected adie connectivity type: %d\n",
10077 __func__, id);
10078 return -ENODEV;
10079 }
10080
10081 if (on) {
10082
10083 rc = bluetooth_use_regulators(1);
10084 if (rc < 0)
10085 goto out;
10086
10087 rc = bluetooth_switch_regulators(1);
10088
10089 if (rc < 0)
10090 goto fail_put;
10091
10092 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10093
10094 if (IS_ERR(bt_clock)) {
10095 pr_err("Couldn't get TCXO_D0 voter\n");
10096 goto fail_switch;
10097 }
10098
10099 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10100
10101 if (rc < 0) {
10102 pr_err("Failed to vote for TCXO_DO ON\n");
10103 goto fail_vote;
10104 }
10105
10106 rc = bahama_bt(1);
10107
10108 if (rc < 0)
10109 goto fail_clock;
10110
10111 msleep(10);
10112
10113 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10114
10115 if (rc < 0) {
10116 pr_err("Failed to vote for TCXO_DO pin control\n");
10117 goto fail_vote;
10118 }
10119 } else {
10120 /* check for initial RFKILL block (power off) */
10121 /* some RFKILL versions/configurations rfkill_register */
10122 /* calls here for an initial set_block */
10123 /* avoid calling i2c and regulator before unblock (on) */
10124 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10125 dev_info(&msm_bt_power_device.dev,
10126 "%s: initialized OFF/blocked\n", __func__);
10127 goto out;
10128 }
10129
10130 bahama_bt(0);
10131
10132fail_clock:
10133 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10134fail_vote:
10135 msm_xo_put(bt_clock);
10136fail_switch:
10137 bluetooth_switch_regulators(0);
10138fail_put:
10139 bluetooth_use_regulators(0);
10140 }
10141
10142out:
10143 if (rc < 0)
10144 on = 0;
10145 dev_info(&msm_bt_power_device.dev,
10146 "Bluetooth power switch: state %d result %d\n", on, rc);
10147
10148 return rc;
10149}
10150
10151#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10152
10153static void __init msm8x60_cfg_smsc911x(void)
10154{
10155 smsc911x_resources[1].start =
10156 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10157 smsc911x_resources[1].end =
10158 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10159}
10160
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010161void msm_fusion_setup_pinctrl(void)
10162{
10163 struct msm_xo_voter *a1;
10164
10165 if (socinfo_get_platform_subtype() == 0x3) {
10166 /*
10167 * Vote for the A1 clock to be in pin control mode before
10168 * the external images are loaded.
10169 */
10170 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10171 BUG_ON(!a1);
10172 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10173 }
10174}
10175
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010176struct msm_board_data {
10177 struct msm_gpiomux_configs *gpiomux_cfgs;
10178};
10179
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010180static struct msm_board_data msm8x60_surf_board_data __initdata = {
10181 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10182};
10183
10184static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10185 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10186};
10187
10188static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10189 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10190};
10191
10192static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10193 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10194};
10195
10196static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10197 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10198};
10199
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010200static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10201 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10202};
10203
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010204static void __init msm8x60_init(struct msm_board_data *board_data)
10205{
10206 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010207#ifdef CONFIG_USB_EHCI_MSM_72K
10208 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10209 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10210 .level = PM8901_MPP_DIG_LEVEL_L5,
10211 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10212 };
10213#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010214 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010215
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010216 /*
10217 * Initialize RPM first as other drivers and devices may need
10218 * it for their initialization.
10219 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010220 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10221 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010222 if (msm_xo_init())
10223 pr_err("Failed to initialize XO votes\n");
10224
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010225 msm8x60_check_2d_hardware();
10226
10227 /* Change SPM handling of core 1 if PMM 8160 is present. */
10228 soc_platform_version = socinfo_get_platform_version();
10229 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10230 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10231 struct msm_spm_platform_data *spm_data;
10232
10233 spm_data = &msm_spm_data_v1[1];
10234 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10235 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10236
10237 spm_data = &msm_spm_data[1];
10238 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10239 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10240 }
10241
10242 /*
10243 * Initialize SPM before acpuclock as the latter calls into SPM
10244 * driver to set ACPU voltages.
10245 */
10246 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10247 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10248 else
10249 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10250
10251 /*
10252 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10253 * devices so that the RPM doesn't drop into a low power mode that an
10254 * un-reworked SURF cannot resume from.
10255 */
10256 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010257 int i;
10258
10259 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10260 if (rpm_regulator_init_data[i].id
10261 == RPM_VREG_ID_PM8901_L4
10262 || rpm_regulator_init_data[i].id
10263 == RPM_VREG_ID_PM8901_L6)
10264 rpm_regulator_init_data[i]
10265 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010266 }
10267
10268 /*
10269 * Disable regulator info printing so that regulator registration
10270 * messages do not enter the kmsg log.
10271 */
10272 regulator_suppress_info_printing();
10273
10274 /* Initialize regulators needed for clock_init. */
10275 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10276
Stephen Boydbb600ae2011-08-02 20:11:40 -070010277 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010278
10279 /* Buses need to be initialized before early-device registration
10280 * to get the platform data for fabrics.
10281 */
10282 msm8x60_init_buses();
10283 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010284
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010285 /*
10286 * Enable EBI2 only for boards which make use of it. Leave
10287 * it disabled for all others for additional power savings.
10288 */
10289 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010290 machine_is_msm8x60_fluid() ||
10291 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010292 msm8x60_init_ebi2();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010293 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10294 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010295#ifdef CONFIG_MSM_CAMERA_V4L2
10296 msm8x60_init_cam();
10297#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010298 msm8x60_init_mmc();
10299
Kevin Chan3be11612012-03-22 20:05:40 -070010300
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010301#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10302 msm8x60_init_pm8058_othc();
10303#endif
10304
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010305 if (machine_is_msm8x60_fluid())
10306 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10307 else if (machine_is_msm8x60_dragon())
10308 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10309 else
10310 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010311#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010312 /* Specify reset pin for OV9726 */
10313 if (machine_is_msm8x60_dragon()) {
10314 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10315 ov9726_sensor_8660_info.mount_angle = 270;
10316 }
Kevin Chan3be11612012-03-22 20:05:40 -070010317#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010318#ifdef CONFIG_BATTERY_MSM8X60
10319 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10320 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10321 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10322 platform_device_register(&msm_charger_device);
10323#endif
10324
10325 if (machine_is_msm8x60_dragon())
10326 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10327 if (!machine_is_msm8x60_fluid())
10328 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10329
10330 /* configure pmic leds */
10331 if (machine_is_msm8x60_fluid())
10332 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10333 else if (machine_is_msm8x60_dragon())
10334 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10335 else
10336 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10337
10338 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10339 machine_is_msm8x60_dragon()) {
10340 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10341 }
10342
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010343 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10344 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010345 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010346 msm8x60_cfg_smsc911x();
10347 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010348 platform_add_devices(msm8660_footswitch,
10349 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010350 platform_add_devices(surf_devices,
10351 ARRAY_SIZE(surf_devices));
10352
10353#ifdef CONFIG_MSM_DSPS
10354 if (machine_is_msm8x60_fluid()) {
10355 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10356 msm8x60_init_dsps();
10357 }
10358#endif
10359
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010360 pm8901_vreg_mpp0_init();
10361
10362 platform_device_register(&msm8x60_8901_mpp_vreg);
10363
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010364#ifdef CONFIG_USB_EHCI_MSM_72K
10365 /*
10366 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10367 * fluid
10368 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010369 if (machine_is_msm8x60_fluid())
10370 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10371 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010372#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010373
10374#ifdef CONFIG_SND_SOC_MSM8660_APQ
10375 if (machine_is_msm8x60_dragon())
10376 platform_add_devices(dragon_alsa_devices,
10377 ARRAY_SIZE(dragon_alsa_devices));
10378 else
10379#endif
10380 platform_add_devices(asoc_devices,
10381 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010382 }
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
Steve Mucklef132c6c2012-06-06 18:30:57 -070010400#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10401 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010402 if (machine_is_msm8x60_fluid())
10403 cyttsp_set_params();
10404#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -070010405 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010406 fixup_i2c_configs();
10407 register_i2c_devices();
10408
Terence Hampson1c73fef2011-07-19 17:10:49 -040010409 if (machine_is_msm8x60_dragon())
10410 smsc911x_config.reset_gpio
10411 = GPIO_ETHERNET_RESET_N_DRAGON;
10412
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010413 platform_device_register(&smsc911x_device);
10414
10415#if (defined(CONFIG_SPI_QUP)) && \
10416 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010417 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10418 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010419
10420 if (machine_is_msm8x60_fluid()) {
10421#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10422 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10423 spi_register_board_info(lcdc_samsung_spi_board_info,
10424 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10425 } else
10426#endif
10427 {
10428#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10429 spi_register_board_info(lcdc_auo_spi_board_info,
10430 ARRAY_SIZE(lcdc_auo_spi_board_info));
10431#endif
10432 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010433#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10434 } else if (machine_is_msm8x60_dragon()) {
10435 spi_register_board_info(lcdc_nt35582_spi_board_info,
10436 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10437#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010438 }
10439#endif
10440
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010441 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010442
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010443 pm8058_gpios_init();
10444
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010445#ifdef CONFIG_SENSORS_MSM_ADC
10446 if (machine_is_msm8x60_fluid()) {
10447 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10448 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10449 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10450 msm_adc_pdata.gpio_config = APROC_CONFIG;
10451 else
10452 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10453 }
10454 msm_adc_pdata.target_hw = MSM_8x60;
10455#endif
10456#ifdef CONFIG_MSM8X60_AUDIO
10457 msm_snddev_init();
10458#endif
10459#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10460 if (machine_is_msm8x60_fluid())
10461 platform_device_register(&fluid_leds_gpio);
10462 else
10463 platform_device_register(&gpio_leds);
10464#endif
10465
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010466 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010467
10468 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10469 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010470}
10471
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010472static void __init msm8x60_surf_init(void)
10473{
10474 msm8x60_init(&msm8x60_surf_board_data);
10475}
10476
10477static void __init msm8x60_ffa_init(void)
10478{
10479 msm8x60_init(&msm8x60_ffa_board_data);
10480}
10481
10482static void __init msm8x60_fluid_init(void)
10483{
10484 msm8x60_init(&msm8x60_fluid_board_data);
10485}
10486
10487static void __init msm8x60_charm_surf_init(void)
10488{
10489 msm8x60_init(&msm8x60_charm_surf_board_data);
10490}
10491
10492static void __init msm8x60_charm_ffa_init(void)
10493{
10494 msm8x60_init(&msm8x60_charm_ffa_board_data);
10495}
10496
10497static void __init msm8x60_charm_init_early(void)
10498{
10499 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010500}
10501
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010502static void __init msm8x60_dragon_init(void)
10503{
10504 msm8x60_init(&msm8x60_dragon_board_data);
10505}
David Brown56e2d8a2011-08-04 02:01:02 -070010506
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010507MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10508 .map_io = msm8x60_map_io,
10509 .reserve = msm8x60_reserve,
10510 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010511 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010512 .init_machine = msm8x60_surf_init,
10513 .timer = &msm_timer,
10514 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010515 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010516MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010517
10518MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10519 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010520 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010521 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010522 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010523 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010524 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010525 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010526 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010527MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010528
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010529MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010530 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010531 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010532 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010533 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010534 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010535 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010536 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010537 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010538MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010539
10540MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10541 .map_io = msm8x60_map_io,
10542 .reserve = msm8x60_reserve,
10543 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010544 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010545 .init_machine = msm8x60_charm_surf_init,
10546 .timer = &msm_timer,
10547 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010548 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010549MACHINE_END
10550
10551MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10552 .map_io = msm8x60_map_io,
10553 .reserve = msm8x60_reserve,
10554 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010555 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010556 .init_machine = msm8x60_charm_ffa_init,
10557 .timer = &msm_timer,
10558 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010559 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010560MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010561
10562MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10563 .map_io = msm8x60_map_io,
10564 .reserve = msm8x60_reserve,
10565 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010566 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010567 .init_machine = msm8x60_dragon_init,
10568 .timer = &msm_timer,
10569 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010570 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010571MACHINE_END