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