blob: 5f35e65ea4744ee516af0bbaac465c57c3676072 [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
Mitchel Humpherysc75b47d2012-09-06 11:35:07 -0700106#include <linux/msm_ion.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700107#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 Pandya490c9712012-08-07 17:19:59 +05302632#ifdef CONFIG_MSM_CP
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302633#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
Chintan Pandya490c9712012-08-07 17:19:59 +05302634#else
2635#define MSM_ION_HOLE_SIZE 0
2636#endif
2637
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302638#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2639#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2640#define MSM_ION_MFC_SIZE SZ_8K
2641
2642#define MSM_MM_FW_BASE MSM_SMI_BASE
2643#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2644#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2645#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2646
Chintan Pandya490c9712012-08-07 17:19:59 +05302647#ifdef CONFIG_MSM_CP
2648#define SECURE_BASE (MSM_ION_HOLE_BASE)
2649#define SECURE_SIZE (MSM_ION_MM_SIZE + MSM_ION_HOLE_SIZE)
2650#else
2651#define SECURE_BASE (MSM_MM_FW_BASE)
2652#define SECURE_SIZE (MSM_ION_MM_SIZE + MSM_MM_FW_SIZE)
2653#endif
2654
Naseer Ahmed51860b02012-02-07 18:53:29 +05302655#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002656#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302657
Mayank Choprac22ace32012-03-03 00:45:04 +05302658#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2659#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2660#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002661#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302662#endif
2663
Olav Haugan424ff492012-03-13 11:41:23 -07002664#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002665
2666#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302667#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002668#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002669#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2670static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002671#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002672#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002673#endif
2674
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002675static unsigned fb_size;
2676static int __init fb_size_setup(char *p)
2677{
2678 fb_size = memparse(p, NULL);
2679 return 0;
2680}
2681early_param("fb_size", fb_size_setup);
2682
2683static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2684static int __init pmem_kernel_ebi1_size_setup(char *p)
2685{
2686 pmem_kernel_ebi1_size = memparse(p, NULL);
2687 return 0;
2688}
2689early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2690
2691#ifdef CONFIG_ANDROID_PMEM
2692static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2693static int __init pmem_sf_size_setup(char *p)
2694{
2695 pmem_sf_size = memparse(p, NULL);
2696 return 0;
2697}
2698early_param("pmem_sf_size", pmem_sf_size_setup);
2699
2700static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2701
2702static int __init pmem_adsp_size_setup(char *p)
2703{
2704 pmem_adsp_size = memparse(p, NULL);
2705 return 0;
2706}
2707early_param("pmem_adsp_size", pmem_adsp_size_setup);
2708
2709static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2710
2711static int __init pmem_audio_size_setup(char *p)
2712{
2713 pmem_audio_size = memparse(p, NULL);
2714 return 0;
2715}
2716early_param("pmem_audio_size", pmem_audio_size_setup);
2717#endif
2718
2719static struct resource msm_fb_resources[] = {
2720 {
2721 .flags = IORESOURCE_DMA,
2722 }
2723};
2724
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002725static void set_mdp_clocks_for_wuxga(void);
2726
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002727static int msm_fb_detect_panel(const char *name)
2728{
2729 if (machine_is_msm8x60_fluid()) {
2730 uint32_t soc_platform_version = socinfo_get_platform_version();
2731 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2732#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2733 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002734 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2735 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736 return 0;
2737#endif
2738 } else { /*P3 and up use AUO panel */
2739#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2740 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002741 strnlen(LCDC_AUO_PANEL_NAME,
2742 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002743 return 0;
2744#endif
2745 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002746#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2747 } else if machine_is_msm8x60_dragon() {
2748 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002749 strnlen(LCDC_NT35582_PANEL_NAME,
2750 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002751 return 0;
2752#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002753 } else {
2754 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002755 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2756 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002757 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002758
2759#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2760 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2761 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2762 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2763 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2764 PANEL_NAME_MAX_LEN)))
2765 return 0;
2766
2767 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2768 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2769 PANEL_NAME_MAX_LEN)))
2770 return 0;
2771
2772 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2773 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2774 PANEL_NAME_MAX_LEN)))
2775 return 0;
2776#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002777 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002778
2779 if (!strncmp(name, HDMI_PANEL_NAME,
2780 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002781 PANEL_NAME_MAX_LEN))) {
2782 if (hdmi_is_primary)
2783 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002784 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002785 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002786
2787 if (!strncmp(name, TVOUT_PANEL_NAME,
2788 strnlen(TVOUT_PANEL_NAME,
2789 PANEL_NAME_MAX_LEN)))
2790 return 0;
2791
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002792 pr_warning("%s: not supported '%s'", __func__, name);
2793 return -ENODEV;
2794}
2795
2796static struct msm_fb_platform_data msm_fb_pdata = {
2797 .detect_client = msm_fb_detect_panel,
2798};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799
2800static struct platform_device msm_fb_device = {
2801 .name = "msm_fb",
2802 .id = 0,
2803 .num_resources = ARRAY_SIZE(msm_fb_resources),
2804 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002806};
2807
2808#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002809#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810static struct android_pmem_platform_data android_pmem_pdata = {
2811 .name = "pmem",
2812 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2813 .cached = 1,
2814 .memory_type = MEMTYPE_EBI1,
2815};
2816
2817static struct platform_device android_pmem_device = {
2818 .name = "android_pmem",
2819 .id = 0,
2820 .dev = {.platform_data = &android_pmem_pdata},
2821};
2822
2823static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2824 .name = "pmem_adsp",
2825 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2826 .cached = 0,
2827 .memory_type = MEMTYPE_EBI1,
2828};
2829
2830static struct platform_device android_pmem_adsp_device = {
2831 .name = "android_pmem",
2832 .id = 2,
2833 .dev = { .platform_data = &android_pmem_adsp_pdata },
2834};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302835
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002836static struct android_pmem_platform_data android_pmem_audio_pdata = {
2837 .name = "pmem_audio",
2838 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2839 .cached = 0,
2840 .memory_type = MEMTYPE_EBI1,
2841};
2842
2843static struct platform_device android_pmem_audio_device = {
2844 .name = "android_pmem",
2845 .id = 4,
2846 .dev = { .platform_data = &android_pmem_audio_pdata },
2847};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302848#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002849#define PMEM_BUS_WIDTH(_bw) \
2850 { \
2851 .vectors = &(struct msm_bus_vectors){ \
2852 .src = MSM_BUS_MASTER_AMPSS_M0, \
2853 .dst = MSM_BUS_SLAVE_SMI, \
2854 .ib = (_bw), \
2855 .ab = 0, \
2856 }, \
2857 .num_paths = 1, \
2858 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002859
2860static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002861 [0] = PMEM_BUS_WIDTH(0), /* Off */
2862 [1] = PMEM_BUS_WIDTH(1), /* On */
2863};
2864
2865static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002866 .usecase = mem_smi_table,
2867 .num_usecases = ARRAY_SIZE(mem_smi_table),
2868 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002869};
2870
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002871int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002872{
2873 int bus_id = (int) data;
2874
2875 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002876 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002877}
2878
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002879int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002880{
2881 int bus_id = (int) data;
2882
2883 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002884 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002885}
2886
Alex Bird199980e2011-10-21 11:29:27 -07002887void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002888{
2889 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2890}
Olav Hauganee0f7802011-12-19 13:28:57 -08002891#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2893 .name = "pmem_smipool",
2894 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2895 .cached = 0,
2896 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002897 .request_region = request_smi_region,
2898 .release_region = release_smi_region,
2899 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002900 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002901};
2902static struct platform_device android_pmem_smipool_device = {
2903 .name = "android_pmem",
2904 .id = 7,
2905 .dev = { .platform_data = &android_pmem_smipool_pdata },
2906};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302907#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2908#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909
2910#define GPIO_DONGLE_PWR_EN 258
2911static void setup_display_power(void);
2912static int lcdc_vga_enabled;
2913static int vga_enable_request(int enable)
2914{
2915 if (enable)
2916 lcdc_vga_enabled = 1;
2917 else
2918 lcdc_vga_enabled = 0;
2919 setup_display_power();
2920
2921 return 0;
2922}
2923
2924#define GPIO_BACKLIGHT_PWM0 0
2925#define GPIO_BACKLIGHT_PWM1 1
2926
2927static int pmic_backlight_gpio[2]
2928 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2929static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2930 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2931 .vga_switch = vga_enable_request,
2932};
2933
2934static struct platform_device lcdc_samsung_panel_device = {
2935 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2936 .id = 0,
2937 .dev = {
2938 .platform_data = &lcdc_samsung_panel_data,
2939 }
2940};
2941#if (!defined(CONFIG_SPI_QUP)) && \
2942 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2943 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2944
2945static int lcdc_spi_gpio_array_num[] = {
2946 LCDC_SPI_GPIO_CLK,
2947 LCDC_SPI_GPIO_CS,
2948 LCDC_SPI_GPIO_MOSI,
2949};
2950
2951static uint32_t lcdc_spi_gpio_config_data[] = {
2952 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2953 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2954 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2955 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2956 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2957 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2958};
2959
2960static void lcdc_config_spi_gpios(int enable)
2961{
2962 int n;
2963 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2964 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2965}
2966#endif
2967
2968#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2969#ifdef CONFIG_SPI_QUP
2970static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2971 {
2972 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2973 .mode = SPI_MODE_3,
2974 .bus_num = 1,
2975 .chip_select = 0,
2976 .max_speed_hz = 10800000,
2977 }
2978};
2979#endif /* CONFIG_SPI_QUP */
2980
2981static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2982#ifndef CONFIG_SPI_QUP
2983 .panel_config_gpio = lcdc_config_spi_gpios,
2984 .gpio_num = lcdc_spi_gpio_array_num,
2985#endif
2986};
2987
2988static struct platform_device lcdc_samsung_oled_panel_device = {
2989 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2990 .id = 0,
2991 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2992};
2993#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2994
2995#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2996#ifdef CONFIG_SPI_QUP
2997static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
2998 {
2999 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3000 .mode = SPI_MODE_3,
3001 .bus_num = 1,
3002 .chip_select = 0,
3003 .max_speed_hz = 10800000,
3004 }
3005};
3006#endif
3007
3008static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3009#ifndef CONFIG_SPI_QUP
3010 .panel_config_gpio = lcdc_config_spi_gpios,
3011 .gpio_num = lcdc_spi_gpio_array_num,
3012#endif
3013};
3014
3015static struct platform_device lcdc_auo_wvga_panel_device = {
3016 .name = LCDC_AUO_PANEL_NAME,
3017 .id = 0,
3018 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3019};
3020#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3021
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003022#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3023
3024#define GPIO_NT35582_RESET 94
3025#define GPIO_NT35582_BL_EN_HW_PIN 24
3026#define GPIO_NT35582_BL_EN \
3027 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3028
3029static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3030
3031static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3032 .gpio_num = lcdc_nt35582_pmic_gpio,
3033};
3034
3035static struct platform_device lcdc_nt35582_panel_device = {
3036 .name = LCDC_NT35582_PANEL_NAME,
3037 .id = 0,
3038 .dev = {
3039 .platform_data = &lcdc_nt35582_panel_data,
3040 }
3041};
3042
3043static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3044 {
3045 .modalias = "lcdc_nt35582_spi",
3046 .mode = SPI_MODE_0,
3047 .bus_num = 0,
3048 .chip_select = 0,
3049 .max_speed_hz = 1100000,
3050 }
3051};
3052#endif
3053
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003054#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3055static struct resource hdmi_msm_resources[] = {
3056 {
3057 .name = "hdmi_msm_qfprom_addr",
3058 .start = 0x00700000,
3059 .end = 0x007060FF,
3060 .flags = IORESOURCE_MEM,
3061 },
3062 {
3063 .name = "hdmi_msm_hdmi_addr",
3064 .start = 0x04A00000,
3065 .end = 0x04A00FFF,
3066 .flags = IORESOURCE_MEM,
3067 },
3068 {
3069 .name = "hdmi_msm_irq",
3070 .start = HDMI_IRQ,
3071 .end = HDMI_IRQ,
3072 .flags = IORESOURCE_IRQ,
3073 },
3074};
3075
3076static int hdmi_enable_5v(int on);
3077static int hdmi_core_power(int on, int show);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303078static int hdmi_gpio_config(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003079static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303080static int hdmi_panel_power(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003081
3082static struct msm_hdmi_platform_data hdmi_msm_data = {
3083 .irq = HDMI_IRQ,
3084 .enable_5v = hdmi_enable_5v,
3085 .core_power = hdmi_core_power,
3086 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303087 .panel_power = hdmi_panel_power,
3088 .gpio_config = hdmi_gpio_config,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003089};
3090
3091static struct platform_device hdmi_msm_device = {
3092 .name = "hdmi_msm",
3093 .id = 0,
3094 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3095 .resource = hdmi_msm_resources,
3096 .dev.platform_data = &hdmi_msm_data,
3097};
3098#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3099
3100#ifdef CONFIG_FB_MSM_MIPI_DSI
3101static struct platform_device mipi_dsi_toshiba_panel_device = {
3102 .name = "mipi_toshiba",
3103 .id = 0,
3104};
3105
3106#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3107
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003108static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003109 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003110 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003111};
3112
3113static struct platform_device mipi_dsi_novatek_panel_device = {
3114 .name = "mipi_novatek",
3115 .id = 0,
3116 .dev = {
3117 .platform_data = &novatek_pdata,
3118 }
3119};
3120#endif
3121
3122static void __init msm8x60_allocate_memory_regions(void)
3123{
3124 void *addr;
3125 unsigned long size;
3126
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003127 if (hdmi_is_primary)
3128 size = roundup((1920 * 1088 * 4 * 2), 4096);
3129 else
3130 size = MSM_FB_SIZE;
3131
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003132 addr = alloc_bootmem_align(size, 0x1000);
3133 msm_fb_resources[0].start = __pa(addr);
3134 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3135 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3136 size, addr, __pa(addr));
3137
3138}
3139
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003140void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3141{
3142 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3143 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3144 PANEL_NAME_MAX_LEN);
3145 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3146 msm_fb_pdata.prim_panel_name);
3147
3148 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3149 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3150 PANEL_NAME_MAX_LEN))) {
3151 pr_debug("HDMI is the primary display by"
3152 " boot parameter\n");
3153 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003154 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003155 }
3156 }
3157 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3158 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3159 PANEL_NAME_MAX_LEN);
3160 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3161 msm_fb_pdata.ext_panel_name);
3162 }
3163}
3164
Steve Mucklef132c6c2012-06-06 18:30:57 -07003165#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3166 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003167/*virtual key support */
3168static ssize_t tma300_vkeys_show(struct kobject *kobj,
3169 struct kobj_attribute *attr, char *buf)
3170{
3171 return sprintf(buf,
3172 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3173 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3174 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3175 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3176 "\n");
3177}
3178
3179static struct kobj_attribute tma300_vkeys_attr = {
3180 .attr = {
3181 .mode = S_IRUGO,
3182 },
3183 .show = &tma300_vkeys_show,
3184};
3185
3186static struct attribute *tma300_properties_attrs[] = {
3187 &tma300_vkeys_attr.attr,
3188 NULL
3189};
3190
3191static struct attribute_group tma300_properties_attr_group = {
3192 .attrs = tma300_properties_attrs,
3193};
3194
3195static struct kobject *properties_kobj;
3196
3197
3198
3199#define CYTTSP_TS_GPIO_IRQ 61
3200static int cyttsp_platform_init(struct i2c_client *client)
3201{
3202 int rc = -EINVAL;
3203 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3204
3205 if (machine_is_msm8x60_fluid()) {
3206 pm8058_l5 = regulator_get(NULL, "8058_l5");
3207 if (IS_ERR(pm8058_l5)) {
3208 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3209 __func__, PTR_ERR(pm8058_l5));
3210 rc = PTR_ERR(pm8058_l5);
3211 return rc;
3212 }
3213 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3214 if (rc) {
3215 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3216 __func__, rc);
3217 goto reg_l5_put;
3218 }
3219
3220 rc = regulator_enable(pm8058_l5);
3221 if (rc) {
3222 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3223 __func__, rc);
3224 goto reg_l5_put;
3225 }
3226 }
3227 /* vote for s3 to enable i2c communication lines */
3228 pm8058_s3 = regulator_get(NULL, "8058_s3");
3229 if (IS_ERR(pm8058_s3)) {
3230 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3231 __func__, PTR_ERR(pm8058_s3));
3232 rc = PTR_ERR(pm8058_s3);
3233 goto reg_l5_disable;
3234 }
3235
3236 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3237 if (rc) {
3238 pr_err("%s: regulator_set_voltage() = %d\n",
3239 __func__, rc);
3240 goto reg_s3_put;
3241 }
3242
3243 rc = regulator_enable(pm8058_s3);
3244 if (rc) {
3245 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3246 __func__, rc);
3247 goto reg_s3_put;
3248 }
3249
3250 /* wait for vregs to stabilize */
3251 usleep_range(10000, 10000);
3252
3253 /* check this device active by reading first byte/register */
3254 rc = i2c_smbus_read_byte_data(client, 0x01);
3255 if (rc < 0) {
3256 pr_err("%s: i2c sanity check failed\n", __func__);
3257 goto reg_s3_disable;
3258 }
3259
3260 /* virtual keys */
3261 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003262 properties_kobj = kobject_create_and_add("board_properties",
3263 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003264 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003265 if (!properties_kobj || rc)
3266 pr_err("%s: failed to create board_properties\n",
3267 __func__);
3268 }
3269 return CY_OK;
3270
3271reg_s3_disable:
3272 regulator_disable(pm8058_s3);
3273reg_s3_put:
3274 regulator_put(pm8058_s3);
3275reg_l5_disable:
3276 if (machine_is_msm8x60_fluid())
3277 regulator_disable(pm8058_l5);
3278reg_l5_put:
3279 if (machine_is_msm8x60_fluid())
3280 regulator_put(pm8058_l5);
3281 return rc;
3282}
3283
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303284/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3285static int cyttsp_platform_suspend(struct i2c_client *client)
3286{
3287 msleep(20);
3288
3289 return CY_OK;
3290}
3291
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003292static int cyttsp_platform_resume(struct i2c_client *client)
3293{
3294 /* add any special code to strobe a wakeup pin or chip reset */
3295 msleep(10);
3296
3297 return CY_OK;
3298}
3299
3300static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3301 .flags = 0x04,
3302 .gen = CY_GEN3, /* or */
3303 .use_st = CY_USE_ST,
3304 .use_mt = CY_USE_MT,
3305 .use_hndshk = CY_SEND_HNDSHK,
3306 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303307 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003308 .use_gestures = CY_USE_GESTURES,
3309 /* activate up to 4 groups
3310 * and set active distance
3311 */
3312 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3313 CY_GEST_GRP3 | CY_GEST_GRP4 |
3314 CY_ACT_DIST,
3315 /* change act_intrvl to customize the Active power state
3316 * scanning/processing refresh interval for Operating mode
3317 */
3318 .act_intrvl = CY_ACT_INTRVL_DFLT,
3319 /* change tch_tmout to customize the touch timeout for the
3320 * Active power state for Operating mode
3321 */
3322 .tch_tmout = CY_TCH_TMOUT_DFLT,
3323 /* change lp_intrvl to customize the Low Power power state
3324 * scanning/processing refresh interval for Operating mode
3325 */
3326 .lp_intrvl = CY_LP_INTRVL_DFLT,
3327 .sleep_gpio = -1,
3328 .resout_gpio = -1,
3329 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3330 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303331 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003332 .init = cyttsp_platform_init,
3333};
3334
3335static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3336 .panel_maxx = 1083,
3337 .panel_maxy = 659,
3338 .disp_minx = 30,
3339 .disp_maxx = 1053,
3340 .disp_miny = 30,
3341 .disp_maxy = 629,
3342 .correct_fw_ver = 8,
3343 .fw_fname = "cyttsp_8660_ffa.hex",
3344 .flags = 0x00,
3345 .gen = CY_GEN2, /* or */
3346 .use_st = CY_USE_ST,
3347 .use_mt = CY_USE_MT,
3348 .use_hndshk = CY_SEND_HNDSHK,
3349 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303350 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003351 .use_gestures = CY_USE_GESTURES,
3352 /* activate up to 4 groups
3353 * and set active distance
3354 */
3355 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3356 CY_GEST_GRP3 | CY_GEST_GRP4 |
3357 CY_ACT_DIST,
3358 /* change act_intrvl to customize the Active power state
3359 * scanning/processing refresh interval for Operating mode
3360 */
3361 .act_intrvl = CY_ACT_INTRVL_DFLT,
3362 /* change tch_tmout to customize the touch timeout for the
3363 * Active power state for Operating mode
3364 */
3365 .tch_tmout = CY_TCH_TMOUT_DFLT,
3366 /* change lp_intrvl to customize the Low Power power state
3367 * scanning/processing refresh interval for Operating mode
3368 */
3369 .lp_intrvl = CY_LP_INTRVL_DFLT,
3370 .sleep_gpio = -1,
3371 .resout_gpio = -1,
3372 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3373 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303374 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003375 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303376 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003377};
3378static void cyttsp_set_params(void)
3379{
3380 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3381 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3382 cyttsp_fluid_pdata.panel_maxx = 539;
3383 cyttsp_fluid_pdata.panel_maxy = 994;
3384 cyttsp_fluid_pdata.disp_minx = 30;
3385 cyttsp_fluid_pdata.disp_maxx = 509;
3386 cyttsp_fluid_pdata.disp_miny = 60;
3387 cyttsp_fluid_pdata.disp_maxy = 859;
3388 cyttsp_fluid_pdata.correct_fw_ver = 4;
3389 } else {
3390 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3391 cyttsp_fluid_pdata.panel_maxx = 550;
3392 cyttsp_fluid_pdata.panel_maxy = 1013;
3393 cyttsp_fluid_pdata.disp_minx = 35;
3394 cyttsp_fluid_pdata.disp_maxx = 515;
3395 cyttsp_fluid_pdata.disp_miny = 69;
3396 cyttsp_fluid_pdata.disp_maxy = 869;
3397 cyttsp_fluid_pdata.correct_fw_ver = 5;
3398 }
3399
3400}
3401
3402static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3403 {
3404 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3405 .platform_data = &cyttsp_fluid_pdata,
3406#ifndef CY_USE_TIMER
3407 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3408#endif /* CY_USE_TIMER */
3409 },
3410};
3411
3412static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3413 {
3414 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3415 .platform_data = &cyttsp_tmg240_pdata,
3416#ifndef CY_USE_TIMER
3417 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3418#endif /* CY_USE_TIMER */
3419 },
3420};
3421#endif
3422
3423static struct regulator *vreg_tmg200;
3424
3425#define TS_PEN_IRQ_GPIO 61
3426static int tmg200_power(int vreg_on)
3427{
3428 int rc = -EINVAL;
3429
3430 if (!vreg_tmg200) {
3431 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3432 __func__, rc);
3433 return rc;
3434 }
3435
3436 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3437 regulator_disable(vreg_tmg200);
3438 if (rc < 0)
3439 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3440 __func__, vreg_on ? "enable" : "disable", rc);
3441
3442 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003443 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003444
3445 return rc;
3446}
3447
3448static int tmg200_dev_setup(bool enable)
3449{
3450 int rc;
3451
3452 if (enable) {
3453 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3454 if (IS_ERR(vreg_tmg200)) {
3455 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3456 __func__, PTR_ERR(vreg_tmg200));
3457 rc = PTR_ERR(vreg_tmg200);
3458 return rc;
3459 }
3460
3461 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3462 if (rc) {
3463 pr_err("%s: regulator_set_voltage() = %d\n",
3464 __func__, rc);
3465 goto reg_put;
3466 }
3467 } else {
3468 /* put voltage sources */
3469 regulator_put(vreg_tmg200);
3470 }
3471 return 0;
3472reg_put:
3473 regulator_put(vreg_tmg200);
3474 return rc;
3475}
3476
3477static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3478 .ts_name = "msm_tmg200_ts",
3479 .dis_min_x = 0,
3480 .dis_max_x = 1023,
3481 .dis_min_y = 0,
3482 .dis_max_y = 599,
3483 .min_tid = 0,
3484 .max_tid = 255,
3485 .min_touch = 0,
3486 .max_touch = 255,
3487 .min_width = 0,
3488 .max_width = 255,
3489 .power_on = tmg200_power,
3490 .dev_setup = tmg200_dev_setup,
3491 .nfingers = 2,
3492 .irq_gpio = TS_PEN_IRQ_GPIO,
3493 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3494};
3495
3496static struct i2c_board_info cy8ctmg200_board_info[] = {
3497 {
3498 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3499 .platform_data = &cy8ctmg200_pdata,
3500 }
3501};
3502
Zhang Chang Ken211df572011-07-05 19:16:39 -04003503static struct regulator *vreg_tma340;
3504
3505static int tma340_power(int vreg_on)
3506{
3507 int rc = -EINVAL;
3508
3509 if (!vreg_tma340) {
3510 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3511 __func__, rc);
3512 return rc;
3513 }
3514
3515 rc = vreg_on ? regulator_enable(vreg_tma340) :
3516 regulator_disable(vreg_tma340);
3517 if (rc < 0)
3518 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3519 __func__, vreg_on ? "enable" : "disable", rc);
3520
3521 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003522 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003523
3524 return rc;
3525}
3526
3527static struct kobject *tma340_prop_kobj;
3528
3529static int tma340_dragon_dev_setup(bool enable)
3530{
3531 int rc;
3532
3533 if (enable) {
3534 vreg_tma340 = regulator_get(NULL, "8901_l2");
3535 if (IS_ERR(vreg_tma340)) {
3536 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3537 __func__, PTR_ERR(vreg_tma340));
3538 rc = PTR_ERR(vreg_tma340);
3539 return rc;
3540 }
3541
3542 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3543 if (rc) {
3544 pr_err("%s: regulator_set_voltage() = %d\n",
3545 __func__, rc);
3546 goto reg_put;
3547 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003548 tma340_prop_kobj = kobject_create_and_add("board_properties",
3549 NULL);
3550 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003551 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003552 if (rc) {
3553 kobject_put(tma340_prop_kobj);
3554 pr_err("%s: failed to create board_properties\n",
3555 __func__);
3556 goto reg_put;
3557 }
3558 }
3559
3560 } else {
3561 /* put voltage sources */
3562 regulator_put(vreg_tma340);
3563 /* destroy virtual keys */
3564 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003565 kobject_put(tma340_prop_kobj);
3566 }
3567 }
3568 return 0;
3569reg_put:
3570 regulator_put(vreg_tma340);
3571 return rc;
3572}
3573
3574
3575static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3576 .ts_name = "cy8ctma340",
3577 .dis_min_x = 0,
3578 .dis_max_x = 479,
3579 .dis_min_y = 0,
3580 .dis_max_y = 799,
3581 .min_tid = 0,
3582 .max_tid = 255,
3583 .min_touch = 0,
3584 .max_touch = 255,
3585 .min_width = 0,
3586 .max_width = 255,
3587 .power_on = tma340_power,
3588 .dev_setup = tma340_dragon_dev_setup,
3589 .nfingers = 2,
3590 .irq_gpio = TS_PEN_IRQ_GPIO,
3591 .resout_gpio = -1,
3592};
3593
3594static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3595 {
3596 I2C_BOARD_INFO("cy8ctma340", 0x24),
3597 .platform_data = &cy8ctma340_dragon_pdata,
3598 }
3599};
3600
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003601#ifdef CONFIG_SERIAL_MSM_HS
3602static int configure_uart_gpios(int on)
3603{
3604 int ret = 0, i;
3605 int uart_gpios[] = {53, 54, 55, 56};
3606 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3607 if (on) {
3608 ret = msm_gpiomux_get(uart_gpios[i]);
3609 if (unlikely(ret))
3610 break;
3611 } else {
3612 ret = msm_gpiomux_put(uart_gpios[i]);
3613 if (unlikely(ret))
3614 return ret;
3615 }
3616 }
3617 if (ret)
3618 for (; i >= 0; i--)
3619 msm_gpiomux_put(uart_gpios[i]);
3620 return ret;
3621}
3622static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3623 .inject_rx_on_wakeup = 1,
3624 .rx_to_inject = 0xFD,
3625 .gpio_config = configure_uart_gpios,
3626};
3627#endif
3628
3629
3630#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3631
3632static struct gpio_led gpio_exp_leds_config[] = {
3633 {
3634 .name = "left_led1:green",
3635 .gpio = GPIO_LEFT_LED_1,
3636 .active_low = 1,
3637 .retain_state_suspended = 0,
3638 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3639 },
3640 {
3641 .name = "left_led2:red",
3642 .gpio = GPIO_LEFT_LED_2,
3643 .active_low = 1,
3644 .retain_state_suspended = 0,
3645 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3646 },
3647 {
3648 .name = "left_led3:green",
3649 .gpio = GPIO_LEFT_LED_3,
3650 .active_low = 1,
3651 .retain_state_suspended = 0,
3652 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3653 },
3654 {
3655 .name = "wlan_led:orange",
3656 .gpio = GPIO_LEFT_LED_WLAN,
3657 .active_low = 1,
3658 .retain_state_suspended = 0,
3659 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3660 },
3661 {
3662 .name = "left_led5:green",
3663 .gpio = GPIO_LEFT_LED_5,
3664 .active_low = 1,
3665 .retain_state_suspended = 0,
3666 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3667 },
3668 {
3669 .name = "right_led1:green",
3670 .gpio = GPIO_RIGHT_LED_1,
3671 .active_low = 1,
3672 .retain_state_suspended = 0,
3673 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3674 },
3675 {
3676 .name = "right_led2:red",
3677 .gpio = GPIO_RIGHT_LED_2,
3678 .active_low = 1,
3679 .retain_state_suspended = 0,
3680 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3681 },
3682 {
3683 .name = "right_led3:green",
3684 .gpio = GPIO_RIGHT_LED_3,
3685 .active_low = 1,
3686 .retain_state_suspended = 0,
3687 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3688 },
3689 {
3690 .name = "bt_led:blue",
3691 .gpio = GPIO_RIGHT_LED_BT,
3692 .active_low = 1,
3693 .retain_state_suspended = 0,
3694 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3695 },
3696 {
3697 .name = "right_led5:green",
3698 .gpio = GPIO_RIGHT_LED_5,
3699 .active_low = 1,
3700 .retain_state_suspended = 0,
3701 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3702 },
3703};
3704
3705static struct gpio_led_platform_data gpio_leds_pdata = {
3706 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3707 .leds = gpio_exp_leds_config,
3708};
3709
3710static struct platform_device gpio_leds = {
3711 .name = "leds-gpio",
3712 .id = -1,
3713 .dev = {
3714 .platform_data = &gpio_leds_pdata,
3715 },
3716};
3717
3718static struct gpio_led fluid_gpio_leds[] = {
3719 {
3720 .name = "dual_led:green",
3721 .gpio = GPIO_LED1_GREEN_N,
3722 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3723 .active_low = 1,
3724 .retain_state_suspended = 0,
3725 },
3726 {
3727 .name = "dual_led:red",
3728 .gpio = GPIO_LED2_RED_N,
3729 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3730 .active_low = 1,
3731 .retain_state_suspended = 0,
3732 },
3733};
3734
3735static struct gpio_led_platform_data gpio_led_pdata = {
3736 .leds = fluid_gpio_leds,
3737 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3738};
3739
3740static struct platform_device fluid_leds_gpio = {
3741 .name = "leds-gpio",
3742 .id = -1,
3743 .dev = {
3744 .platform_data = &gpio_led_pdata,
3745 },
3746};
3747
3748#endif
3749
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003750#ifdef CONFIG_BATTERY_MSM8X60
3751static struct msm_charger_platform_data msm_charger_data = {
3752 .safety_time = 180,
3753 .update_time = 1,
3754 .max_voltage = 4200,
3755 .min_voltage = 3200,
3756};
3757
3758static struct platform_device msm_charger_device = {
3759 .name = "msm-charger",
3760 .id = -1,
3761 .dev = {
3762 .platform_data = &msm_charger_data,
3763 }
3764};
3765#endif
3766
3767/*
3768 * Consumer specific regulator names:
3769 * regulator name consumer dev_name
3770 */
3771static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3772 REGULATOR_SUPPLY("8058_l0", NULL),
3773};
3774static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3775 REGULATOR_SUPPLY("8058_l1", NULL),
3776};
3777static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3778 REGULATOR_SUPPLY("8058_l2", NULL),
3779};
3780static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3781 REGULATOR_SUPPLY("8058_l3", NULL),
3782};
3783static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3784 REGULATOR_SUPPLY("8058_l4", NULL),
3785};
3786static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3787 REGULATOR_SUPPLY("8058_l5", NULL),
3788};
3789static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3790 REGULATOR_SUPPLY("8058_l6", NULL),
3791};
3792static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3793 REGULATOR_SUPPLY("8058_l7", NULL),
3794};
3795static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3796 REGULATOR_SUPPLY("8058_l8", NULL),
3797};
3798static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3799 REGULATOR_SUPPLY("8058_l9", NULL),
3800};
3801static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3802 REGULATOR_SUPPLY("8058_l10", NULL),
3803};
3804static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3805 REGULATOR_SUPPLY("8058_l11", NULL),
3806};
3807static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3808 REGULATOR_SUPPLY("8058_l12", NULL),
3809};
3810static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3811 REGULATOR_SUPPLY("8058_l13", NULL),
3812};
3813static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3814 REGULATOR_SUPPLY("8058_l14", NULL),
3815};
3816static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3817 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003818 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003819 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003820 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003821};
3822static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3823 REGULATOR_SUPPLY("8058_l16", NULL),
3824};
3825static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3826 REGULATOR_SUPPLY("8058_l17", NULL),
3827};
3828static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3829 REGULATOR_SUPPLY("8058_l18", NULL),
3830};
3831static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3832 REGULATOR_SUPPLY("8058_l19", NULL),
3833};
3834static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3835 REGULATOR_SUPPLY("8058_l20", NULL),
3836};
3837static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3838 REGULATOR_SUPPLY("8058_l21", NULL),
3839};
3840static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3841 REGULATOR_SUPPLY("8058_l22", NULL),
3842};
3843static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3844 REGULATOR_SUPPLY("8058_l23", NULL),
3845};
3846static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3847 REGULATOR_SUPPLY("8058_l24", NULL),
3848};
3849static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3850 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003851 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003852 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003853 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003854};
3855static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3856 REGULATOR_SUPPLY("8058_s0", NULL),
3857};
3858static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3859 REGULATOR_SUPPLY("8058_s1", NULL),
3860};
3861static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3862 REGULATOR_SUPPLY("8058_s2", NULL),
3863};
3864static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3865 REGULATOR_SUPPLY("8058_s3", NULL),
3866};
3867static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3868 REGULATOR_SUPPLY("8058_s4", NULL),
3869};
3870static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3871 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003872 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003873 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003874 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003875};
3876static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3877 REGULATOR_SUPPLY("8058_lvs1", NULL),
3878};
3879static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3880 REGULATOR_SUPPLY("8058_ncp", NULL),
3881};
3882
3883static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3884 REGULATOR_SUPPLY("8901_l0", NULL),
3885};
3886static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3887 REGULATOR_SUPPLY("8901_l1", NULL),
3888};
3889static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3890 REGULATOR_SUPPLY("8901_l2", NULL),
3891};
3892static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3893 REGULATOR_SUPPLY("8901_l3", NULL),
3894};
3895static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3896 REGULATOR_SUPPLY("8901_l4", NULL),
3897};
3898static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3899 REGULATOR_SUPPLY("8901_l5", NULL),
3900};
3901static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3902 REGULATOR_SUPPLY("8901_l6", NULL),
3903};
3904static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3905 REGULATOR_SUPPLY("8901_s2", NULL),
3906};
3907static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3908 REGULATOR_SUPPLY("8901_s3", NULL),
3909};
3910static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3911 REGULATOR_SUPPLY("8901_s4", NULL),
3912};
3913static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3914 REGULATOR_SUPPLY("8901_lvs0", NULL),
3915};
3916static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3917 REGULATOR_SUPPLY("8901_lvs1", NULL),
3918};
3919static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3920 REGULATOR_SUPPLY("8901_lvs2", NULL),
3921};
3922static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3923 REGULATOR_SUPPLY("8901_lvs3", NULL),
3924};
3925static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3926 REGULATOR_SUPPLY("8901_mvs0", NULL),
3927};
3928
David Collins6f032ba2011-08-31 14:08:15 -07003929/* Pin control regulators */
3930static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3931 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3932};
3933static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3934 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3935};
3936static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3937 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3938};
3939static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3940 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3941};
3942static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3943 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3944};
3945static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3946 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3947};
3948
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003949#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3950 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003951 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3952 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003953 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003954 .init_data = { \
3955 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003956 .valid_modes_mask = _modes, \
3957 .valid_ops_mask = _ops, \
3958 .min_uV = _min_uV, \
3959 .max_uV = _max_uV, \
3960 .input_uV = _min_uV, \
3961 .apply_uV = _apply_uV, \
3962 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003963 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003964 .consumer_supplies = vreg_consumers_##_id, \
3965 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003966 ARRAY_SIZE(vreg_consumers_##_id), \
3967 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003968 .id = RPM_VREG_ID_##_id, \
3969 .default_uV = _default_uV, \
3970 .peak_uA = _peak_uA, \
3971 .avg_uA = _avg_uA, \
3972 .pull_down_enable = _pull_down, \
3973 .pin_ctrl = _pin_ctrl, \
3974 .freq = RPM_VREG_FREQ_##_freq, \
3975 .pin_fn = _pin_fn, \
3976 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003977 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003978 .state = _state, \
3979 .sleep_selectable = _sleep_selectable, \
3980 }
3981
3982/* Pin control initialization */
3983#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3984 { \
3985 .init_data = { \
3986 .constraints = { \
3987 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3988 .always_on = _always_on, \
3989 }, \
3990 .num_consumer_supplies = \
3991 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3992 .consumer_supplies = vreg_consumers_##_id##_PC, \
3993 }, \
3994 .id = RPM_VREG_ID_##_id##_PC, \
3995 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003996 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003997 }
3998
3999/*
4000 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4001 * via the peak_uA value specified in the table below. If the value is less
4002 * than the high power min threshold for the regulator, then the regulator will
4003 * be set to LPM. Otherwise, it will be set to HPM.
4004 *
4005 * This value can be further overridden by specifying an initial mode via
4006 * .init_data.constraints.initial_mode.
4007 */
4008
David Collins6f032ba2011-08-31 14:08:15 -07004009#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4010 _init_peak_uA) \
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, NONE, \
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, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004020 _sleep_selectable, _always_on)
4021
David Collins6f032ba2011-08-31 14:08:15 -07004022#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4023 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004024 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4025 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4026 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4027 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4028 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004029 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4030 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004031 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004032 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4033 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004034
David Collins6f032ba2011-08-31 14:08:15 -07004035#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004036 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4037 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004038 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4039 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004040 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004041 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4042 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004043
David Collins6f032ba2011-08-31 14:08:15 -07004044#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4046 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004047 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4048 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004049 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004050 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4051 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052
David Collins6f032ba2011-08-31 14:08:15 -07004053#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4054#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4055#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4056#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4057#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004058
David Collins6f032ba2011-08-31 14:08:15 -07004059/* RPM early regulator constraints */
4060static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4061 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004062 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004063 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004064};
4065
David Collins6f032ba2011-08-31 14:08:15 -07004066/* RPM regulator constraints */
4067static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4068 /* ID a_on pd ss min_uV max_uV init_ip */
4069 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4070 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4071 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4072 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4073 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4074 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4075 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4076 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4077 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4078 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4079 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4080 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4081 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4082 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4083 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4084 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4085 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4086 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4087 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4088 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4089 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4090 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4091 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4092 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4093 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4094 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004095
David Collins6f032ba2011-08-31 14:08:15 -07004096 /* ID a_on pd ss min_uV max_uV init_ip freq */
4097 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4098 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4099 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4100
4101 /* ID a_on pd ss */
4102 RPM_VS(PM8058_LVS0, 0, 1, 0),
4103 RPM_VS(PM8058_LVS1, 0, 1, 0),
4104
4105 /* ID a_on pd ss min_uV max_uV */
4106 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4107
4108 /* ID a_on pd ss min_uV max_uV init_ip */
4109 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4110 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4111 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4112 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4113 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4114 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4115 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4116
4117 /* ID a_on pd ss min_uV max_uV init_ip freq */
4118 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4119 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4120 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4121
4122 /* ID a_on pd ss */
4123 RPM_VS(PM8901_LVS0, 1, 1, 0),
4124 RPM_VS(PM8901_LVS1, 0, 1, 0),
4125 RPM_VS(PM8901_LVS2, 0, 1, 0),
4126 RPM_VS(PM8901_LVS3, 0, 1, 0),
4127 RPM_VS(PM8901_MVS0, 0, 1, 0),
4128
4129 /* ID a_on pin_func pin_ctrl */
4130 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4131 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4132 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4133 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4134 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4135 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4136};
4137
4138static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4139 .init_data = rpm_regulator_early_init_data,
4140 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4141 .version = RPM_VREG_VERSION_8660,
4142 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4143 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4144};
4145
4146static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4147 .init_data = rpm_regulator_init_data,
4148 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4149 .version = RPM_VREG_VERSION_8660,
4150};
4151
4152static struct platform_device rpm_regulator_early_device = {
4153 .name = "rpm-regulator",
4154 .id = 0,
4155 .dev = {
4156 .platform_data = &rpm_regulator_early_pdata,
4157 },
4158};
4159
4160static struct platform_device rpm_regulator_device = {
4161 .name = "rpm-regulator",
4162 .id = 1,
4163 .dev = {
4164 .platform_data = &rpm_regulator_pdata,
4165 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004166};
4167
4168static struct platform_device *early_regulators[] __initdata = {
4169 &msm_device_saw_s0,
4170 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004171 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004172};
4173
4174static struct platform_device *early_devices[] __initdata = {
4175#ifdef CONFIG_MSM_BUS_SCALING
4176 &msm_bus_apps_fabric,
4177 &msm_bus_sys_fabric,
4178 &msm_bus_mm_fabric,
4179 &msm_bus_sys_fpb,
4180 &msm_bus_cpss_fpb,
4181#endif
4182 &msm_device_dmov_adm0,
4183 &msm_device_dmov_adm1,
4184};
4185
4186#if (defined(CONFIG_MARIMBA_CORE)) && \
4187 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4188
4189static int bluetooth_power(int);
4190static struct platform_device msm_bt_power_device = {
4191 .name = "bt_power",
4192 .id = -1,
4193 .dev = {
4194 .platform_data = &bluetooth_power,
4195 },
4196};
4197#endif
4198
4199static struct platform_device msm_tsens_device = {
4200 .name = "tsens-tm",
4201 .id = -1,
4202};
4203
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004204#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4205enum {
4206 SX150X_CORE,
4207 SX150X_DOCKING,
4208 SX150X_SURF,
4209 SX150X_LEFT_FHA,
4210 SX150X_RIGHT_FHA,
4211 SX150X_SOUTH,
4212 SX150X_NORTH,
4213 SX150X_CORE_FLUID,
4214};
4215
4216static struct sx150x_platform_data sx150x_data[] __initdata = {
4217 [SX150X_CORE] = {
4218 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4219 .oscio_is_gpo = false,
4220 .io_pullup_ena = 0x0c08,
4221 .io_pulldn_ena = 0x4060,
4222 .io_open_drain_ena = 0x000c,
4223 .io_polarity = 0,
4224 .irq_summary = -1, /* see fixup_i2c_configs() */
4225 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4226 },
4227 [SX150X_DOCKING] = {
4228 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4229 .oscio_is_gpo = false,
4230 .io_pullup_ena = 0x5e06,
4231 .io_pulldn_ena = 0x81b8,
4232 .io_open_drain_ena = 0,
4233 .io_polarity = 0,
4234 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4235 UI_INT2_N),
4236 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4237 GPIO_DOCKING_EXPANDER_BASE -
4238 GPIO_EXPANDER_GPIO_BASE,
4239 },
4240 [SX150X_SURF] = {
4241 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4242 .oscio_is_gpo = false,
4243 .io_pullup_ena = 0,
4244 .io_pulldn_ena = 0,
4245 .io_open_drain_ena = 0,
4246 .io_polarity = 0,
4247 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4248 UI_INT1_N),
4249 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4250 GPIO_SURF_EXPANDER_BASE -
4251 GPIO_EXPANDER_GPIO_BASE,
4252 },
4253 [SX150X_LEFT_FHA] = {
4254 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4255 .oscio_is_gpo = false,
4256 .io_pullup_ena = 0,
4257 .io_pulldn_ena = 0x40,
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_LEFT_KB_EXPANDER_BASE -
4264 GPIO_EXPANDER_GPIO_BASE,
4265 },
4266 [SX150X_RIGHT_FHA] = {
4267 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4268 .oscio_is_gpo = true,
4269 .io_pullup_ena = 0,
4270 .io_pulldn_ena = 0,
4271 .io_open_drain_ena = 0,
4272 .io_polarity = 0,
4273 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4274 UI_INT3_N),
4275 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4276 GPIO_RIGHT_KB_EXPANDER_BASE -
4277 GPIO_EXPANDER_GPIO_BASE,
4278 },
4279 [SX150X_SOUTH] = {
4280 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4281 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4282 GPIO_SOUTH_EXPANDER_BASE -
4283 GPIO_EXPANDER_GPIO_BASE,
4284 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4285 },
4286 [SX150X_NORTH] = {
4287 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4288 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4289 GPIO_NORTH_EXPANDER_BASE -
4290 GPIO_EXPANDER_GPIO_BASE,
4291 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4292 .oscio_is_gpo = true,
4293 .io_open_drain_ena = 0x30,
4294 },
4295 [SX150X_CORE_FLUID] = {
4296 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4297 .oscio_is_gpo = false,
4298 .io_pullup_ena = 0x0408,
4299 .io_pulldn_ena = 0x4060,
4300 .io_open_drain_ena = 0x0008,
4301 .io_polarity = 0,
4302 .irq_summary = -1, /* see fixup_i2c_configs() */
4303 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4304 },
4305};
4306
4307#ifdef CONFIG_SENSORS_MSM_ADC
4308/* Configuration of EPM expander is done when client
4309 * request an adc read
4310 */
4311static struct sx150x_platform_data sx150x_epmdata = {
4312 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4313 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4314 GPIO_EPM_EXPANDER_BASE -
4315 GPIO_EXPANDER_GPIO_BASE,
4316 .irq_summary = -1,
4317};
4318#endif
4319
4320/* sx150x_low_power_cfg
4321 *
4322 * This data and init function are used to put unused gpio-expander output
4323 * lines into their low-power states at boot. The init
4324 * function must be deferred until a later init stage because the i2c
4325 * gpio expander drivers do not probe until after they are registered
4326 * (see register_i2c_devices) and the work-queues for those registrations
4327 * are processed. Because these lines are unused, there is no risk of
4328 * competing with a device driver for the gpio.
4329 *
4330 * gpio lines whose low-power states are input are naturally in their low-
4331 * power configurations once probed, see the platform data structures above.
4332 */
4333struct sx150x_low_power_cfg {
4334 unsigned gpio;
4335 unsigned val;
4336};
4337
4338static struct sx150x_low_power_cfg
4339common_sx150x_lp_cfgs[] __initdata = {
4340 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4341 {GPIO_EXT_GPS_LNA_EN, 0},
4342 {GPIO_MSM_WAKES_BT, 0},
4343 {GPIO_USB_UICC_EN, 0},
4344 {GPIO_BATT_GAUGE_EN, 0},
4345};
4346
4347static struct sx150x_low_power_cfg
4348surf_ffa_sx150x_lp_cfgs[] __initdata = {
4349 {GPIO_MIPI_DSI_RST_N, 0},
4350 {GPIO_DONGLE_PWR_EN, 0},
4351 {GPIO_CAP_TS_SLEEP, 1},
4352 {GPIO_WEB_CAMIF_RESET_N, 0},
4353};
4354
4355static void __init
4356cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4357{
4358 unsigned n;
4359 int rc;
4360
4361 for (n = 0; n < nelems; ++n) {
4362 rc = gpio_request(cfgs[n].gpio, NULL);
4363 if (!rc) {
4364 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4365 gpio_free(cfgs[n].gpio);
4366 }
4367
4368 if (rc) {
4369 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4370 __func__, cfgs[n].gpio, rc);
4371 }
Steve Muckle9161d302010-02-11 11:50:40 -08004372 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004373}
4374
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004375static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004376{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004377 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4378 ARRAY_SIZE(common_sx150x_lp_cfgs));
4379 if (!machine_is_msm8x60_fluid())
4380 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4381 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4382 return 0;
4383}
4384module_init(cfg_sx150xs_low_power);
4385
4386#ifdef CONFIG_I2C
4387static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4388 {
4389 I2C_BOARD_INFO("sx1509q", 0x3e),
4390 .platform_data = &sx150x_data[SX150X_CORE]
4391 },
4392};
4393
4394static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4395 {
4396 I2C_BOARD_INFO("sx1509q", 0x3f),
4397 .platform_data = &sx150x_data[SX150X_DOCKING]
4398 },
4399};
4400
4401static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4402 {
4403 I2C_BOARD_INFO("sx1509q", 0x70),
4404 .platform_data = &sx150x_data[SX150X_SURF]
4405 }
4406};
4407
4408static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4409 {
4410 I2C_BOARD_INFO("sx1508q", 0x21),
4411 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4412 },
4413 {
4414 I2C_BOARD_INFO("sx1508q", 0x22),
4415 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4416 }
4417};
4418
4419static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4420 {
4421 I2C_BOARD_INFO("sx1508q", 0x23),
4422 .platform_data = &sx150x_data[SX150X_SOUTH]
4423 },
4424 {
4425 I2C_BOARD_INFO("sx1508q", 0x20),
4426 .platform_data = &sx150x_data[SX150X_NORTH]
4427 }
4428};
4429
4430static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4431 {
4432 I2C_BOARD_INFO("sx1509q", 0x3e),
4433 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4434 },
4435};
4436
4437#ifdef CONFIG_SENSORS_MSM_ADC
4438static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4439 {
4440 I2C_BOARD_INFO("sx1509q", 0x3e),
4441 .platform_data = &sx150x_epmdata
4442 },
4443};
4444#endif
4445#endif
4446#endif
4447
4448#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004449
4450static struct adc_access_fn xoadc_fn = {
4451 pm8058_xoadc_select_chan_and_start_conv,
4452 pm8058_xoadc_read_adc_code,
4453 pm8058_xoadc_get_properties,
4454 pm8058_xoadc_slot_request,
4455 pm8058_xoadc_restore_slot,
4456 pm8058_xoadc_calibrate,
4457};
4458
4459#if defined(CONFIG_I2C) && \
4460 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4461static struct regulator *vreg_adc_epm1;
4462
4463static struct i2c_client *epm_expander_i2c_register_board(void)
4464
4465{
4466 struct i2c_adapter *i2c_adap;
4467 struct i2c_client *client = NULL;
4468 i2c_adap = i2c_get_adapter(0x0);
4469
4470 if (i2c_adap == NULL)
4471 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4472
4473 if (i2c_adap != NULL)
4474 client = i2c_new_device(i2c_adap,
4475 &fluid_expanders_i2c_epm_info[0]);
4476 return client;
4477
4478}
4479
4480static unsigned int msm_adc_gpio_configure_expander_enable(void)
4481{
4482 int rc = 0;
4483 static struct i2c_client *epm_i2c_client;
4484
4485 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4486
4487 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4488
4489 if (IS_ERR(vreg_adc_epm1)) {
4490 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4491 return 0;
4492 }
4493
4494 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4495 if (rc)
4496 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4497 "regulator set voltage failed\n");
4498
4499 rc = regulator_enable(vreg_adc_epm1);
4500 if (rc) {
4501 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4502 "Error while enabling regulator for epm s3 %d\n", rc);
4503 return rc;
4504 }
4505
4506 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4507 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4508
4509 msleep(1000);
4510
4511 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4512 if (!rc) {
4513 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4514 "Configure 5v boost\n");
4515 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4516 } else {
4517 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4518 "Error for epm 5v boost en\n");
4519 goto exit_vreg_epm;
4520 }
4521
4522 msleep(500);
4523
4524 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4525 if (!rc) {
4526 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4527 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4528 "Configure epm 3.3v\n");
4529 } else {
4530 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4531 "Error for gpio 3.3ven\n");
4532 goto exit_vreg_epm;
4533 }
4534 msleep(500);
4535
4536 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4537 "Trying to request EPM LVLSFT_EN\n");
4538 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4539 if (!rc) {
4540 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4541 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4542 "Configure the lvlsft\n");
4543 } else {
4544 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4545 "Error for epm lvlsft_en\n");
4546 goto exit_vreg_epm;
4547 }
4548
4549 msleep(500);
4550
4551 if (!epm_i2c_client)
4552 epm_i2c_client = epm_expander_i2c_register_board();
4553
4554 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4555 if (!rc)
4556 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4557 if (rc) {
4558 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4559 ": GPIO PWR MON Enable issue\n");
4560 goto exit_vreg_epm;
4561 }
4562
4563 msleep(1000);
4564
4565 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4566 if (!rc) {
4567 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4568 if (rc) {
4569 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4570 ": ADC1_PWDN error direction out\n");
4571 goto exit_vreg_epm;
4572 }
4573 }
4574
4575 msleep(100);
4576
4577 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4578 if (!rc) {
4579 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4580 if (rc) {
4581 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4582 ": ADC2_PWD error direction out\n");
4583 goto exit_vreg_epm;
4584 }
4585 }
4586
4587 msleep(1000);
4588
4589 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4590 if (!rc) {
4591 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4592 if (rc) {
4593 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4594 "Gpio request problem %d\n", rc);
4595 goto exit_vreg_epm;
4596 }
4597 }
4598
4599 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4600 if (!rc) {
4601 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4602 if (rc) {
4603 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4604 ": EPM_SPI_ADC1_CS_N error\n");
4605 goto exit_vreg_epm;
4606 }
4607 }
4608
4609 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4610 if (!rc) {
4611 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4612 if (rc) {
4613 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4614 ": EPM_SPI_ADC2_Cs_N error\n");
4615 goto exit_vreg_epm;
4616 }
4617 }
4618
4619 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4620 "the power monitor reset for epm\n");
4621
4622 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4623 if (!rc) {
4624 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4625 if (rc) {
4626 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4627 ": Error in the power mon reset\n");
4628 goto exit_vreg_epm;
4629 }
4630 }
4631
4632 msleep(1000);
4633
4634 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4635
4636 msleep(500);
4637
4638 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4639
4640 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4641
4642 return rc;
4643
4644exit_vreg_epm:
4645 regulator_disable(vreg_adc_epm1);
4646
4647 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4648 " rc = %d.\n", rc);
4649 return rc;
4650};
4651
4652static unsigned int msm_adc_gpio_configure_expander_disable(void)
4653{
4654 int rc = 0;
4655
4656 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4657 gpio_free(GPIO_PWR_MON_RESET_N);
4658
4659 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4660 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4661
4662 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4663 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4664
4665 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4666 gpio_free(GPIO_PWR_MON_START);
4667
4668 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4669 gpio_free(GPIO_ADC1_PWDN_N);
4670
4671 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4672 gpio_free(GPIO_ADC2_PWDN_N);
4673
4674 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4675 gpio_free(GPIO_PWR_MON_ENABLE);
4676
4677 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4678 gpio_free(GPIO_EPM_LVLSFT_EN);
4679
4680 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4681 gpio_free(GPIO_EPM_5V_BOOST_EN);
4682
4683 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4684 gpio_free(GPIO_EPM_3_3V_EN);
4685
4686 rc = regulator_disable(vreg_adc_epm1);
4687 if (rc)
4688 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4689 "Error while enabling regulator for epm s3 %d\n", rc);
4690 regulator_put(vreg_adc_epm1);
4691
4692 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4693 return rc;
4694};
4695
4696unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4697{
4698 int rc = 0;
4699
4700 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4701 cs_enable);
4702
4703 if (cs_enable < 16) {
4704 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4705 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4706 } else {
4707 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4708 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4709 }
4710 return rc;
4711};
4712
4713unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4714{
4715 int rc = 0;
4716
4717 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4718
4719 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4720
4721 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4722
4723 return rc;
4724};
4725#endif
4726
4727static struct msm_adc_channels msm_adc_channels_data[] = {
4728 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4729 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4730 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4731 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4732 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4733 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4734 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4735 CHAN_PATH_TYPE4,
4736 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4737 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4738 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4739 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4740 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4741 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4742 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4743 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4744 CHAN_PATH_TYPE12,
4745 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4746 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4747 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4748 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4749 CHAN_PATH_TYPE_NONE,
4750 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4751 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4752 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4753 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4754 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4755 scale_xtern_chgr_cur},
4756 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4757 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4758 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4759 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4760 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4761 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4762 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4763 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4764 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4765 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4766 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4767 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4768};
4769
4770static char *msm_adc_fluid_device_names[] = {
4771 "ADS_ADC1",
4772 "ADS_ADC2",
4773};
4774
4775static struct msm_adc_platform_data msm_adc_pdata = {
4776 .channel = msm_adc_channels_data,
4777 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4778#if defined(CONFIG_I2C) && \
4779 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4780 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4781 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4782 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4783 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4784#endif
4785};
4786
4787static struct platform_device msm_adc_device = {
4788 .name = "msm_adc",
4789 .id = -1,
4790 .dev = {
4791 .platform_data = &msm_adc_pdata,
4792 },
4793};
4794
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304795static struct msm_rtb_platform_data msm_rtb_pdata = {
4796 .size = SZ_1M,
4797};
4798
4799static int __init msm_rtb_set_buffer_size(char *p)
4800{
4801 int s;
4802
4803 s = memparse(p, NULL);
4804 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4805 return 0;
4806}
4807early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4808
4809
4810static struct platform_device msm_rtb_device = {
4811 .name = "msm_rtb",
4812 .id = -1,
4813 .dev = {
4814 .platform_data = &msm_rtb_pdata,
4815 },
4816};
4817
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004818static void pmic8058_xoadc_mpp_config(void)
4819{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304820 int rc, i;
4821 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304822 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304823 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304824 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304825 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304826 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304827 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304828 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304829 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304830 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304831 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304832 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4833 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304834 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004835
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304836 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4837 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4838 &xoadc_mpps[i].config);
4839 if (rc) {
4840 pr_err("%s: Config MPP %d of PM8058 failed\n",
4841 __func__, xoadc_mpps[i].mpp);
4842 }
4843 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004844}
4845
4846static struct regulator *vreg_ldo18_adc;
4847
4848static int pmic8058_xoadc_vreg_config(int on)
4849{
4850 int rc;
4851
4852 if (on) {
4853 rc = regulator_enable(vreg_ldo18_adc);
4854 if (rc)
4855 pr_err("%s: Enable of regulator ldo18_adc "
4856 "failed\n", __func__);
4857 } else {
4858 rc = regulator_disable(vreg_ldo18_adc);
4859 if (rc)
4860 pr_err("%s: Disable of regulator ldo18_adc "
4861 "failed\n", __func__);
4862 }
4863
4864 return rc;
4865}
4866
4867static int pmic8058_xoadc_vreg_setup(void)
4868{
4869 int rc;
4870
4871 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4872 if (IS_ERR(vreg_ldo18_adc)) {
4873 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4874 __func__, PTR_ERR(vreg_ldo18_adc));
4875 rc = PTR_ERR(vreg_ldo18_adc);
4876 goto fail;
4877 }
4878
4879 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4880 if (rc) {
4881 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4882 goto fail;
4883 }
4884
4885 return rc;
4886fail:
4887 regulator_put(vreg_ldo18_adc);
4888 return rc;
4889}
4890
4891static void pmic8058_xoadc_vreg_shutdown(void)
4892{
4893 regulator_put(vreg_ldo18_adc);
4894}
4895
4896/* usec. For this ADC,
4897 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4898 * Each channel has different configuration, thus at the time of starting
4899 * the conversion, xoadc will return actual conversion time
4900 * */
4901static struct adc_properties pm8058_xoadc_data = {
4902 .adc_reference = 2200, /* milli-voltage for this adc */
4903 .bitresolution = 15,
4904 .bipolar = 0,
4905 .conversiontime = 54,
4906};
4907
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304908static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004909 .xoadc_prop = &pm8058_xoadc_data,
4910 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4911 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4912 .xoadc_num = XOADC_PMIC_0,
4913 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4914 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4915};
4916#endif
4917
4918#ifdef CONFIG_MSM_SDIO_AL
4919
4920static unsigned mdm2ap_status = 140;
4921
4922static int configure_mdm2ap_status(int on)
4923{
4924 int ret = 0;
4925 if (on)
4926 ret = msm_gpiomux_get(mdm2ap_status);
4927 else
4928 ret = msm_gpiomux_put(mdm2ap_status);
4929
4930 if (ret)
4931 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4932 on);
4933
4934 return ret;
4935}
4936
4937
4938static int get_mdm2ap_status(void)
4939{
4940 return gpio_get_value(mdm2ap_status);
4941}
4942
4943static struct sdio_al_platform_data sdio_al_pdata = {
4944 .config_mdm2ap_status = configure_mdm2ap_status,
4945 .get_mdm2ap_status = get_mdm2ap_status,
4946 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004947 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004948 .peer_sdioc_version_major = 0x0004,
4949 .peer_sdioc_boot_version_minor = 0x0001,
4950 .peer_sdioc_boot_version_major = 0x0003
4951};
4952
4953struct platform_device msm_device_sdio_al = {
4954 .name = "msm_sdio_al",
4955 .id = -1,
4956 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004957 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004958 .platform_data = &sdio_al_pdata,
4959 },
4960};
4961
4962#endif /* CONFIG_MSM_SDIO_AL */
4963
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304964#define GPIO_VREG_ID_EXT_5V 0
4965
4966static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4967 REGULATOR_SUPPLY("ext_5v", NULL),
4968 REGULATOR_SUPPLY("8901_mpp0", NULL),
4969};
4970
4971#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4972 [GPIO_VREG_ID_##_id] = { \
4973 .init_data = { \
4974 .constraints = { \
4975 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
4976 }, \
4977 .num_consumer_supplies = \
4978 ARRAY_SIZE(vreg_consumers_##_id), \
4979 .consumer_supplies = vreg_consumers_##_id, \
4980 }, \
4981 .regulator_name = _reg_name, \
4982 .active_low = _active_low, \
4983 .gpio_label = _gpio_label, \
4984 .gpio = _gpio, \
4985 }
4986
4987/* GPIO regulator constraints */
4988static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
4989 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
4990 PM8901_MPP_PM_TO_SYS(0), 0),
4991};
4992
4993/* GPIO regulator */
4994static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
4995 .name = GPIO_REGULATOR_DEV_NAME,
4996 .id = PM8901_MPP_PM_TO_SYS(0),
4997 .dev = {
4998 .platform_data =
4999 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5000 },
5001};
5002
5003static void __init pm8901_vreg_mpp0_init(void)
5004{
5005 int rc;
5006
5007 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5008 .mpp = PM8901_MPP_PM_TO_SYS(0),
5009 .config = {
5010 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5011 .level = PM8901_MPP_DIG_LEVEL_VPH,
5012 },
5013 };
5014
5015 /*
5016 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5017 * implies that the regulator connected to MPP0 is enabled when
5018 * MPP0 is low.
5019 */
5020 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5021 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5022 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5023 } else {
5024 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5025 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5026 }
5027
5028 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5029 if (rc)
5030 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5031}
5032
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005033static struct platform_device *charm_devices[] __initdata = {
5034 &msm_charm_modem,
5035#ifdef CONFIG_MSM_SDIO_AL
5036 &msm_device_sdio_al,
5037#endif
5038};
5039
Lei Zhou338cab82011-08-19 13:38:17 -04005040#ifdef CONFIG_SND_SOC_MSM8660_APQ
5041static struct platform_device *dragon_alsa_devices[] __initdata = {
5042 &msm_pcm,
5043 &msm_pcm_routing,
5044 &msm_cpudai0,
5045 &msm_cpudai1,
5046 &msm_cpudai_hdmi_rx,
5047 &msm_cpudai_bt_rx,
5048 &msm_cpudai_bt_tx,
5049 &msm_cpudai_fm_rx,
5050 &msm_cpudai_fm_tx,
5051 &msm_cpu_fe,
5052 &msm_stub_codec,
5053 &msm_lpa_pcm,
5054};
5055#endif
5056
5057static struct platform_device *asoc_devices[] __initdata = {
5058 &asoc_msm_pcm,
5059 &asoc_msm_dai0,
5060 &asoc_msm_dai1,
5061};
5062
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305063/* qseecom bus scaling */
5064static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
5065 {
5066 .src = MSM_BUS_MASTER_SPS,
5067 .dst = MSM_BUS_SLAVE_EBI_CH0,
5068 .ib = 0,
5069 .ab = 0,
5070 },
5071 {
5072 .src = MSM_BUS_MASTER_SPDM,
5073 .dst = MSM_BUS_SLAVE_SPDM,
5074 .ib = 0,
5075 .ab = 0,
5076 },
5077};
5078
5079static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
5080 {
5081 .src = MSM_BUS_MASTER_SPS,
5082 .dst = MSM_BUS_SLAVE_EBI_CH0,
5083 .ib = (492 * 8) * 1000000UL,
5084 .ab = (492 * 8) * 100000UL,
5085 },
5086 {
5087 .src = MSM_BUS_MASTER_SPDM,
5088 .dst = MSM_BUS_SLAVE_SPDM,
5089 .ib = 0,
5090 .ab = 0,
5091 },
5092};
5093
5094static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
5095 {
5096 .src = MSM_BUS_MASTER_SPS,
5097 .dst = MSM_BUS_SLAVE_EBI_CH0,
5098 .ib = 0,
5099 .ab = 0,
5100 },
5101 {
5102 .src = MSM_BUS_MASTER_SPDM,
5103 .dst = MSM_BUS_SLAVE_SPDM,
5104 .ib = (64 * 8) * 1000000UL,
5105 .ab = (64 * 8) * 100000UL,
5106 },
5107};
5108
5109static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
5110 {
5111 ARRAY_SIZE(qseecom_clks_init_vectors),
5112 qseecom_clks_init_vectors,
5113 },
5114 {
5115 ARRAY_SIZE(qseecom_enable_dfab_vectors),
5116 qseecom_enable_sfpb_vectors,
5117 },
5118 {
5119 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
5120 qseecom_enable_sfpb_vectors,
5121 },
5122};
5123
5124static struct msm_bus_scale_pdata qseecom_bus_pdata = {
5125 .usecase = qseecom_hw_bus_scale_usecases,
5126 .num_usecases = ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
5127 .name = "qsee",
5128};
5129
5130static struct platform_device qseecom_device = {
5131 .name = "qseecom",
5132 .id = -1,
5133 .dev = {
5134 .platform_data = &qseecom_bus_pdata,
5135 },
5136};
5137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005138static struct platform_device *surf_devices[] __initdata = {
Matt Wagantallbf430eb2012-03-22 11:45:49 -07005139 &msm8x60_device_acpuclk,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005140 &msm_device_smd,
5141 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005142 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005143 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005144 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005145 &msm_pil_dsps,
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05305146 &msm_pil_vidc,
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305147 &qseecom_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005148#ifdef CONFIG_I2C_QUP
5149 &msm_gsbi3_qup_i2c_device,
5150 &msm_gsbi4_qup_i2c_device,
5151 &msm_gsbi7_qup_i2c_device,
5152 &msm_gsbi8_qup_i2c_device,
5153 &msm_gsbi9_qup_i2c_device,
5154 &msm_gsbi12_qup_i2c_device,
5155#endif
5156#ifdef CONFIG_SERIAL_MSM_HS
5157 &msm_device_uart_dm1,
5158#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305159#ifdef CONFIG_MSM_SSBI
5160 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305161 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305162#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005163#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005164 &msm_device_ssbi3,
5165#endif
5166#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5167 &isp1763_device,
5168#endif
5169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005170#if defined (CONFIG_MSM_8x60_VOIP)
5171 &asoc_msm_mvs,
5172 &asoc_mvs_dai0,
5173 &asoc_mvs_dai1,
5174#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005175
Lena Salman57d167e2012-03-21 19:46:38 +02005176#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177 &msm_device_otg,
5178#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005179#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005180 &msm_device_gadget_peripheral,
5181#endif
5182#ifdef CONFIG_USB_G_ANDROID
5183 &android_usb_device,
5184#endif
5185#ifdef CONFIG_BATTERY_MSM
5186 &msm_batt_device,
5187#endif
5188#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005189#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005190 &android_pmem_device,
5191 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005192 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005193 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305194#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5195#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005196#ifdef CONFIG_MSM_ROTATOR
5197 &msm_rotator_device,
5198#endif
5199 &msm_fb_device,
5200 &msm_kgsl_3d0,
5201 &msm_kgsl_2d0,
5202 &msm_kgsl_2d1,
5203 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005204#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5205 &lcdc_nt35582_panel_device,
5206#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005207#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5208 &lcdc_samsung_oled_panel_device,
5209#endif
5210#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5211 &lcdc_auo_wvga_panel_device,
5212#endif
5213#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5214 &hdmi_msm_device,
5215#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5216#ifdef CONFIG_FB_MSM_MIPI_DSI
5217 &mipi_dsi_toshiba_panel_device,
5218 &mipi_dsi_novatek_panel_device,
5219#endif
5220#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005221#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005222#ifdef CONFIG_MT9E013
5223 &msm_camera_sensor_mt9e013,
5224#endif
5225#ifdef CONFIG_IMX074
5226 &msm_camera_sensor_imx074,
5227#endif
5228#ifdef CONFIG_WEBCAM_OV7692
5229 &msm_camera_sensor_webcam_ov7692,
5230#endif
5231#ifdef CONFIG_WEBCAM_OV9726
5232 &msm_camera_sensor_webcam_ov9726,
5233#endif
5234#ifdef CONFIG_QS_S5K4E1
5235 &msm_camera_sensor_qs_s5k4e1,
5236#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005237#ifdef CONFIG_VX6953
5238 &msm_camera_sensor_vx6953,
5239#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005241#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005242#ifdef CONFIG_MSM_GEMINI
5243 &msm_gemini_device,
5244#endif
5245#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005246#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005247 &msm_vpe_device,
5248#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005249#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005250
5251#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005252 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253#endif
5254#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005255 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005256#endif
5257 &msm_device_vidc,
5258#if (defined(CONFIG_MARIMBA_CORE)) && \
5259 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5260 &msm_bt_power_device,
5261#endif
5262#ifdef CONFIG_SENSORS_MSM_ADC
5263 &msm_adc_device,
5264#endif
David Collins6f032ba2011-08-31 14:08:15 -07005265 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005266
5267#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5268 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5269 &qcrypto_device,
5270#endif
5271
5272#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5273 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5274 &qcedev_device,
5275#endif
5276
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005277
5278#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5279#ifdef CONFIG_MSM_USE_TSIF1
5280 &msm_device_tsif[1],
5281#else
5282 &msm_device_tsif[0],
5283#endif /* CONFIG_MSM_USE_TSIF1 */
5284#endif /* CONFIG_TSIF */
5285
5286#ifdef CONFIG_HW_RANDOM_MSM
5287 &msm_device_rng,
5288#endif
5289
5290 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005291 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005292#ifdef CONFIG_ION_MSM
5293 &ion_dev,
5294#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005295 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005296 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305297 &msm_rtb_device,
Laura Abbottd92be422012-06-04 15:11:09 -07005298 &msm8660_iommu_domain_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005299};
5300
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005301#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005302#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5303static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5304 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005305 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005306 .request_region = request_smi_region,
5307 .release_region = release_smi_region,
5308 .setup_region = setup_smi_region,
Chintan Pandya490c9712012-08-07 17:19:59 +05305309 .secure_base = SECURE_BASE,
5310 .secure_size = SECURE_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005311 .iommu_map_all = 1,
5312 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005313};
5314
5315static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5316 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005317 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005318 .request_region = request_smi_region,
5319 .release_region = release_smi_region,
5320 .setup_region = setup_smi_region,
5321};
5322
5323static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5324 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005325 .align = PAGE_SIZE,
5326};
5327
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305328static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005329 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005330};
5331
5332static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005333 .adjacent_mem_id = INVALID_HEAP_ID,
5334 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005335};
5336#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005337
5338/**
5339 * These heaps are listed in the order they will be allocated. Due to
5340 * video hardware restrictions and content protection the FW heap has to
5341 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5342 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5343 * away from the base address of the FW heap.
5344 * However, the order of FW heap and MM heap doesn't matter since these
5345 * two heaps are taken care of by separate code to ensure they are adjacent
5346 * to each other.
5347 * Don't swap the order unless you know what you are doing!
5348 */
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -07005349struct ion_platform_heap msm8x60_heaps [] = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005350 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005351 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005352 .type = ION_HEAP_TYPE_SYSTEM,
5353 .name = ION_VMALLOC_HEAP_NAME,
5354 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005355#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5356 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005357 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005358 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005359 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305360 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005361 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005362 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005363 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005364 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005365 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005366 .id = ION_MM_FIRMWARE_HEAP_ID,
5367 .type = ION_HEAP_TYPE_CARVEOUT,
5368 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305369 .base = MSM_MM_FW_BASE,
5370 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005371 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305372 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005373 },
5374 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005375 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005376 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005377 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305378 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005379 .size = MSM_ION_MFC_SIZE,
5380 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005381 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005382 },
5383 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005384 .id = ION_SF_HEAP_ID,
5385 .type = ION_HEAP_TYPE_CARVEOUT,
5386 .name = ION_SF_HEAP_NAME,
5387 .size = MSM_ION_SF_SIZE,
5388 .memory_type = ION_EBI_TYPE,
5389 .extra_data = (void *)&co_ion_pdata,
5390 },
5391 {
5392 .id = ION_CAMERA_HEAP_ID,
5393 .type = ION_HEAP_TYPE_CARVEOUT,
5394 .name = ION_CAMERA_HEAP_NAME,
5395 .size = MSM_ION_CAMERA_SIZE,
5396 .memory_type = ION_EBI_TYPE,
5397 .extra_data = &co_ion_pdata,
5398 },
5399 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005400 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005401 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005402 .name = ION_WB_HEAP_NAME,
5403 .size = MSM_ION_WB_SIZE,
5404 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005405 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005406 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005407 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005408 .id = ION_QSECOM_HEAP_ID,
5409 .type = ION_HEAP_TYPE_CARVEOUT,
5410 .name = ION_QSECOM_HEAP_NAME,
5411 .size = MSM_ION_QSECOM_SIZE,
5412 .memory_type = ION_EBI_TYPE,
5413 .extra_data = (void *) &co_ion_pdata,
5414 },
5415 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005416 .id = ION_AUDIO_HEAP_ID,
5417 .type = ION_HEAP_TYPE_CARVEOUT,
5418 .name = ION_AUDIO_HEAP_NAME,
5419 .size = MSM_ION_AUDIO_SIZE,
5420 .memory_type = ION_EBI_TYPE,
5421 .extra_data = (void *)&co_ion_pdata,
5422 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005423#endif
Benjamin Gaignardb2d367c2012-06-25 15:27:30 -07005424};
5425
5426static struct ion_platform_data ion_pdata = {
5427 .nr = MSM_ION_HEAP_NUM,
5428 .heaps = msm8x60_heaps,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005429};
5430
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005431static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005432 .name = "ion-msm",
5433 .id = 1,
5434 .dev = { .platform_data = &ion_pdata },
5435};
5436#endif
5437
5438
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005439static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5440 /* Kernel SMI memory pool for video core, used for firmware */
5441 /* and encoder, decoder scratch buffers */
5442 /* Kernel SMI memory pool should always precede the user space */
5443 /* SMI memory pool, as the video core will use offset address */
5444 /* from the Firmware base */
5445 [MEMTYPE_SMI_KERNEL] = {
5446 .start = KERNEL_SMI_BASE,
5447 .limit = KERNEL_SMI_SIZE,
5448 .size = KERNEL_SMI_SIZE,
5449 .flags = MEMTYPE_FLAGS_FIXED,
5450 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005451 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005452 },
5453 [MEMTYPE_EBI0] = {
5454 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5455 },
5456 [MEMTYPE_EBI1] = {
5457 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5458 },
5459};
5460
Stephen Boyd668d7652012-04-25 11:31:01 -07005461static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005462{
5463#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005464 unsigned int i;
5465
5466 if (hdmi_is_primary) {
5467 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5468 for (i = 0; i < ion_pdata.nr; i++) {
5469 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5470 ion_pdata.heaps[i].size = msm_ion_sf_size;
5471 pr_debug("msm_ion_sf_size 0x%x\n",
5472 msm_ion_sf_size);
5473 break;
5474 }
5475 }
5476 }
5477
Olav Haugan8726caf2012-05-10 15:11:35 -07005478 /* Verify size of heap is a multiple of 64K */
5479 for (i = 0; i < ion_pdata.nr; i++) {
5480 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5481
Mitchel Humpherysdc4d01d2012-09-13 10:53:22 -07005482 if (heap->extra_data &&
5483 heap->type == (enum ion_heap_type) ION_HEAP_TYPE_CP) {
Olav Haugan8726caf2012-05-10 15:11:35 -07005484 int map_all = ((struct ion_cp_heap_pdata *)
5485 heap->extra_data)->iommu_map_all;
5486
5487 if (map_all && (heap->size & (SZ_64K-1))) {
5488 heap->size = ALIGN(heap->size, SZ_64K);
5489 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5490 heap->name, heap->size);
5491
5492 }
5493 }
5494 }
5495
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005496 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005497 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5498 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005499 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005500 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005501#endif
5502}
5503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005504static void __init size_pmem_devices(void)
5505{
5506#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005507#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005508 android_pmem_adsp_pdata.size = pmem_adsp_size;
5509 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005510
5511 if (hdmi_is_primary)
5512 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005513 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005514 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305515#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5516#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005517}
5518
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305519#ifdef CONFIG_ANDROID_PMEM
5520#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005521static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5522{
5523 msm8x60_reserve_table[p->memory_type].size += p->size;
5524}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305525#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5526#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005527
5528static void __init reserve_pmem_memory(void)
5529{
5530#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005531#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532 reserve_memory_for(&android_pmem_adsp_pdata);
5533 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005534 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005535 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305536#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005537 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305538#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005539}
5540
Huaibin Yanga5419422011-12-08 23:52:10 -08005541static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005542
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305543static void __init reserve_rtb_memory(void)
5544{
5545#if defined(CONFIG_MSM_RTB)
5546 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5547#endif
5548}
5549
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005550static void __init msm8x60_calculate_reserve_sizes(void)
5551{
5552 size_pmem_devices();
5553 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005554 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005555 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305556 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005557}
5558
5559static int msm8x60_paddr_to_memtype(unsigned int paddr)
5560{
5561 if (paddr >= 0x40000000 && paddr < 0x60000000)
5562 return MEMTYPE_EBI1;
5563 if (paddr >= 0x38000000 && paddr < 0x40000000)
5564 return MEMTYPE_SMI;
5565 return MEMTYPE_NONE;
5566}
5567
5568static struct reserve_info msm8x60_reserve_info __initdata = {
5569 .memtype_reserve_table = msm8x60_reserve_table,
5570 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5571 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5572};
5573
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005574static char prim_panel_name[PANEL_NAME_MAX_LEN];
5575static char ext_panel_name[PANEL_NAME_MAX_LEN];
5576static int __init prim_display_setup(char *param)
5577{
5578 if (strnlen(param, PANEL_NAME_MAX_LEN))
5579 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5580 return 0;
5581}
5582early_param("prim_display", prim_display_setup);
5583
5584static int __init ext_display_setup(char *param)
5585{
5586 if (strnlen(param, PANEL_NAME_MAX_LEN))
5587 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5588 return 0;
5589}
5590early_param("ext_display", ext_display_setup);
5591
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005592static void __init msm8x60_reserve(void)
5593{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005594 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005595 reserve_info = &msm8x60_reserve_info;
5596 msm_reserve();
5597}
5598
5599#define EXT_CHG_VALID_MPP 10
5600#define EXT_CHG_VALID_MPP_2 11
5601
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305602static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305603 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305604 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305605 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305606 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5607};
5608
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005609#ifdef CONFIG_ISL9519_CHARGER
5610static int isl_detection_setup(void)
5611{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305612 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005613
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305614 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5615 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5616 &isl_mpp[i].config);
5617 if (ret) {
5618 pr_err("%s: Config MPP %d of PM8058 failed\n",
5619 __func__, isl_mpp[i].mpp);
5620 return ret;
5621 }
5622 }
5623
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005624 return ret;
5625}
5626
5627static struct isl_platform_data isl_data __initdata = {
5628 .chgcurrent = 700,
5629 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5630 .chg_detection_config = isl_detection_setup,
5631 .max_system_voltage = 4200,
5632 .min_system_voltage = 3200,
5633 .term_current = 120,
5634 .input_current = 2048,
5635};
5636
5637static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5638 {
5639 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305640 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005641 .platform_data = &isl_data,
5642 },
5643};
5644#endif
5645
5646#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5647static int smb137b_detection_setup(void)
5648{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305649 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005650
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305651 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5652 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5653 &isl_mpp[i].config);
5654 if (ret) {
5655 pr_err("%s: Config MPP %d of PM8058 failed\n",
5656 __func__, isl_mpp[i].mpp);
5657 return ret;
5658 }
5659 }
5660
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005661 return ret;
5662}
5663
5664static struct smb137b_platform_data smb137b_data __initdata = {
5665 .chg_detection_config = smb137b_detection_setup,
5666 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5667 .batt_mah_rating = 950,
5668};
5669
5670static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5671 {
5672 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305673 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005674 .platform_data = &smb137b_data,
5675 },
5676};
5677#endif
5678
5679#ifdef CONFIG_PMIC8058
5680#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305681#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005682
5683static int pm8058_gpios_init(void)
5684{
5685 int i;
5686 int rc;
5687 struct pm8058_gpio_cfg {
5688 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305689 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005690 };
5691
5692 struct pm8058_gpio_cfg gpio_cfgs[] = {
5693 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305694 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005695 {
5696 .direction = PM_GPIO_DIR_IN,
5697 .pull = PM_GPIO_PULL_DN,
5698 .vin_sel = 2,
5699 .function = PM_GPIO_FUNC_NORMAL,
5700 .inv_int_pol = 0,
5701 },
5702 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005703 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305704 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005705 {
5706 .direction = PM_GPIO_DIR_IN,
5707 .pull = PM_GPIO_PULL_UP_30,
5708 .vin_sel = 2,
5709 .function = PM_GPIO_FUNC_NORMAL,
5710 .inv_int_pol = 0,
5711 },
5712 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005713 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305714 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005715 {
5716 .direction = PM_GPIO_DIR_IN,
5717 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305718 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 .function = PM_GPIO_FUNC_NORMAL,
5720 .inv_int_pol = 0,
5721 },
5722 },
5723 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305724 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725 {
5726 .direction = PM_GPIO_DIR_IN,
5727 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305728 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005729 .function = PM_GPIO_FUNC_NORMAL,
5730 .inv_int_pol = 0,
5731 },
5732 },
5733 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305734 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005735 {
5736 .direction = PM_GPIO_DIR_IN,
5737 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305738 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005739 .function = PM_GPIO_FUNC_NORMAL,
5740 .inv_int_pol = 0,
5741 },
5742 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005743 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305744 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005745 {
5746 .direction = PM_GPIO_DIR_OUT,
5747 .output_value = 1,
5748 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5749 .pull = PM_GPIO_PULL_DN,
5750 .out_strength = PM_GPIO_STRENGTH_HIGH,
5751 .function = PM_GPIO_FUNC_NORMAL,
5752 .vin_sel = 2,
5753 .inv_int_pol = 0,
5754 }
5755 },
5756 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305757 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005758 {
5759 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305760 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005761 .function = PM_GPIO_FUNC_NORMAL,
5762 .vin_sel = 2,
5763 .inv_int_pol = 0,
5764 }
5765 },
5766 };
5767
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305768#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5769 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305770 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305771 .direction = PM_GPIO_DIR_IN,
5772 .pull = PM_GPIO_PULL_UP_1P5,
5773 .vin_sel = 2,
5774 .function = PM_GPIO_FUNC_NORMAL,
5775 };
5776#endif
5777
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005778#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305779 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305780 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305781 .direction = PM_GPIO_DIR_OUT,
5782 .pull = PM_GPIO_PULL_NO,
5783 .out_strength = PM_GPIO_STRENGTH_HIGH,
5784 .function = PM_GPIO_FUNC_NORMAL,
5785 .inv_int_pol = 0,
5786 .vin_sel = 2,
5787 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5788 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 };
5790#endif
5791
5792#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5793 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305794 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005795 {
5796 .direction = PM_GPIO_DIR_IN,
5797 .pull = PM_GPIO_PULL_UP_1P5,
5798 .vin_sel = 2,
5799 .function = PM_GPIO_FUNC_NORMAL,
5800 .inv_int_pol = 0,
5801 }
5802 };
5803#endif
5804
5805#if defined(CONFIG_QS_S5K4E1)
5806 {
5807 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305808 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005809 {
5810 .direction = PM_GPIO_DIR_OUT,
5811 .output_value = 0,
5812 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5813 .pull = PM_GPIO_PULL_DN,
5814 .out_strength = PM_GPIO_STRENGTH_HIGH,
5815 .function = PM_GPIO_FUNC_NORMAL,
5816 .vin_sel = 2,
5817 .inv_int_pol = 0,
5818 }
5819 };
5820#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005821#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5822 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305823 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005824 {
5825 .direction = PM_GPIO_DIR_OUT,
5826 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5827 .output_value = 1,
5828 .pull = PM_GPIO_PULL_UP_30,
5829 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305830 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005831 .out_strength = PM_GPIO_STRENGTH_HIGH,
5832 .function = PM_GPIO_FUNC_NORMAL,
5833 .inv_int_pol = 0,
5834 }
5835 };
5836#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005837#if defined(CONFIG_HAPTIC_ISA1200) || \
5838 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5839 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305840 rc = pm8xxx_gpio_config(
5841 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5842 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005843 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305844 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005845 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305846 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305847 rc = pm8xxx_gpio_config(
5848 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5849 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305850 if (rc < 0) {
5851 pr_err("%s: pmic haptics ldo gpio config failed\n",
5852 __func__);
5853 }
5854
5855 }
5856#endif
5857
5858#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5859 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5860 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5861 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305862 rc = pm8xxx_gpio_config(
5863 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5864 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305865 if (rc < 0) {
5866 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5867 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005868 }
5869 }
5870#endif
5871
5872#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5873 /* Line_in only for 8660 ffa & surf */
5874 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005875 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005876 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305877 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005878 &line_in_gpio_cfg.cfg);
5879 if (rc < 0) {
5880 pr_err("%s pmic line_in gpio config failed\n",
5881 __func__);
5882 return rc;
5883 }
5884 }
5885#endif
5886
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005887#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5888 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305889 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005890 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5891 if (rc < 0) {
5892 pr_err("%s pmic gpio config failed\n", __func__);
5893 return rc;
5894 }
5895 }
5896#endif
5897
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005898#if defined(CONFIG_QS_S5K4E1)
5899 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5900 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305901 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005902 &qs_hc37_cam_pd_gpio_cfg.cfg);
5903 if (rc < 0) {
5904 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5905 __func__);
5906 return rc;
5907 }
5908 }
5909 }
5910#endif
5911
5912 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305913 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005914 &gpio_cfgs[i].cfg);
5915 if (rc < 0) {
5916 pr_err("%s pmic gpio config failed\n",
5917 __func__);
5918 return rc;
5919 }
5920 }
5921
5922 return 0;
5923}
5924
5925static const unsigned int ffa_keymap[] = {
5926 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5927 KEY(0, 1, KEY_UP), /* NAV - UP */
5928 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5929 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5930
5931 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5932 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5933 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5934 KEY(1, 3, KEY_VOLUMEDOWN),
5935
5936 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5937
5938 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5939 KEY(4, 1, KEY_UP), /* USER_UP */
5940 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5941 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5942 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5943
5944 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5945 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5946 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5947 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5948 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5949};
5950
Zhang Chang Ken683be172011-08-10 17:45:34 -04005951static const unsigned int dragon_keymap[] = {
5952 KEY(0, 0, KEY_MENU),
5953 KEY(0, 2, KEY_1),
5954 KEY(0, 3, KEY_4),
5955 KEY(0, 4, KEY_7),
5956
5957 KEY(1, 0, KEY_UP),
5958 KEY(1, 1, KEY_LEFT),
5959 KEY(1, 2, KEY_DOWN),
5960 KEY(1, 3, KEY_5),
5961 KEY(1, 4, KEY_8),
5962
5963 KEY(2, 0, KEY_HOME),
5964 KEY(2, 1, KEY_REPLY),
5965 KEY(2, 2, KEY_2),
5966 KEY(2, 3, KEY_6),
5967 KEY(2, 4, KEY_0),
5968
5969 KEY(3, 0, KEY_VOLUMEUP),
5970 KEY(3, 1, KEY_RIGHT),
5971 KEY(3, 2, KEY_3),
5972 KEY(3, 3, KEY_9),
5973 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5974
5975 KEY(4, 0, KEY_VOLUMEDOWN),
5976 KEY(4, 1, KEY_BACK),
5977 KEY(4, 2, KEY_CAMERA),
5978 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5979};
5980
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005981static struct matrix_keymap_data ffa_keymap_data = {
5982 .keymap_size = ARRAY_SIZE(ffa_keymap),
5983 .keymap = ffa_keymap,
5984};
5985
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305986static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005987 .input_name = "ffa-keypad",
5988 .input_phys_device = "ffa-keypad/input0",
5989 .num_rows = 6,
5990 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305991 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5992 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5993 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005994 .scan_delay_ms = 32,
5995 .row_hold_ns = 91500,
5996 .wakeup = 1,
5997 .keymap_data = &ffa_keymap_data,
5998};
5999
Zhang Chang Ken683be172011-08-10 17:45:34 -04006000static struct matrix_keymap_data dragon_keymap_data = {
6001 .keymap_size = ARRAY_SIZE(dragon_keymap),
6002 .keymap = dragon_keymap,
6003};
6004
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306005static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006006 .input_name = "dragon-keypad",
6007 .input_phys_device = "dragon-keypad/input0",
6008 .num_rows = 6,
6009 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306010 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6011 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6012 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006013 .scan_delay_ms = 32,
6014 .row_hold_ns = 91500,
6015 .wakeup = 1,
6016 .keymap_data = &dragon_keymap_data,
6017};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306018
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006019static const unsigned int fluid_keymap[] = {
6020 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6021 KEY(0, 1, KEY_UP), /* NAV - UP */
6022 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6023 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6024
6025 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6026 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6027 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6028 KEY(1, 3, KEY_VOLUMEUP),
6029
6030 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6031
6032 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6033 KEY(4, 1, KEY_UP), /* USER_UP */
6034 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6035 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6036 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6037
Jilai Wang9a895102011-07-12 14:00:35 -04006038 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006039 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6040 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6041 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6042 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6043};
6044
6045static struct matrix_keymap_data fluid_keymap_data = {
6046 .keymap_size = ARRAY_SIZE(fluid_keymap),
6047 .keymap = fluid_keymap,
6048};
6049
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306050static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006051 .input_name = "fluid-keypad",
6052 .input_phys_device = "fluid-keypad/input0",
6053 .num_rows = 6,
6054 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306055 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6056 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6057 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006058 .scan_delay_ms = 32,
6059 .row_hold_ns = 91500,
6060 .wakeup = 1,
6061 .keymap_data = &fluid_keymap_data,
6062};
6063
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306064static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006065 .initial_vibrate_ms = 500,
6066 .level_mV = 3000,
6067 .max_timeout_ms = 15000,
6068};
6069
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306070static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6071 .rtc_write_enable = false,
6072 .rtc_alarm_powerup = false,
6073};
6074
6075static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6076 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006077 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306078 .wakeup = 1,
6079};
6080
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006081#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6082
6083static struct othc_accessory_info othc_accessories[] = {
6084 {
6085 .accessory = OTHC_SVIDEO_OUT,
6086 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6087 | OTHC_ADC_DETECT,
6088 .key_code = SW_VIDEOOUT_INSERT,
6089 .enabled = false,
6090 .adc_thres = {
6091 .min_threshold = 20,
6092 .max_threshold = 40,
6093 },
6094 },
6095 {
6096 .accessory = OTHC_ANC_HEADPHONE,
6097 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6098 OTHC_SWITCH_DETECT,
6099 .gpio = PM8058_LINE_IN_DET_GPIO,
6100 .active_low = 1,
6101 .key_code = SW_HEADPHONE_INSERT,
6102 .enabled = true,
6103 },
6104 {
6105 .accessory = OTHC_ANC_HEADSET,
6106 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6107 .gpio = PM8058_LINE_IN_DET_GPIO,
6108 .active_low = 1,
6109 .key_code = SW_HEADPHONE_INSERT,
6110 .enabled = true,
6111 },
6112 {
6113 .accessory = OTHC_HEADPHONE,
6114 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6115 .key_code = SW_HEADPHONE_INSERT,
6116 .enabled = true,
6117 },
6118 {
6119 .accessory = OTHC_MICROPHONE,
6120 .detect_flags = OTHC_GPIO_DETECT,
6121 .gpio = PM8058_LINE_IN_DET_GPIO,
6122 .active_low = 1,
6123 .key_code = SW_MICROPHONE_INSERT,
6124 .enabled = true,
6125 },
6126 {
6127 .accessory = OTHC_HEADSET,
6128 .detect_flags = OTHC_MICBIAS_DETECT,
6129 .key_code = SW_HEADPHONE_INSERT,
6130 .enabled = true,
6131 },
6132};
6133
6134static struct othc_switch_info switch_info[] = {
6135 {
6136 .min_adc_threshold = 0,
6137 .max_adc_threshold = 100,
6138 .key_code = KEY_PLAYPAUSE,
6139 },
6140 {
6141 .min_adc_threshold = 100,
6142 .max_adc_threshold = 200,
6143 .key_code = KEY_REWIND,
6144 },
6145 {
6146 .min_adc_threshold = 200,
6147 .max_adc_threshold = 500,
6148 .key_code = KEY_FASTFORWARD,
6149 },
6150};
6151
6152static struct othc_n_switch_config switch_config = {
6153 .voltage_settling_time_ms = 0,
6154 .num_adc_samples = 3,
6155 .adc_channel = CHANNEL_ADC_HDSET,
6156 .switch_info = switch_info,
6157 .num_keys = ARRAY_SIZE(switch_info),
6158 .default_sw_en = true,
6159 .default_sw_idx = 0,
6160};
6161
6162static struct hsed_bias_config hsed_bias_config = {
6163 /* HSED mic bias config info */
6164 .othc_headset = OTHC_HEADSET_NO,
6165 .othc_lowcurr_thresh_uA = 100,
6166 .othc_highcurr_thresh_uA = 600,
6167 .othc_hyst_prediv_us = 7800,
6168 .othc_period_clkdiv_us = 62500,
6169 .othc_hyst_clk_us = 121000,
6170 .othc_period_clk_us = 312500,
6171 .othc_wakeup = 1,
6172};
6173
6174static struct othc_hsed_config hsed_config_1 = {
6175 .hsed_bias_config = &hsed_bias_config,
6176 /*
6177 * The detection delay and switch reporting delay are
6178 * required to encounter a hardware bug (spurious switch
6179 * interrupts on slow insertion/removal of the headset).
6180 * This will introduce a delay in reporting the accessory
6181 * insertion and removal to the userspace.
6182 */
6183 .detection_delay_ms = 1500,
6184 /* Switch info */
6185 .switch_debounce_ms = 1500,
6186 .othc_support_n_switch = false,
6187 .switch_config = &switch_config,
6188 .ir_gpio = -1,
6189 /* Accessory info */
6190 .accessories_support = true,
6191 .accessories = othc_accessories,
6192 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6193};
6194
6195static struct othc_regulator_config othc_reg = {
6196 .regulator = "8058_l5",
6197 .max_uV = 2850000,
6198 .min_uV = 2850000,
6199};
6200
6201/* MIC_BIAS0 is configured as normal MIC BIAS */
6202static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6203 .micbias_select = OTHC_MICBIAS_0,
6204 .micbias_capability = OTHC_MICBIAS,
6205 .micbias_enable = OTHC_SIGNAL_OFF,
6206 .micbias_regulator = &othc_reg,
6207};
6208
6209/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6210static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6211 .micbias_select = OTHC_MICBIAS_1,
6212 .micbias_capability = OTHC_MICBIAS_HSED,
6213 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6214 .micbias_regulator = &othc_reg,
6215 .hsed_config = &hsed_config_1,
6216 .hsed_name = "8660_handset",
6217};
6218
6219/* MIC_BIAS2 is configured as normal MIC BIAS */
6220static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6221 .micbias_select = OTHC_MICBIAS_2,
6222 .micbias_capability = OTHC_MICBIAS,
6223 .micbias_enable = OTHC_SIGNAL_OFF,
6224 .micbias_regulator = &othc_reg,
6225};
6226
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006227
6228static void __init msm8x60_init_pm8058_othc(void)
6229{
6230 int i;
6231
6232 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6233 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6234 machine_is_msm8x60_fusn_ffa()) {
6235 /* 3-switch headset supported only by V2 FFA and FLUID */
6236 hsed_config_1.accessories_adc_support = true,
6237 /* ADC based accessory detection works only on V2 and FLUID */
6238 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6239 hsed_config_1.othc_support_n_switch = true;
6240 }
6241
6242 /* IR GPIO is absent on FLUID */
6243 if (machine_is_msm8x60_fluid())
6244 hsed_config_1.ir_gpio = -1;
6245
6246 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6247 if (machine_is_msm8x60_fluid()) {
6248 switch (othc_accessories[i].accessory) {
6249 case OTHC_ANC_HEADPHONE:
6250 case OTHC_ANC_HEADSET:
6251 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6252 break;
6253 case OTHC_MICROPHONE:
6254 othc_accessories[i].enabled = false;
6255 break;
6256 case OTHC_SVIDEO_OUT:
6257 othc_accessories[i].enabled = true;
6258 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6259 break;
6260 }
6261 }
6262 }
6263}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006264
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006265
6266static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6267{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306268 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006269 .direction = PM_GPIO_DIR_OUT,
6270 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6271 .output_value = 0,
6272 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306273 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006274 .out_strength = PM_GPIO_STRENGTH_HIGH,
6275 .function = PM_GPIO_FUNC_2,
6276 };
6277
6278 int rc = -EINVAL;
6279 int id, mode, max_mA;
6280
6281 id = mode = max_mA = 0;
6282 switch (ch) {
6283 case 0:
6284 case 1:
6285 case 2:
6286 if (on) {
6287 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306288 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6289 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006290 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306291 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006292 __func__, id, rc);
6293 }
6294 break;
6295
6296 case 6:
6297 id = PM_PWM_LED_FLASH;
6298 mode = PM_PWM_CONF_PWM1;
6299 max_mA = 300;
6300 break;
6301
6302 case 7:
6303 id = PM_PWM_LED_FLASH1;
6304 mode = PM_PWM_CONF_PWM1;
6305 max_mA = 300;
6306 break;
6307
6308 default:
6309 break;
6310 }
6311
6312 if (ch >= 6 && ch <= 7) {
6313 if (!on) {
6314 mode = PM_PWM_CONF_NONE;
6315 max_mA = 0;
6316 }
6317 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6318 if (rc)
6319 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6320 __func__, ch, rc);
6321 }
6322 return rc;
6323
6324}
6325
6326static struct pm8058_pwm_pdata pm8058_pwm_data = {
6327 .config = pm8058_pwm_config,
6328};
6329
6330#define PM8058_GPIO_INT 88
6331
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006332static struct pmic8058_led pmic8058_flash_leds[] = {
6333 [0] = {
6334 .name = "camera:flash0",
6335 .max_brightness = 15,
6336 .id = PMIC8058_ID_FLASH_LED_0,
6337 },
6338 [1] = {
6339 .name = "camera:flash1",
6340 .max_brightness = 15,
6341 .id = PMIC8058_ID_FLASH_LED_1,
6342 },
6343};
6344
6345static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6346 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6347 .leds = pmic8058_flash_leds,
6348};
6349
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006350static struct pmic8058_led pmic8058_dragon_leds[] = {
6351 [0] = {
6352 /* RED */
6353 .name = "led_drv0",
6354 .max_brightness = 15,
6355 .id = PMIC8058_ID_LED_0,
6356 },/* 300 mA flash led0 drv sink */
6357 [1] = {
6358 /* Yellow */
6359 .name = "led_drv1",
6360 .max_brightness = 15,
6361 .id = PMIC8058_ID_LED_1,
6362 },/* 300 mA flash led0 drv sink */
6363 [2] = {
6364 /* Green */
6365 .name = "led_drv2",
6366 .max_brightness = 15,
6367 .id = PMIC8058_ID_LED_2,
6368 },/* 300 mA flash led0 drv sink */
6369 [3] = {
6370 .name = "led_psensor",
6371 .max_brightness = 15,
6372 .id = PMIC8058_ID_LED_KB_LIGHT,
6373 },/* 300 mA flash led0 drv sink */
6374};
6375
6376static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6377 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6378 .leds = pmic8058_dragon_leds,
6379};
6380
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006381static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6382 [0] = {
6383 .name = "led:drv0",
6384 .max_brightness = 15,
6385 .id = PMIC8058_ID_FLASH_LED_0,
6386 },/* 300 mA flash led0 drv sink */
6387 [1] = {
6388 .name = "led:drv1",
6389 .max_brightness = 15,
6390 .id = PMIC8058_ID_FLASH_LED_1,
6391 },/* 300 mA flash led1 sink */
6392 [2] = {
6393 .name = "led:drv2",
6394 .max_brightness = 20,
6395 .id = PMIC8058_ID_LED_0,
6396 },/* 40 mA led0 sink */
6397 [3] = {
6398 .name = "keypad:drv",
6399 .max_brightness = 15,
6400 .id = PMIC8058_ID_LED_KB_LIGHT,
6401 },/* 300 mA keypad drv sink */
6402};
6403
6404static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6405 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6406 .leds = pmic8058_fluid_flash_leds,
6407};
6408
Terence Hampson90508a92011-08-09 10:40:08 -04006409static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306410 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006411 .max_source_current = 1800,
6412 .charger_type = CHG_TYPE_AC,
6413};
6414
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306415static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6416 .charger_data_valid = false,
6417};
6418
6419static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6420 .priority = 0,
6421};
6422
6423static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6424 .irq_base = PM8058_IRQ_BASE,
6425 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6426 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6427};
6428
6429static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6430 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6431};
6432
6433static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6434 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006435};
6436
6437static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306438 .irq_pdata = &pm8058_irq_pdata,
6439 .gpio_pdata = &pm8058_gpio_pdata,
6440 .mpp_pdata = &pm8058_mpp_pdata,
6441 .rtc_pdata = &pm8058_rtc_pdata,
6442 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6443 .othc0_pdata = &othc_config_pdata_0,
6444 .othc1_pdata = &othc_config_pdata_1,
6445 .othc2_pdata = &othc_config_pdata_2,
6446 .pwm_pdata = &pm8058_pwm_data,
6447 .misc_pdata = &pm8058_misc_pdata,
6448#ifdef CONFIG_SENSORS_MSM_ADC
6449 .xoadc_pdata = &pm8058_xoadc_pdata,
6450#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006451};
6452
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306453#ifdef CONFIG_MSM_SSBI
6454static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6455 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6456 .slave = {
6457 .name = "pm8058-core",
6458 .platform_data = &pm8058_platform_data,
6459 },
6460};
6461#endif
6462#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006463
6464#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6465 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6466#define TDISC_I2C_SLAVE_ADDR 0x67
6467#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6468#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6469
6470static const char *vregs_tdisc_name[] = {
6471 "8058_l5",
6472 "8058_s3",
6473};
6474
6475static const int vregs_tdisc_val[] = {
6476 2850000,/* uV */
6477 1800000,
6478};
6479static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6480
6481static int tdisc_shinetsu_setup(void)
6482{
6483 int rc, i;
6484
6485 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6486 if (rc) {
6487 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6488 __func__);
6489 return rc;
6490 }
6491
6492 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6493 if (rc) {
6494 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6495 __func__);
6496 goto fail_gpio_oe;
6497 }
6498
6499 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6500 if (rc) {
6501 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6502 __func__);
6503 gpio_free(GPIO_JOYSTICK_EN);
6504 goto fail_gpio_oe;
6505 }
6506
6507 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6508 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6509 if (IS_ERR(vregs_tdisc[i])) {
6510 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6511 __func__, vregs_tdisc_name[i],
6512 PTR_ERR(vregs_tdisc[i]));
6513 rc = PTR_ERR(vregs_tdisc[i]);
6514 goto vreg_get_fail;
6515 }
6516
6517 rc = regulator_set_voltage(vregs_tdisc[i],
6518 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6519 if (rc) {
6520 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6521 __func__, rc);
6522 goto vreg_set_voltage_fail;
6523 }
6524 }
6525
6526 return rc;
6527vreg_set_voltage_fail:
6528 i++;
6529vreg_get_fail:
6530 while (i)
6531 regulator_put(vregs_tdisc[--i]);
6532fail_gpio_oe:
6533 gpio_free(PMIC_GPIO_TDISC);
6534 return rc;
6535}
6536
6537static void tdisc_shinetsu_release(void)
6538{
6539 int i;
6540
6541 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6542 regulator_put(vregs_tdisc[i]);
6543
6544 gpio_free(PMIC_GPIO_TDISC);
6545 gpio_free(GPIO_JOYSTICK_EN);
6546}
6547
6548static int tdisc_shinetsu_enable(void)
6549{
6550 int i, rc = -EINVAL;
6551
6552 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6553 rc = regulator_enable(vregs_tdisc[i]);
6554 if (rc < 0) {
6555 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6556 __func__, vregs_tdisc_name[i], rc);
6557 goto vreg_fail;
6558 }
6559 }
6560
6561 /* Enable the OE (output enable) gpio */
6562 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6563 /* voltage and gpio stabilization delay */
6564 msleep(50);
6565
6566 return 0;
6567vreg_fail:
6568 while (i)
6569 regulator_disable(vregs_tdisc[--i]);
6570 return rc;
6571}
6572
6573static int tdisc_shinetsu_disable(void)
6574{
6575 int i, rc;
6576
6577 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6578 rc = regulator_disable(vregs_tdisc[i]);
6579 if (rc < 0) {
6580 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6581 __func__, vregs_tdisc_name[i], rc);
6582 goto tdisc_reg_fail;
6583 }
6584 }
6585
6586 /* Disable the OE (output enable) gpio */
6587 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6588
6589 return 0;
6590
6591tdisc_reg_fail:
6592 while (i)
6593 regulator_enable(vregs_tdisc[--i]);
6594 return rc;
6595}
6596
6597static struct tdisc_abs_values tdisc_abs = {
6598 .x_max = 32,
6599 .y_max = 32,
6600 .x_min = -32,
6601 .y_min = -32,
6602 .pressure_max = 32,
6603 .pressure_min = 0,
6604};
6605
6606static struct tdisc_platform_data tdisc_data = {
6607 .tdisc_setup = tdisc_shinetsu_setup,
6608 .tdisc_release = tdisc_shinetsu_release,
6609 .tdisc_enable = tdisc_shinetsu_enable,
6610 .tdisc_disable = tdisc_shinetsu_disable,
6611 .tdisc_wakeup = 0,
6612 .tdisc_gpio = PMIC_GPIO_TDISC,
6613 .tdisc_report_keys = true,
6614 .tdisc_report_relative = true,
6615 .tdisc_report_absolute = false,
6616 .tdisc_report_wheel = false,
6617 .tdisc_reverse_x = false,
6618 .tdisc_reverse_y = true,
6619 .tdisc_abs = &tdisc_abs,
6620};
6621
6622static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6623 {
6624 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6625 .irq = TDISC_INT,
6626 .platform_data = &tdisc_data,
6627 },
6628};
6629#endif
6630
6631#define PM_GPIO_CDC_RST_N 20
6632#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6633
6634static struct regulator *vreg_timpani_1;
6635static struct regulator *vreg_timpani_2;
6636
6637static unsigned int msm_timpani_setup_power(void)
6638{
6639 int rc;
6640
6641 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6642 if (IS_ERR(vreg_timpani_1)) {
6643 pr_err("%s: Unable to get 8058_l0\n", __func__);
6644 return -ENODEV;
6645 }
6646
6647 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6648 if (IS_ERR(vreg_timpani_2)) {
6649 pr_err("%s: Unable to get 8058_s3\n", __func__);
6650 regulator_put(vreg_timpani_1);
6651 return -ENODEV;
6652 }
6653
6654 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6655 if (rc) {
6656 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6657 goto fail;
6658 }
6659
6660 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6661 if (rc) {
6662 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6663 goto fail;
6664 }
6665
6666 rc = regulator_enable(vreg_timpani_1);
6667 if (rc) {
6668 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6669 goto fail;
6670 }
6671
6672 /* The settings for LDO0 should be set such that
6673 * it doesn't require to reset the timpani. */
6674 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6675 if (rc < 0) {
6676 pr_err("Timpani regulator optimum mode setting failed\n");
6677 goto fail;
6678 }
6679
6680 rc = regulator_enable(vreg_timpani_2);
6681 if (rc) {
6682 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6683 regulator_disable(vreg_timpani_1);
6684 goto fail;
6685 }
6686
6687 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6688 if (rc) {
6689 pr_err("%s: GPIO Request %d failed\n", __func__,
6690 GPIO_CDC_RST_N);
6691 regulator_disable(vreg_timpani_1);
6692 regulator_disable(vreg_timpani_2);
6693 goto fail;
6694 } else {
6695 gpio_direction_output(GPIO_CDC_RST_N, 1);
6696 usleep_range(1000, 1050);
6697 gpio_direction_output(GPIO_CDC_RST_N, 0);
6698 usleep_range(1000, 1050);
6699 gpio_direction_output(GPIO_CDC_RST_N, 1);
6700 gpio_free(GPIO_CDC_RST_N);
6701 }
6702 return rc;
6703
6704fail:
6705 regulator_put(vreg_timpani_1);
6706 regulator_put(vreg_timpani_2);
6707 return rc;
6708}
6709
6710static void msm_timpani_shutdown_power(void)
6711{
6712 int rc;
6713
6714 rc = regulator_disable(vreg_timpani_1);
6715 if (rc)
6716 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6717
6718 regulator_put(vreg_timpani_1);
6719
6720 rc = regulator_disable(vreg_timpani_2);
6721 if (rc)
6722 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6723
6724 regulator_put(vreg_timpani_2);
6725}
6726
6727/* Power analog function of codec */
6728static struct regulator *vreg_timpani_cdc_apwr;
6729static int msm_timpani_codec_power(int vreg_on)
6730{
6731 int rc = 0;
6732
6733 if (!vreg_timpani_cdc_apwr) {
6734
6735 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6736
6737 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6738 pr_err("%s: vreg_get failed (%ld)\n",
6739 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6740 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6741 return rc;
6742 }
6743 }
6744
6745 if (vreg_on) {
6746
6747 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6748 2200000, 2200000);
6749 if (rc) {
6750 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6751 __func__);
6752 goto vreg_fail;
6753 }
6754
6755 rc = regulator_enable(vreg_timpani_cdc_apwr);
6756 if (rc) {
6757 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6758 goto vreg_fail;
6759 }
6760 } else {
6761 rc = regulator_disable(vreg_timpani_cdc_apwr);
6762 if (rc) {
6763 pr_err("%s: vreg_disable failed %d\n",
6764 __func__, rc);
6765 goto vreg_fail;
6766 }
6767 }
6768
6769 return 0;
6770
6771vreg_fail:
6772 regulator_put(vreg_timpani_cdc_apwr);
6773 vreg_timpani_cdc_apwr = NULL;
6774 return rc;
6775}
6776
6777static struct marimba_codec_platform_data timpani_codec_pdata = {
6778 .marimba_codec_power = msm_timpani_codec_power,
6779};
6780
6781#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6782#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6783
6784static struct marimba_platform_data timpani_pdata = {
6785 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6786 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6787 .marimba_setup = msm_timpani_setup_power,
6788 .marimba_shutdown = msm_timpani_shutdown_power,
6789 .codec = &timpani_codec_pdata,
6790 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6791};
6792
6793#define TIMPANI_I2C_SLAVE_ADDR 0xD
6794
6795static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6796 {
6797 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6798 .platform_data = &timpani_pdata,
6799 },
6800};
6801
Lei Zhou338cab82011-08-19 13:38:17 -04006802#ifdef CONFIG_SND_SOC_WM8903
6803static struct wm8903_platform_data wm8903_pdata = {
6804 .gpio_cfg[2] = 0x3A8,
6805};
6806
6807#define WM8903_I2C_SLAVE_ADDR 0x34
6808static struct i2c_board_info wm8903_codec_i2c_info[] = {
6809 {
6810 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6811 .platform_data = &wm8903_pdata,
6812 },
6813};
6814#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006815#ifdef CONFIG_PMIC8901
6816
6817#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006818/*
6819 * Consumer specific regulator names:
6820 * regulator name consumer dev_name
6821 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006822static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6823 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6824};
6825static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6826 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6827};
6828
6829#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306830 _always_on) \
6831 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006832 .init_data = { \
6833 .constraints = { \
6834 .valid_modes_mask = _modes, \
6835 .valid_ops_mask = _ops, \
6836 .min_uV = _min_uV, \
6837 .max_uV = _max_uV, \
6838 .input_uV = _min_uV, \
6839 .apply_uV = _apply_uV, \
6840 .always_on = _always_on, \
6841 }, \
6842 .consumer_supplies = vreg_consumers_8901_##_id, \
6843 .num_consumer_supplies = \
6844 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6845 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306846 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006847 }
6848
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006849#define PM8901_VREG_INIT_VS(_id) \
6850 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306851 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306853static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006854 PM8901_VREG_INIT_VS(USB_OTG),
6855 PM8901_VREG_INIT_VS(HDMI_MVS),
6856};
6857
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306858static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6859 .priority = 1,
6860};
6861
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306862static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6863 .irq_base = PM8901_IRQ_BASE,
6864 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6865 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6866};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006867
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306868static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6869 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006870};
6871
6872static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306873 .irq_pdata = &pm8901_irq_pdata,
6874 .mpp_pdata = &pm8901_mpp_pdata,
6875 .regulator_pdatas = pm8901_vreg_init,
6876 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306877 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006878};
6879
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306880static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6881 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6882 .slave = {
6883 .name = "pm8901-core",
6884 .platform_data = &pm8901_platform_data,
6885 },
6886};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006887#endif /* CONFIG_PMIC8901 */
6888
6889#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6890 || defined(CONFIG_GPIO_SX150X_MODULE))
6891
6892static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006893static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006894
6895struct bahama_config_register{
6896 u8 reg;
6897 u8 value;
6898 u8 mask;
6899};
6900
6901enum version{
6902 VER_1_0,
6903 VER_2_0,
6904 VER_UNSUPPORTED = 0xFF
6905};
6906
6907static u8 read_bahama_ver(void)
6908{
6909 int rc;
6910 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6911 u8 bahama_version;
6912
6913 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6914 if (rc < 0) {
6915 printk(KERN_ERR
6916 "%s: version read failed: %d\n",
6917 __func__, rc);
6918 return VER_UNSUPPORTED;
6919 } else {
6920 printk(KERN_INFO
6921 "%s: version read got: 0x%x\n",
6922 __func__, bahama_version);
6923 }
6924
6925 switch (bahama_version) {
6926 case 0x08: /* varient of bahama v1 */
6927 case 0x10:
6928 case 0x00:
6929 return VER_1_0;
6930 case 0x09: /* variant of bahama v2 */
6931 return VER_2_0;
6932 default:
6933 return VER_UNSUPPORTED;
6934 }
6935}
6936
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006937static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006938static unsigned int msm_bahama_setup_power(void)
6939{
6940 int rc = 0;
6941 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006942
6943 if (machine_is_msm8x60_dragon())
6944 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6945
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006946 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6947
6948 if (IS_ERR(vreg_bahama)) {
6949 rc = PTR_ERR(vreg_bahama);
6950 pr_err("%s: regulator_get %s = %d\n", __func__,
6951 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006952 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006953 }
6954
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006955 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6956 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6958 msm_bahama_regulator, rc);
6959 goto unget;
6960 }
6961
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006962 rc = regulator_enable(vreg_bahama);
6963 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006964 pr_err("%s: regulator_enable %s = %d\n", __func__,
6965 msm_bahama_regulator, rc);
6966 goto unget;
6967 }
6968
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006969 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6970 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006971 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006972 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006973 goto unenable;
6974 }
6975
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006976 gpio_direction_output(msm_bahama_sys_rst, 0);
6977 usleep_range(1000, 1050);
6978 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6979 usleep_range(1000, 1050);
6980 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006981 return rc;
6982
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006983unenable:
6984 regulator_disable(vreg_bahama);
6985unget:
6986 regulator_put(vreg_bahama);
6987 return rc;
6988};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006989
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006990static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006991{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006992 if (msm_bahama_setup_power_enable) {
6993 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6994 gpio_free(msm_bahama_sys_rst);
6995 regulator_disable(vreg_bahama);
6996 regulator_put(vreg_bahama);
6997 msm_bahama_setup_power_enable = 0;
6998 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006999
7000 return 0;
7001};
7002
7003static unsigned int msm_bahama_core_config(int type)
7004{
7005 int rc = 0;
7006
7007 if (type == BAHAMA_ID) {
7008
7009 int i;
7010 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7011
7012 const struct bahama_config_register v20_init[] = {
7013 /* reg, value, mask */
7014 { 0xF4, 0x84, 0xFF }, /* AREG */
7015 { 0xF0, 0x04, 0xFF } /* DREG */
7016 };
7017
7018 if (read_bahama_ver() == VER_2_0) {
7019 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7020 u8 value = v20_init[i].value;
7021 rc = marimba_write_bit_mask(&config,
7022 v20_init[i].reg,
7023 &value,
7024 sizeof(v20_init[i].value),
7025 v20_init[i].mask);
7026 if (rc < 0) {
7027 printk(KERN_ERR
7028 "%s: reg %d write failed: %d\n",
7029 __func__, v20_init[i].reg, rc);
7030 return rc;
7031 }
7032 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7033 " mask 0x%02x\n",
7034 __func__, v20_init[i].reg,
7035 v20_init[i].value, v20_init[i].mask);
7036 }
7037 }
7038 }
7039 printk(KERN_INFO "core type: %d\n", type);
7040
7041 return rc;
7042}
7043
7044static struct regulator *fm_regulator_s3;
7045static struct msm_xo_voter *fm_clock;
7046
7047static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7048{
7049 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307050 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007051 .direction = PM_GPIO_DIR_IN,
7052 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307053 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007054 .function = PM_GPIO_FUNC_NORMAL,
7055 .inv_int_pol = 0,
7056 };
7057
7058 if (!fm_regulator_s3) {
7059 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7060 if (IS_ERR(fm_regulator_s3)) {
7061 rc = PTR_ERR(fm_regulator_s3);
7062 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7063 __func__, rc);
7064 goto out;
7065 }
7066 }
7067
7068
7069 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7070 if (rc < 0) {
7071 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7072 __func__, rc);
7073 goto fm_fail_put;
7074 }
7075
7076 rc = regulator_enable(fm_regulator_s3);
7077 if (rc < 0) {
7078 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7079 __func__, rc);
7080 goto fm_fail_put;
7081 }
7082
7083 /*Vote for XO clock*/
7084 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7085
7086 if (IS_ERR(fm_clock)) {
7087 rc = PTR_ERR(fm_clock);
7088 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7089 __func__, rc);
7090 goto fm_fail_switch;
7091 }
7092
7093 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7094 if (rc < 0) {
7095 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7096 __func__, rc);
7097 goto fm_fail_vote;
7098 }
7099
7100 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307101 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007102 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307103 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007104 __func__, rc);
7105 goto fm_fail_clock;
7106 }
7107 goto out;
7108
7109fm_fail_clock:
7110 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7111fm_fail_vote:
7112 msm_xo_put(fm_clock);
7113fm_fail_switch:
7114 regulator_disable(fm_regulator_s3);
7115fm_fail_put:
7116 regulator_put(fm_regulator_s3);
7117out:
7118 return rc;
7119};
7120
7121static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7122{
7123 int rc = 0;
7124 if (fm_regulator_s3 != NULL) {
7125 rc = regulator_disable(fm_regulator_s3);
7126 if (rc < 0) {
7127 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7128 __func__, rc);
7129 }
7130 regulator_put(fm_regulator_s3);
7131 fm_regulator_s3 = NULL;
7132 }
7133 printk(KERN_ERR "%s: Voting off for XO", __func__);
7134
7135 if (fm_clock != NULL) {
7136 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7137 if (rc < 0) {
7138 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7139 __func__, rc);
7140 }
7141 msm_xo_put(fm_clock);
7142 }
7143 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7144}
7145
7146/* Slave id address for FM/CDC/QMEMBIST
7147 * Values can be programmed using Marimba slave id 0
7148 * should there be a conflict with other I2C devices
7149 * */
7150#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7151#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7152
7153static struct marimba_fm_platform_data marimba_fm_pdata = {
7154 .fm_setup = fm_radio_setup,
7155 .fm_shutdown = fm_radio_shutdown,
7156 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7157 .is_fm_soc_i2s_master = false,
7158 .config_i2s_gpio = NULL,
7159};
7160
7161/*
7162Just initializing the BAHAMA related slave
7163*/
7164static struct marimba_platform_data marimba_pdata = {
7165 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7166 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7167 .bahama_setup = msm_bahama_setup_power,
7168 .bahama_shutdown = msm_bahama_shutdown_power,
7169 .bahama_core_config = msm_bahama_core_config,
7170 .fm = &marimba_fm_pdata,
7171 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7172};
7173
7174
7175static struct i2c_board_info msm_marimba_board_info[] = {
7176 {
7177 I2C_BOARD_INFO("marimba", 0xc),
7178 .platform_data = &marimba_pdata,
7179 }
7180};
7181#endif /* CONFIG_MAIMBA_CORE */
7182
7183#ifdef CONFIG_I2C
7184#define I2C_SURF 1
7185#define I2C_FFA (1 << 1)
7186#define I2C_RUMI (1 << 2)
7187#define I2C_SIM (1 << 3)
7188#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007189#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007190
7191struct i2c_registry {
7192 u8 machs;
7193 int bus;
7194 struct i2c_board_info *info;
7195 int len;
7196};
7197
7198static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007199#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7200 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007201 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007202 MSM_GSBI8_QUP_I2C_BUS_ID,
7203 core_expander_i2c_info,
7204 ARRAY_SIZE(core_expander_i2c_info),
7205 },
7206 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007207 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007208 MSM_GSBI8_QUP_I2C_BUS_ID,
7209 docking_expander_i2c_info,
7210 ARRAY_SIZE(docking_expander_i2c_info),
7211 },
7212 {
7213 I2C_SURF,
7214 MSM_GSBI8_QUP_I2C_BUS_ID,
7215 surf_expanders_i2c_info,
7216 ARRAY_SIZE(surf_expanders_i2c_info),
7217 },
7218 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007219 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007220 MSM_GSBI3_QUP_I2C_BUS_ID,
7221 fha_expanders_i2c_info,
7222 ARRAY_SIZE(fha_expanders_i2c_info),
7223 },
7224 {
7225 I2C_FLUID,
7226 MSM_GSBI3_QUP_I2C_BUS_ID,
7227 fluid_expanders_i2c_info,
7228 ARRAY_SIZE(fluid_expanders_i2c_info),
7229 },
7230 {
7231 I2C_FLUID,
7232 MSM_GSBI8_QUP_I2C_BUS_ID,
7233 fluid_core_expander_i2c_info,
7234 ARRAY_SIZE(fluid_core_expander_i2c_info),
7235 },
7236#endif
7237#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7238 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7239 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007240 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007241 MSM_GSBI3_QUP_I2C_BUS_ID,
7242 msm_i2c_gsbi3_tdisc_info,
7243 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7244 },
7245#endif
7246 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007247 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007248 MSM_GSBI3_QUP_I2C_BUS_ID,
7249 cy8ctmg200_board_info,
7250 ARRAY_SIZE(cy8ctmg200_board_info),
7251 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007252 {
7253 I2C_DRAGON,
7254 MSM_GSBI3_QUP_I2C_BUS_ID,
7255 cy8ctma340_dragon_board_info,
7256 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7257 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007258#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7259 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007260 {
7261 I2C_FLUID,
7262 MSM_GSBI3_QUP_I2C_BUS_ID,
7263 cyttsp_fluid_info,
7264 ARRAY_SIZE(cyttsp_fluid_info),
7265 },
7266 {
7267 I2C_FFA | I2C_SURF,
7268 MSM_GSBI3_QUP_I2C_BUS_ID,
7269 cyttsp_ffa_info,
7270 ARRAY_SIZE(cyttsp_ffa_info),
7271 },
7272#endif
7273#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007274#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007275 {
7276 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007277 MSM_GSBI4_QUP_I2C_BUS_ID,
7278 msm_camera_boardinfo,
7279 ARRAY_SIZE(msm_camera_boardinfo),
7280 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007281 {
7282 I2C_DRAGON,
7283 MSM_GSBI4_QUP_I2C_BUS_ID,
7284 msm_camera_dragon_boardinfo,
7285 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7286 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007287#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007288#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007289 {
7290 I2C_SURF | I2C_FFA | I2C_FLUID,
7291 MSM_GSBI7_QUP_I2C_BUS_ID,
7292 msm_i2c_gsbi7_timpani_info,
7293 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7294 },
7295#if defined(CONFIG_MARIMBA_CORE)
7296 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007297 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007298 MSM_GSBI7_QUP_I2C_BUS_ID,
7299 msm_marimba_board_info,
7300 ARRAY_SIZE(msm_marimba_board_info),
7301 },
7302#endif /* CONFIG_MARIMBA_CORE */
7303#ifdef CONFIG_ISL9519_CHARGER
7304 {
7305 I2C_SURF | I2C_FFA,
7306 MSM_GSBI8_QUP_I2C_BUS_ID,
7307 isl_charger_i2c_info,
7308 ARRAY_SIZE(isl_charger_i2c_info),
7309 },
7310#endif
7311#if defined(CONFIG_HAPTIC_ISA1200) || \
7312 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7313 {
7314 I2C_FLUID,
7315 MSM_GSBI8_QUP_I2C_BUS_ID,
7316 msm_isa1200_board_info,
7317 ARRAY_SIZE(msm_isa1200_board_info),
7318 },
7319#endif
7320#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7321 {
7322 I2C_FLUID,
7323 MSM_GSBI8_QUP_I2C_BUS_ID,
7324 smb137b_charger_i2c_info,
7325 ARRAY_SIZE(smb137b_charger_i2c_info),
7326 },
7327#endif
7328#if defined(CONFIG_BATTERY_BQ27520) || \
7329 defined(CONFIG_BATTERY_BQ27520_MODULE)
7330 {
7331 I2C_FLUID,
7332 MSM_GSBI8_QUP_I2C_BUS_ID,
7333 msm_bq27520_board_info,
7334 ARRAY_SIZE(msm_bq27520_board_info),
7335 },
7336#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007337#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7338 {
7339 I2C_DRAGON,
7340 MSM_GSBI8_QUP_I2C_BUS_ID,
7341 wm8903_codec_i2c_info,
7342 ARRAY_SIZE(wm8903_codec_i2c_info),
7343 },
7344#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007345};
7346#endif /* CONFIG_I2C */
7347
Stephen Boyd668d7652012-04-25 11:31:01 -07007348static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007349{
7350#ifdef CONFIG_I2C
7351#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7352 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7353 sx150x_data[SX150X_CORE].irq_summary =
7354 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007355 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7356 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007357 sx150x_data[SX150X_CORE].irq_summary =
7358 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7359 else if (machine_is_msm8x60_fluid())
7360 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7361 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7362#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007363#endif
7364}
7365
Stephen Boyd668d7652012-04-25 11:31:01 -07007366static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007367{
7368#ifdef CONFIG_I2C
7369 u8 mach_mask = 0;
7370 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007371#ifdef CONFIG_MSM_CAMERA_V4L2
7372 struct i2c_registry msm8x60_camera_i2c_devices = {
7373 I2C_SURF | I2C_FFA | I2C_FLUID,
7374 MSM_GSBI4_QUP_I2C_BUS_ID,
7375 msm8x60_camera_board_info.board_info,
7376 msm8x60_camera_board_info.num_i2c_board_info,
7377 };
7378#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007379
7380 /* Build the matching 'supported_machs' bitmask */
7381 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7382 mach_mask = I2C_SURF;
7383 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7384 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007385 else if (machine_is_msm8x60_fluid())
7386 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007387 else if (machine_is_msm8x60_dragon())
7388 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007389 else
7390 pr_err("unmatched machine ID in register_i2c_devices\n");
7391
7392 /* Run the array and install devices as appropriate */
7393 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7394 if (msm8x60_i2c_devices[i].machs & mach_mask)
7395 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7396 msm8x60_i2c_devices[i].info,
7397 msm8x60_i2c_devices[i].len);
7398 }
Kevin Chan3be11612012-03-22 20:05:40 -07007399#ifdef CONFIG_MSM_CAMERA_V4L2
7400 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7401 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7402 msm8x60_camera_i2c_devices.info,
7403 msm8x60_camera_i2c_devices.len);
7404#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007405#endif
7406}
7407
7408static void __init msm8x60_init_uart12dm(void)
7409{
7410#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7411 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7412 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7413
7414 if (!fpga_mem)
7415 pr_err("%s(): Error getting memory\n", __func__);
7416
7417 /* Advanced mode */
7418 writew(0xFFFF, fpga_mem + 0x15C);
7419 /* FPGA_UART_SEL */
7420 writew(0, fpga_mem + 0x172);
7421 /* FPGA_GPIO_CONFIG_117 */
7422 writew(1, fpga_mem + 0xEA);
7423 /* FPGA_GPIO_CONFIG_118 */
7424 writew(1, fpga_mem + 0xEC);
7425 mb();
7426 iounmap(fpga_mem);
7427#endif
7428}
7429
7430#define MSM_GSBI9_PHYS 0x19900000
7431#define GSBI_DUAL_MODE_CODE 0x60
7432
7433static void __init msm8x60_init_buses(void)
7434{
7435#ifdef CONFIG_I2C_QUP
7436 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7437 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7438 writel_relaxed(0x6 << 4, gsbi_mem);
7439 /* Ensure protocol code is written before proceeding further */
7440 mb();
7441 iounmap(gsbi_mem);
7442
7443 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7444 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7445 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7446 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7447
7448#ifdef CONFIG_MSM_GSBI9_UART
7449 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7450 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7451 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7452 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7453 iounmap(gsbi_mem);
7454 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7455 }
7456#endif
7457 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7458 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7459#endif
7460#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7461 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7462#endif
7463#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007464 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7465#endif
7466
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307467#ifdef CONFIG_MSM_SSBI
7468 msm_device_ssbi_pmic1.dev.platform_data =
7469 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307470 msm_device_ssbi_pmic2.dev.platform_data =
7471 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307472#endif
7473
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007474 if (machine_is_msm8x60_fluid()) {
7475#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7476 (defined(CONFIG_SMB137B_CHARGER) || \
7477 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7478 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7479#endif
7480#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7481 msm_gsbi10_qup_spi_device.dev.platform_data =
7482 &msm_gsbi10_qup_spi_pdata;
7483#endif
7484 }
7485
Lena Salman57d167e2012-03-21 19:46:38 +02007486#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007487 /*
7488 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7489 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7490 * and ID notifications are available only on V2 surf and FFA
7491 * with a hardware workaround.
7492 */
7493 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7494 (machine_is_msm8x60_surf() ||
7495 (machine_is_msm8x60_ffa() &&
7496 pmic_id_notif_supported)))
7497 msm_otg_pdata.phy_can_powercollapse = 1;
7498 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7499#endif
7500
Lena Salman57d167e2012-03-21 19:46:38 +02007501#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007502 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7503#endif
7504
7505#ifdef CONFIG_SERIAL_MSM_HS
7506 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7507 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7508#endif
7509#ifdef CONFIG_MSM_GSBI9_UART
7510 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7511 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7512 if (IS_ERR(msm_device_uart_gsbi9))
7513 pr_err("%s(): Failed to create uart gsbi9 device\n",
7514 __func__);
7515 }
7516#endif
7517
7518#ifdef CONFIG_MSM_BUS_SCALING
7519
7520 /* RPM calls are only enabled on V2 */
7521 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7522 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7523 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7524 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7525 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7526 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7527 }
7528
7529 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7530 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7531 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7532 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7533 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7534#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007535}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007536
7537static void __init msm8x60_map_io(void)
7538{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007539 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007540 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007541
7542 if (socinfo_init() < 0)
7543 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007544}
7545
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007546/*
7547 * Most segments of the EBI2 bus are disabled by default.
7548 */
7549static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007550{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007551 uint32_t ebi2_cfg;
7552 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007553 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007554
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007555 if (IS_ERR(mem_clk)) {
7556 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7557 "msm_ebi2", "mem_clk");
7558 return;
7559 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007560 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007561 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007562
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007563 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7564 if (ebi2_cfg_ptr != 0) {
7565 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007567 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007568 machine_is_msm8x60_fluid() ||
7569 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007570 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007571
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007572 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7573 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007574 }
7575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007576 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007577 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007578 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7579 if (ebi2_cfg_ptr != 0) {
7580 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7581 writel_relaxed(0UL, ebi2_cfg_ptr);
7582
7583 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7584 * LAN9221 Ethernet controller reads and writes.
7585 * The lowest 4 bits are the read delay, the next
7586 * 4 are the write delay. */
7587 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7588#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7589 /*
7590 * RECOVERY=5, HOLD_WR=1
7591 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7592 * WAIT_WR=1, WAIT_RD=2
7593 */
7594 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7595 /*
7596 * HOLD_RD=1
7597 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7598 */
7599 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7600#else
7601 /* EBI2 CS3 muxed address/data,
7602 * two cyc addr enable */
7603 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7604
7605#endif
7606 iounmap(ebi2_cfg_ptr);
7607 }
7608 }
David Brown56e2d8a2011-08-04 02:01:02 -07007609}
7610
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007611#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7612 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7613 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7614 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7615 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7616
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007617/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007618#define MAX_SDCC_CONTROLLER 5
7619
7620struct msm_sdcc_gpio {
7621 /* maximum 10 GPIOs per SDCC controller */
7622 s16 no;
7623 /* name of this GPIO */
7624 const char *name;
7625 bool always_on;
7626 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007627};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007628
7629#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7630static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7631 {159, "sdc1_dat_0"},
7632 {160, "sdc1_dat_1"},
7633 {161, "sdc1_dat_2"},
7634 {162, "sdc1_dat_3"},
7635#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7636 {163, "sdc1_dat_4"},
7637 {164, "sdc1_dat_5"},
7638 {165, "sdc1_dat_6"},
7639 {166, "sdc1_dat_7"},
7640#endif
7641 {167, "sdc1_clk"},
7642 {168, "sdc1_cmd"}
7643};
7644#endif
7645
7646#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7647static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7648 {143, "sdc2_dat_0"},
7649 {144, "sdc2_dat_1", 1},
7650 {145, "sdc2_dat_2"},
7651 {146, "sdc2_dat_3"},
7652#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7653 {147, "sdc2_dat_4"},
7654 {148, "sdc2_dat_5"},
7655 {149, "sdc2_dat_6"},
7656 {150, "sdc2_dat_7"},
7657#endif
7658 {151, "sdc2_cmd"},
7659 {152, "sdc2_clk", 1}
7660};
7661#endif
7662
7663#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7664static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7665 {95, "sdc5_cmd"},
7666 {96, "sdc5_dat_3"},
7667 {97, "sdc5_clk", 1},
7668 {98, "sdc5_dat_2"},
7669 {99, "sdc5_dat_1", 1},
7670 {100, "sdc5_dat_0"}
7671};
7672#endif
7673
7674struct msm_sdcc_pad_pull_cfg {
7675 enum msm_tlmm_pull_tgt pull;
7676 u32 pull_val;
7677};
7678
7679struct msm_sdcc_pad_drv_cfg {
7680 enum msm_tlmm_hdrive_tgt drv;
7681 u32 drv_val;
7682};
7683
7684#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7685static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7686 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7687 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7688 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7689};
7690
7691static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7692 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7693 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7694};
7695
7696static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7697 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7698 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7699 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7700};
7701
7702static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7703 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7704 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7705};
7706#endif
7707
7708#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7709static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7710 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7711 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7712 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7713};
7714
7715static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7716 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7717 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7718};
7719
7720static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7721 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7722 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7723 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7724};
7725
7726static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7727 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7728 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7729};
7730#endif
7731
7732struct msm_sdcc_pin_cfg {
7733 /*
7734 * = 1 if controller pins are using gpios
7735 * = 0 if controller has dedicated MSM pins
7736 */
7737 u8 is_gpio;
7738 u8 cfg_sts;
7739 u8 gpio_data_size;
7740 struct msm_sdcc_gpio *gpio_data;
7741 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7742 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7743 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7744 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7745 u8 pad_drv_data_size;
7746 u8 pad_pull_data_size;
7747 u8 sdio_lpm_gpio_cfg;
7748};
7749
7750
7751static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7752#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7753 [0] = {
7754 .is_gpio = 1,
7755 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7756 .gpio_data = sdc1_gpio_cfg
7757 },
7758#endif
7759#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7760 [1] = {
7761 .is_gpio = 1,
7762 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7763 .gpio_data = sdc2_gpio_cfg
7764 },
7765#endif
7766#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7767 [2] = {
7768 .is_gpio = 0,
7769 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7770 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7771 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7772 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7773 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7774 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7775 },
7776#endif
7777#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7778 [3] = {
7779 .is_gpio = 0,
7780 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7781 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7782 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7783 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7784 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7785 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7786 },
7787#endif
7788#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7789 [4] = {
7790 .is_gpio = 1,
7791 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7792 .gpio_data = sdc5_gpio_cfg
7793 }
7794#endif
7795};
7796
7797static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7798{
7799 int rc = 0;
7800 struct msm_sdcc_pin_cfg *curr;
7801 int n;
7802
7803 curr = &sdcc_pin_cfg_data[dev_id - 1];
7804 if (!curr->gpio_data)
7805 goto out;
7806
7807 for (n = 0; n < curr->gpio_data_size; n++) {
7808 if (enable) {
7809
7810 if (curr->gpio_data[n].always_on &&
7811 curr->gpio_data[n].is_enabled)
7812 continue;
7813 pr_debug("%s: enable: %s\n", __func__,
7814 curr->gpio_data[n].name);
7815 rc = gpio_request(curr->gpio_data[n].no,
7816 curr->gpio_data[n].name);
7817 if (rc) {
7818 pr_err("%s: gpio_request(%d, %s)"
7819 "failed", __func__,
7820 curr->gpio_data[n].no,
7821 curr->gpio_data[n].name);
7822 goto free_gpios;
7823 }
7824 /* set direction as output for all GPIOs */
7825 rc = gpio_direction_output(
7826 curr->gpio_data[n].no, 1);
7827 if (rc) {
7828 pr_err("%s: gpio_direction_output"
7829 "(%d, 1) failed\n", __func__,
7830 curr->gpio_data[n].no);
7831 goto free_gpios;
7832 }
7833 curr->gpio_data[n].is_enabled = 1;
7834 } else {
7835 /*
7836 * now free this GPIO which will put GPIO
7837 * in low power mode and will also put GPIO
7838 * in input mode
7839 */
7840 if (curr->gpio_data[n].always_on)
7841 continue;
7842 pr_debug("%s: disable: %s\n", __func__,
7843 curr->gpio_data[n].name);
7844 gpio_free(curr->gpio_data[n].no);
7845 curr->gpio_data[n].is_enabled = 0;
7846 }
7847 }
7848 curr->cfg_sts = enable;
7849 goto out;
7850
7851free_gpios:
7852 for (; n >= 0; n--)
7853 gpio_free(curr->gpio_data[n].no);
7854out:
7855 return rc;
7856}
7857
7858static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7859{
7860 int rc = 0;
7861 struct msm_sdcc_pin_cfg *curr;
7862 int n;
7863
7864 curr = &sdcc_pin_cfg_data[dev_id - 1];
7865 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7866 goto out;
7867
7868 if (enable) {
7869 /*
7870 * set up the normal driver strength and
7871 * pull config for pads
7872 */
7873 for (n = 0; n < curr->pad_drv_data_size; n++) {
7874 if (curr->sdio_lpm_gpio_cfg) {
7875 if (curr->pad_drv_on_data[n].drv ==
7876 TLMM_HDRV_SDC4_DATA)
7877 continue;
7878 }
7879 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7880 curr->pad_drv_on_data[n].drv_val);
7881 }
7882 for (n = 0; n < curr->pad_pull_data_size; n++) {
7883 if (curr->sdio_lpm_gpio_cfg) {
7884 if (curr->pad_pull_on_data[n].pull ==
7885 TLMM_PULL_SDC4_DATA)
7886 continue;
7887 }
7888 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7889 curr->pad_pull_on_data[n].pull_val);
7890 }
7891 } else {
7892 /* set the low power config for pads */
7893 for (n = 0; n < curr->pad_drv_data_size; n++) {
7894 if (curr->sdio_lpm_gpio_cfg) {
7895 if (curr->pad_drv_off_data[n].drv ==
7896 TLMM_HDRV_SDC4_DATA)
7897 continue;
7898 }
7899 msm_tlmm_set_hdrive(
7900 curr->pad_drv_off_data[n].drv,
7901 curr->pad_drv_off_data[n].drv_val);
7902 }
7903 for (n = 0; n < curr->pad_pull_data_size; n++) {
7904 if (curr->sdio_lpm_gpio_cfg) {
7905 if (curr->pad_pull_off_data[n].pull ==
7906 TLMM_PULL_SDC4_DATA)
7907 continue;
7908 }
7909 msm_tlmm_set_pull(
7910 curr->pad_pull_off_data[n].pull,
7911 curr->pad_pull_off_data[n].pull_val);
7912 }
7913 }
7914 curr->cfg_sts = enable;
7915out:
7916 return rc;
7917}
7918
7919struct sdcc_reg {
7920 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7921 const char *reg_name;
7922 /*
7923 * is set voltage supported for this regulator?
7924 * 0 = not supported, 1 = supported
7925 */
7926 unsigned char set_voltage_sup;
7927 /* voltage level to be set */
7928 unsigned int level;
7929 /* VDD/VCC/VCCQ voltage regulator handle */
7930 struct regulator *reg;
7931 /* is this regulator enabled? */
7932 bool enabled;
7933 /* is this regulator needs to be always on? */
7934 bool always_on;
7935 /* is operating power mode setting required for this regulator? */
7936 bool op_pwr_mode_sup;
7937 /* Load values for low power and high power mode */
7938 unsigned int lpm_uA;
7939 unsigned int hpm_uA;
7940};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007941/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007942static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7943/* only SDCC1 requires VCCQ voltage */
7944static struct sdcc_reg sdcc_vccq_reg_data[1];
7945/* all SDCC controllers may require voting for VDD PAD voltage */
7946static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7947
7948struct sdcc_reg_data {
7949 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7950 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7951 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7952 unsigned char sts; /* regulator enable/disable status */
7953};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007954/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007955static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7956
7957static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7958{
7959 int rc = 0;
7960
7961 /* Get the regulator handle */
7962 vreg->reg = regulator_get(NULL, vreg->reg_name);
7963 if (IS_ERR(vreg->reg)) {
7964 rc = PTR_ERR(vreg->reg);
7965 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7966 __func__, vreg->reg_name, rc);
7967 goto out;
7968 }
7969
7970 /* Set the voltage level if required */
7971 if (vreg->set_voltage_sup) {
7972 rc = regulator_set_voltage(vreg->reg, vreg->level,
7973 vreg->level);
7974 if (rc) {
7975 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7976 __func__, vreg->reg_name, rc);
7977 goto vreg_put;
7978 }
7979 }
7980 goto out;
7981
7982vreg_put:
7983 regulator_put(vreg->reg);
7984out:
7985 return rc;
7986}
7987
7988static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7989{
7990 regulator_put(vreg->reg);
7991}
7992
7993/* this init function should be called only once for each SDCC */
7994static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7995{
7996 int rc = 0;
7997 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7998 struct sdcc_reg_data *curr;
7999
8000 curr = &sdcc_vreg_data[dev_id - 1];
8001 curr_vdd_reg = curr->vdd_data;
8002 curr_vccq_reg = curr->vccq_data;
8003 curr_vddp_reg = curr->vddp_data;
8004
8005 if (init) {
8006 /*
8007 * get the regulator handle from voltage regulator framework
8008 * and then try to set the voltage level for the regulator
8009 */
8010 if (curr_vdd_reg) {
8011 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8012 if (rc)
8013 goto out;
8014 }
8015 if (curr_vccq_reg) {
8016 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8017 if (rc)
8018 goto vdd_reg_deinit;
8019 }
8020 if (curr_vddp_reg) {
8021 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8022 if (rc)
8023 goto vccq_reg_deinit;
8024 }
8025 goto out;
8026 } else
8027 /* deregister with all regulators from regulator framework */
8028 goto vddp_reg_deinit;
8029
8030vddp_reg_deinit:
8031 if (curr_vddp_reg)
8032 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8033vccq_reg_deinit:
8034 if (curr_vccq_reg)
8035 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8036vdd_reg_deinit:
8037 if (curr_vdd_reg)
8038 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8039out:
8040 return rc;
8041}
8042
8043static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8044{
8045 int rc;
8046
8047 if (!vreg->enabled) {
8048 rc = regulator_enable(vreg->reg);
8049 if (rc) {
8050 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8051 __func__, vreg->reg_name, rc);
8052 goto out;
8053 }
8054 vreg->enabled = 1;
8055 }
8056
8057 /* Put always_on regulator in HPM (high power mode) */
8058 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8059 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8060 if (rc < 0) {
8061 pr_err("%s: reg=%s: HPM setting failed"
8062 " hpm_uA=%d, rc=%d\n",
8063 __func__, vreg->reg_name,
8064 vreg->hpm_uA, rc);
8065 goto vreg_disable;
8066 }
8067 rc = 0;
8068 }
8069 goto out;
8070
8071vreg_disable:
8072 regulator_disable(vreg->reg);
8073 vreg->enabled = 0;
8074out:
8075 return rc;
8076}
8077
8078static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8079{
8080 int rc;
8081
8082 /* Never disable always_on regulator */
8083 if (!vreg->always_on) {
8084 rc = regulator_disable(vreg->reg);
8085 if (rc) {
8086 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8087 __func__, vreg->reg_name, rc);
8088 goto out;
8089 }
8090 vreg->enabled = 0;
8091 }
8092
8093 /* Put always_on regulator in LPM (low power mode) */
8094 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8095 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8096 if (rc < 0) {
8097 pr_err("%s: reg=%s: LPM setting failed"
8098 " lpm_uA=%d, rc=%d\n",
8099 __func__,
8100 vreg->reg_name,
8101 vreg->lpm_uA, rc);
8102 goto out;
8103 }
8104 rc = 0;
8105 }
8106
8107out:
8108 return rc;
8109}
8110
8111static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8112{
8113 int rc = 0;
8114 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8115 struct sdcc_reg_data *curr;
8116
8117 curr = &sdcc_vreg_data[dev_id - 1];
8118 curr_vdd_reg = curr->vdd_data;
8119 curr_vccq_reg = curr->vccq_data;
8120 curr_vddp_reg = curr->vddp_data;
8121
8122 /* check if regulators are initialized or not? */
8123 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8124 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8125 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8126 /* initialize voltage regulators required for this SDCC */
8127 rc = msm_sdcc_vreg_init(dev_id, 1);
8128 if (rc) {
8129 pr_err("%s: regulator init failed = %d\n",
8130 __func__, rc);
8131 goto out;
8132 }
8133 }
8134
8135 if (curr->sts == enable)
8136 goto out;
8137
8138 if (curr_vdd_reg) {
8139 if (enable)
8140 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8141 else
8142 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8143 if (rc)
8144 goto out;
8145 }
8146
8147 if (curr_vccq_reg) {
8148 if (enable)
8149 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8150 else
8151 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8152 if (rc)
8153 goto out;
8154 }
8155
8156 if (curr_vddp_reg) {
8157 if (enable)
8158 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8159 else
8160 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8161 if (rc)
8162 goto out;
8163 }
8164 curr->sts = enable;
8165
8166out:
8167 return rc;
8168}
8169
8170static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8171{
8172 u32 rc_pin_cfg = 0;
8173 u32 rc_vreg_cfg = 0;
8174 u32 rc = 0;
8175 struct platform_device *pdev;
8176 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8177
8178 pdev = container_of(dv, struct platform_device, dev);
8179
8180 /* setup gpio/pad */
8181 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8182 if (curr_pin_cfg->cfg_sts == !!vdd)
8183 goto setup_vreg;
8184
8185 if (curr_pin_cfg->is_gpio)
8186 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8187 else
8188 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8189
8190setup_vreg:
8191 /* setup voltage regulators */
8192 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8193
8194 if (rc_pin_cfg || rc_vreg_cfg)
8195 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8196
8197 return rc;
8198}
8199
8200static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8201{
8202 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8203 struct platform_device *pdev;
8204
8205 pdev = container_of(dv, struct platform_device, dev);
8206 /* setup gpio/pad */
8207 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8208
8209 if (curr_pin_cfg->cfg_sts == active)
8210 return;
8211
8212 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8213 if (curr_pin_cfg->is_gpio)
8214 msm_sdcc_setup_gpio(pdev->id, active);
8215 else
8216 msm_sdcc_setup_pad(pdev->id, active);
8217 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8218}
8219
8220static int msm_sdc3_get_wpswitch(struct device *dev)
8221{
8222 struct platform_device *pdev;
8223 int status;
8224 pdev = container_of(dev, struct platform_device, dev);
8225
8226 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8227 if (status) {
8228 pr_err("%s:Failed to request GPIO %d\n",
8229 __func__, GPIO_SDC_WP);
8230 } else {
8231 status = gpio_direction_input(GPIO_SDC_WP);
8232 if (!status) {
8233 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8234 pr_info("%s: WP Status for Slot %d = %d\n",
8235 __func__, pdev->id, status);
8236 }
8237 gpio_free(GPIO_SDC_WP);
8238 }
8239 return status;
8240}
8241
8242#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8243int sdc5_register_status_notify(void (*callback)(int, void *),
8244 void *dev_id)
8245{
8246 sdc5_status_notify_cb = callback;
8247 sdc5_status_notify_cb_devid = dev_id;
8248 return 0;
8249}
8250#endif
8251
8252#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8253int sdc2_register_status_notify(void (*callback)(int, void *),
8254 void *dev_id)
8255{
8256 sdc2_status_notify_cb = callback;
8257 sdc2_status_notify_cb_devid = dev_id;
8258 return 0;
8259}
8260#endif
8261
8262/* Interrupt handler for SDC2 and SDC5 detection
8263 * This function uses dual-edge interrputs settings in order
8264 * to get SDIO detection when the GPIO is rising and SDIO removal
8265 * when the GPIO is falling */
8266static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8267{
8268 int status;
8269
8270 if (!machine_is_msm8x60_fusion() &&
8271 !machine_is_msm8x60_fusn_ffa())
8272 return IRQ_NONE;
8273
8274 status = gpio_get_value(MDM2AP_SYNC);
8275 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8276 __func__, status);
8277
8278#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8279 if (sdc2_status_notify_cb) {
8280 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8281 sdc2_status_notify_cb(status,
8282 sdc2_status_notify_cb_devid);
8283 }
8284#endif
8285
8286#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8287 if (sdc5_status_notify_cb) {
8288 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8289 sdc5_status_notify_cb(status,
8290 sdc5_status_notify_cb_devid);
8291 }
8292#endif
8293 return IRQ_HANDLED;
8294}
8295
8296static int msm8x60_multi_sdio_init(void)
8297{
8298 int ret, irq_num;
8299
8300 if (!machine_is_msm8x60_fusion() &&
8301 !machine_is_msm8x60_fusn_ffa())
8302 return 0;
8303
8304 ret = msm_gpiomux_get(MDM2AP_SYNC);
8305 if (ret) {
8306 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8307 __func__, MDM2AP_SYNC, ret);
8308 return ret;
8309 }
8310
8311 irq_num = gpio_to_irq(MDM2AP_SYNC);
8312
8313 ret = request_irq(irq_num,
8314 msm8x60_multi_sdio_slot_status_irq,
8315 IRQ_TYPE_EDGE_BOTH,
8316 "sdio_multidetection", NULL);
8317
8318 if (ret) {
8319 pr_err("%s:Failed to request irq, ret=%d\n",
8320 __func__, ret);
8321 return ret;
8322 }
8323
8324 return ret;
8325}
8326
8327#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008328static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8329{
8330 int status;
8331
8332 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8333 , "SD_HW_Detect");
8334 if (status) {
8335 pr_err("%s:Failed to request GPIO %d\n", __func__,
8336 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8337 } else {
8338 status = gpio_direction_input(
8339 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8340 if (!status)
8341 status = !(gpio_get_value_cansleep(
8342 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8343 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8344 }
8345 return (unsigned int) status;
8346}
8347#endif
8348#endif
8349
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308350#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308351#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008352
8353#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8354static struct mmc_platform_data msm8x60_sdc1_data = {
8355 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8356 .translate_vdd = msm_sdcc_setup_power,
8357#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8358 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8359#else
8360 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8361#endif
8362 .msmsdcc_fmin = 400000,
8363 .msmsdcc_fmid = 24000000,
8364 .msmsdcc_fmax = 48000000,
8365 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308366 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008367};
8368#endif
8369
8370#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8371static struct mmc_platform_data msm8x60_sdc2_data = {
8372 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8373 .translate_vdd = msm_sdcc_setup_power,
8374 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8375 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8376 .msmsdcc_fmin = 400000,
8377 .msmsdcc_fmid = 24000000,
8378 .msmsdcc_fmax = 48000000,
8379 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008380 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008381#ifdef CONFIG_MSM_SDIO_AL
8382 .is_sdio_al_client = 1,
8383#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308384 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008385};
8386#endif
8387
8388#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8389static struct mmc_platform_data msm8x60_sdc3_data = {
8390 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8391 .translate_vdd = msm_sdcc_setup_power,
8392 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8393 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008394 .status = msm8x60_sdcc_slot_status,
8395 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8396 PMIC_GPIO_SDC3_DET - 1),
8397 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008398 .msmsdcc_fmin = 400000,
8399 .msmsdcc_fmid = 24000000,
8400 .msmsdcc_fmax = 48000000,
8401 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308402 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308403 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008404};
8405#endif
8406
8407#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8408static struct mmc_platform_data msm8x60_sdc4_data = {
8409 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8410 .translate_vdd = msm_sdcc_setup_power,
8411 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8412 .msmsdcc_fmin = 400000,
8413 .msmsdcc_fmid = 24000000,
8414 .msmsdcc_fmax = 48000000,
8415 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308416 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308417 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008418};
8419#endif
8420
8421#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8422static struct mmc_platform_data msm8x60_sdc5_data = {
8423 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8424 .translate_vdd = msm_sdcc_setup_power,
8425 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8426 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8427 .msmsdcc_fmin = 400000,
8428 .msmsdcc_fmid = 24000000,
8429 .msmsdcc_fmax = 48000000,
8430 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008431 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008432#ifdef CONFIG_MSM_SDIO_AL
8433 .is_sdio_al_client = 1,
8434#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308435 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008436};
8437#endif
8438
8439static void __init msm8x60_init_mmc(void)
8440{
8441#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8442 /* SDCC1 : eMMC card connected */
8443 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8444 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8445 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8446 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308447 sdcc_vreg_data[0].vdd_data->always_on = 1;
8448 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8449 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8450 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008451
8452 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8453 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8454 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8455 sdcc_vreg_data[0].vccq_data->always_on = 1;
8456
8457 msm_add_sdcc(1, &msm8x60_sdc1_data);
8458#endif
8459#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8460 /*
8461 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8462 * and no card is connected on 8660 SURF/FFA/FLUID.
8463 */
8464 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8465 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8466 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8467 sdcc_vreg_data[1].vdd_data->level = 1800000;
8468
8469 sdcc_vreg_data[1].vccq_data = NULL;
8470
8471 if (machine_is_msm8x60_fusion())
8472 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8473 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008474 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8475 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008476 msm_add_sdcc(2, &msm8x60_sdc2_data);
8477 }
8478#endif
8479#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8480 /* SDCC3 : External card slot connected */
8481 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8482 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8483 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8484 sdcc_vreg_data[2].vdd_data->level = 2850000;
8485 sdcc_vreg_data[2].vdd_data->always_on = 1;
8486 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8487 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8488 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8489
8490 sdcc_vreg_data[2].vccq_data = NULL;
8491
8492 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8493 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8494 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8495 sdcc_vreg_data[2].vddp_data->level = 2850000;
8496 sdcc_vreg_data[2].vddp_data->always_on = 1;
8497 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8498 /* Sleep current required is ~300 uA. But min. RPM
8499 * vote can be in terms of mA (min. 1 mA).
8500 * So let's vote for 2 mA during sleep.
8501 */
8502 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8503 /* Max. Active current required is 16 mA */
8504 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8505
8506 if (machine_is_msm8x60_fluid())
8507 msm8x60_sdc3_data.wpswitch = NULL;
8508 msm_add_sdcc(3, &msm8x60_sdc3_data);
8509#endif
8510#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8511 /* SDCC4 : WLAN WCN1314 chip is connected */
8512 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8513 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8514 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8515 sdcc_vreg_data[3].vdd_data->level = 1800000;
8516
8517 sdcc_vreg_data[3].vccq_data = NULL;
8518
8519 msm_add_sdcc(4, &msm8x60_sdc4_data);
8520#endif
8521#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8522 /*
8523 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8524 * and no card is connected on 8660 SURF/FFA/FLUID.
8525 */
8526 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8527 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8528 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8529 sdcc_vreg_data[4].vdd_data->level = 1800000;
8530
8531 sdcc_vreg_data[4].vccq_data = NULL;
8532
8533 if (machine_is_msm8x60_fusion())
8534 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8535 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008536 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8537 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008538 msm_add_sdcc(5, &msm8x60_sdc5_data);
8539 }
8540#endif
8541}
8542
8543#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8544static inline void display_common_power(int on) {}
8545#else
8546
8547#define _GET_REGULATOR(var, name) do { \
8548 if (var == NULL) { \
8549 var = regulator_get(NULL, name); \
8550 if (IS_ERR(var)) { \
8551 pr_err("'%s' regulator not found, rc=%ld\n", \
8552 name, PTR_ERR(var)); \
8553 var = NULL; \
8554 } \
8555 } \
8556} while (0)
8557
8558static int dsub_regulator(int on)
8559{
8560 static struct regulator *dsub_reg;
8561 static struct regulator *mpp0_reg;
8562 static int dsub_reg_enabled;
8563 int rc = 0;
8564
8565 _GET_REGULATOR(dsub_reg, "8901_l3");
8566 if (IS_ERR(dsub_reg)) {
8567 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8568 __func__, PTR_ERR(dsub_reg));
8569 return PTR_ERR(dsub_reg);
8570 }
8571
8572 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8573 if (IS_ERR(mpp0_reg)) {
8574 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8575 __func__, PTR_ERR(mpp0_reg));
8576 return PTR_ERR(mpp0_reg);
8577 }
8578
8579 if (on && !dsub_reg_enabled) {
8580 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8581 if (rc) {
8582 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8583 " err=%d", __func__, rc);
8584 goto dsub_regulator_err;
8585 }
8586 rc = regulator_enable(dsub_reg);
8587 if (rc) {
8588 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8589 " err=%d", __func__, rc);
8590 goto dsub_regulator_err;
8591 }
8592 rc = regulator_enable(mpp0_reg);
8593 if (rc) {
8594 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8595 " err=%d", __func__, rc);
8596 goto dsub_regulator_err;
8597 }
8598 dsub_reg_enabled = 1;
8599 } else if (!on && dsub_reg_enabled) {
8600 rc = regulator_disable(dsub_reg);
8601 if (rc)
8602 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8603 " err=%d", __func__, rc);
8604 rc = regulator_disable(mpp0_reg);
8605 if (rc)
8606 printk(KERN_WARNING "%s: failed to disable reg "
8607 "8901_mpp0 err=%d", __func__, rc);
8608 dsub_reg_enabled = 0;
8609 }
8610
8611 return rc;
8612
8613dsub_regulator_err:
8614 regulator_put(mpp0_reg);
8615 regulator_put(dsub_reg);
8616 return rc;
8617}
8618
8619static int display_power_on;
8620static void setup_display_power(void)
8621{
8622 if (display_power_on)
8623 if (lcdc_vga_enabled) {
8624 dsub_regulator(1);
8625 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8626 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8627 if (machine_is_msm8x60_ffa() ||
8628 machine_is_msm8x60_fusn_ffa())
8629 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8630 } else {
8631 dsub_regulator(0);
8632 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8633 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8634 if (machine_is_msm8x60_ffa() ||
8635 machine_is_msm8x60_fusn_ffa())
8636 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8637 }
8638 else {
8639 dsub_regulator(0);
8640 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8641 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8642 /* BACKLIGHT */
8643 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8644 /* LVDS */
8645 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8646 }
8647}
8648
8649#define _GET_REGULATOR(var, name) do { \
8650 if (var == NULL) { \
8651 var = regulator_get(NULL, name); \
8652 if (IS_ERR(var)) { \
8653 pr_err("'%s' regulator not found, rc=%ld\n", \
8654 name, PTR_ERR(var)); \
8655 var = NULL; \
8656 } \
8657 } \
8658} while (0)
8659
8660#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8661
8662static void display_common_power(int on)
8663{
8664 int rc;
8665 static struct regulator *display_reg;
8666
8667 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8668 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8669 if (on) {
8670 /* LVDS */
8671 _GET_REGULATOR(display_reg, "8901_l2");
8672 if (!display_reg)
8673 return;
8674 rc = regulator_set_voltage(display_reg,
8675 3300000, 3300000);
8676 if (rc)
8677 goto out;
8678 rc = regulator_enable(display_reg);
8679 if (rc)
8680 goto out;
8681 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8682 "LVDS_STDN_OUT_N");
8683 if (rc) {
8684 printk(KERN_ERR "%s: LVDS gpio %d request"
8685 "failed\n", __func__,
8686 GPIO_LVDS_SHUTDOWN_N);
8687 goto out2;
8688 }
8689
8690 /* BACKLIGHT */
8691 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8692 if (rc) {
8693 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8694 "failed\n", __func__,
8695 GPIO_BACKLIGHT_EN);
8696 goto out3;
8697 }
8698
8699 if (machine_is_msm8x60_ffa() ||
8700 machine_is_msm8x60_fusn_ffa()) {
8701 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8702 "DONGLE_PWR_EN");
8703 if (rc) {
8704 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8705 " %d request failed\n", __func__,
8706 GPIO_DONGLE_PWR_EN);
8707 goto out4;
8708 }
8709 }
8710
8711 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8712 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8713 if (machine_is_msm8x60_ffa() ||
8714 machine_is_msm8x60_fusn_ffa())
8715 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8716 mdelay(20);
8717 display_power_on = 1;
8718 setup_display_power();
8719 } else {
8720 if (display_power_on) {
8721 display_power_on = 0;
8722 setup_display_power();
8723 mdelay(20);
8724 if (machine_is_msm8x60_ffa() ||
8725 machine_is_msm8x60_fusn_ffa())
8726 gpio_free(GPIO_DONGLE_PWR_EN);
8727 goto out4;
8728 }
8729 }
8730 }
8731#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8732 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8733 else if (machine_is_msm8x60_fluid()) {
8734 static struct regulator *fluid_reg;
8735 static struct regulator *fluid_reg2;
8736
8737 if (on) {
8738 _GET_REGULATOR(fluid_reg, "8901_l2");
8739 if (!fluid_reg)
8740 return;
8741 _GET_REGULATOR(fluid_reg2, "8058_s3");
8742 if (!fluid_reg2) {
8743 regulator_put(fluid_reg);
8744 return;
8745 }
8746 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8747 if (rc) {
8748 regulator_put(fluid_reg2);
8749 regulator_put(fluid_reg);
8750 return;
8751 }
8752 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8753 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8754 regulator_enable(fluid_reg);
8755 regulator_enable(fluid_reg2);
8756 msleep(20);
8757 gpio_direction_output(GPIO_RESX_N, 0);
8758 udelay(10);
8759 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8760 display_power_on = 1;
8761 setup_display_power();
8762 } else {
8763 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8764 gpio_free(GPIO_RESX_N);
8765 msleep(20);
8766 regulator_disable(fluid_reg2);
8767 regulator_disable(fluid_reg);
8768 regulator_put(fluid_reg2);
8769 regulator_put(fluid_reg);
8770 display_power_on = 0;
8771 setup_display_power();
8772 fluid_reg = NULL;
8773 fluid_reg2 = NULL;
8774 }
8775 }
8776#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008777#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8778 else if (machine_is_msm8x60_dragon()) {
8779 static struct regulator *dragon_reg;
8780 static struct regulator *dragon_reg2;
8781
8782 if (on) {
8783 _GET_REGULATOR(dragon_reg, "8901_l2");
8784 if (!dragon_reg)
8785 return;
8786 _GET_REGULATOR(dragon_reg2, "8058_l16");
8787 if (!dragon_reg2) {
8788 regulator_put(dragon_reg);
8789 dragon_reg = NULL;
8790 return;
8791 }
8792
8793 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8794 if (rc) {
8795 pr_err("%s: gpio %d request failed with rc=%d\n",
8796 __func__, GPIO_NT35582_BL_EN, rc);
8797 regulator_put(dragon_reg);
8798 regulator_put(dragon_reg2);
8799 dragon_reg = NULL;
8800 dragon_reg2 = NULL;
8801 return;
8802 }
8803
8804 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8805 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8806 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8807 pr_err("%s: config gpio '%d' failed!\n",
8808 __func__, GPIO_NT35582_RESET);
8809 gpio_free(GPIO_NT35582_BL_EN);
8810 regulator_put(dragon_reg);
8811 regulator_put(dragon_reg2);
8812 dragon_reg = NULL;
8813 dragon_reg2 = NULL;
8814 return;
8815 }
8816
8817 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8818 if (rc) {
8819 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8820 __func__, GPIO_NT35582_RESET, rc);
8821 gpio_free(GPIO_NT35582_BL_EN);
8822 regulator_put(dragon_reg);
8823 regulator_put(dragon_reg2);
8824 dragon_reg = NULL;
8825 dragon_reg2 = NULL;
8826 return;
8827 }
8828
8829 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8830 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8831 regulator_enable(dragon_reg);
8832 regulator_enable(dragon_reg2);
8833 msleep(20);
8834
8835 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8836 msleep(20);
8837 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8838 msleep(20);
8839 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8840 msleep(50);
8841
8842 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8843
8844 display_power_on = 1;
8845 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8846 gpio_free(GPIO_NT35582_RESET);
8847 gpio_free(GPIO_NT35582_BL_EN);
8848 regulator_disable(dragon_reg2);
8849 regulator_disable(dragon_reg);
8850 regulator_put(dragon_reg2);
8851 regulator_put(dragon_reg);
8852 display_power_on = 0;
8853 dragon_reg = NULL;
8854 dragon_reg2 = NULL;
8855 }
8856 }
8857#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008858 return;
8859
8860out4:
8861 gpio_free(GPIO_BACKLIGHT_EN);
8862out3:
8863 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8864out2:
8865 regulator_disable(display_reg);
8866out:
8867 regulator_put(display_reg);
8868 display_reg = NULL;
8869}
8870#undef _GET_REGULATOR
8871#endif
8872
8873static int mipi_dsi_panel_power(int on);
8874
8875#define LCDC_NUM_GPIO 28
8876#define LCDC_GPIO_START 0
8877
8878static void lcdc_samsung_panel_power(int on)
8879{
8880 int n, ret = 0;
8881
8882 display_common_power(on);
8883
8884 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8885 if (on) {
8886 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8887 if (unlikely(ret)) {
8888 pr_err("%s not able to get gpio\n", __func__);
8889 break;
8890 }
8891 } else
8892 gpio_free(LCDC_GPIO_START + n);
8893 }
8894
8895 if (ret) {
8896 for (n--; n >= 0; n--)
8897 gpio_free(LCDC_GPIO_START + n);
8898 }
8899
8900 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8901}
8902
8903#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8904#define _GET_REGULATOR(var, name) do { \
8905 var = regulator_get(NULL, name); \
8906 if (IS_ERR(var)) { \
8907 pr_err("'%s' regulator not found, rc=%ld\n", \
8908 name, IS_ERR(var)); \
8909 var = NULL; \
8910 return -ENODEV; \
8911 } \
8912} while (0)
8913
8914static int hdmi_enable_5v(int on)
8915{
8916 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8917 static struct regulator *reg_8901_mpp0; /* External 5V */
8918 static int prev_on;
8919 int rc;
8920
8921 if (on == prev_on)
8922 return 0;
8923
8924 if (!reg_8901_hdmi_mvs)
8925 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8926 if (!reg_8901_mpp0)
8927 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8928
8929 if (on) {
8930 rc = regulator_enable(reg_8901_mpp0);
8931 if (rc) {
8932 pr_err("'%s' regulator enable failed, rc=%d\n",
8933 "reg_8901_mpp0", rc);
8934 return rc;
8935 }
8936 rc = regulator_enable(reg_8901_hdmi_mvs);
8937 if (rc) {
8938 pr_err("'%s' regulator enable failed, rc=%d\n",
8939 "8901_hdmi_mvs", rc);
8940 return rc;
8941 }
8942 pr_info("%s(on): success\n", __func__);
8943 } else {
8944 rc = regulator_disable(reg_8901_hdmi_mvs);
8945 if (rc)
8946 pr_warning("'%s' regulator disable failed, rc=%d\n",
8947 "8901_hdmi_mvs", rc);
8948 rc = regulator_disable(reg_8901_mpp0);
8949 if (rc)
8950 pr_warning("'%s' regulator disable failed, rc=%d\n",
8951 "reg_8901_mpp0", rc);
8952 pr_info("%s(off): success\n", __func__);
8953 }
8954
8955 prev_on = on;
8956
8957 return 0;
8958}
8959
8960static int hdmi_core_power(int on, int show)
8961{
8962 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8963 static int prev_on;
8964 int rc;
8965
8966 if (on == prev_on)
8967 return 0;
8968
8969 if (!reg_8058_l16)
8970 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8971
8972 if (on) {
8973 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8974 if (!rc)
8975 rc = regulator_enable(reg_8058_l16);
8976 if (rc) {
8977 pr_err("'%s' regulator enable failed, rc=%d\n",
8978 "8058_l16", rc);
8979 return rc;
8980 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05308981 pr_debug("%s(on): success\n", __func__);
8982 } else {
8983 rc = regulator_disable(reg_8058_l16);
8984 if (rc)
8985 pr_warning("'%s' regulator disable failed, rc=%d\n",
8986 "8058_l16", rc);
8987 pr_debug("%s(off): success\n", __func__);
8988 }
8989
8990 prev_on = on;
8991
8992 return 0;
8993}
8994
8995static int hdmi_gpio_config(int on)
8996{
8997 int rc = 0;
8998 static int prev_on;
8999
9000 if (on == prev_on)
9001 return 0;
9002
9003 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009004 rc = gpio_request(170, "HDMI_DDC_CLK");
9005 if (rc) {
9006 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9007 "HDMI_DDC_CLK", 170, rc);
9008 goto error1;
9009 }
9010 rc = gpio_request(171, "HDMI_DDC_DATA");
9011 if (rc) {
9012 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9013 "HDMI_DDC_DATA", 171, rc);
9014 goto error2;
9015 }
9016 rc = gpio_request(172, "HDMI_HPD");
9017 if (rc) {
9018 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9019 "HDMI_HPD", 172, rc);
9020 goto error3;
9021 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309022 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009023 } else {
9024 gpio_free(170);
9025 gpio_free(171);
9026 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309027 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009028 }
9029
9030 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009031 return 0;
9032
9033error3:
9034 gpio_free(171);
9035error2:
9036 gpio_free(170);
9037error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009038 return rc;
9039}
9040
9041static int hdmi_cec_power(int on)
9042{
9043 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9044 static int prev_on;
9045 int rc;
9046
9047 if (on == prev_on)
9048 return 0;
9049
9050 if (!reg_8901_l3)
9051 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9052
9053 if (on) {
9054 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9055 if (!rc)
9056 rc = regulator_enable(reg_8901_l3);
9057 if (rc) {
9058 pr_err("'%s' regulator enable failed, rc=%d\n",
9059 "8901_l3", rc);
9060 return rc;
9061 }
9062 rc = gpio_request(169, "HDMI_CEC_VAR");
9063 if (rc) {
9064 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9065 "HDMI_CEC_VAR", 169, rc);
9066 goto error;
9067 }
9068 pr_info("%s(on): success\n", __func__);
9069 } else {
9070 gpio_free(169);
9071 rc = regulator_disable(reg_8901_l3);
9072 if (rc)
9073 pr_warning("'%s' regulator disable failed, rc=%d\n",
9074 "8901_l3", rc);
9075 pr_info("%s(off): success\n", __func__);
9076 }
9077
9078 prev_on = on;
9079
9080 return 0;
9081error:
9082 regulator_disable(reg_8901_l3);
9083 return rc;
9084}
9085
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309086static int hdmi_panel_power(int on)
9087{
9088 int rc;
9089
9090 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9091 rc = hdmi_core_power(on, 1);
9092 if (rc)
9093 rc = hdmi_cec_power(on);
9094
9095 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9096 return rc;
9097}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009098#undef _GET_REGULATOR
9099
9100#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9101
9102static int lcdc_panel_power(int on)
9103{
9104 int flag_on = !!on;
9105 static int lcdc_power_save_on;
9106
9107 if (lcdc_power_save_on == flag_on)
9108 return 0;
9109
9110 lcdc_power_save_on = flag_on;
9111
9112 lcdc_samsung_panel_power(on);
9113
9114 return 0;
9115}
9116
9117#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009118
9119static struct msm_bus_vectors rotator_init_vectors[] = {
9120 {
9121 .src = MSM_BUS_MASTER_ROTATOR,
9122 .dst = MSM_BUS_SLAVE_SMI,
9123 .ab = 0,
9124 .ib = 0,
9125 },
9126 {
9127 .src = MSM_BUS_MASTER_ROTATOR,
9128 .dst = MSM_BUS_SLAVE_EBI_CH0,
9129 .ab = 0,
9130 .ib = 0,
9131 },
9132};
9133
9134static struct msm_bus_vectors rotator_ui_vectors[] = {
9135 {
9136 .src = MSM_BUS_MASTER_ROTATOR,
9137 .dst = MSM_BUS_SLAVE_SMI,
9138 .ab = 0,
9139 .ib = 0,
9140 },
9141 {
9142 .src = MSM_BUS_MASTER_ROTATOR,
9143 .dst = MSM_BUS_SLAVE_EBI_CH0,
9144 .ab = (1024 * 600 * 4 * 2 * 60),
9145 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9146 },
9147};
9148
9149static struct msm_bus_vectors rotator_vga_vectors[] = {
9150 {
9151 .src = MSM_BUS_MASTER_ROTATOR,
9152 .dst = MSM_BUS_SLAVE_SMI,
9153 .ab = (640 * 480 * 2 * 2 * 30),
9154 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9155 },
9156 {
9157 .src = MSM_BUS_MASTER_ROTATOR,
9158 .dst = MSM_BUS_SLAVE_EBI_CH0,
9159 .ab = (640 * 480 * 2 * 2 * 30),
9160 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9161 },
9162};
9163
9164static struct msm_bus_vectors rotator_720p_vectors[] = {
9165 {
9166 .src = MSM_BUS_MASTER_ROTATOR,
9167 .dst = MSM_BUS_SLAVE_SMI,
9168 .ab = (1280 * 736 * 2 * 2 * 30),
9169 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9170 },
9171 {
9172 .src = MSM_BUS_MASTER_ROTATOR,
9173 .dst = MSM_BUS_SLAVE_EBI_CH0,
9174 .ab = (1280 * 736 * 2 * 2 * 30),
9175 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9176 },
9177};
9178
9179static struct msm_bus_vectors rotator_1080p_vectors[] = {
9180 {
9181 .src = MSM_BUS_MASTER_ROTATOR,
9182 .dst = MSM_BUS_SLAVE_SMI,
9183 .ab = (1920 * 1088 * 2 * 2 * 30),
9184 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9185 },
9186 {
9187 .src = MSM_BUS_MASTER_ROTATOR,
9188 .dst = MSM_BUS_SLAVE_EBI_CH0,
9189 .ab = (1920 * 1088 * 2 * 2 * 30),
9190 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9191 },
9192};
9193
9194static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9195 {
9196 ARRAY_SIZE(rotator_init_vectors),
9197 rotator_init_vectors,
9198 },
9199 {
9200 ARRAY_SIZE(rotator_ui_vectors),
9201 rotator_ui_vectors,
9202 },
9203 {
9204 ARRAY_SIZE(rotator_vga_vectors),
9205 rotator_vga_vectors,
9206 },
9207 {
9208 ARRAY_SIZE(rotator_720p_vectors),
9209 rotator_720p_vectors,
9210 },
9211 {
9212 ARRAY_SIZE(rotator_1080p_vectors),
9213 rotator_1080p_vectors,
9214 },
9215};
9216
9217struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9218 rotator_bus_scale_usecases,
9219 ARRAY_SIZE(rotator_bus_scale_usecases),
9220 .name = "rotator",
9221};
9222
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009223static struct msm_bus_vectors mdp_init_vectors[] = {
9224 /* For now, 0th array entry is reserved.
9225 * Please leave 0 as is and don't use it
9226 */
9227 {
9228 .src = MSM_BUS_MASTER_MDP_PORT0,
9229 .dst = MSM_BUS_SLAVE_SMI,
9230 .ab = 0,
9231 .ib = 0,
9232 },
9233 /* Master and slaves can be from different fabrics */
9234 {
9235 .src = MSM_BUS_MASTER_MDP_PORT0,
9236 .dst = MSM_BUS_SLAVE_EBI_CH0,
9237 .ab = 0,
9238 .ib = 0,
9239 },
9240};
9241
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009242#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009243static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9244 /* Default case static display/UI/2d/3d if FB SMI */
9245 {
9246 .src = MSM_BUS_MASTER_MDP_PORT0,
9247 .dst = MSM_BUS_SLAVE_SMI,
9248 .ab = 388800000,
9249 .ib = 486000000,
9250 },
9251 /* Master and slaves can be from different fabrics */
9252 {
9253 .src = MSM_BUS_MASTER_MDP_PORT0,
9254 .dst = MSM_BUS_SLAVE_EBI_CH0,
9255 .ab = 0,
9256 .ib = 0,
9257 },
9258};
9259
9260static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9261 /* Default case static display/UI/2d/3d if FB SMI */
9262 {
9263 .src = MSM_BUS_MASTER_MDP_PORT0,
9264 .dst = MSM_BUS_SLAVE_SMI,
9265 .ab = 0,
9266 .ib = 0,
9267 },
9268 /* Master and slaves can be from different fabrics */
9269 {
9270 .src = MSM_BUS_MASTER_MDP_PORT0,
9271 .dst = MSM_BUS_SLAVE_EBI_CH0,
9272 .ab = 388800000,
9273 .ib = 486000000 * 2,
9274 },
9275};
9276static struct msm_bus_vectors mdp_vga_vectors[] = {
9277 /* VGA and less video */
9278 {
9279 .src = MSM_BUS_MASTER_MDP_PORT0,
9280 .dst = MSM_BUS_SLAVE_SMI,
9281 .ab = 458092800,
9282 .ib = 572616000,
9283 },
9284 {
9285 .src = MSM_BUS_MASTER_MDP_PORT0,
9286 .dst = MSM_BUS_SLAVE_EBI_CH0,
9287 .ab = 458092800,
9288 .ib = 572616000 * 2,
9289 },
9290};
9291static struct msm_bus_vectors mdp_720p_vectors[] = {
9292 /* 720p and less video */
9293 {
9294 .src = MSM_BUS_MASTER_MDP_PORT0,
9295 .dst = MSM_BUS_SLAVE_SMI,
9296 .ab = 471744000,
9297 .ib = 589680000,
9298 },
9299 /* Master and slaves can be from different fabrics */
9300 {
9301 .src = MSM_BUS_MASTER_MDP_PORT0,
9302 .dst = MSM_BUS_SLAVE_EBI_CH0,
9303 .ab = 471744000,
9304 .ib = 589680000 * 2,
9305 },
9306};
9307
9308static struct msm_bus_vectors mdp_1080p_vectors[] = {
9309 /* 1080p and less video */
9310 {
9311 .src = MSM_BUS_MASTER_MDP_PORT0,
9312 .dst = MSM_BUS_SLAVE_SMI,
9313 .ab = 575424000,
9314 .ib = 719280000,
9315 },
9316 /* Master and slaves can be from different fabrics */
9317 {
9318 .src = MSM_BUS_MASTER_MDP_PORT0,
9319 .dst = MSM_BUS_SLAVE_EBI_CH0,
9320 .ab = 575424000,
9321 .ib = 719280000 * 2,
9322 },
9323};
9324
9325#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009326static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9327 /* Default case static display/UI/2d/3d if FB SMI */
9328 {
9329 .src = MSM_BUS_MASTER_MDP_PORT0,
9330 .dst = MSM_BUS_SLAVE_SMI,
9331 .ab = 175110000,
9332 .ib = 218887500,
9333 },
9334 /* Master and slaves can be from different fabrics */
9335 {
9336 .src = MSM_BUS_MASTER_MDP_PORT0,
9337 .dst = MSM_BUS_SLAVE_EBI_CH0,
9338 .ab = 0,
9339 .ib = 0,
9340 },
9341};
9342
9343static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9344 /* Default case static display/UI/2d/3d if FB SMI */
9345 {
9346 .src = MSM_BUS_MASTER_MDP_PORT0,
9347 .dst = MSM_BUS_SLAVE_SMI,
9348 .ab = 0,
9349 .ib = 0,
9350 },
9351 /* Master and slaves can be from different fabrics */
9352 {
9353 .src = MSM_BUS_MASTER_MDP_PORT0,
9354 .dst = MSM_BUS_SLAVE_EBI_CH0,
9355 .ab = 216000000,
9356 .ib = 270000000 * 2,
9357 },
9358};
9359static struct msm_bus_vectors mdp_vga_vectors[] = {
9360 /* VGA and less video */
9361 {
9362 .src = MSM_BUS_MASTER_MDP_PORT0,
9363 .dst = MSM_BUS_SLAVE_SMI,
9364 .ab = 216000000,
9365 .ib = 270000000,
9366 },
9367 {
9368 .src = MSM_BUS_MASTER_MDP_PORT0,
9369 .dst = MSM_BUS_SLAVE_EBI_CH0,
9370 .ab = 216000000,
9371 .ib = 270000000 * 2,
9372 },
9373};
9374
9375static struct msm_bus_vectors mdp_720p_vectors[] = {
9376 /* 720p and less video */
9377 {
9378 .src = MSM_BUS_MASTER_MDP_PORT0,
9379 .dst = MSM_BUS_SLAVE_SMI,
9380 .ab = 230400000,
9381 .ib = 288000000,
9382 },
9383 /* Master and slaves can be from different fabrics */
9384 {
9385 .src = MSM_BUS_MASTER_MDP_PORT0,
9386 .dst = MSM_BUS_SLAVE_EBI_CH0,
9387 .ab = 230400000,
9388 .ib = 288000000 * 2,
9389 },
9390};
9391
9392static struct msm_bus_vectors mdp_1080p_vectors[] = {
9393 /* 1080p and less video */
9394 {
9395 .src = MSM_BUS_MASTER_MDP_PORT0,
9396 .dst = MSM_BUS_SLAVE_SMI,
9397 .ab = 334080000,
9398 .ib = 417600000,
9399 },
9400 /* Master and slaves can be from different fabrics */
9401 {
9402 .src = MSM_BUS_MASTER_MDP_PORT0,
9403 .dst = MSM_BUS_SLAVE_EBI_CH0,
9404 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009405 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009406 },
9407};
9408
9409#endif
9410static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9411 {
9412 ARRAY_SIZE(mdp_init_vectors),
9413 mdp_init_vectors,
9414 },
9415 {
9416 ARRAY_SIZE(mdp_sd_smi_vectors),
9417 mdp_sd_smi_vectors,
9418 },
9419 {
9420 ARRAY_SIZE(mdp_sd_ebi_vectors),
9421 mdp_sd_ebi_vectors,
9422 },
9423 {
9424 ARRAY_SIZE(mdp_vga_vectors),
9425 mdp_vga_vectors,
9426 },
9427 {
9428 ARRAY_SIZE(mdp_720p_vectors),
9429 mdp_720p_vectors,
9430 },
9431 {
9432 ARRAY_SIZE(mdp_1080p_vectors),
9433 mdp_1080p_vectors,
9434 },
9435};
9436static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9437 mdp_bus_scale_usecases,
9438 ARRAY_SIZE(mdp_bus_scale_usecases),
9439 .name = "mdp",
9440};
9441
9442#endif
9443#ifdef CONFIG_MSM_BUS_SCALING
9444static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9445 /* For now, 0th array entry is reserved.
9446 * Please leave 0 as is and don't use it
9447 */
9448 {
9449 .src = MSM_BUS_MASTER_MDP_PORT0,
9450 .dst = MSM_BUS_SLAVE_SMI,
9451 .ab = 0,
9452 .ib = 0,
9453 },
9454 /* Master and slaves can be from different fabrics */
9455 {
9456 .src = MSM_BUS_MASTER_MDP_PORT0,
9457 .dst = MSM_BUS_SLAVE_EBI_CH0,
9458 .ab = 0,
9459 .ib = 0,
9460 },
9461};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009462
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009463static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9464 /* For now, 0th array entry is reserved.
9465 * Please leave 0 as is and don't use it
9466 */
9467 {
9468 .src = MSM_BUS_MASTER_MDP_PORT0,
9469 .dst = MSM_BUS_SLAVE_SMI,
9470 .ab = 566092800,
9471 .ib = 707616000,
9472 },
9473 /* Master and slaves can be from different fabrics */
9474 {
9475 .src = MSM_BUS_MASTER_MDP_PORT0,
9476 .dst = MSM_BUS_SLAVE_EBI_CH0,
9477 .ab = 566092800,
9478 .ib = 707616000,
9479 },
9480};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009481
9482static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9483 /* For now, 0th array entry is reserved.
9484 * Please leave 0 as is and don't use it
9485 */
9486 {
9487 .src = MSM_BUS_MASTER_MDP_PORT0,
9488 .dst = MSM_BUS_SLAVE_SMI,
9489 .ab = 2000000000,
9490 .ib = 2000000000,
9491 },
9492 /* Master and slaves can be from different fabrics */
9493 {
9494 .src = MSM_BUS_MASTER_MDP_PORT0,
9495 .dst = MSM_BUS_SLAVE_EBI_CH0,
9496 .ab = 2000000000,
9497 .ib = 2000000000,
9498 },
9499};
9500
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009501static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9502 {
9503 ARRAY_SIZE(dtv_bus_init_vectors),
9504 dtv_bus_init_vectors,
9505 },
9506 {
9507 ARRAY_SIZE(dtv_bus_def_vectors),
9508 dtv_bus_def_vectors,
9509 },
9510};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009511
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009512static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9513 dtv_bus_scale_usecases,
9514 ARRAY_SIZE(dtv_bus_scale_usecases),
9515 .name = "dtv",
9516};
9517
9518static struct lcdc_platform_data dtv_pdata = {
9519 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309520 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009521};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009522
9523static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9524 {
9525 ARRAY_SIZE(dtv_bus_init_vectors),
9526 dtv_bus_init_vectors,
9527 },
9528 {
9529 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9530 dtv_bus_hdmi_prim_vectors,
9531 },
9532};
9533
9534static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9535 dtv_hdmi_prim_bus_scale_usecases,
9536 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9537 .name = "dtv",
9538};
9539
9540static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9541 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9542};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009543#endif
9544
9545
9546static struct lcdc_platform_data lcdc_pdata = {
9547 .lcdc_power_save = lcdc_panel_power,
9548};
9549
9550
9551#define MDP_VSYNC_GPIO 28
9552
9553/*
9554 * MIPI_DSI only use 8058_LDO0 which need always on
9555 * therefore it need to be put at low power mode if
9556 * it was not used instead of turn it off.
9557 */
9558static int mipi_dsi_panel_power(int on)
9559{
9560 int flag_on = !!on;
9561 static int mipi_dsi_power_save_on;
9562 static struct regulator *ldo0;
9563 int rc = 0;
9564
9565 if (mipi_dsi_power_save_on == flag_on)
9566 return 0;
9567
9568 mipi_dsi_power_save_on = flag_on;
9569
9570 if (ldo0 == NULL) { /* init */
9571 ldo0 = regulator_get(NULL, "8058_l0");
9572 if (IS_ERR(ldo0)) {
9573 pr_debug("%s: LDO0 failed\n", __func__);
9574 rc = PTR_ERR(ldo0);
9575 return rc;
9576 }
9577
9578 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9579 if (rc)
9580 goto out;
9581
9582 rc = regulator_enable(ldo0);
9583 if (rc)
9584 goto out;
9585 }
9586
9587 if (on) {
9588 /* set ldo0 to HPM */
9589 rc = regulator_set_optimum_mode(ldo0, 100000);
9590 if (rc < 0)
9591 goto out;
9592 } else {
9593 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309594 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009595 if (rc < 0)
9596 goto out;
9597 }
9598
9599 return 0;
9600out:
9601 regulator_disable(ldo0);
9602 regulator_put(ldo0);
9603 ldo0 = NULL;
9604 return rc;
9605}
9606
9607static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9608 .vsync_gpio = MDP_VSYNC_GPIO,
9609 .dsi_power_save = mipi_dsi_panel_power,
9610};
9611
9612#ifdef CONFIG_FB_MSM_TVOUT
9613static struct regulator *reg_8058_l13;
9614
9615static int atv_dac_power(int on)
9616{
9617 int rc = 0;
9618 #define _GET_REGULATOR(var, name) do { \
9619 var = regulator_get(NULL, name); \
9620 if (IS_ERR(var)) { \
9621 pr_info("'%s' regulator not found, rc=%ld\n", \
9622 name, IS_ERR(var)); \
9623 var = NULL; \
9624 return -ENODEV; \
9625 } \
9626 } while (0)
9627
9628 if (!reg_8058_l13)
9629 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9630 #undef _GET_REGULATOR
9631
9632 if (on) {
9633 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9634 if (rc) {
9635 pr_info("%s: '%s' regulator set voltage failed,\
9636 rc=%d\n", __func__, "8058_l13", rc);
9637 return rc;
9638 }
9639
9640 rc = regulator_enable(reg_8058_l13);
9641 if (rc) {
9642 pr_err("%s: '%s' regulator enable failed,\
9643 rc=%d\n", __func__, "8058_l13", rc);
9644 return rc;
9645 }
9646 } else {
9647 rc = regulator_force_disable(reg_8058_l13);
9648 if (rc)
9649 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9650 __func__, "8058_l13", rc);
9651 }
9652 return rc;
9653
9654}
9655#endif
9656
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009657static struct msm_panel_common_pdata mdp_pdata = {
9658 .gpio = MDP_VSYNC_GPIO,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009659 .mdp_max_clk = 200000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009660#ifdef CONFIG_MSM_BUS_SCALING
9661 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9662#endif
9663 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009664#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009665 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009666#else
9667 .mem_hid = MEMTYPE_EBI1,
9668#endif
Olav Hauganef95ae32012-05-15 09:50:30 -07009669 .mdp_iommu_split_domain = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009670};
9671
Huaibin Yanga5419422011-12-08 23:52:10 -08009672static void __init reserve_mdp_memory(void)
9673{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009674 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9675 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9676#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9677 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9678 mdp_pdata.ov0_wb_size;
9679 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9680 mdp_pdata.ov1_wb_size;
9681#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009682}
9683
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009684#ifdef CONFIG_FB_MSM_TVOUT
9685
9686#ifdef CONFIG_MSM_BUS_SCALING
9687static struct msm_bus_vectors atv_bus_init_vectors[] = {
9688 /* For now, 0th array entry is reserved.
9689 * Please leave 0 as is and don't use it
9690 */
9691 {
9692 .src = MSM_BUS_MASTER_MDP_PORT0,
9693 .dst = MSM_BUS_SLAVE_SMI,
9694 .ab = 0,
9695 .ib = 0,
9696 },
9697 /* Master and slaves can be from different fabrics */
9698 {
9699 .src = MSM_BUS_MASTER_MDP_PORT0,
9700 .dst = MSM_BUS_SLAVE_EBI_CH0,
9701 .ab = 0,
9702 .ib = 0,
9703 },
9704};
9705static struct msm_bus_vectors atv_bus_def_vectors[] = {
9706 /* For now, 0th array entry is reserved.
9707 * Please leave 0 as is and don't use it
9708 */
9709 {
9710 .src = MSM_BUS_MASTER_MDP_PORT0,
9711 .dst = MSM_BUS_SLAVE_SMI,
9712 .ab = 236390400,
9713 .ib = 265939200,
9714 },
9715 /* Master and slaves can be from different fabrics */
9716 {
9717 .src = MSM_BUS_MASTER_MDP_PORT0,
9718 .dst = MSM_BUS_SLAVE_EBI_CH0,
9719 .ab = 236390400,
9720 .ib = 265939200,
9721 },
9722};
9723static struct msm_bus_paths atv_bus_scale_usecases[] = {
9724 {
9725 ARRAY_SIZE(atv_bus_init_vectors),
9726 atv_bus_init_vectors,
9727 },
9728 {
9729 ARRAY_SIZE(atv_bus_def_vectors),
9730 atv_bus_def_vectors,
9731 },
9732};
9733static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9734 atv_bus_scale_usecases,
9735 ARRAY_SIZE(atv_bus_scale_usecases),
9736 .name = "atv",
9737};
9738#endif
9739
9740static struct tvenc_platform_data atv_pdata = {
9741 .poll = 0,
9742 .pm_vid_en = atv_dac_power,
9743#ifdef CONFIG_MSM_BUS_SCALING
9744 .bus_scale_table = &atv_bus_scale_pdata,
9745#endif
9746};
9747#endif
9748
9749static void __init msm_fb_add_devices(void)
9750{
9751#ifdef CONFIG_FB_MSM_LCDC_DSUB
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009752 mdp_pdata.mdp_max_clk = 200000000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009753#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -07009754 msm_fb_register_device("mdp", &mdp_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009755
9756 msm_fb_register_device("lcdc", &lcdc_pdata);
9757 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9758#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009759 if (hdmi_is_primary)
9760 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9761 else
9762 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009763#endif
9764#ifdef CONFIG_FB_MSM_TVOUT
9765 msm_fb_register_device("tvenc", &atv_pdata);
9766 msm_fb_register_device("tvout_device", NULL);
9767#endif
9768}
9769
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009770/**
9771 * Set MDP clocks to high frequency to avoid underflow when
9772 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9773 */
9774static void set_mdp_clocks_for_wuxga(void)
9775{
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009776 mdp_sd_smi_vectors[0].ab = 2000000000;
9777 mdp_sd_smi_vectors[0].ib = 2000000000;
9778 mdp_sd_smi_vectors[1].ab = 2000000000;
9779 mdp_sd_smi_vectors[1].ib = 2000000000;
9780
9781 mdp_sd_ebi_vectors[0].ab = 2000000000;
9782 mdp_sd_ebi_vectors[0].ib = 2000000000;
9783 mdp_sd_ebi_vectors[1].ab = 2000000000;
9784 mdp_sd_ebi_vectors[1].ib = 2000000000;
9785
9786 mdp_vga_vectors[0].ab = 2000000000;
9787 mdp_vga_vectors[0].ib = 2000000000;
9788 mdp_vga_vectors[1].ab = 2000000000;
9789 mdp_vga_vectors[1].ib = 2000000000;
9790
9791 mdp_720p_vectors[0].ab = 2000000000;
9792 mdp_720p_vectors[0].ib = 2000000000;
9793 mdp_720p_vectors[1].ab = 2000000000;
9794 mdp_720p_vectors[1].ib = 2000000000;
9795
9796 mdp_1080p_vectors[0].ab = 2000000000;
9797 mdp_1080p_vectors[0].ib = 2000000000;
9798 mdp_1080p_vectors[1].ab = 2000000000;
9799 mdp_1080p_vectors[1].ib = 2000000000;
9800
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009801 mdp_pdata.mdp_max_clk = 200000000;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009802}
9803
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009804#if (defined(CONFIG_MARIMBA_CORE)) && \
9805 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9806
9807static const struct {
9808 char *name;
9809 int vmin;
9810 int vmax;
9811} bt_regs_info[] = {
9812 { "8058_s3", 1800000, 1800000 },
9813 { "8058_s2", 1300000, 1300000 },
9814 { "8058_l8", 2900000, 3050000 },
9815};
9816
9817static struct {
9818 bool enabled;
9819} bt_regs_status[] = {
9820 { false },
9821 { false },
9822 { false },
9823};
9824static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9825
9826static int bahama_bt(int on)
9827{
9828 int rc;
9829 int i;
9830 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9831
9832 struct bahama_variant_register {
9833 const size_t size;
9834 const struct bahama_config_register *set;
9835 };
9836
9837 const struct bahama_config_register *p;
9838
9839 u8 version;
9840
9841 const struct bahama_config_register v10_bt_on[] = {
9842 { 0xE9, 0x00, 0xFF },
9843 { 0xF4, 0x80, 0xFF },
9844 { 0xE4, 0x00, 0xFF },
9845 { 0xE5, 0x00, 0x0F },
9846#ifdef CONFIG_WLAN
9847 { 0xE6, 0x38, 0x7F },
9848 { 0xE7, 0x06, 0xFF },
9849#endif
9850 { 0xE9, 0x21, 0xFF },
9851 { 0x01, 0x0C, 0x1F },
9852 { 0x01, 0x08, 0x1F },
9853 };
9854
9855 const struct bahama_config_register v20_bt_on_fm_off[] = {
9856 { 0x11, 0x0C, 0xFF },
9857 { 0x13, 0x01, 0xFF },
9858 { 0xF4, 0x80, 0xFF },
9859 { 0xF0, 0x00, 0xFF },
9860 { 0xE9, 0x00, 0xFF },
9861#ifdef CONFIG_WLAN
9862 { 0x81, 0x00, 0x7F },
9863 { 0x82, 0x00, 0xFF },
9864 { 0xE6, 0x38, 0x7F },
9865 { 0xE7, 0x06, 0xFF },
9866#endif
9867 { 0xE9, 0x21, 0xFF },
9868 };
9869
9870 const struct bahama_config_register v20_bt_on_fm_on[] = {
9871 { 0x11, 0x0C, 0xFF },
9872 { 0x13, 0x01, 0xFF },
9873 { 0xF4, 0x86, 0xFF },
9874 { 0xF0, 0x06, 0xFF },
9875 { 0xE9, 0x00, 0xFF },
9876#ifdef CONFIG_WLAN
9877 { 0x81, 0x00, 0x7F },
9878 { 0x82, 0x00, 0xFF },
9879 { 0xE6, 0x38, 0x7F },
9880 { 0xE7, 0x06, 0xFF },
9881#endif
9882 { 0xE9, 0x21, 0xFF },
9883 };
9884
9885 const struct bahama_config_register v10_bt_off[] = {
9886 { 0xE9, 0x00, 0xFF },
9887 };
9888
9889 const struct bahama_config_register v20_bt_off_fm_off[] = {
9890 { 0xF4, 0x84, 0xFF },
9891 { 0xF0, 0x04, 0xFF },
9892 { 0xE9, 0x00, 0xFF }
9893 };
9894
9895 const struct bahama_config_register v20_bt_off_fm_on[] = {
9896 { 0xF4, 0x86, 0xFF },
9897 { 0xF0, 0x06, 0xFF },
9898 { 0xE9, 0x00, 0xFF }
9899 };
9900 const struct bahama_variant_register bt_bahama[2][3] = {
9901 {
9902 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9903 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9904 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9905 },
9906 {
9907 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9908 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9909 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9910 }
9911 };
9912
9913 u8 offset = 0; /* index into bahama configs */
9914
9915 on = on ? 1 : 0;
9916 version = read_bahama_ver();
9917
9918 if (version == VER_UNSUPPORTED) {
9919 dev_err(&msm_bt_power_device.dev,
9920 "%s: unsupported version\n",
9921 __func__);
9922 return -EIO;
9923 }
9924
9925 if (version == VER_2_0) {
9926 if (marimba_get_fm_status(&config))
9927 offset = 0x01;
9928 }
9929
9930 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9931 if (on && (version == VER_2_0)) {
9932 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9933 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9934 && (bt_regs_status[i].enabled == true)) {
9935 if (regulator_disable(bt_regs[i])) {
9936 dev_err(&msm_bt_power_device.dev,
9937 "%s: regulator disable failed",
9938 __func__);
9939 }
9940 bt_regs_status[i].enabled = false;
9941 break;
9942 }
9943 }
9944 }
9945
9946 p = bt_bahama[on][version + offset].set;
9947
9948 dev_info(&msm_bt_power_device.dev,
9949 "%s: found version %d\n", __func__, version);
9950
9951 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9952 u8 value = (p+i)->value;
9953 rc = marimba_write_bit_mask(&config,
9954 (p+i)->reg,
9955 &value,
9956 sizeof((p+i)->value),
9957 (p+i)->mask);
9958 if (rc < 0) {
9959 dev_err(&msm_bt_power_device.dev,
9960 "%s: reg %d write failed: %d\n",
9961 __func__, (p+i)->reg, rc);
9962 return rc;
9963 }
9964 dev_dbg(&msm_bt_power_device.dev,
9965 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9966 __func__, (p+i)->reg,
9967 value, (p+i)->mask);
9968 }
9969 /* Update BT Status */
9970 if (on)
9971 marimba_set_bt_status(&config, true);
9972 else
9973 marimba_set_bt_status(&config, false);
9974
9975 return 0;
9976}
9977
9978static int bluetooth_use_regulators(int on)
9979{
9980 int i, recover = -1, rc = 0;
9981
9982 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9983 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9984 bt_regs_info[i].name) :
9985 (regulator_put(bt_regs[i]), NULL);
9986 if (IS_ERR(bt_regs[i])) {
9987 rc = PTR_ERR(bt_regs[i]);
9988 dev_err(&msm_bt_power_device.dev,
9989 "regulator %s get failed (%d)\n",
9990 bt_regs_info[i].name, rc);
9991 recover = i - 1;
9992 bt_regs[i] = NULL;
9993 break;
9994 }
9995
9996 if (!on)
9997 continue;
9998
9999 rc = regulator_set_voltage(bt_regs[i],
10000 bt_regs_info[i].vmin,
10001 bt_regs_info[i].vmax);
10002 if (rc < 0) {
10003 dev_err(&msm_bt_power_device.dev,
10004 "regulator %s voltage set (%d)\n",
10005 bt_regs_info[i].name, rc);
10006 recover = i;
10007 break;
10008 }
10009 }
10010
10011 if (on && (recover > -1))
10012 for (i = recover; i >= 0; i--) {
10013 regulator_put(bt_regs[i]);
10014 bt_regs[i] = NULL;
10015 }
10016
10017 return rc;
10018}
10019
10020static int bluetooth_switch_regulators(int on)
10021{
10022 int i, rc = 0;
10023
10024 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10025 if (on && (bt_regs_status[i].enabled == false)) {
10026 rc = regulator_enable(bt_regs[i]);
10027 if (rc < 0) {
10028 dev_err(&msm_bt_power_device.dev,
10029 "regulator %s %s failed (%d)\n",
10030 bt_regs_info[i].name,
10031 "enable", rc);
10032 if (i > 0) {
10033 while (--i) {
10034 regulator_disable(bt_regs[i]);
10035 bt_regs_status[i].enabled
10036 = false;
10037 }
10038 break;
10039 }
10040 }
10041 bt_regs_status[i].enabled = true;
10042 } else if (!on && (bt_regs_status[i].enabled == true)) {
10043 rc = regulator_disable(bt_regs[i]);
10044 if (rc < 0) {
10045 dev_err(&msm_bt_power_device.dev,
10046 "regulator %s %s failed (%d)\n",
10047 bt_regs_info[i].name,
10048 "disable", rc);
10049 break;
10050 }
10051 bt_regs_status[i].enabled = false;
10052 }
10053 }
10054 return rc;
10055}
10056
10057static struct msm_xo_voter *bt_clock;
10058
10059static int bluetooth_power(int on)
10060{
10061 int rc = 0;
10062 int id;
10063
10064 /* In case probe function fails, cur_connv_type would be -1 */
10065 id = adie_get_detected_connectivity_type();
10066 if (id != BAHAMA_ID) {
10067 pr_err("%s: unexpected adie connectivity type: %d\n",
10068 __func__, id);
10069 return -ENODEV;
10070 }
10071
10072 if (on) {
10073
10074 rc = bluetooth_use_regulators(1);
10075 if (rc < 0)
10076 goto out;
10077
10078 rc = bluetooth_switch_regulators(1);
10079
10080 if (rc < 0)
10081 goto fail_put;
10082
10083 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10084
10085 if (IS_ERR(bt_clock)) {
10086 pr_err("Couldn't get TCXO_D0 voter\n");
10087 goto fail_switch;
10088 }
10089
10090 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10091
10092 if (rc < 0) {
10093 pr_err("Failed to vote for TCXO_DO ON\n");
10094 goto fail_vote;
10095 }
10096
10097 rc = bahama_bt(1);
10098
10099 if (rc < 0)
10100 goto fail_clock;
10101
10102 msleep(10);
10103
10104 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10105
10106 if (rc < 0) {
10107 pr_err("Failed to vote for TCXO_DO pin control\n");
10108 goto fail_vote;
10109 }
10110 } else {
10111 /* check for initial RFKILL block (power off) */
10112 /* some RFKILL versions/configurations rfkill_register */
10113 /* calls here for an initial set_block */
10114 /* avoid calling i2c and regulator before unblock (on) */
10115 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10116 dev_info(&msm_bt_power_device.dev,
10117 "%s: initialized OFF/blocked\n", __func__);
10118 goto out;
10119 }
10120
10121 bahama_bt(0);
10122
10123fail_clock:
10124 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10125fail_vote:
10126 msm_xo_put(bt_clock);
10127fail_switch:
10128 bluetooth_switch_regulators(0);
10129fail_put:
10130 bluetooth_use_regulators(0);
10131 }
10132
10133out:
10134 if (rc < 0)
10135 on = 0;
10136 dev_info(&msm_bt_power_device.dev,
10137 "Bluetooth power switch: state %d result %d\n", on, rc);
10138
10139 return rc;
10140}
10141
10142#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10143
10144static void __init msm8x60_cfg_smsc911x(void)
10145{
10146 smsc911x_resources[1].start =
10147 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10148 smsc911x_resources[1].end =
10149 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10150}
10151
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010152void msm_fusion_setup_pinctrl(void)
10153{
10154 struct msm_xo_voter *a1;
10155
10156 if (socinfo_get_platform_subtype() == 0x3) {
10157 /*
10158 * Vote for the A1 clock to be in pin control mode before
10159 * the external images are loaded.
10160 */
10161 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10162 BUG_ON(!a1);
10163 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10164 }
10165}
10166
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010167struct msm_board_data {
10168 struct msm_gpiomux_configs *gpiomux_cfgs;
10169};
10170
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010171static struct msm_board_data msm8x60_surf_board_data __initdata = {
10172 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10173};
10174
10175static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10176 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10177};
10178
10179static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10180 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10181};
10182
10183static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10184 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10185};
10186
10187static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10188 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10189};
10190
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010191static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10192 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10193};
10194
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010195static void __init msm8x60_init(struct msm_board_data *board_data)
10196{
10197 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010198#ifdef CONFIG_USB_EHCI_MSM_72K
10199 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10200 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10201 .level = PM8901_MPP_DIG_LEVEL_L5,
10202 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10203 };
10204#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010205 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010206
Rohit Vaswanib1cc4932012-07-23 21:30:11 -070010207 platform_device_register(&msm_gpio_device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010208 /*
10209 * Initialize RPM first as other drivers and devices may need
10210 * it for their initialization.
10211 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010212 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10213 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010214 if (msm_xo_init())
10215 pr_err("Failed to initialize XO votes\n");
10216
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010217 msm8x60_check_2d_hardware();
10218
10219 /* Change SPM handling of core 1 if PMM 8160 is present. */
10220 soc_platform_version = socinfo_get_platform_version();
10221 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10222 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10223 struct msm_spm_platform_data *spm_data;
10224
10225 spm_data = &msm_spm_data_v1[1];
10226 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10227 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10228
10229 spm_data = &msm_spm_data[1];
10230 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10231 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10232 }
10233
10234 /*
10235 * Initialize SPM before acpuclock as the latter calls into SPM
10236 * driver to set ACPU voltages.
10237 */
10238 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10239 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10240 else
10241 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10242
10243 /*
10244 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10245 * devices so that the RPM doesn't drop into a low power mode that an
10246 * un-reworked SURF cannot resume from.
10247 */
10248 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010249 int i;
10250
10251 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10252 if (rpm_regulator_init_data[i].id
10253 == RPM_VREG_ID_PM8901_L4
10254 || rpm_regulator_init_data[i].id
10255 == RPM_VREG_ID_PM8901_L6)
10256 rpm_regulator_init_data[i]
10257 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010258 }
10259
10260 /*
10261 * Disable regulator info printing so that regulator registration
10262 * messages do not enter the kmsg log.
10263 */
10264 regulator_suppress_info_printing();
10265
10266 /* Initialize regulators needed for clock_init. */
10267 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10268
Stephen Boydbb600ae2011-08-02 20:11:40 -070010269 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010270
10271 /* Buses need to be initialized before early-device registration
10272 * to get the platform data for fabrics.
10273 */
10274 msm8x60_init_buses();
10275 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010276
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010277 /*
10278 * Enable EBI2 only for boards which make use of it. Leave
10279 * it disabled for all others for additional power savings.
10280 */
10281 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010282 machine_is_msm8x60_fluid() ||
10283 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010284 msm8x60_init_ebi2();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010285 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10286 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010287#ifdef CONFIG_MSM_CAMERA_V4L2
10288 msm8x60_init_cam();
10289#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010290 msm8x60_init_mmc();
10291
Kevin Chan3be11612012-03-22 20:05:40 -070010292
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010293#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10294 msm8x60_init_pm8058_othc();
10295#endif
10296
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010297 if (machine_is_msm8x60_fluid())
10298 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10299 else if (machine_is_msm8x60_dragon())
10300 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10301 else
10302 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010303#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010304 /* Specify reset pin for OV9726 */
10305 if (machine_is_msm8x60_dragon()) {
10306 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10307 ov9726_sensor_8660_info.mount_angle = 270;
10308 }
Kevin Chan3be11612012-03-22 20:05:40 -070010309#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010310#ifdef CONFIG_BATTERY_MSM8X60
10311 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10312 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10313 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10314 platform_device_register(&msm_charger_device);
10315#endif
10316
10317 if (machine_is_msm8x60_dragon())
10318 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10319 if (!machine_is_msm8x60_fluid())
10320 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10321
10322 /* configure pmic leds */
10323 if (machine_is_msm8x60_fluid())
10324 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10325 else if (machine_is_msm8x60_dragon())
10326 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10327 else
10328 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10329
10330 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10331 machine_is_msm8x60_dragon()) {
10332 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10333 }
10334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010335 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10336 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010337 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010338 msm8x60_cfg_smsc911x();
10339 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010340 platform_add_devices(msm8660_footswitch,
10341 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010342 platform_add_devices(surf_devices,
10343 ARRAY_SIZE(surf_devices));
10344
10345#ifdef CONFIG_MSM_DSPS
10346 if (machine_is_msm8x60_fluid()) {
10347 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10348 msm8x60_init_dsps();
10349 }
10350#endif
10351
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010352 pm8901_vreg_mpp0_init();
10353
10354 platform_device_register(&msm8x60_8901_mpp_vreg);
10355
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010356#ifdef CONFIG_USB_EHCI_MSM_72K
10357 /*
10358 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10359 * fluid
10360 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010361 if (machine_is_msm8x60_fluid())
10362 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10363 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010364#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010365
10366#ifdef CONFIG_SND_SOC_MSM8660_APQ
10367 if (machine_is_msm8x60_dragon())
10368 platform_add_devices(dragon_alsa_devices,
10369 ARRAY_SIZE(dragon_alsa_devices));
10370 else
10371#endif
10372 platform_add_devices(asoc_devices,
10373 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010374 }
10375#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010376 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10377 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010378 msm8x60_cfg_isp1763();
10379#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010380
10381 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10382 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10383
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010384
10385#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10386 if (machine_is_msm8x60_fluid())
10387 platform_device_register(&msm_gsbi10_qup_spi_device);
10388 else
10389 platform_device_register(&msm_gsbi1_qup_spi_device);
10390#endif
10391
Steve Mucklef132c6c2012-06-06 18:30:57 -070010392#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10393 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010394 if (machine_is_msm8x60_fluid())
10395 cyttsp_set_params();
10396#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -070010397 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010398 fixup_i2c_configs();
10399 register_i2c_devices();
10400
Terence Hampson1c73fef2011-07-19 17:10:49 -040010401 if (machine_is_msm8x60_dragon())
10402 smsc911x_config.reset_gpio
10403 = GPIO_ETHERNET_RESET_N_DRAGON;
10404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010405 platform_device_register(&smsc911x_device);
10406
10407#if (defined(CONFIG_SPI_QUP)) && \
10408 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010409 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10410 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010411
10412 if (machine_is_msm8x60_fluid()) {
10413#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10414 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10415 spi_register_board_info(lcdc_samsung_spi_board_info,
10416 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10417 } else
10418#endif
10419 {
10420#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10421 spi_register_board_info(lcdc_auo_spi_board_info,
10422 ARRAY_SIZE(lcdc_auo_spi_board_info));
10423#endif
10424 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010425#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10426 } else if (machine_is_msm8x60_dragon()) {
10427 spi_register_board_info(lcdc_nt35582_spi_board_info,
10428 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10429#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010430 }
10431#endif
10432
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010433 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010434
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010435 pm8058_gpios_init();
10436
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010437#ifdef CONFIG_SENSORS_MSM_ADC
10438 if (machine_is_msm8x60_fluid()) {
10439 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10440 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10441 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10442 msm_adc_pdata.gpio_config = APROC_CONFIG;
10443 else
10444 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10445 }
10446 msm_adc_pdata.target_hw = MSM_8x60;
10447#endif
10448#ifdef CONFIG_MSM8X60_AUDIO
10449 msm_snddev_init();
10450#endif
10451#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10452 if (machine_is_msm8x60_fluid())
10453 platform_device_register(&fluid_leds_gpio);
10454 else
10455 platform_device_register(&gpio_leds);
10456#endif
10457
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010458 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010459
10460 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10461 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010462}
10463
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010464static void __init msm8x60_surf_init(void)
10465{
10466 msm8x60_init(&msm8x60_surf_board_data);
10467}
10468
10469static void __init msm8x60_ffa_init(void)
10470{
10471 msm8x60_init(&msm8x60_ffa_board_data);
10472}
10473
10474static void __init msm8x60_fluid_init(void)
10475{
10476 msm8x60_init(&msm8x60_fluid_board_data);
10477}
10478
10479static void __init msm8x60_charm_surf_init(void)
10480{
10481 msm8x60_init(&msm8x60_charm_surf_board_data);
10482}
10483
10484static void __init msm8x60_charm_ffa_init(void)
10485{
10486 msm8x60_init(&msm8x60_charm_ffa_board_data);
10487}
10488
10489static void __init msm8x60_charm_init_early(void)
10490{
10491 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010492}
10493
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010494static void __init msm8x60_dragon_init(void)
10495{
10496 msm8x60_init(&msm8x60_dragon_board_data);
10497}
David Brown56e2d8a2011-08-04 02:01:02 -070010498
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010499MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10500 .map_io = msm8x60_map_io,
10501 .reserve = msm8x60_reserve,
10502 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010503 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010504 .init_machine = msm8x60_surf_init,
10505 .timer = &msm_timer,
10506 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010507 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010508MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010509
10510MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10511 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010512 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010513 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010514 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010515 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010516 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010517 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010518 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010519MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010520
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010521MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010522 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010523 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010524 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010525 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010526 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010527 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010528 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010529 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010530MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010531
10532MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10533 .map_io = msm8x60_map_io,
10534 .reserve = msm8x60_reserve,
10535 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010536 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010537 .init_machine = msm8x60_charm_surf_init,
10538 .timer = &msm_timer,
10539 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010540 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010541MACHINE_END
10542
10543MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10544 .map_io = msm8x60_map_io,
10545 .reserve = msm8x60_reserve,
10546 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010547 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010548 .init_machine = msm8x60_charm_ffa_init,
10549 .timer = &msm_timer,
10550 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010551 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010552MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010553
10554MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10555 .map_io = msm8x60_map_io,
10556 .reserve = msm8x60_reserve,
10557 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010558 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010559 .init_machine = msm8x60_dragon_init,
10560 .timer = &msm_timer,
10561 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010562 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010563MACHINE_END