blob: efde720f132fc551de3cb9737cca28f8a57ba78c [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"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -0700103#include "acpuclock.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600104#include "pm-boot.h"
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530105#include "board-storage-common-a.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700106
107#include <linux/ion.h>
108#include <mach/ion.h>
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +0530109#include <mach/msm_rtb.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700110
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112#define MDM2AP_SYNC 129
113
Terence Hampson1c73fef2011-07-19 17:10:49 -0400114#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700115#define LCDC_SPI_GPIO_CLK 73
116#define LCDC_SPI_GPIO_CS 72
117#define LCDC_SPI_GPIO_MOSI 70
118#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
119#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
120#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
121#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
122#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400123#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700124
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700125#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
126#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
127#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
128#define HDMI_PANEL_NAME "hdmi_msm"
129#define TVOUT_PANEL_NAME "tvout_msm"
130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700131#define DSPS_PIL_GENERIC_NAME "dsps"
132#define DSPS_PIL_FLUID_NAME "dsps_fluid"
133
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800134#ifdef CONFIG_ION_MSM
135static struct platform_device ion_dev;
136#endif
137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700138enum {
139 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530140 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141 /* CORE expander */
142 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
143 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
144 GPIO_WLAN_DEEP_SLEEP_N,
145 GPIO_LVDS_SHUTDOWN_N,
146 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
147 GPIO_MS_SYS_RESET_N,
148 GPIO_CAP_TS_RESOUT_N,
149 GPIO_CAP_GAUGE_BI_TOUT,
150 GPIO_ETHERNET_PME,
151 GPIO_EXT_GPS_LNA_EN,
152 GPIO_MSM_WAKES_BT,
153 GPIO_ETHERNET_RESET_N,
154 GPIO_HEADSET_DET_N,
155 GPIO_USB_UICC_EN,
156 GPIO_BACKLIGHT_EN,
157 GPIO_EXT_CAMIF_PWR_EN,
158 GPIO_BATT_GAUGE_INT_N,
159 GPIO_BATT_GAUGE_EN,
160 /* DOCKING expander */
161 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
162 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
163 GPIO_AUX_JTAG_DET_N,
164 GPIO_DONGLE_DET_N,
165 GPIO_SVIDEO_LOAD_DET,
166 GPIO_SVID_AMP_SHUTDOWN1_N,
167 GPIO_SVID_AMP_SHUTDOWN0_N,
168 GPIO_SDC_WP,
169 GPIO_IRDA_PWDN,
170 GPIO_IRDA_RESET_N,
171 GPIO_DONGLE_GPIO0,
172 GPIO_DONGLE_GPIO1,
173 GPIO_DONGLE_GPIO2,
174 GPIO_DONGLE_GPIO3,
175 GPIO_DONGLE_PWR_EN,
176 GPIO_EMMC_RESET_N,
177 GPIO_TP_EXP2_IO15,
178 /* SURF expander */
179 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
180 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
181 GPIO_SD_CARD_DET_2,
182 GPIO_SD_CARD_DET_4,
183 GPIO_SD_CARD_DET_5,
184 GPIO_UIM3_RST,
185 GPIO_SURF_EXPANDER_IO5,
186 GPIO_SURF_EXPANDER_IO6,
187 GPIO_ADC_I2C_EN,
188 GPIO_SURF_EXPANDER_IO8,
189 GPIO_SURF_EXPANDER_IO9,
190 GPIO_SURF_EXPANDER_IO10,
191 GPIO_SURF_EXPANDER_IO11,
192 GPIO_SURF_EXPANDER_IO12,
193 GPIO_SURF_EXPANDER_IO13,
194 GPIO_SURF_EXPANDER_IO14,
195 GPIO_SURF_EXPANDER_IO15,
196 /* LEFT KB IO expander */
197 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
198 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
199 GPIO_LEFT_LED_2,
200 GPIO_LEFT_LED_3,
201 GPIO_LEFT_LED_WLAN,
202 GPIO_JOYSTICK_EN,
203 GPIO_CAP_TS_SLEEP,
204 GPIO_LEFT_KB_IO6,
205 GPIO_LEFT_LED_5,
206 /* RIGHT KB IO expander */
207 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
208 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
209 GPIO_RIGHT_LED_2,
210 GPIO_RIGHT_LED_3,
211 GPIO_RIGHT_LED_BT,
212 GPIO_WEB_CAMIF_STANDBY,
213 GPIO_COMPASS_RST_N,
214 GPIO_WEB_CAMIF_RESET_N,
215 GPIO_RIGHT_LED_5,
216 GPIO_R_ALTIMETER_RESET_N,
217 /* FLUID S IO expander */
218 GPIO_SOUTH_EXPANDER_BASE,
219 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
220 GPIO_MIC1_ANCL_SEL,
221 GPIO_HS_MIC4_SEL,
222 GPIO_FML_MIC3_SEL,
223 GPIO_FMR_MIC5_SEL,
224 GPIO_TS_SLEEP,
225 GPIO_HAP_SHIFT_LVL_OE,
226 GPIO_HS_SW_DIR,
227 /* FLUID N IO expander */
228 GPIO_NORTH_EXPANDER_BASE,
229 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
230 GPIO_EPM_5V_BOOST_EN,
231 GPIO_AUX_CAM_2P7_EN,
232 GPIO_LED_FLASH_EN,
233 GPIO_LED1_GREEN_N,
234 GPIO_LED2_RED_N,
235 GPIO_FRONT_CAM_RESET_N,
236 GPIO_EPM_LVLSFT_EN,
237 GPIO_N_ALTIMETER_RESET_N,
238 /* EPM expander */
239 GPIO_EPM_EXPANDER_BASE,
240 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
241 GPIO_PWR_MON_RESET_N,
242 GPIO_ADC1_PWDN_N,
243 GPIO_ADC2_PWDN_N,
244 GPIO_EPM_EXPANDER_IO4,
245 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
246 GPIO_ADC2_MUX_SPI_INT_N,
247 GPIO_EPM_EXPANDER_IO7,
248 GPIO_PWR_MON_ENABLE,
249 GPIO_EPM_SPI_ADC1_CS_N,
250 GPIO_EPM_SPI_ADC2_CS_N,
251 GPIO_EPM_EXPANDER_IO11,
252 GPIO_EPM_EXPANDER_IO12,
253 GPIO_EPM_EXPANDER_IO13,
254 GPIO_EPM_EXPANDER_IO14,
255 GPIO_EPM_EXPANDER_IO15,
256};
257
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530258struct pm8xxx_mpp_init_info {
259 unsigned mpp;
260 struct pm8xxx_mpp_config_data config;
261};
262
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530263#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530264{ \
265 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
266 .config = { \
267 .type = PM8XXX_MPP_TYPE_##_type, \
268 .level = _level, \
269 .control = PM8XXX_MPP_##_control, \
270 } \
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100271}
272
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530273#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
274{ \
275 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
276 .config = { \
277 .type = PM8XXX_MPP_TYPE_##_type, \
278 .level = _level, \
279 .control = PM8XXX_MPP_##_control, \
280 } \
281}
282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283/*
284 * The UI_INTx_N lines are pmic gpio lines which connect i2c
285 * gpio expanders to the pm8058.
286 */
287#define UI_INT1_N 25
288#define UI_INT2_N 34
289#define UI_INT3_N 14
290/*
291FM GPIO is GPIO 18 on PMIC 8058.
292As the index starts from 0 in the PMIC driver, and hence 17
293corresponds to GPIO 18 on PMIC 8058.
294*/
295#define FM_GPIO 17
296
297#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
298static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
299static void *sdc2_status_notify_cb_devid;
300#endif
301
302#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
303static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
304static void *sdc5_status_notify_cb_devid;
305#endif
306
307static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
308 [0] = {
309 .reg_base_addr = MSM_SAW0_BASE,
310
311#ifdef CONFIG_MSM_AVS_HW
312 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
313#endif
314 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
315 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
316 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
317 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
318
319 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
320 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
322
323 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
324 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
325 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
326
327 .awake_vlevel = 0x94,
328 .retention_vlevel = 0x81,
329 .collapse_vlevel = 0x20,
330 .retention_mid_vlevel = 0x94,
331 .collapse_mid_vlevel = 0x8C,
332
333 .vctl_timeout_us = 50,
334 },
335
336 [1] = {
337 .reg_base_addr = MSM_SAW1_BASE,
338
339#ifdef CONFIG_MSM_AVS_HW
340 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
341#endif
342 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
343 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
344 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
345 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
346
347 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
348 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
350
351 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
352 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
353 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
354
355 .awake_vlevel = 0x94,
356 .retention_vlevel = 0x81,
357 .collapse_vlevel = 0x20,
358 .retention_mid_vlevel = 0x94,
359 .collapse_mid_vlevel = 0x8C,
360
361 .vctl_timeout_us = 50,
362 },
363};
364
365static struct msm_spm_platform_data msm_spm_data[] __initdata = {
366 [0] = {
367 .reg_base_addr = MSM_SAW0_BASE,
368
369#ifdef CONFIG_MSM_AVS_HW
370 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
371#endif
372 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
373 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
374 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
375 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
376
377 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
378 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
380
381 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
382 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
383 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
384
385 .awake_vlevel = 0xA0,
386 .retention_vlevel = 0x89,
387 .collapse_vlevel = 0x20,
388 .retention_mid_vlevel = 0x89,
389 .collapse_mid_vlevel = 0x89,
390
391 .vctl_timeout_us = 50,
392 },
393
394 [1] = {
395 .reg_base_addr = MSM_SAW1_BASE,
396
397#ifdef CONFIG_MSM_AVS_HW
398 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
399#endif
400 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
401 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
402 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
403 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
404
405 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
406 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
408
409 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
410 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
411 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
412
413 .awake_vlevel = 0xA0,
414 .retention_vlevel = 0x89,
415 .collapse_vlevel = 0x20,
416 .retention_mid_vlevel = 0x89,
417 .collapse_mid_vlevel = 0x89,
418
419 .vctl_timeout_us = 50,
420 },
421};
422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700423/*
424 * Consumer specific regulator names:
425 * regulator name consumer dev_name
426 */
427static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
428 REGULATOR_SUPPLY("8901_s0", NULL),
429};
430static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
431 REGULATOR_SUPPLY("8901_s1", NULL),
432};
433
434static struct regulator_init_data saw_s0_init_data = {
435 .constraints = {
436 .name = "8901_s0",
437 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700438 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700439 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700440 },
441 .consumer_supplies = vreg_consumers_8901_S0,
442 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
443};
444
445static struct regulator_init_data saw_s1_init_data = {
446 .constraints = {
447 .name = "8901_s1",
448 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700449 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700450 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700451 },
452 .consumer_supplies = vreg_consumers_8901_S1,
453 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
454};
455
456static struct platform_device msm_device_saw_s0 = {
457 .name = "saw-regulator",
458 .id = 0,
459 .dev = {
460 .platform_data = &saw_s0_init_data,
461 },
462};
463
464static struct platform_device msm_device_saw_s1 = {
465 .name = "saw-regulator",
466 .id = 1,
467 .dev = {
468 .platform_data = &saw_s1_init_data,
469 },
470};
471
472/*
473 * The smc91x configuration varies depending on platform.
474 * The resources data structure is filled in at runtime.
475 */
476static struct resource smc91x_resources[] = {
477 [0] = {
478 .flags = IORESOURCE_MEM,
479 },
480 [1] = {
481 .flags = IORESOURCE_IRQ,
482 },
483};
484
485static struct platform_device smc91x_device = {
486 .name = "smc91x",
487 .id = 0,
488 .num_resources = ARRAY_SIZE(smc91x_resources),
489 .resource = smc91x_resources,
490};
491
492static struct resource smsc911x_resources[] = {
493 [0] = {
494 .flags = IORESOURCE_MEM,
495 .start = 0x1b800000,
496 .end = 0x1b8000ff
497 },
498 [1] = {
499 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
500 },
501};
502
503static struct smsc911x_platform_config smsc911x_config = {
504 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
505 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
506 .flags = SMSC911X_USE_16BIT,
507 .has_reset_gpio = 1,
508 .reset_gpio = GPIO_ETHERNET_RESET_N
509};
510
511static struct platform_device smsc911x_device = {
512 .name = "smsc911x",
513 .id = 0,
514 .num_resources = ARRAY_SIZE(smsc911x_resources),
515 .resource = smsc911x_resources,
516 .dev = {
517 .platform_data = &smsc911x_config
518 }
519};
520
521#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
522 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
523 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
524 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
525
526#define QCE_SIZE 0x10000
527#define QCE_0_BASE 0x18500000
528
529#define QCE_HW_KEY_SUPPORT 0
530#define QCE_SHA_HMAC_SUPPORT 0
531#define QCE_SHARE_CE_RESOURCE 2
532#define QCE_CE_SHARED 1
533
534static struct resource qcrypto_resources[] = {
535 [0] = {
536 .start = QCE_0_BASE,
537 .end = QCE_0_BASE + QCE_SIZE - 1,
538 .flags = IORESOURCE_MEM,
539 },
540 [1] = {
541 .name = "crypto_channels",
542 .start = DMOV_CE_IN_CHAN,
543 .end = DMOV_CE_OUT_CHAN,
544 .flags = IORESOURCE_DMA,
545 },
546 [2] = {
547 .name = "crypto_crci_in",
548 .start = DMOV_CE_IN_CRCI,
549 .end = DMOV_CE_IN_CRCI,
550 .flags = IORESOURCE_DMA,
551 },
552 [3] = {
553 .name = "crypto_crci_out",
554 .start = DMOV_CE_OUT_CRCI,
555 .end = DMOV_CE_OUT_CRCI,
556 .flags = IORESOURCE_DMA,
557 },
558 [4] = {
559 .name = "crypto_crci_hash",
560 .start = DMOV_CE_HASH_CRCI,
561 .end = DMOV_CE_HASH_CRCI,
562 .flags = IORESOURCE_DMA,
563 },
564};
565
566static struct resource qcedev_resources[] = {
567 [0] = {
568 .start = QCE_0_BASE,
569 .end = QCE_0_BASE + QCE_SIZE - 1,
570 .flags = IORESOURCE_MEM,
571 },
572 [1] = {
573 .name = "crypto_channels",
574 .start = DMOV_CE_IN_CHAN,
575 .end = DMOV_CE_OUT_CHAN,
576 .flags = IORESOURCE_DMA,
577 },
578 [2] = {
579 .name = "crypto_crci_in",
580 .start = DMOV_CE_IN_CRCI,
581 .end = DMOV_CE_IN_CRCI,
582 .flags = IORESOURCE_DMA,
583 },
584 [3] = {
585 .name = "crypto_crci_out",
586 .start = DMOV_CE_OUT_CRCI,
587 .end = DMOV_CE_OUT_CRCI,
588 .flags = IORESOURCE_DMA,
589 },
590 [4] = {
591 .name = "crypto_crci_hash",
592 .start = DMOV_CE_HASH_CRCI,
593 .end = DMOV_CE_HASH_CRCI,
594 .flags = IORESOURCE_DMA,
595 },
596};
597
598#endif
599
600#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
601 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
602
603static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
604 .ce_shared = QCE_CE_SHARED,
605 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
606 .hw_key_support = QCE_HW_KEY_SUPPORT,
607 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800608 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700609};
610
611static struct platform_device qcrypto_device = {
612 .name = "qcrypto",
613 .id = 0,
614 .num_resources = ARRAY_SIZE(qcrypto_resources),
615 .resource = qcrypto_resources,
616 .dev = {
617 .coherent_dma_mask = DMA_BIT_MASK(32),
618 .platform_data = &qcrypto_ce_hw_suppport,
619 },
620};
621#endif
622
623#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
624 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
625
626static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
627 .ce_shared = QCE_CE_SHARED,
628 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
629 .hw_key_support = QCE_HW_KEY_SUPPORT,
630 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800631 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700632};
633
634static struct platform_device qcedev_device = {
635 .name = "qce",
636 .id = 0,
637 .num_resources = ARRAY_SIZE(qcedev_resources),
638 .resource = qcedev_resources,
639 .dev = {
640 .coherent_dma_mask = DMA_BIT_MASK(32),
641 .platform_data = &qcedev_ce_hw_suppport,
642 },
643};
644#endif
645
646#if defined(CONFIG_HAPTIC_ISA1200) || \
647 defined(CONFIG_HAPTIC_ISA1200_MODULE)
648
649static const char *vregs_isa1200_name[] = {
650 "8058_s3",
651 "8901_l4",
652};
653
654static const int vregs_isa1200_val[] = {
655 1800000,/* uV */
656 2600000,
657};
658static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
659static struct msm_xo_voter *xo_handle_a1;
660
661static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800662{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700663 int i, rc = 0;
664
665 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
666 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
667 regulator_disable(vregs_isa1200[i]);
668 if (rc < 0) {
669 pr_err("%s: vreg %s %s failed (%d)\n",
670 __func__, vregs_isa1200_name[i],
671 vreg_on ? "enable" : "disable", rc);
672 goto vreg_fail;
673 }
674 }
675
676 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
677 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
678 if (rc < 0) {
679 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
680 __func__, vreg_on ? "" : "de-", rc);
681 goto vreg_fail;
682 }
683 return 0;
684
685vreg_fail:
686 while (i--)
687 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
688 regulator_disable(vregs_isa1200[i]);
689 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800690}
691
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800693{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700694 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800695
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700696 if (enable == true) {
697 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
698 vregs_isa1200[i] = regulator_get(NULL,
699 vregs_isa1200_name[i]);
700 if (IS_ERR(vregs_isa1200[i])) {
701 pr_err("%s: regulator get of %s failed (%ld)\n",
702 __func__, vregs_isa1200_name[i],
703 PTR_ERR(vregs_isa1200[i]));
704 rc = PTR_ERR(vregs_isa1200[i]);
705 goto vreg_get_fail;
706 }
707 rc = regulator_set_voltage(vregs_isa1200[i],
708 vregs_isa1200_val[i], vregs_isa1200_val[i]);
709 if (rc) {
710 pr_err("%s: regulator_set_voltage(%s) failed\n",
711 __func__, vregs_isa1200_name[i]);
712 goto vreg_get_fail;
713 }
714 }
Steve Muckle9161d302010-02-11 11:50:40 -0800715
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700716 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
717 if (rc) {
718 pr_err("%s: unable to request gpio %d (%d)\n",
719 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
720 goto vreg_get_fail;
721 }
Steve Muckle9161d302010-02-11 11:50:40 -0800722
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
724 if (rc) {
725 pr_err("%s: Unable to set direction\n", __func__);;
726 goto free_gpio;
727 }
728
729 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
730 if (IS_ERR(xo_handle_a1)) {
731 rc = PTR_ERR(xo_handle_a1);
732 pr_err("%s: failed to get the handle for A1(%d)\n",
733 __func__, rc);
734 goto gpio_set_dir;
735 }
736 } else {
737 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
738 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
739
740 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
741 regulator_put(vregs_isa1200[i]);
742
743 msm_xo_put(xo_handle_a1);
744 }
745
746 return 0;
747gpio_set_dir:
748 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
749free_gpio:
750 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
751vreg_get_fail:
752 while (i)
753 regulator_put(vregs_isa1200[--i]);
754 return rc;
755}
756
757#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530758#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700759static struct isa1200_platform_data isa1200_1_pdata = {
760 .name = "vibrator",
761 .power_on = isa1200_power,
762 .dev_setup = isa1200_dev_setup,
763 /*gpio to enable haptic*/
764 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530765 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700766 .max_timeout = 15000,
767 .mode_ctrl = PWM_GEN_MODE,
768 .pwm_fd = {
769 .pwm_div = 256,
770 },
771 .is_erm = false,
772 .smart_en = true,
773 .ext_clk_en = true,
774 .chip_en = 1,
775};
776
777static struct i2c_board_info msm_isa1200_board_info[] = {
778 {
779 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
780 .platform_data = &isa1200_1_pdata,
781 },
782};
783#endif
784
785#if defined(CONFIG_BATTERY_BQ27520) || \
786 defined(CONFIG_BATTERY_BQ27520_MODULE)
787static struct bq27520_platform_data bq27520_pdata = {
788 .name = "fuel-gauge",
789 .vreg_name = "8058_s3",
790 .vreg_value = 1800000,
791 .soc_int = GPIO_BATT_GAUGE_INT_N,
792 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
793 .chip_en = GPIO_BATT_GAUGE_EN,
794 .enable_dlog = 0, /* if enable coulomb counter logger */
795};
796
797static struct i2c_board_info msm_bq27520_board_info[] = {
798 {
799 I2C_BOARD_INFO("bq27520", 0xaa>>1),
800 .platform_data = &bq27520_pdata,
801 },
802};
803#endif
804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
806 {
807 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
808 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
809 true,
810 1, 8000, 100000, 1,
811 },
812
813 {
814 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
815 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
816 true,
817 1500, 5000, 60100000, 3000,
818 },
819
820 {
821 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
822 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
823 false,
824 1800, 5000, 60350000, 3500,
825 },
826 {
827 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
828 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
829 false,
830 3800, 4500, 65350000, 5500,
831 },
832
833 {
834 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
835 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
836 false,
837 2800, 2500, 66850000, 4800,
838 },
839
840 {
841 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
842 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
843 false,
844 4800, 2000, 71850000, 6800,
845 },
846
847 {
848 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
849 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
850 false,
851 6800, 500, 75850000, 8800,
852 },
853
854 {
855 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
856 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
857 false,
858 7800, 0, 76350000, 9800,
859 },
860};
861
Praveen Chidambaram78499012011-11-01 17:15:17 -0600862static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
863 .levels = &msm_rpmrs_levels[0],
864 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
865 .vdd_mem_levels = {
866 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
867 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
868 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700869 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600870 },
871 .vdd_dig_levels = {
872 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
873 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
874 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
875 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
876 },
877 .vdd_mask = 0xFFF,
878 .rpmrs_target_id = {
879 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
880 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
881 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
882 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
883 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
884 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
885 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
886 },
887};
888
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600889static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
890 .mode = MSM_PM_BOOT_CONFIG_TZ,
891};
892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700893#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
894
895#define ISP1763_INT_GPIO 117
896#define ISP1763_RST_GPIO 152
897static struct resource isp1763_resources[] = {
898 [0] = {
899 .flags = IORESOURCE_MEM,
900 .start = 0x1D000000,
901 .end = 0x1D005FFF, /* 24KB */
902 },
903 [1] = {
904 .flags = IORESOURCE_IRQ,
905 },
906};
907static void __init msm8x60_cfg_isp1763(void)
908{
909 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
910 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
911}
912
913static int isp1763_setup_gpio(int enable)
914{
915 int status = 0;
916
917 if (enable) {
918 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
919 if (status) {
920 pr_err("%s:Failed to request GPIO %d\n",
921 __func__, ISP1763_INT_GPIO);
922 return status;
923 }
924 status = gpio_direction_input(ISP1763_INT_GPIO);
925 if (status) {
926 pr_err("%s:Failed to configure GPIO %d\n",
927 __func__, ISP1763_INT_GPIO);
928 goto gpio_free_int;
929 }
930 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
931 if (status) {
932 pr_err("%s:Failed to request GPIO %d\n",
933 __func__, ISP1763_RST_GPIO);
934 goto gpio_free_int;
935 }
936 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
937 if (status) {
938 pr_err("%s:Failed to configure GPIO %d\n",
939 __func__, ISP1763_RST_GPIO);
940 goto gpio_free_rst;
941 }
942 pr_debug("\nISP GPIO configuration done\n");
943 return status;
944 }
945
946gpio_free_rst:
947 gpio_free(ISP1763_RST_GPIO);
948gpio_free_int:
949 gpio_free(ISP1763_INT_GPIO);
950
951 return status;
952}
953static struct isp1763_platform_data isp1763_pdata = {
954 .reset_gpio = ISP1763_RST_GPIO,
955 .setup_gpio = isp1763_setup_gpio
956};
957
958static struct platform_device isp1763_device = {
959 .name = "isp1763_usb",
960 .num_resources = ARRAY_SIZE(isp1763_resources),
961 .resource = isp1763_resources,
962 .dev = {
963 .platform_data = &isp1763_pdata
964 }
965};
966#endif
967
Lena Salman57d167e2012-03-21 19:46:38 +0200968#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530969static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700970static struct regulator *ldo6_3p3;
971static struct regulator *ldo7_1p8;
972static struct regulator *vdd_cx;
973#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530974#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700975notify_vbus_state notify_vbus_state_func_ptr;
976static int usb_phy_susp_dig_vol = 750000;
977static int pmic_id_notif_supported;
978
979#ifdef CONFIG_USB_EHCI_MSM_72K
980#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
981struct delayed_work pmic_id_det;
982
983static int __init usb_id_pin_rework_setup(char *support)
984{
985 if (strncmp(support, "true", 4) == 0)
986 pmic_id_notif_supported = 1;
987
988 return 1;
989}
990__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
991
992static void pmic_id_detect(struct work_struct *w)
993{
994 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
995 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
996
997 if (notify_vbus_state_func_ptr)
998 (*notify_vbus_state_func_ptr) (val);
999}
1000
1001static irqreturn_t pmic_id_on_irq(int irq, void *data)
1002{
1003 /*
1004 * Spurious interrupts are observed on pmic gpio line
1005 * even though there is no state change on USB ID. Schedule the
1006 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001007 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001008 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001010 return IRQ_HANDLED;
1011}
1012
Anji jonnalaae745e92011-11-14 18:34:31 +05301013static int msm_hsusb_phy_id_setup_init(int init)
1014{
1015 unsigned ret;
1016
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301017 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1018 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1019 .level = PM8901_MPP_DIG_LEVEL_L5,
1020 };
1021
Anji jonnalaae745e92011-11-14 18:34:31 +05301022 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301023 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1024 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1025 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301026 if (ret < 0)
1027 pr_err("%s:MPP2 configuration failed\n", __func__);
1028 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301029 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1030 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1031 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301032 if (ret < 0)
1033 pr_err("%s:MPP2 un config failed\n", __func__);
1034 }
1035 return ret;
1036}
1037
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001038static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1039{
1040 unsigned ret = -ENODEV;
1041
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301042 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301043 .direction = PM_GPIO_DIR_IN,
1044 .pull = PM_GPIO_PULL_UP_1P5,
1045 .function = PM_GPIO_FUNC_NORMAL,
1046 .vin_sel = 2,
1047 .inv_int_pol = 0,
1048 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301049 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301050 .direction = PM_GPIO_DIR_IN,
1051 .pull = PM_GPIO_PULL_NO,
1052 .function = PM_GPIO_FUNC_NORMAL,
1053 .vin_sel = 2,
1054 .inv_int_pol = 0,
1055 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001056 if (!callback)
1057 return -EINVAL;
1058
1059 if (machine_is_msm8x60_fluid())
1060 return -ENOTSUPP;
1061
1062 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1063 pr_debug("%s: USB_ID pin is not routed to PMIC"
1064 "on V1 surf/ffa\n", __func__);
1065 return -ENOTSUPP;
1066 }
1067
Manu Gautam62158eb2011-11-24 16:20:46 +05301068 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1069 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070 pr_debug("%s: USB_ID is not routed to PMIC"
1071 "on V2 ffa\n", __func__);
1072 return -ENOTSUPP;
1073 }
1074
1075 usb_phy_susp_dig_vol = 500000;
1076
1077 if (init) {
1078 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301079 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301080 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1081 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301082 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301083 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301084 __func__, ret);
1085 return ret;
1086 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001087 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1088 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1089 "msm_otg_id", NULL);
1090 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001091 pr_err("%s:pmic_usb_id interrupt registration failed",
1092 __func__);
1093 return ret;
1094 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301095 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001096 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301097 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001098 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301099 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1100 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301101 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301102 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301103 __func__, ret);
1104 return ret;
1105 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301106 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001107 cancel_delayed_work_sync(&pmic_id_det);
1108 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001109 }
1110 return 0;
1111}
1112#endif
1113
1114#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1115#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1116static int msm_hsusb_init_vddcx(int init)
1117{
1118 int ret = 0;
1119
1120 if (init) {
1121 vdd_cx = regulator_get(NULL, "8058_s1");
1122 if (IS_ERR(vdd_cx)) {
1123 return PTR_ERR(vdd_cx);
1124 }
1125
1126 ret = regulator_set_voltage(vdd_cx,
1127 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1128 USB_PHY_MAX_VDD_DIG_VOL);
1129 if (ret) {
1130 pr_err("%s: unable to set the voltage for regulator"
1131 "vdd_cx\n", __func__);
1132 regulator_put(vdd_cx);
1133 return ret;
1134 }
1135
1136 ret = regulator_enable(vdd_cx);
1137 if (ret) {
1138 pr_err("%s: unable to enable regulator"
1139 "vdd_cx\n", __func__);
1140 regulator_put(vdd_cx);
1141 }
1142 } else {
1143 ret = regulator_disable(vdd_cx);
1144 if (ret) {
1145 pr_err("%s: Unable to disable the regulator:"
1146 "vdd_cx\n", __func__);
1147 return ret;
1148 }
1149
1150 regulator_put(vdd_cx);
1151 }
1152
1153 return ret;
1154}
1155
1156static int msm_hsusb_config_vddcx(int high)
1157{
1158 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1159 int min_vol;
1160 int ret;
1161
1162 if (high)
1163 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1164 else
1165 min_vol = usb_phy_susp_dig_vol;
1166
1167 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1168 if (ret) {
1169 pr_err("%s: unable to set the voltage for regulator"
1170 "vdd_cx\n", __func__);
1171 return ret;
1172 }
1173
1174 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1175
1176 return ret;
1177}
1178
1179#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1180#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1181#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1182#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1183
1184#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1185#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1186#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1187#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1188static int msm_hsusb_ldo_init(int init)
1189{
1190 int rc = 0;
1191
1192 if (init) {
1193 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1194 if (IS_ERR(ldo6_3p3))
1195 return PTR_ERR(ldo6_3p3);
1196
1197 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1198 if (IS_ERR(ldo7_1p8)) {
1199 rc = PTR_ERR(ldo7_1p8);
1200 goto put_3p3;
1201 }
1202
1203 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1204 USB_PHY_3P3_VOL_MAX);
1205 if (rc) {
1206 pr_err("%s: Unable to set voltage level for"
1207 "ldo6_3p3 regulator\n", __func__);
1208 goto put_1p8;
1209 }
1210 rc = regulator_enable(ldo6_3p3);
1211 if (rc) {
1212 pr_err("%s: Unable to enable the regulator:"
1213 "ldo6_3p3\n", __func__);
1214 goto put_1p8;
1215 }
1216 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1217 USB_PHY_1P8_VOL_MAX);
1218 if (rc) {
1219 pr_err("%s: Unable to set voltage level for"
1220 "ldo7_1p8 regulator\n", __func__);
1221 goto disable_3p3;
1222 }
1223 rc = regulator_enable(ldo7_1p8);
1224 if (rc) {
1225 pr_err("%s: Unable to enable the regulator:"
1226 "ldo7_1p8\n", __func__);
1227 goto disable_3p3;
1228 }
1229
1230 return 0;
1231 }
1232
1233 regulator_disable(ldo7_1p8);
1234disable_3p3:
1235 regulator_disable(ldo6_3p3);
1236put_1p8:
1237 regulator_put(ldo7_1p8);
1238put_3p3:
1239 regulator_put(ldo6_3p3);
1240 return rc;
1241}
1242
1243static int msm_hsusb_ldo_enable(int on)
1244{
1245 int ret = 0;
1246
1247 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1248 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1249 return -ENODEV;
1250 }
1251
1252 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1253 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1254 return -ENODEV;
1255 }
1256
1257 if (on) {
1258 ret = regulator_set_optimum_mode(ldo7_1p8,
1259 USB_PHY_1P8_HPM_LOAD);
1260 if (ret < 0) {
1261 pr_err("%s: Unable to set HPM of the regulator:"
1262 "ldo7_1p8\n", __func__);
1263 return ret;
1264 }
1265 ret = regulator_set_optimum_mode(ldo6_3p3,
1266 USB_PHY_3P3_HPM_LOAD);
1267 if (ret < 0) {
1268 pr_err("%s: Unable to set HPM of the regulator:"
1269 "ldo6_3p3\n", __func__);
1270 regulator_set_optimum_mode(ldo7_1p8,
1271 USB_PHY_1P8_LPM_LOAD);
1272 return ret;
1273 }
1274 } else {
1275 ret = regulator_set_optimum_mode(ldo7_1p8,
1276 USB_PHY_1P8_LPM_LOAD);
1277 if (ret < 0)
1278 pr_err("%s: Unable to set LPM of the regulator:"
1279 "ldo7_1p8\n", __func__);
1280 ret = regulator_set_optimum_mode(ldo6_3p3,
1281 USB_PHY_3P3_LPM_LOAD);
1282 if (ret < 0)
1283 pr_err("%s: Unable to set LPM of the regulator:"
1284 "ldo6_3p3\n", __func__);
1285 }
1286
1287 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1288 return ret < 0 ? ret : 0;
1289 }
1290#endif
1291#ifdef CONFIG_USB_EHCI_MSM_72K
1292#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1293static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1294{
1295 static int vbus_is_on;
1296
1297 /* If VBUS is already on (or off), do nothing. */
1298 if (on == vbus_is_on)
1299 return;
1300 smb137b_otg_power(on);
1301 vbus_is_on = on;
1302}
1303#endif
1304static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1305{
1306 static struct regulator *votg_5v_switch;
1307 static struct regulator *ext_5v_reg;
1308 static int vbus_is_on;
1309
1310 /* If VBUS is already on (or off), do nothing. */
1311 if (on == vbus_is_on)
1312 return;
1313
1314 if (!votg_5v_switch) {
1315 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1316 if (IS_ERR(votg_5v_switch)) {
1317 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1318 return;
1319 }
1320 }
1321 if (!ext_5v_reg) {
1322 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1323 if (IS_ERR(ext_5v_reg)) {
1324 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1325 return;
1326 }
1327 }
1328 if (on) {
1329 if (regulator_enable(ext_5v_reg)) {
1330 pr_err("%s: Unable to enable the regulator:"
1331 " ext_5v_reg\n", __func__);
1332 return;
1333 }
1334 if (regulator_enable(votg_5v_switch)) {
1335 pr_err("%s: Unable to enable the regulator:"
1336 " votg_5v_switch\n", __func__);
1337 return;
1338 }
1339 } else {
1340 if (regulator_disable(votg_5v_switch))
1341 pr_err("%s: Unable to enable the regulator:"
1342 " votg_5v_switch\n", __func__);
1343 if (regulator_disable(ext_5v_reg))
1344 pr_err("%s: Unable to enable the regulator:"
1345 " ext_5v_reg\n", __func__);
1346 }
1347
1348 vbus_is_on = on;
1349}
1350
1351static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1352 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1353 .power_budget = 390,
1354};
1355#endif
1356
1357#ifdef CONFIG_BATTERY_MSM8X60
1358static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1359 int init)
1360{
1361 int ret = -ENOTSUPP;
1362
1363#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1364 if (machine_is_msm8x60_fluid()) {
1365 if (init)
1366 msm_charger_register_vbus_sn(callback);
1367 else
1368 msm_charger_unregister_vbus_sn(callback);
1369 return 0;
1370 }
1371#endif
1372 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1373 * hence, irrespective of either peripheral only mode or
1374 * OTG (host and peripheral) modes, can depend on pmic for
1375 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001376 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1378 && (machine_is_msm8x60_surf() ||
1379 pmic_id_notif_supported)) {
1380 if (init)
1381 ret = msm_charger_register_vbus_sn(callback);
1382 else {
1383 msm_charger_unregister_vbus_sn(callback);
1384 ret = 0;
1385 }
1386 } else {
1387#if !defined(CONFIG_USB_EHCI_MSM_72K)
1388 if (init)
1389 ret = msm_charger_register_vbus_sn(callback);
1390 else {
1391 msm_charger_unregister_vbus_sn(callback);
1392 ret = 0;
1393 }
1394#endif
1395 }
1396 return ret;
1397}
1398#endif
1399
Lena Salman57d167e2012-03-21 19:46:38 +02001400#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001401static struct msm_otg_platform_data msm_otg_pdata = {
1402 /* if usb link is in sps there is no need for
1403 * usb pclk as dayatona fabric clock will be
1404 * used instead
1405 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1407 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1408 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301409 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410#ifdef CONFIG_USB_EHCI_MSM_72K
1411 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301412 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001413#endif
1414#ifdef CONFIG_USB_EHCI_MSM_72K
1415 .vbus_power = msm_hsusb_vbus_power,
1416#endif
1417#ifdef CONFIG_BATTERY_MSM8X60
1418 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1419#endif
1420 .ldo_init = msm_hsusb_ldo_init,
1421 .ldo_enable = msm_hsusb_ldo_enable,
1422 .config_vddcx = msm_hsusb_config_vddcx,
1423 .init_vddcx = msm_hsusb_init_vddcx,
1424#ifdef CONFIG_BATTERY_MSM8X60
1425 .chg_vbus_draw = msm_charger_vbus_draw,
1426#endif
1427};
1428#endif
1429
Lena Salman57d167e2012-03-21 19:46:38 +02001430#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001431static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1432 .is_phy_status_timer_on = 1,
1433};
1434#endif
1435
1436#ifdef CONFIG_USB_G_ANDROID
1437
1438#define PID_MAGIC_ID 0x71432909
1439#define SERIAL_NUM_MAGIC_ID 0x61945374
1440#define SERIAL_NUMBER_LENGTH 127
1441#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1442
1443struct magic_num_struct {
1444 uint32_t pid;
1445 uint32_t serial_num;
1446};
1447
1448struct dload_struct {
1449 uint32_t reserved1;
1450 uint32_t reserved2;
1451 uint32_t reserved3;
1452 uint16_t reserved4;
1453 uint16_t pid;
1454 char serial_number[SERIAL_NUMBER_LENGTH];
1455 uint16_t reserved5;
1456 struct magic_num_struct
1457 magic_struct;
1458};
1459
1460static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1461{
1462 struct dload_struct __iomem *dload = 0;
1463
1464 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1465 if (!dload) {
1466 pr_err("%s: cannot remap I/O memory region: %08x\n",
1467 __func__, DLOAD_USB_BASE_ADD);
1468 return -ENXIO;
1469 }
1470
1471 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1472 __func__, dload, pid, snum);
1473 /* update pid */
1474 dload->magic_struct.pid = PID_MAGIC_ID;
1475 dload->pid = pid;
1476
1477 /* update serial number */
1478 dload->magic_struct.serial_num = 0;
1479 if (!snum)
1480 return 0;
1481
1482 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1483 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1484 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1485
1486 iounmap(dload);
1487
1488 return 0;
1489}
1490
1491static struct android_usb_platform_data android_usb_pdata = {
1492 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1493};
1494
1495static struct platform_device android_usb_device = {
1496 .name = "android_usb",
1497 .id = -1,
1498 .dev = {
1499 .platform_data = &android_usb_pdata,
1500 },
1501};
1502
1503
1504#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001505
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001506#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001507#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001508static struct resource msm_vpe_resources[] = {
1509 {
1510 .start = 0x05300000,
1511 .end = 0x05300000 + SZ_1M - 1,
1512 .flags = IORESOURCE_MEM,
1513 },
1514 {
1515 .start = INT_VPE,
1516 .end = INT_VPE,
1517 .flags = IORESOURCE_IRQ,
1518 },
1519};
1520
1521static struct platform_device msm_vpe_device = {
1522 .name = "msm_vpe",
1523 .id = 0,
1524 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1525 .resource = msm_vpe_resources,
1526};
1527#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001528#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001529
1530#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001531#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001532#ifdef CONFIG_MSM_CAMERA_FLASH
1533#define VFE_CAMIF_TIMER1_GPIO 29
1534#define VFE_CAMIF_TIMER2_GPIO 30
1535#define VFE_CAMIF_TIMER3_GPIO_INT 31
1536#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1537static struct msm_camera_sensor_flash_src msm_flash_src = {
1538 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1539 ._fsrc.pmic_src.num_of_src = 2,
1540 ._fsrc.pmic_src.low_current = 100,
1541 ._fsrc.pmic_src.high_current = 300,
1542 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1543 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1544 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1545};
1546#ifdef CONFIG_IMX074
1547static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1548 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1549 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1550 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1551 .flash_recharge_duration = 50000,
1552 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1553};
1554#endif
1555#endif
1556
1557int msm_cam_gpio_tbl[] = {
1558 32,/*CAMIF_MCLK*/
1559 47,/*CAMIF_I2C_DATA*/
1560 48,/*CAMIF_I2C_CLK*/
1561 105,/*STANDBY*/
1562};
1563
1564enum msm_cam_stat{
1565 MSM_CAM_OFF,
1566 MSM_CAM_ON,
1567};
1568
1569static int config_gpio_table(enum msm_cam_stat stat)
1570{
1571 int rc = 0, i = 0;
1572 if (stat == MSM_CAM_ON) {
1573 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1574 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1575 if (unlikely(rc < 0)) {
1576 pr_err("%s not able to get gpio\n", __func__);
1577 for (i--; i >= 0; i--)
1578 gpio_free(msm_cam_gpio_tbl[i]);
1579 break;
1580 }
1581 }
1582 } else {
1583 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1584 gpio_free(msm_cam_gpio_tbl[i]);
1585 }
1586 return rc;
1587}
1588
1589static struct msm_camera_sensor_platform_info sensor_board_info = {
1590 .mount_angle = 0
1591};
1592
1593/*external regulator VREG_5V*/
1594static struct regulator *reg_flash_5V;
1595
1596static int config_camera_on_gpios_fluid(void)
1597{
1598 int rc = 0;
1599
1600 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1601 if (IS_ERR(reg_flash_5V)) {
1602 pr_err("'%s' regulator not found, rc=%ld\n",
1603 "8901_mpp0", IS_ERR(reg_flash_5V));
1604 return -ENODEV;
1605 }
1606
1607 rc = regulator_enable(reg_flash_5V);
1608 if (rc) {
1609 pr_err("'%s' regulator enable failed, rc=%d\n",
1610 "8901_mpp0", rc);
1611 regulator_put(reg_flash_5V);
1612 return rc;
1613 }
1614
1615#ifdef CONFIG_IMX074
1616 sensor_board_info.mount_angle = 90;
1617#endif
1618 rc = config_gpio_table(MSM_CAM_ON);
1619 if (rc < 0) {
1620 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1621 "failed\n", __func__);
1622 return rc;
1623 }
1624
1625 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1626 if (rc < 0) {
1627 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1628 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1629 regulator_disable(reg_flash_5V);
1630 regulator_put(reg_flash_5V);
1631 return rc;
1632 }
1633 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1634 msleep(20);
1635 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1636
1637
1638 /*Enable LED_FLASH_EN*/
1639 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1640 if (rc < 0) {
1641 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1642 "failed\n", __func__, GPIO_LED_FLASH_EN);
1643
1644 regulator_disable(reg_flash_5V);
1645 regulator_put(reg_flash_5V);
1646 config_gpio_table(MSM_CAM_OFF);
1647 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1648 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1649 return rc;
1650 }
1651 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1652 msleep(20);
1653 return rc;
1654}
1655
1656
1657static void config_camera_off_gpios_fluid(void)
1658{
1659 regulator_disable(reg_flash_5V);
1660 regulator_put(reg_flash_5V);
1661
1662 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1663 gpio_free(GPIO_LED_FLASH_EN);
1664
1665 config_gpio_table(MSM_CAM_OFF);
1666
1667 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1668 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1669}
1670static int config_camera_on_gpios(void)
1671{
1672 int rc = 0;
1673
1674 if (machine_is_msm8x60_fluid())
1675 return config_camera_on_gpios_fluid();
1676
1677 rc = config_gpio_table(MSM_CAM_ON);
1678 if (rc < 0) {
1679 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1680 "failed\n", __func__);
1681 return rc;
1682 }
1683
Jilai Wang971f97f2011-07-13 14:25:25 -04001684 if (!machine_is_msm8x60_dragon()) {
1685 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1686 if (rc < 0) {
1687 config_gpio_table(MSM_CAM_OFF);
1688 pr_err("%s: CAMSENSOR gpio %d request"
1689 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1690 return rc;
1691 }
1692 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1693 msleep(20);
1694 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001695 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001696
1697#ifdef CONFIG_MSM_CAMERA_FLASH
1698#ifdef CONFIG_IMX074
1699 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1700 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1701#endif
1702#endif
1703 return rc;
1704}
1705
1706static void config_camera_off_gpios(void)
1707{
1708 if (machine_is_msm8x60_fluid())
1709 return config_camera_off_gpios_fluid();
1710
1711
1712 config_gpio_table(MSM_CAM_OFF);
1713
Jilai Wang971f97f2011-07-13 14:25:25 -04001714 if (!machine_is_msm8x60_dragon()) {
1715 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1716 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1717 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001718}
1719
1720#ifdef CONFIG_QS_S5K4E1
1721
1722#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1723
1724static int config_camera_on_gpios_qs_cam_fluid(void)
1725{
1726 int rc = 0;
1727
1728 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1729 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1730 if (rc < 0) {
1731 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1732 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1733 return rc;
1734 }
1735 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1736 msleep(20);
1737 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1738 msleep(20);
1739
1740 /*
1741 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1742 * to enable 2.7V power to Camera
1743 */
1744 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1745 if (rc < 0) {
1746 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1747 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1748 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1749 gpio_free(QS_CAM_HC37_CAM_PD);
1750 return rc;
1751 }
1752 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1753 msleep(20);
1754 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1755 msleep(20);
1756
1757 rc = config_camera_on_gpios_fluid();
1758 if (rc < 0) {
1759 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1760 " failed\n", __func__);
1761 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1762 gpio_free(QS_CAM_HC37_CAM_PD);
1763 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1764 gpio_free(GPIO_AUX_CAM_2P7_EN);
1765 return rc;
1766 }
1767 return rc;
1768}
1769
1770static void config_camera_off_gpios_qs_cam_fluid(void)
1771{
1772 /*
1773 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1774 * to disable 2.7V power to Camera
1775 */
1776 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1777 gpio_free(GPIO_AUX_CAM_2P7_EN);
1778
1779 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1780 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1781 gpio_free(QS_CAM_HC37_CAM_PD);
1782
1783 config_camera_off_gpios_fluid();
1784 return;
1785}
1786
1787static int config_camera_on_gpios_qs_cam(void)
1788{
1789 int rc = 0;
1790
1791 if (machine_is_msm8x60_fluid())
1792 return config_camera_on_gpios_qs_cam_fluid();
1793
1794 rc = config_camera_on_gpios();
1795 return rc;
1796}
1797
1798static void config_camera_off_gpios_qs_cam(void)
1799{
1800 if (machine_is_msm8x60_fluid())
1801 return config_camera_off_gpios_qs_cam_fluid();
1802
1803 config_camera_off_gpios();
1804 return;
1805}
1806#endif
1807
1808static int config_camera_on_gpios_web_cam(void)
1809{
1810 int rc = 0;
1811 rc = config_gpio_table(MSM_CAM_ON);
1812 if (rc < 0) {
1813 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1814 "failed\n", __func__);
1815 return rc;
1816 }
1817
Jilai Wang53d27a82011-07-13 14:32:58 -04001818 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001819 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1820 if (rc < 0) {
1821 config_gpio_table(MSM_CAM_OFF);
1822 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1823 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1824 return rc;
1825 }
1826 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1827 }
1828 return rc;
1829}
1830
1831static void config_camera_off_gpios_web_cam(void)
1832{
1833 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001834 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001835 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1836 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1837 }
1838 return;
1839}
1840
1841#ifdef CONFIG_MSM_BUS_SCALING
1842static struct msm_bus_vectors cam_init_vectors[] = {
1843 {
1844 .src = MSM_BUS_MASTER_VFE,
1845 .dst = MSM_BUS_SLAVE_SMI,
1846 .ab = 0,
1847 .ib = 0,
1848 },
1849 {
1850 .src = MSM_BUS_MASTER_VFE,
1851 .dst = MSM_BUS_SLAVE_EBI_CH0,
1852 .ab = 0,
1853 .ib = 0,
1854 },
1855 {
1856 .src = MSM_BUS_MASTER_VPE,
1857 .dst = MSM_BUS_SLAVE_SMI,
1858 .ab = 0,
1859 .ib = 0,
1860 },
1861 {
1862 .src = MSM_BUS_MASTER_VPE,
1863 .dst = MSM_BUS_SLAVE_EBI_CH0,
1864 .ab = 0,
1865 .ib = 0,
1866 },
1867 {
1868 .src = MSM_BUS_MASTER_JPEG_ENC,
1869 .dst = MSM_BUS_SLAVE_SMI,
1870 .ab = 0,
1871 .ib = 0,
1872 },
1873 {
1874 .src = MSM_BUS_MASTER_JPEG_ENC,
1875 .dst = MSM_BUS_SLAVE_EBI_CH0,
1876 .ab = 0,
1877 .ib = 0,
1878 },
1879};
1880
1881static struct msm_bus_vectors cam_preview_vectors[] = {
1882 {
1883 .src = MSM_BUS_MASTER_VFE,
1884 .dst = MSM_BUS_SLAVE_SMI,
1885 .ab = 0,
1886 .ib = 0,
1887 },
1888 {
1889 .src = MSM_BUS_MASTER_VFE,
1890 .dst = MSM_BUS_SLAVE_EBI_CH0,
1891 .ab = 283115520,
1892 .ib = 452984832,
1893 },
1894 {
1895 .src = MSM_BUS_MASTER_VPE,
1896 .dst = MSM_BUS_SLAVE_SMI,
1897 .ab = 0,
1898 .ib = 0,
1899 },
1900 {
1901 .src = MSM_BUS_MASTER_VPE,
1902 .dst = MSM_BUS_SLAVE_EBI_CH0,
1903 .ab = 0,
1904 .ib = 0,
1905 },
1906 {
1907 .src = MSM_BUS_MASTER_JPEG_ENC,
1908 .dst = MSM_BUS_SLAVE_SMI,
1909 .ab = 0,
1910 .ib = 0,
1911 },
1912 {
1913 .src = MSM_BUS_MASTER_JPEG_ENC,
1914 .dst = MSM_BUS_SLAVE_EBI_CH0,
1915 .ab = 0,
1916 .ib = 0,
1917 },
1918};
1919
1920static struct msm_bus_vectors cam_video_vectors[] = {
1921 {
1922 .src = MSM_BUS_MASTER_VFE,
1923 .dst = MSM_BUS_SLAVE_SMI,
1924 .ab = 283115520,
1925 .ib = 452984832,
1926 },
1927 {
1928 .src = MSM_BUS_MASTER_VFE,
1929 .dst = MSM_BUS_SLAVE_EBI_CH0,
1930 .ab = 283115520,
1931 .ib = 452984832,
1932 },
1933 {
1934 .src = MSM_BUS_MASTER_VPE,
1935 .dst = MSM_BUS_SLAVE_SMI,
1936 .ab = 319610880,
1937 .ib = 511377408,
1938 },
1939 {
1940 .src = MSM_BUS_MASTER_VPE,
1941 .dst = MSM_BUS_SLAVE_EBI_CH0,
1942 .ab = 0,
1943 .ib = 0,
1944 },
1945 {
1946 .src = MSM_BUS_MASTER_JPEG_ENC,
1947 .dst = MSM_BUS_SLAVE_SMI,
1948 .ab = 0,
1949 .ib = 0,
1950 },
1951 {
1952 .src = MSM_BUS_MASTER_JPEG_ENC,
1953 .dst = MSM_BUS_SLAVE_EBI_CH0,
1954 .ab = 0,
1955 .ib = 0,
1956 },
1957};
1958
1959static struct msm_bus_vectors cam_snapshot_vectors[] = {
1960 {
1961 .src = MSM_BUS_MASTER_VFE,
1962 .dst = MSM_BUS_SLAVE_SMI,
1963 .ab = 566231040,
1964 .ib = 905969664,
1965 },
1966 {
1967 .src = MSM_BUS_MASTER_VFE,
1968 .dst = MSM_BUS_SLAVE_EBI_CH0,
1969 .ab = 69984000,
1970 .ib = 111974400,
1971 },
1972 {
1973 .src = MSM_BUS_MASTER_VPE,
1974 .dst = MSM_BUS_SLAVE_SMI,
1975 .ab = 0,
1976 .ib = 0,
1977 },
1978 {
1979 .src = MSM_BUS_MASTER_VPE,
1980 .dst = MSM_BUS_SLAVE_EBI_CH0,
1981 .ab = 0,
1982 .ib = 0,
1983 },
1984 {
1985 .src = MSM_BUS_MASTER_JPEG_ENC,
1986 .dst = MSM_BUS_SLAVE_SMI,
1987 .ab = 320864256,
1988 .ib = 513382810,
1989 },
1990 {
1991 .src = MSM_BUS_MASTER_JPEG_ENC,
1992 .dst = MSM_BUS_SLAVE_EBI_CH0,
1993 .ab = 320864256,
1994 .ib = 513382810,
1995 },
1996};
1997
1998static struct msm_bus_vectors cam_zsl_vectors[] = {
1999 {
2000 .src = MSM_BUS_MASTER_VFE,
2001 .dst = MSM_BUS_SLAVE_SMI,
2002 .ab = 566231040,
2003 .ib = 905969664,
2004 },
2005 {
2006 .src = MSM_BUS_MASTER_VFE,
2007 .dst = MSM_BUS_SLAVE_EBI_CH0,
2008 .ab = 706199040,
2009 .ib = 1129918464,
2010 },
2011 {
2012 .src = MSM_BUS_MASTER_VPE,
2013 .dst = MSM_BUS_SLAVE_SMI,
2014 .ab = 0,
2015 .ib = 0,
2016 },
2017 {
2018 .src = MSM_BUS_MASTER_VPE,
2019 .dst = MSM_BUS_SLAVE_EBI_CH0,
2020 .ab = 0,
2021 .ib = 0,
2022 },
2023 {
2024 .src = MSM_BUS_MASTER_JPEG_ENC,
2025 .dst = MSM_BUS_SLAVE_SMI,
2026 .ab = 320864256,
2027 .ib = 513382810,
2028 },
2029 {
2030 .src = MSM_BUS_MASTER_JPEG_ENC,
2031 .dst = MSM_BUS_SLAVE_EBI_CH0,
2032 .ab = 320864256,
2033 .ib = 513382810,
2034 },
2035};
2036
2037static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2038 {
2039 .src = MSM_BUS_MASTER_VFE,
2040 .dst = MSM_BUS_SLAVE_SMI,
2041 .ab = 212336640,
2042 .ib = 339738624,
2043 },
2044 {
2045 .src = MSM_BUS_MASTER_VFE,
2046 .dst = MSM_BUS_SLAVE_EBI_CH0,
2047 .ab = 25090560,
2048 .ib = 40144896,
2049 },
2050 {
2051 .src = MSM_BUS_MASTER_VPE,
2052 .dst = MSM_BUS_SLAVE_SMI,
2053 .ab = 239708160,
2054 .ib = 383533056,
2055 },
2056 {
2057 .src = MSM_BUS_MASTER_VPE,
2058 .dst = MSM_BUS_SLAVE_EBI_CH0,
2059 .ab = 79902720,
2060 .ib = 127844352,
2061 },
2062 {
2063 .src = MSM_BUS_MASTER_JPEG_ENC,
2064 .dst = MSM_BUS_SLAVE_SMI,
2065 .ab = 0,
2066 .ib = 0,
2067 },
2068 {
2069 .src = MSM_BUS_MASTER_JPEG_ENC,
2070 .dst = MSM_BUS_SLAVE_EBI_CH0,
2071 .ab = 0,
2072 .ib = 0,
2073 },
2074};
2075
2076static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2077 {
2078 .src = MSM_BUS_MASTER_VFE,
2079 .dst = MSM_BUS_SLAVE_SMI,
2080 .ab = 0,
2081 .ib = 0,
2082 },
2083 {
2084 .src = MSM_BUS_MASTER_VFE,
2085 .dst = MSM_BUS_SLAVE_EBI_CH0,
2086 .ab = 300902400,
2087 .ib = 481443840,
2088 },
2089 {
2090 .src = MSM_BUS_MASTER_VPE,
2091 .dst = MSM_BUS_SLAVE_SMI,
2092 .ab = 230307840,
2093 .ib = 368492544,
2094 },
2095 {
2096 .src = MSM_BUS_MASTER_VPE,
2097 .dst = MSM_BUS_SLAVE_EBI_CH0,
2098 .ab = 245113344,
2099 .ib = 392181351,
2100 },
2101 {
2102 .src = MSM_BUS_MASTER_JPEG_ENC,
2103 .dst = MSM_BUS_SLAVE_SMI,
2104 .ab = 106536960,
2105 .ib = 170459136,
2106 },
2107 {
2108 .src = MSM_BUS_MASTER_JPEG_ENC,
2109 .dst = MSM_BUS_SLAVE_EBI_CH0,
2110 .ab = 106536960,
2111 .ib = 170459136,
2112 },
2113};
2114
2115static struct msm_bus_paths cam_bus_client_config[] = {
2116 {
2117 ARRAY_SIZE(cam_init_vectors),
2118 cam_init_vectors,
2119 },
2120 {
2121 ARRAY_SIZE(cam_preview_vectors),
2122 cam_preview_vectors,
2123 },
2124 {
2125 ARRAY_SIZE(cam_video_vectors),
2126 cam_video_vectors,
2127 },
2128 {
2129 ARRAY_SIZE(cam_snapshot_vectors),
2130 cam_snapshot_vectors,
2131 },
2132 {
2133 ARRAY_SIZE(cam_zsl_vectors),
2134 cam_zsl_vectors,
2135 },
2136 {
2137 ARRAY_SIZE(cam_stereo_video_vectors),
2138 cam_stereo_video_vectors,
2139 },
2140 {
2141 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2142 cam_stereo_snapshot_vectors,
2143 },
2144};
2145
2146static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2147 cam_bus_client_config,
2148 ARRAY_SIZE(cam_bus_client_config),
2149 .name = "msm_camera",
2150};
2151#endif
2152
2153struct msm_camera_device_platform_data msm_camera_device_data = {
2154 .camera_gpio_on = config_camera_on_gpios,
2155 .camera_gpio_off = config_camera_off_gpios,
2156 .ioext.csiphy = 0x04800000,
2157 .ioext.csisz = 0x00000400,
2158 .ioext.csiirq = CSI_0_IRQ,
2159 .ioclk.mclk_clk_rate = 24000000,
2160 .ioclk.vfe_clk_rate = 228570000,
2161#ifdef CONFIG_MSM_BUS_SCALING
2162 .cam_bus_scale_table = &cam_bus_client_pdata,
2163#endif
2164};
2165
2166#ifdef CONFIG_QS_S5K4E1
2167struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2168 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2169 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2170 .ioext.csiphy = 0x04800000,
2171 .ioext.csisz = 0x00000400,
2172 .ioext.csiirq = CSI_0_IRQ,
2173 .ioclk.mclk_clk_rate = 24000000,
2174 .ioclk.vfe_clk_rate = 228570000,
2175#ifdef CONFIG_MSM_BUS_SCALING
2176 .cam_bus_scale_table = &cam_bus_client_pdata,
2177#endif
2178};
2179#endif
2180
2181struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2182 .camera_gpio_on = config_camera_on_gpios_web_cam,
2183 .camera_gpio_off = config_camera_off_gpios_web_cam,
2184 .ioext.csiphy = 0x04900000,
2185 .ioext.csisz = 0x00000400,
2186 .ioext.csiirq = CSI_1_IRQ,
2187 .ioclk.mclk_clk_rate = 24000000,
2188 .ioclk.vfe_clk_rate = 228570000,
2189#ifdef CONFIG_MSM_BUS_SCALING
2190 .cam_bus_scale_table = &cam_bus_client_pdata,
2191#endif
2192};
2193
2194struct resource msm_camera_resources[] = {
2195 {
2196 .start = 0x04500000,
2197 .end = 0x04500000 + SZ_1M - 1,
2198 .flags = IORESOURCE_MEM,
2199 },
2200 {
2201 .start = VFE_IRQ,
2202 .end = VFE_IRQ,
2203 .flags = IORESOURCE_IRQ,
2204 },
2205};
2206#ifdef CONFIG_MT9E013
2207static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2208 .mount_angle = 0
2209};
2210
2211static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2212 .flash_type = MSM_CAMERA_FLASH_LED,
2213 .flash_src = &msm_flash_src
2214};
2215
2216static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2217 .sensor_name = "mt9e013",
2218 .sensor_reset = 106,
2219 .sensor_pwd = 85,
2220 .vcm_pwd = 1,
2221 .vcm_enable = 0,
2222 .pdata = &msm_camera_device_data,
2223 .resource = msm_camera_resources,
2224 .num_resources = ARRAY_SIZE(msm_camera_resources),
2225 .flash_data = &flash_mt9e013,
2226 .strobe_flash_data = &strobe_flash_xenon,
2227 .sensor_platform_info = &mt9e013_sensor_8660_info,
2228 .csi_if = 1
2229};
2230struct platform_device msm_camera_sensor_mt9e013 = {
2231 .name = "msm_camera_mt9e013",
2232 .dev = {
2233 .platform_data = &msm_camera_sensor_mt9e013_data,
2234 },
2235};
2236#endif
2237
2238#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302239static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2240 .mount_angle = 180
2241};
2242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002243static struct msm_camera_sensor_flash_data flash_imx074 = {
2244 .flash_type = MSM_CAMERA_FLASH_LED,
2245 .flash_src = &msm_flash_src
2246};
2247
2248static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2249 .sensor_name = "imx074",
2250 .sensor_reset = 106,
2251 .sensor_pwd = 85,
2252 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2253 .vcm_enable = 1,
2254 .pdata = &msm_camera_device_data,
2255 .resource = msm_camera_resources,
2256 .num_resources = ARRAY_SIZE(msm_camera_resources),
2257 .flash_data = &flash_imx074,
2258 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302259 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002260 .csi_if = 1
2261};
2262struct platform_device msm_camera_sensor_imx074 = {
2263 .name = "msm_camera_imx074",
2264 .dev = {
2265 .platform_data = &msm_camera_sensor_imx074_data,
2266 },
2267};
2268#endif
2269#ifdef CONFIG_WEBCAM_OV9726
2270
2271static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2272 .mount_angle = 0
2273};
2274
2275static struct msm_camera_sensor_flash_data flash_ov9726 = {
2276 .flash_type = MSM_CAMERA_FLASH_LED,
2277 .flash_src = &msm_flash_src
2278};
2279static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2280 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002281 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2283 .sensor_pwd = 85,
2284 .vcm_pwd = 1,
2285 .vcm_enable = 0,
2286 .pdata = &msm_camera_device_data_web_cam,
2287 .resource = msm_camera_resources,
2288 .num_resources = ARRAY_SIZE(msm_camera_resources),
2289 .flash_data = &flash_ov9726,
2290 .sensor_platform_info = &ov9726_sensor_8660_info,
2291 .csi_if = 1
2292};
2293struct platform_device msm_camera_sensor_webcam_ov9726 = {
2294 .name = "msm_camera_ov9726",
2295 .dev = {
2296 .platform_data = &msm_camera_sensor_ov9726_data,
2297 },
2298};
2299#endif
2300#ifdef CONFIG_WEBCAM_OV7692
2301static struct msm_camera_sensor_flash_data flash_ov7692 = {
2302 .flash_type = MSM_CAMERA_FLASH_LED,
2303 .flash_src = &msm_flash_src
2304};
2305static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2306 .sensor_name = "ov7692",
2307 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2308 .sensor_pwd = 85,
2309 .vcm_pwd = 1,
2310 .vcm_enable = 0,
2311 .pdata = &msm_camera_device_data_web_cam,
2312 .resource = msm_camera_resources,
2313 .num_resources = ARRAY_SIZE(msm_camera_resources),
2314 .flash_data = &flash_ov7692,
2315 .csi_if = 1
2316};
2317
2318static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2319 .name = "msm_camera_ov7692",
2320 .dev = {
2321 .platform_data = &msm_camera_sensor_ov7692_data,
2322 },
2323};
2324#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002325#ifdef CONFIG_VX6953
2326static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2327 .mount_angle = 270
2328};
2329
2330static struct msm_camera_sensor_flash_data flash_vx6953 = {
2331 .flash_type = MSM_CAMERA_FLASH_NONE,
2332 .flash_src = &msm_flash_src
2333};
2334
2335static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2336 .sensor_name = "vx6953",
2337 .sensor_reset = 63,
2338 .sensor_pwd = 63,
2339 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2340 .vcm_enable = 1,
2341 .pdata = &msm_camera_device_data,
2342 .resource = msm_camera_resources,
2343 .num_resources = ARRAY_SIZE(msm_camera_resources),
2344 .flash_data = &flash_vx6953,
2345 .sensor_platform_info = &vx6953_sensor_8660_info,
2346 .csi_if = 1
2347};
2348struct platform_device msm_camera_sensor_vx6953 = {
2349 .name = "msm_camera_vx6953",
2350 .dev = {
2351 .platform_data = &msm_camera_sensor_vx6953_data,
2352 },
2353};
2354#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002355#ifdef CONFIG_QS_S5K4E1
2356
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302357static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2358#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2359 .mount_angle = 90
2360#else
2361 .mount_angle = 0
2362#endif
2363};
2364
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002365static char eeprom_data[864];
2366static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2367 .flash_type = MSM_CAMERA_FLASH_LED,
2368 .flash_src = &msm_flash_src
2369};
2370
2371static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2372 .sensor_name = "qs_s5k4e1",
2373 .sensor_reset = 106,
2374 .sensor_pwd = 85,
2375 .vcm_pwd = 1,
2376 .vcm_enable = 0,
2377 .pdata = &msm_camera_device_data_qs_cam,
2378 .resource = msm_camera_resources,
2379 .num_resources = ARRAY_SIZE(msm_camera_resources),
2380 .flash_data = &flash_qs_s5k4e1,
2381 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302382 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002383 .csi_if = 1,
2384 .eeprom_data = eeprom_data,
2385};
2386struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2387 .name = "msm_camera_qs_s5k4e1",
2388 .dev = {
2389 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2390 },
2391};
2392#endif
2393static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2394 #ifdef CONFIG_MT9E013
2395 {
2396 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2397 },
2398 #endif
2399 #ifdef CONFIG_IMX074
2400 {
2401 I2C_BOARD_INFO("imx074", 0x1A),
2402 },
2403 #endif
2404 #ifdef CONFIG_WEBCAM_OV7692
2405 {
2406 I2C_BOARD_INFO("ov7692", 0x78),
2407 },
2408 #endif
2409 #ifdef CONFIG_WEBCAM_OV9726
2410 {
2411 I2C_BOARD_INFO("ov9726", 0x10),
2412 },
2413 #endif
2414 #ifdef CONFIG_QS_S5K4E1
2415 {
2416 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2417 },
2418 #endif
2419};
Jilai Wang971f97f2011-07-13 14:25:25 -04002420
2421static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002422 #ifdef CONFIG_WEBCAM_OV9726
2423 {
2424 I2C_BOARD_INFO("ov9726", 0x10),
2425 },
2426 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002427 #ifdef CONFIG_VX6953
2428 {
2429 I2C_BOARD_INFO("vx6953", 0x20),
2430 },
2431 #endif
2432};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002433#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002434#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002435
2436#ifdef CONFIG_MSM_GEMINI
2437static struct resource msm_gemini_resources[] = {
2438 {
2439 .start = 0x04600000,
2440 .end = 0x04600000 + SZ_1M - 1,
2441 .flags = IORESOURCE_MEM,
2442 },
2443 {
2444 .start = INT_JPEG,
2445 .end = INT_JPEG,
2446 .flags = IORESOURCE_IRQ,
2447 },
2448};
2449
2450static struct platform_device msm_gemini_device = {
2451 .name = "msm_gemini",
2452 .resource = msm_gemini_resources,
2453 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2454};
2455#endif
2456
2457#ifdef CONFIG_I2C_QUP
2458static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2459{
2460}
2461
2462static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2463 .clk_freq = 384000,
2464 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002465 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2466};
2467
2468static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2469 .clk_freq = 100000,
2470 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002471 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2472};
2473
2474static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2475 .clk_freq = 100000,
2476 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002477 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2478};
2479
2480static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2481 .clk_freq = 100000,
2482 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002483 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2484};
2485
2486static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2487 .clk_freq = 100000,
2488 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002489 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2490};
2491
2492static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2493 .clk_freq = 100000,
2494 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002495 .use_gsbi_shared_mode = 1,
2496 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2497};
2498#endif
2499
2500#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2501static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2502 .max_clock_speed = 24000000,
2503};
2504
2505static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2506 .max_clock_speed = 24000000,
2507};
2508#endif
2509
2510#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002511/* CODEC/TSSC SSBI */
2512static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2513 .controller_type = MSM_SBI_CTRL_SSBI,
2514};
2515#endif
2516
2517#ifdef CONFIG_BATTERY_MSM
2518/* Use basic value for fake MSM battery */
2519static struct msm_psy_batt_pdata msm_psy_batt_data = {
2520 .avail_chg_sources = AC_CHG,
2521};
2522
2523static struct platform_device msm_batt_device = {
2524 .name = "msm-battery",
2525 .id = -1,
2526 .dev.platform_data = &msm_psy_batt_data,
2527};
2528#endif
2529
2530#ifdef CONFIG_FB_MSM_LCDC_DSUB
2531/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2532 prim = 1024 x 600 x 4(bpp) x 2(pages)
2533 This is the difference. */
2534#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2535#else
2536#define MSM_FB_DSUB_PMEM_ADDER (0)
2537#endif
2538
2539/* Sensors DSPS platform data */
2540#ifdef CONFIG_MSM_DSPS
2541
2542static struct dsps_gpio_info dsps_surf_gpios[] = {
2543 {
2544 .name = "compass_rst_n",
2545 .num = GPIO_COMPASS_RST_N,
2546 .on_val = 1, /* device not in reset */
2547 .off_val = 0, /* device in reset */
2548 },
2549 {
2550 .name = "gpio_r_altimeter_reset_n",
2551 .num = GPIO_R_ALTIMETER_RESET_N,
2552 .on_val = 1, /* device not in reset */
2553 .off_val = 0, /* device in reset */
2554 }
2555};
2556
2557static struct dsps_gpio_info dsps_fluid_gpios[] = {
2558 {
2559 .name = "gpio_n_altimeter_reset_n",
2560 .num = GPIO_N_ALTIMETER_RESET_N,
2561 .on_val = 1, /* device not in reset */
2562 .off_val = 0, /* device in reset */
2563 }
2564};
2565
2566static void __init msm8x60_init_dsps(void)
2567{
2568 struct msm_dsps_platform_data *pdata =
2569 msm_dsps_device.dev.platform_data;
2570 /*
2571 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2572 * to the power supply and not controled via GPIOs. Fluid uses a
2573 * different IO-Expender (north) than used on surf/ffa.
2574 */
2575 if (machine_is_msm8x60_fluid()) {
2576 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002577 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002578 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002579 pdata->gpios = dsps_fluid_gpios;
2580 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2581 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002582 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002583 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002584 pdata->gpios = dsps_surf_gpios;
2585 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2586 }
2587
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002588 platform_device_register(&msm_dsps_device);
2589}
2590#endif /* CONFIG_MSM_DSPS */
2591
2592#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302593#define MSM_FB_PRIM_BUF_SIZE \
2594 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002595#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302596#define MSM_FB_PRIM_BUF_SIZE \
2597 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002598#endif
2599
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002600#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302601#define MSM_FB_EXT_BUF_SIZE \
2602 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002603#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302604#define MSM_FB_EXT_BUF_SIZE \
2605 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002606#else
2607#define MSM_FB_EXT_BUFT_SIZE 0
2608#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002609
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002610/* Note: must be multiple of 4096 */
2611#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002612 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002613
2614#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302615#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002616
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002617#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002618unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002619#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002620unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002621#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002622
Huaibin Yanga5419422011-12-08 23:52:10 -08002623#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2624#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2625#else
2626#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2627#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2628
2629#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2630#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2631#else
2632#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2633#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2634
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302635#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002636#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302637#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002638
2639#define MSM_SMI_BASE 0x38000000
2640#define MSM_SMI_SIZE 0x4000000
2641
2642#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302643#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2644#define KERNEL_SMI_SIZE 0x000000
2645#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002646#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302647#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002648
2649#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2650#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2651#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2652
Naseer Ahmed51860b02012-02-07 18:53:29 +05302653#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002654#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan42ebe712012-01-10 16:30:58 -08002655#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302656#define MSM_ION_MM_SIZE 0x3c00000 /* (60MB) Must be a multiple of 64K */
Olav Hauganb5be7992011-11-18 14:29:02 -08002657#define MSM_ION_MFC_SIZE SZ_8K
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);
3078static int hdmi_cec_power(int on);
3079
3080static struct msm_hdmi_platform_data hdmi_msm_data = {
3081 .irq = HDMI_IRQ,
3082 .enable_5v = hdmi_enable_5v,
3083 .core_power = hdmi_core_power,
3084 .cec_power = hdmi_cec_power,
3085};
3086
3087static struct platform_device hdmi_msm_device = {
3088 .name = "hdmi_msm",
3089 .id = 0,
3090 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3091 .resource = hdmi_msm_resources,
3092 .dev.platform_data = &hdmi_msm_data,
3093};
3094#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3095
3096#ifdef CONFIG_FB_MSM_MIPI_DSI
3097static struct platform_device mipi_dsi_toshiba_panel_device = {
3098 .name = "mipi_toshiba",
3099 .id = 0,
3100};
3101
3102#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3103
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003104static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003106 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003107};
3108
3109static struct platform_device mipi_dsi_novatek_panel_device = {
3110 .name = "mipi_novatek",
3111 .id = 0,
3112 .dev = {
3113 .platform_data = &novatek_pdata,
3114 }
3115};
3116#endif
3117
3118static void __init msm8x60_allocate_memory_regions(void)
3119{
3120 void *addr;
3121 unsigned long size;
3122
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003123 if (hdmi_is_primary)
3124 size = roundup((1920 * 1088 * 4 * 2), 4096);
3125 else
3126 size = MSM_FB_SIZE;
3127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003128 addr = alloc_bootmem_align(size, 0x1000);
3129 msm_fb_resources[0].start = __pa(addr);
3130 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3131 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3132 size, addr, __pa(addr));
3133
3134}
3135
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003136void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3137{
3138 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3139 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3140 PANEL_NAME_MAX_LEN);
3141 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3142 msm_fb_pdata.prim_panel_name);
3143
3144 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3145 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3146 PANEL_NAME_MAX_LEN))) {
3147 pr_debug("HDMI is the primary display by"
3148 " boot parameter\n");
3149 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003150 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003151 }
3152 }
3153 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3154 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3155 PANEL_NAME_MAX_LEN);
3156 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3157 msm_fb_pdata.ext_panel_name);
3158 }
3159}
3160
Steve Mucklef132c6c2012-06-06 18:30:57 -07003161#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3162 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003163/*virtual key support */
3164static ssize_t tma300_vkeys_show(struct kobject *kobj,
3165 struct kobj_attribute *attr, char *buf)
3166{
3167 return sprintf(buf,
3168 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3169 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3170 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3171 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3172 "\n");
3173}
3174
3175static struct kobj_attribute tma300_vkeys_attr = {
3176 .attr = {
3177 .mode = S_IRUGO,
3178 },
3179 .show = &tma300_vkeys_show,
3180};
3181
3182static struct attribute *tma300_properties_attrs[] = {
3183 &tma300_vkeys_attr.attr,
3184 NULL
3185};
3186
3187static struct attribute_group tma300_properties_attr_group = {
3188 .attrs = tma300_properties_attrs,
3189};
3190
3191static struct kobject *properties_kobj;
3192
3193
3194
3195#define CYTTSP_TS_GPIO_IRQ 61
3196static int cyttsp_platform_init(struct i2c_client *client)
3197{
3198 int rc = -EINVAL;
3199 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3200
3201 if (machine_is_msm8x60_fluid()) {
3202 pm8058_l5 = regulator_get(NULL, "8058_l5");
3203 if (IS_ERR(pm8058_l5)) {
3204 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3205 __func__, PTR_ERR(pm8058_l5));
3206 rc = PTR_ERR(pm8058_l5);
3207 return rc;
3208 }
3209 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3210 if (rc) {
3211 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3212 __func__, rc);
3213 goto reg_l5_put;
3214 }
3215
3216 rc = regulator_enable(pm8058_l5);
3217 if (rc) {
3218 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3219 __func__, rc);
3220 goto reg_l5_put;
3221 }
3222 }
3223 /* vote for s3 to enable i2c communication lines */
3224 pm8058_s3 = regulator_get(NULL, "8058_s3");
3225 if (IS_ERR(pm8058_s3)) {
3226 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3227 __func__, PTR_ERR(pm8058_s3));
3228 rc = PTR_ERR(pm8058_s3);
3229 goto reg_l5_disable;
3230 }
3231
3232 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3233 if (rc) {
3234 pr_err("%s: regulator_set_voltage() = %d\n",
3235 __func__, rc);
3236 goto reg_s3_put;
3237 }
3238
3239 rc = regulator_enable(pm8058_s3);
3240 if (rc) {
3241 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3242 __func__, rc);
3243 goto reg_s3_put;
3244 }
3245
3246 /* wait for vregs to stabilize */
3247 usleep_range(10000, 10000);
3248
3249 /* check this device active by reading first byte/register */
3250 rc = i2c_smbus_read_byte_data(client, 0x01);
3251 if (rc < 0) {
3252 pr_err("%s: i2c sanity check failed\n", __func__);
3253 goto reg_s3_disable;
3254 }
3255
3256 /* virtual keys */
3257 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003258 properties_kobj = kobject_create_and_add("board_properties",
3259 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003260 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003261 if (!properties_kobj || rc)
3262 pr_err("%s: failed to create board_properties\n",
3263 __func__);
3264 }
3265 return CY_OK;
3266
3267reg_s3_disable:
3268 regulator_disable(pm8058_s3);
3269reg_s3_put:
3270 regulator_put(pm8058_s3);
3271reg_l5_disable:
3272 if (machine_is_msm8x60_fluid())
3273 regulator_disable(pm8058_l5);
3274reg_l5_put:
3275 if (machine_is_msm8x60_fluid())
3276 regulator_put(pm8058_l5);
3277 return rc;
3278}
3279
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303280/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3281static int cyttsp_platform_suspend(struct i2c_client *client)
3282{
3283 msleep(20);
3284
3285 return CY_OK;
3286}
3287
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003288static int cyttsp_platform_resume(struct i2c_client *client)
3289{
3290 /* add any special code to strobe a wakeup pin or chip reset */
3291 msleep(10);
3292
3293 return CY_OK;
3294}
3295
3296static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3297 .flags = 0x04,
3298 .gen = CY_GEN3, /* or */
3299 .use_st = CY_USE_ST,
3300 .use_mt = CY_USE_MT,
3301 .use_hndshk = CY_SEND_HNDSHK,
3302 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303303 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003304 .use_gestures = CY_USE_GESTURES,
3305 /* activate up to 4 groups
3306 * and set active distance
3307 */
3308 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3309 CY_GEST_GRP3 | CY_GEST_GRP4 |
3310 CY_ACT_DIST,
3311 /* change act_intrvl to customize the Active power state
3312 * scanning/processing refresh interval for Operating mode
3313 */
3314 .act_intrvl = CY_ACT_INTRVL_DFLT,
3315 /* change tch_tmout to customize the touch timeout for the
3316 * Active power state for Operating mode
3317 */
3318 .tch_tmout = CY_TCH_TMOUT_DFLT,
3319 /* change lp_intrvl to customize the Low Power power state
3320 * scanning/processing refresh interval for Operating mode
3321 */
3322 .lp_intrvl = CY_LP_INTRVL_DFLT,
3323 .sleep_gpio = -1,
3324 .resout_gpio = -1,
3325 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3326 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303327 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003328 .init = cyttsp_platform_init,
3329};
3330
3331static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3332 .panel_maxx = 1083,
3333 .panel_maxy = 659,
3334 .disp_minx = 30,
3335 .disp_maxx = 1053,
3336 .disp_miny = 30,
3337 .disp_maxy = 629,
3338 .correct_fw_ver = 8,
3339 .fw_fname = "cyttsp_8660_ffa.hex",
3340 .flags = 0x00,
3341 .gen = CY_GEN2, /* or */
3342 .use_st = CY_USE_ST,
3343 .use_mt = CY_USE_MT,
3344 .use_hndshk = CY_SEND_HNDSHK,
3345 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303346 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003347 .use_gestures = CY_USE_GESTURES,
3348 /* activate up to 4 groups
3349 * and set active distance
3350 */
3351 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3352 CY_GEST_GRP3 | CY_GEST_GRP4 |
3353 CY_ACT_DIST,
3354 /* change act_intrvl to customize the Active power state
3355 * scanning/processing refresh interval for Operating mode
3356 */
3357 .act_intrvl = CY_ACT_INTRVL_DFLT,
3358 /* change tch_tmout to customize the touch timeout for the
3359 * Active power state for Operating mode
3360 */
3361 .tch_tmout = CY_TCH_TMOUT_DFLT,
3362 /* change lp_intrvl to customize the Low Power power state
3363 * scanning/processing refresh interval for Operating mode
3364 */
3365 .lp_intrvl = CY_LP_INTRVL_DFLT,
3366 .sleep_gpio = -1,
3367 .resout_gpio = -1,
3368 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3369 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303370 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003371 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303372 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003373};
3374static void cyttsp_set_params(void)
3375{
3376 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3377 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3378 cyttsp_fluid_pdata.panel_maxx = 539;
3379 cyttsp_fluid_pdata.panel_maxy = 994;
3380 cyttsp_fluid_pdata.disp_minx = 30;
3381 cyttsp_fluid_pdata.disp_maxx = 509;
3382 cyttsp_fluid_pdata.disp_miny = 60;
3383 cyttsp_fluid_pdata.disp_maxy = 859;
3384 cyttsp_fluid_pdata.correct_fw_ver = 4;
3385 } else {
3386 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3387 cyttsp_fluid_pdata.panel_maxx = 550;
3388 cyttsp_fluid_pdata.panel_maxy = 1013;
3389 cyttsp_fluid_pdata.disp_minx = 35;
3390 cyttsp_fluid_pdata.disp_maxx = 515;
3391 cyttsp_fluid_pdata.disp_miny = 69;
3392 cyttsp_fluid_pdata.disp_maxy = 869;
3393 cyttsp_fluid_pdata.correct_fw_ver = 5;
3394 }
3395
3396}
3397
3398static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3399 {
3400 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3401 .platform_data = &cyttsp_fluid_pdata,
3402#ifndef CY_USE_TIMER
3403 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3404#endif /* CY_USE_TIMER */
3405 },
3406};
3407
3408static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3409 {
3410 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3411 .platform_data = &cyttsp_tmg240_pdata,
3412#ifndef CY_USE_TIMER
3413 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3414#endif /* CY_USE_TIMER */
3415 },
3416};
3417#endif
3418
3419static struct regulator *vreg_tmg200;
3420
3421#define TS_PEN_IRQ_GPIO 61
3422static int tmg200_power(int vreg_on)
3423{
3424 int rc = -EINVAL;
3425
3426 if (!vreg_tmg200) {
3427 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3428 __func__, rc);
3429 return rc;
3430 }
3431
3432 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3433 regulator_disable(vreg_tmg200);
3434 if (rc < 0)
3435 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3436 __func__, vreg_on ? "enable" : "disable", rc);
3437
3438 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003439 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003440
3441 return rc;
3442}
3443
3444static int tmg200_dev_setup(bool enable)
3445{
3446 int rc;
3447
3448 if (enable) {
3449 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3450 if (IS_ERR(vreg_tmg200)) {
3451 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3452 __func__, PTR_ERR(vreg_tmg200));
3453 rc = PTR_ERR(vreg_tmg200);
3454 return rc;
3455 }
3456
3457 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3458 if (rc) {
3459 pr_err("%s: regulator_set_voltage() = %d\n",
3460 __func__, rc);
3461 goto reg_put;
3462 }
3463 } else {
3464 /* put voltage sources */
3465 regulator_put(vreg_tmg200);
3466 }
3467 return 0;
3468reg_put:
3469 regulator_put(vreg_tmg200);
3470 return rc;
3471}
3472
3473static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3474 .ts_name = "msm_tmg200_ts",
3475 .dis_min_x = 0,
3476 .dis_max_x = 1023,
3477 .dis_min_y = 0,
3478 .dis_max_y = 599,
3479 .min_tid = 0,
3480 .max_tid = 255,
3481 .min_touch = 0,
3482 .max_touch = 255,
3483 .min_width = 0,
3484 .max_width = 255,
3485 .power_on = tmg200_power,
3486 .dev_setup = tmg200_dev_setup,
3487 .nfingers = 2,
3488 .irq_gpio = TS_PEN_IRQ_GPIO,
3489 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3490};
3491
3492static struct i2c_board_info cy8ctmg200_board_info[] = {
3493 {
3494 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3495 .platform_data = &cy8ctmg200_pdata,
3496 }
3497};
3498
Zhang Chang Ken211df572011-07-05 19:16:39 -04003499static struct regulator *vreg_tma340;
3500
3501static int tma340_power(int vreg_on)
3502{
3503 int rc = -EINVAL;
3504
3505 if (!vreg_tma340) {
3506 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3507 __func__, rc);
3508 return rc;
3509 }
3510
3511 rc = vreg_on ? regulator_enable(vreg_tma340) :
3512 regulator_disable(vreg_tma340);
3513 if (rc < 0)
3514 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3515 __func__, vreg_on ? "enable" : "disable", rc);
3516
3517 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003518 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003519
3520 return rc;
3521}
3522
3523static struct kobject *tma340_prop_kobj;
3524
3525static int tma340_dragon_dev_setup(bool enable)
3526{
3527 int rc;
3528
3529 if (enable) {
3530 vreg_tma340 = regulator_get(NULL, "8901_l2");
3531 if (IS_ERR(vreg_tma340)) {
3532 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3533 __func__, PTR_ERR(vreg_tma340));
3534 rc = PTR_ERR(vreg_tma340);
3535 return rc;
3536 }
3537
3538 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3539 if (rc) {
3540 pr_err("%s: regulator_set_voltage() = %d\n",
3541 __func__, rc);
3542 goto reg_put;
3543 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003544 tma340_prop_kobj = kobject_create_and_add("board_properties",
3545 NULL);
3546 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003547 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003548 if (rc) {
3549 kobject_put(tma340_prop_kobj);
3550 pr_err("%s: failed to create board_properties\n",
3551 __func__);
3552 goto reg_put;
3553 }
3554 }
3555
3556 } else {
3557 /* put voltage sources */
3558 regulator_put(vreg_tma340);
3559 /* destroy virtual keys */
3560 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003561 kobject_put(tma340_prop_kobj);
3562 }
3563 }
3564 return 0;
3565reg_put:
3566 regulator_put(vreg_tma340);
3567 return rc;
3568}
3569
3570
3571static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3572 .ts_name = "cy8ctma340",
3573 .dis_min_x = 0,
3574 .dis_max_x = 479,
3575 .dis_min_y = 0,
3576 .dis_max_y = 799,
3577 .min_tid = 0,
3578 .max_tid = 255,
3579 .min_touch = 0,
3580 .max_touch = 255,
3581 .min_width = 0,
3582 .max_width = 255,
3583 .power_on = tma340_power,
3584 .dev_setup = tma340_dragon_dev_setup,
3585 .nfingers = 2,
3586 .irq_gpio = TS_PEN_IRQ_GPIO,
3587 .resout_gpio = -1,
3588};
3589
3590static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3591 {
3592 I2C_BOARD_INFO("cy8ctma340", 0x24),
3593 .platform_data = &cy8ctma340_dragon_pdata,
3594 }
3595};
3596
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003597#ifdef CONFIG_SERIAL_MSM_HS
3598static int configure_uart_gpios(int on)
3599{
3600 int ret = 0, i;
3601 int uart_gpios[] = {53, 54, 55, 56};
3602 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3603 if (on) {
3604 ret = msm_gpiomux_get(uart_gpios[i]);
3605 if (unlikely(ret))
3606 break;
3607 } else {
3608 ret = msm_gpiomux_put(uart_gpios[i]);
3609 if (unlikely(ret))
3610 return ret;
3611 }
3612 }
3613 if (ret)
3614 for (; i >= 0; i--)
3615 msm_gpiomux_put(uart_gpios[i]);
3616 return ret;
3617}
3618static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3619 .inject_rx_on_wakeup = 1,
3620 .rx_to_inject = 0xFD,
3621 .gpio_config = configure_uart_gpios,
3622};
3623#endif
3624
3625
3626#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3627
3628static struct gpio_led gpio_exp_leds_config[] = {
3629 {
3630 .name = "left_led1:green",
3631 .gpio = GPIO_LEFT_LED_1,
3632 .active_low = 1,
3633 .retain_state_suspended = 0,
3634 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3635 },
3636 {
3637 .name = "left_led2:red",
3638 .gpio = GPIO_LEFT_LED_2,
3639 .active_low = 1,
3640 .retain_state_suspended = 0,
3641 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3642 },
3643 {
3644 .name = "left_led3:green",
3645 .gpio = GPIO_LEFT_LED_3,
3646 .active_low = 1,
3647 .retain_state_suspended = 0,
3648 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3649 },
3650 {
3651 .name = "wlan_led:orange",
3652 .gpio = GPIO_LEFT_LED_WLAN,
3653 .active_low = 1,
3654 .retain_state_suspended = 0,
3655 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3656 },
3657 {
3658 .name = "left_led5:green",
3659 .gpio = GPIO_LEFT_LED_5,
3660 .active_low = 1,
3661 .retain_state_suspended = 0,
3662 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3663 },
3664 {
3665 .name = "right_led1:green",
3666 .gpio = GPIO_RIGHT_LED_1,
3667 .active_low = 1,
3668 .retain_state_suspended = 0,
3669 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3670 },
3671 {
3672 .name = "right_led2:red",
3673 .gpio = GPIO_RIGHT_LED_2,
3674 .active_low = 1,
3675 .retain_state_suspended = 0,
3676 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3677 },
3678 {
3679 .name = "right_led3:green",
3680 .gpio = GPIO_RIGHT_LED_3,
3681 .active_low = 1,
3682 .retain_state_suspended = 0,
3683 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3684 },
3685 {
3686 .name = "bt_led:blue",
3687 .gpio = GPIO_RIGHT_LED_BT,
3688 .active_low = 1,
3689 .retain_state_suspended = 0,
3690 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3691 },
3692 {
3693 .name = "right_led5:green",
3694 .gpio = GPIO_RIGHT_LED_5,
3695 .active_low = 1,
3696 .retain_state_suspended = 0,
3697 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3698 },
3699};
3700
3701static struct gpio_led_platform_data gpio_leds_pdata = {
3702 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3703 .leds = gpio_exp_leds_config,
3704};
3705
3706static struct platform_device gpio_leds = {
3707 .name = "leds-gpio",
3708 .id = -1,
3709 .dev = {
3710 .platform_data = &gpio_leds_pdata,
3711 },
3712};
3713
3714static struct gpio_led fluid_gpio_leds[] = {
3715 {
3716 .name = "dual_led:green",
3717 .gpio = GPIO_LED1_GREEN_N,
3718 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3719 .active_low = 1,
3720 .retain_state_suspended = 0,
3721 },
3722 {
3723 .name = "dual_led:red",
3724 .gpio = GPIO_LED2_RED_N,
3725 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3726 .active_low = 1,
3727 .retain_state_suspended = 0,
3728 },
3729};
3730
3731static struct gpio_led_platform_data gpio_led_pdata = {
3732 .leds = fluid_gpio_leds,
3733 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3734};
3735
3736static struct platform_device fluid_leds_gpio = {
3737 .name = "leds-gpio",
3738 .id = -1,
3739 .dev = {
3740 .platform_data = &gpio_led_pdata,
3741 },
3742};
3743
3744#endif
3745
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003746#ifdef CONFIG_BATTERY_MSM8X60
3747static struct msm_charger_platform_data msm_charger_data = {
3748 .safety_time = 180,
3749 .update_time = 1,
3750 .max_voltage = 4200,
3751 .min_voltage = 3200,
3752};
3753
3754static struct platform_device msm_charger_device = {
3755 .name = "msm-charger",
3756 .id = -1,
3757 .dev = {
3758 .platform_data = &msm_charger_data,
3759 }
3760};
3761#endif
3762
3763/*
3764 * Consumer specific regulator names:
3765 * regulator name consumer dev_name
3766 */
3767static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3768 REGULATOR_SUPPLY("8058_l0", NULL),
3769};
3770static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3771 REGULATOR_SUPPLY("8058_l1", NULL),
3772};
3773static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3774 REGULATOR_SUPPLY("8058_l2", NULL),
3775};
3776static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3777 REGULATOR_SUPPLY("8058_l3", NULL),
3778};
3779static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3780 REGULATOR_SUPPLY("8058_l4", NULL),
3781};
3782static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3783 REGULATOR_SUPPLY("8058_l5", NULL),
3784};
3785static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3786 REGULATOR_SUPPLY("8058_l6", NULL),
3787};
3788static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3789 REGULATOR_SUPPLY("8058_l7", NULL),
3790};
3791static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3792 REGULATOR_SUPPLY("8058_l8", NULL),
3793};
3794static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3795 REGULATOR_SUPPLY("8058_l9", NULL),
3796};
3797static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3798 REGULATOR_SUPPLY("8058_l10", NULL),
3799};
3800static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3801 REGULATOR_SUPPLY("8058_l11", NULL),
3802};
3803static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3804 REGULATOR_SUPPLY("8058_l12", NULL),
3805};
3806static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3807 REGULATOR_SUPPLY("8058_l13", NULL),
3808};
3809static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3810 REGULATOR_SUPPLY("8058_l14", NULL),
3811};
3812static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3813 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003814 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003815 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003816 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003817};
3818static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3819 REGULATOR_SUPPLY("8058_l16", NULL),
3820};
3821static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3822 REGULATOR_SUPPLY("8058_l17", NULL),
3823};
3824static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3825 REGULATOR_SUPPLY("8058_l18", NULL),
3826};
3827static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3828 REGULATOR_SUPPLY("8058_l19", NULL),
3829};
3830static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3831 REGULATOR_SUPPLY("8058_l20", NULL),
3832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3834 REGULATOR_SUPPLY("8058_l21", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3837 REGULATOR_SUPPLY("8058_l22", NULL),
3838};
3839static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3840 REGULATOR_SUPPLY("8058_l23", NULL),
3841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3843 REGULATOR_SUPPLY("8058_l24", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3846 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003847 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003848 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003849 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3852 REGULATOR_SUPPLY("8058_s0", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3855 REGULATOR_SUPPLY("8058_s1", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3858 REGULATOR_SUPPLY("8058_s2", NULL),
3859};
3860static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3861 REGULATOR_SUPPLY("8058_s3", NULL),
3862};
3863static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3864 REGULATOR_SUPPLY("8058_s4", NULL),
3865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3867 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003868 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003869 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003870 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003871};
3872static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3873 REGULATOR_SUPPLY("8058_lvs1", NULL),
3874};
3875static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3876 REGULATOR_SUPPLY("8058_ncp", NULL),
3877};
3878
3879static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3880 REGULATOR_SUPPLY("8901_l0", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3883 REGULATOR_SUPPLY("8901_l1", NULL),
3884};
3885static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3886 REGULATOR_SUPPLY("8901_l2", NULL),
3887};
3888static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3889 REGULATOR_SUPPLY("8901_l3", NULL),
3890};
3891static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3892 REGULATOR_SUPPLY("8901_l4", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3895 REGULATOR_SUPPLY("8901_l5", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3898 REGULATOR_SUPPLY("8901_l6", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3901 REGULATOR_SUPPLY("8901_s2", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3904 REGULATOR_SUPPLY("8901_s3", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3907 REGULATOR_SUPPLY("8901_s4", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3910 REGULATOR_SUPPLY("8901_lvs0", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3913 REGULATOR_SUPPLY("8901_lvs1", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3916 REGULATOR_SUPPLY("8901_lvs2", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3919 REGULATOR_SUPPLY("8901_lvs3", NULL),
3920};
3921static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3922 REGULATOR_SUPPLY("8901_mvs0", NULL),
3923};
3924
David Collins6f032ba2011-08-31 14:08:15 -07003925/* Pin control regulators */
3926static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3927 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3930 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3933 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3934};
3935static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3936 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3937};
3938static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3939 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3940};
3941static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3942 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3943};
3944
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003945#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3946 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003947 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3948 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003949 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003950 .init_data = { \
3951 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003952 .valid_modes_mask = _modes, \
3953 .valid_ops_mask = _ops, \
3954 .min_uV = _min_uV, \
3955 .max_uV = _max_uV, \
3956 .input_uV = _min_uV, \
3957 .apply_uV = _apply_uV, \
3958 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003960 .consumer_supplies = vreg_consumers_##_id, \
3961 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003962 ARRAY_SIZE(vreg_consumers_##_id), \
3963 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003964 .id = RPM_VREG_ID_##_id, \
3965 .default_uV = _default_uV, \
3966 .peak_uA = _peak_uA, \
3967 .avg_uA = _avg_uA, \
3968 .pull_down_enable = _pull_down, \
3969 .pin_ctrl = _pin_ctrl, \
3970 .freq = RPM_VREG_FREQ_##_freq, \
3971 .pin_fn = _pin_fn, \
3972 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003973 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003974 .state = _state, \
3975 .sleep_selectable = _sleep_selectable, \
3976 }
3977
3978/* Pin control initialization */
3979#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3980 { \
3981 .init_data = { \
3982 .constraints = { \
3983 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3984 .always_on = _always_on, \
3985 }, \
3986 .num_consumer_supplies = \
3987 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3988 .consumer_supplies = vreg_consumers_##_id##_PC, \
3989 }, \
3990 .id = RPM_VREG_ID_##_id##_PC, \
3991 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003992 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003993 }
3994
3995/*
3996 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3997 * via the peak_uA value specified in the table below. If the value is less
3998 * than the high power min threshold for the regulator, then the regulator will
3999 * be set to LPM. Otherwise, it will be set to HPM.
4000 *
4001 * This value can be further overridden by specifying an initial mode via
4002 * .init_data.constraints.initial_mode.
4003 */
4004
David Collins6f032ba2011-08-31 14:08:15 -07004005#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4006 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004007 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4008 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4009 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4010 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4011 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004012 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4013 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004014 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004015 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004016 _sleep_selectable, _always_on)
4017
David Collins6f032ba2011-08-31 14:08:15 -07004018#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4019 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004020 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4021 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4022 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4023 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4024 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004025 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4026 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004027 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004028 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4029 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030
David Collins6f032ba2011-08-31 14:08:15 -07004031#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004032 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4033 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004034 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4035 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004036 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004037 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4038 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004039
David Collins6f032ba2011-08-31 14:08:15 -07004040#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4042 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004043 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4044 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004045 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004046 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4047 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004048
David Collins6f032ba2011-08-31 14:08:15 -07004049#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4050#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4051#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4052#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4053#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004054
David Collins6f032ba2011-08-31 14:08:15 -07004055/* RPM early regulator constraints */
4056static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4057 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004058 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004059 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004060};
4061
David Collins6f032ba2011-08-31 14:08:15 -07004062/* RPM regulator constraints */
4063static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4064 /* ID a_on pd ss min_uV max_uV init_ip */
4065 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4066 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4067 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4068 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4069 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4070 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4071 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4072 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4073 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4074 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4075 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4076 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4077 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4078 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4079 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4080 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4081 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4082 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4083 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4084 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4085 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4086 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4087 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4088 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4089 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4090 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004091
David Collins6f032ba2011-08-31 14:08:15 -07004092 /* ID a_on pd ss min_uV max_uV init_ip freq */
4093 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4094 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4095 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4096
4097 /* ID a_on pd ss */
4098 RPM_VS(PM8058_LVS0, 0, 1, 0),
4099 RPM_VS(PM8058_LVS1, 0, 1, 0),
4100
4101 /* ID a_on pd ss min_uV max_uV */
4102 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4103
4104 /* ID a_on pd ss min_uV max_uV init_ip */
4105 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4106 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4107 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4108 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4109 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4110 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4111 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4112
4113 /* ID a_on pd ss min_uV max_uV init_ip freq */
4114 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4115 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4116 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4117
4118 /* ID a_on pd ss */
4119 RPM_VS(PM8901_LVS0, 1, 1, 0),
4120 RPM_VS(PM8901_LVS1, 0, 1, 0),
4121 RPM_VS(PM8901_LVS2, 0, 1, 0),
4122 RPM_VS(PM8901_LVS3, 0, 1, 0),
4123 RPM_VS(PM8901_MVS0, 0, 1, 0),
4124
4125 /* ID a_on pin_func pin_ctrl */
4126 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4127 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4128 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4129 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4130 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4131 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4132};
4133
4134static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4135 .init_data = rpm_regulator_early_init_data,
4136 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4137 .version = RPM_VREG_VERSION_8660,
4138 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4139 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4140};
4141
4142static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4143 .init_data = rpm_regulator_init_data,
4144 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4145 .version = RPM_VREG_VERSION_8660,
4146};
4147
4148static struct platform_device rpm_regulator_early_device = {
4149 .name = "rpm-regulator",
4150 .id = 0,
4151 .dev = {
4152 .platform_data = &rpm_regulator_early_pdata,
4153 },
4154};
4155
4156static struct platform_device rpm_regulator_device = {
4157 .name = "rpm-regulator",
4158 .id = 1,
4159 .dev = {
4160 .platform_data = &rpm_regulator_pdata,
4161 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162};
4163
4164static struct platform_device *early_regulators[] __initdata = {
4165 &msm_device_saw_s0,
4166 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004167 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168};
4169
4170static struct platform_device *early_devices[] __initdata = {
4171#ifdef CONFIG_MSM_BUS_SCALING
4172 &msm_bus_apps_fabric,
4173 &msm_bus_sys_fabric,
4174 &msm_bus_mm_fabric,
4175 &msm_bus_sys_fpb,
4176 &msm_bus_cpss_fpb,
4177#endif
4178 &msm_device_dmov_adm0,
4179 &msm_device_dmov_adm1,
4180};
4181
4182#if (defined(CONFIG_MARIMBA_CORE)) && \
4183 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4184
4185static int bluetooth_power(int);
4186static struct platform_device msm_bt_power_device = {
4187 .name = "bt_power",
4188 .id = -1,
4189 .dev = {
4190 .platform_data = &bluetooth_power,
4191 },
4192};
4193#endif
4194
4195static struct platform_device msm_tsens_device = {
4196 .name = "tsens-tm",
4197 .id = -1,
4198};
4199
4200static struct platform_device *rumi_sim_devices[] __initdata = {
4201 &smc91x_device,
4202 &msm_device_uart_dm12,
4203#ifdef CONFIG_I2C_QUP
4204 &msm_gsbi3_qup_i2c_device,
4205 &msm_gsbi4_qup_i2c_device,
4206 &msm_gsbi7_qup_i2c_device,
4207 &msm_gsbi8_qup_i2c_device,
4208 &msm_gsbi9_qup_i2c_device,
4209 &msm_gsbi12_qup_i2c_device,
4210#endif
4211#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004212 &msm_device_ssbi3,
4213#endif
4214#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004215#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004216 &android_pmem_device,
4217 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004218 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004219 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304220#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4221#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004222#ifdef CONFIG_MSM_ROTATOR
4223 &msm_rotator_device,
4224#endif
4225 &msm_fb_device,
4226 &msm_kgsl_3d0,
4227 &msm_kgsl_2d0,
4228 &msm_kgsl_2d1,
4229 &lcdc_samsung_panel_device,
4230#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4231 &hdmi_msm_device,
4232#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4233#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004234#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004235#ifdef CONFIG_MT9E013
4236 &msm_camera_sensor_mt9e013,
4237#endif
4238#ifdef CONFIG_IMX074
4239 &msm_camera_sensor_imx074,
4240#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004241#ifdef CONFIG_VX6953
4242 &msm_camera_sensor_vx6953,
4243#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004244#ifdef CONFIG_WEBCAM_OV7692
4245 &msm_camera_sensor_webcam_ov7692,
4246#endif
4247#ifdef CONFIG_WEBCAM_OV9726
4248 &msm_camera_sensor_webcam_ov9726,
4249#endif
4250#ifdef CONFIG_QS_S5K4E1
4251 &msm_camera_sensor_qs_s5k4e1,
4252#endif
4253#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004254#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004255#ifdef CONFIG_MSM_GEMINI
4256 &msm_gemini_device,
4257#endif
4258#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004259#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004260 &msm_vpe_device,
4261#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004262#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004263 &msm_device_vidc,
4264};
4265
4266#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4267enum {
4268 SX150X_CORE,
4269 SX150X_DOCKING,
4270 SX150X_SURF,
4271 SX150X_LEFT_FHA,
4272 SX150X_RIGHT_FHA,
4273 SX150X_SOUTH,
4274 SX150X_NORTH,
4275 SX150X_CORE_FLUID,
4276};
4277
4278static struct sx150x_platform_data sx150x_data[] __initdata = {
4279 [SX150X_CORE] = {
4280 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4281 .oscio_is_gpo = false,
4282 .io_pullup_ena = 0x0c08,
4283 .io_pulldn_ena = 0x4060,
4284 .io_open_drain_ena = 0x000c,
4285 .io_polarity = 0,
4286 .irq_summary = -1, /* see fixup_i2c_configs() */
4287 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4288 },
4289 [SX150X_DOCKING] = {
4290 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4291 .oscio_is_gpo = false,
4292 .io_pullup_ena = 0x5e06,
4293 .io_pulldn_ena = 0x81b8,
4294 .io_open_drain_ena = 0,
4295 .io_polarity = 0,
4296 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4297 UI_INT2_N),
4298 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4299 GPIO_DOCKING_EXPANDER_BASE -
4300 GPIO_EXPANDER_GPIO_BASE,
4301 },
4302 [SX150X_SURF] = {
4303 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4304 .oscio_is_gpo = false,
4305 .io_pullup_ena = 0,
4306 .io_pulldn_ena = 0,
4307 .io_open_drain_ena = 0,
4308 .io_polarity = 0,
4309 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4310 UI_INT1_N),
4311 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4312 GPIO_SURF_EXPANDER_BASE -
4313 GPIO_EXPANDER_GPIO_BASE,
4314 },
4315 [SX150X_LEFT_FHA] = {
4316 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4317 .oscio_is_gpo = false,
4318 .io_pullup_ena = 0,
4319 .io_pulldn_ena = 0x40,
4320 .io_open_drain_ena = 0,
4321 .io_polarity = 0,
4322 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4323 UI_INT3_N),
4324 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4325 GPIO_LEFT_KB_EXPANDER_BASE -
4326 GPIO_EXPANDER_GPIO_BASE,
4327 },
4328 [SX150X_RIGHT_FHA] = {
4329 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4330 .oscio_is_gpo = true,
4331 .io_pullup_ena = 0,
4332 .io_pulldn_ena = 0,
4333 .io_open_drain_ena = 0,
4334 .io_polarity = 0,
4335 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4336 UI_INT3_N),
4337 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4338 GPIO_RIGHT_KB_EXPANDER_BASE -
4339 GPIO_EXPANDER_GPIO_BASE,
4340 },
4341 [SX150X_SOUTH] = {
4342 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4343 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4344 GPIO_SOUTH_EXPANDER_BASE -
4345 GPIO_EXPANDER_GPIO_BASE,
4346 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4347 },
4348 [SX150X_NORTH] = {
4349 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4350 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4351 GPIO_NORTH_EXPANDER_BASE -
4352 GPIO_EXPANDER_GPIO_BASE,
4353 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4354 .oscio_is_gpo = true,
4355 .io_open_drain_ena = 0x30,
4356 },
4357 [SX150X_CORE_FLUID] = {
4358 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4359 .oscio_is_gpo = false,
4360 .io_pullup_ena = 0x0408,
4361 .io_pulldn_ena = 0x4060,
4362 .io_open_drain_ena = 0x0008,
4363 .io_polarity = 0,
4364 .irq_summary = -1, /* see fixup_i2c_configs() */
4365 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4366 },
4367};
4368
4369#ifdef CONFIG_SENSORS_MSM_ADC
4370/* Configuration of EPM expander is done when client
4371 * request an adc read
4372 */
4373static struct sx150x_platform_data sx150x_epmdata = {
4374 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4375 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4376 GPIO_EPM_EXPANDER_BASE -
4377 GPIO_EXPANDER_GPIO_BASE,
4378 .irq_summary = -1,
4379};
4380#endif
4381
4382/* sx150x_low_power_cfg
4383 *
4384 * This data and init function are used to put unused gpio-expander output
4385 * lines into their low-power states at boot. The init
4386 * function must be deferred until a later init stage because the i2c
4387 * gpio expander drivers do not probe until after they are registered
4388 * (see register_i2c_devices) and the work-queues for those registrations
4389 * are processed. Because these lines are unused, there is no risk of
4390 * competing with a device driver for the gpio.
4391 *
4392 * gpio lines whose low-power states are input are naturally in their low-
4393 * power configurations once probed, see the platform data structures above.
4394 */
4395struct sx150x_low_power_cfg {
4396 unsigned gpio;
4397 unsigned val;
4398};
4399
4400static struct sx150x_low_power_cfg
4401common_sx150x_lp_cfgs[] __initdata = {
4402 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4403 {GPIO_EXT_GPS_LNA_EN, 0},
4404 {GPIO_MSM_WAKES_BT, 0},
4405 {GPIO_USB_UICC_EN, 0},
4406 {GPIO_BATT_GAUGE_EN, 0},
4407};
4408
4409static struct sx150x_low_power_cfg
4410surf_ffa_sx150x_lp_cfgs[] __initdata = {
4411 {GPIO_MIPI_DSI_RST_N, 0},
4412 {GPIO_DONGLE_PWR_EN, 0},
4413 {GPIO_CAP_TS_SLEEP, 1},
4414 {GPIO_WEB_CAMIF_RESET_N, 0},
4415};
4416
4417static void __init
4418cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4419{
4420 unsigned n;
4421 int rc;
4422
4423 for (n = 0; n < nelems; ++n) {
4424 rc = gpio_request(cfgs[n].gpio, NULL);
4425 if (!rc) {
4426 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4427 gpio_free(cfgs[n].gpio);
4428 }
4429
4430 if (rc) {
4431 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4432 __func__, cfgs[n].gpio, rc);
4433 }
Steve Muckle9161d302010-02-11 11:50:40 -08004434 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004435}
4436
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004437static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004438{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004439 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4440 ARRAY_SIZE(common_sx150x_lp_cfgs));
4441 if (!machine_is_msm8x60_fluid())
4442 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4443 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4444 return 0;
4445}
4446module_init(cfg_sx150xs_low_power);
4447
4448#ifdef CONFIG_I2C
4449static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4450 {
4451 I2C_BOARD_INFO("sx1509q", 0x3e),
4452 .platform_data = &sx150x_data[SX150X_CORE]
4453 },
4454};
4455
4456static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4457 {
4458 I2C_BOARD_INFO("sx1509q", 0x3f),
4459 .platform_data = &sx150x_data[SX150X_DOCKING]
4460 },
4461};
4462
4463static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4464 {
4465 I2C_BOARD_INFO("sx1509q", 0x70),
4466 .platform_data = &sx150x_data[SX150X_SURF]
4467 }
4468};
4469
4470static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4471 {
4472 I2C_BOARD_INFO("sx1508q", 0x21),
4473 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4474 },
4475 {
4476 I2C_BOARD_INFO("sx1508q", 0x22),
4477 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4478 }
4479};
4480
4481static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4482 {
4483 I2C_BOARD_INFO("sx1508q", 0x23),
4484 .platform_data = &sx150x_data[SX150X_SOUTH]
4485 },
4486 {
4487 I2C_BOARD_INFO("sx1508q", 0x20),
4488 .platform_data = &sx150x_data[SX150X_NORTH]
4489 }
4490};
4491
4492static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4493 {
4494 I2C_BOARD_INFO("sx1509q", 0x3e),
4495 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4496 },
4497};
4498
4499#ifdef CONFIG_SENSORS_MSM_ADC
4500static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4501 {
4502 I2C_BOARD_INFO("sx1509q", 0x3e),
4503 .platform_data = &sx150x_epmdata
4504 },
4505};
4506#endif
4507#endif
4508#endif
4509
4510#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004511
4512static struct adc_access_fn xoadc_fn = {
4513 pm8058_xoadc_select_chan_and_start_conv,
4514 pm8058_xoadc_read_adc_code,
4515 pm8058_xoadc_get_properties,
4516 pm8058_xoadc_slot_request,
4517 pm8058_xoadc_restore_slot,
4518 pm8058_xoadc_calibrate,
4519};
4520
4521#if defined(CONFIG_I2C) && \
4522 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4523static struct regulator *vreg_adc_epm1;
4524
4525static struct i2c_client *epm_expander_i2c_register_board(void)
4526
4527{
4528 struct i2c_adapter *i2c_adap;
4529 struct i2c_client *client = NULL;
4530 i2c_adap = i2c_get_adapter(0x0);
4531
4532 if (i2c_adap == NULL)
4533 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4534
4535 if (i2c_adap != NULL)
4536 client = i2c_new_device(i2c_adap,
4537 &fluid_expanders_i2c_epm_info[0]);
4538 return client;
4539
4540}
4541
4542static unsigned int msm_adc_gpio_configure_expander_enable(void)
4543{
4544 int rc = 0;
4545 static struct i2c_client *epm_i2c_client;
4546
4547 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4548
4549 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4550
4551 if (IS_ERR(vreg_adc_epm1)) {
4552 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4553 return 0;
4554 }
4555
4556 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4557 if (rc)
4558 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4559 "regulator set voltage failed\n");
4560
4561 rc = regulator_enable(vreg_adc_epm1);
4562 if (rc) {
4563 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4564 "Error while enabling regulator for epm s3 %d\n", rc);
4565 return rc;
4566 }
4567
4568 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4569 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4570
4571 msleep(1000);
4572
4573 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4574 if (!rc) {
4575 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4576 "Configure 5v boost\n");
4577 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4578 } else {
4579 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4580 "Error for epm 5v boost en\n");
4581 goto exit_vreg_epm;
4582 }
4583
4584 msleep(500);
4585
4586 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4587 if (!rc) {
4588 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4589 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4590 "Configure epm 3.3v\n");
4591 } else {
4592 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4593 "Error for gpio 3.3ven\n");
4594 goto exit_vreg_epm;
4595 }
4596 msleep(500);
4597
4598 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4599 "Trying to request EPM LVLSFT_EN\n");
4600 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4601 if (!rc) {
4602 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4603 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4604 "Configure the lvlsft\n");
4605 } else {
4606 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4607 "Error for epm lvlsft_en\n");
4608 goto exit_vreg_epm;
4609 }
4610
4611 msleep(500);
4612
4613 if (!epm_i2c_client)
4614 epm_i2c_client = epm_expander_i2c_register_board();
4615
4616 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4617 if (!rc)
4618 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4619 if (rc) {
4620 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4621 ": GPIO PWR MON Enable issue\n");
4622 goto exit_vreg_epm;
4623 }
4624
4625 msleep(1000);
4626
4627 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4628 if (!rc) {
4629 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4630 if (rc) {
4631 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4632 ": ADC1_PWDN error direction out\n");
4633 goto exit_vreg_epm;
4634 }
4635 }
4636
4637 msleep(100);
4638
4639 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4640 if (!rc) {
4641 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4642 if (rc) {
4643 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4644 ": ADC2_PWD error direction out\n");
4645 goto exit_vreg_epm;
4646 }
4647 }
4648
4649 msleep(1000);
4650
4651 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4652 if (!rc) {
4653 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4654 if (rc) {
4655 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4656 "Gpio request problem %d\n", rc);
4657 goto exit_vreg_epm;
4658 }
4659 }
4660
4661 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4662 if (!rc) {
4663 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4664 if (rc) {
4665 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4666 ": EPM_SPI_ADC1_CS_N error\n");
4667 goto exit_vreg_epm;
4668 }
4669 }
4670
4671 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4672 if (!rc) {
4673 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4674 if (rc) {
4675 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4676 ": EPM_SPI_ADC2_Cs_N error\n");
4677 goto exit_vreg_epm;
4678 }
4679 }
4680
4681 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4682 "the power monitor reset for epm\n");
4683
4684 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4685 if (!rc) {
4686 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4687 if (rc) {
4688 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4689 ": Error in the power mon reset\n");
4690 goto exit_vreg_epm;
4691 }
4692 }
4693
4694 msleep(1000);
4695
4696 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4697
4698 msleep(500);
4699
4700 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4701
4702 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4703
4704 return rc;
4705
4706exit_vreg_epm:
4707 regulator_disable(vreg_adc_epm1);
4708
4709 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4710 " rc = %d.\n", rc);
4711 return rc;
4712};
4713
4714static unsigned int msm_adc_gpio_configure_expander_disable(void)
4715{
4716 int rc = 0;
4717
4718 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4719 gpio_free(GPIO_PWR_MON_RESET_N);
4720
4721 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4722 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4723
4724 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4725 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4726
4727 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4728 gpio_free(GPIO_PWR_MON_START);
4729
4730 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4731 gpio_free(GPIO_ADC1_PWDN_N);
4732
4733 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4734 gpio_free(GPIO_ADC2_PWDN_N);
4735
4736 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4737 gpio_free(GPIO_PWR_MON_ENABLE);
4738
4739 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4740 gpio_free(GPIO_EPM_LVLSFT_EN);
4741
4742 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4743 gpio_free(GPIO_EPM_5V_BOOST_EN);
4744
4745 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4746 gpio_free(GPIO_EPM_3_3V_EN);
4747
4748 rc = regulator_disable(vreg_adc_epm1);
4749 if (rc)
4750 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4751 "Error while enabling regulator for epm s3 %d\n", rc);
4752 regulator_put(vreg_adc_epm1);
4753
4754 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4755 return rc;
4756};
4757
4758unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4759{
4760 int rc = 0;
4761
4762 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4763 cs_enable);
4764
4765 if (cs_enable < 16) {
4766 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4767 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4768 } else {
4769 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4770 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4771 }
4772 return rc;
4773};
4774
4775unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4776{
4777 int rc = 0;
4778
4779 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4780
4781 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4782
4783 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4784
4785 return rc;
4786};
4787#endif
4788
4789static struct msm_adc_channels msm_adc_channels_data[] = {
4790 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4791 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4792 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4793 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4794 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4795 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4796 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4797 CHAN_PATH_TYPE4,
4798 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4799 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4800 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4801 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4802 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4803 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4804 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4805 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4806 CHAN_PATH_TYPE12,
4807 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4808 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4809 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4810 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4811 CHAN_PATH_TYPE_NONE,
4812 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4813 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4814 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4815 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4816 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4817 scale_xtern_chgr_cur},
4818 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4819 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4820 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4822 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4823 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4824 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4825 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4826 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4827 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4828 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4829 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4830};
4831
4832static char *msm_adc_fluid_device_names[] = {
4833 "ADS_ADC1",
4834 "ADS_ADC2",
4835};
4836
4837static struct msm_adc_platform_data msm_adc_pdata = {
4838 .channel = msm_adc_channels_data,
4839 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4840#if defined(CONFIG_I2C) && \
4841 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4842 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4843 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4844 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4845 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4846#endif
4847};
4848
4849static struct platform_device msm_adc_device = {
4850 .name = "msm_adc",
4851 .id = -1,
4852 .dev = {
4853 .platform_data = &msm_adc_pdata,
4854 },
4855};
4856
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304857static struct msm_rtb_platform_data msm_rtb_pdata = {
4858 .size = SZ_1M,
4859};
4860
4861static int __init msm_rtb_set_buffer_size(char *p)
4862{
4863 int s;
4864
4865 s = memparse(p, NULL);
4866 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4867 return 0;
4868}
4869early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4870
4871
4872static struct platform_device msm_rtb_device = {
4873 .name = "msm_rtb",
4874 .id = -1,
4875 .dev = {
4876 .platform_data = &msm_rtb_pdata,
4877 },
4878};
4879
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004880static void pmic8058_xoadc_mpp_config(void)
4881{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304882 int rc, i;
4883 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304884 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304885 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304886 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304887 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304888 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304889 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304890 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304891 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304892 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304893 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304894 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4895 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304896 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004897
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304898 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4899 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4900 &xoadc_mpps[i].config);
4901 if (rc) {
4902 pr_err("%s: Config MPP %d of PM8058 failed\n",
4903 __func__, xoadc_mpps[i].mpp);
4904 }
4905 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004906}
4907
4908static struct regulator *vreg_ldo18_adc;
4909
4910static int pmic8058_xoadc_vreg_config(int on)
4911{
4912 int rc;
4913
4914 if (on) {
4915 rc = regulator_enable(vreg_ldo18_adc);
4916 if (rc)
4917 pr_err("%s: Enable of regulator ldo18_adc "
4918 "failed\n", __func__);
4919 } else {
4920 rc = regulator_disable(vreg_ldo18_adc);
4921 if (rc)
4922 pr_err("%s: Disable of regulator ldo18_adc "
4923 "failed\n", __func__);
4924 }
4925
4926 return rc;
4927}
4928
4929static int pmic8058_xoadc_vreg_setup(void)
4930{
4931 int rc;
4932
4933 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4934 if (IS_ERR(vreg_ldo18_adc)) {
4935 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4936 __func__, PTR_ERR(vreg_ldo18_adc));
4937 rc = PTR_ERR(vreg_ldo18_adc);
4938 goto fail;
4939 }
4940
4941 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4942 if (rc) {
4943 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4944 goto fail;
4945 }
4946
4947 return rc;
4948fail:
4949 regulator_put(vreg_ldo18_adc);
4950 return rc;
4951}
4952
4953static void pmic8058_xoadc_vreg_shutdown(void)
4954{
4955 regulator_put(vreg_ldo18_adc);
4956}
4957
4958/* usec. For this ADC,
4959 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4960 * Each channel has different configuration, thus at the time of starting
4961 * the conversion, xoadc will return actual conversion time
4962 * */
4963static struct adc_properties pm8058_xoadc_data = {
4964 .adc_reference = 2200, /* milli-voltage for this adc */
4965 .bitresolution = 15,
4966 .bipolar = 0,
4967 .conversiontime = 54,
4968};
4969
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304970static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004971 .xoadc_prop = &pm8058_xoadc_data,
4972 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4973 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4974 .xoadc_num = XOADC_PMIC_0,
4975 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4976 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4977};
4978#endif
4979
4980#ifdef CONFIG_MSM_SDIO_AL
4981
4982static unsigned mdm2ap_status = 140;
4983
4984static int configure_mdm2ap_status(int on)
4985{
4986 int ret = 0;
4987 if (on)
4988 ret = msm_gpiomux_get(mdm2ap_status);
4989 else
4990 ret = msm_gpiomux_put(mdm2ap_status);
4991
4992 if (ret)
4993 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4994 on);
4995
4996 return ret;
4997}
4998
4999
5000static int get_mdm2ap_status(void)
5001{
5002 return gpio_get_value(mdm2ap_status);
5003}
5004
5005static struct sdio_al_platform_data sdio_al_pdata = {
5006 .config_mdm2ap_status = configure_mdm2ap_status,
5007 .get_mdm2ap_status = get_mdm2ap_status,
5008 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03005009 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005010 .peer_sdioc_version_major = 0x0004,
5011 .peer_sdioc_boot_version_minor = 0x0001,
5012 .peer_sdioc_boot_version_major = 0x0003
5013};
5014
5015struct platform_device msm_device_sdio_al = {
5016 .name = "msm_sdio_al",
5017 .id = -1,
5018 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03005019 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005020 .platform_data = &sdio_al_pdata,
5021 },
5022};
5023
5024#endif /* CONFIG_MSM_SDIO_AL */
5025
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305026#define GPIO_VREG_ID_EXT_5V 0
5027
5028static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5029 REGULATOR_SUPPLY("ext_5v", NULL),
5030 REGULATOR_SUPPLY("8901_mpp0", NULL),
5031};
5032
5033#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5034 [GPIO_VREG_ID_##_id] = { \
5035 .init_data = { \
5036 .constraints = { \
5037 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5038 }, \
5039 .num_consumer_supplies = \
5040 ARRAY_SIZE(vreg_consumers_##_id), \
5041 .consumer_supplies = vreg_consumers_##_id, \
5042 }, \
5043 .regulator_name = _reg_name, \
5044 .active_low = _active_low, \
5045 .gpio_label = _gpio_label, \
5046 .gpio = _gpio, \
5047 }
5048
5049/* GPIO regulator constraints */
5050static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5051 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5052 PM8901_MPP_PM_TO_SYS(0), 0),
5053};
5054
5055/* GPIO regulator */
5056static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5057 .name = GPIO_REGULATOR_DEV_NAME,
5058 .id = PM8901_MPP_PM_TO_SYS(0),
5059 .dev = {
5060 .platform_data =
5061 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5062 },
5063};
5064
5065static void __init pm8901_vreg_mpp0_init(void)
5066{
5067 int rc;
5068
5069 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5070 .mpp = PM8901_MPP_PM_TO_SYS(0),
5071 .config = {
5072 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5073 .level = PM8901_MPP_DIG_LEVEL_VPH,
5074 },
5075 };
5076
5077 /*
5078 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5079 * implies that the regulator connected to MPP0 is enabled when
5080 * MPP0 is low.
5081 */
5082 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5083 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5084 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5085 } else {
5086 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5087 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5088 }
5089
5090 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5091 if (rc)
5092 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5093}
5094
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005095static struct platform_device *charm_devices[] __initdata = {
5096 &msm_charm_modem,
5097#ifdef CONFIG_MSM_SDIO_AL
5098 &msm_device_sdio_al,
5099#endif
5100};
5101
Lei Zhou338cab82011-08-19 13:38:17 -04005102#ifdef CONFIG_SND_SOC_MSM8660_APQ
5103static struct platform_device *dragon_alsa_devices[] __initdata = {
5104 &msm_pcm,
5105 &msm_pcm_routing,
5106 &msm_cpudai0,
5107 &msm_cpudai1,
5108 &msm_cpudai_hdmi_rx,
5109 &msm_cpudai_bt_rx,
5110 &msm_cpudai_bt_tx,
5111 &msm_cpudai_fm_rx,
5112 &msm_cpudai_fm_tx,
5113 &msm_cpu_fe,
5114 &msm_stub_codec,
5115 &msm_lpa_pcm,
5116};
5117#endif
5118
5119static struct platform_device *asoc_devices[] __initdata = {
5120 &asoc_msm_pcm,
5121 &asoc_msm_dai0,
5122 &asoc_msm_dai1,
5123};
5124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005125static struct platform_device *surf_devices[] __initdata = {
5126 &msm_device_smd,
5127 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005128 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005129 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005130 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005131 &msm_pil_dsps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005132#ifdef CONFIG_I2C_QUP
5133 &msm_gsbi3_qup_i2c_device,
5134 &msm_gsbi4_qup_i2c_device,
5135 &msm_gsbi7_qup_i2c_device,
5136 &msm_gsbi8_qup_i2c_device,
5137 &msm_gsbi9_qup_i2c_device,
5138 &msm_gsbi12_qup_i2c_device,
5139#endif
5140#ifdef CONFIG_SERIAL_MSM_HS
5141 &msm_device_uart_dm1,
5142#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305143#ifdef CONFIG_MSM_SSBI
5144 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305145 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305146#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005147#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005148 &msm_device_ssbi3,
5149#endif
5150#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5151 &isp1763_device,
5152#endif
5153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005154#if defined (CONFIG_MSM_8x60_VOIP)
5155 &asoc_msm_mvs,
5156 &asoc_mvs_dai0,
5157 &asoc_mvs_dai1,
5158#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005159
Lena Salman57d167e2012-03-21 19:46:38 +02005160#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005161 &msm_device_otg,
5162#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005163#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005164 &msm_device_gadget_peripheral,
5165#endif
5166#ifdef CONFIG_USB_G_ANDROID
5167 &android_usb_device,
5168#endif
5169#ifdef CONFIG_BATTERY_MSM
5170 &msm_batt_device,
5171#endif
5172#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005173#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005174 &android_pmem_device,
5175 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005176 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005177 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305178#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5179#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005180#ifdef CONFIG_MSM_ROTATOR
5181 &msm_rotator_device,
5182#endif
5183 &msm_fb_device,
5184 &msm_kgsl_3d0,
5185 &msm_kgsl_2d0,
5186 &msm_kgsl_2d1,
5187 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005188#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5189 &lcdc_nt35582_panel_device,
5190#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005191#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5192 &lcdc_samsung_oled_panel_device,
5193#endif
5194#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5195 &lcdc_auo_wvga_panel_device,
5196#endif
5197#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5198 &hdmi_msm_device,
5199#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5200#ifdef CONFIG_FB_MSM_MIPI_DSI
5201 &mipi_dsi_toshiba_panel_device,
5202 &mipi_dsi_novatek_panel_device,
5203#endif
5204#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005205#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005206#ifdef CONFIG_MT9E013
5207 &msm_camera_sensor_mt9e013,
5208#endif
5209#ifdef CONFIG_IMX074
5210 &msm_camera_sensor_imx074,
5211#endif
5212#ifdef CONFIG_WEBCAM_OV7692
5213 &msm_camera_sensor_webcam_ov7692,
5214#endif
5215#ifdef CONFIG_WEBCAM_OV9726
5216 &msm_camera_sensor_webcam_ov9726,
5217#endif
5218#ifdef CONFIG_QS_S5K4E1
5219 &msm_camera_sensor_qs_s5k4e1,
5220#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005221#ifdef CONFIG_VX6953
5222 &msm_camera_sensor_vx6953,
5223#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005224#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005225#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005226#ifdef CONFIG_MSM_GEMINI
5227 &msm_gemini_device,
5228#endif
5229#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005230#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005231 &msm_vpe_device,
5232#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005233#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005234
5235#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005236 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005237#endif
5238#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005239 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240#endif
5241 &msm_device_vidc,
5242#if (defined(CONFIG_MARIMBA_CORE)) && \
5243 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5244 &msm_bt_power_device,
5245#endif
5246#ifdef CONFIG_SENSORS_MSM_ADC
5247 &msm_adc_device,
5248#endif
David Collins6f032ba2011-08-31 14:08:15 -07005249 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005250
5251#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5252 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5253 &qcrypto_device,
5254#endif
5255
5256#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5257 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5258 &qcedev_device,
5259#endif
5260
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005261
5262#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5263#ifdef CONFIG_MSM_USE_TSIF1
5264 &msm_device_tsif[1],
5265#else
5266 &msm_device_tsif[0],
5267#endif /* CONFIG_MSM_USE_TSIF1 */
5268#endif /* CONFIG_TSIF */
5269
5270#ifdef CONFIG_HW_RANDOM_MSM
5271 &msm_device_rng,
5272#endif
5273
5274 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005275 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005276#ifdef CONFIG_ION_MSM
5277 &ion_dev,
5278#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005279 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005280 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305281 &msm_rtb_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005282};
5283
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005284#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005285#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5286static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5287 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005288 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005289 .request_region = request_smi_region,
5290 .release_region = release_smi_region,
5291 .setup_region = setup_smi_region,
Olav Haugan8726caf2012-05-10 15:11:35 -07005292 .iommu_map_all = 1,
5293 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005294};
5295
5296static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5297 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005298 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005299 .request_region = request_smi_region,
5300 .release_region = release_smi_region,
5301 .setup_region = setup_smi_region,
5302};
5303
5304static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5305 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005306 .align = PAGE_SIZE,
5307};
5308
5309static struct ion_co_heap_pdata fw_co_ion_pdata = {
5310 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5311 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005312};
5313
5314static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005315 .adjacent_mem_id = INVALID_HEAP_ID,
5316 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005317};
5318#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005319
5320/**
5321 * These heaps are listed in the order they will be allocated. Due to
5322 * video hardware restrictions and content protection the FW heap has to
5323 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5324 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5325 * away from the base address of the FW heap.
5326 * However, the order of FW heap and MM heap doesn't matter since these
5327 * two heaps are taken care of by separate code to ensure they are adjacent
5328 * to each other.
5329 * Don't swap the order unless you know what you are doing!
5330 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005331static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005332 .nr = MSM_ION_HEAP_NUM,
5333 .heaps = {
5334 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005335 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005336 .type = ION_HEAP_TYPE_SYSTEM,
5337 .name = ION_VMALLOC_HEAP_NAME,
5338 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005339#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5340 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005341 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005342 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005343 .name = ION_MM_HEAP_NAME,
5344 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005345 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005346 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005347 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005348 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005349 .id = ION_MM_FIRMWARE_HEAP_ID,
5350 .type = ION_HEAP_TYPE_CARVEOUT,
5351 .name = ION_MM_FIRMWARE_HEAP_NAME,
5352 .size = MSM_ION_MM_FW_SIZE,
5353 .memory_type = ION_SMI_TYPE,
5354 .extra_data = (void *) &fw_co_ion_pdata,
5355 },
5356 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005357 .id = ION_CP_MFC_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_MFC_HEAP_NAME,
5360 .size = MSM_ION_MFC_SIZE,
5361 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005362 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005363 },
5364 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005365 .id = ION_SF_HEAP_ID,
5366 .type = ION_HEAP_TYPE_CARVEOUT,
5367 .name = ION_SF_HEAP_NAME,
5368 .size = MSM_ION_SF_SIZE,
5369 .memory_type = ION_EBI_TYPE,
5370 .extra_data = (void *)&co_ion_pdata,
5371 },
5372 {
5373 .id = ION_CAMERA_HEAP_ID,
5374 .type = ION_HEAP_TYPE_CARVEOUT,
5375 .name = ION_CAMERA_HEAP_NAME,
5376 .size = MSM_ION_CAMERA_SIZE,
5377 .memory_type = ION_EBI_TYPE,
5378 .extra_data = &co_ion_pdata,
5379 },
5380 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005381 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005382 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005383 .name = ION_WB_HEAP_NAME,
5384 .size = MSM_ION_WB_SIZE,
5385 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005386 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005387 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005388 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005389 .id = ION_QSECOM_HEAP_ID,
5390 .type = ION_HEAP_TYPE_CARVEOUT,
5391 .name = ION_QSECOM_HEAP_NAME,
5392 .size = MSM_ION_QSECOM_SIZE,
5393 .memory_type = ION_EBI_TYPE,
5394 .extra_data = (void *) &co_ion_pdata,
5395 },
5396 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005397 .id = ION_AUDIO_HEAP_ID,
5398 .type = ION_HEAP_TYPE_CARVEOUT,
5399 .name = ION_AUDIO_HEAP_NAME,
5400 .size = MSM_ION_AUDIO_SIZE,
5401 .memory_type = ION_EBI_TYPE,
5402 .extra_data = (void *)&co_ion_pdata,
5403 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005404#endif
5405 }
5406};
5407
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005408static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005409 .name = "ion-msm",
5410 .id = 1,
5411 .dev = { .platform_data = &ion_pdata },
5412};
5413#endif
5414
5415
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005416static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5417 /* Kernel SMI memory pool for video core, used for firmware */
5418 /* and encoder, decoder scratch buffers */
5419 /* Kernel SMI memory pool should always precede the user space */
5420 /* SMI memory pool, as the video core will use offset address */
5421 /* from the Firmware base */
5422 [MEMTYPE_SMI_KERNEL] = {
5423 .start = KERNEL_SMI_BASE,
5424 .limit = KERNEL_SMI_SIZE,
5425 .size = KERNEL_SMI_SIZE,
5426 .flags = MEMTYPE_FLAGS_FIXED,
5427 },
5428 /* User space SMI memory pool for video core */
5429 /* used for encoder, decoder input & output buffers */
5430 [MEMTYPE_SMI] = {
5431 .start = USER_SMI_BASE,
5432 .limit = USER_SMI_SIZE,
5433 .flags = MEMTYPE_FLAGS_FIXED,
5434 },
5435 [MEMTYPE_EBI0] = {
5436 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5437 },
5438 [MEMTYPE_EBI1] = {
5439 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5440 },
5441};
5442
Stephen Boyd668d7652012-04-25 11:31:01 -07005443static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005444{
5445#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005446 unsigned int i;
5447
5448 if (hdmi_is_primary) {
5449 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5450 for (i = 0; i < ion_pdata.nr; i++) {
5451 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5452 ion_pdata.heaps[i].size = msm_ion_sf_size;
5453 pr_debug("msm_ion_sf_size 0x%x\n",
5454 msm_ion_sf_size);
5455 break;
5456 }
5457 }
5458 }
5459
Olav Haugan8726caf2012-05-10 15:11:35 -07005460 /* Verify size of heap is a multiple of 64K */
5461 for (i = 0; i < ion_pdata.nr; i++) {
5462 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5463
5464 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5465 int map_all = ((struct ion_cp_heap_pdata *)
5466 heap->extra_data)->iommu_map_all;
5467
5468 if (map_all && (heap->size & (SZ_64K-1))) {
5469 heap->size = ALIGN(heap->size, SZ_64K);
5470 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5471 heap->name, heap->size);
5472
5473 }
5474 }
5475 }
5476
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005477 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Haugan42ebe712012-01-10 16:30:58 -08005478 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005479 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5480 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5481 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5482 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005483 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005484 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005485#endif
5486}
5487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005488static void __init size_pmem_devices(void)
5489{
5490#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005491#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005492 android_pmem_adsp_pdata.size = pmem_adsp_size;
5493 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005494
5495 if (hdmi_is_primary)
5496 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005498 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305499#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5500#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005501}
5502
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305503#ifdef CONFIG_ANDROID_PMEM
5504#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005505static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5506{
5507 msm8x60_reserve_table[p->memory_type].size += p->size;
5508}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305509#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5510#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005511
5512static void __init reserve_pmem_memory(void)
5513{
5514#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005515#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005516 reserve_memory_for(&android_pmem_adsp_pdata);
5517 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005518 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005519 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305520#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005521 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305522#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523}
5524
Huaibin Yanga5419422011-12-08 23:52:10 -08005525static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005526
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305527static void __init reserve_rtb_memory(void)
5528{
5529#if defined(CONFIG_MSM_RTB)
5530 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5531#endif
5532}
5533
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005534static void __init msm8x60_calculate_reserve_sizes(void)
5535{
5536 size_pmem_devices();
5537 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005538 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005539 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305540 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005541}
5542
5543static int msm8x60_paddr_to_memtype(unsigned int paddr)
5544{
5545 if (paddr >= 0x40000000 && paddr < 0x60000000)
5546 return MEMTYPE_EBI1;
5547 if (paddr >= 0x38000000 && paddr < 0x40000000)
5548 return MEMTYPE_SMI;
5549 return MEMTYPE_NONE;
5550}
5551
5552static struct reserve_info msm8x60_reserve_info __initdata = {
5553 .memtype_reserve_table = msm8x60_reserve_table,
5554 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5555 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5556};
5557
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005558static char prim_panel_name[PANEL_NAME_MAX_LEN];
5559static char ext_panel_name[PANEL_NAME_MAX_LEN];
5560static int __init prim_display_setup(char *param)
5561{
5562 if (strnlen(param, PANEL_NAME_MAX_LEN))
5563 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5564 return 0;
5565}
5566early_param("prim_display", prim_display_setup);
5567
5568static int __init ext_display_setup(char *param)
5569{
5570 if (strnlen(param, PANEL_NAME_MAX_LEN))
5571 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5572 return 0;
5573}
5574early_param("ext_display", ext_display_setup);
5575
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005576static void __init msm8x60_reserve(void)
5577{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005578 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005579 reserve_info = &msm8x60_reserve_info;
5580 msm_reserve();
5581}
5582
5583#define EXT_CHG_VALID_MPP 10
5584#define EXT_CHG_VALID_MPP_2 11
5585
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305586static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305587 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305588 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305589 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305590 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5591};
5592
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593#ifdef CONFIG_ISL9519_CHARGER
5594static int isl_detection_setup(void)
5595{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305596 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005597
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305598 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5599 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5600 &isl_mpp[i].config);
5601 if (ret) {
5602 pr_err("%s: Config MPP %d of PM8058 failed\n",
5603 __func__, isl_mpp[i].mpp);
5604 return ret;
5605 }
5606 }
5607
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608 return ret;
5609}
5610
5611static struct isl_platform_data isl_data __initdata = {
5612 .chgcurrent = 700,
5613 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5614 .chg_detection_config = isl_detection_setup,
5615 .max_system_voltage = 4200,
5616 .min_system_voltage = 3200,
5617 .term_current = 120,
5618 .input_current = 2048,
5619};
5620
5621static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5622 {
5623 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305624 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005625 .platform_data = &isl_data,
5626 },
5627};
5628#endif
5629
5630#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5631static int smb137b_detection_setup(void)
5632{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305633 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005634
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305635 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5636 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5637 &isl_mpp[i].config);
5638 if (ret) {
5639 pr_err("%s: Config MPP %d of PM8058 failed\n",
5640 __func__, isl_mpp[i].mpp);
5641 return ret;
5642 }
5643 }
5644
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645 return ret;
5646}
5647
5648static struct smb137b_platform_data smb137b_data __initdata = {
5649 .chg_detection_config = smb137b_detection_setup,
5650 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5651 .batt_mah_rating = 950,
5652};
5653
5654static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5655 {
5656 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305657 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005658 .platform_data = &smb137b_data,
5659 },
5660};
5661#endif
5662
5663#ifdef CONFIG_PMIC8058
5664#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305665#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005666
5667static int pm8058_gpios_init(void)
5668{
5669 int i;
5670 int rc;
5671 struct pm8058_gpio_cfg {
5672 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305673 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005674 };
5675
5676 struct pm8058_gpio_cfg gpio_cfgs[] = {
5677 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305678 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005679 {
5680 .direction = PM_GPIO_DIR_IN,
5681 .pull = PM_GPIO_PULL_DN,
5682 .vin_sel = 2,
5683 .function = PM_GPIO_FUNC_NORMAL,
5684 .inv_int_pol = 0,
5685 },
5686 },
5687#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5688 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305689 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005690 {
5691 .direction = PM_GPIO_DIR_IN,
5692 .pull = PM_GPIO_PULL_UP_30,
5693 .vin_sel = 2,
5694 .function = PM_GPIO_FUNC_NORMAL,
5695 .inv_int_pol = 0,
5696 },
5697 },
5698#endif
5699 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305700 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005701 {
5702 .direction = PM_GPIO_DIR_IN,
5703 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305704 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005705 .function = PM_GPIO_FUNC_NORMAL,
5706 .inv_int_pol = 0,
5707 },
5708 },
5709 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305710 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005711 {
5712 .direction = PM_GPIO_DIR_IN,
5713 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305714 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005715 .function = PM_GPIO_FUNC_NORMAL,
5716 .inv_int_pol = 0,
5717 },
5718 },
5719 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305720 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005721 {
5722 .direction = PM_GPIO_DIR_IN,
5723 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305724 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725 .function = PM_GPIO_FUNC_NORMAL,
5726 .inv_int_pol = 0,
5727 },
5728 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005729 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305730 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005731 {
5732 .direction = PM_GPIO_DIR_OUT,
5733 .output_value = 1,
5734 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5735 .pull = PM_GPIO_PULL_DN,
5736 .out_strength = PM_GPIO_STRENGTH_HIGH,
5737 .function = PM_GPIO_FUNC_NORMAL,
5738 .vin_sel = 2,
5739 .inv_int_pol = 0,
5740 }
5741 },
5742 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305743 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005744 {
5745 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305746 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005747 .function = PM_GPIO_FUNC_NORMAL,
5748 .vin_sel = 2,
5749 .inv_int_pol = 0,
5750 }
5751 },
5752 };
5753
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305754#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5755 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305756 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305757 .direction = PM_GPIO_DIR_IN,
5758 .pull = PM_GPIO_PULL_UP_1P5,
5759 .vin_sel = 2,
5760 .function = PM_GPIO_FUNC_NORMAL,
5761 };
5762#endif
5763
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005764#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305765 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305766 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305767 .direction = PM_GPIO_DIR_OUT,
5768 .pull = PM_GPIO_PULL_NO,
5769 .out_strength = PM_GPIO_STRENGTH_HIGH,
5770 .function = PM_GPIO_FUNC_NORMAL,
5771 .inv_int_pol = 0,
5772 .vin_sel = 2,
5773 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5774 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005775 };
5776#endif
5777
5778#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5779 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305780 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781 {
5782 .direction = PM_GPIO_DIR_IN,
5783 .pull = PM_GPIO_PULL_UP_1P5,
5784 .vin_sel = 2,
5785 .function = PM_GPIO_FUNC_NORMAL,
5786 .inv_int_pol = 0,
5787 }
5788 };
5789#endif
5790
5791#if defined(CONFIG_QS_S5K4E1)
5792 {
5793 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305794 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005795 {
5796 .direction = PM_GPIO_DIR_OUT,
5797 .output_value = 0,
5798 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5799 .pull = PM_GPIO_PULL_DN,
5800 .out_strength = PM_GPIO_STRENGTH_HIGH,
5801 .function = PM_GPIO_FUNC_NORMAL,
5802 .vin_sel = 2,
5803 .inv_int_pol = 0,
5804 }
5805 };
5806#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005807#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5808 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305809 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005810 {
5811 .direction = PM_GPIO_DIR_OUT,
5812 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5813 .output_value = 1,
5814 .pull = PM_GPIO_PULL_UP_30,
5815 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305816 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005817 .out_strength = PM_GPIO_STRENGTH_HIGH,
5818 .function = PM_GPIO_FUNC_NORMAL,
5819 .inv_int_pol = 0,
5820 }
5821 };
5822#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005823#if defined(CONFIG_HAPTIC_ISA1200) || \
5824 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5825 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305826 rc = pm8xxx_gpio_config(
5827 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5828 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005829 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305830 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005831 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305832 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305833 rc = pm8xxx_gpio_config(
5834 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5835 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305836 if (rc < 0) {
5837 pr_err("%s: pmic haptics ldo gpio config failed\n",
5838 __func__);
5839 }
5840
5841 }
5842#endif
5843
5844#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5845 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5846 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5847 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305848 rc = pm8xxx_gpio_config(
5849 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5850 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305851 if (rc < 0) {
5852 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5853 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005854 }
5855 }
5856#endif
5857
5858#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5859 /* Line_in only for 8660 ffa & surf */
5860 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005861 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005862 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305863 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005864 &line_in_gpio_cfg.cfg);
5865 if (rc < 0) {
5866 pr_err("%s pmic line_in gpio config failed\n",
5867 __func__);
5868 return rc;
5869 }
5870 }
5871#endif
5872
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005873#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5874 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305875 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005876 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5877 if (rc < 0) {
5878 pr_err("%s pmic gpio config failed\n", __func__);
5879 return rc;
5880 }
5881 }
5882#endif
5883
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005884#if defined(CONFIG_QS_S5K4E1)
5885 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5886 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305887 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005888 &qs_hc37_cam_pd_gpio_cfg.cfg);
5889 if (rc < 0) {
5890 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5891 __func__);
5892 return rc;
5893 }
5894 }
5895 }
5896#endif
5897
5898 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305899 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005900 &gpio_cfgs[i].cfg);
5901 if (rc < 0) {
5902 pr_err("%s pmic gpio config failed\n",
5903 __func__);
5904 return rc;
5905 }
5906 }
5907
5908 return 0;
5909}
5910
5911static const unsigned int ffa_keymap[] = {
5912 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5913 KEY(0, 1, KEY_UP), /* NAV - UP */
5914 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5915 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5916
5917 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5918 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5919 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5920 KEY(1, 3, KEY_VOLUMEDOWN),
5921
5922 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5923
5924 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5925 KEY(4, 1, KEY_UP), /* USER_UP */
5926 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5927 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5928 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5929
5930 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5931 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5932 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5933 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5934 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5935};
5936
Zhang Chang Ken683be172011-08-10 17:45:34 -04005937static const unsigned int dragon_keymap[] = {
5938 KEY(0, 0, KEY_MENU),
5939 KEY(0, 2, KEY_1),
5940 KEY(0, 3, KEY_4),
5941 KEY(0, 4, KEY_7),
5942
5943 KEY(1, 0, KEY_UP),
5944 KEY(1, 1, KEY_LEFT),
5945 KEY(1, 2, KEY_DOWN),
5946 KEY(1, 3, KEY_5),
5947 KEY(1, 4, KEY_8),
5948
5949 KEY(2, 0, KEY_HOME),
5950 KEY(2, 1, KEY_REPLY),
5951 KEY(2, 2, KEY_2),
5952 KEY(2, 3, KEY_6),
5953 KEY(2, 4, KEY_0),
5954
5955 KEY(3, 0, KEY_VOLUMEUP),
5956 KEY(3, 1, KEY_RIGHT),
5957 KEY(3, 2, KEY_3),
5958 KEY(3, 3, KEY_9),
5959 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5960
5961 KEY(4, 0, KEY_VOLUMEDOWN),
5962 KEY(4, 1, KEY_BACK),
5963 KEY(4, 2, KEY_CAMERA),
5964 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5965};
5966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005967static struct matrix_keymap_data ffa_keymap_data = {
5968 .keymap_size = ARRAY_SIZE(ffa_keymap),
5969 .keymap = ffa_keymap,
5970};
5971
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305972static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005973 .input_name = "ffa-keypad",
5974 .input_phys_device = "ffa-keypad/input0",
5975 .num_rows = 6,
5976 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305977 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5978 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5979 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 .scan_delay_ms = 32,
5981 .row_hold_ns = 91500,
5982 .wakeup = 1,
5983 .keymap_data = &ffa_keymap_data,
5984};
5985
Zhang Chang Ken683be172011-08-10 17:45:34 -04005986static struct matrix_keymap_data dragon_keymap_data = {
5987 .keymap_size = ARRAY_SIZE(dragon_keymap),
5988 .keymap = dragon_keymap,
5989};
5990
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305991static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005992 .input_name = "dragon-keypad",
5993 .input_phys_device = "dragon-keypad/input0",
5994 .num_rows = 6,
5995 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305996 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5997 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5998 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005999 .scan_delay_ms = 32,
6000 .row_hold_ns = 91500,
6001 .wakeup = 1,
6002 .keymap_data = &dragon_keymap_data,
6003};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306004
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006005static const unsigned int fluid_keymap[] = {
6006 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6007 KEY(0, 1, KEY_UP), /* NAV - UP */
6008 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6009 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6010
6011 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6012 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6013 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6014 KEY(1, 3, KEY_VOLUMEUP),
6015
6016 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6017
6018 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6019 KEY(4, 1, KEY_UP), /* USER_UP */
6020 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6021 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6022 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6023
Jilai Wang9a895102011-07-12 14:00:35 -04006024 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006025 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6026 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6027 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6028 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6029};
6030
6031static struct matrix_keymap_data fluid_keymap_data = {
6032 .keymap_size = ARRAY_SIZE(fluid_keymap),
6033 .keymap = fluid_keymap,
6034};
6035
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306036static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006037 .input_name = "fluid-keypad",
6038 .input_phys_device = "fluid-keypad/input0",
6039 .num_rows = 6,
6040 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306041 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6042 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6043 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006044 .scan_delay_ms = 32,
6045 .row_hold_ns = 91500,
6046 .wakeup = 1,
6047 .keymap_data = &fluid_keymap_data,
6048};
6049
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306050static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006051 .initial_vibrate_ms = 500,
6052 .level_mV = 3000,
6053 .max_timeout_ms = 15000,
6054};
6055
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306056static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6057 .rtc_write_enable = false,
6058 .rtc_alarm_powerup = false,
6059};
6060
6061static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6062 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006063 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306064 .wakeup = 1,
6065};
6066
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006067#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6068
6069static struct othc_accessory_info othc_accessories[] = {
6070 {
6071 .accessory = OTHC_SVIDEO_OUT,
6072 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6073 | OTHC_ADC_DETECT,
6074 .key_code = SW_VIDEOOUT_INSERT,
6075 .enabled = false,
6076 .adc_thres = {
6077 .min_threshold = 20,
6078 .max_threshold = 40,
6079 },
6080 },
6081 {
6082 .accessory = OTHC_ANC_HEADPHONE,
6083 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6084 OTHC_SWITCH_DETECT,
6085 .gpio = PM8058_LINE_IN_DET_GPIO,
6086 .active_low = 1,
6087 .key_code = SW_HEADPHONE_INSERT,
6088 .enabled = true,
6089 },
6090 {
6091 .accessory = OTHC_ANC_HEADSET,
6092 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6093 .gpio = PM8058_LINE_IN_DET_GPIO,
6094 .active_low = 1,
6095 .key_code = SW_HEADPHONE_INSERT,
6096 .enabled = true,
6097 },
6098 {
6099 .accessory = OTHC_HEADPHONE,
6100 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6101 .key_code = SW_HEADPHONE_INSERT,
6102 .enabled = true,
6103 },
6104 {
6105 .accessory = OTHC_MICROPHONE,
6106 .detect_flags = OTHC_GPIO_DETECT,
6107 .gpio = PM8058_LINE_IN_DET_GPIO,
6108 .active_low = 1,
6109 .key_code = SW_MICROPHONE_INSERT,
6110 .enabled = true,
6111 },
6112 {
6113 .accessory = OTHC_HEADSET,
6114 .detect_flags = OTHC_MICBIAS_DETECT,
6115 .key_code = SW_HEADPHONE_INSERT,
6116 .enabled = true,
6117 },
6118};
6119
6120static struct othc_switch_info switch_info[] = {
6121 {
6122 .min_adc_threshold = 0,
6123 .max_adc_threshold = 100,
6124 .key_code = KEY_PLAYPAUSE,
6125 },
6126 {
6127 .min_adc_threshold = 100,
6128 .max_adc_threshold = 200,
6129 .key_code = KEY_REWIND,
6130 },
6131 {
6132 .min_adc_threshold = 200,
6133 .max_adc_threshold = 500,
6134 .key_code = KEY_FASTFORWARD,
6135 },
6136};
6137
6138static struct othc_n_switch_config switch_config = {
6139 .voltage_settling_time_ms = 0,
6140 .num_adc_samples = 3,
6141 .adc_channel = CHANNEL_ADC_HDSET,
6142 .switch_info = switch_info,
6143 .num_keys = ARRAY_SIZE(switch_info),
6144 .default_sw_en = true,
6145 .default_sw_idx = 0,
6146};
6147
6148static struct hsed_bias_config hsed_bias_config = {
6149 /* HSED mic bias config info */
6150 .othc_headset = OTHC_HEADSET_NO,
6151 .othc_lowcurr_thresh_uA = 100,
6152 .othc_highcurr_thresh_uA = 600,
6153 .othc_hyst_prediv_us = 7800,
6154 .othc_period_clkdiv_us = 62500,
6155 .othc_hyst_clk_us = 121000,
6156 .othc_period_clk_us = 312500,
6157 .othc_wakeup = 1,
6158};
6159
6160static struct othc_hsed_config hsed_config_1 = {
6161 .hsed_bias_config = &hsed_bias_config,
6162 /*
6163 * The detection delay and switch reporting delay are
6164 * required to encounter a hardware bug (spurious switch
6165 * interrupts on slow insertion/removal of the headset).
6166 * This will introduce a delay in reporting the accessory
6167 * insertion and removal to the userspace.
6168 */
6169 .detection_delay_ms = 1500,
6170 /* Switch info */
6171 .switch_debounce_ms = 1500,
6172 .othc_support_n_switch = false,
6173 .switch_config = &switch_config,
6174 .ir_gpio = -1,
6175 /* Accessory info */
6176 .accessories_support = true,
6177 .accessories = othc_accessories,
6178 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6179};
6180
6181static struct othc_regulator_config othc_reg = {
6182 .regulator = "8058_l5",
6183 .max_uV = 2850000,
6184 .min_uV = 2850000,
6185};
6186
6187/* MIC_BIAS0 is configured as normal MIC BIAS */
6188static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6189 .micbias_select = OTHC_MICBIAS_0,
6190 .micbias_capability = OTHC_MICBIAS,
6191 .micbias_enable = OTHC_SIGNAL_OFF,
6192 .micbias_regulator = &othc_reg,
6193};
6194
6195/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6196static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6197 .micbias_select = OTHC_MICBIAS_1,
6198 .micbias_capability = OTHC_MICBIAS_HSED,
6199 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6200 .micbias_regulator = &othc_reg,
6201 .hsed_config = &hsed_config_1,
6202 .hsed_name = "8660_handset",
6203};
6204
6205/* MIC_BIAS2 is configured as normal MIC BIAS */
6206static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6207 .micbias_select = OTHC_MICBIAS_2,
6208 .micbias_capability = OTHC_MICBIAS,
6209 .micbias_enable = OTHC_SIGNAL_OFF,
6210 .micbias_regulator = &othc_reg,
6211};
6212
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006213
6214static void __init msm8x60_init_pm8058_othc(void)
6215{
6216 int i;
6217
6218 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6219 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6220 machine_is_msm8x60_fusn_ffa()) {
6221 /* 3-switch headset supported only by V2 FFA and FLUID */
6222 hsed_config_1.accessories_adc_support = true,
6223 /* ADC based accessory detection works only on V2 and FLUID */
6224 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6225 hsed_config_1.othc_support_n_switch = true;
6226 }
6227
6228 /* IR GPIO is absent on FLUID */
6229 if (machine_is_msm8x60_fluid())
6230 hsed_config_1.ir_gpio = -1;
6231
6232 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6233 if (machine_is_msm8x60_fluid()) {
6234 switch (othc_accessories[i].accessory) {
6235 case OTHC_ANC_HEADPHONE:
6236 case OTHC_ANC_HEADSET:
6237 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6238 break;
6239 case OTHC_MICROPHONE:
6240 othc_accessories[i].enabled = false;
6241 break;
6242 case OTHC_SVIDEO_OUT:
6243 othc_accessories[i].enabled = true;
6244 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6245 break;
6246 }
6247 }
6248 }
6249}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006250
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006251
6252static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6253{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306254 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006255 .direction = PM_GPIO_DIR_OUT,
6256 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6257 .output_value = 0,
6258 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306259 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006260 .out_strength = PM_GPIO_STRENGTH_HIGH,
6261 .function = PM_GPIO_FUNC_2,
6262 };
6263
6264 int rc = -EINVAL;
6265 int id, mode, max_mA;
6266
6267 id = mode = max_mA = 0;
6268 switch (ch) {
6269 case 0:
6270 case 1:
6271 case 2:
6272 if (on) {
6273 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306274 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6275 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006276 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306277 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006278 __func__, id, rc);
6279 }
6280 break;
6281
6282 case 6:
6283 id = PM_PWM_LED_FLASH;
6284 mode = PM_PWM_CONF_PWM1;
6285 max_mA = 300;
6286 break;
6287
6288 case 7:
6289 id = PM_PWM_LED_FLASH1;
6290 mode = PM_PWM_CONF_PWM1;
6291 max_mA = 300;
6292 break;
6293
6294 default:
6295 break;
6296 }
6297
6298 if (ch >= 6 && ch <= 7) {
6299 if (!on) {
6300 mode = PM_PWM_CONF_NONE;
6301 max_mA = 0;
6302 }
6303 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6304 if (rc)
6305 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6306 __func__, ch, rc);
6307 }
6308 return rc;
6309
6310}
6311
6312static struct pm8058_pwm_pdata pm8058_pwm_data = {
6313 .config = pm8058_pwm_config,
6314};
6315
6316#define PM8058_GPIO_INT 88
6317
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006318static struct pmic8058_led pmic8058_flash_leds[] = {
6319 [0] = {
6320 .name = "camera:flash0",
6321 .max_brightness = 15,
6322 .id = PMIC8058_ID_FLASH_LED_0,
6323 },
6324 [1] = {
6325 .name = "camera:flash1",
6326 .max_brightness = 15,
6327 .id = PMIC8058_ID_FLASH_LED_1,
6328 },
6329};
6330
6331static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6332 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6333 .leds = pmic8058_flash_leds,
6334};
6335
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006336static struct pmic8058_led pmic8058_dragon_leds[] = {
6337 [0] = {
6338 /* RED */
6339 .name = "led_drv0",
6340 .max_brightness = 15,
6341 .id = PMIC8058_ID_LED_0,
6342 },/* 300 mA flash led0 drv sink */
6343 [1] = {
6344 /* Yellow */
6345 .name = "led_drv1",
6346 .max_brightness = 15,
6347 .id = PMIC8058_ID_LED_1,
6348 },/* 300 mA flash led0 drv sink */
6349 [2] = {
6350 /* Green */
6351 .name = "led_drv2",
6352 .max_brightness = 15,
6353 .id = PMIC8058_ID_LED_2,
6354 },/* 300 mA flash led0 drv sink */
6355 [3] = {
6356 .name = "led_psensor",
6357 .max_brightness = 15,
6358 .id = PMIC8058_ID_LED_KB_LIGHT,
6359 },/* 300 mA flash led0 drv sink */
6360};
6361
6362static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6363 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6364 .leds = pmic8058_dragon_leds,
6365};
6366
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006367static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6368 [0] = {
6369 .name = "led:drv0",
6370 .max_brightness = 15,
6371 .id = PMIC8058_ID_FLASH_LED_0,
6372 },/* 300 mA flash led0 drv sink */
6373 [1] = {
6374 .name = "led:drv1",
6375 .max_brightness = 15,
6376 .id = PMIC8058_ID_FLASH_LED_1,
6377 },/* 300 mA flash led1 sink */
6378 [2] = {
6379 .name = "led:drv2",
6380 .max_brightness = 20,
6381 .id = PMIC8058_ID_LED_0,
6382 },/* 40 mA led0 sink */
6383 [3] = {
6384 .name = "keypad:drv",
6385 .max_brightness = 15,
6386 .id = PMIC8058_ID_LED_KB_LIGHT,
6387 },/* 300 mA keypad drv sink */
6388};
6389
6390static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6391 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6392 .leds = pmic8058_fluid_flash_leds,
6393};
6394
Terence Hampson90508a92011-08-09 10:40:08 -04006395static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306396 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006397 .max_source_current = 1800,
6398 .charger_type = CHG_TYPE_AC,
6399};
6400
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306401static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6402 .charger_data_valid = false,
6403};
6404
6405static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6406 .priority = 0,
6407};
6408
6409static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6410 .irq_base = PM8058_IRQ_BASE,
6411 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6412 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6413};
6414
6415static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6416 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6417};
6418
6419static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6420 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006421};
6422
6423static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306424 .irq_pdata = &pm8058_irq_pdata,
6425 .gpio_pdata = &pm8058_gpio_pdata,
6426 .mpp_pdata = &pm8058_mpp_pdata,
6427 .rtc_pdata = &pm8058_rtc_pdata,
6428 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6429 .othc0_pdata = &othc_config_pdata_0,
6430 .othc1_pdata = &othc_config_pdata_1,
6431 .othc2_pdata = &othc_config_pdata_2,
6432 .pwm_pdata = &pm8058_pwm_data,
6433 .misc_pdata = &pm8058_misc_pdata,
6434#ifdef CONFIG_SENSORS_MSM_ADC
6435 .xoadc_pdata = &pm8058_xoadc_pdata,
6436#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006437};
6438
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306439#ifdef CONFIG_MSM_SSBI
6440static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6441 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6442 .slave = {
6443 .name = "pm8058-core",
6444 .platform_data = &pm8058_platform_data,
6445 },
6446};
6447#endif
6448#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006449
6450#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6451 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6452#define TDISC_I2C_SLAVE_ADDR 0x67
6453#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6454#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6455
6456static const char *vregs_tdisc_name[] = {
6457 "8058_l5",
6458 "8058_s3",
6459};
6460
6461static const int vregs_tdisc_val[] = {
6462 2850000,/* uV */
6463 1800000,
6464};
6465static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6466
6467static int tdisc_shinetsu_setup(void)
6468{
6469 int rc, i;
6470
6471 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6472 if (rc) {
6473 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6474 __func__);
6475 return rc;
6476 }
6477
6478 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6479 if (rc) {
6480 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6481 __func__);
6482 goto fail_gpio_oe;
6483 }
6484
6485 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6486 if (rc) {
6487 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6488 __func__);
6489 gpio_free(GPIO_JOYSTICK_EN);
6490 goto fail_gpio_oe;
6491 }
6492
6493 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6494 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6495 if (IS_ERR(vregs_tdisc[i])) {
6496 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6497 __func__, vregs_tdisc_name[i],
6498 PTR_ERR(vregs_tdisc[i]));
6499 rc = PTR_ERR(vregs_tdisc[i]);
6500 goto vreg_get_fail;
6501 }
6502
6503 rc = regulator_set_voltage(vregs_tdisc[i],
6504 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6505 if (rc) {
6506 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6507 __func__, rc);
6508 goto vreg_set_voltage_fail;
6509 }
6510 }
6511
6512 return rc;
6513vreg_set_voltage_fail:
6514 i++;
6515vreg_get_fail:
6516 while (i)
6517 regulator_put(vregs_tdisc[--i]);
6518fail_gpio_oe:
6519 gpio_free(PMIC_GPIO_TDISC);
6520 return rc;
6521}
6522
6523static void tdisc_shinetsu_release(void)
6524{
6525 int i;
6526
6527 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6528 regulator_put(vregs_tdisc[i]);
6529
6530 gpio_free(PMIC_GPIO_TDISC);
6531 gpio_free(GPIO_JOYSTICK_EN);
6532}
6533
6534static int tdisc_shinetsu_enable(void)
6535{
6536 int i, rc = -EINVAL;
6537
6538 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6539 rc = regulator_enable(vregs_tdisc[i]);
6540 if (rc < 0) {
6541 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6542 __func__, vregs_tdisc_name[i], rc);
6543 goto vreg_fail;
6544 }
6545 }
6546
6547 /* Enable the OE (output enable) gpio */
6548 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6549 /* voltage and gpio stabilization delay */
6550 msleep(50);
6551
6552 return 0;
6553vreg_fail:
6554 while (i)
6555 regulator_disable(vregs_tdisc[--i]);
6556 return rc;
6557}
6558
6559static int tdisc_shinetsu_disable(void)
6560{
6561 int i, rc;
6562
6563 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6564 rc = regulator_disable(vregs_tdisc[i]);
6565 if (rc < 0) {
6566 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6567 __func__, vregs_tdisc_name[i], rc);
6568 goto tdisc_reg_fail;
6569 }
6570 }
6571
6572 /* Disable the OE (output enable) gpio */
6573 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6574
6575 return 0;
6576
6577tdisc_reg_fail:
6578 while (i)
6579 regulator_enable(vregs_tdisc[--i]);
6580 return rc;
6581}
6582
6583static struct tdisc_abs_values tdisc_abs = {
6584 .x_max = 32,
6585 .y_max = 32,
6586 .x_min = -32,
6587 .y_min = -32,
6588 .pressure_max = 32,
6589 .pressure_min = 0,
6590};
6591
6592static struct tdisc_platform_data tdisc_data = {
6593 .tdisc_setup = tdisc_shinetsu_setup,
6594 .tdisc_release = tdisc_shinetsu_release,
6595 .tdisc_enable = tdisc_shinetsu_enable,
6596 .tdisc_disable = tdisc_shinetsu_disable,
6597 .tdisc_wakeup = 0,
6598 .tdisc_gpio = PMIC_GPIO_TDISC,
6599 .tdisc_report_keys = true,
6600 .tdisc_report_relative = true,
6601 .tdisc_report_absolute = false,
6602 .tdisc_report_wheel = false,
6603 .tdisc_reverse_x = false,
6604 .tdisc_reverse_y = true,
6605 .tdisc_abs = &tdisc_abs,
6606};
6607
6608static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6609 {
6610 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6611 .irq = TDISC_INT,
6612 .platform_data = &tdisc_data,
6613 },
6614};
6615#endif
6616
6617#define PM_GPIO_CDC_RST_N 20
6618#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6619
6620static struct regulator *vreg_timpani_1;
6621static struct regulator *vreg_timpani_2;
6622
6623static unsigned int msm_timpani_setup_power(void)
6624{
6625 int rc;
6626
6627 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6628 if (IS_ERR(vreg_timpani_1)) {
6629 pr_err("%s: Unable to get 8058_l0\n", __func__);
6630 return -ENODEV;
6631 }
6632
6633 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6634 if (IS_ERR(vreg_timpani_2)) {
6635 pr_err("%s: Unable to get 8058_s3\n", __func__);
6636 regulator_put(vreg_timpani_1);
6637 return -ENODEV;
6638 }
6639
6640 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6641 if (rc) {
6642 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6643 goto fail;
6644 }
6645
6646 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6647 if (rc) {
6648 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6649 goto fail;
6650 }
6651
6652 rc = regulator_enable(vreg_timpani_1);
6653 if (rc) {
6654 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6655 goto fail;
6656 }
6657
6658 /* The settings for LDO0 should be set such that
6659 * it doesn't require to reset the timpani. */
6660 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6661 if (rc < 0) {
6662 pr_err("Timpani regulator optimum mode setting failed\n");
6663 goto fail;
6664 }
6665
6666 rc = regulator_enable(vreg_timpani_2);
6667 if (rc) {
6668 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6669 regulator_disable(vreg_timpani_1);
6670 goto fail;
6671 }
6672
6673 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6674 if (rc) {
6675 pr_err("%s: GPIO Request %d failed\n", __func__,
6676 GPIO_CDC_RST_N);
6677 regulator_disable(vreg_timpani_1);
6678 regulator_disable(vreg_timpani_2);
6679 goto fail;
6680 } else {
6681 gpio_direction_output(GPIO_CDC_RST_N, 1);
6682 usleep_range(1000, 1050);
6683 gpio_direction_output(GPIO_CDC_RST_N, 0);
6684 usleep_range(1000, 1050);
6685 gpio_direction_output(GPIO_CDC_RST_N, 1);
6686 gpio_free(GPIO_CDC_RST_N);
6687 }
6688 return rc;
6689
6690fail:
6691 regulator_put(vreg_timpani_1);
6692 regulator_put(vreg_timpani_2);
6693 return rc;
6694}
6695
6696static void msm_timpani_shutdown_power(void)
6697{
6698 int rc;
6699
6700 rc = regulator_disable(vreg_timpani_1);
6701 if (rc)
6702 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6703
6704 regulator_put(vreg_timpani_1);
6705
6706 rc = regulator_disable(vreg_timpani_2);
6707 if (rc)
6708 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6709
6710 regulator_put(vreg_timpani_2);
6711}
6712
6713/* Power analog function of codec */
6714static struct regulator *vreg_timpani_cdc_apwr;
6715static int msm_timpani_codec_power(int vreg_on)
6716{
6717 int rc = 0;
6718
6719 if (!vreg_timpani_cdc_apwr) {
6720
6721 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6722
6723 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6724 pr_err("%s: vreg_get failed (%ld)\n",
6725 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6726 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6727 return rc;
6728 }
6729 }
6730
6731 if (vreg_on) {
6732
6733 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6734 2200000, 2200000);
6735 if (rc) {
6736 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6737 __func__);
6738 goto vreg_fail;
6739 }
6740
6741 rc = regulator_enable(vreg_timpani_cdc_apwr);
6742 if (rc) {
6743 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6744 goto vreg_fail;
6745 }
6746 } else {
6747 rc = regulator_disable(vreg_timpani_cdc_apwr);
6748 if (rc) {
6749 pr_err("%s: vreg_disable failed %d\n",
6750 __func__, rc);
6751 goto vreg_fail;
6752 }
6753 }
6754
6755 return 0;
6756
6757vreg_fail:
6758 regulator_put(vreg_timpani_cdc_apwr);
6759 vreg_timpani_cdc_apwr = NULL;
6760 return rc;
6761}
6762
6763static struct marimba_codec_platform_data timpani_codec_pdata = {
6764 .marimba_codec_power = msm_timpani_codec_power,
6765};
6766
6767#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6768#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6769
6770static struct marimba_platform_data timpani_pdata = {
6771 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6772 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6773 .marimba_setup = msm_timpani_setup_power,
6774 .marimba_shutdown = msm_timpani_shutdown_power,
6775 .codec = &timpani_codec_pdata,
6776 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6777};
6778
6779#define TIMPANI_I2C_SLAVE_ADDR 0xD
6780
6781static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6782 {
6783 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6784 .platform_data = &timpani_pdata,
6785 },
6786};
6787
Lei Zhou338cab82011-08-19 13:38:17 -04006788#ifdef CONFIG_SND_SOC_WM8903
6789static struct wm8903_platform_data wm8903_pdata = {
6790 .gpio_cfg[2] = 0x3A8,
6791};
6792
6793#define WM8903_I2C_SLAVE_ADDR 0x34
6794static struct i2c_board_info wm8903_codec_i2c_info[] = {
6795 {
6796 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6797 .platform_data = &wm8903_pdata,
6798 },
6799};
6800#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006801#ifdef CONFIG_PMIC8901
6802
6803#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006804/*
6805 * Consumer specific regulator names:
6806 * regulator name consumer dev_name
6807 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006808static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6809 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6810};
6811static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6812 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6813};
6814
6815#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306816 _always_on) \
6817 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006818 .init_data = { \
6819 .constraints = { \
6820 .valid_modes_mask = _modes, \
6821 .valid_ops_mask = _ops, \
6822 .min_uV = _min_uV, \
6823 .max_uV = _max_uV, \
6824 .input_uV = _min_uV, \
6825 .apply_uV = _apply_uV, \
6826 .always_on = _always_on, \
6827 }, \
6828 .consumer_supplies = vreg_consumers_8901_##_id, \
6829 .num_consumer_supplies = \
6830 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6831 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306832 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833 }
6834
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006835#define PM8901_VREG_INIT_VS(_id) \
6836 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306837 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006838
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306839static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006840 PM8901_VREG_INIT_VS(USB_OTG),
6841 PM8901_VREG_INIT_VS(HDMI_MVS),
6842};
6843
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306844static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6845 .priority = 1,
6846};
6847
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306848static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6849 .irq_base = PM8901_IRQ_BASE,
6850 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6851 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6852};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006853
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306854static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6855 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006856};
6857
6858static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306859 .irq_pdata = &pm8901_irq_pdata,
6860 .mpp_pdata = &pm8901_mpp_pdata,
6861 .regulator_pdatas = pm8901_vreg_init,
6862 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306863 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006864};
6865
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306866static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6867 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6868 .slave = {
6869 .name = "pm8901-core",
6870 .platform_data = &pm8901_platform_data,
6871 },
6872};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006873#endif /* CONFIG_PMIC8901 */
6874
6875#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6876 || defined(CONFIG_GPIO_SX150X_MODULE))
6877
6878static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006879static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006880
6881struct bahama_config_register{
6882 u8 reg;
6883 u8 value;
6884 u8 mask;
6885};
6886
6887enum version{
6888 VER_1_0,
6889 VER_2_0,
6890 VER_UNSUPPORTED = 0xFF
6891};
6892
6893static u8 read_bahama_ver(void)
6894{
6895 int rc;
6896 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6897 u8 bahama_version;
6898
6899 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6900 if (rc < 0) {
6901 printk(KERN_ERR
6902 "%s: version read failed: %d\n",
6903 __func__, rc);
6904 return VER_UNSUPPORTED;
6905 } else {
6906 printk(KERN_INFO
6907 "%s: version read got: 0x%x\n",
6908 __func__, bahama_version);
6909 }
6910
6911 switch (bahama_version) {
6912 case 0x08: /* varient of bahama v1 */
6913 case 0x10:
6914 case 0x00:
6915 return VER_1_0;
6916 case 0x09: /* variant of bahama v2 */
6917 return VER_2_0;
6918 default:
6919 return VER_UNSUPPORTED;
6920 }
6921}
6922
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006923static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006924static unsigned int msm_bahama_setup_power(void)
6925{
6926 int rc = 0;
6927 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006928
6929 if (machine_is_msm8x60_dragon())
6930 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6931
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006932 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6933
6934 if (IS_ERR(vreg_bahama)) {
6935 rc = PTR_ERR(vreg_bahama);
6936 pr_err("%s: regulator_get %s = %d\n", __func__,
6937 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006938 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006939 }
6940
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006941 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6942 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006943 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6944 msm_bahama_regulator, rc);
6945 goto unget;
6946 }
6947
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006948 rc = regulator_enable(vreg_bahama);
6949 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006950 pr_err("%s: regulator_enable %s = %d\n", __func__,
6951 msm_bahama_regulator, rc);
6952 goto unget;
6953 }
6954
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006955 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6956 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006958 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006959 goto unenable;
6960 }
6961
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006962 gpio_direction_output(msm_bahama_sys_rst, 0);
6963 usleep_range(1000, 1050);
6964 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6965 usleep_range(1000, 1050);
6966 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006967 return rc;
6968
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006969unenable:
6970 regulator_disable(vreg_bahama);
6971unget:
6972 regulator_put(vreg_bahama);
6973 return rc;
6974};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006975
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006976static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006977{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006978 if (msm_bahama_setup_power_enable) {
6979 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6980 gpio_free(msm_bahama_sys_rst);
6981 regulator_disable(vreg_bahama);
6982 regulator_put(vreg_bahama);
6983 msm_bahama_setup_power_enable = 0;
6984 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006985
6986 return 0;
6987};
6988
6989static unsigned int msm_bahama_core_config(int type)
6990{
6991 int rc = 0;
6992
6993 if (type == BAHAMA_ID) {
6994
6995 int i;
6996 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6997
6998 const struct bahama_config_register v20_init[] = {
6999 /* reg, value, mask */
7000 { 0xF4, 0x84, 0xFF }, /* AREG */
7001 { 0xF0, 0x04, 0xFF } /* DREG */
7002 };
7003
7004 if (read_bahama_ver() == VER_2_0) {
7005 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7006 u8 value = v20_init[i].value;
7007 rc = marimba_write_bit_mask(&config,
7008 v20_init[i].reg,
7009 &value,
7010 sizeof(v20_init[i].value),
7011 v20_init[i].mask);
7012 if (rc < 0) {
7013 printk(KERN_ERR
7014 "%s: reg %d write failed: %d\n",
7015 __func__, v20_init[i].reg, rc);
7016 return rc;
7017 }
7018 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7019 " mask 0x%02x\n",
7020 __func__, v20_init[i].reg,
7021 v20_init[i].value, v20_init[i].mask);
7022 }
7023 }
7024 }
7025 printk(KERN_INFO "core type: %d\n", type);
7026
7027 return rc;
7028}
7029
7030static struct regulator *fm_regulator_s3;
7031static struct msm_xo_voter *fm_clock;
7032
7033static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7034{
7035 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307036 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007037 .direction = PM_GPIO_DIR_IN,
7038 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307039 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007040 .function = PM_GPIO_FUNC_NORMAL,
7041 .inv_int_pol = 0,
7042 };
7043
7044 if (!fm_regulator_s3) {
7045 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7046 if (IS_ERR(fm_regulator_s3)) {
7047 rc = PTR_ERR(fm_regulator_s3);
7048 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7049 __func__, rc);
7050 goto out;
7051 }
7052 }
7053
7054
7055 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7056 if (rc < 0) {
7057 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7058 __func__, rc);
7059 goto fm_fail_put;
7060 }
7061
7062 rc = regulator_enable(fm_regulator_s3);
7063 if (rc < 0) {
7064 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7065 __func__, rc);
7066 goto fm_fail_put;
7067 }
7068
7069 /*Vote for XO clock*/
7070 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7071
7072 if (IS_ERR(fm_clock)) {
7073 rc = PTR_ERR(fm_clock);
7074 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7075 __func__, rc);
7076 goto fm_fail_switch;
7077 }
7078
7079 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7080 if (rc < 0) {
7081 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7082 __func__, rc);
7083 goto fm_fail_vote;
7084 }
7085
7086 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307087 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007088 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307089 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007090 __func__, rc);
7091 goto fm_fail_clock;
7092 }
7093 goto out;
7094
7095fm_fail_clock:
7096 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7097fm_fail_vote:
7098 msm_xo_put(fm_clock);
7099fm_fail_switch:
7100 regulator_disable(fm_regulator_s3);
7101fm_fail_put:
7102 regulator_put(fm_regulator_s3);
7103out:
7104 return rc;
7105};
7106
7107static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7108{
7109 int rc = 0;
7110 if (fm_regulator_s3 != NULL) {
7111 rc = regulator_disable(fm_regulator_s3);
7112 if (rc < 0) {
7113 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7114 __func__, rc);
7115 }
7116 regulator_put(fm_regulator_s3);
7117 fm_regulator_s3 = NULL;
7118 }
7119 printk(KERN_ERR "%s: Voting off for XO", __func__);
7120
7121 if (fm_clock != NULL) {
7122 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7123 if (rc < 0) {
7124 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7125 __func__, rc);
7126 }
7127 msm_xo_put(fm_clock);
7128 }
7129 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7130}
7131
7132/* Slave id address for FM/CDC/QMEMBIST
7133 * Values can be programmed using Marimba slave id 0
7134 * should there be a conflict with other I2C devices
7135 * */
7136#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7137#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7138
7139static struct marimba_fm_platform_data marimba_fm_pdata = {
7140 .fm_setup = fm_radio_setup,
7141 .fm_shutdown = fm_radio_shutdown,
7142 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7143 .is_fm_soc_i2s_master = false,
7144 .config_i2s_gpio = NULL,
7145};
7146
7147/*
7148Just initializing the BAHAMA related slave
7149*/
7150static struct marimba_platform_data marimba_pdata = {
7151 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7152 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7153 .bahama_setup = msm_bahama_setup_power,
7154 .bahama_shutdown = msm_bahama_shutdown_power,
7155 .bahama_core_config = msm_bahama_core_config,
7156 .fm = &marimba_fm_pdata,
7157 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7158};
7159
7160
7161static struct i2c_board_info msm_marimba_board_info[] = {
7162 {
7163 I2C_BOARD_INFO("marimba", 0xc),
7164 .platform_data = &marimba_pdata,
7165 }
7166};
7167#endif /* CONFIG_MAIMBA_CORE */
7168
7169#ifdef CONFIG_I2C
7170#define I2C_SURF 1
7171#define I2C_FFA (1 << 1)
7172#define I2C_RUMI (1 << 2)
7173#define I2C_SIM (1 << 3)
7174#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007175#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007176
7177struct i2c_registry {
7178 u8 machs;
7179 int bus;
7180 struct i2c_board_info *info;
7181 int len;
7182};
7183
7184static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007185#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7186 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007187 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007188 MSM_GSBI8_QUP_I2C_BUS_ID,
7189 core_expander_i2c_info,
7190 ARRAY_SIZE(core_expander_i2c_info),
7191 },
7192 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007193 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007194 MSM_GSBI8_QUP_I2C_BUS_ID,
7195 docking_expander_i2c_info,
7196 ARRAY_SIZE(docking_expander_i2c_info),
7197 },
7198 {
7199 I2C_SURF,
7200 MSM_GSBI8_QUP_I2C_BUS_ID,
7201 surf_expanders_i2c_info,
7202 ARRAY_SIZE(surf_expanders_i2c_info),
7203 },
7204 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007205 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007206 MSM_GSBI3_QUP_I2C_BUS_ID,
7207 fha_expanders_i2c_info,
7208 ARRAY_SIZE(fha_expanders_i2c_info),
7209 },
7210 {
7211 I2C_FLUID,
7212 MSM_GSBI3_QUP_I2C_BUS_ID,
7213 fluid_expanders_i2c_info,
7214 ARRAY_SIZE(fluid_expanders_i2c_info),
7215 },
7216 {
7217 I2C_FLUID,
7218 MSM_GSBI8_QUP_I2C_BUS_ID,
7219 fluid_core_expander_i2c_info,
7220 ARRAY_SIZE(fluid_core_expander_i2c_info),
7221 },
7222#endif
7223#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7224 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7225 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007226 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007227 MSM_GSBI3_QUP_I2C_BUS_ID,
7228 msm_i2c_gsbi3_tdisc_info,
7229 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7230 },
7231#endif
7232 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007233 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007234 MSM_GSBI3_QUP_I2C_BUS_ID,
7235 cy8ctmg200_board_info,
7236 ARRAY_SIZE(cy8ctmg200_board_info),
7237 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007238 {
7239 I2C_DRAGON,
7240 MSM_GSBI3_QUP_I2C_BUS_ID,
7241 cy8ctma340_dragon_board_info,
7242 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7243 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007244#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7245 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007246 {
7247 I2C_FLUID,
7248 MSM_GSBI3_QUP_I2C_BUS_ID,
7249 cyttsp_fluid_info,
7250 ARRAY_SIZE(cyttsp_fluid_info),
7251 },
7252 {
7253 I2C_FFA | I2C_SURF,
7254 MSM_GSBI3_QUP_I2C_BUS_ID,
7255 cyttsp_ffa_info,
7256 ARRAY_SIZE(cyttsp_ffa_info),
7257 },
7258#endif
7259#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007260#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007261 {
7262 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007263 MSM_GSBI4_QUP_I2C_BUS_ID,
7264 msm_camera_boardinfo,
7265 ARRAY_SIZE(msm_camera_boardinfo),
7266 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007267 {
7268 I2C_DRAGON,
7269 MSM_GSBI4_QUP_I2C_BUS_ID,
7270 msm_camera_dragon_boardinfo,
7271 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7272 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007273#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007274#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007275 {
7276 I2C_SURF | I2C_FFA | I2C_FLUID,
7277 MSM_GSBI7_QUP_I2C_BUS_ID,
7278 msm_i2c_gsbi7_timpani_info,
7279 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7280 },
7281#if defined(CONFIG_MARIMBA_CORE)
7282 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007283 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007284 MSM_GSBI7_QUP_I2C_BUS_ID,
7285 msm_marimba_board_info,
7286 ARRAY_SIZE(msm_marimba_board_info),
7287 },
7288#endif /* CONFIG_MARIMBA_CORE */
7289#ifdef CONFIG_ISL9519_CHARGER
7290 {
7291 I2C_SURF | I2C_FFA,
7292 MSM_GSBI8_QUP_I2C_BUS_ID,
7293 isl_charger_i2c_info,
7294 ARRAY_SIZE(isl_charger_i2c_info),
7295 },
7296#endif
7297#if defined(CONFIG_HAPTIC_ISA1200) || \
7298 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7299 {
7300 I2C_FLUID,
7301 MSM_GSBI8_QUP_I2C_BUS_ID,
7302 msm_isa1200_board_info,
7303 ARRAY_SIZE(msm_isa1200_board_info),
7304 },
7305#endif
7306#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7307 {
7308 I2C_FLUID,
7309 MSM_GSBI8_QUP_I2C_BUS_ID,
7310 smb137b_charger_i2c_info,
7311 ARRAY_SIZE(smb137b_charger_i2c_info),
7312 },
7313#endif
7314#if defined(CONFIG_BATTERY_BQ27520) || \
7315 defined(CONFIG_BATTERY_BQ27520_MODULE)
7316 {
7317 I2C_FLUID,
7318 MSM_GSBI8_QUP_I2C_BUS_ID,
7319 msm_bq27520_board_info,
7320 ARRAY_SIZE(msm_bq27520_board_info),
7321 },
7322#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007323#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7324 {
7325 I2C_DRAGON,
7326 MSM_GSBI8_QUP_I2C_BUS_ID,
7327 wm8903_codec_i2c_info,
7328 ARRAY_SIZE(wm8903_codec_i2c_info),
7329 },
7330#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007331};
7332#endif /* CONFIG_I2C */
7333
Stephen Boyd668d7652012-04-25 11:31:01 -07007334static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007335{
7336#ifdef CONFIG_I2C
7337#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7338 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7339 sx150x_data[SX150X_CORE].irq_summary =
7340 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007341 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7342 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007343 sx150x_data[SX150X_CORE].irq_summary =
7344 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7345 else if (machine_is_msm8x60_fluid())
7346 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7347 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7348#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007349#endif
7350}
7351
Stephen Boyd668d7652012-04-25 11:31:01 -07007352static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007353{
7354#ifdef CONFIG_I2C
7355 u8 mach_mask = 0;
7356 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007357#ifdef CONFIG_MSM_CAMERA_V4L2
7358 struct i2c_registry msm8x60_camera_i2c_devices = {
7359 I2C_SURF | I2C_FFA | I2C_FLUID,
7360 MSM_GSBI4_QUP_I2C_BUS_ID,
7361 msm8x60_camera_board_info.board_info,
7362 msm8x60_camera_board_info.num_i2c_board_info,
7363 };
7364#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007365
7366 /* Build the matching 'supported_machs' bitmask */
7367 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7368 mach_mask = I2C_SURF;
7369 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7370 mach_mask = I2C_FFA;
7371 else if (machine_is_msm8x60_rumi3())
7372 mach_mask = I2C_RUMI;
7373 else if (machine_is_msm8x60_sim())
7374 mach_mask = I2C_SIM;
7375 else if (machine_is_msm8x60_fluid())
7376 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007377 else if (machine_is_msm8x60_dragon())
7378 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007379 else
7380 pr_err("unmatched machine ID in register_i2c_devices\n");
7381
7382 /* Run the array and install devices as appropriate */
7383 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7384 if (msm8x60_i2c_devices[i].machs & mach_mask)
7385 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7386 msm8x60_i2c_devices[i].info,
7387 msm8x60_i2c_devices[i].len);
7388 }
Kevin Chan3be11612012-03-22 20:05:40 -07007389#ifdef CONFIG_MSM_CAMERA_V4L2
7390 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7391 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7392 msm8x60_camera_i2c_devices.info,
7393 msm8x60_camera_i2c_devices.len);
7394#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007395#endif
7396}
7397
7398static void __init msm8x60_init_uart12dm(void)
7399{
7400#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7401 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7402 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7403
7404 if (!fpga_mem)
7405 pr_err("%s(): Error getting memory\n", __func__);
7406
7407 /* Advanced mode */
7408 writew(0xFFFF, fpga_mem + 0x15C);
7409 /* FPGA_UART_SEL */
7410 writew(0, fpga_mem + 0x172);
7411 /* FPGA_GPIO_CONFIG_117 */
7412 writew(1, fpga_mem + 0xEA);
7413 /* FPGA_GPIO_CONFIG_118 */
7414 writew(1, fpga_mem + 0xEC);
7415 mb();
7416 iounmap(fpga_mem);
7417#endif
7418}
7419
7420#define MSM_GSBI9_PHYS 0x19900000
7421#define GSBI_DUAL_MODE_CODE 0x60
7422
7423static void __init msm8x60_init_buses(void)
7424{
7425#ifdef CONFIG_I2C_QUP
7426 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7427 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7428 writel_relaxed(0x6 << 4, gsbi_mem);
7429 /* Ensure protocol code is written before proceeding further */
7430 mb();
7431 iounmap(gsbi_mem);
7432
7433 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7434 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7435 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7436 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7437
7438#ifdef CONFIG_MSM_GSBI9_UART
7439 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7440 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7441 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7442 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7443 iounmap(gsbi_mem);
7444 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7445 }
7446#endif
7447 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7448 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7449#endif
7450#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7451 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7452#endif
7453#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007454 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7455#endif
7456
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307457#ifdef CONFIG_MSM_SSBI
7458 msm_device_ssbi_pmic1.dev.platform_data =
7459 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307460 msm_device_ssbi_pmic2.dev.platform_data =
7461 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307462#endif
7463
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007464 if (machine_is_msm8x60_fluid()) {
7465#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7466 (defined(CONFIG_SMB137B_CHARGER) || \
7467 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7468 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7469#endif
7470#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7471 msm_gsbi10_qup_spi_device.dev.platform_data =
7472 &msm_gsbi10_qup_spi_pdata;
7473#endif
7474 }
7475
Lena Salman57d167e2012-03-21 19:46:38 +02007476#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007477 /*
7478 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7479 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7480 * and ID notifications are available only on V2 surf and FFA
7481 * with a hardware workaround.
7482 */
7483 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7484 (machine_is_msm8x60_surf() ||
7485 (machine_is_msm8x60_ffa() &&
7486 pmic_id_notif_supported)))
7487 msm_otg_pdata.phy_can_powercollapse = 1;
7488 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7489#endif
7490
Lena Salman57d167e2012-03-21 19:46:38 +02007491#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007492 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7493#endif
7494
7495#ifdef CONFIG_SERIAL_MSM_HS
7496 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7497 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7498#endif
7499#ifdef CONFIG_MSM_GSBI9_UART
7500 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7501 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7502 if (IS_ERR(msm_device_uart_gsbi9))
7503 pr_err("%s(): Failed to create uart gsbi9 device\n",
7504 __func__);
7505 }
7506#endif
7507
7508#ifdef CONFIG_MSM_BUS_SCALING
7509
7510 /* RPM calls are only enabled on V2 */
7511 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7512 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7513 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7514 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7515 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7516 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7517 }
7518
7519 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7520 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7521 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7522 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7523 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7524#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007525}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007526
7527static void __init msm8x60_map_io(void)
7528{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007529 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007530 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007531
7532 if (socinfo_init() < 0)
7533 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007534}
7535
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007536/*
7537 * Most segments of the EBI2 bus are disabled by default.
7538 */
7539static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007540{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007541 uint32_t ebi2_cfg;
7542 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007543 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007544
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007545 if (IS_ERR(mem_clk)) {
7546 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7547 "msm_ebi2", "mem_clk");
7548 return;
7549 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007550 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007551 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007552
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007553 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7554 if (ebi2_cfg_ptr != 0) {
7555 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007556
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007557 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007558 machine_is_msm8x60_fluid() ||
7559 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007560 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7561 else if (machine_is_msm8x60_sim())
7562 ebi2_cfg |= (1 << 4); /* CS2 */
7563 else if (machine_is_msm8x60_rumi3())
7564 ebi2_cfg |= (1 << 5); /* CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007566 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7567 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007568 }
7569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007570 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007571 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007572 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7573 if (ebi2_cfg_ptr != 0) {
7574 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7575 writel_relaxed(0UL, ebi2_cfg_ptr);
7576
7577 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7578 * LAN9221 Ethernet controller reads and writes.
7579 * The lowest 4 bits are the read delay, the next
7580 * 4 are the write delay. */
7581 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7582#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7583 /*
7584 * RECOVERY=5, HOLD_WR=1
7585 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7586 * WAIT_WR=1, WAIT_RD=2
7587 */
7588 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7589 /*
7590 * HOLD_RD=1
7591 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7592 */
7593 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7594#else
7595 /* EBI2 CS3 muxed address/data,
7596 * two cyc addr enable */
7597 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7598
7599#endif
7600 iounmap(ebi2_cfg_ptr);
7601 }
7602 }
David Brown56e2d8a2011-08-04 02:01:02 -07007603}
7604
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007605static void __init msm8x60_configure_smc91x(void)
7606{
7607 if (machine_is_msm8x60_sim()) {
7608
7609 smc91x_resources[0].start = 0x1b800300;
7610 smc91x_resources[0].end = 0x1b8003ff;
7611
7612 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7613 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7614
7615 } else if (machine_is_msm8x60_rumi3()) {
7616
7617 smc91x_resources[0].start = 0x1d000300;
7618 smc91x_resources[0].end = 0x1d0003ff;
7619
7620 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7621 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7622 }
7623}
7624
7625static void __init msm8x60_init_tlmm(void)
7626{
7627 if (machine_is_msm8x60_rumi3())
7628 msm_gpio_install_direct_irq(0, 0, 1);
7629}
7630
7631#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7632 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7633 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7634 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7635 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7636
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007637/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007638#define MAX_SDCC_CONTROLLER 5
7639
7640struct msm_sdcc_gpio {
7641 /* maximum 10 GPIOs per SDCC controller */
7642 s16 no;
7643 /* name of this GPIO */
7644 const char *name;
7645 bool always_on;
7646 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007647};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007648
7649#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7650static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7651 {159, "sdc1_dat_0"},
7652 {160, "sdc1_dat_1"},
7653 {161, "sdc1_dat_2"},
7654 {162, "sdc1_dat_3"},
7655#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7656 {163, "sdc1_dat_4"},
7657 {164, "sdc1_dat_5"},
7658 {165, "sdc1_dat_6"},
7659 {166, "sdc1_dat_7"},
7660#endif
7661 {167, "sdc1_clk"},
7662 {168, "sdc1_cmd"}
7663};
7664#endif
7665
7666#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7667static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7668 {143, "sdc2_dat_0"},
7669 {144, "sdc2_dat_1", 1},
7670 {145, "sdc2_dat_2"},
7671 {146, "sdc2_dat_3"},
7672#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7673 {147, "sdc2_dat_4"},
7674 {148, "sdc2_dat_5"},
7675 {149, "sdc2_dat_6"},
7676 {150, "sdc2_dat_7"},
7677#endif
7678 {151, "sdc2_cmd"},
7679 {152, "sdc2_clk", 1}
7680};
7681#endif
7682
7683#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7684static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7685 {95, "sdc5_cmd"},
7686 {96, "sdc5_dat_3"},
7687 {97, "sdc5_clk", 1},
7688 {98, "sdc5_dat_2"},
7689 {99, "sdc5_dat_1", 1},
7690 {100, "sdc5_dat_0"}
7691};
7692#endif
7693
7694struct msm_sdcc_pad_pull_cfg {
7695 enum msm_tlmm_pull_tgt pull;
7696 u32 pull_val;
7697};
7698
7699struct msm_sdcc_pad_drv_cfg {
7700 enum msm_tlmm_hdrive_tgt drv;
7701 u32 drv_val;
7702};
7703
7704#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7705static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7706 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7707 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7708 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7709};
7710
7711static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7712 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7713 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7714};
7715
7716static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7717 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7718 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7719 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7720};
7721
7722static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7723 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7724 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7725};
7726#endif
7727
7728#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7729static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7730 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7731 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7732 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7733};
7734
7735static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7736 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7737 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7738};
7739
7740static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7741 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7742 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7743 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7744};
7745
7746static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7747 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7748 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7749};
7750#endif
7751
7752struct msm_sdcc_pin_cfg {
7753 /*
7754 * = 1 if controller pins are using gpios
7755 * = 0 if controller has dedicated MSM pins
7756 */
7757 u8 is_gpio;
7758 u8 cfg_sts;
7759 u8 gpio_data_size;
7760 struct msm_sdcc_gpio *gpio_data;
7761 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7762 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7763 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7764 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7765 u8 pad_drv_data_size;
7766 u8 pad_pull_data_size;
7767 u8 sdio_lpm_gpio_cfg;
7768};
7769
7770
7771static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7772#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7773 [0] = {
7774 .is_gpio = 1,
7775 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7776 .gpio_data = sdc1_gpio_cfg
7777 },
7778#endif
7779#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7780 [1] = {
7781 .is_gpio = 1,
7782 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7783 .gpio_data = sdc2_gpio_cfg
7784 },
7785#endif
7786#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7787 [2] = {
7788 .is_gpio = 0,
7789 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7790 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7791 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7792 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7793 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7794 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7795 },
7796#endif
7797#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7798 [3] = {
7799 .is_gpio = 0,
7800 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7801 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7802 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7803 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7804 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7805 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7806 },
7807#endif
7808#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7809 [4] = {
7810 .is_gpio = 1,
7811 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7812 .gpio_data = sdc5_gpio_cfg
7813 }
7814#endif
7815};
7816
7817static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7818{
7819 int rc = 0;
7820 struct msm_sdcc_pin_cfg *curr;
7821 int n;
7822
7823 curr = &sdcc_pin_cfg_data[dev_id - 1];
7824 if (!curr->gpio_data)
7825 goto out;
7826
7827 for (n = 0; n < curr->gpio_data_size; n++) {
7828 if (enable) {
7829
7830 if (curr->gpio_data[n].always_on &&
7831 curr->gpio_data[n].is_enabled)
7832 continue;
7833 pr_debug("%s: enable: %s\n", __func__,
7834 curr->gpio_data[n].name);
7835 rc = gpio_request(curr->gpio_data[n].no,
7836 curr->gpio_data[n].name);
7837 if (rc) {
7838 pr_err("%s: gpio_request(%d, %s)"
7839 "failed", __func__,
7840 curr->gpio_data[n].no,
7841 curr->gpio_data[n].name);
7842 goto free_gpios;
7843 }
7844 /* set direction as output for all GPIOs */
7845 rc = gpio_direction_output(
7846 curr->gpio_data[n].no, 1);
7847 if (rc) {
7848 pr_err("%s: gpio_direction_output"
7849 "(%d, 1) failed\n", __func__,
7850 curr->gpio_data[n].no);
7851 goto free_gpios;
7852 }
7853 curr->gpio_data[n].is_enabled = 1;
7854 } else {
7855 /*
7856 * now free this GPIO which will put GPIO
7857 * in low power mode and will also put GPIO
7858 * in input mode
7859 */
7860 if (curr->gpio_data[n].always_on)
7861 continue;
7862 pr_debug("%s: disable: %s\n", __func__,
7863 curr->gpio_data[n].name);
7864 gpio_free(curr->gpio_data[n].no);
7865 curr->gpio_data[n].is_enabled = 0;
7866 }
7867 }
7868 curr->cfg_sts = enable;
7869 goto out;
7870
7871free_gpios:
7872 for (; n >= 0; n--)
7873 gpio_free(curr->gpio_data[n].no);
7874out:
7875 return rc;
7876}
7877
7878static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7879{
7880 int rc = 0;
7881 struct msm_sdcc_pin_cfg *curr;
7882 int n;
7883
7884 curr = &sdcc_pin_cfg_data[dev_id - 1];
7885 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7886 goto out;
7887
7888 if (enable) {
7889 /*
7890 * set up the normal driver strength and
7891 * pull config for pads
7892 */
7893 for (n = 0; n < curr->pad_drv_data_size; n++) {
7894 if (curr->sdio_lpm_gpio_cfg) {
7895 if (curr->pad_drv_on_data[n].drv ==
7896 TLMM_HDRV_SDC4_DATA)
7897 continue;
7898 }
7899 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7900 curr->pad_drv_on_data[n].drv_val);
7901 }
7902 for (n = 0; n < curr->pad_pull_data_size; n++) {
7903 if (curr->sdio_lpm_gpio_cfg) {
7904 if (curr->pad_pull_on_data[n].pull ==
7905 TLMM_PULL_SDC4_DATA)
7906 continue;
7907 }
7908 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7909 curr->pad_pull_on_data[n].pull_val);
7910 }
7911 } else {
7912 /* set the low power config for pads */
7913 for (n = 0; n < curr->pad_drv_data_size; n++) {
7914 if (curr->sdio_lpm_gpio_cfg) {
7915 if (curr->pad_drv_off_data[n].drv ==
7916 TLMM_HDRV_SDC4_DATA)
7917 continue;
7918 }
7919 msm_tlmm_set_hdrive(
7920 curr->pad_drv_off_data[n].drv,
7921 curr->pad_drv_off_data[n].drv_val);
7922 }
7923 for (n = 0; n < curr->pad_pull_data_size; n++) {
7924 if (curr->sdio_lpm_gpio_cfg) {
7925 if (curr->pad_pull_off_data[n].pull ==
7926 TLMM_PULL_SDC4_DATA)
7927 continue;
7928 }
7929 msm_tlmm_set_pull(
7930 curr->pad_pull_off_data[n].pull,
7931 curr->pad_pull_off_data[n].pull_val);
7932 }
7933 }
7934 curr->cfg_sts = enable;
7935out:
7936 return rc;
7937}
7938
7939struct sdcc_reg {
7940 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7941 const char *reg_name;
7942 /*
7943 * is set voltage supported for this regulator?
7944 * 0 = not supported, 1 = supported
7945 */
7946 unsigned char set_voltage_sup;
7947 /* voltage level to be set */
7948 unsigned int level;
7949 /* VDD/VCC/VCCQ voltage regulator handle */
7950 struct regulator *reg;
7951 /* is this regulator enabled? */
7952 bool enabled;
7953 /* is this regulator needs to be always on? */
7954 bool always_on;
7955 /* is operating power mode setting required for this regulator? */
7956 bool op_pwr_mode_sup;
7957 /* Load values for low power and high power mode */
7958 unsigned int lpm_uA;
7959 unsigned int hpm_uA;
7960};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007961/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007962static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7963/* only SDCC1 requires VCCQ voltage */
7964static struct sdcc_reg sdcc_vccq_reg_data[1];
7965/* all SDCC controllers may require voting for VDD PAD voltage */
7966static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7967
7968struct sdcc_reg_data {
7969 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7970 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7971 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7972 unsigned char sts; /* regulator enable/disable status */
7973};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007974/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007975static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7976
7977static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7978{
7979 int rc = 0;
7980
7981 /* Get the regulator handle */
7982 vreg->reg = regulator_get(NULL, vreg->reg_name);
7983 if (IS_ERR(vreg->reg)) {
7984 rc = PTR_ERR(vreg->reg);
7985 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7986 __func__, vreg->reg_name, rc);
7987 goto out;
7988 }
7989
7990 /* Set the voltage level if required */
7991 if (vreg->set_voltage_sup) {
7992 rc = regulator_set_voltage(vreg->reg, vreg->level,
7993 vreg->level);
7994 if (rc) {
7995 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7996 __func__, vreg->reg_name, rc);
7997 goto vreg_put;
7998 }
7999 }
8000 goto out;
8001
8002vreg_put:
8003 regulator_put(vreg->reg);
8004out:
8005 return rc;
8006}
8007
8008static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
8009{
8010 regulator_put(vreg->reg);
8011}
8012
8013/* this init function should be called only once for each SDCC */
8014static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
8015{
8016 int rc = 0;
8017 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8018 struct sdcc_reg_data *curr;
8019
8020 curr = &sdcc_vreg_data[dev_id - 1];
8021 curr_vdd_reg = curr->vdd_data;
8022 curr_vccq_reg = curr->vccq_data;
8023 curr_vddp_reg = curr->vddp_data;
8024
8025 if (init) {
8026 /*
8027 * get the regulator handle from voltage regulator framework
8028 * and then try to set the voltage level for the regulator
8029 */
8030 if (curr_vdd_reg) {
8031 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8032 if (rc)
8033 goto out;
8034 }
8035 if (curr_vccq_reg) {
8036 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8037 if (rc)
8038 goto vdd_reg_deinit;
8039 }
8040 if (curr_vddp_reg) {
8041 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8042 if (rc)
8043 goto vccq_reg_deinit;
8044 }
8045 goto out;
8046 } else
8047 /* deregister with all regulators from regulator framework */
8048 goto vddp_reg_deinit;
8049
8050vddp_reg_deinit:
8051 if (curr_vddp_reg)
8052 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8053vccq_reg_deinit:
8054 if (curr_vccq_reg)
8055 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8056vdd_reg_deinit:
8057 if (curr_vdd_reg)
8058 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8059out:
8060 return rc;
8061}
8062
8063static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8064{
8065 int rc;
8066
8067 if (!vreg->enabled) {
8068 rc = regulator_enable(vreg->reg);
8069 if (rc) {
8070 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8071 __func__, vreg->reg_name, rc);
8072 goto out;
8073 }
8074 vreg->enabled = 1;
8075 }
8076
8077 /* Put always_on regulator in HPM (high power mode) */
8078 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8079 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8080 if (rc < 0) {
8081 pr_err("%s: reg=%s: HPM setting failed"
8082 " hpm_uA=%d, rc=%d\n",
8083 __func__, vreg->reg_name,
8084 vreg->hpm_uA, rc);
8085 goto vreg_disable;
8086 }
8087 rc = 0;
8088 }
8089 goto out;
8090
8091vreg_disable:
8092 regulator_disable(vreg->reg);
8093 vreg->enabled = 0;
8094out:
8095 return rc;
8096}
8097
8098static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8099{
8100 int rc;
8101
8102 /* Never disable always_on regulator */
8103 if (!vreg->always_on) {
8104 rc = regulator_disable(vreg->reg);
8105 if (rc) {
8106 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8107 __func__, vreg->reg_name, rc);
8108 goto out;
8109 }
8110 vreg->enabled = 0;
8111 }
8112
8113 /* Put always_on regulator in LPM (low power mode) */
8114 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8115 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8116 if (rc < 0) {
8117 pr_err("%s: reg=%s: LPM setting failed"
8118 " lpm_uA=%d, rc=%d\n",
8119 __func__,
8120 vreg->reg_name,
8121 vreg->lpm_uA, rc);
8122 goto out;
8123 }
8124 rc = 0;
8125 }
8126
8127out:
8128 return rc;
8129}
8130
8131static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8132{
8133 int rc = 0;
8134 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8135 struct sdcc_reg_data *curr;
8136
8137 curr = &sdcc_vreg_data[dev_id - 1];
8138 curr_vdd_reg = curr->vdd_data;
8139 curr_vccq_reg = curr->vccq_data;
8140 curr_vddp_reg = curr->vddp_data;
8141
8142 /* check if regulators are initialized or not? */
8143 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8144 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8145 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8146 /* initialize voltage regulators required for this SDCC */
8147 rc = msm_sdcc_vreg_init(dev_id, 1);
8148 if (rc) {
8149 pr_err("%s: regulator init failed = %d\n",
8150 __func__, rc);
8151 goto out;
8152 }
8153 }
8154
8155 if (curr->sts == enable)
8156 goto out;
8157
8158 if (curr_vdd_reg) {
8159 if (enable)
8160 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8161 else
8162 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8163 if (rc)
8164 goto out;
8165 }
8166
8167 if (curr_vccq_reg) {
8168 if (enable)
8169 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8170 else
8171 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8172 if (rc)
8173 goto out;
8174 }
8175
8176 if (curr_vddp_reg) {
8177 if (enable)
8178 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8179 else
8180 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8181 if (rc)
8182 goto out;
8183 }
8184 curr->sts = enable;
8185
8186out:
8187 return rc;
8188}
8189
8190static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8191{
8192 u32 rc_pin_cfg = 0;
8193 u32 rc_vreg_cfg = 0;
8194 u32 rc = 0;
8195 struct platform_device *pdev;
8196 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8197
8198 pdev = container_of(dv, struct platform_device, dev);
8199
8200 /* setup gpio/pad */
8201 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8202 if (curr_pin_cfg->cfg_sts == !!vdd)
8203 goto setup_vreg;
8204
8205 if (curr_pin_cfg->is_gpio)
8206 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8207 else
8208 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8209
8210setup_vreg:
8211 /* setup voltage regulators */
8212 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8213
8214 if (rc_pin_cfg || rc_vreg_cfg)
8215 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8216
8217 return rc;
8218}
8219
8220static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8221{
8222 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8223 struct platform_device *pdev;
8224
8225 pdev = container_of(dv, struct platform_device, dev);
8226 /* setup gpio/pad */
8227 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8228
8229 if (curr_pin_cfg->cfg_sts == active)
8230 return;
8231
8232 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8233 if (curr_pin_cfg->is_gpio)
8234 msm_sdcc_setup_gpio(pdev->id, active);
8235 else
8236 msm_sdcc_setup_pad(pdev->id, active);
8237 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8238}
8239
8240static int msm_sdc3_get_wpswitch(struct device *dev)
8241{
8242 struct platform_device *pdev;
8243 int status;
8244 pdev = container_of(dev, struct platform_device, dev);
8245
8246 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8247 if (status) {
8248 pr_err("%s:Failed to request GPIO %d\n",
8249 __func__, GPIO_SDC_WP);
8250 } else {
8251 status = gpio_direction_input(GPIO_SDC_WP);
8252 if (!status) {
8253 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8254 pr_info("%s: WP Status for Slot %d = %d\n",
8255 __func__, pdev->id, status);
8256 }
8257 gpio_free(GPIO_SDC_WP);
8258 }
8259 return status;
8260}
8261
8262#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8263int sdc5_register_status_notify(void (*callback)(int, void *),
8264 void *dev_id)
8265{
8266 sdc5_status_notify_cb = callback;
8267 sdc5_status_notify_cb_devid = dev_id;
8268 return 0;
8269}
8270#endif
8271
8272#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8273int sdc2_register_status_notify(void (*callback)(int, void *),
8274 void *dev_id)
8275{
8276 sdc2_status_notify_cb = callback;
8277 sdc2_status_notify_cb_devid = dev_id;
8278 return 0;
8279}
8280#endif
8281
8282/* Interrupt handler for SDC2 and SDC5 detection
8283 * This function uses dual-edge interrputs settings in order
8284 * to get SDIO detection when the GPIO is rising and SDIO removal
8285 * when the GPIO is falling */
8286static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8287{
8288 int status;
8289
8290 if (!machine_is_msm8x60_fusion() &&
8291 !machine_is_msm8x60_fusn_ffa())
8292 return IRQ_NONE;
8293
8294 status = gpio_get_value(MDM2AP_SYNC);
8295 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8296 __func__, status);
8297
8298#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8299 if (sdc2_status_notify_cb) {
8300 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8301 sdc2_status_notify_cb(status,
8302 sdc2_status_notify_cb_devid);
8303 }
8304#endif
8305
8306#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8307 if (sdc5_status_notify_cb) {
8308 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8309 sdc5_status_notify_cb(status,
8310 sdc5_status_notify_cb_devid);
8311 }
8312#endif
8313 return IRQ_HANDLED;
8314}
8315
8316static int msm8x60_multi_sdio_init(void)
8317{
8318 int ret, irq_num;
8319
8320 if (!machine_is_msm8x60_fusion() &&
8321 !machine_is_msm8x60_fusn_ffa())
8322 return 0;
8323
8324 ret = msm_gpiomux_get(MDM2AP_SYNC);
8325 if (ret) {
8326 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8327 __func__, MDM2AP_SYNC, ret);
8328 return ret;
8329 }
8330
8331 irq_num = gpio_to_irq(MDM2AP_SYNC);
8332
8333 ret = request_irq(irq_num,
8334 msm8x60_multi_sdio_slot_status_irq,
8335 IRQ_TYPE_EDGE_BOTH,
8336 "sdio_multidetection", NULL);
8337
8338 if (ret) {
8339 pr_err("%s:Failed to request irq, ret=%d\n",
8340 __func__, ret);
8341 return ret;
8342 }
8343
8344 return ret;
8345}
8346
8347#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8348#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8349static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8350{
8351 int status;
8352
8353 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8354 , "SD_HW_Detect");
8355 if (status) {
8356 pr_err("%s:Failed to request GPIO %d\n", __func__,
8357 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8358 } else {
8359 status = gpio_direction_input(
8360 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8361 if (!status)
8362 status = !(gpio_get_value_cansleep(
8363 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8364 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8365 }
8366 return (unsigned int) status;
8367}
8368#endif
8369#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308370#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008371
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308372#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308373#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008374
8375#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8376static struct mmc_platform_data msm8x60_sdc1_data = {
8377 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8378 .translate_vdd = msm_sdcc_setup_power,
8379#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8380 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8381#else
8382 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8383#endif
8384 .msmsdcc_fmin = 400000,
8385 .msmsdcc_fmid = 24000000,
8386 .msmsdcc_fmax = 48000000,
8387 .nonremovable = 1,
8388 .pclk_src_dfab = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308389 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008390};
8391#endif
8392
8393#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8394static struct mmc_platform_data msm8x60_sdc2_data = {
8395 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8396 .translate_vdd = msm_sdcc_setup_power,
8397 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8398 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8399 .msmsdcc_fmin = 400000,
8400 .msmsdcc_fmid = 24000000,
8401 .msmsdcc_fmax = 48000000,
8402 .nonremovable = 0,
8403 .pclk_src_dfab = 1,
8404 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008405#ifdef CONFIG_MSM_SDIO_AL
8406 .is_sdio_al_client = 1,
8407#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308408 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008409};
8410#endif
8411
8412#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8413static struct mmc_platform_data msm8x60_sdc3_data = {
8414 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8415 .translate_vdd = msm_sdcc_setup_power,
8416 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8417 .wpswitch = msm_sdc3_get_wpswitch,
8418#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8419 .status = msm8x60_sdcc_slot_status,
8420 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8421 PMIC_GPIO_SDC3_DET - 1),
8422 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8423#endif
8424 .msmsdcc_fmin = 400000,
8425 .msmsdcc_fmid = 24000000,
8426 .msmsdcc_fmax = 48000000,
8427 .nonremovable = 0,
8428 .pclk_src_dfab = 1,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308429 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308430 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008431};
8432#endif
8433
8434#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8435static struct mmc_platform_data msm8x60_sdc4_data = {
8436 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8437 .translate_vdd = msm_sdcc_setup_power,
8438 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8439 .msmsdcc_fmin = 400000,
8440 .msmsdcc_fmid = 24000000,
8441 .msmsdcc_fmax = 48000000,
8442 .nonremovable = 0,
8443 .pclk_src_dfab = 1,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308444 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308445 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008446};
8447#endif
8448
8449#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8450static struct mmc_platform_data msm8x60_sdc5_data = {
8451 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8452 .translate_vdd = msm_sdcc_setup_power,
8453 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8454 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8455 .msmsdcc_fmin = 400000,
8456 .msmsdcc_fmid = 24000000,
8457 .msmsdcc_fmax = 48000000,
8458 .nonremovable = 0,
8459 .pclk_src_dfab = 1,
8460 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008461#ifdef CONFIG_MSM_SDIO_AL
8462 .is_sdio_al_client = 1,
8463#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308464 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008465};
8466#endif
8467
8468static void __init msm8x60_init_mmc(void)
8469{
8470#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8471 /* SDCC1 : eMMC card connected */
8472 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8473 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8474 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8475 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308476 sdcc_vreg_data[0].vdd_data->always_on = 1;
8477 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8478 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8479 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008480
8481 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8482 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8483 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8484 sdcc_vreg_data[0].vccq_data->always_on = 1;
8485
8486 msm_add_sdcc(1, &msm8x60_sdc1_data);
8487#endif
8488#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8489 /*
8490 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8491 * and no card is connected on 8660 SURF/FFA/FLUID.
8492 */
8493 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8494 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8495 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8496 sdcc_vreg_data[1].vdd_data->level = 1800000;
8497
8498 sdcc_vreg_data[1].vccq_data = NULL;
8499
8500 if (machine_is_msm8x60_fusion())
8501 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8502 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008503 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8504 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008505 msm_add_sdcc(2, &msm8x60_sdc2_data);
8506 }
8507#endif
8508#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8509 /* SDCC3 : External card slot connected */
8510 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8511 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8512 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8513 sdcc_vreg_data[2].vdd_data->level = 2850000;
8514 sdcc_vreg_data[2].vdd_data->always_on = 1;
8515 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8516 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8517 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8518
8519 sdcc_vreg_data[2].vccq_data = NULL;
8520
8521 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8522 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8523 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8524 sdcc_vreg_data[2].vddp_data->level = 2850000;
8525 sdcc_vreg_data[2].vddp_data->always_on = 1;
8526 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8527 /* Sleep current required is ~300 uA. But min. RPM
8528 * vote can be in terms of mA (min. 1 mA).
8529 * So let's vote for 2 mA during sleep.
8530 */
8531 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8532 /* Max. Active current required is 16 mA */
8533 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8534
8535 if (machine_is_msm8x60_fluid())
8536 msm8x60_sdc3_data.wpswitch = NULL;
8537 msm_add_sdcc(3, &msm8x60_sdc3_data);
8538#endif
8539#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8540 /* SDCC4 : WLAN WCN1314 chip is connected */
8541 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8542 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8543 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8544 sdcc_vreg_data[3].vdd_data->level = 1800000;
8545
8546 sdcc_vreg_data[3].vccq_data = NULL;
8547
8548 msm_add_sdcc(4, &msm8x60_sdc4_data);
8549#endif
8550#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8551 /*
8552 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8553 * and no card is connected on 8660 SURF/FFA/FLUID.
8554 */
8555 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8556 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8557 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8558 sdcc_vreg_data[4].vdd_data->level = 1800000;
8559
8560 sdcc_vreg_data[4].vccq_data = NULL;
8561
8562 if (machine_is_msm8x60_fusion())
8563 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8564 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008565 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8566 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008567 msm_add_sdcc(5, &msm8x60_sdc5_data);
8568 }
8569#endif
8570}
8571
8572#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8573static inline void display_common_power(int on) {}
8574#else
8575
8576#define _GET_REGULATOR(var, name) do { \
8577 if (var == NULL) { \
8578 var = regulator_get(NULL, name); \
8579 if (IS_ERR(var)) { \
8580 pr_err("'%s' regulator not found, rc=%ld\n", \
8581 name, PTR_ERR(var)); \
8582 var = NULL; \
8583 } \
8584 } \
8585} while (0)
8586
8587static int dsub_regulator(int on)
8588{
8589 static struct regulator *dsub_reg;
8590 static struct regulator *mpp0_reg;
8591 static int dsub_reg_enabled;
8592 int rc = 0;
8593
8594 _GET_REGULATOR(dsub_reg, "8901_l3");
8595 if (IS_ERR(dsub_reg)) {
8596 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8597 __func__, PTR_ERR(dsub_reg));
8598 return PTR_ERR(dsub_reg);
8599 }
8600
8601 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8602 if (IS_ERR(mpp0_reg)) {
8603 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8604 __func__, PTR_ERR(mpp0_reg));
8605 return PTR_ERR(mpp0_reg);
8606 }
8607
8608 if (on && !dsub_reg_enabled) {
8609 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8610 if (rc) {
8611 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8612 " err=%d", __func__, rc);
8613 goto dsub_regulator_err;
8614 }
8615 rc = regulator_enable(dsub_reg);
8616 if (rc) {
8617 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8618 " err=%d", __func__, rc);
8619 goto dsub_regulator_err;
8620 }
8621 rc = regulator_enable(mpp0_reg);
8622 if (rc) {
8623 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8624 " err=%d", __func__, rc);
8625 goto dsub_regulator_err;
8626 }
8627 dsub_reg_enabled = 1;
8628 } else if (!on && dsub_reg_enabled) {
8629 rc = regulator_disable(dsub_reg);
8630 if (rc)
8631 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8632 " err=%d", __func__, rc);
8633 rc = regulator_disable(mpp0_reg);
8634 if (rc)
8635 printk(KERN_WARNING "%s: failed to disable reg "
8636 "8901_mpp0 err=%d", __func__, rc);
8637 dsub_reg_enabled = 0;
8638 }
8639
8640 return rc;
8641
8642dsub_regulator_err:
8643 regulator_put(mpp0_reg);
8644 regulator_put(dsub_reg);
8645 return rc;
8646}
8647
8648static int display_power_on;
8649static void setup_display_power(void)
8650{
8651 if (display_power_on)
8652 if (lcdc_vga_enabled) {
8653 dsub_regulator(1);
8654 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8655 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8656 if (machine_is_msm8x60_ffa() ||
8657 machine_is_msm8x60_fusn_ffa())
8658 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8659 } else {
8660 dsub_regulator(0);
8661 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8662 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8663 if (machine_is_msm8x60_ffa() ||
8664 machine_is_msm8x60_fusn_ffa())
8665 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8666 }
8667 else {
8668 dsub_regulator(0);
8669 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8670 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8671 /* BACKLIGHT */
8672 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8673 /* LVDS */
8674 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8675 }
8676}
8677
8678#define _GET_REGULATOR(var, name) do { \
8679 if (var == NULL) { \
8680 var = regulator_get(NULL, name); \
8681 if (IS_ERR(var)) { \
8682 pr_err("'%s' regulator not found, rc=%ld\n", \
8683 name, PTR_ERR(var)); \
8684 var = NULL; \
8685 } \
8686 } \
8687} while (0)
8688
8689#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8690
8691static void display_common_power(int on)
8692{
8693 int rc;
8694 static struct regulator *display_reg;
8695
8696 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8697 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8698 if (on) {
8699 /* LVDS */
8700 _GET_REGULATOR(display_reg, "8901_l2");
8701 if (!display_reg)
8702 return;
8703 rc = regulator_set_voltage(display_reg,
8704 3300000, 3300000);
8705 if (rc)
8706 goto out;
8707 rc = regulator_enable(display_reg);
8708 if (rc)
8709 goto out;
8710 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8711 "LVDS_STDN_OUT_N");
8712 if (rc) {
8713 printk(KERN_ERR "%s: LVDS gpio %d request"
8714 "failed\n", __func__,
8715 GPIO_LVDS_SHUTDOWN_N);
8716 goto out2;
8717 }
8718
8719 /* BACKLIGHT */
8720 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8721 if (rc) {
8722 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8723 "failed\n", __func__,
8724 GPIO_BACKLIGHT_EN);
8725 goto out3;
8726 }
8727
8728 if (machine_is_msm8x60_ffa() ||
8729 machine_is_msm8x60_fusn_ffa()) {
8730 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8731 "DONGLE_PWR_EN");
8732 if (rc) {
8733 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8734 " %d request failed\n", __func__,
8735 GPIO_DONGLE_PWR_EN);
8736 goto out4;
8737 }
8738 }
8739
8740 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8741 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8742 if (machine_is_msm8x60_ffa() ||
8743 machine_is_msm8x60_fusn_ffa())
8744 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8745 mdelay(20);
8746 display_power_on = 1;
8747 setup_display_power();
8748 } else {
8749 if (display_power_on) {
8750 display_power_on = 0;
8751 setup_display_power();
8752 mdelay(20);
8753 if (machine_is_msm8x60_ffa() ||
8754 machine_is_msm8x60_fusn_ffa())
8755 gpio_free(GPIO_DONGLE_PWR_EN);
8756 goto out4;
8757 }
8758 }
8759 }
8760#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8761 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8762 else if (machine_is_msm8x60_fluid()) {
8763 static struct regulator *fluid_reg;
8764 static struct regulator *fluid_reg2;
8765
8766 if (on) {
8767 _GET_REGULATOR(fluid_reg, "8901_l2");
8768 if (!fluid_reg)
8769 return;
8770 _GET_REGULATOR(fluid_reg2, "8058_s3");
8771 if (!fluid_reg2) {
8772 regulator_put(fluid_reg);
8773 return;
8774 }
8775 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8776 if (rc) {
8777 regulator_put(fluid_reg2);
8778 regulator_put(fluid_reg);
8779 return;
8780 }
8781 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8782 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8783 regulator_enable(fluid_reg);
8784 regulator_enable(fluid_reg2);
8785 msleep(20);
8786 gpio_direction_output(GPIO_RESX_N, 0);
8787 udelay(10);
8788 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8789 display_power_on = 1;
8790 setup_display_power();
8791 } else {
8792 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8793 gpio_free(GPIO_RESX_N);
8794 msleep(20);
8795 regulator_disable(fluid_reg2);
8796 regulator_disable(fluid_reg);
8797 regulator_put(fluid_reg2);
8798 regulator_put(fluid_reg);
8799 display_power_on = 0;
8800 setup_display_power();
8801 fluid_reg = NULL;
8802 fluid_reg2 = NULL;
8803 }
8804 }
8805#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008806#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8807 else if (machine_is_msm8x60_dragon()) {
8808 static struct regulator *dragon_reg;
8809 static struct regulator *dragon_reg2;
8810
8811 if (on) {
8812 _GET_REGULATOR(dragon_reg, "8901_l2");
8813 if (!dragon_reg)
8814 return;
8815 _GET_REGULATOR(dragon_reg2, "8058_l16");
8816 if (!dragon_reg2) {
8817 regulator_put(dragon_reg);
8818 dragon_reg = NULL;
8819 return;
8820 }
8821
8822 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8823 if (rc) {
8824 pr_err("%s: gpio %d request failed with rc=%d\n",
8825 __func__, GPIO_NT35582_BL_EN, rc);
8826 regulator_put(dragon_reg);
8827 regulator_put(dragon_reg2);
8828 dragon_reg = NULL;
8829 dragon_reg2 = NULL;
8830 return;
8831 }
8832
8833 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8834 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8835 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8836 pr_err("%s: config gpio '%d' failed!\n",
8837 __func__, GPIO_NT35582_RESET);
8838 gpio_free(GPIO_NT35582_BL_EN);
8839 regulator_put(dragon_reg);
8840 regulator_put(dragon_reg2);
8841 dragon_reg = NULL;
8842 dragon_reg2 = NULL;
8843 return;
8844 }
8845
8846 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8847 if (rc) {
8848 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8849 __func__, GPIO_NT35582_RESET, rc);
8850 gpio_free(GPIO_NT35582_BL_EN);
8851 regulator_put(dragon_reg);
8852 regulator_put(dragon_reg2);
8853 dragon_reg = NULL;
8854 dragon_reg2 = NULL;
8855 return;
8856 }
8857
8858 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8859 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8860 regulator_enable(dragon_reg);
8861 regulator_enable(dragon_reg2);
8862 msleep(20);
8863
8864 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8865 msleep(20);
8866 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8867 msleep(20);
8868 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8869 msleep(50);
8870
8871 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8872
8873 display_power_on = 1;
8874 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8875 gpio_free(GPIO_NT35582_RESET);
8876 gpio_free(GPIO_NT35582_BL_EN);
8877 regulator_disable(dragon_reg2);
8878 regulator_disable(dragon_reg);
8879 regulator_put(dragon_reg2);
8880 regulator_put(dragon_reg);
8881 display_power_on = 0;
8882 dragon_reg = NULL;
8883 dragon_reg2 = NULL;
8884 }
8885 }
8886#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008887 return;
8888
8889out4:
8890 gpio_free(GPIO_BACKLIGHT_EN);
8891out3:
8892 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8893out2:
8894 regulator_disable(display_reg);
8895out:
8896 regulator_put(display_reg);
8897 display_reg = NULL;
8898}
8899#undef _GET_REGULATOR
8900#endif
8901
8902static int mipi_dsi_panel_power(int on);
8903
8904#define LCDC_NUM_GPIO 28
8905#define LCDC_GPIO_START 0
8906
8907static void lcdc_samsung_panel_power(int on)
8908{
8909 int n, ret = 0;
8910
8911 display_common_power(on);
8912
8913 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8914 if (on) {
8915 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8916 if (unlikely(ret)) {
8917 pr_err("%s not able to get gpio\n", __func__);
8918 break;
8919 }
8920 } else
8921 gpio_free(LCDC_GPIO_START + n);
8922 }
8923
8924 if (ret) {
8925 for (n--; n >= 0; n--)
8926 gpio_free(LCDC_GPIO_START + n);
8927 }
8928
8929 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8930}
8931
8932#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8933#define _GET_REGULATOR(var, name) do { \
8934 var = regulator_get(NULL, name); \
8935 if (IS_ERR(var)) { \
8936 pr_err("'%s' regulator not found, rc=%ld\n", \
8937 name, IS_ERR(var)); \
8938 var = NULL; \
8939 return -ENODEV; \
8940 } \
8941} while (0)
8942
8943static int hdmi_enable_5v(int on)
8944{
8945 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8946 static struct regulator *reg_8901_mpp0; /* External 5V */
8947 static int prev_on;
8948 int rc;
8949
8950 if (on == prev_on)
8951 return 0;
8952
8953 if (!reg_8901_hdmi_mvs)
8954 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8955 if (!reg_8901_mpp0)
8956 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8957
8958 if (on) {
8959 rc = regulator_enable(reg_8901_mpp0);
8960 if (rc) {
8961 pr_err("'%s' regulator enable failed, rc=%d\n",
8962 "reg_8901_mpp0", rc);
8963 return rc;
8964 }
8965 rc = regulator_enable(reg_8901_hdmi_mvs);
8966 if (rc) {
8967 pr_err("'%s' regulator enable failed, rc=%d\n",
8968 "8901_hdmi_mvs", rc);
8969 return rc;
8970 }
8971 pr_info("%s(on): success\n", __func__);
8972 } else {
8973 rc = regulator_disable(reg_8901_hdmi_mvs);
8974 if (rc)
8975 pr_warning("'%s' regulator disable failed, rc=%d\n",
8976 "8901_hdmi_mvs", rc);
8977 rc = regulator_disable(reg_8901_mpp0);
8978 if (rc)
8979 pr_warning("'%s' regulator disable failed, rc=%d\n",
8980 "reg_8901_mpp0", rc);
8981 pr_info("%s(off): success\n", __func__);
8982 }
8983
8984 prev_on = on;
8985
8986 return 0;
8987}
8988
8989static int hdmi_core_power(int on, int show)
8990{
8991 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8992 static int prev_on;
8993 int rc;
8994
8995 if (on == prev_on)
8996 return 0;
8997
8998 if (!reg_8058_l16)
8999 _GET_REGULATOR(reg_8058_l16, "8058_l16");
9000
9001 if (on) {
9002 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
9003 if (!rc)
9004 rc = regulator_enable(reg_8058_l16);
9005 if (rc) {
9006 pr_err("'%s' regulator enable failed, rc=%d\n",
9007 "8058_l16", rc);
9008 return rc;
9009 }
9010 rc = gpio_request(170, "HDMI_DDC_CLK");
9011 if (rc) {
9012 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9013 "HDMI_DDC_CLK", 170, rc);
9014 goto error1;
9015 }
9016 rc = gpio_request(171, "HDMI_DDC_DATA");
9017 if (rc) {
9018 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9019 "HDMI_DDC_DATA", 171, rc);
9020 goto error2;
9021 }
9022 rc = gpio_request(172, "HDMI_HPD");
9023 if (rc) {
9024 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9025 "HDMI_HPD", 172, rc);
9026 goto error3;
9027 }
9028 pr_info("%s(on): success\n", __func__);
9029 } else {
9030 gpio_free(170);
9031 gpio_free(171);
9032 gpio_free(172);
9033 rc = regulator_disable(reg_8058_l16);
9034 if (rc)
9035 pr_warning("'%s' regulator disable failed, rc=%d\n",
9036 "8058_l16", rc);
9037 pr_info("%s(off): success\n", __func__);
9038 }
9039
9040 prev_on = on;
9041
9042 return 0;
9043
9044error3:
9045 gpio_free(171);
9046error2:
9047 gpio_free(170);
9048error1:
9049 regulator_disable(reg_8058_l16);
9050 return rc;
9051}
9052
9053static int hdmi_cec_power(int on)
9054{
9055 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9056 static int prev_on;
9057 int rc;
9058
9059 if (on == prev_on)
9060 return 0;
9061
9062 if (!reg_8901_l3)
9063 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9064
9065 if (on) {
9066 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9067 if (!rc)
9068 rc = regulator_enable(reg_8901_l3);
9069 if (rc) {
9070 pr_err("'%s' regulator enable failed, rc=%d\n",
9071 "8901_l3", rc);
9072 return rc;
9073 }
9074 rc = gpio_request(169, "HDMI_CEC_VAR");
9075 if (rc) {
9076 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9077 "HDMI_CEC_VAR", 169, rc);
9078 goto error;
9079 }
9080 pr_info("%s(on): success\n", __func__);
9081 } else {
9082 gpio_free(169);
9083 rc = regulator_disable(reg_8901_l3);
9084 if (rc)
9085 pr_warning("'%s' regulator disable failed, rc=%d\n",
9086 "8901_l3", rc);
9087 pr_info("%s(off): success\n", __func__);
9088 }
9089
9090 prev_on = on;
9091
9092 return 0;
9093error:
9094 regulator_disable(reg_8901_l3);
9095 return rc;
9096}
9097
9098#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,
9520};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009521
9522static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9523 {
9524 ARRAY_SIZE(dtv_bus_init_vectors),
9525 dtv_bus_init_vectors,
9526 },
9527 {
9528 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9529 dtv_bus_hdmi_prim_vectors,
9530 },
9531};
9532
9533static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9534 dtv_hdmi_prim_bus_scale_usecases,
9535 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9536 .name = "dtv",
9537};
9538
9539static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9540 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9541};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009542#endif
9543
9544
9545static struct lcdc_platform_data lcdc_pdata = {
9546 .lcdc_power_save = lcdc_panel_power,
9547};
9548
9549
9550#define MDP_VSYNC_GPIO 28
9551
9552/*
9553 * MIPI_DSI only use 8058_LDO0 which need always on
9554 * therefore it need to be put at low power mode if
9555 * it was not used instead of turn it off.
9556 */
9557static int mipi_dsi_panel_power(int on)
9558{
9559 int flag_on = !!on;
9560 static int mipi_dsi_power_save_on;
9561 static struct regulator *ldo0;
9562 int rc = 0;
9563
9564 if (mipi_dsi_power_save_on == flag_on)
9565 return 0;
9566
9567 mipi_dsi_power_save_on = flag_on;
9568
9569 if (ldo0 == NULL) { /* init */
9570 ldo0 = regulator_get(NULL, "8058_l0");
9571 if (IS_ERR(ldo0)) {
9572 pr_debug("%s: LDO0 failed\n", __func__);
9573 rc = PTR_ERR(ldo0);
9574 return rc;
9575 }
9576
9577 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9578 if (rc)
9579 goto out;
9580
9581 rc = regulator_enable(ldo0);
9582 if (rc)
9583 goto out;
9584 }
9585
9586 if (on) {
9587 /* set ldo0 to HPM */
9588 rc = regulator_set_optimum_mode(ldo0, 100000);
9589 if (rc < 0)
9590 goto out;
9591 } else {
9592 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309593 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009594 if (rc < 0)
9595 goto out;
9596 }
9597
9598 return 0;
9599out:
9600 regulator_disable(ldo0);
9601 regulator_put(ldo0);
9602 ldo0 = NULL;
9603 return rc;
9604}
9605
9606static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9607 .vsync_gpio = MDP_VSYNC_GPIO,
9608 .dsi_power_save = mipi_dsi_panel_power,
9609};
9610
9611#ifdef CONFIG_FB_MSM_TVOUT
9612static struct regulator *reg_8058_l13;
9613
9614static int atv_dac_power(int on)
9615{
9616 int rc = 0;
9617 #define _GET_REGULATOR(var, name) do { \
9618 var = regulator_get(NULL, name); \
9619 if (IS_ERR(var)) { \
9620 pr_info("'%s' regulator not found, rc=%ld\n", \
9621 name, IS_ERR(var)); \
9622 var = NULL; \
9623 return -ENODEV; \
9624 } \
9625 } while (0)
9626
9627 if (!reg_8058_l13)
9628 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9629 #undef _GET_REGULATOR
9630
9631 if (on) {
9632 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9633 if (rc) {
9634 pr_info("%s: '%s' regulator set voltage failed,\
9635 rc=%d\n", __func__, "8058_l13", rc);
9636 return rc;
9637 }
9638
9639 rc = regulator_enable(reg_8058_l13);
9640 if (rc) {
9641 pr_err("%s: '%s' regulator enable failed,\
9642 rc=%d\n", __func__, "8058_l13", rc);
9643 return rc;
9644 }
9645 } else {
9646 rc = regulator_force_disable(reg_8058_l13);
9647 if (rc)
9648 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9649 __func__, "8058_l13", rc);
9650 }
9651 return rc;
9652
9653}
9654#endif
9655
9656#ifdef CONFIG_FB_MSM_MIPI_DSI
9657int mdp_core_clk_rate_table[] = {
9658 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009659 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009660 160000000,
9661 200000000,
9662};
9663#else
9664int mdp_core_clk_rate_table[] = {
9665 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009666 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009667 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009668 200000000,
9669};
9670#endif
9671
9672static struct msm_panel_common_pdata mdp_pdata = {
9673 .gpio = MDP_VSYNC_GPIO,
9674 .mdp_core_clk_rate = 59080000,
9675 .mdp_core_clk_table = mdp_core_clk_rate_table,
9676 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9677#ifdef CONFIG_MSM_BUS_SCALING
9678 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9679#endif
9680 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009681#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009682 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009683#else
9684 .mem_hid = MEMTYPE_EBI1,
9685#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009686};
9687
Huaibin Yanga5419422011-12-08 23:52:10 -08009688static void __init reserve_mdp_memory(void)
9689{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009690 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9691 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9692#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9693 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9694 mdp_pdata.ov0_wb_size;
9695 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9696 mdp_pdata.ov1_wb_size;
9697#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009698}
9699
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009700#ifdef CONFIG_FB_MSM_TVOUT
9701
9702#ifdef CONFIG_MSM_BUS_SCALING
9703static struct msm_bus_vectors atv_bus_init_vectors[] = {
9704 /* For now, 0th array entry is reserved.
9705 * Please leave 0 as is and don't use it
9706 */
9707 {
9708 .src = MSM_BUS_MASTER_MDP_PORT0,
9709 .dst = MSM_BUS_SLAVE_SMI,
9710 .ab = 0,
9711 .ib = 0,
9712 },
9713 /* Master and slaves can be from different fabrics */
9714 {
9715 .src = MSM_BUS_MASTER_MDP_PORT0,
9716 .dst = MSM_BUS_SLAVE_EBI_CH0,
9717 .ab = 0,
9718 .ib = 0,
9719 },
9720};
9721static struct msm_bus_vectors atv_bus_def_vectors[] = {
9722 /* For now, 0th array entry is reserved.
9723 * Please leave 0 as is and don't use it
9724 */
9725 {
9726 .src = MSM_BUS_MASTER_MDP_PORT0,
9727 .dst = MSM_BUS_SLAVE_SMI,
9728 .ab = 236390400,
9729 .ib = 265939200,
9730 },
9731 /* Master and slaves can be from different fabrics */
9732 {
9733 .src = MSM_BUS_MASTER_MDP_PORT0,
9734 .dst = MSM_BUS_SLAVE_EBI_CH0,
9735 .ab = 236390400,
9736 .ib = 265939200,
9737 },
9738};
9739static struct msm_bus_paths atv_bus_scale_usecases[] = {
9740 {
9741 ARRAY_SIZE(atv_bus_init_vectors),
9742 atv_bus_init_vectors,
9743 },
9744 {
9745 ARRAY_SIZE(atv_bus_def_vectors),
9746 atv_bus_def_vectors,
9747 },
9748};
9749static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9750 atv_bus_scale_usecases,
9751 ARRAY_SIZE(atv_bus_scale_usecases),
9752 .name = "atv",
9753};
9754#endif
9755
9756static struct tvenc_platform_data atv_pdata = {
9757 .poll = 0,
9758 .pm_vid_en = atv_dac_power,
9759#ifdef CONFIG_MSM_BUS_SCALING
9760 .bus_scale_table = &atv_bus_scale_pdata,
9761#endif
9762};
9763#endif
9764
9765static void __init msm_fb_add_devices(void)
9766{
9767#ifdef CONFIG_FB_MSM_LCDC_DSUB
9768 mdp_pdata.mdp_core_clk_table = NULL;
9769 mdp_pdata.num_mdp_clk = 0;
9770 mdp_pdata.mdp_core_clk_rate = 200000000;
9771#endif
9772 if (machine_is_msm8x60_rumi3())
9773 msm_fb_register_device("mdp", NULL);
9774 else
9775 msm_fb_register_device("mdp", &mdp_pdata);
9776
9777 msm_fb_register_device("lcdc", &lcdc_pdata);
9778 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9779#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009780 if (hdmi_is_primary)
9781 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9782 else
9783 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009784#endif
9785#ifdef CONFIG_FB_MSM_TVOUT
9786 msm_fb_register_device("tvenc", &atv_pdata);
9787 msm_fb_register_device("tvout_device", NULL);
9788#endif
9789}
9790
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009791/**
9792 * Set MDP clocks to high frequency to avoid underflow when
9793 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9794 */
9795static void set_mdp_clocks_for_wuxga(void)
9796{
9797 int i;
9798
9799 mdp_sd_smi_vectors[0].ab = 2000000000;
9800 mdp_sd_smi_vectors[0].ib = 2000000000;
9801 mdp_sd_smi_vectors[1].ab = 2000000000;
9802 mdp_sd_smi_vectors[1].ib = 2000000000;
9803
9804 mdp_sd_ebi_vectors[0].ab = 2000000000;
9805 mdp_sd_ebi_vectors[0].ib = 2000000000;
9806 mdp_sd_ebi_vectors[1].ab = 2000000000;
9807 mdp_sd_ebi_vectors[1].ib = 2000000000;
9808
9809 mdp_vga_vectors[0].ab = 2000000000;
9810 mdp_vga_vectors[0].ib = 2000000000;
9811 mdp_vga_vectors[1].ab = 2000000000;
9812 mdp_vga_vectors[1].ib = 2000000000;
9813
9814 mdp_720p_vectors[0].ab = 2000000000;
9815 mdp_720p_vectors[0].ib = 2000000000;
9816 mdp_720p_vectors[1].ab = 2000000000;
9817 mdp_720p_vectors[1].ib = 2000000000;
9818
9819 mdp_1080p_vectors[0].ab = 2000000000;
9820 mdp_1080p_vectors[0].ib = 2000000000;
9821 mdp_1080p_vectors[1].ab = 2000000000;
9822 mdp_1080p_vectors[1].ib = 2000000000;
9823
9824 mdp_pdata.mdp_core_clk_rate = 200000000;
9825
9826 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9827 mdp_core_clk_rate_table[i] = 200000000;
9828}
9829
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009830#if (defined(CONFIG_MARIMBA_CORE)) && \
9831 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9832
9833static const struct {
9834 char *name;
9835 int vmin;
9836 int vmax;
9837} bt_regs_info[] = {
9838 { "8058_s3", 1800000, 1800000 },
9839 { "8058_s2", 1300000, 1300000 },
9840 { "8058_l8", 2900000, 3050000 },
9841};
9842
9843static struct {
9844 bool enabled;
9845} bt_regs_status[] = {
9846 { false },
9847 { false },
9848 { false },
9849};
9850static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9851
9852static int bahama_bt(int on)
9853{
9854 int rc;
9855 int i;
9856 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9857
9858 struct bahama_variant_register {
9859 const size_t size;
9860 const struct bahama_config_register *set;
9861 };
9862
9863 const struct bahama_config_register *p;
9864
9865 u8 version;
9866
9867 const struct bahama_config_register v10_bt_on[] = {
9868 { 0xE9, 0x00, 0xFF },
9869 { 0xF4, 0x80, 0xFF },
9870 { 0xE4, 0x00, 0xFF },
9871 { 0xE5, 0x00, 0x0F },
9872#ifdef CONFIG_WLAN
9873 { 0xE6, 0x38, 0x7F },
9874 { 0xE7, 0x06, 0xFF },
9875#endif
9876 { 0xE9, 0x21, 0xFF },
9877 { 0x01, 0x0C, 0x1F },
9878 { 0x01, 0x08, 0x1F },
9879 };
9880
9881 const struct bahama_config_register v20_bt_on_fm_off[] = {
9882 { 0x11, 0x0C, 0xFF },
9883 { 0x13, 0x01, 0xFF },
9884 { 0xF4, 0x80, 0xFF },
9885 { 0xF0, 0x00, 0xFF },
9886 { 0xE9, 0x00, 0xFF },
9887#ifdef CONFIG_WLAN
9888 { 0x81, 0x00, 0x7F },
9889 { 0x82, 0x00, 0xFF },
9890 { 0xE6, 0x38, 0x7F },
9891 { 0xE7, 0x06, 0xFF },
9892#endif
9893 { 0xE9, 0x21, 0xFF },
9894 };
9895
9896 const struct bahama_config_register v20_bt_on_fm_on[] = {
9897 { 0x11, 0x0C, 0xFF },
9898 { 0x13, 0x01, 0xFF },
9899 { 0xF4, 0x86, 0xFF },
9900 { 0xF0, 0x06, 0xFF },
9901 { 0xE9, 0x00, 0xFF },
9902#ifdef CONFIG_WLAN
9903 { 0x81, 0x00, 0x7F },
9904 { 0x82, 0x00, 0xFF },
9905 { 0xE6, 0x38, 0x7F },
9906 { 0xE7, 0x06, 0xFF },
9907#endif
9908 { 0xE9, 0x21, 0xFF },
9909 };
9910
9911 const struct bahama_config_register v10_bt_off[] = {
9912 { 0xE9, 0x00, 0xFF },
9913 };
9914
9915 const struct bahama_config_register v20_bt_off_fm_off[] = {
9916 { 0xF4, 0x84, 0xFF },
9917 { 0xF0, 0x04, 0xFF },
9918 { 0xE9, 0x00, 0xFF }
9919 };
9920
9921 const struct bahama_config_register v20_bt_off_fm_on[] = {
9922 { 0xF4, 0x86, 0xFF },
9923 { 0xF0, 0x06, 0xFF },
9924 { 0xE9, 0x00, 0xFF }
9925 };
9926 const struct bahama_variant_register bt_bahama[2][3] = {
9927 {
9928 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9929 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9930 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9931 },
9932 {
9933 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9934 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9935 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9936 }
9937 };
9938
9939 u8 offset = 0; /* index into bahama configs */
9940
9941 on = on ? 1 : 0;
9942 version = read_bahama_ver();
9943
9944 if (version == VER_UNSUPPORTED) {
9945 dev_err(&msm_bt_power_device.dev,
9946 "%s: unsupported version\n",
9947 __func__);
9948 return -EIO;
9949 }
9950
9951 if (version == VER_2_0) {
9952 if (marimba_get_fm_status(&config))
9953 offset = 0x01;
9954 }
9955
9956 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9957 if (on && (version == VER_2_0)) {
9958 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9959 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9960 && (bt_regs_status[i].enabled == true)) {
9961 if (regulator_disable(bt_regs[i])) {
9962 dev_err(&msm_bt_power_device.dev,
9963 "%s: regulator disable failed",
9964 __func__);
9965 }
9966 bt_regs_status[i].enabled = false;
9967 break;
9968 }
9969 }
9970 }
9971
9972 p = bt_bahama[on][version + offset].set;
9973
9974 dev_info(&msm_bt_power_device.dev,
9975 "%s: found version %d\n", __func__, version);
9976
9977 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9978 u8 value = (p+i)->value;
9979 rc = marimba_write_bit_mask(&config,
9980 (p+i)->reg,
9981 &value,
9982 sizeof((p+i)->value),
9983 (p+i)->mask);
9984 if (rc < 0) {
9985 dev_err(&msm_bt_power_device.dev,
9986 "%s: reg %d write failed: %d\n",
9987 __func__, (p+i)->reg, rc);
9988 return rc;
9989 }
9990 dev_dbg(&msm_bt_power_device.dev,
9991 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9992 __func__, (p+i)->reg,
9993 value, (p+i)->mask);
9994 }
9995 /* Update BT Status */
9996 if (on)
9997 marimba_set_bt_status(&config, true);
9998 else
9999 marimba_set_bt_status(&config, false);
10000
10001 return 0;
10002}
10003
10004static int bluetooth_use_regulators(int on)
10005{
10006 int i, recover = -1, rc = 0;
10007
10008 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10009 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
10010 bt_regs_info[i].name) :
10011 (regulator_put(bt_regs[i]), NULL);
10012 if (IS_ERR(bt_regs[i])) {
10013 rc = PTR_ERR(bt_regs[i]);
10014 dev_err(&msm_bt_power_device.dev,
10015 "regulator %s get failed (%d)\n",
10016 bt_regs_info[i].name, rc);
10017 recover = i - 1;
10018 bt_regs[i] = NULL;
10019 break;
10020 }
10021
10022 if (!on)
10023 continue;
10024
10025 rc = regulator_set_voltage(bt_regs[i],
10026 bt_regs_info[i].vmin,
10027 bt_regs_info[i].vmax);
10028 if (rc < 0) {
10029 dev_err(&msm_bt_power_device.dev,
10030 "regulator %s voltage set (%d)\n",
10031 bt_regs_info[i].name, rc);
10032 recover = i;
10033 break;
10034 }
10035 }
10036
10037 if (on && (recover > -1))
10038 for (i = recover; i >= 0; i--) {
10039 regulator_put(bt_regs[i]);
10040 bt_regs[i] = NULL;
10041 }
10042
10043 return rc;
10044}
10045
10046static int bluetooth_switch_regulators(int on)
10047{
10048 int i, rc = 0;
10049
10050 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10051 if (on && (bt_regs_status[i].enabled == false)) {
10052 rc = regulator_enable(bt_regs[i]);
10053 if (rc < 0) {
10054 dev_err(&msm_bt_power_device.dev,
10055 "regulator %s %s failed (%d)\n",
10056 bt_regs_info[i].name,
10057 "enable", rc);
10058 if (i > 0) {
10059 while (--i) {
10060 regulator_disable(bt_regs[i]);
10061 bt_regs_status[i].enabled
10062 = false;
10063 }
10064 break;
10065 }
10066 }
10067 bt_regs_status[i].enabled = true;
10068 } else if (!on && (bt_regs_status[i].enabled == true)) {
10069 rc = regulator_disable(bt_regs[i]);
10070 if (rc < 0) {
10071 dev_err(&msm_bt_power_device.dev,
10072 "regulator %s %s failed (%d)\n",
10073 bt_regs_info[i].name,
10074 "disable", rc);
10075 break;
10076 }
10077 bt_regs_status[i].enabled = false;
10078 }
10079 }
10080 return rc;
10081}
10082
10083static struct msm_xo_voter *bt_clock;
10084
10085static int bluetooth_power(int on)
10086{
10087 int rc = 0;
10088 int id;
10089
10090 /* In case probe function fails, cur_connv_type would be -1 */
10091 id = adie_get_detected_connectivity_type();
10092 if (id != BAHAMA_ID) {
10093 pr_err("%s: unexpected adie connectivity type: %d\n",
10094 __func__, id);
10095 return -ENODEV;
10096 }
10097
10098 if (on) {
10099
10100 rc = bluetooth_use_regulators(1);
10101 if (rc < 0)
10102 goto out;
10103
10104 rc = bluetooth_switch_regulators(1);
10105
10106 if (rc < 0)
10107 goto fail_put;
10108
10109 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10110
10111 if (IS_ERR(bt_clock)) {
10112 pr_err("Couldn't get TCXO_D0 voter\n");
10113 goto fail_switch;
10114 }
10115
10116 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10117
10118 if (rc < 0) {
10119 pr_err("Failed to vote for TCXO_DO ON\n");
10120 goto fail_vote;
10121 }
10122
10123 rc = bahama_bt(1);
10124
10125 if (rc < 0)
10126 goto fail_clock;
10127
10128 msleep(10);
10129
10130 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10131
10132 if (rc < 0) {
10133 pr_err("Failed to vote for TCXO_DO pin control\n");
10134 goto fail_vote;
10135 }
10136 } else {
10137 /* check for initial RFKILL block (power off) */
10138 /* some RFKILL versions/configurations rfkill_register */
10139 /* calls here for an initial set_block */
10140 /* avoid calling i2c and regulator before unblock (on) */
10141 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10142 dev_info(&msm_bt_power_device.dev,
10143 "%s: initialized OFF/blocked\n", __func__);
10144 goto out;
10145 }
10146
10147 bahama_bt(0);
10148
10149fail_clock:
10150 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10151fail_vote:
10152 msm_xo_put(bt_clock);
10153fail_switch:
10154 bluetooth_switch_regulators(0);
10155fail_put:
10156 bluetooth_use_regulators(0);
10157 }
10158
10159out:
10160 if (rc < 0)
10161 on = 0;
10162 dev_info(&msm_bt_power_device.dev,
10163 "Bluetooth power switch: state %d result %d\n", on, rc);
10164
10165 return rc;
10166}
10167
10168#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10169
10170static void __init msm8x60_cfg_smsc911x(void)
10171{
10172 smsc911x_resources[1].start =
10173 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10174 smsc911x_resources[1].end =
10175 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10176}
10177
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010178void msm_fusion_setup_pinctrl(void)
10179{
10180 struct msm_xo_voter *a1;
10181
10182 if (socinfo_get_platform_subtype() == 0x3) {
10183 /*
10184 * Vote for the A1 clock to be in pin control mode before
10185 * the external images are loaded.
10186 */
10187 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10188 BUG_ON(!a1);
10189 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10190 }
10191}
10192
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010193struct msm_board_data {
10194 struct msm_gpiomux_configs *gpiomux_cfgs;
10195};
10196
10197static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10198 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10199};
10200
10201static struct msm_board_data msm8x60_sim_board_data __initdata = {
10202 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10203};
10204
10205static struct msm_board_data msm8x60_surf_board_data __initdata = {
10206 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10207};
10208
10209static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10210 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10211};
10212
10213static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10214 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10215};
10216
10217static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10218 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10219};
10220
10221static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10222 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10223};
10224
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010225static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10226 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10227};
10228
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010229static void __init msm8x60_init(struct msm_board_data *board_data)
10230{
10231 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010232#ifdef CONFIG_USB_EHCI_MSM_72K
10233 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10234 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10235 .level = PM8901_MPP_DIG_LEVEL_L5,
10236 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10237 };
10238#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010239 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010240
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010241 /*
10242 * Initialize RPM first as other drivers and devices may need
10243 * it for their initialization.
10244 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010245 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10246 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010247 if (msm_xo_init())
10248 pr_err("Failed to initialize XO votes\n");
10249
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010250 msm8x60_check_2d_hardware();
10251
10252 /* Change SPM handling of core 1 if PMM 8160 is present. */
10253 soc_platform_version = socinfo_get_platform_version();
10254 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10255 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10256 struct msm_spm_platform_data *spm_data;
10257
10258 spm_data = &msm_spm_data_v1[1];
10259 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10260 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10261
10262 spm_data = &msm_spm_data[1];
10263 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10264 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10265 }
10266
10267 /*
10268 * Initialize SPM before acpuclock as the latter calls into SPM
10269 * driver to set ACPU voltages.
10270 */
10271 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10272 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10273 else
10274 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10275
10276 /*
10277 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10278 * devices so that the RPM doesn't drop into a low power mode that an
10279 * un-reworked SURF cannot resume from.
10280 */
10281 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010282 int i;
10283
10284 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10285 if (rpm_regulator_init_data[i].id
10286 == RPM_VREG_ID_PM8901_L4
10287 || rpm_regulator_init_data[i].id
10288 == RPM_VREG_ID_PM8901_L6)
10289 rpm_regulator_init_data[i]
10290 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010291 }
10292
10293 /*
10294 * Disable regulator info printing so that regulator registration
10295 * messages do not enter the kmsg log.
10296 */
10297 regulator_suppress_info_printing();
10298
10299 /* Initialize regulators needed for clock_init. */
10300 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10301
Stephen Boydbb600ae2011-08-02 20:11:40 -070010302 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010303
10304 /* Buses need to be initialized before early-device registration
10305 * to get the platform data for fabrics.
10306 */
10307 msm8x60_init_buses();
10308 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10309 /* CPU frequency control is not supported on simulated targets. */
10310 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010311 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010312
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010313 /*
10314 * Enable EBI2 only for boards which make use of it. Leave
10315 * it disabled for all others for additional power savings.
10316 */
10317 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10318 machine_is_msm8x60_rumi3() ||
10319 machine_is_msm8x60_sim() ||
10320 machine_is_msm8x60_fluid() ||
10321 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010322 msm8x60_init_ebi2();
10323 msm8x60_init_tlmm();
10324 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10325 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010326#ifdef CONFIG_MSM_CAMERA_V4L2
10327 msm8x60_init_cam();
10328#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010329 msm8x60_init_mmc();
10330
Kevin Chan3be11612012-03-22 20:05:40 -070010331
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010332#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10333 msm8x60_init_pm8058_othc();
10334#endif
10335
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010336 if (machine_is_msm8x60_fluid())
10337 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10338 else if (machine_is_msm8x60_dragon())
10339 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10340 else
10341 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010342#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010343 /* Specify reset pin for OV9726 */
10344 if (machine_is_msm8x60_dragon()) {
10345 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10346 ov9726_sensor_8660_info.mount_angle = 270;
10347 }
Kevin Chan3be11612012-03-22 20:05:40 -070010348#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010349#ifdef CONFIG_BATTERY_MSM8X60
10350 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10351 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10352 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10353 platform_device_register(&msm_charger_device);
10354#endif
10355
10356 if (machine_is_msm8x60_dragon())
10357 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10358 if (!machine_is_msm8x60_fluid())
10359 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10360
10361 /* configure pmic leds */
10362 if (machine_is_msm8x60_fluid())
10363 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10364 else if (machine_is_msm8x60_dragon())
10365 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10366 else
10367 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10368
10369 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10370 machine_is_msm8x60_dragon()) {
10371 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10372 }
10373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010374 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10375 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010376 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010377 msm8x60_cfg_smsc911x();
10378 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010379 platform_add_devices(msm8660_footswitch,
10380 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010381 platform_add_devices(surf_devices,
10382 ARRAY_SIZE(surf_devices));
10383
10384#ifdef CONFIG_MSM_DSPS
10385 if (machine_is_msm8x60_fluid()) {
10386 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10387 msm8x60_init_dsps();
10388 }
10389#endif
10390
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010391 pm8901_vreg_mpp0_init();
10392
10393 platform_device_register(&msm8x60_8901_mpp_vreg);
10394
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010395#ifdef CONFIG_USB_EHCI_MSM_72K
10396 /*
10397 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10398 * fluid
10399 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010400 if (machine_is_msm8x60_fluid())
10401 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10402 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010403#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010404
10405#ifdef CONFIG_SND_SOC_MSM8660_APQ
10406 if (machine_is_msm8x60_dragon())
10407 platform_add_devices(dragon_alsa_devices,
10408 ARRAY_SIZE(dragon_alsa_devices));
10409 else
10410#endif
10411 platform_add_devices(asoc_devices,
10412 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010413 } else {
10414 msm8x60_configure_smc91x();
10415 platform_add_devices(rumi_sim_devices,
10416 ARRAY_SIZE(rumi_sim_devices));
10417 }
10418#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010419 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10420 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010421 msm8x60_cfg_isp1763();
10422#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010423
10424 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10425 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10426
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010427
10428#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10429 if (machine_is_msm8x60_fluid())
10430 platform_device_register(&msm_gsbi10_qup_spi_device);
10431 else
10432 platform_device_register(&msm_gsbi1_qup_spi_device);
10433#endif
10434
Steve Mucklef132c6c2012-06-06 18:30:57 -070010435#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10436 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010437 if (machine_is_msm8x60_fluid())
10438 cyttsp_set_params();
10439#endif
10440 if (!machine_is_msm8x60_sim())
10441 msm_fb_add_devices();
10442 fixup_i2c_configs();
10443 register_i2c_devices();
10444
Terence Hampson1c73fef2011-07-19 17:10:49 -040010445 if (machine_is_msm8x60_dragon())
10446 smsc911x_config.reset_gpio
10447 = GPIO_ETHERNET_RESET_N_DRAGON;
10448
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010449 platform_device_register(&smsc911x_device);
10450
10451#if (defined(CONFIG_SPI_QUP)) && \
10452 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010453 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10454 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010455
10456 if (machine_is_msm8x60_fluid()) {
10457#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10458 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10459 spi_register_board_info(lcdc_samsung_spi_board_info,
10460 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10461 } else
10462#endif
10463 {
10464#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10465 spi_register_board_info(lcdc_auo_spi_board_info,
10466 ARRAY_SIZE(lcdc_auo_spi_board_info));
10467#endif
10468 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010469#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10470 } else if (machine_is_msm8x60_dragon()) {
10471 spi_register_board_info(lcdc_nt35582_spi_board_info,
10472 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10473#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010474 }
10475#endif
10476
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010477 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010478
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010479 pm8058_gpios_init();
10480
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010481#ifdef CONFIG_SENSORS_MSM_ADC
10482 if (machine_is_msm8x60_fluid()) {
10483 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10484 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10485 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10486 msm_adc_pdata.gpio_config = APROC_CONFIG;
10487 else
10488 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10489 }
10490 msm_adc_pdata.target_hw = MSM_8x60;
10491#endif
10492#ifdef CONFIG_MSM8X60_AUDIO
10493 msm_snddev_init();
10494#endif
10495#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10496 if (machine_is_msm8x60_fluid())
10497 platform_device_register(&fluid_leds_gpio);
10498 else
10499 platform_device_register(&gpio_leds);
10500#endif
10501
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010502 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010503
10504 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10505 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010506}
10507
10508static void __init msm8x60_rumi3_init(void)
10509{
10510 msm8x60_init(&msm8x60_rumi3_board_data);
10511}
10512
10513static void __init msm8x60_sim_init(void)
10514{
10515 msm8x60_init(&msm8x60_sim_board_data);
10516}
10517
10518static void __init msm8x60_surf_init(void)
10519{
10520 msm8x60_init(&msm8x60_surf_board_data);
10521}
10522
10523static void __init msm8x60_ffa_init(void)
10524{
10525 msm8x60_init(&msm8x60_ffa_board_data);
10526}
10527
10528static void __init msm8x60_fluid_init(void)
10529{
10530 msm8x60_init(&msm8x60_fluid_board_data);
10531}
10532
10533static void __init msm8x60_charm_surf_init(void)
10534{
10535 msm8x60_init(&msm8x60_charm_surf_board_data);
10536}
10537
10538static void __init msm8x60_charm_ffa_init(void)
10539{
10540 msm8x60_init(&msm8x60_charm_ffa_board_data);
10541}
10542
10543static void __init msm8x60_charm_init_early(void)
10544{
10545 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010546}
10547
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010548static void __init msm8x60_dragon_init(void)
10549{
10550 msm8x60_init(&msm8x60_dragon_board_data);
10551}
David Brown56e2d8a2011-08-04 02:01:02 -070010552
Steve Mucklea55df6e2010-01-07 12:43:24 -080010553MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10554 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010555 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010556 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010557 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010558 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010559 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010560 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010561MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010562
10563MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10564 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010565 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010566 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010567 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010568 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010569 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010570 .init_early = msm8x60_charm_init_early,
10571MACHINE_END
10572
10573MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10574 .map_io = msm8x60_map_io,
10575 .reserve = msm8x60_reserve,
10576 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010577 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010578 .init_machine = msm8x60_surf_init,
10579 .timer = &msm_timer,
10580 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010581MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010582
10583MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10584 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010585 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010586 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010587 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010588 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010589 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010590 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010591MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010592
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010593MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010594 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010595 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010596 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010597 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010598 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010599 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010600 .init_early = msm8x60_charm_init_early,
David Brown56e2d8a2011-08-04 02:01:02 -070010601MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010602
10603MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10604 .map_io = msm8x60_map_io,
10605 .reserve = msm8x60_reserve,
10606 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010607 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010608 .init_machine = msm8x60_charm_surf_init,
10609 .timer = &msm_timer,
10610 .init_early = msm8x60_charm_init_early,
10611MACHINE_END
10612
10613MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10614 .map_io = msm8x60_map_io,
10615 .reserve = msm8x60_reserve,
10616 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010617 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010618 .init_machine = msm8x60_charm_ffa_init,
10619 .timer = &msm_timer,
10620 .init_early = msm8x60_charm_init_early,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010621MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010622
10623MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10624 .map_io = msm8x60_map_io,
10625 .reserve = msm8x60_reserve,
10626 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010627 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010628 .init_machine = msm8x60_dragon_init,
10629 .timer = &msm_timer,
10630 .init_early = msm8x60_charm_init_early,
10631MACHINE_END