blob: 418428b099f0bcecfc6ffe51473185fba15ff9fe [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, 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>
Steve Mucklea55df6e2010-01-07 12:43:24 -080088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#include "devices.h"
90#include "devices-msm8x60.h"
91#include "cpuidle.h"
92#include "pm.h"
93#include "mpm.h"
94#include "spm.h"
95#include "rpm_log.h"
96#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097#include "gpiomux-8x60.h"
98#include "rpm_stats.h"
99#include "peripheral-loader.h"
100#include <linux/platform_data/qcom_crypto_device.h>
101#include "rpm_resources.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -0700102#include "acpuclock.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600103#include "pm-boot.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700104
105#include <linux/ion.h>
106#include <mach/ion.h>
107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109#define MDM2AP_SYNC 129
110
Terence Hampson1c73fef2011-07-19 17:10:49 -0400111#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112#define LCDC_SPI_GPIO_CLK 73
113#define LCDC_SPI_GPIO_CS 72
114#define LCDC_SPI_GPIO_MOSI 70
115#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
116#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
117#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
118#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
119#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400120#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700122#define PANEL_NAME_MAX_LEN 30
123#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
124#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
125#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
126#define HDMI_PANEL_NAME "hdmi_msm"
127#define TVOUT_PANEL_NAME "tvout_msm"
128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129#define DSPS_PIL_GENERIC_NAME "dsps"
130#define DSPS_PIL_FLUID_NAME "dsps_fluid"
131
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800132#ifdef CONFIG_ION_MSM
133static struct platform_device ion_dev;
134#endif
135
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136enum {
137 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530138 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700139 /* CORE expander */
140 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
141 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
142 GPIO_WLAN_DEEP_SLEEP_N,
143 GPIO_LVDS_SHUTDOWN_N,
144 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
145 GPIO_MS_SYS_RESET_N,
146 GPIO_CAP_TS_RESOUT_N,
147 GPIO_CAP_GAUGE_BI_TOUT,
148 GPIO_ETHERNET_PME,
149 GPIO_EXT_GPS_LNA_EN,
150 GPIO_MSM_WAKES_BT,
151 GPIO_ETHERNET_RESET_N,
152 GPIO_HEADSET_DET_N,
153 GPIO_USB_UICC_EN,
154 GPIO_BACKLIGHT_EN,
155 GPIO_EXT_CAMIF_PWR_EN,
156 GPIO_BATT_GAUGE_INT_N,
157 GPIO_BATT_GAUGE_EN,
158 /* DOCKING expander */
159 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
160 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
161 GPIO_AUX_JTAG_DET_N,
162 GPIO_DONGLE_DET_N,
163 GPIO_SVIDEO_LOAD_DET,
164 GPIO_SVID_AMP_SHUTDOWN1_N,
165 GPIO_SVID_AMP_SHUTDOWN0_N,
166 GPIO_SDC_WP,
167 GPIO_IRDA_PWDN,
168 GPIO_IRDA_RESET_N,
169 GPIO_DONGLE_GPIO0,
170 GPIO_DONGLE_GPIO1,
171 GPIO_DONGLE_GPIO2,
172 GPIO_DONGLE_GPIO3,
173 GPIO_DONGLE_PWR_EN,
174 GPIO_EMMC_RESET_N,
175 GPIO_TP_EXP2_IO15,
176 /* SURF expander */
177 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
178 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
179 GPIO_SD_CARD_DET_2,
180 GPIO_SD_CARD_DET_4,
181 GPIO_SD_CARD_DET_5,
182 GPIO_UIM3_RST,
183 GPIO_SURF_EXPANDER_IO5,
184 GPIO_SURF_EXPANDER_IO6,
185 GPIO_ADC_I2C_EN,
186 GPIO_SURF_EXPANDER_IO8,
187 GPIO_SURF_EXPANDER_IO9,
188 GPIO_SURF_EXPANDER_IO10,
189 GPIO_SURF_EXPANDER_IO11,
190 GPIO_SURF_EXPANDER_IO12,
191 GPIO_SURF_EXPANDER_IO13,
192 GPIO_SURF_EXPANDER_IO14,
193 GPIO_SURF_EXPANDER_IO15,
194 /* LEFT KB IO expander */
195 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
196 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
197 GPIO_LEFT_LED_2,
198 GPIO_LEFT_LED_3,
199 GPIO_LEFT_LED_WLAN,
200 GPIO_JOYSTICK_EN,
201 GPIO_CAP_TS_SLEEP,
202 GPIO_LEFT_KB_IO6,
203 GPIO_LEFT_LED_5,
204 /* RIGHT KB IO expander */
205 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
206 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
207 GPIO_RIGHT_LED_2,
208 GPIO_RIGHT_LED_3,
209 GPIO_RIGHT_LED_BT,
210 GPIO_WEB_CAMIF_STANDBY,
211 GPIO_COMPASS_RST_N,
212 GPIO_WEB_CAMIF_RESET_N,
213 GPIO_RIGHT_LED_5,
214 GPIO_R_ALTIMETER_RESET_N,
215 /* FLUID S IO expander */
216 GPIO_SOUTH_EXPANDER_BASE,
217 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
218 GPIO_MIC1_ANCL_SEL,
219 GPIO_HS_MIC4_SEL,
220 GPIO_FML_MIC3_SEL,
221 GPIO_FMR_MIC5_SEL,
222 GPIO_TS_SLEEP,
223 GPIO_HAP_SHIFT_LVL_OE,
224 GPIO_HS_SW_DIR,
225 /* FLUID N IO expander */
226 GPIO_NORTH_EXPANDER_BASE,
227 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
228 GPIO_EPM_5V_BOOST_EN,
229 GPIO_AUX_CAM_2P7_EN,
230 GPIO_LED_FLASH_EN,
231 GPIO_LED1_GREEN_N,
232 GPIO_LED2_RED_N,
233 GPIO_FRONT_CAM_RESET_N,
234 GPIO_EPM_LVLSFT_EN,
235 GPIO_N_ALTIMETER_RESET_N,
236 /* EPM expander */
237 GPIO_EPM_EXPANDER_BASE,
238 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
239 GPIO_PWR_MON_RESET_N,
240 GPIO_ADC1_PWDN_N,
241 GPIO_ADC2_PWDN_N,
242 GPIO_EPM_EXPANDER_IO4,
243 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
244 GPIO_ADC2_MUX_SPI_INT_N,
245 GPIO_EPM_EXPANDER_IO7,
246 GPIO_PWR_MON_ENABLE,
247 GPIO_EPM_SPI_ADC1_CS_N,
248 GPIO_EPM_SPI_ADC2_CS_N,
249 GPIO_EPM_EXPANDER_IO11,
250 GPIO_EPM_EXPANDER_IO12,
251 GPIO_EPM_EXPANDER_IO13,
252 GPIO_EPM_EXPANDER_IO14,
253 GPIO_EPM_EXPANDER_IO15,
254};
255
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530256struct pm8xxx_mpp_init_info {
257 unsigned mpp;
258 struct pm8xxx_mpp_config_data config;
259};
260
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530261#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530262{ \
263 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
264 .config = { \
265 .type = PM8XXX_MPP_TYPE_##_type, \
266 .level = _level, \
267 .control = PM8XXX_MPP_##_control, \
268 } \
269}
270
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530271#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
272{ \
273 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
274 .config = { \
275 .type = PM8XXX_MPP_TYPE_##_type, \
276 .level = _level, \
277 .control = PM8XXX_MPP_##_control, \
278 } \
279}
280
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700281/*
282 * The UI_INTx_N lines are pmic gpio lines which connect i2c
283 * gpio expanders to the pm8058.
284 */
285#define UI_INT1_N 25
286#define UI_INT2_N 34
287#define UI_INT3_N 14
288/*
289FM GPIO is GPIO 18 on PMIC 8058.
290As the index starts from 0 in the PMIC driver, and hence 17
291corresponds to GPIO 18 on PMIC 8058.
292*/
293#define FM_GPIO 17
294
295#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
296static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
297static void *sdc2_status_notify_cb_devid;
298#endif
299
300#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
301static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
302static void *sdc5_status_notify_cb_devid;
303#endif
304
305static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
306 [0] = {
307 .reg_base_addr = MSM_SAW0_BASE,
308
309#ifdef CONFIG_MSM_AVS_HW
310 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
311#endif
312 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
313 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
314 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
315 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
316
317 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
318 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
319 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
320
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
322 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
323 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
324
325 .awake_vlevel = 0x94,
326 .retention_vlevel = 0x81,
327 .collapse_vlevel = 0x20,
328 .retention_mid_vlevel = 0x94,
329 .collapse_mid_vlevel = 0x8C,
330
331 .vctl_timeout_us = 50,
332 },
333
334 [1] = {
335 .reg_base_addr = MSM_SAW1_BASE,
336
337#ifdef CONFIG_MSM_AVS_HW
338 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
339#endif
340 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
341 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
342 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
343 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
344
345 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
346 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
347 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
348
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
350 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
351 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
352
353 .awake_vlevel = 0x94,
354 .retention_vlevel = 0x81,
355 .collapse_vlevel = 0x20,
356 .retention_mid_vlevel = 0x94,
357 .collapse_mid_vlevel = 0x8C,
358
359 .vctl_timeout_us = 50,
360 },
361};
362
363static struct msm_spm_platform_data msm_spm_data[] __initdata = {
364 [0] = {
365 .reg_base_addr = MSM_SAW0_BASE,
366
367#ifdef CONFIG_MSM_AVS_HW
368 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
369#endif
370 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
371 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
372 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
373 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
374
375 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
376 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
377 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
378
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
380 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
381 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
382
383 .awake_vlevel = 0xA0,
384 .retention_vlevel = 0x89,
385 .collapse_vlevel = 0x20,
386 .retention_mid_vlevel = 0x89,
387 .collapse_mid_vlevel = 0x89,
388
389 .vctl_timeout_us = 50,
390 },
391
392 [1] = {
393 .reg_base_addr = MSM_SAW1_BASE,
394
395#ifdef CONFIG_MSM_AVS_HW
396 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
397#endif
398 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
399 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
400 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
401 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
402
403 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
404 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
405 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
406
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
408 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
409 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
410
411 .awake_vlevel = 0xA0,
412 .retention_vlevel = 0x89,
413 .collapse_vlevel = 0x20,
414 .retention_mid_vlevel = 0x89,
415 .collapse_mid_vlevel = 0x89,
416
417 .vctl_timeout_us = 50,
418 },
419};
420
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700421/*
422 * Consumer specific regulator names:
423 * regulator name consumer dev_name
424 */
425static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
426 REGULATOR_SUPPLY("8901_s0", NULL),
427};
428static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
429 REGULATOR_SUPPLY("8901_s1", NULL),
430};
431
432static struct regulator_init_data saw_s0_init_data = {
433 .constraints = {
434 .name = "8901_s0",
435 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700436 .min_uV = 800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700437 .max_uV = 1250000,
438 },
439 .consumer_supplies = vreg_consumers_8901_S0,
440 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
441};
442
443static struct regulator_init_data saw_s1_init_data = {
444 .constraints = {
445 .name = "8901_s1",
446 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700447 .min_uV = 800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700448 .max_uV = 1250000,
449 },
450 .consumer_supplies = vreg_consumers_8901_S1,
451 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
452};
453
454static struct platform_device msm_device_saw_s0 = {
455 .name = "saw-regulator",
456 .id = 0,
457 .dev = {
458 .platform_data = &saw_s0_init_data,
459 },
460};
461
462static struct platform_device msm_device_saw_s1 = {
463 .name = "saw-regulator",
464 .id = 1,
465 .dev = {
466 .platform_data = &saw_s1_init_data,
467 },
468};
469
470/*
471 * The smc91x configuration varies depending on platform.
472 * The resources data structure is filled in at runtime.
473 */
474static struct resource smc91x_resources[] = {
475 [0] = {
476 .flags = IORESOURCE_MEM,
477 },
478 [1] = {
479 .flags = IORESOURCE_IRQ,
480 },
481};
482
483static struct platform_device smc91x_device = {
484 .name = "smc91x",
485 .id = 0,
486 .num_resources = ARRAY_SIZE(smc91x_resources),
487 .resource = smc91x_resources,
488};
489
490static struct resource smsc911x_resources[] = {
491 [0] = {
492 .flags = IORESOURCE_MEM,
493 .start = 0x1b800000,
494 .end = 0x1b8000ff
495 },
496 [1] = {
497 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
498 },
499};
500
501static struct smsc911x_platform_config smsc911x_config = {
502 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
503 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
504 .flags = SMSC911X_USE_16BIT,
505 .has_reset_gpio = 1,
506 .reset_gpio = GPIO_ETHERNET_RESET_N
507};
508
509static struct platform_device smsc911x_device = {
510 .name = "smsc911x",
511 .id = 0,
512 .num_resources = ARRAY_SIZE(smsc911x_resources),
513 .resource = smsc911x_resources,
514 .dev = {
515 .platform_data = &smsc911x_config
516 }
517};
518
519#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
520 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
521 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
522 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
523
524#define QCE_SIZE 0x10000
525#define QCE_0_BASE 0x18500000
526
527#define QCE_HW_KEY_SUPPORT 0
528#define QCE_SHA_HMAC_SUPPORT 0
529#define QCE_SHARE_CE_RESOURCE 2
530#define QCE_CE_SHARED 1
531
532static struct resource qcrypto_resources[] = {
533 [0] = {
534 .start = QCE_0_BASE,
535 .end = QCE_0_BASE + QCE_SIZE - 1,
536 .flags = IORESOURCE_MEM,
537 },
538 [1] = {
539 .name = "crypto_channels",
540 .start = DMOV_CE_IN_CHAN,
541 .end = DMOV_CE_OUT_CHAN,
542 .flags = IORESOURCE_DMA,
543 },
544 [2] = {
545 .name = "crypto_crci_in",
546 .start = DMOV_CE_IN_CRCI,
547 .end = DMOV_CE_IN_CRCI,
548 .flags = IORESOURCE_DMA,
549 },
550 [3] = {
551 .name = "crypto_crci_out",
552 .start = DMOV_CE_OUT_CRCI,
553 .end = DMOV_CE_OUT_CRCI,
554 .flags = IORESOURCE_DMA,
555 },
556 [4] = {
557 .name = "crypto_crci_hash",
558 .start = DMOV_CE_HASH_CRCI,
559 .end = DMOV_CE_HASH_CRCI,
560 .flags = IORESOURCE_DMA,
561 },
562};
563
564static struct resource qcedev_resources[] = {
565 [0] = {
566 .start = QCE_0_BASE,
567 .end = QCE_0_BASE + QCE_SIZE - 1,
568 .flags = IORESOURCE_MEM,
569 },
570 [1] = {
571 .name = "crypto_channels",
572 .start = DMOV_CE_IN_CHAN,
573 .end = DMOV_CE_OUT_CHAN,
574 .flags = IORESOURCE_DMA,
575 },
576 [2] = {
577 .name = "crypto_crci_in",
578 .start = DMOV_CE_IN_CRCI,
579 .end = DMOV_CE_IN_CRCI,
580 .flags = IORESOURCE_DMA,
581 },
582 [3] = {
583 .name = "crypto_crci_out",
584 .start = DMOV_CE_OUT_CRCI,
585 .end = DMOV_CE_OUT_CRCI,
586 .flags = IORESOURCE_DMA,
587 },
588 [4] = {
589 .name = "crypto_crci_hash",
590 .start = DMOV_CE_HASH_CRCI,
591 .end = DMOV_CE_HASH_CRCI,
592 .flags = IORESOURCE_DMA,
593 },
594};
595
596#endif
597
598#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
599 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
600
601static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
602 .ce_shared = QCE_CE_SHARED,
603 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
604 .hw_key_support = QCE_HW_KEY_SUPPORT,
605 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800606 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700607};
608
609static struct platform_device qcrypto_device = {
610 .name = "qcrypto",
611 .id = 0,
612 .num_resources = ARRAY_SIZE(qcrypto_resources),
613 .resource = qcrypto_resources,
614 .dev = {
615 .coherent_dma_mask = DMA_BIT_MASK(32),
616 .platform_data = &qcrypto_ce_hw_suppport,
617 },
618};
619#endif
620
621#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
622 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
623
624static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
625 .ce_shared = QCE_CE_SHARED,
626 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
627 .hw_key_support = QCE_HW_KEY_SUPPORT,
628 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800629 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700630};
631
632static struct platform_device qcedev_device = {
633 .name = "qce",
634 .id = 0,
635 .num_resources = ARRAY_SIZE(qcedev_resources),
636 .resource = qcedev_resources,
637 .dev = {
638 .coherent_dma_mask = DMA_BIT_MASK(32),
639 .platform_data = &qcedev_ce_hw_suppport,
640 },
641};
642#endif
643
644#if defined(CONFIG_HAPTIC_ISA1200) || \
645 defined(CONFIG_HAPTIC_ISA1200_MODULE)
646
647static const char *vregs_isa1200_name[] = {
648 "8058_s3",
649 "8901_l4",
650};
651
652static const int vregs_isa1200_val[] = {
653 1800000,/* uV */
654 2600000,
655};
656static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
657static struct msm_xo_voter *xo_handle_a1;
658
659static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800660{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700661 int i, rc = 0;
662
663 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
664 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
665 regulator_disable(vregs_isa1200[i]);
666 if (rc < 0) {
667 pr_err("%s: vreg %s %s failed (%d)\n",
668 __func__, vregs_isa1200_name[i],
669 vreg_on ? "enable" : "disable", rc);
670 goto vreg_fail;
671 }
672 }
673
674 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
675 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
676 if (rc < 0) {
677 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
678 __func__, vreg_on ? "" : "de-", rc);
679 goto vreg_fail;
680 }
681 return 0;
682
683vreg_fail:
684 while (i--)
685 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
686 regulator_disable(vregs_isa1200[i]);
687 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800688}
689
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700690static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800691{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800693
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700694 if (enable == true) {
695 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
696 vregs_isa1200[i] = regulator_get(NULL,
697 vregs_isa1200_name[i]);
698 if (IS_ERR(vregs_isa1200[i])) {
699 pr_err("%s: regulator get of %s failed (%ld)\n",
700 __func__, vregs_isa1200_name[i],
701 PTR_ERR(vregs_isa1200[i]));
702 rc = PTR_ERR(vregs_isa1200[i]);
703 goto vreg_get_fail;
704 }
705 rc = regulator_set_voltage(vregs_isa1200[i],
706 vregs_isa1200_val[i], vregs_isa1200_val[i]);
707 if (rc) {
708 pr_err("%s: regulator_set_voltage(%s) failed\n",
709 __func__, vregs_isa1200_name[i]);
710 goto vreg_get_fail;
711 }
712 }
Steve Muckle9161d302010-02-11 11:50:40 -0800713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700714 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
715 if (rc) {
716 pr_err("%s: unable to request gpio %d (%d)\n",
717 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
718 goto vreg_get_fail;
719 }
Steve Muckle9161d302010-02-11 11:50:40 -0800720
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700721 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
722 if (rc) {
723 pr_err("%s: Unable to set direction\n", __func__);;
724 goto free_gpio;
725 }
726
727 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
728 if (IS_ERR(xo_handle_a1)) {
729 rc = PTR_ERR(xo_handle_a1);
730 pr_err("%s: failed to get the handle for A1(%d)\n",
731 __func__, rc);
732 goto gpio_set_dir;
733 }
734 } else {
735 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
736 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
737
738 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
739 regulator_put(vregs_isa1200[i]);
740
741 msm_xo_put(xo_handle_a1);
742 }
743
744 return 0;
745gpio_set_dir:
746 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
747free_gpio:
748 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
749vreg_get_fail:
750 while (i)
751 regulator_put(vregs_isa1200[--i]);
752 return rc;
753}
754
755#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530756#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757static struct isa1200_platform_data isa1200_1_pdata = {
758 .name = "vibrator",
759 .power_on = isa1200_power,
760 .dev_setup = isa1200_dev_setup,
761 /*gpio to enable haptic*/
762 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530763 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700764 .max_timeout = 15000,
765 .mode_ctrl = PWM_GEN_MODE,
766 .pwm_fd = {
767 .pwm_div = 256,
768 },
769 .is_erm = false,
770 .smart_en = true,
771 .ext_clk_en = true,
772 .chip_en = 1,
773};
774
775static struct i2c_board_info msm_isa1200_board_info[] = {
776 {
777 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
778 .platform_data = &isa1200_1_pdata,
779 },
780};
781#endif
782
783#if defined(CONFIG_BATTERY_BQ27520) || \
784 defined(CONFIG_BATTERY_BQ27520_MODULE)
785static struct bq27520_platform_data bq27520_pdata = {
786 .name = "fuel-gauge",
787 .vreg_name = "8058_s3",
788 .vreg_value = 1800000,
789 .soc_int = GPIO_BATT_GAUGE_INT_N,
790 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
791 .chip_en = GPIO_BATT_GAUGE_EN,
792 .enable_dlog = 0, /* if enable coulomb counter logger */
793};
794
795static struct i2c_board_info msm_bq27520_board_info[] = {
796 {
797 I2C_BOARD_INFO("bq27520", 0xaa>>1),
798 .platform_data = &bq27520_pdata,
799 },
800};
801#endif
802
803static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
804 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
805 .idle_supported = 1,
806 .suspend_supported = 1,
807 .idle_enabled = 0,
808 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700809 },
810
811 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
812 .idle_supported = 1,
813 .suspend_supported = 1,
814 .idle_enabled = 0,
815 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816 },
817
818 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
819 .idle_supported = 1,
820 .suspend_supported = 1,
821 .idle_enabled = 1,
822 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700823 },
824
825 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
826 .idle_supported = 1,
827 .suspend_supported = 1,
828 .idle_enabled = 0,
829 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700830 },
831
832 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
833 .idle_supported = 1,
834 .suspend_supported = 1,
835 .idle_enabled = 0,
836 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837 },
838
839 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
840 .idle_supported = 1,
841 .suspend_supported = 1,
842 .idle_enabled = 1,
843 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700844 },
845};
846
847static struct msm_cpuidle_state msm_cstates[] __initdata = {
848 {0, 0, "C0", "WFI",
849 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
850
851 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
852 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
853
854 {0, 2, "C2", "POWER_COLLAPSE",
855 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
856
857 {1, 0, "C0", "WFI",
858 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
859
860 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
861 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
862};
863
864static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
865 {
866 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
867 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
868 true,
869 1, 8000, 100000, 1,
870 },
871
872 {
873 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
874 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
875 true,
876 1500, 5000, 60100000, 3000,
877 },
878
879 {
880 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
881 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
882 false,
883 1800, 5000, 60350000, 3500,
884 },
885 {
886 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
887 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
888 false,
889 3800, 4500, 65350000, 5500,
890 },
891
892 {
893 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
894 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
895 false,
896 2800, 2500, 66850000, 4800,
897 },
898
899 {
900 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
901 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
902 false,
903 4800, 2000, 71850000, 6800,
904 },
905
906 {
907 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
908 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
909 false,
910 6800, 500, 75850000, 8800,
911 },
912
913 {
914 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
915 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
916 false,
917 7800, 0, 76350000, 9800,
918 },
919};
920
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600921static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
922 .mode = MSM_PM_BOOT_CONFIG_TZ,
923};
924
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700925#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
926
927#define ISP1763_INT_GPIO 117
928#define ISP1763_RST_GPIO 152
929static struct resource isp1763_resources[] = {
930 [0] = {
931 .flags = IORESOURCE_MEM,
932 .start = 0x1D000000,
933 .end = 0x1D005FFF, /* 24KB */
934 },
935 [1] = {
936 .flags = IORESOURCE_IRQ,
937 },
938};
939static void __init msm8x60_cfg_isp1763(void)
940{
941 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
942 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
943}
944
945static int isp1763_setup_gpio(int enable)
946{
947 int status = 0;
948
949 if (enable) {
950 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
951 if (status) {
952 pr_err("%s:Failed to request GPIO %d\n",
953 __func__, ISP1763_INT_GPIO);
954 return status;
955 }
956 status = gpio_direction_input(ISP1763_INT_GPIO);
957 if (status) {
958 pr_err("%s:Failed to configure GPIO %d\n",
959 __func__, ISP1763_INT_GPIO);
960 goto gpio_free_int;
961 }
962 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
963 if (status) {
964 pr_err("%s:Failed to request GPIO %d\n",
965 __func__, ISP1763_RST_GPIO);
966 goto gpio_free_int;
967 }
968 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
969 if (status) {
970 pr_err("%s:Failed to configure GPIO %d\n",
971 __func__, ISP1763_RST_GPIO);
972 goto gpio_free_rst;
973 }
974 pr_debug("\nISP GPIO configuration done\n");
975 return status;
976 }
977
978gpio_free_rst:
979 gpio_free(ISP1763_RST_GPIO);
980gpio_free_int:
981 gpio_free(ISP1763_INT_GPIO);
982
983 return status;
984}
985static struct isp1763_platform_data isp1763_pdata = {
986 .reset_gpio = ISP1763_RST_GPIO,
987 .setup_gpio = isp1763_setup_gpio
988};
989
990static struct platform_device isp1763_device = {
991 .name = "isp1763_usb",
992 .num_resources = ARRAY_SIZE(isp1763_resources),
993 .resource = isp1763_resources,
994 .dev = {
995 .platform_data = &isp1763_pdata
996 }
997};
998#endif
999
1000#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301001static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001002static struct regulator *ldo6_3p3;
1003static struct regulator *ldo7_1p8;
1004static struct regulator *vdd_cx;
1005#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +05301006#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007notify_vbus_state notify_vbus_state_func_ptr;
1008static int usb_phy_susp_dig_vol = 750000;
1009static int pmic_id_notif_supported;
1010
1011#ifdef CONFIG_USB_EHCI_MSM_72K
1012#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
1013struct delayed_work pmic_id_det;
1014
1015static int __init usb_id_pin_rework_setup(char *support)
1016{
1017 if (strncmp(support, "true", 4) == 0)
1018 pmic_id_notif_supported = 1;
1019
1020 return 1;
1021}
1022__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
1023
1024static void pmic_id_detect(struct work_struct *w)
1025{
1026 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
1027 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
1028
1029 if (notify_vbus_state_func_ptr)
1030 (*notify_vbus_state_func_ptr) (val);
1031}
1032
1033static irqreturn_t pmic_id_on_irq(int irq, void *data)
1034{
1035 /*
1036 * Spurious interrupts are observed on pmic gpio line
1037 * even though there is no state change on USB ID. Schedule the
1038 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001039 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001040 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001041
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001042 return IRQ_HANDLED;
1043}
1044
Anji jonnalaae745e92011-11-14 18:34:31 +05301045static int msm_hsusb_phy_id_setup_init(int init)
1046{
1047 unsigned ret;
1048
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301049 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1050 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1051 .level = PM8901_MPP_DIG_LEVEL_L5,
1052 };
1053
Anji jonnalaae745e92011-11-14 18:34:31 +05301054 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301055 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1056 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1057 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301058 if (ret < 0)
1059 pr_err("%s:MPP2 configuration failed\n", __func__);
1060 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301061 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1062 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1063 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301064 if (ret < 0)
1065 pr_err("%s:MPP2 un config failed\n", __func__);
1066 }
1067 return ret;
1068}
1069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1071{
1072 unsigned ret = -ENODEV;
1073
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301074 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301075 .direction = PM_GPIO_DIR_IN,
1076 .pull = PM_GPIO_PULL_UP_1P5,
1077 .function = PM_GPIO_FUNC_NORMAL,
1078 .vin_sel = 2,
1079 .inv_int_pol = 0,
1080 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301081 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301082 .direction = PM_GPIO_DIR_IN,
1083 .pull = PM_GPIO_PULL_NO,
1084 .function = PM_GPIO_FUNC_NORMAL,
1085 .vin_sel = 2,
1086 .inv_int_pol = 0,
1087 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001088 if (!callback)
1089 return -EINVAL;
1090
1091 if (machine_is_msm8x60_fluid())
1092 return -ENOTSUPP;
1093
1094 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1095 pr_debug("%s: USB_ID pin is not routed to PMIC"
1096 "on V1 surf/ffa\n", __func__);
1097 return -ENOTSUPP;
1098 }
1099
Manu Gautam62158eb2011-11-24 16:20:46 +05301100 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1101 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001102 pr_debug("%s: USB_ID is not routed to PMIC"
1103 "on V2 ffa\n", __func__);
1104 return -ENOTSUPP;
1105 }
1106
1107 usb_phy_susp_dig_vol = 500000;
1108
1109 if (init) {
1110 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301111 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301112 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1113 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301114 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301115 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301116 __func__, ret);
1117 return ret;
1118 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001119 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1120 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1121 "msm_otg_id", NULL);
1122 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001123 pr_err("%s:pmic_usb_id interrupt registration failed",
1124 __func__);
1125 return ret;
1126 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301127 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001128 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301129 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001130 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301131 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1132 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301133 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301134 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301135 __func__, ret);
1136 return ret;
1137 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301138 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001139 cancel_delayed_work_sync(&pmic_id_det);
1140 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001141 }
1142 return 0;
1143}
1144#endif
1145
1146#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1147#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1148static int msm_hsusb_init_vddcx(int init)
1149{
1150 int ret = 0;
1151
1152 if (init) {
1153 vdd_cx = regulator_get(NULL, "8058_s1");
1154 if (IS_ERR(vdd_cx)) {
1155 return PTR_ERR(vdd_cx);
1156 }
1157
1158 ret = regulator_set_voltage(vdd_cx,
1159 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1160 USB_PHY_MAX_VDD_DIG_VOL);
1161 if (ret) {
1162 pr_err("%s: unable to set the voltage for regulator"
1163 "vdd_cx\n", __func__);
1164 regulator_put(vdd_cx);
1165 return ret;
1166 }
1167
1168 ret = regulator_enable(vdd_cx);
1169 if (ret) {
1170 pr_err("%s: unable to enable regulator"
1171 "vdd_cx\n", __func__);
1172 regulator_put(vdd_cx);
1173 }
1174 } else {
1175 ret = regulator_disable(vdd_cx);
1176 if (ret) {
1177 pr_err("%s: Unable to disable the regulator:"
1178 "vdd_cx\n", __func__);
1179 return ret;
1180 }
1181
1182 regulator_put(vdd_cx);
1183 }
1184
1185 return ret;
1186}
1187
1188static int msm_hsusb_config_vddcx(int high)
1189{
1190 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1191 int min_vol;
1192 int ret;
1193
1194 if (high)
1195 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1196 else
1197 min_vol = usb_phy_susp_dig_vol;
1198
1199 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1200 if (ret) {
1201 pr_err("%s: unable to set the voltage for regulator"
1202 "vdd_cx\n", __func__);
1203 return ret;
1204 }
1205
1206 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1207
1208 return ret;
1209}
1210
1211#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1212#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1213#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1214#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1215
1216#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1217#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1218#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1219#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1220static int msm_hsusb_ldo_init(int init)
1221{
1222 int rc = 0;
1223
1224 if (init) {
1225 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1226 if (IS_ERR(ldo6_3p3))
1227 return PTR_ERR(ldo6_3p3);
1228
1229 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1230 if (IS_ERR(ldo7_1p8)) {
1231 rc = PTR_ERR(ldo7_1p8);
1232 goto put_3p3;
1233 }
1234
1235 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1236 USB_PHY_3P3_VOL_MAX);
1237 if (rc) {
1238 pr_err("%s: Unable to set voltage level for"
1239 "ldo6_3p3 regulator\n", __func__);
1240 goto put_1p8;
1241 }
1242 rc = regulator_enable(ldo6_3p3);
1243 if (rc) {
1244 pr_err("%s: Unable to enable the regulator:"
1245 "ldo6_3p3\n", __func__);
1246 goto put_1p8;
1247 }
1248 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1249 USB_PHY_1P8_VOL_MAX);
1250 if (rc) {
1251 pr_err("%s: Unable to set voltage level for"
1252 "ldo7_1p8 regulator\n", __func__);
1253 goto disable_3p3;
1254 }
1255 rc = regulator_enable(ldo7_1p8);
1256 if (rc) {
1257 pr_err("%s: Unable to enable the regulator:"
1258 "ldo7_1p8\n", __func__);
1259 goto disable_3p3;
1260 }
1261
1262 return 0;
1263 }
1264
1265 regulator_disable(ldo7_1p8);
1266disable_3p3:
1267 regulator_disable(ldo6_3p3);
1268put_1p8:
1269 regulator_put(ldo7_1p8);
1270put_3p3:
1271 regulator_put(ldo6_3p3);
1272 return rc;
1273}
1274
1275static int msm_hsusb_ldo_enable(int on)
1276{
1277 int ret = 0;
1278
1279 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1280 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1281 return -ENODEV;
1282 }
1283
1284 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1285 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1286 return -ENODEV;
1287 }
1288
1289 if (on) {
1290 ret = regulator_set_optimum_mode(ldo7_1p8,
1291 USB_PHY_1P8_HPM_LOAD);
1292 if (ret < 0) {
1293 pr_err("%s: Unable to set HPM of the regulator:"
1294 "ldo7_1p8\n", __func__);
1295 return ret;
1296 }
1297 ret = regulator_set_optimum_mode(ldo6_3p3,
1298 USB_PHY_3P3_HPM_LOAD);
1299 if (ret < 0) {
1300 pr_err("%s: Unable to set HPM of the regulator:"
1301 "ldo6_3p3\n", __func__);
1302 regulator_set_optimum_mode(ldo7_1p8,
1303 USB_PHY_1P8_LPM_LOAD);
1304 return ret;
1305 }
1306 } else {
1307 ret = regulator_set_optimum_mode(ldo7_1p8,
1308 USB_PHY_1P8_LPM_LOAD);
1309 if (ret < 0)
1310 pr_err("%s: Unable to set LPM of the regulator:"
1311 "ldo7_1p8\n", __func__);
1312 ret = regulator_set_optimum_mode(ldo6_3p3,
1313 USB_PHY_3P3_LPM_LOAD);
1314 if (ret < 0)
1315 pr_err("%s: Unable to set LPM of the regulator:"
1316 "ldo6_3p3\n", __func__);
1317 }
1318
1319 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1320 return ret < 0 ? ret : 0;
1321 }
1322#endif
1323#ifdef CONFIG_USB_EHCI_MSM_72K
1324#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1325static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1326{
1327 static int vbus_is_on;
1328
1329 /* If VBUS is already on (or off), do nothing. */
1330 if (on == vbus_is_on)
1331 return;
1332 smb137b_otg_power(on);
1333 vbus_is_on = on;
1334}
1335#endif
1336static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1337{
1338 static struct regulator *votg_5v_switch;
1339 static struct regulator *ext_5v_reg;
1340 static int vbus_is_on;
1341
1342 /* If VBUS is already on (or off), do nothing. */
1343 if (on == vbus_is_on)
1344 return;
1345
1346 if (!votg_5v_switch) {
1347 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1348 if (IS_ERR(votg_5v_switch)) {
1349 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1350 return;
1351 }
1352 }
1353 if (!ext_5v_reg) {
1354 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1355 if (IS_ERR(ext_5v_reg)) {
1356 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1357 return;
1358 }
1359 }
1360 if (on) {
1361 if (regulator_enable(ext_5v_reg)) {
1362 pr_err("%s: Unable to enable the regulator:"
1363 " ext_5v_reg\n", __func__);
1364 return;
1365 }
1366 if (regulator_enable(votg_5v_switch)) {
1367 pr_err("%s: Unable to enable the regulator:"
1368 " votg_5v_switch\n", __func__);
1369 return;
1370 }
1371 } else {
1372 if (regulator_disable(votg_5v_switch))
1373 pr_err("%s: Unable to enable the regulator:"
1374 " votg_5v_switch\n", __func__);
1375 if (regulator_disable(ext_5v_reg))
1376 pr_err("%s: Unable to enable the regulator:"
1377 " ext_5v_reg\n", __func__);
1378 }
1379
1380 vbus_is_on = on;
1381}
1382
1383static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1384 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1385 .power_budget = 390,
1386};
1387#endif
1388
1389#ifdef CONFIG_BATTERY_MSM8X60
1390static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1391 int init)
1392{
1393 int ret = -ENOTSUPP;
1394
1395#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1396 if (machine_is_msm8x60_fluid()) {
1397 if (init)
1398 msm_charger_register_vbus_sn(callback);
1399 else
1400 msm_charger_unregister_vbus_sn(callback);
1401 return 0;
1402 }
1403#endif
1404 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1405 * hence, irrespective of either peripheral only mode or
1406 * OTG (host and peripheral) modes, can depend on pmic for
1407 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001408 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001409 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1410 && (machine_is_msm8x60_surf() ||
1411 pmic_id_notif_supported)) {
1412 if (init)
1413 ret = msm_charger_register_vbus_sn(callback);
1414 else {
1415 msm_charger_unregister_vbus_sn(callback);
1416 ret = 0;
1417 }
1418 } else {
1419#if !defined(CONFIG_USB_EHCI_MSM_72K)
1420 if (init)
1421 ret = msm_charger_register_vbus_sn(callback);
1422 else {
1423 msm_charger_unregister_vbus_sn(callback);
1424 ret = 0;
1425 }
1426#endif
1427 }
1428 return ret;
1429}
1430#endif
1431
1432#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
1433static struct msm_otg_platform_data msm_otg_pdata = {
1434 /* if usb link is in sps there is no need for
1435 * usb pclk as dayatona fabric clock will be
1436 * used instead
1437 */
1438 .pclk_src_name = "dfab_usb_hs_clk",
1439 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1440 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1441 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301442 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001443#ifdef CONFIG_USB_EHCI_MSM_72K
1444 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301445 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001446#endif
1447#ifdef CONFIG_USB_EHCI_MSM_72K
1448 .vbus_power = msm_hsusb_vbus_power,
1449#endif
1450#ifdef CONFIG_BATTERY_MSM8X60
1451 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1452#endif
1453 .ldo_init = msm_hsusb_ldo_init,
1454 .ldo_enable = msm_hsusb_ldo_enable,
1455 .config_vddcx = msm_hsusb_config_vddcx,
1456 .init_vddcx = msm_hsusb_init_vddcx,
1457#ifdef CONFIG_BATTERY_MSM8X60
1458 .chg_vbus_draw = msm_charger_vbus_draw,
1459#endif
1460};
1461#endif
1462
1463#ifdef CONFIG_USB_GADGET_MSM_72K
1464static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1465 .is_phy_status_timer_on = 1,
1466};
1467#endif
1468
1469#ifdef CONFIG_USB_G_ANDROID
1470
1471#define PID_MAGIC_ID 0x71432909
1472#define SERIAL_NUM_MAGIC_ID 0x61945374
1473#define SERIAL_NUMBER_LENGTH 127
1474#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1475
1476struct magic_num_struct {
1477 uint32_t pid;
1478 uint32_t serial_num;
1479};
1480
1481struct dload_struct {
1482 uint32_t reserved1;
1483 uint32_t reserved2;
1484 uint32_t reserved3;
1485 uint16_t reserved4;
1486 uint16_t pid;
1487 char serial_number[SERIAL_NUMBER_LENGTH];
1488 uint16_t reserved5;
1489 struct magic_num_struct
1490 magic_struct;
1491};
1492
1493static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1494{
1495 struct dload_struct __iomem *dload = 0;
1496
1497 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1498 if (!dload) {
1499 pr_err("%s: cannot remap I/O memory region: %08x\n",
1500 __func__, DLOAD_USB_BASE_ADD);
1501 return -ENXIO;
1502 }
1503
1504 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1505 __func__, dload, pid, snum);
1506 /* update pid */
1507 dload->magic_struct.pid = PID_MAGIC_ID;
1508 dload->pid = pid;
1509
1510 /* update serial number */
1511 dload->magic_struct.serial_num = 0;
1512 if (!snum)
1513 return 0;
1514
1515 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1516 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1517 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1518
1519 iounmap(dload);
1520
1521 return 0;
1522}
1523
1524static struct android_usb_platform_data android_usb_pdata = {
1525 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1526};
1527
1528static struct platform_device android_usb_device = {
1529 .name = "android_usb",
1530 .id = -1,
1531 .dev = {
1532 .platform_data = &android_usb_pdata,
1533 },
1534};
1535
1536
1537#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001538
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001539#ifdef CONFIG_MSM_VPE
1540static struct resource msm_vpe_resources[] = {
1541 {
1542 .start = 0x05300000,
1543 .end = 0x05300000 + SZ_1M - 1,
1544 .flags = IORESOURCE_MEM,
1545 },
1546 {
1547 .start = INT_VPE,
1548 .end = INT_VPE,
1549 .flags = IORESOURCE_IRQ,
1550 },
1551};
1552
1553static struct platform_device msm_vpe_device = {
1554 .name = "msm_vpe",
1555 .id = 0,
1556 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1557 .resource = msm_vpe_resources,
1558};
1559#endif
1560
1561#ifdef CONFIG_MSM_CAMERA
1562#ifdef CONFIG_MSM_CAMERA_FLASH
1563#define VFE_CAMIF_TIMER1_GPIO 29
1564#define VFE_CAMIF_TIMER2_GPIO 30
1565#define VFE_CAMIF_TIMER3_GPIO_INT 31
1566#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1567static struct msm_camera_sensor_flash_src msm_flash_src = {
1568 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1569 ._fsrc.pmic_src.num_of_src = 2,
1570 ._fsrc.pmic_src.low_current = 100,
1571 ._fsrc.pmic_src.high_current = 300,
1572 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1573 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1574 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1575};
1576#ifdef CONFIG_IMX074
1577static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1578 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1579 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1580 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1581 .flash_recharge_duration = 50000,
1582 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1583};
1584#endif
1585#endif
1586
1587int msm_cam_gpio_tbl[] = {
1588 32,/*CAMIF_MCLK*/
1589 47,/*CAMIF_I2C_DATA*/
1590 48,/*CAMIF_I2C_CLK*/
1591 105,/*STANDBY*/
1592};
1593
1594enum msm_cam_stat{
1595 MSM_CAM_OFF,
1596 MSM_CAM_ON,
1597};
1598
1599static int config_gpio_table(enum msm_cam_stat stat)
1600{
1601 int rc = 0, i = 0;
1602 if (stat == MSM_CAM_ON) {
1603 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1604 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1605 if (unlikely(rc < 0)) {
1606 pr_err("%s not able to get gpio\n", __func__);
1607 for (i--; i >= 0; i--)
1608 gpio_free(msm_cam_gpio_tbl[i]);
1609 break;
1610 }
1611 }
1612 } else {
1613 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1614 gpio_free(msm_cam_gpio_tbl[i]);
1615 }
1616 return rc;
1617}
1618
1619static struct msm_camera_sensor_platform_info sensor_board_info = {
1620 .mount_angle = 0
1621};
1622
1623/*external regulator VREG_5V*/
1624static struct regulator *reg_flash_5V;
1625
1626static int config_camera_on_gpios_fluid(void)
1627{
1628 int rc = 0;
1629
1630 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1631 if (IS_ERR(reg_flash_5V)) {
1632 pr_err("'%s' regulator not found, rc=%ld\n",
1633 "8901_mpp0", IS_ERR(reg_flash_5V));
1634 return -ENODEV;
1635 }
1636
1637 rc = regulator_enable(reg_flash_5V);
1638 if (rc) {
1639 pr_err("'%s' regulator enable failed, rc=%d\n",
1640 "8901_mpp0", rc);
1641 regulator_put(reg_flash_5V);
1642 return rc;
1643 }
1644
1645#ifdef CONFIG_IMX074
1646 sensor_board_info.mount_angle = 90;
1647#endif
1648 rc = config_gpio_table(MSM_CAM_ON);
1649 if (rc < 0) {
1650 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1651 "failed\n", __func__);
1652 return rc;
1653 }
1654
1655 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1656 if (rc < 0) {
1657 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1658 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1659 regulator_disable(reg_flash_5V);
1660 regulator_put(reg_flash_5V);
1661 return rc;
1662 }
1663 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1664 msleep(20);
1665 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1666
1667
1668 /*Enable LED_FLASH_EN*/
1669 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1670 if (rc < 0) {
1671 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1672 "failed\n", __func__, GPIO_LED_FLASH_EN);
1673
1674 regulator_disable(reg_flash_5V);
1675 regulator_put(reg_flash_5V);
1676 config_gpio_table(MSM_CAM_OFF);
1677 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1678 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1679 return rc;
1680 }
1681 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1682 msleep(20);
1683 return rc;
1684}
1685
1686
1687static void config_camera_off_gpios_fluid(void)
1688{
1689 regulator_disable(reg_flash_5V);
1690 regulator_put(reg_flash_5V);
1691
1692 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1693 gpio_free(GPIO_LED_FLASH_EN);
1694
1695 config_gpio_table(MSM_CAM_OFF);
1696
1697 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1698 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1699}
1700static int config_camera_on_gpios(void)
1701{
1702 int rc = 0;
1703
1704 if (machine_is_msm8x60_fluid())
1705 return config_camera_on_gpios_fluid();
1706
1707 rc = config_gpio_table(MSM_CAM_ON);
1708 if (rc < 0) {
1709 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1710 "failed\n", __func__);
1711 return rc;
1712 }
1713
Jilai Wang971f97f2011-07-13 14:25:25 -04001714 if (!machine_is_msm8x60_dragon()) {
1715 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1716 if (rc < 0) {
1717 config_gpio_table(MSM_CAM_OFF);
1718 pr_err("%s: CAMSENSOR gpio %d request"
1719 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1720 return rc;
1721 }
1722 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1723 msleep(20);
1724 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001725 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001726
1727#ifdef CONFIG_MSM_CAMERA_FLASH
1728#ifdef CONFIG_IMX074
1729 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1730 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1731#endif
1732#endif
1733 return rc;
1734}
1735
1736static void config_camera_off_gpios(void)
1737{
1738 if (machine_is_msm8x60_fluid())
1739 return config_camera_off_gpios_fluid();
1740
1741
1742 config_gpio_table(MSM_CAM_OFF);
1743
Jilai Wang971f97f2011-07-13 14:25:25 -04001744 if (!machine_is_msm8x60_dragon()) {
1745 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1746 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1747 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001748}
1749
1750#ifdef CONFIG_QS_S5K4E1
1751
1752#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1753
1754static int config_camera_on_gpios_qs_cam_fluid(void)
1755{
1756 int rc = 0;
1757
1758 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1759 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1760 if (rc < 0) {
1761 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1762 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1763 return rc;
1764 }
1765 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1766 msleep(20);
1767 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1768 msleep(20);
1769
1770 /*
1771 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1772 * to enable 2.7V power to Camera
1773 */
1774 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1775 if (rc < 0) {
1776 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1777 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1778 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1779 gpio_free(QS_CAM_HC37_CAM_PD);
1780 return rc;
1781 }
1782 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1783 msleep(20);
1784 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1785 msleep(20);
1786
1787 rc = config_camera_on_gpios_fluid();
1788 if (rc < 0) {
1789 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1790 " failed\n", __func__);
1791 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1792 gpio_free(QS_CAM_HC37_CAM_PD);
1793 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1794 gpio_free(GPIO_AUX_CAM_2P7_EN);
1795 return rc;
1796 }
1797 return rc;
1798}
1799
1800static void config_camera_off_gpios_qs_cam_fluid(void)
1801{
1802 /*
1803 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1804 * to disable 2.7V power to Camera
1805 */
1806 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1807 gpio_free(GPIO_AUX_CAM_2P7_EN);
1808
1809 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1810 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1811 gpio_free(QS_CAM_HC37_CAM_PD);
1812
1813 config_camera_off_gpios_fluid();
1814 return;
1815}
1816
1817static int config_camera_on_gpios_qs_cam(void)
1818{
1819 int rc = 0;
1820
1821 if (machine_is_msm8x60_fluid())
1822 return config_camera_on_gpios_qs_cam_fluid();
1823
1824 rc = config_camera_on_gpios();
1825 return rc;
1826}
1827
1828static void config_camera_off_gpios_qs_cam(void)
1829{
1830 if (machine_is_msm8x60_fluid())
1831 return config_camera_off_gpios_qs_cam_fluid();
1832
1833 config_camera_off_gpios();
1834 return;
1835}
1836#endif
1837
1838static int config_camera_on_gpios_web_cam(void)
1839{
1840 int rc = 0;
1841 rc = config_gpio_table(MSM_CAM_ON);
1842 if (rc < 0) {
1843 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1844 "failed\n", __func__);
1845 return rc;
1846 }
1847
Jilai Wang53d27a82011-07-13 14:32:58 -04001848 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001849 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1850 if (rc < 0) {
1851 config_gpio_table(MSM_CAM_OFF);
1852 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1853 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1854 return rc;
1855 }
1856 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1857 }
1858 return rc;
1859}
1860
1861static void config_camera_off_gpios_web_cam(void)
1862{
1863 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001864 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001865 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1866 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1867 }
1868 return;
1869}
1870
1871#ifdef CONFIG_MSM_BUS_SCALING
1872static struct msm_bus_vectors cam_init_vectors[] = {
1873 {
1874 .src = MSM_BUS_MASTER_VFE,
1875 .dst = MSM_BUS_SLAVE_SMI,
1876 .ab = 0,
1877 .ib = 0,
1878 },
1879 {
1880 .src = MSM_BUS_MASTER_VFE,
1881 .dst = MSM_BUS_SLAVE_EBI_CH0,
1882 .ab = 0,
1883 .ib = 0,
1884 },
1885 {
1886 .src = MSM_BUS_MASTER_VPE,
1887 .dst = MSM_BUS_SLAVE_SMI,
1888 .ab = 0,
1889 .ib = 0,
1890 },
1891 {
1892 .src = MSM_BUS_MASTER_VPE,
1893 .dst = MSM_BUS_SLAVE_EBI_CH0,
1894 .ab = 0,
1895 .ib = 0,
1896 },
1897 {
1898 .src = MSM_BUS_MASTER_JPEG_ENC,
1899 .dst = MSM_BUS_SLAVE_SMI,
1900 .ab = 0,
1901 .ib = 0,
1902 },
1903 {
1904 .src = MSM_BUS_MASTER_JPEG_ENC,
1905 .dst = MSM_BUS_SLAVE_EBI_CH0,
1906 .ab = 0,
1907 .ib = 0,
1908 },
1909};
1910
1911static struct msm_bus_vectors cam_preview_vectors[] = {
1912 {
1913 .src = MSM_BUS_MASTER_VFE,
1914 .dst = MSM_BUS_SLAVE_SMI,
1915 .ab = 0,
1916 .ib = 0,
1917 },
1918 {
1919 .src = MSM_BUS_MASTER_VFE,
1920 .dst = MSM_BUS_SLAVE_EBI_CH0,
1921 .ab = 283115520,
1922 .ib = 452984832,
1923 },
1924 {
1925 .src = MSM_BUS_MASTER_VPE,
1926 .dst = MSM_BUS_SLAVE_SMI,
1927 .ab = 0,
1928 .ib = 0,
1929 },
1930 {
1931 .src = MSM_BUS_MASTER_VPE,
1932 .dst = MSM_BUS_SLAVE_EBI_CH0,
1933 .ab = 0,
1934 .ib = 0,
1935 },
1936 {
1937 .src = MSM_BUS_MASTER_JPEG_ENC,
1938 .dst = MSM_BUS_SLAVE_SMI,
1939 .ab = 0,
1940 .ib = 0,
1941 },
1942 {
1943 .src = MSM_BUS_MASTER_JPEG_ENC,
1944 .dst = MSM_BUS_SLAVE_EBI_CH0,
1945 .ab = 0,
1946 .ib = 0,
1947 },
1948};
1949
1950static struct msm_bus_vectors cam_video_vectors[] = {
1951 {
1952 .src = MSM_BUS_MASTER_VFE,
1953 .dst = MSM_BUS_SLAVE_SMI,
1954 .ab = 283115520,
1955 .ib = 452984832,
1956 },
1957 {
1958 .src = MSM_BUS_MASTER_VFE,
1959 .dst = MSM_BUS_SLAVE_EBI_CH0,
1960 .ab = 283115520,
1961 .ib = 452984832,
1962 },
1963 {
1964 .src = MSM_BUS_MASTER_VPE,
1965 .dst = MSM_BUS_SLAVE_SMI,
1966 .ab = 319610880,
1967 .ib = 511377408,
1968 },
1969 {
1970 .src = MSM_BUS_MASTER_VPE,
1971 .dst = MSM_BUS_SLAVE_EBI_CH0,
1972 .ab = 0,
1973 .ib = 0,
1974 },
1975 {
1976 .src = MSM_BUS_MASTER_JPEG_ENC,
1977 .dst = MSM_BUS_SLAVE_SMI,
1978 .ab = 0,
1979 .ib = 0,
1980 },
1981 {
1982 .src = MSM_BUS_MASTER_JPEG_ENC,
1983 .dst = MSM_BUS_SLAVE_EBI_CH0,
1984 .ab = 0,
1985 .ib = 0,
1986 },
1987};
1988
1989static struct msm_bus_vectors cam_snapshot_vectors[] = {
1990 {
1991 .src = MSM_BUS_MASTER_VFE,
1992 .dst = MSM_BUS_SLAVE_SMI,
1993 .ab = 566231040,
1994 .ib = 905969664,
1995 },
1996 {
1997 .src = MSM_BUS_MASTER_VFE,
1998 .dst = MSM_BUS_SLAVE_EBI_CH0,
1999 .ab = 69984000,
2000 .ib = 111974400,
2001 },
2002 {
2003 .src = MSM_BUS_MASTER_VPE,
2004 .dst = MSM_BUS_SLAVE_SMI,
2005 .ab = 0,
2006 .ib = 0,
2007 },
2008 {
2009 .src = MSM_BUS_MASTER_VPE,
2010 .dst = MSM_BUS_SLAVE_EBI_CH0,
2011 .ab = 0,
2012 .ib = 0,
2013 },
2014 {
2015 .src = MSM_BUS_MASTER_JPEG_ENC,
2016 .dst = MSM_BUS_SLAVE_SMI,
2017 .ab = 320864256,
2018 .ib = 513382810,
2019 },
2020 {
2021 .src = MSM_BUS_MASTER_JPEG_ENC,
2022 .dst = MSM_BUS_SLAVE_EBI_CH0,
2023 .ab = 320864256,
2024 .ib = 513382810,
2025 },
2026};
2027
2028static struct msm_bus_vectors cam_zsl_vectors[] = {
2029 {
2030 .src = MSM_BUS_MASTER_VFE,
2031 .dst = MSM_BUS_SLAVE_SMI,
2032 .ab = 566231040,
2033 .ib = 905969664,
2034 },
2035 {
2036 .src = MSM_BUS_MASTER_VFE,
2037 .dst = MSM_BUS_SLAVE_EBI_CH0,
2038 .ab = 706199040,
2039 .ib = 1129918464,
2040 },
2041 {
2042 .src = MSM_BUS_MASTER_VPE,
2043 .dst = MSM_BUS_SLAVE_SMI,
2044 .ab = 0,
2045 .ib = 0,
2046 },
2047 {
2048 .src = MSM_BUS_MASTER_VPE,
2049 .dst = MSM_BUS_SLAVE_EBI_CH0,
2050 .ab = 0,
2051 .ib = 0,
2052 },
2053 {
2054 .src = MSM_BUS_MASTER_JPEG_ENC,
2055 .dst = MSM_BUS_SLAVE_SMI,
2056 .ab = 320864256,
2057 .ib = 513382810,
2058 },
2059 {
2060 .src = MSM_BUS_MASTER_JPEG_ENC,
2061 .dst = MSM_BUS_SLAVE_EBI_CH0,
2062 .ab = 320864256,
2063 .ib = 513382810,
2064 },
2065};
2066
2067static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2068 {
2069 .src = MSM_BUS_MASTER_VFE,
2070 .dst = MSM_BUS_SLAVE_SMI,
2071 .ab = 212336640,
2072 .ib = 339738624,
2073 },
2074 {
2075 .src = MSM_BUS_MASTER_VFE,
2076 .dst = MSM_BUS_SLAVE_EBI_CH0,
2077 .ab = 25090560,
2078 .ib = 40144896,
2079 },
2080 {
2081 .src = MSM_BUS_MASTER_VPE,
2082 .dst = MSM_BUS_SLAVE_SMI,
2083 .ab = 239708160,
2084 .ib = 383533056,
2085 },
2086 {
2087 .src = MSM_BUS_MASTER_VPE,
2088 .dst = MSM_BUS_SLAVE_EBI_CH0,
2089 .ab = 79902720,
2090 .ib = 127844352,
2091 },
2092 {
2093 .src = MSM_BUS_MASTER_JPEG_ENC,
2094 .dst = MSM_BUS_SLAVE_SMI,
2095 .ab = 0,
2096 .ib = 0,
2097 },
2098 {
2099 .src = MSM_BUS_MASTER_JPEG_ENC,
2100 .dst = MSM_BUS_SLAVE_EBI_CH0,
2101 .ab = 0,
2102 .ib = 0,
2103 },
2104};
2105
2106static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2107 {
2108 .src = MSM_BUS_MASTER_VFE,
2109 .dst = MSM_BUS_SLAVE_SMI,
2110 .ab = 0,
2111 .ib = 0,
2112 },
2113 {
2114 .src = MSM_BUS_MASTER_VFE,
2115 .dst = MSM_BUS_SLAVE_EBI_CH0,
2116 .ab = 300902400,
2117 .ib = 481443840,
2118 },
2119 {
2120 .src = MSM_BUS_MASTER_VPE,
2121 .dst = MSM_BUS_SLAVE_SMI,
2122 .ab = 230307840,
2123 .ib = 368492544,
2124 },
2125 {
2126 .src = MSM_BUS_MASTER_VPE,
2127 .dst = MSM_BUS_SLAVE_EBI_CH0,
2128 .ab = 245113344,
2129 .ib = 392181351,
2130 },
2131 {
2132 .src = MSM_BUS_MASTER_JPEG_ENC,
2133 .dst = MSM_BUS_SLAVE_SMI,
2134 .ab = 106536960,
2135 .ib = 170459136,
2136 },
2137 {
2138 .src = MSM_BUS_MASTER_JPEG_ENC,
2139 .dst = MSM_BUS_SLAVE_EBI_CH0,
2140 .ab = 106536960,
2141 .ib = 170459136,
2142 },
2143};
2144
2145static struct msm_bus_paths cam_bus_client_config[] = {
2146 {
2147 ARRAY_SIZE(cam_init_vectors),
2148 cam_init_vectors,
2149 },
2150 {
2151 ARRAY_SIZE(cam_preview_vectors),
2152 cam_preview_vectors,
2153 },
2154 {
2155 ARRAY_SIZE(cam_video_vectors),
2156 cam_video_vectors,
2157 },
2158 {
2159 ARRAY_SIZE(cam_snapshot_vectors),
2160 cam_snapshot_vectors,
2161 },
2162 {
2163 ARRAY_SIZE(cam_zsl_vectors),
2164 cam_zsl_vectors,
2165 },
2166 {
2167 ARRAY_SIZE(cam_stereo_video_vectors),
2168 cam_stereo_video_vectors,
2169 },
2170 {
2171 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2172 cam_stereo_snapshot_vectors,
2173 },
2174};
2175
2176static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2177 cam_bus_client_config,
2178 ARRAY_SIZE(cam_bus_client_config),
2179 .name = "msm_camera",
2180};
2181#endif
2182
2183struct msm_camera_device_platform_data msm_camera_device_data = {
2184 .camera_gpio_on = config_camera_on_gpios,
2185 .camera_gpio_off = config_camera_off_gpios,
2186 .ioext.csiphy = 0x04800000,
2187 .ioext.csisz = 0x00000400,
2188 .ioext.csiirq = CSI_0_IRQ,
2189 .ioclk.mclk_clk_rate = 24000000,
2190 .ioclk.vfe_clk_rate = 228570000,
2191#ifdef CONFIG_MSM_BUS_SCALING
2192 .cam_bus_scale_table = &cam_bus_client_pdata,
2193#endif
2194};
2195
2196#ifdef CONFIG_QS_S5K4E1
2197struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2198 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2199 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2200 .ioext.csiphy = 0x04800000,
2201 .ioext.csisz = 0x00000400,
2202 .ioext.csiirq = CSI_0_IRQ,
2203 .ioclk.mclk_clk_rate = 24000000,
2204 .ioclk.vfe_clk_rate = 228570000,
2205#ifdef CONFIG_MSM_BUS_SCALING
2206 .cam_bus_scale_table = &cam_bus_client_pdata,
2207#endif
2208};
2209#endif
2210
2211struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2212 .camera_gpio_on = config_camera_on_gpios_web_cam,
2213 .camera_gpio_off = config_camera_off_gpios_web_cam,
2214 .ioext.csiphy = 0x04900000,
2215 .ioext.csisz = 0x00000400,
2216 .ioext.csiirq = CSI_1_IRQ,
2217 .ioclk.mclk_clk_rate = 24000000,
2218 .ioclk.vfe_clk_rate = 228570000,
2219#ifdef CONFIG_MSM_BUS_SCALING
2220 .cam_bus_scale_table = &cam_bus_client_pdata,
2221#endif
2222};
2223
2224struct resource msm_camera_resources[] = {
2225 {
2226 .start = 0x04500000,
2227 .end = 0x04500000 + SZ_1M - 1,
2228 .flags = IORESOURCE_MEM,
2229 },
2230 {
2231 .start = VFE_IRQ,
2232 .end = VFE_IRQ,
2233 .flags = IORESOURCE_IRQ,
2234 },
2235};
2236#ifdef CONFIG_MT9E013
2237static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2238 .mount_angle = 0
2239};
2240
2241static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2242 .flash_type = MSM_CAMERA_FLASH_LED,
2243 .flash_src = &msm_flash_src
2244};
2245
2246static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2247 .sensor_name = "mt9e013",
2248 .sensor_reset = 106,
2249 .sensor_pwd = 85,
2250 .vcm_pwd = 1,
2251 .vcm_enable = 0,
2252 .pdata = &msm_camera_device_data,
2253 .resource = msm_camera_resources,
2254 .num_resources = ARRAY_SIZE(msm_camera_resources),
2255 .flash_data = &flash_mt9e013,
2256 .strobe_flash_data = &strobe_flash_xenon,
2257 .sensor_platform_info = &mt9e013_sensor_8660_info,
2258 .csi_if = 1
2259};
2260struct platform_device msm_camera_sensor_mt9e013 = {
2261 .name = "msm_camera_mt9e013",
2262 .dev = {
2263 .platform_data = &msm_camera_sensor_mt9e013_data,
2264 },
2265};
2266#endif
2267
2268#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302269static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2270 .mount_angle = 180
2271};
2272
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002273static struct msm_camera_sensor_flash_data flash_imx074 = {
2274 .flash_type = MSM_CAMERA_FLASH_LED,
2275 .flash_src = &msm_flash_src
2276};
2277
2278static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2279 .sensor_name = "imx074",
2280 .sensor_reset = 106,
2281 .sensor_pwd = 85,
2282 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2283 .vcm_enable = 1,
2284 .pdata = &msm_camera_device_data,
2285 .resource = msm_camera_resources,
2286 .num_resources = ARRAY_SIZE(msm_camera_resources),
2287 .flash_data = &flash_imx074,
2288 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302289 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002290 .csi_if = 1
2291};
2292struct platform_device msm_camera_sensor_imx074 = {
2293 .name = "msm_camera_imx074",
2294 .dev = {
2295 .platform_data = &msm_camera_sensor_imx074_data,
2296 },
2297};
2298#endif
2299#ifdef CONFIG_WEBCAM_OV9726
2300
2301static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2302 .mount_angle = 0
2303};
2304
2305static struct msm_camera_sensor_flash_data flash_ov9726 = {
2306 .flash_type = MSM_CAMERA_FLASH_LED,
2307 .flash_src = &msm_flash_src
2308};
2309static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2310 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002311 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002312 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2313 .sensor_pwd = 85,
2314 .vcm_pwd = 1,
2315 .vcm_enable = 0,
2316 .pdata = &msm_camera_device_data_web_cam,
2317 .resource = msm_camera_resources,
2318 .num_resources = ARRAY_SIZE(msm_camera_resources),
2319 .flash_data = &flash_ov9726,
2320 .sensor_platform_info = &ov9726_sensor_8660_info,
2321 .csi_if = 1
2322};
2323struct platform_device msm_camera_sensor_webcam_ov9726 = {
2324 .name = "msm_camera_ov9726",
2325 .dev = {
2326 .platform_data = &msm_camera_sensor_ov9726_data,
2327 },
2328};
2329#endif
2330#ifdef CONFIG_WEBCAM_OV7692
2331static struct msm_camera_sensor_flash_data flash_ov7692 = {
2332 .flash_type = MSM_CAMERA_FLASH_LED,
2333 .flash_src = &msm_flash_src
2334};
2335static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2336 .sensor_name = "ov7692",
2337 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2338 .sensor_pwd = 85,
2339 .vcm_pwd = 1,
2340 .vcm_enable = 0,
2341 .pdata = &msm_camera_device_data_web_cam,
2342 .resource = msm_camera_resources,
2343 .num_resources = ARRAY_SIZE(msm_camera_resources),
2344 .flash_data = &flash_ov7692,
2345 .csi_if = 1
2346};
2347
2348static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2349 .name = "msm_camera_ov7692",
2350 .dev = {
2351 .platform_data = &msm_camera_sensor_ov7692_data,
2352 },
2353};
2354#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002355#ifdef CONFIG_VX6953
2356static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2357 .mount_angle = 270
2358};
2359
2360static struct msm_camera_sensor_flash_data flash_vx6953 = {
2361 .flash_type = MSM_CAMERA_FLASH_NONE,
2362 .flash_src = &msm_flash_src
2363};
2364
2365static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2366 .sensor_name = "vx6953",
2367 .sensor_reset = 63,
2368 .sensor_pwd = 63,
2369 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2370 .vcm_enable = 1,
2371 .pdata = &msm_camera_device_data,
2372 .resource = msm_camera_resources,
2373 .num_resources = ARRAY_SIZE(msm_camera_resources),
2374 .flash_data = &flash_vx6953,
2375 .sensor_platform_info = &vx6953_sensor_8660_info,
2376 .csi_if = 1
2377};
2378struct platform_device msm_camera_sensor_vx6953 = {
2379 .name = "msm_camera_vx6953",
2380 .dev = {
2381 .platform_data = &msm_camera_sensor_vx6953_data,
2382 },
2383};
2384#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002385#ifdef CONFIG_QS_S5K4E1
2386
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302387static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2388#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2389 .mount_angle = 90
2390#else
2391 .mount_angle = 0
2392#endif
2393};
2394
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002395static char eeprom_data[864];
2396static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2397 .flash_type = MSM_CAMERA_FLASH_LED,
2398 .flash_src = &msm_flash_src
2399};
2400
2401static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2402 .sensor_name = "qs_s5k4e1",
2403 .sensor_reset = 106,
2404 .sensor_pwd = 85,
2405 .vcm_pwd = 1,
2406 .vcm_enable = 0,
2407 .pdata = &msm_camera_device_data_qs_cam,
2408 .resource = msm_camera_resources,
2409 .num_resources = ARRAY_SIZE(msm_camera_resources),
2410 .flash_data = &flash_qs_s5k4e1,
2411 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302412 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002413 .csi_if = 1,
2414 .eeprom_data = eeprom_data,
2415};
2416struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2417 .name = "msm_camera_qs_s5k4e1",
2418 .dev = {
2419 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2420 },
2421};
2422#endif
2423static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2424 #ifdef CONFIG_MT9E013
2425 {
2426 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2427 },
2428 #endif
2429 #ifdef CONFIG_IMX074
2430 {
2431 I2C_BOARD_INFO("imx074", 0x1A),
2432 },
2433 #endif
2434 #ifdef CONFIG_WEBCAM_OV7692
2435 {
2436 I2C_BOARD_INFO("ov7692", 0x78),
2437 },
2438 #endif
2439 #ifdef CONFIG_WEBCAM_OV9726
2440 {
2441 I2C_BOARD_INFO("ov9726", 0x10),
2442 },
2443 #endif
2444 #ifdef CONFIG_QS_S5K4E1
2445 {
2446 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2447 },
2448 #endif
2449};
Jilai Wang971f97f2011-07-13 14:25:25 -04002450
2451static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002452 #ifdef CONFIG_WEBCAM_OV9726
2453 {
2454 I2C_BOARD_INFO("ov9726", 0x10),
2455 },
2456 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002457 #ifdef CONFIG_VX6953
2458 {
2459 I2C_BOARD_INFO("vx6953", 0x20),
2460 },
2461 #endif
2462};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002463#endif
2464
2465#ifdef CONFIG_MSM_GEMINI
2466static struct resource msm_gemini_resources[] = {
2467 {
2468 .start = 0x04600000,
2469 .end = 0x04600000 + SZ_1M - 1,
2470 .flags = IORESOURCE_MEM,
2471 },
2472 {
2473 .start = INT_JPEG,
2474 .end = INT_JPEG,
2475 .flags = IORESOURCE_IRQ,
2476 },
2477};
2478
2479static struct platform_device msm_gemini_device = {
2480 .name = "msm_gemini",
2481 .resource = msm_gemini_resources,
2482 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2483};
2484#endif
2485
2486#ifdef CONFIG_I2C_QUP
2487static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2488{
2489}
2490
2491static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2492 .clk_freq = 384000,
2493 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002494 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2495};
2496
2497static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2498 .clk_freq = 100000,
2499 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002500 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2501};
2502
2503static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2504 .clk_freq = 100000,
2505 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2507};
2508
2509static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2510 .clk_freq = 100000,
2511 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002512 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2513};
2514
2515static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2516 .clk_freq = 100000,
2517 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002518 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2519};
2520
2521static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2522 .clk_freq = 100000,
2523 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002524 .use_gsbi_shared_mode = 1,
2525 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2526};
2527#endif
2528
2529#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2530static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2531 .max_clock_speed = 24000000,
2532};
2533
2534static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2535 .max_clock_speed = 24000000,
2536};
2537#endif
2538
2539#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002540/* CODEC/TSSC SSBI */
2541static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2542 .controller_type = MSM_SBI_CTRL_SSBI,
2543};
2544#endif
2545
2546#ifdef CONFIG_BATTERY_MSM
2547/* Use basic value for fake MSM battery */
2548static struct msm_psy_batt_pdata msm_psy_batt_data = {
2549 .avail_chg_sources = AC_CHG,
2550};
2551
2552static struct platform_device msm_batt_device = {
2553 .name = "msm-battery",
2554 .id = -1,
2555 .dev.platform_data = &msm_psy_batt_data,
2556};
2557#endif
2558
2559#ifdef CONFIG_FB_MSM_LCDC_DSUB
2560/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2561 prim = 1024 x 600 x 4(bpp) x 2(pages)
2562 This is the difference. */
2563#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2564#else
2565#define MSM_FB_DSUB_PMEM_ADDER (0)
2566#endif
2567
2568/* Sensors DSPS platform data */
2569#ifdef CONFIG_MSM_DSPS
2570
2571static struct dsps_gpio_info dsps_surf_gpios[] = {
2572 {
2573 .name = "compass_rst_n",
2574 .num = GPIO_COMPASS_RST_N,
2575 .on_val = 1, /* device not in reset */
2576 .off_val = 0, /* device in reset */
2577 },
2578 {
2579 .name = "gpio_r_altimeter_reset_n",
2580 .num = GPIO_R_ALTIMETER_RESET_N,
2581 .on_val = 1, /* device not in reset */
2582 .off_val = 0, /* device in reset */
2583 }
2584};
2585
2586static struct dsps_gpio_info dsps_fluid_gpios[] = {
2587 {
2588 .name = "gpio_n_altimeter_reset_n",
2589 .num = GPIO_N_ALTIMETER_RESET_N,
2590 .on_val = 1, /* device not in reset */
2591 .off_val = 0, /* device in reset */
2592 }
2593};
2594
2595static void __init msm8x60_init_dsps(void)
2596{
2597 struct msm_dsps_platform_data *pdata =
2598 msm_dsps_device.dev.platform_data;
2599 /*
2600 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2601 * to the power supply and not controled via GPIOs. Fluid uses a
2602 * different IO-Expender (north) than used on surf/ffa.
2603 */
2604 if (machine_is_msm8x60_fluid()) {
2605 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002606 pdata->pil_name = DSPS_PIL_FLUID_NAME;
2607 pdata->gpios = dsps_fluid_gpios;
2608 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2609 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002610 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2611 pdata->gpios = dsps_surf_gpios;
2612 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2613 }
2614
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002615 platform_device_register(&msm_dsps_device);
2616}
2617#endif /* CONFIG_MSM_DSPS */
2618
2619#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002620#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002621#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002622#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002623#endif
2624
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002625#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2626#define MSM_FB_EXT_BUF_SIZE (1920 * 1080 * 2 * 1) /* 2 bpp x 1 page */
2627#elif defined(CONFIG_FB_MSM_TVOUT)
2628#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
2629#else
2630#define MSM_FB_EXT_BUFT_SIZE 0
2631#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002632
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002633#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2634/* 4 bpp x 2 page HDMI case */
2635#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
2636#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002637/* Note: must be multiple of 4096 */
2638#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002639 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002640#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002641
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002642#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2643#define MSM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
2644#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002645#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002646#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002647
Huaibin Yanga5419422011-12-08 23:52:10 -08002648#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2649#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2650#else
2651#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2652#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2653
2654#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2655#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2656#else
2657#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2658#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2659
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002660#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
2661#define MSM_PMEM_ADSP_SIZE 0x2000000
Ben Romberger09e462d2011-08-09 15:24:37 -07002662#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002663
2664#define MSM_SMI_BASE 0x38000000
2665#define MSM_SMI_SIZE 0x4000000
2666
2667#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002668#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002669
2670#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2671#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2672#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2673
Olav Hauganb5be7992011-11-18 14:29:02 -08002674#define MSM_ION_SF_SIZE 0x1800000 /* 24MB */
2675#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
2676#define MSM_ION_MM_SIZE 0x3800000 /* 56MB */
2677#define MSM_ION_MFC_SIZE SZ_8K
2678#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002679
2680#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Olav Hauganb5be7992011-11-18 14:29:02 -08002681#define MSM_ION_HEAP_NUM 6
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002682#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002683#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002684#endif
2685
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002686static unsigned fb_size;
2687static int __init fb_size_setup(char *p)
2688{
2689 fb_size = memparse(p, NULL);
2690 return 0;
2691}
2692early_param("fb_size", fb_size_setup);
2693
2694static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2695static int __init pmem_kernel_ebi1_size_setup(char *p)
2696{
2697 pmem_kernel_ebi1_size = memparse(p, NULL);
2698 return 0;
2699}
2700early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2701
2702#ifdef CONFIG_ANDROID_PMEM
2703static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2704static int __init pmem_sf_size_setup(char *p)
2705{
2706 pmem_sf_size = memparse(p, NULL);
2707 return 0;
2708}
2709early_param("pmem_sf_size", pmem_sf_size_setup);
2710
2711static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2712
2713static int __init pmem_adsp_size_setup(char *p)
2714{
2715 pmem_adsp_size = memparse(p, NULL);
2716 return 0;
2717}
2718early_param("pmem_adsp_size", pmem_adsp_size_setup);
2719
2720static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2721
2722static int __init pmem_audio_size_setup(char *p)
2723{
2724 pmem_audio_size = memparse(p, NULL);
2725 return 0;
2726}
2727early_param("pmem_audio_size", pmem_audio_size_setup);
2728#endif
2729
2730static struct resource msm_fb_resources[] = {
2731 {
2732 .flags = IORESOURCE_DMA,
2733 }
2734};
2735
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736static int msm_fb_detect_panel(const char *name)
2737{
2738 if (machine_is_msm8x60_fluid()) {
2739 uint32_t soc_platform_version = socinfo_get_platform_version();
2740 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2741#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2742 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002743 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2744 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002745 return 0;
2746#endif
2747 } else { /*P3 and up use AUO panel */
2748#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2749 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002750 strnlen(LCDC_AUO_PANEL_NAME,
2751 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002752 return 0;
2753#endif
2754 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002755#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2756 } else if machine_is_msm8x60_dragon() {
2757 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002758 strnlen(LCDC_NT35582_PANEL_NAME,
2759 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002760 return 0;
2761#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002762 } else {
2763 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002764 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2765 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002766 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002767
2768#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2769 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2770 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2771 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2772 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2773 PANEL_NAME_MAX_LEN)))
2774 return 0;
2775
2776 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2777 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2778 PANEL_NAME_MAX_LEN)))
2779 return 0;
2780
2781 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2782 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2783 PANEL_NAME_MAX_LEN)))
2784 return 0;
2785#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002786 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002787
2788 if (!strncmp(name, HDMI_PANEL_NAME,
2789 strnlen(HDMI_PANEL_NAME,
2790 PANEL_NAME_MAX_LEN)))
2791 return 0;
2792
2793 if (!strncmp(name, TVOUT_PANEL_NAME,
2794 strnlen(TVOUT_PANEL_NAME,
2795 PANEL_NAME_MAX_LEN)))
2796 return 0;
2797
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002798 pr_warning("%s: not supported '%s'", __func__, name);
2799 return -ENODEV;
2800}
2801
2802static struct msm_fb_platform_data msm_fb_pdata = {
2803 .detect_client = msm_fb_detect_panel,
2804};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805
2806static struct platform_device msm_fb_device = {
2807 .name = "msm_fb",
2808 .id = 0,
2809 .num_resources = ARRAY_SIZE(msm_fb_resources),
2810 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002811 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002812};
2813
2814#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002815#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002816static struct android_pmem_platform_data android_pmem_pdata = {
2817 .name = "pmem",
2818 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2819 .cached = 1,
2820 .memory_type = MEMTYPE_EBI1,
2821};
2822
2823static struct platform_device android_pmem_device = {
2824 .name = "android_pmem",
2825 .id = 0,
2826 .dev = {.platform_data = &android_pmem_pdata},
2827};
2828
2829static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2830 .name = "pmem_adsp",
2831 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2832 .cached = 0,
2833 .memory_type = MEMTYPE_EBI1,
2834};
2835
2836static struct platform_device android_pmem_adsp_device = {
2837 .name = "android_pmem",
2838 .id = 2,
2839 .dev = { .platform_data = &android_pmem_adsp_pdata },
2840};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002841#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002842static struct android_pmem_platform_data android_pmem_audio_pdata = {
2843 .name = "pmem_audio",
2844 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2845 .cached = 0,
2846 .memory_type = MEMTYPE_EBI1,
2847};
2848
2849static struct platform_device android_pmem_audio_device = {
2850 .name = "android_pmem",
2851 .id = 4,
2852 .dev = { .platform_data = &android_pmem_audio_pdata },
2853};
2854
Laura Abbott1e36a022011-06-22 17:08:13 -07002855#define PMEM_BUS_WIDTH(_bw) \
2856 { \
2857 .vectors = &(struct msm_bus_vectors){ \
2858 .src = MSM_BUS_MASTER_AMPSS_M0, \
2859 .dst = MSM_BUS_SLAVE_SMI, \
2860 .ib = (_bw), \
2861 .ab = 0, \
2862 }, \
2863 .num_paths = 1, \
2864 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002865
2866static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002867 [0] = PMEM_BUS_WIDTH(0), /* Off */
2868 [1] = PMEM_BUS_WIDTH(1), /* On */
2869};
2870
2871static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002872 .usecase = mem_smi_table,
2873 .num_usecases = ARRAY_SIZE(mem_smi_table),
2874 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002875};
2876
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002877int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002878{
2879 int bus_id = (int) data;
2880
2881 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002882 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002883}
2884
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002885int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002886{
2887 int bus_id = (int) data;
2888
2889 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002890 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002891}
2892
Alex Bird199980e2011-10-21 11:29:27 -07002893void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002894{
2895 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2896}
Olav Hauganee0f7802011-12-19 13:28:57 -08002897#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002898static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2899 .name = "pmem_smipool",
2900 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2901 .cached = 0,
2902 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002903 .request_region = request_smi_region,
2904 .release_region = release_smi_region,
2905 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002906 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002907};
2908static struct platform_device android_pmem_smipool_device = {
2909 .name = "android_pmem",
2910 .id = 7,
2911 .dev = { .platform_data = &android_pmem_smipool_pdata },
2912};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002913#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002914#endif
2915
2916#define GPIO_DONGLE_PWR_EN 258
2917static void setup_display_power(void);
2918static int lcdc_vga_enabled;
2919static int vga_enable_request(int enable)
2920{
2921 if (enable)
2922 lcdc_vga_enabled = 1;
2923 else
2924 lcdc_vga_enabled = 0;
2925 setup_display_power();
2926
2927 return 0;
2928}
2929
2930#define GPIO_BACKLIGHT_PWM0 0
2931#define GPIO_BACKLIGHT_PWM1 1
2932
2933static int pmic_backlight_gpio[2]
2934 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2935static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2936 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2937 .vga_switch = vga_enable_request,
2938};
2939
2940static struct platform_device lcdc_samsung_panel_device = {
2941 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2942 .id = 0,
2943 .dev = {
2944 .platform_data = &lcdc_samsung_panel_data,
2945 }
2946};
2947#if (!defined(CONFIG_SPI_QUP)) && \
2948 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2949 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2950
2951static int lcdc_spi_gpio_array_num[] = {
2952 LCDC_SPI_GPIO_CLK,
2953 LCDC_SPI_GPIO_CS,
2954 LCDC_SPI_GPIO_MOSI,
2955};
2956
2957static uint32_t lcdc_spi_gpio_config_data[] = {
2958 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2959 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2960 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2961 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2962 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2963 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2964};
2965
2966static void lcdc_config_spi_gpios(int enable)
2967{
2968 int n;
2969 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2970 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2971}
2972#endif
2973
2974#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2975#ifdef CONFIG_SPI_QUP
2976static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2977 {
2978 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2979 .mode = SPI_MODE_3,
2980 .bus_num = 1,
2981 .chip_select = 0,
2982 .max_speed_hz = 10800000,
2983 }
2984};
2985#endif /* CONFIG_SPI_QUP */
2986
2987static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2988#ifndef CONFIG_SPI_QUP
2989 .panel_config_gpio = lcdc_config_spi_gpios,
2990 .gpio_num = lcdc_spi_gpio_array_num,
2991#endif
2992};
2993
2994static struct platform_device lcdc_samsung_oled_panel_device = {
2995 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2996 .id = 0,
2997 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2998};
2999#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3000
3001#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3002#ifdef CONFIG_SPI_QUP
3003static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3004 {
3005 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3006 .mode = SPI_MODE_3,
3007 .bus_num = 1,
3008 .chip_select = 0,
3009 .max_speed_hz = 10800000,
3010 }
3011};
3012#endif
3013
3014static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3015#ifndef CONFIG_SPI_QUP
3016 .panel_config_gpio = lcdc_config_spi_gpios,
3017 .gpio_num = lcdc_spi_gpio_array_num,
3018#endif
3019};
3020
3021static struct platform_device lcdc_auo_wvga_panel_device = {
3022 .name = LCDC_AUO_PANEL_NAME,
3023 .id = 0,
3024 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3025};
3026#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3027
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003028#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3029
3030#define GPIO_NT35582_RESET 94
3031#define GPIO_NT35582_BL_EN_HW_PIN 24
3032#define GPIO_NT35582_BL_EN \
3033 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3034
3035static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3036
3037static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3038 .gpio_num = lcdc_nt35582_pmic_gpio,
3039};
3040
3041static struct platform_device lcdc_nt35582_panel_device = {
3042 .name = LCDC_NT35582_PANEL_NAME,
3043 .id = 0,
3044 .dev = {
3045 .platform_data = &lcdc_nt35582_panel_data,
3046 }
3047};
3048
3049static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3050 {
3051 .modalias = "lcdc_nt35582_spi",
3052 .mode = SPI_MODE_0,
3053 .bus_num = 0,
3054 .chip_select = 0,
3055 .max_speed_hz = 1100000,
3056 }
3057};
3058#endif
3059
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003060#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3061static struct resource hdmi_msm_resources[] = {
3062 {
3063 .name = "hdmi_msm_qfprom_addr",
3064 .start = 0x00700000,
3065 .end = 0x007060FF,
3066 .flags = IORESOURCE_MEM,
3067 },
3068 {
3069 .name = "hdmi_msm_hdmi_addr",
3070 .start = 0x04A00000,
3071 .end = 0x04A00FFF,
3072 .flags = IORESOURCE_MEM,
3073 },
3074 {
3075 .name = "hdmi_msm_irq",
3076 .start = HDMI_IRQ,
3077 .end = HDMI_IRQ,
3078 .flags = IORESOURCE_IRQ,
3079 },
3080};
3081
3082static int hdmi_enable_5v(int on);
3083static int hdmi_core_power(int on, int show);
3084static int hdmi_cec_power(int on);
3085
3086static struct msm_hdmi_platform_data hdmi_msm_data = {
3087 .irq = HDMI_IRQ,
3088 .enable_5v = hdmi_enable_5v,
3089 .core_power = hdmi_core_power,
3090 .cec_power = hdmi_cec_power,
3091};
3092
3093static struct platform_device hdmi_msm_device = {
3094 .name = "hdmi_msm",
3095 .id = 0,
3096 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3097 .resource = hdmi_msm_resources,
3098 .dev.platform_data = &hdmi_msm_data,
3099};
3100#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3101
3102#ifdef CONFIG_FB_MSM_MIPI_DSI
3103static struct platform_device mipi_dsi_toshiba_panel_device = {
3104 .name = "mipi_toshiba",
3105 .id = 0,
3106};
3107
3108#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3109
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003110static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003111 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003112 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003113};
3114
3115static struct platform_device mipi_dsi_novatek_panel_device = {
3116 .name = "mipi_novatek",
3117 .id = 0,
3118 .dev = {
3119 .platform_data = &novatek_pdata,
3120 }
3121};
3122#endif
3123
3124static void __init msm8x60_allocate_memory_regions(void)
3125{
3126 void *addr;
3127 unsigned long size;
3128
3129 size = MSM_FB_SIZE;
3130 addr = alloc_bootmem_align(size, 0x1000);
3131 msm_fb_resources[0].start = __pa(addr);
3132 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3133 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3134 size, addr, __pa(addr));
3135
3136}
3137
3138#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3139 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3140/*virtual key support */
3141static ssize_t tma300_vkeys_show(struct kobject *kobj,
3142 struct kobj_attribute *attr, char *buf)
3143{
3144 return sprintf(buf,
3145 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3146 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3147 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3148 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3149 "\n");
3150}
3151
3152static struct kobj_attribute tma300_vkeys_attr = {
3153 .attr = {
3154 .mode = S_IRUGO,
3155 },
3156 .show = &tma300_vkeys_show,
3157};
3158
3159static struct attribute *tma300_properties_attrs[] = {
3160 &tma300_vkeys_attr.attr,
3161 NULL
3162};
3163
3164static struct attribute_group tma300_properties_attr_group = {
3165 .attrs = tma300_properties_attrs,
3166};
3167
3168static struct kobject *properties_kobj;
3169
3170
3171
3172#define CYTTSP_TS_GPIO_IRQ 61
3173static int cyttsp_platform_init(struct i2c_client *client)
3174{
3175 int rc = -EINVAL;
3176 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3177
3178 if (machine_is_msm8x60_fluid()) {
3179 pm8058_l5 = regulator_get(NULL, "8058_l5");
3180 if (IS_ERR(pm8058_l5)) {
3181 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3182 __func__, PTR_ERR(pm8058_l5));
3183 rc = PTR_ERR(pm8058_l5);
3184 return rc;
3185 }
3186 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3187 if (rc) {
3188 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3189 __func__, rc);
3190 goto reg_l5_put;
3191 }
3192
3193 rc = regulator_enable(pm8058_l5);
3194 if (rc) {
3195 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3196 __func__, rc);
3197 goto reg_l5_put;
3198 }
3199 }
3200 /* vote for s3 to enable i2c communication lines */
3201 pm8058_s3 = regulator_get(NULL, "8058_s3");
3202 if (IS_ERR(pm8058_s3)) {
3203 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3204 __func__, PTR_ERR(pm8058_s3));
3205 rc = PTR_ERR(pm8058_s3);
3206 goto reg_l5_disable;
3207 }
3208
3209 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3210 if (rc) {
3211 pr_err("%s: regulator_set_voltage() = %d\n",
3212 __func__, rc);
3213 goto reg_s3_put;
3214 }
3215
3216 rc = regulator_enable(pm8058_s3);
3217 if (rc) {
3218 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3219 __func__, rc);
3220 goto reg_s3_put;
3221 }
3222
3223 /* wait for vregs to stabilize */
3224 usleep_range(10000, 10000);
3225
3226 /* check this device active by reading first byte/register */
3227 rc = i2c_smbus_read_byte_data(client, 0x01);
3228 if (rc < 0) {
3229 pr_err("%s: i2c sanity check failed\n", __func__);
3230 goto reg_s3_disable;
3231 }
3232
3233 /* virtual keys */
3234 if (machine_is_msm8x60_fluid()) {
3235 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3236 properties_kobj = kobject_create_and_add("board_properties",
3237 NULL);
3238 if (properties_kobj)
3239 rc = sysfs_create_group(properties_kobj,
3240 &tma300_properties_attr_group);
3241 if (!properties_kobj || rc)
3242 pr_err("%s: failed to create board_properties\n",
3243 __func__);
3244 }
3245 return CY_OK;
3246
3247reg_s3_disable:
3248 regulator_disable(pm8058_s3);
3249reg_s3_put:
3250 regulator_put(pm8058_s3);
3251reg_l5_disable:
3252 if (machine_is_msm8x60_fluid())
3253 regulator_disable(pm8058_l5);
3254reg_l5_put:
3255 if (machine_is_msm8x60_fluid())
3256 regulator_put(pm8058_l5);
3257 return rc;
3258}
3259
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303260/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3261static int cyttsp_platform_suspend(struct i2c_client *client)
3262{
3263 msleep(20);
3264
3265 return CY_OK;
3266}
3267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003268static int cyttsp_platform_resume(struct i2c_client *client)
3269{
3270 /* add any special code to strobe a wakeup pin or chip reset */
3271 msleep(10);
3272
3273 return CY_OK;
3274}
3275
3276static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3277 .flags = 0x04,
3278 .gen = CY_GEN3, /* or */
3279 .use_st = CY_USE_ST,
3280 .use_mt = CY_USE_MT,
3281 .use_hndshk = CY_SEND_HNDSHK,
3282 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303283 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003284 .use_gestures = CY_USE_GESTURES,
3285 /* activate up to 4 groups
3286 * and set active distance
3287 */
3288 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3289 CY_GEST_GRP3 | CY_GEST_GRP4 |
3290 CY_ACT_DIST,
3291 /* change act_intrvl to customize the Active power state
3292 * scanning/processing refresh interval for Operating mode
3293 */
3294 .act_intrvl = CY_ACT_INTRVL_DFLT,
3295 /* change tch_tmout to customize the touch timeout for the
3296 * Active power state for Operating mode
3297 */
3298 .tch_tmout = CY_TCH_TMOUT_DFLT,
3299 /* change lp_intrvl to customize the Low Power power state
3300 * scanning/processing refresh interval for Operating mode
3301 */
3302 .lp_intrvl = CY_LP_INTRVL_DFLT,
3303 .sleep_gpio = -1,
3304 .resout_gpio = -1,
3305 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3306 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303307 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003308 .init = cyttsp_platform_init,
3309};
3310
3311static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3312 .panel_maxx = 1083,
3313 .panel_maxy = 659,
3314 .disp_minx = 30,
3315 .disp_maxx = 1053,
3316 .disp_miny = 30,
3317 .disp_maxy = 629,
3318 .correct_fw_ver = 8,
3319 .fw_fname = "cyttsp_8660_ffa.hex",
3320 .flags = 0x00,
3321 .gen = CY_GEN2, /* or */
3322 .use_st = CY_USE_ST,
3323 .use_mt = CY_USE_MT,
3324 .use_hndshk = CY_SEND_HNDSHK,
3325 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303326 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003327 .use_gestures = CY_USE_GESTURES,
3328 /* activate up to 4 groups
3329 * and set active distance
3330 */
3331 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3332 CY_GEST_GRP3 | CY_GEST_GRP4 |
3333 CY_ACT_DIST,
3334 /* change act_intrvl to customize the Active power state
3335 * scanning/processing refresh interval for Operating mode
3336 */
3337 .act_intrvl = CY_ACT_INTRVL_DFLT,
3338 /* change tch_tmout to customize the touch timeout for the
3339 * Active power state for Operating mode
3340 */
3341 .tch_tmout = CY_TCH_TMOUT_DFLT,
3342 /* change lp_intrvl to customize the Low Power power state
3343 * scanning/processing refresh interval for Operating mode
3344 */
3345 .lp_intrvl = CY_LP_INTRVL_DFLT,
3346 .sleep_gpio = -1,
3347 .resout_gpio = -1,
3348 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3349 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303350 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003351 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303352 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003353};
3354static void cyttsp_set_params(void)
3355{
3356 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3357 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3358 cyttsp_fluid_pdata.panel_maxx = 539;
3359 cyttsp_fluid_pdata.panel_maxy = 994;
3360 cyttsp_fluid_pdata.disp_minx = 30;
3361 cyttsp_fluid_pdata.disp_maxx = 509;
3362 cyttsp_fluid_pdata.disp_miny = 60;
3363 cyttsp_fluid_pdata.disp_maxy = 859;
3364 cyttsp_fluid_pdata.correct_fw_ver = 4;
3365 } else {
3366 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3367 cyttsp_fluid_pdata.panel_maxx = 550;
3368 cyttsp_fluid_pdata.panel_maxy = 1013;
3369 cyttsp_fluid_pdata.disp_minx = 35;
3370 cyttsp_fluid_pdata.disp_maxx = 515;
3371 cyttsp_fluid_pdata.disp_miny = 69;
3372 cyttsp_fluid_pdata.disp_maxy = 869;
3373 cyttsp_fluid_pdata.correct_fw_ver = 5;
3374 }
3375
3376}
3377
3378static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3379 {
3380 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3381 .platform_data = &cyttsp_fluid_pdata,
3382#ifndef CY_USE_TIMER
3383 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3384#endif /* CY_USE_TIMER */
3385 },
3386};
3387
3388static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3389 {
3390 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3391 .platform_data = &cyttsp_tmg240_pdata,
3392#ifndef CY_USE_TIMER
3393 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3394#endif /* CY_USE_TIMER */
3395 },
3396};
3397#endif
3398
3399static struct regulator *vreg_tmg200;
3400
3401#define TS_PEN_IRQ_GPIO 61
3402static int tmg200_power(int vreg_on)
3403{
3404 int rc = -EINVAL;
3405
3406 if (!vreg_tmg200) {
3407 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3408 __func__, rc);
3409 return rc;
3410 }
3411
3412 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3413 regulator_disable(vreg_tmg200);
3414 if (rc < 0)
3415 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3416 __func__, vreg_on ? "enable" : "disable", rc);
3417
3418 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003419 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003420
3421 return rc;
3422}
3423
3424static int tmg200_dev_setup(bool enable)
3425{
3426 int rc;
3427
3428 if (enable) {
3429 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3430 if (IS_ERR(vreg_tmg200)) {
3431 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3432 __func__, PTR_ERR(vreg_tmg200));
3433 rc = PTR_ERR(vreg_tmg200);
3434 return rc;
3435 }
3436
3437 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3438 if (rc) {
3439 pr_err("%s: regulator_set_voltage() = %d\n",
3440 __func__, rc);
3441 goto reg_put;
3442 }
3443 } else {
3444 /* put voltage sources */
3445 regulator_put(vreg_tmg200);
3446 }
3447 return 0;
3448reg_put:
3449 regulator_put(vreg_tmg200);
3450 return rc;
3451}
3452
3453static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3454 .ts_name = "msm_tmg200_ts",
3455 .dis_min_x = 0,
3456 .dis_max_x = 1023,
3457 .dis_min_y = 0,
3458 .dis_max_y = 599,
3459 .min_tid = 0,
3460 .max_tid = 255,
3461 .min_touch = 0,
3462 .max_touch = 255,
3463 .min_width = 0,
3464 .max_width = 255,
3465 .power_on = tmg200_power,
3466 .dev_setup = tmg200_dev_setup,
3467 .nfingers = 2,
3468 .irq_gpio = TS_PEN_IRQ_GPIO,
3469 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3470};
3471
3472static struct i2c_board_info cy8ctmg200_board_info[] = {
3473 {
3474 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3475 .platform_data = &cy8ctmg200_pdata,
3476 }
3477};
3478
Zhang Chang Ken211df572011-07-05 19:16:39 -04003479static struct regulator *vreg_tma340;
3480
3481static int tma340_power(int vreg_on)
3482{
3483 int rc = -EINVAL;
3484
3485 if (!vreg_tma340) {
3486 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3487 __func__, rc);
3488 return rc;
3489 }
3490
3491 rc = vreg_on ? regulator_enable(vreg_tma340) :
3492 regulator_disable(vreg_tma340);
3493 if (rc < 0)
3494 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3495 __func__, vreg_on ? "enable" : "disable", rc);
3496
3497 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003498 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003499
3500 return rc;
3501}
3502
3503static struct kobject *tma340_prop_kobj;
3504
3505static int tma340_dragon_dev_setup(bool enable)
3506{
3507 int rc;
3508
3509 if (enable) {
3510 vreg_tma340 = regulator_get(NULL, "8901_l2");
3511 if (IS_ERR(vreg_tma340)) {
3512 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3513 __func__, PTR_ERR(vreg_tma340));
3514 rc = PTR_ERR(vreg_tma340);
3515 return rc;
3516 }
3517
3518 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3519 if (rc) {
3520 pr_err("%s: regulator_set_voltage() = %d\n",
3521 __func__, rc);
3522 goto reg_put;
3523 }
3524 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3525 tma340_prop_kobj = kobject_create_and_add("board_properties",
3526 NULL);
3527 if (tma340_prop_kobj) {
3528 rc = sysfs_create_group(tma340_prop_kobj,
3529 &tma300_properties_attr_group);
3530 if (rc) {
3531 kobject_put(tma340_prop_kobj);
3532 pr_err("%s: failed to create board_properties\n",
3533 __func__);
3534 goto reg_put;
3535 }
3536 }
3537
3538 } else {
3539 /* put voltage sources */
3540 regulator_put(vreg_tma340);
3541 /* destroy virtual keys */
3542 if (tma340_prop_kobj) {
3543 sysfs_remove_group(tma340_prop_kobj,
3544 &tma300_properties_attr_group);
3545 kobject_put(tma340_prop_kobj);
3546 }
3547 }
3548 return 0;
3549reg_put:
3550 regulator_put(vreg_tma340);
3551 return rc;
3552}
3553
3554
3555static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3556 .ts_name = "cy8ctma340",
3557 .dis_min_x = 0,
3558 .dis_max_x = 479,
3559 .dis_min_y = 0,
3560 .dis_max_y = 799,
3561 .min_tid = 0,
3562 .max_tid = 255,
3563 .min_touch = 0,
3564 .max_touch = 255,
3565 .min_width = 0,
3566 .max_width = 255,
3567 .power_on = tma340_power,
3568 .dev_setup = tma340_dragon_dev_setup,
3569 .nfingers = 2,
3570 .irq_gpio = TS_PEN_IRQ_GPIO,
3571 .resout_gpio = -1,
3572};
3573
3574static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3575 {
3576 I2C_BOARD_INFO("cy8ctma340", 0x24),
3577 .platform_data = &cy8ctma340_dragon_pdata,
3578 }
3579};
3580
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003581#ifdef CONFIG_SERIAL_MSM_HS
3582static int configure_uart_gpios(int on)
3583{
3584 int ret = 0, i;
3585 int uart_gpios[] = {53, 54, 55, 56};
3586 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3587 if (on) {
3588 ret = msm_gpiomux_get(uart_gpios[i]);
3589 if (unlikely(ret))
3590 break;
3591 } else {
3592 ret = msm_gpiomux_put(uart_gpios[i]);
3593 if (unlikely(ret))
3594 return ret;
3595 }
3596 }
3597 if (ret)
3598 for (; i >= 0; i--)
3599 msm_gpiomux_put(uart_gpios[i]);
3600 return ret;
3601}
3602static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3603 .inject_rx_on_wakeup = 1,
3604 .rx_to_inject = 0xFD,
3605 .gpio_config = configure_uart_gpios,
3606};
3607#endif
3608
3609
3610#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3611
3612static struct gpio_led gpio_exp_leds_config[] = {
3613 {
3614 .name = "left_led1:green",
3615 .gpio = GPIO_LEFT_LED_1,
3616 .active_low = 1,
3617 .retain_state_suspended = 0,
3618 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3619 },
3620 {
3621 .name = "left_led2:red",
3622 .gpio = GPIO_LEFT_LED_2,
3623 .active_low = 1,
3624 .retain_state_suspended = 0,
3625 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3626 },
3627 {
3628 .name = "left_led3:green",
3629 .gpio = GPIO_LEFT_LED_3,
3630 .active_low = 1,
3631 .retain_state_suspended = 0,
3632 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3633 },
3634 {
3635 .name = "wlan_led:orange",
3636 .gpio = GPIO_LEFT_LED_WLAN,
3637 .active_low = 1,
3638 .retain_state_suspended = 0,
3639 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3640 },
3641 {
3642 .name = "left_led5:green",
3643 .gpio = GPIO_LEFT_LED_5,
3644 .active_low = 1,
3645 .retain_state_suspended = 0,
3646 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3647 },
3648 {
3649 .name = "right_led1:green",
3650 .gpio = GPIO_RIGHT_LED_1,
3651 .active_low = 1,
3652 .retain_state_suspended = 0,
3653 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3654 },
3655 {
3656 .name = "right_led2:red",
3657 .gpio = GPIO_RIGHT_LED_2,
3658 .active_low = 1,
3659 .retain_state_suspended = 0,
3660 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3661 },
3662 {
3663 .name = "right_led3:green",
3664 .gpio = GPIO_RIGHT_LED_3,
3665 .active_low = 1,
3666 .retain_state_suspended = 0,
3667 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3668 },
3669 {
3670 .name = "bt_led:blue",
3671 .gpio = GPIO_RIGHT_LED_BT,
3672 .active_low = 1,
3673 .retain_state_suspended = 0,
3674 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3675 },
3676 {
3677 .name = "right_led5:green",
3678 .gpio = GPIO_RIGHT_LED_5,
3679 .active_low = 1,
3680 .retain_state_suspended = 0,
3681 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3682 },
3683};
3684
3685static struct gpio_led_platform_data gpio_leds_pdata = {
3686 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3687 .leds = gpio_exp_leds_config,
3688};
3689
3690static struct platform_device gpio_leds = {
3691 .name = "leds-gpio",
3692 .id = -1,
3693 .dev = {
3694 .platform_data = &gpio_leds_pdata,
3695 },
3696};
3697
3698static struct gpio_led fluid_gpio_leds[] = {
3699 {
3700 .name = "dual_led:green",
3701 .gpio = GPIO_LED1_GREEN_N,
3702 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3703 .active_low = 1,
3704 .retain_state_suspended = 0,
3705 },
3706 {
3707 .name = "dual_led:red",
3708 .gpio = GPIO_LED2_RED_N,
3709 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3710 .active_low = 1,
3711 .retain_state_suspended = 0,
3712 },
3713};
3714
3715static struct gpio_led_platform_data gpio_led_pdata = {
3716 .leds = fluid_gpio_leds,
3717 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3718};
3719
3720static struct platform_device fluid_leds_gpio = {
3721 .name = "leds-gpio",
3722 .id = -1,
3723 .dev = {
3724 .platform_data = &gpio_led_pdata,
3725 },
3726};
3727
3728#endif
3729
3730#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
3731
3732static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
3733 .phys_addr_base = 0x00106000,
3734 .reg_offsets = {
3735 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000C80,
3736 [MSM_RPM_LOG_PAGE_BUFFER] = 0x00000CA0,
3737 },
3738 .phys_size = SZ_8K,
3739 .log_len = 4096, /* log's buffer length in bytes */
3740 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3741};
3742
3743static struct platform_device msm_rpm_log_device = {
3744 .name = "msm_rpm_log",
3745 .id = -1,
3746 .dev = {
3747 .platform_data = &msm_rpm_log_pdata,
3748 },
3749};
3750#endif
3751
3752#ifdef CONFIG_BATTERY_MSM8X60
3753static struct msm_charger_platform_data msm_charger_data = {
3754 .safety_time = 180,
3755 .update_time = 1,
3756 .max_voltage = 4200,
3757 .min_voltage = 3200,
3758};
3759
3760static struct platform_device msm_charger_device = {
3761 .name = "msm-charger",
3762 .id = -1,
3763 .dev = {
3764 .platform_data = &msm_charger_data,
3765 }
3766};
3767#endif
3768
3769/*
3770 * Consumer specific regulator names:
3771 * regulator name consumer dev_name
3772 */
3773static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3774 REGULATOR_SUPPLY("8058_l0", NULL),
3775};
3776static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3777 REGULATOR_SUPPLY("8058_l1", NULL),
3778};
3779static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3780 REGULATOR_SUPPLY("8058_l2", NULL),
3781};
3782static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3783 REGULATOR_SUPPLY("8058_l3", NULL),
3784};
3785static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3786 REGULATOR_SUPPLY("8058_l4", NULL),
3787};
3788static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3789 REGULATOR_SUPPLY("8058_l5", NULL),
3790};
3791static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3792 REGULATOR_SUPPLY("8058_l6", NULL),
3793};
3794static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3795 REGULATOR_SUPPLY("8058_l7", NULL),
3796};
3797static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3798 REGULATOR_SUPPLY("8058_l8", NULL),
3799};
3800static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3801 REGULATOR_SUPPLY("8058_l9", NULL),
3802};
3803static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3804 REGULATOR_SUPPLY("8058_l10", NULL),
3805};
3806static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3807 REGULATOR_SUPPLY("8058_l11", NULL),
3808};
3809static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3810 REGULATOR_SUPPLY("8058_l12", NULL),
3811};
3812static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3813 REGULATOR_SUPPLY("8058_l13", NULL),
3814};
3815static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3816 REGULATOR_SUPPLY("8058_l14", NULL),
3817};
3818static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3819 REGULATOR_SUPPLY("8058_l15", NULL),
3820};
3821static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3822 REGULATOR_SUPPLY("8058_l16", NULL),
3823};
3824static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3825 REGULATOR_SUPPLY("8058_l17", NULL),
3826};
3827static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3828 REGULATOR_SUPPLY("8058_l18", NULL),
3829};
3830static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3831 REGULATOR_SUPPLY("8058_l19", NULL),
3832};
3833static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3834 REGULATOR_SUPPLY("8058_l20", NULL),
3835};
3836static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3837 REGULATOR_SUPPLY("8058_l21", NULL),
3838};
3839static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3840 REGULATOR_SUPPLY("8058_l22", NULL),
3841};
3842static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3843 REGULATOR_SUPPLY("8058_l23", NULL),
3844};
3845static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3846 REGULATOR_SUPPLY("8058_l24", NULL),
3847};
3848static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3849 REGULATOR_SUPPLY("8058_l25", NULL),
3850};
3851static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3852 REGULATOR_SUPPLY("8058_s0", NULL),
3853};
3854static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3855 REGULATOR_SUPPLY("8058_s1", NULL),
3856};
3857static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3858 REGULATOR_SUPPLY("8058_s2", NULL),
3859};
3860static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3861 REGULATOR_SUPPLY("8058_s3", NULL),
3862};
3863static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3864 REGULATOR_SUPPLY("8058_s4", NULL),
3865};
3866static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3867 REGULATOR_SUPPLY("8058_lvs0", NULL),
3868};
3869static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3870 REGULATOR_SUPPLY("8058_lvs1", NULL),
3871};
3872static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3873 REGULATOR_SUPPLY("8058_ncp", NULL),
3874};
3875
3876static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3877 REGULATOR_SUPPLY("8901_l0", NULL),
3878};
3879static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3880 REGULATOR_SUPPLY("8901_l1", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3883 REGULATOR_SUPPLY("8901_l2", NULL),
3884};
3885static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3886 REGULATOR_SUPPLY("8901_l3", NULL),
3887};
3888static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3889 REGULATOR_SUPPLY("8901_l4", NULL),
3890};
3891static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3892 REGULATOR_SUPPLY("8901_l5", NULL),
3893};
3894static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3895 REGULATOR_SUPPLY("8901_l6", NULL),
3896};
3897static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3898 REGULATOR_SUPPLY("8901_s2", NULL),
3899};
3900static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3901 REGULATOR_SUPPLY("8901_s3", NULL),
3902};
3903static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3904 REGULATOR_SUPPLY("8901_s4", NULL),
3905};
3906static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3907 REGULATOR_SUPPLY("8901_lvs0", NULL),
3908};
3909static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3910 REGULATOR_SUPPLY("8901_lvs1", NULL),
3911};
3912static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3913 REGULATOR_SUPPLY("8901_lvs2", NULL),
3914};
3915static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3916 REGULATOR_SUPPLY("8901_lvs3", NULL),
3917};
3918static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3919 REGULATOR_SUPPLY("8901_mvs0", NULL),
3920};
3921
David Collins6f032ba2011-08-31 14:08:15 -07003922/* Pin control regulators */
3923static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3924 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3925};
3926static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3927 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3930 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3933 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3934};
3935static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3936 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3937};
3938static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3939 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3940};
3941
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003942#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3943 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins6f032ba2011-08-31 14:08:15 -07003944 _freq, _pin_fn, _force_mode, _state, _sleep_selectable, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003945 _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003946 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003947 .init_data = { \
3948 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003949 .valid_modes_mask = _modes, \
3950 .valid_ops_mask = _ops, \
3951 .min_uV = _min_uV, \
3952 .max_uV = _max_uV, \
3953 .input_uV = _min_uV, \
3954 .apply_uV = _apply_uV, \
3955 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003956 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003957 .consumer_supplies = vreg_consumers_##_id, \
3958 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959 ARRAY_SIZE(vreg_consumers_##_id), \
3960 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003961 .id = RPM_VREG_ID_##_id, \
3962 .default_uV = _default_uV, \
3963 .peak_uA = _peak_uA, \
3964 .avg_uA = _avg_uA, \
3965 .pull_down_enable = _pull_down, \
3966 .pin_ctrl = _pin_ctrl, \
3967 .freq = RPM_VREG_FREQ_##_freq, \
3968 .pin_fn = _pin_fn, \
3969 .force_mode = _force_mode, \
3970 .state = _state, \
3971 .sleep_selectable = _sleep_selectable, \
3972 }
3973
3974/* Pin control initialization */
3975#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3976 { \
3977 .init_data = { \
3978 .constraints = { \
3979 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3980 .always_on = _always_on, \
3981 }, \
3982 .num_consumer_supplies = \
3983 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3984 .consumer_supplies = vreg_consumers_##_id##_PC, \
3985 }, \
3986 .id = RPM_VREG_ID_##_id##_PC, \
3987 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003988 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003989 }
3990
3991/*
3992 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3993 * via the peak_uA value specified in the table below. If the value is less
3994 * than the high power min threshold for the regulator, then the regulator will
3995 * be set to LPM. Otherwise, it will be set to HPM.
3996 *
3997 * This value can be further overridden by specifying an initial mode via
3998 * .init_data.constraints.initial_mode.
3999 */
4000
David Collins6f032ba2011-08-31 14:08:15 -07004001#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4002 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004003 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4004 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4005 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4006 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4007 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004008 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4009 RPM_VREG_PIN_FN_8660_ENABLE, \
4010 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004011 _sleep_selectable, _always_on)
4012
David Collins6f032ba2011-08-31 14:08:15 -07004013#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4014 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004015 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4016 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4017 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4018 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4019 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004020 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4021 RPM_VREG_PIN_FN_8660_ENABLE, \
4022 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4023 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004024
David Collins6f032ba2011-08-31 14:08:15 -07004025#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004026 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4027 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004028 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4029 RPM_VREG_PIN_FN_8660_ENABLE, \
4030 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_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004034 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4035 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004036 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4037 RPM_VREG_PIN_FN_8660_ENABLE, \
4038 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4039 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004040
David Collins6f032ba2011-08-31 14:08:15 -07004041#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4042#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4043#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4044#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4045#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046
David Collins6f032ba2011-08-31 14:08:15 -07004047/* RPM early regulator constraints */
4048static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4049 /* ID a_on pd ss min_uV max_uV init_ip freq */
4050 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
4051 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052};
4053
David Collins6f032ba2011-08-31 14:08:15 -07004054/* RPM regulator constraints */
4055static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4056 /* ID a_on pd ss min_uV max_uV init_ip */
4057 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4058 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4059 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4060 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4061 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4062 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4063 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4064 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4065 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4066 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4067 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4068 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4069 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4070 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4071 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4072 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4073 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4074 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4075 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4076 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4077 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4078 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4079 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4080 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4081 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4082 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004083
David Collins6f032ba2011-08-31 14:08:15 -07004084 /* ID a_on pd ss min_uV max_uV init_ip freq */
4085 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4086 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4087 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4088
4089 /* ID a_on pd ss */
4090 RPM_VS(PM8058_LVS0, 0, 1, 0),
4091 RPM_VS(PM8058_LVS1, 0, 1, 0),
4092
4093 /* ID a_on pd ss min_uV max_uV */
4094 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4095
4096 /* ID a_on pd ss min_uV max_uV init_ip */
4097 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4098 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4099 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4100 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4101 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4102 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4103 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4104
4105 /* ID a_on pd ss min_uV max_uV init_ip freq */
4106 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4107 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4108 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4109
4110 /* ID a_on pd ss */
4111 RPM_VS(PM8901_LVS0, 1, 1, 0),
4112 RPM_VS(PM8901_LVS1, 0, 1, 0),
4113 RPM_VS(PM8901_LVS2, 0, 1, 0),
4114 RPM_VS(PM8901_LVS3, 0, 1, 0),
4115 RPM_VS(PM8901_MVS0, 0, 1, 0),
4116
4117 /* ID a_on pin_func pin_ctrl */
4118 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4119 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4120 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4121 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4122 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4123 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4124};
4125
4126static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4127 .init_data = rpm_regulator_early_init_data,
4128 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4129 .version = RPM_VREG_VERSION_8660,
4130 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4131 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4132};
4133
4134static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4135 .init_data = rpm_regulator_init_data,
4136 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4137 .version = RPM_VREG_VERSION_8660,
4138};
4139
4140static struct platform_device rpm_regulator_early_device = {
4141 .name = "rpm-regulator",
4142 .id = 0,
4143 .dev = {
4144 .platform_data = &rpm_regulator_early_pdata,
4145 },
4146};
4147
4148static struct platform_device rpm_regulator_device = {
4149 .name = "rpm-regulator",
4150 .id = 1,
4151 .dev = {
4152 .platform_data = &rpm_regulator_pdata,
4153 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004154};
4155
4156static struct platform_device *early_regulators[] __initdata = {
4157 &msm_device_saw_s0,
4158 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004159 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004160};
4161
4162static struct platform_device *early_devices[] __initdata = {
4163#ifdef CONFIG_MSM_BUS_SCALING
4164 &msm_bus_apps_fabric,
4165 &msm_bus_sys_fabric,
4166 &msm_bus_mm_fabric,
4167 &msm_bus_sys_fpb,
4168 &msm_bus_cpss_fpb,
4169#endif
4170 &msm_device_dmov_adm0,
4171 &msm_device_dmov_adm1,
4172};
4173
4174#if (defined(CONFIG_MARIMBA_CORE)) && \
4175 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4176
4177static int bluetooth_power(int);
4178static struct platform_device msm_bt_power_device = {
4179 .name = "bt_power",
4180 .id = -1,
4181 .dev = {
4182 .platform_data = &bluetooth_power,
4183 },
4184};
4185#endif
4186
4187static struct platform_device msm_tsens_device = {
4188 .name = "tsens-tm",
4189 .id = -1,
4190};
4191
4192static struct platform_device *rumi_sim_devices[] __initdata = {
4193 &smc91x_device,
4194 &msm_device_uart_dm12,
4195#ifdef CONFIG_I2C_QUP
4196 &msm_gsbi3_qup_i2c_device,
4197 &msm_gsbi4_qup_i2c_device,
4198 &msm_gsbi7_qup_i2c_device,
4199 &msm_gsbi8_qup_i2c_device,
4200 &msm_gsbi9_qup_i2c_device,
4201 &msm_gsbi12_qup_i2c_device,
4202#endif
4203#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004204 &msm_device_ssbi3,
4205#endif
4206#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004207#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004208 &android_pmem_device,
4209 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004210 &android_pmem_smipool_device,
4211#endif
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004212 &android_pmem_audio_device,
4213#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004214#ifdef CONFIG_MSM_ROTATOR
4215 &msm_rotator_device,
4216#endif
4217 &msm_fb_device,
4218 &msm_kgsl_3d0,
4219 &msm_kgsl_2d0,
4220 &msm_kgsl_2d1,
4221 &lcdc_samsung_panel_device,
4222#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4223 &hdmi_msm_device,
4224#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4225#ifdef CONFIG_MSM_CAMERA
4226#ifdef CONFIG_MT9E013
4227 &msm_camera_sensor_mt9e013,
4228#endif
4229#ifdef CONFIG_IMX074
4230 &msm_camera_sensor_imx074,
4231#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004232#ifdef CONFIG_VX6953
4233 &msm_camera_sensor_vx6953,
4234#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004235#ifdef CONFIG_WEBCAM_OV7692
4236 &msm_camera_sensor_webcam_ov7692,
4237#endif
4238#ifdef CONFIG_WEBCAM_OV9726
4239 &msm_camera_sensor_webcam_ov9726,
4240#endif
4241#ifdef CONFIG_QS_S5K4E1
4242 &msm_camera_sensor_qs_s5k4e1,
4243#endif
4244#endif
4245#ifdef CONFIG_MSM_GEMINI
4246 &msm_gemini_device,
4247#endif
4248#ifdef CONFIG_MSM_VPE
4249 &msm_vpe_device,
4250#endif
4251 &msm_device_vidc,
4252};
4253
4254#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4255enum {
4256 SX150X_CORE,
4257 SX150X_DOCKING,
4258 SX150X_SURF,
4259 SX150X_LEFT_FHA,
4260 SX150X_RIGHT_FHA,
4261 SX150X_SOUTH,
4262 SX150X_NORTH,
4263 SX150X_CORE_FLUID,
4264};
4265
4266static struct sx150x_platform_data sx150x_data[] __initdata = {
4267 [SX150X_CORE] = {
4268 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4269 .oscio_is_gpo = false,
4270 .io_pullup_ena = 0x0c08,
4271 .io_pulldn_ena = 0x4060,
4272 .io_open_drain_ena = 0x000c,
4273 .io_polarity = 0,
4274 .irq_summary = -1, /* see fixup_i2c_configs() */
4275 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4276 },
4277 [SX150X_DOCKING] = {
4278 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4279 .oscio_is_gpo = false,
4280 .io_pullup_ena = 0x5e06,
4281 .io_pulldn_ena = 0x81b8,
4282 .io_open_drain_ena = 0,
4283 .io_polarity = 0,
4284 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4285 UI_INT2_N),
4286 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4287 GPIO_DOCKING_EXPANDER_BASE -
4288 GPIO_EXPANDER_GPIO_BASE,
4289 },
4290 [SX150X_SURF] = {
4291 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4292 .oscio_is_gpo = false,
4293 .io_pullup_ena = 0,
4294 .io_pulldn_ena = 0,
4295 .io_open_drain_ena = 0,
4296 .io_polarity = 0,
4297 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4298 UI_INT1_N),
4299 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4300 GPIO_SURF_EXPANDER_BASE -
4301 GPIO_EXPANDER_GPIO_BASE,
4302 },
4303 [SX150X_LEFT_FHA] = {
4304 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4305 .oscio_is_gpo = false,
4306 .io_pullup_ena = 0,
4307 .io_pulldn_ena = 0x40,
4308 .io_open_drain_ena = 0,
4309 .io_polarity = 0,
4310 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4311 UI_INT3_N),
4312 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4313 GPIO_LEFT_KB_EXPANDER_BASE -
4314 GPIO_EXPANDER_GPIO_BASE,
4315 },
4316 [SX150X_RIGHT_FHA] = {
4317 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4318 .oscio_is_gpo = true,
4319 .io_pullup_ena = 0,
4320 .io_pulldn_ena = 0,
4321 .io_open_drain_ena = 0,
4322 .io_polarity = 0,
4323 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4324 UI_INT3_N),
4325 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4326 GPIO_RIGHT_KB_EXPANDER_BASE -
4327 GPIO_EXPANDER_GPIO_BASE,
4328 },
4329 [SX150X_SOUTH] = {
4330 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4331 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4332 GPIO_SOUTH_EXPANDER_BASE -
4333 GPIO_EXPANDER_GPIO_BASE,
4334 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4335 },
4336 [SX150X_NORTH] = {
4337 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4338 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4339 GPIO_NORTH_EXPANDER_BASE -
4340 GPIO_EXPANDER_GPIO_BASE,
4341 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4342 .oscio_is_gpo = true,
4343 .io_open_drain_ena = 0x30,
4344 },
4345 [SX150X_CORE_FLUID] = {
4346 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4347 .oscio_is_gpo = false,
4348 .io_pullup_ena = 0x0408,
4349 .io_pulldn_ena = 0x4060,
4350 .io_open_drain_ena = 0x0008,
4351 .io_polarity = 0,
4352 .irq_summary = -1, /* see fixup_i2c_configs() */
4353 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4354 },
4355};
4356
4357#ifdef CONFIG_SENSORS_MSM_ADC
4358/* Configuration of EPM expander is done when client
4359 * request an adc read
4360 */
4361static struct sx150x_platform_data sx150x_epmdata = {
4362 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4363 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4364 GPIO_EPM_EXPANDER_BASE -
4365 GPIO_EXPANDER_GPIO_BASE,
4366 .irq_summary = -1,
4367};
4368#endif
4369
4370/* sx150x_low_power_cfg
4371 *
4372 * This data and init function are used to put unused gpio-expander output
4373 * lines into their low-power states at boot. The init
4374 * function must be deferred until a later init stage because the i2c
4375 * gpio expander drivers do not probe until after they are registered
4376 * (see register_i2c_devices) and the work-queues for those registrations
4377 * are processed. Because these lines are unused, there is no risk of
4378 * competing with a device driver for the gpio.
4379 *
4380 * gpio lines whose low-power states are input are naturally in their low-
4381 * power configurations once probed, see the platform data structures above.
4382 */
4383struct sx150x_low_power_cfg {
4384 unsigned gpio;
4385 unsigned val;
4386};
4387
4388static struct sx150x_low_power_cfg
4389common_sx150x_lp_cfgs[] __initdata = {
4390 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4391 {GPIO_EXT_GPS_LNA_EN, 0},
4392 {GPIO_MSM_WAKES_BT, 0},
4393 {GPIO_USB_UICC_EN, 0},
4394 {GPIO_BATT_GAUGE_EN, 0},
4395};
4396
4397static struct sx150x_low_power_cfg
4398surf_ffa_sx150x_lp_cfgs[] __initdata = {
4399 {GPIO_MIPI_DSI_RST_N, 0},
4400 {GPIO_DONGLE_PWR_EN, 0},
4401 {GPIO_CAP_TS_SLEEP, 1},
4402 {GPIO_WEB_CAMIF_RESET_N, 0},
4403};
4404
4405static void __init
4406cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4407{
4408 unsigned n;
4409 int rc;
4410
4411 for (n = 0; n < nelems; ++n) {
4412 rc = gpio_request(cfgs[n].gpio, NULL);
4413 if (!rc) {
4414 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4415 gpio_free(cfgs[n].gpio);
4416 }
4417
4418 if (rc) {
4419 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4420 __func__, cfgs[n].gpio, rc);
4421 }
Steve Muckle9161d302010-02-11 11:50:40 -08004422 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004423}
4424
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004425static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004426{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004427 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4428 ARRAY_SIZE(common_sx150x_lp_cfgs));
4429 if (!machine_is_msm8x60_fluid())
4430 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4431 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4432 return 0;
4433}
4434module_init(cfg_sx150xs_low_power);
4435
4436#ifdef CONFIG_I2C
4437static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4438 {
4439 I2C_BOARD_INFO("sx1509q", 0x3e),
4440 .platform_data = &sx150x_data[SX150X_CORE]
4441 },
4442};
4443
4444static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4445 {
4446 I2C_BOARD_INFO("sx1509q", 0x3f),
4447 .platform_data = &sx150x_data[SX150X_DOCKING]
4448 },
4449};
4450
4451static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4452 {
4453 I2C_BOARD_INFO("sx1509q", 0x70),
4454 .platform_data = &sx150x_data[SX150X_SURF]
4455 }
4456};
4457
4458static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4459 {
4460 I2C_BOARD_INFO("sx1508q", 0x21),
4461 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4462 },
4463 {
4464 I2C_BOARD_INFO("sx1508q", 0x22),
4465 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4466 }
4467};
4468
4469static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4470 {
4471 I2C_BOARD_INFO("sx1508q", 0x23),
4472 .platform_data = &sx150x_data[SX150X_SOUTH]
4473 },
4474 {
4475 I2C_BOARD_INFO("sx1508q", 0x20),
4476 .platform_data = &sx150x_data[SX150X_NORTH]
4477 }
4478};
4479
4480static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4481 {
4482 I2C_BOARD_INFO("sx1509q", 0x3e),
4483 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4484 },
4485};
4486
4487#ifdef CONFIG_SENSORS_MSM_ADC
4488static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4489 {
4490 I2C_BOARD_INFO("sx1509q", 0x3e),
4491 .platform_data = &sx150x_epmdata
4492 },
4493};
4494#endif
4495#endif
4496#endif
4497
4498#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004499
4500static struct adc_access_fn xoadc_fn = {
4501 pm8058_xoadc_select_chan_and_start_conv,
4502 pm8058_xoadc_read_adc_code,
4503 pm8058_xoadc_get_properties,
4504 pm8058_xoadc_slot_request,
4505 pm8058_xoadc_restore_slot,
4506 pm8058_xoadc_calibrate,
4507};
4508
4509#if defined(CONFIG_I2C) && \
4510 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4511static struct regulator *vreg_adc_epm1;
4512
4513static struct i2c_client *epm_expander_i2c_register_board(void)
4514
4515{
4516 struct i2c_adapter *i2c_adap;
4517 struct i2c_client *client = NULL;
4518 i2c_adap = i2c_get_adapter(0x0);
4519
4520 if (i2c_adap == NULL)
4521 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4522
4523 if (i2c_adap != NULL)
4524 client = i2c_new_device(i2c_adap,
4525 &fluid_expanders_i2c_epm_info[0]);
4526 return client;
4527
4528}
4529
4530static unsigned int msm_adc_gpio_configure_expander_enable(void)
4531{
4532 int rc = 0;
4533 static struct i2c_client *epm_i2c_client;
4534
4535 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4536
4537 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4538
4539 if (IS_ERR(vreg_adc_epm1)) {
4540 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4541 return 0;
4542 }
4543
4544 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4545 if (rc)
4546 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4547 "regulator set voltage failed\n");
4548
4549 rc = regulator_enable(vreg_adc_epm1);
4550 if (rc) {
4551 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4552 "Error while enabling regulator for epm s3 %d\n", rc);
4553 return rc;
4554 }
4555
4556 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4557 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4558
4559 msleep(1000);
4560
4561 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4562 if (!rc) {
4563 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4564 "Configure 5v boost\n");
4565 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4566 } else {
4567 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4568 "Error for epm 5v boost en\n");
4569 goto exit_vreg_epm;
4570 }
4571
4572 msleep(500);
4573
4574 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4575 if (!rc) {
4576 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4577 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4578 "Configure epm 3.3v\n");
4579 } else {
4580 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4581 "Error for gpio 3.3ven\n");
4582 goto exit_vreg_epm;
4583 }
4584 msleep(500);
4585
4586 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4587 "Trying to request EPM LVLSFT_EN\n");
4588 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4589 if (!rc) {
4590 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4591 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4592 "Configure the lvlsft\n");
4593 } else {
4594 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4595 "Error for epm lvlsft_en\n");
4596 goto exit_vreg_epm;
4597 }
4598
4599 msleep(500);
4600
4601 if (!epm_i2c_client)
4602 epm_i2c_client = epm_expander_i2c_register_board();
4603
4604 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4605 if (!rc)
4606 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4607 if (rc) {
4608 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4609 ": GPIO PWR MON Enable issue\n");
4610 goto exit_vreg_epm;
4611 }
4612
4613 msleep(1000);
4614
4615 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4616 if (!rc) {
4617 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4618 if (rc) {
4619 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4620 ": ADC1_PWDN error direction out\n");
4621 goto exit_vreg_epm;
4622 }
4623 }
4624
4625 msleep(100);
4626
4627 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4628 if (!rc) {
4629 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4630 if (rc) {
4631 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4632 ": ADC2_PWD error direction out\n");
4633 goto exit_vreg_epm;
4634 }
4635 }
4636
4637 msleep(1000);
4638
4639 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4640 if (!rc) {
4641 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4642 if (rc) {
4643 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4644 "Gpio request problem %d\n", rc);
4645 goto exit_vreg_epm;
4646 }
4647 }
4648
4649 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4650 if (!rc) {
4651 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4652 if (rc) {
4653 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4654 ": EPM_SPI_ADC1_CS_N error\n");
4655 goto exit_vreg_epm;
4656 }
4657 }
4658
4659 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4660 if (!rc) {
4661 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4662 if (rc) {
4663 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4664 ": EPM_SPI_ADC2_Cs_N error\n");
4665 goto exit_vreg_epm;
4666 }
4667 }
4668
4669 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4670 "the power monitor reset for epm\n");
4671
4672 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4673 if (!rc) {
4674 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4675 if (rc) {
4676 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4677 ": Error in the power mon reset\n");
4678 goto exit_vreg_epm;
4679 }
4680 }
4681
4682 msleep(1000);
4683
4684 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4685
4686 msleep(500);
4687
4688 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4689
4690 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4691
4692 return rc;
4693
4694exit_vreg_epm:
4695 regulator_disable(vreg_adc_epm1);
4696
4697 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4698 " rc = %d.\n", rc);
4699 return rc;
4700};
4701
4702static unsigned int msm_adc_gpio_configure_expander_disable(void)
4703{
4704 int rc = 0;
4705
4706 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4707 gpio_free(GPIO_PWR_MON_RESET_N);
4708
4709 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4710 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4711
4712 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4713 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4714
4715 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4716 gpio_free(GPIO_PWR_MON_START);
4717
4718 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4719 gpio_free(GPIO_ADC1_PWDN_N);
4720
4721 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4722 gpio_free(GPIO_ADC2_PWDN_N);
4723
4724 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4725 gpio_free(GPIO_PWR_MON_ENABLE);
4726
4727 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4728 gpio_free(GPIO_EPM_LVLSFT_EN);
4729
4730 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4731 gpio_free(GPIO_EPM_5V_BOOST_EN);
4732
4733 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4734 gpio_free(GPIO_EPM_3_3V_EN);
4735
4736 rc = regulator_disable(vreg_adc_epm1);
4737 if (rc)
4738 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4739 "Error while enabling regulator for epm s3 %d\n", rc);
4740 regulator_put(vreg_adc_epm1);
4741
4742 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4743 return rc;
4744};
4745
4746unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4747{
4748 int rc = 0;
4749
4750 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4751 cs_enable);
4752
4753 if (cs_enable < 16) {
4754 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4755 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4756 } else {
4757 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4758 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4759 }
4760 return rc;
4761};
4762
4763unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4764{
4765 int rc = 0;
4766
4767 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4768
4769 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4770
4771 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4772
4773 return rc;
4774};
4775#endif
4776
4777static struct msm_adc_channels msm_adc_channels_data[] = {
4778 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4779 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4780 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4781 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4782 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4783 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4784 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4785 CHAN_PATH_TYPE4,
4786 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4787 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4788 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4789 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4790 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4791 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4792 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4793 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4794 CHAN_PATH_TYPE12,
4795 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4796 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4797 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4798 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4799 CHAN_PATH_TYPE_NONE,
4800 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4801 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4802 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4803 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4804 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4805 scale_xtern_chgr_cur},
4806 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4807 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4808 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4809 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4810 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4811 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4812 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4813 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4814 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4815 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4816 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4817 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4818};
4819
4820static char *msm_adc_fluid_device_names[] = {
4821 "ADS_ADC1",
4822 "ADS_ADC2",
4823};
4824
4825static struct msm_adc_platform_data msm_adc_pdata = {
4826 .channel = msm_adc_channels_data,
4827 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4828#if defined(CONFIG_I2C) && \
4829 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4830 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4831 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4832 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4833 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4834#endif
4835};
4836
4837static struct platform_device msm_adc_device = {
4838 .name = "msm_adc",
4839 .id = -1,
4840 .dev = {
4841 .platform_data = &msm_adc_pdata,
4842 },
4843};
4844
4845static void pmic8058_xoadc_mpp_config(void)
4846{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304847 int rc, i;
4848 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304849 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304850 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304851 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304852 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304853 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304854 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304855 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304856 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304857 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304858 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304859 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4860 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304861 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004862
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304863 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4864 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4865 &xoadc_mpps[i].config);
4866 if (rc) {
4867 pr_err("%s: Config MPP %d of PM8058 failed\n",
4868 __func__, xoadc_mpps[i].mpp);
4869 }
4870 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004871}
4872
4873static struct regulator *vreg_ldo18_adc;
4874
4875static int pmic8058_xoadc_vreg_config(int on)
4876{
4877 int rc;
4878
4879 if (on) {
4880 rc = regulator_enable(vreg_ldo18_adc);
4881 if (rc)
4882 pr_err("%s: Enable of regulator ldo18_adc "
4883 "failed\n", __func__);
4884 } else {
4885 rc = regulator_disable(vreg_ldo18_adc);
4886 if (rc)
4887 pr_err("%s: Disable of regulator ldo18_adc "
4888 "failed\n", __func__);
4889 }
4890
4891 return rc;
4892}
4893
4894static int pmic8058_xoadc_vreg_setup(void)
4895{
4896 int rc;
4897
4898 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4899 if (IS_ERR(vreg_ldo18_adc)) {
4900 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4901 __func__, PTR_ERR(vreg_ldo18_adc));
4902 rc = PTR_ERR(vreg_ldo18_adc);
4903 goto fail;
4904 }
4905
4906 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4907 if (rc) {
4908 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4909 goto fail;
4910 }
4911
4912 return rc;
4913fail:
4914 regulator_put(vreg_ldo18_adc);
4915 return rc;
4916}
4917
4918static void pmic8058_xoadc_vreg_shutdown(void)
4919{
4920 regulator_put(vreg_ldo18_adc);
4921}
4922
4923/* usec. For this ADC,
4924 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4925 * Each channel has different configuration, thus at the time of starting
4926 * the conversion, xoadc will return actual conversion time
4927 * */
4928static struct adc_properties pm8058_xoadc_data = {
4929 .adc_reference = 2200, /* milli-voltage for this adc */
4930 .bitresolution = 15,
4931 .bipolar = 0,
4932 .conversiontime = 54,
4933};
4934
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304935static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004936 .xoadc_prop = &pm8058_xoadc_data,
4937 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4938 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4939 .xoadc_num = XOADC_PMIC_0,
4940 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4941 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4942};
4943#endif
4944
4945#ifdef CONFIG_MSM_SDIO_AL
4946
4947static unsigned mdm2ap_status = 140;
4948
4949static int configure_mdm2ap_status(int on)
4950{
4951 int ret = 0;
4952 if (on)
4953 ret = msm_gpiomux_get(mdm2ap_status);
4954 else
4955 ret = msm_gpiomux_put(mdm2ap_status);
4956
4957 if (ret)
4958 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4959 on);
4960
4961 return ret;
4962}
4963
4964
4965static int get_mdm2ap_status(void)
4966{
4967 return gpio_get_value(mdm2ap_status);
4968}
4969
4970static struct sdio_al_platform_data sdio_al_pdata = {
4971 .config_mdm2ap_status = configure_mdm2ap_status,
4972 .get_mdm2ap_status = get_mdm2ap_status,
4973 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004974 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004975 .peer_sdioc_version_major = 0x0004,
4976 .peer_sdioc_boot_version_minor = 0x0001,
4977 .peer_sdioc_boot_version_major = 0x0003
4978};
4979
4980struct platform_device msm_device_sdio_al = {
4981 .name = "msm_sdio_al",
4982 .id = -1,
4983 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004984 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004985 .platform_data = &sdio_al_pdata,
4986 },
4987};
4988
4989#endif /* CONFIG_MSM_SDIO_AL */
4990
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304991#define GPIO_VREG_ID_EXT_5V 0
4992
4993static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4994 REGULATOR_SUPPLY("ext_5v", NULL),
4995 REGULATOR_SUPPLY("8901_mpp0", NULL),
4996};
4997
4998#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4999 [GPIO_VREG_ID_##_id] = { \
5000 .init_data = { \
5001 .constraints = { \
5002 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5003 }, \
5004 .num_consumer_supplies = \
5005 ARRAY_SIZE(vreg_consumers_##_id), \
5006 .consumer_supplies = vreg_consumers_##_id, \
5007 }, \
5008 .regulator_name = _reg_name, \
5009 .active_low = _active_low, \
5010 .gpio_label = _gpio_label, \
5011 .gpio = _gpio, \
5012 }
5013
5014/* GPIO regulator constraints */
5015static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5016 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5017 PM8901_MPP_PM_TO_SYS(0), 0),
5018};
5019
5020/* GPIO regulator */
5021static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5022 .name = GPIO_REGULATOR_DEV_NAME,
5023 .id = PM8901_MPP_PM_TO_SYS(0),
5024 .dev = {
5025 .platform_data =
5026 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5027 },
5028};
5029
5030static void __init pm8901_vreg_mpp0_init(void)
5031{
5032 int rc;
5033
5034 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5035 .mpp = PM8901_MPP_PM_TO_SYS(0),
5036 .config = {
5037 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5038 .level = PM8901_MPP_DIG_LEVEL_VPH,
5039 },
5040 };
5041
5042 /*
5043 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5044 * implies that the regulator connected to MPP0 is enabled when
5045 * MPP0 is low.
5046 */
5047 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5048 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5049 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5050 } else {
5051 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5052 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5053 }
5054
5055 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5056 if (rc)
5057 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5058}
5059
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005060static struct platform_device *charm_devices[] __initdata = {
5061 &msm_charm_modem,
5062#ifdef CONFIG_MSM_SDIO_AL
5063 &msm_device_sdio_al,
5064#endif
5065};
5066
Lei Zhou338cab82011-08-19 13:38:17 -04005067#ifdef CONFIG_SND_SOC_MSM8660_APQ
5068static struct platform_device *dragon_alsa_devices[] __initdata = {
5069 &msm_pcm,
5070 &msm_pcm_routing,
5071 &msm_cpudai0,
5072 &msm_cpudai1,
5073 &msm_cpudai_hdmi_rx,
5074 &msm_cpudai_bt_rx,
5075 &msm_cpudai_bt_tx,
5076 &msm_cpudai_fm_rx,
5077 &msm_cpudai_fm_tx,
5078 &msm_cpu_fe,
5079 &msm_stub_codec,
5080 &msm_lpa_pcm,
5081};
5082#endif
5083
5084static struct platform_device *asoc_devices[] __initdata = {
5085 &asoc_msm_pcm,
5086 &asoc_msm_dai0,
5087 &asoc_msm_dai1,
5088};
5089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005090static struct platform_device *surf_devices[] __initdata = {
5091 &msm_device_smd,
5092 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005093 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005094 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005095 &msm_pil_tzapps,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005096#ifdef CONFIG_I2C_QUP
5097 &msm_gsbi3_qup_i2c_device,
5098 &msm_gsbi4_qup_i2c_device,
5099 &msm_gsbi7_qup_i2c_device,
5100 &msm_gsbi8_qup_i2c_device,
5101 &msm_gsbi9_qup_i2c_device,
5102 &msm_gsbi12_qup_i2c_device,
5103#endif
5104#ifdef CONFIG_SERIAL_MSM_HS
5105 &msm_device_uart_dm1,
5106#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305107#ifdef CONFIG_MSM_SSBI
5108 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305109 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305110#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005111#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005112 &msm_device_ssbi3,
5113#endif
5114#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5115 &isp1763_device,
5116#endif
5117
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005118#if defined (CONFIG_MSM_8x60_VOIP)
5119 &asoc_msm_mvs,
5120 &asoc_mvs_dai0,
5121 &asoc_mvs_dai1,
5122#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005124#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
5125 &msm_device_otg,
5126#endif
5127#ifdef CONFIG_USB_GADGET_MSM_72K
5128 &msm_device_gadget_peripheral,
5129#endif
5130#ifdef CONFIG_USB_G_ANDROID
5131 &android_usb_device,
5132#endif
5133#ifdef CONFIG_BATTERY_MSM
5134 &msm_batt_device,
5135#endif
5136#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005137#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005138 &android_pmem_device,
5139 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005140 &android_pmem_smipool_device,
5141#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005142 &android_pmem_audio_device,
5143#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005144#ifdef CONFIG_MSM_ROTATOR
5145 &msm_rotator_device,
5146#endif
5147 &msm_fb_device,
5148 &msm_kgsl_3d0,
5149 &msm_kgsl_2d0,
5150 &msm_kgsl_2d1,
5151 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005152#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5153 &lcdc_nt35582_panel_device,
5154#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005155#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5156 &lcdc_samsung_oled_panel_device,
5157#endif
5158#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5159 &lcdc_auo_wvga_panel_device,
5160#endif
5161#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5162 &hdmi_msm_device,
5163#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5164#ifdef CONFIG_FB_MSM_MIPI_DSI
5165 &mipi_dsi_toshiba_panel_device,
5166 &mipi_dsi_novatek_panel_device,
5167#endif
5168#ifdef CONFIG_MSM_CAMERA
5169#ifdef CONFIG_MT9E013
5170 &msm_camera_sensor_mt9e013,
5171#endif
5172#ifdef CONFIG_IMX074
5173 &msm_camera_sensor_imx074,
5174#endif
5175#ifdef CONFIG_WEBCAM_OV7692
5176 &msm_camera_sensor_webcam_ov7692,
5177#endif
5178#ifdef CONFIG_WEBCAM_OV9726
5179 &msm_camera_sensor_webcam_ov9726,
5180#endif
5181#ifdef CONFIG_QS_S5K4E1
5182 &msm_camera_sensor_qs_s5k4e1,
5183#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005184#ifdef CONFIG_VX6953
5185 &msm_camera_sensor_vx6953,
5186#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005187#endif
5188#ifdef CONFIG_MSM_GEMINI
5189 &msm_gemini_device,
5190#endif
5191#ifdef CONFIG_MSM_VPE
5192 &msm_vpe_device,
5193#endif
5194
5195#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
5196 &msm_rpm_log_device,
5197#endif
5198#if defined(CONFIG_MSM_RPM_STATS_LOG)
5199 &msm_rpm_stat_device,
5200#endif
5201 &msm_device_vidc,
5202#if (defined(CONFIG_MARIMBA_CORE)) && \
5203 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5204 &msm_bt_power_device,
5205#endif
5206#ifdef CONFIG_SENSORS_MSM_ADC
5207 &msm_adc_device,
5208#endif
David Collins6f032ba2011-08-31 14:08:15 -07005209 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005210
5211#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5212 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5213 &qcrypto_device,
5214#endif
5215
5216#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5217 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5218 &qcedev_device,
5219#endif
5220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005221
5222#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5223#ifdef CONFIG_MSM_USE_TSIF1
5224 &msm_device_tsif[1],
5225#else
5226 &msm_device_tsif[0],
5227#endif /* CONFIG_MSM_USE_TSIF1 */
5228#endif /* CONFIG_TSIF */
5229
5230#ifdef CONFIG_HW_RANDOM_MSM
5231 &msm_device_rng,
5232#endif
5233
5234 &msm_tsens_device,
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06005235 &msm_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005236#ifdef CONFIG_ION_MSM
5237 &ion_dev,
5238#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005239 &msm8660_device_watchdog,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240};
5241
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005242#ifdef CONFIG_ION_MSM
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005243static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005244 .nr = MSM_ION_HEAP_NUM,
5245 .heaps = {
5246 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005247 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005248 .type = ION_HEAP_TYPE_SYSTEM,
5249 .name = ION_VMALLOC_HEAP_NAME,
5250 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005251#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5252 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005253 .id = ION_SF_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005254 .type = ION_HEAP_TYPE_CARVEOUT,
Olav Hauganb5be7992011-11-18 14:29:02 -08005255 .name = ION_SF_HEAP_NAME,
5256 .size = MSM_ION_SF_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005257 .memory_type = ION_EBI_TYPE,
5258 },
5259 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005260 .id = ION_CP_MM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005261 .type = ION_HEAP_TYPE_CARVEOUT,
Olav Hauganb5be7992011-11-18 14:29:02 -08005262 .name = ION_MM_HEAP_NAME,
5263 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005264 .memory_type = ION_SMI_TYPE,
Olav Hauganee0f7802011-12-19 13:28:57 -08005265 .request_region = request_smi_region,
5266 .release_region = release_smi_region,
5267 .setup_region = setup_smi_region,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005268 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005269 {
5270 .id = ION_CAMERA_HEAP_ID,
5271 .type = ION_HEAP_TYPE_CARVEOUT,
5272 .name = ION_CAMERA_HEAP_NAME,
5273 .size = MSM_ION_CAMERA_SIZE,
5274 .memory_type = ION_EBI_TYPE,
5275 },
5276 {
5277 .id = ION_CP_MFC_HEAP_ID,
5278 .type = ION_HEAP_TYPE_CARVEOUT,
5279 .name = ION_MFC_HEAP_NAME,
5280 .size = MSM_ION_MFC_SIZE,
5281 .memory_type = ION_SMI_TYPE,
5282 .request_region = request_smi_region,
5283 .release_region = release_smi_region,
5284 .setup_region = setup_smi_region,
5285 },
5286 {
5287 .id = ION_CP_WB_HEAP_ID,
5288 .type = ION_HEAP_TYPE_CARVEOUT,
5289 .name = ION_WB_HEAP_NAME,
5290 .size = MSM_ION_WB_SIZE,
5291 .memory_type = ION_EBI_TYPE,
5292 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005293#endif
5294 }
5295};
5296
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005297static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005298 .name = "ion-msm",
5299 .id = 1,
5300 .dev = { .platform_data = &ion_pdata },
5301};
5302#endif
5303
5304
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005305static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5306 /* Kernel SMI memory pool for video core, used for firmware */
5307 /* and encoder, decoder scratch buffers */
5308 /* Kernel SMI memory pool should always precede the user space */
5309 /* SMI memory pool, as the video core will use offset address */
5310 /* from the Firmware base */
5311 [MEMTYPE_SMI_KERNEL] = {
5312 .start = KERNEL_SMI_BASE,
5313 .limit = KERNEL_SMI_SIZE,
5314 .size = KERNEL_SMI_SIZE,
5315 .flags = MEMTYPE_FLAGS_FIXED,
5316 },
5317 /* User space SMI memory pool for video core */
5318 /* used for encoder, decoder input & output buffers */
5319 [MEMTYPE_SMI] = {
5320 .start = USER_SMI_BASE,
5321 .limit = USER_SMI_SIZE,
5322 .flags = MEMTYPE_FLAGS_FIXED,
5323 },
5324 [MEMTYPE_EBI0] = {
5325 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5326 },
5327 [MEMTYPE_EBI1] = {
5328 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5329 },
5330};
5331
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005332static void reserve_ion_memory(void)
5333{
5334#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Olav Hauganb5be7992011-11-18 14:29:02 -08005335 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
5336 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MM_SIZE;
5337 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_MFC_SIZE;
5338 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5339 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005340#endif
5341}
5342
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005343static void __init size_pmem_devices(void)
5344{
5345#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005346#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005347 android_pmem_adsp_pdata.size = pmem_adsp_size;
5348 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005349 android_pmem_pdata.size = pmem_sf_size;
5350#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005351 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
5352#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005353}
5354
5355static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5356{
5357 msm8x60_reserve_table[p->memory_type].size += p->size;
5358}
5359
5360static void __init reserve_pmem_memory(void)
5361{
5362#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005363#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005364 reserve_memory_for(&android_pmem_adsp_pdata);
5365 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005366 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005367#endif
5368 reserve_memory_for(&android_pmem_audio_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005369 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
5370#endif
5371}
5372
Huaibin Yanga5419422011-12-08 23:52:10 -08005373static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005374
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005375static void __init msm8x60_calculate_reserve_sizes(void)
5376{
5377 size_pmem_devices();
5378 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005379 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005380 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005381}
5382
5383static int msm8x60_paddr_to_memtype(unsigned int paddr)
5384{
5385 if (paddr >= 0x40000000 && paddr < 0x60000000)
5386 return MEMTYPE_EBI1;
5387 if (paddr >= 0x38000000 && paddr < 0x40000000)
5388 return MEMTYPE_SMI;
5389 return MEMTYPE_NONE;
5390}
5391
5392static struct reserve_info msm8x60_reserve_info __initdata = {
5393 .memtype_reserve_table = msm8x60_reserve_table,
5394 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5395 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5396};
5397
5398static void __init msm8x60_reserve(void)
5399{
5400 reserve_info = &msm8x60_reserve_info;
5401 msm_reserve();
5402}
5403
5404#define EXT_CHG_VALID_MPP 10
5405#define EXT_CHG_VALID_MPP_2 11
5406
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305407static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305408 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305409 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305410 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305411 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5412};
5413
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005414#ifdef CONFIG_ISL9519_CHARGER
5415static int isl_detection_setup(void)
5416{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305417 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005418
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305419 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5420 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5421 &isl_mpp[i].config);
5422 if (ret) {
5423 pr_err("%s: Config MPP %d of PM8058 failed\n",
5424 __func__, isl_mpp[i].mpp);
5425 return ret;
5426 }
5427 }
5428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005429 return ret;
5430}
5431
5432static struct isl_platform_data isl_data __initdata = {
5433 .chgcurrent = 700,
5434 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5435 .chg_detection_config = isl_detection_setup,
5436 .max_system_voltage = 4200,
5437 .min_system_voltage = 3200,
5438 .term_current = 120,
5439 .input_current = 2048,
5440};
5441
5442static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5443 {
5444 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305445 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005446 .platform_data = &isl_data,
5447 },
5448};
5449#endif
5450
5451#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5452static int smb137b_detection_setup(void)
5453{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305454 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305456 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5457 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5458 &isl_mpp[i].config);
5459 if (ret) {
5460 pr_err("%s: Config MPP %d of PM8058 failed\n",
5461 __func__, isl_mpp[i].mpp);
5462 return ret;
5463 }
5464 }
5465
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005466 return ret;
5467}
5468
5469static struct smb137b_platform_data smb137b_data __initdata = {
5470 .chg_detection_config = smb137b_detection_setup,
5471 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5472 .batt_mah_rating = 950,
5473};
5474
5475static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5476 {
5477 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305478 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005479 .platform_data = &smb137b_data,
5480 },
5481};
5482#endif
5483
5484#ifdef CONFIG_PMIC8058
5485#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305486#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005487
5488static int pm8058_gpios_init(void)
5489{
5490 int i;
5491 int rc;
5492 struct pm8058_gpio_cfg {
5493 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305494 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005495 };
5496
5497 struct pm8058_gpio_cfg gpio_cfgs[] = {
5498 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305499 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005500 {
5501 .direction = PM_GPIO_DIR_IN,
5502 .pull = PM_GPIO_PULL_DN,
5503 .vin_sel = 2,
5504 .function = PM_GPIO_FUNC_NORMAL,
5505 .inv_int_pol = 0,
5506 },
5507 },
5508#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5509 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305510 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005511 {
5512 .direction = PM_GPIO_DIR_IN,
5513 .pull = PM_GPIO_PULL_UP_30,
5514 .vin_sel = 2,
5515 .function = PM_GPIO_FUNC_NORMAL,
5516 .inv_int_pol = 0,
5517 },
5518 },
5519#endif
5520 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305521 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522 {
5523 .direction = PM_GPIO_DIR_IN,
5524 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305525 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005526 .function = PM_GPIO_FUNC_NORMAL,
5527 .inv_int_pol = 0,
5528 },
5529 },
5530 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305531 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532 {
5533 .direction = PM_GPIO_DIR_IN,
5534 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305535 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005536 .function = PM_GPIO_FUNC_NORMAL,
5537 .inv_int_pol = 0,
5538 },
5539 },
5540 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305541 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005542 {
5543 .direction = PM_GPIO_DIR_IN,
5544 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305545 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005546 .function = PM_GPIO_FUNC_NORMAL,
5547 .inv_int_pol = 0,
5548 },
5549 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005550 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305551 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005552 {
5553 .direction = PM_GPIO_DIR_OUT,
5554 .output_value = 1,
5555 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5556 .pull = PM_GPIO_PULL_DN,
5557 .out_strength = PM_GPIO_STRENGTH_HIGH,
5558 .function = PM_GPIO_FUNC_NORMAL,
5559 .vin_sel = 2,
5560 .inv_int_pol = 0,
5561 }
5562 },
5563 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305564 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005565 {
5566 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305567 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005568 .function = PM_GPIO_FUNC_NORMAL,
5569 .vin_sel = 2,
5570 .inv_int_pol = 0,
5571 }
5572 },
5573 };
5574
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305575#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5576 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305577 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305578 .direction = PM_GPIO_DIR_IN,
5579 .pull = PM_GPIO_PULL_UP_1P5,
5580 .vin_sel = 2,
5581 .function = PM_GPIO_FUNC_NORMAL,
5582 };
5583#endif
5584
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005585#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305586 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305587 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305588 .direction = PM_GPIO_DIR_OUT,
5589 .pull = PM_GPIO_PULL_NO,
5590 .out_strength = PM_GPIO_STRENGTH_HIGH,
5591 .function = PM_GPIO_FUNC_NORMAL,
5592 .inv_int_pol = 0,
5593 .vin_sel = 2,
5594 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5595 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596 };
5597#endif
5598
5599#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5600 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305601 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602 {
5603 .direction = PM_GPIO_DIR_IN,
5604 .pull = PM_GPIO_PULL_UP_1P5,
5605 .vin_sel = 2,
5606 .function = PM_GPIO_FUNC_NORMAL,
5607 .inv_int_pol = 0,
5608 }
5609 };
5610#endif
5611
5612#if defined(CONFIG_QS_S5K4E1)
5613 {
5614 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305615 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616 {
5617 .direction = PM_GPIO_DIR_OUT,
5618 .output_value = 0,
5619 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5620 .pull = PM_GPIO_PULL_DN,
5621 .out_strength = PM_GPIO_STRENGTH_HIGH,
5622 .function = PM_GPIO_FUNC_NORMAL,
5623 .vin_sel = 2,
5624 .inv_int_pol = 0,
5625 }
5626 };
5627#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005628#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5629 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305630 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005631 {
5632 .direction = PM_GPIO_DIR_OUT,
5633 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5634 .output_value = 1,
5635 .pull = PM_GPIO_PULL_UP_30,
5636 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305637 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005638 .out_strength = PM_GPIO_STRENGTH_HIGH,
5639 .function = PM_GPIO_FUNC_NORMAL,
5640 .inv_int_pol = 0,
5641 }
5642 };
5643#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005644#if defined(CONFIG_HAPTIC_ISA1200) || \
5645 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5646 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305647 rc = pm8xxx_gpio_config(
5648 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5649 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005650 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305651 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005652 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305653 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305654 rc = pm8xxx_gpio_config(
5655 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5656 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305657 if (rc < 0) {
5658 pr_err("%s: pmic haptics ldo gpio config failed\n",
5659 __func__);
5660 }
5661
5662 }
5663#endif
5664
5665#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5666 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5667 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5668 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305669 rc = pm8xxx_gpio_config(
5670 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5671 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305672 if (rc < 0) {
5673 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5674 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005675 }
5676 }
5677#endif
5678
5679#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5680 /* Line_in only for 8660 ffa & surf */
5681 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005682 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005683 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305684 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005685 &line_in_gpio_cfg.cfg);
5686 if (rc < 0) {
5687 pr_err("%s pmic line_in gpio config failed\n",
5688 __func__);
5689 return rc;
5690 }
5691 }
5692#endif
5693
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005694#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5695 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305696 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005697 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5698 if (rc < 0) {
5699 pr_err("%s pmic gpio config failed\n", __func__);
5700 return rc;
5701 }
5702 }
5703#endif
5704
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005705#if defined(CONFIG_QS_S5K4E1)
5706 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5707 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305708 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005709 &qs_hc37_cam_pd_gpio_cfg.cfg);
5710 if (rc < 0) {
5711 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5712 __func__);
5713 return rc;
5714 }
5715 }
5716 }
5717#endif
5718
5719 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305720 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005721 &gpio_cfgs[i].cfg);
5722 if (rc < 0) {
5723 pr_err("%s pmic gpio config failed\n",
5724 __func__);
5725 return rc;
5726 }
5727 }
5728
5729 return 0;
5730}
5731
5732static const unsigned int ffa_keymap[] = {
5733 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5734 KEY(0, 1, KEY_UP), /* NAV - UP */
5735 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5736 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5737
5738 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5739 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5740 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5741 KEY(1, 3, KEY_VOLUMEDOWN),
5742
5743 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5744
5745 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5746 KEY(4, 1, KEY_UP), /* USER_UP */
5747 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5748 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5749 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5750
5751 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5752 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5753 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5754 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5755 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5756};
5757
Zhang Chang Ken683be172011-08-10 17:45:34 -04005758static const unsigned int dragon_keymap[] = {
5759 KEY(0, 0, KEY_MENU),
5760 KEY(0, 2, KEY_1),
5761 KEY(0, 3, KEY_4),
5762 KEY(0, 4, KEY_7),
5763
5764 KEY(1, 0, KEY_UP),
5765 KEY(1, 1, KEY_LEFT),
5766 KEY(1, 2, KEY_DOWN),
5767 KEY(1, 3, KEY_5),
5768 KEY(1, 4, KEY_8),
5769
5770 KEY(2, 0, KEY_HOME),
5771 KEY(2, 1, KEY_REPLY),
5772 KEY(2, 2, KEY_2),
5773 KEY(2, 3, KEY_6),
5774 KEY(2, 4, KEY_0),
5775
5776 KEY(3, 0, KEY_VOLUMEUP),
5777 KEY(3, 1, KEY_RIGHT),
5778 KEY(3, 2, KEY_3),
5779 KEY(3, 3, KEY_9),
5780 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5781
5782 KEY(4, 0, KEY_VOLUMEDOWN),
5783 KEY(4, 1, KEY_BACK),
5784 KEY(4, 2, KEY_CAMERA),
5785 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5786};
5787
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788static struct matrix_keymap_data ffa_keymap_data = {
5789 .keymap_size = ARRAY_SIZE(ffa_keymap),
5790 .keymap = ffa_keymap,
5791};
5792
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305793static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794 .input_name = "ffa-keypad",
5795 .input_phys_device = "ffa-keypad/input0",
5796 .num_rows = 6,
5797 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305798 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5799 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5800 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005801 .scan_delay_ms = 32,
5802 .row_hold_ns = 91500,
5803 .wakeup = 1,
5804 .keymap_data = &ffa_keymap_data,
5805};
5806
Zhang Chang Ken683be172011-08-10 17:45:34 -04005807static struct matrix_keymap_data dragon_keymap_data = {
5808 .keymap_size = ARRAY_SIZE(dragon_keymap),
5809 .keymap = dragon_keymap,
5810};
5811
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305812static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005813 .input_name = "dragon-keypad",
5814 .input_phys_device = "dragon-keypad/input0",
5815 .num_rows = 6,
5816 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305817 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5818 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5819 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005820 .scan_delay_ms = 32,
5821 .row_hold_ns = 91500,
5822 .wakeup = 1,
5823 .keymap_data = &dragon_keymap_data,
5824};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305825
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005826static const unsigned int fluid_keymap[] = {
5827 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5828 KEY(0, 1, KEY_UP), /* NAV - UP */
5829 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5830 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5831
5832 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5833 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5834 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5835 KEY(1, 3, KEY_VOLUMEUP),
5836
5837 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5838
5839 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5840 KEY(4, 1, KEY_UP), /* USER_UP */
5841 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5842 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5843 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5844
Jilai Wang9a895102011-07-12 14:00:35 -04005845 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005846 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5847 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5848 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5849 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5850};
5851
5852static struct matrix_keymap_data fluid_keymap_data = {
5853 .keymap_size = ARRAY_SIZE(fluid_keymap),
5854 .keymap = fluid_keymap,
5855};
5856
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305857static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005858 .input_name = "fluid-keypad",
5859 .input_phys_device = "fluid-keypad/input0",
5860 .num_rows = 6,
5861 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305862 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5863 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5864 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005865 .scan_delay_ms = 32,
5866 .row_hold_ns = 91500,
5867 .wakeup = 1,
5868 .keymap_data = &fluid_keymap_data,
5869};
5870
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305871static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005872 .initial_vibrate_ms = 500,
5873 .level_mV = 3000,
5874 .max_timeout_ms = 15000,
5875};
5876
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305877static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
5878 .rtc_write_enable = false,
5879 .rtc_alarm_powerup = false,
5880};
5881
5882static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
5883 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08005884 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305885 .wakeup = 1,
5886};
5887
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005888#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5889
5890static struct othc_accessory_info othc_accessories[] = {
5891 {
5892 .accessory = OTHC_SVIDEO_OUT,
5893 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5894 | OTHC_ADC_DETECT,
5895 .key_code = SW_VIDEOOUT_INSERT,
5896 .enabled = false,
5897 .adc_thres = {
5898 .min_threshold = 20,
5899 .max_threshold = 40,
5900 },
5901 },
5902 {
5903 .accessory = OTHC_ANC_HEADPHONE,
5904 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5905 OTHC_SWITCH_DETECT,
5906 .gpio = PM8058_LINE_IN_DET_GPIO,
5907 .active_low = 1,
5908 .key_code = SW_HEADPHONE_INSERT,
5909 .enabled = true,
5910 },
5911 {
5912 .accessory = OTHC_ANC_HEADSET,
5913 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5914 .gpio = PM8058_LINE_IN_DET_GPIO,
5915 .active_low = 1,
5916 .key_code = SW_HEADPHONE_INSERT,
5917 .enabled = true,
5918 },
5919 {
5920 .accessory = OTHC_HEADPHONE,
5921 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
5922 .key_code = SW_HEADPHONE_INSERT,
5923 .enabled = true,
5924 },
5925 {
5926 .accessory = OTHC_MICROPHONE,
5927 .detect_flags = OTHC_GPIO_DETECT,
5928 .gpio = PM8058_LINE_IN_DET_GPIO,
5929 .active_low = 1,
5930 .key_code = SW_MICROPHONE_INSERT,
5931 .enabled = true,
5932 },
5933 {
5934 .accessory = OTHC_HEADSET,
5935 .detect_flags = OTHC_MICBIAS_DETECT,
5936 .key_code = SW_HEADPHONE_INSERT,
5937 .enabled = true,
5938 },
5939};
5940
5941static struct othc_switch_info switch_info[] = {
5942 {
5943 .min_adc_threshold = 0,
5944 .max_adc_threshold = 100,
5945 .key_code = KEY_PLAYPAUSE,
5946 },
5947 {
5948 .min_adc_threshold = 100,
5949 .max_adc_threshold = 200,
5950 .key_code = KEY_REWIND,
5951 },
5952 {
5953 .min_adc_threshold = 200,
5954 .max_adc_threshold = 500,
5955 .key_code = KEY_FASTFORWARD,
5956 },
5957};
5958
5959static struct othc_n_switch_config switch_config = {
5960 .voltage_settling_time_ms = 0,
5961 .num_adc_samples = 3,
5962 .adc_channel = CHANNEL_ADC_HDSET,
5963 .switch_info = switch_info,
5964 .num_keys = ARRAY_SIZE(switch_info),
5965 .default_sw_en = true,
5966 .default_sw_idx = 0,
5967};
5968
5969static struct hsed_bias_config hsed_bias_config = {
5970 /* HSED mic bias config info */
5971 .othc_headset = OTHC_HEADSET_NO,
5972 .othc_lowcurr_thresh_uA = 100,
5973 .othc_highcurr_thresh_uA = 600,
5974 .othc_hyst_prediv_us = 7800,
5975 .othc_period_clkdiv_us = 62500,
5976 .othc_hyst_clk_us = 121000,
5977 .othc_period_clk_us = 312500,
5978 .othc_wakeup = 1,
5979};
5980
5981static struct othc_hsed_config hsed_config_1 = {
5982 .hsed_bias_config = &hsed_bias_config,
5983 /*
5984 * The detection delay and switch reporting delay are
5985 * required to encounter a hardware bug (spurious switch
5986 * interrupts on slow insertion/removal of the headset).
5987 * This will introduce a delay in reporting the accessory
5988 * insertion and removal to the userspace.
5989 */
5990 .detection_delay_ms = 1500,
5991 /* Switch info */
5992 .switch_debounce_ms = 1500,
5993 .othc_support_n_switch = false,
5994 .switch_config = &switch_config,
5995 .ir_gpio = -1,
5996 /* Accessory info */
5997 .accessories_support = true,
5998 .accessories = othc_accessories,
5999 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6000};
6001
6002static struct othc_regulator_config othc_reg = {
6003 .regulator = "8058_l5",
6004 .max_uV = 2850000,
6005 .min_uV = 2850000,
6006};
6007
6008/* MIC_BIAS0 is configured as normal MIC BIAS */
6009static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6010 .micbias_select = OTHC_MICBIAS_0,
6011 .micbias_capability = OTHC_MICBIAS,
6012 .micbias_enable = OTHC_SIGNAL_OFF,
6013 .micbias_regulator = &othc_reg,
6014};
6015
6016/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6017static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6018 .micbias_select = OTHC_MICBIAS_1,
6019 .micbias_capability = OTHC_MICBIAS_HSED,
6020 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6021 .micbias_regulator = &othc_reg,
6022 .hsed_config = &hsed_config_1,
6023 .hsed_name = "8660_handset",
6024};
6025
6026/* MIC_BIAS2 is configured as normal MIC BIAS */
6027static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6028 .micbias_select = OTHC_MICBIAS_2,
6029 .micbias_capability = OTHC_MICBIAS,
6030 .micbias_enable = OTHC_SIGNAL_OFF,
6031 .micbias_regulator = &othc_reg,
6032};
6033
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006034
6035static void __init msm8x60_init_pm8058_othc(void)
6036{
6037 int i;
6038
6039 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6040 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6041 machine_is_msm8x60_fusn_ffa()) {
6042 /* 3-switch headset supported only by V2 FFA and FLUID */
6043 hsed_config_1.accessories_adc_support = true,
6044 /* ADC based accessory detection works only on V2 and FLUID */
6045 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6046 hsed_config_1.othc_support_n_switch = true;
6047 }
6048
6049 /* IR GPIO is absent on FLUID */
6050 if (machine_is_msm8x60_fluid())
6051 hsed_config_1.ir_gpio = -1;
6052
6053 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6054 if (machine_is_msm8x60_fluid()) {
6055 switch (othc_accessories[i].accessory) {
6056 case OTHC_ANC_HEADPHONE:
6057 case OTHC_ANC_HEADSET:
6058 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6059 break;
6060 case OTHC_MICROPHONE:
6061 othc_accessories[i].enabled = false;
6062 break;
6063 case OTHC_SVIDEO_OUT:
6064 othc_accessories[i].enabled = true;
6065 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6066 break;
6067 }
6068 }
6069 }
6070}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006071
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006072
6073static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6074{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306075 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006076 .direction = PM_GPIO_DIR_OUT,
6077 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6078 .output_value = 0,
6079 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306080 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006081 .out_strength = PM_GPIO_STRENGTH_HIGH,
6082 .function = PM_GPIO_FUNC_2,
6083 };
6084
6085 int rc = -EINVAL;
6086 int id, mode, max_mA;
6087
6088 id = mode = max_mA = 0;
6089 switch (ch) {
6090 case 0:
6091 case 1:
6092 case 2:
6093 if (on) {
6094 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306095 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6096 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006097 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306098 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006099 __func__, id, rc);
6100 }
6101 break;
6102
6103 case 6:
6104 id = PM_PWM_LED_FLASH;
6105 mode = PM_PWM_CONF_PWM1;
6106 max_mA = 300;
6107 break;
6108
6109 case 7:
6110 id = PM_PWM_LED_FLASH1;
6111 mode = PM_PWM_CONF_PWM1;
6112 max_mA = 300;
6113 break;
6114
6115 default:
6116 break;
6117 }
6118
6119 if (ch >= 6 && ch <= 7) {
6120 if (!on) {
6121 mode = PM_PWM_CONF_NONE;
6122 max_mA = 0;
6123 }
6124 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6125 if (rc)
6126 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6127 __func__, ch, rc);
6128 }
6129 return rc;
6130
6131}
6132
6133static struct pm8058_pwm_pdata pm8058_pwm_data = {
6134 .config = pm8058_pwm_config,
6135};
6136
6137#define PM8058_GPIO_INT 88
6138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006139static struct pmic8058_led pmic8058_flash_leds[] = {
6140 [0] = {
6141 .name = "camera:flash0",
6142 .max_brightness = 15,
6143 .id = PMIC8058_ID_FLASH_LED_0,
6144 },
6145 [1] = {
6146 .name = "camera:flash1",
6147 .max_brightness = 15,
6148 .id = PMIC8058_ID_FLASH_LED_1,
6149 },
6150};
6151
6152static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6153 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6154 .leds = pmic8058_flash_leds,
6155};
6156
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006157static struct pmic8058_led pmic8058_dragon_leds[] = {
6158 [0] = {
6159 /* RED */
6160 .name = "led_drv0",
6161 .max_brightness = 15,
6162 .id = PMIC8058_ID_LED_0,
6163 },/* 300 mA flash led0 drv sink */
6164 [1] = {
6165 /* Yellow */
6166 .name = "led_drv1",
6167 .max_brightness = 15,
6168 .id = PMIC8058_ID_LED_1,
6169 },/* 300 mA flash led0 drv sink */
6170 [2] = {
6171 /* Green */
6172 .name = "led_drv2",
6173 .max_brightness = 15,
6174 .id = PMIC8058_ID_LED_2,
6175 },/* 300 mA flash led0 drv sink */
6176 [3] = {
6177 .name = "led_psensor",
6178 .max_brightness = 15,
6179 .id = PMIC8058_ID_LED_KB_LIGHT,
6180 },/* 300 mA flash led0 drv sink */
6181};
6182
6183static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6184 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6185 .leds = pmic8058_dragon_leds,
6186};
6187
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006188static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6189 [0] = {
6190 .name = "led:drv0",
6191 .max_brightness = 15,
6192 .id = PMIC8058_ID_FLASH_LED_0,
6193 },/* 300 mA flash led0 drv sink */
6194 [1] = {
6195 .name = "led:drv1",
6196 .max_brightness = 15,
6197 .id = PMIC8058_ID_FLASH_LED_1,
6198 },/* 300 mA flash led1 sink */
6199 [2] = {
6200 .name = "led:drv2",
6201 .max_brightness = 20,
6202 .id = PMIC8058_ID_LED_0,
6203 },/* 40 mA led0 sink */
6204 [3] = {
6205 .name = "keypad:drv",
6206 .max_brightness = 15,
6207 .id = PMIC8058_ID_LED_KB_LIGHT,
6208 },/* 300 mA keypad drv sink */
6209};
6210
6211static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6212 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6213 .leds = pmic8058_fluid_flash_leds,
6214};
6215
Terence Hampson90508a92011-08-09 10:40:08 -04006216static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306217 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006218 .max_source_current = 1800,
6219 .charger_type = CHG_TYPE_AC,
6220};
6221
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306222static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6223 .charger_data_valid = false,
6224};
6225
6226static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6227 .priority = 0,
6228};
6229
6230static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6231 .irq_base = PM8058_IRQ_BASE,
6232 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6233 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6234};
6235
6236static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6237 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6238};
6239
6240static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6241 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006242};
6243
6244static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306245 .irq_pdata = &pm8058_irq_pdata,
6246 .gpio_pdata = &pm8058_gpio_pdata,
6247 .mpp_pdata = &pm8058_mpp_pdata,
6248 .rtc_pdata = &pm8058_rtc_pdata,
6249 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6250 .othc0_pdata = &othc_config_pdata_0,
6251 .othc1_pdata = &othc_config_pdata_1,
6252 .othc2_pdata = &othc_config_pdata_2,
6253 .pwm_pdata = &pm8058_pwm_data,
6254 .misc_pdata = &pm8058_misc_pdata,
6255#ifdef CONFIG_SENSORS_MSM_ADC
6256 .xoadc_pdata = &pm8058_xoadc_pdata,
6257#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006258};
6259
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306260#ifdef CONFIG_MSM_SSBI
6261static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6262 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6263 .slave = {
6264 .name = "pm8058-core",
6265 .platform_data = &pm8058_platform_data,
6266 },
6267};
6268#endif
6269#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006270
6271#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6272 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6273#define TDISC_I2C_SLAVE_ADDR 0x67
6274#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6275#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6276
6277static const char *vregs_tdisc_name[] = {
6278 "8058_l5",
6279 "8058_s3",
6280};
6281
6282static const int vregs_tdisc_val[] = {
6283 2850000,/* uV */
6284 1800000,
6285};
6286static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6287
6288static int tdisc_shinetsu_setup(void)
6289{
6290 int rc, i;
6291
6292 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6293 if (rc) {
6294 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6295 __func__);
6296 return rc;
6297 }
6298
6299 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6300 if (rc) {
6301 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6302 __func__);
6303 goto fail_gpio_oe;
6304 }
6305
6306 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6307 if (rc) {
6308 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6309 __func__);
6310 gpio_free(GPIO_JOYSTICK_EN);
6311 goto fail_gpio_oe;
6312 }
6313
6314 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6315 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6316 if (IS_ERR(vregs_tdisc[i])) {
6317 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6318 __func__, vregs_tdisc_name[i],
6319 PTR_ERR(vregs_tdisc[i]));
6320 rc = PTR_ERR(vregs_tdisc[i]);
6321 goto vreg_get_fail;
6322 }
6323
6324 rc = regulator_set_voltage(vregs_tdisc[i],
6325 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6326 if (rc) {
6327 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6328 __func__, rc);
6329 goto vreg_set_voltage_fail;
6330 }
6331 }
6332
6333 return rc;
6334vreg_set_voltage_fail:
6335 i++;
6336vreg_get_fail:
6337 while (i)
6338 regulator_put(vregs_tdisc[--i]);
6339fail_gpio_oe:
6340 gpio_free(PMIC_GPIO_TDISC);
6341 return rc;
6342}
6343
6344static void tdisc_shinetsu_release(void)
6345{
6346 int i;
6347
6348 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6349 regulator_put(vregs_tdisc[i]);
6350
6351 gpio_free(PMIC_GPIO_TDISC);
6352 gpio_free(GPIO_JOYSTICK_EN);
6353}
6354
6355static int tdisc_shinetsu_enable(void)
6356{
6357 int i, rc = -EINVAL;
6358
6359 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6360 rc = regulator_enable(vregs_tdisc[i]);
6361 if (rc < 0) {
6362 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6363 __func__, vregs_tdisc_name[i], rc);
6364 goto vreg_fail;
6365 }
6366 }
6367
6368 /* Enable the OE (output enable) gpio */
6369 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6370 /* voltage and gpio stabilization delay */
6371 msleep(50);
6372
6373 return 0;
6374vreg_fail:
6375 while (i)
6376 regulator_disable(vregs_tdisc[--i]);
6377 return rc;
6378}
6379
6380static int tdisc_shinetsu_disable(void)
6381{
6382 int i, rc;
6383
6384 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6385 rc = regulator_disable(vregs_tdisc[i]);
6386 if (rc < 0) {
6387 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6388 __func__, vregs_tdisc_name[i], rc);
6389 goto tdisc_reg_fail;
6390 }
6391 }
6392
6393 /* Disable the OE (output enable) gpio */
6394 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6395
6396 return 0;
6397
6398tdisc_reg_fail:
6399 while (i)
6400 regulator_enable(vregs_tdisc[--i]);
6401 return rc;
6402}
6403
6404static struct tdisc_abs_values tdisc_abs = {
6405 .x_max = 32,
6406 .y_max = 32,
6407 .x_min = -32,
6408 .y_min = -32,
6409 .pressure_max = 32,
6410 .pressure_min = 0,
6411};
6412
6413static struct tdisc_platform_data tdisc_data = {
6414 .tdisc_setup = tdisc_shinetsu_setup,
6415 .tdisc_release = tdisc_shinetsu_release,
6416 .tdisc_enable = tdisc_shinetsu_enable,
6417 .tdisc_disable = tdisc_shinetsu_disable,
6418 .tdisc_wakeup = 0,
6419 .tdisc_gpio = PMIC_GPIO_TDISC,
6420 .tdisc_report_keys = true,
6421 .tdisc_report_relative = true,
6422 .tdisc_report_absolute = false,
6423 .tdisc_report_wheel = false,
6424 .tdisc_reverse_x = false,
6425 .tdisc_reverse_y = true,
6426 .tdisc_abs = &tdisc_abs,
6427};
6428
6429static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6430 {
6431 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6432 .irq = TDISC_INT,
6433 .platform_data = &tdisc_data,
6434 },
6435};
6436#endif
6437
6438#define PM_GPIO_CDC_RST_N 20
6439#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6440
6441static struct regulator *vreg_timpani_1;
6442static struct regulator *vreg_timpani_2;
6443
6444static unsigned int msm_timpani_setup_power(void)
6445{
6446 int rc;
6447
6448 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6449 if (IS_ERR(vreg_timpani_1)) {
6450 pr_err("%s: Unable to get 8058_l0\n", __func__);
6451 return -ENODEV;
6452 }
6453
6454 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6455 if (IS_ERR(vreg_timpani_2)) {
6456 pr_err("%s: Unable to get 8058_s3\n", __func__);
6457 regulator_put(vreg_timpani_1);
6458 return -ENODEV;
6459 }
6460
6461 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6462 if (rc) {
6463 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6464 goto fail;
6465 }
6466
6467 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6468 if (rc) {
6469 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6470 goto fail;
6471 }
6472
6473 rc = regulator_enable(vreg_timpani_1);
6474 if (rc) {
6475 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6476 goto fail;
6477 }
6478
6479 /* The settings for LDO0 should be set such that
6480 * it doesn't require to reset the timpani. */
6481 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6482 if (rc < 0) {
6483 pr_err("Timpani regulator optimum mode setting failed\n");
6484 goto fail;
6485 }
6486
6487 rc = regulator_enable(vreg_timpani_2);
6488 if (rc) {
6489 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6490 regulator_disable(vreg_timpani_1);
6491 goto fail;
6492 }
6493
6494 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6495 if (rc) {
6496 pr_err("%s: GPIO Request %d failed\n", __func__,
6497 GPIO_CDC_RST_N);
6498 regulator_disable(vreg_timpani_1);
6499 regulator_disable(vreg_timpani_2);
6500 goto fail;
6501 } else {
6502 gpio_direction_output(GPIO_CDC_RST_N, 1);
6503 usleep_range(1000, 1050);
6504 gpio_direction_output(GPIO_CDC_RST_N, 0);
6505 usleep_range(1000, 1050);
6506 gpio_direction_output(GPIO_CDC_RST_N, 1);
6507 gpio_free(GPIO_CDC_RST_N);
6508 }
6509 return rc;
6510
6511fail:
6512 regulator_put(vreg_timpani_1);
6513 regulator_put(vreg_timpani_2);
6514 return rc;
6515}
6516
6517static void msm_timpani_shutdown_power(void)
6518{
6519 int rc;
6520
6521 rc = regulator_disable(vreg_timpani_1);
6522 if (rc)
6523 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6524
6525 regulator_put(vreg_timpani_1);
6526
6527 rc = regulator_disable(vreg_timpani_2);
6528 if (rc)
6529 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6530
6531 regulator_put(vreg_timpani_2);
6532}
6533
6534/* Power analog function of codec */
6535static struct regulator *vreg_timpani_cdc_apwr;
6536static int msm_timpani_codec_power(int vreg_on)
6537{
6538 int rc = 0;
6539
6540 if (!vreg_timpani_cdc_apwr) {
6541
6542 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6543
6544 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6545 pr_err("%s: vreg_get failed (%ld)\n",
6546 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6547 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6548 return rc;
6549 }
6550 }
6551
6552 if (vreg_on) {
6553
6554 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6555 2200000, 2200000);
6556 if (rc) {
6557 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6558 __func__);
6559 goto vreg_fail;
6560 }
6561
6562 rc = regulator_enable(vreg_timpani_cdc_apwr);
6563 if (rc) {
6564 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6565 goto vreg_fail;
6566 }
6567 } else {
6568 rc = regulator_disable(vreg_timpani_cdc_apwr);
6569 if (rc) {
6570 pr_err("%s: vreg_disable failed %d\n",
6571 __func__, rc);
6572 goto vreg_fail;
6573 }
6574 }
6575
6576 return 0;
6577
6578vreg_fail:
6579 regulator_put(vreg_timpani_cdc_apwr);
6580 vreg_timpani_cdc_apwr = NULL;
6581 return rc;
6582}
6583
6584static struct marimba_codec_platform_data timpani_codec_pdata = {
6585 .marimba_codec_power = msm_timpani_codec_power,
6586};
6587
6588#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6589#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6590
6591static struct marimba_platform_data timpani_pdata = {
6592 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6593 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6594 .marimba_setup = msm_timpani_setup_power,
6595 .marimba_shutdown = msm_timpani_shutdown_power,
6596 .codec = &timpani_codec_pdata,
6597 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6598};
6599
6600#define TIMPANI_I2C_SLAVE_ADDR 0xD
6601
6602static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6603 {
6604 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6605 .platform_data = &timpani_pdata,
6606 },
6607};
6608
Lei Zhou338cab82011-08-19 13:38:17 -04006609#ifdef CONFIG_SND_SOC_WM8903
6610static struct wm8903_platform_data wm8903_pdata = {
6611 .gpio_cfg[2] = 0x3A8,
6612};
6613
6614#define WM8903_I2C_SLAVE_ADDR 0x34
6615static struct i2c_board_info wm8903_codec_i2c_info[] = {
6616 {
6617 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6618 .platform_data = &wm8903_pdata,
6619 },
6620};
6621#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006622#ifdef CONFIG_PMIC8901
6623
6624#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006625/*
6626 * Consumer specific regulator names:
6627 * regulator name consumer dev_name
6628 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006629static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6630 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6631};
6632static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6633 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6634};
6635
6636#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306637 _always_on) \
6638 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006639 .init_data = { \
6640 .constraints = { \
6641 .valid_modes_mask = _modes, \
6642 .valid_ops_mask = _ops, \
6643 .min_uV = _min_uV, \
6644 .max_uV = _max_uV, \
6645 .input_uV = _min_uV, \
6646 .apply_uV = _apply_uV, \
6647 .always_on = _always_on, \
6648 }, \
6649 .consumer_supplies = vreg_consumers_8901_##_id, \
6650 .num_consumer_supplies = \
6651 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6652 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306653 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006654 }
6655
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006656#define PM8901_VREG_INIT_VS(_id) \
6657 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306658 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006659
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306660static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006661 PM8901_VREG_INIT_VS(USB_OTG),
6662 PM8901_VREG_INIT_VS(HDMI_MVS),
6663};
6664
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306665static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6666 .priority = 1,
6667};
6668
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306669static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6670 .irq_base = PM8901_IRQ_BASE,
6671 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6672 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6673};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006674
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306675static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6676 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006677};
6678
6679static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306680 .irq_pdata = &pm8901_irq_pdata,
6681 .mpp_pdata = &pm8901_mpp_pdata,
6682 .regulator_pdatas = pm8901_vreg_init,
6683 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306684 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006685};
6686
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306687static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6688 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6689 .slave = {
6690 .name = "pm8901-core",
6691 .platform_data = &pm8901_platform_data,
6692 },
6693};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006694#endif /* CONFIG_PMIC8901 */
6695
6696#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6697 || defined(CONFIG_GPIO_SX150X_MODULE))
6698
6699static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006700static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006701
6702struct bahama_config_register{
6703 u8 reg;
6704 u8 value;
6705 u8 mask;
6706};
6707
6708enum version{
6709 VER_1_0,
6710 VER_2_0,
6711 VER_UNSUPPORTED = 0xFF
6712};
6713
6714static u8 read_bahama_ver(void)
6715{
6716 int rc;
6717 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6718 u8 bahama_version;
6719
6720 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6721 if (rc < 0) {
6722 printk(KERN_ERR
6723 "%s: version read failed: %d\n",
6724 __func__, rc);
6725 return VER_UNSUPPORTED;
6726 } else {
6727 printk(KERN_INFO
6728 "%s: version read got: 0x%x\n",
6729 __func__, bahama_version);
6730 }
6731
6732 switch (bahama_version) {
6733 case 0x08: /* varient of bahama v1 */
6734 case 0x10:
6735 case 0x00:
6736 return VER_1_0;
6737 case 0x09: /* variant of bahama v2 */
6738 return VER_2_0;
6739 default:
6740 return VER_UNSUPPORTED;
6741 }
6742}
6743
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006744static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006745static unsigned int msm_bahama_setup_power(void)
6746{
6747 int rc = 0;
6748 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006749
6750 if (machine_is_msm8x60_dragon())
6751 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6752
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006753 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6754
6755 if (IS_ERR(vreg_bahama)) {
6756 rc = PTR_ERR(vreg_bahama);
6757 pr_err("%s: regulator_get %s = %d\n", __func__,
6758 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006759 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006760 }
6761
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006762 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6763 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006764 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6765 msm_bahama_regulator, rc);
6766 goto unget;
6767 }
6768
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006769 rc = regulator_enable(vreg_bahama);
6770 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006771 pr_err("%s: regulator_enable %s = %d\n", __func__,
6772 msm_bahama_regulator, rc);
6773 goto unget;
6774 }
6775
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006776 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6777 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006778 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006779 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006780 goto unenable;
6781 }
6782
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006783 gpio_direction_output(msm_bahama_sys_rst, 0);
6784 usleep_range(1000, 1050);
6785 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6786 usleep_range(1000, 1050);
6787 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006788 return rc;
6789
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006790unenable:
6791 regulator_disable(vreg_bahama);
6792unget:
6793 regulator_put(vreg_bahama);
6794 return rc;
6795};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006796
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006797static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006798{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006799 if (msm_bahama_setup_power_enable) {
6800 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6801 gpio_free(msm_bahama_sys_rst);
6802 regulator_disable(vreg_bahama);
6803 regulator_put(vreg_bahama);
6804 msm_bahama_setup_power_enable = 0;
6805 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006806
6807 return 0;
6808};
6809
6810static unsigned int msm_bahama_core_config(int type)
6811{
6812 int rc = 0;
6813
6814 if (type == BAHAMA_ID) {
6815
6816 int i;
6817 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6818
6819 const struct bahama_config_register v20_init[] = {
6820 /* reg, value, mask */
6821 { 0xF4, 0x84, 0xFF }, /* AREG */
6822 { 0xF0, 0x04, 0xFF } /* DREG */
6823 };
6824
6825 if (read_bahama_ver() == VER_2_0) {
6826 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6827 u8 value = v20_init[i].value;
6828 rc = marimba_write_bit_mask(&config,
6829 v20_init[i].reg,
6830 &value,
6831 sizeof(v20_init[i].value),
6832 v20_init[i].mask);
6833 if (rc < 0) {
6834 printk(KERN_ERR
6835 "%s: reg %d write failed: %d\n",
6836 __func__, v20_init[i].reg, rc);
6837 return rc;
6838 }
6839 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6840 " mask 0x%02x\n",
6841 __func__, v20_init[i].reg,
6842 v20_init[i].value, v20_init[i].mask);
6843 }
6844 }
6845 }
6846 printk(KERN_INFO "core type: %d\n", type);
6847
6848 return rc;
6849}
6850
6851static struct regulator *fm_regulator_s3;
6852static struct msm_xo_voter *fm_clock;
6853
6854static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6855{
6856 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306857 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006858 .direction = PM_GPIO_DIR_IN,
6859 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306860 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006861 .function = PM_GPIO_FUNC_NORMAL,
6862 .inv_int_pol = 0,
6863 };
6864
6865 if (!fm_regulator_s3) {
6866 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6867 if (IS_ERR(fm_regulator_s3)) {
6868 rc = PTR_ERR(fm_regulator_s3);
6869 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6870 __func__, rc);
6871 goto out;
6872 }
6873 }
6874
6875
6876 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6877 if (rc < 0) {
6878 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6879 __func__, rc);
6880 goto fm_fail_put;
6881 }
6882
6883 rc = regulator_enable(fm_regulator_s3);
6884 if (rc < 0) {
6885 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6886 __func__, rc);
6887 goto fm_fail_put;
6888 }
6889
6890 /*Vote for XO clock*/
6891 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6892
6893 if (IS_ERR(fm_clock)) {
6894 rc = PTR_ERR(fm_clock);
6895 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6896 __func__, rc);
6897 goto fm_fail_switch;
6898 }
6899
6900 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6901 if (rc < 0) {
6902 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6903 __func__, rc);
6904 goto fm_fail_vote;
6905 }
6906
6907 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306908 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006909 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306910 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006911 __func__, rc);
6912 goto fm_fail_clock;
6913 }
6914 goto out;
6915
6916fm_fail_clock:
6917 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6918fm_fail_vote:
6919 msm_xo_put(fm_clock);
6920fm_fail_switch:
6921 regulator_disable(fm_regulator_s3);
6922fm_fail_put:
6923 regulator_put(fm_regulator_s3);
6924out:
6925 return rc;
6926};
6927
6928static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
6929{
6930 int rc = 0;
6931 if (fm_regulator_s3 != NULL) {
6932 rc = regulator_disable(fm_regulator_s3);
6933 if (rc < 0) {
6934 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
6935 __func__, rc);
6936 }
6937 regulator_put(fm_regulator_s3);
6938 fm_regulator_s3 = NULL;
6939 }
6940 printk(KERN_ERR "%s: Voting off for XO", __func__);
6941
6942 if (fm_clock != NULL) {
6943 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6944 if (rc < 0) {
6945 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
6946 __func__, rc);
6947 }
6948 msm_xo_put(fm_clock);
6949 }
6950 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
6951}
6952
6953/* Slave id address for FM/CDC/QMEMBIST
6954 * Values can be programmed using Marimba slave id 0
6955 * should there be a conflict with other I2C devices
6956 * */
6957#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
6958#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
6959
6960static struct marimba_fm_platform_data marimba_fm_pdata = {
6961 .fm_setup = fm_radio_setup,
6962 .fm_shutdown = fm_radio_shutdown,
6963 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
6964 .is_fm_soc_i2s_master = false,
6965 .config_i2s_gpio = NULL,
6966};
6967
6968/*
6969Just initializing the BAHAMA related slave
6970*/
6971static struct marimba_platform_data marimba_pdata = {
6972 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
6973 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
6974 .bahama_setup = msm_bahama_setup_power,
6975 .bahama_shutdown = msm_bahama_shutdown_power,
6976 .bahama_core_config = msm_bahama_core_config,
6977 .fm = &marimba_fm_pdata,
6978 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6979};
6980
6981
6982static struct i2c_board_info msm_marimba_board_info[] = {
6983 {
6984 I2C_BOARD_INFO("marimba", 0xc),
6985 .platform_data = &marimba_pdata,
6986 }
6987};
6988#endif /* CONFIG_MAIMBA_CORE */
6989
6990#ifdef CONFIG_I2C
6991#define I2C_SURF 1
6992#define I2C_FFA (1 << 1)
6993#define I2C_RUMI (1 << 2)
6994#define I2C_SIM (1 << 3)
6995#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006996#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006997
6998struct i2c_registry {
6999 u8 machs;
7000 int bus;
7001 struct i2c_board_info *info;
7002 int len;
7003};
7004
7005static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007006#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7007 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007008 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007009 MSM_GSBI8_QUP_I2C_BUS_ID,
7010 core_expander_i2c_info,
7011 ARRAY_SIZE(core_expander_i2c_info),
7012 },
7013 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007014 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007015 MSM_GSBI8_QUP_I2C_BUS_ID,
7016 docking_expander_i2c_info,
7017 ARRAY_SIZE(docking_expander_i2c_info),
7018 },
7019 {
7020 I2C_SURF,
7021 MSM_GSBI8_QUP_I2C_BUS_ID,
7022 surf_expanders_i2c_info,
7023 ARRAY_SIZE(surf_expanders_i2c_info),
7024 },
7025 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007026 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007027 MSM_GSBI3_QUP_I2C_BUS_ID,
7028 fha_expanders_i2c_info,
7029 ARRAY_SIZE(fha_expanders_i2c_info),
7030 },
7031 {
7032 I2C_FLUID,
7033 MSM_GSBI3_QUP_I2C_BUS_ID,
7034 fluid_expanders_i2c_info,
7035 ARRAY_SIZE(fluid_expanders_i2c_info),
7036 },
7037 {
7038 I2C_FLUID,
7039 MSM_GSBI8_QUP_I2C_BUS_ID,
7040 fluid_core_expander_i2c_info,
7041 ARRAY_SIZE(fluid_core_expander_i2c_info),
7042 },
7043#endif
7044#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7045 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7046 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007047 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007048 MSM_GSBI3_QUP_I2C_BUS_ID,
7049 msm_i2c_gsbi3_tdisc_info,
7050 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7051 },
7052#endif
7053 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007054 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007055 MSM_GSBI3_QUP_I2C_BUS_ID,
7056 cy8ctmg200_board_info,
7057 ARRAY_SIZE(cy8ctmg200_board_info),
7058 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007059 {
7060 I2C_DRAGON,
7061 MSM_GSBI3_QUP_I2C_BUS_ID,
7062 cy8ctma340_dragon_board_info,
7063 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7064 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007065#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7066 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7067 {
7068 I2C_FLUID,
7069 MSM_GSBI3_QUP_I2C_BUS_ID,
7070 cyttsp_fluid_info,
7071 ARRAY_SIZE(cyttsp_fluid_info),
7072 },
7073 {
7074 I2C_FFA | I2C_SURF,
7075 MSM_GSBI3_QUP_I2C_BUS_ID,
7076 cyttsp_ffa_info,
7077 ARRAY_SIZE(cyttsp_ffa_info),
7078 },
7079#endif
7080#ifdef CONFIG_MSM_CAMERA
Jilai Wang971f97f2011-07-13 14:25:25 -04007081 {
7082 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007083 MSM_GSBI4_QUP_I2C_BUS_ID,
7084 msm_camera_boardinfo,
7085 ARRAY_SIZE(msm_camera_boardinfo),
7086 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007087 {
7088 I2C_DRAGON,
7089 MSM_GSBI4_QUP_I2C_BUS_ID,
7090 msm_camera_dragon_boardinfo,
7091 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7092 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007093#endif
7094 {
7095 I2C_SURF | I2C_FFA | I2C_FLUID,
7096 MSM_GSBI7_QUP_I2C_BUS_ID,
7097 msm_i2c_gsbi7_timpani_info,
7098 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7099 },
7100#if defined(CONFIG_MARIMBA_CORE)
7101 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007102 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007103 MSM_GSBI7_QUP_I2C_BUS_ID,
7104 msm_marimba_board_info,
7105 ARRAY_SIZE(msm_marimba_board_info),
7106 },
7107#endif /* CONFIG_MARIMBA_CORE */
7108#ifdef CONFIG_ISL9519_CHARGER
7109 {
7110 I2C_SURF | I2C_FFA,
7111 MSM_GSBI8_QUP_I2C_BUS_ID,
7112 isl_charger_i2c_info,
7113 ARRAY_SIZE(isl_charger_i2c_info),
7114 },
7115#endif
7116#if defined(CONFIG_HAPTIC_ISA1200) || \
7117 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7118 {
7119 I2C_FLUID,
7120 MSM_GSBI8_QUP_I2C_BUS_ID,
7121 msm_isa1200_board_info,
7122 ARRAY_SIZE(msm_isa1200_board_info),
7123 },
7124#endif
7125#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7126 {
7127 I2C_FLUID,
7128 MSM_GSBI8_QUP_I2C_BUS_ID,
7129 smb137b_charger_i2c_info,
7130 ARRAY_SIZE(smb137b_charger_i2c_info),
7131 },
7132#endif
7133#if defined(CONFIG_BATTERY_BQ27520) || \
7134 defined(CONFIG_BATTERY_BQ27520_MODULE)
7135 {
7136 I2C_FLUID,
7137 MSM_GSBI8_QUP_I2C_BUS_ID,
7138 msm_bq27520_board_info,
7139 ARRAY_SIZE(msm_bq27520_board_info),
7140 },
7141#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007142#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7143 {
7144 I2C_DRAGON,
7145 MSM_GSBI8_QUP_I2C_BUS_ID,
7146 wm8903_codec_i2c_info,
7147 ARRAY_SIZE(wm8903_codec_i2c_info),
7148 },
7149#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007150};
7151#endif /* CONFIG_I2C */
7152
7153static void fixup_i2c_configs(void)
7154{
7155#ifdef CONFIG_I2C
7156#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7157 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7158 sx150x_data[SX150X_CORE].irq_summary =
7159 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007160 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7161 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007162 sx150x_data[SX150X_CORE].irq_summary =
7163 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7164 else if (machine_is_msm8x60_fluid())
7165 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7166 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7167#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007168#endif
7169}
7170
7171static void register_i2c_devices(void)
7172{
7173#ifdef CONFIG_I2C
7174 u8 mach_mask = 0;
7175 int i;
7176
7177 /* Build the matching 'supported_machs' bitmask */
7178 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7179 mach_mask = I2C_SURF;
7180 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7181 mach_mask = I2C_FFA;
7182 else if (machine_is_msm8x60_rumi3())
7183 mach_mask = I2C_RUMI;
7184 else if (machine_is_msm8x60_sim())
7185 mach_mask = I2C_SIM;
7186 else if (machine_is_msm8x60_fluid())
7187 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007188 else if (machine_is_msm8x60_dragon())
7189 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007190 else
7191 pr_err("unmatched machine ID in register_i2c_devices\n");
7192
7193 /* Run the array and install devices as appropriate */
7194 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7195 if (msm8x60_i2c_devices[i].machs & mach_mask)
7196 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7197 msm8x60_i2c_devices[i].info,
7198 msm8x60_i2c_devices[i].len);
7199 }
7200#endif
7201}
7202
7203static void __init msm8x60_init_uart12dm(void)
7204{
7205#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7206 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7207 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7208
7209 if (!fpga_mem)
7210 pr_err("%s(): Error getting memory\n", __func__);
7211
7212 /* Advanced mode */
7213 writew(0xFFFF, fpga_mem + 0x15C);
7214 /* FPGA_UART_SEL */
7215 writew(0, fpga_mem + 0x172);
7216 /* FPGA_GPIO_CONFIG_117 */
7217 writew(1, fpga_mem + 0xEA);
7218 /* FPGA_GPIO_CONFIG_118 */
7219 writew(1, fpga_mem + 0xEC);
7220 mb();
7221 iounmap(fpga_mem);
7222#endif
7223}
7224
7225#define MSM_GSBI9_PHYS 0x19900000
7226#define GSBI_DUAL_MODE_CODE 0x60
7227
7228static void __init msm8x60_init_buses(void)
7229{
7230#ifdef CONFIG_I2C_QUP
7231 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7232 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7233 writel_relaxed(0x6 << 4, gsbi_mem);
7234 /* Ensure protocol code is written before proceeding further */
7235 mb();
7236 iounmap(gsbi_mem);
7237
7238 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7239 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7240 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7241 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7242
7243#ifdef CONFIG_MSM_GSBI9_UART
7244 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7245 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7246 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7247 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7248 iounmap(gsbi_mem);
7249 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7250 }
7251#endif
7252 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7253 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7254#endif
7255#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7256 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7257#endif
7258#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007259 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7260#endif
7261
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307262#ifdef CONFIG_MSM_SSBI
7263 msm_device_ssbi_pmic1.dev.platform_data =
7264 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307265 msm_device_ssbi_pmic2.dev.platform_data =
7266 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307267#endif
7268
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007269 if (machine_is_msm8x60_fluid()) {
7270#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7271 (defined(CONFIG_SMB137B_CHARGER) || \
7272 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7273 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7274#endif
7275#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7276 msm_gsbi10_qup_spi_device.dev.platform_data =
7277 &msm_gsbi10_qup_spi_pdata;
7278#endif
7279 }
7280
7281#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7282 /*
7283 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7284 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7285 * and ID notifications are available only on V2 surf and FFA
7286 * with a hardware workaround.
7287 */
7288 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7289 (machine_is_msm8x60_surf() ||
7290 (machine_is_msm8x60_ffa() &&
7291 pmic_id_notif_supported)))
7292 msm_otg_pdata.phy_can_powercollapse = 1;
7293 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7294#endif
7295
7296#ifdef CONFIG_USB_GADGET_MSM_72K
7297 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7298#endif
7299
7300#ifdef CONFIG_SERIAL_MSM_HS
7301 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7302 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7303#endif
7304#ifdef CONFIG_MSM_GSBI9_UART
7305 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7306 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7307 if (IS_ERR(msm_device_uart_gsbi9))
7308 pr_err("%s(): Failed to create uart gsbi9 device\n",
7309 __func__);
7310 }
7311#endif
7312
7313#ifdef CONFIG_MSM_BUS_SCALING
7314
7315 /* RPM calls are only enabled on V2 */
7316 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7317 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7318 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7319 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7320 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7321 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7322 }
7323
7324 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7325 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7326 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7327 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7328 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7329#endif
7330}
7331
7332static void __init msm8x60_map_io(void)
7333{
7334 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7335 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007336
7337 if (socinfo_init() < 0)
7338 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007339}
7340
7341/*
7342 * Most segments of the EBI2 bus are disabled by default.
7343 */
7344static void __init msm8x60_init_ebi2(void)
7345{
7346 uint32_t ebi2_cfg;
7347 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007348 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7349
7350 if (IS_ERR(mem_clk)) {
7351 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7352 "msm_ebi2", "mem_clk");
7353 return;
7354 }
7355 clk_enable(mem_clk);
7356 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007357
7358 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7359 if (ebi2_cfg_ptr != 0) {
7360 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7361
7362 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007363 machine_is_msm8x60_fluid() ||
7364 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007365 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7366 else if (machine_is_msm8x60_sim())
7367 ebi2_cfg |= (1 << 4); /* CS2 */
7368 else if (machine_is_msm8x60_rumi3())
7369 ebi2_cfg |= (1 << 5); /* CS3 */
7370
7371 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7372 iounmap(ebi2_cfg_ptr);
7373 }
7374
7375 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007376 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007377 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7378 if (ebi2_cfg_ptr != 0) {
7379 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7380 writel_relaxed(0UL, ebi2_cfg_ptr);
7381
7382 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7383 * LAN9221 Ethernet controller reads and writes.
7384 * The lowest 4 bits are the read delay, the next
7385 * 4 are the write delay. */
7386 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7387#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7388 /*
7389 * RECOVERY=5, HOLD_WR=1
7390 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7391 * WAIT_WR=1, WAIT_RD=2
7392 */
7393 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7394 /*
7395 * HOLD_RD=1
7396 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7397 */
7398 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7399#else
7400 /* EBI2 CS3 muxed address/data,
7401 * two cyc addr enable */
7402 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7403
7404#endif
7405 iounmap(ebi2_cfg_ptr);
7406 }
7407 }
7408}
7409
7410static void __init msm8x60_configure_smc91x(void)
7411{
7412 if (machine_is_msm8x60_sim()) {
7413
7414 smc91x_resources[0].start = 0x1b800300;
7415 smc91x_resources[0].end = 0x1b8003ff;
7416
7417 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7418 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7419
7420 } else if (machine_is_msm8x60_rumi3()) {
7421
7422 smc91x_resources[0].start = 0x1d000300;
7423 smc91x_resources[0].end = 0x1d0003ff;
7424
7425 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7426 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7427 }
7428}
7429
7430static void __init msm8x60_init_tlmm(void)
7431{
7432 if (machine_is_msm8x60_rumi3())
7433 msm_gpio_install_direct_irq(0, 0, 1);
7434}
7435
7436#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7437 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7438 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7439 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7440 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7441
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007442/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007443#define MAX_SDCC_CONTROLLER 5
7444
7445struct msm_sdcc_gpio {
7446 /* maximum 10 GPIOs per SDCC controller */
7447 s16 no;
7448 /* name of this GPIO */
7449 const char *name;
7450 bool always_on;
7451 bool is_enabled;
7452};
7453
7454#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7455static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7456 {159, "sdc1_dat_0"},
7457 {160, "sdc1_dat_1"},
7458 {161, "sdc1_dat_2"},
7459 {162, "sdc1_dat_3"},
7460#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7461 {163, "sdc1_dat_4"},
7462 {164, "sdc1_dat_5"},
7463 {165, "sdc1_dat_6"},
7464 {166, "sdc1_dat_7"},
7465#endif
7466 {167, "sdc1_clk"},
7467 {168, "sdc1_cmd"}
7468};
7469#endif
7470
7471#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7472static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7473 {143, "sdc2_dat_0"},
7474 {144, "sdc2_dat_1", 1},
7475 {145, "sdc2_dat_2"},
7476 {146, "sdc2_dat_3"},
7477#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7478 {147, "sdc2_dat_4"},
7479 {148, "sdc2_dat_5"},
7480 {149, "sdc2_dat_6"},
7481 {150, "sdc2_dat_7"},
7482#endif
7483 {151, "sdc2_cmd"},
7484 {152, "sdc2_clk", 1}
7485};
7486#endif
7487
7488#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7489static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7490 {95, "sdc5_cmd"},
7491 {96, "sdc5_dat_3"},
7492 {97, "sdc5_clk", 1},
7493 {98, "sdc5_dat_2"},
7494 {99, "sdc5_dat_1", 1},
7495 {100, "sdc5_dat_0"}
7496};
7497#endif
7498
7499struct msm_sdcc_pad_pull_cfg {
7500 enum msm_tlmm_pull_tgt pull;
7501 u32 pull_val;
7502};
7503
7504struct msm_sdcc_pad_drv_cfg {
7505 enum msm_tlmm_hdrive_tgt drv;
7506 u32 drv_val;
7507};
7508
7509#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7510static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7511 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7512 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7513 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7514};
7515
7516static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7517 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7518 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7519};
7520
7521static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7522 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7523 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7524 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7525};
7526
7527static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7528 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7529 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7530};
7531#endif
7532
7533#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7534static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7535 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7536 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7537 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7538};
7539
7540static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7541 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7542 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7543};
7544
7545static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7546 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7547 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7548 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7549};
7550
7551static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7552 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7553 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7554};
7555#endif
7556
7557struct msm_sdcc_pin_cfg {
7558 /*
7559 * = 1 if controller pins are using gpios
7560 * = 0 if controller has dedicated MSM pins
7561 */
7562 u8 is_gpio;
7563 u8 cfg_sts;
7564 u8 gpio_data_size;
7565 struct msm_sdcc_gpio *gpio_data;
7566 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7567 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7568 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7569 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7570 u8 pad_drv_data_size;
7571 u8 pad_pull_data_size;
7572 u8 sdio_lpm_gpio_cfg;
7573};
7574
7575
7576static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7577#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7578 [0] = {
7579 .is_gpio = 1,
7580 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7581 .gpio_data = sdc1_gpio_cfg
7582 },
7583#endif
7584#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7585 [1] = {
7586 .is_gpio = 1,
7587 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7588 .gpio_data = sdc2_gpio_cfg
7589 },
7590#endif
7591#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7592 [2] = {
7593 .is_gpio = 0,
7594 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7595 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7596 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7597 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7598 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7599 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7600 },
7601#endif
7602#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7603 [3] = {
7604 .is_gpio = 0,
7605 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7606 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7607 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7608 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7609 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7610 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7611 },
7612#endif
7613#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7614 [4] = {
7615 .is_gpio = 1,
7616 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7617 .gpio_data = sdc5_gpio_cfg
7618 }
7619#endif
7620};
7621
7622static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7623{
7624 int rc = 0;
7625 struct msm_sdcc_pin_cfg *curr;
7626 int n;
7627
7628 curr = &sdcc_pin_cfg_data[dev_id - 1];
7629 if (!curr->gpio_data)
7630 goto out;
7631
7632 for (n = 0; n < curr->gpio_data_size; n++) {
7633 if (enable) {
7634
7635 if (curr->gpio_data[n].always_on &&
7636 curr->gpio_data[n].is_enabled)
7637 continue;
7638 pr_debug("%s: enable: %s\n", __func__,
7639 curr->gpio_data[n].name);
7640 rc = gpio_request(curr->gpio_data[n].no,
7641 curr->gpio_data[n].name);
7642 if (rc) {
7643 pr_err("%s: gpio_request(%d, %s)"
7644 "failed", __func__,
7645 curr->gpio_data[n].no,
7646 curr->gpio_data[n].name);
7647 goto free_gpios;
7648 }
7649 /* set direction as output for all GPIOs */
7650 rc = gpio_direction_output(
7651 curr->gpio_data[n].no, 1);
7652 if (rc) {
7653 pr_err("%s: gpio_direction_output"
7654 "(%d, 1) failed\n", __func__,
7655 curr->gpio_data[n].no);
7656 goto free_gpios;
7657 }
7658 curr->gpio_data[n].is_enabled = 1;
7659 } else {
7660 /*
7661 * now free this GPIO which will put GPIO
7662 * in low power mode and will also put GPIO
7663 * in input mode
7664 */
7665 if (curr->gpio_data[n].always_on)
7666 continue;
7667 pr_debug("%s: disable: %s\n", __func__,
7668 curr->gpio_data[n].name);
7669 gpio_free(curr->gpio_data[n].no);
7670 curr->gpio_data[n].is_enabled = 0;
7671 }
7672 }
7673 curr->cfg_sts = enable;
7674 goto out;
7675
7676free_gpios:
7677 for (; n >= 0; n--)
7678 gpio_free(curr->gpio_data[n].no);
7679out:
7680 return rc;
7681}
7682
7683static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7684{
7685 int rc = 0;
7686 struct msm_sdcc_pin_cfg *curr;
7687 int n;
7688
7689 curr = &sdcc_pin_cfg_data[dev_id - 1];
7690 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7691 goto out;
7692
7693 if (enable) {
7694 /*
7695 * set up the normal driver strength and
7696 * pull config for pads
7697 */
7698 for (n = 0; n < curr->pad_drv_data_size; n++) {
7699 if (curr->sdio_lpm_gpio_cfg) {
7700 if (curr->pad_drv_on_data[n].drv ==
7701 TLMM_HDRV_SDC4_DATA)
7702 continue;
7703 }
7704 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7705 curr->pad_drv_on_data[n].drv_val);
7706 }
7707 for (n = 0; n < curr->pad_pull_data_size; n++) {
7708 if (curr->sdio_lpm_gpio_cfg) {
7709 if (curr->pad_pull_on_data[n].pull ==
7710 TLMM_PULL_SDC4_DATA)
7711 continue;
7712 }
7713 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7714 curr->pad_pull_on_data[n].pull_val);
7715 }
7716 } else {
7717 /* set the low power config for pads */
7718 for (n = 0; n < curr->pad_drv_data_size; n++) {
7719 if (curr->sdio_lpm_gpio_cfg) {
7720 if (curr->pad_drv_off_data[n].drv ==
7721 TLMM_HDRV_SDC4_DATA)
7722 continue;
7723 }
7724 msm_tlmm_set_hdrive(
7725 curr->pad_drv_off_data[n].drv,
7726 curr->pad_drv_off_data[n].drv_val);
7727 }
7728 for (n = 0; n < curr->pad_pull_data_size; n++) {
7729 if (curr->sdio_lpm_gpio_cfg) {
7730 if (curr->pad_pull_off_data[n].pull ==
7731 TLMM_PULL_SDC4_DATA)
7732 continue;
7733 }
7734 msm_tlmm_set_pull(
7735 curr->pad_pull_off_data[n].pull,
7736 curr->pad_pull_off_data[n].pull_val);
7737 }
7738 }
7739 curr->cfg_sts = enable;
7740out:
7741 return rc;
7742}
7743
7744struct sdcc_reg {
7745 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7746 const char *reg_name;
7747 /*
7748 * is set voltage supported for this regulator?
7749 * 0 = not supported, 1 = supported
7750 */
7751 unsigned char set_voltage_sup;
7752 /* voltage level to be set */
7753 unsigned int level;
7754 /* VDD/VCC/VCCQ voltage regulator handle */
7755 struct regulator *reg;
7756 /* is this regulator enabled? */
7757 bool enabled;
7758 /* is this regulator needs to be always on? */
7759 bool always_on;
7760 /* is operating power mode setting required for this regulator? */
7761 bool op_pwr_mode_sup;
7762 /* Load values for low power and high power mode */
7763 unsigned int lpm_uA;
7764 unsigned int hpm_uA;
7765};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007766/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007767static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7768/* only SDCC1 requires VCCQ voltage */
7769static struct sdcc_reg sdcc_vccq_reg_data[1];
7770/* all SDCC controllers may require voting for VDD PAD voltage */
7771static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7772
7773struct sdcc_reg_data {
7774 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7775 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7776 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7777 unsigned char sts; /* regulator enable/disable status */
7778};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007779/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007780static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7781
7782static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7783{
7784 int rc = 0;
7785
7786 /* Get the regulator handle */
7787 vreg->reg = regulator_get(NULL, vreg->reg_name);
7788 if (IS_ERR(vreg->reg)) {
7789 rc = PTR_ERR(vreg->reg);
7790 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7791 __func__, vreg->reg_name, rc);
7792 goto out;
7793 }
7794
7795 /* Set the voltage level if required */
7796 if (vreg->set_voltage_sup) {
7797 rc = regulator_set_voltage(vreg->reg, vreg->level,
7798 vreg->level);
7799 if (rc) {
7800 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7801 __func__, vreg->reg_name, rc);
7802 goto vreg_put;
7803 }
7804 }
7805 goto out;
7806
7807vreg_put:
7808 regulator_put(vreg->reg);
7809out:
7810 return rc;
7811}
7812
7813static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7814{
7815 regulator_put(vreg->reg);
7816}
7817
7818/* this init function should be called only once for each SDCC */
7819static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7820{
7821 int rc = 0;
7822 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7823 struct sdcc_reg_data *curr;
7824
7825 curr = &sdcc_vreg_data[dev_id - 1];
7826 curr_vdd_reg = curr->vdd_data;
7827 curr_vccq_reg = curr->vccq_data;
7828 curr_vddp_reg = curr->vddp_data;
7829
7830 if (init) {
7831 /*
7832 * get the regulator handle from voltage regulator framework
7833 * and then try to set the voltage level for the regulator
7834 */
7835 if (curr_vdd_reg) {
7836 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7837 if (rc)
7838 goto out;
7839 }
7840 if (curr_vccq_reg) {
7841 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7842 if (rc)
7843 goto vdd_reg_deinit;
7844 }
7845 if (curr_vddp_reg) {
7846 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7847 if (rc)
7848 goto vccq_reg_deinit;
7849 }
7850 goto out;
7851 } else
7852 /* deregister with all regulators from regulator framework */
7853 goto vddp_reg_deinit;
7854
7855vddp_reg_deinit:
7856 if (curr_vddp_reg)
7857 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7858vccq_reg_deinit:
7859 if (curr_vccq_reg)
7860 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7861vdd_reg_deinit:
7862 if (curr_vdd_reg)
7863 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7864out:
7865 return rc;
7866}
7867
7868static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7869{
7870 int rc;
7871
7872 if (!vreg->enabled) {
7873 rc = regulator_enable(vreg->reg);
7874 if (rc) {
7875 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7876 __func__, vreg->reg_name, rc);
7877 goto out;
7878 }
7879 vreg->enabled = 1;
7880 }
7881
7882 /* Put always_on regulator in HPM (high power mode) */
7883 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7884 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7885 if (rc < 0) {
7886 pr_err("%s: reg=%s: HPM setting failed"
7887 " hpm_uA=%d, rc=%d\n",
7888 __func__, vreg->reg_name,
7889 vreg->hpm_uA, rc);
7890 goto vreg_disable;
7891 }
7892 rc = 0;
7893 }
7894 goto out;
7895
7896vreg_disable:
7897 regulator_disable(vreg->reg);
7898 vreg->enabled = 0;
7899out:
7900 return rc;
7901}
7902
7903static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7904{
7905 int rc;
7906
7907 /* Never disable always_on regulator */
7908 if (!vreg->always_on) {
7909 rc = regulator_disable(vreg->reg);
7910 if (rc) {
7911 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7912 __func__, vreg->reg_name, rc);
7913 goto out;
7914 }
7915 vreg->enabled = 0;
7916 }
7917
7918 /* Put always_on regulator in LPM (low power mode) */
7919 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7920 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
7921 if (rc < 0) {
7922 pr_err("%s: reg=%s: LPM setting failed"
7923 " lpm_uA=%d, rc=%d\n",
7924 __func__,
7925 vreg->reg_name,
7926 vreg->lpm_uA, rc);
7927 goto out;
7928 }
7929 rc = 0;
7930 }
7931
7932out:
7933 return rc;
7934}
7935
7936static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
7937{
7938 int rc = 0;
7939 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7940 struct sdcc_reg_data *curr;
7941
7942 curr = &sdcc_vreg_data[dev_id - 1];
7943 curr_vdd_reg = curr->vdd_data;
7944 curr_vccq_reg = curr->vccq_data;
7945 curr_vddp_reg = curr->vddp_data;
7946
7947 /* check if regulators are initialized or not? */
7948 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
7949 (curr_vccq_reg && !curr_vccq_reg->reg) ||
7950 (curr_vddp_reg && !curr_vddp_reg->reg)) {
7951 /* initialize voltage regulators required for this SDCC */
7952 rc = msm_sdcc_vreg_init(dev_id, 1);
7953 if (rc) {
7954 pr_err("%s: regulator init failed = %d\n",
7955 __func__, rc);
7956 goto out;
7957 }
7958 }
7959
7960 if (curr->sts == enable)
7961 goto out;
7962
7963 if (curr_vdd_reg) {
7964 if (enable)
7965 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
7966 else
7967 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
7968 if (rc)
7969 goto out;
7970 }
7971
7972 if (curr_vccq_reg) {
7973 if (enable)
7974 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
7975 else
7976 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
7977 if (rc)
7978 goto out;
7979 }
7980
7981 if (curr_vddp_reg) {
7982 if (enable)
7983 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
7984 else
7985 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
7986 if (rc)
7987 goto out;
7988 }
7989 curr->sts = enable;
7990
7991out:
7992 return rc;
7993}
7994
7995static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
7996{
7997 u32 rc_pin_cfg = 0;
7998 u32 rc_vreg_cfg = 0;
7999 u32 rc = 0;
8000 struct platform_device *pdev;
8001 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8002
8003 pdev = container_of(dv, struct platform_device, dev);
8004
8005 /* setup gpio/pad */
8006 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8007 if (curr_pin_cfg->cfg_sts == !!vdd)
8008 goto setup_vreg;
8009
8010 if (curr_pin_cfg->is_gpio)
8011 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8012 else
8013 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8014
8015setup_vreg:
8016 /* setup voltage regulators */
8017 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8018
8019 if (rc_pin_cfg || rc_vreg_cfg)
8020 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8021
8022 return rc;
8023}
8024
8025static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8026{
8027 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8028 struct platform_device *pdev;
8029
8030 pdev = container_of(dv, struct platform_device, dev);
8031 /* setup gpio/pad */
8032 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8033
8034 if (curr_pin_cfg->cfg_sts == active)
8035 return;
8036
8037 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8038 if (curr_pin_cfg->is_gpio)
8039 msm_sdcc_setup_gpio(pdev->id, active);
8040 else
8041 msm_sdcc_setup_pad(pdev->id, active);
8042 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8043}
8044
8045static int msm_sdc3_get_wpswitch(struct device *dev)
8046{
8047 struct platform_device *pdev;
8048 int status;
8049 pdev = container_of(dev, struct platform_device, dev);
8050
8051 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8052 if (status) {
8053 pr_err("%s:Failed to request GPIO %d\n",
8054 __func__, GPIO_SDC_WP);
8055 } else {
8056 status = gpio_direction_input(GPIO_SDC_WP);
8057 if (!status) {
8058 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8059 pr_info("%s: WP Status for Slot %d = %d\n",
8060 __func__, pdev->id, status);
8061 }
8062 gpio_free(GPIO_SDC_WP);
8063 }
8064 return status;
8065}
8066
8067#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8068int sdc5_register_status_notify(void (*callback)(int, void *),
8069 void *dev_id)
8070{
8071 sdc5_status_notify_cb = callback;
8072 sdc5_status_notify_cb_devid = dev_id;
8073 return 0;
8074}
8075#endif
8076
8077#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8078int sdc2_register_status_notify(void (*callback)(int, void *),
8079 void *dev_id)
8080{
8081 sdc2_status_notify_cb = callback;
8082 sdc2_status_notify_cb_devid = dev_id;
8083 return 0;
8084}
8085#endif
8086
8087/* Interrupt handler for SDC2 and SDC5 detection
8088 * This function uses dual-edge interrputs settings in order
8089 * to get SDIO detection when the GPIO is rising and SDIO removal
8090 * when the GPIO is falling */
8091static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8092{
8093 int status;
8094
8095 if (!machine_is_msm8x60_fusion() &&
8096 !machine_is_msm8x60_fusn_ffa())
8097 return IRQ_NONE;
8098
8099 status = gpio_get_value(MDM2AP_SYNC);
8100 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8101 __func__, status);
8102
8103#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8104 if (sdc2_status_notify_cb) {
8105 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8106 sdc2_status_notify_cb(status,
8107 sdc2_status_notify_cb_devid);
8108 }
8109#endif
8110
8111#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8112 if (sdc5_status_notify_cb) {
8113 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8114 sdc5_status_notify_cb(status,
8115 sdc5_status_notify_cb_devid);
8116 }
8117#endif
8118 return IRQ_HANDLED;
8119}
8120
8121static int msm8x60_multi_sdio_init(void)
8122{
8123 int ret, irq_num;
8124
8125 if (!machine_is_msm8x60_fusion() &&
8126 !machine_is_msm8x60_fusn_ffa())
8127 return 0;
8128
8129 ret = msm_gpiomux_get(MDM2AP_SYNC);
8130 if (ret) {
8131 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8132 __func__, MDM2AP_SYNC, ret);
8133 return ret;
8134 }
8135
8136 irq_num = gpio_to_irq(MDM2AP_SYNC);
8137
8138 ret = request_irq(irq_num,
8139 msm8x60_multi_sdio_slot_status_irq,
8140 IRQ_TYPE_EDGE_BOTH,
8141 "sdio_multidetection", NULL);
8142
8143 if (ret) {
8144 pr_err("%s:Failed to request irq, ret=%d\n",
8145 __func__, ret);
8146 return ret;
8147 }
8148
8149 return ret;
8150}
8151
8152#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8153#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8154static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8155{
8156 int status;
8157
8158 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8159 , "SD_HW_Detect");
8160 if (status) {
8161 pr_err("%s:Failed to request GPIO %d\n", __func__,
8162 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8163 } else {
8164 status = gpio_direction_input(
8165 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8166 if (!status)
8167 status = !(gpio_get_value_cansleep(
8168 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8169 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8170 }
8171 return (unsigned int) status;
8172}
8173#endif
8174#endif
8175
8176#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8177static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
8178{
8179 struct platform_device *pdev;
8180 enum msm_mpm_pin pin;
8181 int ret = 0;
8182
8183 pdev = container_of(dev, struct platform_device, dev);
8184
8185 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
8186 if (pdev->id == 4)
8187 pin = MSM_MPM_PIN_SDC4_DAT1;
8188 else
8189 return -EINVAL;
8190
8191 switch (mode) {
8192 case SDC_DAT1_DISABLE:
8193 ret = msm_mpm_enable_pin(pin, 0);
8194 break;
8195 case SDC_DAT1_ENABLE:
8196 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
8197 ret = msm_mpm_enable_pin(pin, 1);
8198 break;
8199 case SDC_DAT1_ENWAKE:
8200 ret = msm_mpm_set_pin_wake(pin, 1);
8201 break;
8202 case SDC_DAT1_DISWAKE:
8203 ret = msm_mpm_set_pin_wake(pin, 0);
8204 break;
8205 default:
8206 ret = -EINVAL;
8207 break;
8208 }
8209 return ret;
8210}
8211#endif
8212#endif
8213
8214#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8215static struct mmc_platform_data msm8x60_sdc1_data = {
8216 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8217 .translate_vdd = msm_sdcc_setup_power,
8218#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8219 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8220#else
8221 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8222#endif
8223 .msmsdcc_fmin = 400000,
8224 .msmsdcc_fmid = 24000000,
8225 .msmsdcc_fmax = 48000000,
8226 .nonremovable = 1,
8227 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008228};
8229#endif
8230
8231#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8232static struct mmc_platform_data msm8x60_sdc2_data = {
8233 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8234 .translate_vdd = msm_sdcc_setup_power,
8235 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8236 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8237 .msmsdcc_fmin = 400000,
8238 .msmsdcc_fmid = 24000000,
8239 .msmsdcc_fmax = 48000000,
8240 .nonremovable = 0,
8241 .pclk_src_dfab = 1,
8242 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008243#ifdef CONFIG_MSM_SDIO_AL
8244 .is_sdio_al_client = 1,
8245#endif
8246};
8247#endif
8248
8249#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8250static struct mmc_platform_data msm8x60_sdc3_data = {
8251 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8252 .translate_vdd = msm_sdcc_setup_power,
8253 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8254 .wpswitch = msm_sdc3_get_wpswitch,
8255#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8256 .status = msm8x60_sdcc_slot_status,
8257 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8258 PMIC_GPIO_SDC3_DET - 1),
8259 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8260#endif
8261 .msmsdcc_fmin = 400000,
8262 .msmsdcc_fmid = 24000000,
8263 .msmsdcc_fmax = 48000000,
8264 .nonremovable = 0,
8265 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008266};
8267#endif
8268
8269#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8270static struct mmc_platform_data msm8x60_sdc4_data = {
8271 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8272 .translate_vdd = msm_sdcc_setup_power,
8273 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8274 .msmsdcc_fmin = 400000,
8275 .msmsdcc_fmid = 24000000,
8276 .msmsdcc_fmax = 48000000,
8277 .nonremovable = 0,
8278 .pclk_src_dfab = 1,
8279 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008280};
8281#endif
8282
8283#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8284static struct mmc_platform_data msm8x60_sdc5_data = {
8285 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8286 .translate_vdd = msm_sdcc_setup_power,
8287 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8288 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8289 .msmsdcc_fmin = 400000,
8290 .msmsdcc_fmid = 24000000,
8291 .msmsdcc_fmax = 48000000,
8292 .nonremovable = 0,
8293 .pclk_src_dfab = 1,
8294 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008295#ifdef CONFIG_MSM_SDIO_AL
8296 .is_sdio_al_client = 1,
8297#endif
8298};
8299#endif
8300
8301static void __init msm8x60_init_mmc(void)
8302{
8303#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8304 /* SDCC1 : eMMC card connected */
8305 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8306 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8307 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8308 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308309 sdcc_vreg_data[0].vdd_data->always_on = 1;
8310 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8311 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8312 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008313
8314 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8315 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8316 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8317 sdcc_vreg_data[0].vccq_data->always_on = 1;
8318
8319 msm_add_sdcc(1, &msm8x60_sdc1_data);
8320#endif
8321#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8322 /*
8323 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8324 * and no card is connected on 8660 SURF/FFA/FLUID.
8325 */
8326 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8327 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8328 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8329 sdcc_vreg_data[1].vdd_data->level = 1800000;
8330
8331 sdcc_vreg_data[1].vccq_data = NULL;
8332
8333 if (machine_is_msm8x60_fusion())
8334 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8335 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8336#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8337 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8338 msm_sdcc_setup_gpio(2, 1);
8339#endif
8340 msm_add_sdcc(2, &msm8x60_sdc2_data);
8341 }
8342#endif
8343#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8344 /* SDCC3 : External card slot connected */
8345 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8346 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8347 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8348 sdcc_vreg_data[2].vdd_data->level = 2850000;
8349 sdcc_vreg_data[2].vdd_data->always_on = 1;
8350 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8351 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8352 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8353
8354 sdcc_vreg_data[2].vccq_data = NULL;
8355
8356 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8357 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8358 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8359 sdcc_vreg_data[2].vddp_data->level = 2850000;
8360 sdcc_vreg_data[2].vddp_data->always_on = 1;
8361 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8362 /* Sleep current required is ~300 uA. But min. RPM
8363 * vote can be in terms of mA (min. 1 mA).
8364 * So let's vote for 2 mA during sleep.
8365 */
8366 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8367 /* Max. Active current required is 16 mA */
8368 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8369
8370 if (machine_is_msm8x60_fluid())
8371 msm8x60_sdc3_data.wpswitch = NULL;
8372 msm_add_sdcc(3, &msm8x60_sdc3_data);
8373#endif
8374#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8375 /* SDCC4 : WLAN WCN1314 chip is connected */
8376 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8377 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8378 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8379 sdcc_vreg_data[3].vdd_data->level = 1800000;
8380
8381 sdcc_vreg_data[3].vccq_data = NULL;
8382
8383 msm_add_sdcc(4, &msm8x60_sdc4_data);
8384#endif
8385#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8386 /*
8387 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8388 * and no card is connected on 8660 SURF/FFA/FLUID.
8389 */
8390 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8391 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8392 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8393 sdcc_vreg_data[4].vdd_data->level = 1800000;
8394
8395 sdcc_vreg_data[4].vccq_data = NULL;
8396
8397 if (machine_is_msm8x60_fusion())
8398 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8399 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8400#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8401 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8402 msm_sdcc_setup_gpio(5, 1);
8403#endif
8404 msm_add_sdcc(5, &msm8x60_sdc5_data);
8405 }
8406#endif
8407}
8408
8409#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8410static inline void display_common_power(int on) {}
8411#else
8412
8413#define _GET_REGULATOR(var, name) do { \
8414 if (var == NULL) { \
8415 var = regulator_get(NULL, name); \
8416 if (IS_ERR(var)) { \
8417 pr_err("'%s' regulator not found, rc=%ld\n", \
8418 name, PTR_ERR(var)); \
8419 var = NULL; \
8420 } \
8421 } \
8422} while (0)
8423
8424static int dsub_regulator(int on)
8425{
8426 static struct regulator *dsub_reg;
8427 static struct regulator *mpp0_reg;
8428 static int dsub_reg_enabled;
8429 int rc = 0;
8430
8431 _GET_REGULATOR(dsub_reg, "8901_l3");
8432 if (IS_ERR(dsub_reg)) {
8433 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8434 __func__, PTR_ERR(dsub_reg));
8435 return PTR_ERR(dsub_reg);
8436 }
8437
8438 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8439 if (IS_ERR(mpp0_reg)) {
8440 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8441 __func__, PTR_ERR(mpp0_reg));
8442 return PTR_ERR(mpp0_reg);
8443 }
8444
8445 if (on && !dsub_reg_enabled) {
8446 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8447 if (rc) {
8448 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8449 " err=%d", __func__, rc);
8450 goto dsub_regulator_err;
8451 }
8452 rc = regulator_enable(dsub_reg);
8453 if (rc) {
8454 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8455 " err=%d", __func__, rc);
8456 goto dsub_regulator_err;
8457 }
8458 rc = regulator_enable(mpp0_reg);
8459 if (rc) {
8460 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8461 " err=%d", __func__, rc);
8462 goto dsub_regulator_err;
8463 }
8464 dsub_reg_enabled = 1;
8465 } else if (!on && dsub_reg_enabled) {
8466 rc = regulator_disable(dsub_reg);
8467 if (rc)
8468 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8469 " err=%d", __func__, rc);
8470 rc = regulator_disable(mpp0_reg);
8471 if (rc)
8472 printk(KERN_WARNING "%s: failed to disable reg "
8473 "8901_mpp0 err=%d", __func__, rc);
8474 dsub_reg_enabled = 0;
8475 }
8476
8477 return rc;
8478
8479dsub_regulator_err:
8480 regulator_put(mpp0_reg);
8481 regulator_put(dsub_reg);
8482 return rc;
8483}
8484
8485static int display_power_on;
8486static void setup_display_power(void)
8487{
8488 if (display_power_on)
8489 if (lcdc_vga_enabled) {
8490 dsub_regulator(1);
8491 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8492 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8493 if (machine_is_msm8x60_ffa() ||
8494 machine_is_msm8x60_fusn_ffa())
8495 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8496 } else {
8497 dsub_regulator(0);
8498 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8499 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8500 if (machine_is_msm8x60_ffa() ||
8501 machine_is_msm8x60_fusn_ffa())
8502 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8503 }
8504 else {
8505 dsub_regulator(0);
8506 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8507 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8508 /* BACKLIGHT */
8509 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8510 /* LVDS */
8511 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8512 }
8513}
8514
8515#define _GET_REGULATOR(var, name) do { \
8516 if (var == NULL) { \
8517 var = regulator_get(NULL, name); \
8518 if (IS_ERR(var)) { \
8519 pr_err("'%s' regulator not found, rc=%ld\n", \
8520 name, PTR_ERR(var)); \
8521 var = NULL; \
8522 } \
8523 } \
8524} while (0)
8525
8526#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8527
8528static void display_common_power(int on)
8529{
8530 int rc;
8531 static struct regulator *display_reg;
8532
8533 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8534 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8535 if (on) {
8536 /* LVDS */
8537 _GET_REGULATOR(display_reg, "8901_l2");
8538 if (!display_reg)
8539 return;
8540 rc = regulator_set_voltage(display_reg,
8541 3300000, 3300000);
8542 if (rc)
8543 goto out;
8544 rc = regulator_enable(display_reg);
8545 if (rc)
8546 goto out;
8547 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8548 "LVDS_STDN_OUT_N");
8549 if (rc) {
8550 printk(KERN_ERR "%s: LVDS gpio %d request"
8551 "failed\n", __func__,
8552 GPIO_LVDS_SHUTDOWN_N);
8553 goto out2;
8554 }
8555
8556 /* BACKLIGHT */
8557 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8558 if (rc) {
8559 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8560 "failed\n", __func__,
8561 GPIO_BACKLIGHT_EN);
8562 goto out3;
8563 }
8564
8565 if (machine_is_msm8x60_ffa() ||
8566 machine_is_msm8x60_fusn_ffa()) {
8567 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8568 "DONGLE_PWR_EN");
8569 if (rc) {
8570 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8571 " %d request failed\n", __func__,
8572 GPIO_DONGLE_PWR_EN);
8573 goto out4;
8574 }
8575 }
8576
8577 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8578 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8579 if (machine_is_msm8x60_ffa() ||
8580 machine_is_msm8x60_fusn_ffa())
8581 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8582 mdelay(20);
8583 display_power_on = 1;
8584 setup_display_power();
8585 } else {
8586 if (display_power_on) {
8587 display_power_on = 0;
8588 setup_display_power();
8589 mdelay(20);
8590 if (machine_is_msm8x60_ffa() ||
8591 machine_is_msm8x60_fusn_ffa())
8592 gpio_free(GPIO_DONGLE_PWR_EN);
8593 goto out4;
8594 }
8595 }
8596 }
8597#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8598 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8599 else if (machine_is_msm8x60_fluid()) {
8600 static struct regulator *fluid_reg;
8601 static struct regulator *fluid_reg2;
8602
8603 if (on) {
8604 _GET_REGULATOR(fluid_reg, "8901_l2");
8605 if (!fluid_reg)
8606 return;
8607 _GET_REGULATOR(fluid_reg2, "8058_s3");
8608 if (!fluid_reg2) {
8609 regulator_put(fluid_reg);
8610 return;
8611 }
8612 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8613 if (rc) {
8614 regulator_put(fluid_reg2);
8615 regulator_put(fluid_reg);
8616 return;
8617 }
8618 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8619 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8620 regulator_enable(fluid_reg);
8621 regulator_enable(fluid_reg2);
8622 msleep(20);
8623 gpio_direction_output(GPIO_RESX_N, 0);
8624 udelay(10);
8625 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8626 display_power_on = 1;
8627 setup_display_power();
8628 } else {
8629 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8630 gpio_free(GPIO_RESX_N);
8631 msleep(20);
8632 regulator_disable(fluid_reg2);
8633 regulator_disable(fluid_reg);
8634 regulator_put(fluid_reg2);
8635 regulator_put(fluid_reg);
8636 display_power_on = 0;
8637 setup_display_power();
8638 fluid_reg = NULL;
8639 fluid_reg2 = NULL;
8640 }
8641 }
8642#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008643#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8644 else if (machine_is_msm8x60_dragon()) {
8645 static struct regulator *dragon_reg;
8646 static struct regulator *dragon_reg2;
8647
8648 if (on) {
8649 _GET_REGULATOR(dragon_reg, "8901_l2");
8650 if (!dragon_reg)
8651 return;
8652 _GET_REGULATOR(dragon_reg2, "8058_l16");
8653 if (!dragon_reg2) {
8654 regulator_put(dragon_reg);
8655 dragon_reg = NULL;
8656 return;
8657 }
8658
8659 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8660 if (rc) {
8661 pr_err("%s: gpio %d request failed with rc=%d\n",
8662 __func__, GPIO_NT35582_BL_EN, rc);
8663 regulator_put(dragon_reg);
8664 regulator_put(dragon_reg2);
8665 dragon_reg = NULL;
8666 dragon_reg2 = NULL;
8667 return;
8668 }
8669
8670 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8671 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8672 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8673 pr_err("%s: config gpio '%d' failed!\n",
8674 __func__, GPIO_NT35582_RESET);
8675 gpio_free(GPIO_NT35582_BL_EN);
8676 regulator_put(dragon_reg);
8677 regulator_put(dragon_reg2);
8678 dragon_reg = NULL;
8679 dragon_reg2 = NULL;
8680 return;
8681 }
8682
8683 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8684 if (rc) {
8685 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8686 __func__, GPIO_NT35582_RESET, rc);
8687 gpio_free(GPIO_NT35582_BL_EN);
8688 regulator_put(dragon_reg);
8689 regulator_put(dragon_reg2);
8690 dragon_reg = NULL;
8691 dragon_reg2 = NULL;
8692 return;
8693 }
8694
8695 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8696 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8697 regulator_enable(dragon_reg);
8698 regulator_enable(dragon_reg2);
8699 msleep(20);
8700
8701 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8702 msleep(20);
8703 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8704 msleep(20);
8705 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8706 msleep(50);
8707
8708 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8709
8710 display_power_on = 1;
8711 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8712 gpio_free(GPIO_NT35582_RESET);
8713 gpio_free(GPIO_NT35582_BL_EN);
8714 regulator_disable(dragon_reg2);
8715 regulator_disable(dragon_reg);
8716 regulator_put(dragon_reg2);
8717 regulator_put(dragon_reg);
8718 display_power_on = 0;
8719 dragon_reg = NULL;
8720 dragon_reg2 = NULL;
8721 }
8722 }
8723#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008724 return;
8725
8726out4:
8727 gpio_free(GPIO_BACKLIGHT_EN);
8728out3:
8729 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8730out2:
8731 regulator_disable(display_reg);
8732out:
8733 regulator_put(display_reg);
8734 display_reg = NULL;
8735}
8736#undef _GET_REGULATOR
8737#endif
8738
8739static int mipi_dsi_panel_power(int on);
8740
8741#define LCDC_NUM_GPIO 28
8742#define LCDC_GPIO_START 0
8743
8744static void lcdc_samsung_panel_power(int on)
8745{
8746 int n, ret = 0;
8747
8748 display_common_power(on);
8749
8750 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8751 if (on) {
8752 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8753 if (unlikely(ret)) {
8754 pr_err("%s not able to get gpio\n", __func__);
8755 break;
8756 }
8757 } else
8758 gpio_free(LCDC_GPIO_START + n);
8759 }
8760
8761 if (ret) {
8762 for (n--; n >= 0; n--)
8763 gpio_free(LCDC_GPIO_START + n);
8764 }
8765
8766 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8767}
8768
8769#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8770#define _GET_REGULATOR(var, name) do { \
8771 var = regulator_get(NULL, name); \
8772 if (IS_ERR(var)) { \
8773 pr_err("'%s' regulator not found, rc=%ld\n", \
8774 name, IS_ERR(var)); \
8775 var = NULL; \
8776 return -ENODEV; \
8777 } \
8778} while (0)
8779
8780static int hdmi_enable_5v(int on)
8781{
8782 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8783 static struct regulator *reg_8901_mpp0; /* External 5V */
8784 static int prev_on;
8785 int rc;
8786
8787 if (on == prev_on)
8788 return 0;
8789
8790 if (!reg_8901_hdmi_mvs)
8791 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8792 if (!reg_8901_mpp0)
8793 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8794
8795 if (on) {
8796 rc = regulator_enable(reg_8901_mpp0);
8797 if (rc) {
8798 pr_err("'%s' regulator enable failed, rc=%d\n",
8799 "reg_8901_mpp0", rc);
8800 return rc;
8801 }
8802 rc = regulator_enable(reg_8901_hdmi_mvs);
8803 if (rc) {
8804 pr_err("'%s' regulator enable failed, rc=%d\n",
8805 "8901_hdmi_mvs", rc);
8806 return rc;
8807 }
8808 pr_info("%s(on): success\n", __func__);
8809 } else {
8810 rc = regulator_disable(reg_8901_hdmi_mvs);
8811 if (rc)
8812 pr_warning("'%s' regulator disable failed, rc=%d\n",
8813 "8901_hdmi_mvs", rc);
8814 rc = regulator_disable(reg_8901_mpp0);
8815 if (rc)
8816 pr_warning("'%s' regulator disable failed, rc=%d\n",
8817 "reg_8901_mpp0", rc);
8818 pr_info("%s(off): success\n", __func__);
8819 }
8820
8821 prev_on = on;
8822
8823 return 0;
8824}
8825
8826static int hdmi_core_power(int on, int show)
8827{
8828 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8829 static int prev_on;
8830 int rc;
8831
8832 if (on == prev_on)
8833 return 0;
8834
8835 if (!reg_8058_l16)
8836 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8837
8838 if (on) {
8839 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8840 if (!rc)
8841 rc = regulator_enable(reg_8058_l16);
8842 if (rc) {
8843 pr_err("'%s' regulator enable failed, rc=%d\n",
8844 "8058_l16", rc);
8845 return rc;
8846 }
8847 rc = gpio_request(170, "HDMI_DDC_CLK");
8848 if (rc) {
8849 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8850 "HDMI_DDC_CLK", 170, rc);
8851 goto error1;
8852 }
8853 rc = gpio_request(171, "HDMI_DDC_DATA");
8854 if (rc) {
8855 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8856 "HDMI_DDC_DATA", 171, rc);
8857 goto error2;
8858 }
8859 rc = gpio_request(172, "HDMI_HPD");
8860 if (rc) {
8861 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8862 "HDMI_HPD", 172, rc);
8863 goto error3;
8864 }
8865 pr_info("%s(on): success\n", __func__);
8866 } else {
8867 gpio_free(170);
8868 gpio_free(171);
8869 gpio_free(172);
8870 rc = regulator_disable(reg_8058_l16);
8871 if (rc)
8872 pr_warning("'%s' regulator disable failed, rc=%d\n",
8873 "8058_l16", rc);
8874 pr_info("%s(off): success\n", __func__);
8875 }
8876
8877 prev_on = on;
8878
8879 return 0;
8880
8881error3:
8882 gpio_free(171);
8883error2:
8884 gpio_free(170);
8885error1:
8886 regulator_disable(reg_8058_l16);
8887 return rc;
8888}
8889
8890static int hdmi_cec_power(int on)
8891{
8892 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8893 static int prev_on;
8894 int rc;
8895
8896 if (on == prev_on)
8897 return 0;
8898
8899 if (!reg_8901_l3)
8900 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8901
8902 if (on) {
8903 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8904 if (!rc)
8905 rc = regulator_enable(reg_8901_l3);
8906 if (rc) {
8907 pr_err("'%s' regulator enable failed, rc=%d\n",
8908 "8901_l3", rc);
8909 return rc;
8910 }
8911 rc = gpio_request(169, "HDMI_CEC_VAR");
8912 if (rc) {
8913 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8914 "HDMI_CEC_VAR", 169, rc);
8915 goto error;
8916 }
8917 pr_info("%s(on): success\n", __func__);
8918 } else {
8919 gpio_free(169);
8920 rc = regulator_disable(reg_8901_l3);
8921 if (rc)
8922 pr_warning("'%s' regulator disable failed, rc=%d\n",
8923 "8901_l3", rc);
8924 pr_info("%s(off): success\n", __func__);
8925 }
8926
8927 prev_on = on;
8928
8929 return 0;
8930error:
8931 regulator_disable(reg_8901_l3);
8932 return rc;
8933}
8934
8935#undef _GET_REGULATOR
8936
8937#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
8938
8939static int lcdc_panel_power(int on)
8940{
8941 int flag_on = !!on;
8942 static int lcdc_power_save_on;
8943
8944 if (lcdc_power_save_on == flag_on)
8945 return 0;
8946
8947 lcdc_power_save_on = flag_on;
8948
8949 lcdc_samsung_panel_power(on);
8950
8951 return 0;
8952}
8953
8954#ifdef CONFIG_MSM_BUS_SCALING
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008955static struct msm_bus_vectors mdp_init_vectors[] = {
8956 /* For now, 0th array entry is reserved.
8957 * Please leave 0 as is and don't use it
8958 */
8959 {
8960 .src = MSM_BUS_MASTER_MDP_PORT0,
8961 .dst = MSM_BUS_SLAVE_SMI,
8962 .ab = 0,
8963 .ib = 0,
8964 },
8965 /* Master and slaves can be from different fabrics */
8966 {
8967 .src = MSM_BUS_MASTER_MDP_PORT0,
8968 .dst = MSM_BUS_SLAVE_EBI_CH0,
8969 .ab = 0,
8970 .ib = 0,
8971 },
8972};
8973
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07008974#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
8975static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
8976 /* If HDMI is used as primary */
8977 {
8978 .src = MSM_BUS_MASTER_MDP_PORT0,
8979 .dst = MSM_BUS_SLAVE_SMI,
8980 .ab = 2000000000,
8981 .ib = 2000000000,
8982 },
8983 /* Master and slaves can be from different fabrics */
8984 {
8985 .src = MSM_BUS_MASTER_MDP_PORT0,
8986 .dst = MSM_BUS_SLAVE_EBI_CH0,
8987 .ab = 2000000000,
8988 .ib = 2000000000,
8989 },
8990};
8991
8992static struct msm_bus_paths mdp_bus_scale_usecases[] = {
8993 {
8994 ARRAY_SIZE(mdp_init_vectors),
8995 mdp_init_vectors,
8996 },
8997 {
8998 ARRAY_SIZE(hdmi_as_primary_vectors),
8999 hdmi_as_primary_vectors,
9000 },
9001 {
9002 ARRAY_SIZE(hdmi_as_primary_vectors),
9003 hdmi_as_primary_vectors,
9004 },
9005 {
9006 ARRAY_SIZE(hdmi_as_primary_vectors),
9007 hdmi_as_primary_vectors,
9008 },
9009 {
9010 ARRAY_SIZE(hdmi_as_primary_vectors),
9011 hdmi_as_primary_vectors,
9012 },
9013 {
9014 ARRAY_SIZE(hdmi_as_primary_vectors),
9015 hdmi_as_primary_vectors,
9016 },
9017};
9018#else
9019#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009020static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9021 /* Default case static display/UI/2d/3d if FB SMI */
9022 {
9023 .src = MSM_BUS_MASTER_MDP_PORT0,
9024 .dst = MSM_BUS_SLAVE_SMI,
9025 .ab = 388800000,
9026 .ib = 486000000,
9027 },
9028 /* Master and slaves can be from different fabrics */
9029 {
9030 .src = MSM_BUS_MASTER_MDP_PORT0,
9031 .dst = MSM_BUS_SLAVE_EBI_CH0,
9032 .ab = 0,
9033 .ib = 0,
9034 },
9035};
9036
9037static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9038 /* Default case static display/UI/2d/3d if FB SMI */
9039 {
9040 .src = MSM_BUS_MASTER_MDP_PORT0,
9041 .dst = MSM_BUS_SLAVE_SMI,
9042 .ab = 0,
9043 .ib = 0,
9044 },
9045 /* Master and slaves can be from different fabrics */
9046 {
9047 .src = MSM_BUS_MASTER_MDP_PORT0,
9048 .dst = MSM_BUS_SLAVE_EBI_CH0,
9049 .ab = 388800000,
9050 .ib = 486000000 * 2,
9051 },
9052};
9053static struct msm_bus_vectors mdp_vga_vectors[] = {
9054 /* VGA and less video */
9055 {
9056 .src = MSM_BUS_MASTER_MDP_PORT0,
9057 .dst = MSM_BUS_SLAVE_SMI,
9058 .ab = 458092800,
9059 .ib = 572616000,
9060 },
9061 {
9062 .src = MSM_BUS_MASTER_MDP_PORT0,
9063 .dst = MSM_BUS_SLAVE_EBI_CH0,
9064 .ab = 458092800,
9065 .ib = 572616000 * 2,
9066 },
9067};
9068static struct msm_bus_vectors mdp_720p_vectors[] = {
9069 /* 720p and less video */
9070 {
9071 .src = MSM_BUS_MASTER_MDP_PORT0,
9072 .dst = MSM_BUS_SLAVE_SMI,
9073 .ab = 471744000,
9074 .ib = 589680000,
9075 },
9076 /* Master and slaves can be from different fabrics */
9077 {
9078 .src = MSM_BUS_MASTER_MDP_PORT0,
9079 .dst = MSM_BUS_SLAVE_EBI_CH0,
9080 .ab = 471744000,
9081 .ib = 589680000 * 2,
9082 },
9083};
9084
9085static struct msm_bus_vectors mdp_1080p_vectors[] = {
9086 /* 1080p and less video */
9087 {
9088 .src = MSM_BUS_MASTER_MDP_PORT0,
9089 .dst = MSM_BUS_SLAVE_SMI,
9090 .ab = 575424000,
9091 .ib = 719280000,
9092 },
9093 /* Master and slaves can be from different fabrics */
9094 {
9095 .src = MSM_BUS_MASTER_MDP_PORT0,
9096 .dst = MSM_BUS_SLAVE_EBI_CH0,
9097 .ab = 575424000,
9098 .ib = 719280000 * 2,
9099 },
9100};
9101
9102#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009103static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9104 /* Default case static display/UI/2d/3d if FB SMI */
9105 {
9106 .src = MSM_BUS_MASTER_MDP_PORT0,
9107 .dst = MSM_BUS_SLAVE_SMI,
9108 .ab = 175110000,
9109 .ib = 218887500,
9110 },
9111 /* Master and slaves can be from different fabrics */
9112 {
9113 .src = MSM_BUS_MASTER_MDP_PORT0,
9114 .dst = MSM_BUS_SLAVE_EBI_CH0,
9115 .ab = 0,
9116 .ib = 0,
9117 },
9118};
9119
9120static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9121 /* Default case static display/UI/2d/3d if FB SMI */
9122 {
9123 .src = MSM_BUS_MASTER_MDP_PORT0,
9124 .dst = MSM_BUS_SLAVE_SMI,
9125 .ab = 0,
9126 .ib = 0,
9127 },
9128 /* Master and slaves can be from different fabrics */
9129 {
9130 .src = MSM_BUS_MASTER_MDP_PORT0,
9131 .dst = MSM_BUS_SLAVE_EBI_CH0,
9132 .ab = 216000000,
9133 .ib = 270000000 * 2,
9134 },
9135};
9136static struct msm_bus_vectors mdp_vga_vectors[] = {
9137 /* VGA and less video */
9138 {
9139 .src = MSM_BUS_MASTER_MDP_PORT0,
9140 .dst = MSM_BUS_SLAVE_SMI,
9141 .ab = 216000000,
9142 .ib = 270000000,
9143 },
9144 {
9145 .src = MSM_BUS_MASTER_MDP_PORT0,
9146 .dst = MSM_BUS_SLAVE_EBI_CH0,
9147 .ab = 216000000,
9148 .ib = 270000000 * 2,
9149 },
9150};
9151
9152static struct msm_bus_vectors mdp_720p_vectors[] = {
9153 /* 720p and less video */
9154 {
9155 .src = MSM_BUS_MASTER_MDP_PORT0,
9156 .dst = MSM_BUS_SLAVE_SMI,
9157 .ab = 230400000,
9158 .ib = 288000000,
9159 },
9160 /* Master and slaves can be from different fabrics */
9161 {
9162 .src = MSM_BUS_MASTER_MDP_PORT0,
9163 .dst = MSM_BUS_SLAVE_EBI_CH0,
9164 .ab = 230400000,
9165 .ib = 288000000 * 2,
9166 },
9167};
9168
9169static struct msm_bus_vectors mdp_1080p_vectors[] = {
9170 /* 1080p and less video */
9171 {
9172 .src = MSM_BUS_MASTER_MDP_PORT0,
9173 .dst = MSM_BUS_SLAVE_SMI,
9174 .ab = 334080000,
9175 .ib = 417600000,
9176 },
9177 /* Master and slaves can be from different fabrics */
9178 {
9179 .src = MSM_BUS_MASTER_MDP_PORT0,
9180 .dst = MSM_BUS_SLAVE_EBI_CH0,
9181 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009182 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009183 },
9184};
9185
9186#endif
9187static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9188 {
9189 ARRAY_SIZE(mdp_init_vectors),
9190 mdp_init_vectors,
9191 },
9192 {
9193 ARRAY_SIZE(mdp_sd_smi_vectors),
9194 mdp_sd_smi_vectors,
9195 },
9196 {
9197 ARRAY_SIZE(mdp_sd_ebi_vectors),
9198 mdp_sd_ebi_vectors,
9199 },
9200 {
9201 ARRAY_SIZE(mdp_vga_vectors),
9202 mdp_vga_vectors,
9203 },
9204 {
9205 ARRAY_SIZE(mdp_720p_vectors),
9206 mdp_720p_vectors,
9207 },
9208 {
9209 ARRAY_SIZE(mdp_1080p_vectors),
9210 mdp_1080p_vectors,
9211 },
9212};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009213#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009214static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9215 mdp_bus_scale_usecases,
9216 ARRAY_SIZE(mdp_bus_scale_usecases),
9217 .name = "mdp",
9218};
9219
9220#endif
9221#ifdef CONFIG_MSM_BUS_SCALING
9222static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9223 /* For now, 0th array entry is reserved.
9224 * Please leave 0 as is and don't use it
9225 */
9226 {
9227 .src = MSM_BUS_MASTER_MDP_PORT0,
9228 .dst = MSM_BUS_SLAVE_SMI,
9229 .ab = 0,
9230 .ib = 0,
9231 },
9232 /* Master and slaves can be from different fabrics */
9233 {
9234 .src = MSM_BUS_MASTER_MDP_PORT0,
9235 .dst = MSM_BUS_SLAVE_EBI_CH0,
9236 .ab = 0,
9237 .ib = 0,
9238 },
9239};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009240#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9241static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9242 /* For now, 0th array entry is reserved.
9243 * Please leave 0 as is and don't use it
9244 */
9245 {
9246 .src = MSM_BUS_MASTER_MDP_PORT0,
9247 .dst = MSM_BUS_SLAVE_SMI,
9248 .ab = 2000000000,
9249 .ib = 2000000000,
9250 },
9251 /* Master and slaves can be from different fabrics */
9252 {
9253 .src = MSM_BUS_MASTER_MDP_PORT0,
9254 .dst = MSM_BUS_SLAVE_EBI_CH0,
9255 .ab = 2000000000,
9256 .ib = 2000000000,
9257 },
9258};
9259#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009260static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9261 /* For now, 0th array entry is reserved.
9262 * Please leave 0 as is and don't use it
9263 */
9264 {
9265 .src = MSM_BUS_MASTER_MDP_PORT0,
9266 .dst = MSM_BUS_SLAVE_SMI,
9267 .ab = 566092800,
9268 .ib = 707616000,
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 = 566092800,
9275 .ib = 707616000,
9276 },
9277};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009278#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009279static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9280 {
9281 ARRAY_SIZE(dtv_bus_init_vectors),
9282 dtv_bus_init_vectors,
9283 },
9284 {
9285 ARRAY_SIZE(dtv_bus_def_vectors),
9286 dtv_bus_def_vectors,
9287 },
9288};
9289static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9290 dtv_bus_scale_usecases,
9291 ARRAY_SIZE(dtv_bus_scale_usecases),
9292 .name = "dtv",
9293};
9294
9295static struct lcdc_platform_data dtv_pdata = {
9296 .bus_scale_table = &dtv_bus_scale_pdata,
9297};
9298#endif
9299
9300
9301static struct lcdc_platform_data lcdc_pdata = {
9302 .lcdc_power_save = lcdc_panel_power,
9303};
9304
9305
9306#define MDP_VSYNC_GPIO 28
9307
9308/*
9309 * MIPI_DSI only use 8058_LDO0 which need always on
9310 * therefore it need to be put at low power mode if
9311 * it was not used instead of turn it off.
9312 */
9313static int mipi_dsi_panel_power(int on)
9314{
9315 int flag_on = !!on;
9316 static int mipi_dsi_power_save_on;
9317 static struct regulator *ldo0;
9318 int rc = 0;
9319
9320 if (mipi_dsi_power_save_on == flag_on)
9321 return 0;
9322
9323 mipi_dsi_power_save_on = flag_on;
9324
9325 if (ldo0 == NULL) { /* init */
9326 ldo0 = regulator_get(NULL, "8058_l0");
9327 if (IS_ERR(ldo0)) {
9328 pr_debug("%s: LDO0 failed\n", __func__);
9329 rc = PTR_ERR(ldo0);
9330 return rc;
9331 }
9332
9333 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9334 if (rc)
9335 goto out;
9336
9337 rc = regulator_enable(ldo0);
9338 if (rc)
9339 goto out;
9340 }
9341
9342 if (on) {
9343 /* set ldo0 to HPM */
9344 rc = regulator_set_optimum_mode(ldo0, 100000);
9345 if (rc < 0)
9346 goto out;
9347 } else {
9348 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309349 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009350 if (rc < 0)
9351 goto out;
9352 }
9353
9354 return 0;
9355out:
9356 regulator_disable(ldo0);
9357 regulator_put(ldo0);
9358 ldo0 = NULL;
9359 return rc;
9360}
9361
9362static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9363 .vsync_gpio = MDP_VSYNC_GPIO,
9364 .dsi_power_save = mipi_dsi_panel_power,
9365};
9366
9367#ifdef CONFIG_FB_MSM_TVOUT
9368static struct regulator *reg_8058_l13;
9369
9370static int atv_dac_power(int on)
9371{
9372 int rc = 0;
9373 #define _GET_REGULATOR(var, name) do { \
9374 var = regulator_get(NULL, name); \
9375 if (IS_ERR(var)) { \
9376 pr_info("'%s' regulator not found, rc=%ld\n", \
9377 name, IS_ERR(var)); \
9378 var = NULL; \
9379 return -ENODEV; \
9380 } \
9381 } while (0)
9382
9383 if (!reg_8058_l13)
9384 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9385 #undef _GET_REGULATOR
9386
9387 if (on) {
9388 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9389 if (rc) {
9390 pr_info("%s: '%s' regulator set voltage failed,\
9391 rc=%d\n", __func__, "8058_l13", rc);
9392 return rc;
9393 }
9394
9395 rc = regulator_enable(reg_8058_l13);
9396 if (rc) {
9397 pr_err("%s: '%s' regulator enable failed,\
9398 rc=%d\n", __func__, "8058_l13", rc);
9399 return rc;
9400 }
9401 } else {
9402 rc = regulator_force_disable(reg_8058_l13);
9403 if (rc)
9404 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9405 __func__, "8058_l13", rc);
9406 }
9407 return rc;
9408
9409}
9410#endif
9411
9412#ifdef CONFIG_FB_MSM_MIPI_DSI
9413int mdp_core_clk_rate_table[] = {
9414 85330000,
9415 85330000,
9416 160000000,
9417 200000000,
9418};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009419#elif defined(CONFIG_FB_MSM_HDMI_AS_PRIMARY)
9420int mdp_core_clk_rate_table[] = {
9421 200000000,
9422 200000000,
9423 200000000,
9424 200000000,
9425};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009426#else
9427int mdp_core_clk_rate_table[] = {
9428 59080000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009429 85330000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009430 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009431 200000000,
9432};
9433#endif
9434
9435static struct msm_panel_common_pdata mdp_pdata = {
9436 .gpio = MDP_VSYNC_GPIO,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009437#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9438 .mdp_core_clk_rate = 200000000,
9439#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009440 .mdp_core_clk_rate = 59080000,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009441#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009442 .mdp_core_clk_table = mdp_core_clk_rate_table,
9443 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9444#ifdef CONFIG_MSM_BUS_SCALING
9445 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9446#endif
9447 .mdp_rev = MDP_REV_41,
Huaibin Yanga5419422011-12-08 23:52:10 -08009448 .mdp_writeback_memtype = MEMTYPE_EBI1,
9449 .mdp_writeback_phys = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009450};
9451
Huaibin Yanga5419422011-12-08 23:52:10 -08009452static void __init reserve_mdp_memory(void)
9453{
9454 mdp_pdata.mdp_writeback_size_ov0 = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9455 mdp_pdata.mdp_writeback_size_ov1 = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9456
9457 msm8x60_reserve_table[mdp_pdata.mdp_writeback_memtype].size +=
9458 mdp_pdata.mdp_writeback_size_ov0;
9459 msm8x60_reserve_table[mdp_pdata.mdp_writeback_memtype].size +=
9460 mdp_pdata.mdp_writeback_size_ov1;
9461}
9462
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009463#ifdef CONFIG_FB_MSM_TVOUT
9464
9465#ifdef CONFIG_MSM_BUS_SCALING
9466static struct msm_bus_vectors atv_bus_init_vectors[] = {
9467 /* For now, 0th array entry is reserved.
9468 * Please leave 0 as is and don't use it
9469 */
9470 {
9471 .src = MSM_BUS_MASTER_MDP_PORT0,
9472 .dst = MSM_BUS_SLAVE_SMI,
9473 .ab = 0,
9474 .ib = 0,
9475 },
9476 /* Master and slaves can be from different fabrics */
9477 {
9478 .src = MSM_BUS_MASTER_MDP_PORT0,
9479 .dst = MSM_BUS_SLAVE_EBI_CH0,
9480 .ab = 0,
9481 .ib = 0,
9482 },
9483};
9484static struct msm_bus_vectors atv_bus_def_vectors[] = {
9485 /* For now, 0th array entry is reserved.
9486 * Please leave 0 as is and don't use it
9487 */
9488 {
9489 .src = MSM_BUS_MASTER_MDP_PORT0,
9490 .dst = MSM_BUS_SLAVE_SMI,
9491 .ab = 236390400,
9492 .ib = 265939200,
9493 },
9494 /* Master and slaves can be from different fabrics */
9495 {
9496 .src = MSM_BUS_MASTER_MDP_PORT0,
9497 .dst = MSM_BUS_SLAVE_EBI_CH0,
9498 .ab = 236390400,
9499 .ib = 265939200,
9500 },
9501};
9502static struct msm_bus_paths atv_bus_scale_usecases[] = {
9503 {
9504 ARRAY_SIZE(atv_bus_init_vectors),
9505 atv_bus_init_vectors,
9506 },
9507 {
9508 ARRAY_SIZE(atv_bus_def_vectors),
9509 atv_bus_def_vectors,
9510 },
9511};
9512static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9513 atv_bus_scale_usecases,
9514 ARRAY_SIZE(atv_bus_scale_usecases),
9515 .name = "atv",
9516};
9517#endif
9518
9519static struct tvenc_platform_data atv_pdata = {
9520 .poll = 0,
9521 .pm_vid_en = atv_dac_power,
9522#ifdef CONFIG_MSM_BUS_SCALING
9523 .bus_scale_table = &atv_bus_scale_pdata,
9524#endif
9525};
9526#endif
9527
9528static void __init msm_fb_add_devices(void)
9529{
9530#ifdef CONFIG_FB_MSM_LCDC_DSUB
9531 mdp_pdata.mdp_core_clk_table = NULL;
9532 mdp_pdata.num_mdp_clk = 0;
9533 mdp_pdata.mdp_core_clk_rate = 200000000;
9534#endif
9535 if (machine_is_msm8x60_rumi3())
9536 msm_fb_register_device("mdp", NULL);
9537 else
9538 msm_fb_register_device("mdp", &mdp_pdata);
9539
9540 msm_fb_register_device("lcdc", &lcdc_pdata);
9541 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9542#ifdef CONFIG_MSM_BUS_SCALING
9543 msm_fb_register_device("dtv", &dtv_pdata);
9544#endif
9545#ifdef CONFIG_FB_MSM_TVOUT
9546 msm_fb_register_device("tvenc", &atv_pdata);
9547 msm_fb_register_device("tvout_device", NULL);
9548#endif
9549}
9550
9551#if (defined(CONFIG_MARIMBA_CORE)) && \
9552 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9553
9554static const struct {
9555 char *name;
9556 int vmin;
9557 int vmax;
9558} bt_regs_info[] = {
9559 { "8058_s3", 1800000, 1800000 },
9560 { "8058_s2", 1300000, 1300000 },
9561 { "8058_l8", 2900000, 3050000 },
9562};
9563
9564static struct {
9565 bool enabled;
9566} bt_regs_status[] = {
9567 { false },
9568 { false },
9569 { false },
9570};
9571static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9572
9573static int bahama_bt(int on)
9574{
9575 int rc;
9576 int i;
9577 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9578
9579 struct bahama_variant_register {
9580 const size_t size;
9581 const struct bahama_config_register *set;
9582 };
9583
9584 const struct bahama_config_register *p;
9585
9586 u8 version;
9587
9588 const struct bahama_config_register v10_bt_on[] = {
9589 { 0xE9, 0x00, 0xFF },
9590 { 0xF4, 0x80, 0xFF },
9591 { 0xE4, 0x00, 0xFF },
9592 { 0xE5, 0x00, 0x0F },
9593#ifdef CONFIG_WLAN
9594 { 0xE6, 0x38, 0x7F },
9595 { 0xE7, 0x06, 0xFF },
9596#endif
9597 { 0xE9, 0x21, 0xFF },
9598 { 0x01, 0x0C, 0x1F },
9599 { 0x01, 0x08, 0x1F },
9600 };
9601
9602 const struct bahama_config_register v20_bt_on_fm_off[] = {
9603 { 0x11, 0x0C, 0xFF },
9604 { 0x13, 0x01, 0xFF },
9605 { 0xF4, 0x80, 0xFF },
9606 { 0xF0, 0x00, 0xFF },
9607 { 0xE9, 0x00, 0xFF },
9608#ifdef CONFIG_WLAN
9609 { 0x81, 0x00, 0x7F },
9610 { 0x82, 0x00, 0xFF },
9611 { 0xE6, 0x38, 0x7F },
9612 { 0xE7, 0x06, 0xFF },
9613#endif
9614 { 0xE9, 0x21, 0xFF },
9615 };
9616
9617 const struct bahama_config_register v20_bt_on_fm_on[] = {
9618 { 0x11, 0x0C, 0xFF },
9619 { 0x13, 0x01, 0xFF },
9620 { 0xF4, 0x86, 0xFF },
9621 { 0xF0, 0x06, 0xFF },
9622 { 0xE9, 0x00, 0xFF },
9623#ifdef CONFIG_WLAN
9624 { 0x81, 0x00, 0x7F },
9625 { 0x82, 0x00, 0xFF },
9626 { 0xE6, 0x38, 0x7F },
9627 { 0xE7, 0x06, 0xFF },
9628#endif
9629 { 0xE9, 0x21, 0xFF },
9630 };
9631
9632 const struct bahama_config_register v10_bt_off[] = {
9633 { 0xE9, 0x00, 0xFF },
9634 };
9635
9636 const struct bahama_config_register v20_bt_off_fm_off[] = {
9637 { 0xF4, 0x84, 0xFF },
9638 { 0xF0, 0x04, 0xFF },
9639 { 0xE9, 0x00, 0xFF }
9640 };
9641
9642 const struct bahama_config_register v20_bt_off_fm_on[] = {
9643 { 0xF4, 0x86, 0xFF },
9644 { 0xF0, 0x06, 0xFF },
9645 { 0xE9, 0x00, 0xFF }
9646 };
9647 const struct bahama_variant_register bt_bahama[2][3] = {
9648 {
9649 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9650 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9651 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9652 },
9653 {
9654 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9655 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9656 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9657 }
9658 };
9659
9660 u8 offset = 0; /* index into bahama configs */
9661
9662 on = on ? 1 : 0;
9663 version = read_bahama_ver();
9664
9665 if (version == VER_UNSUPPORTED) {
9666 dev_err(&msm_bt_power_device.dev,
9667 "%s: unsupported version\n",
9668 __func__);
9669 return -EIO;
9670 }
9671
9672 if (version == VER_2_0) {
9673 if (marimba_get_fm_status(&config))
9674 offset = 0x01;
9675 }
9676
9677 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9678 if (on && (version == VER_2_0)) {
9679 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9680 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9681 && (bt_regs_status[i].enabled == true)) {
9682 if (regulator_disable(bt_regs[i])) {
9683 dev_err(&msm_bt_power_device.dev,
9684 "%s: regulator disable failed",
9685 __func__);
9686 }
9687 bt_regs_status[i].enabled = false;
9688 break;
9689 }
9690 }
9691 }
9692
9693 p = bt_bahama[on][version + offset].set;
9694
9695 dev_info(&msm_bt_power_device.dev,
9696 "%s: found version %d\n", __func__, version);
9697
9698 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9699 u8 value = (p+i)->value;
9700 rc = marimba_write_bit_mask(&config,
9701 (p+i)->reg,
9702 &value,
9703 sizeof((p+i)->value),
9704 (p+i)->mask);
9705 if (rc < 0) {
9706 dev_err(&msm_bt_power_device.dev,
9707 "%s: reg %d write failed: %d\n",
9708 __func__, (p+i)->reg, rc);
9709 return rc;
9710 }
9711 dev_dbg(&msm_bt_power_device.dev,
9712 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9713 __func__, (p+i)->reg,
9714 value, (p+i)->mask);
9715 }
9716 /* Update BT Status */
9717 if (on)
9718 marimba_set_bt_status(&config, true);
9719 else
9720 marimba_set_bt_status(&config, false);
9721
9722 return 0;
9723}
9724
9725static int bluetooth_use_regulators(int on)
9726{
9727 int i, recover = -1, rc = 0;
9728
9729 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9730 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9731 bt_regs_info[i].name) :
9732 (regulator_put(bt_regs[i]), NULL);
9733 if (IS_ERR(bt_regs[i])) {
9734 rc = PTR_ERR(bt_regs[i]);
9735 dev_err(&msm_bt_power_device.dev,
9736 "regulator %s get failed (%d)\n",
9737 bt_regs_info[i].name, rc);
9738 recover = i - 1;
9739 bt_regs[i] = NULL;
9740 break;
9741 }
9742
9743 if (!on)
9744 continue;
9745
9746 rc = regulator_set_voltage(bt_regs[i],
9747 bt_regs_info[i].vmin,
9748 bt_regs_info[i].vmax);
9749 if (rc < 0) {
9750 dev_err(&msm_bt_power_device.dev,
9751 "regulator %s voltage set (%d)\n",
9752 bt_regs_info[i].name, rc);
9753 recover = i;
9754 break;
9755 }
9756 }
9757
9758 if (on && (recover > -1))
9759 for (i = recover; i >= 0; i--) {
9760 regulator_put(bt_regs[i]);
9761 bt_regs[i] = NULL;
9762 }
9763
9764 return rc;
9765}
9766
9767static int bluetooth_switch_regulators(int on)
9768{
9769 int i, rc = 0;
9770
9771 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9772 if (on && (bt_regs_status[i].enabled == false)) {
9773 rc = regulator_enable(bt_regs[i]);
9774 if (rc < 0) {
9775 dev_err(&msm_bt_power_device.dev,
9776 "regulator %s %s failed (%d)\n",
9777 bt_regs_info[i].name,
9778 "enable", rc);
9779 if (i > 0) {
9780 while (--i) {
9781 regulator_disable(bt_regs[i]);
9782 bt_regs_status[i].enabled
9783 = false;
9784 }
9785 break;
9786 }
9787 }
9788 bt_regs_status[i].enabled = true;
9789 } else if (!on && (bt_regs_status[i].enabled == true)) {
9790 rc = regulator_disable(bt_regs[i]);
9791 if (rc < 0) {
9792 dev_err(&msm_bt_power_device.dev,
9793 "regulator %s %s failed (%d)\n",
9794 bt_regs_info[i].name,
9795 "disable", rc);
9796 break;
9797 }
9798 bt_regs_status[i].enabled = false;
9799 }
9800 }
9801 return rc;
9802}
9803
9804static struct msm_xo_voter *bt_clock;
9805
9806static int bluetooth_power(int on)
9807{
9808 int rc = 0;
9809 int id;
9810
9811 /* In case probe function fails, cur_connv_type would be -1 */
9812 id = adie_get_detected_connectivity_type();
9813 if (id != BAHAMA_ID) {
9814 pr_err("%s: unexpected adie connectivity type: %d\n",
9815 __func__, id);
9816 return -ENODEV;
9817 }
9818
9819 if (on) {
9820
9821 rc = bluetooth_use_regulators(1);
9822 if (rc < 0)
9823 goto out;
9824
9825 rc = bluetooth_switch_regulators(1);
9826
9827 if (rc < 0)
9828 goto fail_put;
9829
9830 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
9831
9832 if (IS_ERR(bt_clock)) {
9833 pr_err("Couldn't get TCXO_D0 voter\n");
9834 goto fail_switch;
9835 }
9836
9837 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
9838
9839 if (rc < 0) {
9840 pr_err("Failed to vote for TCXO_DO ON\n");
9841 goto fail_vote;
9842 }
9843
9844 rc = bahama_bt(1);
9845
9846 if (rc < 0)
9847 goto fail_clock;
9848
9849 msleep(10);
9850
9851 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
9852
9853 if (rc < 0) {
9854 pr_err("Failed to vote for TCXO_DO pin control\n");
9855 goto fail_vote;
9856 }
9857 } else {
9858 /* check for initial RFKILL block (power off) */
9859 /* some RFKILL versions/configurations rfkill_register */
9860 /* calls here for an initial set_block */
9861 /* avoid calling i2c and regulator before unblock (on) */
9862 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
9863 dev_info(&msm_bt_power_device.dev,
9864 "%s: initialized OFF/blocked\n", __func__);
9865 goto out;
9866 }
9867
9868 bahama_bt(0);
9869
9870fail_clock:
9871 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
9872fail_vote:
9873 msm_xo_put(bt_clock);
9874fail_switch:
9875 bluetooth_switch_regulators(0);
9876fail_put:
9877 bluetooth_use_regulators(0);
9878 }
9879
9880out:
9881 if (rc < 0)
9882 on = 0;
9883 dev_info(&msm_bt_power_device.dev,
9884 "Bluetooth power switch: state %d result %d\n", on, rc);
9885
9886 return rc;
9887}
9888
9889#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
9890
9891static void __init msm8x60_cfg_smsc911x(void)
9892{
9893 smsc911x_resources[1].start =
9894 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9895 smsc911x_resources[1].end =
9896 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9897}
9898
9899#ifdef CONFIG_MSM_RPM
9900static struct msm_rpm_platform_data msm_rpm_data = {
9901 .reg_base_addrs = {
9902 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
9903 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
9904 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
9905 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
9906 },
9907
9908 .irq_ack = RPM_SCSS_CPU0_GP_HIGH_IRQ,
9909 .irq_err = RPM_SCSS_CPU0_GP_LOW_IRQ,
9910 .irq_vmpm = RPM_SCSS_CPU0_GP_MEDIUM_IRQ,
9911 .msm_apps_ipc_rpm_reg = MSM_GCC_BASE + 0x008,
9912 .msm_apps_ipc_rpm_val = 4,
9913};
9914#endif
9915
Laura Abbott5d2d1e62011-08-10 16:27:35 -07009916void msm_fusion_setup_pinctrl(void)
9917{
9918 struct msm_xo_voter *a1;
9919
9920 if (socinfo_get_platform_subtype() == 0x3) {
9921 /*
9922 * Vote for the A1 clock to be in pin control mode before
9923 * the external images are loaded.
9924 */
9925 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
9926 BUG_ON(!a1);
9927 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
9928 }
9929}
9930
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009931struct msm_board_data {
9932 struct msm_gpiomux_configs *gpiomux_cfgs;
9933};
9934
9935static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
9936 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9937};
9938
9939static struct msm_board_data msm8x60_sim_board_data __initdata = {
9940 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9941};
9942
9943static struct msm_board_data msm8x60_surf_board_data __initdata = {
9944 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9945};
9946
9947static struct msm_board_data msm8x60_ffa_board_data __initdata = {
9948 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9949};
9950
9951static struct msm_board_data msm8x60_fluid_board_data __initdata = {
9952 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
9953};
9954
9955static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
9956 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9957};
9958
9959static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
9960 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9961};
9962
Zhang Chang Kenef05b172011-07-27 15:28:13 -04009963static struct msm_board_data msm8x60_dragon_board_data __initdata = {
9964 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
9965};
9966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009967static void __init msm8x60_init(struct msm_board_data *board_data)
9968{
9969 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05309970#ifdef CONFIG_USB_EHCI_MSM_72K
9971 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
9972 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
9973 .level = PM8901_MPP_DIG_LEVEL_L5,
9974 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
9975 };
9976#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +05309977 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07009978
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009979 /*
9980 * Initialize RPM first as other drivers and devices may need
9981 * it for their initialization.
9982 */
9983#ifdef CONFIG_MSM_RPM
9984 BUG_ON(msm_rpm_init(&msm_rpm_data));
9985#endif
9986 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
9987 ARRAY_SIZE(msm_rpmrs_levels)));
9988 if (msm_xo_init())
9989 pr_err("Failed to initialize XO votes\n");
9990
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009991 msm8x60_check_2d_hardware();
9992
9993 /* Change SPM handling of core 1 if PMM 8160 is present. */
9994 soc_platform_version = socinfo_get_platform_version();
9995 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
9996 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
9997 struct msm_spm_platform_data *spm_data;
9998
9999 spm_data = &msm_spm_data_v1[1];
10000 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10001 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10002
10003 spm_data = &msm_spm_data[1];
10004 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10005 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10006 }
10007
10008 /*
10009 * Initialize SPM before acpuclock as the latter calls into SPM
10010 * driver to set ACPU voltages.
10011 */
10012 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10013 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10014 else
10015 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10016
10017 /*
10018 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10019 * devices so that the RPM doesn't drop into a low power mode that an
10020 * un-reworked SURF cannot resume from.
10021 */
10022 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010023 int i;
10024
10025 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10026 if (rpm_regulator_init_data[i].id
10027 == RPM_VREG_ID_PM8901_L4
10028 || rpm_regulator_init_data[i].id
10029 == RPM_VREG_ID_PM8901_L6)
10030 rpm_regulator_init_data[i]
10031 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010032 }
10033
10034 /*
10035 * Disable regulator info printing so that regulator registration
10036 * messages do not enter the kmsg log.
10037 */
10038 regulator_suppress_info_printing();
10039
10040 /* Initialize regulators needed for clock_init. */
10041 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10042
Stephen Boydbb600ae2011-08-02 20:11:40 -070010043 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010044
10045 /* Buses need to be initialized before early-device registration
10046 * to get the platform data for fabrics.
10047 */
10048 msm8x60_init_buses();
10049 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10050 /* CPU frequency control is not supported on simulated targets. */
10051 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010052 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010053
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010054 /*
10055 * Enable EBI2 only for boards which make use of it. Leave
10056 * it disabled for all others for additional power savings.
10057 */
10058 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10059 machine_is_msm8x60_rumi3() ||
10060 machine_is_msm8x60_sim() ||
10061 machine_is_msm8x60_fluid() ||
10062 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010063 msm8x60_init_ebi2();
10064 msm8x60_init_tlmm();
10065 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10066 msm8x60_init_uart12dm();
10067 msm8x60_init_mmc();
10068
10069#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10070 msm8x60_init_pm8058_othc();
10071#endif
10072
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010073 if (machine_is_msm8x60_fluid())
10074 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10075 else if (machine_is_msm8x60_dragon())
10076 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10077 else
10078 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010079
Jilai Wang53d27a82011-07-13 14:32:58 -040010080 /* Specify reset pin for OV9726 */
10081 if (machine_is_msm8x60_dragon()) {
10082 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10083 ov9726_sensor_8660_info.mount_angle = 270;
10084 }
10085
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010086#ifdef CONFIG_BATTERY_MSM8X60
10087 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10088 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10089 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10090 platform_device_register(&msm_charger_device);
10091#endif
10092
10093 if (machine_is_msm8x60_dragon())
10094 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10095 if (!machine_is_msm8x60_fluid())
10096 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10097
10098 /* configure pmic leds */
10099 if (machine_is_msm8x60_fluid())
10100 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10101 else if (machine_is_msm8x60_dragon())
10102 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10103 else
10104 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10105
10106 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10107 machine_is_msm8x60_dragon()) {
10108 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10109 }
10110
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010111 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10112 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010113 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010114 msm8x60_cfg_smsc911x();
10115 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10116 platform_add_devices(msm_footswitch_devices,
10117 msm_num_footswitch_devices);
10118 platform_add_devices(surf_devices,
10119 ARRAY_SIZE(surf_devices));
10120
10121#ifdef CONFIG_MSM_DSPS
10122 if (machine_is_msm8x60_fluid()) {
10123 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10124 msm8x60_init_dsps();
10125 }
10126#endif
10127
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010128 pm8901_vreg_mpp0_init();
10129
10130 platform_device_register(&msm8x60_8901_mpp_vreg);
10131
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010132#ifdef CONFIG_USB_EHCI_MSM_72K
10133 /*
10134 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10135 * fluid
10136 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010137 if (machine_is_msm8x60_fluid())
10138 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10139 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010140#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010141
10142#ifdef CONFIG_SND_SOC_MSM8660_APQ
10143 if (machine_is_msm8x60_dragon())
10144 platform_add_devices(dragon_alsa_devices,
10145 ARRAY_SIZE(dragon_alsa_devices));
10146 else
10147#endif
10148 platform_add_devices(asoc_devices,
10149 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010150 } else {
10151 msm8x60_configure_smc91x();
10152 platform_add_devices(rumi_sim_devices,
10153 ARRAY_SIZE(rumi_sim_devices));
10154 }
10155#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010156 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10157 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010158 msm8x60_cfg_isp1763();
10159#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010160
10161 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10162 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10163
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010164
10165#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10166 if (machine_is_msm8x60_fluid())
10167 platform_device_register(&msm_gsbi10_qup_spi_device);
10168 else
10169 platform_device_register(&msm_gsbi1_qup_spi_device);
10170#endif
10171
10172#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10173 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10174 if (machine_is_msm8x60_fluid())
10175 cyttsp_set_params();
10176#endif
10177 if (!machine_is_msm8x60_sim())
10178 msm_fb_add_devices();
10179 fixup_i2c_configs();
10180 register_i2c_devices();
10181
Terence Hampson1c73fef2011-07-19 17:10:49 -040010182 if (machine_is_msm8x60_dragon())
10183 smsc911x_config.reset_gpio
10184 = GPIO_ETHERNET_RESET_N_DRAGON;
10185
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010186 platform_device_register(&smsc911x_device);
10187
10188#if (defined(CONFIG_SPI_QUP)) && \
10189 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010190 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10191 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010192
10193 if (machine_is_msm8x60_fluid()) {
10194#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10195 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10196 spi_register_board_info(lcdc_samsung_spi_board_info,
10197 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10198 } else
10199#endif
10200 {
10201#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10202 spi_register_board_info(lcdc_auo_spi_board_info,
10203 ARRAY_SIZE(lcdc_auo_spi_board_info));
10204#endif
10205 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010206#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10207 } else if (machine_is_msm8x60_dragon()) {
10208 spi_register_board_info(lcdc_nt35582_spi_board_info,
10209 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10210#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010211 }
10212#endif
10213
10214 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
10215 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
10216 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
10217 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010218 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010219
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010220 pm8058_gpios_init();
10221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010222#ifdef CONFIG_SENSORS_MSM_ADC
10223 if (machine_is_msm8x60_fluid()) {
10224 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10225 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10226 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10227 msm_adc_pdata.gpio_config = APROC_CONFIG;
10228 else
10229 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10230 }
10231 msm_adc_pdata.target_hw = MSM_8x60;
10232#endif
10233#ifdef CONFIG_MSM8X60_AUDIO
10234 msm_snddev_init();
10235#endif
10236#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10237 if (machine_is_msm8x60_fluid())
10238 platform_device_register(&fluid_leds_gpio);
10239 else
10240 platform_device_register(&gpio_leds);
10241#endif
10242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010243 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010244
10245 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10246 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010247}
10248
10249static void __init msm8x60_rumi3_init(void)
10250{
10251 msm8x60_init(&msm8x60_rumi3_board_data);
10252}
10253
10254static void __init msm8x60_sim_init(void)
10255{
10256 msm8x60_init(&msm8x60_sim_board_data);
10257}
10258
10259static void __init msm8x60_surf_init(void)
10260{
10261 msm8x60_init(&msm8x60_surf_board_data);
10262}
10263
10264static void __init msm8x60_ffa_init(void)
10265{
10266 msm8x60_init(&msm8x60_ffa_board_data);
10267}
10268
10269static void __init msm8x60_fluid_init(void)
10270{
10271 msm8x60_init(&msm8x60_fluid_board_data);
10272}
10273
10274static void __init msm8x60_charm_surf_init(void)
10275{
10276 msm8x60_init(&msm8x60_charm_surf_board_data);
10277}
10278
10279static void __init msm8x60_charm_ffa_init(void)
10280{
10281 msm8x60_init(&msm8x60_charm_ffa_board_data);
10282}
10283
10284static void __init msm8x60_charm_init_early(void)
10285{
10286 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010287}
10288
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010289static void __init msm8x60_dragon_init(void)
10290{
10291 msm8x60_init(&msm8x60_dragon_board_data);
10292}
10293
Steve Mucklea55df6e2010-01-07 12:43:24 -080010294MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10295 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010296 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010297 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010298 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010299 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010300 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010301 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010302MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010303
10304MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10305 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010306 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010307 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010308 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010309 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010310 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010311 .init_early = msm8x60_charm_init_early,
10312MACHINE_END
10313
10314MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10315 .map_io = msm8x60_map_io,
10316 .reserve = msm8x60_reserve,
10317 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010318 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010319 .init_machine = msm8x60_surf_init,
10320 .timer = &msm_timer,
10321 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010322MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010323
10324MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10325 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010326 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010327 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010328 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010329 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010330 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010331 .init_early = msm8x60_charm_init_early,
10332MACHINE_END
10333
10334MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10335 .map_io = msm8x60_map_io,
10336 .reserve = msm8x60_reserve,
10337 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010338 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010339 .init_machine = msm8x60_fluid_init,
10340 .timer = &msm_timer,
10341 .init_early = msm8x60_charm_init_early,
10342MACHINE_END
10343
10344MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10345 .map_io = msm8x60_map_io,
10346 .reserve = msm8x60_reserve,
10347 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010348 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010349 .init_machine = msm8x60_charm_surf_init,
10350 .timer = &msm_timer,
10351 .init_early = msm8x60_charm_init_early,
10352MACHINE_END
10353
10354MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10355 .map_io = msm8x60_map_io,
10356 .reserve = msm8x60_reserve,
10357 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010358 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010359 .init_machine = msm8x60_charm_ffa_init,
10360 .timer = &msm_timer,
10361 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010362MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010363
10364MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10365 .map_io = msm8x60_map_io,
10366 .reserve = msm8x60_reserve,
10367 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010368 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010369 .init_machine = msm8x60_dragon_init,
10370 .timer = &msm_timer,
10371 .init_early = msm8x60_charm_init_early,
10372MACHINE_END