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