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