blob: b0799c259deae890c558a8560cd503d76bc0bb7c [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)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002642#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002643
2644#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2645#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2646#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2647
Naseer Ahmed51860b02012-02-07 18:53:29 +05302648#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002649#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Olav Haugan42ebe712012-01-10 16:30:58 -08002650#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
Olav Haugan8726caf2012-05-10 15:11:35 -07002651#define MSM_ION_MM_SIZE 0x3600000 /* (54MB) Must be a multiple of 64K */
Olav Hauganb5be7992011-11-18 14:29:02 -08002652#define MSM_ION_MFC_SIZE SZ_8K
Mayank Choprac22ace32012-03-03 00:45:04 +05302653#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2654#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2655#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002656#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302657#endif
2658
Olav Haugan424ff492012-03-13 11:41:23 -07002659#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002660
2661#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302662#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002663#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002664#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2665static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002666#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002667#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002668#endif
2669
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002670static unsigned fb_size;
2671static int __init fb_size_setup(char *p)
2672{
2673 fb_size = memparse(p, NULL);
2674 return 0;
2675}
2676early_param("fb_size", fb_size_setup);
2677
2678static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2679static int __init pmem_kernel_ebi1_size_setup(char *p)
2680{
2681 pmem_kernel_ebi1_size = memparse(p, NULL);
2682 return 0;
2683}
2684early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2685
2686#ifdef CONFIG_ANDROID_PMEM
2687static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2688static int __init pmem_sf_size_setup(char *p)
2689{
2690 pmem_sf_size = memparse(p, NULL);
2691 return 0;
2692}
2693early_param("pmem_sf_size", pmem_sf_size_setup);
2694
2695static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2696
2697static int __init pmem_adsp_size_setup(char *p)
2698{
2699 pmem_adsp_size = memparse(p, NULL);
2700 return 0;
2701}
2702early_param("pmem_adsp_size", pmem_adsp_size_setup);
2703
2704static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2705
2706static int __init pmem_audio_size_setup(char *p)
2707{
2708 pmem_audio_size = memparse(p, NULL);
2709 return 0;
2710}
2711early_param("pmem_audio_size", pmem_audio_size_setup);
2712#endif
2713
2714static struct resource msm_fb_resources[] = {
2715 {
2716 .flags = IORESOURCE_DMA,
2717 }
2718};
2719
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002720static void set_mdp_clocks_for_wuxga(void);
2721
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002722static int msm_fb_detect_panel(const char *name)
2723{
2724 if (machine_is_msm8x60_fluid()) {
2725 uint32_t soc_platform_version = socinfo_get_platform_version();
2726 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2727#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2728 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002729 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2730 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002731 return 0;
2732#endif
2733 } else { /*P3 and up use AUO panel */
2734#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2735 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002736 strnlen(LCDC_AUO_PANEL_NAME,
2737 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002738 return 0;
2739#endif
2740 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002741#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2742 } else if machine_is_msm8x60_dragon() {
2743 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002744 strnlen(LCDC_NT35582_PANEL_NAME,
2745 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002746 return 0;
2747#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002748 } else {
2749 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002750 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2751 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002752 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002753
2754#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2755 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2756 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2757 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2758 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2759 PANEL_NAME_MAX_LEN)))
2760 return 0;
2761
2762 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2763 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2764 PANEL_NAME_MAX_LEN)))
2765 return 0;
2766
2767 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2768 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2769 PANEL_NAME_MAX_LEN)))
2770 return 0;
2771#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002772 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002773
2774 if (!strncmp(name, HDMI_PANEL_NAME,
2775 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002776 PANEL_NAME_MAX_LEN))) {
2777 if (hdmi_is_primary)
2778 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002779 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002780 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002781
2782 if (!strncmp(name, TVOUT_PANEL_NAME,
2783 strnlen(TVOUT_PANEL_NAME,
2784 PANEL_NAME_MAX_LEN)))
2785 return 0;
2786
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002787 pr_warning("%s: not supported '%s'", __func__, name);
2788 return -ENODEV;
2789}
2790
2791static struct msm_fb_platform_data msm_fb_pdata = {
2792 .detect_client = msm_fb_detect_panel,
2793};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002794
2795static struct platform_device msm_fb_device = {
2796 .name = "msm_fb",
2797 .id = 0,
2798 .num_resources = ARRAY_SIZE(msm_fb_resources),
2799 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002800 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002801};
2802
2803#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002804#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805static struct android_pmem_platform_data android_pmem_pdata = {
2806 .name = "pmem",
2807 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2808 .cached = 1,
2809 .memory_type = MEMTYPE_EBI1,
2810};
2811
2812static struct platform_device android_pmem_device = {
2813 .name = "android_pmem",
2814 .id = 0,
2815 .dev = {.platform_data = &android_pmem_pdata},
2816};
2817
2818static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2819 .name = "pmem_adsp",
2820 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2821 .cached = 0,
2822 .memory_type = MEMTYPE_EBI1,
2823};
2824
2825static struct platform_device android_pmem_adsp_device = {
2826 .name = "android_pmem",
2827 .id = 2,
2828 .dev = { .platform_data = &android_pmem_adsp_pdata },
2829};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302830
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002831static struct android_pmem_platform_data android_pmem_audio_pdata = {
2832 .name = "pmem_audio",
2833 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2834 .cached = 0,
2835 .memory_type = MEMTYPE_EBI1,
2836};
2837
2838static struct platform_device android_pmem_audio_device = {
2839 .name = "android_pmem",
2840 .id = 4,
2841 .dev = { .platform_data = &android_pmem_audio_pdata },
2842};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302843#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002844#define PMEM_BUS_WIDTH(_bw) \
2845 { \
2846 .vectors = &(struct msm_bus_vectors){ \
2847 .src = MSM_BUS_MASTER_AMPSS_M0, \
2848 .dst = MSM_BUS_SLAVE_SMI, \
2849 .ib = (_bw), \
2850 .ab = 0, \
2851 }, \
2852 .num_paths = 1, \
2853 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002854
2855static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002856 [0] = PMEM_BUS_WIDTH(0), /* Off */
2857 [1] = PMEM_BUS_WIDTH(1), /* On */
2858};
2859
2860static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002861 .usecase = mem_smi_table,
2862 .num_usecases = ARRAY_SIZE(mem_smi_table),
2863 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002864};
2865
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002866int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002867{
2868 int bus_id = (int) data;
2869
2870 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002871 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002872}
2873
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002874int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002875{
2876 int bus_id = (int) data;
2877
2878 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002879 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002880}
2881
Alex Bird199980e2011-10-21 11:29:27 -07002882void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002883{
2884 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2885}
Olav Hauganee0f7802011-12-19 13:28:57 -08002886#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2888 .name = "pmem_smipool",
2889 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2890 .cached = 0,
2891 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002892 .request_region = request_smi_region,
2893 .release_region = release_smi_region,
2894 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002895 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002896};
2897static struct platform_device android_pmem_smipool_device = {
2898 .name = "android_pmem",
2899 .id = 7,
2900 .dev = { .platform_data = &android_pmem_smipool_pdata },
2901};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302902#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2903#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002904
2905#define GPIO_DONGLE_PWR_EN 258
2906static void setup_display_power(void);
2907static int lcdc_vga_enabled;
2908static int vga_enable_request(int enable)
2909{
2910 if (enable)
2911 lcdc_vga_enabled = 1;
2912 else
2913 lcdc_vga_enabled = 0;
2914 setup_display_power();
2915
2916 return 0;
2917}
2918
2919#define GPIO_BACKLIGHT_PWM0 0
2920#define GPIO_BACKLIGHT_PWM1 1
2921
2922static int pmic_backlight_gpio[2]
2923 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2924static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2925 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2926 .vga_switch = vga_enable_request,
2927};
2928
2929static struct platform_device lcdc_samsung_panel_device = {
2930 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2931 .id = 0,
2932 .dev = {
2933 .platform_data = &lcdc_samsung_panel_data,
2934 }
2935};
2936#if (!defined(CONFIG_SPI_QUP)) && \
2937 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2938 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2939
2940static int lcdc_spi_gpio_array_num[] = {
2941 LCDC_SPI_GPIO_CLK,
2942 LCDC_SPI_GPIO_CS,
2943 LCDC_SPI_GPIO_MOSI,
2944};
2945
2946static uint32_t lcdc_spi_gpio_config_data[] = {
2947 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2948 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2949 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2950 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2951 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2952 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2953};
2954
2955static void lcdc_config_spi_gpios(int enable)
2956{
2957 int n;
2958 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2959 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2960}
2961#endif
2962
2963#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2964#ifdef CONFIG_SPI_QUP
2965static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2966 {
2967 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2968 .mode = SPI_MODE_3,
2969 .bus_num = 1,
2970 .chip_select = 0,
2971 .max_speed_hz = 10800000,
2972 }
2973};
2974#endif /* CONFIG_SPI_QUP */
2975
2976static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2977#ifndef CONFIG_SPI_QUP
2978 .panel_config_gpio = lcdc_config_spi_gpios,
2979 .gpio_num = lcdc_spi_gpio_array_num,
2980#endif
2981};
2982
2983static struct platform_device lcdc_samsung_oled_panel_device = {
2984 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2985 .id = 0,
2986 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2987};
2988#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2989
2990#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2991#ifdef CONFIG_SPI_QUP
2992static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
2993 {
2994 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
2995 .mode = SPI_MODE_3,
2996 .bus_num = 1,
2997 .chip_select = 0,
2998 .max_speed_hz = 10800000,
2999 }
3000};
3001#endif
3002
3003static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3004#ifndef CONFIG_SPI_QUP
3005 .panel_config_gpio = lcdc_config_spi_gpios,
3006 .gpio_num = lcdc_spi_gpio_array_num,
3007#endif
3008};
3009
3010static struct platform_device lcdc_auo_wvga_panel_device = {
3011 .name = LCDC_AUO_PANEL_NAME,
3012 .id = 0,
3013 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3014};
3015#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3016
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003017#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3018
3019#define GPIO_NT35582_RESET 94
3020#define GPIO_NT35582_BL_EN_HW_PIN 24
3021#define GPIO_NT35582_BL_EN \
3022 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3023
3024static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3025
3026static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3027 .gpio_num = lcdc_nt35582_pmic_gpio,
3028};
3029
3030static struct platform_device lcdc_nt35582_panel_device = {
3031 .name = LCDC_NT35582_PANEL_NAME,
3032 .id = 0,
3033 .dev = {
3034 .platform_data = &lcdc_nt35582_panel_data,
3035 }
3036};
3037
3038static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3039 {
3040 .modalias = "lcdc_nt35582_spi",
3041 .mode = SPI_MODE_0,
3042 .bus_num = 0,
3043 .chip_select = 0,
3044 .max_speed_hz = 1100000,
3045 }
3046};
3047#endif
3048
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003049#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3050static struct resource hdmi_msm_resources[] = {
3051 {
3052 .name = "hdmi_msm_qfprom_addr",
3053 .start = 0x00700000,
3054 .end = 0x007060FF,
3055 .flags = IORESOURCE_MEM,
3056 },
3057 {
3058 .name = "hdmi_msm_hdmi_addr",
3059 .start = 0x04A00000,
3060 .end = 0x04A00FFF,
3061 .flags = IORESOURCE_MEM,
3062 },
3063 {
3064 .name = "hdmi_msm_irq",
3065 .start = HDMI_IRQ,
3066 .end = HDMI_IRQ,
3067 .flags = IORESOURCE_IRQ,
3068 },
3069};
3070
3071static int hdmi_enable_5v(int on);
3072static int hdmi_core_power(int on, int show);
3073static int hdmi_cec_power(int on);
3074
3075static struct msm_hdmi_platform_data hdmi_msm_data = {
3076 .irq = HDMI_IRQ,
3077 .enable_5v = hdmi_enable_5v,
3078 .core_power = hdmi_core_power,
3079 .cec_power = hdmi_cec_power,
3080};
3081
3082static struct platform_device hdmi_msm_device = {
3083 .name = "hdmi_msm",
3084 .id = 0,
3085 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3086 .resource = hdmi_msm_resources,
3087 .dev.platform_data = &hdmi_msm_data,
3088};
3089#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3090
3091#ifdef CONFIG_FB_MSM_MIPI_DSI
3092static struct platform_device mipi_dsi_toshiba_panel_device = {
3093 .name = "mipi_toshiba",
3094 .id = 0,
3095};
3096
3097#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3098
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003099static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003100 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003101 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102};
3103
3104static struct platform_device mipi_dsi_novatek_panel_device = {
3105 .name = "mipi_novatek",
3106 .id = 0,
3107 .dev = {
3108 .platform_data = &novatek_pdata,
3109 }
3110};
3111#endif
3112
3113static void __init msm8x60_allocate_memory_regions(void)
3114{
3115 void *addr;
3116 unsigned long size;
3117
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003118 if (hdmi_is_primary)
3119 size = roundup((1920 * 1088 * 4 * 2), 4096);
3120 else
3121 size = MSM_FB_SIZE;
3122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003123 addr = alloc_bootmem_align(size, 0x1000);
3124 msm_fb_resources[0].start = __pa(addr);
3125 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3126 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3127 size, addr, __pa(addr));
3128
3129}
3130
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003131void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3132{
3133 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3134 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3135 PANEL_NAME_MAX_LEN);
3136 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3137 msm_fb_pdata.prim_panel_name);
3138
3139 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3140 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3141 PANEL_NAME_MAX_LEN))) {
3142 pr_debug("HDMI is the primary display by"
3143 " boot parameter\n");
3144 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003145 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003146 }
3147 }
3148 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3149 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3150 PANEL_NAME_MAX_LEN);
3151 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3152 msm_fb_pdata.ext_panel_name);
3153 }
3154}
3155
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003156#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3157 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3158/*virtual key support */
3159static ssize_t tma300_vkeys_show(struct kobject *kobj,
3160 struct kobj_attribute *attr, char *buf)
3161{
3162 return sprintf(buf,
3163 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3164 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3165 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3166 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3167 "\n");
3168}
3169
3170static struct kobj_attribute tma300_vkeys_attr = {
3171 .attr = {
3172 .mode = S_IRUGO,
3173 },
3174 .show = &tma300_vkeys_show,
3175};
3176
3177static struct attribute *tma300_properties_attrs[] = {
3178 &tma300_vkeys_attr.attr,
3179 NULL
3180};
3181
3182static struct attribute_group tma300_properties_attr_group = {
3183 .attrs = tma300_properties_attrs,
3184};
3185
3186static struct kobject *properties_kobj;
3187
3188
3189
3190#define CYTTSP_TS_GPIO_IRQ 61
3191static int cyttsp_platform_init(struct i2c_client *client)
3192{
3193 int rc = -EINVAL;
3194 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3195
3196 if (machine_is_msm8x60_fluid()) {
3197 pm8058_l5 = regulator_get(NULL, "8058_l5");
3198 if (IS_ERR(pm8058_l5)) {
3199 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3200 __func__, PTR_ERR(pm8058_l5));
3201 rc = PTR_ERR(pm8058_l5);
3202 return rc;
3203 }
3204 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3205 if (rc) {
3206 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3207 __func__, rc);
3208 goto reg_l5_put;
3209 }
3210
3211 rc = regulator_enable(pm8058_l5);
3212 if (rc) {
3213 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3214 __func__, rc);
3215 goto reg_l5_put;
3216 }
3217 }
3218 /* vote for s3 to enable i2c communication lines */
3219 pm8058_s3 = regulator_get(NULL, "8058_s3");
3220 if (IS_ERR(pm8058_s3)) {
3221 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3222 __func__, PTR_ERR(pm8058_s3));
3223 rc = PTR_ERR(pm8058_s3);
3224 goto reg_l5_disable;
3225 }
3226
3227 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3228 if (rc) {
3229 pr_err("%s: regulator_set_voltage() = %d\n",
3230 __func__, rc);
3231 goto reg_s3_put;
3232 }
3233
3234 rc = regulator_enable(pm8058_s3);
3235 if (rc) {
3236 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3237 __func__, rc);
3238 goto reg_s3_put;
3239 }
3240
3241 /* wait for vregs to stabilize */
3242 usleep_range(10000, 10000);
3243
3244 /* check this device active by reading first byte/register */
3245 rc = i2c_smbus_read_byte_data(client, 0x01);
3246 if (rc < 0) {
3247 pr_err("%s: i2c sanity check failed\n", __func__);
3248 goto reg_s3_disable;
3249 }
3250
3251 /* virtual keys */
3252 if (machine_is_msm8x60_fluid()) {
3253 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3254 properties_kobj = kobject_create_and_add("board_properties",
3255 NULL);
3256 if (properties_kobj)
3257 rc = sysfs_create_group(properties_kobj,
3258 &tma300_properties_attr_group);
3259 if (!properties_kobj || rc)
3260 pr_err("%s: failed to create board_properties\n",
3261 __func__);
3262 }
3263 return CY_OK;
3264
3265reg_s3_disable:
3266 regulator_disable(pm8058_s3);
3267reg_s3_put:
3268 regulator_put(pm8058_s3);
3269reg_l5_disable:
3270 if (machine_is_msm8x60_fluid())
3271 regulator_disable(pm8058_l5);
3272reg_l5_put:
3273 if (machine_is_msm8x60_fluid())
3274 regulator_put(pm8058_l5);
3275 return rc;
3276}
3277
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303278/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3279static int cyttsp_platform_suspend(struct i2c_client *client)
3280{
3281 msleep(20);
3282
3283 return CY_OK;
3284}
3285
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003286static int cyttsp_platform_resume(struct i2c_client *client)
3287{
3288 /* add any special code to strobe a wakeup pin or chip reset */
3289 msleep(10);
3290
3291 return CY_OK;
3292}
3293
3294static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3295 .flags = 0x04,
3296 .gen = CY_GEN3, /* or */
3297 .use_st = CY_USE_ST,
3298 .use_mt = CY_USE_MT,
3299 .use_hndshk = CY_SEND_HNDSHK,
3300 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303301 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003302 .use_gestures = CY_USE_GESTURES,
3303 /* activate up to 4 groups
3304 * and set active distance
3305 */
3306 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3307 CY_GEST_GRP3 | CY_GEST_GRP4 |
3308 CY_ACT_DIST,
3309 /* change act_intrvl to customize the Active power state
3310 * scanning/processing refresh interval for Operating mode
3311 */
3312 .act_intrvl = CY_ACT_INTRVL_DFLT,
3313 /* change tch_tmout to customize the touch timeout for the
3314 * Active power state for Operating mode
3315 */
3316 .tch_tmout = CY_TCH_TMOUT_DFLT,
3317 /* change lp_intrvl to customize the Low Power power state
3318 * scanning/processing refresh interval for Operating mode
3319 */
3320 .lp_intrvl = CY_LP_INTRVL_DFLT,
3321 .sleep_gpio = -1,
3322 .resout_gpio = -1,
3323 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3324 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303325 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003326 .init = cyttsp_platform_init,
3327};
3328
3329static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3330 .panel_maxx = 1083,
3331 .panel_maxy = 659,
3332 .disp_minx = 30,
3333 .disp_maxx = 1053,
3334 .disp_miny = 30,
3335 .disp_maxy = 629,
3336 .correct_fw_ver = 8,
3337 .fw_fname = "cyttsp_8660_ffa.hex",
3338 .flags = 0x00,
3339 .gen = CY_GEN2, /* or */
3340 .use_st = CY_USE_ST,
3341 .use_mt = CY_USE_MT,
3342 .use_hndshk = CY_SEND_HNDSHK,
3343 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303344 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003345 .use_gestures = CY_USE_GESTURES,
3346 /* activate up to 4 groups
3347 * and set active distance
3348 */
3349 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3350 CY_GEST_GRP3 | CY_GEST_GRP4 |
3351 CY_ACT_DIST,
3352 /* change act_intrvl to customize the Active power state
3353 * scanning/processing refresh interval for Operating mode
3354 */
3355 .act_intrvl = CY_ACT_INTRVL_DFLT,
3356 /* change tch_tmout to customize the touch timeout for the
3357 * Active power state for Operating mode
3358 */
3359 .tch_tmout = CY_TCH_TMOUT_DFLT,
3360 /* change lp_intrvl to customize the Low Power power state
3361 * scanning/processing refresh interval for Operating mode
3362 */
3363 .lp_intrvl = CY_LP_INTRVL_DFLT,
3364 .sleep_gpio = -1,
3365 .resout_gpio = -1,
3366 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3367 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303368 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003369 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303370 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003371};
3372static void cyttsp_set_params(void)
3373{
3374 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3375 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3376 cyttsp_fluid_pdata.panel_maxx = 539;
3377 cyttsp_fluid_pdata.panel_maxy = 994;
3378 cyttsp_fluid_pdata.disp_minx = 30;
3379 cyttsp_fluid_pdata.disp_maxx = 509;
3380 cyttsp_fluid_pdata.disp_miny = 60;
3381 cyttsp_fluid_pdata.disp_maxy = 859;
3382 cyttsp_fluid_pdata.correct_fw_ver = 4;
3383 } else {
3384 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3385 cyttsp_fluid_pdata.panel_maxx = 550;
3386 cyttsp_fluid_pdata.panel_maxy = 1013;
3387 cyttsp_fluid_pdata.disp_minx = 35;
3388 cyttsp_fluid_pdata.disp_maxx = 515;
3389 cyttsp_fluid_pdata.disp_miny = 69;
3390 cyttsp_fluid_pdata.disp_maxy = 869;
3391 cyttsp_fluid_pdata.correct_fw_ver = 5;
3392 }
3393
3394}
3395
3396static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3397 {
3398 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3399 .platform_data = &cyttsp_fluid_pdata,
3400#ifndef CY_USE_TIMER
3401 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3402#endif /* CY_USE_TIMER */
3403 },
3404};
3405
3406static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3407 {
3408 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3409 .platform_data = &cyttsp_tmg240_pdata,
3410#ifndef CY_USE_TIMER
3411 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3412#endif /* CY_USE_TIMER */
3413 },
3414};
3415#endif
3416
3417static struct regulator *vreg_tmg200;
3418
3419#define TS_PEN_IRQ_GPIO 61
3420static int tmg200_power(int vreg_on)
3421{
3422 int rc = -EINVAL;
3423
3424 if (!vreg_tmg200) {
3425 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3426 __func__, rc);
3427 return rc;
3428 }
3429
3430 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3431 regulator_disable(vreg_tmg200);
3432 if (rc < 0)
3433 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3434 __func__, vreg_on ? "enable" : "disable", rc);
3435
3436 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003437 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003438
3439 return rc;
3440}
3441
3442static int tmg200_dev_setup(bool enable)
3443{
3444 int rc;
3445
3446 if (enable) {
3447 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3448 if (IS_ERR(vreg_tmg200)) {
3449 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3450 __func__, PTR_ERR(vreg_tmg200));
3451 rc = PTR_ERR(vreg_tmg200);
3452 return rc;
3453 }
3454
3455 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3456 if (rc) {
3457 pr_err("%s: regulator_set_voltage() = %d\n",
3458 __func__, rc);
3459 goto reg_put;
3460 }
3461 } else {
3462 /* put voltage sources */
3463 regulator_put(vreg_tmg200);
3464 }
3465 return 0;
3466reg_put:
3467 regulator_put(vreg_tmg200);
3468 return rc;
3469}
3470
3471static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3472 .ts_name = "msm_tmg200_ts",
3473 .dis_min_x = 0,
3474 .dis_max_x = 1023,
3475 .dis_min_y = 0,
3476 .dis_max_y = 599,
3477 .min_tid = 0,
3478 .max_tid = 255,
3479 .min_touch = 0,
3480 .max_touch = 255,
3481 .min_width = 0,
3482 .max_width = 255,
3483 .power_on = tmg200_power,
3484 .dev_setup = tmg200_dev_setup,
3485 .nfingers = 2,
3486 .irq_gpio = TS_PEN_IRQ_GPIO,
3487 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3488};
3489
3490static struct i2c_board_info cy8ctmg200_board_info[] = {
3491 {
3492 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3493 .platform_data = &cy8ctmg200_pdata,
3494 }
3495};
3496
Zhang Chang Ken211df572011-07-05 19:16:39 -04003497static struct regulator *vreg_tma340;
3498
3499static int tma340_power(int vreg_on)
3500{
3501 int rc = -EINVAL;
3502
3503 if (!vreg_tma340) {
3504 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3505 __func__, rc);
3506 return rc;
3507 }
3508
3509 rc = vreg_on ? regulator_enable(vreg_tma340) :
3510 regulator_disable(vreg_tma340);
3511 if (rc < 0)
3512 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3513 __func__, vreg_on ? "enable" : "disable", rc);
3514
3515 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003516 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003517
3518 return rc;
3519}
3520
3521static struct kobject *tma340_prop_kobj;
3522
3523static int tma340_dragon_dev_setup(bool enable)
3524{
3525 int rc;
3526
3527 if (enable) {
3528 vreg_tma340 = regulator_get(NULL, "8901_l2");
3529 if (IS_ERR(vreg_tma340)) {
3530 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3531 __func__, PTR_ERR(vreg_tma340));
3532 rc = PTR_ERR(vreg_tma340);
3533 return rc;
3534 }
3535
3536 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3537 if (rc) {
3538 pr_err("%s: regulator_set_voltage() = %d\n",
3539 __func__, rc);
3540 goto reg_put;
3541 }
3542 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3543 tma340_prop_kobj = kobject_create_and_add("board_properties",
3544 NULL);
3545 if (tma340_prop_kobj) {
3546 rc = sysfs_create_group(tma340_prop_kobj,
3547 &tma300_properties_attr_group);
3548 if (rc) {
3549 kobject_put(tma340_prop_kobj);
3550 pr_err("%s: failed to create board_properties\n",
3551 __func__);
3552 goto reg_put;
3553 }
3554 }
3555
3556 } else {
3557 /* put voltage sources */
3558 regulator_put(vreg_tma340);
3559 /* destroy virtual keys */
3560 if (tma340_prop_kobj) {
3561 sysfs_remove_group(tma340_prop_kobj,
3562 &tma300_properties_attr_group);
3563 kobject_put(tma340_prop_kobj);
3564 }
3565 }
3566 return 0;
3567reg_put:
3568 regulator_put(vreg_tma340);
3569 return rc;
3570}
3571
3572
3573static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3574 .ts_name = "cy8ctma340",
3575 .dis_min_x = 0,
3576 .dis_max_x = 479,
3577 .dis_min_y = 0,
3578 .dis_max_y = 799,
3579 .min_tid = 0,
3580 .max_tid = 255,
3581 .min_touch = 0,
3582 .max_touch = 255,
3583 .min_width = 0,
3584 .max_width = 255,
3585 .power_on = tma340_power,
3586 .dev_setup = tma340_dragon_dev_setup,
3587 .nfingers = 2,
3588 .irq_gpio = TS_PEN_IRQ_GPIO,
3589 .resout_gpio = -1,
3590};
3591
3592static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3593 {
3594 I2C_BOARD_INFO("cy8ctma340", 0x24),
3595 .platform_data = &cy8ctma340_dragon_pdata,
3596 }
3597};
3598
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003599#ifdef CONFIG_SERIAL_MSM_HS
3600static int configure_uart_gpios(int on)
3601{
3602 int ret = 0, i;
3603 int uart_gpios[] = {53, 54, 55, 56};
3604 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3605 if (on) {
3606 ret = msm_gpiomux_get(uart_gpios[i]);
3607 if (unlikely(ret))
3608 break;
3609 } else {
3610 ret = msm_gpiomux_put(uart_gpios[i]);
3611 if (unlikely(ret))
3612 return ret;
3613 }
3614 }
3615 if (ret)
3616 for (; i >= 0; i--)
3617 msm_gpiomux_put(uart_gpios[i]);
3618 return ret;
3619}
3620static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3621 .inject_rx_on_wakeup = 1,
3622 .rx_to_inject = 0xFD,
3623 .gpio_config = configure_uart_gpios,
3624};
3625#endif
3626
3627
3628#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3629
3630static struct gpio_led gpio_exp_leds_config[] = {
3631 {
3632 .name = "left_led1:green",
3633 .gpio = GPIO_LEFT_LED_1,
3634 .active_low = 1,
3635 .retain_state_suspended = 0,
3636 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3637 },
3638 {
3639 .name = "left_led2:red",
3640 .gpio = GPIO_LEFT_LED_2,
3641 .active_low = 1,
3642 .retain_state_suspended = 0,
3643 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3644 },
3645 {
3646 .name = "left_led3:green",
3647 .gpio = GPIO_LEFT_LED_3,
3648 .active_low = 1,
3649 .retain_state_suspended = 0,
3650 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3651 },
3652 {
3653 .name = "wlan_led:orange",
3654 .gpio = GPIO_LEFT_LED_WLAN,
3655 .active_low = 1,
3656 .retain_state_suspended = 0,
3657 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3658 },
3659 {
3660 .name = "left_led5:green",
3661 .gpio = GPIO_LEFT_LED_5,
3662 .active_low = 1,
3663 .retain_state_suspended = 0,
3664 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3665 },
3666 {
3667 .name = "right_led1:green",
3668 .gpio = GPIO_RIGHT_LED_1,
3669 .active_low = 1,
3670 .retain_state_suspended = 0,
3671 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3672 },
3673 {
3674 .name = "right_led2:red",
3675 .gpio = GPIO_RIGHT_LED_2,
3676 .active_low = 1,
3677 .retain_state_suspended = 0,
3678 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3679 },
3680 {
3681 .name = "right_led3:green",
3682 .gpio = GPIO_RIGHT_LED_3,
3683 .active_low = 1,
3684 .retain_state_suspended = 0,
3685 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3686 },
3687 {
3688 .name = "bt_led:blue",
3689 .gpio = GPIO_RIGHT_LED_BT,
3690 .active_low = 1,
3691 .retain_state_suspended = 0,
3692 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3693 },
3694 {
3695 .name = "right_led5:green",
3696 .gpio = GPIO_RIGHT_LED_5,
3697 .active_low = 1,
3698 .retain_state_suspended = 0,
3699 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3700 },
3701};
3702
3703static struct gpio_led_platform_data gpio_leds_pdata = {
3704 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3705 .leds = gpio_exp_leds_config,
3706};
3707
3708static struct platform_device gpio_leds = {
3709 .name = "leds-gpio",
3710 .id = -1,
3711 .dev = {
3712 .platform_data = &gpio_leds_pdata,
3713 },
3714};
3715
3716static struct gpio_led fluid_gpio_leds[] = {
3717 {
3718 .name = "dual_led:green",
3719 .gpio = GPIO_LED1_GREEN_N,
3720 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3721 .active_low = 1,
3722 .retain_state_suspended = 0,
3723 },
3724 {
3725 .name = "dual_led:red",
3726 .gpio = GPIO_LED2_RED_N,
3727 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3728 .active_low = 1,
3729 .retain_state_suspended = 0,
3730 },
3731};
3732
3733static struct gpio_led_platform_data gpio_led_pdata = {
3734 .leds = fluid_gpio_leds,
3735 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3736};
3737
3738static struct platform_device fluid_leds_gpio = {
3739 .name = "leds-gpio",
3740 .id = -1,
3741 .dev = {
3742 .platform_data = &gpio_led_pdata,
3743 },
3744};
3745
3746#endif
3747
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003748#ifdef CONFIG_BATTERY_MSM8X60
3749static struct msm_charger_platform_data msm_charger_data = {
3750 .safety_time = 180,
3751 .update_time = 1,
3752 .max_voltage = 4200,
3753 .min_voltage = 3200,
3754};
3755
3756static struct platform_device msm_charger_device = {
3757 .name = "msm-charger",
3758 .id = -1,
3759 .dev = {
3760 .platform_data = &msm_charger_data,
3761 }
3762};
3763#endif
3764
3765/*
3766 * Consumer specific regulator names:
3767 * regulator name consumer dev_name
3768 */
3769static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3770 REGULATOR_SUPPLY("8058_l0", NULL),
3771};
3772static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3773 REGULATOR_SUPPLY("8058_l1", NULL),
3774};
3775static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3776 REGULATOR_SUPPLY("8058_l2", NULL),
3777};
3778static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3779 REGULATOR_SUPPLY("8058_l3", NULL),
3780};
3781static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3782 REGULATOR_SUPPLY("8058_l4", NULL),
3783};
3784static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3785 REGULATOR_SUPPLY("8058_l5", NULL),
3786};
3787static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3788 REGULATOR_SUPPLY("8058_l6", NULL),
3789};
3790static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3791 REGULATOR_SUPPLY("8058_l7", NULL),
3792};
3793static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3794 REGULATOR_SUPPLY("8058_l8", NULL),
3795};
3796static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3797 REGULATOR_SUPPLY("8058_l9", NULL),
3798};
3799static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3800 REGULATOR_SUPPLY("8058_l10", NULL),
3801};
3802static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3803 REGULATOR_SUPPLY("8058_l11", NULL),
3804};
3805static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3806 REGULATOR_SUPPLY("8058_l12", NULL),
3807};
3808static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3809 REGULATOR_SUPPLY("8058_l13", NULL),
3810};
3811static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3812 REGULATOR_SUPPLY("8058_l14", NULL),
3813};
3814static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3815 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003816 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003817 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003818 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003819};
3820static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3821 REGULATOR_SUPPLY("8058_l16", NULL),
3822};
3823static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3824 REGULATOR_SUPPLY("8058_l17", NULL),
3825};
3826static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3827 REGULATOR_SUPPLY("8058_l18", NULL),
3828};
3829static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3830 REGULATOR_SUPPLY("8058_l19", NULL),
3831};
3832static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3833 REGULATOR_SUPPLY("8058_l20", NULL),
3834};
3835static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3836 REGULATOR_SUPPLY("8058_l21", NULL),
3837};
3838static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3839 REGULATOR_SUPPLY("8058_l22", NULL),
3840};
3841static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3842 REGULATOR_SUPPLY("8058_l23", NULL),
3843};
3844static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3845 REGULATOR_SUPPLY("8058_l24", NULL),
3846};
3847static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3848 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003849 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003850 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003851 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003852};
3853static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3854 REGULATOR_SUPPLY("8058_s0", NULL),
3855};
3856static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3857 REGULATOR_SUPPLY("8058_s1", NULL),
3858};
3859static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3860 REGULATOR_SUPPLY("8058_s2", NULL),
3861};
3862static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3863 REGULATOR_SUPPLY("8058_s3", NULL),
3864};
3865static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3866 REGULATOR_SUPPLY("8058_s4", NULL),
3867};
3868static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3869 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003870 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003871 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003872 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003873};
3874static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3875 REGULATOR_SUPPLY("8058_lvs1", NULL),
3876};
3877static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3878 REGULATOR_SUPPLY("8058_ncp", NULL),
3879};
3880
3881static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3882 REGULATOR_SUPPLY("8901_l0", NULL),
3883};
3884static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3885 REGULATOR_SUPPLY("8901_l1", NULL),
3886};
3887static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3888 REGULATOR_SUPPLY("8901_l2", NULL),
3889};
3890static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3891 REGULATOR_SUPPLY("8901_l3", NULL),
3892};
3893static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3894 REGULATOR_SUPPLY("8901_l4", NULL),
3895};
3896static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3897 REGULATOR_SUPPLY("8901_l5", NULL),
3898};
3899static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3900 REGULATOR_SUPPLY("8901_l6", NULL),
3901};
3902static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3903 REGULATOR_SUPPLY("8901_s2", NULL),
3904};
3905static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3906 REGULATOR_SUPPLY("8901_s3", NULL),
3907};
3908static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3909 REGULATOR_SUPPLY("8901_s4", NULL),
3910};
3911static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3912 REGULATOR_SUPPLY("8901_lvs0", NULL),
3913};
3914static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3915 REGULATOR_SUPPLY("8901_lvs1", NULL),
3916};
3917static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3918 REGULATOR_SUPPLY("8901_lvs2", NULL),
3919};
3920static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3921 REGULATOR_SUPPLY("8901_lvs3", NULL),
3922};
3923static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3924 REGULATOR_SUPPLY("8901_mvs0", NULL),
3925};
3926
David Collins6f032ba2011-08-31 14:08:15 -07003927/* Pin control regulators */
3928static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3929 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3930};
3931static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3932 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3933};
3934static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3935 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3936};
3937static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3938 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3939};
3940static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3941 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3942};
3943static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3944 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3945};
3946
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003947#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3948 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003949 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3950 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003951 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003952 .init_data = { \
3953 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003954 .valid_modes_mask = _modes, \
3955 .valid_ops_mask = _ops, \
3956 .min_uV = _min_uV, \
3957 .max_uV = _max_uV, \
3958 .input_uV = _min_uV, \
3959 .apply_uV = _apply_uV, \
3960 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003961 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003962 .consumer_supplies = vreg_consumers_##_id, \
3963 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003964 ARRAY_SIZE(vreg_consumers_##_id), \
3965 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003966 .id = RPM_VREG_ID_##_id, \
3967 .default_uV = _default_uV, \
3968 .peak_uA = _peak_uA, \
3969 .avg_uA = _avg_uA, \
3970 .pull_down_enable = _pull_down, \
3971 .pin_ctrl = _pin_ctrl, \
3972 .freq = RPM_VREG_FREQ_##_freq, \
3973 .pin_fn = _pin_fn, \
3974 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003975 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003976 .state = _state, \
3977 .sleep_selectable = _sleep_selectable, \
3978 }
3979
3980/* Pin control initialization */
3981#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3982 { \
3983 .init_data = { \
3984 .constraints = { \
3985 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3986 .always_on = _always_on, \
3987 }, \
3988 .num_consumer_supplies = \
3989 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3990 .consumer_supplies = vreg_consumers_##_id##_PC, \
3991 }, \
3992 .id = RPM_VREG_ID_##_id##_PC, \
3993 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003994 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003995 }
3996
3997/*
3998 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3999 * via the peak_uA value specified in the table below. If the value is less
4000 * than the high power min threshold for the regulator, then the regulator will
4001 * be set to LPM. Otherwise, it will be set to HPM.
4002 *
4003 * This value can be further overridden by specifying an initial mode via
4004 * .init_data.constraints.initial_mode.
4005 */
4006
David Collins6f032ba2011-08-31 14:08:15 -07004007#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4008 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004009 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4010 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4011 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4012 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4013 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004014 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4015 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004016 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004017 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004018 _sleep_selectable, _always_on)
4019
David Collins6f032ba2011-08-31 14:08:15 -07004020#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4021 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004022 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4023 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4024 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4025 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4026 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004027 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4028 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004029 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004030 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4031 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004032
David Collins6f032ba2011-08-31 14:08:15 -07004033#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004034 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4035 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004036 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4037 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004038 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004039 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4040 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041
David Collins6f032ba2011-08-31 14:08:15 -07004042#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004043 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4044 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004045 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4046 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004047 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004048 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4049 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004050
David Collins6f032ba2011-08-31 14:08:15 -07004051#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4052#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4053#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4054#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4055#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004056
David Collins6f032ba2011-08-31 14:08:15 -07004057/* RPM early regulator constraints */
4058static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4059 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004060 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004061 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004062};
4063
David Collins6f032ba2011-08-31 14:08:15 -07004064/* RPM regulator constraints */
4065static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4066 /* ID a_on pd ss min_uV max_uV init_ip */
4067 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4068 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4069 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4070 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4071 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4072 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4073 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4074 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4075 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4076 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4077 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4078 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4079 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4080 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4081 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4082 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4083 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4084 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4085 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4086 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4087 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4088 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4089 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4090 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4091 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4092 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004093
David Collins6f032ba2011-08-31 14:08:15 -07004094 /* ID a_on pd ss min_uV max_uV init_ip freq */
4095 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4096 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4097 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4098
4099 /* ID a_on pd ss */
4100 RPM_VS(PM8058_LVS0, 0, 1, 0),
4101 RPM_VS(PM8058_LVS1, 0, 1, 0),
4102
4103 /* ID a_on pd ss min_uV max_uV */
4104 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4105
4106 /* ID a_on pd ss min_uV max_uV init_ip */
4107 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4108 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4109 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4110 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4111 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4112 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4113 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4114
4115 /* ID a_on pd ss min_uV max_uV init_ip freq */
4116 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4117 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4118 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4119
4120 /* ID a_on pd ss */
4121 RPM_VS(PM8901_LVS0, 1, 1, 0),
4122 RPM_VS(PM8901_LVS1, 0, 1, 0),
4123 RPM_VS(PM8901_LVS2, 0, 1, 0),
4124 RPM_VS(PM8901_LVS3, 0, 1, 0),
4125 RPM_VS(PM8901_MVS0, 0, 1, 0),
4126
4127 /* ID a_on pin_func pin_ctrl */
4128 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4129 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4130 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4131 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4132 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4133 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4134};
4135
4136static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4137 .init_data = rpm_regulator_early_init_data,
4138 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4139 .version = RPM_VREG_VERSION_8660,
4140 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4141 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4142};
4143
4144static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4145 .init_data = rpm_regulator_init_data,
4146 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4147 .version = RPM_VREG_VERSION_8660,
4148};
4149
4150static struct platform_device rpm_regulator_early_device = {
4151 .name = "rpm-regulator",
4152 .id = 0,
4153 .dev = {
4154 .platform_data = &rpm_regulator_early_pdata,
4155 },
4156};
4157
4158static struct platform_device rpm_regulator_device = {
4159 .name = "rpm-regulator",
4160 .id = 1,
4161 .dev = {
4162 .platform_data = &rpm_regulator_pdata,
4163 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004164};
4165
4166static struct platform_device *early_regulators[] __initdata = {
4167 &msm_device_saw_s0,
4168 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004169 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004170};
4171
4172static struct platform_device *early_devices[] __initdata = {
4173#ifdef CONFIG_MSM_BUS_SCALING
4174 &msm_bus_apps_fabric,
4175 &msm_bus_sys_fabric,
4176 &msm_bus_mm_fabric,
4177 &msm_bus_sys_fpb,
4178 &msm_bus_cpss_fpb,
4179#endif
4180 &msm_device_dmov_adm0,
4181 &msm_device_dmov_adm1,
4182};
4183
4184#if (defined(CONFIG_MARIMBA_CORE)) && \
4185 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4186
4187static int bluetooth_power(int);
4188static struct platform_device msm_bt_power_device = {
4189 .name = "bt_power",
4190 .id = -1,
4191 .dev = {
4192 .platform_data = &bluetooth_power,
4193 },
4194};
4195#endif
4196
4197static struct platform_device msm_tsens_device = {
4198 .name = "tsens-tm",
4199 .id = -1,
4200};
4201
4202static struct platform_device *rumi_sim_devices[] __initdata = {
4203 &smc91x_device,
4204 &msm_device_uart_dm12,
4205#ifdef CONFIG_I2C_QUP
4206 &msm_gsbi3_qup_i2c_device,
4207 &msm_gsbi4_qup_i2c_device,
4208 &msm_gsbi7_qup_i2c_device,
4209 &msm_gsbi8_qup_i2c_device,
4210 &msm_gsbi9_qup_i2c_device,
4211 &msm_gsbi12_qup_i2c_device,
4212#endif
4213#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004214 &msm_device_ssbi3,
4215#endif
4216#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004217#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004218 &android_pmem_device,
4219 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004220 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004221 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304222#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4223#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004224#ifdef CONFIG_MSM_ROTATOR
4225 &msm_rotator_device,
4226#endif
4227 &msm_fb_device,
4228 &msm_kgsl_3d0,
4229 &msm_kgsl_2d0,
4230 &msm_kgsl_2d1,
4231 &lcdc_samsung_panel_device,
4232#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4233 &hdmi_msm_device,
4234#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4235#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004236#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004237#ifdef CONFIG_MT9E013
4238 &msm_camera_sensor_mt9e013,
4239#endif
4240#ifdef CONFIG_IMX074
4241 &msm_camera_sensor_imx074,
4242#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004243#ifdef CONFIG_VX6953
4244 &msm_camera_sensor_vx6953,
4245#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004246#ifdef CONFIG_WEBCAM_OV7692
4247 &msm_camera_sensor_webcam_ov7692,
4248#endif
4249#ifdef CONFIG_WEBCAM_OV9726
4250 &msm_camera_sensor_webcam_ov9726,
4251#endif
4252#ifdef CONFIG_QS_S5K4E1
4253 &msm_camera_sensor_qs_s5k4e1,
4254#endif
4255#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004256#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004257#ifdef CONFIG_MSM_GEMINI
4258 &msm_gemini_device,
4259#endif
4260#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004261#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004262 &msm_vpe_device,
4263#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004264#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004265 &msm_device_vidc,
4266};
4267
4268#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4269enum {
4270 SX150X_CORE,
4271 SX150X_DOCKING,
4272 SX150X_SURF,
4273 SX150X_LEFT_FHA,
4274 SX150X_RIGHT_FHA,
4275 SX150X_SOUTH,
4276 SX150X_NORTH,
4277 SX150X_CORE_FLUID,
4278};
4279
4280static struct sx150x_platform_data sx150x_data[] __initdata = {
4281 [SX150X_CORE] = {
4282 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4283 .oscio_is_gpo = false,
4284 .io_pullup_ena = 0x0c08,
4285 .io_pulldn_ena = 0x4060,
4286 .io_open_drain_ena = 0x000c,
4287 .io_polarity = 0,
4288 .irq_summary = -1, /* see fixup_i2c_configs() */
4289 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4290 },
4291 [SX150X_DOCKING] = {
4292 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4293 .oscio_is_gpo = false,
4294 .io_pullup_ena = 0x5e06,
4295 .io_pulldn_ena = 0x81b8,
4296 .io_open_drain_ena = 0,
4297 .io_polarity = 0,
4298 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4299 UI_INT2_N),
4300 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4301 GPIO_DOCKING_EXPANDER_BASE -
4302 GPIO_EXPANDER_GPIO_BASE,
4303 },
4304 [SX150X_SURF] = {
4305 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4306 .oscio_is_gpo = false,
4307 .io_pullup_ena = 0,
4308 .io_pulldn_ena = 0,
4309 .io_open_drain_ena = 0,
4310 .io_polarity = 0,
4311 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4312 UI_INT1_N),
4313 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4314 GPIO_SURF_EXPANDER_BASE -
4315 GPIO_EXPANDER_GPIO_BASE,
4316 },
4317 [SX150X_LEFT_FHA] = {
4318 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4319 .oscio_is_gpo = false,
4320 .io_pullup_ena = 0,
4321 .io_pulldn_ena = 0x40,
4322 .io_open_drain_ena = 0,
4323 .io_polarity = 0,
4324 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4325 UI_INT3_N),
4326 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4327 GPIO_LEFT_KB_EXPANDER_BASE -
4328 GPIO_EXPANDER_GPIO_BASE,
4329 },
4330 [SX150X_RIGHT_FHA] = {
4331 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4332 .oscio_is_gpo = true,
4333 .io_pullup_ena = 0,
4334 .io_pulldn_ena = 0,
4335 .io_open_drain_ena = 0,
4336 .io_polarity = 0,
4337 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4338 UI_INT3_N),
4339 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4340 GPIO_RIGHT_KB_EXPANDER_BASE -
4341 GPIO_EXPANDER_GPIO_BASE,
4342 },
4343 [SX150X_SOUTH] = {
4344 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4345 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4346 GPIO_SOUTH_EXPANDER_BASE -
4347 GPIO_EXPANDER_GPIO_BASE,
4348 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4349 },
4350 [SX150X_NORTH] = {
4351 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4352 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4353 GPIO_NORTH_EXPANDER_BASE -
4354 GPIO_EXPANDER_GPIO_BASE,
4355 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4356 .oscio_is_gpo = true,
4357 .io_open_drain_ena = 0x30,
4358 },
4359 [SX150X_CORE_FLUID] = {
4360 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4361 .oscio_is_gpo = false,
4362 .io_pullup_ena = 0x0408,
4363 .io_pulldn_ena = 0x4060,
4364 .io_open_drain_ena = 0x0008,
4365 .io_polarity = 0,
4366 .irq_summary = -1, /* see fixup_i2c_configs() */
4367 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4368 },
4369};
4370
4371#ifdef CONFIG_SENSORS_MSM_ADC
4372/* Configuration of EPM expander is done when client
4373 * request an adc read
4374 */
4375static struct sx150x_platform_data sx150x_epmdata = {
4376 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4377 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4378 GPIO_EPM_EXPANDER_BASE -
4379 GPIO_EXPANDER_GPIO_BASE,
4380 .irq_summary = -1,
4381};
4382#endif
4383
4384/* sx150x_low_power_cfg
4385 *
4386 * This data and init function are used to put unused gpio-expander output
4387 * lines into their low-power states at boot. The init
4388 * function must be deferred until a later init stage because the i2c
4389 * gpio expander drivers do not probe until after they are registered
4390 * (see register_i2c_devices) and the work-queues for those registrations
4391 * are processed. Because these lines are unused, there is no risk of
4392 * competing with a device driver for the gpio.
4393 *
4394 * gpio lines whose low-power states are input are naturally in their low-
4395 * power configurations once probed, see the platform data structures above.
4396 */
4397struct sx150x_low_power_cfg {
4398 unsigned gpio;
4399 unsigned val;
4400};
4401
4402static struct sx150x_low_power_cfg
4403common_sx150x_lp_cfgs[] __initdata = {
4404 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4405 {GPIO_EXT_GPS_LNA_EN, 0},
4406 {GPIO_MSM_WAKES_BT, 0},
4407 {GPIO_USB_UICC_EN, 0},
4408 {GPIO_BATT_GAUGE_EN, 0},
4409};
4410
4411static struct sx150x_low_power_cfg
4412surf_ffa_sx150x_lp_cfgs[] __initdata = {
4413 {GPIO_MIPI_DSI_RST_N, 0},
4414 {GPIO_DONGLE_PWR_EN, 0},
4415 {GPIO_CAP_TS_SLEEP, 1},
4416 {GPIO_WEB_CAMIF_RESET_N, 0},
4417};
4418
4419static void __init
4420cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4421{
4422 unsigned n;
4423 int rc;
4424
4425 for (n = 0; n < nelems; ++n) {
4426 rc = gpio_request(cfgs[n].gpio, NULL);
4427 if (!rc) {
4428 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4429 gpio_free(cfgs[n].gpio);
4430 }
4431
4432 if (rc) {
4433 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4434 __func__, cfgs[n].gpio, rc);
4435 }
Steve Muckle9161d302010-02-11 11:50:40 -08004436 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004437}
4438
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004439static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004440{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004441 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4442 ARRAY_SIZE(common_sx150x_lp_cfgs));
4443 if (!machine_is_msm8x60_fluid())
4444 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4445 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4446 return 0;
4447}
4448module_init(cfg_sx150xs_low_power);
4449
4450#ifdef CONFIG_I2C
4451static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4452 {
4453 I2C_BOARD_INFO("sx1509q", 0x3e),
4454 .platform_data = &sx150x_data[SX150X_CORE]
4455 },
4456};
4457
4458static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4459 {
4460 I2C_BOARD_INFO("sx1509q", 0x3f),
4461 .platform_data = &sx150x_data[SX150X_DOCKING]
4462 },
4463};
4464
4465static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4466 {
4467 I2C_BOARD_INFO("sx1509q", 0x70),
4468 .platform_data = &sx150x_data[SX150X_SURF]
4469 }
4470};
4471
4472static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4473 {
4474 I2C_BOARD_INFO("sx1508q", 0x21),
4475 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4476 },
4477 {
4478 I2C_BOARD_INFO("sx1508q", 0x22),
4479 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4480 }
4481};
4482
4483static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4484 {
4485 I2C_BOARD_INFO("sx1508q", 0x23),
4486 .platform_data = &sx150x_data[SX150X_SOUTH]
4487 },
4488 {
4489 I2C_BOARD_INFO("sx1508q", 0x20),
4490 .platform_data = &sx150x_data[SX150X_NORTH]
4491 }
4492};
4493
4494static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4495 {
4496 I2C_BOARD_INFO("sx1509q", 0x3e),
4497 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4498 },
4499};
4500
4501#ifdef CONFIG_SENSORS_MSM_ADC
4502static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4503 {
4504 I2C_BOARD_INFO("sx1509q", 0x3e),
4505 .platform_data = &sx150x_epmdata
4506 },
4507};
4508#endif
4509#endif
4510#endif
4511
4512#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004513
4514static struct adc_access_fn xoadc_fn = {
4515 pm8058_xoadc_select_chan_and_start_conv,
4516 pm8058_xoadc_read_adc_code,
4517 pm8058_xoadc_get_properties,
4518 pm8058_xoadc_slot_request,
4519 pm8058_xoadc_restore_slot,
4520 pm8058_xoadc_calibrate,
4521};
4522
4523#if defined(CONFIG_I2C) && \
4524 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4525static struct regulator *vreg_adc_epm1;
4526
4527static struct i2c_client *epm_expander_i2c_register_board(void)
4528
4529{
4530 struct i2c_adapter *i2c_adap;
4531 struct i2c_client *client = NULL;
4532 i2c_adap = i2c_get_adapter(0x0);
4533
4534 if (i2c_adap == NULL)
4535 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4536
4537 if (i2c_adap != NULL)
4538 client = i2c_new_device(i2c_adap,
4539 &fluid_expanders_i2c_epm_info[0]);
4540 return client;
4541
4542}
4543
4544static unsigned int msm_adc_gpio_configure_expander_enable(void)
4545{
4546 int rc = 0;
4547 static struct i2c_client *epm_i2c_client;
4548
4549 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4550
4551 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4552
4553 if (IS_ERR(vreg_adc_epm1)) {
4554 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4555 return 0;
4556 }
4557
4558 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4559 if (rc)
4560 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4561 "regulator set voltage failed\n");
4562
4563 rc = regulator_enable(vreg_adc_epm1);
4564 if (rc) {
4565 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4566 "Error while enabling regulator for epm s3 %d\n", rc);
4567 return rc;
4568 }
4569
4570 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4571 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4572
4573 msleep(1000);
4574
4575 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4576 if (!rc) {
4577 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4578 "Configure 5v boost\n");
4579 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4580 } else {
4581 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4582 "Error for epm 5v boost en\n");
4583 goto exit_vreg_epm;
4584 }
4585
4586 msleep(500);
4587
4588 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4589 if (!rc) {
4590 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4591 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4592 "Configure epm 3.3v\n");
4593 } else {
4594 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4595 "Error for gpio 3.3ven\n");
4596 goto exit_vreg_epm;
4597 }
4598 msleep(500);
4599
4600 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4601 "Trying to request EPM LVLSFT_EN\n");
4602 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4603 if (!rc) {
4604 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4605 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4606 "Configure the lvlsft\n");
4607 } else {
4608 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4609 "Error for epm lvlsft_en\n");
4610 goto exit_vreg_epm;
4611 }
4612
4613 msleep(500);
4614
4615 if (!epm_i2c_client)
4616 epm_i2c_client = epm_expander_i2c_register_board();
4617
4618 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4619 if (!rc)
4620 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4621 if (rc) {
4622 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4623 ": GPIO PWR MON Enable issue\n");
4624 goto exit_vreg_epm;
4625 }
4626
4627 msleep(1000);
4628
4629 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4630 if (!rc) {
4631 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4632 if (rc) {
4633 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4634 ": ADC1_PWDN error direction out\n");
4635 goto exit_vreg_epm;
4636 }
4637 }
4638
4639 msleep(100);
4640
4641 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4642 if (!rc) {
4643 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4644 if (rc) {
4645 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4646 ": ADC2_PWD error direction out\n");
4647 goto exit_vreg_epm;
4648 }
4649 }
4650
4651 msleep(1000);
4652
4653 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4654 if (!rc) {
4655 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4656 if (rc) {
4657 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4658 "Gpio request problem %d\n", rc);
4659 goto exit_vreg_epm;
4660 }
4661 }
4662
4663 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4664 if (!rc) {
4665 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4666 if (rc) {
4667 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4668 ": EPM_SPI_ADC1_CS_N error\n");
4669 goto exit_vreg_epm;
4670 }
4671 }
4672
4673 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4674 if (!rc) {
4675 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4676 if (rc) {
4677 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4678 ": EPM_SPI_ADC2_Cs_N error\n");
4679 goto exit_vreg_epm;
4680 }
4681 }
4682
4683 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4684 "the power monitor reset for epm\n");
4685
4686 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4687 if (!rc) {
4688 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4689 if (rc) {
4690 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4691 ": Error in the power mon reset\n");
4692 goto exit_vreg_epm;
4693 }
4694 }
4695
4696 msleep(1000);
4697
4698 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4699
4700 msleep(500);
4701
4702 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4703
4704 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4705
4706 return rc;
4707
4708exit_vreg_epm:
4709 regulator_disable(vreg_adc_epm1);
4710
4711 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4712 " rc = %d.\n", rc);
4713 return rc;
4714};
4715
4716static unsigned int msm_adc_gpio_configure_expander_disable(void)
4717{
4718 int rc = 0;
4719
4720 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4721 gpio_free(GPIO_PWR_MON_RESET_N);
4722
4723 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4724 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4725
4726 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4727 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4728
4729 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4730 gpio_free(GPIO_PWR_MON_START);
4731
4732 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4733 gpio_free(GPIO_ADC1_PWDN_N);
4734
4735 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4736 gpio_free(GPIO_ADC2_PWDN_N);
4737
4738 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4739 gpio_free(GPIO_PWR_MON_ENABLE);
4740
4741 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4742 gpio_free(GPIO_EPM_LVLSFT_EN);
4743
4744 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4745 gpio_free(GPIO_EPM_5V_BOOST_EN);
4746
4747 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4748 gpio_free(GPIO_EPM_3_3V_EN);
4749
4750 rc = regulator_disable(vreg_adc_epm1);
4751 if (rc)
4752 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4753 "Error while enabling regulator for epm s3 %d\n", rc);
4754 regulator_put(vreg_adc_epm1);
4755
4756 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4757 return rc;
4758};
4759
4760unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4761{
4762 int rc = 0;
4763
4764 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4765 cs_enable);
4766
4767 if (cs_enable < 16) {
4768 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4769 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4770 } else {
4771 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4772 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4773 }
4774 return rc;
4775};
4776
4777unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4778{
4779 int rc = 0;
4780
4781 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4782
4783 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4784
4785 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4786
4787 return rc;
4788};
4789#endif
4790
4791static struct msm_adc_channels msm_adc_channels_data[] = {
4792 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4793 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4794 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4795 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4796 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4797 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4798 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4799 CHAN_PATH_TYPE4,
4800 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4801 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4802 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4803 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4804 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4805 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4806 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4807 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4808 CHAN_PATH_TYPE12,
4809 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4810 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4811 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4812 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4813 CHAN_PATH_TYPE_NONE,
4814 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4815 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4816 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4817 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4818 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4819 scale_xtern_chgr_cur},
4820 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4821 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4822 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4823 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4824 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4825 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4826 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4827 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4828 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4829 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4830 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4831 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4832};
4833
4834static char *msm_adc_fluid_device_names[] = {
4835 "ADS_ADC1",
4836 "ADS_ADC2",
4837};
4838
4839static struct msm_adc_platform_data msm_adc_pdata = {
4840 .channel = msm_adc_channels_data,
4841 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4842#if defined(CONFIG_I2C) && \
4843 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4844 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4845 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4846 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4847 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4848#endif
4849};
4850
4851static struct platform_device msm_adc_device = {
4852 .name = "msm_adc",
4853 .id = -1,
4854 .dev = {
4855 .platform_data = &msm_adc_pdata,
4856 },
4857};
4858
4859static void pmic8058_xoadc_mpp_config(void)
4860{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304861 int rc, i;
4862 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304863 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304864 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304865 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304866 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304867 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304868 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304869 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304870 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304871 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304872 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304873 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4874 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304875 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004876
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304877 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4878 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4879 &xoadc_mpps[i].config);
4880 if (rc) {
4881 pr_err("%s: Config MPP %d of PM8058 failed\n",
4882 __func__, xoadc_mpps[i].mpp);
4883 }
4884 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004885}
4886
4887static struct regulator *vreg_ldo18_adc;
4888
4889static int pmic8058_xoadc_vreg_config(int on)
4890{
4891 int rc;
4892
4893 if (on) {
4894 rc = regulator_enable(vreg_ldo18_adc);
4895 if (rc)
4896 pr_err("%s: Enable of regulator ldo18_adc "
4897 "failed\n", __func__);
4898 } else {
4899 rc = regulator_disable(vreg_ldo18_adc);
4900 if (rc)
4901 pr_err("%s: Disable of regulator ldo18_adc "
4902 "failed\n", __func__);
4903 }
4904
4905 return rc;
4906}
4907
4908static int pmic8058_xoadc_vreg_setup(void)
4909{
4910 int rc;
4911
4912 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4913 if (IS_ERR(vreg_ldo18_adc)) {
4914 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4915 __func__, PTR_ERR(vreg_ldo18_adc));
4916 rc = PTR_ERR(vreg_ldo18_adc);
4917 goto fail;
4918 }
4919
4920 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4921 if (rc) {
4922 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4923 goto fail;
4924 }
4925
4926 return rc;
4927fail:
4928 regulator_put(vreg_ldo18_adc);
4929 return rc;
4930}
4931
4932static void pmic8058_xoadc_vreg_shutdown(void)
4933{
4934 regulator_put(vreg_ldo18_adc);
4935}
4936
4937/* usec. For this ADC,
4938 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4939 * Each channel has different configuration, thus at the time of starting
4940 * the conversion, xoadc will return actual conversion time
4941 * */
4942static struct adc_properties pm8058_xoadc_data = {
4943 .adc_reference = 2200, /* milli-voltage for this adc */
4944 .bitresolution = 15,
4945 .bipolar = 0,
4946 .conversiontime = 54,
4947};
4948
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304949static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004950 .xoadc_prop = &pm8058_xoadc_data,
4951 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4952 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4953 .xoadc_num = XOADC_PMIC_0,
4954 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4955 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4956};
4957#endif
4958
4959#ifdef CONFIG_MSM_SDIO_AL
4960
4961static unsigned mdm2ap_status = 140;
4962
4963static int configure_mdm2ap_status(int on)
4964{
4965 int ret = 0;
4966 if (on)
4967 ret = msm_gpiomux_get(mdm2ap_status);
4968 else
4969 ret = msm_gpiomux_put(mdm2ap_status);
4970
4971 if (ret)
4972 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4973 on);
4974
4975 return ret;
4976}
4977
4978
4979static int get_mdm2ap_status(void)
4980{
4981 return gpio_get_value(mdm2ap_status);
4982}
4983
4984static struct sdio_al_platform_data sdio_al_pdata = {
4985 .config_mdm2ap_status = configure_mdm2ap_status,
4986 .get_mdm2ap_status = get_mdm2ap_status,
4987 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004988 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004989 .peer_sdioc_version_major = 0x0004,
4990 .peer_sdioc_boot_version_minor = 0x0001,
4991 .peer_sdioc_boot_version_major = 0x0003
4992};
4993
4994struct platform_device msm_device_sdio_al = {
4995 .name = "msm_sdio_al",
4996 .id = -1,
4997 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004998 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004999 .platform_data = &sdio_al_pdata,
5000 },
5001};
5002
5003#endif /* CONFIG_MSM_SDIO_AL */
5004
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305005#define GPIO_VREG_ID_EXT_5V 0
5006
5007static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5008 REGULATOR_SUPPLY("ext_5v", NULL),
5009 REGULATOR_SUPPLY("8901_mpp0", NULL),
5010};
5011
5012#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5013 [GPIO_VREG_ID_##_id] = { \
5014 .init_data = { \
5015 .constraints = { \
5016 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5017 }, \
5018 .num_consumer_supplies = \
5019 ARRAY_SIZE(vreg_consumers_##_id), \
5020 .consumer_supplies = vreg_consumers_##_id, \
5021 }, \
5022 .regulator_name = _reg_name, \
5023 .active_low = _active_low, \
5024 .gpio_label = _gpio_label, \
5025 .gpio = _gpio, \
5026 }
5027
5028/* GPIO regulator constraints */
5029static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5030 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5031 PM8901_MPP_PM_TO_SYS(0), 0),
5032};
5033
5034/* GPIO regulator */
5035static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5036 .name = GPIO_REGULATOR_DEV_NAME,
5037 .id = PM8901_MPP_PM_TO_SYS(0),
5038 .dev = {
5039 .platform_data =
5040 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5041 },
5042};
5043
5044static void __init pm8901_vreg_mpp0_init(void)
5045{
5046 int rc;
5047
5048 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5049 .mpp = PM8901_MPP_PM_TO_SYS(0),
5050 .config = {
5051 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5052 .level = PM8901_MPP_DIG_LEVEL_VPH,
5053 },
5054 };
5055
5056 /*
5057 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5058 * implies that the regulator connected to MPP0 is enabled when
5059 * MPP0 is low.
5060 */
5061 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5062 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5063 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5064 } else {
5065 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5066 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5067 }
5068
5069 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5070 if (rc)
5071 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5072}
5073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005074static struct platform_device *charm_devices[] __initdata = {
5075 &msm_charm_modem,
5076#ifdef CONFIG_MSM_SDIO_AL
5077 &msm_device_sdio_al,
5078#endif
5079};
5080
Lei Zhou338cab82011-08-19 13:38:17 -04005081#ifdef CONFIG_SND_SOC_MSM8660_APQ
5082static struct platform_device *dragon_alsa_devices[] __initdata = {
5083 &msm_pcm,
5084 &msm_pcm_routing,
5085 &msm_cpudai0,
5086 &msm_cpudai1,
5087 &msm_cpudai_hdmi_rx,
5088 &msm_cpudai_bt_rx,
5089 &msm_cpudai_bt_tx,
5090 &msm_cpudai_fm_rx,
5091 &msm_cpudai_fm_tx,
5092 &msm_cpu_fe,
5093 &msm_stub_codec,
5094 &msm_lpa_pcm,
5095};
5096#endif
5097
5098static struct platform_device *asoc_devices[] __initdata = {
5099 &asoc_msm_pcm,
5100 &asoc_msm_dai0,
5101 &asoc_msm_dai1,
5102};
5103
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005104static struct platform_device *surf_devices[] __initdata = {
5105 &msm_device_smd,
5106 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005107 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005108 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005109 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005110 &msm_pil_dsps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005111#ifdef CONFIG_I2C_QUP
5112 &msm_gsbi3_qup_i2c_device,
5113 &msm_gsbi4_qup_i2c_device,
5114 &msm_gsbi7_qup_i2c_device,
5115 &msm_gsbi8_qup_i2c_device,
5116 &msm_gsbi9_qup_i2c_device,
5117 &msm_gsbi12_qup_i2c_device,
5118#endif
5119#ifdef CONFIG_SERIAL_MSM_HS
5120 &msm_device_uart_dm1,
5121#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305122#ifdef CONFIG_MSM_SSBI
5123 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305124 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305125#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005126#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005127 &msm_device_ssbi3,
5128#endif
5129#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5130 &isp1763_device,
5131#endif
5132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005133#if defined (CONFIG_MSM_8x60_VOIP)
5134 &asoc_msm_mvs,
5135 &asoc_mvs_dai0,
5136 &asoc_mvs_dai1,
5137#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005138
Lena Salman57d167e2012-03-21 19:46:38 +02005139#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005140 &msm_device_otg,
5141#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005142#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005143 &msm_device_gadget_peripheral,
5144#endif
5145#ifdef CONFIG_USB_G_ANDROID
5146 &android_usb_device,
5147#endif
5148#ifdef CONFIG_BATTERY_MSM
5149 &msm_batt_device,
5150#endif
5151#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005152#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005153 &android_pmem_device,
5154 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005155 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005156 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305157#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5158#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005159#ifdef CONFIG_MSM_ROTATOR
5160 &msm_rotator_device,
5161#endif
5162 &msm_fb_device,
5163 &msm_kgsl_3d0,
5164 &msm_kgsl_2d0,
5165 &msm_kgsl_2d1,
5166 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005167#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5168 &lcdc_nt35582_panel_device,
5169#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005170#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5171 &lcdc_samsung_oled_panel_device,
5172#endif
5173#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5174 &lcdc_auo_wvga_panel_device,
5175#endif
5176#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5177 &hdmi_msm_device,
5178#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5179#ifdef CONFIG_FB_MSM_MIPI_DSI
5180 &mipi_dsi_toshiba_panel_device,
5181 &mipi_dsi_novatek_panel_device,
5182#endif
5183#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005184#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005185#ifdef CONFIG_MT9E013
5186 &msm_camera_sensor_mt9e013,
5187#endif
5188#ifdef CONFIG_IMX074
5189 &msm_camera_sensor_imx074,
5190#endif
5191#ifdef CONFIG_WEBCAM_OV7692
5192 &msm_camera_sensor_webcam_ov7692,
5193#endif
5194#ifdef CONFIG_WEBCAM_OV9726
5195 &msm_camera_sensor_webcam_ov9726,
5196#endif
5197#ifdef CONFIG_QS_S5K4E1
5198 &msm_camera_sensor_qs_s5k4e1,
5199#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005200#ifdef CONFIG_VX6953
5201 &msm_camera_sensor_vx6953,
5202#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005204#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005205#ifdef CONFIG_MSM_GEMINI
5206 &msm_gemini_device,
5207#endif
5208#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005209#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005210 &msm_vpe_device,
5211#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005212#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005213
5214#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005215 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005216#endif
5217#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005218 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005219#endif
5220 &msm_device_vidc,
5221#if (defined(CONFIG_MARIMBA_CORE)) && \
5222 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5223 &msm_bt_power_device,
5224#endif
5225#ifdef CONFIG_SENSORS_MSM_ADC
5226 &msm_adc_device,
5227#endif
David Collins6f032ba2011-08-31 14:08:15 -07005228 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005229
5230#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5231 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5232 &qcrypto_device,
5233#endif
5234
5235#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5236 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5237 &qcedev_device,
5238#endif
5239
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240
5241#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5242#ifdef CONFIG_MSM_USE_TSIF1
5243 &msm_device_tsif[1],
5244#else
5245 &msm_device_tsif[0],
5246#endif /* CONFIG_MSM_USE_TSIF1 */
5247#endif /* CONFIG_TSIF */
5248
5249#ifdef CONFIG_HW_RANDOM_MSM
5250 &msm_device_rng,
5251#endif
5252
5253 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005254 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005255#ifdef CONFIG_ION_MSM
5256 &ion_dev,
5257#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005258 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005259 &msm_device_tz_log,
5260
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005261};
5262
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005263#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005264#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5265static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5266 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005267 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005268 .request_region = request_smi_region,
5269 .release_region = release_smi_region,
5270 .setup_region = setup_smi_region,
Olav Haugan8726caf2012-05-10 15:11:35 -07005271 .iommu_map_all = 1,
5272 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005273};
5274
5275static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5276 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005277 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005278 .request_region = request_smi_region,
5279 .release_region = release_smi_region,
5280 .setup_region = setup_smi_region,
5281};
5282
5283static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5284 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005285 .align = PAGE_SIZE,
5286};
5287
5288static struct ion_co_heap_pdata fw_co_ion_pdata = {
5289 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
5290 .align = SZ_128K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005291};
5292
5293static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005294 .adjacent_mem_id = INVALID_HEAP_ID,
5295 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005296};
5297#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005298
5299/**
5300 * These heaps are listed in the order they will be allocated. Due to
5301 * video hardware restrictions and content protection the FW heap has to
5302 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5303 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5304 * away from the base address of the FW heap.
5305 * However, the order of FW heap and MM heap doesn't matter since these
5306 * two heaps are taken care of by separate code to ensure they are adjacent
5307 * to each other.
5308 * Don't swap the order unless you know what you are doing!
5309 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005310static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005311 .nr = MSM_ION_HEAP_NUM,
5312 .heaps = {
5313 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005314 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005315 .type = ION_HEAP_TYPE_SYSTEM,
5316 .name = ION_VMALLOC_HEAP_NAME,
5317 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005318#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5319 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005320 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005321 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005322 .name = ION_MM_HEAP_NAME,
5323 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005324 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005325 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005326 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005327 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005328 .id = ION_MM_FIRMWARE_HEAP_ID,
5329 .type = ION_HEAP_TYPE_CARVEOUT,
5330 .name = ION_MM_FIRMWARE_HEAP_NAME,
5331 .size = MSM_ION_MM_FW_SIZE,
5332 .memory_type = ION_SMI_TYPE,
5333 .extra_data = (void *) &fw_co_ion_pdata,
5334 },
5335 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005336 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005337 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005338 .name = ION_MFC_HEAP_NAME,
5339 .size = MSM_ION_MFC_SIZE,
5340 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005341 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005342 },
5343 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005344 .id = ION_SF_HEAP_ID,
5345 .type = ION_HEAP_TYPE_CARVEOUT,
5346 .name = ION_SF_HEAP_NAME,
5347 .size = MSM_ION_SF_SIZE,
5348 .memory_type = ION_EBI_TYPE,
5349 .extra_data = (void *)&co_ion_pdata,
5350 },
5351 {
5352 .id = ION_CAMERA_HEAP_ID,
5353 .type = ION_HEAP_TYPE_CARVEOUT,
5354 .name = ION_CAMERA_HEAP_NAME,
5355 .size = MSM_ION_CAMERA_SIZE,
5356 .memory_type = ION_EBI_TYPE,
5357 .extra_data = &co_ion_pdata,
5358 },
5359 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005360 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005361 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005362 .name = ION_WB_HEAP_NAME,
5363 .size = MSM_ION_WB_SIZE,
5364 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005365 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005366 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005367 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005368 .id = ION_QSECOM_HEAP_ID,
5369 .type = ION_HEAP_TYPE_CARVEOUT,
5370 .name = ION_QSECOM_HEAP_NAME,
5371 .size = MSM_ION_QSECOM_SIZE,
5372 .memory_type = ION_EBI_TYPE,
5373 .extra_data = (void *) &co_ion_pdata,
5374 },
5375 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005376 .id = ION_AUDIO_HEAP_ID,
5377 .type = ION_HEAP_TYPE_CARVEOUT,
5378 .name = ION_AUDIO_HEAP_NAME,
5379 .size = MSM_ION_AUDIO_SIZE,
5380 .memory_type = ION_EBI_TYPE,
5381 .extra_data = (void *)&co_ion_pdata,
5382 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005383#endif
5384 }
5385};
5386
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005387static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005388 .name = "ion-msm",
5389 .id = 1,
5390 .dev = { .platform_data = &ion_pdata },
5391};
5392#endif
5393
5394
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005395static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5396 /* Kernel SMI memory pool for video core, used for firmware */
5397 /* and encoder, decoder scratch buffers */
5398 /* Kernel SMI memory pool should always precede the user space */
5399 /* SMI memory pool, as the video core will use offset address */
5400 /* from the Firmware base */
5401 [MEMTYPE_SMI_KERNEL] = {
5402 .start = KERNEL_SMI_BASE,
5403 .limit = KERNEL_SMI_SIZE,
5404 .size = KERNEL_SMI_SIZE,
5405 .flags = MEMTYPE_FLAGS_FIXED,
5406 },
5407 /* User space SMI memory pool for video core */
5408 /* used for encoder, decoder input & output buffers */
5409 [MEMTYPE_SMI] = {
5410 .start = USER_SMI_BASE,
5411 .limit = USER_SMI_SIZE,
5412 .flags = MEMTYPE_FLAGS_FIXED,
5413 },
5414 [MEMTYPE_EBI0] = {
5415 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5416 },
5417 [MEMTYPE_EBI1] = {
5418 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5419 },
5420};
5421
Stephen Boyd668d7652012-04-25 11:31:01 -07005422static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005423{
5424#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005425 unsigned int i;
5426
5427 if (hdmi_is_primary) {
5428 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5429 for (i = 0; i < ion_pdata.nr; i++) {
5430 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5431 ion_pdata.heaps[i].size = msm_ion_sf_size;
5432 pr_debug("msm_ion_sf_size 0x%x\n",
5433 msm_ion_sf_size);
5434 break;
5435 }
5436 }
5437 }
5438
Olav Haugan8726caf2012-05-10 15:11:35 -07005439 /* Verify size of heap is a multiple of 64K */
5440 for (i = 0; i < ion_pdata.nr; i++) {
5441 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5442
5443 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5444 int map_all = ((struct ion_cp_heap_pdata *)
5445 heap->extra_data)->iommu_map_all;
5446
5447 if (map_all && (heap->size & (SZ_64K-1))) {
5448 heap->size = ALIGN(heap->size, SZ_64K);
5449 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5450 heap->name, heap->size);
5451
5452 }
5453 }
5454 }
5455
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005456 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Haugan42ebe712012-01-10 16:30:58 -08005457 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_FW_SIZE;
Olav Hauganb5be7992011-11-18 14:29:02 -08005458 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5459 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5460 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5461 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005462 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005463 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005464#endif
5465}
5466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005467static void __init size_pmem_devices(void)
5468{
5469#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005470#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005471 android_pmem_adsp_pdata.size = pmem_adsp_size;
5472 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005473
5474 if (hdmi_is_primary)
5475 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005476 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005477 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305478#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5479#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005480}
5481
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305482#ifdef CONFIG_ANDROID_PMEM
5483#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005484static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5485{
5486 msm8x60_reserve_table[p->memory_type].size += p->size;
5487}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305488#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5489#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005490
5491static void __init reserve_pmem_memory(void)
5492{
5493#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005494#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005495 reserve_memory_for(&android_pmem_adsp_pdata);
5496 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005498 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305499#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005500 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305501#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005502}
5503
Huaibin Yanga5419422011-12-08 23:52:10 -08005504static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005505
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005506static void __init msm8x60_calculate_reserve_sizes(void)
5507{
5508 size_pmem_devices();
5509 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005510 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005511 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005512}
5513
5514static int msm8x60_paddr_to_memtype(unsigned int paddr)
5515{
5516 if (paddr >= 0x40000000 && paddr < 0x60000000)
5517 return MEMTYPE_EBI1;
5518 if (paddr >= 0x38000000 && paddr < 0x40000000)
5519 return MEMTYPE_SMI;
5520 return MEMTYPE_NONE;
5521}
5522
5523static struct reserve_info msm8x60_reserve_info __initdata = {
5524 .memtype_reserve_table = msm8x60_reserve_table,
5525 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5526 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5527};
5528
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005529static char prim_panel_name[PANEL_NAME_MAX_LEN];
5530static char ext_panel_name[PANEL_NAME_MAX_LEN];
5531static int __init prim_display_setup(char *param)
5532{
5533 if (strnlen(param, PANEL_NAME_MAX_LEN))
5534 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5535 return 0;
5536}
5537early_param("prim_display", prim_display_setup);
5538
5539static int __init ext_display_setup(char *param)
5540{
5541 if (strnlen(param, PANEL_NAME_MAX_LEN))
5542 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5543 return 0;
5544}
5545early_param("ext_display", ext_display_setup);
5546
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005547static void __init msm8x60_reserve(void)
5548{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005549 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005550 reserve_info = &msm8x60_reserve_info;
5551 msm_reserve();
5552}
5553
5554#define EXT_CHG_VALID_MPP 10
5555#define EXT_CHG_VALID_MPP_2 11
5556
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305557static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305558 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305559 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305560 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305561 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5562};
5563
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005564#ifdef CONFIG_ISL9519_CHARGER
5565static int isl_detection_setup(void)
5566{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305567 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005568
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305569 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5570 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5571 &isl_mpp[i].config);
5572 if (ret) {
5573 pr_err("%s: Config MPP %d of PM8058 failed\n",
5574 __func__, isl_mpp[i].mpp);
5575 return ret;
5576 }
5577 }
5578
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005579 return ret;
5580}
5581
5582static struct isl_platform_data isl_data __initdata = {
5583 .chgcurrent = 700,
5584 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5585 .chg_detection_config = isl_detection_setup,
5586 .max_system_voltage = 4200,
5587 .min_system_voltage = 3200,
5588 .term_current = 120,
5589 .input_current = 2048,
5590};
5591
5592static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5593 {
5594 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305595 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596 .platform_data = &isl_data,
5597 },
5598};
5599#endif
5600
5601#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5602static int smb137b_detection_setup(void)
5603{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305604 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005605
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305606 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5607 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5608 &isl_mpp[i].config);
5609 if (ret) {
5610 pr_err("%s: Config MPP %d of PM8058 failed\n",
5611 __func__, isl_mpp[i].mpp);
5612 return ret;
5613 }
5614 }
5615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616 return ret;
5617}
5618
5619static struct smb137b_platform_data smb137b_data __initdata = {
5620 .chg_detection_config = smb137b_detection_setup,
5621 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5622 .batt_mah_rating = 950,
5623};
5624
5625static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5626 {
5627 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305628 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005629 .platform_data = &smb137b_data,
5630 },
5631};
5632#endif
5633
5634#ifdef CONFIG_PMIC8058
5635#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305636#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005637
5638static int pm8058_gpios_init(void)
5639{
5640 int i;
5641 int rc;
5642 struct pm8058_gpio_cfg {
5643 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305644 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645 };
5646
5647 struct pm8058_gpio_cfg gpio_cfgs[] = {
5648 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305649 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005650 {
5651 .direction = PM_GPIO_DIR_IN,
5652 .pull = PM_GPIO_PULL_DN,
5653 .vin_sel = 2,
5654 .function = PM_GPIO_FUNC_NORMAL,
5655 .inv_int_pol = 0,
5656 },
5657 },
5658#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5659 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305660 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005661 {
5662 .direction = PM_GPIO_DIR_IN,
5663 .pull = PM_GPIO_PULL_UP_30,
5664 .vin_sel = 2,
5665 .function = PM_GPIO_FUNC_NORMAL,
5666 .inv_int_pol = 0,
5667 },
5668 },
5669#endif
5670 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305671 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005672 {
5673 .direction = PM_GPIO_DIR_IN,
5674 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305675 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005676 .function = PM_GPIO_FUNC_NORMAL,
5677 .inv_int_pol = 0,
5678 },
5679 },
5680 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305681 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005682 {
5683 .direction = PM_GPIO_DIR_IN,
5684 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305685 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005686 .function = PM_GPIO_FUNC_NORMAL,
5687 .inv_int_pol = 0,
5688 },
5689 },
5690 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305691 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005692 {
5693 .direction = PM_GPIO_DIR_IN,
5694 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305695 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005696 .function = PM_GPIO_FUNC_NORMAL,
5697 .inv_int_pol = 0,
5698 },
5699 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005700 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305701 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005702 {
5703 .direction = PM_GPIO_DIR_OUT,
5704 .output_value = 1,
5705 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5706 .pull = PM_GPIO_PULL_DN,
5707 .out_strength = PM_GPIO_STRENGTH_HIGH,
5708 .function = PM_GPIO_FUNC_NORMAL,
5709 .vin_sel = 2,
5710 .inv_int_pol = 0,
5711 }
5712 },
5713 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305714 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005715 {
5716 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305717 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005718 .function = PM_GPIO_FUNC_NORMAL,
5719 .vin_sel = 2,
5720 .inv_int_pol = 0,
5721 }
5722 },
5723 };
5724
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305725#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5726 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305727 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305728 .direction = PM_GPIO_DIR_IN,
5729 .pull = PM_GPIO_PULL_UP_1P5,
5730 .vin_sel = 2,
5731 .function = PM_GPIO_FUNC_NORMAL,
5732 };
5733#endif
5734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005735#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305736 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305737 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305738 .direction = PM_GPIO_DIR_OUT,
5739 .pull = PM_GPIO_PULL_NO,
5740 .out_strength = PM_GPIO_STRENGTH_HIGH,
5741 .function = PM_GPIO_FUNC_NORMAL,
5742 .inv_int_pol = 0,
5743 .vin_sel = 2,
5744 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5745 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005746 };
5747#endif
5748
5749#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5750 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305751 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752 {
5753 .direction = PM_GPIO_DIR_IN,
5754 .pull = PM_GPIO_PULL_UP_1P5,
5755 .vin_sel = 2,
5756 .function = PM_GPIO_FUNC_NORMAL,
5757 .inv_int_pol = 0,
5758 }
5759 };
5760#endif
5761
5762#if defined(CONFIG_QS_S5K4E1)
5763 {
5764 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305765 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005766 {
5767 .direction = PM_GPIO_DIR_OUT,
5768 .output_value = 0,
5769 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5770 .pull = PM_GPIO_PULL_DN,
5771 .out_strength = PM_GPIO_STRENGTH_HIGH,
5772 .function = PM_GPIO_FUNC_NORMAL,
5773 .vin_sel = 2,
5774 .inv_int_pol = 0,
5775 }
5776 };
5777#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005778#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5779 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305780 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005781 {
5782 .direction = PM_GPIO_DIR_OUT,
5783 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5784 .output_value = 1,
5785 .pull = PM_GPIO_PULL_UP_30,
5786 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305787 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005788 .out_strength = PM_GPIO_STRENGTH_HIGH,
5789 .function = PM_GPIO_FUNC_NORMAL,
5790 .inv_int_pol = 0,
5791 }
5792 };
5793#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794#if defined(CONFIG_HAPTIC_ISA1200) || \
5795 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5796 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305797 rc = pm8xxx_gpio_config(
5798 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5799 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005800 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305801 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005802 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305803 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305804 rc = pm8xxx_gpio_config(
5805 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5806 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305807 if (rc < 0) {
5808 pr_err("%s: pmic haptics ldo gpio config failed\n",
5809 __func__);
5810 }
5811
5812 }
5813#endif
5814
5815#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5816 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5817 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5818 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305819 rc = pm8xxx_gpio_config(
5820 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5821 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305822 if (rc < 0) {
5823 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5824 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005825 }
5826 }
5827#endif
5828
5829#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5830 /* Line_in only for 8660 ffa & surf */
5831 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005832 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005833 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305834 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005835 &line_in_gpio_cfg.cfg);
5836 if (rc < 0) {
5837 pr_err("%s pmic line_in gpio config failed\n",
5838 __func__);
5839 return rc;
5840 }
5841 }
5842#endif
5843
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005844#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5845 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305846 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005847 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5848 if (rc < 0) {
5849 pr_err("%s pmic gpio config failed\n", __func__);
5850 return rc;
5851 }
5852 }
5853#endif
5854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005855#if defined(CONFIG_QS_S5K4E1)
5856 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5857 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305858 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005859 &qs_hc37_cam_pd_gpio_cfg.cfg);
5860 if (rc < 0) {
5861 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5862 __func__);
5863 return rc;
5864 }
5865 }
5866 }
5867#endif
5868
5869 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305870 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005871 &gpio_cfgs[i].cfg);
5872 if (rc < 0) {
5873 pr_err("%s pmic gpio config failed\n",
5874 __func__);
5875 return rc;
5876 }
5877 }
5878
5879 return 0;
5880}
5881
5882static const unsigned int ffa_keymap[] = {
5883 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5884 KEY(0, 1, KEY_UP), /* NAV - UP */
5885 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5886 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5887
5888 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5889 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5890 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5891 KEY(1, 3, KEY_VOLUMEDOWN),
5892
5893 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5894
5895 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5896 KEY(4, 1, KEY_UP), /* USER_UP */
5897 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5898 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5899 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5900
5901 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5902 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5903 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5904 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5905 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5906};
5907
Zhang Chang Ken683be172011-08-10 17:45:34 -04005908static const unsigned int dragon_keymap[] = {
5909 KEY(0, 0, KEY_MENU),
5910 KEY(0, 2, KEY_1),
5911 KEY(0, 3, KEY_4),
5912 KEY(0, 4, KEY_7),
5913
5914 KEY(1, 0, KEY_UP),
5915 KEY(1, 1, KEY_LEFT),
5916 KEY(1, 2, KEY_DOWN),
5917 KEY(1, 3, KEY_5),
5918 KEY(1, 4, KEY_8),
5919
5920 KEY(2, 0, KEY_HOME),
5921 KEY(2, 1, KEY_REPLY),
5922 KEY(2, 2, KEY_2),
5923 KEY(2, 3, KEY_6),
5924 KEY(2, 4, KEY_0),
5925
5926 KEY(3, 0, KEY_VOLUMEUP),
5927 KEY(3, 1, KEY_RIGHT),
5928 KEY(3, 2, KEY_3),
5929 KEY(3, 3, KEY_9),
5930 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5931
5932 KEY(4, 0, KEY_VOLUMEDOWN),
5933 KEY(4, 1, KEY_BACK),
5934 KEY(4, 2, KEY_CAMERA),
5935 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5936};
5937
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005938static struct matrix_keymap_data ffa_keymap_data = {
5939 .keymap_size = ARRAY_SIZE(ffa_keymap),
5940 .keymap = ffa_keymap,
5941};
5942
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305943static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005944 .input_name = "ffa-keypad",
5945 .input_phys_device = "ffa-keypad/input0",
5946 .num_rows = 6,
5947 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305948 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5949 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5950 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005951 .scan_delay_ms = 32,
5952 .row_hold_ns = 91500,
5953 .wakeup = 1,
5954 .keymap_data = &ffa_keymap_data,
5955};
5956
Zhang Chang Ken683be172011-08-10 17:45:34 -04005957static struct matrix_keymap_data dragon_keymap_data = {
5958 .keymap_size = ARRAY_SIZE(dragon_keymap),
5959 .keymap = dragon_keymap,
5960};
5961
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305962static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005963 .input_name = "dragon-keypad",
5964 .input_phys_device = "dragon-keypad/input0",
5965 .num_rows = 6,
5966 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305967 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5968 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5969 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005970 .scan_delay_ms = 32,
5971 .row_hold_ns = 91500,
5972 .wakeup = 1,
5973 .keymap_data = &dragon_keymap_data,
5974};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305975
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005976static const unsigned int fluid_keymap[] = {
5977 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5978 KEY(0, 1, KEY_UP), /* NAV - UP */
5979 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5980 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5981
5982 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5983 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5984 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5985 KEY(1, 3, KEY_VOLUMEUP),
5986
5987 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5988
5989 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5990 KEY(4, 1, KEY_UP), /* USER_UP */
5991 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5992 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5993 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5994
Jilai Wang9a895102011-07-12 14:00:35 -04005995 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005996 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5997 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5998 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5999 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6000};
6001
6002static struct matrix_keymap_data fluid_keymap_data = {
6003 .keymap_size = ARRAY_SIZE(fluid_keymap),
6004 .keymap = fluid_keymap,
6005};
6006
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306007static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006008 .input_name = "fluid-keypad",
6009 .input_phys_device = "fluid-keypad/input0",
6010 .num_rows = 6,
6011 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306012 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6013 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6014 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006015 .scan_delay_ms = 32,
6016 .row_hold_ns = 91500,
6017 .wakeup = 1,
6018 .keymap_data = &fluid_keymap_data,
6019};
6020
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306021static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006022 .initial_vibrate_ms = 500,
6023 .level_mV = 3000,
6024 .max_timeout_ms = 15000,
6025};
6026
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306027static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6028 .rtc_write_enable = false,
6029 .rtc_alarm_powerup = false,
6030};
6031
6032static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6033 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006034 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306035 .wakeup = 1,
6036};
6037
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006038#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6039
6040static struct othc_accessory_info othc_accessories[] = {
6041 {
6042 .accessory = OTHC_SVIDEO_OUT,
6043 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6044 | OTHC_ADC_DETECT,
6045 .key_code = SW_VIDEOOUT_INSERT,
6046 .enabled = false,
6047 .adc_thres = {
6048 .min_threshold = 20,
6049 .max_threshold = 40,
6050 },
6051 },
6052 {
6053 .accessory = OTHC_ANC_HEADPHONE,
6054 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6055 OTHC_SWITCH_DETECT,
6056 .gpio = PM8058_LINE_IN_DET_GPIO,
6057 .active_low = 1,
6058 .key_code = SW_HEADPHONE_INSERT,
6059 .enabled = true,
6060 },
6061 {
6062 .accessory = OTHC_ANC_HEADSET,
6063 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6064 .gpio = PM8058_LINE_IN_DET_GPIO,
6065 .active_low = 1,
6066 .key_code = SW_HEADPHONE_INSERT,
6067 .enabled = true,
6068 },
6069 {
6070 .accessory = OTHC_HEADPHONE,
6071 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6072 .key_code = SW_HEADPHONE_INSERT,
6073 .enabled = true,
6074 },
6075 {
6076 .accessory = OTHC_MICROPHONE,
6077 .detect_flags = OTHC_GPIO_DETECT,
6078 .gpio = PM8058_LINE_IN_DET_GPIO,
6079 .active_low = 1,
6080 .key_code = SW_MICROPHONE_INSERT,
6081 .enabled = true,
6082 },
6083 {
6084 .accessory = OTHC_HEADSET,
6085 .detect_flags = OTHC_MICBIAS_DETECT,
6086 .key_code = SW_HEADPHONE_INSERT,
6087 .enabled = true,
6088 },
6089};
6090
6091static struct othc_switch_info switch_info[] = {
6092 {
6093 .min_adc_threshold = 0,
6094 .max_adc_threshold = 100,
6095 .key_code = KEY_PLAYPAUSE,
6096 },
6097 {
6098 .min_adc_threshold = 100,
6099 .max_adc_threshold = 200,
6100 .key_code = KEY_REWIND,
6101 },
6102 {
6103 .min_adc_threshold = 200,
6104 .max_adc_threshold = 500,
6105 .key_code = KEY_FASTFORWARD,
6106 },
6107};
6108
6109static struct othc_n_switch_config switch_config = {
6110 .voltage_settling_time_ms = 0,
6111 .num_adc_samples = 3,
6112 .adc_channel = CHANNEL_ADC_HDSET,
6113 .switch_info = switch_info,
6114 .num_keys = ARRAY_SIZE(switch_info),
6115 .default_sw_en = true,
6116 .default_sw_idx = 0,
6117};
6118
6119static struct hsed_bias_config hsed_bias_config = {
6120 /* HSED mic bias config info */
6121 .othc_headset = OTHC_HEADSET_NO,
6122 .othc_lowcurr_thresh_uA = 100,
6123 .othc_highcurr_thresh_uA = 600,
6124 .othc_hyst_prediv_us = 7800,
6125 .othc_period_clkdiv_us = 62500,
6126 .othc_hyst_clk_us = 121000,
6127 .othc_period_clk_us = 312500,
6128 .othc_wakeup = 1,
6129};
6130
6131static struct othc_hsed_config hsed_config_1 = {
6132 .hsed_bias_config = &hsed_bias_config,
6133 /*
6134 * The detection delay and switch reporting delay are
6135 * required to encounter a hardware bug (spurious switch
6136 * interrupts on slow insertion/removal of the headset).
6137 * This will introduce a delay in reporting the accessory
6138 * insertion and removal to the userspace.
6139 */
6140 .detection_delay_ms = 1500,
6141 /* Switch info */
6142 .switch_debounce_ms = 1500,
6143 .othc_support_n_switch = false,
6144 .switch_config = &switch_config,
6145 .ir_gpio = -1,
6146 /* Accessory info */
6147 .accessories_support = true,
6148 .accessories = othc_accessories,
6149 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6150};
6151
6152static struct othc_regulator_config othc_reg = {
6153 .regulator = "8058_l5",
6154 .max_uV = 2850000,
6155 .min_uV = 2850000,
6156};
6157
6158/* MIC_BIAS0 is configured as normal MIC BIAS */
6159static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6160 .micbias_select = OTHC_MICBIAS_0,
6161 .micbias_capability = OTHC_MICBIAS,
6162 .micbias_enable = OTHC_SIGNAL_OFF,
6163 .micbias_regulator = &othc_reg,
6164};
6165
6166/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6167static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6168 .micbias_select = OTHC_MICBIAS_1,
6169 .micbias_capability = OTHC_MICBIAS_HSED,
6170 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6171 .micbias_regulator = &othc_reg,
6172 .hsed_config = &hsed_config_1,
6173 .hsed_name = "8660_handset",
6174};
6175
6176/* MIC_BIAS2 is configured as normal MIC BIAS */
6177static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6178 .micbias_select = OTHC_MICBIAS_2,
6179 .micbias_capability = OTHC_MICBIAS,
6180 .micbias_enable = OTHC_SIGNAL_OFF,
6181 .micbias_regulator = &othc_reg,
6182};
6183
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006184
6185static void __init msm8x60_init_pm8058_othc(void)
6186{
6187 int i;
6188
6189 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6190 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6191 machine_is_msm8x60_fusn_ffa()) {
6192 /* 3-switch headset supported only by V2 FFA and FLUID */
6193 hsed_config_1.accessories_adc_support = true,
6194 /* ADC based accessory detection works only on V2 and FLUID */
6195 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6196 hsed_config_1.othc_support_n_switch = true;
6197 }
6198
6199 /* IR GPIO is absent on FLUID */
6200 if (machine_is_msm8x60_fluid())
6201 hsed_config_1.ir_gpio = -1;
6202
6203 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6204 if (machine_is_msm8x60_fluid()) {
6205 switch (othc_accessories[i].accessory) {
6206 case OTHC_ANC_HEADPHONE:
6207 case OTHC_ANC_HEADSET:
6208 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6209 break;
6210 case OTHC_MICROPHONE:
6211 othc_accessories[i].enabled = false;
6212 break;
6213 case OTHC_SVIDEO_OUT:
6214 othc_accessories[i].enabled = true;
6215 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6216 break;
6217 }
6218 }
6219 }
6220}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006222
6223static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6224{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306225 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006226 .direction = PM_GPIO_DIR_OUT,
6227 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6228 .output_value = 0,
6229 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306230 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006231 .out_strength = PM_GPIO_STRENGTH_HIGH,
6232 .function = PM_GPIO_FUNC_2,
6233 };
6234
6235 int rc = -EINVAL;
6236 int id, mode, max_mA;
6237
6238 id = mode = max_mA = 0;
6239 switch (ch) {
6240 case 0:
6241 case 1:
6242 case 2:
6243 if (on) {
6244 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306245 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6246 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006247 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306248 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006249 __func__, id, rc);
6250 }
6251 break;
6252
6253 case 6:
6254 id = PM_PWM_LED_FLASH;
6255 mode = PM_PWM_CONF_PWM1;
6256 max_mA = 300;
6257 break;
6258
6259 case 7:
6260 id = PM_PWM_LED_FLASH1;
6261 mode = PM_PWM_CONF_PWM1;
6262 max_mA = 300;
6263 break;
6264
6265 default:
6266 break;
6267 }
6268
6269 if (ch >= 6 && ch <= 7) {
6270 if (!on) {
6271 mode = PM_PWM_CONF_NONE;
6272 max_mA = 0;
6273 }
6274 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6275 if (rc)
6276 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6277 __func__, ch, rc);
6278 }
6279 return rc;
6280
6281}
6282
6283static struct pm8058_pwm_pdata pm8058_pwm_data = {
6284 .config = pm8058_pwm_config,
6285};
6286
6287#define PM8058_GPIO_INT 88
6288
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006289static struct pmic8058_led pmic8058_flash_leds[] = {
6290 [0] = {
6291 .name = "camera:flash0",
6292 .max_brightness = 15,
6293 .id = PMIC8058_ID_FLASH_LED_0,
6294 },
6295 [1] = {
6296 .name = "camera:flash1",
6297 .max_brightness = 15,
6298 .id = PMIC8058_ID_FLASH_LED_1,
6299 },
6300};
6301
6302static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6303 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6304 .leds = pmic8058_flash_leds,
6305};
6306
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006307static struct pmic8058_led pmic8058_dragon_leds[] = {
6308 [0] = {
6309 /* RED */
6310 .name = "led_drv0",
6311 .max_brightness = 15,
6312 .id = PMIC8058_ID_LED_0,
6313 },/* 300 mA flash led0 drv sink */
6314 [1] = {
6315 /* Yellow */
6316 .name = "led_drv1",
6317 .max_brightness = 15,
6318 .id = PMIC8058_ID_LED_1,
6319 },/* 300 mA flash led0 drv sink */
6320 [2] = {
6321 /* Green */
6322 .name = "led_drv2",
6323 .max_brightness = 15,
6324 .id = PMIC8058_ID_LED_2,
6325 },/* 300 mA flash led0 drv sink */
6326 [3] = {
6327 .name = "led_psensor",
6328 .max_brightness = 15,
6329 .id = PMIC8058_ID_LED_KB_LIGHT,
6330 },/* 300 mA flash led0 drv sink */
6331};
6332
6333static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6334 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6335 .leds = pmic8058_dragon_leds,
6336};
6337
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006338static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6339 [0] = {
6340 .name = "led:drv0",
6341 .max_brightness = 15,
6342 .id = PMIC8058_ID_FLASH_LED_0,
6343 },/* 300 mA flash led0 drv sink */
6344 [1] = {
6345 .name = "led:drv1",
6346 .max_brightness = 15,
6347 .id = PMIC8058_ID_FLASH_LED_1,
6348 },/* 300 mA flash led1 sink */
6349 [2] = {
6350 .name = "led:drv2",
6351 .max_brightness = 20,
6352 .id = PMIC8058_ID_LED_0,
6353 },/* 40 mA led0 sink */
6354 [3] = {
6355 .name = "keypad:drv",
6356 .max_brightness = 15,
6357 .id = PMIC8058_ID_LED_KB_LIGHT,
6358 },/* 300 mA keypad drv sink */
6359};
6360
6361static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6362 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6363 .leds = pmic8058_fluid_flash_leds,
6364};
6365
Terence Hampson90508a92011-08-09 10:40:08 -04006366static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306367 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006368 .max_source_current = 1800,
6369 .charger_type = CHG_TYPE_AC,
6370};
6371
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306372static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6373 .charger_data_valid = false,
6374};
6375
6376static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6377 .priority = 0,
6378};
6379
6380static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6381 .irq_base = PM8058_IRQ_BASE,
6382 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6383 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6384};
6385
6386static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6387 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6388};
6389
6390static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6391 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006392};
6393
6394static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306395 .irq_pdata = &pm8058_irq_pdata,
6396 .gpio_pdata = &pm8058_gpio_pdata,
6397 .mpp_pdata = &pm8058_mpp_pdata,
6398 .rtc_pdata = &pm8058_rtc_pdata,
6399 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6400 .othc0_pdata = &othc_config_pdata_0,
6401 .othc1_pdata = &othc_config_pdata_1,
6402 .othc2_pdata = &othc_config_pdata_2,
6403 .pwm_pdata = &pm8058_pwm_data,
6404 .misc_pdata = &pm8058_misc_pdata,
6405#ifdef CONFIG_SENSORS_MSM_ADC
6406 .xoadc_pdata = &pm8058_xoadc_pdata,
6407#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006408};
6409
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306410#ifdef CONFIG_MSM_SSBI
6411static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6412 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6413 .slave = {
6414 .name = "pm8058-core",
6415 .platform_data = &pm8058_platform_data,
6416 },
6417};
6418#endif
6419#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006420
6421#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6422 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6423#define TDISC_I2C_SLAVE_ADDR 0x67
6424#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6425#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6426
6427static const char *vregs_tdisc_name[] = {
6428 "8058_l5",
6429 "8058_s3",
6430};
6431
6432static const int vregs_tdisc_val[] = {
6433 2850000,/* uV */
6434 1800000,
6435};
6436static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6437
6438static int tdisc_shinetsu_setup(void)
6439{
6440 int rc, i;
6441
6442 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6443 if (rc) {
6444 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6445 __func__);
6446 return rc;
6447 }
6448
6449 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6450 if (rc) {
6451 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6452 __func__);
6453 goto fail_gpio_oe;
6454 }
6455
6456 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6457 if (rc) {
6458 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6459 __func__);
6460 gpio_free(GPIO_JOYSTICK_EN);
6461 goto fail_gpio_oe;
6462 }
6463
6464 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6465 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6466 if (IS_ERR(vregs_tdisc[i])) {
6467 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6468 __func__, vregs_tdisc_name[i],
6469 PTR_ERR(vregs_tdisc[i]));
6470 rc = PTR_ERR(vregs_tdisc[i]);
6471 goto vreg_get_fail;
6472 }
6473
6474 rc = regulator_set_voltage(vregs_tdisc[i],
6475 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6476 if (rc) {
6477 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6478 __func__, rc);
6479 goto vreg_set_voltage_fail;
6480 }
6481 }
6482
6483 return rc;
6484vreg_set_voltage_fail:
6485 i++;
6486vreg_get_fail:
6487 while (i)
6488 regulator_put(vregs_tdisc[--i]);
6489fail_gpio_oe:
6490 gpio_free(PMIC_GPIO_TDISC);
6491 return rc;
6492}
6493
6494static void tdisc_shinetsu_release(void)
6495{
6496 int i;
6497
6498 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6499 regulator_put(vregs_tdisc[i]);
6500
6501 gpio_free(PMIC_GPIO_TDISC);
6502 gpio_free(GPIO_JOYSTICK_EN);
6503}
6504
6505static int tdisc_shinetsu_enable(void)
6506{
6507 int i, rc = -EINVAL;
6508
6509 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6510 rc = regulator_enable(vregs_tdisc[i]);
6511 if (rc < 0) {
6512 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6513 __func__, vregs_tdisc_name[i], rc);
6514 goto vreg_fail;
6515 }
6516 }
6517
6518 /* Enable the OE (output enable) gpio */
6519 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6520 /* voltage and gpio stabilization delay */
6521 msleep(50);
6522
6523 return 0;
6524vreg_fail:
6525 while (i)
6526 regulator_disable(vregs_tdisc[--i]);
6527 return rc;
6528}
6529
6530static int tdisc_shinetsu_disable(void)
6531{
6532 int i, rc;
6533
6534 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6535 rc = regulator_disable(vregs_tdisc[i]);
6536 if (rc < 0) {
6537 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6538 __func__, vregs_tdisc_name[i], rc);
6539 goto tdisc_reg_fail;
6540 }
6541 }
6542
6543 /* Disable the OE (output enable) gpio */
6544 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6545
6546 return 0;
6547
6548tdisc_reg_fail:
6549 while (i)
6550 regulator_enable(vregs_tdisc[--i]);
6551 return rc;
6552}
6553
6554static struct tdisc_abs_values tdisc_abs = {
6555 .x_max = 32,
6556 .y_max = 32,
6557 .x_min = -32,
6558 .y_min = -32,
6559 .pressure_max = 32,
6560 .pressure_min = 0,
6561};
6562
6563static struct tdisc_platform_data tdisc_data = {
6564 .tdisc_setup = tdisc_shinetsu_setup,
6565 .tdisc_release = tdisc_shinetsu_release,
6566 .tdisc_enable = tdisc_shinetsu_enable,
6567 .tdisc_disable = tdisc_shinetsu_disable,
6568 .tdisc_wakeup = 0,
6569 .tdisc_gpio = PMIC_GPIO_TDISC,
6570 .tdisc_report_keys = true,
6571 .tdisc_report_relative = true,
6572 .tdisc_report_absolute = false,
6573 .tdisc_report_wheel = false,
6574 .tdisc_reverse_x = false,
6575 .tdisc_reverse_y = true,
6576 .tdisc_abs = &tdisc_abs,
6577};
6578
6579static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6580 {
6581 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6582 .irq = TDISC_INT,
6583 .platform_data = &tdisc_data,
6584 },
6585};
6586#endif
6587
6588#define PM_GPIO_CDC_RST_N 20
6589#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6590
6591static struct regulator *vreg_timpani_1;
6592static struct regulator *vreg_timpani_2;
6593
6594static unsigned int msm_timpani_setup_power(void)
6595{
6596 int rc;
6597
6598 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6599 if (IS_ERR(vreg_timpani_1)) {
6600 pr_err("%s: Unable to get 8058_l0\n", __func__);
6601 return -ENODEV;
6602 }
6603
6604 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6605 if (IS_ERR(vreg_timpani_2)) {
6606 pr_err("%s: Unable to get 8058_s3\n", __func__);
6607 regulator_put(vreg_timpani_1);
6608 return -ENODEV;
6609 }
6610
6611 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6612 if (rc) {
6613 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6614 goto fail;
6615 }
6616
6617 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6618 if (rc) {
6619 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6620 goto fail;
6621 }
6622
6623 rc = regulator_enable(vreg_timpani_1);
6624 if (rc) {
6625 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6626 goto fail;
6627 }
6628
6629 /* The settings for LDO0 should be set such that
6630 * it doesn't require to reset the timpani. */
6631 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6632 if (rc < 0) {
6633 pr_err("Timpani regulator optimum mode setting failed\n");
6634 goto fail;
6635 }
6636
6637 rc = regulator_enable(vreg_timpani_2);
6638 if (rc) {
6639 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6640 regulator_disable(vreg_timpani_1);
6641 goto fail;
6642 }
6643
6644 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6645 if (rc) {
6646 pr_err("%s: GPIO Request %d failed\n", __func__,
6647 GPIO_CDC_RST_N);
6648 regulator_disable(vreg_timpani_1);
6649 regulator_disable(vreg_timpani_2);
6650 goto fail;
6651 } else {
6652 gpio_direction_output(GPIO_CDC_RST_N, 1);
6653 usleep_range(1000, 1050);
6654 gpio_direction_output(GPIO_CDC_RST_N, 0);
6655 usleep_range(1000, 1050);
6656 gpio_direction_output(GPIO_CDC_RST_N, 1);
6657 gpio_free(GPIO_CDC_RST_N);
6658 }
6659 return rc;
6660
6661fail:
6662 regulator_put(vreg_timpani_1);
6663 regulator_put(vreg_timpani_2);
6664 return rc;
6665}
6666
6667static void msm_timpani_shutdown_power(void)
6668{
6669 int rc;
6670
6671 rc = regulator_disable(vreg_timpani_1);
6672 if (rc)
6673 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6674
6675 regulator_put(vreg_timpani_1);
6676
6677 rc = regulator_disable(vreg_timpani_2);
6678 if (rc)
6679 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6680
6681 regulator_put(vreg_timpani_2);
6682}
6683
6684/* Power analog function of codec */
6685static struct regulator *vreg_timpani_cdc_apwr;
6686static int msm_timpani_codec_power(int vreg_on)
6687{
6688 int rc = 0;
6689
6690 if (!vreg_timpani_cdc_apwr) {
6691
6692 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6693
6694 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6695 pr_err("%s: vreg_get failed (%ld)\n",
6696 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6697 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6698 return rc;
6699 }
6700 }
6701
6702 if (vreg_on) {
6703
6704 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6705 2200000, 2200000);
6706 if (rc) {
6707 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6708 __func__);
6709 goto vreg_fail;
6710 }
6711
6712 rc = regulator_enable(vreg_timpani_cdc_apwr);
6713 if (rc) {
6714 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6715 goto vreg_fail;
6716 }
6717 } else {
6718 rc = regulator_disable(vreg_timpani_cdc_apwr);
6719 if (rc) {
6720 pr_err("%s: vreg_disable failed %d\n",
6721 __func__, rc);
6722 goto vreg_fail;
6723 }
6724 }
6725
6726 return 0;
6727
6728vreg_fail:
6729 regulator_put(vreg_timpani_cdc_apwr);
6730 vreg_timpani_cdc_apwr = NULL;
6731 return rc;
6732}
6733
6734static struct marimba_codec_platform_data timpani_codec_pdata = {
6735 .marimba_codec_power = msm_timpani_codec_power,
6736};
6737
6738#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6739#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6740
6741static struct marimba_platform_data timpani_pdata = {
6742 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6743 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6744 .marimba_setup = msm_timpani_setup_power,
6745 .marimba_shutdown = msm_timpani_shutdown_power,
6746 .codec = &timpani_codec_pdata,
6747 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6748};
6749
6750#define TIMPANI_I2C_SLAVE_ADDR 0xD
6751
6752static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6753 {
6754 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6755 .platform_data = &timpani_pdata,
6756 },
6757};
6758
Lei Zhou338cab82011-08-19 13:38:17 -04006759#ifdef CONFIG_SND_SOC_WM8903
6760static struct wm8903_platform_data wm8903_pdata = {
6761 .gpio_cfg[2] = 0x3A8,
6762};
6763
6764#define WM8903_I2C_SLAVE_ADDR 0x34
6765static struct i2c_board_info wm8903_codec_i2c_info[] = {
6766 {
6767 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6768 .platform_data = &wm8903_pdata,
6769 },
6770};
6771#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006772#ifdef CONFIG_PMIC8901
6773
6774#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006775/*
6776 * Consumer specific regulator names:
6777 * regulator name consumer dev_name
6778 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006779static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6780 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6781};
6782static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6783 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6784};
6785
6786#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306787 _always_on) \
6788 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006789 .init_data = { \
6790 .constraints = { \
6791 .valid_modes_mask = _modes, \
6792 .valid_ops_mask = _ops, \
6793 .min_uV = _min_uV, \
6794 .max_uV = _max_uV, \
6795 .input_uV = _min_uV, \
6796 .apply_uV = _apply_uV, \
6797 .always_on = _always_on, \
6798 }, \
6799 .consumer_supplies = vreg_consumers_8901_##_id, \
6800 .num_consumer_supplies = \
6801 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6802 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306803 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006804 }
6805
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006806#define PM8901_VREG_INIT_VS(_id) \
6807 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306808 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006809
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306810static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006811 PM8901_VREG_INIT_VS(USB_OTG),
6812 PM8901_VREG_INIT_VS(HDMI_MVS),
6813};
6814
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306815static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6816 .priority = 1,
6817};
6818
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306819static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6820 .irq_base = PM8901_IRQ_BASE,
6821 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6822 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6823};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006824
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306825static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6826 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006827};
6828
6829static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306830 .irq_pdata = &pm8901_irq_pdata,
6831 .mpp_pdata = &pm8901_mpp_pdata,
6832 .regulator_pdatas = pm8901_vreg_init,
6833 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306834 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006835};
6836
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306837static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6838 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6839 .slave = {
6840 .name = "pm8901-core",
6841 .platform_data = &pm8901_platform_data,
6842 },
6843};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006844#endif /* CONFIG_PMIC8901 */
6845
6846#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6847 || defined(CONFIG_GPIO_SX150X_MODULE))
6848
6849static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006850static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006851
6852struct bahama_config_register{
6853 u8 reg;
6854 u8 value;
6855 u8 mask;
6856};
6857
6858enum version{
6859 VER_1_0,
6860 VER_2_0,
6861 VER_UNSUPPORTED = 0xFF
6862};
6863
6864static u8 read_bahama_ver(void)
6865{
6866 int rc;
6867 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6868 u8 bahama_version;
6869
6870 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6871 if (rc < 0) {
6872 printk(KERN_ERR
6873 "%s: version read failed: %d\n",
6874 __func__, rc);
6875 return VER_UNSUPPORTED;
6876 } else {
6877 printk(KERN_INFO
6878 "%s: version read got: 0x%x\n",
6879 __func__, bahama_version);
6880 }
6881
6882 switch (bahama_version) {
6883 case 0x08: /* varient of bahama v1 */
6884 case 0x10:
6885 case 0x00:
6886 return VER_1_0;
6887 case 0x09: /* variant of bahama v2 */
6888 return VER_2_0;
6889 default:
6890 return VER_UNSUPPORTED;
6891 }
6892}
6893
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006894static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006895static unsigned int msm_bahama_setup_power(void)
6896{
6897 int rc = 0;
6898 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006899
6900 if (machine_is_msm8x60_dragon())
6901 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6902
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006903 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6904
6905 if (IS_ERR(vreg_bahama)) {
6906 rc = PTR_ERR(vreg_bahama);
6907 pr_err("%s: regulator_get %s = %d\n", __func__,
6908 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006909 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006910 }
6911
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006912 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6913 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006914 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6915 msm_bahama_regulator, rc);
6916 goto unget;
6917 }
6918
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006919 rc = regulator_enable(vreg_bahama);
6920 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006921 pr_err("%s: regulator_enable %s = %d\n", __func__,
6922 msm_bahama_regulator, rc);
6923 goto unget;
6924 }
6925
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006926 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6927 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006928 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006929 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006930 goto unenable;
6931 }
6932
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006933 gpio_direction_output(msm_bahama_sys_rst, 0);
6934 usleep_range(1000, 1050);
6935 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6936 usleep_range(1000, 1050);
6937 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006938 return rc;
6939
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006940unenable:
6941 regulator_disable(vreg_bahama);
6942unget:
6943 regulator_put(vreg_bahama);
6944 return rc;
6945};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006946
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006947static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006948{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006949 if (msm_bahama_setup_power_enable) {
6950 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6951 gpio_free(msm_bahama_sys_rst);
6952 regulator_disable(vreg_bahama);
6953 regulator_put(vreg_bahama);
6954 msm_bahama_setup_power_enable = 0;
6955 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956
6957 return 0;
6958};
6959
6960static unsigned int msm_bahama_core_config(int type)
6961{
6962 int rc = 0;
6963
6964 if (type == BAHAMA_ID) {
6965
6966 int i;
6967 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6968
6969 const struct bahama_config_register v20_init[] = {
6970 /* reg, value, mask */
6971 { 0xF4, 0x84, 0xFF }, /* AREG */
6972 { 0xF0, 0x04, 0xFF } /* DREG */
6973 };
6974
6975 if (read_bahama_ver() == VER_2_0) {
6976 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6977 u8 value = v20_init[i].value;
6978 rc = marimba_write_bit_mask(&config,
6979 v20_init[i].reg,
6980 &value,
6981 sizeof(v20_init[i].value),
6982 v20_init[i].mask);
6983 if (rc < 0) {
6984 printk(KERN_ERR
6985 "%s: reg %d write failed: %d\n",
6986 __func__, v20_init[i].reg, rc);
6987 return rc;
6988 }
6989 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6990 " mask 0x%02x\n",
6991 __func__, v20_init[i].reg,
6992 v20_init[i].value, v20_init[i].mask);
6993 }
6994 }
6995 }
6996 printk(KERN_INFO "core type: %d\n", type);
6997
6998 return rc;
6999}
7000
7001static struct regulator *fm_regulator_s3;
7002static struct msm_xo_voter *fm_clock;
7003
7004static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7005{
7006 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307007 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007008 .direction = PM_GPIO_DIR_IN,
7009 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307010 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007011 .function = PM_GPIO_FUNC_NORMAL,
7012 .inv_int_pol = 0,
7013 };
7014
7015 if (!fm_regulator_s3) {
7016 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7017 if (IS_ERR(fm_regulator_s3)) {
7018 rc = PTR_ERR(fm_regulator_s3);
7019 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7020 __func__, rc);
7021 goto out;
7022 }
7023 }
7024
7025
7026 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7027 if (rc < 0) {
7028 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7029 __func__, rc);
7030 goto fm_fail_put;
7031 }
7032
7033 rc = regulator_enable(fm_regulator_s3);
7034 if (rc < 0) {
7035 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7036 __func__, rc);
7037 goto fm_fail_put;
7038 }
7039
7040 /*Vote for XO clock*/
7041 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7042
7043 if (IS_ERR(fm_clock)) {
7044 rc = PTR_ERR(fm_clock);
7045 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7046 __func__, rc);
7047 goto fm_fail_switch;
7048 }
7049
7050 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7051 if (rc < 0) {
7052 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7053 __func__, rc);
7054 goto fm_fail_vote;
7055 }
7056
7057 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307058 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007059 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307060 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007061 __func__, rc);
7062 goto fm_fail_clock;
7063 }
7064 goto out;
7065
7066fm_fail_clock:
7067 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7068fm_fail_vote:
7069 msm_xo_put(fm_clock);
7070fm_fail_switch:
7071 regulator_disable(fm_regulator_s3);
7072fm_fail_put:
7073 regulator_put(fm_regulator_s3);
7074out:
7075 return rc;
7076};
7077
7078static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7079{
7080 int rc = 0;
7081 if (fm_regulator_s3 != NULL) {
7082 rc = regulator_disable(fm_regulator_s3);
7083 if (rc < 0) {
7084 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7085 __func__, rc);
7086 }
7087 regulator_put(fm_regulator_s3);
7088 fm_regulator_s3 = NULL;
7089 }
7090 printk(KERN_ERR "%s: Voting off for XO", __func__);
7091
7092 if (fm_clock != NULL) {
7093 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7094 if (rc < 0) {
7095 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7096 __func__, rc);
7097 }
7098 msm_xo_put(fm_clock);
7099 }
7100 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7101}
7102
7103/* Slave id address for FM/CDC/QMEMBIST
7104 * Values can be programmed using Marimba slave id 0
7105 * should there be a conflict with other I2C devices
7106 * */
7107#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7108#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7109
7110static struct marimba_fm_platform_data marimba_fm_pdata = {
7111 .fm_setup = fm_radio_setup,
7112 .fm_shutdown = fm_radio_shutdown,
7113 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7114 .is_fm_soc_i2s_master = false,
7115 .config_i2s_gpio = NULL,
7116};
7117
7118/*
7119Just initializing the BAHAMA related slave
7120*/
7121static struct marimba_platform_data marimba_pdata = {
7122 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7123 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7124 .bahama_setup = msm_bahama_setup_power,
7125 .bahama_shutdown = msm_bahama_shutdown_power,
7126 .bahama_core_config = msm_bahama_core_config,
7127 .fm = &marimba_fm_pdata,
7128 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7129};
7130
7131
7132static struct i2c_board_info msm_marimba_board_info[] = {
7133 {
7134 I2C_BOARD_INFO("marimba", 0xc),
7135 .platform_data = &marimba_pdata,
7136 }
7137};
7138#endif /* CONFIG_MAIMBA_CORE */
7139
7140#ifdef CONFIG_I2C
7141#define I2C_SURF 1
7142#define I2C_FFA (1 << 1)
7143#define I2C_RUMI (1 << 2)
7144#define I2C_SIM (1 << 3)
7145#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007146#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007147
7148struct i2c_registry {
7149 u8 machs;
7150 int bus;
7151 struct i2c_board_info *info;
7152 int len;
7153};
7154
7155static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007156#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7157 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007158 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007159 MSM_GSBI8_QUP_I2C_BUS_ID,
7160 core_expander_i2c_info,
7161 ARRAY_SIZE(core_expander_i2c_info),
7162 },
7163 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007164 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007165 MSM_GSBI8_QUP_I2C_BUS_ID,
7166 docking_expander_i2c_info,
7167 ARRAY_SIZE(docking_expander_i2c_info),
7168 },
7169 {
7170 I2C_SURF,
7171 MSM_GSBI8_QUP_I2C_BUS_ID,
7172 surf_expanders_i2c_info,
7173 ARRAY_SIZE(surf_expanders_i2c_info),
7174 },
7175 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007176 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007177 MSM_GSBI3_QUP_I2C_BUS_ID,
7178 fha_expanders_i2c_info,
7179 ARRAY_SIZE(fha_expanders_i2c_info),
7180 },
7181 {
7182 I2C_FLUID,
7183 MSM_GSBI3_QUP_I2C_BUS_ID,
7184 fluid_expanders_i2c_info,
7185 ARRAY_SIZE(fluid_expanders_i2c_info),
7186 },
7187 {
7188 I2C_FLUID,
7189 MSM_GSBI8_QUP_I2C_BUS_ID,
7190 fluid_core_expander_i2c_info,
7191 ARRAY_SIZE(fluid_core_expander_i2c_info),
7192 },
7193#endif
7194#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7195 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7196 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007197 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007198 MSM_GSBI3_QUP_I2C_BUS_ID,
7199 msm_i2c_gsbi3_tdisc_info,
7200 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7201 },
7202#endif
7203 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007204 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007205 MSM_GSBI3_QUP_I2C_BUS_ID,
7206 cy8ctmg200_board_info,
7207 ARRAY_SIZE(cy8ctmg200_board_info),
7208 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007209 {
7210 I2C_DRAGON,
7211 MSM_GSBI3_QUP_I2C_BUS_ID,
7212 cy8ctma340_dragon_board_info,
7213 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7214 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007215#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7216 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7217 {
7218 I2C_FLUID,
7219 MSM_GSBI3_QUP_I2C_BUS_ID,
7220 cyttsp_fluid_info,
7221 ARRAY_SIZE(cyttsp_fluid_info),
7222 },
7223 {
7224 I2C_FFA | I2C_SURF,
7225 MSM_GSBI3_QUP_I2C_BUS_ID,
7226 cyttsp_ffa_info,
7227 ARRAY_SIZE(cyttsp_ffa_info),
7228 },
7229#endif
7230#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007231#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007232 {
7233 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007234 MSM_GSBI4_QUP_I2C_BUS_ID,
7235 msm_camera_boardinfo,
7236 ARRAY_SIZE(msm_camera_boardinfo),
7237 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007238 {
7239 I2C_DRAGON,
7240 MSM_GSBI4_QUP_I2C_BUS_ID,
7241 msm_camera_dragon_boardinfo,
7242 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7243 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007244#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007245#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007246 {
7247 I2C_SURF | I2C_FFA | I2C_FLUID,
7248 MSM_GSBI7_QUP_I2C_BUS_ID,
7249 msm_i2c_gsbi7_timpani_info,
7250 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7251 },
7252#if defined(CONFIG_MARIMBA_CORE)
7253 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007254 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007255 MSM_GSBI7_QUP_I2C_BUS_ID,
7256 msm_marimba_board_info,
7257 ARRAY_SIZE(msm_marimba_board_info),
7258 },
7259#endif /* CONFIG_MARIMBA_CORE */
7260#ifdef CONFIG_ISL9519_CHARGER
7261 {
7262 I2C_SURF | I2C_FFA,
7263 MSM_GSBI8_QUP_I2C_BUS_ID,
7264 isl_charger_i2c_info,
7265 ARRAY_SIZE(isl_charger_i2c_info),
7266 },
7267#endif
7268#if defined(CONFIG_HAPTIC_ISA1200) || \
7269 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7270 {
7271 I2C_FLUID,
7272 MSM_GSBI8_QUP_I2C_BUS_ID,
7273 msm_isa1200_board_info,
7274 ARRAY_SIZE(msm_isa1200_board_info),
7275 },
7276#endif
7277#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7278 {
7279 I2C_FLUID,
7280 MSM_GSBI8_QUP_I2C_BUS_ID,
7281 smb137b_charger_i2c_info,
7282 ARRAY_SIZE(smb137b_charger_i2c_info),
7283 },
7284#endif
7285#if defined(CONFIG_BATTERY_BQ27520) || \
7286 defined(CONFIG_BATTERY_BQ27520_MODULE)
7287 {
7288 I2C_FLUID,
7289 MSM_GSBI8_QUP_I2C_BUS_ID,
7290 msm_bq27520_board_info,
7291 ARRAY_SIZE(msm_bq27520_board_info),
7292 },
7293#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007294#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7295 {
7296 I2C_DRAGON,
7297 MSM_GSBI8_QUP_I2C_BUS_ID,
7298 wm8903_codec_i2c_info,
7299 ARRAY_SIZE(wm8903_codec_i2c_info),
7300 },
7301#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007302};
7303#endif /* CONFIG_I2C */
7304
Stephen Boyd668d7652012-04-25 11:31:01 -07007305static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007306{
7307#ifdef CONFIG_I2C
7308#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7309 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7310 sx150x_data[SX150X_CORE].irq_summary =
7311 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007312 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7313 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007314 sx150x_data[SX150X_CORE].irq_summary =
7315 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7316 else if (machine_is_msm8x60_fluid())
7317 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7318 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7319#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007320#endif
7321}
7322
Stephen Boyd668d7652012-04-25 11:31:01 -07007323static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007324{
7325#ifdef CONFIG_I2C
7326 u8 mach_mask = 0;
7327 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007328#ifdef CONFIG_MSM_CAMERA_V4L2
7329 struct i2c_registry msm8x60_camera_i2c_devices = {
7330 I2C_SURF | I2C_FFA | I2C_FLUID,
7331 MSM_GSBI4_QUP_I2C_BUS_ID,
7332 msm8x60_camera_board_info.board_info,
7333 msm8x60_camera_board_info.num_i2c_board_info,
7334 };
7335#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007336
7337 /* Build the matching 'supported_machs' bitmask */
7338 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7339 mach_mask = I2C_SURF;
7340 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7341 mach_mask = I2C_FFA;
7342 else if (machine_is_msm8x60_rumi3())
7343 mach_mask = I2C_RUMI;
7344 else if (machine_is_msm8x60_sim())
7345 mach_mask = I2C_SIM;
7346 else if (machine_is_msm8x60_fluid())
7347 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007348 else if (machine_is_msm8x60_dragon())
7349 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007350 else
7351 pr_err("unmatched machine ID in register_i2c_devices\n");
7352
7353 /* Run the array and install devices as appropriate */
7354 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7355 if (msm8x60_i2c_devices[i].machs & mach_mask)
7356 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7357 msm8x60_i2c_devices[i].info,
7358 msm8x60_i2c_devices[i].len);
7359 }
Kevin Chan3be11612012-03-22 20:05:40 -07007360#ifdef CONFIG_MSM_CAMERA_V4L2
7361 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7362 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7363 msm8x60_camera_i2c_devices.info,
7364 msm8x60_camera_i2c_devices.len);
7365#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007366#endif
7367}
7368
7369static void __init msm8x60_init_uart12dm(void)
7370{
7371#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7372 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7373 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7374
7375 if (!fpga_mem)
7376 pr_err("%s(): Error getting memory\n", __func__);
7377
7378 /* Advanced mode */
7379 writew(0xFFFF, fpga_mem + 0x15C);
7380 /* FPGA_UART_SEL */
7381 writew(0, fpga_mem + 0x172);
7382 /* FPGA_GPIO_CONFIG_117 */
7383 writew(1, fpga_mem + 0xEA);
7384 /* FPGA_GPIO_CONFIG_118 */
7385 writew(1, fpga_mem + 0xEC);
7386 mb();
7387 iounmap(fpga_mem);
7388#endif
7389}
7390
7391#define MSM_GSBI9_PHYS 0x19900000
7392#define GSBI_DUAL_MODE_CODE 0x60
7393
7394static void __init msm8x60_init_buses(void)
7395{
7396#ifdef CONFIG_I2C_QUP
7397 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7398 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7399 writel_relaxed(0x6 << 4, gsbi_mem);
7400 /* Ensure protocol code is written before proceeding further */
7401 mb();
7402 iounmap(gsbi_mem);
7403
7404 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7405 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7406 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7407 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7408
7409#ifdef CONFIG_MSM_GSBI9_UART
7410 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7411 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7412 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7413 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7414 iounmap(gsbi_mem);
7415 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7416 }
7417#endif
7418 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7419 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7420#endif
7421#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7422 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7423#endif
7424#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007425 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7426#endif
7427
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307428#ifdef CONFIG_MSM_SSBI
7429 msm_device_ssbi_pmic1.dev.platform_data =
7430 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307431 msm_device_ssbi_pmic2.dev.platform_data =
7432 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307433#endif
7434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007435 if (machine_is_msm8x60_fluid()) {
7436#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7437 (defined(CONFIG_SMB137B_CHARGER) || \
7438 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7439 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7440#endif
7441#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7442 msm_gsbi10_qup_spi_device.dev.platform_data =
7443 &msm_gsbi10_qup_spi_pdata;
7444#endif
7445 }
7446
Lena Salman57d167e2012-03-21 19:46:38 +02007447#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007448 /*
7449 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7450 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7451 * and ID notifications are available only on V2 surf and FFA
7452 * with a hardware workaround.
7453 */
7454 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7455 (machine_is_msm8x60_surf() ||
7456 (machine_is_msm8x60_ffa() &&
7457 pmic_id_notif_supported)))
7458 msm_otg_pdata.phy_can_powercollapse = 1;
7459 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7460#endif
7461
Lena Salman57d167e2012-03-21 19:46:38 +02007462#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007463 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7464#endif
7465
7466#ifdef CONFIG_SERIAL_MSM_HS
7467 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7468 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7469#endif
7470#ifdef CONFIG_MSM_GSBI9_UART
7471 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7472 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7473 if (IS_ERR(msm_device_uart_gsbi9))
7474 pr_err("%s(): Failed to create uart gsbi9 device\n",
7475 __func__);
7476 }
7477#endif
7478
7479#ifdef CONFIG_MSM_BUS_SCALING
7480
7481 /* RPM calls are only enabled on V2 */
7482 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7483 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7484 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7485 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7486 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7487 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7488 }
7489
7490 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7491 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7492 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7493 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7494 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7495#endif
7496}
7497
7498static void __init msm8x60_map_io(void)
7499{
7500 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7501 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007502
7503 if (socinfo_init() < 0)
7504 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007505}
7506
7507/*
7508 * Most segments of the EBI2 bus are disabled by default.
7509 */
7510static void __init msm8x60_init_ebi2(void)
7511{
7512 uint32_t ebi2_cfg;
7513 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007514 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7515
7516 if (IS_ERR(mem_clk)) {
7517 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7518 "msm_ebi2", "mem_clk");
7519 return;
7520 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007521 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007522 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007523
7524 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7525 if (ebi2_cfg_ptr != 0) {
7526 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7527
7528 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007529 machine_is_msm8x60_fluid() ||
7530 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007531 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7532 else if (machine_is_msm8x60_sim())
7533 ebi2_cfg |= (1 << 4); /* CS2 */
7534 else if (machine_is_msm8x60_rumi3())
7535 ebi2_cfg |= (1 << 5); /* CS3 */
7536
7537 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7538 iounmap(ebi2_cfg_ptr);
7539 }
7540
7541 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007542 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007543 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7544 if (ebi2_cfg_ptr != 0) {
7545 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7546 writel_relaxed(0UL, ebi2_cfg_ptr);
7547
7548 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7549 * LAN9221 Ethernet controller reads and writes.
7550 * The lowest 4 bits are the read delay, the next
7551 * 4 are the write delay. */
7552 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7553#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7554 /*
7555 * RECOVERY=5, HOLD_WR=1
7556 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7557 * WAIT_WR=1, WAIT_RD=2
7558 */
7559 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7560 /*
7561 * HOLD_RD=1
7562 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7563 */
7564 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7565#else
7566 /* EBI2 CS3 muxed address/data,
7567 * two cyc addr enable */
7568 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7569
7570#endif
7571 iounmap(ebi2_cfg_ptr);
7572 }
7573 }
7574}
7575
7576static void __init msm8x60_configure_smc91x(void)
7577{
7578 if (machine_is_msm8x60_sim()) {
7579
7580 smc91x_resources[0].start = 0x1b800300;
7581 smc91x_resources[0].end = 0x1b8003ff;
7582
7583 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7584 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7585
7586 } else if (machine_is_msm8x60_rumi3()) {
7587
7588 smc91x_resources[0].start = 0x1d000300;
7589 smc91x_resources[0].end = 0x1d0003ff;
7590
7591 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7592 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7593 }
7594}
7595
7596static void __init msm8x60_init_tlmm(void)
7597{
7598 if (machine_is_msm8x60_rumi3())
7599 msm_gpio_install_direct_irq(0, 0, 1);
7600}
7601
7602#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7603 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7604 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7605 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7606 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7607
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007608/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007609#define MAX_SDCC_CONTROLLER 5
7610
7611struct msm_sdcc_gpio {
7612 /* maximum 10 GPIOs per SDCC controller */
7613 s16 no;
7614 /* name of this GPIO */
7615 const char *name;
7616 bool always_on;
7617 bool is_enabled;
7618};
7619
7620#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7621static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7622 {159, "sdc1_dat_0"},
7623 {160, "sdc1_dat_1"},
7624 {161, "sdc1_dat_2"},
7625 {162, "sdc1_dat_3"},
7626#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7627 {163, "sdc1_dat_4"},
7628 {164, "sdc1_dat_5"},
7629 {165, "sdc1_dat_6"},
7630 {166, "sdc1_dat_7"},
7631#endif
7632 {167, "sdc1_clk"},
7633 {168, "sdc1_cmd"}
7634};
7635#endif
7636
7637#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7638static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7639 {143, "sdc2_dat_0"},
7640 {144, "sdc2_dat_1", 1},
7641 {145, "sdc2_dat_2"},
7642 {146, "sdc2_dat_3"},
7643#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7644 {147, "sdc2_dat_4"},
7645 {148, "sdc2_dat_5"},
7646 {149, "sdc2_dat_6"},
7647 {150, "sdc2_dat_7"},
7648#endif
7649 {151, "sdc2_cmd"},
7650 {152, "sdc2_clk", 1}
7651};
7652#endif
7653
7654#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7655static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7656 {95, "sdc5_cmd"},
7657 {96, "sdc5_dat_3"},
7658 {97, "sdc5_clk", 1},
7659 {98, "sdc5_dat_2"},
7660 {99, "sdc5_dat_1", 1},
7661 {100, "sdc5_dat_0"}
7662};
7663#endif
7664
7665struct msm_sdcc_pad_pull_cfg {
7666 enum msm_tlmm_pull_tgt pull;
7667 u32 pull_val;
7668};
7669
7670struct msm_sdcc_pad_drv_cfg {
7671 enum msm_tlmm_hdrive_tgt drv;
7672 u32 drv_val;
7673};
7674
7675#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7676static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7677 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7678 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7679 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7680};
7681
7682static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7683 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7684 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7685};
7686
7687static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7688 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7689 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7690 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7691};
7692
7693static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7694 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7695 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7696};
7697#endif
7698
7699#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7700static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7701 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7702 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7703 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7704};
7705
7706static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7707 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7708 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7709};
7710
7711static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7712 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7713 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7714 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7715};
7716
7717static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7718 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7719 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7720};
7721#endif
7722
7723struct msm_sdcc_pin_cfg {
7724 /*
7725 * = 1 if controller pins are using gpios
7726 * = 0 if controller has dedicated MSM pins
7727 */
7728 u8 is_gpio;
7729 u8 cfg_sts;
7730 u8 gpio_data_size;
7731 struct msm_sdcc_gpio *gpio_data;
7732 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7733 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7734 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7735 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7736 u8 pad_drv_data_size;
7737 u8 pad_pull_data_size;
7738 u8 sdio_lpm_gpio_cfg;
7739};
7740
7741
7742static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7743#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7744 [0] = {
7745 .is_gpio = 1,
7746 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7747 .gpio_data = sdc1_gpio_cfg
7748 },
7749#endif
7750#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7751 [1] = {
7752 .is_gpio = 1,
7753 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7754 .gpio_data = sdc2_gpio_cfg
7755 },
7756#endif
7757#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7758 [2] = {
7759 .is_gpio = 0,
7760 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7761 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7762 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7763 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7764 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7765 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7766 },
7767#endif
7768#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7769 [3] = {
7770 .is_gpio = 0,
7771 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7772 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7773 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7774 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7775 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7776 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7777 },
7778#endif
7779#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7780 [4] = {
7781 .is_gpio = 1,
7782 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7783 .gpio_data = sdc5_gpio_cfg
7784 }
7785#endif
7786};
7787
7788static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7789{
7790 int rc = 0;
7791 struct msm_sdcc_pin_cfg *curr;
7792 int n;
7793
7794 curr = &sdcc_pin_cfg_data[dev_id - 1];
7795 if (!curr->gpio_data)
7796 goto out;
7797
7798 for (n = 0; n < curr->gpio_data_size; n++) {
7799 if (enable) {
7800
7801 if (curr->gpio_data[n].always_on &&
7802 curr->gpio_data[n].is_enabled)
7803 continue;
7804 pr_debug("%s: enable: %s\n", __func__,
7805 curr->gpio_data[n].name);
7806 rc = gpio_request(curr->gpio_data[n].no,
7807 curr->gpio_data[n].name);
7808 if (rc) {
7809 pr_err("%s: gpio_request(%d, %s)"
7810 "failed", __func__,
7811 curr->gpio_data[n].no,
7812 curr->gpio_data[n].name);
7813 goto free_gpios;
7814 }
7815 /* set direction as output for all GPIOs */
7816 rc = gpio_direction_output(
7817 curr->gpio_data[n].no, 1);
7818 if (rc) {
7819 pr_err("%s: gpio_direction_output"
7820 "(%d, 1) failed\n", __func__,
7821 curr->gpio_data[n].no);
7822 goto free_gpios;
7823 }
7824 curr->gpio_data[n].is_enabled = 1;
7825 } else {
7826 /*
7827 * now free this GPIO which will put GPIO
7828 * in low power mode and will also put GPIO
7829 * in input mode
7830 */
7831 if (curr->gpio_data[n].always_on)
7832 continue;
7833 pr_debug("%s: disable: %s\n", __func__,
7834 curr->gpio_data[n].name);
7835 gpio_free(curr->gpio_data[n].no);
7836 curr->gpio_data[n].is_enabled = 0;
7837 }
7838 }
7839 curr->cfg_sts = enable;
7840 goto out;
7841
7842free_gpios:
7843 for (; n >= 0; n--)
7844 gpio_free(curr->gpio_data[n].no);
7845out:
7846 return rc;
7847}
7848
7849static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7850{
7851 int rc = 0;
7852 struct msm_sdcc_pin_cfg *curr;
7853 int n;
7854
7855 curr = &sdcc_pin_cfg_data[dev_id - 1];
7856 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7857 goto out;
7858
7859 if (enable) {
7860 /*
7861 * set up the normal driver strength and
7862 * pull config for pads
7863 */
7864 for (n = 0; n < curr->pad_drv_data_size; n++) {
7865 if (curr->sdio_lpm_gpio_cfg) {
7866 if (curr->pad_drv_on_data[n].drv ==
7867 TLMM_HDRV_SDC4_DATA)
7868 continue;
7869 }
7870 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7871 curr->pad_drv_on_data[n].drv_val);
7872 }
7873 for (n = 0; n < curr->pad_pull_data_size; n++) {
7874 if (curr->sdio_lpm_gpio_cfg) {
7875 if (curr->pad_pull_on_data[n].pull ==
7876 TLMM_PULL_SDC4_DATA)
7877 continue;
7878 }
7879 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7880 curr->pad_pull_on_data[n].pull_val);
7881 }
7882 } else {
7883 /* set the low power config for pads */
7884 for (n = 0; n < curr->pad_drv_data_size; n++) {
7885 if (curr->sdio_lpm_gpio_cfg) {
7886 if (curr->pad_drv_off_data[n].drv ==
7887 TLMM_HDRV_SDC4_DATA)
7888 continue;
7889 }
7890 msm_tlmm_set_hdrive(
7891 curr->pad_drv_off_data[n].drv,
7892 curr->pad_drv_off_data[n].drv_val);
7893 }
7894 for (n = 0; n < curr->pad_pull_data_size; n++) {
7895 if (curr->sdio_lpm_gpio_cfg) {
7896 if (curr->pad_pull_off_data[n].pull ==
7897 TLMM_PULL_SDC4_DATA)
7898 continue;
7899 }
7900 msm_tlmm_set_pull(
7901 curr->pad_pull_off_data[n].pull,
7902 curr->pad_pull_off_data[n].pull_val);
7903 }
7904 }
7905 curr->cfg_sts = enable;
7906out:
7907 return rc;
7908}
7909
7910struct sdcc_reg {
7911 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7912 const char *reg_name;
7913 /*
7914 * is set voltage supported for this regulator?
7915 * 0 = not supported, 1 = supported
7916 */
7917 unsigned char set_voltage_sup;
7918 /* voltage level to be set */
7919 unsigned int level;
7920 /* VDD/VCC/VCCQ voltage regulator handle */
7921 struct regulator *reg;
7922 /* is this regulator enabled? */
7923 bool enabled;
7924 /* is this regulator needs to be always on? */
7925 bool always_on;
7926 /* is operating power mode setting required for this regulator? */
7927 bool op_pwr_mode_sup;
7928 /* Load values for low power and high power mode */
7929 unsigned int lpm_uA;
7930 unsigned int hpm_uA;
7931};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007932/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007933static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7934/* only SDCC1 requires VCCQ voltage */
7935static struct sdcc_reg sdcc_vccq_reg_data[1];
7936/* all SDCC controllers may require voting for VDD PAD voltage */
7937static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7938
7939struct sdcc_reg_data {
7940 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7941 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7942 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7943 unsigned char sts; /* regulator enable/disable status */
7944};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007945/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007946static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7947
7948static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7949{
7950 int rc = 0;
7951
7952 /* Get the regulator handle */
7953 vreg->reg = regulator_get(NULL, vreg->reg_name);
7954 if (IS_ERR(vreg->reg)) {
7955 rc = PTR_ERR(vreg->reg);
7956 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7957 __func__, vreg->reg_name, rc);
7958 goto out;
7959 }
7960
7961 /* Set the voltage level if required */
7962 if (vreg->set_voltage_sup) {
7963 rc = regulator_set_voltage(vreg->reg, vreg->level,
7964 vreg->level);
7965 if (rc) {
7966 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7967 __func__, vreg->reg_name, rc);
7968 goto vreg_put;
7969 }
7970 }
7971 goto out;
7972
7973vreg_put:
7974 regulator_put(vreg->reg);
7975out:
7976 return rc;
7977}
7978
7979static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7980{
7981 regulator_put(vreg->reg);
7982}
7983
7984/* this init function should be called only once for each SDCC */
7985static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7986{
7987 int rc = 0;
7988 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7989 struct sdcc_reg_data *curr;
7990
7991 curr = &sdcc_vreg_data[dev_id - 1];
7992 curr_vdd_reg = curr->vdd_data;
7993 curr_vccq_reg = curr->vccq_data;
7994 curr_vddp_reg = curr->vddp_data;
7995
7996 if (init) {
7997 /*
7998 * get the regulator handle from voltage regulator framework
7999 * and then try to set the voltage level for the regulator
8000 */
8001 if (curr_vdd_reg) {
8002 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8003 if (rc)
8004 goto out;
8005 }
8006 if (curr_vccq_reg) {
8007 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8008 if (rc)
8009 goto vdd_reg_deinit;
8010 }
8011 if (curr_vddp_reg) {
8012 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8013 if (rc)
8014 goto vccq_reg_deinit;
8015 }
8016 goto out;
8017 } else
8018 /* deregister with all regulators from regulator framework */
8019 goto vddp_reg_deinit;
8020
8021vddp_reg_deinit:
8022 if (curr_vddp_reg)
8023 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8024vccq_reg_deinit:
8025 if (curr_vccq_reg)
8026 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8027vdd_reg_deinit:
8028 if (curr_vdd_reg)
8029 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8030out:
8031 return rc;
8032}
8033
8034static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8035{
8036 int rc;
8037
8038 if (!vreg->enabled) {
8039 rc = regulator_enable(vreg->reg);
8040 if (rc) {
8041 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8042 __func__, vreg->reg_name, rc);
8043 goto out;
8044 }
8045 vreg->enabled = 1;
8046 }
8047
8048 /* Put always_on regulator in HPM (high power mode) */
8049 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8050 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8051 if (rc < 0) {
8052 pr_err("%s: reg=%s: HPM setting failed"
8053 " hpm_uA=%d, rc=%d\n",
8054 __func__, vreg->reg_name,
8055 vreg->hpm_uA, rc);
8056 goto vreg_disable;
8057 }
8058 rc = 0;
8059 }
8060 goto out;
8061
8062vreg_disable:
8063 regulator_disable(vreg->reg);
8064 vreg->enabled = 0;
8065out:
8066 return rc;
8067}
8068
8069static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8070{
8071 int rc;
8072
8073 /* Never disable always_on regulator */
8074 if (!vreg->always_on) {
8075 rc = regulator_disable(vreg->reg);
8076 if (rc) {
8077 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8078 __func__, vreg->reg_name, rc);
8079 goto out;
8080 }
8081 vreg->enabled = 0;
8082 }
8083
8084 /* Put always_on regulator in LPM (low power mode) */
8085 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8086 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8087 if (rc < 0) {
8088 pr_err("%s: reg=%s: LPM setting failed"
8089 " lpm_uA=%d, rc=%d\n",
8090 __func__,
8091 vreg->reg_name,
8092 vreg->lpm_uA, rc);
8093 goto out;
8094 }
8095 rc = 0;
8096 }
8097
8098out:
8099 return rc;
8100}
8101
8102static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8103{
8104 int rc = 0;
8105 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8106 struct sdcc_reg_data *curr;
8107
8108 curr = &sdcc_vreg_data[dev_id - 1];
8109 curr_vdd_reg = curr->vdd_data;
8110 curr_vccq_reg = curr->vccq_data;
8111 curr_vddp_reg = curr->vddp_data;
8112
8113 /* check if regulators are initialized or not? */
8114 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8115 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8116 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8117 /* initialize voltage regulators required for this SDCC */
8118 rc = msm_sdcc_vreg_init(dev_id, 1);
8119 if (rc) {
8120 pr_err("%s: regulator init failed = %d\n",
8121 __func__, rc);
8122 goto out;
8123 }
8124 }
8125
8126 if (curr->sts == enable)
8127 goto out;
8128
8129 if (curr_vdd_reg) {
8130 if (enable)
8131 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8132 else
8133 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8134 if (rc)
8135 goto out;
8136 }
8137
8138 if (curr_vccq_reg) {
8139 if (enable)
8140 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8141 else
8142 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8143 if (rc)
8144 goto out;
8145 }
8146
8147 if (curr_vddp_reg) {
8148 if (enable)
8149 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8150 else
8151 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8152 if (rc)
8153 goto out;
8154 }
8155 curr->sts = enable;
8156
8157out:
8158 return rc;
8159}
8160
8161static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8162{
8163 u32 rc_pin_cfg = 0;
8164 u32 rc_vreg_cfg = 0;
8165 u32 rc = 0;
8166 struct platform_device *pdev;
8167 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8168
8169 pdev = container_of(dv, struct platform_device, dev);
8170
8171 /* setup gpio/pad */
8172 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8173 if (curr_pin_cfg->cfg_sts == !!vdd)
8174 goto setup_vreg;
8175
8176 if (curr_pin_cfg->is_gpio)
8177 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8178 else
8179 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8180
8181setup_vreg:
8182 /* setup voltage regulators */
8183 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8184
8185 if (rc_pin_cfg || rc_vreg_cfg)
8186 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8187
8188 return rc;
8189}
8190
8191static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8192{
8193 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8194 struct platform_device *pdev;
8195
8196 pdev = container_of(dv, struct platform_device, dev);
8197 /* setup gpio/pad */
8198 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8199
8200 if (curr_pin_cfg->cfg_sts == active)
8201 return;
8202
8203 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8204 if (curr_pin_cfg->is_gpio)
8205 msm_sdcc_setup_gpio(pdev->id, active);
8206 else
8207 msm_sdcc_setup_pad(pdev->id, active);
8208 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8209}
8210
8211static int msm_sdc3_get_wpswitch(struct device *dev)
8212{
8213 struct platform_device *pdev;
8214 int status;
8215 pdev = container_of(dev, struct platform_device, dev);
8216
8217 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8218 if (status) {
8219 pr_err("%s:Failed to request GPIO %d\n",
8220 __func__, GPIO_SDC_WP);
8221 } else {
8222 status = gpio_direction_input(GPIO_SDC_WP);
8223 if (!status) {
8224 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8225 pr_info("%s: WP Status for Slot %d = %d\n",
8226 __func__, pdev->id, status);
8227 }
8228 gpio_free(GPIO_SDC_WP);
8229 }
8230 return status;
8231}
8232
8233#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8234int sdc5_register_status_notify(void (*callback)(int, void *),
8235 void *dev_id)
8236{
8237 sdc5_status_notify_cb = callback;
8238 sdc5_status_notify_cb_devid = dev_id;
8239 return 0;
8240}
8241#endif
8242
8243#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8244int sdc2_register_status_notify(void (*callback)(int, void *),
8245 void *dev_id)
8246{
8247 sdc2_status_notify_cb = callback;
8248 sdc2_status_notify_cb_devid = dev_id;
8249 return 0;
8250}
8251#endif
8252
8253/* Interrupt handler for SDC2 and SDC5 detection
8254 * This function uses dual-edge interrputs settings in order
8255 * to get SDIO detection when the GPIO is rising and SDIO removal
8256 * when the GPIO is falling */
8257static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8258{
8259 int status;
8260
8261 if (!machine_is_msm8x60_fusion() &&
8262 !machine_is_msm8x60_fusn_ffa())
8263 return IRQ_NONE;
8264
8265 status = gpio_get_value(MDM2AP_SYNC);
8266 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8267 __func__, status);
8268
8269#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8270 if (sdc2_status_notify_cb) {
8271 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8272 sdc2_status_notify_cb(status,
8273 sdc2_status_notify_cb_devid);
8274 }
8275#endif
8276
8277#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8278 if (sdc5_status_notify_cb) {
8279 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8280 sdc5_status_notify_cb(status,
8281 sdc5_status_notify_cb_devid);
8282 }
8283#endif
8284 return IRQ_HANDLED;
8285}
8286
8287static int msm8x60_multi_sdio_init(void)
8288{
8289 int ret, irq_num;
8290
8291 if (!machine_is_msm8x60_fusion() &&
8292 !machine_is_msm8x60_fusn_ffa())
8293 return 0;
8294
8295 ret = msm_gpiomux_get(MDM2AP_SYNC);
8296 if (ret) {
8297 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8298 __func__, MDM2AP_SYNC, ret);
8299 return ret;
8300 }
8301
8302 irq_num = gpio_to_irq(MDM2AP_SYNC);
8303
8304 ret = request_irq(irq_num,
8305 msm8x60_multi_sdio_slot_status_irq,
8306 IRQ_TYPE_EDGE_BOTH,
8307 "sdio_multidetection", NULL);
8308
8309 if (ret) {
8310 pr_err("%s:Failed to request irq, ret=%d\n",
8311 __func__, ret);
8312 return ret;
8313 }
8314
8315 return ret;
8316}
8317
8318#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8319#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8320static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8321{
8322 int status;
8323
8324 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8325 , "SD_HW_Detect");
8326 if (status) {
8327 pr_err("%s:Failed to request GPIO %d\n", __func__,
8328 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8329 } else {
8330 status = gpio_direction_input(
8331 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8332 if (!status)
8333 status = !(gpio_get_value_cansleep(
8334 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8335 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8336 }
8337 return (unsigned int) status;
8338}
8339#endif
8340#endif
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308341#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008342
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308343#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308344#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008345
8346#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8347static struct mmc_platform_data msm8x60_sdc1_data = {
8348 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8349 .translate_vdd = msm_sdcc_setup_power,
8350#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8351 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8352#else
8353 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8354#endif
8355 .msmsdcc_fmin = 400000,
8356 .msmsdcc_fmid = 24000000,
8357 .msmsdcc_fmax = 48000000,
8358 .nonremovable = 1,
8359 .pclk_src_dfab = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308360 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008361};
8362#endif
8363
8364#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8365static struct mmc_platform_data msm8x60_sdc2_data = {
8366 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8367 .translate_vdd = msm_sdcc_setup_power,
8368 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8369 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8370 .msmsdcc_fmin = 400000,
8371 .msmsdcc_fmid = 24000000,
8372 .msmsdcc_fmax = 48000000,
8373 .nonremovable = 0,
8374 .pclk_src_dfab = 1,
8375 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008376#ifdef CONFIG_MSM_SDIO_AL
8377 .is_sdio_al_client = 1,
8378#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308379 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008380};
8381#endif
8382
8383#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8384static struct mmc_platform_data msm8x60_sdc3_data = {
8385 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8386 .translate_vdd = msm_sdcc_setup_power,
8387 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8388 .wpswitch = msm_sdc3_get_wpswitch,
8389#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8390 .status = msm8x60_sdcc_slot_status,
8391 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8392 PMIC_GPIO_SDC3_DET - 1),
8393 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8394#endif
8395 .msmsdcc_fmin = 400000,
8396 .msmsdcc_fmid = 24000000,
8397 .msmsdcc_fmax = 48000000,
8398 .nonremovable = 0,
8399 .pclk_src_dfab = 1,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308400 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308401 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008402};
8403#endif
8404
8405#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8406static struct mmc_platform_data msm8x60_sdc4_data = {
8407 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8408 .translate_vdd = msm_sdcc_setup_power,
8409 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8410 .msmsdcc_fmin = 400000,
8411 .msmsdcc_fmid = 24000000,
8412 .msmsdcc_fmax = 48000000,
8413 .nonremovable = 0,
8414 .pclk_src_dfab = 1,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308415 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308416 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008417};
8418#endif
8419
8420#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8421static struct mmc_platform_data msm8x60_sdc5_data = {
8422 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8423 .translate_vdd = msm_sdcc_setup_power,
8424 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8425 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8426 .msmsdcc_fmin = 400000,
8427 .msmsdcc_fmid = 24000000,
8428 .msmsdcc_fmax = 48000000,
8429 .nonremovable = 0,
8430 .pclk_src_dfab = 1,
8431 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008432#ifdef CONFIG_MSM_SDIO_AL
8433 .is_sdio_al_client = 1,
8434#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308435 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008436};
8437#endif
8438
8439static void __init msm8x60_init_mmc(void)
8440{
8441#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8442 /* SDCC1 : eMMC card connected */
8443 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8444 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8445 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8446 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308447 sdcc_vreg_data[0].vdd_data->always_on = 1;
8448 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8449 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8450 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008451
8452 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8453 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8454 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8455 sdcc_vreg_data[0].vccq_data->always_on = 1;
8456
8457 msm_add_sdcc(1, &msm8x60_sdc1_data);
8458#endif
8459#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8460 /*
8461 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8462 * and no card is connected on 8660 SURF/FFA/FLUID.
8463 */
8464 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8465 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8466 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8467 sdcc_vreg_data[1].vdd_data->level = 1800000;
8468
8469 sdcc_vreg_data[1].vccq_data = NULL;
8470
8471 if (machine_is_msm8x60_fusion())
8472 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8473 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008474 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8475 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008476 msm_add_sdcc(2, &msm8x60_sdc2_data);
8477 }
8478#endif
8479#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8480 /* SDCC3 : External card slot connected */
8481 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8482 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8483 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8484 sdcc_vreg_data[2].vdd_data->level = 2850000;
8485 sdcc_vreg_data[2].vdd_data->always_on = 1;
8486 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8487 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8488 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8489
8490 sdcc_vreg_data[2].vccq_data = NULL;
8491
8492 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8493 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8494 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8495 sdcc_vreg_data[2].vddp_data->level = 2850000;
8496 sdcc_vreg_data[2].vddp_data->always_on = 1;
8497 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8498 /* Sleep current required is ~300 uA. But min. RPM
8499 * vote can be in terms of mA (min. 1 mA).
8500 * So let's vote for 2 mA during sleep.
8501 */
8502 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8503 /* Max. Active current required is 16 mA */
8504 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8505
8506 if (machine_is_msm8x60_fluid())
8507 msm8x60_sdc3_data.wpswitch = NULL;
8508 msm_add_sdcc(3, &msm8x60_sdc3_data);
8509#endif
8510#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8511 /* SDCC4 : WLAN WCN1314 chip is connected */
8512 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8513 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8514 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8515 sdcc_vreg_data[3].vdd_data->level = 1800000;
8516
8517 sdcc_vreg_data[3].vccq_data = NULL;
8518
8519 msm_add_sdcc(4, &msm8x60_sdc4_data);
8520#endif
8521#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8522 /*
8523 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8524 * and no card is connected on 8660 SURF/FFA/FLUID.
8525 */
8526 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8527 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8528 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8529 sdcc_vreg_data[4].vdd_data->level = 1800000;
8530
8531 sdcc_vreg_data[4].vccq_data = NULL;
8532
8533 if (machine_is_msm8x60_fusion())
8534 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8535 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008536 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8537 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008538 msm_add_sdcc(5, &msm8x60_sdc5_data);
8539 }
8540#endif
8541}
8542
8543#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8544static inline void display_common_power(int on) {}
8545#else
8546
8547#define _GET_REGULATOR(var, name) do { \
8548 if (var == NULL) { \
8549 var = regulator_get(NULL, name); \
8550 if (IS_ERR(var)) { \
8551 pr_err("'%s' regulator not found, rc=%ld\n", \
8552 name, PTR_ERR(var)); \
8553 var = NULL; \
8554 } \
8555 } \
8556} while (0)
8557
8558static int dsub_regulator(int on)
8559{
8560 static struct regulator *dsub_reg;
8561 static struct regulator *mpp0_reg;
8562 static int dsub_reg_enabled;
8563 int rc = 0;
8564
8565 _GET_REGULATOR(dsub_reg, "8901_l3");
8566 if (IS_ERR(dsub_reg)) {
8567 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8568 __func__, PTR_ERR(dsub_reg));
8569 return PTR_ERR(dsub_reg);
8570 }
8571
8572 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8573 if (IS_ERR(mpp0_reg)) {
8574 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8575 __func__, PTR_ERR(mpp0_reg));
8576 return PTR_ERR(mpp0_reg);
8577 }
8578
8579 if (on && !dsub_reg_enabled) {
8580 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8581 if (rc) {
8582 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8583 " err=%d", __func__, rc);
8584 goto dsub_regulator_err;
8585 }
8586 rc = regulator_enable(dsub_reg);
8587 if (rc) {
8588 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8589 " err=%d", __func__, rc);
8590 goto dsub_regulator_err;
8591 }
8592 rc = regulator_enable(mpp0_reg);
8593 if (rc) {
8594 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8595 " err=%d", __func__, rc);
8596 goto dsub_regulator_err;
8597 }
8598 dsub_reg_enabled = 1;
8599 } else if (!on && dsub_reg_enabled) {
8600 rc = regulator_disable(dsub_reg);
8601 if (rc)
8602 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8603 " err=%d", __func__, rc);
8604 rc = regulator_disable(mpp0_reg);
8605 if (rc)
8606 printk(KERN_WARNING "%s: failed to disable reg "
8607 "8901_mpp0 err=%d", __func__, rc);
8608 dsub_reg_enabled = 0;
8609 }
8610
8611 return rc;
8612
8613dsub_regulator_err:
8614 regulator_put(mpp0_reg);
8615 regulator_put(dsub_reg);
8616 return rc;
8617}
8618
8619static int display_power_on;
8620static void setup_display_power(void)
8621{
8622 if (display_power_on)
8623 if (lcdc_vga_enabled) {
8624 dsub_regulator(1);
8625 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8626 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8627 if (machine_is_msm8x60_ffa() ||
8628 machine_is_msm8x60_fusn_ffa())
8629 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8630 } else {
8631 dsub_regulator(0);
8632 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8633 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8634 if (machine_is_msm8x60_ffa() ||
8635 machine_is_msm8x60_fusn_ffa())
8636 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8637 }
8638 else {
8639 dsub_regulator(0);
8640 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8641 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8642 /* BACKLIGHT */
8643 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8644 /* LVDS */
8645 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8646 }
8647}
8648
8649#define _GET_REGULATOR(var, name) do { \
8650 if (var == NULL) { \
8651 var = regulator_get(NULL, name); \
8652 if (IS_ERR(var)) { \
8653 pr_err("'%s' regulator not found, rc=%ld\n", \
8654 name, PTR_ERR(var)); \
8655 var = NULL; \
8656 } \
8657 } \
8658} while (0)
8659
8660#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8661
8662static void display_common_power(int on)
8663{
8664 int rc;
8665 static struct regulator *display_reg;
8666
8667 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8668 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8669 if (on) {
8670 /* LVDS */
8671 _GET_REGULATOR(display_reg, "8901_l2");
8672 if (!display_reg)
8673 return;
8674 rc = regulator_set_voltage(display_reg,
8675 3300000, 3300000);
8676 if (rc)
8677 goto out;
8678 rc = regulator_enable(display_reg);
8679 if (rc)
8680 goto out;
8681 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8682 "LVDS_STDN_OUT_N");
8683 if (rc) {
8684 printk(KERN_ERR "%s: LVDS gpio %d request"
8685 "failed\n", __func__,
8686 GPIO_LVDS_SHUTDOWN_N);
8687 goto out2;
8688 }
8689
8690 /* BACKLIGHT */
8691 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8692 if (rc) {
8693 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8694 "failed\n", __func__,
8695 GPIO_BACKLIGHT_EN);
8696 goto out3;
8697 }
8698
8699 if (machine_is_msm8x60_ffa() ||
8700 machine_is_msm8x60_fusn_ffa()) {
8701 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8702 "DONGLE_PWR_EN");
8703 if (rc) {
8704 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8705 " %d request failed\n", __func__,
8706 GPIO_DONGLE_PWR_EN);
8707 goto out4;
8708 }
8709 }
8710
8711 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8712 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8713 if (machine_is_msm8x60_ffa() ||
8714 machine_is_msm8x60_fusn_ffa())
8715 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8716 mdelay(20);
8717 display_power_on = 1;
8718 setup_display_power();
8719 } else {
8720 if (display_power_on) {
8721 display_power_on = 0;
8722 setup_display_power();
8723 mdelay(20);
8724 if (machine_is_msm8x60_ffa() ||
8725 machine_is_msm8x60_fusn_ffa())
8726 gpio_free(GPIO_DONGLE_PWR_EN);
8727 goto out4;
8728 }
8729 }
8730 }
8731#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8732 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8733 else if (machine_is_msm8x60_fluid()) {
8734 static struct regulator *fluid_reg;
8735 static struct regulator *fluid_reg2;
8736
8737 if (on) {
8738 _GET_REGULATOR(fluid_reg, "8901_l2");
8739 if (!fluid_reg)
8740 return;
8741 _GET_REGULATOR(fluid_reg2, "8058_s3");
8742 if (!fluid_reg2) {
8743 regulator_put(fluid_reg);
8744 return;
8745 }
8746 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8747 if (rc) {
8748 regulator_put(fluid_reg2);
8749 regulator_put(fluid_reg);
8750 return;
8751 }
8752 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8753 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8754 regulator_enable(fluid_reg);
8755 regulator_enable(fluid_reg2);
8756 msleep(20);
8757 gpio_direction_output(GPIO_RESX_N, 0);
8758 udelay(10);
8759 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8760 display_power_on = 1;
8761 setup_display_power();
8762 } else {
8763 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8764 gpio_free(GPIO_RESX_N);
8765 msleep(20);
8766 regulator_disable(fluid_reg2);
8767 regulator_disable(fluid_reg);
8768 regulator_put(fluid_reg2);
8769 regulator_put(fluid_reg);
8770 display_power_on = 0;
8771 setup_display_power();
8772 fluid_reg = NULL;
8773 fluid_reg2 = NULL;
8774 }
8775 }
8776#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008777#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8778 else if (machine_is_msm8x60_dragon()) {
8779 static struct regulator *dragon_reg;
8780 static struct regulator *dragon_reg2;
8781
8782 if (on) {
8783 _GET_REGULATOR(dragon_reg, "8901_l2");
8784 if (!dragon_reg)
8785 return;
8786 _GET_REGULATOR(dragon_reg2, "8058_l16");
8787 if (!dragon_reg2) {
8788 regulator_put(dragon_reg);
8789 dragon_reg = NULL;
8790 return;
8791 }
8792
8793 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8794 if (rc) {
8795 pr_err("%s: gpio %d request failed with rc=%d\n",
8796 __func__, GPIO_NT35582_BL_EN, rc);
8797 regulator_put(dragon_reg);
8798 regulator_put(dragon_reg2);
8799 dragon_reg = NULL;
8800 dragon_reg2 = NULL;
8801 return;
8802 }
8803
8804 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8805 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8806 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8807 pr_err("%s: config gpio '%d' failed!\n",
8808 __func__, GPIO_NT35582_RESET);
8809 gpio_free(GPIO_NT35582_BL_EN);
8810 regulator_put(dragon_reg);
8811 regulator_put(dragon_reg2);
8812 dragon_reg = NULL;
8813 dragon_reg2 = NULL;
8814 return;
8815 }
8816
8817 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8818 if (rc) {
8819 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8820 __func__, GPIO_NT35582_RESET, rc);
8821 gpio_free(GPIO_NT35582_BL_EN);
8822 regulator_put(dragon_reg);
8823 regulator_put(dragon_reg2);
8824 dragon_reg = NULL;
8825 dragon_reg2 = NULL;
8826 return;
8827 }
8828
8829 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8830 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8831 regulator_enable(dragon_reg);
8832 regulator_enable(dragon_reg2);
8833 msleep(20);
8834
8835 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8836 msleep(20);
8837 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8838 msleep(20);
8839 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8840 msleep(50);
8841
8842 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8843
8844 display_power_on = 1;
8845 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8846 gpio_free(GPIO_NT35582_RESET);
8847 gpio_free(GPIO_NT35582_BL_EN);
8848 regulator_disable(dragon_reg2);
8849 regulator_disable(dragon_reg);
8850 regulator_put(dragon_reg2);
8851 regulator_put(dragon_reg);
8852 display_power_on = 0;
8853 dragon_reg = NULL;
8854 dragon_reg2 = NULL;
8855 }
8856 }
8857#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008858 return;
8859
8860out4:
8861 gpio_free(GPIO_BACKLIGHT_EN);
8862out3:
8863 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8864out2:
8865 regulator_disable(display_reg);
8866out:
8867 regulator_put(display_reg);
8868 display_reg = NULL;
8869}
8870#undef _GET_REGULATOR
8871#endif
8872
8873static int mipi_dsi_panel_power(int on);
8874
8875#define LCDC_NUM_GPIO 28
8876#define LCDC_GPIO_START 0
8877
8878static void lcdc_samsung_panel_power(int on)
8879{
8880 int n, ret = 0;
8881
8882 display_common_power(on);
8883
8884 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8885 if (on) {
8886 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8887 if (unlikely(ret)) {
8888 pr_err("%s not able to get gpio\n", __func__);
8889 break;
8890 }
8891 } else
8892 gpio_free(LCDC_GPIO_START + n);
8893 }
8894
8895 if (ret) {
8896 for (n--; n >= 0; n--)
8897 gpio_free(LCDC_GPIO_START + n);
8898 }
8899
8900 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8901}
8902
8903#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8904#define _GET_REGULATOR(var, name) do { \
8905 var = regulator_get(NULL, name); \
8906 if (IS_ERR(var)) { \
8907 pr_err("'%s' regulator not found, rc=%ld\n", \
8908 name, IS_ERR(var)); \
8909 var = NULL; \
8910 return -ENODEV; \
8911 } \
8912} while (0)
8913
8914static int hdmi_enable_5v(int on)
8915{
8916 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8917 static struct regulator *reg_8901_mpp0; /* External 5V */
8918 static int prev_on;
8919 int rc;
8920
8921 if (on == prev_on)
8922 return 0;
8923
8924 if (!reg_8901_hdmi_mvs)
8925 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8926 if (!reg_8901_mpp0)
8927 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8928
8929 if (on) {
8930 rc = regulator_enable(reg_8901_mpp0);
8931 if (rc) {
8932 pr_err("'%s' regulator enable failed, rc=%d\n",
8933 "reg_8901_mpp0", rc);
8934 return rc;
8935 }
8936 rc = regulator_enable(reg_8901_hdmi_mvs);
8937 if (rc) {
8938 pr_err("'%s' regulator enable failed, rc=%d\n",
8939 "8901_hdmi_mvs", rc);
8940 return rc;
8941 }
8942 pr_info("%s(on): success\n", __func__);
8943 } else {
8944 rc = regulator_disable(reg_8901_hdmi_mvs);
8945 if (rc)
8946 pr_warning("'%s' regulator disable failed, rc=%d\n",
8947 "8901_hdmi_mvs", rc);
8948 rc = regulator_disable(reg_8901_mpp0);
8949 if (rc)
8950 pr_warning("'%s' regulator disable failed, rc=%d\n",
8951 "reg_8901_mpp0", rc);
8952 pr_info("%s(off): success\n", __func__);
8953 }
8954
8955 prev_on = on;
8956
8957 return 0;
8958}
8959
8960static int hdmi_core_power(int on, int show)
8961{
8962 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8963 static int prev_on;
8964 int rc;
8965
8966 if (on == prev_on)
8967 return 0;
8968
8969 if (!reg_8058_l16)
8970 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8971
8972 if (on) {
8973 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8974 if (!rc)
8975 rc = regulator_enable(reg_8058_l16);
8976 if (rc) {
8977 pr_err("'%s' regulator enable failed, rc=%d\n",
8978 "8058_l16", rc);
8979 return rc;
8980 }
8981 rc = gpio_request(170, "HDMI_DDC_CLK");
8982 if (rc) {
8983 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8984 "HDMI_DDC_CLK", 170, rc);
8985 goto error1;
8986 }
8987 rc = gpio_request(171, "HDMI_DDC_DATA");
8988 if (rc) {
8989 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8990 "HDMI_DDC_DATA", 171, rc);
8991 goto error2;
8992 }
8993 rc = gpio_request(172, "HDMI_HPD");
8994 if (rc) {
8995 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8996 "HDMI_HPD", 172, rc);
8997 goto error3;
8998 }
8999 pr_info("%s(on): success\n", __func__);
9000 } else {
9001 gpio_free(170);
9002 gpio_free(171);
9003 gpio_free(172);
9004 rc = regulator_disable(reg_8058_l16);
9005 if (rc)
9006 pr_warning("'%s' regulator disable failed, rc=%d\n",
9007 "8058_l16", rc);
9008 pr_info("%s(off): success\n", __func__);
9009 }
9010
9011 prev_on = on;
9012
9013 return 0;
9014
9015error3:
9016 gpio_free(171);
9017error2:
9018 gpio_free(170);
9019error1:
9020 regulator_disable(reg_8058_l16);
9021 return rc;
9022}
9023
9024static int hdmi_cec_power(int on)
9025{
9026 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9027 static int prev_on;
9028 int rc;
9029
9030 if (on == prev_on)
9031 return 0;
9032
9033 if (!reg_8901_l3)
9034 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9035
9036 if (on) {
9037 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9038 if (!rc)
9039 rc = regulator_enable(reg_8901_l3);
9040 if (rc) {
9041 pr_err("'%s' regulator enable failed, rc=%d\n",
9042 "8901_l3", rc);
9043 return rc;
9044 }
9045 rc = gpio_request(169, "HDMI_CEC_VAR");
9046 if (rc) {
9047 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9048 "HDMI_CEC_VAR", 169, rc);
9049 goto error;
9050 }
9051 pr_info("%s(on): success\n", __func__);
9052 } else {
9053 gpio_free(169);
9054 rc = regulator_disable(reg_8901_l3);
9055 if (rc)
9056 pr_warning("'%s' regulator disable failed, rc=%d\n",
9057 "8901_l3", rc);
9058 pr_info("%s(off): success\n", __func__);
9059 }
9060
9061 prev_on = on;
9062
9063 return 0;
9064error:
9065 regulator_disable(reg_8901_l3);
9066 return rc;
9067}
9068
9069#undef _GET_REGULATOR
9070
9071#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9072
9073static int lcdc_panel_power(int on)
9074{
9075 int flag_on = !!on;
9076 static int lcdc_power_save_on;
9077
9078 if (lcdc_power_save_on == flag_on)
9079 return 0;
9080
9081 lcdc_power_save_on = flag_on;
9082
9083 lcdc_samsung_panel_power(on);
9084
9085 return 0;
9086}
9087
9088#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009089
9090static struct msm_bus_vectors rotator_init_vectors[] = {
9091 {
9092 .src = MSM_BUS_MASTER_ROTATOR,
9093 .dst = MSM_BUS_SLAVE_SMI,
9094 .ab = 0,
9095 .ib = 0,
9096 },
9097 {
9098 .src = MSM_BUS_MASTER_ROTATOR,
9099 .dst = MSM_BUS_SLAVE_EBI_CH0,
9100 .ab = 0,
9101 .ib = 0,
9102 },
9103};
9104
9105static struct msm_bus_vectors rotator_ui_vectors[] = {
9106 {
9107 .src = MSM_BUS_MASTER_ROTATOR,
9108 .dst = MSM_BUS_SLAVE_SMI,
9109 .ab = 0,
9110 .ib = 0,
9111 },
9112 {
9113 .src = MSM_BUS_MASTER_ROTATOR,
9114 .dst = MSM_BUS_SLAVE_EBI_CH0,
9115 .ab = (1024 * 600 * 4 * 2 * 60),
9116 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9117 },
9118};
9119
9120static struct msm_bus_vectors rotator_vga_vectors[] = {
9121 {
9122 .src = MSM_BUS_MASTER_ROTATOR,
9123 .dst = MSM_BUS_SLAVE_SMI,
9124 .ab = (640 * 480 * 2 * 2 * 30),
9125 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9126 },
9127 {
9128 .src = MSM_BUS_MASTER_ROTATOR,
9129 .dst = MSM_BUS_SLAVE_EBI_CH0,
9130 .ab = (640 * 480 * 2 * 2 * 30),
9131 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9132 },
9133};
9134
9135static struct msm_bus_vectors rotator_720p_vectors[] = {
9136 {
9137 .src = MSM_BUS_MASTER_ROTATOR,
9138 .dst = MSM_BUS_SLAVE_SMI,
9139 .ab = (1280 * 736 * 2 * 2 * 30),
9140 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9141 },
9142 {
9143 .src = MSM_BUS_MASTER_ROTATOR,
9144 .dst = MSM_BUS_SLAVE_EBI_CH0,
9145 .ab = (1280 * 736 * 2 * 2 * 30),
9146 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9147 },
9148};
9149
9150static struct msm_bus_vectors rotator_1080p_vectors[] = {
9151 {
9152 .src = MSM_BUS_MASTER_ROTATOR,
9153 .dst = MSM_BUS_SLAVE_SMI,
9154 .ab = (1920 * 1088 * 2 * 2 * 30),
9155 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9156 },
9157 {
9158 .src = MSM_BUS_MASTER_ROTATOR,
9159 .dst = MSM_BUS_SLAVE_EBI_CH0,
9160 .ab = (1920 * 1088 * 2 * 2 * 30),
9161 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9162 },
9163};
9164
9165static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9166 {
9167 ARRAY_SIZE(rotator_init_vectors),
9168 rotator_init_vectors,
9169 },
9170 {
9171 ARRAY_SIZE(rotator_ui_vectors),
9172 rotator_ui_vectors,
9173 },
9174 {
9175 ARRAY_SIZE(rotator_vga_vectors),
9176 rotator_vga_vectors,
9177 },
9178 {
9179 ARRAY_SIZE(rotator_720p_vectors),
9180 rotator_720p_vectors,
9181 },
9182 {
9183 ARRAY_SIZE(rotator_1080p_vectors),
9184 rotator_1080p_vectors,
9185 },
9186};
9187
9188struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9189 rotator_bus_scale_usecases,
9190 ARRAY_SIZE(rotator_bus_scale_usecases),
9191 .name = "rotator",
9192};
9193
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009194static struct msm_bus_vectors mdp_init_vectors[] = {
9195 /* For now, 0th array entry is reserved.
9196 * Please leave 0 as is and don't use it
9197 */
9198 {
9199 .src = MSM_BUS_MASTER_MDP_PORT0,
9200 .dst = MSM_BUS_SLAVE_SMI,
9201 .ab = 0,
9202 .ib = 0,
9203 },
9204 /* Master and slaves can be from different fabrics */
9205 {
9206 .src = MSM_BUS_MASTER_MDP_PORT0,
9207 .dst = MSM_BUS_SLAVE_EBI_CH0,
9208 .ab = 0,
9209 .ib = 0,
9210 },
9211};
9212
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009213#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009214static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9215 /* Default case static display/UI/2d/3d if FB SMI */
9216 {
9217 .src = MSM_BUS_MASTER_MDP_PORT0,
9218 .dst = MSM_BUS_SLAVE_SMI,
9219 .ab = 388800000,
9220 .ib = 486000000,
9221 },
9222 /* Master and slaves can be from different fabrics */
9223 {
9224 .src = MSM_BUS_MASTER_MDP_PORT0,
9225 .dst = MSM_BUS_SLAVE_EBI_CH0,
9226 .ab = 0,
9227 .ib = 0,
9228 },
9229};
9230
9231static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9232 /* Default case static display/UI/2d/3d if FB SMI */
9233 {
9234 .src = MSM_BUS_MASTER_MDP_PORT0,
9235 .dst = MSM_BUS_SLAVE_SMI,
9236 .ab = 0,
9237 .ib = 0,
9238 },
9239 /* Master and slaves can be from different fabrics */
9240 {
9241 .src = MSM_BUS_MASTER_MDP_PORT0,
9242 .dst = MSM_BUS_SLAVE_EBI_CH0,
9243 .ab = 388800000,
9244 .ib = 486000000 * 2,
9245 },
9246};
9247static struct msm_bus_vectors mdp_vga_vectors[] = {
9248 /* VGA and less video */
9249 {
9250 .src = MSM_BUS_MASTER_MDP_PORT0,
9251 .dst = MSM_BUS_SLAVE_SMI,
9252 .ab = 458092800,
9253 .ib = 572616000,
9254 },
9255 {
9256 .src = MSM_BUS_MASTER_MDP_PORT0,
9257 .dst = MSM_BUS_SLAVE_EBI_CH0,
9258 .ab = 458092800,
9259 .ib = 572616000 * 2,
9260 },
9261};
9262static struct msm_bus_vectors mdp_720p_vectors[] = {
9263 /* 720p and less video */
9264 {
9265 .src = MSM_BUS_MASTER_MDP_PORT0,
9266 .dst = MSM_BUS_SLAVE_SMI,
9267 .ab = 471744000,
9268 .ib = 589680000,
9269 },
9270 /* Master and slaves can be from different fabrics */
9271 {
9272 .src = MSM_BUS_MASTER_MDP_PORT0,
9273 .dst = MSM_BUS_SLAVE_EBI_CH0,
9274 .ab = 471744000,
9275 .ib = 589680000 * 2,
9276 },
9277};
9278
9279static struct msm_bus_vectors mdp_1080p_vectors[] = {
9280 /* 1080p and less video */
9281 {
9282 .src = MSM_BUS_MASTER_MDP_PORT0,
9283 .dst = MSM_BUS_SLAVE_SMI,
9284 .ab = 575424000,
9285 .ib = 719280000,
9286 },
9287 /* Master and slaves can be from different fabrics */
9288 {
9289 .src = MSM_BUS_MASTER_MDP_PORT0,
9290 .dst = MSM_BUS_SLAVE_EBI_CH0,
9291 .ab = 575424000,
9292 .ib = 719280000 * 2,
9293 },
9294};
9295
9296#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009297static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9298 /* Default case static display/UI/2d/3d if FB SMI */
9299 {
9300 .src = MSM_BUS_MASTER_MDP_PORT0,
9301 .dst = MSM_BUS_SLAVE_SMI,
9302 .ab = 175110000,
9303 .ib = 218887500,
9304 },
9305 /* Master and slaves can be from different fabrics */
9306 {
9307 .src = MSM_BUS_MASTER_MDP_PORT0,
9308 .dst = MSM_BUS_SLAVE_EBI_CH0,
9309 .ab = 0,
9310 .ib = 0,
9311 },
9312};
9313
9314static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9315 /* Default case static display/UI/2d/3d if FB SMI */
9316 {
9317 .src = MSM_BUS_MASTER_MDP_PORT0,
9318 .dst = MSM_BUS_SLAVE_SMI,
9319 .ab = 0,
9320 .ib = 0,
9321 },
9322 /* Master and slaves can be from different fabrics */
9323 {
9324 .src = MSM_BUS_MASTER_MDP_PORT0,
9325 .dst = MSM_BUS_SLAVE_EBI_CH0,
9326 .ab = 216000000,
9327 .ib = 270000000 * 2,
9328 },
9329};
9330static struct msm_bus_vectors mdp_vga_vectors[] = {
9331 /* VGA and less video */
9332 {
9333 .src = MSM_BUS_MASTER_MDP_PORT0,
9334 .dst = MSM_BUS_SLAVE_SMI,
9335 .ab = 216000000,
9336 .ib = 270000000,
9337 },
9338 {
9339 .src = MSM_BUS_MASTER_MDP_PORT0,
9340 .dst = MSM_BUS_SLAVE_EBI_CH0,
9341 .ab = 216000000,
9342 .ib = 270000000 * 2,
9343 },
9344};
9345
9346static struct msm_bus_vectors mdp_720p_vectors[] = {
9347 /* 720p and less video */
9348 {
9349 .src = MSM_BUS_MASTER_MDP_PORT0,
9350 .dst = MSM_BUS_SLAVE_SMI,
9351 .ab = 230400000,
9352 .ib = 288000000,
9353 },
9354 /* Master and slaves can be from different fabrics */
9355 {
9356 .src = MSM_BUS_MASTER_MDP_PORT0,
9357 .dst = MSM_BUS_SLAVE_EBI_CH0,
9358 .ab = 230400000,
9359 .ib = 288000000 * 2,
9360 },
9361};
9362
9363static struct msm_bus_vectors mdp_1080p_vectors[] = {
9364 /* 1080p and less video */
9365 {
9366 .src = MSM_BUS_MASTER_MDP_PORT0,
9367 .dst = MSM_BUS_SLAVE_SMI,
9368 .ab = 334080000,
9369 .ib = 417600000,
9370 },
9371 /* Master and slaves can be from different fabrics */
9372 {
9373 .src = MSM_BUS_MASTER_MDP_PORT0,
9374 .dst = MSM_BUS_SLAVE_EBI_CH0,
9375 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009376 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009377 },
9378};
9379
9380#endif
9381static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9382 {
9383 ARRAY_SIZE(mdp_init_vectors),
9384 mdp_init_vectors,
9385 },
9386 {
9387 ARRAY_SIZE(mdp_sd_smi_vectors),
9388 mdp_sd_smi_vectors,
9389 },
9390 {
9391 ARRAY_SIZE(mdp_sd_ebi_vectors),
9392 mdp_sd_ebi_vectors,
9393 },
9394 {
9395 ARRAY_SIZE(mdp_vga_vectors),
9396 mdp_vga_vectors,
9397 },
9398 {
9399 ARRAY_SIZE(mdp_720p_vectors),
9400 mdp_720p_vectors,
9401 },
9402 {
9403 ARRAY_SIZE(mdp_1080p_vectors),
9404 mdp_1080p_vectors,
9405 },
9406};
9407static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9408 mdp_bus_scale_usecases,
9409 ARRAY_SIZE(mdp_bus_scale_usecases),
9410 .name = "mdp",
9411};
9412
9413#endif
9414#ifdef CONFIG_MSM_BUS_SCALING
9415static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9416 /* For now, 0th array entry is reserved.
9417 * Please leave 0 as is and don't use it
9418 */
9419 {
9420 .src = MSM_BUS_MASTER_MDP_PORT0,
9421 .dst = MSM_BUS_SLAVE_SMI,
9422 .ab = 0,
9423 .ib = 0,
9424 },
9425 /* Master and slaves can be from different fabrics */
9426 {
9427 .src = MSM_BUS_MASTER_MDP_PORT0,
9428 .dst = MSM_BUS_SLAVE_EBI_CH0,
9429 .ab = 0,
9430 .ib = 0,
9431 },
9432};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009433
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009434static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9435 /* For now, 0th array entry is reserved.
9436 * Please leave 0 as is and don't use it
9437 */
9438 {
9439 .src = MSM_BUS_MASTER_MDP_PORT0,
9440 .dst = MSM_BUS_SLAVE_SMI,
9441 .ab = 566092800,
9442 .ib = 707616000,
9443 },
9444 /* Master and slaves can be from different fabrics */
9445 {
9446 .src = MSM_BUS_MASTER_MDP_PORT0,
9447 .dst = MSM_BUS_SLAVE_EBI_CH0,
9448 .ab = 566092800,
9449 .ib = 707616000,
9450 },
9451};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009452
9453static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9454 /* For now, 0th array entry is reserved.
9455 * Please leave 0 as is and don't use it
9456 */
9457 {
9458 .src = MSM_BUS_MASTER_MDP_PORT0,
9459 .dst = MSM_BUS_SLAVE_SMI,
9460 .ab = 2000000000,
9461 .ib = 2000000000,
9462 },
9463 /* Master and slaves can be from different fabrics */
9464 {
9465 .src = MSM_BUS_MASTER_MDP_PORT0,
9466 .dst = MSM_BUS_SLAVE_EBI_CH0,
9467 .ab = 2000000000,
9468 .ib = 2000000000,
9469 },
9470};
9471
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009472static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9473 {
9474 ARRAY_SIZE(dtv_bus_init_vectors),
9475 dtv_bus_init_vectors,
9476 },
9477 {
9478 ARRAY_SIZE(dtv_bus_def_vectors),
9479 dtv_bus_def_vectors,
9480 },
9481};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009482
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009483static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9484 dtv_bus_scale_usecases,
9485 ARRAY_SIZE(dtv_bus_scale_usecases),
9486 .name = "dtv",
9487};
9488
9489static struct lcdc_platform_data dtv_pdata = {
9490 .bus_scale_table = &dtv_bus_scale_pdata,
9491};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009492
9493static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9494 {
9495 ARRAY_SIZE(dtv_bus_init_vectors),
9496 dtv_bus_init_vectors,
9497 },
9498 {
9499 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9500 dtv_bus_hdmi_prim_vectors,
9501 },
9502};
9503
9504static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9505 dtv_hdmi_prim_bus_scale_usecases,
9506 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9507 .name = "dtv",
9508};
9509
9510static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9511 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9512};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009513#endif
9514
9515
9516static struct lcdc_platform_data lcdc_pdata = {
9517 .lcdc_power_save = lcdc_panel_power,
9518};
9519
9520
9521#define MDP_VSYNC_GPIO 28
9522
9523/*
9524 * MIPI_DSI only use 8058_LDO0 which need always on
9525 * therefore it need to be put at low power mode if
9526 * it was not used instead of turn it off.
9527 */
9528static int mipi_dsi_panel_power(int on)
9529{
9530 int flag_on = !!on;
9531 static int mipi_dsi_power_save_on;
9532 static struct regulator *ldo0;
9533 int rc = 0;
9534
9535 if (mipi_dsi_power_save_on == flag_on)
9536 return 0;
9537
9538 mipi_dsi_power_save_on = flag_on;
9539
9540 if (ldo0 == NULL) { /* init */
9541 ldo0 = regulator_get(NULL, "8058_l0");
9542 if (IS_ERR(ldo0)) {
9543 pr_debug("%s: LDO0 failed\n", __func__);
9544 rc = PTR_ERR(ldo0);
9545 return rc;
9546 }
9547
9548 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9549 if (rc)
9550 goto out;
9551
9552 rc = regulator_enable(ldo0);
9553 if (rc)
9554 goto out;
9555 }
9556
9557 if (on) {
9558 /* set ldo0 to HPM */
9559 rc = regulator_set_optimum_mode(ldo0, 100000);
9560 if (rc < 0)
9561 goto out;
9562 } else {
9563 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309564 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009565 if (rc < 0)
9566 goto out;
9567 }
9568
9569 return 0;
9570out:
9571 regulator_disable(ldo0);
9572 regulator_put(ldo0);
9573 ldo0 = NULL;
9574 return rc;
9575}
9576
9577static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9578 .vsync_gpio = MDP_VSYNC_GPIO,
9579 .dsi_power_save = mipi_dsi_panel_power,
9580};
9581
9582#ifdef CONFIG_FB_MSM_TVOUT
9583static struct regulator *reg_8058_l13;
9584
9585static int atv_dac_power(int on)
9586{
9587 int rc = 0;
9588 #define _GET_REGULATOR(var, name) do { \
9589 var = regulator_get(NULL, name); \
9590 if (IS_ERR(var)) { \
9591 pr_info("'%s' regulator not found, rc=%ld\n", \
9592 name, IS_ERR(var)); \
9593 var = NULL; \
9594 return -ENODEV; \
9595 } \
9596 } while (0)
9597
9598 if (!reg_8058_l13)
9599 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9600 #undef _GET_REGULATOR
9601
9602 if (on) {
9603 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9604 if (rc) {
9605 pr_info("%s: '%s' regulator set voltage failed,\
9606 rc=%d\n", __func__, "8058_l13", rc);
9607 return rc;
9608 }
9609
9610 rc = regulator_enable(reg_8058_l13);
9611 if (rc) {
9612 pr_err("%s: '%s' regulator enable failed,\
9613 rc=%d\n", __func__, "8058_l13", rc);
9614 return rc;
9615 }
9616 } else {
9617 rc = regulator_force_disable(reg_8058_l13);
9618 if (rc)
9619 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9620 __func__, "8058_l13", rc);
9621 }
9622 return rc;
9623
9624}
9625#endif
9626
9627#ifdef CONFIG_FB_MSM_MIPI_DSI
9628int mdp_core_clk_rate_table[] = {
9629 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009630 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009631 160000000,
9632 200000000,
9633};
9634#else
9635int mdp_core_clk_rate_table[] = {
9636 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009637 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009638 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009639 200000000,
9640};
9641#endif
9642
9643static struct msm_panel_common_pdata mdp_pdata = {
9644 .gpio = MDP_VSYNC_GPIO,
9645 .mdp_core_clk_rate = 59080000,
9646 .mdp_core_clk_table = mdp_core_clk_rate_table,
9647 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9648#ifdef CONFIG_MSM_BUS_SCALING
9649 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9650#endif
9651 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009652#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009653 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009654#else
9655 .mem_hid = MEMTYPE_EBI1,
9656#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009657};
9658
Huaibin Yanga5419422011-12-08 23:52:10 -08009659static void __init reserve_mdp_memory(void)
9660{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009661 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9662 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9663#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9664 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9665 mdp_pdata.ov0_wb_size;
9666 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9667 mdp_pdata.ov1_wb_size;
9668#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009669}
9670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009671#ifdef CONFIG_FB_MSM_TVOUT
9672
9673#ifdef CONFIG_MSM_BUS_SCALING
9674static struct msm_bus_vectors atv_bus_init_vectors[] = {
9675 /* For now, 0th array entry is reserved.
9676 * Please leave 0 as is and don't use it
9677 */
9678 {
9679 .src = MSM_BUS_MASTER_MDP_PORT0,
9680 .dst = MSM_BUS_SLAVE_SMI,
9681 .ab = 0,
9682 .ib = 0,
9683 },
9684 /* Master and slaves can be from different fabrics */
9685 {
9686 .src = MSM_BUS_MASTER_MDP_PORT0,
9687 .dst = MSM_BUS_SLAVE_EBI_CH0,
9688 .ab = 0,
9689 .ib = 0,
9690 },
9691};
9692static struct msm_bus_vectors atv_bus_def_vectors[] = {
9693 /* For now, 0th array entry is reserved.
9694 * Please leave 0 as is and don't use it
9695 */
9696 {
9697 .src = MSM_BUS_MASTER_MDP_PORT0,
9698 .dst = MSM_BUS_SLAVE_SMI,
9699 .ab = 236390400,
9700 .ib = 265939200,
9701 },
9702 /* Master and slaves can be from different fabrics */
9703 {
9704 .src = MSM_BUS_MASTER_MDP_PORT0,
9705 .dst = MSM_BUS_SLAVE_EBI_CH0,
9706 .ab = 236390400,
9707 .ib = 265939200,
9708 },
9709};
9710static struct msm_bus_paths atv_bus_scale_usecases[] = {
9711 {
9712 ARRAY_SIZE(atv_bus_init_vectors),
9713 atv_bus_init_vectors,
9714 },
9715 {
9716 ARRAY_SIZE(atv_bus_def_vectors),
9717 atv_bus_def_vectors,
9718 },
9719};
9720static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9721 atv_bus_scale_usecases,
9722 ARRAY_SIZE(atv_bus_scale_usecases),
9723 .name = "atv",
9724};
9725#endif
9726
9727static struct tvenc_platform_data atv_pdata = {
9728 .poll = 0,
9729 .pm_vid_en = atv_dac_power,
9730#ifdef CONFIG_MSM_BUS_SCALING
9731 .bus_scale_table = &atv_bus_scale_pdata,
9732#endif
9733};
9734#endif
9735
9736static void __init msm_fb_add_devices(void)
9737{
9738#ifdef CONFIG_FB_MSM_LCDC_DSUB
9739 mdp_pdata.mdp_core_clk_table = NULL;
9740 mdp_pdata.num_mdp_clk = 0;
9741 mdp_pdata.mdp_core_clk_rate = 200000000;
9742#endif
9743 if (machine_is_msm8x60_rumi3())
9744 msm_fb_register_device("mdp", NULL);
9745 else
9746 msm_fb_register_device("mdp", &mdp_pdata);
9747
9748 msm_fb_register_device("lcdc", &lcdc_pdata);
9749 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9750#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009751 if (hdmi_is_primary)
9752 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9753 else
9754 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009755#endif
9756#ifdef CONFIG_FB_MSM_TVOUT
9757 msm_fb_register_device("tvenc", &atv_pdata);
9758 msm_fb_register_device("tvout_device", NULL);
9759#endif
9760}
9761
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009762/**
9763 * Set MDP clocks to high frequency to avoid underflow when
9764 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9765 */
9766static void set_mdp_clocks_for_wuxga(void)
9767{
9768 int i;
9769
9770 mdp_sd_smi_vectors[0].ab = 2000000000;
9771 mdp_sd_smi_vectors[0].ib = 2000000000;
9772 mdp_sd_smi_vectors[1].ab = 2000000000;
9773 mdp_sd_smi_vectors[1].ib = 2000000000;
9774
9775 mdp_sd_ebi_vectors[0].ab = 2000000000;
9776 mdp_sd_ebi_vectors[0].ib = 2000000000;
9777 mdp_sd_ebi_vectors[1].ab = 2000000000;
9778 mdp_sd_ebi_vectors[1].ib = 2000000000;
9779
9780 mdp_vga_vectors[0].ab = 2000000000;
9781 mdp_vga_vectors[0].ib = 2000000000;
9782 mdp_vga_vectors[1].ab = 2000000000;
9783 mdp_vga_vectors[1].ib = 2000000000;
9784
9785 mdp_720p_vectors[0].ab = 2000000000;
9786 mdp_720p_vectors[0].ib = 2000000000;
9787 mdp_720p_vectors[1].ab = 2000000000;
9788 mdp_720p_vectors[1].ib = 2000000000;
9789
9790 mdp_1080p_vectors[0].ab = 2000000000;
9791 mdp_1080p_vectors[0].ib = 2000000000;
9792 mdp_1080p_vectors[1].ab = 2000000000;
9793 mdp_1080p_vectors[1].ib = 2000000000;
9794
9795 mdp_pdata.mdp_core_clk_rate = 200000000;
9796
9797 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9798 mdp_core_clk_rate_table[i] = 200000000;
9799}
9800
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009801#if (defined(CONFIG_MARIMBA_CORE)) && \
9802 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9803
9804static const struct {
9805 char *name;
9806 int vmin;
9807 int vmax;
9808} bt_regs_info[] = {
9809 { "8058_s3", 1800000, 1800000 },
9810 { "8058_s2", 1300000, 1300000 },
9811 { "8058_l8", 2900000, 3050000 },
9812};
9813
9814static struct {
9815 bool enabled;
9816} bt_regs_status[] = {
9817 { false },
9818 { false },
9819 { false },
9820};
9821static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9822
9823static int bahama_bt(int on)
9824{
9825 int rc;
9826 int i;
9827 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9828
9829 struct bahama_variant_register {
9830 const size_t size;
9831 const struct bahama_config_register *set;
9832 };
9833
9834 const struct bahama_config_register *p;
9835
9836 u8 version;
9837
9838 const struct bahama_config_register v10_bt_on[] = {
9839 { 0xE9, 0x00, 0xFF },
9840 { 0xF4, 0x80, 0xFF },
9841 { 0xE4, 0x00, 0xFF },
9842 { 0xE5, 0x00, 0x0F },
9843#ifdef CONFIG_WLAN
9844 { 0xE6, 0x38, 0x7F },
9845 { 0xE7, 0x06, 0xFF },
9846#endif
9847 { 0xE9, 0x21, 0xFF },
9848 { 0x01, 0x0C, 0x1F },
9849 { 0x01, 0x08, 0x1F },
9850 };
9851
9852 const struct bahama_config_register v20_bt_on_fm_off[] = {
9853 { 0x11, 0x0C, 0xFF },
9854 { 0x13, 0x01, 0xFF },
9855 { 0xF4, 0x80, 0xFF },
9856 { 0xF0, 0x00, 0xFF },
9857 { 0xE9, 0x00, 0xFF },
9858#ifdef CONFIG_WLAN
9859 { 0x81, 0x00, 0x7F },
9860 { 0x82, 0x00, 0xFF },
9861 { 0xE6, 0x38, 0x7F },
9862 { 0xE7, 0x06, 0xFF },
9863#endif
9864 { 0xE9, 0x21, 0xFF },
9865 };
9866
9867 const struct bahama_config_register v20_bt_on_fm_on[] = {
9868 { 0x11, 0x0C, 0xFF },
9869 { 0x13, 0x01, 0xFF },
9870 { 0xF4, 0x86, 0xFF },
9871 { 0xF0, 0x06, 0xFF },
9872 { 0xE9, 0x00, 0xFF },
9873#ifdef CONFIG_WLAN
9874 { 0x81, 0x00, 0x7F },
9875 { 0x82, 0x00, 0xFF },
9876 { 0xE6, 0x38, 0x7F },
9877 { 0xE7, 0x06, 0xFF },
9878#endif
9879 { 0xE9, 0x21, 0xFF },
9880 };
9881
9882 const struct bahama_config_register v10_bt_off[] = {
9883 { 0xE9, 0x00, 0xFF },
9884 };
9885
9886 const struct bahama_config_register v20_bt_off_fm_off[] = {
9887 { 0xF4, 0x84, 0xFF },
9888 { 0xF0, 0x04, 0xFF },
9889 { 0xE9, 0x00, 0xFF }
9890 };
9891
9892 const struct bahama_config_register v20_bt_off_fm_on[] = {
9893 { 0xF4, 0x86, 0xFF },
9894 { 0xF0, 0x06, 0xFF },
9895 { 0xE9, 0x00, 0xFF }
9896 };
9897 const struct bahama_variant_register bt_bahama[2][3] = {
9898 {
9899 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9900 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9901 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9902 },
9903 {
9904 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9905 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9906 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9907 }
9908 };
9909
9910 u8 offset = 0; /* index into bahama configs */
9911
9912 on = on ? 1 : 0;
9913 version = read_bahama_ver();
9914
9915 if (version == VER_UNSUPPORTED) {
9916 dev_err(&msm_bt_power_device.dev,
9917 "%s: unsupported version\n",
9918 __func__);
9919 return -EIO;
9920 }
9921
9922 if (version == VER_2_0) {
9923 if (marimba_get_fm_status(&config))
9924 offset = 0x01;
9925 }
9926
9927 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9928 if (on && (version == VER_2_0)) {
9929 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9930 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9931 && (bt_regs_status[i].enabled == true)) {
9932 if (regulator_disable(bt_regs[i])) {
9933 dev_err(&msm_bt_power_device.dev,
9934 "%s: regulator disable failed",
9935 __func__);
9936 }
9937 bt_regs_status[i].enabled = false;
9938 break;
9939 }
9940 }
9941 }
9942
9943 p = bt_bahama[on][version + offset].set;
9944
9945 dev_info(&msm_bt_power_device.dev,
9946 "%s: found version %d\n", __func__, version);
9947
9948 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9949 u8 value = (p+i)->value;
9950 rc = marimba_write_bit_mask(&config,
9951 (p+i)->reg,
9952 &value,
9953 sizeof((p+i)->value),
9954 (p+i)->mask);
9955 if (rc < 0) {
9956 dev_err(&msm_bt_power_device.dev,
9957 "%s: reg %d write failed: %d\n",
9958 __func__, (p+i)->reg, rc);
9959 return rc;
9960 }
9961 dev_dbg(&msm_bt_power_device.dev,
9962 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9963 __func__, (p+i)->reg,
9964 value, (p+i)->mask);
9965 }
9966 /* Update BT Status */
9967 if (on)
9968 marimba_set_bt_status(&config, true);
9969 else
9970 marimba_set_bt_status(&config, false);
9971
9972 return 0;
9973}
9974
9975static int bluetooth_use_regulators(int on)
9976{
9977 int i, recover = -1, rc = 0;
9978
9979 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9980 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9981 bt_regs_info[i].name) :
9982 (regulator_put(bt_regs[i]), NULL);
9983 if (IS_ERR(bt_regs[i])) {
9984 rc = PTR_ERR(bt_regs[i]);
9985 dev_err(&msm_bt_power_device.dev,
9986 "regulator %s get failed (%d)\n",
9987 bt_regs_info[i].name, rc);
9988 recover = i - 1;
9989 bt_regs[i] = NULL;
9990 break;
9991 }
9992
9993 if (!on)
9994 continue;
9995
9996 rc = regulator_set_voltage(bt_regs[i],
9997 bt_regs_info[i].vmin,
9998 bt_regs_info[i].vmax);
9999 if (rc < 0) {
10000 dev_err(&msm_bt_power_device.dev,
10001 "regulator %s voltage set (%d)\n",
10002 bt_regs_info[i].name, rc);
10003 recover = i;
10004 break;
10005 }
10006 }
10007
10008 if (on && (recover > -1))
10009 for (i = recover; i >= 0; i--) {
10010 regulator_put(bt_regs[i]);
10011 bt_regs[i] = NULL;
10012 }
10013
10014 return rc;
10015}
10016
10017static int bluetooth_switch_regulators(int on)
10018{
10019 int i, rc = 0;
10020
10021 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10022 if (on && (bt_regs_status[i].enabled == false)) {
10023 rc = regulator_enable(bt_regs[i]);
10024 if (rc < 0) {
10025 dev_err(&msm_bt_power_device.dev,
10026 "regulator %s %s failed (%d)\n",
10027 bt_regs_info[i].name,
10028 "enable", rc);
10029 if (i > 0) {
10030 while (--i) {
10031 regulator_disable(bt_regs[i]);
10032 bt_regs_status[i].enabled
10033 = false;
10034 }
10035 break;
10036 }
10037 }
10038 bt_regs_status[i].enabled = true;
10039 } else if (!on && (bt_regs_status[i].enabled == true)) {
10040 rc = regulator_disable(bt_regs[i]);
10041 if (rc < 0) {
10042 dev_err(&msm_bt_power_device.dev,
10043 "regulator %s %s failed (%d)\n",
10044 bt_regs_info[i].name,
10045 "disable", rc);
10046 break;
10047 }
10048 bt_regs_status[i].enabled = false;
10049 }
10050 }
10051 return rc;
10052}
10053
10054static struct msm_xo_voter *bt_clock;
10055
10056static int bluetooth_power(int on)
10057{
10058 int rc = 0;
10059 int id;
10060
10061 /* In case probe function fails, cur_connv_type would be -1 */
10062 id = adie_get_detected_connectivity_type();
10063 if (id != BAHAMA_ID) {
10064 pr_err("%s: unexpected adie connectivity type: %d\n",
10065 __func__, id);
10066 return -ENODEV;
10067 }
10068
10069 if (on) {
10070
10071 rc = bluetooth_use_regulators(1);
10072 if (rc < 0)
10073 goto out;
10074
10075 rc = bluetooth_switch_regulators(1);
10076
10077 if (rc < 0)
10078 goto fail_put;
10079
10080 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10081
10082 if (IS_ERR(bt_clock)) {
10083 pr_err("Couldn't get TCXO_D0 voter\n");
10084 goto fail_switch;
10085 }
10086
10087 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10088
10089 if (rc < 0) {
10090 pr_err("Failed to vote for TCXO_DO ON\n");
10091 goto fail_vote;
10092 }
10093
10094 rc = bahama_bt(1);
10095
10096 if (rc < 0)
10097 goto fail_clock;
10098
10099 msleep(10);
10100
10101 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10102
10103 if (rc < 0) {
10104 pr_err("Failed to vote for TCXO_DO pin control\n");
10105 goto fail_vote;
10106 }
10107 } else {
10108 /* check for initial RFKILL block (power off) */
10109 /* some RFKILL versions/configurations rfkill_register */
10110 /* calls here for an initial set_block */
10111 /* avoid calling i2c and regulator before unblock (on) */
10112 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10113 dev_info(&msm_bt_power_device.dev,
10114 "%s: initialized OFF/blocked\n", __func__);
10115 goto out;
10116 }
10117
10118 bahama_bt(0);
10119
10120fail_clock:
10121 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10122fail_vote:
10123 msm_xo_put(bt_clock);
10124fail_switch:
10125 bluetooth_switch_regulators(0);
10126fail_put:
10127 bluetooth_use_regulators(0);
10128 }
10129
10130out:
10131 if (rc < 0)
10132 on = 0;
10133 dev_info(&msm_bt_power_device.dev,
10134 "Bluetooth power switch: state %d result %d\n", on, rc);
10135
10136 return rc;
10137}
10138
10139#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10140
10141static void __init msm8x60_cfg_smsc911x(void)
10142{
10143 smsc911x_resources[1].start =
10144 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10145 smsc911x_resources[1].end =
10146 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10147}
10148
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010149void msm_fusion_setup_pinctrl(void)
10150{
10151 struct msm_xo_voter *a1;
10152
10153 if (socinfo_get_platform_subtype() == 0x3) {
10154 /*
10155 * Vote for the A1 clock to be in pin control mode before
10156 * the external images are loaded.
10157 */
10158 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10159 BUG_ON(!a1);
10160 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10161 }
10162}
10163
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010164struct msm_board_data {
10165 struct msm_gpiomux_configs *gpiomux_cfgs;
10166};
10167
10168static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10169 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10170};
10171
10172static struct msm_board_data msm8x60_sim_board_data __initdata = {
10173 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10174};
10175
10176static struct msm_board_data msm8x60_surf_board_data __initdata = {
10177 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10178};
10179
10180static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10181 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10182};
10183
10184static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10185 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10186};
10187
10188static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10189 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10190};
10191
10192static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10193 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10194};
10195
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010196static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10197 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10198};
10199
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010200static void __init msm8x60_init(struct msm_board_data *board_data)
10201{
10202 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010203#ifdef CONFIG_USB_EHCI_MSM_72K
10204 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10205 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10206 .level = PM8901_MPP_DIG_LEVEL_L5,
10207 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10208 };
10209#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010210 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010211
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010212 /*
10213 * Initialize RPM first as other drivers and devices may need
10214 * it for their initialization.
10215 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010216 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10217 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010218 if (msm_xo_init())
10219 pr_err("Failed to initialize XO votes\n");
10220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010221 msm8x60_check_2d_hardware();
10222
10223 /* Change SPM handling of core 1 if PMM 8160 is present. */
10224 soc_platform_version = socinfo_get_platform_version();
10225 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10226 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10227 struct msm_spm_platform_data *spm_data;
10228
10229 spm_data = &msm_spm_data_v1[1];
10230 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10231 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10232
10233 spm_data = &msm_spm_data[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
10238 /*
10239 * Initialize SPM before acpuclock as the latter calls into SPM
10240 * driver to set ACPU voltages.
10241 */
10242 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10243 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10244 else
10245 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10246
10247 /*
10248 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10249 * devices so that the RPM doesn't drop into a low power mode that an
10250 * un-reworked SURF cannot resume from.
10251 */
10252 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010253 int i;
10254
10255 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10256 if (rpm_regulator_init_data[i].id
10257 == RPM_VREG_ID_PM8901_L4
10258 || rpm_regulator_init_data[i].id
10259 == RPM_VREG_ID_PM8901_L6)
10260 rpm_regulator_init_data[i]
10261 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010262 }
10263
10264 /*
10265 * Disable regulator info printing so that regulator registration
10266 * messages do not enter the kmsg log.
10267 */
10268 regulator_suppress_info_printing();
10269
10270 /* Initialize regulators needed for clock_init. */
10271 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10272
Stephen Boydbb600ae2011-08-02 20:11:40 -070010273 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010274
10275 /* Buses need to be initialized before early-device registration
10276 * to get the platform data for fabrics.
10277 */
10278 msm8x60_init_buses();
10279 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10280 /* CPU frequency control is not supported on simulated targets. */
10281 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010282 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010283
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010284 /*
10285 * Enable EBI2 only for boards which make use of it. Leave
10286 * it disabled for all others for additional power savings.
10287 */
10288 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10289 machine_is_msm8x60_rumi3() ||
10290 machine_is_msm8x60_sim() ||
10291 machine_is_msm8x60_fluid() ||
10292 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010293 msm8x60_init_ebi2();
10294 msm8x60_init_tlmm();
10295 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10296 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010297#ifdef CONFIG_MSM_CAMERA_V4L2
10298 msm8x60_init_cam();
10299#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010300 msm8x60_init_mmc();
10301
Kevin Chan3be11612012-03-22 20:05:40 -070010302
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010303#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10304 msm8x60_init_pm8058_othc();
10305#endif
10306
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010307 if (machine_is_msm8x60_fluid())
10308 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10309 else if (machine_is_msm8x60_dragon())
10310 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10311 else
10312 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Kevin Chan3be11612012-03-22 20:05:40 -070010313#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang53d27a82011-07-13 14:32:58 -040010314 /* Specify reset pin for OV9726 */
10315 if (machine_is_msm8x60_dragon()) {
10316 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10317 ov9726_sensor_8660_info.mount_angle = 270;
10318 }
Kevin Chan3be11612012-03-22 20:05:40 -070010319#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010320#ifdef CONFIG_BATTERY_MSM8X60
10321 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10322 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10323 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10324 platform_device_register(&msm_charger_device);
10325#endif
10326
10327 if (machine_is_msm8x60_dragon())
10328 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10329 if (!machine_is_msm8x60_fluid())
10330 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10331
10332 /* configure pmic leds */
10333 if (machine_is_msm8x60_fluid())
10334 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10335 else if (machine_is_msm8x60_dragon())
10336 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10337 else
10338 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10339
10340 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10341 machine_is_msm8x60_dragon()) {
10342 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10343 }
10344
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010345 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10346 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010347 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010348 msm8x60_cfg_smsc911x();
10349 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010350 platform_add_devices(msm8660_footswitch,
10351 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010352 platform_add_devices(surf_devices,
10353 ARRAY_SIZE(surf_devices));
10354
10355#ifdef CONFIG_MSM_DSPS
10356 if (machine_is_msm8x60_fluid()) {
10357 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10358 msm8x60_init_dsps();
10359 }
10360#endif
10361
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010362 pm8901_vreg_mpp0_init();
10363
10364 platform_device_register(&msm8x60_8901_mpp_vreg);
10365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010366#ifdef CONFIG_USB_EHCI_MSM_72K
10367 /*
10368 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10369 * fluid
10370 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010371 if (machine_is_msm8x60_fluid())
10372 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10373 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010374#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010375
10376#ifdef CONFIG_SND_SOC_MSM8660_APQ
10377 if (machine_is_msm8x60_dragon())
10378 platform_add_devices(dragon_alsa_devices,
10379 ARRAY_SIZE(dragon_alsa_devices));
10380 else
10381#endif
10382 platform_add_devices(asoc_devices,
10383 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010384 } else {
10385 msm8x60_configure_smc91x();
10386 platform_add_devices(rumi_sim_devices,
10387 ARRAY_SIZE(rumi_sim_devices));
10388 }
10389#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010390 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10391 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010392 msm8x60_cfg_isp1763();
10393#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010394
10395 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10396 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10397
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010398
10399#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10400 if (machine_is_msm8x60_fluid())
10401 platform_device_register(&msm_gsbi10_qup_spi_device);
10402 else
10403 platform_device_register(&msm_gsbi1_qup_spi_device);
10404#endif
10405
10406#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10407 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10408 if (machine_is_msm8x60_fluid())
10409 cyttsp_set_params();
10410#endif
10411 if (!machine_is_msm8x60_sim())
10412 msm_fb_add_devices();
10413 fixup_i2c_configs();
10414 register_i2c_devices();
10415
Terence Hampson1c73fef2011-07-19 17:10:49 -040010416 if (machine_is_msm8x60_dragon())
10417 smsc911x_config.reset_gpio
10418 = GPIO_ETHERNET_RESET_N_DRAGON;
10419
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010420 platform_device_register(&smsc911x_device);
10421
10422#if (defined(CONFIG_SPI_QUP)) && \
10423 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010424 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10425 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010426
10427 if (machine_is_msm8x60_fluid()) {
10428#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10429 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10430 spi_register_board_info(lcdc_samsung_spi_board_info,
10431 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10432 } else
10433#endif
10434 {
10435#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10436 spi_register_board_info(lcdc_auo_spi_board_info,
10437 ARRAY_SIZE(lcdc_auo_spi_board_info));
10438#endif
10439 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010440#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10441 } else if (machine_is_msm8x60_dragon()) {
10442 spi_register_board_info(lcdc_nt35582_spi_board_info,
10443 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10444#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010445 }
10446#endif
10447
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010448 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010449
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010450 pm8058_gpios_init();
10451
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010452#ifdef CONFIG_SENSORS_MSM_ADC
10453 if (machine_is_msm8x60_fluid()) {
10454 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10455 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10456 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10457 msm_adc_pdata.gpio_config = APROC_CONFIG;
10458 else
10459 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10460 }
10461 msm_adc_pdata.target_hw = MSM_8x60;
10462#endif
10463#ifdef CONFIG_MSM8X60_AUDIO
10464 msm_snddev_init();
10465#endif
10466#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10467 if (machine_is_msm8x60_fluid())
10468 platform_device_register(&fluid_leds_gpio);
10469 else
10470 platform_device_register(&gpio_leds);
10471#endif
10472
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010473 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010474
10475 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10476 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010477}
10478
10479static void __init msm8x60_rumi3_init(void)
10480{
10481 msm8x60_init(&msm8x60_rumi3_board_data);
10482}
10483
10484static void __init msm8x60_sim_init(void)
10485{
10486 msm8x60_init(&msm8x60_sim_board_data);
10487}
10488
10489static void __init msm8x60_surf_init(void)
10490{
10491 msm8x60_init(&msm8x60_surf_board_data);
10492}
10493
10494static void __init msm8x60_ffa_init(void)
10495{
10496 msm8x60_init(&msm8x60_ffa_board_data);
10497}
10498
10499static void __init msm8x60_fluid_init(void)
10500{
10501 msm8x60_init(&msm8x60_fluid_board_data);
10502}
10503
10504static void __init msm8x60_charm_surf_init(void)
10505{
10506 msm8x60_init(&msm8x60_charm_surf_board_data);
10507}
10508
10509static void __init msm8x60_charm_ffa_init(void)
10510{
10511 msm8x60_init(&msm8x60_charm_ffa_board_data);
10512}
10513
10514static void __init msm8x60_charm_init_early(void)
10515{
10516 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010517}
10518
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010519static void __init msm8x60_dragon_init(void)
10520{
10521 msm8x60_init(&msm8x60_dragon_board_data);
10522}
10523
Steve Mucklea55df6e2010-01-07 12:43:24 -080010524MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10525 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010526 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010527 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010528 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010529 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010530 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010531 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010532MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010533
10534MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10535 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010536 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010537 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010538 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010539 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010540 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010541 .init_early = msm8x60_charm_init_early,
10542MACHINE_END
10543
10544MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10545 .map_io = msm8x60_map_io,
10546 .reserve = msm8x60_reserve,
10547 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010548 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010549 .init_machine = msm8x60_surf_init,
10550 .timer = &msm_timer,
10551 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010552MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010553
10554MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10555 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010556 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010557 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010558 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010559 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010560 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010561 .init_early = msm8x60_charm_init_early,
10562MACHINE_END
10563
10564MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10565 .map_io = msm8x60_map_io,
10566 .reserve = msm8x60_reserve,
10567 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010568 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010569 .init_machine = msm8x60_fluid_init,
10570 .timer = &msm_timer,
10571 .init_early = msm8x60_charm_init_early,
10572MACHINE_END
10573
10574MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10575 .map_io = msm8x60_map_io,
10576 .reserve = msm8x60_reserve,
10577 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010578 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010579 .init_machine = msm8x60_charm_surf_init,
10580 .timer = &msm_timer,
10581 .init_early = msm8x60_charm_init_early,
10582MACHINE_END
10583
10584MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10585 .map_io = msm8x60_map_io,
10586 .reserve = msm8x60_reserve,
10587 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010588 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010589 .init_machine = msm8x60_charm_ffa_init,
10590 .timer = &msm_timer,
10591 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010592MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010593
10594MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10595 .map_io = msm8x60_map_io,
10596 .reserve = msm8x60_reserve,
10597 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010598 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010599 .init_machine = msm8x60_dragon_init,
10600 .timer = &msm_timer,
10601 .init_early = msm8x60_charm_init_early,
10602MACHINE_END